@deephaven/code-studio 0.32.1-beta.1 → 0.32.1-demo.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,4 +1,4 @@
1
- import{A as b,B as D,H as X,P as Pm,C as l,D as gt,F as $,R as Pi,G as J,I as Pe,J as pe,K as Ye,L as _m,M as jm,N as wl,O as Za,Q as Hm,E as vl,S as Bm,T as fe,U as el,V as ks,W as bh,X as it,Y as Tl,Z as Vm,_ as Um,$ as $m,a0 as Wm,a1 as me,a2 as Fd,a3 as El,a4 as Gm,a5 as zm,a6 as wh,a7 as je,a8 as tl,a9 as Nd,aa as Qa,ab as Md,ac as Km,ad as Mn,ae as qm,af as Ym,ag as Xm,ah as Zm,ai as nl,aj as Qm,ak as Jm,al as ep,am as kd,an as tp,ao as Od,ap as np,aq as sp,ar as ip,as as op,at as ap,au as rp,av as ft,aw as vh,ax as lp,ay as Th,az as dp,aA as Eh,aB as cp,aC as hp,aD as up,aE as mp,aF as pp,aG as gp,aH as fp,aI as Cp,aJ as Sp,aK as bp,aL as Ad,aM as wp}from"./vendor-0d2b9258.js";import{e as Yn,l as wi,K as rn,a as Ld,b as xs,W as vp}from"./monaco-1ecfd680.js";import{T as We,L as Z,M as Do,a as Fo,b as No,v as yh,c as Ln,d as xh,e as kn,f as Tp,g as Ep,h as Mo,i as yp,j as Ui,k as yl,l as xp,m as sl,n as Rp,o as Rh,p as xl,q as Ih,r as Pd,s as Ip,t as Dp,u as Fp,w as Np,x as Qt,y as Ms,z as Dh,A as Xn,B as Ja,C as _i,D as Mp,E as kp,F as _d,G as ya,H as jd,I as Fh,J as Op,K as ko,N as Nh,O as Ap,P as Lp,Q as Rl,R as Il,S as xa,U as Bn,V as Pp,W as _p,X as jp,Y as Hp,Z as Bp,_ as Dl,$ as Os,a0 as Hd,a1 as Oo,a2 as Fl,a3 as Nl,a4 as Vp,a5 as Up,a6 as Ra,a7 as $p,a8 as Ml,a9 as Mh,aa as ei,ab as Wp,ac as Gp,ad as zp,ae as Kp,af as qp,ag as Yp,ah as Bd,ai as Mr,aj as Xp,ak as Zp,al as Qp,am as Jp,an as eg,ao as kh,ap as tg,aq as ng,ar as sg,as as Oh,at as ig,au as og,av as ag,aw as rg,ax as lg,ay as dg,az as cg,aA as hg,aB as ug,aC as mg,aD as pg,aE as gg,aF as Ah,aG as fg,aH as il,aI as ol,aJ as Cg,aK as Sg,aL as bg,aM as wg,aN as vg,aO as Tg,aP as Eg,aQ as yg,aR as xg,aS as Rg,aT as Ig,aU as Vd,aV as Dg,aW as Fg}from"./index-be1665ce.js";import{P as Ia,b as Ng,h as Mg,p as kg,o as Og,s as Ag,t as Lg,c as kr}from"./plotly-08ea603d.js";import"./helpers-042e6b4d.js";class Pg extends b.Component{static propTypes={children:D.node.isRequired,options:D.shape({}),className:D.string,timeout:D.number,onEntered:D.func,onExited:D.func,isShown:D.bool,closeOnBlur:D.bool,interactive:D.bool,referenceObject:D.shape({}),"data-testid":D.string};static defaultProps={options:{},className:"",timeout:We.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=X.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 Pm(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(gt,{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&&Pi.createPortal(this.renderContent(),this.element)})}}const ri=Pg,_g=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=X.createRef(),this.popper=X.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){_g.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(ri,{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 er(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})}er.displayName="ButtonGroup";er.propTypes={children:D.node.isRequired,className:D.string,style:D.object,"data-testid":D.string};er.defaultProps={className:null,style:{},"data-testid":void 0};const jg=["primary","secondary","tertiary","success","danger","inline","ghost"],Hg=["group-end"];function Bg(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 Vg(d){switch(d){case"group-end":return $("pl-2","pr-3")}}const tr=X.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:p,onMouseLeave:g,onKeyDown:C,className:f,style:S,children:v,tabIndex:w,"data-testid":T,"aria-label":y}=d,E=Boolean(o&&v==null),I=Bg(t,E);let F;n&&(F=Vg(n));let N;o&&(N=X.isValidElement(o)?o:l.jsx(J,{icon:o}));let H;i!==void 0&&(H=typeof i=="string"?l.jsx(tt,{children:i}):i);let P=y;y===void 0&&E&&i!=null&&typeof i=="string"&&(P=i);const O=l.jsxs("button",{"data-testid":T,ref:e,type:s,className:$("btn",I,F,{active:r},f),onClick:c,onContextMenu:h,onMouseUp:m,onMouseDown:u,onMouseEnter:p,onMouseLeave:g,onKeyDown:C,style:S,disabled:a,tabIndex:w,"aria-label":P,children:[o&&N,v,i!=null&&!a&&H]});return a?l.jsxs("span",{className:"btn-disabled-wrapper",children:[O,i!==void 0&&H]}):O});tr.displayName="Button";tr.propTypes={kind:D.oneOf(jg).isRequired,variant:D.oneOf(Hg),type:D.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&&!X.isValidElement(t)&&(t==null||t.iconName===""||t.iconName==null)?new Error("Icon must be react element or fontawesome IconDefinition"):null},disabled:D.bool,active:D.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:D.func,onMouseUp:D.func,onMouseDown:D.func,onMouseEnter:D.func,onMouseLeave:D.func,onKeyDown:D.func,tabIndex:D.number,children:D.node,className:D.string,style:D.object,"data-testid":D.string};tr.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 V=tr;function kl({className:d="modal-footer",children:e,"data-testid":t}){return l.jsx("div",{className:d,"data-testid":t,children:e})}function ji(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":p}=d,g=b.useRef(null),C=b.useRef(null),f=b.useCallback(()=>{C.current!==null&&C.current.checked&&a&&a(),i()},[i,a]),S=b.useCallback(()=>{g.current?.focus()},[]);let v="";return e&&(v=typeof n=="function"?n():n),l.jsxs(Do,{isOpen:e,className:"theme-bg-light",onOpened:S,children:[l.jsx(Fo,{closeButton:!1,children:t}),l.jsx(No,{children:v}),l.jsxs(kl,{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":p!==void 0?`${p}-checkbox-confirm`:void 0}),l.jsx("label",{className:"custom-control-label",htmlFor:"move-confirmation-checkbox",children:"Don't ask me again"})]}),o&&l.jsx(V,{kind:"secondary",className:"mr-auto","data-dismiss":"modal",onClick:o,"data-testid":p!==void 0?`${p}-btn-discard`:void 0,children:h}),s&&l.jsx(V,{kind:"secondary","data-dismiss":"modal",onClick:s,"data-testid":p!==void 0?`${p}-btn-cancel`:void 0,children:r}),l.jsxs(er,{children:[l.jsx(V,{kind:u?"danger":"primary",onClick:f,ref:g,"data-testid":p!==void 0?`${p}-btn-confirm`:void 0,children:c}),m]})]})]})}ji.propTypes={isOpen:D.bool.isRequired,headerText:D.string.isRequired,bodyText:D.oneOfType([D.string,D.func]).isRequired,onCancel:D.func,onConfirm:D.func.isRequired,onDiscard:D.func,onModalDisable:D.func,cancelButtonText:D.string,confirmButtonText:D.string,discardButtonText:D.string,children:D.node,"data-testid":D.string};ji.defaultProps={children:void 0,cancelButtonText:"Cancel",confirmButtonText:"Okay",discardButtonText:"Discard",onCancel:void 0,onDiscard:void 0,onModalDisable:void 0,"data-testid":void 0};const nr=X.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})});nr.displayName="Button";nr.propTypes={children:D.node,className:D.string,disabled:D.bool,onClick:D.func,style:D.shape({}),id:D.string};nr.defaultProps={children:null,className:"",disabled:!1,onClick:()=>null,style:{},id:""};const Ud=nr;function Ol({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 Or(d){return d.then!==void 0}class Xs{static actionsDisabled=!1;static disableAllActions(){Xs.actionsDisabled=!0}static enableAllActions(){Xs.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(Xs.compareActions),t}static isMacPlatform(){const{platform:e}=window.navigator;return e.startsWith("Mac")}static getModifierKey(){return Xs.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(e){const t=Xs.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 He=Xs,$d=Z.module("GlobalContextAction");class Ug 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),$d.debug("Received context menu event at global action! Menu items are now: ",t.contextActions))}handleKeyDown(e){const{action:t}=this.props;!He.actionsDisabled&&t.shortcut!==void 0&&t.shortcut.matchesEvent(e)&&($d.debug("Global hotkey matched!",e),t.action?.(e),e.preventDefault(),e.stopPropagation())}render(){return null}}const $g=Ug;class Wg 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($g,{action:i,"data-testid":t},`${i.title}.${o?.id}`);n.push(a)}}return n}}const Gg=Wg;const Qo=Z.module("ContextActions");class zg 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=X.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=>!Or(s)&&typeof s!="function"&&s.isGlobal),n=e.actions.filter(s=>!Or(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){Qo.debug2(`Contextmenu event ignored based on the target className "${o}"`);return}s=s.parentElement}}if(He.isContextActionEvent(e)||(e.contextActions=[]),!He.isContextActionEvent(e))return;const{actions:n}=this.props;if(n!=null){let s=n;Array.isArray(s)&&(s=s.filter(i=>Or(i)||typeof i=="function"||i.isGlobal===void 0||!i.isGlobal)),e.contextActions=e.contextActions.concat(s)}Qo.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];!He.actionsDisabled&&s.shortcut!=null&&s.shortcut.matchesEvent(e)&&(Qo.debug("Context hotkey matched!",e),s.action?.(e),e.stopPropagation(),e.preventDefault(),Qo.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(Gg,{actions:t})})}}const ae=zg,Al=X.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":I}=d,F={menuItem:T,closeMenu:w,isKeyboardSelected:y,isMouseSelected:E,iconElement:S,displayShortcut:v,"data-testid":I};return X.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(X.isValidElement(f))m=f;else{let S;a.iconColor!=null&&(a.disabled===void 0||!a.disabled)&&(S={color:a.iconColor}),m=l.jsx(J,{icon:f,style:S})}}let p=null;const g=Boolean(o);a.actions&&(p=l.jsx(J,{icon:yh}));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:(g||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}),p&&l.jsx("span",{className:$("submenu-indicator",{disabled:f}),children:p})]})})}return l.jsxs("div",{className:"context-menu-item",ref:e,"data-testid":h,children:[o,C]})});Al.displayName="ContextMenuItem";Al.defaultProps={children:null,isKeyboardSelected:!1,isMouseSelected:!1,"data-testid":void 0};const Lh=Al,De=Object.freeze([]),Gn=new Map;class Kg extends Error{isCanceled=!0}const Hi=Kg;class sr{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),sr.getBrightness(i)<125}static getBrightness(e){return Math.round((e[0]*299+e[1]*587+e[2]*114)/1e3)}}async function $i(d){const{clipboard:e}=navigator;if(e!==void 0)try{return navigator.clipboard.writeText(d)}catch{return Wd(d)}Wd(d)}function Wd(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 qg="table_",Gd="column_",Yg=new Set(["in","not","i","ii","k"]),Xg=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"]),Zg=/[^a-zA-Z0-9_$+@-]/g,Qg=/[^A-Za-z0-9_$]/g;class cn{static legalize=(e,t,n,s,i)=>{let o=e.trim().replace(/[- ]/g,"_");return s&&(Yg.has(o)||Xg.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=>cn.legalize(e,qg,Zg,!1,0);static legalizeColumnNames=e=>{const t=[];return e.forEach((n,s)=>{let i=cn.legalizeColumnName(n,s);t.includes(i)&&(i=Gd+s),t.push(i)}),t};static legalizeColumnName=(e,t=0)=>cn.legalize(e,Gd,Qg,!0,t);static isValidTableName=e=>cn.legalizeTableName(e)===e;static isValidColumnName=e=>cn.legalizeColumnName(e)===e}function Jg(d,e){return d?d.closest(`.${e}`):null}const ef={getClosestByClassName:Jg};class Ve extends CustomEvent{constructor(e,t){super(e,t)}}class tf extends Error{isTimeout=!0}const Ph=tf;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 Hi),s!=null&&t&&t(s)},o}static isCanceled(e){return e instanceof Hi}static isTimedOut(e){return e instanceof Ph}}class nf{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 ts=nf;function M(d){if(d==null)throw new Error("Value is null or undefined")}function _(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 ln{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(!ln.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 sf{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 Wt=sf;class Wi{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(Wi.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 of extends Error{isInvalid=!0}const Ni=of,zd=Z.module("ContextMenu");class Da 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=X.createRef(),this.oldFocus=document.activeElement,this.activeSubMenuRef=X.createRef(),this.subMenuTimer=0,this.rAF=0,this.initialPosition={top:e.top,left:e.left},this.state={menuItems:[],pendingItems:[],activeSubMenu:null,hasOverflow:!1,subMenuTop:null,subMenuLeft:null,subMenuParentWidth:0,subMenuParentHeight:0,keyboardIndex:-1,mouseIndex:-1}}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=He.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:He.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:He.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}),zd.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){zd.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=He.getNextMenuItem(s,-1,t):(e.key==="ArrowDown"||e.key==="Tab")&&(s=He.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:p}=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(Lh,{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 g=null;c.length>0&&(g=l.jsx("div",{className:"loading",children:l.jsx(Ln,{})}));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:Da.handleContextMenu,role:"menuitem",tabIndex:0,"data-testid":f,children:[e,g]}),S&&s!==null&&h!==null&&u!==null&&l.jsx(Da,{actions:a[s].actions||[],closeMenu:this.handleCloseSubMenu,top:h,left:u,updatePosition:(v,w)=>{this.setState({subMenuTop:v,subMenuLeft:w})},subMenuParentWidth:m,subMenuParentHeight:p},`sub-${s}`)]})}}const af=Da;class rf extends b.Component{constructor(e){super(e),this.handleMenuClose=this.handleMenuClose.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.container=X.createRef(),this.openMenu=X.createRef(),this.state={actions:null,left:0,top:0}}componentDidMount(){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(!He.isContextActionEvent(e)||!this.container.current||e.metaKey||e.ctrlKey)return;const t=He.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(af,{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 _h=rf;class Ss extends b.Component{static propTypes={className:D.string,in:D.bool.isRequired,children:D.node.isRequired,autoFocusOnShow:D.bool,"data-testid":D.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=`${Ss.getHeight(t)}px`}static handleExiting(e){const t=e;t.style.height="0"}static handleExit(e){const t=e;t.style.height=`${Ss.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(gt,{in:n,classNames:{enterActive:"collapsing",enterDone:"collapse show",exitActive:"collapsing",exitDone:"collapse"},onEnter:Ss.handleEnter,onEntering:Ss.handleEntering,onEntered:this.handleEntered,onExit:Ss.handleExit,onExiting:Ss.handleExiting,timeout:350,children:i=>l.jsx("div",{className:$({collapse:i==="exited"},t),"data-testid":s,children:e})})}}const lf=Ss;function ir(d){const e=b.useRef();return b.useEffect(function(){e.current=d}),e.current}function jh(d){const e=b.useRef(null);return b.useEffect(function(){d&&(typeof d=="function"?d(e.current):d.current=e.current)}),e}const df=3500,cf=Z.module("useCopyToClipboard");function hf(){const[d,e]=b.useState(!1),t=b.useRef(null),n=b.useCallback(s=>{$i(s).then(()=>{e(!0)}).catch(i=>cf.error(`Unable to copy ${s}`,`
1
+ import{A as b,B as D,H as X,P as Pm,C as l,D as gt,F as $,R as Pi,G as J,I as Pe,J as pe,K as Ye,L as _m,M as jm,N as wl,O as Za,Q as Hm,E as vl,S as Bm,T as fe,U as el,V as ks,W as bh,X as it,Y as Tl,Z as Vm,_ as Um,$ as $m,a0 as Wm,a1 as me,a2 as Fd,a3 as El,a4 as Gm,a5 as zm,a6 as wh,a7 as je,a8 as tl,a9 as Nd,aa as Qa,ab as Md,ac as Km,ad as Mn,ae as qm,af as Ym,ag as Xm,ah as Zm,ai as nl,aj as Qm,ak as Jm,al as ep,am as kd,an as tp,ao as Od,ap as np,aq as sp,ar as ip,as as op,at as ap,au as rp,av as ft,aw as vh,ax as lp,ay as Th,az as dp,aA as Eh,aB as cp,aC as hp,aD as up,aE as mp,aF as pp,aG as gp,aH as fp,aI as Cp,aJ as Sp,aK as bp,aL as Ad,aM as wp}from"./vendor-0d2b9258.js";import{e as Yn,l as wi,K as rn,a as Ld,b as xs,W as vp}from"./monaco-1ecfd680.js";import{T as We,L as Z,M as Do,a as Fo,b as No,v as yh,c as Ln,d as xh,e as kn,f as Tp,g as Ep,h as Mo,i as yp,j as Ui,k as yl,l as xp,m as sl,n as Rp,o as Rh,p as xl,q as Ih,r as Pd,s as Ip,t as Dp,u as Fp,w as Np,x as Qt,y as Ms,z as Dh,A as Xn,B as Ja,C as _i,D as Mp,E as kp,F as _d,G as ya,H as jd,I as Fh,J as Op,K as ko,N as Nh,O as Ap,P as Lp,Q as Rl,R as Il,S as xa,U as Bn,V as Pp,W as _p,X as jp,Y as Hp,Z as Bp,_ as Dl,$ as Os,a0 as Hd,a1 as Oo,a2 as Fl,a3 as Nl,a4 as Vp,a5 as Up,a6 as Ra,a7 as $p,a8 as Ml,a9 as Mh,aa as ei,ab as Wp,ac as Gp,ad as zp,ae as Kp,af as qp,ag as Yp,ah as Bd,ai as Mr,aj as Xp,ak as Zp,al as Qp,am as Jp,an as eg,ao as kh,ap as tg,aq as ng,ar as sg,as as Oh,at as ig,au as og,av as ag,aw as rg,ax as lg,ay as dg,az as cg,aA as hg,aB as ug,aC as mg,aD as pg,aE as gg,aF as Ah,aG as fg,aH as il,aI as ol,aJ as Cg,aK as Sg,aL as bg,aM as wg,aN as vg,aO as Tg,aP as Eg,aQ as yg,aR as xg,aS as Rg,aT as Ig,aU as Vd,aV as Dg,aW as Fg}from"./index-eb9f5fb1.js";import{P as Ia,b as Ng,h as Mg,p as kg,o as Og,s as Ag,t as Lg,c as kr}from"./plotly-08ea603d.js";import"./helpers-042e6b4d.js";class Pg extends b.Component{static propTypes={children:D.node.isRequired,options:D.shape({}),className:D.string,timeout:D.number,onEntered:D.func,onExited:D.func,isShown:D.bool,closeOnBlur:D.bool,interactive:D.bool,referenceObject:D.shape({}),"data-testid":D.string};static defaultProps={options:{},className:"",timeout:We.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=X.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 Pm(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(gt,{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&&Pi.createPortal(this.renderContent(),this.element)})}}const ri=Pg,_g=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=X.createRef(),this.popper=X.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){_g.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(ri,{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 er(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})}er.displayName="ButtonGroup";er.propTypes={children:D.node.isRequired,className:D.string,style:D.object,"data-testid":D.string};er.defaultProps={className:null,style:{},"data-testid":void 0};const jg=["primary","secondary","tertiary","success","danger","inline","ghost"],Hg=["group-end"];function Bg(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 Vg(d){switch(d){case"group-end":return $("pl-2","pr-3")}}const tr=X.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:p,onMouseLeave:g,onKeyDown:C,className:f,style:S,children:v,tabIndex:w,"data-testid":T,"aria-label":y}=d,E=Boolean(o&&v==null),I=Bg(t,E);let F;n&&(F=Vg(n));let N;o&&(N=X.isValidElement(o)?o:l.jsx(J,{icon:o}));let H;i!==void 0&&(H=typeof i=="string"?l.jsx(tt,{children:i}):i);let P=y;y===void 0&&E&&i!=null&&typeof i=="string"&&(P=i);const O=l.jsxs("button",{"data-testid":T,ref:e,type:s,className:$("btn",I,F,{active:r},f),onClick:c,onContextMenu:h,onMouseUp:m,onMouseDown:u,onMouseEnter:p,onMouseLeave:g,onKeyDown:C,style:S,disabled:a,tabIndex:w,"aria-label":P,children:[o&&N,v,i!=null&&!a&&H]});return a?l.jsxs("span",{className:"btn-disabled-wrapper",children:[O,i!==void 0&&H]}):O});tr.displayName="Button";tr.propTypes={kind:D.oneOf(jg).isRequired,variant:D.oneOf(Hg),type:D.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&&!X.isValidElement(t)&&(t==null||t.iconName===""||t.iconName==null)?new Error("Icon must be react element or fontawesome IconDefinition"):null},disabled:D.bool,active:D.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:D.func,onMouseUp:D.func,onMouseDown:D.func,onMouseEnter:D.func,onMouseLeave:D.func,onKeyDown:D.func,tabIndex:D.number,children:D.node,className:D.string,style:D.object,"data-testid":D.string};tr.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 V=tr;function kl({className:d="modal-footer",children:e,"data-testid":t}){return l.jsx("div",{className:d,"data-testid":t,children:e})}function ji(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":p}=d,g=b.useRef(null),C=b.useRef(null),f=b.useCallback(()=>{C.current!==null&&C.current.checked&&a&&a(),i()},[i,a]),S=b.useCallback(()=>{g.current?.focus()},[]);let v="";return e&&(v=typeof n=="function"?n():n),l.jsxs(Do,{isOpen:e,className:"theme-bg-light",onOpened:S,children:[l.jsx(Fo,{closeButton:!1,children:t}),l.jsx(No,{children:v}),l.jsxs(kl,{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":p!==void 0?`${p}-checkbox-confirm`:void 0}),l.jsx("label",{className:"custom-control-label",htmlFor:"move-confirmation-checkbox",children:"Don't ask me again"})]}),o&&l.jsx(V,{kind:"secondary",className:"mr-auto","data-dismiss":"modal",onClick:o,"data-testid":p!==void 0?`${p}-btn-discard`:void 0,children:h}),s&&l.jsx(V,{kind:"secondary","data-dismiss":"modal",onClick:s,"data-testid":p!==void 0?`${p}-btn-cancel`:void 0,children:r}),l.jsxs(er,{children:[l.jsx(V,{kind:u?"danger":"primary",onClick:f,ref:g,"data-testid":p!==void 0?`${p}-btn-confirm`:void 0,children:c}),m]})]})]})}ji.propTypes={isOpen:D.bool.isRequired,headerText:D.string.isRequired,bodyText:D.oneOfType([D.string,D.func]).isRequired,onCancel:D.func,onConfirm:D.func.isRequired,onDiscard:D.func,onModalDisable:D.func,cancelButtonText:D.string,confirmButtonText:D.string,discardButtonText:D.string,children:D.node,"data-testid":D.string};ji.defaultProps={children:void 0,cancelButtonText:"Cancel",confirmButtonText:"Okay",discardButtonText:"Discard",onCancel:void 0,onDiscard:void 0,onModalDisable:void 0,"data-testid":void 0};const nr=X.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})});nr.displayName="Button";nr.propTypes={children:D.node,className:D.string,disabled:D.bool,onClick:D.func,style:D.shape({}),id:D.string};nr.defaultProps={children:null,className:"",disabled:!1,onClick:()=>null,style:{},id:""};const Ud=nr;function Ol({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 Or(d){return d.then!==void 0}class Xs{static actionsDisabled=!1;static disableAllActions(){Xs.actionsDisabled=!0}static enableAllActions(){Xs.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(Xs.compareActions),t}static isMacPlatform(){const{platform:e}=window.navigator;return e.startsWith("Mac")}static getModifierKey(){return Xs.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(e){const t=Xs.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 He=Xs,$d=Z.module("GlobalContextAction");class Ug 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),$d.debug("Received context menu event at global action! Menu items are now: ",t.contextActions))}handleKeyDown(e){const{action:t}=this.props;!He.actionsDisabled&&t.shortcut!==void 0&&t.shortcut.matchesEvent(e)&&($d.debug("Global hotkey matched!",e),t.action?.(e),e.preventDefault(),e.stopPropagation())}render(){return null}}const $g=Ug;class Wg 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($g,{action:i,"data-testid":t},`${i.title}.${o?.id}`);n.push(a)}}return n}}const Gg=Wg;const Qo=Z.module("ContextActions");class zg 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=X.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=>!Or(s)&&typeof s!="function"&&s.isGlobal),n=e.actions.filter(s=>!Or(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){Qo.debug2(`Contextmenu event ignored based on the target className "${o}"`);return}s=s.parentElement}}if(He.isContextActionEvent(e)||(e.contextActions=[]),!He.isContextActionEvent(e))return;const{actions:n}=this.props;if(n!=null){let s=n;Array.isArray(s)&&(s=s.filter(i=>Or(i)||typeof i=="function"||i.isGlobal===void 0||!i.isGlobal)),e.contextActions=e.contextActions.concat(s)}Qo.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];!He.actionsDisabled&&s.shortcut!=null&&s.shortcut.matchesEvent(e)&&(Qo.debug("Context hotkey matched!",e),s.action?.(e),e.stopPropagation(),e.preventDefault(),Qo.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(Gg,{actions:t})})}}const ae=zg,Al=X.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":I}=d,F={menuItem:T,closeMenu:w,isKeyboardSelected:y,isMouseSelected:E,iconElement:S,displayShortcut:v,"data-testid":I};return X.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(X.isValidElement(f))m=f;else{let S;a.iconColor!=null&&(a.disabled===void 0||!a.disabled)&&(S={color:a.iconColor}),m=l.jsx(J,{icon:f,style:S})}}let p=null;const g=Boolean(o);a.actions&&(p=l.jsx(J,{icon:yh}));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:(g||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}),p&&l.jsx("span",{className:$("submenu-indicator",{disabled:f}),children:p})]})})}return l.jsxs("div",{className:"context-menu-item",ref:e,"data-testid":h,children:[o,C]})});Al.displayName="ContextMenuItem";Al.defaultProps={children:null,isKeyboardSelected:!1,isMouseSelected:!1,"data-testid":void 0};const Lh=Al,De=Object.freeze([]),Gn=new Map;class Kg extends Error{isCanceled=!0}const Hi=Kg;class sr{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),sr.getBrightness(i)<125}static getBrightness(e){return Math.round((e[0]*299+e[1]*587+e[2]*114)/1e3)}}async function $i(d){const{clipboard:e}=navigator;if(e!==void 0)try{return navigator.clipboard.writeText(d)}catch{return Wd(d)}Wd(d)}function Wd(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 qg="table_",Gd="column_",Yg=new Set(["in","not","i","ii","k"]),Xg=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"]),Zg=/[^a-zA-Z0-9_$+@-]/g,Qg=/[^A-Za-z0-9_$]/g;class cn{static legalize=(e,t,n,s,i)=>{let o=e.trim().replace(/[- ]/g,"_");return s&&(Yg.has(o)||Xg.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=>cn.legalize(e,qg,Zg,!1,0);static legalizeColumnNames=e=>{const t=[];return e.forEach((n,s)=>{let i=cn.legalizeColumnName(n,s);t.includes(i)&&(i=Gd+s),t.push(i)}),t};static legalizeColumnName=(e,t=0)=>cn.legalize(e,Gd,Qg,!0,t);static isValidTableName=e=>cn.legalizeTableName(e)===e;static isValidColumnName=e=>cn.legalizeColumnName(e)===e}function Jg(d,e){return d?d.closest(`.${e}`):null}const ef={getClosestByClassName:Jg};class Ve extends CustomEvent{constructor(e,t){super(e,t)}}class tf extends Error{isTimeout=!0}const Ph=tf;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 Hi),s!=null&&t&&t(s)},o}static isCanceled(e){return e instanceof Hi}static isTimedOut(e){return e instanceof Ph}}class nf{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 ts=nf;function M(d){if(d==null)throw new Error("Value is null or undefined")}function _(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 ln{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(!ln.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 sf{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 Wt=sf;class Wi{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(Wi.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 of extends Error{isInvalid=!0}const Ni=of,zd=Z.module("ContextMenu");class Da 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=X.createRef(),this.oldFocus=document.activeElement,this.activeSubMenuRef=X.createRef(),this.subMenuTimer=0,this.rAF=0,this.initialPosition={top:e.top,left:e.left},this.state={menuItems:[],pendingItems:[],activeSubMenu:null,hasOverflow:!1,subMenuTop:null,subMenuLeft:null,subMenuParentWidth:0,subMenuParentHeight:0,keyboardIndex:-1,mouseIndex:-1}}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=He.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:He.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:He.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}),zd.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){zd.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=He.getNextMenuItem(s,-1,t):(e.key==="ArrowDown"||e.key==="Tab")&&(s=He.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:p}=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(Lh,{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 g=null;c.length>0&&(g=l.jsx("div",{className:"loading",children:l.jsx(Ln,{})}));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:Da.handleContextMenu,role:"menuitem",tabIndex:0,"data-testid":f,children:[e,g]}),S&&s!==null&&h!==null&&u!==null&&l.jsx(Da,{actions:a[s].actions||[],closeMenu:this.handleCloseSubMenu,top:h,left:u,updatePosition:(v,w)=>{this.setState({subMenuTop:v,subMenuLeft:w})},subMenuParentWidth:m,subMenuParentHeight:p},`sub-${s}`)]})}}const af=Da;class rf extends b.Component{constructor(e){super(e),this.handleMenuClose=this.handleMenuClose.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.container=X.createRef(),this.openMenu=X.createRef(),this.state={actions:null,left:0,top:0}}componentDidMount(){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(!He.isContextActionEvent(e)||!this.container.current||e.metaKey||e.ctrlKey)return;const t=He.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(af,{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 _h=rf;class Ss extends b.Component{static propTypes={className:D.string,in:D.bool.isRequired,children:D.node.isRequired,autoFocusOnShow:D.bool,"data-testid":D.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=`${Ss.getHeight(t)}px`}static handleExiting(e){const t=e;t.style.height="0"}static handleExit(e){const t=e;t.style.height=`${Ss.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(gt,{in:n,classNames:{enterActive:"collapsing",enterDone:"collapse show",exitActive:"collapsing",exitDone:"collapse"},onEnter:Ss.handleEnter,onEntering:Ss.handleEntering,onEntered:this.handleEntered,onExit:Ss.handleExit,onExiting:Ss.handleExiting,timeout:350,children:i=>l.jsx("div",{className:$({collapse:i==="exited"},t),"data-testid":s,children:e})})}}const lf=Ss;function ir(d){const e=b.useRef();return b.useEffect(function(){e.current=d}),e.current}function jh(d){const e=b.useRef(null);return b.useEffect(function(){d&&(typeof d=="function"?d(e.current):d.current=e.current)}),e}const df=3500,cf=Z.module("useCopyToClipboard");function hf(){const[d,e]=b.useState(!1),t=b.useRef(null),n=b.useCallback(s=>{$i(s).then(()=>{e(!0)}).catch(i=>cf.error(`Unable to copy ${s}`,`
2
2
  `,i))},[]);return b.useEffect(()=>(t.current&&clearTimeout(t.current),d&&(t.current=setTimeout(()=>{e(!1)},df)),()=>{t.current&&clearTimeout(t.current)}),[d]),[d,n]}const or=X.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(Pe()),p=jh(e);b.useEffect(function(){p.current&&(p.current.indeterminate=t===null)},[p,t]);const g=b.useCallback(C=>{p.current&&(p.current.indeterminate=t===null),h&&h(C)},[p,t,h]);return l.jsxs("div",{className:$("custom-control custom-checkbox",s),children:[l.jsx("input",{type:"checkbox",ref:p,checked:t??!1,className:$("custom-control-input",o,{"is-invalid":a}),disabled:i,id:m,name:c,onChange:g,"data-testid":u}),l.jsx("label",{className:$("custom-control-label",r),htmlFor:m,children:n})]})});or.displayName="Checkbox";or.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:D.node.isRequired,className:D.string,disabled:D.bool,inputClassName:D.string,isInvalid:D.bool,labelClassName:D.string,name:D.string,onChange:D.func,"data-testid":D.string};or.defaultProps={checked:!1,className:"",disabled:!1,inputClassName:"",isInvalid:!1,labelClassName:"",name:void 0,onChange:void 0,"data-testid":void 0};const Xt=or;class uf extends b.PureComponent{static defaultProps={placeholder:"Search",className:"",matchCount:null,onKeyDown(){},id:"","data-testid":void 0};constructor(e){super(e),this.inputField=X.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(J,{icon:xh})})]})}}const As=uf;var Hh=(d=>(d.UP="UP",d.DOWN="DOWN",d))(Hh||{});class Ti extends b.Component{static MENU_NAVIGATION_DIRECTION=Hh;static DROP_DOWN_MENU_HEIGHT=200;static propTypes={options:D.arrayOf(D.shape({title:D.string.isRequired,value:D.string.isRequired})).isRequired,popperOptions:D.shape({title:D.string.isRequired,value:D.string.isRequired}),onChange:D.func,inputPlaceholder:D.string,searchPlaceholder:D.string,disabled:D.bool,className:D.string,defaultValue:D.string,spellCheck:D.bool,onEnter:D.func,"data-testid":D.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=X.createRef(),this.cbContainer=X.createRef(),this.toggleButton=X.createRef(),this.menuContainer=X.createRef(),this.input=X.createRef(),this.searchInput=X.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=pe((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(Ti.MENU_NAVIGATION_DIRECTION.UP),e.stopPropagation(),e.preventDefault();break;case"ArrowDown":this.handleMenuNavigation(Ti.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 Ti.MENU_NAVIGATION_DIRECTION.UP:r=-1;break;case Ti.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(As,{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(J,{icon:kn}),l.jsx(ri,{ref:this.popper,options:c,className:$("combobox interactive"),onEntered:this.handleMenuOpened,onExited:this.handleMenuExited,children:this.renderMenuElement()})]})})]})}}const Bh=Ti;function ar({copy:d,kind:e="ghost",tooltip:t="Copy",className:n,"data-testid":s,children:i}){const[o,a]=hf();return l.jsx(V,{kind:e,className:n,"data-testid":s,icon:o?Tp:Ep,tooltip:o?"Copied":t,onClick:()=>{a(typeof d=="function"?d():d)},children:i})}const hn=Z.module("MaskedInput"),fi={FORWARD:"forward",BACKWARD:"backward",NONE:"none"},Jo=" ";function Vh(d,e,t){return d.substring(0,e)+t+d.substring(e+1)}function mf(d,e,t){return d.length<t?`${d}${e.substring(d.length,t)}`:d}function Kd(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 Uh=X.forwardRef((d,e)=>{const{className:t,example:n,getNextSegmentValue:s=(O,k,L)=>L,getPreferredReplacementString:i=Vh,onChange:o=()=>!1,onSelect:a=()=>!1,pattern:r,placeholder:c,selection:h,value:u,onFocus:m=()=>!1,onBlur:p=()=>!1,"data-testid":g}=d,C=jh(e),f=b.useMemo(()=>Array.isArray(n)?n:[n],[n]),S=b.useMemo(()=>f[0].replace(/[a-zA-Z0-9]/g,Jo),[f]);b.useEffect(function(){if(h!=null){hn.debug("setting selection...",h);const{selectionStart:k,selectionEnd:L,selectionDirection:A}=h;C.current?.setSelectionRange(k,L,A),hn.debug("selection set!")}},[h,C]);const v=b.useCallback(O=>{let k=O,L=O;const A=f.length>0?f[0]:u;for(let j=k-1;j>=0&&/[a-zA-Z0-9]/g.test(A.charAt(j));j-=1)k=j;for(let j=L;j<A.length&&/[a-zA-Z0-9]/g.test(A.charAt(j));j+=1)L=j+1;const U=k===L?fi.NONE:fi.BACKWARD;return{selectionStart:k,selectionEnd:L,selectionDirection:U}},[f,u]);function w(O,k,L=O.length){let A="";for(let U=0;U<L;U+=1)O.charAt(U)!==Jo?A=A.concat(O[U]):A=A.concat(k[U]);return A=A.concat(k.substring(L)),A}function T(O,k=O.length){const L=new RegExp(`^${r}$`);if(L.test(O))return!0;for(let A=0;A<f.length;A+=1){const U=w(O,f[A],k);if(L.test(U))return!0}return!1}function y(O){const k=v(O),L=k.selectionEnd+1;return L>=u.length?k:v(L)}function E(O){const k=v(O),L=k.selectionStart-1;return L<=0?k:v(L)}function I(O,k){const L=v(O),A=u.substring(L.selectionStart,L.selectionEnd),U=s(L,k,A,u),j=u.substring(0,L.selectionStart)+U+u.substring(L.selectionEnd);T(j,L.selectionEnd)&&(o(j),a(L))}const F=b.useCallback(O=>{const{selectionStart:k=0,selectionEnd:L=0,selectionDirection:A="none"}=O.target;if(k===null||L===null||A===null){hn.error("Selection attempted on non-text input element",O.target);return}if(hn.debug2("handleSelect",k,L,A),!(h!=null&&k===h.selectionStart&&L===h.selectionEnd)){if(h!=null&&k===u.length&&L===u.length&&O.nativeEvent.type!=="mouseup"){a({...h});return}if(k===L){const U=v(k);hn.debug("Selection segment from ",k,L,"=>",U),a(U)}else a({selectionStart:k,selectionEnd:L,selectionDirection:A})}},[v,a,h,u]),N=b.useCallback(O=>{if(!C.current)return;hn.debug("handleSelectCapture",O);const k=C.current.selectionStart??0;k===u.length&&h!=null&&k!==h.selectionStart&&(O.preventDefault(),O.stopPropagation())},[C,h,u]);function H(O){if(O.preventDefault(),O.stopPropagation(),!C.current)return;const{key:k}=O,{selectionStart:L=0,selectionEnd:A=0}=C.current;if(L===null||A===null){hn.error("Selection arrow nvaigation attempted on non-text input element",O.target);return}k==="ArrowLeft"?a(E(L)):k==="ArrowRight"?a(y(A)):k==="ArrowUp"?I(L,-1):k==="ArrowDown"&&I(L,1)}function P(O){if(!C.current)return;hn.debug("handleKeyDown",O);const{key:k}=O,{selectionStart:L=0,selectionEnd:A=0}=C.current;if(L===null||A===null){hn.error("Selection key event on non-text input element",O.target);return}if(k.startsWith("Arrow")){H(O);return}if(k==="Delete"||k==="Backspace"){if(O.preventDefault(),O.stopPropagation(),A>=Kd(u,S).length){const j=u.substring(0,L===A?L-1:L),W=Kd(j,S);W!==u&&(o(W),a({selectionStart:W.length,selectionEnd:W.length,selectionDirection:fi.NONE}));return}if(L!==A){const j=u.substring(0,L)+u.substring(L,A).replace(/[a-zA-Z0-9]/g,Jo)+u.substring(A);hn.debug("Range ",L,A,"deleted, setting value",j),o(j),a({selectionStart:L,selectionEnd:L,selectionDirection:fi.NONE})}else if(L>0)for(let j=L-1;j>=0;j-=1){const W=u.substring(0,j)+u.substring(j,L).replace(/[a-zA-Z0-9]/g,Jo)+u.substring(L);if(W!==u){o(W),a({selectionStart:j,selectionEnd:j,selectionDirection:fi.NONE});return}}return}if(O.altKey||O.metaKey||O.ctrlKey||k.length>1)return;O.preventDefault(),O.stopPropagation();const U=Array.from(new Set([k,k.toUpperCase(),k.toLowerCase()]));for(let j=0;j<U.length;j+=1){const W=U[j],ie=/[a-zA-Z0-9]/g.test(W)?f[0].length-1:L;for(let se=L;se<=ie;se+=1){const G=mf(u,f[0],se+1),K=i(G,se,W,L,A);if(T(K,se+1)){const te=v(se),oe=se+1;let de={selectionStart:oe,selectionEnd:oe,selectionDirection:fi.NONE};if(oe>=te.selectionEnd){const ee=y(se);ee.selectionStart!==te.selectionStart&&(de=ee)}hn.debug("handleKeyDown",k,"=>",K,de),o(K),a(de);return}}}}return l.jsx("input",{ref:C,className:$("form-control masked-input",t),type:"text",pattern:r,placeholder:c,value:u,onChange:()=>{},onKeyDown:P,onSelect:F,onSelectCapture:N,onFocus:m,onBlur:p,"data-testid":g})});Uh.defaultProps={className:"",placeholder:void 0,onChange(){},onSelect(){},getNextSegmentValue:(d,e,t)=>t,getPreferredReplacementString:Vh,selection:void 0,onFocus(){},onBlur(){},"data-testid":void 0};const pf=Uh;let gf=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=X.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=He.getMenuItems(e,!1);t.length>0&&this.setState(n=>({menuItems:He.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=He.getNextMenuItem(s??0,-1,t):(e.key==="ArrowDown"||e.key==="Tab"&&e.shiftKey===!1)&&(s=He.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(Lh,{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 ff=gf;class Cf 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=X.createRef(),this.parent=null,this.popper=X.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(ri,{ref:this.popper,options:a,className:$("menu-popper",n),onExited:this.handleExited,closeOnBlur:!0,interactive:!0,children:l.jsx(ff,{actions:e,closeMenu:this.handleCloseMenu,onMenuOpened:t,options:o,menuStyle:i})})})}}const Zn=Cf;function Ci(d,e,t,n,s){const i=n-t+1;return`${((parseInt(e,10)-d-t)%i+i)%i+t}`.padStart(s,"0")}function Sf(d,e,t){const{selectionStart:n}=d;return n===0?Ci(e,t,1900,2099,4):n===5?Ci(e,t,1,12,2):n===8?Ci(e,t,1,31,2):n===11?Ci(e,t,0,23,2):n===17||n===14?Ci(e,t,0,59,2):n===20||n===24||n===28?Ci(e,t,0,999,3):t}const bf=Z.module("DateTimeInput"),wf="[12][0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])",vf="([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]\\.[0-9]{3}​[0-9]{3}​[0-9]{3}",Tf=`${wf} ${vf}`,ba="2022-01-01",$h=`${ba} 00:00:00.000000000`,Ef="YYYY-MM-DD HH:MM:SS.SSSSSSSSS";function qd(d){return d!=null&&d.length>=ba.length?`${d.substring(0,ba.length)}${d.substring(ba.length).replace(/\u2007/g,"0")}${$h.substring(d.length)}`:d}function al(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 Yd=d=>d.replace(/\u200B/g,""),yf=[al($h)],Ll=X.forwardRef((d,e)=>{const{className:t="",onChange:n=()=>{},defaultValue:s="",onFocus:i=()=>{},onBlur:o=()=>{},"data-testid":a}=d,[r,c]=b.useState(s.length>0?al(s):""),[h,u]=b.useState(),m=b.useCallback(g=>{bf.debug("handleChange",g),c(g),n(qd(Yd(g)))},[n]),p=b.useCallback(()=>{const g=Yd(r),C=qd(g);C!==g&&c(al(C)),o()},[r,o]);return l.jsx("div",{className:"d-flex flex-row align-items-center",children:l.jsx(pf,{ref:e,className:$(t),example:yf,getNextSegmentValue:Sf,onChange:m,onSelect:u,pattern:Tf,placeholder:Ef,selection:h,value:r,onFocus:i,onBlur:p,"data-testid":a})})});Ll.displayName="DateTimeInput";Ll.defaultProps={className:"",onChange:()=>{},defaultValue:"",onFocus:()=>{},onBlur:()=>{},"data-testid":void 0};const xf=Ll;class Rf extends b.PureComponent{static defaultProps={placeholder:"Search",className:"",matchCount:null,debounceMs:250,id:"","data-testid":void 0};constructor(e){super(e),this.searchInput=X.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(As,{value:o,placeholder:e,onChange:this.handleChange,className:t,matchCount:n,ref:this.searchInput,id:s,"data-testid":i})}}const If=Rf;const Df=Z.module("ItemListItem");class Pl 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 Df.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=X.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:Pl.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 Ff=Pl;const Xd=Z.module("ItemList"),Zd=5;class Ht extends b.PureComponent{static CACHE_SIZE=1e3;static DEFAULT_ROW_HEIGHT=20;static DEFAULT_OVERSCAN=10;static defaultProps={offset:0,items:[],rowHeight:Ht.DEFAULT_ROW_HEIGHT,isDeselectOnClick:!0,isDoubleClickSelect:!1,isDragSelect:!0,isMultiSelect:!1,isStickyBottom:!1,disableSelect:!1,onFocusChange(){},onSelect(){},onSelectionChange(){},onViewportChange(){},overscanCount:Ht.DEFAULT_OVERSCAN,renderItem:Ht.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=X.createRef(),this.listContainer=X.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=pe((e,t)=>ln.isSelected(t,e),{max:Ht.CACHE_SIZE});getCachedItem=pe((e,t,n,s,i,o,a,r)=>{const c=o({item:n,itemIndex:e,isFocused:s,isSelected:i,style:a});return l.jsx(Ff,{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:Ht.CACHE_SIZE});getOuterElement=pe(e=>{const t=X.forwardRef((n,s)=>l.jsx("div",{ref:s,tabIndex:-1,onKeyDown:e,role:"presentation",...n}));return t.displayName="ItemListOuterElement",t});getInnerElement=pe(()=>{const e=X.forwardRef((t,n)=>l.jsx("div",{className:"item-list-inner-element",ref:n,...t}));return e.displayName="ItemListInnerElement",e});getItemData=pe((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=ln.isSelected(n,e)||He.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:ln.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){Xd.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){Xd.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>Zd&&u>Zd&&this.setState({isDragging:!0}),(n||o===e)&&(this.focusItem(e),s?(!n&&!this.getItemSelected(e,a)&&!He.isModifierKeyDown(t)&&this.deselectAll(),this.selectRange([Math.min(o,e),Math.max(o,e)])):this.toggleSelect(e,t.shiftKey,He.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=He.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){ln.validateRange(e),this.setState(({selectedRanges:t})=>({selectedRanges:ln.deselectRange(t,e)}))}selectItem(e){const{disableSelect:t}=this.props;t||this.selectRange([e,e])}selectRange(e){ln.validateRange(e),this.setState(({selectedRanges:t})=>({selectedRanges:ln.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(_m,{className:"item-list-auto-sizer",onResize:this.handleResize,children:({width:c,height:h})=>l.jsx(jm,{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 bs extends b.PureComponent{static DEFAULT_ROW_HEIGHT=30;static defaultProps={className:"",draggingItemClassName:"",offset:0,items:[],rowHeight:bs.DEFAULT_ROW_HEIGHT,isDeselectOnClick:!0,isDoubleClickSelect:!0,isDropDisabled:!1,isDragDisabled:!1,isMultiSelect:!1,isStickyBottom:!1,disableSelect:!1,style:null,onFocusChange(){},onSelect(){},onSelectionChange(){},onViewportChange(){},renderItem:bs.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(J,{icon:Mo})]})}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}),bs.renderBadge({text:t}),bs.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 bs.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=X.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=pe((e,t,n,s,i,o,a,r)=>l.jsx(wl,{draggableId:bs.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:Ht.CACHE_SIZE});handleSelectionChange(e){this.setState({selectedCount:ln.count(e)});const{onSelectionChange:t}=this.props;t(e)}getCachedRenderDraggableItem=pe((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=pe((e,t,n,s)=>(i,o,a)=>{const{selectedCount:r}=this.state,{draggableProps:c,dragHandleProps:h,innerRef:u}=i,{index:m}=a.source,p=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:p,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:p,onSelect:g,onViewportChange:C,renderItem:f,rowHeight:S,selectedRanges:v,style:w,"data-testid":T}=this.props;return l.jsx(Za,{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(Ht,{focusSelector:".draggable-item-list-item",isDoubleClickSelect:i,isDragSelect:!1,isMultiSelect:r,isStickyBottom:c,itemCount:h,items:u,onFocusChange:p,onSelect:g,onSelectionChange:this.handleSelectionChange,onViewportChange:C,offset:m,ref:this.itemList,renderItem:this.getCachedRenderDraggableItem(t,o,f),rowHeight:S,selectedRanges:v})})})}}const gn=bs;class Fa{static reorder(e,t,n,s){const i=e===n?Fa.adjustDestinationIndex(s,t):s,o=Fa.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 Hm(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 bn=Fa;function Wh({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 Qd(d){return d.isOn!==void 0}function Nf({item:d,onSelect:e=()=>{},"data-testid":t}){const{icon:n,subtitle:s,title:i}=d,o=b.useMemo(()=>Qd(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(J,{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:Qd(d)?l.jsx(Wh,{on:d.isOn,onClick:a=>{a.stopPropagation(),o()}}):l.jsx(J,{icon:yh})})]})}function Gh({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(Nf,{item:n,onSelect:()=>{e(s)}})},n.title))})})}function Jd({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(V,{kind:"ghost",className:"btn-back","data-testid":"btn-page-back",onClick:e,icon:yp,children:"Back"})}),l.jsx("div",{className:"navigation-title",children:n}),l.jsx("div",{className:"navigation-right-buttons",children:t!==void 0&&l.jsx(V,{kind:"ghost",className:"btn-close px-2 m-1","data-testid":"btn-page-close",onClick:t,icon:Ui,tooltip:"Close"})})]}),l.jsx("div",{className:"navigation-content",children:d})]})}function Mf({children:d,"data-testid":e}){const t=b.useMemo(()=>X.Children.toArray(d),[d]),n=ir(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 p=t[t.length-1];t.length===n.length||n.length===0||o!==null||r!==null?o!==null&&p!==o?a(p):p!==r&&p!==s&&i(p):t.length>n.length?a(p):t.length<n.length&&(i(p),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(gt,{in:r!=null,timeout:We.transitionMidMs,classNames:"slide-right",onEntered:u,children:l.jsx(l.Fragment,{children:r!=null&&l.jsx("div",{className:"popping-view",children:r})})}),l.jsx(gt,{in:o!=null,timeout:We.transitionMidMs,classNames:"slide-left",onEntered:h,children:l.jsx(l.Fragment,{children:o!=null&&l.jsx("div",{className:"pushing-view",children:o})})})]})}function kf({children:d,disabled:e,value:t,"data-testid":n}){return l.jsx("option",{value:t,disabled:e,"data-testid":n,children:d})}function rr(d){const{children:e,disabled:t=!1,name:n,onChange:s,value:i="","data-testid":o}=d,[a]=b.useState(n??Pe());return l.jsx(l.Fragment,{children:X.Children.map(e,r=>r?X.cloneElement(r,{name:a,onChange:r.props.onChange??s,checked:i===r.props.value,disabled:r.props.disabled??t,"data-testid":o}):null)})}const _l=X.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,[p]=b.useState(Pe());return l.jsxs("div",{className:$("custom-control custom-radio",s),children:[l.jsx("input",{type:"radio",id:p,"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:p,children:n})]})});_l.displayName="RadioItem";_l.defaultProps={checked:void 0,className:"",disabled:!1,inputClassName:"",isInvalid:!1,labelClassName:"",name:void 0,onChange:void 0,"data-testid":void 0};const Qn=_l;function Of({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 Af 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=X.createRef(),this.topRow=null,this.bottomRow=null}componentDidMount(){this.sendViewportUpdate()}componentDidUpdate(){this.sendViewportUpdate()}list;topRow;bottomRow;getCachedItem=pe((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(Xt,{checked:o,disabled:a,onChange:()=>this.handleSelect(e),children:c})},t)},{max:1e3});getCachedItems=pe((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,p=this.getCachedItem(u,m,r,c,t,h,s);i.push(p)}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 Lf=Af,ec=Z.module("Shortcut");var ce=(d=>(d.CTRL="MODIFIER_CTRL",d.CMD="MODIFIER_CMD",d.ALT="MODIFIER_ALT",d.OPTION="MODIFIER_OPTION",d.SHIFT="MODIFIER_SHIFT",d))(ce||{}),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 Pf=new Set(["Enter","Delete","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"]);class ke extends vl{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:!ke.isMacPlatform&&e.metaKey||!ke.isAllowedKey(t)?!1:!(!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey)||Pf.has(t)}static isMacPlatform=He.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="":!ke.isAllowedKey(t)&&ke.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?"":ke.isMacPlatform?ke.getMacDisplayText(e):ke.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=ke.isMacPlatform?n:t;this.defaultKeyState=ke.createKeyState(r),this.keyState=this.defaultKeyState}getDisplayText(){return ke.getDisplayText(this.keyState)}getKeyState(){return this.keyState}setKeyState(e){ke.isValidKeyState(e)?(ec.debug2(`Shortcut ${this.id} updated to ${JSON.stringify(e)}`),this.keyState=e,this.dispatchEvent(new Ve("onUpdate",{detail:this}))):ec.debug2(`Shortcut ${this.id} tried to update to invalid keyState ${JSON.stringify(e)}`)}getDefaultKeyState(){return this.defaultKeyState}isDefault(){return ke.doKeyStatesMatch(this.getDefaultKeyState(),this.getKeyState())}setToNull(){this.setKeyState(ke.NULL_KEY_STATE)}isNull(){return ke.doKeyStatesMatch(this.keyState,ke.NULL_KEY_STATE)}setToDefault(){this.setKeyState(this.defaultKeyState)}matchesKeyState(e){return ke.doKeyStatesMatch(e,this.keyState)}matchesEvent(e){return this.matchesKeyState(ke.getKeyStateFromEvent(e))}}const tc=Z.module("ShortcutRegistry");class _f extends vl{shortcutMap=new Map;shortcutsByCategory=new Map;createAndAdd(e){const t=new ke(e);return this.add(t)}add(e){const t=this.shortcutMap.get(e.id);if(t)return tc.warn(`Skipping attempt to add duplicate shortcut ID to registry: ${e.id}`),t;tc.debug2(`Adding shortcut to registry: ${e.id}`),e.addEventListener("onUpdate",({detail:s})=>this.dispatchEvent(new Ve("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 jf=Object.freeze(new _f),Fe=jf,Hf={COPY:Fe.createAndAdd({id:"GLOBAL.COPY",name:"Copy",shortcut:[ce.CTRL,ue.C],macShortcut:[ce.CMD,ue.C],isEditable:!1}),PASTE:Fe.createAndAdd({id:"GLOBAL.PASTE",name:"Paste",shortcut:[ce.CTRL,ue.V],macShortcut:[ce.CMD,ue.V],isEditable:!1}),SAVE:Fe.createAndAdd({id:"GLOBAL.SAVE",name:"Save",shortcut:[ce.CTRL,ue.S],macShortcut:[ce.CMD,ue.S],isEditable:!1}),SELECT_ALL:Fe.createAndAdd({id:"GLOBAL.SELECT_ALL",name:"Select All",shortcut:[ce.CTRL,ue.A],macShortcut:[ce.CMD,ue.A],isEditable:!1}),LINKER:Fe.createAndAdd({id:"GLOBAL.LINKER",name:"Linker",shortcut:[ce.CTRL,ue.L],macShortcut:[ce.CMD,ue.L]}),LINKER_CLOSE:Fe.createAndAdd({id:"GLOBAL.LINKER_CLOSE",name:"Close Linker Overlay",shortcut:[ue.ESCAPE],macShortcut:[ue.ESCAPE],isEditable:!1})},es=Hf;const jl=X.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":p}=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":p,children:[t,l.jsx(J,{icon:yl,className:"linked btn-socketed-icon",transform:"down-1"}),l.jsx(J,{icon:xp,className:"is-invalid btn-socketed-icon"})]})});jl.displayName="SocketedButton";jl.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 zh=jl,{dh:x}=globalThis,Hl=D.shape({name:D.string.isRequired,type:D.string.isRequired,description:D.string,constituentType:D.string}),Bf=D.shape({not:D.func.isRequired,and:D.func.isRequired,or:D.func.isRequired});D.shape({asc:D.func.isRequired,desc:D.func.isRequired,abs:D.func.isRequired,column:Hl.isRequired,direction:D.string.isRequired,isAbs:D.bool.isRequired});D.shape({columns:D.arrayOf(Hl).isRequired,customColumns:D.arrayOf(D.string).isRequired,filter:D.arrayOf(Bf),addEventListener:D.func.isRequired,removeEventListener:D.func.isRequired,size:D.number.isRequired,sort:D.arrayOf(D.any),copy:D.func.isRequired,applyFilter:D.func.isRequired,applySort:D.func.isRequired,applyCustomColumns:D.func.isRequired,description:D.string});D.shape({columns:D.arrayOf(Hl),filter:D.arrayOf(D.any),isExpanded:D.func.isRequired,saveExpandedState:D.func.isRequired,addEventListener:D.func.isRequired,removeEventListener:D.func.isRequired,size:D.number.isRequired,sort:D.arrayOf(D.any),applyFilter:D.func.isRequired,applySort:D.func.isRequired});const Ar=D.shape({name:D.string.isRequired,type:D.string.isRequired});D.shape({created:D.arrayOf(Ar).isRequired,updated:D.arrayOf(Ar).isRequired,removed:D.arrayOf(Ar).isRequired});D.shape({groupingColumns:D.arrayOf(D.string),aggregations:D.shape({}),includeConstituents:D.bool,includeOriginalColumns:D.bool,includeDescriptions:D.bool});D.shape({addEventListener:D.func.isRequired,removeEventListener:D.func.isRequired,onLogMessage:D.func,getTable:D.func.isRequired,runCode:D.func.isRequired});function Kh({type:d}){switch(d){case x.VariableType.TABLE:case x.VariableType.TABLEMAP:case x.VariableType.TREETABLE:case x.VariableType.HIERARCHICALTABLE:return l.jsx(J,{icon:xl});case x.VariableType.FIGURE:return l.jsx(J,{icon:Rh});case x.VariableType.PANDAS:return l.jsx(J,{icon:Rp});default:return l.jsx(J,{icon:sl})}}class Vf extends b.Component{constructor(e){super(e),this.container=null}componentDidMount(){this.colorize()}container;colorize(){const{children:e}=this.props;this.container&&e!=null&&Yn.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 lr=Vf;class Uf{static get LANGUAGE_MAP(){return new Map([["python","Python"],["groovy","Groovy"],["scala","Scala"]])}}const qh=Uf;class Na{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)?[]:Bm.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===x.VariableType.TABLE||e===x.VariableType.TREETABLE||e===x.VariableType.HIERARCHICALTABLE}static isWidgetType(e){return e===x.VariableType.FIGURE||e===x.VariableType.OTHERWIDGET||e===x.VariableType.PANDAS}static isOpenableType(e){return Na.isTableType(e)||Na.isWidgetType(e)}static isFigureType(e){return e===x.VariableType.FIGURE}static isPandas(e){return e===x.VariableType.PANDAS}}const rl=Na;function Yh({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})]})}Yh.propTypes={children:D.node.isRequired};class $f 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(Ln,{})," Running... ",Wi.formatElapsedTime(n)," ",l.jsx(V,{className:"console-history-result-in-progress-cancel",kind:"ghost",icon:Ui,tooltip:"Cancel",onClick:t,disabled:e})]})})}}const Wf=$f;class Ma 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)>=Ma.mouseDragThreshold||Math.abs(e.clientY-this.mouseY)>=Ma.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
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(J,{icon:e?kn:Ih,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 Gf=Ma;const nc=Z.module("ConsoleHistoryItem");class zf 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){nc.debug("handleObjectClick",e);const{openObject:t}=this.props;t(e)}handleCancelClick(){const{item:e}=this.props;e!=null&&e.cancelResult&&(nc.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(lr,{language:n,children:t.command})})]}));const a=[];let r=!1;if(i){const{error:h,message:u,changes:m}=i;if(m){const{created:p,updated:g}=m;[...p,...g].forEach(C=>{r=!0;const{title:f}=C,S=`${f}`,v=e===void 0||e||(s??[]).indexOf(S)>=0,w=l.jsx(V,{kind:"primary",onClick:()=>this.handleObjectClick(C),className:"btn-console-object",disabled:v,icon:l.jsx(Kh,{type:C.type}),children:f},S);a.push(w)})}if(h!=null&&t.command==null){let p=`${h.message??h}`;p||(p=h);const g=l.jsx(Gf,{message:p},"result-error");a.push(g)}if(u!==void 0&&u!==""){const p=l.jsx("div",{className:"log-message",children:u},"log-message");a.push(p)}}else{r=!0;const h=l.jsx(Wf,{onCancelClick:this.handleCancelClick,disabled:e},"in_progress");a.push(h)}let c=null;return a.length>0&&(c=l.jsx(Yh,{children:a})),l.jsxs("div",{className:$("console-command-result",{"console-result-buttons":r}),children:[o,c]})}}const Kf=zf;class Bl 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(Kf,{disabled:e,item:a,openObject:s,language:n},Bl.itemKey(o,a));i.push(r)}return l.jsx("div",{className:"container-fluid console-history",children:i})}}const qf=Bl,Yf={name:"Console",CLEAR:Fe.createAndAdd({id:"CONSOLE.CLEAR",name:"Clear",shortcut:[ce.CTRL,ue.L],macShortcut:[ce.CTRL,ue.C]}),FOCUS_HISTORY:Fe.createAndAdd({id:"CONSOLE.FOCUS_HISTORY",name:"Focus History",shortcut:[ce.CTRL,ue.H],macShortcut:[ce.CTRL,ce.OPTION,ue.H]})},Xf={name:"Command History",FOCUS_HISTORY:Fe.createAndAdd({id:"COMMAND_HISTORY.FOCUS_HISTORY",name:"Focus History Search",shortcut:[ce.CTRL,ue.H],macShortcut:[ce.CTRL,ce.OPTION,ue.H]}),SEND_TO_CONSOLE:Fe.createAndAdd({id:"COMMAND_HISTORY.SEND_TO_CONSOLE",name:"Send to Console",shortcut:[ue.ENTER],macShortcut:[ue.ENTER]}),SEND_TO_NOTEBOOK:Fe.createAndAdd({id:"COMMAND_HISTORY.SEND_TO_NOTEBOOK",name:"Send to Notebook",shortcut:[ce.CTRL,ue.ENTER],macShortcut:[ce.CMD,ue.ENTER]}),RUN:Fe.createAndAdd({id:"COMMAND_HISTORY.RUN",name:"Run",shortcut:[ce.ALT,ue.R],macShortcut:[ce.OPTION,ue.R]})},Zf={name:"Notebook",RUN:Fe.createAndAdd({id:"NOTEBOOK.RUN",name:"Run",shortcut:[ce.ALT,ue.R],macShortcut:[ce.OPTION,ue.R]}),RUN_SELECTED:Fe.createAndAdd({id:"NOTEBOOK.RUN_SELECTED",name:"Run Selected",shortcut:[ce.ALT,ce.SHIFT,ue.R],macShortcut:[ce.OPTION,ce.SHIFT,ue.R]}),FIND:Fe.createAndAdd({id:"NOTEBOOK.FIND",name:"Find",shortcut:[ce.CTRL,ue.F],macShortcut:[ce.CMD,ue.F],isEditable:!1}),MINIMAP:Fe.createAndAdd({id:"NOTEBOOK.MINIMAP",name:"Show Minimap",shortcut:[ce.ALT,ue.M],macShortcut:[ce.OPTION,ue.M]}),WORDWRAP:Fe.createAndAdd({id:"NOTEBOOK.WORDWRAP",name:"Word Wrap",shortcut:[ce.ALT,ue.Z],macShortcut:[ce.OPTION,ue.Z]})},Qf={CONSOLE:Yf,COMMAND_HISTORY:Xf,NOTEBOOK:Zf},Nt=Qf,mt=Object.freeze({FATAL:"FATAL",STDERR:"STDERR",ERROR:"ERROR",WARN:"WARN",STDOUT:"STDOUT",INFO:"INFO",DEBUG:"DEBUG",TRACE:"TRACE"}),Jf="#2d2a2e",eC="#fcfcfa",tC="#fcd65b",nC="#b2b1b2",sC="#9edc6f",iC="#76d9e4",oC="#f95d84",aC="#aa9af4",rC="#f95d84",lC="#fcfcfa",dC="#7c7b7c",Se={"error-foreground":"#f95d84",background:Jf,foreground:eC,"line-height":"19px",string:tC,"string-delim":"#929192",delimiter:nC,predefined:sC,keyword:iC,storage:oC,number:aC,operator:rC,identifier:lC,"namespace-identifier":"#f95d84","identifier-js":"#fcd65b",comment:dC,"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"},cC="python",hC={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/}}},uC={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"]]}},mC={id:cC,conf:hC,language:uC},pC=mC,gC="groovy",fC={comments:{lineComment:"//",blockComment:["/*","*/"]},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"',notIn:["string"]},{open:"'",close:"'",notIn:["string","comment"]}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],onEnterRules:[{beforeText:/^\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async).*?:\s*$/,action:{indentAction:1}}],folding:{offSide:!0,markers:{start:/^\s*#region\b/,end:/^\s*#endregion\b/}}},CC={keywords:["and","del","from","not","while","as","elif","global","or","with","assert","else","if","pass","yield","break","except","import","print","println","class","exec","in","raise","continue","finally","is","return","def","for","lambda","try",":","=","isinstance","__debug__"],operators:["+","-","*","**","/","//","%","<<",">>","&","|","^","~","<",">","<=",">=","==","!=","<>","+=","-=","*=","/","//=","%=","&=","|=","^=",">>=","<<=","**="],brackets:[{open:"{",close:"}",token:"delimiter.curly"},{open:"[",close:"]",token:"delimiter.square"},{open:"(",close:")",token:"delimiter.parenthesis"}],symbols:/[=><!~&|+\-*/^%]+/,delimiters:/[;=.@:,`]/,escapes:/\\(?:[abfnrtv\\"'\n\r]|x[0-9A-Fa-f]{2}|[0-7]{3}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8}|N\{\w+\})/,rawpre:/(?:[rR]|ur|Ur|uR|UR|br|Br|bR|BR)/,strpre:/(?:[buBU])/,tokenizer:{root:[[/@strpre?("""|''')/,{token:"string.delim",bracket:"@open",next:"@mstring.$1"}],[/@strpre?"([^"\\]|\\.)*$/,"string.invalid"],[/@strpre?'([^'\\]|\\.)*$/,"string.invalid"],[/@strpre?(["])/,{token:"string.delim",bracket:"@open",next:"@sstring.$1",nextEmbedded:"deephavenDb"}],[/@strpre?(["'])/,{token:"string.delim",bracket:"@open",next:"@string.$1"}],[/@rawpre("""|''')/,{token:"string.delim",bracket:"@open",next:"@mrawstring.$1"}],[/@rawpre"([^"\\]|\\.)*$/,"string.invalid"],[/@rawpre'([^'\\]|\\.)*$/,"string.invalid"],[/@rawpre(["'])/,{token:"string.delim",bracket:"@open",next:"@rawstring.$1"}],[/__[\w$]*/,"predefined"],[/[a-z_$][\w$]*/,{cases:{"@keywords":"keyword","@default":"identifier"}}],[/[A-Z][\w]*/,{cases:{"~[A-Z0-9_]+":"constructor.identifier","@default":"namespace.identifier"}}],{include:"@whitespace"},[/[{}()[\]]/,"@brackets"],[/@symbols/,{cases:{"@keywords":"keyword","@operators":"operator","@default":""}}],[/\d*\.\d+([eE][-+]?\d+)?/,"number.float"],[/0[xX][0-9a-fA-F]+[lL]?/,"number.hex"],[/0[bB][0-1]+[lL]?/,"number.binary"],[/(0[oO][0-7]+|0[0-7]+)[lL]?/,"number.octal"],[/(0|[1-9]\d*)[lL]?/,"number"],[":",{token:"keyword",bracket:"@open"}],[/@delimiters/,{cases:{"@keywords":"keyword","@default":"delimiter"}}]],mstring:[{include:"@strcontent"},[/"""|'''/,{cases:{"$#==$S2":{token:"string.delim",bracket:"@close",next:"@pop"},"@default":{token:"string"}}}],[/["']/,"string"],[/./,"string.invalid"]],sstring:[{include:"@strcontent"},[/["]/,{token:"string.delim",bracket:"@close",next:"@pop",nextEmbedded:"@pop"}],[/./,"string.invalid"]],string:[{include:"@strcontent"},[/[']/,{token:"string.delim",bracket:"@close",next:"@pop"}],[/./,"string.invalid"]],strcontent:[[/[^\\"']+/,"string"],[/\\$/,"string.escape"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"]],mrawstring:[{include:"@rawstrcontent"},[/"""|'''/,{cases:{"$#==$S2":{token:"string.delim",bracket:"@close",next:"@pop"},"@default":{token:"string"}}}],[/["']/,"string"],[/./,"string.invalid"]],rawstring:[{include:"@rawstrcontent"},[/["']/,{cases:{"$#==$S2":{token:"string.delim",bracket:"@close",next:"@pop"},"@default":{token:"string"}}}],[/./,"string.invalid"]],rawstrcontent:[[/[^\\"']+/,"string"],[/\\["']/,"string"],[/\\u[0-9A-Fa-f]{4}/,"string.escape"],[/\\/,"string"]],whitespace:[[/[ \t\r\n]+/,""],[/\/\*\*(?!\/)/,"comment.doc","@doccomment"],[/\/\*/,"comment","@comment"],[/\/\/.*$/,"comment"]],comment:[[/[^/*]+/,"comment"],[/\*\//,"comment","@pop"],[/[/*]/,"comment"]],doccomment:[[/[^/*]+/,"comment.doc"],[/\*\//,"comment.doc","@pop"],[/[/*]/,"comment.doc"]]}},SC={id:gC,conf:fC,language:CC},bC=SC,wC="scala",vC={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>))/}}},TC={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"]]}},EC={id:wC,conf:vC,language:TC},yC=EC,xC="deephavenDb",RC={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/}}},IC={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"]]}},DC={id:xC,conf:RC,language:IC},FC=DC,NC="log",MC={},kC={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"}]]}},OC={id:NC,conf:MC,language:kC},AC=OC,yn=Z.module("MonacoUtils");class In{static init({getWorker:e}={}){yn.debug("Initializing Monaco..."),e!==void 0&&In.registerGetWorker(e);const{registerLanguages:t,removeHashtag:n}=In,s=[{token:"",foreground:n(Se.foreground)},{token:"string",foreground:n(Se.string)},{token:"string.delim",foreground:n(Se["string-delim"])},{token:"keyword",foreground:n(Se.keyword)},{token:"identifier.js",foreground:n(Se["identifier-js"])},{token:"delimiter",foreground:n(Se.delimiter)},{token:"comment",foreground:n(Se.comment)},{token:"number",foreground:n(Se.number)},{token:"storage",foreground:n(Se.storage)},{token:"identifier",foreground:n(Se.identifier)},{token:"namespace.identifier",foreground:n(Se["namespace-identifier"])},{token:"operator",foreground:n(Se.operator)},{token:"predefined",foreground:n(Se.predefined)},{token:"error.log",foreground:Se["log-error"].substring(1)},{token:"warn.log",foreground:n(Se["log-warn"])},{token:"info.log",foreground:n(Se["log-info"])},{token:"stdout.log",foreground:n(Se["log-stdout"])},{token:"trace.log",foreground:n(Se["log-trace"])},{token:"debug.log",foreground:n(Se["log-debug"])},{token:"date.log",foreground:n(Se["log-date"])}],i={errorForeground:Se["error-foreground"],"inputOption.activeBorder":Se["input-option-active-border"],"editor.background":Se.background,"editor.foreground":Se.foreground,"editor.lineHighlightBackground":Se["editor-line-highlight-bg"],"editorLineNumber.foreground":Se["editor-line-number-foreground"],"editor.selectionBackground":Se["editor-selection-background"],"editor.findMatchBackground":Se["editor-find-match-background"],"editor.findMatchHighlightBackground":Se["editor-find-match-highlight-background"],"editorSuggestWidget.background":Se["editor-suggest-widget-background"],"editorSuggestWidget.border":Se["editor-suggest-widget-border"],"editorSuggestWidget.foreground":Se["editor-suggest-widget-foreground"],"editorSuggestWidget.selectedBackground":Se["editor-suggest-widget-selected-background"],"editorSuggestWidget.highlightForeground":Se["editor-suggest-widget-highlightForeground"],"list.hoverBackground":Se["list-hover-background"],"dropdown.background":Se["context-menu-background"],"dropdown.foreground":Se["context-menu-foreground"],"menu.selectionBackground":Se["menu-selection-background"],"list.focusBackground":Se["menu-selection-background"],"editorWidget.background":Se["editor-widget-background"],"inputOption.activeBackground":Se["input-option-active-background"],"inputOption.activeForeground":Se["input-option-active-foreground"],focusBorder:Se["focus-border"],"input.background":Se["input-background"],"input.foreground":Se["input-foreground"],"input.border":Se["input-border"]};Yn.defineTheme("dh-dark",{base:"vs-dark",inherit:!0,rules:s,colors:i}),yn.debug2("monaco theme: ",Se),Yn.setTheme("dh-dark"),t([FC,pC,bC,AC,yC]),yn.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);wi.getLanguages().filter(({id:n})=>t.includes(n)).forEach(n=>{const s=n;yn.debug2("Overriding default language loader:",s.id)}),e.forEach(n=>{In.registerLanguage(n)})}static registerLanguage(e){yn.debug2("Registering language: ",e.id),wi.register(e),wi.onLanguage(e.id,()=>{wi.setLanguageConfiguration(e.id,e.conf),wi.setMonarchTokensProvider(e.id,e.language)})}static setEOL(e,t=Yn.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 yn.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:p,text:g}=u,C={range:{start:{line:m.startLineNumber-1,character:m.startColumn-1},end:{line:m.endLineNumber-1,character:m.endColumn-1}},rangeLength:p,text:g};c.push(C)}if(c.length>0){const h={textDocument:{version:r,uri:`${n.uri}`},contentChanges:c};yn.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=>{In.isMacPlatform()&&n.mac===""||!In.isMacPlatform()&&n.windows===""||In.removeKeybinding(e,In.isMacPlatform()?n.mac:n.windows)})}catch(n){yn.error(n)}}static removeKeybinding(e,t){if(t===void 0)return;const n=e._standaloneKeybindingService._getResolver()._map.get(t);n!=null?n.forEach(s=>{yn.debug2(`Removing Monaco keybinding ${t} for ${s.command}`),e._standaloneKeybindingService.addDynamicKeybinding(`-${s.command}`,null,()=>{})}):yn.warn(`Did not find any keybindings to remove for ${t}`)}static getMonacoKeyCodeFromShortcut(e){const{keyState:t}=e,{keyValue:n}=t;return n===null?0:In.isMacPlatform()?(t.metaKey?rn.CtrlCmd:0)|(t.shiftKey?rn.Shift:0)|(t.altKey?rn.Alt:0)|(t.ctrlKey?rn.WinCtrl:0)|Ld.fromString(n):(t.ctrlKey?rn.CtrlCmd:0)|(t.shiftKey?rn.Shift:0)|(t.altKey?rn.Alt:0)|(t.metaKey?rn.WinCtrl:0)|Ld.fromString(n)}}const zt=In,sc=Z.module("MonacoCompletionProvider");class LC extends b.PureComponent{constructor(e){super(e),this.handleCompletionRequest=this.handleCompletionRequest.bind(this)}componentDidMount(){const{language:e}=this.props;this.registeredCompletionProvider=wi.registerCompletionItemProvider(e??"",{provideCompletionItems:this.handleCompletionRequest,triggerCharacters:['"',".","'","(","[","{",","]})}componentWillUnmount(){this.registeredCompletionProvider?.dispose()}registeredCompletionProvider;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:{line:t.lineNumber-1,character:t.column-1},context:n},a=i.getCompletionItems(o);return sc.debug("Completion items received: ",o,a),a.then(c=>({incomplete:!0,suggestions:c.map(u=>{const{label:m,kind:p,detail:g,documentation:C,sortText:f,filterText:S,textEdit:v,insertTextFormat:w}=u,{start:T,end:y}=v.range,E={startLineNumber:T.line+1,startColumn:T.character+1,endLineNumber:y.line+1,endColumn:y.character+1};return{label:m,kind:p,detail:g,documentation:C,sortText:f,filterText:S,insertText:v.text,insertTextRules:w===2?4:w,range:E}})})).catch(c=>(sc.error("There was an error retrieving completion items",c),{suggestions:[]}))}render(){return null}}const Xh=LC;const Lr=Z.module("ConsoleInput"),wa=parseInt(Se["line-height"],10),Zh=6,Qh=6,PC=wa+Zh+Qh,Pr=100;class Vl extends b.PureComponent{static defaultProps={maxHeight:wa*10,scope:null,disabled:!1};static INPUT_CLASS_NAME="console-input";constructor(e){super(e),this.handleWindowResize=this.handleWindowResize.bind(this),this.commandContainer=X.createRef(),this.commandHistoryIndex=null,this.timestamp=Date.now(),this.bufferIndex=0,this.history=[],this.modifiedCommands=new Map,this.state={commandEditorHeight:wa,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&&(Lr.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:wa,lineDecorationsWidth:3,lineNumbers:"off",minimap:{enabled:!1},renderLineHighlight:"none",scrollBeyondLastLine:!1,scrollbar:{arrowSize:0,horizontal:"hidden",horizontalScrollbarSize:0},padding:{top:Zh,bottom:Qh},tabCompletion:"on",value:"",wordWrap:"on"},s=this.commandContainer.current;M(s),this.commandEditor=Yn.create(s,n),zt.setEOL(this.commandEditor),zt.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===xs.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===xs.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(rn.CtrlCmd|xs.KeyF,()=>{}),zt.removeConflictingKeybindings(this.commandEditor),zt.registerPasteHandler(this.commandEditor),this.commandEditor.focus(),this.updateDimensions(),this.setState({model:this.commandEditor.getModel()})}destroyCommandEditor(){const{session:e}=this.props;this.commandEditor&&(zt.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-Pr&&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+Pr-1}),this.loadingPromise=ve.makeCancelable(s.getViewportData(),()=>s.close());const i=await this.loadingPromise;this.bufferIndex+=Pr,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)){Lr.debug2("Promise canceled, not loading history");return}Lr.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),PC),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:Vl.INPUT_CLASS_NAME,ref:this.commandContainer,style:{height:s}}),o&&l.jsx(Xh,{model:o,language:t,session:n})]})})}}const ic=Vl;const oc="pasted values",_C=[/^audio.*/,/^font.*/,/^image.*/,/^video.*/],_r=[".csv",".tsv",".tab",".psv",".dsv",".txt"],ac=[".zip"];class Zs 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"&&!_C.find(t=>t.test(e.type))}static isValidExtension(e,t=!1){return _r.some(n=>e.endsWith(n))||t&&ac.some(n=>e.endsWith(n))}static handleDragOver(e){e.preventDefault(),e.stopPropagation()}static getIcon(e){return e===oc?Pd:e.endsWith(".csv")?Ip:e.endsWith(".zip")?Dp:Fp}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=X.createRef(),this.divElem=X.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),Zs.isValidExtension(i.name,t)?this.handleFile(i):this.setState({dropError:Zs.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:oc,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:Pd,action:this.handleMenuPaste,shortcut:es.PASTE,disabled:e}]}getValidExtensions=fe(e=>e?[..._r,...ac]:[..._r]);getAcceptString=fe(e=>this.getValidExtensions(e).join(", "));getFileTypeErrorString=fe(e=>Wt.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:Zs.handleDragOver,onDrop:this.handleDrop,tabIndex:-1,children:[l.jsx(ae,{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(J,{icon:Np})}),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(V,{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(J,{icon:Zs.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(V,{kind:"ghost",className:"ml-2",onClick:this.unstageFile,icon:Qt,tooltip:"Remove"})]})]})]}),Boolean(o)&&l.jsxs("div",{className:"message-content",children:[l.jsx("div",{className:"message-icon",children:l.jsx(J,{icon:Ms})}),l.jsx("label",{children:o}),o===Zs.FILE_TYPE_ERROR&&l.jsx("div",{className:"message-small",children:l.jsx("label",{children:this.getFileTypeErrorString(e)})})]})]})}}const vi=Zs;class jC{static INTEGER="int";static LONG="long";static DOUBLE="double";static BOOLEAN="bool";static STRING="string";static DATE_TIME="datetime";static LOCAL_TIME="localtime"}const Ae=jC,rc="unknown",HC=2147483647,BC=-2147483648,lc=/^[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]+)?$/,dc=/^([0-9]+T)?([0-9]+):([0-9]+)(:[0-9]+)?(?:\.[0-9]{1,9})?$/;class Tt{static determineType(e,t,n){if(!e||e===n)return t;switch(t){case Ae.STRING:return Ae.STRING;case Ae.INTEGER:return Tt.checkInteger(e);case Ae.LONG:return Tt.checkLong(e);case Ae.DOUBLE:return Tt.checkDouble(e);case Ae.BOOLEAN:return Tt.checkBoolean(e);case Ae.DATE_TIME:return Tt.checkDateTime(e);case Ae.LOCAL_TIME:return Tt.checkLocalTime(e);default:return Tt.getTypeFromUnknown(e)}}static isNotParsableNumber(e){return isNaN(e)||e==="Infinity"||e==="-Infinity"}static checkInteger(e){const t=e.replace(/,/g,"");return Tt.isNotParsableNumber(t)?Ae.STRING:Tt.getNumberType(t)}static checkLong(e){const t=e.replace(/,/g,"");return Tt.isNotParsableNumber(t)?Ae.STRING:t.includes(".")?Ae.DOUBLE:Ae.LONG}static checkDouble(e){const t=e.replace(/,/g,"");return Tt.isNotParsableNumber(t)?Ae.STRING:Ae.DOUBLE}static checkBoolean(e){const t=e.toLowerCase();return t==="true"||t==="false"?Ae.BOOLEAN:Ae.STRING}static checkDateTime(e){return lc.test(e)?Ae.DATE_TIME:Ae.STRING}static checkLocalTime(e){return dc.test(e)?Ae.LOCAL_TIME:Ae.STRING}static getTypeFromUnknown(e){const t=e.replace(/,/g,"");if(Tt.isNotParsableNumber(t)){const n=e.toLowerCase();return n==="true"||n==="false"?Ae.BOOLEAN:lc.test(e)&&e.includes(":")?Ae.DATE_TIME:dc.test(e)?Ae.LOCAL_TIME:Ae.STRING}return Tt.getNumberType(t)}static getNumberType(e){if(e.includes("."))return Ae.DOUBLE;const t=e.startsWith("-")?11:10;if(e.length>t)return Ae.LONG;const n=parseInt(e,10);return n>HC||n<BC?Ae.LONG:Ae.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;el.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(rc),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]=Tt.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
4
  Expected length ${s.length} but found ${a.length}.
@@ -31,7 +31,7 @@ ${e}`):n.setValue(`${e}`);const i=n.getLineCount(),o=n.getLineLength(i)+1;this.e
31
31
  ${KE(d)}`}function YE(d){const{rules:e=[],onChange:t=Gr,onCreate:n=Gr,onSelect:s=Gr}=d,i=b.useCallback((c,h,u)=>{c.stopPropagation(),Wc.debug("Rule clicked",h,u),s(u)},[s]),o=b.useCallback((c,h,u)=>{c.stopPropagation(),Wc.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(bn.stopDragging(),c.destination==null)return;const h=c.source.index,u=c.destination.index,m=[...e],p=e[h];m.splice(h,1),m.splice(u,0,p),t(m)},[t,e]);return l.jsxs("div",{className:"conditional-formatting-rules",children:[l.jsx(Qa,{onDragStart:bn.startDragging,onDragEnd:r,children:l.jsx(Za,{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(wl,{draggableId:`${m}-${u.type}`,index:m,disableInteractiveElementBlocking:!0,children:(p,g)=>l.jsx("div",{role:"menuitem",tabIndex:0,onClick:C=>i(C,u,m),className:$("draggable-container",{dragging:g.isDragging}),ref:p.innerRef,...p.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:ja(u.config.style),color:Ha(u.config.style)},children:u.type===An.ROWS?"row":"col"})}),l.jsx("div",{className:"rule-title",children:qE(u.config)}),l.jsx(V,{kind:"ghost",className:"ml-1 px-2",onClick:C=>o(C,u,m),icon:Qt,tooltip:"Delete rule"}),l.jsxs("button",{type:"button",className:"btn btn-link btn-link-icon px-2 btn-drag-handle",onClick:a,...p.dragHandleProps,children:[l.jsx(tt,{children:"Drag to re-order"}),l.jsx(J,{icon:Mo})]})]})})})},`${m}-${u.type}`)),c.placeholder]})})}),l.jsx("hr",{}),l.jsx(V,{kind:"ghost",onClick:n,icon:Os,children:"Add New Rule"})]})}const Gs=Z.module("ConditionEditor"),XE=()=>{},ZE=[Ge.IS_EQUAL,Ge.IS_NOT_EQUAL,Ge.IS_BETWEEN,Ge.GREATER_THAN,Ge.GREATER_THAN_OR_EQUAL,Ge.LESS_THAN,Ge.LESS_THAN_OR_EQUAL,Ge.IS_NULL,Ge.IS_NOT_NULL].map(d=>l.jsx("option",{value:d,children:gv(d)},d)),QE=[Gt.IS_EXACTLY,Gt.IS_NOT_EXACTLY,Gt.CONTAINS,Gt.DOES_NOT_CONTAIN,Gt.STARTS_WITH,Gt.ENDS_WITH,Gt.IS_NULL,Gt.IS_NOT_NULL].map(d=>l.jsx("option",{value:d,children:fv(d)},d)),JE=[Ft.IS_EXACTLY,Ft.IS_NOT_EXACTLY,Ft.IS_BEFORE,Ft.IS_BEFORE_OR_EQUAL,Ft.IS_AFTER,Ft.IS_AFTER_OR_EQUAL,Ft.IS_NULL,Ft.IS_NOT_NULL].map(d=>l.jsx("option",{value:d,children:Cv(d)},d)),ey=[fo.IS_TRUE,fo.IS_FALSE,fo.IS_NULL,fo.IS_NOT_NULL].map(d=>l.jsx("option",{value:d,children:Sv(d)},d)),ty=[ni.IS_EQUAL,ni.IS_NOT_EQUAL,ni.IS_NULL,ni.IS_NOT_NULL].map(d=>l.jsx("option",{value:d,children:bv(d)},d));function ny(d,e,t,n){return d===Ge.IS_NULL||d===Ge.IS_NOT_NULL||d===Ge.IS_BETWEEN&&t!=null&&t!==""&&!Number.isNaN(Number.parseFloat(t))&&n!=null&&n!==""&&!Number.isNaN(Number.parseFloat(n))||d!==Ge.IS_BETWEEN&&e!==void 0&&e!==""&&!Number.isNaN(Number.parseFloat(e))}function sy(d,e,t,n,s,i,o){switch(d){case Ge.IS_EQUAL:case Ge.IS_NOT_EQUAL:case Ge.GREATER_THAN:case Ge.GREATER_THAN_OR_EQUAL:case Ge.LESS_THAN:case Ge.LESS_THAN_OR_EQUAL:return l.jsx("input",{type:"number",className:"form-control",placeholder:"Enter value",value:s??"",onChange:e});case Ge.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 Ge.IS_NULL:case Ge.IS_NOT_NULL:return null}}function iy(d,e,t){switch(d){case Gt.IS_NULL:case Gt.IS_NOT_NULL:return null;default:return l.jsx("input",{type:"text",className:"form-control",placeholder:"Enter value",value:t??"",onChange:e})}}function oy(d,e,t){switch(d){case Ft.IS_NULL:case Ft.IS_NOT_NULL:return null;default:return l.jsx("input",{type:"text",className:"form-control",placeholder:"Enter value",value:t??"",onChange:e})}}function ay(){return null}function ry(d,e,t){switch(d){case ni.IS_NULL:case ni.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 cm(d){const{column:e,config:t,onChange:n=XE}=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),[p,g]=b.useState(t.end);s!==i&&(r(Xu(s)),h(Zu(s)),m(void 0),g(void 0),o(s));const C=b.useMemo(()=>{if(s===void 0)return[];if(R.isNumberType(s))return ZE;if(R.isCharType(s))return ty;if(R.isStringType(s))return QE;if(R.isDateType(s))return JE;if(R.isBooleanType(s))return ey},[s]),f=b.useCallback(y=>{const{value:E}=y.target;Gs.debug("handleConditionChange",E),r(E)},[]),S=b.useCallback(y=>{const{value:E}=y.target;Gs.debug("handleValueChange",E),h(E)},[]),v=b.useCallback(y=>{const{value:E}=y.target;Gs.debug("handleStartValueChange",E),m(E)},[]),w=b.useCallback(y=>{const{value:E}=y.target;Gs.debug("handleEndValueChange",E),g(E)},[]);b.useEffect(function(){let E=!0;a===void 0?(Gs.debug("Unable to create formatting rule. Condition is not selected."),E=!1):R.isNumberType(e.type)&&!ny(a,c,u,p)?(Gs.debug("Unable to create formatting rule. Invalid value",c),E=!1):R.isDateType(e.type)&&!kv(a,c)&&(Gs.debug("Unable to create formatting rule. Invalid date condition",c),E=!1),n({condition:a,value:c,start:u,end:p},E)},[n,e.type,a,c,u,p]);const T=b.useMemo(()=>{if(s===void 0)return null;if(R.isNumberType(s))return sy(a,S,v,w,c,u,p);if(R.isCharType(s))return ry(a,S,c);if(R.isStringType(s))return iy(a,S,c);if(R.isDateType(s))return oy(a,S,c);if(R.isBooleanType(s))return ay()},[s,a,c,u,p,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 ly=Z.module("StyleEditor"),dy="#fcfcfa",cy="#f0f0ee",hy="#1a171a",uy=200,my=()=>{};function hm(d){const{config:e,onChange:t=my}=d,[n,s]=b.useState(e.type),[i,o]=b.useState(e.customConfig?.background??dy),[a,r]=b.useState(!1),[c,h]=b.useState(uy),u=b.useRef(null),m=b.useCallback(w=>{const{value:T}=w.target;ly.debug("handleBackgroundChange",T),o(T)},[]),p=b.useCallback(()=>{a&&r(!1)},[a]),g=b.useCallback(()=>{a||f(),r(!a)},[a]),C=b.useMemo(()=>[un.NO_FORMATTING,un.POSITIVE,un.NEGATIVE,un.WARN,un.NEUTRAL,un.ACCENT_1,un.ACCENT_2,un.CUSTOM],[]);function f(){u.current&&h(u.current.getBoundingClientRect().width)}b.useEffect(function(){t({type:n,customConfig:{color:sr.isDark(i)?cy:hy,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(V,{kind:"inline",className:"style-option-btn",onClick:()=>{s(y),r(!1)},style:{color:Ha({type:y}),background:ja({type:y})},children:[y===n&&l.jsx(J,{icon:Xn,className:"mr-2"}),y!==n&&l.jsx("span",{className:"mr-4"}),Ac(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(V,{kind:"inline",className:"cs-dropdown",style:{color:Ha({type:n}),background:ja({type:n})},onClick:g,children:[Ac(n),l.jsx("span",{children:l.jsx(J,{icon:Qp,className:"cs-caret"})}),l.jsx(Zn,{isShown:a,actions:{menuElement:v()},popperOptions:{placement:"bottom-start"},popperClassName:"style-dropdown-menu",onMenuClosed:p,menuStyle:{maxWidth:"100rem"}})]})]}),n===un.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 ro=Z.module("ColumnFormatEditor"),py=()=>{};function gy(d){const{type:e,name:t}=d[0];return{column:{type:e,name:t},style:Ju(),...Sr(e)}}function fy(d){const{columns:e,config:t=gy(e),onChange:n=py}=d,[s,i]=b.useState(e.find(f=>f.name===t.column.name&&f.type===t.column.type)??e[0]),[o,a]=b.useState(Qu(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(Sr(S.type)),c(!1))):ro.error(`Column ${f} not found.`)},[e,s]),p=b.useCallback((f,S)=>{ro.debug("handleConditionChange",f,S),a(f),c(S)},[]),g=b.useCallback(f=>{ro.debug("handleStyleChange",f),u(f)},[]);b.useEffect(function(){let S=r;s===void 0&&(ro.debug("Column is not selected, invalidating update."),S=!1),(h===void 0||h.type===un.NO_FORMATTING)&&(ro.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(Bh,{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(cm,{column:s,config:o,onChange:p}),l.jsx(hm,{config:h,onChange:g})]})]})}const lo=Z.module("RowFormatEditor"),Cy=()=>{};function Sy(d){const{type:e,name:t}=d[0];return{column:{type:e,name:t},style:Ju(),...Sr(e)}}function by(d){const{columns:e,config:t=Sy(e),onChange:n=Cy}=d,[s,i]=b.useState(e.find(f=>f.name===t.column.name&&f.type===t.column.type)??e[0]),[o,a]=b.useState(Qu(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(Sr(S.type)),c(!1))):lo.error(`Column ${f} not found.`)},[e,s]),p=b.useCallback((f,S)=>{lo.debug("handleConditionChange",f,S),a(f),c(S)},[]),g=b.useCallback(f=>{lo.debug("handleStyleChange",f),u(f)},[]);b.useEffect(function(){if(s===void 0){lo.debug("Column is not selected, skip update.");return}if(h===void 0){lo.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(Bh,{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(cm,{column:s,config:o,onChange:p}),l.jsx(hm,{config:h,onChange:g})]})]})}const zr=Z.module("ConditionalFormatEditor"),Kr=()=>{};function wy(d){switch(d){case An.CONDITIONAL:return l.jsx(QT,{});case An.ROWS:return l.jsx(JT,{})}}function vy(d){switch(d){case An.CONDITIONAL:return"Conditional";case An.ROWS:return"Rows"}}const Gc=[An.CONDITIONAL,An.ROWS];function Ty(d){const{columns:e,onSave:t=Kr,onUpdate:n=Kr,onCancel:s=Kr,rule:i}=d,o=e.filter(Ov),[a,r]=b.useState(i?.type??Gc[0]),[c,h]=b.useState(i),[u,m]=b.useState(!1),p=b.useCallback(()=>{s()},[s]),g=b.useCallback(()=>{if(c===void 0){zr.error("Rule is not defined.");return}t(c)},[t,c]),C=b.useCallback(S=>{zr.debug("handleFormatterChange",S),r(S)},[]),f=b.useCallback((S,v)=>{zr.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:Gc.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:[wy(S),vy(S)]})},S))})]}),a===An.CONDITIONAL&&l.jsx(fy,{columns:o,config:c?.config,onChange:f}),a===An.ROWS&&l.jsx(by,{columns:o,config:c?.config,onChange:f}),l.jsx("hr",{}),l.jsxs("div",{className:"d-flex justify-content-end my-3",children:[l.jsx(V,{kind:"secondary",onClick:p,className:"mr-2",children:"Cancel"}),l.jsx(V,{kind:"primary",onClick:g,disabled:c===void 0||!u,children:"Done"})]})]})}function Ey({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),p=b.useRef();b.useEffect(function(){if(e){try{JSON.parse(d),m(!0)}catch{m(!1)}h(!1)}},[e,d]),b.useEffect(function(){p.current&&p.current.layout()},[i]),b.useEffect(function(){p.current&&p.current.updateOptions({lineNumbers:a?"on":"off"})},[a]);function g(){r(!a)}function C(){const w=p.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=p.current;w&&r((w.getModel()?.getLineCount()??0)>1)}function S(){n&&(p.current=void 0,t())}function v(w){p.current=w,o(w.getContentHeight()),w.onDidContentSizeChange(({contentHeight:T})=>o(T)),f()}return!e&&!n?null:l.jsxs(Do,{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(Fo,{toggle:t,children:[l.jsx("h5",{className:"overflow-modal-title",children:"Cell Contents"}),l.jsx(ar,{kind:"inline",tooltip:"Copy cell contents",copy:p.current?.getValue()??d}),l.jsx(V,{kind:"inline",active:a,icon:Jp,tooltip:"Toggle line numbers",onClick:g}),u&&l.jsx(V,{kind:"inline",icon:eg,active:c,tooltip:"Format as JSON",onClick:C})]}),l.jsx(No,{style:{height:i},children:l.jsx(Ul,{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 yy(d){return d.model!==void 0}const xy="###,##0";function Ry({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:p,onGotoValueSelectedColumnNameChanged:g,onGotoValueSelectedFilterChanged:C,onGotoValueChanged:f,onGotoValueSubmit:S}){const v=b.useRef(null),w=b.useRef(null),[T,y]=b.useState(!1);let E=[];yy(c)&&c.table!==void 0&&({columns:E}=c.table);const I="Row number",{rowCount:F}=c,N=W=>{W.key==="Enter"?(W.stopPropagation(),W.preventDefault(),S()):(W.key==="Backspace"||W.key==="Delete")&&(p===`${Number.POSITIVE_INFINITY}`||p===`${Number.NEGATIVE_INFINITY}`)&&A("")},H=W=>{W.key==="Enter"&&(W.stopPropagation(),W.preventDefault(),S())},P=c.getColumnIndexByName(m),k=E[P??0]?.type,L=R.getNormalizedType(k),A=W=>{f(W??"")},U=()=>{T&&document.activeElement!==v.current?v.current?.select():!T&&document.activeElement!==w.current&&w.current?.select()};b.useEffect(U,[T,d,p]);const j=()=>{switch(L){case R.dataType.DECIMAL:case R.dataType.INT:return l.jsx("div",{className:"goto-row-input",children:l.jsx("input",{ref:w,className:$("form-control",{"is-invalid":t!==""}),onKeyDown:N,placeholder:"value",onChange:W=>{const ie=W.target.value.toLowerCase();/^-?[0-9]*\.?[0-9]*$/.test(W.target.value)?A(W.target.value):ie==="-i"||ie==="-infinity"?A(`${Number.NEGATIVE_INFINITY}`):(ie==="i"||ie==="infinity")&&A(`${Number.POSITIVE_INFINITY}`)},value:p})});case R.dataType.DATETIME:return l.jsx("div",{className:"goto-value-date-time-input",children:l.jsx(xf,{className:$("form-control","goto-value-date-time-input",{"is-invalid":t!==""}),defaultValue:p,onChange:A})});case R.dataType.STRING:return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"goto-row-input",children:l.jsxs("select",{className:"custom-select",onChange:W=>{C(W.target.value)},children:[l.jsx("option",{value:Y.eq,children:"Equals"},Y.eq),l.jsx("option",{value:Y.contains,children:"Contains"},Y.contains),l.jsx("option",{value:Y.eqIgnoreCase,children:"EqIgnoreCase"},Y.eqIgnoreCase)]})}),l.jsx("div",{className:"goto-row-input",children:l.jsx("input",{ref:w,className:$("form-control",{"is-invalid":t!==""}),onKeyDown:H,placeholder:"value",onChange:W=>A(W.target.value),value:p})})]});case R.dataType.BOOLEAN:return l.jsx("div",{className:"goto-row-input",children:l.jsxs("select",{className:"custom-select",onChange:W=>{A(W.target.value)},value:p,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:w,className:"form-control",onKeyDown:H,placeholder:"value",onChange:W=>A(W.target.value),value:p})})}};return l.jsx(br,{isShown:s,className:$("goto-row"),onEntering:i,onEntered:()=>{o(),U()},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":!T}),onClick:()=>y(!0),onFocus:()=>y(!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:v,type:"number",onKeyDown:W=>{W.key==="Enter"&&(W.stopPropagation(),W.preventDefault(),n())},className:$("form-control",{"is-invalid":e!==""}),placeholder:I,onChange:W=>{h(W)},value:d})}),l.jsxs("div",{className:"goto-row-text",children:["of ",dh.i18n.NumberFormat.format(xy,F)]}),e&&l.jsx("div",{className:"text-danger",children:e})]}),l.jsx("div",{className:"goto-row-close",children:l.jsx(V,{kind:"ghost",onClick:u,children:l.jsx(J,{icon:Ui,style:{marginRight:"0"}})})})]}),c.isSeekRowAvailable&&l.jsx("div",{className:"goto-row-row",children:l.jsxs("div",{className:$("goto-row-wrapper",{"is-inactive":T}),onClick:()=>y(!1),onFocus:()=>y(!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:W=>{const ie=W.target.value;g(ie)},value:m,children:E.map(W=>l.jsx("option",{value:W.name,children:W.name},W.name))})}),j(),l.jsxs("div",{children:[l.jsx(V,{kind:"ghost",disabled:p==="",onClick:()=>{S(!0)},children:l.jsx(J,{icon:kh})}),l.jsx(V,{kind:"ghost",disabled:p==="",onClick:()=>{S(!1)},children:l.jsx(J,{icon:tg})})]}),t&&l.jsx("div",{className:"text-danger",children:t})]})})]})})}const ge=Z.module("IrisGrid"),Iy=500,Dy=250,Fy=250,Ny=250,zc=Object.freeze({aggregations:De,showOnTop:!1}),My="yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS z";function Kc({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===R.REVERSE_TYPE.NONE&&i==null&&o==null&&a.length===0&&r.length===0}class Kn extends b.Component{static minDebounce=150;static maxDebounce=500;static loadingSpinnerDelay=800;static defaultProps={children:null,advancedFilters:Gn,advancedSettings:Gn,alwaysFetchColumns:De,conditionalFormats:De,customColumnFormatMap:Gn,isFilterBarShown:!1,applyInputFiltersOnInit:!1,movedColumns:De,movedRows:De,inputFilters:De,customFilters:De,onCreateChart:void 0,onColumnSelected:()=>{},onDataSelected:()=>{},onError:()=>{},onStateChange:()=>{},onPartitionAppend:()=>{},onAdvancedSettingsChange:()=>{},partition:null,partitionColumn:null,quickFilters:Gn,selectDistinctColumns:De,sorts:De,reverseType:R.REVERSE_TYPE.NONE,customColumns:De,aggregationSettings:zc,rollupConfig:void 0,userColumnWidths:Gn,userRowHeights:Gn,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:Gn,getDownloadWorker:void 0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:et.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,truncateNumbersWithPound:!1,formatter:De,decimalFormatOptions:D.shape({defaultFormatString:D.string}),integerFormatOptions:D.shape({defaultFormatString:D.string})},canCopy:!0,canDownloadCsv:!0,frozenColumns:null,theme:jc,canToggleSearch:!0};static makeQuickFilter(e,t,n){try{return R.makeQuickFilter(e,t,n)}catch(s){ge.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 ts,this.globalColumnFormats=De,this.decimalFormatOptions={},this.integerFormatOptions={},this.truncateNumbersWithPound=!1,this.renderer=new kT,this.tableSaver=null,this.crossColumnRef=X.createRef(),this.isAnimating=!1,this.filterInputRef=X.createRef(),this.toggleFilterBarAction={action:()=>this.toggleFilterBar(),shortcut:Kt.TABLE.TOGGLE_QUICK_FILTER},this.toggleSearchBarAction={action:()=>this.toggleSearchBar(),shortcut:Kt.TABLE.TOGGLE_SEARCH},this.toggleGotoRowAction={action:()=>this.toggleGotoRow(),shortcut:Kt.TABLE.GOTO_ROW},this.discardAction={action:()=>{const{model:j}=this.props;Ze(j)&&j.isEditable&&j.pendingDataMap.size>0&&this.discardPending().catch(ge.error)},shortcut:Kt.INPUT_TABLE.DISCARD},this.commitAction={action:()=>{const{model:j}=this.props;Ze(j)&&j.isEditable&&j.pendingDataMap.size>0&&j.pendingDataErrors.size===0&&this.commitPending().catch(ge.error)},shortcut:Kt.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:p,userRowHeights:g,showSearchBar:C,searchValue:f,selectedSearchColumns:S,invertSearchColumns:v,advancedFilters:w,quickFilters:T,selectDistinctColumns:y,pendingDataMap:E,canCopy:I,frozenColumns:F,columnHeaderGroups:N}=e,H=[new Qv(this),new eT(this)];I&&H.push(new Kv(this));const P=[new nT(this),new bT(this),new xT(this),new iT(this),new aT(this),new vT(this),new CT(this),new mT(this),new gT(this),new ET(this)],O=r.length>0?r:a.initialMovedColumns,k=c.length>0?c:a.initialMovedRows,L=new FT({userColumnWidths:new Map(p),userRowHeights:new Map(g),movedColumns:O,initialColumnWidths:new Map(a?.layoutHints?.hiddenColumns?.map(j=>[a.getColumnIndexByName(j),0]))}),A=S??[],U=ca.createSearchFilter(f,A,a.columns,v);this.state={isFilterBarShown:i,isSelectingPartition:o,focusedFilterBarColumn:null,metricCalculator:L,metrics:void 0,keyHandlers:H,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:R.REVERSE_TYPE.NONE,customColumns:[],selectDistinctColumns:y,selectedRanges:[],copyOperation:null,loadingText:null,loadingScrimProgress:null,loadingSpinnerShown:!1,movedColumns:O,movedRows:k,shownColumnTooltip:null,formatter:new Zt,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:U,searchValue:f,selectedSearchColumns:A,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:Y.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(Vi.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,p=h-c,g=Math.min(m/p,1);h<u&&(this.loadingScrimStartTime=void 0,this.loadingScrimFinishTime=void 0),this.setState(C=>C.loadingScrimProgress==null?(ge.debug2("Ignoring scrim update because loading cancelled."),null):{loadingScrimProgress:g})}),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=pe(e=>this.handleAdvancedMenuOpened.bind(this,e),{max:100});getCachedAdvancedFilterMenuActions=pe((e,t,n,s,i)=>l.jsx(UT,{model:e,column:t,onFilterChange:this.handleAdvancedFilterChange,onSortChange:this.handleAdvancedFilterSortChange,onDone:this.handleAdvancedFilterDone,options:n,sortDirection:s,formatter:i}),{max:50});getCachedOptionItems=pe((e,t,n,s,i,o,a,r,c,h,u,m,p,g,C,f)=>{const S=[];return e&&S.push({type:Ie.CHART_BUILDER,title:"Chart Builder",icon:ng}),S.push({type:Ie.VISIBILITY_ORDERING_BUILDER,title:"Organize Columns",icon:Ml}),n&&S.push({type:Ie.CONDITIONAL_FORMATTING,title:"Conditional Formatting",icon:Oo}),t&&S.push({type:Ie.CUSTOM_COLUMN_BUILDER,title:"Custom Columns",icon:sg}),s&&S.push({type:Ie.ROLLUP_ROWS,title:"Rollup Rows",icon:Oh}),i&&S.push({type:Ie.AGGREGATIONS,title:"Aggregate Columns",icon:ig}),o&&S.push({type:Ie.SELECT_DISTINCT,title:"Select Distinct Values",icon:og}),a&&p&&S.push({type:Ie.TABLE_EXPORTER,title:"Download CSV",icon:ag}),f&&S.push({type:Ie.ADVANCED_SETTINGS,title:"Advanced Settings",icon:rg}),S.push({type:Ie.QUICK_FILTERS,title:"Quick Filters",subtitle:r.shortcut.getDisplayText(),icon:xa,isOn:u,onChange:r.action}),g&&S.push({type:Ie.SEARCH_BAR,title:"Search Bar",subtitle:c.shortcut.getDisplayText(),icon:xh,isOn:m,onChange:c.action}),S.push({type:Ie.GOTO,title:"Go to",subtitle:h.shortcut.getDisplayText(),icon:lg,isOn:C,onChange:h.action}),Object.freeze(S)},{max:1});getCachedHiddenColumns=pe((e,t)=>be.getHiddenColumns(new Map([...e.initialColumnWidths,...t])),{max:1});getAggregationMap=pe((e,t)=>{const n={};return t.forEach(({operation:s,selected:i,invert:o})=>{n[s]=Rs.getOperationColumnNames(e,s,i,o)}),n});getOperationMap=pe((e,t)=>{const n={};return t.filter(s=>!Rs.isRollupOperation(s.operation)).forEach(({operation:s,selected:i,invert:o})=>{Rs.getOperationColumnNames(e,s,i,o).forEach(a=>{const r=[...n[a]??[],s];n[a]=Object.freeze(r)})}),n});getOperationOrder=pe(e=>e.map(t=>t.operation).filter(t=>!Rs.isRollupOperation(t)));getCachedFormatColumns=pe((e,t)=>Mv(e,t));getCachedModelColumns=pe((e,t)=>e.columns);getCachedPreviewFormatColumns=pe((e,t,n,s)=>{if(ge.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=pe((e,t,n)=>be.getModelRollupConfig(e,t,n));getModelTotalsConfig=pe((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=pe((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=pe((e,t,n,s,i)=>[...e??[],...s??[],...be.getFiltersFromFilterMap(t),...be.getFiltersFromFilterMap(n),...i!==void 0?[i]:[]],{max:1});getCachedTheme=pe((e,t,n)=>({...jc,...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(R.isDateType(s.columns[i].type)){const{formatter:r}=s;return x.i18n.DateTimeFormat.format(My,a,x.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 B.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:p,type:g})=>p===c&&g===h);m>=0?(r=o.delete(m)||r,r=this.applyQuickFilter(m,u,a)||r):ge.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 ge.debug2("Ignoring change to existing filter"),!1}return n.set(e,{text:t,filter:Kn.makeQuickFilter(o,t,i.timeZone)}),!0}return n.delete(e)}setAdvancedFilterMap(e){this.setState({advancedFilters:e})}setAdvancedFilter(e,t,n){ge.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){ge.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){ge.debug("setFilterMap",e);const{advancedSettings:t}=this.props;(t.get(Vi.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,Kn.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(){ge.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(){ge.debug("Clearing cross-column search"),this.setState({searchValue:"",searchFilter:void 0})}clearGridInputField(){this.filterInputRef.current!=null&&this.filterInputRef.current.setValue("")}rebuildFilters(){ge.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=R.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:Kn.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=Jn.getColumnFormats(e),s=Jn.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=pe((e,t,n,s,i,o)=>{const a=[];for(let c=0;c<s;c+=1)a.push(t[B.getModelIndex(c,n)].name);for(let c=0;c<i;c+=1)a.push(t[B.getModelIndex(t.length-1-c,n)].name);if(o)for(let c=o[0];c<=o[1];c+=1)a.push(t[B.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 Zt(i,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions,this.truncateNumbersWithPound);ge.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=ca.createSearchFilter(a,h,s.columns,c);if(e){const m=t.filter(p=>p.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 ge.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(x.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));$i(i).catch(o=>ge.error("Unable to copy cell",o))}else ge.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 ge.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})},Kn.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){ge.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 ge.debug("remove all sorts, filters, and custom columns"),this.setState({advancedFilters:new Map,aggregationSettings:zc,customColumns:[],quickFilters:new Map,reverseType:R.REVERSE_TYPE.NONE,rollupConfig:void 0,selectDistinctColumns:[],sorts:[]})}canRollback(){return this.lastLoadedConfig!=null||!Kc(this.state)}startListening(e){e.addEventListener(Ce.EVENT.UPDATED,this.handleUpdate),e.addEventListener(Ce.EVENT.REQUEST_FAILED,this.handleRequestFailed),e.addEventListener(Ce.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),e.addEventListener(Ce.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}stopListening(e){e.removeEventListener(Ce.EVENT.UPDATED,this.handleUpdate),e.removeEventListener(Ce.EVENT.REQUEST_FAILED,this.handleRequestFailed),e.removeEventListener(Ce.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),e.removeEventListener(Ce.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=B.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(B.getModelIndex(e,n),0),this.grid?.forceUpdate()}freezeColumnByColumnName(e){const{frozenColumns:t,movedColumns:n}=this.state,{model:s}=this.props;ge.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=B.getVisibleIndex(o,n),r=B.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;ge.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=B.getVisibleIndex(o,n),r=B.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=_(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=ca.createSearchFilter(e,t,n,s);this.setState({searchFilter:i})},Dy);handleAnimationLoop(){this.grid?.updateCanvas(),this.isAnimating&&(this.animationFrame=requestAnimationFrame(this.handleAnimationLoop))}handleAnimationStart(){ge.debug2("handleAnimationStart"),this.isAnimating=!0,this.animationFrame=requestAnimationFrame(this.handleAnimationLoop)}handleAnimationEnd(){ge.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;ge.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){ge.info("Toggling sort for column",e);const{model:n}=this.props,{sorts:s}=this.state,i=this.getModelColumn(e);M(i);const o=R.toggleSortForColumn(s,n.columns,i,t);this.updateSorts(o)}updateSorts(e){this.startLoading("Sorting..."),this.setState({sorts:e}),this.grid?.forceUpdate()}sortColumn(e,t=R.sortDirection.none,n=!1,s=!1){M(e);const{model:i}=this.props,o=R.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&&R.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===x.SearchDisplayMode?.SEARCH_DISPLAY_HIDE?!1:n===x.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 Ni("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),p=n.textForCell(r,t),g=this.getVisibleColumn(r),C=ze(n)&&n.isRowExpandable(t),f=i.find(S=>S.name===h)!=null;o[h]={value:m,text:p,type:u,isGrouped:f,isExpandable:C,visibleIndex:g}}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=R.getSortForColumn(s.sort,o);let r=null;(a==null||a.direction!==t)&&(t===R.sortDirection.descending?r=e.sort().desc():r=e.sort().asc());const c=R.setSortForColumn(s.sort,o,r,n);ge.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){ge.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=R.getNormalizedType(s.type);M(a);const r=Zt.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(ge.error("request failed:",t.detail),this.stopLoading(),this.canRollback())this.startLoading("Rolling back changes...",!0),this.rollback();else{ge.error("Table failed and unable to rollback");const{onError:n}=this.props;n(new Error(`Error displaying table: ${t.detail}`))}}handleUpdate(){this.stopLoading(),ge.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};Kc(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){ge.debug("Updated conditional formats",e),this.setState({conditionalFormats:e})}handleConditionalFormatCreate(){ge.debug("Create new conditional format");const{openOptions:e,conditionalFormats:t}=this.state;this.setState({openOptions:[...e,{type:Ie.CONDITIONAL_FORMATTING_EDIT,title:"Create Formatting Rule"}],conditionalFormatEditIndex:t.length,conditionalFormatPreview:void 0})}handleConditionalFormatEdit(e){ge.debug("Edit conditional format",e);const{openOptions:t,conditionalFormats:n}=this.state;this.setState({openOptions:[...t,{type:Ie.CONDITIONAL_FORMATTING_EDIT,title:"Edit Formatting Rule"}],conditionalFormatEditIndex:e,conditionalFormatPreview:{...n[e]}})}handleConditionalFormatEditorUpdate=Ye(e=>{this.setState({conditionalFormatPreview:e})},Ny);handleConditionalFormatEditorSave(e){ge.debug("Save conditional format changes",e),this.setState(t=>{if(t.conditionalFormatEditIndex===null)return ge.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){ge.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),p=be.removeFiltersInColumns(r,o,h),g=be.removeColumnFromMovedColumns(r,n,h),C=be.removeColumnsFromSelectDistinctColumns(a,h);u.length!==s.length&&(ge.debug("removing sorts from removed custom columns..."),this.setState({sorts:u})),(m.size!==i.size||p.size!==o.size)&&(ge.debug("removing filters from removed custom columns..."),this.setState({quickFilters:m,advancedFilters:p})),it(n,g)||(ge.debug("change moved columns for removed custom columns",g),this.setState({movedColumns:g})),it(a,C)||(ge.debug("change selectDistinct columns for removed custom columns",g),this.setState({selectDistinctColumns:C}))}this.setState({customColumns:e}),e.length>0&&this.startLoading("Applying custom columns...")}handleCustomColumnsChanged(){ge.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(){ge.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){ge.debug("handleAggregationsChange",e),this.startLoading(`Aggregating ${e.aggregations.map(t=>t.operation).join(", ")}...`),this.setState({aggregationSettings:e})}handleAggregationChange(e){ge.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){ge.debug("handleAggregationEdit",e);const{openOptions:t}=this.state;this.setState({openOptions:[...t,{type:Ie.AGGREGATION_EDIT,title:`Edit Columns to ${e.operation}`}],selectedAggregation:e})}handleRollupChange(e){ge.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:R.REVERSE_TYPE.NONE,selectDistinctColumns:[]})}handleSelectDistinctChanged(e){ge.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:R.REVERSE_TYPE.NONE})}handleDownloadTableStart(){const{canDownloadCsv:e}=this.props;e?this.setState({isTableDownloading:!0,tableDownloadProgress:0,tableDownloadEstimatedTime:null,tableDownloadStatus:Ws.DOWNLOAD_STATUS.INITIATING}):ge.error("Attempted to handleDownloadTableStart for user without download CSV permission.")}handleDownloadTable(e,t,n,s,i,o,a){const{canDownloadCsv:r}=this.props;r?(ge.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:Ws.DOWNLOAD_STATUS.DOWNLOADING}))):ge.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===Y.contains,c=s===Y.eq||s===Y.eqIgnoreCase;try{const{formatter:h}=i,u=R.getNormalizedType(o.type);let m;switch(u){case R.dataType.CHAR:case R.dataType.STRING:{m=await i.seekRow(t===!0?a-1:a+1,o,x.ValueType.STRING,e,c,r,t??!1);break}case R.dataType.DATETIME:{const[p]=et.parseDateRange(e,h.timeZone);m=await i.seekRow(t===!0?a-1:a+1,o,x.ValueType.DATETIME,p,void 0,void 0,t??!1);break}case R.dataType.DECIMAL:case R.dataType.INT:{if(!R.isBigDecimalType(o.type)&&!R.isBigIntegerType(o.type)){let p=parseInt(e,10);e==="-Infinity"?p=Number.NEGATIVE_INFINITY:e==="Infinity"&&(p=Number.POSITIVE_INFINITY),m=await i.seekRow(a,o,x.ValueType.NUMBER,p,void 0,void 0,t??!1)}else m=await i.seekRow(a,o,x.ValueType.STRING,e,void 0,void 0,t??!1);break}default:m=await i.seekRow(a,o,x.ValueType.STRING,R.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=ks((e,t)=>{const{tableDownloadStatus:n}=this.state;n===Ws.DOWNLOAD_STATUS.DOWNLOADING&&this.setState({tableDownloadProgress:e,tableDownloadEstimatedTime:t})},Iy);handleDownloadCompleted(){this.setState({isTableDownloading:!1,tableDownloadProgress:100,tableDownloadStatus:Ws.DOWNLOAD_STATUS.FINISHED})}handleDownloadCanceled(){this.setState({isTableDownloading:!1,tableDownloadProgress:0,tableDownloadStatus:Ws.DOWNLOAD_STATUS.CANCELED})}deleteRanges(e){const{model:t}=this.props;this.pending.add(t.delete(e)).catch(n=>{ve.isCanceled(n)||ge.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+je(h+u/2,s,r-s);return{top:n.top+(c-1)*i,left:n.left+je(h+u/2,s,r-s),bottom:n.top+c*i,right:n.left+je(h+u/2,s,r-s)+1,width:1,height:i,x:m,y:n.top,toJSON:()=>{throw new Error("not implemented")}}}getOverflowButtonTooltip=pe(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=pe(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",{}),He.isMacPlatform()?"⌘":"Ctrl+","Click to expand row and all children"]})},Date.now())})});getLinkHoverTooltip=pe(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 p={position:"absolute",top:(i-1)*s,left:u,width:m,height:s,pointerEvents:"none"},g={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:p,children:l.jsx(tt,{timeout:400,interactive:!0,options:C,ref:this.handleTooltipRef,referenceObject:g,onExited:()=>{this.setState({shownColumnTooltip:null})},children:l.jsx(jT,{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)},Fy);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:p,onCreateChart:g}=this.props,{metricCalculator:C,metrics:f,isFilterBarShown:S,isSelectingPartition:v,isMenuShown:w,isReady:T,copyOperation:y,focusedFilterBarColumn:E,loadingText:I,loadingScrimProgress:F,loadingSpinnerShown:N,keyHandlers:H,mouseHandlers:P,shownColumnTooltip:O,hoverAdvancedFilter:k,shownAdvancedFilter:L,hoverSelectColumn:A,quickFilters:U,advancedFilters:j,partition:W,partitionFilters:ie,partitionTable:se,partitionColumn:G,searchFilter:K,selectDistinctColumns:te,movedColumns:oe,movedRows:de,formatter:ee,conditionalFormats:re,conditionalFormatPreview:we,conditionalFormatEditIndex:xe,sorts:Oe,reverseType:Jt,customColumns:Mt,selectedRanges:ss,isTableDownloading:Tn,tableDownloadStatus:kt,tableDownloadProgress:ye,tableDownloadEstimatedTime:ht,showSearchBar:at,searchValue:St,selectedSearchColumns:Ot,invertSearchColumns:En,aggregationSettings:en,selectedAggregation:_o,rollupConfig:_s,openOptions:tn,pendingSavePromise:is,pendingSaveError:di,pendingRowCount:qi,pendingDataErrors:ci,pendingDataMap:hi,toastMessage:jo,frozenColumns:Ho,columnHeaderGroups:os,showOverflowModal:js,overflowText:Tr,overflowButtonTooltipProps:Bo,expandCellTooltipProps:Yi,linkHoverTooltipProps:Xi,isGotoShown:Zi,gotoRow:Vo,gotoRowError:Er,gotoValueError:yr,gotoValueSelectedColumnName:xr,gotoValue:Rr}=this.state;if(!T)return null;const Hs=this.getTheme(),Ir=this.getCachedFilter(t,U,j,ie,K),Qi=C.getUserColumnWidths(),Ji=this.getCachedStateOverride(A,S,s,F,U,j,Oe,Jt,_s,w),Uo=f?f.top:0,Bs=f?f.bottomViewport:0;let eo=null,to=null;c&&(eo=f?f.left:0,to=f?f.right:0);const $o=f!=null&&f.width>0&&f.height>0,no=(_s?.columns?.length??0)>0;let Wo=null;const Dr=f?Math.min(Math.max(Kn.minDebounce,Math.round(f.rowCount/200)),Kn.maxDebounce):Kn.maxDebounce;if(S&&E!=null&&f!=null){const{gridX:Ke,gridY:yt,allColumnXs:qe,allColumnWidths:_n,width:ui}=f,as=qe.get(E),At=_n.get(E);if(as!=null&&At!=null){const xt=Ke+as,jn=yt-(Hs.filterBarHeight??0),Vs=At+1,Us=(Hs.filterBarHeight??0)-1,Zo={top:jn,left:xt,minWidth:Math.min(Vs,ui-xt),height:Us};let Hn="",mi=!0;const $s=this.getModelColumn(E);M($s);const pi=U.get($s),rs=j.get($s);pi!=null&&(Hn=pi.text,mi=pi.filter!=null);const gi=U.size!==0||j.size!==0;Wo=l.jsx(Gv,{ref:this.filterInputRef,style:Zo,className:$({error:!mi,active:Hn!==""||rs!=null,"iris-grid-has-filter":gi}),isAdvancedFilterSet:rs!=null,onAdvancedFiltersTriggered:()=>{this.setState({shownAdvancedFilter:E})},onChange:this.handleFilterBarChange,onDone:this.handleFilterBarDone,onTab:this.handleFilterBarTab,onContextMenu:this.grid?.handleContextMenu,debounceMs:Dr,value:Hn},E)}}let Go=null;if(I!=null){const Ke=l.jsxs("div",{className:"iris-grid-loading-status",children:[l.jsx("div",{className:$("iris-grid-loading-status-bar",{show:N}),children:I}),l.jsxs("button",{type:"button",onClick:this.handleCancel,className:$("iris-grid-btn-cancel",{show:N}),children:[l.jsx(J,{icon:Ui,transform:"down-1"}),"Cancel"]})]}),yt=f?f.gridY:0;Go=l.jsx("div",{className:"iris-grid-loading",style:{top:yt},children:Ke})}let zo=null;O!=null&&f&&(zo=this.getColumnTooltip(O,f,a),this.tooltip?.update());const Ko=[];if(f&&S){const{gridX:Ke,gridY:yt,visibleColumns:qe,allColumnXs:_n,allColumnWidths:ui}=f,{filterBarHeight:as}=Hs;for(let At=0;At<qe.length;At+=1){const xt=qe[At],jn=_n.get(xt),Vs=ui.get(xt),Us=this.getModelColumn(xt);if(Us!=null&&a.isFilterable(Us)&&jn!=null&&Vs!=null&&Vs>0){const Hn=Ke+jn+Vs-24,$s={position:"absolute",top:yt-(as??0)+2,left:Hn},rs=j.get(Us)!=null,gi=xt===k||xt===E||rs,Nr=l.jsx("div",{className:$("advanced-filter-button-container",{hidden:!gi}),style:$s,children:gi&&l.jsx(V,{kind:"ghost",className:$("btn-link-icon advanced-filter-button",{"filter-set":rs}),onClick:()=>{this.setState({shownAdvancedFilter:xt})},onContextMenu:Lm=>{this.grid?.handleContextMenu(Lm)},onMouseEnter:()=>{this.setState({hoverAdvancedFilter:xt})},onMouseLeave:()=>{this.setState({hoverAdvancedFilter:null})},children:l.jsxs("div",{className:"fa-layers",children:[l.jsx(J,{icon:Il,className:"filter-solid"}),l.jsx(J,{icon:xa,className:"filter-light"})]})})},xt);Ko.push(Nr)}}}const qo=[];if(f){const{gridX:Ke,visibleColumns:yt,allColumnXs:qe,allColumnWidths:_n,columnHeaderHeight:ui}=f;for(let as=0;as<yt.length;as+=1){const At=yt[as],xt=qe.get(At),jn=_n.get(At);if(xt!=null&&jn!=null&&jn>0){const Vs=Ke+xt,Us=Ke+xt+jn-20,Zo=S?{position:"absolute",top:ui,left:Us,width:20,height:Hs.filterBarHeight}:{position:"absolute",top:0,left:Vs,width:jn,height:ui},Hn=this.getModelColumn(At);if(Hn!=null){const mi=a.columns[Hn],$s=j.get(Hn),{options:pi}=$s||{},rs=R.getSortForColumn(a.sort,mi.name),gi=rs?rs.direction:null,Nr=l.jsx("div",{className:"advanced-filter-menu-container",style:Zo,children:l.jsx(ri,{className:"advanced-filter-menu-popper",onEntered:this.getAdvancedMenuOpenedHandler(At),onExited:()=>{this.handleAdvancedMenuClosed(At)},isShown:L===At,interactive:!0,closeOnBlur:!0,options:{positionFixed:!0},children:this.getCachedAdvancedFilterMenuActions(a,mi,pi,gi,ee)})},At);qo.push(Nr)}}}}const Yo=this.getCachedOptionItems(g!==void 0&&a.isChartBuilderAvailable,a.isCustomColumnsAvailable,a.isFormatColumnsAvailable,a.isRollupAvailable,a.isTotalsAvailable||no,a.isSelectDistinctAvailable,a.isExportAvailable,this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,S,at,p,this.isTableSearchAvailable(),Zi,u.size>0),Xo=this.getCachedHiddenColumns(C,Qi),Fr=tn.map(Ke=>{switch(Ke.type){case Ie.CHART_BUILDER:return l.jsx(eE,{model:a,onChange:this.handleChartChange,onSubmit:this.handleChartCreate},Ie.CHART_BUILDER);case Ie.VISIBILITY_ORDERING_BUILDER:return l.jsx(_E,{model:a,movedColumns:oe,hiddenColumns:Xo,columnHeaderGroups:os,onColumnVisibilityChanged:this.handleColumnVisibilityChanged,onReset:this.handleColumnVisibilityReset,onMovedColumnsChanged:this.handleMovedColumnsChanged,onColumnHeaderGroupChanged:this.handleHeaderGroupsChanged},Ie.VISIBILITY_ORDERING_BUILDER);case Ie.CONDITIONAL_FORMATTING:return l.jsx(YE,{rules:re,onChange:this.handleConditionalFormatsChange,onCreate:this.handleConditionalFormatCreate,onSelect:this.handleConditionalFormatEdit});case Ie.CONDITIONAL_FORMATTING_EDIT:return M(a.columns),M(this.handleConditionalFormatEditorUpdate),l.jsx(Ty,{columns:a.columns,rule:we,onUpdate:this.handleConditionalFormatEditorUpdate,onSave:this.handleConditionalFormatEditorSave,onCancel:this.handleConditionalFormatEditorCancel});case Ie.CUSTOM_COLUMN_BUILDER:return l.jsx(oE,{model:a,customColumns:Mt,onSave:this.handleUpdateCustomColumns,onCancel:this.handleMenuBack},Ie.CUSTOM_COLUMN_BUILDER);case Ie.ROLLUP_ROWS:return l.jsx(rE,{model:a,onChange:this.handleRollupChange,config:_s},Ie.ROLLUP_ROWS);case Ie.AGGREGATIONS:return l.jsx(WT,{settings:en,isRollup:no,onChange:this.handleAggregationsChange,onEdit:this.handleAggregationEdit});case Ie.AGGREGATION_EDIT:return _o&&l.jsx(zT,{aggregation:_o,columns:a.originalColumns,onChange:this.handleAggregationChange});case Ie.TABLE_EXPORTER:return l.jsx(Ws,{model:a,name:r,userColumnWidths:Qi,movedColumns:oe,isDownloading:Tn,tableDownloadStatus:kt,tableDownloadProgress:ye,tableDownloadEstimatedTime:ht??void 0,onDownload:this.handleDownloadTable,onDownloadStart:this.handleDownloadTableStart,onCancel:this.handleCancelDownloadTable,selectedRanges:ss},Ie.TABLE_EXPORTER);case Ie.SELECT_DISTINCT:return l.jsx(zE,{model:a,selectDistinctColumns:te,onChange:this.handleSelectDistinctChanged});case Ie.ADVANCED_SETTINGS:return l.jsx(hd,{items:u,onChange:m});default:throw Error(`Unexpected option type ${Ke.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(gt,{in:v,timeout:We.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:se&&G&&W!=null&&l.jsx($E,{table:se,getFormattedString:(Ke,yt,qe)=>a.displayString(Ke,yt,qe),columnName:G.name,partition:W,onChange:this.handlePartitionChange,onFetchAll:this.handlePartitionFetchAll,onAppend:this.handlePartitionAppend,onDone:this.handlePartitionDone})})}),l.jsx(gt,{in:at,timeout:We.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(ca,{value:St,selectedColumns:Ot,invertSelection:En,onChange:this.handleCrossColumnSearch,columns:a.columns,ref:this.crossColumnRef})})}),l.jsxs("div",{className:"grid-wrapper",ref:Ke=>{this.gridWrapper=Ke},children:[l.jsx(ws,{ref:Ke=>{this.grid=Ke},isStickyBottom:!Ze(a)||!a.isEditable,isStuckToBottom:i,isStuckToRight:o,metricCalculator:C,model:a,keyHandlers:H,mouseHandlers:P,movedColumns:oe,movedRows:de,onError:this.handleGridError,onViewChanged:this.handleViewChanged,onSelectionChanged:this.handleSelectionChanged,onMovedColumnsChanged:this.handleMovedColumnsChanged,renderer:this.renderer,stateOverride:Ji,theme:Hs}),l.jsx(Ey,{isOpen:js,text:Tr,onClose:this.handleOverflowClose}),$o&&l.jsx(MT,{model:a,modelColumns:a.columns,top:Uo,bottom:Bs,left:eo,right:to,filter:Ir,formatter:ee,sorts:Oe,reverseType:Jt,movedColumns:oe,customColumns:Mt,hiddenColumns:Xo,alwaysFetchColumns:this.getAlwaysFetchColumns(h,a.columns,oe,a.floatingLeftColumnCount,a.floatingRightColumnCount,this.grid?.state.draggingColumn?.range),formatColumns:this.getCachedPreviewFormatColumns(this.getCachedModelColumns(a,Mt),re,we,tn[tn.length-1]?.type===Ie.CONDITIONAL_FORMATTING_EDIT?xe??void 0:void 0),rollupConfig:this.getModelRollupConfig(a.originalColumns,_s,en),totalsConfig:this.getModelTotalsConfig(a.columns,_s,en),selectDistinctColumns:te,pendingRowCount:qi,pendingDataMap:hi,frozenColumns:Ho,columnHeaderGroups:os}),!w&&l.jsx("div",{className:"grid-settings-button",children:l.jsx(V,{kind:"ghost","data-testid":`btn-iris-grid-settings-button-${r}`,onClick:this.handleMenu,icon:l.jsx(J,{icon:dg,transform:"up-1"}),tooltip:"Table Options"})}),Wo,Go,Ko,zo,qo,Bo&&this.getOverflowButtonTooltip(Bo),Yi&&this.getExpandCellTooltip(Yi),Xi&&this.getLinkHoverTooltip(Xi)]}),l.jsx(Ry,{model:a,isShown:Zi,gotoRow:Vo,gotoRowError:Er,gotoValueError:yr,onGotoRowSubmit:this.handleGotoRowSelectedRowNumberSubmit,onGotoRowNumberChanged:this.handleGotoRowSelectedRowNumberChanged,onClose:this.handleGotoRowClosed,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:()=>{this.handleAnimationStart(),this.focus()},onExited:this.handleAnimationEnd,gotoValueSelectedColumnName:xr,gotoValue:Rr,onGotoValueSelectedColumnNameChanged:this.handleGotoValueSelectedColumnNameChanged,onGotoValueSelectedFilterChanged:this.handleGotoValueSelectedFilterChanged,onGotoValueChanged:this.handleGotoValueChanged,onGotoValueSubmit:this.handleGotoValueSubmitted}),l.jsx(Pv,{error:di,isSaving:is!=null,saveTooltip:`Commit (${this.commitAction.shortcut.getDisplayText()})`,discardTooltip:`Discard (${this.discardAction.shortcut.getDisplayText()})`,pendingDataErrors:ci,pendingDataMap:hi,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,onSave:this.handlePendingCommitClicked,onDiscard:this.handlePendingDiscardClicked}),l.jsx(IT,{children:jo}),l.jsx($v,{model:a,copyOperation:y??void 0,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd}),l.jsx(zn,{ref:Ke=>{this.tableSaver=Ke},getDownloadWorker:n,onDownloadCompleted:this.handleDownloadCompleted,onDownloadCanceled:this.handleDownloadCanceled,onDownloadProgressUpdate:this.handleDownloadProgressUpdate,isDownloading:kt===Ws.DOWNLOAD_STATUS.DOWNLOADING,formatter:ee})]}),l.jsx(gt,{in:w,timeout:We.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(Mf,{children:[l.jsx(Jd,{title:"Table Options",onClose:this.handleMenuClose,children:l.jsx(Gh,{onSelect:Ke=>this.handleMenuSelect(Yo[Ke]),items:Yo})}),Fr.map((Ke,yt)=>l.jsx(Jd,{title:tn[yt].title,onBack:this.handleMenuBack,onClose:this.handleMenuClose,children:Ke},tn[yt].type))]})})}),l.jsx(ae,{actions:this.contextActions})]})}}const um=Kn;class ky 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 Oy=ky,nt=Z.module("IrisGridTableModel"),Ay=150,Ly=0,Py=[];function si(d){return d.table!==void 0}class xo extends Ce{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 Zt,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(x.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.addEventListener(x.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.addEventListener(x.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.addEventListener(x.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.addEventListener(x.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable),this.applyViewport()}stopListening(){super.stopListening(),this.table.removeEventListener(x.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.removeEventListener(x.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.removeEventListener(x.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.removeEventListener(x.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.removeEventListener(x.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.removeTotalsListeners(this.totalsTable),this.closeSubscription()}addTotalsListeners(e){e.addEventListener(x.Table.EVENT_UPDATED,this.handleTotalsUpdate),e.setViewport(0,0)}removeTotalsListeners(e){e.removeEventListener(x.Table.EVENT_UPDATED,this.handleTotalsUpdate)}handleTableDisconnect(){this.dispatchEvent(new Ve(Ce.EVENT.DISCONNECT))}handleTableReconnect(){this.dispatchEvent(new Ve(Ce.EVENT.RECONNECT))}handleTableUpdate(e){this.copyViewportData(e.detail),this.dispatchEvent(new Ve(Ce.EVENT.UPDATED))}handleTotalsUpdate(e){this.copyTotalsData(e.detail),this.dispatchEvent(new Ve(Ce.EVENT.UPDATED))}handleRequestFailed(e){this.dispatchEvent(new Ve(Ce.EVENT.REQUEST_FAILED,e))}handleCustomColumnsChanged(){this.dispatchEvent(new Ve(Ce.EVENT.COLUMNS_CHANGED,{detail:this.columns}))}get rowCount(){return this.table.size+this.pendingNewRowCount+(this.totals?.operationOrder?.length??0)}get pendingDataErrors(){return this.getCachedPendingErrors(this.pendingNewDataMap,this.columns,this.inputTable?.keyColumns.length??0)}get pendingDataMap(){return this.pendingNewDataMap}set pendingDataMap(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 Ve(Ce.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 Ve(Ce.EVENT.UPDATED)))}get maxPendingDataRow(){return this.pendingNewDataMap.size>0?Math.max(...this.pendingNewDataMap.keys())+1:0}get columnCount(){return this.columns.length}get floatingBottomRowCount(){return this.totals!=null&&this.totals.showOnTop?0:this.totals?.operationOrder?.length??0}get floatingTopRowCount(){return this.totals!=null&&this.totals.showOnTop?this.totals?.operationOrder?.length??0:0}get isChartBuilderAvailable(){return!0}get isTotalsAvailable(){return this.table.getTotalsTable!=null}get isEditable(){return!this.isSaveInProgress&&this.inputTable!=null}cacheFormattedValue(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(R.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(R.isDateType(a.type)||a.name==="Date")return M(n.dateColor),n.dateColor;if(R.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 R.isNumberType(n)?"right":R.isDateType(n)||t.name==="Date"?"center":"left"}textForColumnHeader(e,t=0){const n=this.columnAtDepth(e,t);return Vr(n)?n.isNew?"":n.name:n?.name}colorForColumnHeader(e,t=0){const n=this.columnAtDepth(e,t);return Vr(n)?n.color??null:null}getColumnHeaderGroup(e,t){const n=this.columnAtDepth(e,t);if(Vr(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 p=B.getVisibleIndex(m,t);t=B.moveItem(p,u,t)},i=(h,u)=>{const m=n.get(h);if(m==null)throw new Error(`Unknown layout hint group: ${h}`);const p=m.getVisibleRange(t);t=B.moveRange(p,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(p=>{if(h.has(p))throw new Error(`Column specified in multiple layout hints: ${p}`);s(p,u),u+=1}),o.forEach(p=>{if(h.has(p))throw new Error(`Column specified in multiple layout hints: ${p}`);s(p,u),u+=1});let m=this.columnMap.size-1;a.forEach(p=>{if(h.has(p))throw new Error(`Column specified in multiple layout hints: ${p}`);s(p,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],p=this.getColumnIndexByName(m);let g;if(p!=null)g=B.getVisibleIndex(p,t);else{const C=n.get(m);if(!C)throw new Error(`Unknown column ${m} in group ${u.name}`);[,g]=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]<g?g-S.childIndexes.length+1:g+1;i(f,T),g=T+S.childIndexes.length-1}else if(v!=null){const T=B.getVisibleIndex(v,t)<g?g:g+1;s(f,T),g=T}}})}return this._movedColumns=t,t});get initialMovedColumns(){return this.getMemoizedInitialMovedColumns(this.layoutHints??void 0)}get initialMovedRows(){return Py}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??Me.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??Me.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),p=this.columns.findIndex(g=>g.name===h);m.set(p,{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 Ve(Ce.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 Ve(Ce.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 Ve(Ce.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=ks((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()},Ay);applyViewport=ks(()=>{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)},Ly,{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 p=0;p<i.length;p+=1){const g=i[p];M(g.endRow),M(g.startRow);for(let C=g.startRow;C<=g.endRow&&C<this.floatingTopRowCount;C+=1)o.add(C);g.endRow>=this.floatingTopRowCount&&g.startRow<=this.floatingTopRowCount+this.table.size&&a.push(new z(g.startColumn,Math.min(Math.max(0,g.startRow-this.floatingTopRowCount)),g.endColumn,Math.min(Math.max(0,g.endRow-this.floatingTopRowCount),this.table.size-this.floatingTopRowCount)));for(let C=Math.max(g.startRow,this.floatingTopRowCount+this.table.size);C<=g.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(p=>p.name));const u=[...o].sort();for(let p=0;p<u.length;p+=1){const g=u[p],C=c.map(f=>{const S=this.getColumnIndexByName(f.name);return M(S),n(this.valueForCell(S,g),f)});t&&C.push(this.textForRowFooter(g)),h.push(C)}if(a.length>0){const p=be.rangeSetFromRanges(a),g=await this.subscription.snapshot(p,c);h.push(...g.rows.map(C=>c.map(f=>n(C.get(f),f))))}const m=[...r].sort();for(let p=0;p<m.length;p+=1){const g=m[p],C=c.map(f=>{const S=this.getColumnIndexByName(f.name);return M(S),n(this.valueForCell(S,g),f)});t&&C.push(this.textForRowFooter(g)),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
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=qn((e,t,n,s,i)=>e.getFormattedString(t,n,s,i),{max:1e4});getCachedCustomColumnFormatFlag=qn(Jn.isCustomColumnFormatDefined,{max:1e4});getCachedViewportRowRange=fe((e,t)=>{const n=t-e,s=Math.max(0,e-n*xo.ROW_BUFFER_PAGES),i=t+n*xo.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 Oy(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=R.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],p=c.get(u);M(p);const{data:g}=p,C=new Map(g),f=R.makeValue(m.type,t,this.formatter.timeZone);f!=null?C.set(h,{value:f}):C.delete(h),C.size>0?c.set(u,{...p,data:C}):c.delete(u)}),this.pendingDataMap=c}this.dispatchEvent(new Ve(Ce.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 p={};for(let g=0;g<this.columns.length;g+=1)p[this.columns[g].name]=m[g];return n.forEach(g=>{p[g.name]=R.makeValue(g.type,t,this.formatter.timeZone)}),p}),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=R.makeValue(u.type,r,this.formatter.timeZone),p=m!=null?this.displayString(m,u.type,u.name):null;this.cachePendingValue(c,h,p);const g=this.pendingRow(h);if(g!=null){t.has(g)||t.set(g,{data:new Map});const C=t.get(g);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(g,{...C,data:S}):t.delete(g)}}),this.pendingDataMap=t,this.dispatchEvent(new Ve(Ce.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,p=u;for(let f=0;f<o.length;f+=1){const S=o[f];M(S);const v=z.rowCount([S]);if(p<v){M(S.startRow),m=S.startRow+p;break}p-=v}const g={};for(let f=0;f<this.columns.length;f+=1)g[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];g[S.name]=R.makeValue(S.type,f.text,this.formatter.timeZone)}),g});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=R.makeValue(u.type,r,this.formatter.timeZone),p=m!=null?this.displayString(m,u.type,u.name):null;this.cacheFormattedValue(c,h,p)})}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 Ve(Ce.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 p=s[m];M(p.startRow),M(p.endRow);for(let g=p.startRow;g<=p.endRow;g+=1)u.delete(g)}this.pendingNewDataMap=u,this.formattedStringData=[],this.dispatchEvent(new Ve(Ce.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new Ve(Ce.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 p=0;p<t.length;p+=1){const g=t[p],C=u[p],f=R.makeFilterRawValue(g.type,C),S=g.filter().eq(f);m.push(S)}return m.reduce((p,g)=>p?.and(g)??g)}).reduce((u,m)=>u?.or(m)??m);r.applyFilter([h]),r.close()}isValidForCell(e,t,n){try{const s=this.columns[e];return R.makeValue(s.type,n,this.formatter.timeZone),!0}catch{return!1}}}const gs=Z.module("IrisGridTableModel");class _y extends xo{userFrozenColumns;customColumnList;formatColumnList;constructor(e,t=new Zt,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(gs.debug2("set customColumns",e,this.customColumnList,e===this.customColumnList),this.customColumnList.length===0&&e.length===0){gs.debug("Ignore empty initial customColumns"),this.customColumnList=e;return}if(this.customColumnList===e){gs.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(gs.debug2("set formatColumns",e,this.formatColumnList,e===this.formatColumnList),this.formatColumnList.length===0&&e.length===0){gs.debug("Ignore empty initial formatColumns"),this.formatColumnList=e;return}if(this.formatColumnList===e){gs.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 Ve(Ce.EVENT.TABLE_CHANGED,{detail:this.table}))}set totalsConfig(e){if(gs.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 Ve(Ce.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)||(gs.error("Unable to set next totalsTable",t),this.totalsTablePromise=null,this.dispatchEvent(new Ve(Ce.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 p=s[m];M(p.startRow),M(p.endRow);for(let g=p.startRow;g<=p.endRow;g+=1)u.delete(g)}super.pendingDataMap=u,this.formattedStringData=[],this.dispatchEvent(new Ve(Ce.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new Ve(Ce.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 p=0;p<t.length;p+=1){const g=t[p],C=u[p],f=R.makeFilterRawValue(g.type,C),S=g.filter().eq(f);m.push(S)}return m.reduce((p,g)=>p?.and(g)??g)}).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 mm=_y;class jy extends xo{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 Hy=jy,fs=Z.module("IrisGridProxyModel");function qr(d,e,t){return R.isTreeTable(d)?new Hy(d,e):new mm(d,e,t)}class By extends Ce{originalModel;model;modelPromise;rollup;selectDistinct;constructor(e,t=new Zt,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){fs.debug2("handleModelEvent",e);const{detail:t,type:n}=e;this.dispatchEvent(new Ve(n,{detail:t}))}setModel(e){fs.debug("setModel",e);const t=this.model;t!==this.originalModel&&t.close(),this.model=e,this.listenerCount>0&&this.addListeners(e),this.dispatchEvent(new Ve(Ce.EVENT.COLUMNS_CHANGED,{detail:e.columns})),si(e)&&this.dispatchEvent(new Ve(Ce.EVENT.TABLE_CHANGED,{detail:e.table}))}setNextModel(e){fs.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)){fs.debug2("setNextModel cancelled");return}fs.error("Unable to set next model",t),this.modelPromise=null,this.dispatchEvent(new Ve(Ce.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(Ce.EVENT);for(let n=0;n<t.length;n+=1)e.addEventListener(t[n],this.handleModelEvent)}removeListeners(e){const t=Object.keys(Ce.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 ze(this.model)?this.model.hasExpandableRows:!1}get isExpandAllAvailable(){return ze(this.model)?this.model.isExpandAllAvailable??!1:!1}isRowExpandable=(...e)=>ze(this.model)?this.model.isRowExpandable(...e):!1;isRowExpanded=(...e)=>ze(this.model)?this.model.isRowExpanded(...e):!1;setRowExpanded=(...e)=>{if(ze(this.model))return this.model.setRowExpanded(...e);throw Error("Function setRowExpanded does not exist on IrisGridTableModel")};expandAll=()=>{if(ze(this.model))return this.model.expandAll();throw Error("Function expandAll does not exist on IrisGridTableModel")};collapseAll=()=>{if(ze(this.model))return this.model.collapseAll();throw Error("Function collapseAll does not exist on IrisGridTableModel")};depthForRow=(...e)=>ze(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(fs.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);si(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(fs.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){fs.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);si(this.originalModel)&&t.length>0&&(n=this.originalModel.table.selectDistinct(t).then(s=>qr(s,this.formatter))),this.setNextModel(n)}get table(){if(si(this.model))return this.model.table}get totalsConfig(){return this.model.totalsConfig}set totalsConfig(e){this.model.totalsConfig=e}get isFilterRequired(){return this.model.isFilterRequired}get isEditable(){return 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(R.isTreeTable(this.model))throw new Error("TreeTable has no 'export' property");return this.model.export()}valuesTable=(...e)=>this.model.valuesTable(...e);columnStatistics(e){if(R.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 Vy=By;class Uy{static async makeModel(e,t=new Zt){let n=null;return!R.isTreeTable(e)&&e.hasInputTable&&(n=await e.inputTable()),new Vy(e,t,n)}}const ud=Uy;class pl{static OPEN="ChartEvent.OPEN";static CLOSE="ChartEvent.CLOSE";static COLUMN_SELECTED="ChartEvent.COLUMN_SELECTED"}class Yt{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 Cn{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 pm=Object.freeze({OPEN:"MarkdownEvent.OPEN"});class Xe{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"}class ha{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 $y 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:ae.groups.low,action:this.handleCloseTab,disabled:s===void 0||!s}),n.push(()=>({title:"Close Tabs to Right",order:20,group:ae.groups.low,action:this.handleCloseTabsRight,disabled:this.canCloseTabsRight()})),n.push(()=>({title:"Close All",order:30,group:ae.groups.low,action:this.handleCloseTabsAll,disabled:this.canCloseAny()})),l.jsx(ae,{actions:n})}}class Wy 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=X.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(V,{kind:"secondary",className:"mr-2",onClick:this.handleRenameCancel,children:"Cancel"}),l.jsx(V,{kind:"primary",type:"submit",children:"Rename"})]})]})}render(){const{isShown:e,onCancel:t}=this.props;return l.jsx(ri,{isShown:e,onEntered:this.handleRenameDialogOpened,onExited:t,options:{placement:"bottom"},interactive:!0,closeOnBlur:!0,children:this.renderRenameDialog()})}}const Gy=Z.module("Panel");class ns 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:q.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(Yt.SESSION_CLOSED,this.handleSessionClosed),n.on(Yt.SESSION_OPENED,this.handleSessionOpened),n.on(ha.focus,this.handleTabFocus),n.on(ha.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(Yt.SESSION_CLOSED,this.handleSessionClosed),n.off(Yt.SESSION_OPENED,this.handleSessionOpened),n.off(ha.focus,this.handleTabFocus),n.off(ha.blur,this.handleTabBlur),n.off(Qe.CLEAR_ALL_FILTERS,this.handleClearAllFilters),n.emit(Ee.UNMOUNT,e)}handleTab(e){e!=null&&this.setState({title:q.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=q.getRootFromContainer(t),s=q.getComponentConfigFromContainer(t);M(s),q.renameComponent(n,s,e)}handleCopyPanel(){const{glContainer:e,glEventHub:t}=this.props,n=q.getRootFromContainer(e),s=q.getComponentConfigFromContainer(e);if(s==null){Gy.error("Could not get component config from container",e);return}const i=q.cloneComponent(n,s);i!==null&&t.emit(Ee.CLONED,this,i)}getCloneAction(){return{title:"Copy Panel",order:10,group:ae.groups.high,action:this.handleCopyPanel}}getRenameAction(){return{title:"Rename",order:10,group:ae.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:p}=this.state;return l.jsxs("div",{className:$("h-100 w-100 iris-panel",t),onFocusCapture:this.handleFocus,onBlurCapture:this.handleBlur,children:[e,l.jsx(Ja,{errorMessage:o,isLoaded:a,isLoading:r}),u!=null&&Pi.createPortal(l.jsxs(l.Fragment,{children:[l.jsx($y,{glContainer:s,additionalActions:this.getAdditionActions(i,c,h)}),h&&l.jsx(Wy,{isShown:m,value:p,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 wr(d){const{widgetType:e,widgetName:t,glContainer:n,description:s,children:i}=d,o=q.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(ar,{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]})}wr.propTypes={glContainer:ed.Container.isRequired,widgetType:D.string,widgetName:D.string,description:D.string,children:D.node};wr.defaultProps={widgetType:"",widgetName:"",description:null,children:null};class md 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;$i(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
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(wr,{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:p,widgetName:g,description:C,onClearAllFilters:f,onHide:S,onFocus:v,onBlur:w,onResize:T,onShow:y,onTabBlur:E,onTabFocus:I,onTabClicked:F}=this.props,{isPanelDisconnected:N,isWidgetDisconnected:H,isPanelInactive:P}=this.state,O=this.getErrorMessage(),k=m??this.getCachedRenderTabTooltip(u,o,p,g,C),L=[{title:`Copy ${p} Name`,group:ae.groups.medium,order:20,action:this.handleCopyName}];return l.jsxs(ns,{className:$(t,{disconnected:N||H||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:I,onTabClicked:F,renderTabTooltip:k,errorMessage:O,isLoaded:s,isLoading:i,isClonable:c,isRenamable:h,additionalActions:L,children:[e,P&&l.jsx("div",{className:"fill-parent-absolute"})]})}}const jt=Object.freeze({DEFAULT:"DEFAULT",LINKER:"LINKER"}),zy="SET_SESSION_WRAPPER",Ky=Ls(zy,null),qy={sessionWrapper:Ky},Yy=new Map,vr=Object.freeze([]),gm=(d,e)=>Vt(d,e).columns??vr,Xy=(d,e)=>Vt(d,e).filterSets??vr,pd=(d,e)=>Vt(d,e).filters??vr,gd=(d,e)=>Vt(d,e).tableMap??Yy,fd=(d,e)=>Vt(d,e).isolatedLinkerPanelId,Ki=(d,e)=>Vt(d,e).links??vr,Cd=(d,e)=>Vt(d,e).columnSelectionValidator,Zy=(d,e)=>Vt(d,e).connection,ai=(d,e)=>Vt(d,e).sessionWrapper,Qy=(d,e)=>t=>t(Pn(d,{connection:e})),Jy=(d,e)=>t=>t(Pn(d,{sessionWrapper:e})),Sd=(d,e)=>t=>t(Pn(d,{links:e})),ex=(d,e)=>(t,n)=>{const s=Ki(n(),d),i=e.filter(o=>s.findIndex(a=>it(a.start,o.start)&&it(a.end,o.end))<0);return t(Sd(d,s.concat(i)))},tx=(d,e)=>(t,n)=>{const i=Ki(n(),d).filter(o=>!e.includes(o.id));return t(Sd(d,i))},fm=(d,e)=>t=>t(Pn(d,{isolatedLinkerPanelId:e})),nx=(d,e)=>t=>t(Pn(d,{columnSelectionValidator:e})),sx=(d,e)=>t=>t(Pn(d,{consoleSettings:e})),ix=(d,e)=>t=>t(Pn(d,{filterSets:e}));Object.entries(qy).map(([d,e])=>Gi.register(d,e));function Cm({columnMap:d,inputFilterMap:e,linkedColumnMap:t,onAdd:n,onOpenLinker:s,waitingFilterMap:i,waitingInputMap:o}){const a=b.useMemo(()=>{const p=Array.from(o.keys()),g=p.find(S=>e.get(S)!=null),C=p.find(S=>t.get(S)!=null),f=Wt.join(p.map(S=>`"${S}"`));return g!=null&&g&&C!=null&&C?`Use a filter control or linked table to set a value for ${f}`:g!=null&&g?`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(p=>{p.stopPropagation(),p.preventDefault(),n(Array.from(i.values()))},[n,i]),h=b.useCallback(p=>{p.stopPropagation(),p.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(p=>{const g=i.has(p.name),C=g?Ms:Rl;return l.jsxs("div",{className:$("waiting-filter-item",{"is-invalid":g}),children:[l.jsx(J,{icon:C}),p.name]},p.name)})}),l.jsxs("div",{children:[l.jsx(Ud,{onClick:c,className:"btn-primary",children:"Add Input Filters"}),l.jsx(Ud,{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})]})]})})}Cm.propTypes={columnMap:D.instanceOf(Map).isRequired,inputFilterMap:D.instanceOf(Map).isRequired,linkedColumnMap:D.instanceOf(Map).isRequired,onAdd:D.func.isRequired,onOpenLinker:D.func.isRequired,waitingFilterMap:D.instanceOf(Map).isRequired,waitingInputMap:D.instanceOf(Map).isRequired};function Ro({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(zh,{className:$("btn-chart-column-selector",Ro.makeButtonClassName(s.name)),onClick:()=>e(s.name),onMouseEnter:()=>{t&&t(s)},onMouseLeave:n,disabled:!s.isValid,isLinked:s.isActive,children:s.name},s.name))})]})})}Ro.makeButtonClassName=d=>`btn-chart-column-selector-${d}`;Ro.defaultProps={onMouseEnter:()=>{},onMouseLeave:()=>{}};const $t=Z.module("ChartPanel"),ox=150;function va(d){return d.settings!==void 0}function ax(d){return d.inputFilters!=null}function rx(d){return d.panelState!=null}class lx 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),ox),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.panelContainer=X.createRef(),this.chart=X.createRef(),this.pending=new ts;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&&va(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&&wc(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=q.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){$t.debug("startListeningToSource",e),e.addEventListener(x.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleSourceColumnChange),e.addEventListener(x.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.addEventListener(x.Table.EVENT_SORTCHANGED,this.handleSourceSortChange)}stopListeningToSource(e){$t.debug("stopListeningToSource",e),e.removeEventListener(x.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleSourceColumnChange),e.removeEventListener(x.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.removeEventListener(x.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(pl.COLUMN_SELECTED,this,n.get(e))}handleColumnMouseEnter({type:e,name:t}){const{columnSelectionValidator:n}=this.props;$t.debug("handleColumnMouseEnter",n,e,t),n&&n(this,{type:e,name:t})}handleColumnMouseLeave(){const{columnSelectionValidator:e}=this.props;$t.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(jt.LINKER)}handleReconnect(){this.setState({isDisconnected:!1,error:void 0}),this.sendColumnChange(),this.updateColumnFilters()}handleLoadSuccess(e){$t.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)||($t.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){$t.debug2("updateModelFromSource ignoring",n,s,t);return}if(this.pending.cancel(),va(e)){const{settings:i}=e;this.pending.add(x.plot.Figure.create(Je.makeFigureSettings(i,t))).then(o=>{wc(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&&ax(e.props)&&rx(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 $t.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=Ro.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){$t.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 $t.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 p=i.get(c);p!==m&&p!=null&&(a=!0,o.set(c,p))}else a=!0,o.delete(c)}}return $t.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=Wt.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),$t.debug2("updateFilters filters set",t),this.setState({isLoading:!0})}else $t.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:p,isDisconnected:g,isLoaded:C,isLoading:f}=this.state;let S;va(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,I=T.size>0,F=c.size>0&&i;return l.jsx(md,{className:$("iris-chart-panel",{"input-required":I}),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:g,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(PS,{isActive:p,model:m,settings:r,ref:this.chart,onDisconnect:this.handleDisconnect,onReconnect:this.handleReconnect,onUpdate:this.handleUpdate,onError:this.handleError,onSettingsChanged:this.handleSettingsChanged})}),l.jsx(gt,{in:I&&!F&&!f,timeout:We.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:l.jsx(Cm,{inputFilterMap:v,linkedColumnMap:w,onAdd:this.handleFilterAdd,onOpenLinker:this.handleOpenLinker,columnMap:c,waitingFilterMap:y,waitingInputMap:T})}),l.jsx(gt,{in:F,timeout:We.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:l.jsx(Ro,{columns:this.getSelectorColumns(c,w,e),onColumnSelected:this.handleColumnSelected,onMouseEnter:this.handleColumnMouseEnter,onMouseLeave:this.handleColumnMouseLeave})})]})})}}const dx=(d,e)=>{const{localDashboardId:t,metadata:n}=e;let s;n!=null&&(s=n.sourcePanelId);const i=gd(d,t),o=Gu(d,t),a=cr(d),r=fd(d,t),c=a===jt.LINKER&&r===void 0;return{columnSelectionValidator:Cd(d,t),isLinkerActive:c,inputFilters:pd(d,t),links:Ki(d,t),source:s!=null?i.get(s):void 0,sourcePanel:s!=null?o.get(s):void 0,settings:Ct(d)}},ki=ft(dx,{setActiveTool:ur,setDashboardIsolatedLinkerPanelId:fm},null,{forwardRef:!0})(lx);const ua=Z.module("CommandHistoryPanel");class bd extends b.Component{static COMPONENT="CommandHistoryPanel";static TITLE="Command History";static handleError(e){ua.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=X.createRef(),this.pending=new ts;const{session:t,sessionId:n,language:s}=e;this.state={panelState:{},session:t,sessionId:n,language:s,contextActions:[{action:this.handleFocusHistory,shortcut:Nt.COMMAND_HISTORY.FOCUS_HISTORY}]}}componentDidMount(){const{glEventHub:e,session:t}=this.props;e.on(Yt.FOCUS_HISTORY,this.handleFocusHistory),t!=null&&this.loadTable()}componentWillUnmount(){const{glEventHub:e}=this.props;e.off(Yt.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(ua.debug("handleSendToNotebook",n,e),!n){ua.error("Session is not connected.");return}const{glEventHub:i}=this.props;i.emit(t?Xe.CREATE_NOTEBOOK:Xe.SEND_TO_NOTEBOOK,n,s,e)}handleSendToConsole(e,t=!0,n=!1){ua.debug("handleSendToConsole",e);const{glEventHub:s}=this.props;s.emit(Yt.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(bd.handleError)}render(){const{glContainer:e,glEventHub:t,commandHistoryStorage:n}=this.props,{language:s,contextActions:i,table:o}=this.state;return l.jsxs(ns,{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(cS,{ref:this.container,language:s,sendToNotebook:this.handleSendToNotebook,sendToConsole:this.handleSendToConsole,table:o,commandHistoryStorage:n}),l.jsx(ae,{actions:i})]})]})}}const cx=(d,e)=>{const t=ou(d),n=ai(d,e.localDashboardId),{session:s,config:i}=n??{},{type:o,id:a}=i??{};return{commandHistoryStorage:t,language:o,session:s,sessionId:a}},$a=ft(cx,null,null,{forwardRef:!0})(bd);const ma=Z.module("ConsolePanel"),hx=500,ux=Object.freeze({consoleSettings:{},itemIds:[]});class mx 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=X.createRef();const{panelState:t}=e,n={...ux,...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=>{ma.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=Pe.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(Yt.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;ma.debug("handleSettingsChange",e),this.setState({consoleSettings:e}),t.emit(Yt.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};ma.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]};ma.debug("Saving panel state",n),this.setState({panelState:n})},hx);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:p,type:g}=h;return l.jsx(ns,{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(ZC,{ref:this.consoleRef,settings:a,session:u,focusCommandHistory:this.handleFocusCommandHistory,openObject:this.handleOpenObject,closeObject:this.handleCloseObject,commandHistoryStorage:e,onSettingsChange:this.handleSettingsChange,language:g,statusBarChildren:l.jsxs(l.Fragment,{children:[l.jsx("div",{children:" "}),l.jsx("div",{children:qh.LANGUAGE_MAP.get(g)}),l.jsx("div",{children:" "}),l.jsx("div",{children:l.jsx(_S,{connection:m,defaultUpdateInterval:10*1e3,hoverUpdateInterval:3*1e3,monitorDuration:10*60*1e3})}),l.jsx("div",{children:" "})]}),scope:p,timeZone:i,objectMap:c,unzip:o})})}}const px=(d,e)=>({commandHistoryStorage:ou(d),sessionWrapper:ai(d,e.localDashboardId),timeZone:Ao(d)}),Ii=ft(px,null,null,{forwardRef:!0})(mx);const pa=Z.module("DropdownFilter"),gx=150;class Oi 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=X.createRef();const{column:t,isValueShown:n,value:s}=e;this.state={column:t,id:Pe(),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&&R.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:Oi.PLACEHOLDER},"-1"),...e.map((t,n)=>l.jsx("option",{value:n,children:t??"(null)"},`${n}/${t}`))]);getItemLabel=pe((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(pa.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(),pa.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]:pa.debug2("Selected default item"),pa.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})},gx);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:p,isValueShown:g,selectedColumn:C,value:f}=this.state,S=i===null,v=this.getCompatibleColumns(i,e),w=i!=null,T=i?.columnName??Oi.SOURCE_BUTTON_PLACEHOLDER,y=u!=null?`${u.name} Filter`:null,[E,I]=this.getColumnOptions(v,C),F=this.getValueOptions(c),N=this.getSelectedOptionIndex(c,f),H=!w||C==null,P=g&&!n,O=`source-column-btn-${p}`,k=`filter-column-select-${p}`;return l.jsxs(Ol,{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:O,children:"Source Column"}),l.jsx(zh,{id:O,isLinked:w,onClick:o,onMouseEnter:a,onMouseLeave:r,className:Oi.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:k,children:"Filter Column"}),l.jsx("select",{id:k,value:I,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(V,{kind:"secondary",type:"button",onClick:this.handleSettingsCancel,disabled:m||g||n,tooltip:n?"Cancel disabled while linker open":void 0,children:"Cancel"}),l.jsx(V,{kind:"primary",type:"button",className:"ml-2",onClick:this.handleSettingsSave,disabled:H||g||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(V,{kind:"ghost",className:"m-2 px-2",onClick:this.handleSettingsClick,icon:l.jsx(J,{icon:ko,transform:"grow-4"}),tooltip:"Dropdown Filter Settings"})})]})})]})}}const st=Z.module("DropdownFilterPanel"),fx=250,Cx=(d,e)=>{const{localDashboardId:t}=e,n=q.getIdFromPanel({props:e}),s=gd(d,t),i=Ki(d,t),o=cr(d),a=fd(d,t),r=o===jt.LINKER&&(a===void 0||a===n),c=o===jt.LINKER&&a!==void 0&&a!==n;return{columns:gm(d,t),columnSelectionValidator:Cd(d,t),isLinkerActive:r,disableLinking:c,settings:Ct(d),panelTableMap:s,dashboardLinks:i}},Sx=ft(Cx,null,null,{forwardRef:!0});class Es extends b.Component{static displayName="DropdownFilterPanel";static COMPONENT="DropdownFilterPanel";static MAX_TABLE_SIZE=256;static DATETIME_FORMATTER=new _e({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),fx),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=X.createRef(),this.panelContainer=X.createRef(),this.pending=new ts;const{panelState:t,settings:n}=e;this.columnFormats=Jn.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 Zt(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=pe((e,{type:t,name:n},s)=>t!==void 0&&R.isDateType(t)?e.map(i=>Es.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(`.${Oi.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>Es.MAX_TABLE_SIZE)return`Table too large, must have fewer than ${Es.MAX_TABLE_SIZE} options.`}getPanelErrorMessage(){const{error:e}=this.state;return e!=null?`${e}`:void 0}getCachedPanelLinks=pe((e,t)=>{const n=q.getIdFromPanel(t);return st.debug("getCachedPanelLinks",e,n),e.filter(s=>s.end?.panelId===n)});getCachedSource=pe(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=pe((e,t)=>{if(st.debug("getCachedSourceTable",e,t),t==null)return null;const{panelId:n}=t;return e.get(n)??null});getCachedSourceColumn=pe((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(x.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.addEventListener(x.Table.EVENT_SORTCHANGED,this.handleSourceSortChange),e.addEventListener(x.Table.EVENT_SIZECHANGED,this.handleSourceSizeChange),e.addEventListener(x.Table.EVENT_DISCONNECT,this.handleDisconnect),e.addEventListener(x.Table.EVENT_RECONNECT,this.handleReconnect)}stopListeningToSource(e){st.debug("stopListeningToSource"),e.removeEventListener(x.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.removeEventListener(x.Table.EVENT_SORTCHANGED,this.handleSourceSortChange),e.removeEventListener(x.Table.EVENT_SIZECHANGED,this.handleSourceSizeChange),e.removeEventListener(x.Table.EVENT_DISCONNECT,this.handleDisconnect),e.removeEventListener(x.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,Es.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(x.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,Es.MAX_TABLE_SIZE-1,[n])}updateFormatterSettings(e){const t=Jn.getColumnFormats(e);it(this.columnFormats,t)||(this.columnFormats=t,this.setState({formatter:new Zt(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,Es.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:p,isLoading:g,isLoaded:C}=this.state,f=this.getSource(t),S=this.getSettingsErrorMessage(),v=this.getPanelErrorMessage(),w=C&&p!=null?this.getCachedValues(m,p,r):[];return l.jsx(md,{errorMessage:v,isLoading:g,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(Oi,{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 ii=Sx(Es);function On(d){return d.type==="directory"}var Sm=(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))(Sm||{});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 Ni("Name cannot be empty");if(t.includes(e))throw new Ni(`"${e}" is a reserved name`);if(n.test(e))throw new Ni(`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 It=Z.module("FileList"),gl=d=>On(d)?he.makePath(d.filename):he.getPath(d.filename),wd=26,bx=500,qc="item-list-scroll-pane",fl=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,p=t?.some(E=>E.id===o.id)??!1,g=gl(o),C=n&&r?gl(r):null,f=n&&s&&On(o)&&C===g,S=n&&s&&C===g,v=n&&!s&&C===g,w=wx(o),T=he.getDepth(o.filename),y=Array(T).fill(null).map((E,I)=>l.jsx("span",{className:"file-list-depth-line"},I));return l.jsxs("div",{className:$("d-flex w-100 align-items-center","file-list-item",{"is-dragged":p,"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(J,{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})]})]})};function wx(d){if(On(d))return d.isExpanded?cg:hg;switch(he.getMimeType(d.basename)){case Sm.PYTHON:return mg;default:return ug}}function Yc(d,e){if(d.length===0||e==null)throw new Error("No items to move");const t=gl(e);if(d.some(({filename:n})=>he.getPath(n)===t))throw new Error("File already in the destination folder");if(d.some(n=>On(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 vx(d){const{isMultiSelect:e=!1,table:t,onFocusChange:n=()=>{},onMove:s,onSelect:i,onSelectionChange:o=()=>{},renderItem:a=fl,rowHeight:r=wd,overscanCount:c=Ht.DEFAULT_OVERSCAN}=d,[h,u]=b.useState(()=>({items:[],offset:0,itemCount:0})),[m,p]=b.useState({top:0,bottom:0}),[g,C]=b.useState(),[f,S]=b.useState(),[v,w]=b.useState(),[T,y]=b.useState([]),E=b.useRef(null),I=b.useRef(null),F=b.useCallback(ee=>{if(ee.length===0||h==null)return[];const re=[];for(let we=0;we<ee.length;we+=1){const xe=ee[we];for(let Oe=xe[0];Oe<=xe[1];Oe+=1)Oe>=h.offset&&Oe<h.offset+h.items.length&&re.push(h.items[Oe-h.offset])}return re},[h]),N=b.useCallback(ee=>{const re=F([[ee,ee]]);if(re.length>0)return re[0]},[F]),H=b.useCallback(()=>{const ee=ln.count(T);if(ee===0)return null;if(ee===1){const re=T[0][0],we=N(re);if(we!=null)return we.filename}return`${ee} items`},[N,T]),P=b.useCallback(ee=>{if(!(!f||!g)){It.debug("dropItems",f,"to",ee);try{const{files:re,targetPath:we}=Yc(f,g);s?.(re,we),ee!=null&&(y([[ee,ee]]),E.current?.focusItem(ee))}catch(re){It.error("Unable to complete move",re)}}},[f,g,s]),O=b.useCallback((ee,re)=>{const we=h.items[ee-h.offset];we!==void 0&&(It.debug("handleItemClick",we),i(we,re),On(we)&&t?.setExpanded(we.filename,!we.isExpanded))},[h,i,t]),k=b.useCallback((ee,re)=>{It.debug2("handleItemDragStart",ee,T);let we=T;ln.isSelected(T,ee)||(we=[[ee,ee]],y(we)),S(F(we)),E.current?.resetMouseState();const xe=document.createElement("div");xe.innerHTML=`<div class="dnd-placeholder-content">${H()}</div>`,xe.className="file-list-dnd-placeholder",document.body.appendChild(xe),re.dataTransfer.setDragImage(xe,0,0),re.dataTransfer.effectAllowed="move",w(xe)},[H,F,T]),L=b.useCallback((ee,re)=>{re.preventDefault(),It.debug2("handleItemDragOver",re),C(N(ee))},[N]),A=b.useCallback((ee,re)=>{It.debug("handleItemDragEnd",ee),v?.remove(),S(void 0),C(void 0),w(void 0)},[v]),U=b.useCallback((ee,re)=>{P(ee)},[P]),j=b.useCallback(()=>{It.debug2("handleItemDragExit"),C(void 0)},[]),W=b.useCallback(ee=>{ee.target instanceof Element&&ee.target.classList.contains(qc)&&(ee.preventDefault(),It.debug2("handleListDragOver",ee),C({type:"directory",filename:"/",basename:"/",id:"/"}))},[]),ie=b.useCallback(ee=>{ee.target instanceof Element&&ee.target.classList.contains(qc)&&(It.debug("handleListDrop"),P())},[P]),se=b.useCallback(ee=>{if(It.debug2("handleSelectionChange",ee),ee!==T){y(ee);const re=F(ee);o(re)}},[F,o,T]),G=b.useCallback(ee=>{if(It.debug2("handleFocusChange",ee),ee!=null){const[re]=F([[ee,ee]]);n(re)}else n()},[F,n]),K=b.useCallback((ee,re)=>{It.debug("handleViewportChange",ee,re),(ee!==m.top||re!==m.bottom)&&p({top:ee,bottom:re})},[m]),te=b.useMemo(()=>{if(!f||!g)return!1;try{return Yc(f,g),It.debug("handleValidateDropTarget true"),!0}catch{return It.debug("handleValidateDropTarget false"),!1}},[f,g]),{focusedPath:oe}=d;b.useEffect(()=>{oe!==void 0&&(oe==="/"?t.collapseAll():(t.setExpanded(oe,!1),t.setExpanded(oe,!0)))},[t,oe]),b.useEffect(function(){It.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(xe=>({...xe,itemName:xe.basename})),offset:we.offset,itemCount:t.size})});return()=>{re()}},[t]),b.useEffect(function(){if(g!=null&&On(g)&&g.filename!=="/"){const re=setTimeout(()=>{g.isExpanded||t?.setExpanded(g.filename,!0)},bx);return()=>clearTimeout(re)}},[g,t]);const de=b.useCallback(ee=>a({...ee,isDragInProgress:f!=null,dropTargetItem:g,draggedItems:f,isDropTargetValid:te,onDragStart:k,onDragEnd:A,onDragOver:L,onDragExit:j,onDrop:U}),[A,j,L,k,U,f,g,te,a]);return l.jsx("div",{ref:I,className:$("file-list",{"is-dragging":f!=null}),onDragOver:W,onDrop:ie,children:l.jsx(Ht,{ref:E,items:h.items,itemCount:h.itemCount,offset:h.offset,onFocusChange:G,onSelect:O,onSelectionChange:se,onViewportChange:K,selectedRanges:T,renderItem:de,rowHeight:r,isMultiSelect:e,isDragSelect:!1,isDeselectOnClick:!1})})}const Tx={name:"File Explorer",DELETE:Fe.createAndAdd({id:"FILE_EXPLORER.DELETE",name:"Delete",shortcut:[ue.DELETE],macShortcut:[ce.CMD,ue.BACKSPACE]}),RENAME:Fe.createAndAdd({id:"FILE_EXPLORER.RENAME",name:"Rename",shortcut:[ue.ENTER],macShortcut:[ue.ENTER]})},Xc={FILE_EXPLORER:Tx};const Zc=Z.module("FileListItemEditor"),Ex=()=>Promise.resolve();function yx({item:d,onCancel:e,onSubmit:t,validate:n=Ex}){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(),[]),p=b.useCallback(()=>{c.then(()=>{t(i)}).catch(S=>Zc.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 g=b.useCallback(()=>{Zc.debug2("handleBlur"),p()},[p]),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":{p();break}case"Escape":{e();break}}},[e,p]);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:g,onKeyDown:f,onChange:C,onClick:m,onDoubleClick:m,onMouseDown:m}),a&&l.jsx("div",{className:"invalid-feedback",children:`${a}`})]})}function bm(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:p=wd,validateRename:g=()=>Promise.resolve()}=d,[C,f]=b.useState(),[S,v]=b.useState([]),[w,T]=b.useState(),y=b.useCallback(j=>{v(j),u?.(j)},[u]),E=b.useCallback(j=>{T(j)},[]),I=b.useCallback(()=>{w&&o?.(w)},[w,o]),F=b.useCallback(()=>{S.length>0&&a?.(S)},[a,S]),N=b.useCallback(()=>{s?.()},[s]),H=b.useCallback(()=>{w&&i?.(he.getPath(w.filename))},[w,i]),P=b.useCallback(()=>{w&&f(w)},[w]),O=b.useCallback(()=>{f(void 0)},[]),k=b.useCallback(j=>{C&&(c?.(C,j),f(void 0))},[c,C]),L=b.useMemo(()=>{if(C)return[];const j=[];return s&&j.push({title:"New File",description:"Create new file",action:N,group:ae.groups.medium}),i&&j.push({title:"New Folder",description:"Create new folder",action:H,group:ae.groups.medium}),o&&j.push({title:"Copy",description:"Copy",action:I,group:ae.groups.low,disabled:w==null||On(w)}),a&&S.length>0&&j.push({title:"Delete",description:"Delete",shortcut:Xc.FILE_EXPLORER.DELETE,action:F,group:ae.groups.low}),c&&j.push({title:"Rename",description:"Rename",shortcut:Xc.FILE_EXPLORER.RENAME,action:P,group:ae.groups.low,disabled:w==null}),j},[I,F,N,H,P,w,o,s,i,a,c,S,C]),A=b.useCallback(j=>(M(C),g(C,j)),[C,g]),U=b.useCallback(j=>{const{item:W}=j;return C&&C.filename===W.filename?fl({...j,children:l.jsx(yx,{item:W,validate:A,onSubmit:k,onCancel:O})}):fl(j)},[O,k,C,A]);return l.jsxs("div",{className:"file-list-container",children:[m!=null&&l.jsx(vx,{onMove:r,onSelect:h,onSelectionChange:y,onFocusChange:E,renderItem:U,rowHeight:p,table:m,isMultiSelect:e,focusedPath:t}),n&&l.jsx(ae,{actions:L})]})}bm.displayName="FileListContainer";class Ta extends Ni{isExistingFile=!0;info;constructor(e){super("Name already exists"),this.info=e}}class vd extends Error{constructor(){super("No file exists at the path specified")}isFileNotFound=!0}const zs=Z.module("FileExplorer");function Td(d){const{storage:e,isMultiSelect:t=!1,focusedPath:n,onDelete:s=()=>{},onRename:i=()=>{},onSelect:o,onSelectionChange:a,rowHeight:r=wd}=d,[c,h]=b.useState([]),[u,m]=b.useState();b.useEffect(function(){let I;async function F(){zs.debug("initTable"),I=ve.makeCancelable(e.getTable(),N=>N.close());try{m(await I)}catch(N){ve.isCanceled(N)||zs.error("Unable to initialize table",N)}}return F(),()=>{I.cancel()}},[e]);const p=b.useCallback(E=>{ve.isCanceled(E)||zs.error(E)},[]),g=b.useCallback(E=>{zs.debug("handleDelete, pending confirmation",E),h(E)},[]),C=b.useCallback(()=>{zs.debug("handleDeleteConfirm",c),c.forEach(E=>e.deleteFile(On(E)?he.makePath(E.filename):E.filename)),s(c),h([])},[c,s,e]),f=b.useCallback(()=>{zs.debug("handleDeleteCancel"),h([])},[]),S=b.useCallback((E,I)=>{he.reducePaths(E.map(N=>On(N)?he.makePath(N.filename):N.filename)).forEach(N=>{const H=he.isPath(N)?`${I}${he.getBaseName(N.substring(0,N.length-1))}/`:`${I}${he.getBaseName(N)}`;e.moveFile(N,H).then(()=>{i(N,H)}).catch(p)})},[p,i,e]),v=b.useCallback((E,I)=>{let F=E.filename;const N=On(E);N&&!F.endsWith("/")&&(F=`${F}/`);let H=`${he.getParent(F)}${I}`;N&&!H.endsWith("/")&&(H=`${H}/`),zs.debug2("handleRename",F,H),e.moveFile(F,H).catch(p),i(F,H)},[p,i,e]),w=b.useCallback(async(E,I)=>{if(I===E.basename)return;he.validateName(I);const F=`${he.getPath(E.filename)}${I}`;try{const N=await e.info(F);throw new Ta(N)}catch(N){if(!(N instanceof vd))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(bm,{isMultiSelect:t,focusedPath:n,showContextMenu:!0,onMove:S,onDelete:g,onRename:v,onSelect:o,onSelectionChange:a,rowHeight:r,table:u,validateRename:w}),l.jsx(ji,{isOpen:T,headerText:y,bodyText:"You cannot undo this action.",onCancel:f,onConfirm:C,confirmButtonText:"Delete"})]})}Td.displayName="FileExplorer";const Ks=Z.module("NewItemModal");class Ai extends b.PureComponent{static propTypes={isOpen:D.bool,title:D.string.isRequired,defaultValue:D.string,type:D.oneOf(["file","directory"]).isRequired,onSubmit:D.func,onCancel:D.func,placeholder:D.string,storage:D.shape({}).isRequired,notifyOnExtensionChange:D.bool};static defaultProps={isOpen:!1,defaultValue:"/",notifyOnExtensionChange:!1,placeholder:"",onSubmit:(e,t)=>{},onCancel:()=>{}};static getValidationMessage(e){return e instanceof Ta&&e.info.type==="directory"?"Error: Cannot overwrite existing directory":`${e}`}static handleError(e){ve.isCanceled(e)||Ks.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=X.createRef();cancelableValidatePromise;cancelableExistingItemPromise;pending=new ts;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 Ta(a)}catch(a){if(!(a instanceof vd))throw a}}return t}updateValidationStatus(e,t){this.getValidationPromise(e,t).then(()=>{this.setState({validationError:void 0})}).catch(this.handleValidationError).catch(Ai.handleError)}handleModalOpened(){this.focusRenameInput()}handleModalSubmit(){this.submitModal()}handleChange(e){const{value:t}=e.target;this.setState({value:t})}handleSelect(e){if(Ks.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 Ni))throw e;Ks.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;Ks.debug("handleOverwriteConfirm",t,n),e(`${t}${n}`,!0)}handleExtensionChangeCancel(){Ks.debug("handleExtensionChangeCancel"),this.setState(({value:e,prevExtension:t})=>({showExtensionChangeModal:!1,value:he.replaceExtension(e,t)})),this.submitModal(!0)}handleExtensionChangeConfirm(){Ks.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;Ks.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 Ta&&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(Ai.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(X.Fragment,{children:[l.jsx(V,{kind:"ghost",className:"directory-breadcrumbs",onClick:()=>this.handleBreadcrumbSelect(i),"aria-label":s===0?"Home":void 0,icon:s===0?l.jsx(J,{icon:pg,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:p,newExtension:g}=this.state,C=o==="directory",f=he.fileExtensionToString(p),S=he.fileExtensionToString(g),v=C?"Create":"Save",w=C?"New folder name":"Save file as";return l.jsxs(l.Fragment,{children:[l.jsxs(Do,{isOpen:t,toggle:n,onOpened:this.handleModalOpened,className:"modal-dialog-centered new-file-modal theme-bg-dark",children:[l.jsx(Fo,{toggle:n,children:i}),l.jsx(No,{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:Ai.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(Td,{onSelect:this.handleSelect,storage:e,focusedPath:r})})]})})}),l.jsxs(kl,{children:[l.jsx(V,{kind:"secondary",onClick:n,children:"Cancel"}),l.jsx(V,{kind:"primary",disabled:a,onClick:this.handleModalSubmit,children:v})]})]}),l.jsx(ji,{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(ji,{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 xx({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(V,{kind:"ghost",icon:Fh,tooltip:"New notebook",onClick:d,"aria-label":"New notebook"}),l.jsx(V,{kind:"ghost",icon:gg,tooltip:"New folder",onClick:e,"aria-label":"New folder"})]}),t&&l.jsx("div",{className:"file-explorer-toolbar-search",children:l.jsx(If,{value:n,onChange:t,placeholder:"Search by name"})})]})}const bi=Z.module("FileExplorerPanel"),Rx=(d,e)=>{const t=au(d),n=ai(d,e.localDashboardId),{session:s,config:i}=n??{},o=i?.type;return{fileStorage:t,language:o,session:s}},Ix=ft(Rx,null,null,{forwardRef:!0});function Dx(d){const e=d;return e!=null&&typeof e.button=="number"}class Wa extends X.Component{static COMPONENT="FileExplorerPanel";static TITLE="File Explorer";static handleError(e){bi.error(e)}static isFocusEvent(e){return Dx(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:""};bi.debug("handleCreateFile",t,n,s),e.emit(Xe.CREATE_NOTEBOOK,t,n,s)}handleCreateDirectory(e){this.setState({showCreateFolder:!0})}handleCreateDirectoryCancel(){bi.debug("handleCreateDirectoryCancel"),this.setState({showCreateFolder:!1})}handleCreateDirectorySubmit(e){bi.debug("handleCreateDirectorySubmit",e),this.setState({showCreateFolder:!1});const{fileStorage:t}=this.props;t.createDirectory(e).catch(Wa.handleError)}handleDelete(e){const{glEventHub:t}=this.props;e.forEach(n=>{t.emit(Xe.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(bi.debug("fileSelect",e),e.type==="directory")return;const n=Wa.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(Xe.SELECT_NOTEBOOK,o,a,r,s,n)}handleRename(e,t){const{glEventHub:n}=this.props;bi.debug("handleRename",e,t),n.emit(Xe.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(ns,{className:"file-explorer-panel",componentPanel:this,glContainer:t,glEventHub:n,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onShow:this.handleShow,children:[l.jsx(xx,{createFile:this.handleCreateFile,createFolder:this.handleCreateDirectory}),s&&l.jsx(Td,{isMultiSelect:!0,storage:e,onDelete:this.handleDelete,onRename:this.handleRename,onSelect:this.handleFileSelect,onSelectionChange:this.handleSelectionChange}),l.jsx(Ai,{isOpen:i,type:"directory",title:"Create New Folder",storage:e,onSubmit:this.handleCreateDirectorySubmit,onCancel:this.handleCreateDirectoryCancel,defaultValue:o})]})}}const Ga=Ix(Wa);const ot=Z.module("FilterSetManager"),Fx="Enter name...",Qc="No Available Filter Sets";class za 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=X.createRef();dropdownRef=X.createRef();editDropdownRef=X.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;za.animateScreenFlash();const t=Pe(),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;za.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,p=!h&&m&&r.length===0,g=!h&&!p,C=l.jsxs("div",{className:"fa-layers mr-3",children:[l.jsx(J,{icon:_i,mask:il,transform:"shrink-1 down-5 right-7"}),l.jsx(J,{icon:Os,className:"text-primary",transform:"shrink-6 down-5 right-7"})]}),f=l.jsxs("div",{className:"fa-layers",children:[l.jsx(J,{icon:_i,mask:il,transform:"shrink-1 down-5 right-7"}),l.jsx(J,{icon:ol,transform:"shrink-1 down-5 right-7"})]});return l.jsx("div",{className:"filter-set-manager fill-parent-absolute",children:l.jsxs(Ol,{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:[p&&l.jsxs("div",{children:[l.jsx(V,{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:Fx,value:e,ref:this.renameInputRef,onChange:this.handleNameInputChange,onKeyPress:this.handleNameInputKeyPress,spellCheck:"false"}),l.jsx(V,{"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:Ah}),l.jsx(V,{"data-testid":"rename-cancel-button",kind:"ghost",className:"btn btn-link no-underline pt-2 pb-2",onClick:this.handleRenameCancel,tooltip:"Cancel",icon:fg})]}),t!==void 0&&l.jsx("div",{className:"error-message",children:t})]}),l.jsx("div",{className:"form-group",children:l.jsxs(rr,{onChange:this.handleRestoreFullStateChange,value:`${o}`,children:[l.jsx(Qn,{value:"false",children:"Restore only filters"}),l.jsx(Qn,{value:"true",children:"Restore full table state"})]})})]}),g&&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:Qc}),i.map(({id:S,title:v})=>l.jsx("option",{value:S,children:v},S))]}),l.jsx(V,{kind:"ghost",onClick:this.handleSetUpdate,disabled:m,icon:f,tooltip:"Update"}),l.jsx(V,{kind:"ghost",onClick:this.handleSetEdit,disabled:m,icon:Oo,tooltip:"Edit"}),l.jsx(V,{kind:"ghost",onClick:this.handleSetDelete,disabled:m,icon:Qt,tooltip:"Delete"})]})]}),l.jsx("div",{children:l.jsx(V,{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(V,{kind:"secondary",onClick:this.handleSettingsCancel,children:"Cancel"})," ",l.jsx(V,{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:Qc}),r.map(({id:S,title:v})=>l.jsx("option",{value:S,children:v},S))]}),l.jsx(V,{"data-testid":"filter-apply-button",kind:"ghost",onClick:this.handleFilterApply,icon:Dl,tooltip:"Apply Filter Set"})]})})}),l.jsx("div",{className:"filter-set-manager-menu",children:l.jsx(V,{kind:"ghost",className:"btn btn-link btn-link-icon m-2 px-2",onClick:this.handleSettingsClick,tooltip:"Settings",icon:l.jsx(J,{icon:ko,transform:"grow-4"})})})]},"back")]})})}}function Ed(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(wr,{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})]})})}Ed.propTypes={glContainer:ed.Container.isRequired,widgetName:D.string.isRequired,description:D.string};Ed.defaultProps={description:null};const Rn=Z.module("IrisGridPanel"),Nx=500,Mx={IrisGrid:um,IrisGridTableModel:mm,ContextMenuRoot:_h};class Cl 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=X.createRef(),this.pluginRef=X.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(nm.DEFAULTS),customColumns:[],customColumnFormatMap:new Map,isFilterBarShown:!1,quickFilters:new Map,sorts:[],userColumnWidths:new Map,userRowHeights:new Map,reverseType:R.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=q.getIdFromPanel(this);return n!=null&&(s==null||i!=null&&!s.includes(i))})));getAlwaysFetchColumns=fe((e,t)=>{const n=q.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||!si(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:Mx,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,p,g,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:p,sorts:t,invertSearchColumns:g,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();Rn.debug("initModelQueue",s),s&&s(n),this.setState({modelQueue:t})}handleAdvancedSettingsChange(e,t){Rn.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(Cn.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){Rn.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(Yt.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=q.getIdFromPanel(this);let c;a&&(c=be.extractTableSettings(a,s)),n.emit(Cn.CREATE_CHART,{metadata:{settings:e,sourcePanelId:r,table:o,tableSettings:c},table:si(t)?t.table:void 0})})}handleColumnSelected(e){const{glEventHub:t}=this.props;t.emit(Cn.COLUMN_SELECTED,this,e)}handleDataSelected(e,t){const{glEventHub:n}=this.props;n.emit(Cn.DATA_SELECTED,this,t)}handleResize(){this.updateGrid()}handleShow(){this.updateGrid()}handleTabClicked(){this.irisGrid.current&&this.irisGrid.current.focus()}handleError(e){Rn.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}),si(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){Rn.debug2("sendColumnsChange",e);const{glEventHub:t}=this.props;t.emit(Qe.COLUMNS_CHANGED,this,e)}startModelListening(e){e.addEventListener(Ce.EVENT.DISCONNECT,this.handleDisconnect),e.addEventListener(Ce.EVENT.RECONNECT,this.handleReconnect),e.addEventListener(Ce.EVENT.COLUMNS_CHANGED,this.handleColumnsChanged),e.addEventListener(Ce.EVENT.TABLE_CHANGED,this.handleTableChanged)}stopModelListening(e){e.removeEventListener(Ce.EVENT.DISCONNECT,this.handleDisconnect),e.removeEventListener(Ce.EVENT.RECONNECT,this.handleReconnect),e.removeEventListener(Ce.EVENT.COLUMNS_CHANGED,this.handleColumnsChanged),e.removeEventListener(Ce.EVENT.TABLE_CHANGED,this.handleTableChanged)}getCoordinateForColumn(e){const{model: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 p=n.getVisibleColumn(m),g=r.get(p)??0,C=c.get(p)??0,f=Math.max(i.left,Math.min(p>h?i.right:i.left+g+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}){Rn.debug("setFilters",e,t);const{model:n,isDisconnected:s}=this.state,i=this.irisGrid.current;if(i==null||s){Rn.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){Rn.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:p,advancedSettings:g}=be.hydrateIrisGridPanelState(e,a),{advancedFilters:C,customColumns:f,customColumnFormatMap:S,isFilterBarShown:v,quickFilters:w,reverseType:T,rollupConfig:y,aggregationSettings:E,sorts:I,userColumnWidths:F,userRowHeights:N,showSearchBar:H,searchValue:P,selectDistinctColumns:O,selectedSearchColumns:k,invertSearchColumns:L,pendingDataMap:A,frozenColumns:U,conditionalFormats:j,columnHeaderGroups:W}=be.hydrateIrisGridState(e,{...o,...r}),{isStuckToBottom:ie,isStuckToRight:se,movedColumns:G,movedRows:K}=be.hydrateGridState(e,{...i,...s},o.customColumns);this.setState({advancedFilters:C,advancedSettings:g,conditionalFormats:j,customColumns:f,customColumnFormatMap:S,isFilterBarShown:v,isSelectingPartition:u,movedColumns:G,movedRows:K,partition:m,partitionColumn:p,quickFilters:w,reverseType:T,rollupConfig:y,aggregationSettings:E,sorts:I,userColumnWidths:F,userRowHeights:N,showSearchBar:H,searchValue:P,selectDistinctColumns:O,selectedSearchColumns:k,invertSearchColumns:L,pendingDataMap:A,frozenColumns:U,isStuckToBottom:ie,isStuckToRight:se,columnHeaderGroups:W})}catch(i){Rn.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:p,isFilterBarShown:g,quickFilters:C,customColumns:f,reverseType:S,rollupConfig:v,showSearchBar:w,searchValue:T,selectDistinctColumns:y,selectedSearchColumns:E,sorts:I,invertSearchColumns:F,metrics:N,pendingDataMap:H,frozenColumns:P,conditionalFormats:O,columnHeaderGroups:k}=e;M(i),M(N);const{userColumnWidths:L,userRowHeights:A}=N;M(t);const{isStuckToBottom:U,isStuckToRight:j,movedColumns:W,movedRows:ie}=t,se=this.getCachedPanelState(this.getDehydratedIrisGridPanelState(i,a,r,c,h),this.getDehydratedIrisGridState(i,I,u,p,g,C,f,S,v,w,T,y,E,F,L,A,m,H,P,O,k),this.getDehydratedGridState(i,W,ie,U,j),n);se!==o&&(Rn.debug("Saving panel state",this,se),this.setState({panelState:se}),s?.(se))},Nx);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:p}=this.props,{advancedFilters:g,aggregationSettings:C,advancedSettings:f,conditionalFormats:S,customColumns:v,customColumnFormatMap:w,error:T,isDisconnected:y,isFilterBarShown:E,isSelectingPartition:I,isStuckToBottom:F,isStuckToRight:N,isLoaded:H,isLoading:P,isModelReady:O,model:k,movedColumns:L,movedRows:A,partition:U,partitionColumn:j,quickFilters:W,reverseType:ie,rollupConfig:se,sorts:G,userColumnWidths:K,userRowHeights:te,showSearchBar:oe,searchValue:de,selectDistinctColumns:ee,selectedSearchColumns:re,invertSearchColumns:we,Plugin:xe,pluginFilters:Oe,pluginFetchColumns:Jt,pendingDataMap:Mt,frozenColumns:ss,columnHeaderGroups:Tn}=this.state,kt=T!=null?`Unable to open table. ${T}`:void 0,{table:ye}=r,ht=k?.description??void 0,at=c?.pluginState??null,St=e??this.getPluginContent(xe,k,h,u,at),{permissions:Ot}=h,{canCopy:En,canDownloadCsv:en}=Ot;return l.jsx(md,{errorMessage:kt,isDisconnected:y,isLoading:P,isLoaded:H,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:ht,componentPanel:this,renderTabTooltip:()=>l.jsx(Ed,{model:k,widgetName:ye,glContainer:t,description:ht}),children:O&&k&&l.jsx(um,{advancedFilters:g,aggregationSettings:C,advancedSettings:f,alwaysFetchColumns:this.getAlwaysFetchColumns(a,Jt),columnAllowedCursor:"linker",columnNotAllowedCursor:"linker-not-allowed",customColumns:v,customColumnFormatMap:w,columnSelectionValidator:this.isColumnSelectionValid,conditionalFormats:S,inputFilters:this.getGridInputFilters(k.columns,o),applyInputFiltersOnInit:c==null,isFilterBarShown:E,isSelectingColumn:s!=null,isSelectingPartition:I,isStuckToBottom:F,isStuckToRight:N,movedColumns:L,movedRows:A,partition:U,partitionColumn:j,quickFilters:W,reverseType:ie,rollupConfig:se,settings:m,sorts:G,userColumnWidths:K,userRowHeights:te,model:k,showSearchBar:oe,searchValue:de,selectedSearchColumns:re,selectDistinctColumns:ee,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:Oe,pendingDataMap:Mt,canCopy:En,canDownloadCsv:en,ref:this.irisGrid,getDownloadWorker:i,frozenColumns:ss,theme:p,columnHeaderGroups:Tn,children:St})})}}const kx=(d,{localDashboardId:e=wn})=>({inputFilters:pd(d,e),links:Ki(d,e),columnSelectionValidator:Cd(d,e),user:iu(d),workspace:dr(d),settings:Ct(d)}),oi=ft(kx,null,null,{forwardRef:!0})(Cl);const Jc=Z.module("InputFilter"),Ox=150;class Ka 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=X.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=pe((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)];Jc.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;Jc.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})},Ox);render(){const{columns:e}=this.props,{column:t,isValueShown:n,selectedColumn:s,value:i}=this.state,o=i==null||i.length===0?Ka.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(Ol,{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(V,{kind:"secondary",onClick:this.handleSettingsCancel,disabled:t==null,children:"Cancel"}),l.jsx(V,{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:Ka.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(V,{kind:"ghost",className:"m-2 px-2",onClick:this.handleSettingsClick,icon:l.jsx(J,{icon:ko,transform:"grow-4"}),tooltip:"Input Filter Settings"})})]})]})}}const Ax=250;class Lx extends b.Component{static defaultProps={panelState:null};static COMPONENT="InputFilterPanel";static displayName="InputFilterPanel";constructor(e){super(e),this.handleChange=Ye(this.handleChange.bind(this),Ax),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.inputFilterRef=X.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(ns,{className:"iris-input-filter-panel",componentPanel:this,glContainer:e,glEventHub:t,onClearAllFilters:this.handleClearAllFilters,isClonable:!0,isRenamable:!0,children:l.jsx(Ka,{ref:this.inputFilterRef,column:n,columns:s,onChange:this.handleChange,isValueShown:i,value:o})})}}const Px=(d,e)=>{const{localDashboardId:t}=e;return{columns:gm(d,t)}},wo=ft(Px,null,null,{forwardRef:!0})(Lx);const wt=Z.module("FilterSetManagerPanel");function _x(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){wt.error("Could not get panel",s);return}const i=q.getComponentNameFromPanel(s),o=q.getIdFromPanel(s);wt.debug("Panel:",s,i);const{glContainer:a=null}=s.props;if(a==null){wt.error("Could not get panel container",s);return}const r=q.getComponentConfigFromContainer(a);if(r==null){wt.error("Could not get component config from container",a);return}const c=q.getPanelComponentState(r);if(c==null){wt.debug(`Panel state is null ${o}`);return}switch(i){case q.getComponentName(Cl):{let h;o!=null&&(h=this.getIrisGridPanelFilters(o,c)),h!=null&&t.push({panelId:o,type:i,state:h});break}case q.getComponentName(wo):case q.getComponentName(ii):{const{isValueShown:h,name:u,type:m,value:p}=c;t.push({panelId:o,type:i,state:{isValueShown:h,name:u,type:m,value:p}});break}}}),t}getIrisGridPanelFilters(e,t){const{panelTableMap:n}=this.props,s=n.get(e);if(s==null)return wt.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}){wt.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;wt.debug("Apply filters from filter set",e),n.forEach(({panelId:i,type:o,state:a})=>{if(i==null){wt.debug("panel is null",i);return}if(!t.has(i)){wt.debug("Ignore closed panel",i);return}wt.debug("Apply panel filters",i,o,a);const r=t.get(i);switch(o){case q.getComponentName(Cl):this.restoreIrisGridFilters(r,a,s);break;case q.getComponentName(wo):case q.getComponentName(ii):this.restoreInputFilterState(r,a);break}})}handleSetsUpdate(e){const{setDashboardFilterSets:t,localDashboardId:n}=this.props;wt.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=q.getIdFromPanel(e);if(h==null){wt.error("Panel Id is null.");return}if(c.get(h)==null){wt.error(`Unable to get table for panel ${h}.`);return}wt.debug("restoreIrisGridFilters",h,t,n),n?e.setStateOverrides(t):e.setFilters({quickFilters:r,advancedFilters:a})}restoreInputFilterState(e,t){const n={...t};delete n.isValueShown,wt.debug("restoreInputFilterState",e,n),e&&_x(e)&&e.setPanelState(n)}render(){const{glContainer:e,glEventHub:t,filterSets:n}=this.props,{isValueShown:s,selectedId:i}=this.state;return l.jsx(ns,{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(za,{onChange:this.handleChange,onApply:this.handleFilterApply,onUpdateSets:this.handleSetsUpdate,isValueShown:s,filterSets:n,selectedId:i,getFilterState:this.handleGetFilterState})})})}}const jx=(d,e)=>{const{localDashboardId:t}=e;return{filterSets:Xy(d,t),dashboardOpenedPanelMap:Gu(d,t),dashboardInputFilters:pd(d,t),panelTableMap:gd(d,t)}},Yr=ft(jx,{setDashboardFilterSets:ix},null,{forwardRef:!0})(qa);const eh=Z.module("LogPanel");class Hx 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){eh.debug("Session opened",[e]),this.setState({session:e})}handleSessionClosed(e){eh.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(ns,{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(mS,{session:n,ref:s=>{this.logView=s}})]})}}const Bx=(d,e)=>({session:ai(d,e.localDashboardId)?.session}),Ya=ft(Bx,null,null,{forwardRef:!0})(Hx);class Vx 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(J,{icon:Oo})]})}),t]})}}const Ux=Z.module("MarkdownStartPage");class $x 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(Ux.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(V,{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(V,{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(J,{icon:Qt})})]},o.id)),l.jsxs(Do,{isOpen:s,toggle:this.handleDeleteModalClose,className:"modal-dialog-centered markdown-delete-modal theme-bg-light",children:[l.jsx(Fo,{children:"Are you sure you want to permanently delete this note?"}),l.jsx(No,{children:"You can't undo this action."}),l.jsxs(kl,{children:[l.jsx(V,{kind:"secondary",onClick:this.handleDeleteModalClose,children:"Cancel"}),l.jsx(V,{kind:"danger",onClick:()=>{this.handleDeleteMarkdown(i)},children:"Delete"})]})]})]})]})})}}const Wx=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(lr,{language:n,children:X.Children.map(e,s=>typeof s=="string"?s.trim():s)})})})};class Gx 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(Ul,{settings:{language:"markdown",value:t,lineNumbers:"off"},onEditorInitialized:n}):l.jsx(vh,{components:{code:Wx},children:t})})}}const ga=Z.module("MarkdownPanel");class zx 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){ga.debug("Markdown Editor Initialized..."),this.editor=e}handleCreateMarkdown(){ga.debug("create markdown..."),this.setState({isStartPageShown:!1,content:"",isEditing:!0,panelState:{content:""}},()=>{this.editor!=null&&this.editor.focus!=null&&this.editor.focus()})}handleOpenMarkdown(e){ga.debug("open markdown...",e);const{glContainer:t,glEventHub:n}=this.props,s=q.getComponentConfigFromContainer(t);n.emit(Ee.REOPEN,e,s)}handleDeleteMarkdown(e){const{glEventHub:t}=this.props;t.emit(Ee.DELETE,e)}handleEditorBlur(e){ga.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(ns,{glContainer:e,glEventHub:t,className:"markdown-panel",componentPanel:this,onResize:this.handleEditorResize,onBlur:this.handleEditorBlur,isClonable:!0,isRenamable:!0,children:i?l.jsx($x,{closedMarkdowns:a,onCreate:this.handleCreateMarkdown,onOpen:this.handleOpenMarkdown,onDelete:this.handleDeleteMarkdown}):l.jsx(Vx,{isEditing:s,onDoubleClick:this.handleContainerDoubleClick,children:l.jsx(Gx,{ref:r=>{this.markdownEditor=r},isEditing:s,content:o??void 0,onEditorInitialized:this.handleEditorInitialized})})})}}const Kx=(d,e)=>{const{localDashboardId:t}=e;return{closedPanels:Ow(d,t)}},co=ft(Kx,null,null,{forwardRef:!0})(zx);class qx 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=X.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,p=X.createRef(),g=this.commands.size===0,C=a===u||g&&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,p),l.jsxs("div",{className:$("markdown-notebook-code-block",{"is-selected":C}),ref:p,onClick:()=>{this.setState({nextStartLine:u})},role:"presentation",children:[l.jsx(V,{kind:"ghost",icon:ya,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(lr,{language:f,children:X.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(V,{className:$("btn-play-selected-cell",{flashing:s&&!i}),kind:"ghost",icon:ya,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(vh,{components:{code:this.renderCodeBlock,a:this.renderLink},linkTarget:"_blank",remarkPlugins:[lp],transformLinkUri:n,transformImageUri:t,includeElementIndex:!0,children:e})})]})}}const Le=Z.module("NotebookPanel"),th=400;class Js extends b.Component{static COMPONENT="NotebookPanel";static POPPER_OPTIONS={placement:"bottom-end"};static DEFAULT_NAME="Untitled";static handleError(e){ve.isCanceled(e)||Le.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.handlePanelTabClick=this.handlePanelTabClick.bind(this),this.handleRenameFile=this.handleRenameFile.bind(this),this.handleResize=this.handleResize.bind(this),this.handleRunCommand=this.handleRunCommand.bind(this),this.handleRunAll=this.handleRunAll.bind(this),this.handleRunSelected=this.handleRunSelected.bind(this),this.handleSave=this.handleSave.bind(this),this.handleSaveAsCancel=this.handleSaveAsCancel.bind(this),this.handleSaveAsSubmit=this.handleSaveAsSubmit.bind(this),this.handleSaveError=this.handleSaveError.bind(this),this.handleSaveSuccess=this.handleSaveSuccess.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleShowRename=this.handleShowRename.bind(this),this.handleTab=this.handleTab.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTransformLinkUri=this.handleTransformLinkUri.bind(this),this.handleOverwrite=this.handleOverwrite.bind(this),this.getDropdownOverflowActions=this.getDropdownOverflowActions.bind(this),this.pending=new ts,this.debouncedSavePanelState=Ye(this.savePanelState.bind(this),th),this.debouncedLoad=Ye(this.load.bind(this),th),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:"",shouldPromptClose:!0},Le.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(Xe.RENAME_FILE,this.handleRenameFile),e.on("tabClicked",this.handlePanelTabClick)}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{glContainer:e,glEventHub:t}=this.props,{fileMetadata:n,isPreview:s}=this.state;t.off(Xe.RENAME_FILE,this.handleRenameFile),e.off("tabClicked",this.handlePanelTabClick),t.emit(Xe.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,shouldPromptClose:i}=this.state;return n!==s&&i?(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){Le.debug("Init content from file"),this.registerFileMetadata(e,n),this.load();return}if(t.value!=null){Le.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(Xe.CLOSE_FILE,{id:e})}registerFileMetadata(e,t){const{glEventHub:n,metadata:s}=this.props,{id:i}=s;n.emit(Xe.REGISTER_FILE,i,e,t)}renameTab(e,t){const{glEventHub:n}=this.props;n.emit(Xe.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=>{Le.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:Js.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){Le.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;Le.debug("setPreviewStatus",this.tabTitleElement,e),e?this.tabTitleElement.classList.add("is-preview"):this.tabTitleElement.classList.remove("is-preview")}getSettings=fe((e,t)=>({...e,minimap:{enabled:t}}));getOverflowActions=fe((e,t)=>[{title:"Find",icon:Sg,action:this.handleFind,group:ae.groups.high,shortcut:Nt.NOTEBOOK.FIND,order:10},{title:"Show Minimap",icon:e?Xn:void 0,action:this.handleMinimapChange,group:ae.groups.medium,shortcut:Nt.NOTEBOOK.MINIMAP,order:20},{title:"Word Wrap",icon:t?Xn:void 0,action:this.handleWordWrapChange,group:ae.groups.medium,shortcut:Nt.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 Le.debug("Saving panel state",u),{settings:c,panelState:u}})}handleCloseDiscard(){this.setState({shouldPromptClose:!1,showCloseModal:!1});const{glContainer:e}=this.props;e.close()}handleCloseSave(){if(this.setState({shouldPromptClose:!1,showCloseModal:!1}),this.save()){const{glContainer:e}=this.props;e.close()}}handleCloseCancel(){this.setState({shouldPromptClose:!0,showCloseModal:!1})}handleOverwrite(e){const{glEventHub:t}=this.props;t.emit(Xe.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);Le.debug("handleCopy",e,i,o),this.createNotebook(o,s,n)}handleEditorInitialized(e){this.editor=e}handleEditorWillDestroy(){this.editor=void 0}handleEditorChange(e){Le.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(){Le.debug("handleBlur"),this.setState({isFocused:!1})}handleFocus(){Le.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==="/"){Le.debug("Ignoring invalid notebook link",o);return}Le.debug("Notebook link clicked, opening",o);const{glEventHub:a}=this.props,r={value:null,language:s},c={id:o,itemName:o};a.emit(Xe.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.")),Le.error(t),this.setState({error:t,isLoading:!1}))}handleSave(){Le.debug("handleSave"),this.save()}handleSaveSuccess(e){const{fileStorage:t}=this.props,n={id:e.filename,itemName:e.filename},s=Js.languageFromFileName(e.filename)??"";this.setState(i=>{const{fileMetadata:o}=i,a={...i.settings,language:s};return Le.debug("handleSaveSuccess",n,o,a),o&&he.hasPath(o.itemName)&&o.itemName!==n.itemName&&(Le.debug("handleSaveSuccess deleting old file",o.itemName),t.deleteFile(o.itemName).catch(Js.handleError)),{fileMetadata:n,settings:a,isPreview:!1}}),this.debouncedSavePanelState(),this.registerFileMetadata(n,!1)}handleSaveError(e){ve.isCanceled(e)||(this.setState({savedChangeCount:0}),Le.error(e))}handleSaveAsCancel(){this.setState({showSaveAsModal:!1})}handleSaveAsSubmit(e,t=!1){t&&this.handleOverwrite(e),Le.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){Le.error("Editor is not initialized.");return}this.runCommand(this.notebook.getValue()??void 0)}handleRunSelected(){if(!this.notebook){Le.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(){Le.debug("handleShow"),this.notebook?.updateDimensions()}handleShowRename(){this.setState({showSaveAsModal:!0})}handleTab(e){Le.debug("NotebookPanel tab event",e),this.initTab(e)}handleTabFocus(...e){Le.debug("handleTabFocus",...e);const{glContainer:t}=this.props;this.setState({isDashboardActive:!0}),this.notebook&&!t.isHidden&&this.notebook.updateDimensions()}handleTabBlur(){Le.debug("handleTabBlur"),this.setState({isDashboardActive:!1})}handlePanelTabClick(){Le.debug("handlePanelTabClick"),this.focus()}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};Le.debug("handleCreateNotebook",i,o,r,c),s.emit(Xe.CREATE_NOTEBOOK,i,o,r,c)}runCommand(e){if(e===void 0){Le.debug("Ignoring empty command.");return}this.removePreviewStatus();const{glEventHub:t}=this.props;t.emit(Yt.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:p,session:g,sessionLanguage:C,settings:f,showCloseModal:S,showSaveAsModal:v}=this.state,w=c&&!t.isHidden&&!m,T=p?.itemName??Js.DEFAULT_NAME,y=T.endsWith(".md"),E=p?.id!=null,I=this.getSettings(f,i.isMinimapEnabled),F=g!=null,N=C===I.language,H=!h||!F||!N,P=!h,O=[{action:this.handleSave,shortcut:es.SAVE},{action:this.handleMinimapChange,shortcut:Nt.NOTEBOOK.MINIMAP},{action:this.handleWordWrapChange,shortcut:Nt.NOTEBOOK.WORDWRAP}],k=mc.getDisabledRunTooltip(F,N,"Notebook extension","Run"),L=mc.getDisabledRunTooltip(F,N,"Notebook extension","Run Selected"),A=[{title:E?"Rename":"Save As…",order:10,group:ae.groups.high,action:this.handleShowRename},{title:"Copy File",action:this.handleCopy,group:ae.groups.high,order:20}],U=n?.element.find(".lm_title_before").get(0);return l.jsxs(l.Fragment,{children:[U&&Pi.createPortal(l.jsx("span",{className:$("editor-unsaved-indicator",{"is-unsaved":o!==a})}),U),l.jsxs(ns,{className:"notebook-container",componentPanel:this,glContainer:t,glEventHub:s,onTab:this.handleTab,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleTabFocus,onTabBlur:this.handleTabBlur,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onFocus:this.handleFocus,onBlur:this.handleBlur,additionalActions:A,renderTabTooltip:()=>T,children:[!y&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"notebook-toolbar",children:[l.jsxs("span",{children:[l.jsx(V,{kind:"ghost",className:"btn-play",onClick:this.handleRunAll,disabled:H,icon:l.jsx(J,{icon:ya,transform:"grow-4"}),tooltip:`Run ${Nt.NOTEBOOK.RUN.getDisplayText()}`,"aria-label":"Run"}),k!=null&&l.jsx(tt,{children:k})]}),l.jsxs("span",{children:[l.jsx(V,{kind:"ghost",className:"btn-play",onClick:this.handleRunSelected,disabled:H,icon:l.jsx(J,{icon:Cg,transform:"grow-4"}),tooltip:`Run Selected ${Nt.NOTEBOOK.RUN_SELECTED.getDisplayText()}`,"aria-label":"Run Selected"}),L!=null&&l.jsx(tt,{children:L})]}),l.jsx(V,{kind:"ghost",className:"mr-auto",disabled:P,onClick:this.handleSave,icon:Ah,tooltip:`Save ${es.SAVE.getDisplayText()}`,"aria-label":"Save"}),l.jsx(V,{kind:"ghost",className:"btn-overflow btn-link-icon",disabled:P,icon:Dh,tooltip:"More Actions...",onClick:()=>{},children:l.jsx(Zn,{actions:this.getDropdownOverflowActions,popperOptions:Js.POPPER_OPTIONS})})]}),l.jsx(eS,{isLoaded:h,isLoading:u,error:r,onChange:this.handleEditorChange,onRunCommand:this.handleRunCommand,session:g,sessionLanguage:C,onEditorInitialized:this.handleEditorInitialized,onEditorWillDestroy:this.handleEditorWillDestroy,settings:I,focusOnMount:w,ref:j=>{this.notebook=j}})]}),y&&l.jsx(qx,{content:I.value??"",onLinkClick:this.handleLinkClick,onRunCode:this.handleRunCommand,transformImageUri:this.handleTransformLinkUri,transformLinkUri:this.handleTransformLinkUri}),l.jsx(Ai,{isOpen:v,type:"file",defaultValue:T,title:E?"Rename":"Save file as",onSubmit:this.handleSaveAsSubmit,onCancel:this.handleSaveAsCancel,notifyOnExtensionChange:!0,storage:e}),l.jsx(ji,{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(ae,{actions:O})]})]})}}const Yx=(d,e)=>{const t=au(d),n=Ct(d),s=VS(d),i=ai(d,e.localDashboardId),{session:o,config:a}=i??{},{type:r}=a??{};return{fileStorage:t,settings:n,defaultNotebookSettings:s,session:o,sessionLanguage:r}},qs=ft(Yx,{saveSettings:hr},null,{forwardRef:!0})(Js);class Xr extends b.Component{static defaultProps={panelState:null};static COMPONENT="PandasPanel";constructor(e){super(e),this.irisGridRef=X.createRef(),this.buttonRef=X.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(oi,{ref:this.irisGridRef,onStateChange:this.handleGridStateChange,onPanelStateUpdate:this.handlePanelStateUpdate,...e,children:l.jsxs(V,{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(J,{icon:Dl,transform:"shrink-1",className:"mr-1"}),"Reload"]})]})})}}function Xx(d){Ps(d);const{id:e,layout:t,registerComponent:n,hydrate:s}=d,i=b.useCallback(({dragEvent:o,fetch:a,panelId:r=Pe.generate(),widget:c})=>{const{name:h,type:u}=c;if(u!==dh.VariableType.FIGURE)return;const m={name:h,figure:h},p=()=>a().then(f=>Aa.makeModel(void 0,f)),g={type:"react-component",component:ki.COMPONENT,props:{localDashboardId:e,id:r,metadata:m,makeModel:p},title:h,id:r},{root:C}=t;q.openComponent({root:C,config:g,dragEvent:o})},[e,t]);return b.useEffect(function(){const a=[n(ki.COMPONENT,ki,s)];return()=>{a.forEach(r=>r())}},[s,n]),Ue(t.eventHub,Ee.OPEN,i),null}function Zx(d){Ps(d);const{id:e,layout:t}=d,n=b.useCallback(({metadata:s,panelId:i=Pe.generate(),table:o})=>{const{settings:a}=s,r=()=>Aa.makeModelFromSettings(a,o),c=Je.titleFromSettings(a),h={type:"react-component",component:ki.COMPONENT,props:{localDashboardId:e,id:i,metadata:s,makeModel:r},title:c,id:i},{root:u}=t;q.openComponent({root:u,config:h})},[e,t]);return Ue(t.eventHub,Cn.CREATE_CHART,n),null}const rt=Z.module("ConsolePlugin");function nh(d){return d.notebook!==void 0}function Qx(d){Ps(d)}function Jx(d){Qx(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=El(),p=b.useCallback(()=>s.getLastUsedPanelOfType(Ii),[s]),g=b.useCallback((G,K)=>{c(te=>new Map(te.set(G,K)))},[c]),C=b.useCallback(G=>{c(K=>(K.delete(G),new Map(K)))},[c]),f=b.useCallback((G,K)=>{u(te=>new Map(te.set(G,K)))},[u]),S=b.useCallback(G=>{u(K=>(K.delete(G),new Map(K)))},[u]),v=b.useCallback((G,K=!0,te=!0)=>{if(!(G&&G.trim()))rt.info("Ignoring empty code");else{const de=p();if(!de||!(de instanceof Ii.WrappedComponent)){rt.error("Console panel not found");return}rt.debug("Send command: ",G,K,te),de.addCommand(G,K,te)}},[p]),w=b.useCallback(G=>{m(sx(e,G))},[m,e]),T=b.useCallback(({language:G})=>{const K=G==="python"?"py":G;let te=null;return K==null?(rt.debug("No extension for language",G),te=`Untitled-${a.current}`):te=`Untitled-${a.current}.${K}`,a.current+=1,te},[]),y=b.useCallback((G,K=!0)=>{const{id:te}=G;return te!=null&&r.has(te)?r.get(te):te!=null&&h.has(te)?h.get(te):K?Pe.generate():null},[r,h]),E=b.useCallback((G,K)=>{q.renameComponent(n.root,{id:G},K)},[n.root]),I=b.useCallback((G,K)=>{rt.debug("Rename file panel",G,K);let te;if(r.has(G)&&(te=r.get(G),C(G),te!=null&&g(K,te)),h.has(G)&&(te=h.get(G),S(G),te!=null&&f(K,te)),te===void 0){rt.debug2(`File ${G} isn't open, no need to rename the tab`);return}E(te,he.getBaseName(K))},[r,h,E,g,f,C,S]),F=b.useCallback(G=>{const K=y(G,!1);if(K==null){rt.error("Could not find panel id for file metadata",G);return}q.activateTab(n.root,{id:K})},[y,n.root]),N=b.useCallback((G,K,te)=>{if(rt.debug("registerFilePanel",G,K,te),K==null||K.id==null){rt.debug("Ignore empty file id",K);return}const{id:oe}=K;if(te){f(oe,G);return}if(r.has(oe)){const de=r.get(oe);if(G===de){rt.debug(`Update tab title for file ${oe}`);const{itemName:ee}=K;I(oe,ee)}else rt.error(`File ${oe} already associated with a different tab ${de}`);return}g(oe,G),h.has(oe)&&S(oe)},[r,h,I,g,f,S]),H=b.useCallback((G,K)=>{if(rt.debug("unregisterFileTab",G,K),G==null||G.id==null){rt.debug("Ignore empty file id",G);return}const{id:te}=G;if(K){S(te);return}C(te)},[C,S]),P=b.useCallback((G,K)=>{rt.debug("closeFilePanel",G);const{id:te}=G;let oe=null,de=!1;if(r.has(te))oe=r.get(te);else if(h.has(te))oe=h.get(te),de=!0;else{rt.debug(`File ${te} isn't open, ignore close event`);return}H(G,de),q.closeComponent(n.root,{id:oe},K)},[n.root,r,h,H]),O=b.useCallback(G=>{const{itemName:K}=G;return he.getBaseName(K)},[]),k=b.useCallback(G=>{const{id:K}=G;return rt.debug("fileIsOpen",G,K,r),K!=null&&r.has(K)},[r]),L=b.useCallback(G=>{const{id:K}=G;return rt.debug("fileIsOpenAsPreview",G,K,h),K!=null&&h.has(K)},[h]),A=b.useCallback(G=>{if(G==null)return;const K=s.getOpenedPanelById(G);K&&nh(K)&&K.focus()},[s]),U=b.useCallback(({id:G,settings:K,fileMetadata:te,session:oe,sessionLanguage:de,isPreview:ee=!1})=>{const re={settings:K,fileMetadata:te},we=O(te);return{type:"react-component",component:qs.COMPONENT,isFocusOnShow:!1,props:{localDashboardId:e,metadata:{id:G},session:oe,sessionLanguage:de,panelState:re,isPreview:ee,notebooksUrl:o},title:we,id:G}},[O,e,o]),j=b.useCallback((G,K,te,oe={id:null,itemName:T(te)})=>{const de=y(oe);if(k(oe)&&de!=null){rt.debug("File is already open, focus panel"),F(oe),A(de);return}const ee=q.getStackForComponentTypes(n.root,[qs.COMPONENT]),re=U({id:de,settings:te,fileMetadata:oe,session:G,sessionLanguage:K});rt.debug("createNotebook",re,r),q.openComponentInStack(ee,re)},[k,A,T,y,n.root,U,r,F]),W=b.useCallback((G,K,te,oe,de=!1)=>{rt.debug("selectNotebook",oe,de);const ee=k(oe),re=L(oe);if(ee){if(F(oe),de){const Mt=y(oe);A(Mt)}return}if(re&&!de){F(oe);return}const[we]=Array.from(h.values());let xe=null,Oe=null;we!=null&&(xe=we,Oe=q.getStackForConfig(n.root,{component:qs.COMPONENT,id:xe})),Oe==null&&(xe=y(oe),Oe=q.getStackForComponentTypes(n.root,[qs.COMPONENT]));const Jt=U({id:xe,settings:te,fileMetadata:oe,session:G,sessionLanguage:K,isPreview:!de});q.openComponentInStack(Oe,Jt),de&&A(xe)},[F,k,L,A,y,n.root,U,h]),ie=b.useCallback((G,K,te={},oe=!0)=>{const de=s.getLastUsedPanelOfType(qs);de&&nh(de)?te!=null&&te.value!=null&&de.notebook!=null&&de.notebook.append(te.value):oe&&j(G,K,te)},[j,s]),se=b.useCallback((G,K)=>ml.hydrate({...G,notebooksUrl:o},K),[o]);return b.useEffect(function(){const K=[i(Ii.COMPONENT,Ii,t),i($a.COMPONENT,$a),i(Ga.COMPONENT,Ga),i(Ya.COMPONENT,Ya),i(qs.COMPONENT,qs,se)];return()=>{K.forEach(te=>te())}},[i,t,se]),Ue(n.eventHub,Yt.SEND_COMMAND,v),Ue(n.eventHub,Yt.SETTINGS_CHANGED,w),Ue(n.eventHub,Xe.CLOSE_FILE,P),Ue(n.eventHub,Xe.CREATE_NOTEBOOK,j),Ue(n.eventHub,Xe.SELECT_NOTEBOOK,W),Ue(n.eventHub,Xe.RENAME,E),Ue(n.eventHub,Xe.RENAME_FILE,I),Ue(n.eventHub,Xe.SEND_TO_NOTEBOOK,ie),Ue(n.eventHub,Xe.REGISTER_FILE,N),Ue(n.eventHub,Xe.UNREGISTER_FILE,H),null}const ho=Z.module("FilterPlugin");function sh(d,e){return d.concat(e)}function eR(d){Ps(d);const{id:e,layout:t,registerComponent:n}=d,s=El(),[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(sh,[]).sort((w,T)=>{const y=Wt.toLower(w.name),E=Wt.toLower(T.name);if(y!==E)return y>E?1:-1;const I=Wt.toLower(w.type),F=Wt.toLower(T.type);return I!==F?I>F?1:-1:0}).reduce((w,T)=>((w.length===0||Wt.toLower(w[w.length-1].name)!==Wt.toLower(T.name)||Wt.toLower(w[w.length-1].type)!==Wt.toLower(T.type))&&w.push(T),w),[]),S=Array.from(o.values()).reduce(sh,[]).sort((w,T)=>w.timestamp-T.timestamp),v=new Map(a);ho.debug("sendUpdate",{columns:f,filters:S,tableMap:v}),s(Pn(e,{columns:f,filters:S,tableMap:v}))},[s,e,i,o,a]),c=b.useCallback((f,S)=>{ho.debug2("handleColumnsChanged",f,S),i.set(f,[].concat(S)),r()},[i,r]),h=b.useCallback((f,S)=>{ho.debug2("handleFiltersChanged",f,S),o.set(f,[].concat(S)),r()},[o,r]),u=b.useCallback((f,S)=>{ho.debug2("handleTableChanged",f,S),a.set(q.getIdFromPanel(f),S),r()},[a,r]),m=b.useCallback(f=>{ho.debug2("handlePanelUnmount",f),i.delete(f),o.delete(f),a.delete(q.getIdFromPanel(f)),r()},[i,o,a,r]),p=b.useCallback(({title:f="DropdownFilter",metadata:S={},panelState:v=null,id:w=Pe.generate(),focusElement:T=q.DEFAULT_FOCUS_SELECTOR,createNewStack:y=!1,dragEvent:E=null})=>{const I={type:"react-component",component:ii.COMPONENT,props:{id:w,metadata:S,panelState:v,localDashboardId:e},title:f,id:w},{root:F}=t;q.openComponent({root:F,config:I,focusElement:T,createNewStack:y,dragEvent:E})},[t,e]),g=b.useCallback(({title:f="InputFilter",metadata:S={},panelState:v=null,id:w=Pe.generate(),focusElement:T=q.DEFAULT_FOCUS_SELECTOR,createNewStack:y=!1,dragEvent:E=null})=>{const I={type:"react-component",component:wo.COMPONENT,props:{id:w,metadata:S,panelState:v,localDashboardId:e},title:f,id:w},{root:F}=t;q.openComponent({root:F,config:I,focusElement:T,createNewStack:y,dragEvent:E})},[t,e]),C=b.useCallback(({title:f="FilterSets",metadata:S={},panelState:v=null,id:w=Pe.generate(),focusElement:T=q.DEFAULT_FOCUS_SELECTOR,createNewStack:y=!1,dragEvent:E=null})=>{const I={type:"react-component",component:Yr.COMPONENT,props:{id:w,metadata:S,panelState:v,localDashboardId:e},title:f,id:w},{root:F}=t;q.openComponent({root:F,config:I,focusElement:T,createNewStack:y,dragEvent:E})},[t,e]);return b.useEffect(function(){const S=[n(ii.COMPONENT,ii),n(wo.COMPONENT,wo),n(Yr.COMPONENT,Yr)];return()=>{S.forEach(v=>v())}},[n]),Ue(t.eventHub,Qe.COLUMNS_CHANGED,c),Ue(t.eventHub,Qe.FILTERS_CHANGED,h),Ue(t.eventHub,Qe.TABLE_CHANGED,u),Ue(t.eventHub,Qe.OPEN_DROPDOWN,p),Ue(t.eventHub,Qe.OPEN_INPUT,g),Ue(t.eventHub,Qe.OPEN_FILTER_SET_MANAGER,C),Ue(t.eventHub,Ee.UNMOUNT,m),null}const tR=[dh.VariableType.TABLE,dh.VariableType.TREETABLE,dh.VariableType.HIERARCHICALTABLE];function nR(d){Ps(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=Pe.generate(),widget:m})=>{const{name:p,type:g}=m;if(!tR.includes(g))return;const C={name:p,table:p,type:m.type},f=()=>h().then(w=>ud.makeModel(w)),S={type:"react-component",component:oi.COMPONENT,props:{getDownloadWorker:e,loadPlugin:t,localDashboardId:n,id:u,metadata:C,makeModel:f,theme:a},title:p,id:u},{root:v}=s;q.openComponent({root:v,config:S,dragEvent:c})},[e,n,s,t,a]);return b.useEffect(function(){const h=[i(oi.COMPONENT,oi,o)];return()=>{h.forEach(u=>u())}},[o,i]),Ue(s.eventHub,Ee.OPEN,r),null}function wm(d){return typeof d.getCoordinateForColumn=="function"}function ih(d){const e=d;return wm(d)&&typeof e.setFilterMap=="function"&&typeof e.unsetFilterValue=="function"}function oh(d){return d.description===void 0||!d.description?.startsWith("Preview of type: ")}const uo=Z.module("LinkerUtils");class ys{static ALLOWED_LINKS=new Map([[q.getComponentName(oi),[q.getComponentName(oi),q.getComponentName(ki),q.getComponentName(ii)]]]);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 uo.debug2("Incompatible panel ids",e,t,n),"invalid";if(e.panelComponent==null||t.panelComponent==null)return uo.error("PanelComponent should not be null",e,t),"invalid";const s=ys.ALLOWED_LINKS.get(e.panelComponent)?.includes(t.panelComponent);if(s===void 0||!s)return uo.debug2("Incompatible panel components",e,t),"invalid";const{columnType:i}=e,{columnType:o}=t;if(!(o===null||R.isCompatibleType(i,o)))return uo.debug2("Incompatible type",i,o),"invalid";switch(t.panelComponent){case q.getComponentName(ki):case q.getComponentName(oi):return"tableLink";case q.getComponentName(ii):return"filterSource"}return uo.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:Pe.generate(),start:{...i.start,panelId:n}}):i.end?.panelId===t&&s.push({...i,id:Pe.generate(),end:{...i.end,panelId:n}})}),s}}const sR=Z.module("LinkerLink"),ah=.015,rh=1.5,vm=12,Tm=12,lh=2,fa=Math.sqrt((Tm*.5)**2+vm**2),ch=Math.asin(Tm*.5/vm),hh=15,Cs=Math.PI*.5;class vo 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(R.isNumberType(e)||R.isCharType(e))return tu(t);if(R.isTextType(e))return eu(t);if(R.isDateType(e))return nu(t);if(R.isBooleanType(e)){if(t===Y.eq)return"is equal to";if(t===Y.notEq)return"is not equal to"}throw new Error(`Unrecognized column type: ${e}`)}catch(n){return sR.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=R.getFilterTypes(t);return R.isBooleanType(t)&&(s=[Y.eq,Y.notEq]),s.flatMap((i,o)=>{if(i==="eqIgnoreCase"||i==="notEqIgnoreCase")return[];let a="";return i==="startsWith"?a="a*":i==="endsWith"?a="*z":a=R.getFilterOperatorString(i),[{title:vo.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),p=Math.sin(m),g=Math.cos(m)+2,C=window.innerWidth,f=window.innerHeight,S=0,v=0,w=Math.max(S,Math.min(s+(o-s)/2+p*(u*ah)**rh,C)),T=Math.max(v,Math.min(i+(a-i)/2+g*(u*ah)**rh,f)),y=`M ${s} ${i} Q ${w} ${T} ${o} ${a}`,E=`M ${S} ${v} L ${S} ${f} L ${C} ${f} L ${C} ${v} z
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(wr,{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:p,widgetName:g,description:C,onClearAllFilters:f,onHide:S,onFocus:v,onBlur:w,onResize:T,onShow:y,onTabBlur:E,onTabFocus:I,onTabClicked:F}=this.props,{isPanelDisconnected:N,isWidgetDisconnected:H,isPanelInactive:P}=this.state,O=this.getErrorMessage(),k=m??this.getCachedRenderTabTooltip(u,o,p,g,C),L=[{title:`Copy ${p} Name`,group:ae.groups.medium,order:20,action:this.handleCopyName}];return l.jsxs(ns,{className:$(t,{disconnected:N||H||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:I,onTabClicked:F,renderTabTooltip:k,errorMessage:O,isLoaded:s,isLoading:i,isClonable:c,isRenamable:h,additionalActions:L,children:[e,P&&l.jsx("div",{className:"fill-parent-absolute"})]})}}const jt=Object.freeze({DEFAULT:"DEFAULT",LINKER:"LINKER"}),zy="SET_SESSION_WRAPPER",Ky=Ls(zy,null),qy={sessionWrapper:Ky},Yy=new Map,vr=Object.freeze([]),gm=(d,e)=>Vt(d,e).columns??vr,Xy=(d,e)=>Vt(d,e).filterSets??vr,pd=(d,e)=>Vt(d,e).filters??vr,gd=(d,e)=>Vt(d,e).tableMap??Yy,fd=(d,e)=>Vt(d,e).isolatedLinkerPanelId,Ki=(d,e)=>Vt(d,e).links??vr,Cd=(d,e)=>Vt(d,e).columnSelectionValidator,Zy=(d,e)=>Vt(d,e).connection,ai=(d,e)=>Vt(d,e).sessionWrapper,Qy=(d,e)=>t=>t(Pn(d,{connection:e})),Jy=(d,e)=>t=>t(Pn(d,{sessionWrapper:e})),Sd=(d,e)=>t=>t(Pn(d,{links:e})),ex=(d,e)=>(t,n)=>{const s=Ki(n(),d),i=e.filter(o=>s.findIndex(a=>it(a.start,o.start)&&it(a.end,o.end))<0);return t(Sd(d,s.concat(i)))},tx=(d,e)=>(t,n)=>{const i=Ki(n(),d).filter(o=>!e.includes(o.id));return t(Sd(d,i))},fm=(d,e)=>t=>t(Pn(d,{isolatedLinkerPanelId:e})),nx=(d,e)=>t=>t(Pn(d,{columnSelectionValidator:e})),sx=(d,e)=>t=>t(Pn(d,{consoleSettings:e})),ix=(d,e)=>t=>t(Pn(d,{filterSets:e}));Object.entries(qy).map(([d,e])=>Gi.register(d,e));function Cm({columnMap:d,inputFilterMap:e,linkedColumnMap:t,onAdd:n,onOpenLinker:s,waitingFilterMap:i,waitingInputMap:o}){const a=b.useMemo(()=>{const p=Array.from(o.keys()),g=p.find(S=>e.get(S)!=null),C=p.find(S=>t.get(S)!=null),f=Wt.join(p.map(S=>`"${S}"`));return g!=null&&g&&C!=null&&C?`Use a filter control or linked table to set a value for ${f}`:g!=null&&g?`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(p=>{p.stopPropagation(),p.preventDefault(),n(Array.from(i.values()))},[n,i]),h=b.useCallback(p=>{p.stopPropagation(),p.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(p=>{const g=i.has(p.name),C=g?Ms:Rl;return l.jsxs("div",{className:$("waiting-filter-item",{"is-invalid":g}),children:[l.jsx(J,{icon:C}),p.name]},p.name)})}),l.jsxs("div",{children:[l.jsx(Ud,{onClick:c,className:"btn-primary",children:"Add Input Filters"}),l.jsx(Ud,{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})]})]})})}Cm.propTypes={columnMap:D.instanceOf(Map).isRequired,inputFilterMap:D.instanceOf(Map).isRequired,linkedColumnMap:D.instanceOf(Map).isRequired,onAdd:D.func.isRequired,onOpenLinker:D.func.isRequired,waitingFilterMap:D.instanceOf(Map).isRequired,waitingInputMap:D.instanceOf(Map).isRequired};function Ro({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(zh,{className:$("btn-chart-column-selector",Ro.makeButtonClassName(s.name)),onClick:()=>e(s.name),onMouseEnter:()=>{t&&t(s)},onMouseLeave:n,disabled:!s.isValid,isLinked:s.isActive,children:s.name},s.name))})]})})}Ro.makeButtonClassName=d=>`btn-chart-column-selector-${d}`;Ro.defaultProps={onMouseEnter:()=>{},onMouseLeave:()=>{}};const $t=Z.module("ChartPanel"),ox=150;function va(d){return d.settings!==void 0}function ax(d){return d.inputFilters!=null}function rx(d){return d.panelState!=null}class lx 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),ox),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.panelContainer=X.createRef(),this.chart=X.createRef(),this.pending=new ts;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&&va(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&&wc(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=q.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){$t.debug("startListeningToSource",e),e.addEventListener(x.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleSourceColumnChange),e.addEventListener(x.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.addEventListener(x.Table.EVENT_SORTCHANGED,this.handleSourceSortChange)}stopListeningToSource(e){$t.debug("stopListeningToSource",e),e.removeEventListener(x.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleSourceColumnChange),e.removeEventListener(x.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.removeEventListener(x.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(pl.COLUMN_SELECTED,this,n.get(e))}handleColumnMouseEnter({type:e,name:t}){const{columnSelectionValidator:n}=this.props;$t.debug("handleColumnMouseEnter",n,e,t),n&&n(this,{type:e,name:t})}handleColumnMouseLeave(){const{columnSelectionValidator:e}=this.props;$t.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(jt.LINKER)}handleReconnect(){this.setState({isDisconnected:!1,error:void 0}),this.sendColumnChange(),this.updateColumnFilters()}handleLoadSuccess(e){$t.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)||($t.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){$t.debug2("updateModelFromSource ignoring",n,s,t);return}if(this.pending.cancel(),va(e)){const{settings:i}=e;this.pending.add(x.plot.Figure.create(Je.makeFigureSettings(i,t))).then(o=>{wc(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&&ax(e.props)&&rx(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 $t.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=Ro.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){$t.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 $t.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 p=i.get(c);p!==m&&p!=null&&(a=!0,o.set(c,p))}else a=!0,o.delete(c)}}return $t.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=Wt.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),$t.debug2("updateFilters filters set",t),this.setState({isLoading:!0})}else $t.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:p,isDisconnected:g,isLoaded:C,isLoading:f}=this.state;let S;va(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,I=T.size>0,F=c.size>0&&i;return l.jsx(md,{className:$("iris-chart-panel",{"input-required":I}),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:g,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(PS,{isActive:p,model:m,settings:r,ref:this.chart,onDisconnect:this.handleDisconnect,onReconnect:this.handleReconnect,onUpdate:this.handleUpdate,onError:this.handleError,onSettingsChanged:this.handleSettingsChanged})}),l.jsx(gt,{in:I&&!F&&!f,timeout:We.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:l.jsx(Cm,{inputFilterMap:v,linkedColumnMap:w,onAdd:this.handleFilterAdd,onOpenLinker:this.handleOpenLinker,columnMap:c,waitingFilterMap:y,waitingInputMap:T})}),l.jsx(gt,{in:F,timeout:We.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:l.jsx(Ro,{columns:this.getSelectorColumns(c,w,e),onColumnSelected:this.handleColumnSelected,onMouseEnter:this.handleColumnMouseEnter,onMouseLeave:this.handleColumnMouseLeave})})]})})}}const dx=(d,e)=>{const{localDashboardId:t,metadata:n}=e;let s;n!=null&&(s=n.sourcePanelId);const i=gd(d,t),o=Gu(d,t),a=cr(d),r=fd(d,t),c=a===jt.LINKER&&r===void 0;return{columnSelectionValidator:Cd(d,t),isLinkerActive:c,inputFilters:pd(d,t),links:Ki(d,t),source:s!=null?i.get(s):void 0,sourcePanel:s!=null?o.get(s):void 0,settings:Ct(d)}},ki=ft(dx,{setActiveTool:ur,setDashboardIsolatedLinkerPanelId:fm},null,{forwardRef:!0})(lx);const ua=Z.module("CommandHistoryPanel");class bd extends b.Component{static COMPONENT="CommandHistoryPanel";static TITLE="Command History";static handleError(e){ua.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=X.createRef(),this.pending=new ts;const{session:t,sessionId:n,language:s}=e;this.state={panelState:{},session:t,sessionId:n,language:s,contextActions:[{action:this.handleFocusHistory,shortcut:Nt.COMMAND_HISTORY.FOCUS_HISTORY}]}}componentDidMount(){const{glEventHub:e,session:t}=this.props;e.on(Yt.FOCUS_HISTORY,this.handleFocusHistory),t!=null&&this.loadTable()}componentWillUnmount(){const{glEventHub:e}=this.props;e.off(Yt.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(ua.debug("handleSendToNotebook",n,e),!n){ua.error("Session is not connected.");return}const{glEventHub:i}=this.props;i.emit(t?Xe.CREATE_NOTEBOOK:Xe.SEND_TO_NOTEBOOK,n,s,e)}handleSendToConsole(e,t=!0,n=!1){ua.debug("handleSendToConsole",e);const{glEventHub:s}=this.props;s.emit(Yt.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(bd.handleError)}render(){const{glContainer:e,glEventHub:t,commandHistoryStorage:n}=this.props,{language:s,contextActions:i,table:o}=this.state;return l.jsxs(ns,{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(cS,{ref:this.container,language:s,sendToNotebook:this.handleSendToNotebook,sendToConsole:this.handleSendToConsole,table:o,commandHistoryStorage:n}),l.jsx(ae,{actions:i})]})]})}}const cx=(d,e)=>{const t=ou(d),n=ai(d,e.localDashboardId),{session:s,config:i}=n??{},{type:o,id:a}=i??{};return{commandHistoryStorage:t,language:o,session:s,sessionId:a}},$a=ft(cx,null,null,{forwardRef:!0})(bd);const ma=Z.module("ConsolePanel"),hx=500,ux=Object.freeze({consoleSettings:{},itemIds:[]});class mx 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=X.createRef();const{panelState:t}=e,n={...ux,...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=>{ma.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=Pe.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(Yt.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;ma.debug("handleSettingsChange",e),this.setState({consoleSettings:e}),t.emit(Yt.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};ma.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]};ma.debug("Saving panel state",n),this.setState({panelState:n})},hx);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:p,type:g}=h;return l.jsx(ns,{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(ZC,{ref:this.consoleRef,settings:a,session:u,focusCommandHistory:this.handleFocusCommandHistory,openObject:this.handleOpenObject,closeObject:this.handleCloseObject,commandHistoryStorage:e,onSettingsChange:this.handleSettingsChange,language:g,statusBarChildren:l.jsxs(l.Fragment,{children:[l.jsx("div",{children:" "}),l.jsx("div",{children:qh.LANGUAGE_MAP.get(g)}),l.jsx("div",{children:" "}),l.jsx("div",{children:l.jsx(_S,{connection:m,defaultUpdateInterval:10*1e3,hoverUpdateInterval:3*1e3,monitorDuration:10*60*1e3})}),l.jsx("div",{children:" "})]}),scope:p,timeZone:i,objectMap:c,unzip:o})})}}const px=(d,e)=>({commandHistoryStorage:ou(d),sessionWrapper:ai(d,e.localDashboardId),timeZone:Ao(d)}),Ii=ft(px,null,null,{forwardRef:!0})(mx);const pa=Z.module("DropdownFilter"),gx=150;class Oi 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=X.createRef();const{column:t,isValueShown:n,value:s}=e;this.state={column:t,id:Pe(),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&&R.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:Oi.PLACEHOLDER},"-1"),...e.map((t,n)=>l.jsx("option",{value:n,children:t??"(null)"},`${n}/${t}`))]);getItemLabel=pe((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(pa.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(),pa.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]:pa.debug2("Selected default item"),pa.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})},gx);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:p,isValueShown:g,selectedColumn:C,value:f}=this.state,S=i===null,v=this.getCompatibleColumns(i,e),w=i!=null,T=i?.columnName??Oi.SOURCE_BUTTON_PLACEHOLDER,y=u!=null?`${u.name} Filter`:null,[E,I]=this.getColumnOptions(v,C),F=this.getValueOptions(c),N=this.getSelectedOptionIndex(c,f),H=!w||C==null,P=g&&!n,O=`source-column-btn-${p}`,k=`filter-column-select-${p}`;return l.jsxs(Ol,{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:O,children:"Source Column"}),l.jsx(zh,{id:O,isLinked:w,onClick:o,onMouseEnter:a,onMouseLeave:r,className:Oi.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:k,children:"Filter Column"}),l.jsx("select",{id:k,value:I,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(V,{kind:"secondary",type:"button",onClick:this.handleSettingsCancel,disabled:m||g||n,tooltip:n?"Cancel disabled while linker open":void 0,children:"Cancel"}),l.jsx(V,{kind:"primary",type:"button",className:"ml-2",onClick:this.handleSettingsSave,disabled:H||g||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(V,{kind:"ghost",className:"m-2 px-2",onClick:this.handleSettingsClick,icon:l.jsx(J,{icon:ko,transform:"grow-4"}),tooltip:"Dropdown Filter Settings"})})]})})]})}}const st=Z.module("DropdownFilterPanel"),fx=250,Cx=(d,e)=>{const{localDashboardId:t}=e,n=q.getIdFromPanel({props:e}),s=gd(d,t),i=Ki(d,t),o=cr(d),a=fd(d,t),r=o===jt.LINKER&&(a===void 0||a===n),c=o===jt.LINKER&&a!==void 0&&a!==n;return{columns:gm(d,t),columnSelectionValidator:Cd(d,t),isLinkerActive:r,disableLinking:c,settings:Ct(d),panelTableMap:s,dashboardLinks:i}},Sx=ft(Cx,null,null,{forwardRef:!0});class Es extends b.Component{static displayName="DropdownFilterPanel";static COMPONENT="DropdownFilterPanel";static MAX_TABLE_SIZE=256;static DATETIME_FORMATTER=new _e({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),fx),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=X.createRef(),this.panelContainer=X.createRef(),this.pending=new ts;const{panelState:t,settings:n}=e;this.columnFormats=Jn.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 Zt(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=pe((e,{type:t,name:n},s)=>t!==void 0&&R.isDateType(t)?e.map(i=>Es.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(`.${Oi.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>Es.MAX_TABLE_SIZE)return`Table too large, must have fewer than ${Es.MAX_TABLE_SIZE} options.`}getPanelErrorMessage(){const{error:e}=this.state;return e!=null?`${e}`:void 0}getCachedPanelLinks=pe((e,t)=>{const n=q.getIdFromPanel(t);return st.debug("getCachedPanelLinks",e,n),e.filter(s=>s.end?.panelId===n)});getCachedSource=pe(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=pe((e,t)=>{if(st.debug("getCachedSourceTable",e,t),t==null)return null;const{panelId:n}=t;return e.get(n)??null});getCachedSourceColumn=pe((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(x.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.addEventListener(x.Table.EVENT_SORTCHANGED,this.handleSourceSortChange),e.addEventListener(x.Table.EVENT_SIZECHANGED,this.handleSourceSizeChange),e.addEventListener(x.Table.EVENT_DISCONNECT,this.handleDisconnect),e.addEventListener(x.Table.EVENT_RECONNECT,this.handleReconnect)}stopListeningToSource(e){st.debug("stopListeningToSource"),e.removeEventListener(x.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.removeEventListener(x.Table.EVENT_SORTCHANGED,this.handleSourceSortChange),e.removeEventListener(x.Table.EVENT_SIZECHANGED,this.handleSourceSizeChange),e.removeEventListener(x.Table.EVENT_DISCONNECT,this.handleDisconnect),e.removeEventListener(x.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,Es.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(x.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,Es.MAX_TABLE_SIZE-1,[n])}updateFormatterSettings(e){const t=Jn.getColumnFormats(e);it(this.columnFormats,t)||(this.columnFormats=t,this.setState({formatter:new Zt(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,Es.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:p,isLoading:g,isLoaded:C}=this.state,f=this.getSource(t),S=this.getSettingsErrorMessage(),v=this.getPanelErrorMessage(),w=C&&p!=null?this.getCachedValues(m,p,r):[];return l.jsx(md,{errorMessage:v,isLoading:g,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(Oi,{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 ii=Sx(Es);function On(d){return d.type==="directory"}var Sm=(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))(Sm||{});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 Ni("Name cannot be empty");if(t.includes(e))throw new Ni(`"${e}" is a reserved name`);if(n.test(e))throw new Ni(`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 It=Z.module("FileList"),gl=d=>On(d)?he.makePath(d.filename):he.getPath(d.filename),wd=26,bx=500,qc="item-list-scroll-pane",fl=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,p=t?.some(E=>E.id===o.id)??!1,g=gl(o),C=n&&r?gl(r):null,f=n&&s&&On(o)&&C===g,S=n&&s&&C===g,v=n&&!s&&C===g,w=wx(o),T=he.getDepth(o.filename),y=Array(T).fill(null).map((E,I)=>l.jsx("span",{className:"file-list-depth-line"},I));return l.jsxs("div",{className:$("d-flex w-100 align-items-center","file-list-item",{"is-dragged":p,"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(J,{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})]})]})};function wx(d){if(On(d))return d.isExpanded?cg:hg;switch(he.getMimeType(d.basename)){case Sm.PYTHON:return mg;default:return ug}}function Yc(d,e){if(d.length===0||e==null)throw new Error("No items to move");const t=gl(e);if(d.some(({filename:n})=>he.getPath(n)===t))throw new Error("File already in the destination folder");if(d.some(n=>On(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 vx(d){const{isMultiSelect:e=!1,table:t,onFocusChange:n=()=>{},onMove:s,onSelect:i,onSelectionChange:o=()=>{},renderItem:a=fl,rowHeight:r=wd,overscanCount:c=Ht.DEFAULT_OVERSCAN}=d,[h,u]=b.useState(()=>({items:[],offset:0,itemCount:0})),[m,p]=b.useState({top:0,bottom:0}),[g,C]=b.useState(),[f,S]=b.useState(),[v,w]=b.useState(),[T,y]=b.useState([]),E=b.useRef(null),I=b.useRef(null),F=b.useCallback(ee=>{if(ee.length===0||h==null)return[];const re=[];for(let we=0;we<ee.length;we+=1){const xe=ee[we];for(let Oe=xe[0];Oe<=xe[1];Oe+=1)Oe>=h.offset&&Oe<h.offset+h.items.length&&re.push(h.items[Oe-h.offset])}return re},[h]),N=b.useCallback(ee=>{const re=F([[ee,ee]]);if(re.length>0)return re[0]},[F]),H=b.useCallback(()=>{const ee=ln.count(T);if(ee===0)return null;if(ee===1){const re=T[0][0],we=N(re);if(we!=null)return we.filename}return`${ee} items`},[N,T]),P=b.useCallback(ee=>{if(!(!f||!g)){It.debug("dropItems",f,"to",ee);try{const{files:re,targetPath:we}=Yc(f,g);s?.(re,we),ee!=null&&(y([[ee,ee]]),E.current?.focusItem(ee))}catch(re){It.error("Unable to complete move",re)}}},[f,g,s]),O=b.useCallback((ee,re)=>{const we=h.items[ee-h.offset];we!==void 0&&(It.debug("handleItemClick",we),i(we,re),On(we)&&t?.setExpanded(we.filename,!we.isExpanded))},[h,i,t]),k=b.useCallback((ee,re)=>{It.debug2("handleItemDragStart",ee,T);let we=T;ln.isSelected(T,ee)||(we=[[ee,ee]],y(we)),S(F(we)),E.current?.resetMouseState();const xe=document.createElement("div");xe.innerHTML=`<div class="dnd-placeholder-content">${H()}</div>`,xe.className="file-list-dnd-placeholder",document.body.appendChild(xe),re.dataTransfer.setDragImage(xe,0,0),re.dataTransfer.effectAllowed="move",w(xe)},[H,F,T]),L=b.useCallback((ee,re)=>{re.preventDefault(),It.debug2("handleItemDragOver",re),C(N(ee))},[N]),A=b.useCallback((ee,re)=>{It.debug("handleItemDragEnd",ee),v?.remove(),S(void 0),C(void 0),w(void 0)},[v]),U=b.useCallback((ee,re)=>{P(ee)},[P]),j=b.useCallback(()=>{It.debug2("handleItemDragExit"),C(void 0)},[]),W=b.useCallback(ee=>{ee.target instanceof Element&&ee.target.classList.contains(qc)&&(ee.preventDefault(),It.debug2("handleListDragOver",ee),C({type:"directory",filename:"/",basename:"/",id:"/"}))},[]),ie=b.useCallback(ee=>{ee.target instanceof Element&&ee.target.classList.contains(qc)&&(It.debug("handleListDrop"),P())},[P]),se=b.useCallback(ee=>{if(It.debug2("handleSelectionChange",ee),ee!==T){y(ee);const re=F(ee);o(re)}},[F,o,T]),G=b.useCallback(ee=>{if(It.debug2("handleFocusChange",ee),ee!=null){const[re]=F([[ee,ee]]);n(re)}else n()},[F,n]),K=b.useCallback((ee,re)=>{It.debug("handleViewportChange",ee,re),(ee!==m.top||re!==m.bottom)&&p({top:ee,bottom:re})},[m]),te=b.useMemo(()=>{if(!f||!g)return!1;try{return Yc(f,g),It.debug("handleValidateDropTarget true"),!0}catch{return It.debug("handleValidateDropTarget false"),!1}},[f,g]),{focusedPath:oe}=d;b.useEffect(()=>{oe!==void 0&&(oe==="/"?t.collapseAll():(t.setExpanded(oe,!1),t.setExpanded(oe,!0)))},[t,oe]),b.useEffect(function(){It.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(xe=>({...xe,itemName:xe.basename})),offset:we.offset,itemCount:t.size})});return()=>{re()}},[t]),b.useEffect(function(){if(g!=null&&On(g)&&g.filename!=="/"){const re=setTimeout(()=>{g.isExpanded||t?.setExpanded(g.filename,!0)},bx);return()=>clearTimeout(re)}},[g,t]);const de=b.useCallback(ee=>a({...ee,isDragInProgress:f!=null,dropTargetItem:g,draggedItems:f,isDropTargetValid:te,onDragStart:k,onDragEnd:A,onDragOver:L,onDragExit:j,onDrop:U}),[A,j,L,k,U,f,g,te,a]);return l.jsx("div",{ref:I,className:$("file-list",{"is-dragging":f!=null}),onDragOver:W,onDrop:ie,children:l.jsx(Ht,{ref:E,items:h.items,itemCount:h.itemCount,offset:h.offset,onFocusChange:G,onSelect:O,onSelectionChange:se,onViewportChange:K,selectedRanges:T,renderItem:de,rowHeight:r,isMultiSelect:e,isDragSelect:!1,isDeselectOnClick:!1})})}const Tx={name:"File Explorer",DELETE:Fe.createAndAdd({id:"FILE_EXPLORER.DELETE",name:"Delete",shortcut:[ue.DELETE],macShortcut:[ce.CMD,ue.BACKSPACE]}),RENAME:Fe.createAndAdd({id:"FILE_EXPLORER.RENAME",name:"Rename",shortcut:[ue.ENTER],macShortcut:[ue.ENTER]})},Xc={FILE_EXPLORER:Tx};const Zc=Z.module("FileListItemEditor"),Ex=()=>Promise.resolve();function yx({item:d,onCancel:e,onSubmit:t,validate:n=Ex}){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(),[]),p=b.useCallback(()=>{c.then(()=>{t(i)}).catch(S=>Zc.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 g=b.useCallback(()=>{Zc.debug2("handleBlur"),p()},[p]),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":{p();break}case"Escape":{e();break}}},[e,p]);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:g,onKeyDown:f,onChange:C,onClick:m,onDoubleClick:m,onMouseDown:m}),a&&l.jsx("div",{className:"invalid-feedback",children:`${a}`})]})}function bm(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:p=wd,validateRename:g=()=>Promise.resolve()}=d,[C,f]=b.useState(),[S,v]=b.useState([]),[w,T]=b.useState(),y=b.useCallback(j=>{v(j),u?.(j)},[u]),E=b.useCallback(j=>{T(j)},[]),I=b.useCallback(()=>{w&&o?.(w)},[w,o]),F=b.useCallback(()=>{S.length>0&&a?.(S)},[a,S]),N=b.useCallback(()=>{s?.()},[s]),H=b.useCallback(()=>{w&&i?.(he.getPath(w.filename))},[w,i]),P=b.useCallback(()=>{w&&f(w)},[w]),O=b.useCallback(()=>{f(void 0)},[]),k=b.useCallback(j=>{C&&(c?.(C,j),f(void 0))},[c,C]),L=b.useMemo(()=>{if(C)return[];const j=[];return s&&j.push({title:"New File",description:"Create new file",action:N,group:ae.groups.medium}),i&&j.push({title:"New Folder",description:"Create new folder",action:H,group:ae.groups.medium}),o&&j.push({title:"Copy",description:"Copy",action:I,group:ae.groups.low,disabled:w==null||On(w)}),a&&S.length>0&&j.push({title:"Delete",description:"Delete",shortcut:Xc.FILE_EXPLORER.DELETE,action:F,group:ae.groups.low}),c&&j.push({title:"Rename",description:"Rename",shortcut:Xc.FILE_EXPLORER.RENAME,action:P,group:ae.groups.low,disabled:w==null}),j},[I,F,N,H,P,w,o,s,i,a,c,S,C]),A=b.useCallback(j=>(M(C),g(C,j)),[C,g]),U=b.useCallback(j=>{const{item:W}=j;return C&&C.filename===W.filename?fl({...j,children:l.jsx(yx,{item:W,validate:A,onSubmit:k,onCancel:O})}):fl(j)},[O,k,C,A]);return l.jsxs("div",{className:"file-list-container",children:[m!=null&&l.jsx(vx,{onMove:r,onSelect:h,onSelectionChange:y,onFocusChange:E,renderItem:U,rowHeight:p,table:m,isMultiSelect:e,focusedPath:t}),n&&l.jsx(ae,{actions:L})]})}bm.displayName="FileListContainer";class Ta extends Ni{isExistingFile=!0;info;constructor(e){super("Name already exists"),this.info=e}}class vd extends Error{constructor(){super("No file exists at the path specified")}isFileNotFound=!0}const zs=Z.module("FileExplorer");function Td(d){const{storage:e,isMultiSelect:t=!1,focusedPath:n,onDelete:s=()=>{},onRename:i=()=>{},onSelect:o,onSelectionChange:a,rowHeight:r=wd}=d,[c,h]=b.useState([]),[u,m]=b.useState();b.useEffect(function(){let I;async function F(){zs.debug("initTable"),I=ve.makeCancelable(e.getTable(),N=>N.close());try{m(await I)}catch(N){ve.isCanceled(N)||zs.error("Unable to initialize table",N)}}return F(),()=>{I.cancel()}},[e]);const p=b.useCallback(E=>{ve.isCanceled(E)||zs.error(E)},[]),g=b.useCallback(E=>{zs.debug("handleDelete, pending confirmation",E),h(E)},[]),C=b.useCallback(()=>{zs.debug("handleDeleteConfirm",c),c.forEach(E=>e.deleteFile(On(E)?he.makePath(E.filename):E.filename)),s(c),h([])},[c,s,e]),f=b.useCallback(()=>{zs.debug("handleDeleteCancel"),h([])},[]),S=b.useCallback((E,I)=>{he.reducePaths(E.map(N=>On(N)?he.makePath(N.filename):N.filename)).forEach(N=>{const H=he.isPath(N)?`${I}${he.getBaseName(N.substring(0,N.length-1))}/`:`${I}${he.getBaseName(N)}`;e.moveFile(N,H).then(()=>{i(N,H)}).catch(p)})},[p,i,e]),v=b.useCallback((E,I)=>{let F=E.filename;const N=On(E);N&&!F.endsWith("/")&&(F=`${F}/`);let H=`${he.getParent(F)}${I}`;N&&!H.endsWith("/")&&(H=`${H}/`),zs.debug2("handleRename",F,H),e.moveFile(F,H).catch(p),i(F,H)},[p,i,e]),w=b.useCallback(async(E,I)=>{if(I===E.basename)return;he.validateName(I);const F=`${he.getPath(E.filename)}${I}`;try{const N=await e.info(F);throw new Ta(N)}catch(N){if(!(N instanceof vd))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(bm,{isMultiSelect:t,focusedPath:n,showContextMenu:!0,onMove:S,onDelete:g,onRename:v,onSelect:o,onSelectionChange:a,rowHeight:r,table:u,validateRename:w}),l.jsx(ji,{isOpen:T,headerText:y,bodyText:"You cannot undo this action.",onCancel:f,onConfirm:C,confirmButtonText:"Delete"})]})}Td.displayName="FileExplorer";const Ks=Z.module("NewItemModal");class Ai extends b.PureComponent{static propTypes={isOpen:D.bool,title:D.string.isRequired,defaultValue:D.string,type:D.oneOf(["file","directory"]).isRequired,onSubmit:D.func,onCancel:D.func,placeholder:D.string,storage:D.shape({}).isRequired,notifyOnExtensionChange:D.bool};static defaultProps={isOpen:!1,defaultValue:"/",notifyOnExtensionChange:!1,placeholder:"",onSubmit:(e,t)=>{},onCancel:()=>{}};static getValidationMessage(e){return e instanceof Ta&&e.info.type==="directory"?"Error: Cannot overwrite existing directory":`${e}`}static handleError(e){ve.isCanceled(e)||Ks.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=X.createRef();cancelableValidatePromise;cancelableExistingItemPromise;pending=new ts;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 Ta(a)}catch(a){if(!(a instanceof vd))throw a}}return t}updateValidationStatus(e,t){this.getValidationPromise(e,t).then(()=>{this.setState({validationError:void 0})}).catch(this.handleValidationError).catch(Ai.handleError)}handleModalOpened(){this.focusRenameInput()}handleModalSubmit(){this.submitModal()}handleChange(e){const{value:t}=e.target;this.setState({value:t})}handleSelect(e){if(Ks.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 Ni))throw e;Ks.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;Ks.debug("handleOverwriteConfirm",t,n),e(`${t}${n}`,!0)}handleExtensionChangeCancel(){Ks.debug("handleExtensionChangeCancel"),this.setState(({value:e,prevExtension:t})=>({showExtensionChangeModal:!1,value:he.replaceExtension(e,t)})),this.submitModal(!0)}handleExtensionChangeConfirm(){Ks.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;Ks.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 Ta&&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(Ai.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(X.Fragment,{children:[l.jsx(V,{kind:"ghost",className:"directory-breadcrumbs",onClick:()=>this.handleBreadcrumbSelect(i),"aria-label":s===0?"Home":void 0,icon:s===0?l.jsx(J,{icon:pg,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:p,newExtension:g}=this.state,C=o==="directory",f=he.fileExtensionToString(p),S=he.fileExtensionToString(g),v=C?"Create":"Save",w=C?"New folder name":"Save file as";return l.jsxs(l.Fragment,{children:[l.jsxs(Do,{isOpen:t,toggle:n,onOpened:this.handleModalOpened,className:"modal-dialog-centered new-file-modal theme-bg-dark",children:[l.jsx(Fo,{toggle:n,children:i}),l.jsx(No,{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:Ai.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(Td,{onSelect:this.handleSelect,storage:e,focusedPath:r})})]})})}),l.jsxs(kl,{children:[l.jsx(V,{kind:"secondary",onClick:n,children:"Cancel"}),l.jsx(V,{kind:"primary",disabled:a,onClick:this.handleModalSubmit,children:v})]})]}),l.jsx(ji,{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(ji,{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 xx({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(V,{kind:"ghost",icon:Fh,tooltip:"New notebook",onClick:d,"aria-label":"New notebook"}),l.jsx(V,{kind:"ghost",icon:gg,tooltip:"New folder",onClick:e,"aria-label":"New folder"})]}),t&&l.jsx("div",{className:"file-explorer-toolbar-search",children:l.jsx(If,{value:n,onChange:t,placeholder:"Search by name"})})]})}const bi=Z.module("FileExplorerPanel"),Rx=(d,e)=>{const t=au(d),n=ai(d,e.localDashboardId),{session:s,config:i}=n??{},o=i?.type;return{fileStorage:t,language:o,session:s}},Ix=ft(Rx,null,null,{forwardRef:!0});function Dx(d){const e=d;return e!=null&&typeof e.button=="number"}class Wa extends X.Component{static COMPONENT="FileExplorerPanel";static TITLE="File Explorer";static handleError(e){bi.error(e)}static isFocusEvent(e){return Dx(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:""};bi.debug("handleCreateFile",t,n,s),e.emit(Xe.CREATE_NOTEBOOK,t,n,s)}handleCreateDirectory(e){this.setState({showCreateFolder:!0})}handleCreateDirectoryCancel(){bi.debug("handleCreateDirectoryCancel"),this.setState({showCreateFolder:!1})}handleCreateDirectorySubmit(e){bi.debug("handleCreateDirectorySubmit",e),this.setState({showCreateFolder:!1});const{fileStorage:t}=this.props;t.createDirectory(e).catch(Wa.handleError)}handleDelete(e){const{glEventHub:t}=this.props;e.forEach(n=>{t.emit(Xe.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(bi.debug("fileSelect",e),e.type==="directory")return;const n=Wa.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(Xe.SELECT_NOTEBOOK,o,a,r,s,n)}handleRename(e,t){const{glEventHub:n}=this.props;bi.debug("handleRename",e,t),n.emit(Xe.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(ns,{className:"file-explorer-panel",componentPanel:this,glContainer:t,glEventHub:n,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onShow:this.handleShow,children:[l.jsx(xx,{createFile:this.handleCreateFile,createFolder:this.handleCreateDirectory}),s&&l.jsx(Td,{isMultiSelect:!0,storage:e,onDelete:this.handleDelete,onRename:this.handleRename,onSelect:this.handleFileSelect,onSelectionChange:this.handleSelectionChange}),l.jsx(Ai,{isOpen:i,type:"directory",title:"Create New Folder",storage:e,onSubmit:this.handleCreateDirectorySubmit,onCancel:this.handleCreateDirectoryCancel,defaultValue:o})]})}}const Ga=Ix(Wa);const ot=Z.module("FilterSetManager"),Fx="Enter name...",Qc="No Available Filter Sets";class za 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=X.createRef();dropdownRef=X.createRef();editDropdownRef=X.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;za.animateScreenFlash();const t=Pe(),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;za.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,p=!h&&m&&r.length===0,g=!h&&!p,C=l.jsxs("div",{className:"fa-layers mr-3",children:[l.jsx(J,{icon:_i,mask:il,transform:"shrink-1 down-5 right-7"}),l.jsx(J,{icon:Os,className:"text-primary",transform:"shrink-6 down-5 right-7"})]}),f=l.jsxs("div",{className:"fa-layers",children:[l.jsx(J,{icon:_i,mask:il,transform:"shrink-1 down-5 right-7"}),l.jsx(J,{icon:ol,transform:"shrink-1 down-5 right-7"})]});return l.jsx("div",{className:"filter-set-manager fill-parent-absolute",children:l.jsxs(Ol,{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:[p&&l.jsxs("div",{children:[l.jsx(V,{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:Fx,value:e,ref:this.renameInputRef,onChange:this.handleNameInputChange,onKeyPress:this.handleNameInputKeyPress,spellCheck:"false"}),l.jsx(V,{"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:Ah}),l.jsx(V,{"data-testid":"rename-cancel-button",kind:"ghost",className:"btn btn-link no-underline pt-2 pb-2",onClick:this.handleRenameCancel,tooltip:"Cancel",icon:fg})]}),t!==void 0&&l.jsx("div",{className:"error-message",children:t})]}),l.jsx("div",{className:"form-group",children:l.jsxs(rr,{onChange:this.handleRestoreFullStateChange,value:`${o}`,children:[l.jsx(Qn,{value:"false",children:"Restore only filters"}),l.jsx(Qn,{value:"true",children:"Restore full table state"})]})})]}),g&&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:Qc}),i.map(({id:S,title:v})=>l.jsx("option",{value:S,children:v},S))]}),l.jsx(V,{kind:"ghost",onClick:this.handleSetUpdate,disabled:m,icon:f,tooltip:"Update"}),l.jsx(V,{kind:"ghost",onClick:this.handleSetEdit,disabled:m,icon:Oo,tooltip:"Edit"}),l.jsx(V,{kind:"ghost",onClick:this.handleSetDelete,disabled:m,icon:Qt,tooltip:"Delete"})]})]}),l.jsx("div",{children:l.jsx(V,{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(V,{kind:"secondary",onClick:this.handleSettingsCancel,children:"Cancel"})," ",l.jsx(V,{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:Qc}),r.map(({id:S,title:v})=>l.jsx("option",{value:S,children:v},S))]}),l.jsx(V,{"data-testid":"filter-apply-button",kind:"ghost",onClick:this.handleFilterApply,icon:Dl,tooltip:"Apply Filter Set"})]})})}),l.jsx("div",{className:"filter-set-manager-menu",children:l.jsx(V,{kind:"ghost",className:"btn btn-link btn-link-icon m-2 px-2",onClick:this.handleSettingsClick,tooltip:"Settings",icon:l.jsx(J,{icon:ko,transform:"grow-4"})})})]},"back")]})})}}function Ed(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(wr,{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})]})})}Ed.propTypes={glContainer:ed.Container.isRequired,widgetName:D.string.isRequired,description:D.string};Ed.defaultProps={description:null};const Rn=Z.module("IrisGridPanel"),Nx=500,Mx={IrisGrid:um,IrisGridTableModel:mm,ContextMenuRoot:_h};class Cl 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=X.createRef(),this.pluginRef=X.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(nm.DEFAULTS),customColumns:[],customColumnFormatMap:new Map,isFilterBarShown:!1,quickFilters:new Map,sorts:[],userColumnWidths:new Map,userRowHeights:new Map,reverseType:R.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=q.getIdFromPanel(this);return n!=null&&(s==null||i!=null&&!s.includes(i))})));getAlwaysFetchColumns=fe((e,t)=>{const n=q.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||!si(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:Mx,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,p,g,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:p,sorts:t,invertSearchColumns:g,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();Rn.debug("initModelQueue",s),s&&s(n),this.setState({modelQueue:t})}handleAdvancedSettingsChange(e,t){Rn.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(Cn.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){Rn.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(Yt.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=q.getIdFromPanel(this);let c;a&&(c=be.extractTableSettings(a,s)),n.emit(Cn.CREATE_CHART,{metadata:{settings:e,sourcePanelId:r,table:o,tableSettings:c},table:si(t)?t.table:void 0})})}handleColumnSelected(e){const{glEventHub:t}=this.props;t.emit(Cn.COLUMN_SELECTED,this,e)}handleDataSelected(e,t){const{glEventHub:n}=this.props;n.emit(Cn.DATA_SELECTED,this,t)}handleResize(){this.updateGrid()}handleShow(){this.updateGrid()}handleTabClicked(){this.irisGrid.current&&this.irisGrid.current.focus()}handleError(e){Rn.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}),si(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){Rn.debug2("sendColumnsChange",e);const{glEventHub:t}=this.props;t.emit(Qe.COLUMNS_CHANGED,this,e)}startModelListening(e){e.addEventListener(Ce.EVENT.DISCONNECT,this.handleDisconnect),e.addEventListener(Ce.EVENT.RECONNECT,this.handleReconnect),e.addEventListener(Ce.EVENT.COLUMNS_CHANGED,this.handleColumnsChanged),e.addEventListener(Ce.EVENT.TABLE_CHANGED,this.handleTableChanged)}stopModelListening(e){e.removeEventListener(Ce.EVENT.DISCONNECT,this.handleDisconnect),e.removeEventListener(Ce.EVENT.RECONNECT,this.handleReconnect),e.removeEventListener(Ce.EVENT.COLUMNS_CHANGED,this.handleColumnsChanged),e.removeEventListener(Ce.EVENT.TABLE_CHANGED,this.handleTableChanged)}getCoordinateForColumn(e){const{model: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 p=n.getVisibleColumn(m),g=r.get(p)??0,C=c.get(p)??0,f=Math.max(i.left,Math.min(p>h?i.right:i.left+g+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}){Rn.debug("setFilters",e,t);const{model:n,isDisconnected:s}=this.state,i=this.irisGrid.current;if(i==null||s){Rn.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){Rn.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:p,advancedSettings:g}=be.hydrateIrisGridPanelState(e,a),{advancedFilters:C,customColumns:f,customColumnFormatMap:S,isFilterBarShown:v,quickFilters:w,reverseType:T,rollupConfig:y,aggregationSettings:E,sorts:I,userColumnWidths:F,userRowHeights:N,showSearchBar:H,searchValue:P,selectDistinctColumns:O,selectedSearchColumns:k,invertSearchColumns:L,pendingDataMap:A,frozenColumns:U,conditionalFormats:j,columnHeaderGroups:W}=be.hydrateIrisGridState(e,{...o,...r}),{isStuckToBottom:ie,isStuckToRight:se,movedColumns:G,movedRows:K}=be.hydrateGridState(e,{...i,...s},o.customColumns);this.setState({advancedFilters:C,advancedSettings:g,conditionalFormats:j,customColumns:f,customColumnFormatMap:S,isFilterBarShown:v,isSelectingPartition:u,movedColumns:G,movedRows:K,partition:m,partitionColumn:p,quickFilters:w,reverseType:T,rollupConfig:y,aggregationSettings:E,sorts:I,userColumnWidths:F,userRowHeights:N,showSearchBar:H,searchValue:P,selectDistinctColumns:O,selectedSearchColumns:k,invertSearchColumns:L,pendingDataMap:A,frozenColumns:U,isStuckToBottom:ie,isStuckToRight:se,columnHeaderGroups:W})}catch(i){Rn.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:p,isFilterBarShown:g,quickFilters:C,customColumns:f,reverseType:S,rollupConfig:v,showSearchBar:w,searchValue:T,selectDistinctColumns:y,selectedSearchColumns:E,sorts:I,invertSearchColumns:F,metrics:N,pendingDataMap:H,frozenColumns:P,conditionalFormats:O,columnHeaderGroups:k}=e;M(i),M(N);const{userColumnWidths:L,userRowHeights:A}=N;M(t);const{isStuckToBottom:U,isStuckToRight:j,movedColumns:W,movedRows:ie}=t,se=this.getCachedPanelState(this.getDehydratedIrisGridPanelState(i,a,r,c,h),this.getDehydratedIrisGridState(i,I,u,p,g,C,f,S,v,w,T,y,E,F,L,A,m,H,P,O,k),this.getDehydratedGridState(i,W,ie,U,j),n);se!==o&&(Rn.debug("Saving panel state",this,se),this.setState({panelState:se}),s?.(se))},Nx);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:p}=this.props,{advancedFilters:g,aggregationSettings:C,advancedSettings:f,conditionalFormats:S,customColumns:v,customColumnFormatMap:w,error:T,isDisconnected:y,isFilterBarShown:E,isSelectingPartition:I,isStuckToBottom:F,isStuckToRight:N,isLoaded:H,isLoading:P,isModelReady:O,model:k,movedColumns:L,movedRows:A,partition:U,partitionColumn:j,quickFilters:W,reverseType:ie,rollupConfig:se,sorts:G,userColumnWidths:K,userRowHeights:te,showSearchBar:oe,searchValue:de,selectDistinctColumns:ee,selectedSearchColumns:re,invertSearchColumns:we,Plugin:xe,pluginFilters:Oe,pluginFetchColumns:Jt,pendingDataMap:Mt,frozenColumns:ss,columnHeaderGroups:Tn}=this.state,kt=T!=null?`Unable to open table. ${T}`:void 0,{table:ye}=r,ht=k?.description??void 0,at=c?.pluginState??null,St=e??this.getPluginContent(xe,k,h,u,at),{permissions:Ot}=h,{canCopy:En,canDownloadCsv:en}=Ot;return l.jsx(md,{errorMessage:kt,isDisconnected:y,isLoading:P,isLoaded:H,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:ht,componentPanel:this,renderTabTooltip:()=>l.jsx(Ed,{model:k,widgetName:ye,glContainer:t,description:ht}),children:O&&k&&l.jsx(um,{advancedFilters:g,aggregationSettings:C,advancedSettings:f,alwaysFetchColumns:this.getAlwaysFetchColumns(a,Jt),columnAllowedCursor:"linker",columnNotAllowedCursor:"linker-not-allowed",customColumns:v,customColumnFormatMap:w,columnSelectionValidator:this.isColumnSelectionValid,conditionalFormats:S,inputFilters:this.getGridInputFilters(k.columns,o),applyInputFiltersOnInit:c==null,isFilterBarShown:E,isSelectingColumn:s!=null,isSelectingPartition:I,isStuckToBottom:F,isStuckToRight:N,movedColumns:L,movedRows:A,partition:U,partitionColumn:j,quickFilters:W,reverseType:ie,rollupConfig:se,settings:m,sorts:G,userColumnWidths:K,userRowHeights:te,model:k,showSearchBar:oe,searchValue:de,selectedSearchColumns:re,selectDistinctColumns:ee,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:Oe,pendingDataMap:Mt,canCopy:En,canDownloadCsv:en,ref:this.irisGrid,getDownloadWorker:i,frozenColumns:ss,theme:p,columnHeaderGroups:Tn,children:St})})}}const kx=(d,{localDashboardId:e=wn})=>({inputFilters:pd(d,e),links:Ki(d,e),columnSelectionValidator:Cd(d,e),user:iu(d),workspace:dr(d),settings:Ct(d)}),oi=ft(kx,null,null,{forwardRef:!0})(Cl);const Jc=Z.module("InputFilter"),Ox=150;class Ka 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=X.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=pe((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)];Jc.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;Jc.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})},Ox);render(){const{columns:e}=this.props,{column:t,isValueShown:n,selectedColumn:s,value:i}=this.state,o=i==null||i.length===0?Ka.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(Ol,{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(V,{kind:"secondary",onClick:this.handleSettingsCancel,disabled:t==null,children:"Cancel"}),l.jsx(V,{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:Ka.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(V,{kind:"ghost",className:"m-2 px-2",onClick:this.handleSettingsClick,icon:l.jsx(J,{icon:ko,transform:"grow-4"}),tooltip:"Input Filter Settings"})})]})]})}}const Ax=250;class Lx extends b.Component{static defaultProps={panelState:null};static COMPONENT="InputFilterPanel";static displayName="InputFilterPanel";constructor(e){super(e),this.handleChange=Ye(this.handleChange.bind(this),Ax),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.inputFilterRef=X.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(ns,{className:"iris-input-filter-panel",componentPanel:this,glContainer:e,glEventHub:t,onClearAllFilters:this.handleClearAllFilters,isClonable:!0,isRenamable:!0,children:l.jsx(Ka,{ref:this.inputFilterRef,column:n,columns:s,onChange:this.handleChange,isValueShown:i,value:o})})}}const Px=(d,e)=>{const{localDashboardId:t}=e;return{columns:gm(d,t)}},wo=ft(Px,null,null,{forwardRef:!0})(Lx);const wt=Z.module("FilterSetManagerPanel");function _x(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){wt.error("Could not get panel",s);return}const i=q.getComponentNameFromPanel(s),o=q.getIdFromPanel(s);wt.debug("Panel:",s,i);const{glContainer:a=null}=s.props;if(a==null){wt.error("Could not get panel container",s);return}const r=q.getComponentConfigFromContainer(a);if(r==null){wt.error("Could not get component config from container",a);return}const c=q.getPanelComponentState(r);if(c==null){wt.debug(`Panel state is null ${o}`);return}switch(i){case q.getComponentName(Cl):{let h;o!=null&&(h=this.getIrisGridPanelFilters(o,c)),h!=null&&t.push({panelId:o,type:i,state:h});break}case q.getComponentName(wo):case q.getComponentName(ii):{const{isValueShown:h,name:u,type:m,value:p}=c;t.push({panelId:o,type:i,state:{isValueShown:h,name:u,type:m,value:p}});break}}}),t}getIrisGridPanelFilters(e,t){const{panelTableMap:n}=this.props,s=n.get(e);if(s==null)return wt.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}){wt.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;wt.debug("Apply filters from filter set",e),n.forEach(({panelId:i,type:o,state:a})=>{if(i==null){wt.debug("panel is null",i);return}if(!t.has(i)){wt.debug("Ignore closed panel",i);return}wt.debug("Apply panel filters",i,o,a);const r=t.get(i);switch(o){case q.getComponentName(Cl):this.restoreIrisGridFilters(r,a,s);break;case q.getComponentName(wo):case q.getComponentName(ii):this.restoreInputFilterState(r,a);break}})}handleSetsUpdate(e){const{setDashboardFilterSets:t,localDashboardId:n}=this.props;wt.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=q.getIdFromPanel(e);if(h==null){wt.error("Panel Id is null.");return}if(c.get(h)==null){wt.error(`Unable to get table for panel ${h}.`);return}wt.debug("restoreIrisGridFilters",h,t,n),n?e.setStateOverrides(t):e.setFilters({quickFilters:r,advancedFilters:a})}restoreInputFilterState(e,t){const n={...t};delete n.isValueShown,wt.debug("restoreInputFilterState",e,n),e&&_x(e)&&e.setPanelState(n)}render(){const{glContainer:e,glEventHub:t,filterSets:n}=this.props,{isValueShown:s,selectedId:i}=this.state;return l.jsx(ns,{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(za,{onChange:this.handleChange,onApply:this.handleFilterApply,onUpdateSets:this.handleSetsUpdate,isValueShown:s,filterSets:n,selectedId:i,getFilterState:this.handleGetFilterState})})})}}const jx=(d,e)=>{const{localDashboardId:t}=e;return{filterSets:Xy(d,t),dashboardOpenedPanelMap:Gu(d,t),dashboardInputFilters:pd(d,t),panelTableMap:gd(d,t)}},Yr=ft(jx,{setDashboardFilterSets:ix},null,{forwardRef:!0})(qa);const eh=Z.module("LogPanel");class Hx 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){eh.debug("Session opened",[e]),this.setState({session:e})}handleSessionClosed(e){eh.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(ns,{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(mS,{session:n,ref:s=>{this.logView=s}})]})}}const Bx=(d,e)=>({session:ai(d,e.localDashboardId)?.session}),Ya=ft(Bx,null,null,{forwardRef:!0})(Hx);class Vx 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(J,{icon:Oo})]})}),t]})}}const Ux=Z.module("MarkdownStartPage");class $x 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(Ux.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(V,{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(V,{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(J,{icon:Qt})})]},o.id)),l.jsxs(Do,{isOpen:s,toggle:this.handleDeleteModalClose,className:"modal-dialog-centered markdown-delete-modal theme-bg-light",children:[l.jsx(Fo,{children:"Are you sure you want to permanently delete this note?"}),l.jsx(No,{children:"You can't undo this action."}),l.jsxs(kl,{children:[l.jsx(V,{kind:"secondary",onClick:this.handleDeleteModalClose,children:"Cancel"}),l.jsx(V,{kind:"danger",onClick:()=>{this.handleDeleteMarkdown(i)},children:"Delete"})]})]})]})]})})}}const Wx=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(lr,{language:n,children:X.Children.map(e,s=>typeof s=="string"?s.trim():s)})})})};class Gx 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(Ul,{settings:{language:"markdown",value:t,lineNumbers:"off"},onEditorInitialized:n}):l.jsx(vh,{components:{code:Wx},children:t})})}}const ga=Z.module("MarkdownPanel");class zx 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){ga.debug("Markdown Editor Initialized..."),this.editor=e}handleCreateMarkdown(){ga.debug("create markdown..."),this.setState({isStartPageShown:!1,content:"",isEditing:!0,panelState:{content:""}},()=>{this.editor!=null&&this.editor.focus!=null&&this.editor.focus()})}handleOpenMarkdown(e){ga.debug("open markdown...",e);const{glContainer:t,glEventHub:n}=this.props,s=q.getComponentConfigFromContainer(t);n.emit(Ee.REOPEN,e,s)}handleDeleteMarkdown(e){const{glEventHub:t}=this.props;t.emit(Ee.DELETE,e)}handleEditorBlur(e){ga.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(ns,{glContainer:e,glEventHub:t,className:"markdown-panel",componentPanel:this,onResize:this.handleEditorResize,onBlur:this.handleEditorBlur,isClonable:!0,isRenamable:!0,children:i?l.jsx($x,{closedMarkdowns:a,onCreate:this.handleCreateMarkdown,onOpen:this.handleOpenMarkdown,onDelete:this.handleDeleteMarkdown}):l.jsx(Vx,{isEditing:s,onDoubleClick:this.handleContainerDoubleClick,children:l.jsx(Gx,{ref:r=>{this.markdownEditor=r},isEditing:s,content:o??void 0,onEditorInitialized:this.handleEditorInitialized})})})}}const Kx=(d,e)=>{const{localDashboardId:t}=e;return{closedPanels:Ow(d,t)}},co=ft(Kx,null,null,{forwardRef:!0})(zx);class qx 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=X.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,p=X.createRef(),g=this.commands.size===0,C=a===u||g&&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,p),l.jsxs("div",{className:$("markdown-notebook-code-block",{"is-selected":C}),ref:p,onClick:()=>{this.setState({nextStartLine:u})},role:"presentation",children:[l.jsx(V,{kind:"ghost",icon:ya,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(lr,{language:f,children:X.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(V,{className:$("btn-play-selected-cell",{flashing:s&&!i}),kind:"ghost",icon:ya,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(vh,{components:{code:this.renderCodeBlock,a:this.renderLink},linkTarget:"_blank",remarkPlugins:[lp],transformLinkUri:n,transformImageUri:t,includeElementIndex:!0,children:e})})]})}}const Le=Z.module("NotebookPanel"),th=400;class Js extends b.Component{static COMPONENT="NotebookPanel";static POPPER_OPTIONS={placement:"bottom-end"};static DEFAULT_NAME="Untitled";static handleError(e){ve.isCanceled(e)||Le.error(e)}static defaultProps={isDashboardActive:!0,isPreview:!1,session:null,sessionLanguage:null,defaultNotebookSettings:null,notebooksUrl:new URL("/notebooks/",`${window.location}`).href};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.handlePanelTabClick=this.handlePanelTabClick.bind(this),this.handleRenameFile=this.handleRenameFile.bind(this),this.handleResize=this.handleResize.bind(this),this.handleRunCommand=this.handleRunCommand.bind(this),this.handleRunAll=this.handleRunAll.bind(this),this.handleRunSelected=this.handleRunSelected.bind(this),this.handleSave=this.handleSave.bind(this),this.handleSaveAsCancel=this.handleSaveAsCancel.bind(this),this.handleSaveAsSubmit=this.handleSaveAsSubmit.bind(this),this.handleSaveError=this.handleSaveError.bind(this),this.handleSaveSuccess=this.handleSaveSuccess.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleShowRename=this.handleShowRename.bind(this),this.handleTab=this.handleTab.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTransformLinkUri=this.handleTransformLinkUri.bind(this),this.handleOverwrite=this.handleOverwrite.bind(this),this.getDropdownOverflowActions=this.getDropdownOverflowActions.bind(this),this.pending=new ts,this.debouncedSavePanelState=Ye(this.savePanelState.bind(this),th),this.debouncedLoad=Ye(this.load.bind(this),th),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:"",shouldPromptClose:!0},Le.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(Xe.RENAME_FILE,this.handleRenameFile),e.on("tabClicked",this.handlePanelTabClick)}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{glContainer:e,glEventHub:t}=this.props,{fileMetadata:n,isPreview:s}=this.state;t.off(Xe.RENAME_FILE,this.handleRenameFile),e.off("tabClicked",this.handlePanelTabClick),t.emit(Xe.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,shouldPromptClose:i}=this.state;return n!==s&&i?(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){Le.debug("Init content from file"),this.registerFileMetadata(e,n),this.load();return}if(t.value!=null){Le.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(Xe.CLOSE_FILE,{id:e})}registerFileMetadata(e,t){const{glEventHub:n,metadata:s}=this.props,{id:i}=s;n.emit(Xe.REGISTER_FILE,i,e,t)}renameTab(e,t){const{glEventHub:n}=this.props;n.emit(Xe.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=>{Le.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:Js.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){Le.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;Le.debug("setPreviewStatus",this.tabTitleElement,e),e?this.tabTitleElement.classList.add("is-preview"):this.tabTitleElement.classList.remove("is-preview")}getSettings=fe((e,t)=>({...e,minimap:{enabled:t}}));getOverflowActions=fe((e,t)=>[{title:"Find",icon:Sg,action:this.handleFind,group:ae.groups.high,shortcut:Nt.NOTEBOOK.FIND,order:10},{title:"Show Minimap",icon:e?Xn:void 0,action:this.handleMinimapChange,group:ae.groups.medium,shortcut:Nt.NOTEBOOK.MINIMAP,order:20},{title:"Word Wrap",icon:t?Xn:void 0,action:this.handleWordWrapChange,group:ae.groups.medium,shortcut:Nt.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 Le.debug("Saving panel state",u),{settings:c,panelState:u}})}handleCloseDiscard(){this.setState({shouldPromptClose:!1,showCloseModal:!1});const{glContainer:e}=this.props;e.close()}handleCloseSave(){if(this.setState({shouldPromptClose:!1,showCloseModal:!1}),this.save()){const{glContainer:e}=this.props;e.close()}}handleCloseCancel(){this.setState({shouldPromptClose:!0,showCloseModal:!1})}handleOverwrite(e){const{glEventHub:t}=this.props;t.emit(Xe.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);Le.debug("handleCopy",e,i,o),this.createNotebook(o,s,n)}handleEditorInitialized(e){this.editor=e}handleEditorWillDestroy(){this.editor=void 0}handleEditorChange(e){Le.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(){Le.debug("handleBlur"),this.setState({isFocused:!1})}handleFocus(){Le.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==="/"){Le.debug("Ignoring invalid notebook link",o);return}Le.debug("Notebook link clicked, opening",o);const{glEventHub:a}=this.props,r={value:null,language:s},c={id:o,itemName:o};a.emit(Xe.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.")),Le.error(t),this.setState({error:t,isLoading:!1}))}handleSave(){Le.debug("handleSave"),this.save()}handleSaveSuccess(e){const{fileStorage:t}=this.props,n={id:e.filename,itemName:e.filename},s=Js.languageFromFileName(e.filename)??"";this.setState(i=>{const{fileMetadata:o}=i,a={...i.settings,language:s};return Le.debug("handleSaveSuccess",n,o,a),o&&he.hasPath(o.itemName)&&o.itemName!==n.itemName&&(Le.debug("handleSaveSuccess deleting old file",o.itemName),t.deleteFile(o.itemName).catch(Js.handleError)),{fileMetadata:n,settings:a,isPreview:!1}}),this.debouncedSavePanelState(),this.registerFileMetadata(n,!1)}handleSaveError(e){ve.isCanceled(e)||(this.setState({savedChangeCount:0}),Le.error(e))}handleSaveAsCancel(){this.setState({showSaveAsModal:!1})}handleSaveAsSubmit(e,t=!1){t&&this.handleOverwrite(e),Le.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){Le.error("Editor is not initialized.");return}this.runCommand(this.notebook.getValue()??void 0)}handleRunSelected(){if(!this.notebook){Le.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(){Le.debug("handleShow"),this.notebook?.updateDimensions()}handleShowRename(){this.setState({showSaveAsModal:!0})}handleTab(e){Le.debug("NotebookPanel tab event",e),this.initTab(e)}handleTabFocus(...e){Le.debug("handleTabFocus",...e);const{glContainer:t}=this.props;this.setState({isDashboardActive:!0}),this.notebook&&!t.isHidden&&this.notebook.updateDimensions()}handleTabBlur(){Le.debug("handleTabBlur"),this.setState({isDashboardActive:!1})}handlePanelTabClick(){Le.debug("handlePanelTabClick"),this.focus()}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};Le.debug("handleCreateNotebook",i,o,r,c),s.emit(Xe.CREATE_NOTEBOOK,i,o,r,c)}runCommand(e){if(e===void 0){Le.debug("Ignoring empty command.");return}this.removePreviewStatus();const{glEventHub:t}=this.props;t.emit(Yt.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:p,session:g,sessionLanguage:C,settings:f,showCloseModal:S,showSaveAsModal:v}=this.state,w=c&&!t.isHidden&&!m,T=p?.itemName??Js.DEFAULT_NAME,y=T.endsWith(".md"),E=p?.id!=null,I=this.getSettings(f,i.isMinimapEnabled),F=g!=null,N=C===I.language,H=!h||!F||!N,P=!h,O=[{action:this.handleSave,shortcut:es.SAVE},{action:this.handleMinimapChange,shortcut:Nt.NOTEBOOK.MINIMAP},{action:this.handleWordWrapChange,shortcut:Nt.NOTEBOOK.WORDWRAP}],k=mc.getDisabledRunTooltip(F,N,"Notebook extension","Run"),L=mc.getDisabledRunTooltip(F,N,"Notebook extension","Run Selected"),A=[{title:E?"Rename":"Save As…",order:10,group:ae.groups.high,action:this.handleShowRename},{title:"Copy File",action:this.handleCopy,group:ae.groups.high,order:20}],U=n?.element.find(".lm_title_before").get(0);return l.jsxs(l.Fragment,{children:[U&&Pi.createPortal(l.jsx("span",{className:$("editor-unsaved-indicator",{"is-unsaved":o!==a})}),U),l.jsxs(ns,{className:"notebook-container",componentPanel:this,glContainer:t,glEventHub:s,onTab:this.handleTab,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleTabFocus,onTabBlur:this.handleTabBlur,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onFocus:this.handleFocus,onBlur:this.handleBlur,additionalActions:A,renderTabTooltip:()=>T,children:[!y&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"notebook-toolbar",children:[l.jsxs("span",{children:[l.jsx(V,{kind:"ghost",className:"btn-play",onClick:this.handleRunAll,disabled:H,icon:l.jsx(J,{icon:ya,transform:"grow-4"}),tooltip:`Run ${Nt.NOTEBOOK.RUN.getDisplayText()}`,"aria-label":"Run"}),k!=null&&l.jsx(tt,{children:k})]}),l.jsxs("span",{children:[l.jsx(V,{kind:"ghost",className:"btn-play",onClick:this.handleRunSelected,disabled:H,icon:l.jsx(J,{icon:Cg,transform:"grow-4"}),tooltip:`Run Selected ${Nt.NOTEBOOK.RUN_SELECTED.getDisplayText()}`,"aria-label":"Run Selected"}),L!=null&&l.jsx(tt,{children:L})]}),l.jsx(V,{kind:"ghost",className:"mr-auto",disabled:P,onClick:this.handleSave,icon:Ah,tooltip:`Save ${es.SAVE.getDisplayText()}`,"aria-label":"Save"}),l.jsx(V,{kind:"ghost",className:"btn-overflow btn-link-icon",disabled:P,icon:Dh,tooltip:"More Actions...",onClick:()=>{},children:l.jsx(Zn,{actions:this.getDropdownOverflowActions,popperOptions:Js.POPPER_OPTIONS})})]}),l.jsx(eS,{isLoaded:h,isLoading:u,error:r,onChange:this.handleEditorChange,onRunCommand:this.handleRunCommand,session:g,sessionLanguage:C,onEditorInitialized:this.handleEditorInitialized,onEditorWillDestroy:this.handleEditorWillDestroy,settings:I,focusOnMount:w,ref:j=>{this.notebook=j}})]}),y&&l.jsx(qx,{content:I.value??"",onLinkClick:this.handleLinkClick,onRunCode:this.handleRunCommand,transformImageUri:this.handleTransformLinkUri,transformLinkUri:this.handleTransformLinkUri}),l.jsx(Ai,{isOpen:v,type:"file",defaultValue:T,title:E?"Rename":"Save file as",onSubmit:this.handleSaveAsSubmit,onCancel:this.handleSaveAsCancel,notifyOnExtensionChange:!0,storage:e}),l.jsx(ji,{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(ae,{actions:O})]})]})}}const Yx=(d,e)=>{const t=au(d),n=Ct(d),s=VS(d),i=ai(d,e.localDashboardId),{session:o,config:a}=i??{},{type:r}=a??{};return{fileStorage:t,settings:n,defaultNotebookSettings:s,session:o,sessionLanguage:r}},qs=ft(Yx,{saveSettings:hr},null,{forwardRef:!0})(Js);class Xr extends b.Component{static defaultProps={panelState:null};static COMPONENT="PandasPanel";constructor(e){super(e),this.irisGridRef=X.createRef(),this.buttonRef=X.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(oi,{ref:this.irisGridRef,onStateChange:this.handleGridStateChange,onPanelStateUpdate:this.handlePanelStateUpdate,...e,children:l.jsxs(V,{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(J,{icon:Dl,transform:"shrink-1",className:"mr-1"}),"Reload"]})]})})}}function Xx(d){Ps(d);const{id:e,layout:t,registerComponent:n,hydrate:s}=d,i=b.useCallback(({dragEvent:o,fetch:a,panelId:r=Pe.generate(),widget:c})=>{const{name:h,type:u}=c;if(u!==dh.VariableType.FIGURE)return;const m={name:h,figure:h},p=()=>a().then(f=>Aa.makeModel(void 0,f)),g={type:"react-component",component:ki.COMPONENT,props:{localDashboardId:e,id:r,metadata:m,makeModel:p},title:h,id:r},{root:C}=t;q.openComponent({root:C,config:g,dragEvent:o})},[e,t]);return b.useEffect(function(){const a=[n(ki.COMPONENT,ki,s)];return()=>{a.forEach(r=>r())}},[s,n]),Ue(t.eventHub,Ee.OPEN,i),null}function Zx(d){Ps(d);const{id:e,layout:t}=d,n=b.useCallback(({metadata:s,panelId:i=Pe.generate(),table:o})=>{const{settings:a}=s,r=()=>Aa.makeModelFromSettings(a,o),c=Je.titleFromSettings(a),h={type:"react-component",component:ki.COMPONENT,props:{localDashboardId:e,id:i,metadata:s,makeModel:r},title:c,id:i},{root:u}=t;q.openComponent({root:u,config:h})},[e,t]);return Ue(t.eventHub,Cn.CREATE_CHART,n),null}const rt=Z.module("ConsolePlugin");function nh(d){return d.notebook!==void 0}function Qx(d){Ps(d)}function Jx(d){Qx(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=El(),p=b.useCallback(()=>s.getLastUsedPanelOfType(Ii),[s]),g=b.useCallback((G,K)=>{c(te=>new Map(te.set(G,K)))},[c]),C=b.useCallback(G=>{c(K=>(K.delete(G),new Map(K)))},[c]),f=b.useCallback((G,K)=>{u(te=>new Map(te.set(G,K)))},[u]),S=b.useCallback(G=>{u(K=>(K.delete(G),new Map(K)))},[u]),v=b.useCallback((G,K=!0,te=!0)=>{if(!(G&&G.trim()))rt.info("Ignoring empty code");else{const de=p();if(!de||!(de instanceof Ii.WrappedComponent)){rt.error("Console panel not found");return}rt.debug("Send command: ",G,K,te),de.addCommand(G,K,te)}},[p]),w=b.useCallback(G=>{m(sx(e,G))},[m,e]),T=b.useCallback(({language:G})=>{const K=G==="python"?"py":G;let te=null;return K==null?(rt.debug("No extension for language",G),te=`Untitled-${a.current}`):te=`Untitled-${a.current}.${K}`,a.current+=1,te},[]),y=b.useCallback((G,K=!0)=>{const{id:te}=G;return te!=null&&r.has(te)?r.get(te):te!=null&&h.has(te)?h.get(te):K?Pe.generate():null},[r,h]),E=b.useCallback((G,K)=>{q.renameComponent(n.root,{id:G},K)},[n.root]),I=b.useCallback((G,K)=>{rt.debug("Rename file panel",G,K);let te;if(r.has(G)&&(te=r.get(G),C(G),te!=null&&g(K,te)),h.has(G)&&(te=h.get(G),S(G),te!=null&&f(K,te)),te===void 0){rt.debug2(`File ${G} isn't open, no need to rename the tab`);return}E(te,he.getBaseName(K))},[r,h,E,g,f,C,S]),F=b.useCallback(G=>{const K=y(G,!1);if(K==null){rt.error("Could not find panel id for file metadata",G);return}q.activateTab(n.root,{id:K})},[y,n.root]),N=b.useCallback((G,K,te)=>{if(rt.debug("registerFilePanel",G,K,te),K==null||K.id==null){rt.debug("Ignore empty file id",K);return}const{id:oe}=K;if(te){f(oe,G);return}if(r.has(oe)){const de=r.get(oe);if(G===de){rt.debug(`Update tab title for file ${oe}`);const{itemName:ee}=K;I(oe,ee)}else rt.error(`File ${oe} already associated with a different tab ${de}`);return}g(oe,G),h.has(oe)&&S(oe)},[r,h,I,g,f,S]),H=b.useCallback((G,K)=>{if(rt.debug("unregisterFileTab",G,K),G==null||G.id==null){rt.debug("Ignore empty file id",G);return}const{id:te}=G;if(K){S(te);return}C(te)},[C,S]),P=b.useCallback((G,K)=>{rt.debug("closeFilePanel",G);const{id:te}=G;let oe=null,de=!1;if(r.has(te))oe=r.get(te);else if(h.has(te))oe=h.get(te),de=!0;else{rt.debug(`File ${te} isn't open, ignore close event`);return}H(G,de),q.closeComponent(n.root,{id:oe},K)},[n.root,r,h,H]),O=b.useCallback(G=>{const{itemName:K}=G;return he.getBaseName(K)},[]),k=b.useCallback(G=>{const{id:K}=G;return rt.debug("fileIsOpen",G,K,r),K!=null&&r.has(K)},[r]),L=b.useCallback(G=>{const{id:K}=G;return rt.debug("fileIsOpenAsPreview",G,K,h),K!=null&&h.has(K)},[h]),A=b.useCallback(G=>{if(G==null)return;const K=s.getOpenedPanelById(G);K&&nh(K)&&K.focus()},[s]),U=b.useCallback(({id:G,settings:K,fileMetadata:te,session:oe,sessionLanguage:de,isPreview:ee=!1})=>{const re={settings:K,fileMetadata:te},we=O(te);return{type:"react-component",component:qs.COMPONENT,isFocusOnShow:!1,props:{localDashboardId:e,metadata:{id:G},session:oe,sessionLanguage:de,panelState:re,isPreview:ee,notebooksUrl:o},title:we,id:G}},[O,e,o]),j=b.useCallback((G,K,te,oe={id:null,itemName:T(te)})=>{const de=y(oe);if(k(oe)&&de!=null){rt.debug("File is already open, focus panel"),F(oe),A(de);return}const ee=q.getStackForComponentTypes(n.root,[qs.COMPONENT]),re=U({id:de,settings:te,fileMetadata:oe,session:G,sessionLanguage:K});rt.debug("createNotebook",re,r),q.openComponentInStack(ee,re)},[k,A,T,y,n.root,U,r,F]),W=b.useCallback((G,K,te,oe,de=!1)=>{rt.debug("selectNotebook",oe,de);const ee=k(oe),re=L(oe);if(ee){if(F(oe),de){const Mt=y(oe);A(Mt)}return}if(re&&!de){F(oe);return}const[we]=Array.from(h.values());let xe=null,Oe=null;we!=null&&(xe=we,Oe=q.getStackForConfig(n.root,{component:qs.COMPONENT,id:xe})),Oe==null&&(xe=y(oe),Oe=q.getStackForComponentTypes(n.root,[qs.COMPONENT]));const Jt=U({id:xe,settings:te,fileMetadata:oe,session:G,sessionLanguage:K,isPreview:!de});q.openComponentInStack(Oe,Jt),de&&A(xe)},[F,k,L,A,y,n.root,U,h]),ie=b.useCallback((G,K,te={},oe=!0)=>{const de=s.getLastUsedPanelOfType(qs);de&&nh(de)?te!=null&&te.value!=null&&de.notebook!=null&&de.notebook.append(te.value):oe&&j(G,K,te)},[j,s]),se=b.useCallback((G,K)=>ml.hydrate({...G,notebooksUrl:o},K),[o]);return b.useEffect(function(){const K=[i(Ii.COMPONENT,Ii,t),i($a.COMPONENT,$a),i(Ga.COMPONENT,Ga),i(Ya.COMPONENT,Ya),i(qs.COMPONENT,qs,se)];return()=>{K.forEach(te=>te())}},[i,t,se]),Ue(n.eventHub,Yt.SEND_COMMAND,v),Ue(n.eventHub,Yt.SETTINGS_CHANGED,w),Ue(n.eventHub,Xe.CLOSE_FILE,P),Ue(n.eventHub,Xe.CREATE_NOTEBOOK,j),Ue(n.eventHub,Xe.SELECT_NOTEBOOK,W),Ue(n.eventHub,Xe.RENAME,E),Ue(n.eventHub,Xe.RENAME_FILE,I),Ue(n.eventHub,Xe.SEND_TO_NOTEBOOK,ie),Ue(n.eventHub,Xe.REGISTER_FILE,N),Ue(n.eventHub,Xe.UNREGISTER_FILE,H),null}const ho=Z.module("FilterPlugin");function sh(d,e){return d.concat(e)}function eR(d){Ps(d);const{id:e,layout:t,registerComponent:n}=d,s=El(),[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(sh,[]).sort((w,T)=>{const y=Wt.toLower(w.name),E=Wt.toLower(T.name);if(y!==E)return y>E?1:-1;const I=Wt.toLower(w.type),F=Wt.toLower(T.type);return I!==F?I>F?1:-1:0}).reduce((w,T)=>((w.length===0||Wt.toLower(w[w.length-1].name)!==Wt.toLower(T.name)||Wt.toLower(w[w.length-1].type)!==Wt.toLower(T.type))&&w.push(T),w),[]),S=Array.from(o.values()).reduce(sh,[]).sort((w,T)=>w.timestamp-T.timestamp),v=new Map(a);ho.debug("sendUpdate",{columns:f,filters:S,tableMap:v}),s(Pn(e,{columns:f,filters:S,tableMap:v}))},[s,e,i,o,a]),c=b.useCallback((f,S)=>{ho.debug2("handleColumnsChanged",f,S),i.set(f,[].concat(S)),r()},[i,r]),h=b.useCallback((f,S)=>{ho.debug2("handleFiltersChanged",f,S),o.set(f,[].concat(S)),r()},[o,r]),u=b.useCallback((f,S)=>{ho.debug2("handleTableChanged",f,S),a.set(q.getIdFromPanel(f),S),r()},[a,r]),m=b.useCallback(f=>{ho.debug2("handlePanelUnmount",f),i.delete(f),o.delete(f),a.delete(q.getIdFromPanel(f)),r()},[i,o,a,r]),p=b.useCallback(({title:f="DropdownFilter",metadata:S={},panelState:v=null,id:w=Pe.generate(),focusElement:T=q.DEFAULT_FOCUS_SELECTOR,createNewStack:y=!1,dragEvent:E=null})=>{const I={type:"react-component",component:ii.COMPONENT,props:{id:w,metadata:S,panelState:v,localDashboardId:e},title:f,id:w},{root:F}=t;q.openComponent({root:F,config:I,focusElement:T,createNewStack:y,dragEvent:E})},[t,e]),g=b.useCallback(({title:f="InputFilter",metadata:S={},panelState:v=null,id:w=Pe.generate(),focusElement:T=q.DEFAULT_FOCUS_SELECTOR,createNewStack:y=!1,dragEvent:E=null})=>{const I={type:"react-component",component:wo.COMPONENT,props:{id:w,metadata:S,panelState:v,localDashboardId:e},title:f,id:w},{root:F}=t;q.openComponent({root:F,config:I,focusElement:T,createNewStack:y,dragEvent:E})},[t,e]),C=b.useCallback(({title:f="FilterSets",metadata:S={},panelState:v=null,id:w=Pe.generate(),focusElement:T=q.DEFAULT_FOCUS_SELECTOR,createNewStack:y=!1,dragEvent:E=null})=>{const I={type:"react-component",component:Yr.COMPONENT,props:{id:w,metadata:S,panelState:v,localDashboardId:e},title:f,id:w},{root:F}=t;q.openComponent({root:F,config:I,focusElement:T,createNewStack:y,dragEvent:E})},[t,e]);return b.useEffect(function(){const S=[n(ii.COMPONENT,ii),n(wo.COMPONENT,wo),n(Yr.COMPONENT,Yr)];return()=>{S.forEach(v=>v())}},[n]),Ue(t.eventHub,Qe.COLUMNS_CHANGED,c),Ue(t.eventHub,Qe.FILTERS_CHANGED,h),Ue(t.eventHub,Qe.TABLE_CHANGED,u),Ue(t.eventHub,Qe.OPEN_DROPDOWN,p),Ue(t.eventHub,Qe.OPEN_INPUT,g),Ue(t.eventHub,Qe.OPEN_FILTER_SET_MANAGER,C),Ue(t.eventHub,Ee.UNMOUNT,m),null}const tR=[dh.VariableType.TABLE,dh.VariableType.TREETABLE,dh.VariableType.HIERARCHICALTABLE];function nR(d){Ps(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=Pe.generate(),widget:m})=>{const{name:p,type:g}=m;if(!tR.includes(g))return;const C={name:p,table:p,type:m.type},f=()=>h().then(w=>ud.makeModel(w)),S={type:"react-component",component:oi.COMPONENT,props:{getDownloadWorker:e,loadPlugin:t,localDashboardId:n,id:u,metadata:C,makeModel:f,theme:a},title:p,id:u},{root:v}=s;q.openComponent({root:v,config:S,dragEvent:c})},[e,n,s,t,a]);return b.useEffect(function(){const h=[i(oi.COMPONENT,oi,o)];return()=>{h.forEach(u=>u())}},[o,i]),Ue(s.eventHub,Ee.OPEN,r),null}function wm(d){return typeof d.getCoordinateForColumn=="function"}function ih(d){const e=d;return wm(d)&&typeof e.setFilterMap=="function"&&typeof e.unsetFilterValue=="function"}function oh(d){return d.description===void 0||!d.description?.startsWith("Preview of type: ")}const uo=Z.module("LinkerUtils");class ys{static ALLOWED_LINKS=new Map([[q.getComponentName(oi),[q.getComponentName(oi),q.getComponentName(ki),q.getComponentName(ii)]]]);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 uo.debug2("Incompatible panel ids",e,t,n),"invalid";if(e.panelComponent==null||t.panelComponent==null)return uo.error("PanelComponent should not be null",e,t),"invalid";const s=ys.ALLOWED_LINKS.get(e.panelComponent)?.includes(t.panelComponent);if(s===void 0||!s)return uo.debug2("Incompatible panel components",e,t),"invalid";const{columnType:i}=e,{columnType:o}=t;if(!(o===null||R.isCompatibleType(i,o)))return uo.debug2("Incompatible type",i,o),"invalid";switch(t.panelComponent){case q.getComponentName(ki):case q.getComponentName(oi):return"tableLink";case q.getComponentName(ii):return"filterSource"}return uo.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:Pe.generate(),start:{...i.start,panelId:n}}):i.end?.panelId===t&&s.push({...i,id:Pe.generate(),end:{...i.end,panelId:n}})}),s}}const sR=Z.module("LinkerLink"),ah=.015,rh=1.5,vm=12,Tm=12,lh=2,fa=Math.sqrt((Tm*.5)**2+vm**2),ch=Math.asin(Tm*.5/vm),hh=15,Cs=Math.PI*.5;class vo 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(R.isNumberType(e)||R.isCharType(e))return tu(t);if(R.isTextType(e))return eu(t);if(R.isDateType(e))return nu(t);if(R.isBooleanType(e)){if(t===Y.eq)return"is equal to";if(t===Y.notEq)return"is not equal to"}throw new Error(`Unrecognized column type: ${e}`)}catch(n){return sR.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=R.getFilterTypes(t);return R.isBooleanType(t)&&(s=[Y.eq,Y.notEq]),s.flatMap((i,o)=>{if(i==="eqIgnoreCase"||i==="notEqIgnoreCase")return[];let a="";return i==="startsWith"?a="a*":i==="endsWith"?a="*z":a=R.getFilterOperatorString(i),[{title:vo.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),p=Math.sin(m),g=Math.cos(m)+2,C=window.innerWidth,f=window.innerHeight,S=0,v=0,w=Math.max(S,Math.min(s+(o-s)/2+p*(u*ah)**rh,C)),T=Math.max(v,Math.min(i+(a-i)/2+g*(u*ah)**rh,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
35
  ${vo.makeCirclePath(s,i,hh)}
36
36
  ${vo.makeCirclePath(o,a,hh)}`,I=`link-select-clip-${r}`,F=Math.atan2(a-T,o-w),N=F-ch+Math.PI,H=F+ch+Math.PI,P=o+Math.cos(F)*lh,O=a+Math.sin(F)*lh,k=P+Math.cos(N)*fa,L=O+Math.sin(N)*fa,A=P+Math.cos(H)*fa,U=O+Math.sin(H)*fa,j=`${P},${O} ${k},${L} ${A},${U}`,W=.25*s+.5*w+.25*o,ie=.25*i+.5*T+.25*a,se=w-s+(o-w),K=(T-i+(a-T))/se;let oe=20/Math.sqrt(1+K**2),de=oe*K,ee=oe*-1,re=de*-1;Number.isFinite(K)?K>0?(oe*=-1,de*=-1,ee*=-1,re*=-1,ee-=50-10*(Math.abs(m)%Cs),re+=10*(Math.abs(m)%Cs),oe-=50-10*(Math.abs(m)%Cs),de+=10*(Math.abs(m)%Cs)):K<0?(ee+=10*(Math.abs(m)%Cs),re+=10*(Math.abs(m)%Cs),oe+=10*(Math.abs(m)%Cs),de+=10*(Math.abs(m)%Cs)):(ee=15,re=10,oe=-25,de=10):(ee=10,re=5,oe=10,de=-35);let we="";return t!==void 0&&(t==="startsWith"?we="a*":t==="endsWith"?we="*z":we=R.getFilterOperatorString(t)),l.jsxs(l.Fragment,{children:[l.jsxs("svg",{className:$(e,{hovering:h}),children:[l.jsx("clipPath",{id:I,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(#${I})`}),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:j})]}),c!=null&&n&&l.jsxs(l.Fragment,{children:[l.jsx(V,{kind:"primary",className:"btn-fab btn-operator",style:{top:ie+(K>=0?de:re),left:W+(K>=0?oe:ee)},onClick:()=>{},icon:l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx("b",{children:we}),l.jsx(J,{icon:kn,transform:"right-8 down-9 shrink-5"})]}),tooltip:"Change comparison operator",children:l.jsx(Zn,{actions:this.getDropdownActions,popperOptions:{placement:"bottom-start"}})}),l.jsx(V,{kind:"primary",className:"btn-fab btn-delete",style:{top:ie+(K<0?de:re),left:W+(K<0?oe:ee)},onClick:this.handleDelete,icon:Qt,tooltip:"Delete"})]})]})}}const Zr=Z.module("LinkerOverlayContent");class iR 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=X.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){Zr.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(!wm(i))throw new Error(`Panel does not have getCoordinateForColumn method: ${n}`);try{const a=i.getCoordinateForColumn(s);if(a!=null)return a}catch{Zr.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 q.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=je(e.x,0,window.innerWidth-t.width),s=je(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=je(window.innerWidth-(e.clientX+s.width+t.x),0,window.innerWidth-s.width),o=je(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,p=t.map(g=>{try{const{id:C,type:f,isReversed:S,start:v,end:w,operator:T}=g,y=v.columnType;let[E,I]=this.getPointFromLinkPoint(v),F=c?.x??E,N=c?.y??I;if(w!=null&&([F,N]=this.getPointFromLinkPoint(w)),S!=null&&S){const[P,O]=[E,I];[E,I]=[F,N],[F,N]=[P,O]}const H=$("linker-link",{disabled:e},{"link-filter-source":f==="filterSource"},{"link-invalid":f==="invalid"},{interactive:g.end==null},{"link-is-selected":n.has(C)},{"danger-delete":m==="delete"});return{x1:E,y1:I,x2:F,y2:N,id:C,className:H,operator:T,startColumnType:y}}catch(C){return Zr.warn("Unable to get point for link",g,C),null}}).filter(g=>g!=null);return l.jsxs("div",{className:$("linker-overlay",{"danger-delete":m==="delete"}),children:[p.map(({x1:g,y1:C,x2:f,y2:S,id:v,className:w,operator:T,startColumnType:y})=>l.jsx(vo,{className:w,id:v,x1:g,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(V,{draggable:!0,kind:"inline",className:"btn-drag-handle",icon:Mo,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(V,{kind:"secondary",onClick:a,children:"Clear All"}),l.jsx(V,{kind:"primary",onClick:r,children:"Done"})]})]}),l.jsx(ae,{actions:[{action:this.handleEscapePressed,shortcut:es.LINKER_CLOSE,isGlobal:!0}]})]})}}const vt=Z.module("Linker"),oR=(d,e)=>({activeTool:cr(d),isolatedLinkerPanelId:fd(d,e.localDashboardId),links:Ki(d,e.localDashboardId),timeZone:Ao(d)}),aR=ft(oR,{setActiveTool:ur,setDashboardLinks:Sd,addDashboardLinks:ex,deleteDashboardLinks:tx,setDashboardIsolatedLinkerPanelId:fm,setDashboardColumnSelectionValidator:nx});class rR 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===jt.DEFAULT&&this.reset())}componentDidCatch(e,t){vt.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(Cn.COLUMN_SELECTED,this.handleGridColumnSelect),t.on(Cn.DATA_SELECTED,this.handleUpdateValues),t.on(Cn.STATE_CHANGED,this.handleStateChange),t.on(pl.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(Cn.COLUMN_SELECTED,this.handleGridColumnSelect),t.off(Cn.DATA_SELECTED,this.handleUpdateValues),t.off(Cn.STATE_CHANGED,this.handleStateChange),t.off(pl.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(jt.DEFAULT)}this.setState({linkInProgress:void 0})}handleDone(){const{setActiveTool:e}=this.props;e(jt.DEFAULT)}handleChartColumnSelect(e,t){this.columnSelected(e,t,!0)}handleFilterColumnSelect(e,t){vt.debug("handleFilterColumnSelect",this.isOverlayShown());const{links:n,localDashboardId:s,setActiveTool:i,setDashboardIsolatedLinkerPanelId:o}=this.props,a=q.getIdFromPanel(e),r=n.filter(c=>c.start?.panelId===a||c.end?.panelId===a);if(!this.isOverlayShown()&&a!=null){i(jt.LINKER),o(s,a),r.length===0&&this.columnSelected(e,t,!0,a);return}this.columnSelected(e,t,!0)}handleColumnsChanged(e,t){vt.debug("handleColumnsChanged",e,t);const{links:n}=this.props,s=q.getIdFromPanel(e);if(s==null){vt.error("Invalid panelId",e);return}const i=n.filter(({start:o,end:a})=>o.panelId===s&&ys.findColumn(t,o)==null||a!=null&&a.panelId===s&&ys.findColumn(t,a)==null);this.deleteLinks(i)}handleGridColumnSelect(e,t){if(!oh(t)){vt.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=q.getIdFromPanel(e);if(a==null)return;const r=q.getComponentNameFromPanel(e),{name:c,type:h}=t;if(o==null||o.start==null){const u={id:Pe.generate(),start:{panelId:a,panelComponent:r,columnName:c,columnType:h},type:"invalid",isReversed:n};vt.debug("starting link",u),this.setState({linkInProgress:u})}else{const{links:u}=this.props,{start:m,id:p,isReversed:g}=o,C={panelId:a,panelComponent:r,columnName:c,columnType:h},f=ys.getLinkType(g!==void 0&&g?C:m,g!==void 0&&g?m:C,s??i);switch(f){case"invalid":vt.debug("Ignore invalid link connection",o,C);return;case"filterSource":{const v=g!==void 0&&g?m.panelId:C.panelId,w=u.filter(({end:T})=>T?.panelId===v);this.deleteLinks(w);break}}const S={start:g!==void 0&&g?C:m,end:g!==void 0&&g?m:C,id:p,type:f,operator:Y.eq};vt.info("creating link",S),this.setState({linkInProgress:void 0,selectedIds:new Set([p])},()=>{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?ih(a)?a.unsetFilterValue(i,o):vt.debug("endPanel.unsetFilterValue not implemented",a):vt.debug("endPanel no longer exists, ignoring unsetFilterValue",s)}}setPanelFilterMap(e,t){vt.debug("Set filter data for panel:",e,t);const{panelManager:n}=this.props,s=n.getOpenedPanelById(e);s?ih(s)?s.setFilterMap(t):vt.debug("panel.setFilterMap not implemented",e,s):vt.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]):vt.error("Unable to find link to delete",e)}handleUpdateValues(e,t){const n=q.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:p}=c,g=o.has(u)?o.get(u):new Map,C=g.has(m)===!0?g.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),p!=null&&R.isDateType(p)&&(T=new _e({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),g.set(m,{columnType:p,filterList:C}),o.set(u,g)}}o.forEach((a,r)=>{this.setPanelFilterMap(r,a)})}handlePanelCloned(e,t){const{links:n}=this.props,s=q.getIdFromPanel(e),i=t.id;if(s!=null){const o=ys.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){vt.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===jt.LINKER}updateSelectionValidators(){const{activeTool:e,setDashboardColumnSelectionValidator:t,localDashboardId:n}=this.props;switch(e){case jt.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(!oh(t))return vt.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=q.getIdFromPanel(e);if(a==null)return!1;const r={panelId:a,panelComponent:q.getComponentNameFromPanel(e),columnName:t.name,columnType:t.type},c=i!==void 0&&i?ys.getLinkType(r,o,s):ys.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(gt,{in:a,timeout:We.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,onExited:this.handleExited,children:l.jsx(iR,{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 lR=aR(rR);function dR(d){Ps(d);const{id:e,layout:t,panelManager:n}=d;return l.jsx(lR,{layout:t,localDashboardId:e,panelManager:n})}class Li{static DEFAULT_TITLE="Note";static DEFAULT_CONTENT=`# Markdown Note
37
37
 
@@ -40,4 +40,4 @@ This note can be edited using **markdown** for styling.`;static getNewMarkdownTi
40
40
  Web UI Version: ${e}
41
41
  Java Version: ${o}
42
42
  Barrage Version: ${i}`,children:"Copy Versions"})]})]})]}),l.jsx("div",{className:"app-settings-footer-item",children:l.jsx(IR,{})})]}),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:ym,alt:"Deephaven Data Labs",width:"230px"})})})})]})]})]})}}const fh=10;function Di(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,p]=b.useState(!1),g=b.useCallback(S=>{c.current!=null&&h.current!=null&&u.current&&(Math.abs(c.current-S.clientX)>=fh||Math.abs(h.current-S.clientY)>=fh)&&(p(!0),window.removeEventListener("mousemove",g),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",g)}function f(S){u.current===S.target&&(p(!0),r(),e(),window.removeEventListener("mousemove",g)),u.current=null}return b.useEffect(function(){return function(){return window.removeEventListener("mousemove",g)}},[g]),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 Rd(d){const{handleControlSelect:e,handleToolSelect:t,onClearFilter:n}=d,s=b.useMemo(()=>[{title:"Input Filter",icon:xg,menuElement:l.jsx(Di,{}),action:i=>{e(Is.INPUT_FILTER,i)},order:10},{title:"Dropdown Filter",icon:Oh,menuElement:l.jsx(Di,{}),action:i=>{e(Is.DROPDOWN_FILTER,i)},order:15},{title:"Markdown Widget",icon:Rg,menuElement:l.jsx(Di,{}),action:i=>{e(Is.MARKDOWN,i)},order:20},{title:"Filter Sets",icon:il,menuElement:l.jsx(Di,{}),action:i=>{e(Is.FILTER_SET_MANAGER,i)},order:25},{disabled:!0,menuElement:l.jsx("div",{className:"context-menu-group-header",children:"Tools"}),order:30},{title:"Linker",icon:yl,action:()=>{t(jt.LINKER)},order:40,shortcut:es.LINKER},{disabled:!0,menuElement:l.jsx("div",{className:"context-menu-group-header",children:"Actions"}),order:50},{title:"Clear All Filters",icon:Ig,action:()=>{n()},order:60,shortcut:Kt.TABLE.CLEAR_ALL_FILTERS}],[e,t,n]);return l.jsx(Zn,{popperClassName:"controls-menu-popper",actions:s})}Rd.propTypes={handleControlSelect:D.func,handleToolSelect:D.func,onClearFilter:D.func};Rd.defaultProps={handleControlSelect:()=>{},handleToolSelect:()=>{},onClearFilter:()=>{}};Di.propTypes={forwardedProps:D.shape({iconElement:D.node,displayShortcut:D.string,isMouseSelected:D.bool.isRequired,isKeyboardSelected:D.bool.isRequired,closeMenu:D.func.isRequired,menuItem:D.shape({action:D.func,title:D.string,disabled:D.bool}).isRequired})};Di.defaultProps={forwardedProps:null};const UR=Ls(Em,null),$R={layoutStorage:UR},WR=d=>d.layoutStorage,GR=d=>d.serverConfigValues;Object.entries($R).map(([d,e])=>Gi.register(d,e));const Ch=10;function zR(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]),p=b.useCallback(T=>{c(T.target.value)},[]),g=b.useCallback(T=>{u.current!=null&&(Math.abs(u.current.x-T.clientX)>=Ch||Math.abs(u.current.y-T.clientY)>=Ch)&&(a(!0),window.removeEventListener("mousemove",g),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",g)},[g]),f=b.useCallback((T,y)=>{window.removeEventListener("mousemove",g),u.current?.widget===y&&(a(!0),m(y)),u.current=void 0},[g,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(V,{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(Kh,{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(As,{value:r,placeholder:"Find Table, Plot or Widget",onChange:p,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(V,{kind:"ghost",onClick:e,children:[l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx(J,{mask:sl,icon:Vd,transform:"right-5 down-5"}),l.jsx(J,{icon:Vd,transform:"right-8 down-6"})]}),"Export Layout"]}),l.jsxs(V,{kind:"ghost",onClick:t,children:[l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx(J,{mask:sl,icon:ol,transform:"right-5 down-5"}),l.jsx(J,{icon:ol,transform:"right-8 down-6"})]}),"Import Layout"]}),l.jsx(V,{kind:"ghost",icon:ei,onClick:n,tooltip:"Reset Layout"})]})]})}const KR=async(d,e,t)=>{let n,s,i,o;if(va(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:x.VariableType.FIGURE},h=await d.getObject(c);return Aa.makeModel(n,h)}const a={title:i,name:s,type:x.VariableType.TABLE},r=await d.getObject(a);return be.applyTableSettings(r,o,Ao(mr.getState())),Aa.makeModelFromSettings(n,r)},qR=async(d,e,t=x.VariableType.TABLE)=>{const{table:n}=e,s={title:n,name:n,type:t},i=await d.getObject(s);return ud.makeModel(i)};function YR({onAutoFillClick:d=()=>{}}){return l.jsxs("div",{className:"empty-dashboard-container",children:[l.jsxs("div",{className:"hint-container",children:[l.jsx(J,{icon:kh})," ",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(V,{kind:"tertiary",onClick:d,children:"Auto fill objects"})]})]})}function XR(d){return d.version===2}function ZR(d){return Array.isArray(d)}const Ca=Z.module("UserLayoutUtils"),QR={layoutConfig:[{type:"column",content:[{type:"row",height:40,content:[{type:"stack",content:[{type:"react-component",component:Ii.COMPONENT,title:Ii.TITLE,isClosable:!1},{type:"react-component",component:Ya.COMPONENT,title:Ya.TITLE,isClosable:!1}]},{type:"stack",width:25,content:[{type:"react-component",component:$a.COMPONENT,title:$a.TITLE,isClosable:!1},{type:"react-component",component:Ga.COMPONENT,title:Ga.TITLE,isClosable:!1}]}]},{type:"row",content:[{type:"stack",title:"Notebooks",content:[]}]}]}],links:[],filterSets:[],version:2},JR={layoutConfig:[],links:[],filterSets:[],version:2};function Mm(d){if(XR(d))return d;if(ZR(d))return{layoutConfig:d,links:[],filterSets:[],version:2};throw new Error(`Unexpected layout import format: ${d}`)}async function eI(d,e=!0){try{const t=await d.getLayouts();if(t.length>0)try{const n=await d.getLayout(t[0]);return Mm(n)}catch(n){Ca.error("Unable to load layout",t[0],":",n),Ca.warn("No valid layouts found, falling back to default layout")}}catch(t){Ca.error("Unable to fetch layout list",t),Ca.warn("Falling back to default layout")}return e?QR:JR}function tI(d){const{filterSets:e,layoutConfig:t,links:n}=d;return{filterSets:e,layoutConfig:t,links:n,version:2}}const Ea={exportLayout:tI,getDefaultLayout:eI,normalizeLayout:Mm},Sa=Z.module("DownloadServiceWorkerUtils");class Io{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(),Sa.info("Registering service worker on ",t,n)}).catch(n=>{Sa.error("Failed to register service worker",n)})}):Sa.info("Service worker is not supported."))}static async getServiceWorker(){if("serviceWorker"in navigator){const t=(await navigator.serviceWorker.getRegistrations()).find(n=>n.scope.endsWith(Io.DOWNLOAD_PATH));if(t&&t.active)return Sa.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 km={react:X,"react-dom":Pi,redux:hp,"react-redux":up},nI=mp(km),sI=pp({requires:nI}),iI=gp.createRequires(km),oI=fp({requires:iI}),aI=Z.module("PluginUtils");class bl{static loadComponentPlugin(e){const t=new URL("/ide/plugins/",`${window.location}`),n=new URL(`${e}.js`,t),s=X.forwardRef((i,o)=>l.jsx(sI,{url:n,render:({err:a,Component:r})=>{if(a!=null&&a!==""){const c=`Error loading plugin ${e} from ${n} due to ${a}`;return aI.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 oI(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 Dt=Z.module("AppMainContainer");class Eo extends b.Component{static handleWindowBeforeUnload(e){e.preventDefault(),e.returnValue=""}static hydrateConsole(e,t){return ml.hydrate({...e,unzip:n=>Eh.loadAsync(n).then(s=>Object.values(s.files))},t)}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.importElement=X.createRef(),this.state={contextActions:[{action:()=>{this.handleToolSelect(jt.LINKER)},shortcut:es.LINKER,isGlobal:!0},{action:()=>{this.sendClearFilter()},shortcut:Kt.TABLE.CLEAR_ALL_FILTERS,isGlobal:!0},{action:()=>{Dt.debug("Consume unhandled save shortcut")},shortcut:es.SAVE,isGlobal:!0}],isPanelsMenuShown:!1,isSettingsMenuShown:!1,widgets:[]}}componentDidMount(){this.initWidgets(),window.addEventListener("beforeunload",Eo.handleWindowBeforeUnload)}componentDidUpdate(e){const{dashboardData:t}=this.props;e.dashboardData!==t&&this.handleDataChange(t)}componentWillUnmount(){this.deinitWidgets(),window.removeEventListener("beforeunload",Eo.handleWindowBeforeUnload)}goldenLayout;importElement;widgetListenerRemover;initWidgets(){const{connection:e}=this.props;if(e.subscribeToFieldUpdates==null){Dt.warn("subscribeToFieldUpdates not supported, not initializing widgets");return}this.widgetListenerRemover=e.subscribeToFieldUpdates(t=>{Dt.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){Dt.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(Xe.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)||Dt.error(e)}handleSettingsMenuHide(){this.setState({isSettingsMenuShown:!1})}handleSettingsMenuShow(){this.setState({isSettingsMenuShown:!0})}handleControlSelect(e,t=null){switch(Dt.debug("handleControlSelect",e),e){case Is.DROPDOWN_FILTER:this.emitLayoutEvent(Qe.OPEN_DROPDOWN,{title:"DropdownFilter",type:e,createNewStack:!0,dragEvent:t});break;case Is.INPUT_FILTER:this.emitLayoutEvent(Qe.OPEN_INPUT,{title:"InputFilter",type:e,createNewStack:!0,dragEvent:t});break;case Is.MARKDOWN:this.emitLayoutEvent(pm.OPEN,{title:"Markdown",type:e,dragEvent:t});break;case Is.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){Dt.debug("handleToolSelect",e);const{activeTool:t,setActiveTool:n}=this.props;n(t===e?jt.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}),Dt.debug("handleWidgetSelect",e,t),this.openWidget(e,t)}handleWidgetsMenuClose(){this.setState({isPanelsMenuShown:!1})}handleAutoFillClick(){const{widgets:e}=this.state;Dt.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(){Dt.info("handleExportLayoutClick"),this.setState({isPanelsMenuShown:!1});try{const{workspace:e}=this.props,{data:t}=e,n=Ea.exportLayout(t);Dt.info("handleExportLayoutClick exportedConfig",n);const s=new Blob([JSON.stringify(n)],{type:"application/json"}),i=x.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){Dt.error("Unable to export layout",e)}}handleImportLayoutClick(){Dt.info("handleImportLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.importElement.current!=null&&(this.importElement.current.value="",this.importElement.current.click())}handleResetLayoutClick(){Dt.info("handleResetLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.resetLayout()}handleImportLayoutFiles(e){e.stopPropagation(),e.preventDefault(),e.target.files!=null&&this.importLayoutFile(e.target.files?.[0])}async importLayoutFile(e){try{const{updateDashboardData:t,updateWorkspaceData:n}=this.props,s=await e.text(),i=JSON.parse(s),{filterSets:o,layoutConfig:a,links:r}=Ea.normalizeLayout(i);n({layoutConfig:a}),t(wn,{filterSets:o,links:r})}catch(t){Dt.error("Unable to import layout",t)}}async resetLayout(){const{layoutStorage:e,session:t}=this.props,{filterSets:n,layoutConfig:s,links:i}=await Ea.getDefaultLayout(e,t!==void 0),{updateDashboardData:o,updateWorkspaceData:a}=this.props;a({layoutConfig:s}),o(wn,{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:bl.loadComponentPlugin(e)}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 ml.hydrate(e,t)}hydrateGrid(e,t){return this.hydrateTable(e,t,e.metadata.type??x.VariableType.TABLE)}hydratePandas(e,t){return this.hydrateTable(e,t,x.VariableType.PANDAS)}hydrateTable(e,t,n=x.VariableType.TABLE){const{connection:s}=this.props;return{...e,getDownloadWorker:Io.getServiceWorker,loadPlugin:this.handleLoadTablePlugin,localDashboardId:t,makeModel:()=>qR(s,e.metadata,n)}}hydrateChart(e,t){const{connection:n}=this.props;return{...e,localDashboardId:t,makeModel:()=>{const{metadata:s,panelState:i}=e;return KR(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,isPanelsMenuShown:u,isSettingsMenuShown:m,widgets:p}=this.state,g=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:ym,alt:"Deephaven Data Labs",width:"115px",className:"ml-1"}),l.jsxs("div",{children:[l.jsxs(V,{kind:"ghost",className:"btn-panels-menu",icon:Dg,onClick:()=>{},children:["Controls",l.jsx(Rd,{handleControlSelect:this.handleControlSelect,handleToolSelect:this.handleToolSelect,onClearFilter:this.handleClearFilter})]}),c&&l.jsxs(V,{kind:"ghost",className:"btn-panels-menu btn-show-panels","data-testid":"app-main-panels-button",onClick:this.handleWidgetMenuClick,icon:Fg,children:["Panels",l.jsx(ri,{isShown:u,className:"panels-menu-popper",onExited:this.handleWidgetsMenuClose,closeOnBlur:!0,interactive:!0,children:l.jsx(zR,{widgets:p,onExportLayout:this.handleExportLayoutClick,onImportLayout:this.handleImportLayoutClick,onResetLayout:this.handleResetLayoutClick,onSelect:this.handleWidgetSelect})})]}),l.jsx(V,{kind:"ghost",className:$("btn-settings-menu",{"text-warning":n.operateAs!==n.name}),onClick:this.handleSettingsMenuShow,icon:l.jsx(J,{icon:ko,transform:"grow-3 right-1 down-1"}),tooltip:"User Settings"})]})]})}),l.jsxs(jw,{emptyDashboard:l.jsx(YR,{onAutoFillClick:this.handleAutoFillClick}),id:wn,layoutConfig:a,onGoldenLayoutChange:this.handleGoldenLayoutChange,onLayoutConfigChange:this.handleLayoutConfigChange,onLayoutInitialized:this.openNotebookFromURL,hydrate:this.hydrateDefault,children:[l.jsx(nR,{hydrate:this.hydrateGrid,getDownloadWorker:Io.getServiceWorker,loadPlugin:this.handleLoadTablePlugin}),l.jsx(Xx,{hydrate:this.hydrateChart}),l.jsx(Zx,{}),l.jsx(Jx,{hydrateConsole:Eo.hydrateConsole,notebooksUrl:new URL("/notebooks/",`${window.location}`).href}),l.jsx(eR,{}),l.jsx(hR,{hydrate:this.hydratePandas}),l.jsx(cR,{}),l.jsx(dR,{}),g]}),l.jsx(gt,{in:m,timeout:We.transitionMidMs,classNames:"slide-left",mountOnEnter:!0,unmountOnExit:!0,children:l.jsx(Nn,{serverConfigValues:i,onDone:this.handleSettingsMenuHide})}),l.jsx(ae,{actions:h}),l.jsx("input",{ref:this.importElement,type:"file",accept:".json",style:{display:"none"},onChange:this.handleImportLayoutFiles})]})}}const rI=d=>({activeTool:cr(d),dashboardData:Vt(d,wn),layoutStorage:WR(d),plugins:US(d),connection:Zy(d,wn),session:ai(d,wn)?.session,sessionConfig:ai(d,wn)?.config,user:iu(d),workspace:dr(d),serverConfigValues:GR(d)}),lI=ft(rI,{setActiveTool:ur,updateDashboardData:Pn,updateWorkspaceData:Eu})(Cp(Eo));function dI(){return l.jsxs("div",{className:"app",children:[l.jsx(lI,{}),l.jsx(_h,{})]})}const cI=Z.module("LocalWorkspaceStorage");class Fi{static STORAGE_KEY="deephaven.WorkspaceStorage";static async makeDefaultWorkspaceData(e,t){const{filterSets:n,links:s,layoutConfig:i}=await Ea.getDefaultLayout(e,t?.isConsoleAvailable);return{settings:{defaultDateTimeFormat:_e.DEFAULT_DATETIME_FORMAT_STRING,formatter:[],timeZone:_e.DEFAULT_TIME_ZONE_ID,showTimeZone:!1,showTSeparator:!0,disableMoveConfirmation:!1,defaultDecimalFormatOptions:{defaultFormatString:Re.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:$e.DEFAULT_FORMAT_STRING},truncateNumbersWithPound:!1,defaultNotebookSettings:{isMinimapEnabled:!1}},layoutConfig:i,closed:[{}],links:s,filterSets:n}}static async makeDefaultWorkspace(e,t){return{data:await Fi.makeDefaultWorkspaceData(e,t)}}layoutStorage;constructor(e){this.layoutStorage=e}async load(e){try{return JSON.parse(localStorage.getItem(Fi.STORAGE_KEY)??"")}catch{return cI.info("Unable to load workspace data, initializing to default data"),Fi.makeDefaultWorkspace(this.layoutStorage,e)}}async save(e){return localStorage.setItem(Fi.STORAGE_KEY,JSON.stringify(e)),e}}class hI extends Error{isNoConsolesError=!0}function uI(d){return d.isNoConsolesError}const Fs=Z.module("SessionUtils");var Om=(d=>(d.ANONYMOUS="anonymous",d.PARENT="parent",d))(Om||{});function mI(){return new URL("/jsapi",`${window.location}`)}function Am(){const d=mI();return`${d.protocol}//${d.host}`}function pI(){switch(new URLSearchParams(window.location.search).get("authProvider")){case"parent":return"parent";default:return"anonymous"}}function gI(){const d=Am();return Fs.info(`Starting connection to '${d}'...`),new x.IdeConnection(d)}async function fI(d){Fs.info("Getting console types...");const e=await d.getConsoleTypes();if(Fs.info("Available types:",e),e.length===0)throw new hI("No console types available");const t=e[0];Fs.info("Starting session with type",t);const n=await d.startSession(t),s={type:t,id:Pe.generate()};return Fs.info("Console session established",s),{session:n,config:s,connection:d}}function CI(){const d=Am();return Fs.info("createCoreClient",d),new x.CoreClient(d)}async function SI(){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(Fs.debug("Received message",n),n?.message!=="loginOptions"){Fs.debug("Ignore received message",n);return}window.removeEventListener("message",e),d(n.payload)};window.addEventListener("message",e),window.opener.postMessage("requestLoginOptionsFromParent","*")})}async function bI(d){switch(d){case"parent":return SI();case"anonymous":return{type:x.CoreClient.LOGIN_TYPE_ANONYMOUS};default:throw new Error(`Unknown auth type: ${d}`)}}class wI{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 mo=Z.module("GrpcFileStorageTable");class Xa{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),Xa.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 Xa(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){mo.debug2("doRefresh",this.root),e(this.fetchData())}refresh(){mo.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 Hi;return this.currentViewportData=n,this.sendUpdate(),n}));t.catch(n=>{ve.isCanceled(n)||mo.error("Error updating viewport",n)}),this.viewportUpdatePromise=t}refreshInternal(){try{this.refresh()}catch(e){ve.isCanceled(e)||mo.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,mo.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 vI=Z.module("GrpcFileStorage");class Id{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 Xa(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 vd;if(t.length>1)throw vI.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=ks(()=>{this.tables.forEach(e=>e.refresh())},Id.REFRESH_THROTTLE)}const Ns=Z.module("AppInit");async function TI(){Ns.debug("Loading plugins...");try{const d=await bl.loadJson("/js-plugins/manifest.json");Ns.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(bl.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 Ns.info("Plugins loaded:",n),n}catch(d){return Ns.error("Unable to load plugins:",d),new Map}}async function EI(d){let e;try{e=await fI(d)}catch(t){if(!uI(t))throw t}return e}function Dd(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:p}=d,[g,C]=b.useState(),[f,S]=b.useState(!0),v=b.useCallback(async()=>{try{Ns.info("Initializing Web UI","0.32.0",navigator.userAgent);const I=CI(),F=pI();Ns.info(`Login using auth type ${F}...`),await I.login(await bI(F));const N=await TI(),H=await(F===Om.ANONYMOUS&&I.getAsIdeConnection==null?gI():I.getAsIdeConnection());H.addEventListener(x.IdeConnection.HACK_CONNECTION_FAILURE,we=>{const{detail:xe}=we;Ns.error("Connection failure",`${JSON.stringify(xe)}`),C(`Unable to connect: ${xe.details??"Unknown Error"}`)});const P=await EI(H),O="user",k=I.getStorageService(),L=new wI(k,"/layouts"),A=new Id(k,"/notebooks"),U=new Fi(L),j=new SR,W=await U.load({isConsoleAvailable:P!==void 0}),{data:ie}=W,{settings:se}=ie;se.defaultDecimalFormatOptions===void 0&&(se.defaultDecimalFormatOptions={defaultFormatString:Re.DEFAULT_FORMAT_STRING}),se.defaultIntegerFormatOptions===void 0&&(se.defaultIntegerFormatOptions={defaultFormatString:$e.DEFAULT_FORMAT_STRING}),se.truncateNumbersWithPound===void 0&&(se.truncateNumbersWithPound=!1);const{shortcutOverrides:G={}}=se,te=ke.isMacPlatform?G.mac??{}:G.windows??{};Object.entries(te).forEach(([we,xe])=>{Fe.get(we)?.setKeyState(xe)});const oe={filterSets:ie.filterSets,links:ie.links},de=await I.getServerConfigValues(),ee=new Map(de),re={name:O,operateAs:O,groups:[],permissions:{isSuperUser:!1,isQueryViewOnly:!1,isNonInteractive:!1,canUsePanels:!0,canCreateDashboard:!0,canCreateCodeStudio:!0,canCreateQueryMonitor:!0,canCopy:ee.get("internal.webClient.appInit.canCopy")!=="false",canDownloadCsv:ee.get("internal.webClient.appInit.canDownloadCsv")!=="false"}};t(jt.DEFAULT),p(ee),n(j),s(wn,oe),i(A),o(L),a(wn,H),P!==void 0&&r(wn,P),c(N),h(re),m(U),u(W)}catch(I){Ns.error(I),C(I)}},[t,n,s,i,o,a,r,c,h,u,m,p]),w=b.useCallback(()=>{document.fonts!=null?document.fonts.ready.then(()=>{S(!1)}):S(!1)},[]);b.useEffect(function(){v(),w()},[v,w]);const T=e==null&&g==null||f,y=!T&&g==null,E=g!=null?`${g}`:null;return l.jsxs(l.Fragment,{children:[y&&l.jsx(dI,{}),l.jsx(Ja,{isLoading:T,isLoaded:y,errorMessage:E}),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"})]})]})}Dd.propTypes={workspace:D.shape({}),workspaceStorage:D.shape({close:D.func}),setActiveTool:D.func.isRequired,setCommandHistoryStorage:D.func.isRequired,setDashboardData:D.func.isRequired,setFileStorage:D.func.isRequired,setLayoutStorage:D.func.isRequired,setDashboardConnection:D.func.isRequired,setDashboardSessionWrapper:D.func.isRequired,setPlugins:D.func.isRequired,setUser:D.func.isRequired,setWorkspace:D.func.isRequired,setWorkspaceStorage:D.func.isRequired};Dd.defaultProps={workspace:null,workspaceStorage:null};const yI=d=>({workspace:dr(d),workspaceStorage:HS(d)}),Sh=ft(yI,{setActiveTool:ur,setCommandHistoryStorage:GS,setDashboardData:zu,setFileStorage:zS,setLayoutStorage:bR,setDashboardConnection:Qy,setDashboardSessionWrapper:Jy,setPlugins:qS,setUser:$S,setWorkspace:Tu,setWorkspaceStorage:WS,setServerConfigValues:YS})(Dd);function xI(){return l.jsx(Sp,{basename:"/ide/",children:l.jsxs(bp,{children:[l.jsx(Ad,{exact:!0,path:"/",component:Sh}),l.jsx(Ad,{path:"/notebook/:notebookPath+",component:Sh}),l.jsx(wp,{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 RI(){"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(d=>{d.forEach(e=>{e.scope.endsWith("/download/")||e.unregister()})})}function AI(){return RI(),Io.registerOnLoaded(),zt.init({getWorker:()=>new vp}),window["__react-beautiful-dnd-disable-dev-warnings"]=!0,l.jsx(wh,{store:mr,children:l.jsx(xI,{})})}export{AI as AppRoot,AI as default};
43
- //# sourceMappingURL=AppRoot-caede86f.js.map
43
+ //# sourceMappingURL=AppRoot-7deb9884.js.map