@deephaven/code-studio 0.23.0 → 0.23.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,13 +35,13 @@ ${e}`):s.setValue(`${e}`);const o=s.getLineCount(),r=s.getLineLength(o)+1;this.e
35
35
  ${fT(t)}`}function bT(t){const{rules:e=[],onChange:n=fa,onCreate:s=fa,onSelect:i=fa}=t,o=S.exports.useCallback((d,c,u)=>{d.stopPropagation(),Nh.debug("Rule clicked",c,u),i(u)},[i]),r=S.exports.useCallback((d,c,u)=>{d.stopPropagation(),Nh.debug("Delete button clicked",c,u);const m=[...e];m.splice(u,1),n(m)},[n,e]),l=S.exports.useCallback(d=>{d.stopPropagation()},[]),a=S.exports.useCallback(d=>{if(Xt.stopDragging(),d.destination==null)return;const c=d.source.index,u=d.destination.index,m=[...e],p=e[c];m.splice(c,1),m.splice(u,0,p),n(m)},[n,e]);return v("div",{className:"conditional-formatting-rules",children:[h(Bo,{onDragStart:Xt.startDragging,onDragEnd:a,children:h(Uo,{droppableId:"droppable-custom-columns",children:(d,c)=>v("div",{ref:d.innerRef,...d.droppableProps,className:W("droppable-container",{dragging:c.draggingFromThisWith}),children:[e.length===0&&h("div",{className:"text-muted pl-2",children:"No formats defined"}),e.map((u,m)=>h(hl,{draggableId:`${m}-${u.type}`,index:m,disableInteractiveElementBlocking:!0,children:(p,g)=>h("div",{role:"menuitem",tabIndex:0,onClick:f=>o(f,u,m),className:W("draggable-container",{dragging:g.isDragging}),ref:p.innerRef,...p.draggableProps,children:h("div",{className:"conditional-formatting-list-item",children:v("div",{className:"formatting-item",children:[h("div",{className:"rule-icon",children:h("span",{className:"rule-icon-bg",style:{backgroundColor:nl(u.config.style),color:sl(u.config.style)},children:u.type===Yn.ROWS?"row":"col"})}),h("div",{className:"rule-title",children:CT(u.config)}),h(z,{kind:"ghost",className:"ml-1 px-2",onClick:f=>r(f,u,m),icon:wn,tooltip:"Delete rule"}),v("button",{type:"button",className:"btn btn-link btn-link-icon px-2 btn-drag-handle",onClick:l,...p.dragHandleProps,children:[h($e,{children:"Drag to re-order"}),h(j,{icon:pl})]})]})})})},`${m}-${u.type}`)),d.placeholder]})})}),h("hr",{}),h(z,{kind:"ghost",onClick:s,icon:Ps,children:"Add New Rule"})]})}const Ii=X.module("ConditionEditor"),ST=()=>{},wT=[Xe.IS_EQUAL,Xe.IS_NOT_EQUAL,Xe.IS_BETWEEN,Xe.GREATER_THAN,Xe.GREATER_THAN_OR_EQUAL,Xe.LESS_THAN,Xe.LESS_THAN_OR_EQUAL,Xe.IS_NULL,Xe.IS_NOT_NULL].map(t=>h("option",{value:t,children:nv(t)},t)),vT=[rn.IS_EXACTLY,rn.IS_NOT_EXACTLY,rn.CONTAINS,rn.DOES_NOT_CONTAIN,rn.STARTS_WITH,rn.ENDS_WITH,rn.IS_NULL,rn.IS_NOT_NULL].map(t=>h("option",{value:t,children:sv(t)},t)),TT=[Vt.IS_EXACTLY,Vt.IS_NOT_EXACTLY,Vt.IS_BEFORE,Vt.IS_BEFORE_OR_EQUAL,Vt.IS_AFTER,Vt.IS_AFTER_OR_EQUAL,Vt.IS_NULL,Vt.IS_NOT_NULL].map(t=>h("option",{value:t,children:iv(t)},t)),ET=[Do.IS_TRUE,Do.IS_FALSE,Do.IS_NULL,Do.IS_NOT_NULL].map(t=>h("option",{value:t,children:ov(t)},t)),yT=[ri.IS_EQUAL,ri.IS_NOT_EQUAL,ri.IS_NULL,ri.IS_NOT_NULL].map(t=>h("option",{value:t,children:rv(t)},t));function IT(t,e,n,s){return t===Xe.IS_NULL||t===Xe.IS_NOT_NULL||t===Xe.IS_BETWEEN&&n!=null&&n!==""&&!Number.isNaN(Number.parseFloat(n))&&s!=null&&s!==""&&!Number.isNaN(Number.parseFloat(s))||t!==Xe.IS_BETWEEN&&e!==void 0&&e!==""&&!Number.isNaN(Number.parseFloat(e))}function RT(t,e,n,s,i,o,r){switch(t){case Xe.IS_EQUAL:case Xe.IS_NOT_EQUAL:case Xe.GREATER_THAN:case Xe.GREATER_THAN_OR_EQUAL:case Xe.LESS_THAN:case Xe.LESS_THAN_OR_EQUAL:return h("input",{type:"number",className:"form-control",placeholder:"Enter value",value:i!=null?i:"",onChange:e});case Xe.IS_BETWEEN:return v("div",{className:"d-flex flex-row",children:[h("input",{type:"number",className:"form-control d-flex mr-2",placeholder:"Start value",value:o!=null?o:"",onChange:n}),h("input",{type:"number",className:"form-control d-flex",placeholder:"End value",value:r!=null?r:"",onChange:s})]});case Xe.IS_NULL:case Xe.IS_NOT_NULL:return null}}function DT(t,e,n){switch(t){case rn.IS_NULL:case rn.IS_NOT_NULL:return null;default:return h("input",{type:"text",className:"form-control",placeholder:"Enter value",value:n!=null?n:"",onChange:e})}}function MT(t,e,n){switch(t){case Vt.IS_NULL:case Vt.IS_NOT_NULL:return null;default:return h("input",{type:"text",className:"form-control",placeholder:"Enter value",value:n!=null?n:"",onChange:e})}}function NT(){return null}function FT(t,e,n){switch(t){case ri.IS_NULL:case ri.IS_NOT_NULL:return null;default:return h("input",{type:"text",className:"form-control",maxLength:1,placeholder:"Enter value",value:n!=null?n:"",onChange:e})}}function wp(t){const{column:e,config:n,onChange:s=ST}=t,i=e.type,[o,r]=S.exports.useState(i),[l,a]=S.exports.useState(n.condition),[d,c]=S.exports.useState(n.value),[u,m]=S.exports.useState(n.start),[p,g]=S.exports.useState(n.end);i!==o&&(a(sp(i)),c(void 0),m(void 0),g(void 0),r(i));const f=S.exports.useMemo(()=>{if(i===void 0)return[];if(L.isNumberType(i))return wT;if(L.isCharType(i))return yT;if(L.isStringType(i))return vT;if(L.isDateType(i))return TT;if(L.isBooleanType(i))return ET},[i]),b=S.exports.useCallback(E=>{const{value:I}=E.target;Ii.debug("handleConditionChange",I),a(I)},[]),C=S.exports.useCallback(E=>{const{value:I}=E.target;Ii.debug("handleValueChange",I),c(I)},[]),w=S.exports.useCallback(E=>{const{value:I}=E.target;Ii.debug("handleStartValueChange",I),m(I)},[]),T=S.exports.useCallback(E=>{const{value:I}=E.target;Ii.debug("handleEndValueChange",I),g(I)},[]);S.exports.useEffect(function(){let I=!0;l===void 0&&(Ii.debug("Unable to create formatting rule. Condition is not selected."),I=!1),L.isNumberType(e.type)&&!IT(l,d,u,p)&&(Ii.debug("Unable to create formatting rule. Invalid value",d),I=!1),s({condition:l,value:d,start:u,end:p},I)},[s,e.type,l,d,u,p]);const y=S.exports.useMemo(()=>{if(i===void 0)return null;if(L.isNumberType(i))return RT(l,C,w,T,d,u,p);if(L.isCharType(i))return FT(l,C,d);if(L.isStringType(i))return DT(l,C,d);if(L.isDateType(i))return MT(l,C,d);if(L.isBooleanType(i))return NT()},[i,l,d,u,p,C,w,T]);return v("div",{className:"condition-editor mb-2",children:[h("select",{value:l,id:"condition-select",className:"custom-select mb-2",onChange:b,children:f}),y]})}const xT=X.module("StyleEditor"),_T="#fcfcfa",kT="#f0f0ee",OT="#1a171a",LT=200,AT=()=>{};function vp(t){var T,y;const{config:e,onChange:n=AT}=t,[s,i]=S.exports.useState(e.type),[o,r]=S.exports.useState((y=(T=e.customConfig)==null?void 0:T.background)!=null?y:_T),[l,a]=S.exports.useState(!1),[d,c]=S.exports.useState(LT),u=S.exports.useRef(null),m=S.exports.useCallback(E=>{const{value:I}=E.target;xT.debug("handleBackgroundChange",I),r(I)},[]),p=S.exports.useCallback(()=>{l&&a(!1)},[l]),g=S.exports.useCallback(()=>{l||b(),a(!l)},[l]),f=S.exports.useMemo(()=>[Bn.NO_FORMATTING,Bn.POSITIVE,Bn.NEGATIVE,Bn.WARN,Bn.NEUTRAL,Bn.ACCENT_1,Bn.ACCENT_2,Bn.CUSTOM],[]);function b(){u.current&&c(u.current.getBoundingClientRect().width)}S.exports.useEffect(function(){n({type:s,customConfig:{color:fl.isDark(o)?kT:OT,background:o}})},[n,s,o]);const C=S.exports.useCallback(()=>{const E=[];for(let I=0;I<f.length;I+=1){const D=f[I],F=`option-${I}-${D}`;E.push(v(z,{kind:"inline",className:"style-option-btn",onClick:()=>{i(D),a(!1)},style:{color:sl({type:D}),background:nl({type:D})},children:[D===s&&h(j,{icon:ds,className:"mr-2"}),D!==s&&h("span",{className:"mr-4"}),Eh(D)]},F))}return E},[f,s]),w=S.exports.useCallback(()=>h("div",{className:"style-menu-container",role:"presentation",style:{width:d},children:h("div",{className:"style-options",children:C()})}),[d,C]);return v("div",{className:"style-editor",children:[v("div",{className:"mb-2",ref:u,children:[h("label",{className:"mb-0",children:"Style"}),v(z,{kind:"inline",className:"cs-dropdown",style:{color:sl({type:s}),background:nl({type:s})},onClick:g,children:[Eh(s),h("span",{children:h(j,{icon:md,className:"cs-caret"})}),h(Fn,{isShown:l,actions:{menuElement:w()},popperOptions:{placement:"bottom-start"},popperClassName:"style-dropdown-menu",onMenuClosed:p,menuStyle:{maxWidth:"100rem"}})]})]}),s===Bn.CUSTOM&&v("div",{className:"mb-2",children:[h("label",{className:"mb-0",children:"Background"}),h("input",{type:"color",value:o,className:"custom-select color-select",onChange:m})]})]})}const fo=X.module("ColumnFormatEditor"),PT=()=>{};function HT(t){const{type:e,name:n}=t[0];return{column:{type:e,name:n},style:op(),...Ol(e)}}function VT(t){var b;const{columns:e,config:n=HT(e),onChange:s=PT}=t,[i,o]=S.exports.useState((b=e.find(C=>C.name===n.column.name&&C.type===n.column.type))!=null?b:e[0]),[r,l]=S.exports.useState(ip(n)),[a,d]=S.exports.useState(!1),[c,u]=S.exports.useState(n.style),m=S.exports.useCallback(C=>{const w=e.find(({name:T})=>T===C);w!==void 0?(o(w),i.type!==w.type&&(l(Ol(w.type)),d(!1))):fo.error(`Column ${C} not found.`)},[e,i]),p=S.exports.useCallback((C,w)=>{fo.debug("handleConditionChange",C,w),l(C),d(w)},[]),g=S.exports.useCallback(C=>{fo.debug("handleStyleChange",C),u(C)},[]);S.exports.useEffect(function(){if(i===void 0){fo.debug("Column is not selected, skip update.");return}if(c===void 0){fo.debug("Style is not selected, skip update.");return}const{type:w,name:T}=i;s({column:{type:w,name:T},style:c,...r},a)},[s,i,c,r,a]);const f=e.map(({name:C})=>({title:C,value:C}));return v("div",{className:"conditional-rule-editor form",children:[v("div",{className:"mb-2",children:[h("label",{className:"mb-0",children:"Format Cell If"}),h(Zi,{defaultValue:i==null?void 0:i.name,options:f,inputPlaceholder:"Select a column",spellCheck:!1,onChange:m,searchPlaceholder:"Filter columns"})]}),i!==void 0&&v(ye,{children:[h(wp,{column:i,config:r,onChange:p}),h(vp,{config:c,onChange:g})]})]})}const Co=X.module("RowFormatEditor"),UT=()=>{};function BT(t){const{type:e,name:n}=t[0];return{column:{type:e,name:n},style:op(),...Ol(e)}}function $T(t){var b;const{columns:e,config:n=BT(e),onChange:s=UT}=t,[i,o]=S.exports.useState((b=e.find(C=>C.name===n.column.name&&C.type===n.column.type))!=null?b:e[0]),[r,l]=S.exports.useState(ip(n)),[a,d]=S.exports.useState(!1),[c,u]=S.exports.useState(n.style),m=S.exports.useCallback(C=>{const w=e.find(({name:T})=>T===C);w!==void 0?(o(w),i.type!==w.type&&(l(Ol(w.type)),d(!1))):Co.error(`Column ${C} not found.`)},[e,i]),p=S.exports.useCallback((C,w)=>{Co.debug("handleConditionChange",C,w),l(C),d(w)},[]),g=S.exports.useCallback(C=>{Co.debug("handleStyleChange",C),u(C)},[]);S.exports.useEffect(function(){if(i===void 0){Co.debug("Column is not selected, skip update.");return}if(c===void 0){Co.debug("Style is not selected, skip update.");return}const{type:w,name:T}=i;s({column:{type:w,name:T},style:c,...r},a)},[s,i,c,r,a]);const f=e.map(({name:C})=>({title:C,value:C}));return v("div",{className:"conditional-rule-editor form",children:[v("div",{className:"mb-2",children:[h("label",{className:"mb-0",children:"Format Row If"}),h(Zi,{defaultValue:i==null?void 0:i.name,options:f,inputPlaceholder:"Select a column",spellCheck:!1,onChange:m,searchPlaceholder:"Filter columns"})]}),i!==void 0&&v(ye,{children:[h(wp,{column:i,config:r,onChange:p}),h(vp,{config:c,onChange:g})]})]})}const Ca=X.module("ConditionalFormatEditor"),ba=()=>{};function WT(t){switch(t){case Yn.CONDITIONAL:return h(iT,{});case Yn.ROWS:return h(oT,{})}}function zT(t){switch(t){case Yn.CONDITIONAL:return"Conditional";case Yn.ROWS:return"Rows"}}const Fh=[Yn.CONDITIONAL,Yn.ROWS];function GT(t){var C;const{columns:e,onSave:n=ba,onUpdate:s=ba,onCancel:i=ba,rule:o}=t,r=e.filter(wv),[l,a]=S.exports.useState((C=o==null?void 0:o.type)!=null?C:Fh[0]),[d,c]=S.exports.useState(o),[u,m]=S.exports.useState(!1),p=S.exports.useCallback(()=>{i()},[i]),g=S.exports.useCallback(()=>{if(d===void 0){Ca.error("Rule is not defined.");return}n(d)},[n,d]),f=S.exports.useCallback(w=>{Ca.debug("handleFormatterChange",w),a(w)},[]),b=S.exports.useCallback((w,T)=>{Ca.debug("handleRuleChange",w,T,l);const y={type:l,config:w};c(y),m(T),s(T?y:void 0)},[s,l]);return v("div",{className:"conditional-format-editor form",children:[v("div",{className:"mb-2",children:[h("label",{className:"mb-0",htmlFor:"formatter-select",children:"Select Formatter"}),h("div",{className:"formatter-list",children:Fh.map((w,T)=>h("div",{className:"formatter-type",children:v("button",{type:"button",className:W("btn","btn-icon","btn-formatter-type",{active:w===l}),"data-index":T,onClick:()=>f(w),children:[WT(w),zT(w)]})},w))})]}),l===Yn.CONDITIONAL&&h(VT,{columns:r,config:d==null?void 0:d.config,onChange:b}),l===Yn.ROWS&&h($T,{columns:r,config:d==null?void 0:d.config,onChange:b}),h("hr",{}),v("div",{className:"d-flex justify-content-end my-3",children:[h(z,{kind:"secondary",onClick:p,className:"mr-2",children:"Cancel"}),h(z,{kind:"primary",onClick:g,disabled:d===void 0||!u,children:"Done"})]})]})}function KT({text:t,isOpen:e,onClose:n}){var T,y;const[s,i]=S.exports.useState(!1),[o,r]=S.exports.useState(0),[l,a]=S.exports.useState(!1),[d,c]=S.exports.useState(!1),[u,m]=S.exports.useState(!1),p=S.exports.useRef();S.exports.useEffect(function(){if(!!e){try{JSON.parse(t),m(!0)}catch{m(!1)}c(!1)}},[e,t]),S.exports.useEffect(function(){p.current&&p.current.layout()},[o]),S.exports.useEffect(function(){p.current&&p.current.updateOptions({lineNumbers:l?"on":"off"})},[l]);function g(){a(!l)}function f(){var I;const E=(I=p.current)==null?void 0:I.getModel();!u||!E||(d?(E.setValue(t),c(!1)):(E.setValue(JSON.stringify(JSON.parse(t),void 0,2)),c(!0)),b())}function b(){var I,D;const E=p.current;!E||a(((D=(I=E.getModel())==null?void 0:I.getLineCount())!=null?D:0)>1)}function C(){s&&(p.current=void 0,n())}function w(E){p.current=E,E.onDidContentSizeChange(({contentHeight:I})=>r(I)),b()}return!e&&!s?null:v($o,{isOpen:e,centered:!0,keyboard:!0,toggle:C,onOpened:()=>i(!0),onClosed:()=>{i(!1),r(0)},className:"theme-bg-dark cell-overflow-modal",children:[v(zo,{toggle:n,children:[h("h5",{className:"overflow-modal-title",children:"Cell Contents"}),h(bl,{kind:"inline",tooltip:"Copy cell contents",copy:(y=(T=p.current)==null?void 0:T.getValue())!=null?y:t}),h(z,{kind:"inline",active:l,icon:kf,tooltip:"Toggle line numbers",onClick:g}),u&&h(z,{kind:"inline",icon:Ff,active:d,tooltip:"Format as JSON",onClick:f})]}),h(Wo,{style:{height:o},children:h(Il,{onEditorInitialized:w,settings:{value:t,readOnly:!0,wordWrap:"on",language:u?"typescript":"plaintext",folding:u,padding:{bottom:16},lineNumbers:l?"on":"off",overviewRulerLanes:0,renderLineHighlight:"none",find:{seedSearchStringFromSelection:"never"}}})})]})}const qT="###,##0";function YT({gotoRow:t,gotoRowError:e,onSubmit:n,isShown:s,onEntering:i,onEntered:o,onExiting:r,onExited:l,model:a,onGotoRowNumberChanged:d,onClose:c}){const u=S.exports.useRef(null),m="Row number",{rowCount:p}=a;return S.exports.useEffect(()=>{var g;document.activeElement!==u.current&&((g=u.current)==null||g.select())},[t]),h(Ll,{isShown:s,className:W("goto-row"),onEntering:i,onEntered:()=>{var g;o(),(g=u.current)==null||g.select()},onExiting:r,onExited:l,children:v(ye,{children:[v("div",{className:"goto-row-wrapper",children:[h("div",{className:"goto-row-text",children:"Go to row"}),h("div",{className:"goto-row-input",children:h("input",{ref:u,type:"number",onKeyDown:g=>{g.key==="Enter"&&(g.stopPropagation(),g.preventDefault(),n())},className:W("form-control",{"is-invalid":e!==""}),placeholder:m,onChange:g=>{d(g)},value:t})}),v("div",{className:"goto-row-text",children:["of ",dh.i18n.NumberFormat.format(qT,p)]}),e&&h("div",{className:"goto-row-error text-danger",children:e})]}),h("div",{className:"goto-row-close",children:h(z,{kind:"ghost",onClick:c,children:h(j,{icon:Xi,style:{marginRight:"0"}})})})]})})}const fe=X.module("IrisGrid"),XT=500,jT=250,QT=250,Tp=Object.freeze({aggregations:[],showOnTop:!1}),ZT="yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS z";function xh({advancedFilters:t,aggregationSettings:e,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}){return t.size===0&&e.aggregations.length===0&&n.length===0&&s.size===0&&i===L.REVERSE_TYPE.NONE&&o==null&&r==null&&l.length===0&&a.length===0}const Os=class extends S.exports.Component{constructor(t){super(t),this.getAdvancedMenuOpenedHandler=ve(N=>this.handleAdvancedMenuOpened.bind(this,N),{max:100}),this.getCachedAdvancedFilterMenuActions=ve((N,k,O,V,G)=>h(Bd,{model:N,column:k,onFilterChange:this.handleAdvancedFilterChange,onSortChange:this.handleAdvancedFilterSortChange,onDone:this.handleAdvancedFilterDone,options:O,sortDirection:V,formatter:G}),{max:50}),this.getCachedOptionItems=ve((N,k,O,V,G,Q,Z,be,le,he,Re,ee,ue,Se,De,qe)=>{const ke=[];return N&&ke.push({type:_e.CHART_BUILDER,title:"Chart Builder",icon:sC}),ke.push({type:_e.VISIBILITY_ORDERING_BUILDER,title:"Column Visibility & Ordering",icon:Na}),O&&ke.push({type:_e.CONDITIONAL_FORMATTING,title:"Conditional Formatting",icon:ml}),k&&ke.push({type:_e.CUSTOM_COLUMN_BUILDER,title:"Manage Custom Columns",icon:$f}),V&&ke.push({type:_e.ROLLUP_ROWS,title:"Rollup Rows",icon:vu}),G&&ke.push({type:_e.AGGREGATIONS,title:"Aggregate Columns",icon:Wf}),Q&&ke.push({type:_e.SELECT_DISTINCT,title:"Select Distinct Values",icon:Bf}),Z&&ue&&ke.push({type:_e.TABLE_EXPORTER,title:"Download CSV",icon:vf}),qe&&ke.push({type:_e.ADVANCED_SETTINGS,title:"Advanced Settings",icon:zf}),ke.push({type:_e.QUICK_FILTERS,title:"Quick Filters",subtitle:be.shortcut.getDisplayText(),icon:Kr,isOn:Re,onChange:be.action}),Se&&ke.push({type:_e.SEARCH_BAR,title:"Search Bar",subtitle:le.shortcut.getDisplayText(),icon:Su,isOn:ee,onChange:le.action}),ke.push({type:_e.GOTO,title:"Go to",subtitle:he.shortcut.getDisplayText(),icon:Uf,isOn:De,onChange:he.action}),ke},{max:1}),this.getCachedHiddenColumns=ve(N=>N,{max:1,normalizer:([N])=>N.join()}),this.getAggregationMap=ve((N,k)=>{const O={};return k.forEach(({operation:V,selected:G,invert:Q})=>{O[V]=As.getOperationColumnNames(N,V,G,Q)}),O}),this.getOperationMap=ve((N,k)=>{const O={};return k.filter(V=>!As.isRollupOperation(V.operation)).forEach(({operation:V,selected:G,invert:Q})=>{As.getOperationColumnNames(N,V,G,Q).forEach(Z=>{var le;const be=[...(le=O[Z])!=null?le:[],V];O[Z]=be})}),O}),this.getOperationOrder=ve(N=>N.map(k=>k.operation).filter(k=>!As.isRollupOperation(k))),this.getCachedFormatColumns=ve((N,k)=>Sv(N,k)),this.getCachedModelColumns=ve((N,k)=>N.columns),this.getCachedPreviewFormatColumns=ve((N,k,O,V)=>{if(fe.debug("getCachedPreviewFormatColumns",k,O,V),O!==void 0&&V!==void 0){const G=[...k];return G[V]=O,this.getCachedFormatColumns(N,G)}return this.getCachedFormatColumns(N,k)}),this.getModelRollupConfig=ve((N,k,O)=>te.getModelRollupConfig(N,k,O)),this.getModelTotalsConfig=ve((N,k,O)=>{var be,le,he;const{aggregations:V,showOnTop:G}=O;if(((le=(be=k==null?void 0:k.columns)==null?void 0:be.length)!=null?le:0)>0||((he=V==null?void 0:V.length)!=null?he:0)===0)return null;const Q=this.getOperationMap(N,V),Z=this.getOperationOrder(V);return{operationMap:Q,operationOrder:Z,showOnTop:G}}),this.getCachedStateOverride=ve((N,k,O,V,G,Q,Z,be,le,he)=>({hoverSelectColumn:N,isFilterBarShown:k,isSelectingColumn:O,loadingScrimProgress:V,quickFilters:G,advancedFilters:Q,sorts:Z,reverseType:be,rollupConfig:le,isMenuShown:he}),{max:1}),this.getCachedFilter=ve((N,k,O,V,G)=>[...N!=null?N:[],...V!=null?V:[],...te.getFiltersFromFilterMap(k),...te.getFiltersFromFilterMap(O),...G!==void 0?[G]:[]],{max:1}),this.getCachedTheme=ve((N,k,O)=>({...hp,...N,autoSelectRow:!k,rowFooterWidth:O>0?N.rowFooterWidth:0}),{max:1}),this.getAlwaysFetchColumns=ve((N,k,O,V,G,Q)=>{const Z=[];for(let le=0;le<V;le+=1)Z.push(k[K.getModelIndex(le,O)].name);for(let le=0;le<G;le+=1)Z.push(k[K.getModelIndex(k.length-1-le,O)].name);if(Q)for(let le=Q[0];le<=Q[1];le+=1)Z.push(k[K.getModelIndex(le,O)].name);return[...new Set([...N,...Z])]}),this.updateSearchFilter=je((N,k,O,V)=>{const G=Dr.createSearchFilter(N,k,O,V);this.setState({searchFilter:G})},jT),this.handleConditionalFormatEditorUpdate=je(N=>{this.setState({conditionalFormatPreview:N})},QT),this.handleDownloadProgressUpdate=us((N,k)=>{const{tableDownloadStatus:O}=this.state;O===ln.DOWNLOAD_STATUS.DOWNLOADING&&this.setState({tableDownloadProgress:N,tableDownloadEstimatedTime:k})},XT),this.getOverflowButtonTooltip=ve(N=>{if(N==null)return null;const k={position:"absolute",...N,pointerEvents:"none"};return h("div",{style:k,children:h($e,{options:{placement:"left",modifiers:{flip:{behavior:["left","right"]}}},ref:this.handleTooltipRef,children:"View full contents"},Date.now())})}),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.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.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.grid=null,this.gridWrapper=null,this.lastLoadedConfig=null,this.pending=new fs,this.globalColumnFormats=[],this.decimalFormatOptions={},this.integerFormatOptions={},this.truncateNumbersWithPound=!1,this.renderer=new xo,this.tableSaver=null,this.crossColumnRef=Y.createRef(),this.isAnimating=!1,this.filterInputRef=Y.createRef(),this.toggleFilterBarAction={action:()=>this.toggleFilterBar(),shortcut:dn.TABLE.TOGGLE_QUICK_FILTER},this.toggleSearchBarAction={action:()=>this.toggleSearchBar(),shortcut:dn.TABLE.TOGGLE_SEARCH},this.toggleGotoRowAction={action:()=>this.toggleGotoRow(),shortcut:dn.TABLE.GOTO_ROW},this.discardAction={action:()=>{const{model:N}=this.props;Je(N)&&N.isEditable&&N.pendingDataMap.size>0&&this.discardPending().catch(fe.error)},shortcut:dn.INPUT_TABLE.DISCARD},this.commitAction={action:()=>{const{model:N}=this.props;Je(N)&&N.isEditable&&N.pendingDataMap.size>0&&N.pendingDataErrors.size===0&&this.commitPending().catch(fe.error)},shortcut:dn.INPUT_TABLE.COMMIT},this.contextActions=[this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,this.discardAction,this.commitAction];const{aggregationSettings:e,conditionalFormats:n,customColumnFormatMap:s,isFilterBarShown:i,isSelectingPartition:o,model:r,movedColumns:l,movedRows:a,partition:d,partitionColumn:c,rollupConfig:u,userColumnWidths:m,userRowHeights:p,showSearchBar:g,searchValue:f,selectedSearchColumns:b,invertSearchColumns:C,advancedFilters:w,quickFilters:T,selectDistinctColumns:y,pendingDataMap:E,canCopy:I,frozenColumns:D}=t,F=[new xv(this),new _v(this)];I&&F.push(new Mv(this));const x=[new kv(this),new Ov(this),new Lv(this),new Vv(this),new Hv(this),new bs(this),new Pv(this),new Uv(this)],U=l.length>0?l:r.movedColumns,B=a.length>0?a:r.movedRows,_=new Wv({userColumnWidths:new Map(m),userRowHeights:new Map(p),movedColumns:U}),H=b!=null?b:[],A=Dr.createSearchFilter(f,H,r.columns,C);this.state={isFilterBarShown:i,isSelectingPartition:o,focusedFilterBarColumn:null,metricCalculator:_,metrics:void 0,keyHandlers:F,mouseHandlers:x,partition:d,partitionColumn:c,partitionTable:null,partitionFilters:[],quickFilters:T?new Map(T):new Map,advancedFilters:new Map(w),shownAdvancedFilter:null,hoverAdvancedFilter:null,sorts:[],reverseType:L.REVERSE_TYPE.NONE,customColumns:[],selectDistinctColumns:y,selectedRanges:[],copyOperation:null,loadingText:null,loadingScrimProgress:null,loadingSpinnerShown:!1,movedColumns:U,movedRows:B,shownColumnTooltip:null,formatter:new un,isMenuShown:!1,customColumnFormatMap:new Map(s),conditionalFormats:n,conditionalFormatEditIndex:null,conditionalFormatPreview:void 0,hoverSelectColumn:null,isTableDownloading:!1,isReady:!1,tableDownloadStatus:"",tableDownloadProgress:0,tableDownloadEstimatedTime:0,showSearchBar:g,searchFilter:A,searchValue:f,selectedSearchColumns:H,invertSearchColumns:C,rollupConfig:u,rollupSelectedColumns:[],aggregationSettings:e,selectedAggregation:null,openOptions:[],pendingRowCount:0,pendingDataMap:E!=null?E:new Map,pendingDataErrors:new Map,pendingSavePromise:null,pendingSaveError:null,toastMessage:null,frozenColumns:D,showOverflowModal:!1,overflowText:"",overflowButtonTooltipProps:null,isGotoRowShown:!1,gotoRow:"",gotoRowError:""}}static makeQuickFilter(t,e,n){try{return L.makeQuickFilter(t,e,n)}catch(s){fe.error("Error creating quick filter",s)}return null}componentDidMount(){const{partitionColumn:t,model:e}=this.props,n=t!=null?t:e.columns.find(s=>s.isPartitionColumn);e.isFilterRequired&&e.isValuesTableAvailable&&n!=null?this.loadPartitionsTable(n):this.initState(),this.startListening(e)}componentDidUpdate(t){var c;const{inputFilters:e,isSelectingColumn:n,settings:s,model:i,customFilters:o,sorts:r}=this.props;i!==t.model&&(this.stopListening(t.model),this.startListening(i));const l=e!==t.inputFilters?e.filter(u=>!t.inputFilters.includes(u)):[];if(l.length>0){const{advancedSettings:u}=this.props,m=(c=u.get(mi.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS))!=null?c:!1;m&&(this.clearGridInputField(),this.clearCrossColumSearch()),this.startLoading("Filtering...",!0),this.applyInputFilters(l,m)}n!==t.isSelectingColumn&&this.resetColumnSelection(),s!==t.settings&&this.updateFormatterSettings(s),o!==t.customFilters&&this.startLoading("Filtering...",!0),r!==t.sorts&&this.updateSorts(r);const{loadingScrimStartTime:a,loadingScrimFinishTime:d}=this;a!=null&&d!=null&&window.requestAnimationFrame(()=>{const u=Date.now(),m=u-a,p=d-a,g=Math.min(m/p,1);d<u&&(this.loadingScrimStartTime=void 0,this.loadingScrimFinishTime=void 0),this.setState(f=>f.loadingScrimProgress==null?(fe.debug2("Ignoring scrim update because loading cancelled."),null):{loadingScrimProgress:g})}),this.sendStateChange()}componentWillUnmount(){const{model:t}=this.props;this.stopListening(t),this.pending.cancel(),this.updateSearchFilter.cancel(),this.loadingTimer&&clearTimeout(this.loadingTimer),this.handleDownloadProgressUpdate.cancel(),this.animationFrame!==void 0&&cancelAnimationFrame(this.animationFrame)}getValueForCell(t,e,n=!1){const{model:s}=this.props,i=this.getModelColumn(t),o=this.getModelRow(e);if(n&&i!=null&&o!=null){const r=s.valueForCell(i,o);if(L.isDateType(s.columns[i].type)){const{formatter:l}=s;return M.i18n.DateTimeFormat.format(ZT,r,M.i18n.TimeZone.getTimeZone(l.timeZone))}return r}return n?null:i!=null&&o!=null?s.textForCell(i,o):""}getModelColumn(t){const{metrics:e}=this.state;P(e);const{modelColumns:n}=e;return n==null?null:t!=null?n.get(t):null}getModelRow(t){const{metrics:e}=this.state;P(e);const{modelRows:n}=e;return n==null?null:t!=null?n.get(t):null}getTheme(){var n;const{model:t,theme:e}=this.props;return this.getCachedTheme(e,(n=Je(t)&&t.isEditable)!=null?n:!1,t.floatingTopRowCount+t.floatingBottomRowCount)}getVisibleColumn(t){const{movedColumns:e}=this.state;return K.getVisibleIndex(t,e)}applyInputFilters(t,e=!1){const{model:n}=this.props,{advancedFilters:s,quickFilters:i}=this.state,o=e?new Map:new Map(s),r=e?new Map:new Map(i);let l=e&&s.size>0;t.forEach(({name:a,type:d,value:c})=>{const u=n.columns.findIndex(({name:m,type:p})=>m===a&&p===d);u>=0?(l=o.delete(u)||l,l=this.applyQuickFilter(u,c,r)||l):fe.error("Unable to find column for inputFilter",a,d,c)}),l&&this.setState({quickFilters:r,advancedFilters:o})}applyQuickFilter(t,e,n){const{model:s}=this.props,{formatter:i}=s,o=s.columns[t];if(e!=null&&`${e}`.trim().length>0){const r=n.get(t);if(r!=null){const{text:l}=r;if(l===e)return fe.debug2("Ignoring change to existing filter"),!1}return n.set(t,{text:e,filter:Os.makeQuickFilter(o,e,i.timeZone)}),!0}return n.delete(t)}setAdvancedFilterMap(t){this.setState({advancedFilters:t})}setAdvancedFilter(t,e,n){fe.debug("Setting advanced filter",t,e),this.startLoading("Filtering...",!0),this.setState(({advancedFilters:s})=>{const i=new Map(s);return e==null?i.delete(t):i.set(t,{filter:e,options:n}),{advancedFilters:i}})}setQuickFilter(t,e,n){fe.debug("Setting quick filter",t,e,n),this.startLoading("Filtering...",!0),this.setState(({quickFilters:s})=>{const i=new Map(s);return i.set(t,{filter:e,text:n}),{quickFilters:i}})}setFilterMap(t){var i;fe.debug("setFilterMap",t);const{advancedSettings:e}=this.props;((i=e.get(mi.LINK_CHANGE_CLEARS_ALL_FILTERS))!=null?i:!1)&&this.clearAllFilters();const{model:s}=this.props;t.forEach(({columnType:o,filterList:r},l)=>{const a=s.columns.find(u=>u.name===l&&u.type===o);if(a==null)return;const d=s.getColumnIndexByName(a.name);P(d);const c=te.combineFiltersFromList(o,r);if(c.length===0)this.removeQuickFilter(d);else{const{formatter:u}=s;this.setQuickFilter(d,Os.makeQuickFilter(a,c,u.timeZone),`${c}`)}})}removeColumnFilter(t){this.startLoading("Filtering...",!0),this.setState(({advancedFilters:e,quickFilters:n})=>{const s=e?new Map(e):new Map,i=n?new Map(n):new Map;return i.delete(t),s.delete(t),{quickFilters:i,advancedFilters:s}})}removeQuickFilter(t){this.startLoading("Clearing Filter...",!0),this.setState(({quickFilters:e})=>{const n=new Map(e);return n.delete(t),{quickFilters:n}})}clearAllFilters(){fe.debug("Clearing all filters");const{advancedFilters:t,quickFilters:e,searchFilter:n}=this.state;e.size===0&&t.size===0&&n===null||(this.clearGridInputField(),this.startLoading("Clearing Filters...",!0),this.setState({quickFilters:new Map,advancedFilters:new Map,searchValue:"",searchFilter:void 0}))}clearCrossColumSearch(){fe.debug("Clearing cross-column search"),this.setState({searchValue:"",searchFilter:void 0})}clearGridInputField(){this.filterInputRef.current!=null&&this.filterInputRef.current.setValue("")}rebuildFilters(){fe.debug("Rebuilding filters");const{model:t}=this.props,{advancedFilters:e,quickFilters:n}=this.state,{columns:s,formatter:i}=t,o=new Map,r=new Map;e.forEach((l,a)=>{const{options:d}=l,c=s[a],u=L.makeAdvancedFilter(c,d,i.timeZone);o.set(a,{options:d,filter:u})}),n.forEach((l,a)=>{const{text:d}=l,c=s[a];r.set(a,{text:d,filter:Os.makeQuickFilter(c,d,i.timeZone)})}),this.startLoading("Rebuilding filters...",!0),this.setState({quickFilters:r,advancedFilters:o})}setFilters({quickFilters:t,advancedFilters:e}){this.setState({quickFilters:t,advancedFilters:e})}updateFormatterSettings(t,e=!0){var m,p,g;const n=hs.getColumnFormats(t),s=hs.getDateTimeFormatterOptions(t),i=(m=t==null?void 0:t.defaultDecimalFormatOptions)!=null?m:{},o=(p=t==null?void 0:t.defaultIntegerFormatOptions)!=null?p:{},r=(g=t==null?void 0:t.truncateNumbersWithPound)!=null?g:!1,l=!ht(this.globalColumnFormats,n),a=!ht(this.dateTimeFormatterOptions,s),d=!ht(this.decimalFormatOptions,t==null?void 0:t.defaultDecimalFormatOptions),c=!ht(this.integerFormatOptions,o),u=this.truncateNumbersWithPound!==r;(l||a||d||c||u)&&(this.globalColumnFormats=n,this.dateTimeFormatterOptions=s,this.decimalFormatOptions=i,this.integerFormatOptions=o,this.truncateNumbersWithPound=r,this.updateFormatter({},e),a&&e&&this.rebuildFilters())}updateFormatter(t,e=!0){var r;const{customColumnFormatMap:n}=this.state,s={customColumnFormatMap:n,...t},i=[...(r=this.globalColumnFormats)!=null?r:[],...s.customColumnFormatMap.values()],o=new un(i,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions,this.truncateNumbersWithPound);fe.debug("updateFormatter",this.globalColumnFormats,i),this.setState({...s,formatter:o},()=>{e&&this.grid&&this.grid.forceUpdate()})}initFormatter(){const{settings:t}=this.props;this.updateFormatterSettings(t)}initState(){const{applyInputFiltersOnInit:t,inputFilters:e,sorts:n,model:s,reverseType:i,customColumns:o,searchValue:r,selectedSearchColumns:l,invertSearchColumns:a}=this.props,d=l!=null?l:[],c=Dr.createSearchFilter(r,d,s.columns,a);if(t){const u=e.filter(m=>m.value!=null);this.applyInputFilters(u)}this.setState({sorts:n,reverseType:i,customColumns:o,isReady:!0,searchFilter:c}),this.initFormatter()}async loadPartitionsTable(t){const{model:e}=this.props;this.setState({isSelectingPartition:!0});try{const n=await this.pending.add(e.valuesTable(t),r=>r.close()),s=n.columns[0],i=s.sort().desc();n.applySort([i]),n.setViewport(0,0,[s]);const o=await this.pending.add(n.getViewportData());if(o.rows.length>0){const l=o.rows[0].get(s);this.updatePartition(l,t),this.setState({isSelectingPartition:!0})}else fe.info("Table does not have any data, just fetching all"),this.setState({isSelectingPartition:!1}),this.handlePartitionFetchAll();this.setState({partitionTable:n,partitionColumn:t},()=>{this.initState()})}catch(n){this.handleTableLoadError(n)}}updatePartition(t,e){const s=[e.filter().eq(M.FilterValue.ofString(t))];this.setState({partition:t,partitionFilters:s})}copyCell(t,e,n=!1){const{canCopy:s}=this.props;if(s){const i=String(this.getValueForCell(t,e,n));ji(i).catch(o=>fe.error("Unable to copy cell",o))}else fe.error("Attempted to copyCell for user without copy permission.")}copyRanges(t,e=!1,n=!0,s){const{model:i,canCopy:o}=this.props,{metricCalculator:r,movedColumns:l}=this.state,a=r.getUserColumnWidths();if(o){const d={ranges:re.boundedRanges(t,i.columnCount,i.rowCount),includeHeaders:e,formatValues:n,movedColumns:l,userColumnWidths:a,error:s};this.setState({copyOperation:d})}else fe.error("Attempted copyRanges for user without copy permission.")}startLoading(t,e=!1){var s,i;this.setState({loadingText:t});const n=this.getTheme();if(e&&this.grid&&(this.grid.clearSelectedRanges(),this.grid.setViewState({top:0},!0)),this.loadingScrimStartTime==null){const{minScrimTransitionTime:o,maxScrimTransitionTime:r}=n;P(o),P(r);const l=(i=(s=this.gridWrapper)==null?void 0:s.getBoundingClientRect().height)!=null?i:0,a=Math.max(o,Math.min(l/2,r));this.loadingScrimStartTime=Date.now(),this.loadingScrimFinishTime=this.loadingScrimStartTime+a,this.setState({loadingScrimProgress:0}),this.loadingTimer=setTimeout(()=>{this.setState({loadingSpinnerShown:!0})},Os.loadingSpinnerDelay)}}stopLoading(){this.loadingScrimStartTime=void 0,this.loadingScrimFinishTime=void 0,this.setState({loadingText:null,loadingScrimProgress:null,loadingSpinnerShown:!1}),this.loadingTimer!=null&&(clearTimeout(this.loadingTimer),this.loadingTimer=void 0)}rollback(){if(this.lastLoadedConfig){fe.debug("loading last loading config",this.lastLoadedConfig);const{advancedFilters:t,aggregationSettings:e,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}=this.lastLoadedConfig;this.lastLoadedConfig=null,this.setState({advancedFilters:t,aggregationSettings:e,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a})}else fe.debug("remove all sorts, filters, and custom columns"),this.setState({advancedFilters:new Map,aggregationSettings:Tp,customColumns:[],quickFilters:new Map,reverseType:L.REVERSE_TYPE.NONE,rollupConfig:void 0,selectDistinctColumns:[],sorts:[]})}canRollback(){return this.lastLoadedConfig!=null||!xh(this.state)}startListening(t){t.addEventListener(Ce.EVENT.UPDATED,this.handleUpdate),t.addEventListener(Ce.EVENT.REQUEST_FAILED,this.handleRequestFailed),t.addEventListener(Ce.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),t.addEventListener(Ce.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}stopListening(t){t.removeEventListener(Ce.EVENT.UPDATED,this.handleUpdate),t.removeEventListener(Ce.EVENT.REQUEST_FAILED,this.handleRequestFailed),t.removeEventListener(Ce.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),t.removeEventListener(Ce.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}focus(){var t;(t=this.grid)==null||t.focus()}focusFilterBar(t){var c,u,m;const{movedColumns:e}=this.state,{model:n}=this.props,{columnCount:s}=n,i=K.getModelIndex(t,e);if(t==null||t<0||s<=t||!n.isFilterable(i)){this.setState({focusedFilterBarColumn:null});return}const{metricCalculator:o,metrics:r}=this.state;P(r);const{left:l,rightVisible:a,lastLeft:d}=r;if(t<l)(c=this.grid)==null||c.setViewState({left:t},!0);else if(a<t){const p=(u=this.grid)==null?void 0:u.getMetricState();P(p);const g=o.getLastLeft(p,t,o.getVisibleWidth(p));(m=this.grid)==null||m.setViewState({left:Math.min(g,d),leftOffset:0},!0)}this.lastFocusedFilterBarColumn=t,this.setState({focusedFilterBarColumn:t,isFilterBarShown:!0})}hideColumnByVisibleIndex(t){var s;const{metricCalculator:e,movedColumns:n}=this.state;e.setColumnWidth(K.getModelIndex(t,n),0),(s=this.grid)==null||s.forceUpdate()}freezeColumnByColumnName(t){const{frozenColumns:e,movedColumns:n}=this.state,{model:s}=this.props;fe.debug2("freezing column",t);const i=e==null?new Set(s.frozenColumns):new Set(e);i.add(t);const o=s.getColumnIndexByName(t);P(o);const r=K.getVisibleIndex(o,n),l=K.moveItem(r,i.size-1,n);this.setState({frozenColumns:[...i],movedColumns:l})}unFreezeColumnByColumnName(t){const{frozenColumns:e,movedColumns:n}=this.state,{model:s}=this.props;fe.debug2("unfreezing column",t);const i=e==null?new Set(s.frozenColumns):new Set(e);i.delete(t);const o=s.getColumnIndexByName(t);P(o);const r=K.getVisibleIndex(o,n),l=K.moveItem(r,i.size+s.frontColumns.length,n);this.setState({frozenColumns:[...i],movedColumns:l})}handleColumnVisibilityChanged(t,e){var s;const{metricCalculator:n}=this.state;e===pi.VISIBILITY_OPTIONS.SHOW?t.forEach(i=>{n.resetColumnWidth(i)}):t.forEach(i=>{n.setColumnWidth(i,0)}),(s=this.grid)==null||s.forceUpdate()}handleCrossColumnSearch(t,e,n){const{model:s}=this.props;this.updateSearchFilter(t,e,s.columns,n),this.setState({searchValue:t,selectedSearchColumns:e,invertSearchColumns:n})}handleAnimationLoop(){var t,e;(t=this.grid)==null||t.updateCanvasScale(),(e=this.grid)==null||e.updateCanvas(),this.isAnimating&&(this.animationFrame=requestAnimationFrame(this.handleAnimationLoop))}handleAnimationStart(){fe.debug2("handleAnimationStart"),this.isAnimating=!0,this.animationFrame=requestAnimationFrame(this.handleAnimationLoop)}handleAnimationEnd(){fe.debug2("handleAnimationEnd"),this.isAnimating=!1}handlePartitionAppend(t){const{onPartitionAppend:e}=this.props,{partitionColumn:n}=this.state;!n||e(n,t)}handlePartitionChange(t){const{partitionColumn:e}=this.state;!e||this.updatePartition(t,e)}handlePartitionFetchAll(){this.setState({partitionFilters:[],isSelectingPartition:!1})}handlePartitionDone(){this.setState({isSelectingPartition:!1})}handleTableLoadError(t){if(Te.isCanceled(t))return;fe.error(t);const{onError:e}=this.props;e(t)}showAllColumns(){var s;const{metricCalculator:t}=this.state,n=[...t.getUserColumnWidths().entries()];for(let i=0;i<n.length;i+=1){const[o,r]=n[i];r===0&&t.resetColumnWidth(o)}(s=this.grid)==null||s.forceUpdate()}toggleSort(t,e){fe.info("Toggling sort for column",t);const{model:n}=this.props,{sorts:s}=this.state,i=this.getModelColumn(t);P(i);const o=L.toggleSortForColumn(s,n.columns,i,e);this.updateSorts(o)}updateSorts(t){var e;this.startLoading("Sorting..."),this.setState({sorts:t}),(e=this.grid)==null||e.forceUpdate()}sortColumn(t,e=L.sortDirection.none,n=!1,s=!1){var r;P(t);const{model:i}=this.props,o=L.sortColumn(i.sort,i.columns,t,e,n,s);this.startLoading("Sorting..."),this.setState({sorts:o}),(r=this.grid)==null||r.forceUpdate()}reverse(t){var e;this.startLoading("Reversing..."),this.setState({reverseType:t}),(e=this.grid)==null||e.forceUpdate()}isReversible(){const{model:t}=this.props;return t.isReversible}toggleFilterBar(t=this.lastFocusedFilterBarColumn){var n;let{isFilterBarShown:e}=this.state;if(e=!e,this.setState({isFilterBarShown:e}),e)if(t!=null)this.focusFilterBar(t);else{let s=0;const{model:i}=this.props,{columnCount:o}=i;for(let r=0;r<o;r+=1){const l=this.getModelColumn(r);if(l!=null){const a=i.columns[l];if(a!=null&&L.isTextType(a.type)){s=r;break}}}this.focusFilterBar(s)}else(n=this.grid)==null||n.focus()}isTableSearchAvailable(){var s,i,o;const{model:t,canToggleSearch:e}=this.props,n=(s=t==null?void 0:t.layoutHints)==null?void 0:s.searchDisplayMode;return n===((i=M.SearchDisplayMode)==null?void 0:i.SEARCH_DISPLAY_HIDE)?!1:n===((o=M.SearchDisplayMode)==null?void 0:o.SEARCH_DISPLAY_SHOW)?!0:e}toggleSearchBar(){const{showSearchBar:t}=this.state;if(!this.isTableSearchAvailable())return;const e=!t;this.setState({showSearchBar:e},()=>{var n,s,i;e&&((n=this.crossColumnRef)==null?void 0:n.current)?(s=this.crossColumnRef)==null||s.current.focus():(i=this.grid)==null||i.focus()})}toggleGotoRow(t=""){const{isGotoRowShown:e}=this.state;if(t){this.setState({isGotoRowShown:!0,gotoRow:t,gotoRowError:""});return}this.setState({isGotoRowShown:!e,gotoRow:"",gotoRowError:""})}async commitPending(){var i,o;const{model:t}=this.props;if(!Je(t)||!t.isEditable)throw new Error("Cannot save, table is not editable");const{pendingSavePromise:e}=this.state;if(e!=null)throw new Error("Save already in progress");const n=(i=document==null?void 0:document.activeElement)==null?void 0:i.classList.contains("grid-cell-input-field");if(n!=null&&n){if(document.activeElement!=null&&document.activeElement.classList.contains("error"))throw new Hi("Current input is invalid");(o=this.grid)==null||o.focus()}const s=this.pending.add(t.commitPending()).then(()=>{this.setState({pendingSaveError:null,pendingSavePromise:null})}).catch(r=>{Te.isCanceled(r)||this.setState({pendingSaveError:r,pendingSavePromise:null})});return this.setState({pendingSavePromise:s}),s}async discardPending(){const{pendingSavePromise:t}=this.state;if(t!=null)throw new Error("Cannot cancel a save in progress");this.setState({pendingSavePromise:null,pendingSaveError:null,pendingDataMap:new Map,pendingDataErrors:new Map})}selectColumn(t){const{onColumnSelected:e}=this.props;e(t)}selectData(t,e){const{model:n}=this.props,{columns:s,groupedColumns:i}=n,o={};for(let l=0;l<s.length;l+=1){const a=s[l],{name:d,type:c}=a,u=n.valueForCell(l,e),m=n.textForCell(l,e),p=this.getVisibleColumn(l),g=pt(n)&&n.isRowExpandable(e),f=i.find(b=>b.name===d)!=null;o[d]={value:u,text:m,type:c,isGrouped:f,isExpandable:g,visibleIndex:p}}const{onDataSelected:r}=this.props;r(e,o)}handleAdvancedFilterChange(t,e,n){const{model:s}=this.props,i=s.getColumnIndexByName(t.name);P(i),this.setAdvancedFilter(i,e,n)}handleAdvancedFilterSortChange(t,e,n=!1){var a;const{model:s}=this.props,i=s.getColumnIndexByName(t.name);P(i);const o=L.getSortForColumn(s.sort,i);let r=null;(o==null||o.direction!==e)&&(e===L.sortDirection.descending?r=t.sort().desc():r=t.sort().asc());const l=L.setSortForColumn(s.sort,i,r,n);fe.info("Setting table sorts",l),this.startLoading("Sorting..."),this.setState({sorts:l}),(a=this.grid)==null||a.forceUpdate()}handleAdvancedFilterDone(){var t;(t=this.grid)==null||t.focus()}handleAdvancedMenuOpened(t){this.setState({shownAdvancedFilter:t})}handleGotoRowOpened(){this.setState({isGotoRowShown:!0})}handleGotoRowClosed(){this.setState({isGotoRowShown:!1})}handleAdvancedMenuClosed(t){var s,i;const{focusedFilterBarColumn:e,isFilterBarShown:n}=this.state;n&&e===t&&((s=this.filterInputRef)==null?void 0:s.current)!==null?((i=this.filterInputRef)==null||i.current.focus(),this.setState({shownAdvancedFilter:null})):this.setState({focusedFilterBarColumn:null,shownAdvancedFilter:null})}handleCancel(){this.rollback()}handleChartChange(){}handleChartCreate(t){const{model:e,onCreateChart:n}=this.props;n(t,e)}handleGridError(t){fe.warn("Grid Error",t),this.setState({toastMessage:h("div",{className:"error-message",children:`${t}`})})}handleFilterBarChange(t){this.startLoading("Filtering...",!0),this.setState(({focusedFilterBarColumn:e,quickFilters:n})=>{const s=new Map(n);if(e!=null){const i=this.getModelColumn(e);P(i),this.applyQuickFilter(i,t,s)}return{quickFilters:s}})}handleFilterBarDone(t=!0,e=!0){var n;t&&((n=this.grid)==null||n.focus()),e&&this.setState({focusedFilterBarColumn:null})}handleFilterBarTab(t){const{focusedFilterBarColumn:e}=this.state;P(e),t?this.focusFilterBar(e-1):this.focusFilterBar(e+1)}handleFormatSelection(t,e){const{model:n}=this.props,s=n.columns[t],{customColumnFormatMap:i}=this.state,o=new Map(i);if(e!=null){const r=L.getNormalizedType(s.type);P(r);const l=un.makeColumnFormattingRule(r,s.name,e);o.set(s.name,l)}else o.delete(s.name);this.updateFormatter({customColumnFormatMap:o})}handleMenu(t){t.stopPropagation(),this.setState({isMenuShown:!0})}handleMenuClose(){this.setState({isMenuShown:!1,openOptions:[]})}handleMenuBack(){this.setState(({openOptions:t})=>{const e=[...t];return e.pop(),{openOptions:e}})}handleMenuSelect(t){this.setState(({openOptions:e})=>({openOptions:[...e,t]}))}handleRequestFailed(t){const e=t;if(fe.error("request failed:",e.detail),this.stopLoading(),this.canRollback())this.startLoading("Rolling back changes...",!0),this.rollback();else{fe.error("Table failed and unable to rollback");const{onError:n}=this.props;n(new Error(`Error displaying table: ${e.detail}`))}}handleUpdate(){var c;this.stopLoading(),fe.debug2("Received model update");const{advancedFilters:t,aggregationSettings:e,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}=this.state,d={advancedFilters:t,aggregationSettings:e,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a};xh(d)?this.lastLoadedConfig=null:this.lastLoadedConfig=d,(c=this.grid)==null||c.forceUpdate()}handleViewChanged(t){var i,o;const{model:e}=this.props,{selectionEndRow:n=0}=(o=(i=this.grid)==null?void 0:i.state)!=null?o:{};let s=0;if(Je(e)&&e.isEditable){P(t);const{bottomViewport:r}=t,l=e.rowCount-e.floatingBottomRowCount;n===l-1?s=e.pendingRowCount+1:n===l-2?s=e.pendingRowCount:s=Math.max(0,r-(e.rowCount-e.pendingRowCount)-e.floatingTopRowCount-e.floatingBottomRowCount-1)}this.setState({metrics:t,pendingRowCount:s})}handleSelectionChanged(t){P(t);const{onSelectionChanged:e}=this.props,{copyOperation:n}=this.state;this.setState({selectedRanges:t}),n!=null&&this.setState({copyOperation:null}),e(t)}handleMovedColumnsChanged(t,e=()=>null){this.setState({movedColumns:t},e)}handleTooltipRef(t){t!=null&&t.startTimer(),this.tooltip=t}handleConditionalFormatsChange(t){fe.debug("Updated conditional formats",t),this.setState({conditionalFormats:t})}handleConditionalFormatCreate(){fe.debug("Create new conditional format");const{openOptions:t,conditionalFormats:e}=this.state;this.setState({openOptions:[...t,{type:_e.CONDITIONAL_FORMATTING_EDIT,title:"Create Formatting Rule"}],conditionalFormatEditIndex:e.length,conditionalFormatPreview:void 0})}handleConditionalFormatEdit(t){fe.debug("Edit conditional format",t);const{openOptions:e,conditionalFormats:n}=this.state;this.setState({openOptions:[...e,{type:_e.CONDITIONAL_FORMATTING_EDIT,title:"Edit Formatting Rule"}],conditionalFormatEditIndex:t,conditionalFormatPreview:{...n[t]}})}handleConditionalFormatEditorSave(t){fe.debug("Save conditional format changes",t),this.setState(e=>{if(e.conditionalFormatEditIndex===null)return fe.debug("Invalid format index"),null;const n=[...e.conditionalFormats];return n[e.conditionalFormatEditIndex]=t,{conditionalFormats:n}},()=>{this.handleMenuBack()})}handleConditionalFormatEditorCancel(){this.handleMenuBack(),this.setState({conditionalFormatEditIndex:null})}handleUpdateCustomColumns(t){fe.info("handleUpdateCustomColumns:",t);const{model:e}=this.props,{movedColumns:n,sorts:s,quickFilters:i,advancedFilters:o,selectDistinctColumns:r}=this.state,{columns:l}=e,a=e.customColumns.map(c=>`${c}`),d=te.getRemovedCustomColumnNames(a,t);if(d.length>0){const c=te.removeSortsInColumns(s,d),u=te.removeFiltersInColumns(l,i,d),m=te.removeFiltersInColumns(l,o,d),p=te.removeColumnFromMovedColumns(l,n,d),g=te.removeColumnsFromSelectDistinctColumns(r,d);c.length!==s.length&&(fe.debug("removing sorts from removed custom columns..."),this.setState({sorts:c})),(u.size!==i.size||m.size!==o.size)&&(fe.debug("removing filters from removed custom columns..."),this.setState({quickFilters:u,advancedFilters:m})),ht(n,p)||(fe.debug("change moved columns for removed custom columns",p),this.setState({movedColumns:p})),ht(r,g)||(fe.debug("change selectDistinct columns for removed custom columns",p),this.setState({selectDistinctColumns:g}))}this.setState({customColumns:t}),this.startLoading("Applying custom columns...")}handleCustomColumnsChanged(){var e;fe.debug("custom columns changed");const{isReady:t}=this.state;t?(this.stopLoading(),(e=this.grid)==null||e.forceUpdate()):this.initState()}handlePendingCommitClicked(){return this.commitPending()}handlePendingDiscardClicked(){return this.discardPending()}handlePendingDataUpdated(){var s;fe.debug("pending data updated");const{model:t}=this.props,{pendingDataMap:e,pendingDataErrors:n}=t;this.setState({pendingDataMap:e,pendingDataErrors:n,pendingSaveError:null}),(s=this.grid)==null||s.forceUpdate()}handleAggregationsChange(t){fe.debug("handleAggregationsChange",t),this.startLoading(`Aggregating ${t.aggregations.map(e=>e.operation).join(", ")}...`),this.setState({aggregationSettings:t})}handleAggregationChange(t){fe.debug("handleAggregationChange",t),this.startLoading(`Aggregating ${t.operation}...`),this.setState(({aggregationSettings:e})=>({selectedAggregation:t,aggregationSettings:{...e,aggregations:e.aggregations.map(n=>n.operation===t.operation?t:n)}}))}handleAggregationEdit(t){fe.debug("handleAggregationEdit",t);const{openOptions:e}=this.state;this.setState({openOptions:[...e,{type:_e.AGGREGATION_EDIT,title:`Edit Columns to ${t.operation}`}],selectedAggregation:t})}handleRollupChange(t){var e,n;fe.info("Rollup change",t),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Grouping by columns ${(n=(e=t==null?void 0:t.columns)==null?void 0:e.join(", "))!=null?n:""}...`),this.setState({rollupConfig:t,movedColumns:[],sorts:[],reverseType:L.REVERSE_TYPE.NONE,selectDistinctColumns:[]})}handleSelectDistinctChanged(t){fe.debug("SelectDistinct change",t),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Selecting distinct values in ${t.length>0?t.join(", "):""}...`),this.setState({selectDistinctColumns:t,movedColumns:[],sorts:[],reverseType:L.REVERSE_TYPE.NONE})}handleDownloadTableStart(){const{canDownloadCsv:t}=this.props;t?this.setState({isTableDownloading:!0,tableDownloadProgress:0,tableDownloadEstimatedTime:null,tableDownloadStatus:ln.DOWNLOAD_STATUS.INITIATING}):fe.error("Attempted to handleDownloadTableStart for user without download CSV permission.")}handleDownloadTable(t,e,n,s,i,o,r){const{canDownloadCsv:l}=this.props;l?(fe.info("start table downloading",t,e,n,s,i,o,r),this.setState(()=>(this.tableSaver&&this.tableSaver.startDownload(t,e,n,s,i,o,r),{tableDownloadStatus:ln.DOWNLOAD_STATUS.DOWNLOADING}))):fe.error("Attempted to handleDownloadTable for user without download CSV permission.")}handleCancelDownloadTable(){var t;(t=this.tableSaver)==null||t.cancelDownload(),this.setState({isTableDownloading:!1})}handleDownloadCompleted(){this.setState({isTableDownloading:!1,tableDownloadProgress:100,tableDownloadStatus:ln.DOWNLOAD_STATUS.FINISHED})}handleDownloadCanceled(){this.setState({isTableDownloading:!1,tableDownloadProgress:0,tableDownloadStatus:ln.DOWNLOAD_STATUS.CANCELED})}deleteRanges(t){const{model:e}=this.props;this.pending.add(e.delete(t)).catch(n=>{Te.isCanceled(n)||fe.error("Unable to delete ranges",t,n)})}resetColumnSelection(){if(this.grid==null)return;const{isSelectingColumn:t}=this.props;if(t){const{columnAllowedCursor:e}=this.props;this.grid.setState({cursor:e})}else this.grid.setState({cursor:null}),this.setState({hoverSelectColumn:null})}resetGridViewState(t=!0){!this.grid||(this.grid.clearSelectedRanges(),this.grid.setViewState({left:0,top:0,topOffset:0,leftOffset:0},t))}sendStateChange(){if(!this.grid)return;const{state:t}=this,{state:e}=this.grid,{onStateChange:n}=this.props;n(t,e)}handleOverflowClose(){this.setState({showOverflowModal:!1})}getColumnBoundingRect(){var m;const{metrics:t,shownColumnTooltip:e}=this.state;P(t),P(e);const n=(m=this.gridWrapper)==null?void 0:m.getBoundingClientRect(),s=20;P(n);const{columnHeaderHeight:i,visibleColumnXs:o,visibleColumnWidths:r,width:l,columnHeaderMaxDepth:a}=t,d=o.get(e),c=r.get(e);P(d),P(c);const u=n.left+Bt(d+c/2,s,l-s);return{top:n.top+(a-1)*i,left:n.left+Bt(d+c/2,s,l-s),bottom:n.top+a*i,right:n.left+Bt(d+c/2,s,l-s)+1,width:1,height:i,x:u,y:n.top,toJSON:()=>{throw new Error("not implemented")}}}handleGotoRowSelectedRowNumberSubmit(){const{gotoRow:t}=this.state;this.focusRowInGrid(t)}focusRowInGrid(t){var i,o,r;const{model:e}=this.props,{rowCount:n}=e;if(this.setState({gotoRow:t}),t===""){this.setState({gotoRowError:""});return}const s=parseInt(t,10);s>n||s<-n?this.setState({gotoRowError:"Invalid row index"}):s===0?(this.setState({gotoRowError:""}),(i=this.grid)==null||i.setFocusRow(0)):s<0?(this.setState({gotoRowError:""}),(o=this.grid)==null||o.setFocusRow(s+n)):((r=this.grid)==null||r.setFocusRow(s-1),this.setState({gotoRowError:""}))}handleGotoRowSelectedRowNumberChanged(t){const e=t.target.value;this.focusRowInGrid(e)}getColumnTooltip(t,e,n){const{columnHeaderHeight:s,columnHeaderMaxDepth:i,visibleColumnXs:o,visibleColumnWidths:r,width:l}=e,a=o.get(t),d=r.get(t);if(a==null||d==null)return null;const c=Math.max(0,a);let u=d;a+d>l?u=l-a:a<0&&(u=d-Math.abs(a));const m={position:"absolute",top:(i-1)*s,left:c,width:u,height:s,pointerEvents:"none"},p={clientWidth:1,clientHeight:s,getBoundingClientRect:this.getColumnBoundingRect},g={placement:"bottom",modifiers:{flip:{behavior:["bottom","top"]}}},f=this.getModelColumn(t);if(f==null)return null;const b=n.columns[f];return b==null?null:h("div",{style:m,children:h($e,{timeout:400,interactive:!0,options:g,ref:this.handleTooltipRef,referenceObject:p,onExited:()=>{this.setState({shownColumnTooltip:null})},children:h(up,{model:n,column:b,onStatistics:()=>{var C;(C=this.tooltip)==null||C.update()}})},b.name)})}render(){var mt,Ci,mc,pc,gc,fc,Cc,bc,Sc;const{children:t,customFilters:e,getDownloadWorker:n,isSelectingColumn:s,isStuckToBottom:i,isStuckToRight:o,model:r,name:l,onlyFetchVisibleColumns:a,alwaysFetchColumns:d,advancedSettings:c,onAdvancedSettingsChange:u,canDownloadCsv:m,onCreateChart:p}=this.props,{metricCalculator:g,metrics:f,isFilterBarShown:b,isSelectingPartition:C,isMenuShown:w,isReady:T,copyOperation:y,focusedFilterBarColumn:E,loadingText:I,loadingScrimProgress:D,loadingSpinnerShown:F,keyHandlers:x,mouseHandlers:U,shownColumnTooltip:B,hoverAdvancedFilter:_,shownAdvancedFilter:H,hoverSelectColumn:A,quickFilters:N,advancedFilters:k,partition:O,partitionFilters:V,partitionTable:G,partitionColumn:Q,searchFilter:Z,selectDistinctColumns:be,movedColumns:le,movedRows:he,formatter:Re,conditionalFormats:ee,conditionalFormatPreview:ue,conditionalFormatEditIndex:Se,sorts:De,reverseType:qe,customColumns:ke,selectedRanges:Qn,isTableDownloading:vn,tableDownloadStatus:St,tableDownloadProgress:Ie,tableDownloadEstimatedTime:ot,showSearchBar:rt,searchValue:xt,selectedSearchColumns:Qt,invertSearchColumns:Zt,aggregationSettings:_t,selectedAggregation:Ln,rollupConfig:$t,openOptions:Tn,pendingSavePromise:Us,pendingSaveError:Kl,pendingRowCount:ql,pendingDataErrors:Yl,pendingDataMap:er,toastMessage:tr,frozenColumns:nr,showOverflowModal:sr,overflowText:ir,overflowButtonTooltipProps:or,isGotoRowShown:rr,gotoRow:Xl,gotoRowError:jl}=this.state;if(!T)return null;const Bs=this.getTheme(),Ql=this.getCachedFilter(e,N,k,V,Z),$s=g.getUserColumnWidths(),lo=this.getCachedStateOverride(A,b,s,D,N,k,De,qe,$t,w),lr=f?f.top:0,ar=f?f.bottomViewport:0;let ao=null,co=null;a&&(ao=f?f.left:0,co=f?f.right:0);const Zl=f!=null&&f.width>0&&f.height>0,Jl=((Ci=(mt=$t==null?void 0:$t.columns)==null?void 0:mt.length)!=null?Ci:0)>0;let dr=null;const ea=f?Math.min(Math.max(Os.minDebounce,Math.round(f.rowCount/200)),Os.maxDebounce):Os.maxDebounce;if(b&&E!=null&&f!=null){const{gridX:Qe,gridY:Jt,visibleColumnXs:Ss,visibleColumnWidths:ho,width:bi}=f,An=Ss.get(E),Wt=ho.get(E);if(An!=null&&Wt!=null){const kt=Qe+An,Zn=Jt-((mc=Bs.filterBarHeight)!=null?mc:0),Ws=Wt+1,zs=((pc=Bs.filterBarHeight)!=null?pc:0)-1,gr={top:Zn,left:kt,minWidth:Math.min(Ws,bi-kt),height:zs};let Pn="",Si=!0;const Gs=this.getModelColumn(E);P(Gs);const wi=N.get(Gs),ws=k.get(Gs);wi!=null&&(Pn=wi.text,Si=wi.filter!=null);const vi=N.size!==0||k.size!==0;dr=h(lp,{ref:this.filterInputRef,style:gr,className:W({error:!Si,active:Pn!==""||ws!=null,"iris-grid-has-filter":vi}),isAdvancedFilterSet:ws!=null,onAdvancedFiltersTriggered:()=>{this.setState({shownAdvancedFilter:E})},onChange:this.handleFilterBarChange,onDone:this.handleFilterBarDone,onTab:this.handleFilterBarTab,onContextMenu:(gc=this.grid)==null?void 0:gc.handleContextMenu,debounceMs:ea,value:Pn},E)}}let cr=null;if(I!=null){const Qe=v("div",{className:"iris-grid-loading-status",children:[h("div",{className:W("iris-grid-loading-status-bar",{show:F}),children:I}),v("button",{type:"button",onClick:this.handleCancel,className:W("iris-grid-btn-cancel",{show:F}),children:[h(j,{icon:Xi,transform:"down-1"}),"Cancel"]})]}),Jt=f?f.gridY:0;cr=h("div",{className:"iris-grid-loading",style:{top:Jt},children:Qe})}let hr=null;B!=null&&f&&(hr=this.getColumnTooltip(B,f,r),(fc=this.tooltip)==null||fc.update());const ur=[];if(f&&b){const{gridX:Qe,gridY:Jt,visibleColumns:Ss,visibleColumnXs:ho,visibleColumnWidths:bi}=f,{filterBarHeight:An}=Bs;for(let Wt=0;Wt<Ss.length;Wt+=1){const kt=Ss[Wt],Zn=ho.get(kt),Ws=bi.get(kt),zs=this.getModelColumn(kt);if(zs!=null&&r.isFilterable(zs)&&Zn!=null&&Ws!=null&&Ws>0){const Pn=Qe+Zn+Ws-24,Si=Jt-(An!=null?An:0)+2,Gs={position:"absolute",top:Si,left:Pn},ws=k.get(zs)!=null,vi=kt===_||kt===E||ws,sa=h("div",{className:W("advanced-filter-button-container",{hidden:!vi}),style:Gs,children:vi&&h(z,{kind:"ghost",className:W("btn-link-icon advanced-filter-button",{"filter-set":ws}),onClick:()=>{this.setState({shownAdvancedFilter:kt})},onContextMenu:ig=>{var wc;(wc=this.grid)==null||wc.handleContextMenu(ig)},onMouseEnter:()=>{this.setState({hoverAdvancedFilter:kt})},onMouseLeave:()=>{this.setState({hoverAdvancedFilter:null})},children:v("div",{className:"fa-layers",children:[h(j,{icon:dd,className:"filter-solid"}),h(j,{icon:Kr,className:"filter-light"})]})})},kt);ur.push(sa)}}}const mr=[];if(f){const{gridX:Qe,visibleColumns:Jt,visibleColumnXs:Ss,visibleColumnWidths:ho,columnHeaderHeight:bi}=f;for(let An=0;An<Jt.length;An+=1){const Wt=Jt[An],kt=Ss.get(Wt),Zn=ho.get(Wt);if(kt!=null&&Zn!=null&&Zn>0){const Ws=Qe+kt,zs=Qe+kt+Zn-20,gr=b?{position:"absolute",top:bi,left:zs,width:20,height:Bs.filterBarHeight}:{position:"absolute",top:0,left:Ws,width:Zn,height:bi},Pn=this.getModelColumn(Wt);if(Pn!=null){const Si=r.columns[Pn],Gs=k.get(Pn),{options:wi}=Gs||{},ws=L.getSortForColumn(r.sort,Pn),vi=ws?ws.direction:null,sa=h("div",{className:"advanced-filter-menu-container",style:gr,children:h(kn,{className:"advanced-filter-menu-popper",onEntered:this.getAdvancedMenuOpenedHandler(Wt),onExited:()=>{this.handleAdvancedMenuClosed(Wt)},isShown:H===Wt,interactive:!0,closeOnBlur:!0,options:{positionFixed:!0},children:this.getCachedAdvancedFilterMenuActions(r,Si,wi,vi,Re)})},Wt);mr.push(sa)}}}}const pr=this.getCachedOptionItems(p!==void 0&&r.isChartBuilderAvailable,r.isCustomColumnsAvailable,r.isFormatColumnsAvailable,r.isRollupAvailable,r.isTotalsAvailable,r.isSelectDistinctAvailable,r.isExportAvailable,this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,b,rt,m,this.isTableSearchAvailable(),rr,c.size>0),ta=Tn.map(Qe=>{switch(Qe.type){case _e.CHART_BUILDER:return h(gp,{model:r,onChange:this.handleChartChange,onSubmit:this.handleChartCreate},_e.CHART_BUILDER);case _e.VISIBILITY_ORDERING_BUILDER:return h(pi,{model:r,movedColumns:le,userColumnWidths:$s,onColumnVisibilityChanged:this.handleColumnVisibilityChanged,onMovedColumnsChanged:this.handleMovedColumnsChanged},_e.VISIBILITY_ORDERING_BUILDER);case _e.CONDITIONAL_FORMATTING:return h(bT,{rules:ee,onChange:this.handleConditionalFormatsChange,onCreate:this.handleConditionalFormatCreate,onSelect:this.handleConditionalFormatEdit});case _e.CONDITIONAL_FORMATTING_EDIT:return P(r.columns),P(this.handleConditionalFormatEditorUpdate),h(GT,{columns:r.columns,rule:ue,onUpdate:this.handleConditionalFormatEditorUpdate,onSave:this.handleConditionalFormatEditorSave,onCancel:this.handleConditionalFormatEditorCancel});case _e.CUSTOM_COLUMN_BUILDER:return h(Wd,{model:r,customColumns:ke,onSave:this.handleUpdateCustomColumns,onCancel:this.handleMenuBack},_e.CUSTOM_COLUMN_BUILDER);case _e.ROLLUP_ROWS:return h(zd,{model:r,onChange:this.handleRollupChange,config:$t},_e.ROLLUP_ROWS);case _e.AGGREGATIONS:return h(jv,{settings:_t,isRollup:Jl,onChange:this.handleAggregationsChange,onEdit:this.handleAggregationEdit});case _e.AGGREGATION_EDIT:return Ln&&h(Zv,{aggregation:Ln,columns:r.originalColumns,onChange:this.handleAggregationChange});case _e.TABLE_EXPORTER:return h(ln,{model:r,name:l,userColumnWidths:$s,movedColumns:le,isDownloading:vn,tableDownloadStatus:St,tableDownloadProgress:Ie,tableDownloadEstimatedTime:ot!=null?ot:void 0,onDownload:this.handleDownloadTable,onDownloadStart:this.handleDownloadTableStart,onCancel:this.handleCancelDownloadTable,selectedRanges:Qn},_e.TABLE_EXPORTER);case _e.SELECT_DISTINCT:return h(Sp,{model:r,selectDistinctColumns:be,onChange:this.handleSelectDistinctChanged});case _e.ADVANCED_SETTINGS:return h(Gd,{items:c,onChange:u});default:throw Error(`Unexpected option type ${Qe.type}`)}}),na=this.getCachedHiddenColumns(te.getHiddenColumns($s));return v("div",{className:"iris-grid",role:"presentation",children:[v("div",{className:"iris-grid-column",children:[t!=null&&h("div",{className:"iris-grid-bar",children:t}),h(ut,{in:C,timeout:yt.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"iris-grid-partition-selector-wrapper iris-grid-bar iris-grid-bar-primary",children:G&&Q&&O!=null&&h(bp,{table:G,getFormattedString:(Qe,Jt,Ss)=>r.displayString(Qe,Jt,Ss),columnName:Q.name,partition:O,onChange:this.handlePartitionChange,onFetchAll:this.handlePartitionFetchAll,onAppend:this.handlePartitionAppend,onDone:this.handlePartitionDone})})}),h(ut,{in:rt,timeout:yt.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"iris-grid-bar",children:h(Dr,{value:xt,selectedColumns:Qt,invertSelection:Zt,onChange:this.handleCrossColumnSearch,columns:r.columns,ref:this.crossColumnRef})})}),v("div",{className:"grid-wrapper",ref:Qe=>{this.gridWrapper=Qe},children:[h(to,{ref:Qe=>{this.grid=Qe},isStickyBottom:!Je(r)||!r.isEditable,isStuckToBottom:i,isStuckToRight:o,metricCalculator:g,model:r,keyHandlers:x,mouseHandlers:U,movedColumns:le,movedRows:he,onError:this.handleGridError,onViewChanged:this.handleViewChanged,onSelectionChanged:this.handleSelectionChanged,onMovedColumnsChanged:this.handleMovedColumnsChanged,renderer:this.renderer,stateOverride:lo,theme:Bs}),h(KT,{isOpen:sr,text:ir,onClose:this.handleOverflowClose}),Zl&&h(cp,{model:r,modelColumns:r.columns,top:lr,bottom:ar,left:ao,right:co,filter:Ql,formatter:Re,sorts:De,reverseType:qe,movedColumns:le,customColumns:ke,hiddenColumns:na,alwaysFetchColumns:this.getAlwaysFetchColumns(d,r.columns,le,r.floatingLeftColumnCount,r.floatingRightColumnCount,(bc=(Cc=this.grid)==null?void 0:Cc.state.draggingColumn)==null?void 0:bc.range),formatColumns:this.getCachedPreviewFormatColumns(this.getCachedModelColumns(r,ke),ee,ue,((Sc=Tn[Tn.length-1])==null?void 0:Sc.type)===_e.CONDITIONAL_FORMATTING_EDIT&&Se!=null?Se:void 0),rollupConfig:this.getModelRollupConfig(r.originalColumns,$t,_t),totalsConfig:this.getModelTotalsConfig(r.columns,$t,_t),selectDistinctColumns:be,pendingRowCount:ql,pendingDataMap:er,frozenColumns:nr}),!w&&h("div",{className:"grid-settings-button",children:h(z,{kind:"ghost","data-testid":`btn-iris-grid-settings-button-${l}`,onClick:this.handleMenu,icon:h(j,{icon:Af,transform:"up-1"}),tooltip:"Table Options"})}),dr,cr,ur,hr,mr,or&&this.getOverflowButtonTooltip(or)]}),h(YT,{model:r,isShown:rr,gotoRow:Xl,gotoRowError:jl,onSubmit:this.handleGotoRowSelectedRowNumberSubmit,onGotoRowNumberChanged:this.handleGotoRowSelectedRowNumberChanged,onClose:this.handleGotoRowClosed,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:()=>{this.handleAnimationStart(),this.focus()},onExited:this.handleAnimationEnd}),h(Ev,{error:Kl,isSaving:Us!=null,saveTooltip:`Commit (${this.commitAction.shortcut.getDisplayText()})`,discardTooltip:`Discard (${this.discardAction.shortcut.getDisplayText()})`,pendingDataErrors:Yl,pendingDataMap:er,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,onSave:this.handlePendingCommitClicked,onDiscard:this.handlePendingDiscardClicked}),h($v,{children:tr}),h(no,{model:r,copyOperation:y!=null?y:void 0,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd}),h(so,{ref:Qe=>{this.tableSaver=Qe},getDownloadWorker:n,onDownloadCompleted:this.handleDownloadCompleted,onDownloadCanceled:this.handleDownloadCanceled,onDownloadProgressUpdate:this.handleDownloadProgressUpdate,isDownloading:St===ln.DOWNLOAD_STATUS.DOWNLOADING,formatter:Re})]}),h(ut,{in:w,timeout:yt.transitionMidMs,classNames:"slide-left",onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"table-sidebar",children:v($C,{children:[h(Wc,{title:"Table Options",onClose:this.handleMenuClose,children:h(Bu,{onSelect:Qe=>this.handleMenuSelect(pr[Qe]),items:pr})}),ta.map((Qe,Jt)=>h(Wc,{title:Tn[Jt].title,onBack:this.handleMenuBack,onClose:this.handleMenuClose,children:Qe},Tn[Jt].type))]})})}),h(oe,{actions:this.contextActions})]})}};let io=Os;io.minDebounce=150;io.maxDebounce=500;io.loadingSpinnerDelay=800;io.defaultProps={children:null,advancedFilters:new Map,advancedSettings:new Map,alwaysFetchColumns:[],conditionalFormats:[],customColumnFormatMap:new Map,isFilterBarShown:!1,applyInputFiltersOnInit:!1,movedColumns:[],movedRows:[],inputFilters:[],customFilters:[],onCreateChart:void 0,onColumnSelected:()=>{},onDataSelected:()=>{},onError:()=>{},onStateChange:()=>{},onPartitionAppend:()=>{},onAdvancedSettingsChange:()=>{},partition:null,partitionColumn:null,quickFilters:new Map,selectDistinctColumns:[],sorts:[],reverseType:L.REVERSE_TYPE.NONE,customColumns:[],aggregationSettings:Tp,rollupConfig:void 0,userColumnWidths:new Map,userRowHeights:new Map,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:new Map,getDownloadWorker:void 0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:ps.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,truncateNumbersWithPound:!1,formatter:[],decimalFormatOptions:R.exports.shape({defaultFormatString:R.exports.string}),integerFormatOptions:R.exports.shape({defaultFormatString:R.exports.string})},canCopy:!0,canDownloadCsv:!0,frozenColumns:null,theme:hp,canToggleSearch:!0};class JT extends Error{constructor(e,n){super(`${n} can't be empty (on pending row ${e+1})`),this.isMissingKey=!0,this.rowIndex=e,this.columnName=n}}const eE=X.module("ColumnHeaderGroup");function _h(t){return t instanceof Ep}class Ep{constructor({name:e,children:n,color:s,depth:i,childIndexes:o}){this.getVisibleRange=pe(r=>{const l=this.childIndexes.flat(),a=K.getVisibleIndexes(l,r),d=Math.min(...a),c=Math.max(...a);return c-d!==l.length-1&&eE.warn(`Column header group ${this.name} is not contiguous`),[d,c]}),this.name=e,this.children=n,this.color=s,this.depth=i,this.childIndexes=o}}const tt=X.module("IrisGridTableModel"),tE=150,nE=0;function li(t){return t.table!==void 0}const za=class extends Ce{constructor(t,e=new un,n=null){super(),this.pendingNewRowCount=0,this.columnHeaderGroupMap=new Map,this.columnHeaderParentMap=new Map,this._columnHeaderMaxDepth=null,this._columnHeaderGroups=[],this.getMemoizedColumnMap=pe(s=>{const i=new Map;return s.forEach(o=>i.set(o.name,o)),i}),this.getColumnIndicesByNameMap=pe(s=>{const i=new Map;return s.forEach(({name:o},r)=>i.set(o,r)),i}),this.setViewport=us((s,i,o)=>{if(i<s){tt.error("Invalid viewport",s,i);return}const{viewport:r}=this;if(r!=null&&r.top===s&&r.bottom===i&&r.columns===o){tt.debug2("Ignoring duplicate viewport",r);return}this.viewport={top:s,bottom:i,columns:o},tt.debug2("setViewport",this.viewport),this.applyViewport()},tE),this.applyViewport=us(()=>{if(!this.viewport)return;tt.debug2("applyViewport",this.viewport);const{top:s,bottom:i,columns:o}=this.viewport,[r,l]=this.getCachedViewportRowRange(s,i);this.applyBufferedViewport(r,l,o)},nE,{leading:!1}),this.getCachedFormattedString=an((s,i,o,r,l)=>s.getFormattedString(i,o,r,l),{max:1e4}),this.getCachedCustomColumnFormatFlag=an(hs.isCustomColumnFormatDefined,{max:1e4}),this.getCachedViewportRowRange=pe((s,i)=>{const o=i-s,r=Math.max(0,s-o*za.ROW_BUFFER_PAGES),l=i+o*za.ROW_BUFFER_PAGES;return[r,l]}),this.getCachedPendingErrors=pe((s,i,o)=>{const r=new Map;return s.forEach((l,a)=>{var c;const{data:d}=l;for(let u=0;u<o;u+=1)d.has(u)||(r.has(a)||r.set(a,[]),(c=r.get(a))==null||c.push(new JT(a,i[u].name)))}),r}),this.handleTableDisconnect=this.handleTableDisconnect.bind(this),this.handleTableReconnect=this.handleTableReconnect.bind(this),this.handleTableUpdate=this.handleTableUpdate.bind(this),this.handleTotalsUpdate=this.handleTotalsUpdate.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.handleCustomColumnsChanged=this.handleCustomColumnsChanged.bind(this),this.irisFormatter=e,this.inputTable=n,this.subscription=null,this.table=t,this.viewport=null,this.viewportData=null,this.formattedStringData=[],this.pendingStringData=[],this.isSaveInProgress=!1,this.totalsTable=null,this.totalsTablePromise=null,this.totals=null,this.totalsDataMap=null,this.pendingNewDataMap=new Map,this.pendingNewDataErrors=null,this.pendingNewRowCount=0}export(){throw new Error("Method not implemented.")}columnStatistics(t){throw new Error("Method not implemented.")}get customColumns(){return[]}set customColumns(t){throw new Error("Method not implemented.")}get formatColumns(){return[]}set formatColumns(t){throw new Error("Method not implemented.")}updateFrozenColumns(t){throw new Error("Method not implemented.")}get rollupConfig(){throw new Error("Method not implemented.")}set rollupConfig(t){throw new Error("Method not implemented.")}get selectDistinctColumns(){throw new Error("Method not implemented.")}set selectDistinctColumns(t){throw new Error("Method not implemented.")}get columns(){return this.table.columns}close(){this.table.close(),this.totalsTable!==null&&this.totalsTable.close(),this.totalsTablePromise!==null&&this.totalsTablePromise.cancel()}startListening(){super.startListening(),this.table.addEventListener(M.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.addEventListener(M.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.addEventListener(M.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.addEventListener(M.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.addEventListener(M.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable),this.applyViewport()}stopListening(){super.stopListening(),this.table.removeEventListener(M.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.removeEventListener(M.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.removeEventListener(M.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.removeEventListener(M.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.removeEventListener(M.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.removeTotalsListeners(this.totalsTable),this.closeSubscription()}addTotalsListeners(t){t.addEventListener(M.Table.EVENT_UPDATED,this.handleTotalsUpdate),t.setViewport(0,0)}removeTotalsListeners(t){t.removeEventListener(M.Table.EVENT_UPDATED,this.handleTotalsUpdate)}handleTableDisconnect(){this.dispatchEvent(new Ge(Ce.EVENT.DISCONNECT))}handleTableReconnect(){this.dispatchEvent(new Ge(Ce.EVENT.RECONNECT))}handleTableUpdate(t){this.copyViewportData(t.detail),this.dispatchEvent(new Ge(Ce.EVENT.UPDATED))}handleTotalsUpdate(t){this.copyTotalsData(t.detail),this.dispatchEvent(new Ge(Ce.EVENT.UPDATED))}handleRequestFailed(t){this.dispatchEvent(new Ge(Ce.EVENT.REQUEST_FAILED,t))}handleCustomColumnsChanged(){this.dispatchEvent(new Ge(Ce.EVENT.COLUMNS_CHANGED,{detail:this.columns}))}get rowCount(){var t,e,n;return this.table.size+this.pendingNewRowCount+((n=(e=(t=this.totals)==null?void 0:t.operationOrder)==null?void 0:e.length)!=null?n:0)}get pendingDataErrors(){var t,e;return this.getCachedPendingErrors(this.pendingNewDataMap,this.columns,(e=(t=this.inputTable)==null?void 0:t.keyColumns.length)!=null?e:0)}get pendingDataMap(){return this.pendingNewDataMap}set pendingDataMap(t){t!==this.pendingNewDataMap&&(t.forEach((e,n)=>{if(!te.isValidIndex(n))throw new Error(`Invalid rowIndex ${n}`);const{data:s}=e;s.forEach((i,o)=>{if(!te.isValidIndex(o))throw new Error(`Invalid columnIndex ${o}`)})}),this.pendingNewDataMap=t,this.pendingNewRowCount=Math.max(this.pendingNewRowCount,this.maxPendingDataRow),this.formattedStringData=[],this.dispatchEvent(new Ge(Ce.EVENT.PENDING_DATA_UPDATED)))}get pendingRowCount(){return this.pendingNewRowCount}set pendingRowCount(t){t!==this.pendingNewRowCount&&(this.pendingNewRowCount=Math.max(0,t,this.maxPendingDataRow),this.dispatchEvent(new Ge(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(){var t,e,n;return this.totals!=null&&this.totals.showOnTop?0:(n=(e=(t=this.totals)==null?void 0:t.operationOrder)==null?void 0:e.length)!=null?n:0}get floatingTopRowCount(){var t,e,n;return this.totals!=null&&this.totals.showOnTop&&(n=(e=(t=this.totals)==null?void 0:t.operationOrder)==null?void 0:e.length)!=null?n:0}get isChartBuilderAvailable(){return!0}get isTotalsAvailable(){return this.table.getTotalsTable!=null}get isEditable(){return!this.isSaveInProgress&&this.inputTable!=null}cacheFormattedValue(t,e,n){this.formattedStringData[t]==null&&(this.formattedStringData[t]=[]),this.formattedStringData[t][e]=n}cachePendingValue(t,e,n){this.pendingStringData[t]==null&&(this.pendingStringData[t]=[]),this.pendingStringData[t][e]=n}clearPendingValue(t,e){const n=this.pendingStringData[t];n!=null&&delete n[e]}textValueForCell(t,e){var n,s,i;if(((n=this.pendingStringData[t])==null?void 0:n[e])!==void 0)return this.pendingStringData[t][e];if(((s=this.formattedStringData[t])==null?void 0:s[e])===void 0){const o=this.valueForCell(t,e);if(o==null)return null;const r=(i=this.totalsColumn(t,e))!=null?i:this.columns[t],l=this.getCachedCustomColumnFormatFlag(this.formatter,r.name,r.type);let a;if(!l){const c=this.formatForCell(t,e);(c==null?void 0:c.formatString)!=null&&(a=c)}const d=this.displayString(o,r.type,r.name,a);this.cacheFormattedValue(t,e,d)}return this.formattedStringData[t][e]}textForCell(t,e){const n=this.textValueForCell(t,e);if(n==null&&this.isKeyColumn(t)){const s=this.pendingRow(e);if(s!=null&&this.pendingDataMap.has(s))return"*"}return n!=null?n:""}truncationCharForCell(t){const e=this.columns[t],{type:n}=e;if(L.isNumberType(n)&&this.formatter.truncateNumbersWithPound)return"#"}colorForCell(t,e,n){var i;const s=this.dataForCell(t,e);if(s){const{format:o,value:r}=s;if(r==null||r==="")return P(n.nullStringColor),n.nullStringColor;if(o&&o.color)return o.color;if(this.isPendingRow(e))return P(n.pendingTextColor),n.pendingTextColor;if(r!=null){const l=(i=this.totalsColumn(t,e))!=null?i:this.columns[t];if(L.isDateType(l.type)||l.name==="Date")return P(n.dateColor),n.dateColor;if(L.isNumberType(l.type))return r>0?(P(n.positiveNumberColor),n.positiveNumberColor):r<0?(P(n.negativeNumberColor),n.negativeNumberColor):(P(n.zeroNumberColor),n.zeroNumberColor)}}else if(this.isPendingRow(e)&&this.isKeyColumn(t))return P(n.errorTextColor),n.errorTextColor;return n.textColor}backgroundColorForCell(t,e){var n,s;return(s=(n=this.formatForCell(t,e))==null?void 0:n.backgroundColor)!=null?s:null}textAlignForCell(t){const e=this.columns[t],{type:n}=e;return L.isNumberType(n)?"right":L.isDateType(n)||e.name==="Date"?"center":"left"}textForColumnHeader(t,e=0){var n,s;return(s=(n=this.columnAtDepth(t,e))==null?void 0:n.name)!=null?s:void 0}colorForColumnHeader(t,e=0){var s;const n=this.columnAtDepth(t,e);return _h(n)&&(s=n.color)!=null?s:null}getColumnHeaderGroup(t,e){const n=this.columnAtDepth(t,e);if(_h(n))return n}getColumnHeaderParentGroup(t,e){var n,s;return this.columnHeaderParentMap.get((s=(n=this.columnAtDepth(t,e))==null?void 0:n.name)!=null?s:"")}columnAtDepth(t,e=0){var o;if(e===0)return this.columns[t];const n=(o=this.columns[t])==null?void 0:o.name;let s=this.columnHeaderParentMap.get(n);if(!s)return;let i=s.depth;for(;i<e;){if(s=this.columnHeaderParentMap.get(s.name),!s)return;i=s.depth}if(s.depth===e)return s}textForRowFooter(t){const e=this.totalsRow(t);return e!=null&&this.totals?this.totals.operationOrder[e]:""}get movedColumns(){var i;let t=[];const e=(o,r)=>{const l=this.getColumnIndexByName(o);if(l==null)throw new Error(`Unknown layout hint column: ${o}`);const a=K.getVisibleIndex(l,t);t=K.moveItem(a,r,t)},n=(o,r)=>{const l=this.columnHeaderGroupMap.get(o);if(!l)throw new Error(`Unknown layout hint group: ${o}`);const a=l.getVisibleRange(t);t=K.moveRange(a,r,t)};if(this.frontColumns.length||this.backColumns.length||this.frozenColumns.length){const o=new Set;let r=0;this.frozenColumns.forEach(a=>{if(o.has(a))throw new Error(`Column specified in multiple layout hints: ${a}`);e(a,r),r+=1}),this.frontColumns.forEach(a=>{if(o.has(a))throw new Error(`Column specified in multiple layout hints: ${a}`);e(a,r),r+=1});let l=this.columnMap.size-1;this.backColumns.forEach(a=>{if(o.has(a))throw new Error(`Column specified in multiple layout hints: ${a}`);e(a,l),l-=1})}const s=(i=this.layoutHints)==null?void 0:i.columnGroups;if(s){this.setColumnHeaderGroups(s);const o=[...this.columnHeaderGroupMap.values()];o.sort((r,l)=>r.depth-l.depth),o.forEach(r=>{const l=r.children[0],a=this.getColumnIndexByName(l);let d;if(a!=null)d=K.getVisibleIndex(a,t);else{const c=this.columnHeaderGroupMap.get(l);if(!c)throw new Error(`Unknown column ${l} in group ${r.name}`);[,d]=c.getVisibleRange(t)}for(let c=1;c<r.children.length;c+=1){const u=r.children[c],m=this.columnHeaderGroupMap.get(u),p=this.getColumnIndexByName(u);if(m){const f=m.getVisibleRange(t)[0]<d?d-m.childIndexes.length+1:d+1;n(u,f),d=f+m.childIndexes.length-1}else if(p!=null){const f=K.getVisibleIndex(p,t)<d?d:d+1;e(u,f),d=f}}})}return t}get columnMap(){return this.getMemoizedColumnMap(this.table.columns)}get columnHeaderMaxDepth(){var t,e;return this._columnHeaderMaxDepth==null&&this.setColumnHeaderGroups((t=this.layoutHints)==null?void 0:t.columnGroups),(e=this._columnHeaderMaxDepth)!=null?e:1}set columnHeaderMaxDepth(t){this._columnHeaderMaxDepth=t}setColumnHeaderGroups(t){if(t===this._columnHeaderGroups||(this._columnHeaderGroups=t!=null?t:[],this.columnHeaderMaxDepth=1,this.columnHeaderParentMap=new Map,this.columnHeaderGroupMap=new Map,!t||t.length===0))return;const e=new Map(t.map(o=>[o.name,o])),n=new Set,s=o=>{const{name:r}=o;if(this.getColumnIndexByName(r)!=null)throw new Error(`Column header group has same name as column: ${r}`);const l=this.columnHeaderGroupMap.get(r);if(l)return l;const a=[];let d=1;o.children.forEach(u=>{if(n.has(u))throw new Error(`Column group child ${u} specified in multiple groups`);n.add(u);const m=e.get(u),p=this.getColumnIndexByName(u);if(m){const g=s(m);a.push(g.childIndexes.flat()),d=Math.max(d,g.depth+1)}else if(p!=null)a.push(p),d=Math.max(d,1);else throw new Error(`Unknown child ${u} in group ${r}`)});const c=new Ep({...o,depth:d,childIndexes:a});return this.columnHeaderGroupMap.set(r,c),o.children.forEach(u=>this.columnHeaderParentMap.set(u,c)),this.columnHeaderMaxDepth=Math.max(this.columnHeaderMaxDepth,c.depth+1),c},i=new Set;t.forEach(o=>{const{name:r}=o;if(i.has(r))throw new Error(`Duplicate column group name: ${r}`);i.add(r),s(o)})}get groupedColumns(){return[]}row(t){var l,a,d,c,u,m,p,g,f,b,C,w,T,y;const e=(d=(a=(l=this.totals)==null?void 0:l.operationOrder)==null?void 0:a.length)!=null?d:0,n=(u=(c=this.totals)==null?void 0:c.showOnTop)!=null?u:!1,s=this.totalsRow(t);if(s!=null){const E=(m=this.totals)==null?void 0:m.operationOrder[s];return P(E),(g=(p=this.totalsDataMap)==null?void 0:p.get(E))!=null?g:null}const i=this.pendingRow(t);if(i!=null)return(f=this.pendingNewDataMap.get(i))!=null?f:null;const o=(C=(b=this.viewportData)==null?void 0:b.offset)!=null?C:0,r=(n?t-e:t)-o;return(y=(T=(w=this.viewportData)==null?void 0:w.rows)==null?void 0:T[r])!=null?y:null}totalsColumn(t,e){var r,l,a,d;const n=this.totalsRow(e);if(n==null)return null;const s=(r=this.totals)==null?void 0:r.operationOrder[n],i=(a=(l=this.totals)==null?void 0:l.defaultOperation)!=null?a:Oe.SUM,o=this.columns[t];return(d=this.totalsTable)==null?void 0:d.columns.find(c=>{var u;return c.name===`${o.name}__${s}`||(s===i||((u=this.totals)==null?void 0:u.operationOrder.length)===1)&&c.name===o.name})}totalsRow(t){var i,o,r,l,a;const e=(r=(o=(i=this.totals)==null?void 0:i.operationOrder)==null?void 0:o.length)!=null?r:0,s=((a=(l=this.totals)==null?void 0:l.showOnTop)!=null?a:!1)?t:t-this.table.size;return s>=0&&s<e?s:null}pendingRow(t){const e=t-this.floatingTopRowCount-this.table.size;return e>=0&&e<this.pendingNewRowCount?e:null}isTotalsRow(t){return this.totalsRow(t)!=null}isPendingRow(t){return this.pendingRow(t)!=null}dataForCell(t,e){var n;return(n=this.row(e))==null?void 0:n.data.get(t)}formatForCell(t,e){var n;return(n=this.dataForCell(t,e))==null?void 0:n.format}valueForCell(t,e){var s;const n=this.dataForCell(t,e);if(n)return(s=n.value)!=null?s:null}copyViewportData(t){if(t==null){tt.warn("invalid data!");return}this.viewportData=this.extractViewportData(t),this.formattedStringData=[]}copyTotalsData(t){var l,a,d,c,u;if(t==null){tt.warn("invalid data!");return}const{columns:e,rows:n}=t;if(n.length!==1){tt.error("Unexpected number of rows received for totals table, ignoring update");return}const s=new Map,i=n[0],o=(a=(l=this.totals)==null?void 0:l.defaultOperation)!=null?a:Oe.SUM,r=(d=this.totals)==null?void 0:d.operationMap;for(let m=0;m<e.length;m+=1){const p=e[m],[g,f=(u=(c=r==null?void 0:r[g])==null?void 0:c[0])!=null?u:o]=p.name.split("__");s.has(f)||s.set(f,{data:new Map});const{data:b}=s.get(f),C=this.columns.findIndex(w=>w.name===g);b.set(C,{value:i.get(p),format:i.getFormat(p)})}tt.debug2("copyTotalsData",s),this.totalsDataMap=s,this.formattedStringData=[]}getColumnIndexByName(t){return this.getColumnIndicesByNameMap(this.columns).get(t)}extractViewportData(t){const e={offset:t.offset,rows:[]},{columns:n}=t;for(let s=0;s<t.rows.length;s+=1){const i=t.rows[s],o=this.extractViewportRow(i,n);e.rows.push(o)}return e}extractViewportRow(t,e){const n=new Map;for(let s=0;s<e.length;s+=1){const i=e[s],o=this.getColumnIndexByName(i.name);P(o),n.set(o,{value:t.get(i),format:t.getFormat(i)})}return{data:n}}closeSubscription(){tt.debug2("closeSubscription",this.subscription),this.subscription&&(this.subscription.close(),this.subscription=null),this.setViewport.cancel(),this.applyViewport.cancel()}get filter(){return this.table.filter}set filter(t){this.closeSubscription(),this.table.applyFilter(t),this.applyViewport()}get formatter(){return this.irisFormatter}set formatter(t){this.irisFormatter=t,this.formattedStringData=[],this.dispatchEvent(new Ge(Ce.EVENT.FORMATTER_UPDATED))}displayString(t,e,n="",s){return this.getCachedFormattedString(this.formatter,t,e,n,s)}get sort(){return this.table.sort}set sort(t){this.closeSubscription(),this.table.applySort(t),this.applyViewport()}set totalsConfig(t){if(tt.debug("set totalsConfig",t),t!==this.totals){if(this.totals=t,this.formattedStringData=[],this.totalsTablePromise!=null&&this.totalsTablePromise.cancel(),this.setTotalsTable(null),t==null){this.dispatchEvent(new Ge(Ce.EVENT.UPDATED));return}this.totalsTablePromise=Te.makeCancelable(this.table.getTotalsTable(t),e=>e.close()),this.totalsTablePromise.then(e=>{this.totalsTablePromise=null,this.setTotalsTable(e)}).catch(e=>{Te.isCanceled(e)||(tt.error("Unable to set next totalsTable",e),this.totalsTablePromise=null,this.dispatchEvent(new Ge(Ce.EVENT.REQUEST_FAILED,{detail:e})))})}}setTotalsTable(t){tt.debug("setTotalsTable",t),this.totalsTable!==null&&(this.listenerCount>0&&this.removeTotalsListeners(this.totalsTable),this.totalsTable.close()),this.totalsTable=t,this.totalsDataMap=null,this.listenerCount>0&&this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable)}applyBufferedViewport(t,e,n){tt.debug2("applyBufferedViewport",t,e,n),this.subscription==null?(tt.debug2("applyBufferedViewport creating new subscription"),this.subscription=this.table.setViewport(t,e,n)):(tt.debug2("applyBufferedViewport using existing subscription"),this.subscription.setViewport(t,e,n))}async snapshot(t,e=!1,n=i=>i,s=!0){if(this.subscription==null)throw new Error("No subscription available");const i=s?re.consolidate(t):t;if(!te.isValidSnapshotRanges(i))throw new Error(`Invalid snapshot ranges ${t}`);const o=new Set,r=[],l=new Set;for(let m=0;m<i.length;m+=1){const p=i[m];P(p.endRow),P(p.startRow);for(let g=p.startRow;g<=p.endRow&&g<this.floatingTopRowCount;g+=1)o.add(g);p.endRow>=this.floatingTopRowCount&&p.startRow<=this.floatingTopRowCount+this.table.size&&r.push(new re(p.startColumn,Math.min(Math.max(0,p.startRow-this.floatingTopRowCount)),p.endColumn,Math.min(Math.max(0,p.endRow-this.floatingTopRowCount),this.table.size-this.floatingTopRowCount)));for(let g=Math.max(p.startRow,this.floatingTopRowCount+this.table.size);g<=p.endRow&&g<this.floatingTopRowCount+this.table.size+this.floatingBottomRowCount;g+=1)l.add(g)}const a=te.columnsFromRanges(i,this.columns),d=[];e&&d.push(a.map(m=>m.name));const c=[...o].sort();for(let m=0;m<c.length;m+=1){const p=c[m],g=a.map(f=>{const b=this.getColumnIndexByName(f.name);return P(b),n(this.valueForCell(b,p),f)});e&&g.push(this.textForRowFooter(p)),d.push(g)}if(r.length>0){const m=te.rangeSetFromRanges(r),p=await this.subscription.snapshot(m,a);d.push(...p.rows.map(g=>a.map(f=>n(g.get(f),f))))}const u=[...l].sort();for(let m=0;m<u.length;m+=1){const p=u[m],g=a.map(f=>{const b=this.getColumnIndexByName(f.name);return P(b),n(this.valueForCell(b,p),f)});e&&g.push(this.textForRowFooter(p)),d.push(g)}return d}async textSnapshot(t,e=!1,n=s=>`${s}`){return tt.debug2("textSnapshot",t,e),(await this.snapshot(t,e,n,!1)).map(i=>i.join(" ")).join(`
36
36
  `)}async valuesTable(t){let e=null;try{return e=await this.table.copy(),e.applyFilter([]),e.applySort([]),e.selectDistinct([t])}finally{e!=null&&e.close()}}isColumnMovable(t,e){if(t<0||t>=this.columnCount)return!1;if(e>0)return!0;const n=this.columns[t].name;return this.frontColumns.includes(n)||this.backColumns.includes(n)||this.frozenColumns.includes(n)||!n?!1:!this.isKeyColumn(t)}isKeyColumn(t){var e,n;return t<((n=(e=this.inputTable)==null?void 0:e.keyColumns.length)!=null?n:0)}isRowMovable(){return!1}isEditableRange(t){return this.inputTable!=null&&re.isBounded(t)&&(this.isPendingRow(t.startRow)&&this.isPendingRow(t.endRow)||t.startColumn>=this.inputTable.keyColumns.length&&t.endColumn>=this.inputTable.keyColumns.length)&&t.startRow>=this.floatingTopRowCount&&t.startRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount&&t.endRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount}isDeletableRange(t){return this.inputTable!=null&&t.startRow!=null&&t.endRow!=null&&t.startRow>=this.floatingTopRowCount&&t.startRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount&&t.endRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount}isEditableRanges(t){return t.every(e=>this.isEditableRange(e))}isDeletableRanges(t){return t.every(e=>this.isDeletableRange(e))}getTableAreaRange(){return new re(null,this.floatingTopRowCount,null,this.floatingTopRowCount+this.table.size-1)}getPendingAreaRange(){return new re(null,this.floatingTopRowCount+this.table.size,null,this.floatingTopRowCount+this.table.size+this.pendingNewRowCount-1)}async setValueForCell(t,e,n){return this.setValueForRanges([new re(t,e,t,e)],n)}async setValueForRanges(t,e){var n;if(!this.isEditableRanges(t))throw new Error(`Uneditable ranges ${t}`);try{const s=new Set,i=[];re.forEachCell(t,(d,c)=>{const u=this.columns[d];if(s.add(u),i[d]===void 0){const m=L.makeValue(u.type,e,this.formatter.timeZone);i[d]=m!=null?this.displayString(m,u.type,u.name):null}this.cachePendingValue(d,c,i[d])});const o=this.getPendingAreaRange(),r=t.map(d=>re.intersection(o,d)).filter(d=>d!=null).map(d=>(P(d),re.offset(d,0,-(this.floatingTopRowCount+this.table.size))));if(r.length>0){const d=new Map(this.pendingNewDataMap);re.forEachCell(r,(c,u)=>{d.has(u)||d.set(u,{data:new Map});const m=this.columns[c],p=d.get(u);P(p);const{data:g}=p,f=new Map(g),b=L.makeValue(m.type,e,this.formatter.timeZone);b!=null?f.set(c,{value:b}):f.delete(c),f.size>0?d.set(u,{...p,data:f}):d.delete(u)}),this.pendingDataMap=d}this.dispatchEvent(new Ge(Ce.EVENT.UPDATED));const l=this.getTableAreaRange(),a=t.map(d=>re.intersection(l,d)).filter(d=>d!=null);if(a.length>0){const c=(await this.snapshot(a.map(m=>{var p,g;return new re(null,(p=m==null?void 0:m.startRow)!=null?p:null,null,(g=m==null?void 0:m.endRow)!=null?g:null)}))).map(m=>{const p={};for(let g=0;g<this.columns.length;g+=1)p[this.columns[g].name]=m[g];return s.forEach(g=>{p[g.name]=L.makeValue(g.type,e,this.formatter.timeZone)}),p}),u=await((n=this.inputTable)==null?void 0:n.addRows(c));tt.debug("setValueForRanges(",t,",",e,") set tableRanges",a,"result",u)}re.forEachCell(t,(d,c)=>{const u=i[d];P(u),this.cacheFormattedValue(d,c,u)})}catch(s){tt.error("Unable to set ranges",t,e,s)}finally{re.forEachCell(t,(s,i)=>{this.clearPendingValue(s,i)})}}async setValues(t=[]){var e;if(tt.debug("setValues(",t,")"),!t.every(n=>{var s,i;return this.isEditableRange(re.makeCell((s=n.column)!=null?s:n.x,(i=n.row)!=null?i:n.y))}))throw new Error(`Uneditable ranges ${t}`);try{const n=new Map(this.pendingNewDataMap);t.forEach(l=>{var f,b;const{text:a}=l,d=(f=l.column)!=null?f:l.x,c=(b=l.row)!=null?b:l.y,u=this.columns[d],m=L.makeValue(u.type,a,this.formatter.timeZone),p=m!=null?this.displayString(m,u.type,u.name):null;this.cachePendingValue(d,c,p);const g=this.pendingRow(c);if(g!=null){n.has(g)||n.set(g,{data:new Map});const C=n.get(g);P(C);const{data:w}=C,T=new Map(w);m!=null?T.set(d,{value:m}):T.delete(d),T.size>0?n.set(g,{...C,data:T}):n.delete(g)}}),this.pendingDataMap=n,this.dispatchEvent(new Ge(Ce.EVENT.UPDATED));const s=t.reduce((l,a)=>{var c,u;const d=(c=a.row)!=null?c:a.y;return l.has(d)||l.set(d,[]),(u=l.get(d))==null||u.push(a),l},new Map),i=re.consolidate(t.map(l=>{var a,d;return re.makeCell((a=l.column)!=null?a:l.x,(d=l.row)!=null?d:l.y)})),o=this.getTableAreaRange(),r=i.map(l=>re.intersection(o,l)).filter(l=>l!=null);if(r.length>0){const a=(await this.snapshot(r.map(c=>(P(c),new re(null,c.startRow,null,c.endRow))))).map((c,u)=>{let m=null,p=u;for(let b=0;b<r.length;b+=1){const C=r[b];P(C);const w=re.rowCount([C]);if(p<w){P(C.startRow),m=C.startRow+p;break}p-=w}const g={};for(let b=0;b<this.columns.length;b+=1)g[this.columns[b].name]=c[b];P(m);const f=s.get(m);return f!=null&&f.forEach(b=>{var w;const C=this.columns[(w=b.column)!=null?w:b.x];g[C.name]=L.makeValue(C.type,b.text,this.formatter.timeZone)}),g});tt.info("setValues setting tableRanges",r);const d=await((e=this.inputTable)==null?void 0:e.addRows(a));tt.info("setValues set tableRanges",r,"SUCCESS",d)}t.forEach(l=>{var g,f;const{text:a}=l,d=(g=l.column)!=null?g:l.x,c=(f=l.row)!=null?f:l.y,u=this.columns[d],m=L.makeValue(u.type,a,this.formatter.timeZone),p=m!=null?this.displayString(m,u.type,u.name):null;this.cacheFormattedValue(d,c,p)})}finally{t.forEach(n=>{this.clearPendingValue(n.column,n.row)})}}async commitPending(){var t,e,n;if(this.pendingNewDataMap.size<=0)throw new Error("No pending changes to commit");try{this.isSaveInProgress=!0;const s=[];this.pendingNewDataMap.forEach(o=>{const r={};o.data.forEach(({value:l},a)=>{const d=this.columns[a];r[d.name]=l}),s.push(r)});const i=await((t=this.inputTable)==null?void 0:t.addRows(s));tt.debug("commitPending()",this.pendingNewDataMap,"result",i),this.pendingNewDataMap=new Map,this.pendingNewDataErrors=new Map,this.pendingNewRowCount=Math.max(0,((n=(e=this.viewport)==null?void 0:e.bottom)!=null?n:0)-this.table.size),this.formattedStringData=[],this.dispatchEvent(new Ge(Ce.EVENT.PENDING_DATA_UPDATED))}finally{this.isSaveInProgress=!1}}editValueForCell(t,e){return this.textValueForCell(t,e)}async delete(t){if(!this.isDeletableRanges(t))throw new Error(`Undeletable ranges ${t}`);P(this.inputTable);const{keyColumns:e}=this.inputTable;if(e.length===0)throw new Error("No key columns to allow deletion");const n=this.getPendingAreaRange(),s=t.map(c=>re.intersection(n,c)).filter(c=>c!=null).map(c=>(P(c),re.offset(c,0,-(this.floatingTopRowCount+this.table.size))));if(s.length>0){const c=new Map(this.pendingNewDataMap);for(let u=0;u<s.length;u+=1){const m=s[u];P(m.startRow),P(m.endRow);for(let p=m.startRow;p<=m.endRow;p+=1)c.delete(p)}this.pendingNewDataMap=c,this.formattedStringData=[],this.dispatchEvent(new Ge(Ce.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new Ge(Ce.EVENT.UPDATED))}const i=this.getTableAreaRange(),o=t.map(c=>re.intersection(i,c)).filter(c=>c!=null);if(o.length<=0)return;const[r,l]=await Promise.all([this.snapshot(o.map(c=>(P(c),new re(0,c.startRow,e.length-1,c.endRow)))),this.table.copy()]),d=r.map(c=>{const u=[];for(let m=0;m<e.length;m+=1){const p=e[m],g=c[m],f=L.makeFilterRawValue(p.type,g),b=p.filter().eq(f);u.push(b)}return u.reduce((m,p)=>{var g;return(g=m==null?void 0:m.and(p))!=null?g:p})}).reduce((c,u)=>{var m;return(m=c==null?void 0:c.or(u))!=null?m:u});l.applyFilter([d]),l.close()}isValidForCell(t,e,n){try{const s=this.columns[t];return L.makeValue(s.type,n,this.formatter.timeZone),!0}catch{return!1}}};let Kd=za;Kd.ROW_BUFFER_PAGES=1;const Ns=X.module("IrisGridTableModel");class yp extends Kd{constructor(e,n=new un,s=null){super(e,n,s),this.getMemoizedFrontColumns=pe(i=>i!=null?i:[]),this.getMemoizedBackColumns=pe(i=>i!=null?i:[]),this.getMemoizedFrozenColumns=pe((i,o)=>{var r;return(r=o!=null?o:i)!=null?r:[]}),this.getCachedFilterableColumnSet=pe(i=>new Set(i.map((o,r)=>r))),this.customColumnList=[],this.formatColumnList=[]}get isExportAvailable(){return this.table.freeze!=null}get isColumnStatisticsAvailable(){return this.table.getColumnStatistics!=null}get isValuesTableAvailable(){return this.table.selectDistinct!=null&&this.table.copy!=null}get isRollupAvailable(){return this.table.rollup!=null}get isSelectDistinctAvailable(){return this.table.selectDistinct!=null}get isCustomColumnsAvailable(){return this.table.applyCustomColumns!=null}get isFormatColumnsAvailable(){return this.table.applyCustomColumns!=null}get frontColumns(){var e;return this.getMemoizedFrontColumns((e=this.layoutHints)==null?void 0:e.frontColumns)}get backColumns(){var e;return this.getMemoizedBackColumns((e=this.layoutHints)==null?void 0:e.backColumns)}get frozenColumns(){var e;return this.getMemoizedFrozenColumns((e=this.layoutHints)==null?void 0:e.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(Ns.debug2("set customColumns",e,this.customColumnList,e===this.customColumnList),this.customColumnList.length===0&&e.length===0){Ns.debug("Ignore empty initial customColumns"),this.customColumnList=e;return}if(this.customColumnList===e){Ns.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(Ns.debug2("set formatColumns",e,this.formatColumnList,e===this.formatColumnList),this.formatColumnList.length===0&&e.length===0){Ns.debug("Ignore empty initial formatColumns"),this.formatColumnList=e;return}if(this.formatColumnList===e){Ns.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 Ge(Ce.EVENT.TABLE_CHANGED,{detail:this.table}))}set totalsConfig(e){if(Ns.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 Ge(Ce.EVENT.UPDATED));return}this.totalsTablePromise=Te.makeCancelable(this.table.getTotalsTable(e),n=>n.close()),this.totalsTablePromise.then(n=>{this.totalsTablePromise=null,this.setTotalsTable(n)}).catch(n=>{Te.isCanceled(n)||(Ns.error("Unable to set next totalsTable",n),this.totalsTablePromise=null,this.dispatchEvent(new Ge(Ce.EVENT.REQUEST_FAILED,{detail:n})))})}}get isFilterRequired(){return this.table.isUncoalesced}isFilterable(e){return this.getCachedFilterableColumnSet(this.columns).has(e)}async export(){return this.table.freeze()}columnStatistics(e){return this.table.getColumnStatistics(e)}isColumnMovable(e){const n=this.columns[e].name;return this.frontColumns.includes(n)||this.backColumns.includes(n)||this.frozenColumns.includes(n)?!1:!this.isKeyColumn(e)}isColumnFrozen(e){return this.frozenColumns.includes(this.columns[e].name)}async delete(e){var u;if(!this.isDeletableRanges(e))throw new Error(`Undeletable ranges ${e}`);P(this.inputTable);const{keyColumns:n}=this.inputTable;if(n.length===0)throw new Error("No key columns to allow deletion");const s=this.getPendingAreaRange(),i=e.map(m=>re.intersection(s,m)).filter(m=>m!=null).map(m=>(P(m),re.offset(m,0,-(this.floatingTopRowCount+this.table.size))));if(i.length>0){const m=new Map(super.pendingDataMap);for(let p=0;p<i.length;p+=1){const g=i[p];P(g.startRow),P(g.endRow);for(let f=g.startRow;f<=g.endRow;f+=1)m.delete(f)}super.pendingDataMap=m,this.formattedStringData=[],this.dispatchEvent(new Ge(Ce.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new Ge(Ce.EVENT.UPDATED))}const o=this.getTableAreaRange(),r=e.map(m=>re.intersection(o,m)).filter(m=>m!=null);if(r.length<=0)return;const[l,a]=await Promise.all([this.snapshot(r.map(m=>(P(m),new re(0,m.startRow,n.length-1,m.endRow)))),this.table.copy()]),c=l.map(m=>{const p=[];for(let g=0;g<n.length;g+=1){const f=n[g],b=m[g],C=L.makeFilterRawValue(f.type,b),w=f.filter().eq(C);p.push(w)}return p.reduce((g,f)=>{var b;return(b=g==null?void 0:g.and(f))!=null?b:f})}).reduce((m,p)=>{var g;return(g=m==null?void 0:m.or(p))!=null?g:p});a.applyFilter([c]),await((u=this.inputTable)==null?void 0:u.deleteTable(a)),a.close()}}class sE extends Kd{constructor(){super(...arguments),this.getCachedFilterableColumnSet=pe((e,n)=>new Set(((n==null?void 0:n.length)>0?n:e).map(s=>e.findIndex(i=>s.name===i.name))))}applyBufferedViewport(e,n,s){this.table.setViewport(e,n,s)}textForCell(e,n){const s=this.columns[e],i=this.row(n);if(i!=null&&s!=null&&!i.hasChildren&&s.constituentType!=null){const o=this.valueForCell(e,n);return this.displayString(o,s.constituentType,s.name)}return super.textForCell(e,n)}extractViewportRow(e,n){const{isExpanded:s,hasChildren:i,depth:o}=e;return{...super.extractViewportRow(e,n),isExpanded:s,hasChildren:i,depth:o}}async snapshot(e,n,s){var l,a;P(this.viewport),P(this.viewportData);const{columns:i}=this.viewport,o=[];n!=null&&n&&o.push(i.map(d=>d.name));const r=new re(0,(l=this.viewportData)==null?void 0:l.offset,i.length,this.viewportData.offset+this.viewportData.rows.length);for(let d=0;d<e.length;d+=1){const c=re.intersection(r,e[d]);P(c),P(c.startRow),P(c.endRow);for(let u=c.startRow;u<=c.endRow;u+=1){const m=[],p=this.viewportData.rows[u-this.viewportData.offset];P(c.startColumn),P(c.endColumn);for(let g=c.startColumn;g<=c.endColumn;g+=1)P(s),m.push(s((a=p.data.get(g))==null?void 0:a.value,this.columns[g]));o.push(m)}}return o}get groupedColumns(){return[]}get hasExpandableRows(){return!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){var s;const n=this.row(e);return(s=n==null?void 0:n.hasChildren)!=null?s:!1}isRowExpanded(e){var s;const n=this.row(e);return(s=n==null?void 0:n.isExpanded)!=null?s:!1}setRowExpanded(e,n){this.table.setExpanded(e,n)}depthForRow(e){var s;const n=this.row(e);return((s=n==null?void 0:n.depth)!=null?s:1)-1}}const Fs=X.module("IrisGridProxyModel");function Sa(t,e,n){return L.isTreeTable(t)?new sE(t,e):new yp(t,e,n)}class iE extends Ce{constructor(e,n=new un,s=null){super(),this.textForCell=(...o)=>this.model.textForCell(...o),this.truncationCharForCell=(...o)=>this.model.truncationCharForCell(...o),this.textAlignForCell=(...o)=>this.model.textAlignForCell(...o),this.colorForCell=(...o)=>this.model.colorForCell(...o),this.backgroundColorForCell=(...o)=>this.model.backgroundColorForCell(...o),this.textForColumnHeader=(...o)=>this.model.textForColumnHeader(...o),this.colorForColumnHeader=(...o)=>this.model.colorForColumnHeader(...o),this.textForRowHeader=(...o)=>this.model.textForRowHeader(...o),this.textForRowFooter=(...o)=>this.model.textForRowFooter(...o),this.isRowMovable=(...o)=>this.model.isRowMovable(...o),this.isColumnMovable=(...o)=>this.model.isColumnMovable(...o),this.isRowExpandable=(...o)=>pt(this.model)?this.model.isRowExpandable(...o):!1,this.isRowExpanded=(...o)=>pt(this.model)?this.model.isRowExpanded(...o):!1,this.setRowExpanded=(...o)=>{if(pt(this.model))return this.model.setRowExpanded(...o);throw Error("Function setRowExpanded does not exist on IrisGridTableModel")},this.depthForRow=(...o)=>pt(this.model)?this.model.depthForRow(...o):0,this.getColumnHeaderGroup=(...o)=>this.model.getColumnHeaderGroup(...o),this.getColumnHeaderParentGroup=(...o)=>this.model.getColumnHeaderParentGroup(...o),this.formatForCell=(...o)=>this.model.formatForCell(...o),this.valueForCell=(...o)=>this.model.valueForCell(...o),this.displayString=(...o)=>this.model.displayString(...o),this.isEditableRange=(...o)=>Je(this.model)?this.model.isEditableRange(...o):!1,this.isFilterable=(...o)=>this.model.isFilterable(...o),this.setViewport=(o,r,l)=>this.model.setViewport(o,r,l),this.snapshot=(...o)=>this.model.snapshot(...o),this.textSnapshot=(...o)=>this.model.textSnapshot(...o),this.valuesTable=(...o)=>this.model.valuesTable(...o),this.editValueForCell=(...o)=>(Je(this.model)&&this.model.editValueForCell(...o),""),this.setValueForCell=(...o)=>Je(this.model)?this.model.setValueForCell(...o):Promise.reject(new Error("Model is not editable")),this.setValueForRanges=(...o)=>Je(this.model)?this.model.setValueForRanges(...o):Promise.reject(new Error("Model is not editable")),this.setValues=(...o)=>Je(this.model)?this.model.setValues(...o):Promise.resolve(),this.isValidForCell=(...o)=>Je(this.model)?this.model.isValidForCell(...o):!1,this.delete=(...o)=>this.model.delete(...o),this.commitPending=(...o)=>this.model.commitPending(...o),this.handleModelEvent=this.handleModelEvent.bind(this);const i=Sa(e,n,s);this.originalModel=i,this.model=i,this.modelPromise=null,this.rollup=null,this.selectDistinct=[]}close(){this.originalModel.close(),this.model!==this.originalModel&&this.model.close(),this.modelPromise!=null&&this.modelPromise.cancel()}handleModelEvent(e){Fs.debug2("handleModelEvent",e);const{detail:n,type:s}=e;this.dispatchEvent(new Ge(s,{detail:n}))}setModel(e){Fs.debug("setModel",e);const n=this.model;n!==this.originalModel&&n.close(),this.model=e,this.listenerCount>0&&this.addListeners(e),this.dispatchEvent(new Ge(Ce.EVENT.COLUMNS_CHANGED,{detail:e.columns})),li(e)&&this.dispatchEvent(new Ge(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=Te.makeCancelable(e,n=>n.close()),this.modelPromise.then(n=>{this.modelPromise=null,this.setModel(n)}).catch(n=>{if(Te.isCanceled(n)){Fs.debug2("setNextModel cancelled");return}Fs.error("Unable to set next model",n),this.modelPromise=null,this.dispatchEvent(new Ge(Ce.EVENT.REQUEST_FAILED,{detail:n}))})}startListening(){super.startListening(),this.addListeners(this.model)}stopListening(){super.stopListening(),this.removeListeners(this.model)}addListeners(e){const n=Object.keys(Ce.EVENT);for(let s=0;s<n.length;s+=1)e.addEventListener(n[s],this.handleModelEvent)}removeListeners(e){const n=Object.keys(Ce.EVENT);for(let s=0;s<n.length;s+=1)e.removeEventListener(n[s],this.handleModelEvent)}get rowCount(){return this.model.rowCount}get columnCount(){return this.model.columnCount}get floatingTopRowCount(){return this.model.floatingTopRowCount}get floatingBottomRowCount(){return this.model.floatingBottomRowCount}get floatingLeftColumnCount(){return this.model.floatingLeftColumnCount}get floatingRightColumnCount(){return this.model.floatingRightColumnCount}isColumnFrozen(e){return this.model.isColumnFrozen(e)}get hasExpandableRows(){return pt(this.model)?this.model.hasExpandableRows:!1}get isExportAvailable(){return this.model.isExportAvailable}get isColumnStatisticsAvailable(){return this.model.isColumnStatisticsAvailable}get isValuesTableAvailable(){return this.model.isValuesTableAvailable}get isCustomColumnsAvailable(){return this.model.isCustomColumnsAvailable&&!(this.isSelectDistinctAvailable&&this.selectDistinctColumns.length>0)}get isFormatColumnsAvailable(){return this.model.isFormatColumnsAvailable}get isChartBuilderAvailable(){return this.model.isChartBuilderAvailable}get isRollupAvailable(){return(this.originalModel.isRollupAvailable||this.rollup!=null)&&this.selectDistinct.length===0}get isSelectDistinctAvailable(){return(this.originalModel.isSelectDistinctAvailable||this.selectDistinct.length>0)&&this.rollup==null}get isTotalsAvailable(){return this.model.isTotalsAvailable}get isReversible(){return this.model.isReversible}get columns(){return this.model.columns}get movedColumns(){return this.model.movedColumns}get movedRows(){return this.model.movedRows}get layoutHints(){return this.model.layoutHints}get frontColumns(){return this.model.frontColumns}get backColumns(){return this.model.backColumns}get frozenColumns(){return this.model.frozenColumns}get columnHeaderMaxDepth(){return this.model.columnHeaderMaxDepth}updateFrozenColumns(e){return this.model.updateFrozenColumns(e)}get originalColumns(){return this.originalModel.columns}get groupedColumns(){return this.model.groupedColumns}get description(){return this.model.description}get filter(){return this.model.filter}set filter(e){this.model.filter=e}get formatter(){return this.model.formatter}set formatter(e){this.model.formatter=e}get sort(){return this.model.sort}set sort(e){this.model.sort=e}get customColumns(){return this.model.customColumns}set customColumns(e){this.model.customColumns=e}get formatColumns(){return this.model.formatColumns}set formatColumns(e){this.model.formatColumns=e}get rollupConfig(){return this.rollup}set rollupConfig(e){if(Fs.debug("set rollupConfig",e),!this.isRollupAvailable)throw new Error("Rollup Rows are not available");if(ht(e,this.rollup))return;this.rollup=e;let n=Promise.resolve(this.originalModel);li(this.originalModel)&&e!=null&&(n=this.originalModel.table.rollup(e).then(s=>Sa(s,this.formatter))),this.setNextModel(n)}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 n=e.map(i=>this.originalColumns.find(o=>o.name===i)).filter(i=>i!=null);let s=Promise.resolve(this.originalModel);li(this.originalModel)&&n.length>0&&(s=this.originalModel.table.selectDistinct(n).then(i=>Sa(i,this.formatter))),this.setNextModel(s)}get table(){if(li(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 Je(this.model)&&this.model.isEditable}export(){if(L.isTreeTable(this.model))throw new Error("TreeTable has no 'export' property");return this.model.export()}columnStatistics(e){if(L.isTreeTable(this.model))throw new Error("TreeTable has no 'columnStatistics' function");return this.model.columnStatistics(e)}get pendingDataMap(){return this.model.pendingDataMap}set pendingDataMap(e){this.model.pendingDataMap=e}get pendingRowCount(){return this.model.pendingRowCount}set pendingRowCount(e){this.model.pendingRowCount=e}get pendingDataErrors(){return this.model.pendingDataErrors}getColumnIndexByName(e){return this.model.getColumnIndexByName(e)}}class qd{static async makeModel(e,n=new un){let s=null;return!L.isTreeTable(e)&&e.hasInputTable&&(s=await e.inputTable()),new iE(e,n,s)}}const ns=X.module("TableViewportUpdater"),oE=150,No=class extends S.exports.PureComponent{constructor(){super(...arguments),this.getViewportRowRange=pe((t,e,n)=>{const s=n-e,i=Math.max(0,e-s*No.ROW_BUFFER_PAGES),o=n+s*No.ROW_BUFFER_PAGES;return[i,o]}),this.getViewportColumns=pe((t,e,n,s)=>{if(e==null||n==null)return null;const i=n-e,o=Math.max(0,e-i*No.COLUMN_BUFFER_PAGES),r=Math.min(n+i*No.COLUMN_BUFFER_PAGES,t.columns.length-1),l=[];for(let a=o;a<=r;a+=1){const d=K.getModelIndex(a,s);l.push(t.columns[d])}return l}),this.updateViewport=us((t,e,n,s,i)=>{if(e<t){ns.error("Invalid viewport",t,e);return}if(t===0&&e===0){ns.debug2("Ignoring 0-0 viewport");return}const{movedColumns:o,table:r}=this.props,[l,a]=this.getViewportRowRange(r,t,e),d=i!=null?i:this.getViewportColumns(r,n,s,o);if(ns.debug2("Setting Viewport Top:",l,"Bottom:",a,"Columns:",d),this.subscription==null){ns.debug2("updateViewport creating new subscription"),this.subscription=r.setViewport(l,a,d);const{onSubscription:c}=this.props;c(this.subscription)}else ns.debug2("updateViewport using existing subscription"),this.subscription.setViewport(l,a,d)},oE)}componentDidMount(){const{top:t,bottom:e,left:n,right:s,table:i,filters:o,sorts:r,columns:l,customColumns:a}=this.props;i.applyFilter(o),i.applySort(r),i.applyCustomColumns(a),this.updateViewport(t,e,n,s,l)}componentDidUpdate(t){const{top:e,bottom:n,left:s,right:i,table:o,filters:r,sorts:l,customColumns:a,columns:d}=this.props,c=r!==t.filters,u=l!==t.sorts,m=a!==t.customColumns,p=o!==t.table;(c||u||m||p)&&this.closeSubscription(),(c||p)&&(ns.debug("update table filter",r),o.applyFilter(r)),(u||p)&&(ns.debug("update table sort",l),o.applySort(l)),(m||p)&&(ns.debug("update table custom columns",a),o.applyCustomColumns(a)),this.updateViewport(e,n,s,i,d)}componentWillUnmount(){this.closeSubscription()}closeSubscription(){if(ns.debug2("closeSubscription",this.subscription),this.subscription){this.subscription.close(),this.subscription=void 0;const{onSubscription:t}=this.props;t()}this.updateViewport.cancel()}render(){return null}};let Yd=No;Yd.ROW_BUFFER_PAGES=3;Yd.COLUMN_BUFFER_PAGES=1;Yd.defaultProps={top:0,bottom:0,left:null,right:null,columns:null,onSubscription:()=>{},filters:[],sorts:[],customColumns:[],movedColumns:[]};const Ri=X.module("TreeTableViewportUpdater"),rE=150,Ip=class extends S.exports.PureComponent{constructor(t){super(t),this.updateViewport=us((e,n)=>{if(n<e){Ri.error("Invalid viewport",e,n);return}if(e===0&&n===0){Ri.debug2("Ignoring 0-0 viewport");return}const{table:s,updateInterval:i}=this.props,o=n-e,r=Math.max(0,e-o*3),l=n+o*3+1;if(Ri.debug2("Setting Viewport Top:",r,"Bottom:",l,s),!this.listenerCleanup){const{onViewportUpdate:a}=this.props;this.listenerCleanup=s.addEventListener(M.TreeTable.EVENT_UPDATED,a)}s.setViewport(r,l,void 0,i)},rE),this.listenerCleanup=null}componentDidMount(){const{top:t,bottom:e,table:n,filters:s,sorts:i}=this.props;Ri.debug("componentDidMount",this.props),n.applyFilter(s),n.applySort(i),this.updateViewport(t,e)}componentDidUpdate(t){const{top:e,bottom:n,table:s,filters:i,sorts:o}=this.props;i!==t.filters&&(Ri.debug("update table filter",i),s.applyFilter(i)),o!==t.sorts&&(Ri.debug("update table sort",o),s.applySort(o)),this.updateViewport(e,n)}componentWillUnmount(){this.updateViewport.cancel(),this.listenerCleanup&&this.listenerCleanup()}render(){return null}};let Rp=Ip;Rp.UPDATE_INTERVAL=1e3;Rp.defaultProps={top:0,bottom:0,onViewportUpdate:()=>{},filters:[],sorts:[],updateInterval:Ip.UPDATE_INTERVAL};class Ki{}Ki.OPEN="ChartEvent.OPEN";Ki.CLOSE="ChartEvent.CLOSE";Ki.COLUMN_SELECTED="ChartEvent.COLUMN_SELECTED";class Ct{}Ct.SESSION_OPENED="ConsoleEvent.SESSION_OPENED";Ct.SESSION_CLOSED="ConsoleEvent.SESSION_CLOSED";Ct.FOCUS_HISTORY="ConsoleEvent.FOCUS_HISTORY";Ct.SEND_COMMAND="ConsoleEvent.SEND_COMMAND";Ct.SETTINGS_CHANGED="ConsoleEvent.SETTINGS_CHANGED";class Pe{}Pe.TABLE_CHANGED="InputFilterEvent.TABLE_CHANGED";Pe.COLUMNS_CHANGED="InputFilterEvent.COLUMNS_CHANGED";Pe.FILTERS_CHANGED="InputFilterEvent.FILTERS_CHANGED";Pe.CLEAR_ALL_FILTERS="InputFilterEvent.CLEAR_ALL_FILTERS";Pe.COLUMN_SELECTED="InputFilterEvent.COLUMN_SELECTED";Pe.OPEN_DROPDOWN="InputFilterEvent.OPEN_DROPDOWN";Pe.OPEN_INPUT="InputFilterEvent.OPEN_INPUT";Pe.OPEN_FILTER_SET_MANAGER="InputFilterEvent.OPEN_FILTER_SET_MANAGER";class Tt{}Tt.OPEN_GRID="IrisGridEvent.OPEN_GRID";Tt.CLOSE_GRID="IrisGridEvent.CLOSE_GRID";Tt.DATA_SELECTED="IrisGridEvent.DATA_SELECTED";Tt.COLUMN_SELECTED="IrisGridEvent.COLUMN_SELECTED";Tt.STATE_CHANGED="IrisGridEvent.STATE_CHANGED";Tt.CREATE_CHART="IrisGridevent.CREATE_CHART";const Dp=Object.freeze({OPEN:"MarkdownEvent.OPEN"});class He{}He.CREATE_NOTEBOOK="NotebookEvent.createNotebook";He.SELECT_NOTEBOOK="NotebookEvent.selectNotebook";He.CLOSE_FILE="NotebookEvent.closeFile";He.RENAME="NotebookEvent.rename";He.RENAME_FILE="NotebookEvent.renameFile";He.REGISTER_FILE="NotebookEvent.registerFile";He.SEND_TO_NOTEBOOK="NotebookEvent.sendToNotebook";He.UNREGISTER_FILE="NotebookEvent.unregisterFile";class Kn{}Kn.focus="TabEvent.focus";Kn.blur="TabEvent.blur";Kn.openPQObject="TabEvent.openPQObject";Kn.openControl="TabEvent.openControl";Kn.reload="TabEvent.reload";Kn.clearAllFilters="TabEvent.clearAllFilters";class Mp extends S.exports.PureComponent{constructor(e){super(e),this.handleCloseTab=this.handleCloseTab.bind(this),this.handleCloseTabsRight=this.handleCloseTabsRight.bind(this),this.handleCloseTabsAll=this.handleCloseTabsAll.bind(this)}getAllTabs(){var n,s,i;const{glContainer:e}=this.props;return[...(i=(s=(n=e==null?void 0:e.tab)==null?void 0:n.header)==null?void 0:s.tabs)!=null?i:[]]}handleCloseTab(){const{glContainer:e}=this.props;e.close()}handleCloseTabsAll(){this.getAllTabs().forEach(n=>{var s;return(s=(n==null?void 0:n.contentItem).container)==null?void 0:s.close()})}handleCloseTabsRight(){var s,i,o,r,l,a,d;const{glContainer:e}=this.props,n=this.getAllTabs();for(let c=n.length-1;c>0&&((i=(s=n[c].contentItem)==null?void 0:s.config)==null?void 0:i.id)!==((l=(r=(o=e.tab)==null?void 0:o.contentItem)==null?void 0:r.config)==null?void 0:l.id);c-=1)(d=((a=n[c])==null?void 0:a.contentItem).container)==null||d.close()}canCloseTabsRight(){var i,o,r,l,a,d,c,u;const{glContainer:e}=this.props,n=this.getAllTabs();let s=!0;for(let m=n.length-1;m>0&&((o=(i=n[m].contentItem)==null?void 0:i.config)==null?void 0:o.id)!==((a=(l=(r=e.tab)==null?void 0:r.contentItem)==null?void 0:l.config)==null?void 0:a.id);m-=1)if(Boolean((u=(c=(d=n[m])==null?void 0:d.contentItem)==null?void 0:c.config)==null?void 0:u.isClosable)){s=!1;break}return s}canCloseAny(){var s,i,o;const e=this.getAllTabs();let n=!0;for(let r=e.length-1;r>0;r-=1)if(Boolean((o=(i=(s=e[r])==null?void 0:s.contentItem)==null?void 0:i.config)==null?void 0:o.isClosable)){n=!1;break}return n}render(){var o,r,l;const{additionalActions:e,glContainer:n}=this.props,s=[...e],i=(l=(r=(o=n.tab)==null?void 0:o.contentItem)==null?void 0:r.config)==null?void 0:l.isClosable;return s.push({title:"Close",order:10,group:oe.groups.low,action:this.handleCloseTab,disabled:i===void 0||!i}),s.push(()=>({title:"Close Tabs to Right",order:20,group:oe.groups.low,action:this.handleCloseTabsRight,disabled:this.canCloseTabsRight()})),s.push(()=>({title:"Close All",order:30,group:oe.groups.low,action:this.handleCloseTabsAll,disabled:this.canCloseAny()})),h(oe,{actions:s})}}Mp.defaultProps={additionalActions:[]};class Np extends S.exports.PureComponent{constructor(e){super(e),this.handleRenameDialogOpened=this.handleRenameDialogOpened.bind(this),this.handleRenameInputChange=this.handleRenameInputChange.bind(this),this.handleRenameCancel=this.handleRenameCancel.bind(this),this.handleRenameSubmit=this.handleRenameSubmit.bind(this),this.renameInputRef=Y.createRef();const{value:n}=e;this.state={value:n,valueWasValidated:!1}}componentDidUpdate(e){const{isShown:n}=e,{isShown:s}=this.props;s&&!n&&this.resetState()}resetState(){const{value:e}=this.props;this.setState({value:e,valueWasValidated:!1})}handleRenameDialogOpened(){var e,n;(n=(e=this.renameInputRef)==null?void 0:e.current)==null||n.focus()}handleRenameInputChange(e){this.setState({value:e.target.value})}handleRenameCancel(){const{onCancel:e}=this.props;e()}handleRenameSubmit(e){e.stopPropagation(),e.preventDefault();const{value:n}=this.state,s=n==null?void 0:n.trim();if(s!==void 0&&s!==""){const{onSubmit:i}=this.props;i(s)}else this.setState({value:s,valueWasValidated:!0})}renderRenameDialog(){const{isShared:e,isOwner:n,itemType:s}=this.props,{value:i,valueWasValidated:o}=this.state;return v("form",{className:W("p-3",{"was-validated":o}),onSubmit:this.handleRenameSubmit,noValidate:!0,role:"presentation",onMouseDown:r=>{r.stopPropagation()},onMouseUp:r=>{r.stopPropagation()},children:[v("div",{className:"form-group",children:[v("label",{htmlFor:`rename-dialog-${s}-input`,children:["Rename ",s]}),h("input",{type:"text",className:"form-control",id:`rename-dialog-${s}-input`,value:i!=null?i:void 0,ref:this.renameInputRef,onChange:this.handleRenameInputChange,required:!0}),v("div",{className:"invalid-feedback",children:[s," name cannot be empty"]}),(e||!n)&&v("div",{className:"pt-2",children:["Renaming this ",s," will rename for all users."]})]}),v("div",{className:"text-right",children:[h(z,{kind:"secondary",className:"mr-2",onClick:this.handleRenameCancel,children:"Cancel"}),h(z,{kind:"primary",type:"submit",children:"Rename"})]})]})}render(){const{isShown:e,onCancel:n}=this.props;return h(kn,{isShown:e,onEntered:this.handleRenameDialogOpened,onExited:n,options:{placement:"bottom",modifiers:{preventOverflow:{boundariesElement:"viewport"}}},interactive:!0,closeOnBlur:!0,children:this.renderRenameDialog()})}}Np.defaultProps={isShared:!1,isOwner:!0,itemType:"Item",value:""};const lE=X.module("Panel");class jn extends S.exports.PureComponent{constructor(e){super(e),this.getAdditionActions=pe((s,i,o)=>{const r=[];return i&&r.push(this.getCloneAction()),o&&r.push(this.getRenameAction()),[...r,...s]}),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.handleCopyPanel=this.handleCopyPanel.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleHide=this.handleHide.bind(this),this.handleResize=this.handleResize.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleBeforeShow=this.handleBeforeShow.bind(this),this.handleShow=this.handleShow.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleRenameCancel=this.handleRenameCancel.bind(this),this.handleRenameSubmit=this.handleRenameSubmit.bind(this),this.handleShowRenameDialog=this.handleShowRenameDialog.bind(this),this.handleTabClicked=this.handleTabClicked.bind(this),this.handleTab=this.handleTab.bind(this);const{glContainer:n}=this.props;this.state={title:ne.getTitleFromContainer(n),showRenameDialog:!1}}componentDidMount(){const{componentPanel:e,glContainer:n,glEventHub:s}=this.props;n.on("resize",this.handleResize),n.on("show",this.handleBeforeShow),n.on("shown",this.handleShow),n.on("hide",this.handleHide),n.on("tab",this.handleTab),n.on("tabClicked",this.handleTabClicked),s.on(Ct.SESSION_CLOSED,this.handleSessionClosed),s.on(Ct.SESSION_OPENED,this.handleSessionOpened),s.on(Kn.focus,this.handleTabFocus),s.on(Kn.blur,this.handleTabBlur),s.on(Pe.CLEAR_ALL_FILTERS,this.handleClearAllFilters),s.emit(Ne.MOUNT,e)}componentWillUnmount(){const{componentPanel:e,glContainer:n,glEventHub:s}=this.props;n.off("resize",this.handleResize),n.off("show",this.handleBeforeShow),n.off("shown",this.handleShow),n.off("hide",this.handleHide),n.off("tab",this.handleTab),n.off("tabClicked",this.handleTabClicked),s.off(Ct.SESSION_CLOSED,this.handleSessionClosed),s.off(Ct.SESSION_OPENED,this.handleSessionOpened),s.off(Kn.focus,this.handleTabFocus),s.off(Kn.blur,this.handleTabBlur),s.off(Pe.CLEAR_ALL_FILTERS,this.handleClearAllFilters),s.emit(Ne.UNMOUNT,e)}handleTab(e){e!=null&&this.setState({title:ne.getTitleFromTab(e)}),this.forceUpdate();const{onTab:n}=this.props;n(e)}handleTabClicked(...e){const{onTabClicked:n}=this.props;n(...e)}handleClearAllFilters(...e){const{onClearAllFilters:n}=this.props;n(...e)}handleFocus(e){const{componentPanel:n,glEventHub:s}=this.props;s.emit(Ne.FOCUS,n);const{onFocus:i}=this.props;i(e)}handleBlur(e){const{onBlur:n}=this.props;n(e)}handleHide(...e){const{onHide:n}=this.props;n(...e)}handleResize(...e){const{onResize:n}=this.props;n(...e)}handleSessionClosed(e){const{onSessionClose:n}=this.props;n(e)}handleSessionOpened(e,n){const{onSessionOpen:s}=this.props;s(e,n)}handleBeforeShow(...e){const{onBeforeShow:n}=this.props;n(...e)}handleShow(...e){const{onShow:n}=this.props;n(...e)}handleTabBlur(...e){const{onTabBlur:n}=this.props;n(...e)}handleTabFocus(...e){const{onTabFocus:n}=this.props;n(...e)}handleRenameCancel(){this.setState({showRenameDialog:!1})}handleShowRenameDialog(){this.setState({showRenameDialog:!0})}handleRenameSubmit(e){const{glContainer:n}=this.props;this.setState({showRenameDialog:!1,title:e});const s=ne.getRootFromContainer(n),i=ne.getComponentConfigFromContainer(n);P(i),ne.renameComponent(s,i,e)}handleCopyPanel(){const{glContainer:e,glEventHub:n}=this.props,s=ne.getRootFromContainer(e),i=ne.getComponentConfigFromContainer(e);if(i==null){lE.error("Could not get component config from container",e);return}const o=ne.cloneComponent(s,i);o!==null&&n.emit(Ne.CLONED,this,o)}getCloneAction(){return{title:"Copy Panel",order:10,group:oe.groups.high,action:this.handleCopyPanel}}getRenameAction(){return{title:"Rename",order:10,group:oe.groups.medium,action:this.handleShowRenameDialog}}render(){const{children:e,className:n,renderTabTooltip:s,glContainer:i,additionalActions:o,errorMessage:r,isLoaded:l,isLoading:a,isClonable:d,isRenamable:c}=this.props,{tab:u}=i,{showRenameDialog:m,title:p}=this.state;return v("div",{className:W("h-100 w-100 iris-panel",n),onFocusCapture:this.handleFocus,onBlurCapture:this.handleBlur,children:[e,h(wl,{errorMessage:r,isLoaded:l,isLoading:a}),u!=null&&ui.createPortal(v(ye,{children:[h(Mp,{glContainer:i,additionalActions:this.getAdditionActions(o,d,c)}),c&&h(Np,{isShown:m,value:p,itemType:"Panel",onCancel:this.handleRenameCancel,onSubmit:this.handleRenameSubmit}),s!=null&&h($e,{interactive:!0,options:{placement:"bottom"},popperClassName:"panel-tab-popper",children:s()})]}),u.element[0])]})}}jn.defaultProps={className:"",onTab:()=>{},onTabClicked:()=>{},onClearAllFilters:()=>{},onFocus:()=>{},onBlur:()=>{},onHide:()=>{},onResize:()=>{},onSessionClose:()=>{},onSessionOpen:()=>{},onBeforeShow:()=>{},onShow:()=>{},onTabBlur:()=>{},onTabFocus:()=>{},renderTabTooltip:null,additionalActions:[],errorMessage:null,isLoading:!1,isLoaded:!0,isClonable:!1,isRenamable:!1};function Vl(t){const{widgetType:e,widgetName:n,glContainer:s,description:i,children:o}=t,r=ne.getTitleFromContainer(s);return v("div",{className:"tab-tooltip-container",children:[v("div",{className:"row flex-nowrap align-items-start",children:[h("span",{className:"tab-tooltip-title",children:v("b",{children:[e," Name "]})}),h("span",{className:"tab-tooltip-name",children:n}),h(bl,{className:"tab-tooltip-copy",tooltip:"Copy name",copy:n})]}),n!==r&&v("div",{className:"row",children:[h("span",{className:"tab-tooltip-title",children:h("b",{children:"Display Name"})}),h("span",{className:"tab-tooltip-name",children:r})]}),i&&h("div",{className:"row",children:h("span",{className:"tab-tooltip-description",children:i})}),o]})}Vl.propTypes={glContainer:kd.Container.isRequired,widgetType:R.exports.string,widgetName:R.exports.string,description:R.exports.string,children:R.exports.node};Vl.defaultProps={widgetType:"",widgetName:"",description:null,children:null};class Ul extends S.exports.PureComponent{constructor(e){super(e),this.getCachedRenderTabTooltip=pe((n,s,i,o,r)=>n?()=>h(Vl,{glContainer:s,widgetType:i,widgetName:o,description:r}):null),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleCopyName=this.handleCopyName.bind(this),this.state={isClientDisconnected:!1,isPanelDisconnected:!1,isWidgetDisconnected:!1,isWaitingForReconnect:!1,isPanelInactive:!1}}handleCopyName(){const{widgetName:e}=this.props;ji(e)}getErrorMessage(){const{errorMessage:e}=this.props,{isClientDisconnected:n,isPanelDisconnected:s,isWidgetDisconnected:i,isWaitingForReconnect:o}=this.state;if(e)return`${e}`;if(n&&s&&o)return`Disconnected from server.
37
37
  Check your internet connection.`;if(n&&s)return"Disconnected from server.";if(s){const{widgetName:r,widgetType:l}=this.props;return`Variable "${r}" not set.
38
- ${l} does not exist yet.`}if(i){const{widgetName:r}=this.props;return`${r} is unavailable.`}}handleSessionClosed(...e){const{onSessionClose:n}=this.props;this.setState({isPanelDisconnected:!0,isWaitingForReconnect:!1}),n(...e)}handleSessionOpened(...e){const{onSessionOpen:n}=this.props;n(...e)}render(){const{children:e,className:n,componentPanel:s,isLoaded:i,isLoading:o,glContainer:r,glEventHub:l,isDisconnected:a,isClonable:d,isRenamable:c,showTabTooltip:u,renderTabTooltip:m,widgetType:p,widgetName:g,description:f,onClearAllFilters:b,onHide:C,onFocus:w,onBlur:T,onResize:y,onShow:E,onTabBlur:I,onTabFocus:D,onTabClicked:F}=this.props,{isPanelDisconnected:x,isWidgetDisconnected:U,isPanelInactive:B}=this.state,_=this.getErrorMessage(),H=m!=null?m:this.getCachedRenderTabTooltip(u,r,p,g,f),A=[{title:`Copy ${p} Name`,group:oe.groups.medium,order:20,action:this.handleCopyName}];return v(jn,{className:W(n,{disconnected:x||U||a,inactive:B}),componentPanel:s,glContainer:r,glEventHub:l,onClearAllFilters:b,onHide:C,onFocus:w,onBlur:T,onResize:y,onShow:E,onSessionClose:this.handleSessionClosed,onSessionOpen:this.handleSessionOpened,onTabBlur:I,onTabFocus:D,onTabClicked:F,renderTabTooltip:H,errorMessage:_,isLoaded:i,isLoading:o,isClonable:d,isRenamable:c,additionalActions:A,children:[e,B&&h("div",{className:"fill-parent-absolute"})]})}}Ul.defaultProps={className:"",errorMessage:null,isClonable:!0,isDisconnected:!1,isLoading:!1,isLoaded:!0,isRenamable:!0,showTabTooltip:!0,widgetName:"Widget",widgetType:"Widget",renderTabTooltip:null,description:"",onFocus:()=>{},onBlur:()=>{},onHide:()=>{},onClearAllFilters:()=>{},onResize:()=>{},onSessionClose:()=>{},onSessionOpen:()=>{},onShow:()=>{},onTabBlur:()=>{},onTabFocus:()=>{},onTabClicked:()=>{}};const hn=Object.freeze({DEFAULT:"DEFAULT",LINKER:"LINKER"}),aE="SET_SESSION_WRAPPER",dE=Hs(aE,null),cE={sessionWrapper:dE},hE=new Map,Bl=Object.freeze([]),Fp=(t,e)=>{var n;return(n=jt(t,e).columns)!=null?n:Bl},uE=(t,e)=>{var n;return(n=jt(t,e).filterSets)!=null?n:Bl},Xd=(t,e)=>{var n;return(n=jt(t,e).filters)!=null?n:Bl},jd=(t,e)=>{var n;return(n=jt(t,e).tableMap)!=null?n:hE},Qd=(t,e)=>jt(t,e).isolatedLinkerPanelId,oo=(t,e)=>{var n;return(n=jt(t,e).links)!=null?n:Bl},Zd=(t,e)=>jt(t,e).columnSelectionValidator,mE=(t,e)=>jt(t,e).connection,gi=(t,e)=>jt(t,e).sessionWrapper,pE=(t,e)=>n=>n(Xn(t,{connection:e})),gE=(t,e)=>n=>n(Xn(t,{sessionWrapper:e})),Jd=(t,e)=>n=>n(Xn(t,{links:e})),fE=(t,e)=>(n,s)=>{const i=oo(s(),t),o=e.filter(r=>i.findIndex(l=>ht(l.start,r.start)&&ht(l.end,r.end))<0);return n(Jd(t,i.concat(o)))},CE=(t,e)=>(n,s)=>{const o=oo(s(),t).filter(r=>!e.includes(r.id));return n(Jd(t,o))},xp=(t,e)=>n=>n(Xn(t,{isolatedLinkerPanelId:e})),bE=(t,e)=>n=>n(Xn(t,{columnSelectionValidator:e})),SE=(t,e)=>n=>n(Xn(t,{consoleSettings:e})),wE=(t,e)=>n=>n(Xn(t,{filterSets:e}));Object.entries(cE).map(([t,e])=>eo.register(t,e));function _p({columnMap:t,inputFilterMap:e,linkedColumnMap:n,onAdd:s,onOpenLinker:i,waitingFilterMap:o,waitingInputMap:r}){const l=S.exports.useMemo(()=>{const p=Array.from(r.keys()),g=p.find(C=>e.get(C)!=null),f=p.find(C=>n.get(C)!=null),b=sn.join(p.map(C=>`"${C}"`));return g!=null&&g&&f!=null&&f?`Use a filter control or linked table to set a value for ${b}`:g!=null&&g?`Set a filter control value for ${b}`:`Double click a row in a linked table to set a value for ${b}`},[e,n,r]),a=S.exports.useMemo(()=>Array.from(t.values()),[t]),d=S.exports.useCallback(p=>{p.stopPropagation(),p.preventDefault(),s(Array.from(o.values()))},[s,o]),c=S.exports.useCallback(p=>{p.stopPropagation(),p.preventDefault(),i()},[i]),u=o.size>0,m=!u&&r.size>0;return h("div",{className:"chart-panel-overlay chart-filter-overlay",children:v("div",{className:W("chart-panel-overlay-content chart-filter-overlay-content",{"chart-filter-waiting-filter":u},{"chart-filter-waiting-input":m}),children:[u&&v(ye,{children:[h("div",{className:"info-message",children:"This plot requires a filter control to be added to the layout or a table link to be created on the following columns:"}),h("div",{className:"waiting-filter-list",children:a.map(p=>{const g=o.has(p.name),f=g?cs:ad;return v("div",{className:W("waiting-filter-item",{"is-invalid":g}),children:[h(j,{icon:f}),p.name]},p.name)})}),v("div",{children:[h(Ao,{onClick:d,className:"btn-primary",children:"Add Input Filters"}),h(Ao,{onClick:c,className:"btn-primary",children:"Open Linker Tool"})]})]}),m&&v(ye,{children:[h("div",{className:"info-message",children:"Waiting for User Input"}),h("div",{className:"",children:l})]})]})})}_p.propTypes={columnMap:R.exports.instanceOf(Map).isRequired,inputFilterMap:R.exports.instanceOf(Map).isRequired,linkedColumnMap:R.exports.instanceOf(Map).isRequired,onAdd:R.exports.func.isRequired,onOpenLinker:R.exports.func.isRequired,waitingFilterMap:R.exports.instanceOf(Map).isRequired,waitingInputMap:R.exports.instanceOf(Map).isRequired};function Vo({columns:t,onColumnSelected:e,onMouseEnter:n,onMouseLeave:s}){return h("div",{className:"chart-panel-overlay chart-column-selector-overlay",children:v("div",{className:W("chart-panel-overlay-content"),children:[h("div",{className:"info-message",children:"This plot requires a filter control to be added to the layout or a table link to be created on the following columns:"}),h("div",{className:"waiting-column-select-list",children:t.map(i=>h(Tl,{className:W("btn-chart-column-selector",Vo.makeButtonClassName(i.name)),onClick:()=>e(i.name),onMouseEnter:()=>{n&&n(i)},onMouseLeave:s,disabled:!i.isValid,isLinked:i.isActive,children:i.name},i.name))})]})})}Vo.makeButtonClassName=t=>`btn-chart-column-selector-${t}`;Vo.defaultProps={onMouseEnter:()=>{},onMouseLeave:()=>{}};const tn=X.module("ChartPanel"),vE=150;function Hr(t){return t.settings!==void 0}function TE(t){return t.inputFilters!=null}function EE(t){return t.panelState!=null}class $l extends S.exports.Component{constructor(e){super(e),this.getWaitingInputMap=pe((r,l,a)=>{if(!r)return new Map;const d=new Map(l);return a.forEach((c,u)=>{d.delete(u)}),d}),this.getWaitingFilterMap=pe((r,l,a,d,c)=>{if(!r)return new Map;const u=new Map(l);return a.forEach((m,p)=>{u.delete(p)}),c.forEach((m,p)=>{u.delete(p)}),d.forEach((m,p)=>{u.delete(p)}),u}),this.getInputFilterColumnMap=pe((r,l)=>{const a=new Map;for(let d=0;d<l.length;d+=1){const c=l[d],{name:u,type:m}=c,p=r.get(u);p!=null&&p.type===m&&a.set(u,c)}return a}),this.getLinkedColumnMap=pe((r,l)=>{const a=new Map,d=ne.getIdFromPanel(this);for(let c=0;c<l.length;c+=1){const u=l[c];let m=null;if(u.start!=null&&u.start.panelId===d&&r.has(u.start.columnName)?m=u.start.columnName:u.end&&u.end.panelId===d&&r.has(u.end.columnName)&&(m=u.end.columnName),m!=null&&r.has(m)){const p=r.get(m);P(p),a.set(m,p)}}return a}),this.getSelectorColumns=pe((r,l,a)=>Array.from(r.values()).map(d=>({name:d.name,type:d.type,isValid:a?a(this,d):!1,isActive:l.has(d.name)}))),this.handleColumnSelected=this.handleColumnSelected.bind(this),this.handleColumnMouseEnter=this.handleColumnMouseEnter.bind(this),this.handleColumnMouseLeave=this.handleColumnMouseLeave.bind(this),this.handleDisconnect=this.handleDisconnect.bind(this),this.handleReconnect=this.handleReconnect.bind(this),this.handleFilterAdd=this.handleFilterAdd.bind(this),this.handleHide=this.handleHide.bind(this),this.handleError=this.handleError.bind(this),this.handleLoadError=this.handleLoadError.bind(this),this.handleLoadSuccess=this.handleLoadSuccess.bind(this),this.handleResize=this.handleResize.bind(this),this.handleSettingsChanged=this.handleSettingsChanged.bind(this),this.handleOpenLinker=this.handleOpenLinker.bind(this),this.handleShow=this.handleShow.bind(this),this.handleSourceColumnChange=this.handleSourceColumnChange.bind(this),this.handleSourceFilterChange=this.handleSourceFilterChange.bind(this),this.handleSourceSortChange=this.handleSourceSortChange.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleUpdate=this.handleUpdate.bind(this),this.updateModelFromSource=je(this.updateModelFromSource.bind(this),vE),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.panelContainer=Y.createRef(),this.chart=Y.createRef(),this.pending=new fs;const{metadata:n,panelState:s}=e,{filterValueMap:i=[],settings:o={}}=s!=null?s:{};this.state={settings:o,error:void 0,isActive:!1,isDisconnected:!1,isLoading:!1,isLoaded:!1,isLinked:n!=null&&Hr(n)&&n.settings.isLinked,filterMap:new Map(i),filterValueMap:new Map(i),model:void 0,columnMap:new Map,panelState:s}}componentDidMount(){this.isHidden()||(this.setState({isActive:!0}),this.initModel())}componentDidUpdate(e,n){const{inputFilters:s,source:i}=this.props,{columnMap:o,model:r,filterMap:l,filterValueMap:a,isLinked:d,settings:c}=this.state;!r||(o!==n.columnMap&&this.pruneFilterMaps(),s!==e.inputFilters&&this.updateChangedInputFilters(s,e.inputFilters),l!==n.filterMap?this.updateFilters():a!==n.filterValueMap&&this.updatePanelState(),c!==n.settings&&ah(r)&&(r.updateSettings(c),this.updatePanelState()),d!==n.isLinked?i&&(d?(this.startListeningToSource(i),this.updateModelFromSource()):this.stopListeningToSource(i)):d&&i!==e.source&&(e.source&&this.stopListeningToSource(e.source),i&&(this.startListeningToSource(i),this.updateModelFromSource())))}componentWillUnmount(){this.pending.cancel();const{source:e}=this.props;e&&this.stopListeningToSource(e)}initModel(){this.setState({isLoading:!0,isLoaded:!1,error:void 0});const{makeModel:e}=this.props;this.pending.add(e(),n=>{n.close()}).then(this.handleLoadSuccess,this.handleLoadError)}startListeningToSource(e){tn.debug("startListeningToSource",e),e.addEventListener(M.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleSourceColumnChange),e.addEventListener(M.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.addEventListener(M.Table.EVENT_SORTCHANGED,this.handleSourceSortChange)}stopListeningToSource(e){tn.debug("stopListeningToSource",e),e.removeEventListener(M.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleSourceColumnChange),e.removeEventListener(M.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.removeEventListener(M.Table.EVENT_SORTCHANGED,this.handleSourceSortChange)}loadModelIfNecessary(){const{isActive:e,isLoaded:n,isLoading:s}=this.state;e&&!n&&!s&&this.initModel()}isHidden(){const{glContainer:e}=this.props,{isHidden:n}=e;return n}handleColumnSelected(e){const{glEventHub:n}=this.props,{columnMap:s}=this.state;n.emit(Ki.COLUMN_SELECTED,this,s.get(e))}handleColumnMouseEnter({type:e,name:n}){const{columnSelectionValidator:s}=this.props;tn.debug("handleColumnMouseEnter",s,e,n),s&&s(this,{type:e,name:n})}handleColumnMouseLeave(){const{columnSelectionValidator:e}=this.props;tn.debug("handleColumnMouseLeave",e),e&&e(this,void 0)}handleDisconnect(){this.setState({error:new Error("Figure disconnected"),isDisconnected:!0})}handleFilterAdd(e){for(let n=0;n<e.length;n+=1)this.openInputFilter(e[n])}handleOpenLinker(){const{localDashboardId:e,setActiveTool:n,setDashboardIsolatedLinkerPanelId:s}=this.props;s(e,void 0),n(hn.LINKER)}handleReconnect(){this.setState({isDisconnected:!1,error:void 0}),this.sendColumnChange(),this.updateColumnFilters()}handleLoadSuccess(e){tn.debug("handleLoadSuccess");const{model:n}=this.state;this.setState({model:e,isLoaded:!0},()=>{const{inputFilters:s,source:i}=this.props,{filterMap:o,isLinked:r}=this.state;e!==n&&(this.sendColumnChange(),this.updateColumnFilters(),this.updateInputFilters(s,o.size>0||e.isFilterRequired()),i&&r&&(this.startListeningToSource(i),this.updateModelFromSource()))})}handleLoadError(e){Te.isCanceled(e)||(tn.error("handleLoadError",e),this.setState({error:e,isLoading:!1}))}handleSourceColumnChange(){this.updateModelFromSource()}handleSourceFilterChange(){this.updateModelFromSource()}handleSourceSortChange(){this.updateModelFromSource()}updateModelFromSource(){const{metadata:e,source:n}=this.props,{isLinked:s,model:i}=this.state;if(!s||!i||!n){tn.debug2("updateModelFromSource ignoring",s,i,n);return}if(this.pending.cancel(),Hr(e)){const{settings:o}=e;this.pending.add(M.plot.Figure.create(xe.makeFigureSettings(o,n))).then(r=>{ah(i)&&i.setFigure(r)}).catch(this.handleLoadError)}this.updatePanelState()}updatePanelState(){const{sourcePanel:e}=this.props,{panelState:n,filterValueMap:s,settings:i}=this.state;let{tableSettings:o}=n!=null?n:{};if(e&&TE(e.props)&&EE(e.state)){const{inputFilters:r}=e.props,{panelState:l}=e.state;l!=null&&(o=te.extractTableSettings(l,r))}this.setState({panelState:{settings:i,tableSettings:o,filterValueMap:Array.from(s)}})}handleError(){this.setState({isLoading:!1})}handleResize(){this.updateChart()}handleSettingsChanged(e){this.setState(({settings:n})=>{const s={...n,...e};return tn.debug("Updated settings",s),{settings:s}})}handleHide(){this.setActive(!1)}handleShow(){this.setActive(!0)}handleTabBlur(){this.setActive(!1)}handleTabFocus(){const e=this.isHidden();this.setActive(!e)}handleUpdate(){this.setState({isLoading:!1})}handleClearAllFilters(){this.setState({filterValueMap:new Map,filterMap:new Map}),this.updatePanelState()}openInputFilter(e){const{glEventHub:n}=this.props,{name:s,type:i}=e;n.emit(Pe.OPEN_INPUT,{title:`${s} Filter`,panelState:{name:s,type:i,isValueShown:!0},createNewStack:!0,focusElement:"input"})}setActive(e){this.setState({isActive:e},()=>{e&&(this.loadModelIfNecessary(),this.updateChart())})}sendColumnChange(){const{model:e}=this.state;if(!e)return;const{glEventHub:n}=this.props;n.emit(Pe.COLUMNS_CHANGED,this,Array.from(e.getFilterColumnMap().values()))}getCoordinateForColumn(e){var l;const n=Vo.makeButtonClassName(e);if(!this.panelContainer.current)return null;const s=this.panelContainer.current.querySelector(`.${n}`),i=(l=s==null?void 0:s.getBoundingClientRect())!=null?l:null;if(i==null||i.width<=0||i.height<=0)return null;const o=i.left+i.width/2,r=i.bottom;return[o,r]}setFilterMap(e){tn.debug("setFilterMap",e),this.setState(n=>{const{columnMap:s,filterMap:i}=n;let o=null;const r=new Map(n.filterValueMap);return e.forEach(({columnType:l,value:a},d)=>{const c=s.get(d);c==null||c.type!==l||(r.set(d,a),i.get(d)!==a&&(o===null&&(o=new Map(i)),o.set(d,a)))}),{filterValueMap:r,filterMap:o!=null?o:i}})}unsetFilterValue(e){this.setState(n=>{var a;const{inputFilters:s}=this.props,{columnMap:i}=n;let{filterMap:o,filterValueMap:r}=n;if(!r.has(e))return null;r=new Map(n.filterValueMap),r.delete(e);const l=this.getInputFilterColumnMap(i,s);if(l.has(e)){const d=o.get(e),c=(a=l.get(e))==null?void 0:a.value;c!=null&&d!==c&&(o=new Map(n.filterMap),c.length>0?o.set(e,c):o.delete(e))}else o=new Map(n.filterMap),o.delete(e);return{filterMap:o,filterValueMap:r}})}updateChangedInputFilters(e,n){const s=n.filter(o=>e.find(r=>r.name===o.name&&r.type===o.type)===void 0);s.length>0&&this.deleteInputFilters(s);const i=e.filter(o=>!n.includes(o));i.length>0&&this.updateInputFilters(i)}updateInputFilters(e,n=!1){this.setState(s=>{const{columnMap:i}=s,o=new Map(s.filterValueMap),r=new Map(s.filterMap),l=n?{filterMap:r,filterValueMap:o}:{};for(let a=0;a<e.length;a+=1){const{name:d,type:c,value:u}=e[a],m=i.get(d);m!=null&&m.type===c&&(u!=null&&r.get(d)!==u&&(u===""?r.delete(d):r.set(d,u),l.filterMap=r),o.has(d)&&(o.delete(d),l.filterValueMap=o))}return tn.debug("updateInputFilters",l),l})}deleteInputFilters(e,n=!1){this.setState(s=>{const{columnMap:i,filterValueMap:o}=s,r=new Map(s.filterMap);let l=n;for(let a=0;a<e.length;a+=1){const{name:d,type:c}=e[a],u=i.get(d);if(u!=null&&u.type===c&&r.has(d)){const m=r.get(d);if(o.has(d)){const p=o.get(d);p!==m&&p!=null&&(l=!0,r.set(d,p))}else l=!0,r.delete(d)}}return tn.debug("deleteInputFilters",l),l?{filterMap:r}:null})}updateColumnFilters(){this.setState(({model:e})=>e?{columnMap:e.getFilterColumnMap()}:null)}updateFilters(){const{columnMap:e,filterMap:n,model:s}=this.state;P(s);const i=this.getWaitingInputMap(s.isFilterRequired(),e,n);if(s.setFilter(n),n.size>0&&i.size===0){const o=s.getDefaultTitle(),r=sn.join(Array.from(n.entries()).map(([l,a])=>`${l}: ${a}`));o?s.setTitle(`${o}<br><span style="font-size: smaller">${r}</span>`):s.setTitle(r),tn.debug2("updateFilters filters set",n),this.setState({isLoading:!0})}else tn.debug2("updateFilters waiting on inputs",i),s.setTitle(s.getDefaultTitle()),this.setState({isLoading:!1});this.updatePanelState()}pruneFilterMaps(){this.setState(e=>{const{columnMap:n}=e,s=new Map(e.filterMap),i=new Map(e.filterValueMap),o={};return e.filterValueMap.forEach((r,l)=>{n.has(l)||(i.delete(l),o.filterValueMap=i)}),e.filterMap.forEach((r,l)=>{n.has(l)||(s.delete(l),o.filterMap=s)}),o})}updateChart(){this.chart.current&&this.chart.current.updateDimensions()}render(){const{columnSelectionValidator:e,glContainer:n,glEventHub:s,inputFilters:i,isLinkerActive:o,links:r,metadata:l,settings:a}=this.props,{columnMap:d,filterMap:c,error:u,model:m,isActive:p,isDisconnected:g,isLoaded:f,isLoading:b}=this.state;let C;Hr(l)?C=l.table:C=l.figure;const w=this.getInputFilterColumnMap(d,i),T=this.getLinkedColumnMap(d,r),y=m!=null?this.getWaitingInputMap(m.isFilterRequired(),d,c):new Map,E=m!=null?this.getWaitingFilterMap(m.isFilterRequired(),d,c,T,w):new Map,I=u!=null?`Unable to open chart. ${u}`:void 0,D=y.size>0,F=d.size>0&&o;return h(Ul,{className:W("iris-chart-panel",{"input-required":D}),componentPanel:this,glContainer:n,glEventHub:s,onHide:this.handleHide,onClearAllFilters:this.handleClearAllFilters,onResize:this.handleResize,onShow:this.handleShow,onTabBlur:this.handleTabBlur,onTabFocus:this.handleTabFocus,errorMessage:I,isDisconnected:g,isLoading:b,isLoaded:f,widgetName:C,widgetType:"Chart",children:v("div",{ref:this.panelContainer,className:"chart-panel-container h-100 w-100",children:[h("div",{className:"chart-container h-100 w-100",children:f&&m&&h(mm,{isActive:p,model:m,settings:a,ref:this.chart,onDisconnect:this.handleDisconnect,onReconnect:this.handleReconnect,onUpdate:this.handleUpdate,onError:this.handleError,onSettingsChanged:this.handleSettingsChanged})}),h(ut,{in:D&&!F&&!b,timeout:yt.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:h(_p,{inputFilterMap:w,linkedColumnMap:T,onAdd:this.handleFilterAdd,onOpenLinker:this.handleOpenLinker,columnMap:d,waitingFilterMap:E,waitingInputMap:y})}),h(ut,{in:F,timeout:yt.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:h(Vo,{columns:this.getSelectorColumns(d,T,e),onColumnSelected:this.handleColumnSelected,onMouseEnter:this.handleColumnMouseEnter,onMouseLeave:this.handleColumnMouseLeave})})]})})}}$l.defaultProps={columnSelectionValidator:null,isLinkerActive:!1,source:null,sourcePanel:null,panelState:null,settings:{}};$l.displayName="ChartPanel";$l.COMPONENT="ChartPanel";const yE=(t,e)=>{const{localDashboardId:n,metadata:s}=e;let i;s!=null&&(i=s.sourcePanelId);const o=jd(t,n),r=jm(t,n),l=Nl(t),a=Qd(t,n),d=l===hn.LINKER&&a===void 0;return{columnSelectionValidator:Zd(t,n),isLinkerActive:d,inputFilters:Xd(t,n),links:oo(t,n),source:i!=null?o.get(i):void 0,sourcePanel:i!=null?r.get(i):void 0,settings:Ft(t)}},Bi=Nt(yE,{setActiveTool:Fl,setDashboardIsolatedLinkerPanelId:xp},null,{forwardRef:!0})($l);const Mr=X.module("CommandHistoryPanel"),kp=class extends S.exports.Component{constructor(t){super(t),this.handleFocusHistory=this.handleFocusHistory.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleSendToConsole=this.handleSendToConsole.bind(this),this.handleSendToNotebook=this.handleSendToNotebook.bind(this),this.container=Y.createRef(),this.pending=new fs;const{session:e,sessionId:n,language:s}=t;this.state={panelState:{},session:e,sessionId:n,language:s,contextActions:[{action:this.handleFocusHistory,shortcut:Ut.COMMAND_HISTORY.FOCUS_HISTORY}]}}static handleError(t){Mr.error(t)}componentDidMount(){const{glEventHub:t,session:e}=this.props;t.on(Ct.FOCUS_HISTORY,this.handleFocusHistory),e!=null&&this.loadTable()}componentWillUnmount(){const{glEventHub:t}=this.props;t.off(Ct.FOCUS_HISTORY,this.handleFocusHistory),this.pending.cancel()}handleFocusHistory(){this.container.current&&this.container.current.focus()}handleShow(){var t;(t=this.container.current)==null||t.restoreScrollPosition()}handleSessionOpened(t,{language:e,sessionId:n}){this.setState({session:t,sessionId:n,language:e},()=>{this.loadTable()})}handleSessionClosed(){this.pending.cancel(),this.setState({session:void 0,language:void 0,table:void 0})}handleSendToNotebook(t,e=!1){const{session:n,language:s}=this.state;if(Mr.debug("handleSendToNotebook",n,t),!n){Mr.error("Session is not connected.");return}const{glEventHub:i}=this.props;i.emit(e?He.CREATE_NOTEBOOK:He.SEND_TO_NOTEBOOK,n,s,t)}handleSendToConsole(t,e=!0,n=!1){Mr.debug("handleSendToConsole",t);const{glEventHub:s}=this.props;s.emit(Ct.SEND_COMMAND,t,e,n)}loadTable(){const{commandHistoryStorage:t}=this.props,{language:e,sessionId:n}=this.state;P(e),P(n),this.pending.add(t.getTable(e,n,Date.now()),s=>s.close()).then(s=>{this.setState({table:s})}).catch(kp.handleError)}render(){const{glContainer:t,glEventHub:e,commandHistoryStorage:n}=this.props,{language:s,contextActions:i,table:o}=this.state;return v(jn,{className:"command-history-pane",componentPanel:this,glContainer:t,glEventHub:e,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onShow:this.handleShow,children:[!o&&h("div",{className:"command-history-disconnected-message",children:"Waiting for console connection"}),o&&s!=null&&v(ye,{children:[h(Rl,{ref:this.container,language:s,sendToNotebook:this.handleSendToNotebook,sendToConsole:this.handleSendToConsole,table:o,commandHistoryStorage:n}),h(oe,{actions:i})]})]})}};let ec=kp;ec.COMPONENT="CommandHistoryPanel";ec.TITLE="Command History";const IE=(t,e)=>{const n=fm(t),s=gi(t,e.localDashboardId),{session:i,config:o}=s!=null?s:{},{type:r,id:l}=o!=null?o:{};return{commandHistoryStorage:n,language:r,session:i,sessionId:l}},il=Nt(IE,null,null,{forwardRef:!0})(ec);const Nr=X.module("ConsolePanel"),RE=500,DE=Object.freeze({consoleSettings:{},itemIds:[]});class tc extends S.exports.PureComponent{constructor(e){super(e),this.savePanelState=je(()=>{const{consoleSettings:r,itemIds:l}=this.state,a={consoleSettings:r,itemIds:[...l]};Nr.debug("Saving panel state",a),this.setState({panelState:a})},RE),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=Y.createRef();const{panelState:n}=e,s={...DE,...n||{}},{consoleSettings:i,itemIds:o}=s;this.state={consoleSettings:i,itemIds:new Map(o),objectMap:new Map,error:void 0,panelState:s}}componentDidMount(){const{glEventHub:e}=this.props;this.closeDisconnectedPanels(),e.on(Ne.MOUNT,this.handlePanelMount),this.subscribeToFieldUpdates()}componentDidUpdate(e,n){const{consoleSettings:s,itemIds:i}=this.state;(n.consoleSettings!==s||n.itemIds!==i)&&this.savePanelState()}componentWillUnmount(){var n;const{glEventHub:e}=this.props;this.savePanelState.flush(),e.off(Ne.MOUNT,this.handlePanelMount),(n=this.objectSubscriptionCleanup)==null||n.call(this)}subscribeToFieldUpdates(){const{sessionWrapper:e}=this.props,{session:n}=e;this.objectSubscriptionCleanup=n.subscribeToFieldUpdates(s=>{Nr.debug("Got updates",s),this.setState(({objectMap:i})=>{const{updated:o,created:r,removed:l}=s,a=[...o,...l],d=new Map(i);return a.forEach(u=>{const{title:m}=u;m!==void 0&&d.delete(m)}),[...o,...r].forEach(u=>{u.title!==void 0&&d.set(u.title,u)}),{objectMap:d}})})}setItemId(e,n){this.setState(({itemIds:s})=>{const i=new Map(s);return i.set(e,n),{itemIds:i}})}getItemId(e,n=!0){const{itemIds:s}=this.state;let i=s.get(e);return i==null&&n&&(i=ze.generate(),this.setItemId(e,i)),i}handleTabFocus(){var e;(e=this.consoleRef.current)==null||e.focus()}handlePanelMount(e){var o,r,l;const{itemIds:n}=this.state,s=(o=e==null?void 0:e.props)==null?void 0:o.id,i=(l=(r=e==null?void 0:e.props)==null?void 0:r.metadata)==null?void 0:l.sourcePanelId;s&&i&&new Set(n.values()).has(i)&&this.setItemId(s,s)}handleFocusCommandHistory(){const{glEventHub:e}=this.props;e.emit(Ct.FOCUS_HISTORY)}handleResize(){this.updateDimensions()}handleShow(){this.updateDimensions()}handleOpenObject(e){const{sessionWrapper:n}=this.props,{session:s}=n;this.openWidget(e,s)}handleCloseObject(e){const{title:n}=e;if(n!==void 0){const s=this.getItemId(n,!1),{glEventHub:i}=this.props;i.emit(Ne.CLOSE,s)}}handleSettingsChange(e){const{glEventHub:n}=this.props;Nr.debug("handleSettingsChange",e),this.setState({consoleSettings:e}),n.emit(Ct.SETTINGS_CHANGED,e)}openWidget(e,n){const{glEventHub:s}=this.props,{title:i}=e;P(i);const o=this.getItemId(i),r={fetch:()=>n.getObject(e),panelId:o,widget:e};Nr.debug("openWidget",r),s.emit(Ne.OPEN,r)}addCommand(e,n=!0,s=!1){var i;(i=this.consoleRef.current)==null||i.addCommand(e,n,s)}closeDisconnectedPanels(e=!1){const{consoleSettings:n,itemIds:s}=this.state,{isClosePanelsOnDisconnectEnabled:i=!0}=n;if(!i&&!e)return;const o=[...s.values()],{glEventHub:r}=this.props;o.forEach(l=>{r.emit(Ne.CLOSE,l)}),this.setState({itemIds:new Map})}updateDimensions(){var e;(e=this.consoleRef.current)==null||e.updateDimensions()}render(){const{commandHistoryStorage:e,glContainer:n,glEventHub:s,sessionWrapper:i,timeZone:o,unzip:r}=this.props,{consoleSettings:l,error:a,objectMap:d}=this.state,{config:c,session:u,connection:m}=i,{id:p,type:g}=c;return h(jn,{componentPanel:this,glContainer:n,glEventHub:s,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleTabFocus,errorMessage:a!=null?`${a}`:void 0,children:u!=null&&h(Sd,{ref:this.consoleRef,settings:l,session:u,focusCommandHistory:this.handleFocusCommandHistory,openObject:this.handleOpenObject,closeObject:this.handleCloseObject,commandHistoryStorage:e,onSettingsChange:this.handleSettingsChange,language:g,statusBarChildren:v(ye,{children:[h("div",{children:"\xA0"}),h("div",{children:Ku.LANGUAGE_MAP.get(g)}),h("div",{children:"\xA0"}),h("div",{children:h(CS,{connection:m,defaultUpdateInterval:10*1e3,hoverUpdateInterval:3*1e3,monitorDuration:10*60*1e3})}),h("div",{children:"\xA0"})]}),scope:p,timeZone:o,objectMap:d,unzip:r})})}}tc.COMPONENT="ConsolePanel";tc.TITLE="Console";const ME=(t,e)=>({commandHistoryStorage:fm(t),sessionWrapper:gi(t,e.localDashboardId),timeZone:Ml(t)}),Li=Nt(ME,null,null,{forwardRef:!0})(tc);const bo=X.module("DropdownFilter"),NE=150,Vr=class extends S.exports.Component{constructor(t){super(t),this.getCompatibleColumns=pe((i,o)=>i!=null?o.filter(({type:r})=>r!==void 0&&L.isCompatibleType(r,i.columnType)):[]),this.getColumnOptions=pe((i,o)=>{let r=-1;const l=[];return l.push(h("option",{value:"-1",children:"Select a column"},"placeholder")),i.forEach((a,d)=>{l.push(h("option",{value:d,children:this.getItemLabel(i,d)},`${a.name}/${a.type}`)),o!==null&&a.name===o.name&&a.type===o.type&&(r=d)}),[l,r]}),this.getSelectedOptionIndex=pe((i,o)=>i.indexOf(o)),this.getValueOptions=pe(i=>[h("option",{value:"-1",children:Vr.PLACEHOLDER},"-1"),...i.map((o,r)=>h("option",{value:r,children:o},`${r}/${o}`))]),this.getItemLabel=ve((i,o)=>{const{name:r,type:l}=i[o];if(o>0&&i[o-1].name===r||o<i.length-1&&i[o+1].name===r){const a=l.substring(l.lastIndexOf(".")+1);return`${r} (${a})`}return r}),this.sendUpdate=je(()=>{const{onChange:i}=this.props,{column:o,value:r,isValueShown:l}=this.state;i({column:o,isValueShown:l,value:r!=null?r:void 0})},NE),this.handleColumnChange=this.handleColumnChange.bind(this),this.handleSettingsCancel=this.handleSettingsCancel.bind(this),this.handleSettingsClick=this.handleSettingsClick.bind(this),this.handleSettingsSave=this.handleSettingsSave.bind(this),this.handleBackgroundClick=this.handleBackgroundClick.bind(this),this.handleDropdownKeyPress=this.handleDropdownKeyPress.bind(this),this.handleValueChange=this.handleValueChange.bind(this),this.dropdownRef=Y.createRef();const{column:e,isValueShown:n,value:s}=t;this.state={column:e,selectedColumn:e,disableCancel:!n,isValueShown:n,value:s}}componentDidUpdate(t,e){const{source:n,values:s,isLoaded:i}=this.props,{column:o,value:r,isValueShown:l}=this.state;i&&(n!==t.source&&this.sourceUpdated(),s!==t.values&&r!==""&&!s.includes(r)&&this.resetValue(),l!==e.isValueShown&&l&&this.focusInput(),(o!==e.column||r!==e.value||l!==e.isValueShown)&&this.sendUpdate())}componentWillUnmount(){this.sendUpdate.flush()}handleColumnChange(t){const{value:e}=t.target;if(bo.debug2("handleColumnChange",e),e!=null&&parseInt(e,10)<0){this.setState({selectedColumn:null});return}const{columns:n,source:s}=this.props,i=this.getCompatibleColumns(s,n);this.setState({selectedColumn:i[parseInt(e,10)]})}handleDropdownKeyPress(t){t.key==="Enter"&&(t.preventDefault(),t.stopPropagation(),bo.debug2("handleDropdownKeyPress"),this.sendUpdate(),this.sendUpdate.flush())}handleValueChange(t){const{value:e}=t.target,n=parseInt(e,10);let s="";const{values:i}=this.props;if(n===-1)bo.debug2("Selected default item");else if(n>=0&&n<i.length)s=i[n];else{bo.error("Invalid index",n,i);return}bo.debug2("handleValueChange",s),this.setState({value:s})}handleSettingsCancel(){this.setState(({column:t})=>({selectedColumn:t,isValueShown:!0}))}handleSettingsSave(){this.setState(({column:t,selectedColumn:e,value:n})=>({column:e,value:t===e?n:"",isValueShown:!0,disableCancel:!1}))}handleSettingsClick(t){t.stopPropagation(),this.showSettings()}handleBackgroundClick(t){t.target!==this.dropdownRef.current&&this.focusInput()}handleMouseEnter(){const{onSourceMouseEnter:t}=this.props;t()}handleMouseLeave(){const{onSourceMouseLeave:t}=this.props;t()}sourceUpdated(){this.setState({column:null,selectedColumn:null,isValueShown:!1,disableCancel:!0,value:""})}showSettings(){const{column:t}=this.state;this.setState({selectedColumn:t,isValueShown:!1})}focusInput(){this.dropdownRef.current!==null&&this.dropdownRef.current.focus()}resetValue(){this.setState({value:""})}clearFilter(){this.resetValue()}setFilterState({name:t,type:e,value:n,isValueShown:s}){const i=t!=null&&e!=null?{name:t,type:e}:null;this.setState({column:i,value:n,isValueShown:s})}render(){var U;const{columns:t,disableLinking:e,isLinkerActive:n,isLoaded:s,source:i,onColumnSelected:o,onSourceMouseEnter:r,onSourceMouseLeave:l,values:a,settingsError:d}=this.props,{column:c,disableCancel:u,isValueShown:m,selectedColumn:p,value:g}=this.state,f=i===null,b=this.getCompatibleColumns(i,t),C=i!=null,w=(U=i==null?void 0:i.columnName)!=null?U:Vr.SOURCE_BUTTON_PLACEHOLDER,T=c!=null?`${c.name} Filter`:null,[y,E]=this.getColumnOptions(b,p),I=this.getValueOptions(a),D=this.getSelectedOptionIndex(a,g),F=!C||p==null;return v(rd,{className:"dropdown-filter fill-parent-absolute",isFlipped:m&&!n,children:[h("div",{className:"dropdown-filter-settings-card",children:v("div",{className:"dropdown-filter-card-content",children:[v("div",{className:"dropdown-filter-settings-grid",children:[h("label",{children:"Source Column"}),h(Tl,{isLinked:C,onClick:o,onMouseEnter:r,onMouseLeave:l,className:Vr.SOURCE_BUTTON_CLASS_NAME,disabled:e,children:w}),h("div",{className:"text-muted small",children:"Select a source column for the list by linking to a table."}),h("label",{children:"Filter Column"}),h("select",{value:E,className:"custom-select",onChange:this.handleColumnChange,disabled:f,children:y}),h("div",{className:"text-muted small",children:"Dropdown filter control will apply its filter to all columns matching this name in this dashboard."})]}),d&&h("div",{className:"error-message text-center",children:d}),C&&v("div",{className:"dropdown-filter-settings-buttons",children:[h(z,{kind:"secondary",type:"button",onClick:this.handleSettingsCancel,disabled:u||m||n,tooltip:n?"Cancel disabled while linker open":void 0,children:"Cancel"}),h(z,{kind:"primary",type:"button",className:"ml-2",onClick:this.handleSettingsSave,disabled:F||m||n,tooltip:n?"Save disabled while linker open":void 0,children:"Save"})]})]})}),h("div",{className:"dropdown-filter-value-card",onClick:this.handleBackgroundClick,children:s&&v(ye,{children:[h("div",{className:"dropdown-filter-column",children:h("div",{className:"dropdown-filter-column-title",children:T})}),v("div",{className:"dropdown-filter-card-content",children:[h("div",{className:"dropdown-filter-value-input d-flex flex-column justify-content-center",children:h("select",{className:"custom-select",value:D,ref:this.dropdownRef,onChange:this.handleValueChange,onKeyPress:this.handleDropdownKeyPress,children:I})}),d&&h("div",{className:"error-message mt-3 text-center",children:d})]}),h("div",{className:"dropdown-filter-menu",children:h(z,{kind:"ghost",className:"m-2 px-2",onClick:this.handleSettingsClick,icon:h(j,{icon:Go,transform:"grow-4"}),tooltip:"Dropdown Filter Settings"})})]})})]})}};let qi=Vr;qi.defaultProps={column:null,disableLinking:!1,isLinkerActive:!1,isLoaded:!1,isValueShown:!1,settingsError:null,source:null,value:"",values:[],onColumnSelected:()=>{},onSourceMouseEnter:()=>{},onSourceMouseLeave:()=>{}};qi.PLACEHOLDER="Select a value...";qi.SOURCE_BUTTON_CLASS_NAME="btn-dropdown-filter-selector";qi.SOURCE_BUTTON_PLACEHOLDER="Select a column";const nt=X.module("DropdownFilterPanel"),FE=250,ti=class extends S.exports.Component{constructor(t){super(t),this.getCachedValues=pe((d,{type:c,name:u},m)=>c!==void 0&&L.isDateType(c)?d.map(p=>ti.DATETIME_FORMATTER.format(p)):d.map(p=>p!=null&&c!=null?m.getFormattedString(p,c,u):null)),this.getCachedPanelLinks=pe((d,c)=>{const u=ne.getIdFromPanel(c);return nt.debug("getCachedPanelLinks",d,u),d.filter(m=>{var p;return((p=m.end)==null?void 0:p.panelId)===u})}),this.getCachedSource=pe(d=>{nt.debug("getCachedSource",d);let c;if(d.length>0){const[u]=d;c=u.start,d.length>1&&nt.error("Filter has more that one link",d)}return c}),this.getCachedSourceTable=pe((d,c)=>{var m;if(nt.debug("getCachedSourceTable",d,c),c==null)return null;const{panelId:u}=c;return(m=d.get(u))!=null?m:null}),this.getCachedSourceColumn=pe((d,c)=>{var u;return nt.debug("getCachedSourceColumn",d,c),d==null||c==null?null:(u=d.columns.find(({name:m,type:p})=>m===c.columnName&&p===c.columnType))!=null?u:null}),this.handleChange=je(this.handleChange.bind(this),FE),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=Y.createRef(),this.panelContainer=Y.createRef(),this.pending=new fs;const{panelState:e,settings:n}=t;this.columnFormats=hs.getColumnFormats(n);const{value:s="",isValueShown:i=!1,name:o,type:r,timestamp:l}=e!=null?e:{},a=o!=null&&r!=null?{name:o,type:r}:void 0;this.state={column:a,formatter:new un(this.columnFormats),valuesTable:void 0,valuesColumn:void 0,sourceSize:0,value:s,timestamp:l,values:[],isValueShown:i,wasFlipped:!1,skipUpdate:!1,panelState:e,isDisconnected:!1,isLoading:!1,isLoaded:!1,error:null}}componentDidMount(){this.updateValuesTable();const{column:t,value:e,timestamp:n}=this.state,s=this.getSourceTable();if(s!==null&&this.startListeningToSource(s),t!=null){const{name:i,type:o}=t;this.sendUpdate(i,o,e,n)}}componentDidUpdate(t,e){const{valuesTable:n}=this.state,{settings:s}=this.props,i=this.getSource(),o=this.getSourceTable(),r=this.getSource(t),l=this.getSourceTable(t);s!==t.settings&&s!==void 0&&this.updateFormatterSettings(s),n!==e.valuesTable&&e.valuesTable!=null&&(nt.debug("Table in state modified, closing the old table."),e.valuesTable.close()),(o!==l||i!==r)&&this.updateValuesTable(),o!==l&&(l!==null&&this.stopListeningToSource(l),o!==null&&this.startListeningToSource(o))}componentWillUnmount(){const{valuesTable:t}=this.state,e=this.getSourceTable();this.pending.cancel(),e!==null&&this.stopListeningToSource(e),this.cleanup&&this.cleanup(),t!=null&&t.close()}getCoordinateForColumn(){var i;if(this.panelContainer.current==null)return null;const t=this.panelContainer.current.querySelector(`.${qi.SOURCE_BUTTON_CLASS_NAME}`),e=(i=t==null?void 0:t.getBoundingClientRect())!=null?i:null;if(e==null||e.width<=0||e.height<=0)return null;const n=e.left+e.width/2,s=e.bottom;return[n,s]}getSettingsErrorMessage(){const{sourceSize:t}=this.state;if(t>ti.MAX_TABLE_SIZE)return`Table too large, must have fewer than ${ti.MAX_TABLE_SIZE} options.`}getPanelErrorMessage(){const{error:t}=this.state;return t!=null?`${t}`:void 0}getSource(t=this.props){const{dashboardLinks:e}=t,n=this.getCachedPanelLinks(e,this);return this.getCachedSource(n)}getSourceTable(t=this.props){const{panelTableMap:e}=t,n=this.getSource(t);return this.getCachedSourceTable(e,n)}getValuesColumn(t){const e=this.getSource();return this.getCachedSourceColumn(t,e)}startListeningToSource(t){nt.debug("startListeningToSource"),t.addEventListener(M.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),t.addEventListener(M.Table.EVENT_SORTCHANGED,this.handleSourceSortChange),t.addEventListener(M.Table.EVENT_SIZECHANGED,this.handleSourceSizeChange),t.addEventListener(M.Table.EVENT_DISCONNECT,this.handleDisconnect),t.addEventListener(M.Table.EVENT_RECONNECT,this.handleReconnect)}stopListeningToSource(t){nt.debug("stopListeningToSource"),t.removeEventListener(M.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),t.removeEventListener(M.Table.EVENT_SORTCHANGED,this.handleSourceSortChange),t.removeEventListener(M.Table.EVENT_SIZECHANGED,this.handleSourceSizeChange),t.removeEventListener(M.Table.EVENT_DISCONNECT,this.handleDisconnect),t.removeEventListener(M.Table.EVENT_RECONNECT,this.handleReconnect)}handleChange({column:t,isValueShown:e=!1,value:n}){const{name:s=void 0,type:i=void 0}=t!=null?t:{};let o=!0,r=Date.now();this.setState(({panelState:l,timestamp:a,wasFlipped:d,skipUpdate:c})=>{var m;const u=l!=null&&e!==l.isValueShown&&s===l.name&&i===l.type&&n===l.value;return o=(m=!c&&e&&(!u||!d))!=null?m:!1,o||(r=a),{panelState:{isValueShown:e,name:s,type:i,value:n,timestamp:r!=null?r:void 0},timestamp:r,wasFlipped:u,skipUpdate:!1}},()=>{o&&this.sendUpdate(s!=null?s:null,i,n,r)})}handleDisconnect(){this.setState({error:new Error("Table disconnected"),isDisconnected:!0,isLoading:!1})}handleReconnect(){this.setState({isDisconnected:!1,error:null})}handleSourceFilterChange(){this.applySourceFilters()}handleSourceSortChange(){this.applySourceSorts()}handleSourceSizeChange({detail:t}){this.setState({sourceSize:t})}handleColumnSelected(){nt.debug("handleColumnSelected");const{glEventHub:t}=this.props;t.emit(Pe.COLUMN_SELECTED,this,ti.SOURCE_COLUMN)}handleClearAllFilters(){var t,e;(e=(t=this.dropdownFilterRef)==null?void 0:t.current)==null||e.clearFilter()}setPanelState(t,e=!1){var n,s;if(this.getSource()==null){nt.debug("Ignore state update for unlinked filter",t);return}this.setState({skipUpdate:!e}),(s=(n=this.dropdownFilterRef)==null?void 0:n.current)==null||s.setFilterState(t)}sendUpdate(t,e,n,s){var l;const{glEventHub:i}=this.props,o=(l=this.getSource())==null?void 0:l.panelId,r=o===null?[]:[o];nt.debug("sendUpdate",{name:t,type:e,value:n,timestamp:s,excludePanelIds:r}),i.emit(Pe.FILTERS_CHANGED,this,{name:t,type:e,value:n!=null?n:"=null",timestamp:s,excludePanelIds:r})}updateValuesTable(){const t=this.getSource(),e=this.getSourceTable();if(nt.debug("updateValuesTable",t,e),this.setState({values:[],valuesTable:void 0,error:null}),t==null){nt.debug("Filter unlinked."),this.setState({isLoading:!1,isLoaded:!0,isValueShown:!1,sourceSize:0});return}this.setState({isLoading:!0}),e!=null&&(this.setState({isLoaded:!1,sourceSize:e.size}),this.pending.add(e.copy(),n=>n.close()).then(n=>{this.updateViewportListener(n),this.setState({valuesTable:n})}).catch(n=>{Te.isCanceled(n)||(nt.error(n),this.setState({isLoading:!1,error:n}))}))}applySourceSorts(){const{valuesTable:t}=this.state,e=this.getSourceTable();if(nt.debug("applySourceSorts",e==null?void 0:e.sort),t==null||e==null){nt.debug("Table not initialized");return}const n=[...e.sort];t.applySort(n),this.setViewport(t)}applySourceFilters(){const{valuesTable:t}=this.state,e=this.getSourceTable();if(nt.debug("applySourceFilters",e==null?void 0:e.filter),t==null||e==null){nt.debug("Table not initialized");return}const n=[...e.filter];t.applyFilter(n),this.setViewport(t)}updateViewportListener(t){if(nt.debug("updateViewportListener",t==null?void 0:t.size),this.cleanup&&this.cleanup(),t==null){this.cleanup=void 0;return}this.cleanup=t.addEventListener(M.Table.EVENT_UPDATED,this.handleValuesTableUpdate),this.setViewport(t)}setViewport(t){const e=this.getValuesColumn(t);if(!e){nt.error("values column is null");return}t.setViewport(0,ti.MAX_TABLE_SIZE-1,[e])}updateFormatterSettings(t){const e=hs.getColumnFormats(t);ht(this.columnFormats,e)||(this.columnFormats=e,this.setState({formatter:new un(e)}))}handleValuesTableUpdate({detail:t}){const{rows:e}=t,{valuesTable:n}=this.state;if(!n){nt.error("valuesTable is null");return}const s=this.getValuesColumn(n);if(!s){nt.error("Values column not found");return}const i=e.map(o=>o.get(s));this.setState({values:i,isLoading:!1,isLoaded:!0,valuesColumn:s})}handleSourceMouseEnter(){const{columnSelectionValidator:t}=this.props;!t||t(this,ti.SOURCE_COLUMN)}handleSourceMouseLeave(){const{columnSelectionValidator:t}=this.props;!t||t(this,void 0)}render(){const{columns:t,disableLinking:e,glContainer:n,glEventHub:s,isLinkerActive:i}=this.props,{column:o,formatter:r,isDisconnected:l,isValueShown:a,value:d,values:c,valuesColumn:u,isLoading:m,isLoaded:p}=this.state,g=this.getSource(),f=this.getSettingsErrorMessage(),b=this.getPanelErrorMessage(),C=p&&u!=null?this.getCachedValues(c,u,r):[];return h(Ul,{errorMessage:b,isLoading:m,isLoaded:p,isDisconnected:l,className:"iris-dropdown-filter-panel",componentPanel:this,glContainer:n,glEventHub:s,onClearAllFilters:this.handleClearAllFilters,widgetName:"Dropdown Filter",widgetType:"DropdownFilter",children:h("div",{ref:this.panelContainer,className:"dropdown-filter-container h-100 w-100 container",children:h(qi,{ref:this.dropdownFilterRef,column:o,columns:t,isValueShown:a,isLinkerActive:i,disableLinking:e,isLoaded:p,settingsError:f,source:g,value:d,values:C,onChange:this.handleChange,onColumnSelected:this.handleColumnSelected,onSourceMouseEnter:this.handleSourceMouseEnter,onSourceMouseLeave:this.handleSourceMouseLeave})})})}};let ro=ti;ro.displayName="DropdownFilterPanel";ro.COMPONENT="DropdownFilterPanel";ro.MAX_TABLE_SIZE=256;ro.DATETIME_FORMATTER=new dt({showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:"yyyy-MM-dd HH:mm:ss.SSSSSSSSS"});ro.SOURCE_COLUMN=Object.freeze({name:"FilterSource",type:null});const xE=(t,e)=>{const{localDashboardId:n}=e,s=ne.getIdFromPanel({props:e}),i=jd(t,n),o=oo(t,n),r=Nl(t),l=Qd(t,n),a=r===hn.LINKER&&(l===void 0||l===s),d=r===hn.LINKER&&l!==void 0&&l!==s;return{columns:Fp(t,n),columnSelectionValidator:Zd(t,n),isLinkerActive:a,disableLinking:d,settings:Ft(t),panelTableMap:i,dashboardLinks:o}},ci=Nt(xE,null,null,{forwardRef:!0})(ro);function qn(t){return t.type==="directory"}var Op=(t=>(t.GROOVY="text/x-groovy",t.PLAIN_TEXT="text/plain",t.PYTHON="text/x-python",t.PYTHON_COMPILED="application/x-python-code",t.SCALA="text/x-scala",t.UNKNOWN="",t))(Op||{});class ce{static fileExtensionToString(e=""){return e.length===0?"":`.${e}`}static getDepth(e){var s;if(!ce.hasPath(e))throw new Error(`Invalid path provided: ${e}`);return((s=e.match(/\//g))!=null?s:[]).length-1}static getExtension(e){var s;const n=this.getBaseName(e).split(".");return n.length>1&&(s=n.pop())!=null?s:""}static getBaseName(e){var n;return(n=e.split("/").pop())!=null?n:""}static getCopyFileName(e){const n=e.lastIndexOf(".");let s=null,i=null;n<0?i=e:(i=e.substring(0,n),s=e.substring(n+1));const o=i?`${i}-copy`:"Copy";return s!==null?`${o}.${s}`:o}static getMimeType(e){switch(this.getExtension(e).toLowerCase()){case"groovy":return"text/x-groovy";case"py":return"text/x-python";case"pyc":return"application/x-python-code";case"scala":return"text/x-scala";case"txt":return"text/plain";default:return""}}static getParent(e){if(!ce.hasPath(e))throw new Error(`Invalid name provided: ${e}`);const n=e.split("/");for(;n.pop()==="";);if(n.length===0)throw new Error(`No parent for path provided: ${e}`);return`${n.join("/")}/`}static getPath(e){if(!ce.hasPath(e))throw new Error(`Invalid filename provided: ${e}`);const n=e.split("/");return n.pop(),`${n.join("/")}/`}static hasPath(e){return e.startsWith("/")}static isPath(e){return e.startsWith("/")&&e.endsWith("/")}static makePath(e){return e.endsWith("/")?e:`${e}/`}static replaceExtension(e,n=""){const s=e.lastIndexOf("."),i=s>-1?e.substring(0,s):e,o=ce.fileExtensionToString(n);return`${i}${o}`}static validateName(e){var o,r;const n=[".",".."],s=/[\\/\0]/g,i=new Map([["\0","null"]]);if(!e)throw new Hi("Name cannot be empty");if(n.includes(e))throw new Hi(`"${e}" is a reserved name`);if(s.test(e))throw new Hi(`Invalid characters in name: "${(r=(o=e.match(s))==null?void 0:o.reduce((l,a)=>l.includes(a)?l:[...l,a],[]).map(l=>i.has(l)?i.get(l):l).join('", "'))!=null?r:""}"`)}static reducePaths(e){const n=e.filter(s=>ce.isPath(s));return e.filter(s=>!n.some(i=>s!==i&&s.startsWith(i)))}static removeRoot(e,n){if(e.length===0)return n;if(!n.startsWith(e))throw new Error(`Filename ${n} does not start with expected root ${e}`);return n.substring(e.length)}static addRoot(e,n){return`${e}${n}`}}const Lt=X.module("FileList"),Ga=t=>qn(t)?ce.makePath(t.filename):ce.getPath(t.filename),nc=26,_E=500,kh="item-list-scroll-pane",Ka=t=>{var I;const{children:e,draggedItems:n,isDragInProgress:s,isDropTargetValid:i,isSelected:o,item:r,itemIndex:l,dropTargetItem:a,onDragStart:d,onDragOver:c,onDragEnd:u,onDrop:m}=t,p=(I=n==null?void 0:n.some(D=>D.id===r.id))!=null?I:!1,g=Ga(r),f=s&&a?Ga(a):null,b=s&&i&&qn(r)&&f===g,C=s&&i&&f===g,w=s&&!i&&f===g,T=kE(r),y=ce.getDepth(r.filename),E=Array(y).fill(null).map((D,F)=>h("span",{className:"file-list-depth-line"},F));return v("div",{className:W("d-flex w-100 align-items-center","file-list-item",{"is-dragged":p,"is-exact-drop-target":b,"is-in-drop-target":C,"is-invalid-drop-target":w,"is-selected":o}),onDragStart:D=>d(l,D),onDragOver:D=>c(l,D),onDragEnd:D=>u(l,D),onDrop:D=>m(l,D),draggable:!0,role:"presentation","aria-label":r.basename,children:[E," ",h(j,{icon:T,className:"item-icon",fixedWidth:!0})," ",v("span",{className:"truncation-wrapper",children:[e!=null?e:r.basename,h($e,{options:{modifiers:{preventOverflow:{boundariesElement:"window"}},placement:"left"},children:e!=null?e:r.basename})]})]})};function kE(t){if(qn(t))return t.isExpanded?Rf:Df;switch(ce.getMimeType(t.basename)){case Op.PYTHON:return lC;default:return Tf}}function Oh(t,e){if(t.length===0||e==null)throw new Error("No items to move");const n=Ga(e);if(t.some(({filename:s})=>ce.getPath(s)===n))throw new Error("File already in the destination folder");if(t.some(s=>qn(s)&&n.startsWith(ce.makePath(s.filename))))throw new Error("Destination folder cannot be a child of a dragged folder");return{files:t,targetPath:n}}function OE(t){const{isMultiSelect:e=!1,table:n,onFocusChange:s=()=>{},onMove:i,onSelect:o,onSelectionChange:r=()=>{},renderItem:l=Ka,rowHeight:a=nc,overscanCount:d=bn.DEFAULT_OVERSCAN}=t,[c,u]=S.exports.useState(()=>({items:[],offset:0,itemCount:0})),[m,p]=S.exports.useState({top:0,bottom:0}),[g,f]=S.exports.useState(),[b,C]=S.exports.useState(),[w,T]=S.exports.useState(),[y,E]=S.exports.useState([]),I=S.exports.useRef(null),D=S.exports.useRef(null),F=S.exports.useCallback(ee=>{if(ee.length===0||c==null)return[];const ue=[];for(let Se=0;Se<ee.length;Se+=1){const De=ee[Se];for(let qe=De[0];qe<=De[1];qe+=1)qe>=c.offset&&qe<c.offset+c.items.length&&ue.push(c.items[qe-c.offset])}return ue},[c]),x=S.exports.useCallback(ee=>{const ue=F([[ee,ee]]);if(ue.length>0)return ue[0]},[F]),U=S.exports.useCallback(()=>{const ee=fn.count(y);if(ee===0)return null;if(ee===1){const ue=y[0][0],Se=x(ue);if(Se!=null)return Se.filename}return`${ee} items`},[x,y]),B=S.exports.useCallback(ee=>{var ue;if(!(!b||!g)){Lt.debug("dropItems",b,"to",ee);try{const{files:Se,targetPath:De}=Oh(b,g);i(Se,De),ee!=null&&(E([[ee,ee]]),(ue=I.current)==null||ue.focusItem(ee))}catch(Se){Lt.error("Unable to complete move",Se)}}},[b,g,i]),_=S.exports.useCallback((ee,ue)=>{const Se=c.items[ee-c.offset];Se!==void 0&&(Lt.debug("handleItemClick",Se),o(Se,ue),qn(Se)&&(n==null||n.setExpanded(Se.filename,!Se.isExpanded)))},[c,o,n]),H=S.exports.useCallback((ee,ue)=>{var qe;Lt.debug2("handleItemDragStart",ee,y);let Se=y;fn.isSelected(y,ee)||(Se=[[ee,ee]],E(Se)),C(F(Se)),(qe=I.current)==null||qe.resetMouseState();const De=document.createElement("div");De.innerHTML=`<div class="dnd-placeholder-content">${U()}</div>`,De.className="file-list-dnd-placeholder",document.body.appendChild(De),ue.dataTransfer.setDragImage(De,0,0),ue.dataTransfer.effectAllowed="move",T(De)},[U,F,y]),A=S.exports.useCallback((ee,ue)=>{ue.preventDefault(),Lt.debug2("handleItemDragOver",ue),f(x(ee))},[x]),N=S.exports.useCallback((ee,ue)=>{Lt.debug("handleItemDragEnd",ee),w==null||w.remove(),C(void 0),f(void 0),T(void 0)},[w]),k=S.exports.useCallback((ee,ue)=>{B(ee)},[B]),O=S.exports.useCallback(()=>{Lt.debug2("handleItemDragExit"),f(void 0)},[]),V=S.exports.useCallback(ee=>{ee.target instanceof Element&&ee.target.classList.contains(kh)&&(ee.preventDefault(),Lt.debug2("handleListDragOver",ee),f({type:"directory",filename:"/",basename:"/",id:"/"}))},[]),G=S.exports.useCallback(ee=>{ee.target instanceof Element&&ee.target.classList.contains(kh)&&(Lt.debug("handleListDrop"),B())},[B]),Q=S.exports.useCallback(ee=>{if(Lt.debug2("handleSelectionChange",ee),ee!==y){E(ee);const ue=F(ee);r(ue)}},[F,r,y]),Z=S.exports.useCallback(ee=>{if(Lt.debug2("handleFocusChange",ee),ee!=null){const[ue]=F([[ee,ee]]);s(ue)}else s()},[F,s]),be=S.exports.useCallback((ee,ue)=>{Lt.debug("handleViewportChange",ee,ue),(ee!==m.top||ue!==m.bottom)&&p({top:ee,bottom:ue})},[m]),le=S.exports.useMemo(()=>{if(!b||!g)return!1;try{return Oh(b,g),Lt.debug("handleValidateDropTarget true"),!0}catch{return Lt.debug("handleValidateDropTarget false"),!1}},[b,g]),{focusedPath:he}=t;S.exports.useEffect(()=>{he!==void 0&&(he==="/"?n.collapseAll():(n.setExpanded(he,!1),n.setExpanded(he,!0)))},[n,he]),S.exports.useEffect(function(){Lt.debug("updating table viewport",m),n==null||n.setViewport({top:Math.max(0,m.top-d),bottom:m.bottom+d})},[d,n,m]),S.exports.useEffect(function(){const ue=n.onUpdate(Se=>{u({items:Se.items.map(De=>({...De,itemName:De.basename})),offset:Se.offset,itemCount:n.size})});return()=>{ue()}},[n]),S.exports.useEffect(function(){if(g!=null&&qn(g)&&g.filename!=="/"){const ue=setTimeout(()=>{g.isExpanded||n==null||n.setExpanded(g.filename,!0)},_E);return()=>clearTimeout(ue)}},[g,n]);const Re=S.exports.useCallback(ee=>l({...ee,isDragInProgress:b!=null,dropTargetItem:g,draggedItems:b,isDropTargetValid:le,onDragStart:H,onDragEnd:N,onDragOver:A,onDragExit:O,onDrop:k}),[N,O,A,H,k,b,g,le,l]);return h("div",{ref:D,className:W("file-list",{"is-dragging":b!=null}),onDragOver:V,onDrop:G,children:h(bn,{ref:I,items:c.items,itemCount:c.itemCount,offset:c.offset,onFocusChange:Z,onSelect:_,onSelectionChange:Q,onViewportChange:be,selectedRanges:y,renderItem:Re,rowHeight:a,isMultiSelect:e,isDragSelect:!1,isDeselectOnClick:!1})})}const LE={name:"File Explorer",DELETE:Ae.createAndAdd({id:"FILE_EXPLORER.DELETE",name:"Delete",shortcut:[me.DELETE],macShortcut:[de.CMD,me.BACKSPACE]}),RENAME:Ae.createAndAdd({id:"FILE_EXPLORER.RENAME",name:"Rename",shortcut:[me.ENTER],macShortcut:[me.ENTER]})},Lh={FILE_EXPLORER:LE};const Ah=X.module("FileListItemEditor");function AE({item:t,onCancel:e,onSubmit:n,validate:s=()=>Promise.resolve()}){const i=S.exports.useRef(null),[o,r]=S.exports.useState(t.basename),[l,a]=S.exports.useState(),[d,c]=S.exports.useState(Promise.resolve()),u=S.exports.useCallback(()=>{var C;(C=i.current)==null||C.focus()},[i]),m=S.exports.useCallback(C=>C.stopPropagation(),[]),p=S.exports.useCallback(()=>{d.then(()=>{n(o)}).catch(C=>Ah.info("Unable to validate name",C))},[n,o,d]);S.exports.useEffect(function(){const w=Te.makeCancelable(s(o));return w.then(()=>a(void 0)).catch(T=>{Te.isCanceled(T)||a(T)}),c(w),()=>w.cancel()},[s,o]),S.exports.useEffect(function(){u()},[u]);const g=S.exports.useCallback(()=>{Ah.debug2("handleBlur"),p()},[p]),f=S.exports.useCallback(C=>{const{value:w}=C.target;r(w)},[]),b=S.exports.useCallback(C=>{C.stopPropagation();const{key:w}=C;switch(w){case"Enter":{p();break}case"Escape":{e();break}}},[e,p]);return v("div",{className:"file-list-item-editor",children:[h("input",{type:"text",className:W("form-control file-list-item-editor-input",{"is-invalid":l}),value:o,ref:i,onBlur:g,onKeyDown:b,onChange:f,onClick:m,onDoubleClick:m,onMouseDown:m}),l&&h("div",{className:"invalid-feedback",children:`${l}`})]})}function Lp(t){const{isMultiSelect:e=!1,focusedPath:n,showContextMenu:s=!1,onCreateFile:i,onCreateFolder:o,onCopy:r,onDelete:l,onMove:a=()=>{},onRename:d,onSelect:c,onSelectionChange:u,table:m,rowHeight:p=nc,validateRename:g=()=>Promise.resolve()}=t,[f,b]=S.exports.useState(),[C,w]=S.exports.useState([]),[T,y]=S.exports.useState(),E=S.exports.useCallback(O=>{w(O),u==null||u(O)},[u]),I=S.exports.useCallback(O=>{y(O)},[]),D=S.exports.useCallback(()=>{T&&(r==null||r(T))},[T,r]),F=S.exports.useCallback(()=>{C.length>0&&(l==null||l(C))},[l,C]),x=S.exports.useCallback(()=>{i==null||i()},[i]),U=S.exports.useCallback(()=>{T&&(o==null||o(ce.getPath(T.filename)))},[T,o]),B=S.exports.useCallback(()=>{T&&b(T)},[T]),_=S.exports.useCallback(()=>{b(void 0)},[]),H=S.exports.useCallback(O=>{f&&(d==null||d(f,O),b(void 0))},[d,f]),A=S.exports.useMemo(()=>{if(f)return[];const O=[];return i&&O.push({title:"New File",description:"Create new file",action:x,group:oe.groups.medium}),o&&O.push({title:"New Folder",description:"Create new folder",action:U,group:oe.groups.medium}),r&&O.push({title:"Copy",description:"Copy",action:D,group:oe.groups.low,disabled:T==null||qn(T)}),l&&C.length>0&&O.push({title:"Delete",description:"Delete",shortcut:Lh.FILE_EXPLORER.DELETE,action:F,group:oe.groups.low}),d&&O.push({title:"Rename",description:"Rename",shortcut:Lh.FILE_EXPLORER.RENAME,action:B,group:oe.groups.low,disabled:T==null}),O},[D,F,x,U,B,T,r,i,o,l,d,C,f]),N=S.exports.useCallback(O=>f?g(f,O):Promise.reject(new Error("No rename item")),[f,g]),k=S.exports.useCallback(O=>{const{item:V}=O;return f&&f.filename===V.filename?Ka({...O,children:h(AE,{item:V,validate:N,onSubmit:H,onCancel:_})}):Ka(O)},[_,H,f,N]);return v("div",{className:"file-list-container",children:[m!=null&&h(OE,{onMove:a,onSelect:c,onSelectionChange:E,onFocusChange:I,renderItem:k,rowHeight:p,table:m,isMultiSelect:e,focusedPath:n}),s&&h(oe,{actions:A})]})}Lp.displayName="FileListContainer";class Ur extends Hi{constructor(e){super("Name already exists"),this.isExistingFile=!0,this.info=e}}class sc extends Error{constructor(){super("No file exists at the path specified"),this.isFileNotFound=!0}}const Ks=X.module("FileExplorer");function ic(t){const{storage:e,isMultiSelect:n=!1,focusedPath:s,onDelete:i=()=>{},onRename:o=()=>{},onSelect:r,onSelectionChange:l,rowHeight:a=nc}=t,[d,c]=S.exports.useState([]),[u,m]=S.exports.useState();S.exports.useEffect(function(){let D;async function F(){Ks.debug("initTable"),D=Te.makeCancelable(e.getTable(),x=>x.close());try{m(await D)}catch(x){Te.isCanceled(x)||Ks.error("Unable to initialize table",x)}}return F(),()=>{D.cancel()}},[e]);const p=S.exports.useCallback(I=>{Te.isCanceled(I)||Ks.error(I)},[]),g=S.exports.useCallback(I=>{Ks.debug("handleDelete, pending confirmation",I),c(I)},[]),f=S.exports.useCallback(()=>{Ks.debug("handleDeleteConfirm",d),d.forEach(I=>e.deleteFile(qn(I)?ce.makePath(I.filename):I.filename)),i(d),c([])},[d,i,e]),b=S.exports.useCallback(()=>{Ks.debug("handleDeleteCancel"),c([])},[]),C=S.exports.useCallback((I,D)=>{ce.reducePaths(I.map(x=>qn(x)?ce.makePath(x.filename):x.filename)).forEach(x=>{const U=ce.isPath(x)?`${D}${ce.getBaseName(x.substring(0,x.length-1))}/`:`${D}${ce.getBaseName(x)}`;e.moveFile(x,U).then(()=>{o(x,U)}).catch(p)})},[p,o,e]),w=S.exports.useCallback((I,D)=>{let F=I.filename;const x=qn(I);x&&!F.endsWith("/")&&(F=`${F}/`);let U=`${ce.getParent(F)}${D}`;x&&!U.endsWith("/")&&(U=`${U}/`),Ks.debug2("handleRename",F,U),e.moveFile(F,U).catch(p),o(F,U)},[p,o,e]),T=S.exports.useCallback(async(I,D)=>{if(D===I.basename)return;ce.validateName(D);const F=`${ce.getPath(I.filename)}${D}`;try{const x=await e.info(F);throw new Ur(x)}catch(x){if(!(x instanceof sc))throw x}},[e]),y=d.length>0,E=S.exports.useMemo(()=>d.length===1?`Are you sure you want to delete "${d[0].filename}"?`:"Are you sure you want to delete the selected files?",[d]);return v("div",{className:"file-explorer",children:[u&&h(Lp,{isMultiSelect:n,focusedPath:s,showContextMenu:!0,onMove:C,onDelete:g,onRename:w,onSelect:r,onSelectionChange:l,rowHeight:a,table:u,validateRename:T}),h($i,{isOpen:y,headerText:E,bodyText:"You cannot undo this action.",onCancel:b,onConfirm:f,confirmButtonText:"Delete"})]})}ic.displayName="FileExplorer";const qs=X.module("NewItemModal"),Br=class extends S.exports.PureComponent{constructor(t){super(t),this.inputRef=Y.createRef(),this.pending=new fs,this.pathMap=new Map,this.isInitialLoad=!0,this.handleModalSubmit=this.handleModalSubmit.bind(this),this.handleModalOpened=this.handleModalOpened.bind(this),this.handleSelect=this.handleSelect.bind(this),this.handleChange=this.handleChange.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleValidationError=this.handleValidationError.bind(this),this.handleOverwriteCancel=this.handleOverwriteCancel.bind(this),this.handleOverwriteConfirm=this.handleOverwriteConfirm.bind(this),this.handleExtensionChangeCancel=this.handleExtensionChangeCancel.bind(this),this.handleExtensionChangeConfirm=this.handleExtensionChangeConfirm.bind(this),this.handleBreadcrumbSelect=this.handleBreadcrumbSelect.bind(this);const{defaultValue:e}=t,n=ce.hasPath(e)?ce.getPath(e):"/";this.state={isSubmitting:!1,path:n,prevExtension:ce.getExtension(e),showExtensionChangeModal:!1,showOverwriteModal:!1,value:ce.getBaseName(e)}}static getValidationMessage(t){return t instanceof Ur&&t.info.type==="directory"?"Error: Cannot overwrite existing directory":`${t}`}static handleError(t){Te.isCanceled(t)||qs.error(t)}componentDidUpdate(t,e){const{isOpen:n}=this.props,{isOpen:s}=t,{value:i,path:o}=this.state;!s&&n&&(this.resetValue(),this.isInitialLoad=!0),s&&n&&(!this.isInitialLoad&&(o!==e.path||i!==e.value)&&this.updateValidationStatus(o,i),this.isInitialLoad=!1)}componentWillUnmount(){this.pending.cancel(),this.cancelableValidatePromise&&this.cancelableValidatePromise.cancel(),this.cancelableExistingItemPromise&&this.cancelableExistingItemPromise.cancel()}resetValue(){const{defaultValue:t}=this.props,e=ce.hasPath(t)?ce.getPath(t):"/";this.setState({path:e,value:ce.getBaseName(t),validationError:void 0,prevExtension:ce.getExtension(t),isSubmitting:!1})}getValidationPromise(t,e,n=!1){return this.cancelableValidatePromise&&this.cancelableValidatePromise.cancel(),this.cancelableValidatePromise=Te.makeCancelable(this.validateName(t,e,n)),this.cancelableValidatePromise}async validateName(t,e,n){ce.validateName(e);const{defaultValue:s,storage:i}=this.props;if(n){const o=`${t}${e}`;if(o!==s)try{const r=await i.info(o);throw new Ur(r)}catch(r){if(!(r instanceof sc))throw r}}return e}updateValidationStatus(t,e){this.getValidationPromise(t,e).then(()=>{this.setState({validationError:void 0})}).catch(this.handleValidationError).catch(Br.handleError)}handleModalOpened(){this.focusRenameInput()}handleModalSubmit(){this.submitModal()}handleChange(t){const{value:e}=t.target;this.setState({value:e})}handleSelect(t){if(qs.debug("handleSelect",t),t.type==="directory")this.setState({path:ce.makePath(t.filename)});else{const e=t.basename,n=ce.getPath(t.filename);this.setState({value:e,path:n},()=>{this.focusRenameInput()})}}handleKeyDown(t){const{key:e}=t;switch(t.stopPropagation(),e){case"Enter":{t.preventDefault(),this.submitModal();break}case"Escape":{t.preventDefault();const{onCancel:n}=this.props;n();break}}}handleValidationError(t){if(!(t instanceof Hi))throw t;qs.debug("Validation error",t),this.setState({validationError:t})}handleOverwriteCancel(){this.setState({showOverwriteModal:!1,isSubmitting:!1})}handleOverwriteConfirm(){this.setState({showOverwriteModal:!1});const{onSubmit:t}=this.props,{path:e,value:n}=this.state;qs.debug("handleOverwriteConfirm",e,n),t(`${e}${n}`)}handleExtensionChangeCancel(){qs.debug("handleExtensionChangeCancel"),this.setState(({value:t,prevExtension:e})=>{const n=ce.replaceExtension(t,e);return{showExtensionChangeModal:!1,value:n}}),this.submitModal(!0)}handleExtensionChangeConfirm(){qs.debug("handleExtensionChangeConfirm"),this.setState({showExtensionChangeModal:!1}),this.submitModal(!0)}focusRenameInput(){const t=this.inputRef.current;if(t){const{type:e}=this.props,{value:n}=t,s=e==="directory"?n.length:n.lastIndexOf(".");t.focus(),t.setSelectionRange(0,s>0?s:n.length)}}submitModal(t=!1){this.setState(({prevExtension:e,value:n,path:s})=>{const{notifyOnExtensionChange:i,type:o}=this.props;qs.debug("submitModal",e,n);const r=ce.getExtension(n);return i&&!t&&e!==null&&e!==r?{isSubmitting:!1,showExtensionChangeModal:!0,newExtension:r}:(this.getValidationPromise(s,n,!0).then(l=>{const{onSubmit:a}=this.props;a(`${s}${n}`)}).catch(l=>{if(l instanceof Ur&&o!=="directory"&&l.info.type!=="directory"){this.setState({showOverwriteModal:!0});return}throw l}).catch(l=>{throw Te.isCanceled(l)&&this.setState({isSubmitting:!1}),l}).catch(this.handleValidationError).catch(Br.handleError),{isSubmitting:!0,showExtensionChangeModal:!1,newExtension:void 0})})}handleBreadcrumbSelect(t){this.setState({path:t})}renderPathButtons(t){const e=t.split("/");return e.pop(),e.map((n,s)=>{let i="";for(let o=0;o<s;o+=1)i+=`${e[o]}/`;return i+=`${n}/`,v(Y.Fragment,{children:[h(z,{kind:"ghost",className:"directory-breadcrumbs",onClick:()=>this.handleBreadcrumbSelect(i),"aria-label":s===0?"Home":void 0,icon:s===0?h(j,{icon:Mf,transform:"right-1.6"}):void 0,tooltip:s===0?"Home":void 0,children:n}),"/"]},i)})}render(){const{storage:t,isOpen:e,onCancel:n,placeholder:s,title:i,type:o}=this.props,{isSubmitting:r,path:l,showExtensionChangeModal:a,showOverwriteModal:d,validationError:c,value:u,prevExtension:m,newExtension:p}=this.state,g=o==="directory",f=ce.fileExtensionToString(m),b=ce.fileExtensionToString(p),C=g?"Create":"Save",w=g?"New folder name":"Save file as";return v(ye,{children:[v($o,{isOpen:e,toggle:n,onOpened:this.handleModalOpened,className:"modal-dialog-centered new-file-modal theme-bg-dark",children:[h(zo,{toggle:n,children:i}),h(Wo,{children:h("form",{children:v("div",{className:"d-flex flex-column new-file-modal-content",children:[v("div",{className:"flex-grow-0 mb-4",children:[h("label",{htmlFor:"file-name-input",children:w}),h("input",{id:"file-name-input",type:"text",autoComplete:"off",autoCapitalize:"none",autoCorrect:"off",spellCheck:"false",className:W("form-control",{"is-invalid":c}),value:u,placeholder:s,ref:this.inputRef,onKeyDown:this.handleKeyDown,onChange:this.handleChange}),c&&h("div",{className:"invalid-feedback",children:Br.getValidationMessage(c)})]}),v("div",{className:"flex-grow-0",children:[h("label",{children:"Directory: /"}),this.renderPathButtons(l)]}),h("div",{className:"flex-grow-1 file-explorer-container",children:h(ic,{onSelect:this.handleSelect,storage:t,focusedPath:l})})]})})}),v(od,{children:[h(z,{kind:"secondary",onClick:n,children:"Cancel"}),h(z,{kind:"primary",disabled:r,onClick:this.handleModalSubmit,children:C})]})]}),h($i,{isOpen:d,headerText:"Confirm overwrite",bodyText:"File with this name already exists, are you sure you want to overwrite it?",onCancel:this.handleOverwriteCancel,onConfirm:this.handleOverwriteConfirm,cancelButtonText:"Cancel",confirmButtonText:"Overwrite"}),h($i,{isOpen:a,headerText:"Confirm extension change",bodyText:`Are you sure you want to change extension from "${f}" to "${b}"?`,onCancel:this.handleExtensionChangeCancel,onConfirm:this.handleExtensionChangeConfirm,cancelButtonText:`Keep "${f}"`,confirmButtonText:`Use "${b}"`})]})}};let Wl=Br;Wl.propTypes={isOpen:R.exports.bool,title:R.exports.string.isRequired,defaultValue:R.exports.string,type:R.exports.oneOf(["file","directory"]).isRequired,onSubmit:R.exports.func,onCancel:R.exports.func,placeholder:R.exports.string,storage:R.exports.shape({}).isRequired,notifyOnExtensionChange:R.exports.bool};Wl.defaultProps={isOpen:!1,defaultValue:"/",notifyOnExtensionChange:!1,placeholder:"",onSubmit:t=>{},onCancel:()=>{}};function PE({createFile:t,createFolder:e,onSearchChange:n,defaultSearchText:s=""}){return v("div",{className:"file-explorer-toolbar",children:[v("div",{className:"file-explorer-toolbar-buttons",children:[h(z,{kind:"ghost",icon:Cu,tooltip:"New notebook",onClick:t,"aria-label":"New notebook"}),h(z,{kind:"ghost",icon:Pf,tooltip:"New folder",onClick:e,"aria-label":"New folder"})]}),n&&h("div",{className:"file-explorer-toolbar-search",children:h(Pu,{value:s,onChange:n,placeholder:"Search by name"})})]})}const Di=X.module("FileExplorerPanel"),HE=(t,e)=>{const n=Cm(t),s=gi(t,e.localDashboardId),{session:i,config:o}=s!=null?s:{},r=o==null?void 0:o.type;return{fileStorage:n,language:r,session:i}},VE=Nt(HE,null,null,{forwardRef:!0});function UE(t){const e=t;return e!=null&&typeof e.button=="number"}const qa=class extends Y.Component{static handleError(t){Di.error(t)}static isFocusEvent(t){return UE(t)?t.detail>=2:!0}constructor(t){super(t),this.handleFileSelect=this.handleFileSelect.bind(this),this.handleCreateFile=this.handleCreateFile.bind(this),this.handleCreateDirectory=this.handleCreateDirectory.bind(this),this.handleCreateDirectoryCancel=this.handleCreateDirectoryCancel.bind(this),this.handleCreateDirectorySubmit=this.handleCreateDirectorySubmit.bind(this),this.handleDelete=this.handleDelete.bind(this),this.handleRename=this.handleRename.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleSelectionChange=this.handleSelectionChange.bind(this);const{session:e,language:n}=t;this.state={isShown:!1,language:n,session:e,showCreateFolder:!1,focusedFilePath:"/"}}componentDidMount(){this.isHidden()||this.setState({isShown:!0})}handleCreateFile(){const{glEventHub:t}=this.props,{session:e,language:n}=this.state,s={language:n,value:""};Di.debug("handleCreateFile",e,n,s),t.emit(He.CREATE_NOTEBOOK,e,n,s)}handleCreateDirectory(t){this.setState({showCreateFolder:!0})}handleCreateDirectoryCancel(){Di.debug("handleCreateDirectoryCancel"),this.setState({showCreateFolder:!1})}handleCreateDirectorySubmit(t){Di.debug("handleCreateDirectorySubmit",t),this.setState({showCreateFolder:!1});const{fileStorage:e}=this.props;e.createDirectory(t).catch(qa.handleError)}handleDelete(t){const{glEventHub:e}=this.props;t.forEach(n=>{e.emit(He.CLOSE_FILE,{id:n.filename,itemName:n.filename})})}handleSelectionChange(t){let e="/";t.length===1&&(t[0].type==="directory"?e=ce.makePath(t[0].filename):e=ce.getPath(t[0].filename)),this.setState({focusedFilePath:e})}handleFileSelect(t,e){if(Di.debug("fileSelect",t),t.type==="directory")return;const n=qa.isFocusEvent(e),s={id:t.filename,itemName:t.filename},{glEventHub:i}=this.props,{session:o,language:r}=this.state,l={value:null,language:r};i.emit(He.SELECT_NOTEBOOK,o,r,l,s,n)}handleRename(t,e){const{glEventHub:n}=this.props;Di.debug("handleRename",t,e),n.emit(He.RENAME_FILE,t,e)}handleSessionOpened(t,{language:e}){this.setState({session:t,language:e})}handleSessionClosed(){this.setState({session:void 0,language:void 0})}handleShow(){this.setState({isShown:!0})}isHidden(){const{glContainer:t}=this.props,{isHidden:e}=t;return e}render(){const{fileStorage:t,glContainer:e,glEventHub:n}=this.props,{isShown:s,showCreateFolder:i,focusedFilePath:o}=this.state;return v(jn,{className:"file-explorer-panel",componentPanel:this,glContainer:e,glEventHub:n,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onShow:this.handleShow,children:[h(PE,{createFile:this.handleCreateFile,createFolder:this.handleCreateDirectory}),s&&h(ic,{isMultiSelect:!0,storage:t,onDelete:this.handleDelete,onRename:this.handleRename,onSelect:this.handleFileSelect,onSelectionChange:this.handleSelectionChange}),h(Wl,{isOpen:i,type:"directory",title:"Create New Folder",storage:t,onSubmit:this.handleCreateDirectorySubmit,onCancel:this.handleCreateDirectoryCancel,defaultValue:o})]})}};let oc=qa;oc.COMPONENT="FileExplorerPanel";oc.TITLE="File Explorer";const ol=VE(oc);const lt=X.module("FilterSetManager"),BE="Enter name...",Ph="No Available Filter Sets";class rl extends S.exports.Component{constructor(e){super(e),this.renameInputRef=Y.createRef(),this.dropdownRef=Y.createRef(),this.editDropdownRef=Y.createRef(),this.isRenamingExistingSet=pe((n,s)=>s!==void 0&&n.some(({id:i})=>i===s.id)),this.handleSettingsCancel=this.handleSettingsCancel.bind(this),this.handleSettingsClick=this.handleSettingsClick.bind(this),this.handleSettingsSave=this.handleSettingsSave.bind(this),this.handleBackgroundClick=this.handleBackgroundClick.bind(this),this.handleEditDropdownChange=this.handleEditDropdownChange.bind(this),this.handleFilterChange=this.handleFilterChange.bind(this),this.handleFilterApply=this.handleFilterApply.bind(this),this.handleCaptureNewSet=this.handleCaptureNewSet.bind(this),this.handleNameInputChange=this.handleNameInputChange.bind(this),this.handleNameInputKeyPress=this.handleNameInputKeyPress.bind(this),this.handleRenameConfirm=this.handleRenameConfirm.bind(this),this.handleRenameCancel=this.handleRenameCancel.bind(this),this.handleRestoreFullStateChange=this.handleRestoreFullStateChange.bind(this),this.handleSetDelete=this.handleSetDelete.bind(this),this.handleSetEdit=this.handleSetEdit.bind(this),this.handleSetUpdate=this.handleSetUpdate.bind(this),this.state={editId:void 0,renameSet:void 0,nameInputValue:"",nameInputError:void 0,modifiedFilterSets:[],restoreFullState:!1}}static animateScreenFlash(){var n;const e=document.createElement("div");e.classList.add("screen-flash-overlay"),e.addEventListener("animationend",()=>{e.remove()}),(n=document.querySelector("body"))==null||n.appendChild(e)}componentDidMount(){const{isValueShown:e}=this.props;e?this.updateSelectedId():this.initSettingsScreen()}componentDidUpdate(e,n){const{isValueShown:s,filterSets:i}=this.props,{modifiedFilterSets:o}=this.state;if(e.isValueShown&&!s&&this.initSettingsScreen(),this.isNameInputScreen()&&!this.isNameInputScreen(n)&&this.focusRenameInput(),i!==e.filterSets)if(!s&&i.length>0&&e.filterSets.length===0&&o.length===0){const{onChange:r}=this.props;r({isValueShown:!0,selectedId:i[0].id})}else this.updateSelectedId()}initSettingsScreen(){const{filterSets:e,selectedId:n}=this.props;lt.debug("initSettingsScreen",e,n),this.setState({modifiedFilterSets:[...e],editId:n})}updateSelectedId(){const{isValueShown:e,filterSets:n,selectedId:s,onChange:i}=this.props;if(lt.debug("updateSelectedId",n,s),!!e&&!n.some(({id:o})=>o===s)){const o=n.length===0;i({isValueShown:!o,selectedId:o?void 0:n[0].id})}}handleEditDropdownChange(e){const{value:n}=e.target;this.setState({editId:n})}handleFilterChange(e){const{value:n}=e.target,{isValueShown:s,onChange:i}=this.props;this.applyFilterSet(n),i({isValueShown:s,selectedId:n})}handleFilterApply(){const{selectedId:e}=this.props;this.applyFilterSet(e)}handleSettingsCancel(){const{onChange:e,selectedId:n,filterSets:s}=this.props;this.setState({modifiedFilterSets:[]}),s.length>0&&e({isValueShown:!0,selectedId:n})}handleSettingsSave(){const{onChange:e,onUpdateSets:n}=this.props,{modifiedFilterSets:s,editId:i}=this.state;this.setState({modifiedFilterSets:[]}),lt.debug("Update sets",s,i),n(s),s.length>0&&e({isValueShown:!0,selectedId:i})}handleCaptureNewSet(){const{getFilterState:e}=this.props;rl.animateScreenFlash();const n=ze(),s=e(),i={id:n,title:"",panels:s};lt.debug("handleSetCreate",i),this.setState({nameInputValue:"",nameInputError:void 0,renameSet:i})}handleRenameCancel(){this.setState({renameSet:void 0})}handleRestoreFullStateChange(e){this.setState({restoreFullState:e.target.value==="true"})}getNameError(e){var o;const{renameSet:n,modifiedFilterSets:s}=this.state,i=(o=e==null?void 0:e.trim())!=null?o:"";if(i.length===0)return lt.debug("Name cannot be empty",i),"Name cannot be empty";if(n!==void 0&&s.some(({title:r,id:l})=>r===i&&l!==n.id))return lt.debug("Set with this name already exists",i),"Set with this name already exists"}handleRenameConfirm(){var c;const{nameInputValue:e,renameSet:n,modifiedFilterSets:s,restoreFullState:i}=this.state;if(n===void 0){lt.error("Renamed set undefined.");return}const o=this.getNameError(e);if(lt.debug("handleRenameConfirm",e,o),o!==void 0){this.setState({nameInputError:o});return}const r=(c=e==null?void 0:e.trim())!=null?c:"",l={...n,title:r,restoreFullState:i},a=s.findIndex(({id:u})=>u===n.id),d=[...s];a>=0?(d[a]=l,lt.debug("Renamed existing set",d)):(d.push(l),lt.debug("Added new set to modified sets",d)),this.setState({editId:l.id,modifiedFilterSets:d,renameSet:void 0})}handleSetDelete(){this.setState(e=>{const{editId:n,modifiedFilterSets:s}=e,i=s.findIndex(({id:a})=>a===n);if(i<0)return lt.error("Unable to find selected filterSet index",s,n),null;const o=s.filter(({id:a})=>a!==n),r=Math.max(0,Math.min(o.length-1,i-1)),l=o.length>0?o[r].id:void 0;return lt.debug("Deleted selected set",n,s,o),lt.debug("New selection",r,l),{modifiedFilterSets:o,editId:l}})}handleSetUpdate(){const{getFilterState:e}=this.props;rl.animateScreenFlash();const n=e();this.setState(({modifiedFilterSets:s,editId:i})=>{if(i===void 0)return lt.error("Filter for update not selected."),null;const o=[...s],r=o.findIndex(({id:l})=>l===i);return r<0?(lt.error("Selected set for update not found."),null):(o[r]={...o[r],panels:n},lt.debug("Update set",o,n),{modifiedFilterSets:o})})}handleSetEdit(){this.setState(({editId:e,modifiedFilterSets:n})=>{const s=n.find(({id:r})=>r===e);if(s===void 0)return lt.error("Could not find selected set",e,n),null;const{title:i,restoreFullState:o=!1}=s;return{nameInputValue:i,nameInputError:void 0,renameSet:s,restoreFullState:o}})}handleSettingsClick(e){e.stopPropagation();const{onChange:n,selectedId:s}=this.props;n({isValueShown:!1,selectedId:s})}handleBackgroundClick(e){lt.debug("handleBackgroundClick"),e.target!==this.dropdownRef.current&&this.focusInput()}handleNameInputChange(e){const{value:n}=e.target,s=this.getNameError(n);this.setState({nameInputValue:n,nameInputError:s})}handleNameInputKeyPress(e){const{key:n}=e;n==="Enter"&&(e.preventDefault(),this.handleRenameConfirm())}isNameInputScreen(e=this.state){const{renameSet:n}=e;return n!==void 0}applyFilterSet(e){const{onApply:n,filterSets:s}=this.props;if(e===void 0){lt.debug("No filter selected");return}const i=s.find(({id:o})=>o===e);if(i===void 0){lt.debug("Selected id not found in filterSets",e,s);return}lt.debug("Apply filterSet",i),n(i)}focusInput(){var e;(e=this.dropdownRef.current)==null||e.focus()}focusRenameInput(){var e;(e=this.renameInputRef.current)==null||e.focus()}render(){const{nameInputValue:e,nameInputError:n,editId:s,renameSet:i,modifiedFilterSets:o,restoreFullState:r}=this.state,{isValueShown:l,filterSets:a,selectedId:d}=this.props,c=this.isNameInputScreen(),u=this.isRenamingExistingSet(o,i),m=o.length===0,p=!c&&m&&a.length===0,g=!c&&!p,f=v("div",{className:"fa-layers mr-3",children:[h(j,{icon:Po,mask:Da,transform:"shrink-1 down-5 right-7"}),h(j,{icon:Ps,className:"text-primary",transform:"shrink-6 down-5 right-7"})]}),b=v("div",{className:"fa-layers",children:[h(j,{icon:Po,mask:Da,transform:"shrink-1 down-5 right-7"}),h(j,{icon:Ra,transform:"shrink-1 down-5 right-7"})]});return h("div",{className:"filter-set-manager fill-parent-absolute",children:v(rd,{className:"w-100 h-100",isFlipped:l,children:[h("div",{className:"filter-set-manager-settings-card fill-parent-absolute",children:v("div",{className:"filter-set-manager-card-content",children:[p&&v("div",{children:[h(z,{kind:"ghost",className:"btn btn-link no-underline",onClick:this.handleCaptureNewSet,icon:f,children:"Capture filter set"}),h("div",{className:"py-3 text-muted small",children:"Takes a snapshot of the currently applied filters on all panels, allowing you to restore saved filter sets later."})]}),c&&v("div",{className:"d-flex flex-column justify-content-center","data-testid":"edit-filter-set-container",children:[v("div",{className:"form-group",children:[h("label",{children:u?"Edit set":"Name captured set"}),v("div",{className:"name-input-container",children:[h("input",{type:"text",className:"input-set-name form-control",placeholder:BE,value:e,ref:this.renameInputRef,onChange:this.handleNameInputChange,onKeyPress:this.handleNameInputKeyPress,spellCheck:"false"}),h(z,{"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:bu}),h(z,{"data-testid":"rename-cancel-button",kind:"ghost",className:"btn btn-link no-underline pt-2 pb-2",onClick:this.handleRenameCancel,tooltip:"Cancel",icon:wf})]}),n!==void 0&&h("div",{className:"error-message",children:n})]}),h("div",{className:"form-group",children:v(vl,{onChange:this.handleRestoreFullStateChange,value:`${r}`,children:[h(xn,{value:"false",children:"Restore only filters"}),h(xn,{value:"true",children:"Restore full table state"})]})})]}),g&&v("div",{className:"filter-set-manager-settings-grid-1",children:[v("div",{className:"form-group",children:[h("label",{children:"Edit filter sets"}),v("div",{className:"filter-select-container",children:[v("select",{"data-testid":"settings-card-filter-select",ref:this.editDropdownRef,value:s!=null?s:"-1",className:"custom-select filter-value-select",onChange:this.handleEditDropdownChange,disabled:m,children:[m&&h("option",{value:"-1",disabled:!0,children:Ph}),o.map(({id:C,title:w})=>h("option",{value:C,children:w},C))]}),h(z,{kind:"ghost",onClick:this.handleSetUpdate,disabled:m,icon:b,tooltip:"Update"}),h(z,{kind:"ghost",onClick:this.handleSetEdit,disabled:m,icon:ml,tooltip:"Edit"}),h(z,{kind:"ghost",onClick:this.handleSetDelete,disabled:m,icon:wn,tooltip:"Delete"})]})]}),h("div",{children:h(z,{kind:"ghost",className:"btn btn-link no-underline",onClick:this.handleCaptureNewSet,icon:f,children:"Capture new filter set"})}),v("div",{className:"py-3 text-right",children:[h(z,{kind:"secondary",onClick:this.handleSettingsCancel,children:"Cancel"}),"\xA0",h(z,{kind:"primary",onClick:this.handleSettingsSave,children:"Save"})]})]})]})},"front"),v("div",{className:"filter-set-manager-value-card fill-parent-absolute",onClick:this.handleBackgroundClick,children:[h("div",{className:"filter-set-manager-column",children:h("div",{className:"filter-set-manager-column-title",children:"Filter sets"})}),h("div",{className:"filter-set-manager-card-content",children:h("div",{className:"filter-set-manager-value-input",children:v("div",{className:"filter-select-container",children:[v("select",{"data-testid":"value-card-filter-select",ref:this.dropdownRef,value:d,className:"custom-select filter-value-select",onChange:this.handleFilterChange,children:[a.length===0&&h("option",{value:"-1",disabled:!0,children:Ph}),a.map(({id:C,title:w})=>h("option",{value:C,children:w},C))]}),h(z,{"data-testid":"filter-apply-button",kind:"ghost",onClick:this.handleFilterApply,icon:cd,tooltip:"Apply Filter Set"})]})})}),h("div",{className:"filter-set-manager-menu",children:h(z,{kind:"ghost",className:"btn btn-link btn-link-icon m-2 px-2",onClick:this.handleSettingsClick,tooltip:"Settings",icon:h(j,{icon:Go,transform:"grow-4"})})})]},"back")]})})}}function rc(t){var l,a;const{model:e,widgetName:n,glContainer:s,description:i}=t,o=((l=e==null?void 0:e.rowCount)!=null?l:0)-((a=e==null?void 0:e.pendingRowCount)!=null?a:0),r=e==null?void 0:e.displayString(o,"long");return h(Vl,{widgetType:"Table",widgetName:n,glContainer:s,description:i,children:v("div",{className:"column-statistics-grid",children:[h("span",{className:"column-statistic-operation",children:"Number of Rows"}),h("span",{className:"column-statistic-value",children:r})]})})}rc.propTypes={glContainer:kd.Container.isRequired,widgetName:R.exports.string.isRequired,description:R.exports.string};rc.defaultProps={description:null};const Un=X.module("IrisGridPanel"),$E=500,WE={IrisGrid:io,IrisGridTableModel:yp,ContextMenuRoot:Du};class Yi extends S.exports.PureComponent{constructor(e){super(e),this.getGridInputFilters=pe((s,i)=>te.getInputFiltersForColumns(s,i.filter(({value:o,excludePanelIds:r})=>{const l=ne.getIdFromPanel(this);return o!=null&&(r==null||l!=null&&!r.includes(l))}))),this.getAlwaysFetchColumns=pe((s,i)=>{const o=ne.getIdFromPanel(this),r=new Set(i);for(let l=0;l<s.length;l+=1){const{start:a}=s[l];a!=null&&a.panelId===o&&r.add(a.columnName)}return[...r]}),this.getPluginContent=pe((s,i,o,r,l)=>!i||!li(i)||s==null||i.table==null?null:h("div",{className:"iris-grid-plugin",children:h(s,{ref:this.pluginRef,filter:this.handlePluginFilter,onFilter:this.handlePluginFilter,fetchColumns:this.handlePluginFetchColumns,onFetchColumns:this.handlePluginFetchColumns,table:i.table,user:o,panel:this,workspace:r,components:WE,onStateChange:this.handlePluginStateChange,pluginState:l})})),this.getDehydratedIrisGridPanelState=pe((s,i,o,r,l)=>te.dehydrateIrisGridPanelState(s,{isSelectingPartition:i,partition:o,partitionColumn:r,advancedSettings:l})),this.getDehydratedIrisGridState=pe((s,i,o,r,l,a,d,c,u,m,p,g,f,b,C,w,T,y,E,I)=>te.dehydrateIrisGridState(s,{advancedFilters:o,aggregationSettings:T,customColumnFormatMap:r,isFilterBarShown:l,metrics:{userColumnWidths:C,userRowHeights:w},quickFilters:a,customColumns:d,reverseType:c,rollupConfig:u,showSearchBar:m,searchValue:p,selectDistinctColumns:g,selectedSearchColumns:f,sorts:i,invertSearchColumns:b,pendingDataMap:y,frozenColumns:E,conditionalFormats:I})),this.getDehydratedGridState=pe((s,i,o,r,l)=>te.dehydrateGridState(s,{isStuckToBottom:r,isStuckToRight:l,movedColumns:i,movedRows:o})),this.getCachedPanelState=pe((s,i,o,r)=>({irisGridPanelState:s,irisGridState:i,gridState:o,pluginState:r})),this.savePanelState=je(()=>{const{irisGridState:s,gridState:i,pluginState:o}=this;P(s);const{onPanelStateUpdate:r}=this.props,{model:l,panelState:a,isSelectingPartition:d,partition:c,partitionColumn:u,advancedSettings:m}=this.state,{advancedFilters:p,aggregationSettings:g,customColumnFormatMap:f,isFilterBarShown:b,quickFilters:C,customColumns:w,reverseType:T,rollupConfig:y,showSearchBar:E,searchValue:I,selectDistinctColumns:D,selectedSearchColumns:F,sorts:x,invertSearchColumns:U,metrics:B,pendingDataMap:_,frozenColumns:H,conditionalFormats:A}=s;P(l),P(B);const{userColumnWidths:N,userRowHeights:k}=B;P(i);const{isStuckToBottom:O,isStuckToRight:V,movedColumns:G,movedRows:Q}=i,Z=this.getCachedPanelState(this.getDehydratedIrisGridPanelState(l,d,c,u,m),this.getDehydratedIrisGridState(l,x,p,f,b,C,w,T,y,E,I,D,F,U,N,k,g,_,H,A),this.getDehydratedGridState(l,G,Q,O,V),o);Z!==a&&(Un.debug("Saving panel state",this,Z),this.setState({panelState:Z}),r==null||r(Z))},$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=Y.createRef(),this.pluginRef=Y.createRef();const{panelState:n}=e;this.pluginState=null,this.state={error:null,isDisconnected:!1,isLoaded:!1,isLoading:!0,isModelReady:!1,model:void 0,advancedFilters:new Map,aggregationSettings:{aggregations:[],showOnTop:!1},advancedSettings:new Map(rp.DEFAULTS),customColumns:[],customColumnFormatMap:new Map,isFilterBarShown:!1,quickFilters:new Map,sorts:[],userColumnWidths:new Map,userRowHeights:new Map,reverseType:L.REVERSE_TYPE.NONE,movedColumns:[],movedRows:[],isSelectingPartition:!1,partition:void 0,partitionColumn:void 0,rollupConfig:void 0,showSearchBar:!1,searchValue:"",selectedSearchColumns:void 0,invertSearchColumns:!0,Plugin:void 0,pluginFilters:[],pluginFetchColumns:[],modelQueue:[],pendingDataMap:new Map,frozenColumns:void 0,panelState:n,irisGridStateOverrides:{},gridStateOverrides:{},isStuckToBottom:!1,isStuckToRight:!1,conditionalFormats:[],selectDistinctColumns:[]}}componentDidMount(){this.initModel()}componentDidUpdate(e,n){const{model:s}=this.state;s!==n.model&&(n.model!=null&&(this.stopModelListening(n.model),n.model.close()),s!=null&&this.startModelListening(s))}componentWillUnmount(){this.savePanelState.cancel(),this.modelPromise!=null&&(this.modelPromise.cancel(),this.modelPromise=void 0);const{model:e}=this.state;e&&(this.stopModelListening(e),e.close())}getTableName(){const{metadata:e}=this.props;return e.table}initModel(){this.setState({isModelReady:!1,isLoading:!0,error:null});const{makeModel:e}=this.props;this.modelPromise!=null&&this.modelPromise.cancel(),this.modelPromise=Te.makeCancelable(e(),n=>n.close()),this.modelPromise.then(this.handleLoadSuccess).catch(this.handleLoadError)}handleLoadSuccess(e){const n=e,{panelState:s,irisGridStateOverrides:i}=this.state,o=[];if(s!=null){const{irisGridState:r}=s,{aggregationSettings:l,customColumns:a,selectDistinctColumns:d=[],rollupConfig:c}={...r,...i};a.length>0&&o.push(u=>{u.customColumns=a}),c!=null&&c.columns.length>0&&o.push(u=>{u.rollupConfig=te.getModelRollupConfig(u.originalColumns,c,l)}),d.length>0&&o.push(u=>{u.selectDistinctColumns=d})}this.setState({model:n,modelQueue:o}),this.initModelQueue(n,o)}initModelQueue(e,n){const s=e;if(n.length===0){this.modelInitialized(s);return}const i=n.shift();Un.debug("initModelQueue",i),i&&i(s),this.setState({modelQueue:n})}handleAdvancedSettingsChange(e,n){Un.debug("handleAdvancedSettingsChange",e,n),this.setState(({advancedSettings:s})=>s.get(e)===n?null:{advancedSettings:new Map(s).set(e,n)})}handlePluginFilter(e){const{model:n}=this.state;P(n);const{columns:s,formatter:i}=n,o=te.getFiltersFromInputFilters(s,e,i.timeZone);this.setState({pluginFilters:o})}handlePluginFetchColumns(e){this.setState({pluginFetchColumns:e})}handleContextMenu(e){var n,s,i;return(i=(s=(n=this.pluginRef.current)==null?void 0:n.getMenu)==null?void 0:s.call(n,e))!=null?i:[]}isColumnSelectionValid(e){const{columnSelectionValidator:n}=this.props;return n&&e?n(this,e):!1}handleGridStateChange(e,n){this.irisGridState=e,this.gridState=n,this.setState({isLoaded:!0,isLoading:!1}),this.savePanelState();const{glEventHub:s,onStateChange:i}=this.props;s.emit(Tt.STATE_CHANGED,this),i==null||i(e,n)}handlePluginStateChange(e){const{irisGridState:n,gridState:s}=this;this.pluginState=e,n!==null&&s!==null&&this.savePanelState()}handleColumnsChanged(e){const{isModelReady:n,model:s,modelQueue:i}=this.state;n?this.sendColumnsChange(e.detail):(P(s),this.initModelQueue(s,i))}handleTableChanged(e){Un.debug("handleTableChanged",e);const{glEventHub:n}=this.props,{detail:s}=e;n.emit(Pe.TABLE_CHANGED,this,s)}handlePartitionAppend(e,n){const{glEventHub:s}=this.props,{name:i}=e,o=this.getTableName(),r=`${o} = ${o}.where("${i}=\`${n}\`")`;s.emit(Ct.SEND_COMMAND,r,!1,!0)}handleCreateChart(e,n){this.savePanelState.flush(),this.setState(()=>null,()=>{const{glEventHub:s,inputFilters:i,metadata:o}=this.props,{table:r}=o,{panelState:l}=this.state,a=ne.getIdFromPanel(this);let d;l&&(d=te.extractTableSettings(l,i)),s.emit(Tt.CREATE_CHART,{metadata:{settings:e,sourcePanelId:a,table:r,tableSettings:d},table:li(n)?n.table:void 0})})}handleColumnSelected(e){const{glEventHub:n}=this.props;n.emit(Tt.COLUMN_SELECTED,this,e)}handleDataSelected(e,n){const{glEventHub:s}=this.props;s.emit(Tt.DATA_SELECTED,this,n)}handleResize(){this.updateGrid()}handleShow(){this.updateGrid()}handleTabClicked(){this.irisGrid.current&&this.irisGrid.current.focus()}handleError(e){Un.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){Te.isCanceled(e)||this.handleError(e)}modelInitialized(e){const{glEventHub:n,loadPlugin:s}=this.props;if(this.modelPromise=void 0,this.loadPanelState(e),this.setState({isModelReady:!0}),li(e)){const{table:i}=e,{pluginName:o}=i;if(o!==""&&s!=null&&o!=null){const r=s(o);this.setState({Plugin:r})}n.emit(Pe.TABLE_CHANGED,this,i)}this.sendColumnsChange(e.columns)}handleClearAllFilters(){const e=this.irisGrid.current,{isDisconnected:n}=this.state;e!=null&&!n&&e.clearAllFilters()}sendColumnsChange(e){Un.debug2("sendColumnsChange",e);const{glEventHub:n}=this.props;n.emit(Pe.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){var w,T,y;const{model:n}=this.state;if(!n)return null;const s=this.irisGrid.current,{gridWrapper:i}=s||{},o=(w=i==null?void 0:i.getBoundingClientRect())!=null?w:null;if(o==null||o.width<=0||o.height<=0)return null;P(s);const{metrics:r}=s.state;P(r);const{columnHeaderHeight:l,visibleColumnXs:a,visibleColumnWidths:d,right:c,columnHeaderMaxDepth:u}=r,m=n.getColumnIndexByName(e);P(m);const p=s.getVisibleColumn(m),g=(T=a.get(p))!=null?T:0,f=(y=d.get(p))!=null?y:0,b=Math.max(o.left,Math.min(p>c?o.right:o.left+g+f*.5,o.right)),C=o.top+l*u;return[b,C]}setFilterMap(e){const n=this.irisGrid.current;n!=null&&n.setFilterMap(e)}setAdvancedFilterMap(e){const n=this.irisGrid.current;n!=null&&n.setAdvancedFilterMap(e)}setFilters({quickFilters:e,advancedFilters:n}){Un.debug("setFilters",e,n);const{model:s,isDisconnected:i}=this.state,o=this.irisGrid.current;if(o==null||i){Un.debug("Ignore setFilters, model disconnected");return}P(s);const{columns:r,formatter:l}=s,a=te.changeFilterColumnNamesToIndexes(s.columns,e).filter(([c])=>s.isFilterable(c)),d=te.changeFilterColumnNamesToIndexes(s.columns,n).filter(([c])=>s.isFilterable(c));o.clearAllFilters(),o.setFilters({quickFilters:te.hydrateQuickFilters(r,a,l.timeZone),advancedFilters:te.hydrateAdvancedFilters(r,d,l.timeZone)})}setStateOverrides(e){Un.debug("setStateOverrides",e);const{irisGridState:n,gridState:s}=e;this.setState({irisGridStateOverrides:n,gridStateOverrides:s},()=>{this.initModel()})}unsetFilterValue(){}loadPanelState(e){const{panelState:n,irisGridStateOverrides:s,gridStateOverrides:i}=this.state;if(n!=null)try{const{gridState:o,irisGridState:r,irisGridPanelState:l}=n,a={...s},{quickFilters:d,advancedFilters:c}=a;d&&(a.quickFilters=te.changeFilterColumnNamesToIndexes(e.columns,d)),c&&(a.advancedFilters=te.changeFilterColumnNamesToIndexes(e.columns,c));const{isSelectingPartition:u,partition:m,partitionColumn:p,advancedSettings:g}=te.hydrateIrisGridPanelState(e,l),{advancedFilters:f,customColumns:b,customColumnFormatMap:C,isFilterBarShown:w,quickFilters:T,reverseType:y,rollupConfig:E,aggregationSettings:I,sorts:D,userColumnWidths:F,userRowHeights:x,showSearchBar:U,searchValue:B,selectDistinctColumns:_,selectedSearchColumns:H,invertSearchColumns:A,pendingDataMap:N,frozenColumns:k,conditionalFormats:O}=te.hydrateIrisGridState(e,{...r,...a}),{isStuckToBottom:V,isStuckToRight:G,movedColumns:Q,movedRows:Z}=te.hydrateGridState(e,{...o,...i},r.customColumns);this.setState({advancedFilters:f,advancedSettings:g,conditionalFormats:O,customColumns:b,customColumnFormatMap:C,isFilterBarShown:w,isSelectingPartition:u,movedColumns:Q,movedRows:Z,partition:m,partitionColumn:p,quickFilters:T,reverseType:y,rollupConfig:E,aggregationSettings:I,sorts:D,userColumnWidths:F,userRowHeights:x,showSearchBar:U,searchValue:B,selectDistinctColumns:_,selectedSearchColumns:H,invertSearchColumns:A,pendingDataMap:N,frozenColumns:k,isStuckToBottom:V,isStuckToRight:G})}catch(o){Un.error("loadPanelState failed to load panelState",n,o)}}updateGrid(){var n,s;const e=(s=(n=this.irisGrid.current)==null?void 0:n.grid)!=null?s:null;!e||e.handleResize()}render(){var Ln,$t;const{children:e,glContainer:n,glEventHub:s,columnSelectionValidator:i,getDownloadWorker:o,inputFilters:r,links:l,metadata:a,panelState:d,user:c,workspace:u,settings:m,theme:p}=this.props,{advancedFilters:g,aggregationSettings:f,advancedSettings:b,conditionalFormats:C,customColumns:w,customColumnFormatMap:T,error:y,isDisconnected:E,isFilterBarShown:I,isSelectingPartition:D,isStuckToBottom:F,isStuckToRight:x,isLoaded:U,isLoading:B,isModelReady:_,model:H,movedColumns:A,movedRows:N,partition:k,partitionColumn:O,quickFilters:V,reverseType:G,rollupConfig:Q,sorts:Z,userColumnWidths:be,userRowHeights:le,showSearchBar:he,searchValue:Re,selectDistinctColumns:ee,selectedSearchColumns:ue,invertSearchColumns:Se,Plugin:De,pluginFilters:qe,pluginFetchColumns:ke,pendingDataMap:Qn,frozenColumns:vn}=this.state,St=y!=null?`Unable to open table. ${y}`:void 0,{table:Ie}=a,ot=(Ln=H==null?void 0:H.description)!=null?Ln:void 0,rt=($t=d==null?void 0:d.pluginState)!=null?$t:null,xt=e!=null?e:this.getPluginContent(De,H,c,u,rt),{permissions:Qt}=c,{canCopy:Zt,canDownloadCsv:_t}=Qt;return h(Ul,{errorMessage:St,isDisconnected:E,isLoading:B,isLoaded:U,className:"iris-grid-panel",glContainer:n,glEventHub:s,onClearAllFilters:this.handleClearAllFilters,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleShow,onTabClicked:this.handleTabClicked,widgetName:Ie,widgetType:"Table",description:ot,componentPanel:this,renderTabTooltip:()=>h(rc,{model:H,widgetName:Ie,glContainer:n,description:ot}),children:_&&H&&h(io,{advancedFilters:g,aggregationSettings:f,advancedSettings:b,alwaysFetchColumns:this.getAlwaysFetchColumns(l,ke),columnAllowedCursor:"linker",columnNotAllowedCursor:"not-allowed",customColumns:w,customColumnFormatMap:T,columnSelectionValidator:this.isColumnSelectionValid,conditionalFormats:C,inputFilters:this.getGridInputFilters(H.columns,r),applyInputFiltersOnInit:d==null,isFilterBarShown:I,isSelectingColumn:i!=null,isSelectingPartition:D,isStuckToBottom:F,isStuckToRight:x,movedColumns:A,movedRows:N,partition:k,partitionColumn:O,quickFilters:V,reverseType:G,rollupConfig:Q,settings:m,sorts:Z,userColumnWidths:be,userRowHeights:le,model:H,showSearchBar:he,searchValue:Re,selectedSearchColumns:ue,selectDistinctColumns:ee,invertSearchColumns:Se,onColumnSelected:this.handleColumnSelected,onCreateChart:this.handleCreateChart,onDataSelected:this.handleDataSelected,onError:this.handleError,onPartitionAppend:this.handlePartitionAppend,onStateChange:this.handleGridStateChange,onContextMenu:this.handleContextMenu,onAdvancedSettingsChange:this.handleAdvancedSettingsChange,customFilters:qe,pendingDataMap:Qn,canCopy:Zt,canDownloadCsv:_t,ref:this.irisGrid,getDownloadWorker:o,frozenColumns:vn,theme:p,children:xt})})}}Yi.defaultProps={onStateChange:()=>{},onPanelStateUpdate:()=>{}};Yi.displayName="IrisGridPanel";Yi.COMPONENT="IrisGridPanel";const zE=(t,{localDashboardId:e=Mn})=>({inputFilters:Xd(t,e),links:oo(t,e),columnSelectionValidator:Zd(t,e),user:gm(t),workspace:Dl(t),settings:Ft(t)}),hi=Nt(zE,null,null,{forwardRef:!0})(Yi);const Hh=X.module("InputFilter"),GE=150,Ya=class extends S.exports.Component{constructor(t){super(t),this.getItemLabel=ve((i,o)=>{const{name:r,type:l}=i[o];if(o>0&&i[o-1].name===r||o<i.length-1&&i[o+1].name===r){const a=l.substring(l.lastIndexOf(".")+1);return`${r} (${a})`}return r}),this.sendUpdate=je(()=>{const{onChange:i}=this.props,{column:o,value:r,isValueShown:l}=this.state;i({column:o,isValueShown:l,value:r})},GE),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=Y.createRef();const{column:e,isValueShown:n,value:s}=t;this.state={column:e,selectedColumn:e,value:s,isValueShown:n}}componentDidUpdate(t,e){const{column:n}=this.props,{column:s,value:i,isValueShown:o}=this.state;n!==t.column&&this.setState({column:n,selectedColumn:n}),o!==void 0&&o&&o!==e.isValueShown&&this.focusInput(),(s!==e.column||i!==e.value||o!==e.isValueShown)&&this.sendUpdate()}componentWillUnmount(){this.sendUpdate.flush()}handleColumnChange(t){const{columns:e}=this.props,{value:n}=t.target,s=e[parseInt(n,10)];Hh.debug2("handleColumnChange",s),this.setState({selectedColumn:s,value:void 0})}handleInputKeyPress(t){t.key==="Enter"&&(t.preventDefault(),t.stopPropagation(),this.setState(({value:e})=>e==null?{value:""}:null,()=>{this.sendUpdate(),this.sendUpdate.flush()}))}handleValueChange(t){const{value:e}=t.target;Hh.debug2("handleValueChange",e),this.setState({value:e})}handleSettingsCancel(){const{column:t}=this.state;this.setState({selectedColumn:t,isValueShown:!0})}handleSettingsSave(){const{selectedColumn:t}=this.state;this.setState({column:t,isValueShown:!0})}handleSettingsClick(t){const{column:e}=this.state;this.setState({selectedColumn:e,isValueShown:!1}),t.stopPropagation()}handleBackgroundClick(t){t.target!==this.inputRef.current&&this.focusInput()}focusInput(){this.inputRef.current!==null&&(this.inputRef.current.select(),this.inputRef.current.focus())}clearFilter(){this.setState({value:""})}setFilterState({name:t,type:e,value:n,isValueShown:s}){const i=t!=null&&e!=null?{name:t,type:e}:void 0,o=s===void 0?{column:i,value:n}:{column:i,value:n,isValueShown:s};this.setState(o)}render(){const{columns:t}=this.props,{column:e,isValueShown:n,selectedColumn:s,value:i}=this.state,o=i==null||i.length===0?Ya.PLACEHOLDER.length:i.length;let r=null;if(e!=null){const l=t.findIndex(a=>a.name===e.name&&a.type===e.type);r=l>=0?this.getItemLabel(t,l):e.name}return v(rd,{className:"input-filter fill-parent-absolute",isFlipped:n!=null?n:!1,children:[h("div",{className:"input-filter-settings-card",children:v("div",{className:"input-filter-settings-content",children:[v("div",{className:"input-filter-settings-grid",children:[h("label",{children:"Filter Column"}),v("select",{value:t.findIndex(l=>l.name===(s==null?void 0:s.name)&&l.type===(s==null?void 0:s.type)),className:"custom-select",onChange:this.handleColumnChange,children:[t.map((l,a)=>h("option",{value:a,children:this.getItemLabel(t,a)},`${l.name}/${l.type}`)),t.length===0&&h("option",{value:"-1",disabled:!0,children:"No Available Columns"})]}),h("div",{className:"text-muted small",children:"Input filter control will apply its filter to all columns matching this name in this dashboard."})]}),v("div",{className:"input-filter-settings-buttons",children:[h(z,{kind:"secondary",onClick:this.handleSettingsCancel,disabled:e==null,children:"Cancel"}),h(z,{kind:"primary",className:"ml-2",onClick:this.handleSettingsSave,disabled:s==null,children:"Save"})]})]})}),v("div",{className:"input-filter-value-card",onClick:this.handleBackgroundClick,children:[h("div",{className:"input-filter-column",children:v("div",{className:"input-filter-column-title",children:[r," Filter"]})}),h("div",{className:"d-flex justify-content-center align-items-center h-100 w-100",children:h("div",{className:"input-filter-value-input d-flex flex-column justify-content-center",children:h("input",{type:"text",ref:this.inputRef,placeholder:Ya.PLACEHOLDER,value:i!=null?i:"",onChange:this.handleValueChange,onKeyPress:this.handleInputKeyPress,style:{width:`${o+3}ch`},spellCheck:"false"})})}),h("div",{className:"input-filter-menu",children:h(z,{kind:"ghost",className:"m-2 px-2",onClick:this.handleSettingsClick,icon:h(j,{icon:Go,transform:"grow-4"}),tooltip:"Input Filter Settings"})})]})]})}};let lc=Ya;lc.PLACEHOLDER="Enter value...";lc.defaultProps={column:null,isValueShown:!1,value:null};const KE=250;class zl extends S.exports.Component{constructor(e){super(e),this.handleChange=je(this.handleChange.bind(this),KE),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.inputFilterRef=Y.createRef();const{panelState:n}=e,{value:s,isValueShown:i=!1,name:o,type:r,timestamp:l}=n!=null?n:{};this.state={columns:[],column:o!=null&&r!=null?{name:o,type:r}:void 0,value:s,timestamp:l,isValueShown:i,wasFlipped:!1,skipUpdate:!1,panelState:n}}componentDidMount(){this.updateColumns();const{column:e,value:n,timestamp:s}=this.state;if(e!=null){const{name:i,type:o}=e;this.sendUpdate(i,o,n,s)}}componentDidUpdate(e){const{columns:n}=this.props;n!==e.columns&&this.updateColumns()}handleChange({column:e,isValueShown:n=!1,value:s}){let i,o;e!=null&&({name:i,type:o}=e);let r=!0,l=Date.now();this.setState(({panelState:a,timestamp:d,wasFlipped:c,skipUpdate:u})=>{var p;const m=a!=null&&n!==a.isValueShown&&i===a.name&&o===a.type&&s===a.value;return r=(p=!u&&n&&(!m||!c))!=null?p:!1,r||(l=d),{panelState:{isValueShown:n,name:i,type:o,value:s,timestamp:l},timestamp:l,wasFlipped:m,skipUpdate:!1}},()=>{r&&this.sendUpdate(i,o,s,l)})}handleClearAllFilters(){var e;(e=this.inputFilterRef.current)==null||e.clearFilter()}sendUpdate(e,n,s,i){const{glEventHub:o}=this.props;o.emit(Pe.FILTERS_CHANGED,this,{name:e,type:n,value:s,timestamp:i})}setPanelState(e,n=!1){var s;this.setState({skipUpdate:!n}),(s=this.inputFilterRef.current)==null||s.setFilterState(e)}updateColumns(){const{columns:e}=this.props;e!=null&&this.setState(n=>{const{column:s}=n;return s==null&&e.length>0?{columns:[...e],column:e[0]}:s!=null&&!e.find(({name:i,type:o})=>s.name===i&&s.type===o)?{columns:[...e,s]}:{columns:[...e]}})}render(){const{glContainer:e,glEventHub:n}=this.props,{column:s,columns:i,isValueShown:o,value:r}=this.state;return h(jn,{className:"iris-input-filter-panel",componentPanel:this,glContainer:e,glEventHub:n,onClearAllFilters:this.handleClearAllFilters,isClonable:!0,isRenamable:!0,children:h(lc,{ref:this.inputFilterRef,column:s,columns:i,onChange:this.handleChange,isValueShown:o,value:r})})}}zl.defaultProps={panelState:null};zl.COMPONENT="InputFilterPanel";zl.displayName="InputFilterPanel";const qE=(t,e)=>{const{localDashboardId:n}=e;return{columns:Fp(t,n)}},_o=Nt(qE,null,null,{forwardRef:!0})(zl);const Dt=X.module("FilterSetManagerPanel");function YE(t){return t.setPanelState!=null}const Xa=class extends S.exports.Component{static changeFilterIndexesToColumnNames(t,e){return e.map(([n,s])=>{if(n>=t.columns.length)return null;const{name:i}=t.columns[n];return{name:i,filter:s}}).filter(n=>n!=null)}constructor(t){super(t),this.handleChange=this.handleChange.bind(this),this.handleFilterApply=this.handleFilterApply.bind(this),this.handleSetsUpdate=this.handleSetsUpdate.bind(this),this.handleGetFilterState=this.handleGetFilterState.bind(this);const{panelState:e,filterSets:n}=t,{selectedId:s=n.length>0?n[0].id:void 0,isValueShown:i=!1}=e!=null?e:{};this.state={selectedId:s,isValueShown:i,panelState:e}}getFilterState(){const{dashboardOpenedPanelMap:t}=this.props,e=[];return[...t.keys()].forEach(n=>{const s=t.get(n);if(s===void 0){Dt.error("Could not get panel",s);return}const i=ne.getComponentNameFromPanel(s),o=ne.getIdFromPanel(s);Dt.debug("Panel:",s,i);const{glContainer:r=null}=s.props;if(r==null){Dt.error("Could not get panel container",s);return}const l=ne.getComponentConfigFromContainer(r);if(l==null){Dt.error("Could not get component config from container",r);return}const a=ne.getPanelComponentState(l);if(a==null){Dt.debug(`Panel state is null ${o}`);return}switch(i){case ne.getComponentName(Yi):{let d;o!=null&&(d=this.getIrisGridPanelFilters(o,a)),d!=null&&e.push({panelId:o,type:i,state:d});break}case ne.getComponentName(_o):case ne.getComponentName(ci):{const{isValueShown:d,name:c,type:u,value:m}=a;e.push({panelId:o,type:i,state:{isValueShown:d,name:c,type:u,value:m}});break}}}),e}getIrisGridPanelFilters(t,e){const{panelTableMap:n}=this.props,s=n.get(t);if(s==null)return Dt.error(`Unable to get table for panel ${t}.`),null;const{irisGridState:i={advancedFilters:void 0,quickFilters:void 0},gridState:o={}}=e,{advancedFilters:r,quickFilters:l}=i;let a;r&&(a=Xa.changeFilterIndexesToColumnNames(s,r));let d;return l&&(d=Xa.changeFilterIndexesToColumnNames(s,l)),{irisGridState:{...i,advancedFilters:a,quickFilters:d},gridState:{...o}}}handleGetFilterState(){return this.getFilterState()}handleChange({isValueShown:t,selectedId:e}){Dt.debug("handleChange",t,e),this.setState({isValueShown:t,selectedId:e}),this.updatePanelState()}handleFilterApply(t){const{dashboardOpenedPanelMap:e}=this.props,{panels:n,restoreFullState:s=!1}=t;Dt.debug("Apply filters from filter set",t),n.forEach(({panelId:i,type:o,state:r})=>{if(i==null){Dt.debug("panel is null",i);return}if(!e.has(i)){Dt.debug("Ignore closed panel",i);return}Dt.debug("Apply panel filters",i,o,r);const l=e.get(i);switch(o){case ne.getComponentName(Yi):this.restoreIrisGridFilters(l,r,s);break;case ne.getComponentName(_o):case ne.getComponentName(ci):this.restoreInputFilterState(l,r);break}})}handleSetsUpdate(t){const{setDashboardFilterSets:e,localDashboardId:n}=this.props;Dt.debug("Saving updated sets",t),e(n,[...t])}updatePanelState(){this.setState(({selectedId:t,isValueShown:e})=>({panelState:{selectedId:t,isValueShown:e}}))}restoreIrisGridFilters(t,e,n){const{irisGridState:s={},advancedFilters:i=[],quickFilters:o=[]}=e,{advancedFilters:r=i,quickFilters:l=o}=s,{panelTableMap:a}=this.props,d=ne.getIdFromPanel(t);if(d==null){Dt.error("Panel Id is null.");return}if(a.get(d)==null){Dt.error(`Unable to get table for panel ${d}.`);return}Dt.debug("restoreIrisGridFilters",d,e,n),n?t.setStateOverrides(e):t.setFilters({quickFilters:l,advancedFilters:r})}restoreInputFilterState(t,e){const n={...e};delete n.isValueShown,Dt.debug("restoreInputFilterState",t,n),t&&YE(t)&&t.setPanelState(n)}render(){const{glContainer:t,glEventHub:e,filterSets:n}=this.props,{isValueShown:s,selectedId:i}=this.state;return h(jn,{className:"filter-set-manager-panel",componentPanel:this,glContainer:t,glEventHub:e,isClonable:!0,isRenamable:!0,children:h("div",{className:"input-filter-container h-100 w-100 container",children:h(rl,{onChange:this.handleChange,onApply:this.handleFilterApply,onUpdateSets:this.handleSetsUpdate,isValueShown:s,filterSets:n,selectedId:i,getFilterState:this.handleGetFilterState})})})}};let ac=Xa;ac.defaultProps={panelState:null};ac.COMPONENT="FilterSetManagerPanel";const XE=(t,e)=>{const{localDashboardId:n}=e;return{filterSets:uE(t,n),dashboardOpenedPanelMap:jm(t,n),dashboardInputFilters:Xd(t,n),panelTableMap:jd(t,n)}},wa=Nt(XE,{setDashboardFilterSets:wE},null,{forwardRef:!0})(ac);const Vh=X.module("LogPanel");class Gl extends S.exports.PureComponent{constructor(e){super(e),this.handleResize=this.handleResize.bind(this),this.handleShow=this.handleShow.bind(this),this.handleHide=this.handleHide.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.isBottomVisible=!0,this.logView=null;const{session:n}=this.props;this.state={session:n}}handleResize(){this.updateDimensions()}handleShow(){this.updateDimensions(),this.logView&&(this.logView.triggerFindWidget(),this.isBottomVisible&&this.logView.scrollToBottom())}handleHide(){this.logView&&(this.isBottomVisible=this.logView.isBottomVisible())}handleSessionOpened(e){Vh.debug("Session opened",[e]),this.setState({session:e})}handleSessionClosed(e){Vh.debug("Session closed",e)}updateDimensions(){this.logView&&this.logView.updateDimensions()}render(){const{glContainer:e,glEventHub:n}=this.props,{session:s}=this.state;return v(jn,{componentPanel:this,glContainer:e,glEventHub:n,onResize:this.handleResize,onHide:this.handleHide,onShow:this.handleShow,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,children:[s==null&&h("div",{className:"log-panel-disconnected-message",children:"Waiting for session connection"}),s!=null&&h(Ji,{session:s,ref:i=>{this.logView=i}})]})}}Gl.defaultProps={session:null};Gl.COMPONENT="LogPanel";Gl.TITLE="Log";const jE=(t,e)=>{var n;return{session:(n=gi(t,e.localDashboardId))==null?void 0:n.session}},ll=Nt(jE,null,null,{forwardRef:!0})(Gl);class Ap extends S.exports.PureComponent{render(){const{isEditing:e,children:n,onDoubleClick:s}=this.props;return v("div",{className:"markdown-editor-container h-100 w-100",onDoubleClick:s,children:[h("div",{className:W("text-muted","edit-hint",{viewing:e===void 0||!e}),children:v("span",{children:["double-click to edit ",h(j,{icon:ml})]})}),n]})}}Ap.defaultProps={isEditing:!1};const QE=X.module("MarkdownStartPage");class Pp extends S.exports.PureComponent{constructor(e){super(e),this.handleDeleteButtonClick=this.handleDeleteButtonClick.bind(this),this.handleDeleteModalClose=this.handleDeleteModalClose.bind(this),this.state={isDeleteModalShown:!1}}handleDeleteButtonClick(e){this.setState({isDeleteModalShown:!0,toBeDeleted:e})}handleDeleteModalClose(){this.setState({isDeleteModalShown:!1,toBeDeleted:void 0})}handleDeleteMarkdown(e){if(QE.debug("delete markdown: ",e),e!==void 0){const{onDelete:n}=this.props;n(e)}this.setState({isDeleteModalShown:!1,toBeDeleted:void 0})}render(){const{closedMarkdowns:e,onOpen:n,onCreate:s}=this.props,{isDeleteModalShown:i,toBeDeleted:o}=this.state;return h("div",{className:"markdown-panel-start-page h-100 w-100",children:v("div",{className:"markdown-panel-start-page-container",children:[v("div",{className:"markdown-panel-start-list",children:[h("h3",{className:"list-title",children:"Start"}),h("div",{className:"list-item",children:h(z,{kind:"ghost",className:"title",onClick:s,children:"New Markdown Note"})})]}),v("div",{className:"markdown-panel-start-list",children:[h("h3",{className:"list-title",children:"Recently Closed from Dashboard"}),e.map(r=>v("div",{className:"list-item",children:[h(z,{kind:"ghost",className:"title",onClick:()=>n(r),children:r.title}),h("button",{className:"btn-link icon",type:"button",onClick:()=>{this.handleDeleteButtonClick(r)},children:h(j,{icon:wn})})]},r.id)),v($o,{isOpen:i,toggle:this.handleDeleteModalClose,className:"modal-dialog-centered markdown-delete-modal theme-bg-light",children:[h(zo,{children:"Are you sure you want to permanently delete this note?"}),h(Wo,{children:"You can't undo this action."}),v(od,{children:[h(z,{kind:"secondary",onClick:this.handleDeleteModalClose,children:"Cancel"}),h(z,{kind:"danger",onClick:()=>{this.handleDeleteMarkdown(o)},children:"Delete"})]})]})]})]})})}}Pp.defaultProps={closedMarkdowns:[],onOpen:()=>{},onCreate:()=>{},onDelete:()=>{}};const ZE=t=>{const{children:e,className:n}=t,s=n!==void 0&&(n==null?void 0:n.startsWith("language-"))?n.substring(9):"plaintext";return h("pre",{children:h("code",{children:h(yl,{language:s,children:Y.Children.map(e,i=>typeof i=="string"?i.trim():i)})})})};class Hp extends S.exports.PureComponent{constructor(e){super(e),this.container=null}render(){const{isEditing:e,content:n,onEditorInitialized:s}=this.props;return h("div",{className:"markdown-editor-container",ref:i=>{this.container=i},children:e?h(Il,{settings:{language:"markdown",value:n,lineNumbers:"off"},onEditorInitialized:s}):h(ou,{components:{code:ZE},children:n})})}}Hp.defaultProps={isEditing:!1,content:""};const Fr=X.module("MarkdownPanel");class dc extends S.exports.Component{constructor(e){super(e),this.getClosedMarkdowns=pe(i=>i.filter(o=>o.component==="MarkdownPanel").reverse()),this.handleContainerDoubleClick=this.handleContainerDoubleClick.bind(this),this.handleCreateMarkdown=this.handleCreateMarkdown.bind(this),this.handleDeleteMarkdown=this.handleDeleteMarkdown.bind(this),this.handleOpenMarkdown=this.handleOpenMarkdown.bind(this),this.handleEditorInitialized=this.handleEditorInitialized.bind(this),this.handleEditorBlur=this.handleEditorBlur.bind(this),this.handleEditorResize=this.handleEditorResize.bind(this);const{panelState:n}=e;let s=null;n!=null&&n.content!=null&&({content:s}=n),this.state={isStartPageShown:s==null,isEditing:!1,content:s,panelState:n},this.markdownEditor=null}setEditorPosition(e){var s,i;P(this.markdownEditor);const{container:n}=this.markdownEditor;if(this.editor&&n){const o=n.getBoundingClientRect().top,r=n.scrollTop,l=n.scrollHeight,a=(i=(s=this.editor.getModel())==null?void 0:s.getLineCount())!=null?i:0;let d=Math.round((r+e-o)/l*a);d>a&&(d=a),this.editor.revealLine(d),this.editor.setPosition({lineNumber:d,column:1}),this.editor.focus()}}handleContainerDoubleClick(e){const{isEditing:n}=this.state,s=e.clientY;n||this.setState({isEditing:!0},()=>{this.setEditorPosition(s)})}handleEditorInitialized(e){Fr.debug("Markdown Editor Initialized..."),this.editor=e}handleCreateMarkdown(){Fr.debug("create markdown..."),this.setState({isStartPageShown:!1,content:"",isEditing:!0,panelState:{content:""}},()=>{this.editor!=null&&this.editor.focus!=null&&this.editor.focus()})}handleOpenMarkdown(e){Fr.debug("open markdown...",e);const{glContainer:n,glEventHub:s}=this.props,i=ne.getComponentConfigFromContainer(n);s.emit(Ne.REOPEN,e,i)}handleDeleteMarkdown(e){const{glEventHub:n}=this.props;n.emit(Ne.DELETE,e)}handleEditorBlur(e){var i;Fr.debug("markdown content changed, saving...");const{isEditing:n}=this.state;if(!n||this.markdownEditor!=null&&this.markdownEditor.container!=null&&this.markdownEditor.container.contains(e.relatedTarget))return;const s=(i=this.editor)==null?void 0:i.getValue();this.setState({content:s,isEditing:!1,panelState:{content:s}})}handleEditorResize(){const{isEditing:e}=this.state;e&&this.editor&&this.editor.layout()}render(){const{glContainer:e,glEventHub:n,closedPanels:s}=this.props,{isEditing:i,isStartPageShown:o,content:r}=this.state,l=this.getClosedMarkdowns(s);return h(jn,{glContainer:e,glEventHub:n,className:"markdown-panel",componentPanel:this,onResize:this.handleEditorResize,onBlur:this.handleEditorBlur,isClonable:!0,isRenamable:!0,children:o?h(Pp,{closedMarkdowns:l,onCreate:this.handleCreateMarkdown,onOpen:this.handleOpenMarkdown,onDelete:this.handleDeleteMarkdown}):h(Ap,{isEditing:i,onDoubleClick:this.handleContainerDoubleClick,children:h(Hp,{ref:a=>{this.markdownEditor=a},isEditing:i,content:r!=null?r:void 0,onEditorInitialized:this.handleEditorInitialized})})})}}dc.defaultProps={panelState:null};dc.COMPONENT="MarkdownPanel";const JE=(t,e)=>{const{localDashboardId:n}=e;return{closedPanels:ww(t,n)}},So=Nt(JE,null,null,{forwardRef:!0})(dc);class Vp extends S.exports.PureComponent{constructor(e){super(e),this.handleRunSelected=this.handleRunSelected.bind(this),this.renderCodeBlock=this.renderCodeBlock.bind(this),this.renderLink=this.renderLink.bind(this),this.commands=new Map,this.codeElements=new Map,this.editorScrollView=Y.createRef(),this.state={hasCode:!1,hasRunCode:!1,nextStartLine:null}}componentDidMount(){this.updateHasCode()}componentDidUpdate(){this.updateHasCode()}updateHasCode(){const{hasCode:e}=this.state;this.commands.size===0&&e?this.setState({hasCode:!1}):this.commands.size>0&&!e&&this.setState({hasCode:!0})}getNextStartLine(e){const n=[...this.commands.keys()],s=n.findIndex(i=>i===e)+1;return s>=n.length?null:n[s]}handleRunSelected(e){var c,u,m;e.preventDefault(),e.stopPropagation();const{nextStartLine:n}=this.state,s=[...this.commands.keys()],i=s.findIndex(p=>p===n||n==null);if(i<0)return;const o=s[i],r=this.commands.get(o),l=this.getNextStartLine(o),a=(c=this.codeElements.get(o))==null?void 0:c.current,d=(u=a==null?void 0:a.parentElement)==null?void 0:u.nextElementSibling;if(d!=null){const{offsetTop:p}=d,g=p;(m=this.editorScrollView.current)==null||m.scroll({top:g,left:0})}this.runCode(r),this.setState({nextStartLine:l})}runCode(e){const{onRunCode:n}=this.props;n(e),this.setState({hasRunCode:!0})}renderCodeBlock(e){const{children:n,className:s,inline:i,node:o}=e,{hasRunCode:r,nextStartLine:l}=this.state,{children:a,position:d}=o;P(d);const{start:c}=d,{line:u}=c,m=a[0].value,p=Y.createRef(),g=this.commands.size===0,f=l===u||g&&l==null&&!r,b=s!==void 0&&s.startsWith("language-")?s.substring(9):"plaintext";return i!=null&&i?h("code",{className:s,children:n}):(this.commands.set(u,m),this.codeElements.set(u,p),v("div",{className:W("markdown-notebook-code-block",{"is-selected":f}),ref:p,onClick:()=>{this.setState({nextStartLine:u})},role:"presentation",children:[h(z,{kind:"ghost",icon:qr,className:"btn-play-block",onClick:C=>{C.stopPropagation(),C.preventDefault(),this.runCode(m),this.setState({nextStartLine:u})},tooltip:"Run code"}),h("code",{children:h(yl,{language:b,children:Y.Children.map(n,C=>typeof C=="string"?C.trim():C)})})]}))}renderLink(e){const{onLinkClick:n}=this.props,{href:s,children:i,target:o}=e;return h("a",{href:s,onClick:n,target:o,children:i})}render(){const{content:e,transformImageUri:n,transformLinkUri:s}=this.props,{hasCode:i,hasRunCode:o,nextStartLine:r}=this.state;return v("div",{className:"markdown-notebook",children:[h("div",{className:"markdown-notebook-toolbar",children:h(z,{className:W("btn-play-selected-cell",{flashing:i&&!o}),kind:"ghost",icon:qr,onClick:this.handleRunSelected,tooltip:"Run code and select next",disabled:o&&r==null||!i,children:"Run Selected Code"})}),h("div",{className:"markdown-notebook-content",ref:this.editorScrollView,children:h(ou,{components:{code:this.renderCodeBlock,a:this.renderLink},linkTarget:"_blank",remarkPlugins:[fg],transformLinkUri:s,transformImageUri:n,includeElementIndex:!0,children:e})})]})}}Vp.defaultProps={onRunCode:()=>{}};const Ue=X.module("NotebookPanel"),Uh=400,_i=class extends S.exports.Component{constructor(t){super(t),this.getSettings=pe((u,m)=>({...u,minimap:{enabled:m}})),this.getOverflowActions=pe((u,m)=>[{title:"Find",icon:Zf,action:this.handleFind,group:oe.groups.high,shortcut:Ut.NOTEBOOK.FIND,order:10},{title:"Show Minimap",icon:u?ds:void 0,action:this.handleMinimapChange,group:oe.groups.medium,shortcut:Ut.NOTEBOOK.MINIMAP,order:20},{title:"Word Wrap",icon:m?ds:void 0,action:this.handleWordWrapChange,group:oe.groups.medium,shortcut:Ut.NOTEBOOK.WORDWRAP,order:30}]),this.handleBlur=this.handleBlur.bind(this),this.handleCloseCancel=this.handleCloseCancel.bind(this),this.handleCloseDiscard=this.handleCloseDiscard.bind(this),this.handleCloseSave=this.handleCloseSave.bind(this),this.handleCopy=this.handleCopy.bind(this),this.handleEditorInitialized=this.handleEditorInitialized.bind(this),this.handleEditorWillDestroy=this.handleEditorWillDestroy.bind(this),this.handleEditorChange=this.handleEditorChange.bind(this),this.handleFind=this.handleFind.bind(this),this.handleMinimapChange=this.handleMinimapChange.bind(this),this.handleWordWrapChange=this.handleWordWrapChange.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleLinkClick=this.handleLinkClick.bind(this),this.handleLoadSuccess=this.handleLoadSuccess.bind(this),this.handleLoadError=this.handleLoadError.bind(this),this.handlePanelTabClick=this.handlePanelTabClick.bind(this),this.handleRenameFile=this.handleRenameFile.bind(this),this.handleResize=this.handleResize.bind(this),this.handleRunCommand=this.handleRunCommand.bind(this),this.handleRunAll=this.handleRunAll.bind(this),this.handleRunSelected=this.handleRunSelected.bind(this),this.handleSave=this.handleSave.bind(this),this.handleSaveAsCancel=this.handleSaveAsCancel.bind(this),this.handleSaveAsSubmit=this.handleSaveAsSubmit.bind(this),this.handleSaveError=this.handleSaveError.bind(this),this.handleSaveSuccess=this.handleSaveSuccess.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleShowRename=this.handleShowRename.bind(this),this.handleTab=this.handleTab.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTransformLinkUri=this.handleTransformLinkUri.bind(this),this.getDropdownOverflowActions=this.getDropdownOverflowActions.bind(this),this.pending=new fs,this.debouncedSavePanelState=je(this.savePanelState.bind(this),Uh),this.debouncedLoad=je(this.load.bind(this),Uh),this.notebook=null,this.tabTitleElement=null,this.tabInitOnce=!1,this.shouldPromptClose=!0;const{isDashboardActive:e,session:n,sessionLanguage:s,panelState:i}=t;let o={value:"",language:"",wordWrap:"off"},r=null,{isPreview:l}=t;i!=null&&({fileMetadata:r=r,isPreview:l=l,settings:o=o}=i);const a=r!=null&&ce.hasPath(r.itemName),c=a===!0&&o.value!=null||!a&&o.value!=null&&o.value.length>0?1:0;this.state={error:void 0,isDashboardActive:e,isFocused:!1,isLoading:!0,isLoaded:!1,isPreview:l,savedChangeCount:0,changeCount:c,fileMetadata:r,settings:o,session:n,sessionLanguage:s,panelState:{fileMetadata:r,settings:o},showCloseModal:!1,showSaveAsModal:!1,scriptCode:""},Ue.debug("constructor",t,this.state)}static handleError(t){Te.isCanceled(t)||Ue.error(t)}static languageFromFileName(t){switch(ce.getExtension(t).toLowerCase()){case"py":case"python":return"python";case"groovy":return"groovy";case"scala":return"scala";default:return null}}componentDidMount(){const{glContainer:t,glEventHub:e}=this.props,{tab:n}=t;n!=null&&this.initTab(n),this.initNotebookContent(),e.on(He.RENAME_FILE,this.handleRenameFile),t.on("tabClicked",this.handlePanelTabClick)}componentDidUpdate(t,e){const{isPreview:n,settings:s}=this.state,{wordWrap:i}=s,{defaultNotebookSettings:o}=this.props;n!==e.isPreview&&this.setPreviewStatus(),i!==e.settings.wordWrap&&(this.updateEditorWordWrap(),this.debouncedSavePanelState()),o.isMinimapEnabled!==t.defaultNotebookSettings.isMinimapEnabled&&this.updateEditorMinimap()}componentWillUnmount(){this.debouncedSavePanelState.flush(),this.pending.cancel();const{glContainer:t,glEventHub:e}=this.props,{fileMetadata:n,isPreview:s}=this.state;e.off(He.RENAME_FILE,this.handleRenameFile),t.off("tabClicked",this.handlePanelTabClick),e.emit(He.UNREGISTER_FILE,n,s)}initTab(t){this.tabInitOnce||(this.tabInitOnce=!0,this.initTabCloseOverride()),this.initTabClasses(t)}initTabCloseOverride(){const{glContainer:t}=this.props,e=t.close.bind(t);t.close=()=>{const{changeCount:n,savedChangeCount:s}=this.state;return n!==s&&this.shouldPromptClose?this.setState({showCloseModal:!0}):e(),!0}}initTabClasses(t){const e=t.element.get(0);P(e);const n=e.querySelector(".lm_title");this.tabTitleElement=n,n==null||n.classList.add("notebook-title"),this.setPreviewStatus()}getNotebookValue(){const{changeCount:t,savedChangeCount:e,settings:n}=this.state,{value:s}=n;if(t!==e&&this.notebook){const i=this.notebook.getValue();return i!=null?i:s}return s}initNotebookContent(){const{fileMetadata:t,settings:e,isPreview:n}=this.state;if(t&&t.id){Ue.debug("Init content from file"),this.registerFileMetadata(t,n),this.load();return}if(e.value!=null){Ue.debug("Use content passed in the settings prop"),this.handleLoadSuccess();return}this.handleLoadError(new Error("Missing file metadata"))}closeFileTabById(t){const{glEventHub:e}=this.props;e.emit(He.CLOSE_FILE,{id:t})}registerFileMetadata(t,e){const{glEventHub:n,metadata:s}=this.props,{id:i}=s;n.emit(He.REGISTER_FILE,i,t,e)}renameTab(t,e){const{glEventHub:n}=this.props;n.emit(He.RENAME,t,e)}load(){const{fileMetadata:t,settings:e}=this.state;P(t);const{id:n}=t,{fileStorage:s}=this.props;this.pending.add(s.loadFile(n)).then(i=>{var a;Ue.debug("Loaded file",i);const{filename:o}=i,{itemName:r}=this.state;if(o!==r){const{metadata:d}=this.props,{id:c}=d;this.renameTab(c,ce.getBaseName(o))}const l={...e,language:(a=_i.languageFromFileName(o))!=null?a:""};e.value==null&&(l.value=i.content),e.wordWrap===void 0&&(e.wordWrap="off"),this.setState({fileMetadata:{id:o,itemName:o},settings:l}),this.debouncedSavePanelState()}).then(this.handleLoadSuccess).catch(this.handleLoadError)}save(){const{fileMetadata:t}=this.state;if(t&&ce.hasPath(t.itemName)){const e=this.getNotebookValue();return e!==void 0?(this.saveContent(t.itemName,e),!0):!1}return this.setState({showSaveAsModal:!0}),!1}saveContent(t,e){Ue.debug("saveContent",t,e),this.updateSavedChangeCount();const{fileStorage:n}=this.props;this.pending.add(n.saveFile({filename:t,content:e,basename:t})).then(this.handleSaveSuccess).catch(this.handleSaveError)}updateSavedChangeCount(){this.setState(({changeCount:t})=>({savedChangeCount:t}))}setPreviewStatus(){if(!this.tabTitleElement)return;const{isPreview:t}=this.state;Ue.debug("setPreviewStatus",this.tabTitleElement,t),t?this.tabTitleElement.classList.add("is-preview"):this.tabTitleElement.classList.remove("is-preview")}savePanelState(){this.setState(t=>{const{changeCount:e,savedChangeCount:n,fileMetadata:s,isPreview:i,settings:o}=t,r=this.getNotebookValue(),l=e!==n?r:void 0,a={...o,value:r},c={settings:{...o,value:l},fileMetadata:s,isPreview:i};return Ue.debug("Saving panel state",c),{settings:a,panelState:c}})}handleCloseDiscard(){this.shouldPromptClose=!1,this.setState({showCloseModal:!1});const{glContainer:t}=this.props;t.close()}handleCloseSave(){if(this.shouldPromptClose=!1,this.setState({showCloseModal:!1}),this.save()){const{glContainer:t}=this.props;t.close()}}handleCloseCancel(){this.shouldPromptClose=!0,this.setState({showCloseModal:!1})}handleCopy(){const{fileMetadata:t,settings:e}=this.state;P(t);const n=this.getNotebookValue(),{language:s}=e,{itemName:i}=t,o=ce.getCopyFileName(i);Ue.debug("handleCopy",t,i,o),this.createNotebook(o,s,n)}handleEditorInitialized(t){this.editor=t}handleEditorWillDestroy(){this.editor=void 0}handleEditorChange(t){Ue.debug2("handleEditorChanged",t),this.removePreviewStatus(),this.setState(e=>{const{changeCount:n,savedChangeCount:s}=e,{isUndoing:i,isRedoing:o}=t;return i?{changeCount:n-1,savedChangeCount:s}:!o&&n<s?{changeCount:n+1,savedChangeCount:0}:{changeCount:n+1,savedChangeCount:s}}),this.debouncedSavePanelState()}handleFind(){this.notebook&&this.notebook.toggleFind()}updateEditorMinimap(){if(this.editor){const{defaultNotebookSettings:t}=this.props;this.editor.updateOptions({minimap:{enabled:t.isMinimapEnabled}})}}handleMinimapChange(){const{settings:t,defaultNotebookSettings:e,saveSettings:n}=this.props,s={...t,defaultNotebookSettings:{isMinimapEnabled:!e.isMinimapEnabled}};n(s)}updateEditorWordWrap(){if(this.editor){const{settings:t}=this.state,{wordWrap:e}=t;this.editor.updateOptions({wordWrap:e})}}handleWordWrapChange(){this.editor&&this.setState(t=>{const{settings:e}=t,n=e.wordWrap==="on"?"off":"on";return{settings:{...e,wordWrap:n}}})}handleBlur(){Ue.debug("handleBlur"),this.setState({isFocused:!1})}handleFocus(){Ue.debug("handleFocus"),this.setState({isFocused:!0})}handleLinkClick(t){const{notebooksUrl:e,session:n,sessionLanguage:s}=this.props,{href:i}=t.currentTarget;if(!i||!i.startsWith(e))return;t.stopPropagation(),t.preventDefault();const o=`/${i.substring(e.length)}`.replace(/%20/g," ");if(o==="/"){Ue.debug("Ignoring invalid notebook link",o);return}Ue.debug("Notebook link clicked, opening",o);const{glEventHub:r}=this.props,l={value:null,language:s},a={id:o,itemName:o};r.emit(He.SELECT_NOTEBOOK,n,s,l,a)}handleLoadSuccess(){this.setState({error:void 0,isLoaded:!0,isLoading:!1})}handleLoadError(t){let e=t;Te.isCanceled(e)||(Te.isTimedOut(e)&&(e=new Error("File not found.")),Ue.error(e),this.setState({error:e,isLoading:!1}))}handleSave(){Ue.debug("handleSave"),this.save()}handleSaveSuccess(t){var i;const{fileStorage:e}=this.props,n={id:t.filename,itemName:t.filename},s=(i=_i.languageFromFileName(t.filename))!=null?i:"";this.setState(o=>{const{fileMetadata:r}=o,l={...o.settings,language:s};return Ue.debug("handleSaveSuccess",n,r,l),r&&ce.hasPath(r.itemName)&&r.itemName!==n.itemName&&(Ue.debug("handleSaveSuccess deleting old file",r.itemName),e.deleteFile(r.itemName).catch(_i.handleError)),{fileMetadata:n,settings:l,isPreview:!1}}),this.debouncedSavePanelState(),this.registerFileMetadata(n,!1)}handleSaveError(t){Te.isCanceled(t)||(this.setState({savedChangeCount:0}),Ue.error(t))}handleSaveAsCancel(){this.setState({showSaveAsModal:!1})}handleSaveAsSubmit(t){var i;Ue.debug("handleSaveAsSubmit",t);const{fileMetadata:e}=this.state;if(!e)return;const{itemName:n}=e,s=(i=this.getNotebookValue())!=null?i:"";if(this.setState({showSaveAsModal:!1}),ce.getBaseName(n)!==ce.getBaseName(t)){const{metadata:o}=this.props,{id:r}=o;this.renameTab(r,ce.getBaseName(t))}this.saveContent(t,s)}handleRenameFile(t,e){const{fileMetadata:n}=this.state;n&&n.id===t&&(this.setState({fileMetadata:{id:e,itemName:e}}),this.debouncedSavePanelState())}handleResize(){var t;(t=this.notebook)==null||t.updateDimensions()}handleRunCommand(t){this.runCommand(t)}handleRunAll(){var t;if(!this.notebook){Ue.error("Editor is not initialized.");return}this.runCommand((t=this.notebook.getValue())!=null?t:void 0)}handleRunSelected(){if(!this.notebook){Ue.error("Editor is not initialized.");return}this.runCommand(this.notebook.getSelectedCommand())}handleSessionOpened(t,{language:e}){this.setState({session:t,sessionLanguage:e})}handleSessionClosed(){this.setState({session:void 0,sessionLanguage:void 0})}handleShow(){var t;Ue.debug("handleShow"),(t=this.notebook)==null||t.updateDimensions()}handleShowRename(){this.setState({showSaveAsModal:!0})}handleTab(t){Ue.debug("NotebookPanel tab event",t),this.initTab(t)}handleTabFocus(...t){Ue.debug("handleTabFocus",...t);const{glContainer:e}=this.props;this.setState({isDashboardActive:!0}),this.notebook&&!e.isHidden&&this.notebook.updateDimensions()}handleTabBlur(){Ue.debug("handleTabBlur"),this.setState({isDashboardActive:!1})}handlePanelTabClick(){Ue.debug("handlePanelTabClick"),this.focus()}handleTransformLinkUri(t){const{notebooksUrl:e}=this.props,{fileMetadata:n}=this.state;if(t.endsWith("/"))return t;if(t.startsWith("/"))return`${e}${t.substring(1)}`;let s=n==null?void 0:n.itemName;if(s===void 0)return t;s.charAt(0)==="/"&&(s=s.substring(1));const i=new URL(s,e);return new URL(t,i).href}focus(){requestAnimationFrame(()=>{this.notebook&&this.notebook.focus()})}createNotebook(t,e,n=""){const{glEventHub:s}=this.props,{session:i,sessionLanguage:o,settings:r}=this.state,l={...r,language:e,value:n},a={id:null,itemName:t};Ue.debug("handleCreateNotebook",i,o,l,a),s.emit(He.CREATE_NOTEBOOK,i,o,l,a)}runCommand(t){if(t===void 0){Ue.debug("Ignoring empty command.");return}this.removePreviewStatus();const{glEventHub:e}=this.props;e.emit(Ct.SEND_COMMAND,t,!1,!0)}removePreviewStatus(){this.setState(({isPreview:t})=>{if(t){const{fileMetadata:e}=this.state;return e&&this.registerFileMetadata(e,!1),{isPreview:!1}}return null})}getDropdownOverflowActions(){const{defaultNotebookSettings:t}=this.props,{settings:e}=this.state;return this.getOverflowActions(t.isMinimapEnabled,this.getSettings(e,t.isMinimapEnabled).wordWrap==="on")}render(){var k,O;const{fileStorage:t,glContainer:e,glContainer:{tab:n},glEventHub:s,defaultNotebookSettings:i}=this.props,{changeCount:o,savedChangeCount:r,error:l,isDashboardActive:a,isLoaded:d,isLoading:c,isPreview:u,fileMetadata:m,session:p,sessionLanguage:g,settings:f,showCloseModal:b,showSaveAsModal:C}=this.state,w=a&&!e.isHidden&&!u,T=(k=m==null?void 0:m.itemName)!=null?k:_i.DEFAULT_NAME,y=T.endsWith(".md"),E=(m==null?void 0:m.id)!=null,I=this.getSettings(f,i.isMinimapEnabled),D=p!=null,F=g===I.language,x=!d||!D||!F,U=!d,B=[{action:this.handleSave,shortcut:ms.SAVE},{action:this.handleMinimapChange,shortcut:Ut.NOTEBOOK.MINIMAP},{action:this.handleWordWrapChange,shortcut:Ut.NOTEBOOK.WORDWRAP}],_=nh.getDisabledRunTooltip(D,F,"Notebook extension","Run"),H=nh.getDisabledRunTooltip(D,F,"Notebook extension","Run Selected"),A=[{title:E?"Rename":"Save As\u2026",order:10,group:oe.groups.high,action:this.handleShowRename},{title:"Copy File",action:this.handleCopy,group:oe.groups.high,order:20}],N=n==null?void 0:n.element.find(".lm_title_before").get(0);return v(ye,{children:[N&&ui.createPortal(h("span",{className:W("editor-unsaved-indicator",{"is-unsaved":o!==r})}),N),v(jn,{className:"notebook-container",componentPanel:this,glContainer:e,glEventHub:s,onTab:this.handleTab,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleTabFocus,onTabBlur:this.handleTabBlur,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onFocus:this.handleFocus,onBlur:this.handleBlur,additionalActions:A,renderTabTooltip:()=>T,children:[!y&&v(ye,{children:[v("div",{className:"notebook-toolbar",children:[v("span",{children:[h(z,{kind:"ghost",className:"btn-play",onClick:this.handleRunAll,disabled:x,icon:h(j,{icon:qr,transform:"grow-4"}),tooltip:`Run ${Ut.NOTEBOOK.RUN.getDisplayText()}`,"aria-label":"Run"}),_!=null&&h($e,{children:_})]}),v("span",{children:[h(z,{kind:"ghost",className:"btn-play",onClick:this.handleRunSelected,disabled:x,icon:h(j,{icon:dC,transform:"grow-4"}),tooltip:`Run Selected ${Ut.NOTEBOOK.RUN_SELECTED.getDisplayText()}`,"aria-label":"Run Selected"}),H!=null&&h($e,{children:H})]}),h(z,{kind:"ghost",className:"mr-auto",disabled:U,onClick:this.handleSave,icon:bu,tooltip:`Save ${ms.SAVE.getDisplayText()}`,"aria-label":"Save"}),h(z,{kind:"ghost",className:"btn-overflow btn-link-icon",disabled:U,icon:gu,tooltip:"More Actions...",onClick:()=>{},children:h(Fn,{actions:this.getDropdownOverflowActions,popperOptions:_i.POPPER_OPTIONS})})]}),h(om,{isLoaded:d,isLoading:c,error:l,onChange:this.handleEditorChange,onRunCommand:this.handleRunCommand,session:p,sessionLanguage:g,onEditorInitialized:this.handleEditorInitialized,onEditorWillDestroy:this.handleEditorWillDestroy,settings:I,focusOnMount:w,ref:V=>{this.notebook=V}})]}),y&&h(Vp,{content:(O=I.value)!=null?O:"",onLinkClick:this.handleLinkClick,onRunCode:this.handleRunCommand,transformImageUri:this.handleTransformLinkUri,transformLinkUri:this.handleTransformLinkUri}),h(Wl,{isOpen:C,type:"file",defaultValue:T,title:E?"Rename":"Save file as",onSubmit:this.handleSaveAsSubmit,onCancel:this.handleSaveAsCancel,notifyOnExtensionChange:!0,storage:t}),h($i,{isOpen:b,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"}),h(oe,{actions:B})]})]})}};let Zo=_i;Zo.COMPONENT="NotebookPanel";Zo.POPPER_OPTIONS={placement:"bottom-end"};Zo.DEFAULT_NAME="Untitled";Zo.defaultProps={isDashboardActive:!0,isPreview:!1,session:null,sessionLanguage:null,defaultNotebookSettings:null};const e1=(t,e)=>{const n=Cm(t),s=Ft(t),i=MS(t),o=gi(t,e.localDashboardId),{session:r,config:l}=o!=null?o:{},{type:a}=l!=null?l:{};return{fileStorage:n,settings:s,defaultNotebookSettings:i,session:r,sessionLanguage:a}},Ys=Nt(e1,{saveSettings:Td},null,{forwardRef:!0})(Zo);class ko extends S.exports.Component{constructor(e){super(e),this.irisGridRef=Y.createRef(),this.buttonRef=Y.createRef(),this.handleReload=this.handleReload.bind(this),this.handleGridStateChange=this.handleGridStateChange.bind(this),this.handlePanelStateUpdate=this.handlePanelStateUpdate.bind(this);const{panelState:n}=e;this.state={shouldFocusGrid:!1,panelState:n}}handleReload(){var e,n;(e=this.irisGridRef.current)==null||e.initModel(),(n=this.buttonRef.current)==null||n.blur(),this.setState({shouldFocusGrid:!0})}handleGridStateChange(){var n,s,i;const{shouldFocusGrid:e}=this.state;e&&((i=(s=(n=this.irisGridRef.current)==null?void 0:n.irisGrid)==null?void 0:s.current)==null?void 0:i.grid)&&(this.irisGridRef.current.irisGrid.current.grid.focus(),this.setState({shouldFocusGrid:!1}))}handlePanelStateUpdate(e){this.setState({panelState:e})}render(){const{...e}=this.props;return h(hi,{ref:this.irisGridRef,onStateChange:this.handleGridStateChange,onPanelStateUpdate:this.handlePanelStateUpdate,...e,children:v(z,{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",v("span",{children:[h(j,{icon:cd,transform:"shrink-1",className:"mr-1"}),"Reload"]})]})})}}ko.defaultProps={panelState:null};ko.COMPONENT="PandasPanel";function t1(t){Vs(t);const{id:e,layout:n,registerComponent:s,hydrate:i}=t,o=S.exports.useCallback(({dragEvent:r,fetch:l,panelId:a=ze.generate(),widget:d})=>{const{name:c,type:u}=d;if(u!==dh.VariableType.FIGURE)return;const m={name:c,figure:c},p=()=>l().then(b=>zi.makeModel(void 0,b)),g={type:"react-component",component:Bi.COMPONENT,props:{localDashboardId:e,id:a,metadata:m,makeModel:p},title:c,id:a},{root:f}=n;ne.openComponent({root:f,config:g,dragEvent:r})},[e,n]);return S.exports.useEffect(function(){const l=[s(Bi.COMPONENT,Bi,i)];return()=>{l.forEach(a=>a())}},[i,s]),Ke(n.eventHub,Ne.OPEN,o),null}function n1(t){Vs(t);const{id:e,layout:n}=t,s=S.exports.useCallback(({metadata:i,panelId:o=ze.generate(),table:r})=>{const{settings:l}=i,a=()=>zi.makeModelFromSettings(l,r),d=xe.titleFromSettings(l),c={type:"react-component",component:Bi.COMPONENT,props:{localDashboardId:e,id:o,metadata:i,makeModel:a},title:d,id:o},{root:u}=n;ne.openComponent({root:u,config:c})},[e,n]);return Ke(n.eventHub,Tt.CREATE_CHART,s),null}const ct=X.module("ConsolePlugin");function Bh(t){return t.notebook!==void 0}function s1(t){Vs(t)}function i1(t){s1(t);const{id:e,hydrateConsole:n,layout:s,panelManager:i,registerComponent:o,notebooksUrl:r}=t,l=S.exports.useRef(0),[a]=S.exports.useState(new Map),[d]=S.exports.useState(new Map),c=nd(),u=S.exports.useCallback(()=>i.getLastUsedPanelOfType(Li),[i]),m=S.exports.useCallback((N,k=!0,O=!0)=>{if(!(N&&N.trim()))ct.info("Ignoring empty code");else{const G=u();if(!G||!(G instanceof Li.WrappedComponent)){ct.error("Console panel not found");return}ct.debug("Send command: ",N,k,O),G.addCommand(N,k,O)}},[u]),p=S.exports.useCallback(N=>{c(SE(e,N))},[c,e]),g=S.exports.useCallback(({language:N})=>{const k=N==="python"?"py":N;let O=null;return k==null?(ct.debug("No extension for language",N),O=`Untitled-${l.current}`):O=`Untitled-${l.current}.${k}`,l.current+=1,O},[]),f=S.exports.useCallback((N,k=!0)=>{const{id:O}=N;return O!=null&&a.has(O)?a.get(O):O!=null&&d.has(O)?d.get(O):k?ze.generate():null},[a,d]),b=S.exports.useCallback((N,k)=>{ne.renameComponent(s.root,{id:N},k)},[s.root]),C=S.exports.useCallback((N,k)=>{ct.debug("Rename file panel",N,k);let O;if(a.has(N)&&(O=a.get(N),a.delete(N),O!=null&&a.set(k,O)),d.has(N)&&(O=d.get(N),d.delete(N),O!=null&&d.set(k,O)),O===void 0){ct.debug2(`File ${N} isn't open, no need to rename the tab`);return}b(O,ce.getBaseName(k))},[a,d,b]),w=S.exports.useCallback(N=>{const k=f(N,!1);if(k==null){ct.error("Could not find panel id for file metadata",N);return}ne.activateTab(s.root,{id:k})},[f,s.root]),T=S.exports.useCallback((N,k,O)=>{if(ct.debug("registerFilePanel",N,k,O),k==null||k.id==null){ct.debug("Ignore empty file id",k);return}const{id:V}=k;if(O){d.set(V,N);return}if(a.has(V)){const G=a.get(V);if(N===G){ct.debug(`Update tab title for file ${V}`);const{itemName:Q}=k;C(V,ce.getBaseName(Q))}else ct.error(`File ${V} already associated with a different tab ${G}`);return}a.set(V,N),d.has(V)&&d.delete(V)},[a,d,C]),y=S.exports.useCallback((N,k)=>{if(ct.debug("unregisterFileTab",N,k),N==null||N.id==null){ct.debug("Ignore empty file id",N);return}const{id:O}=N;if(k){d.delete(O);return}a.delete(O)},[a,d]),E=S.exports.useCallback(N=>{ct.debug("closeFilePanel",N);const{id:k}=N;let O=null,V=!1;if(a.has(k))O=a.get(k);else if(d.has(k))O=d.get(k),V=!0;else{ct.debug(`File ${k} isn't open, ignore close event`);return}y(N,V),ne.closeComponent(s.root,{id:O})},[s.root,a,d,y]),I=S.exports.useCallback(N=>{const{itemName:k}=N;return ce.getBaseName(k)},[]),D=S.exports.useCallback(N=>{const{id:k}=N;return ct.debug("fileIsOpen",N,k,a),k!=null&&a.has(k)},[a]),F=S.exports.useCallback(N=>{const{id:k}=N;return ct.debug("fileIsOpenAsPreview",N,k,d),k!=null&&d.has(k)},[d]),x=S.exports.useCallback(N=>{if(N==null)return;const k=i.getOpenedPanelById(N);k&&Bh(k)&&k.focus()},[i]),U=S.exports.useCallback(({id:N,settings:k,fileMetadata:O,session:V,sessionLanguage:G,isPreview:Q=!1})=>{const Z={settings:k,fileMetadata:O},be=I(O);return{type:"react-component",component:Ys.COMPONENT,isFocusOnShow:!1,props:{localDashboardId:e,metadata:{id:N},session:V,sessionLanguage:G,panelState:Z,isPreview:Q,notebooksUrl:r},title:be,id:N}},[I,e,r]),B=S.exports.useCallback((N,k,O,V={id:null,itemName:g(O)})=>{const G=f(V);if(D(V)&&G!=null){ct.debug("File is already open, focus panel"),w(V),x(G);return}const Q=ne.getStackForComponentTypes(s.root,[Ys.COMPONENT]),Z=U({id:G,settings:O,fileMetadata:V,session:N,sessionLanguage:k});ct.debug("createNotebook",Z,a),ne.openComponentInStack(Q,Z)},[D,x,g,f,s.root,U,a,w]),_=S.exports.useCallback((N,k,O,V,G=!1)=>{ct.debug("selectNotebook",V,G);const Q=D(V),Z=F(V);if(Q){if(w(V),G){const ee=f(V);x(ee)}return}if(Z&&!G){w(V);return}const[be]=Array.from(d.values());let le=null,he=null;be!=null&&(le=be,he=ne.getStackForConfig(s.root,{component:Ys.COMPONENT,id:le})),he==null&&(le=f(V),he=ne.getStackForComponentTypes(s.root,[Ys.COMPONENT]));const Re=U({id:le,settings:O,fileMetadata:V,session:N,sessionLanguage:k,isPreview:!G});ne.openComponentInStack(he,Re),G&&x(le)},[w,D,F,x,f,s.root,U,d]),H=S.exports.useCallback((N,k,O={},V=!0)=>{const G=i.getLastUsedPanelOfType(Ys);G&&Bh(G)?O!=null&&O.value!=null&&G.notebook!=null&&G.notebook.append(O.value):V&&B(N,k,O)},[B,i]),A=S.exports.useCallback((N,k)=>Ua.hydrate({...N,notebooksUrl:r},k),[r]);return S.exports.useEffect(function(){const k=[o(Li.COMPONENT,Li,n),o(il.COMPONENT,il),o(ol.COMPONENT,ol),o(ll.COMPONENT,ll),o(Ys.COMPONENT,Ys,A)];return()=>{k.forEach(O=>O())}},[o,n,A]),Ke(s.eventHub,Ct.SEND_COMMAND,m),Ke(s.eventHub,Ct.SETTINGS_CHANGED,p),Ke(s.eventHub,He.CLOSE_FILE,E),Ke(s.eventHub,He.CREATE_NOTEBOOK,B),Ke(s.eventHub,He.SELECT_NOTEBOOK,_),Ke(s.eventHub,He.RENAME,b),Ke(s.eventHub,He.RENAME_FILE,C),Ke(s.eventHub,He.SEND_TO_NOTEBOOK,H),Ke(s.eventHub,He.REGISTER_FILE,T),Ke(s.eventHub,He.UNREGISTER_FILE,y),null}const wo=X.module("FilterPlugin");function $h(t,e){return t.concat(e)}function o1(t){Vs(t);const{id:e,layout:n,registerComponent:s}=t,i=nd(),[o]=S.exports.useState(()=>new Map),[r]=S.exports.useState(()=>new Map),[l]=S.exports.useState(()=>new Map),a=S.exports.useCallback(()=>{const b=Array.from(o.values()).reduce($h,[]).sort((T,y)=>{const E=sn.toLower(T.name),I=sn.toLower(y.name);if(E!==I)return E>I?1:-1;const D=sn.toLower(T.type),F=sn.toLower(y.type);return D!==F?D>F?1:-1:0}).reduce((T,y)=>((T.length===0||sn.toLower(T[T.length-1].name)!==sn.toLower(y.name)||sn.toLower(T[T.length-1].type)!==sn.toLower(y.type))&&T.push(y),T),[]),C=Array.from(r.values()).reduce($h,[]).sort((T,y)=>T.timestamp-y.timestamp),w=new Map(l);wo.debug("sendUpdate",{columns:b,filters:C,tableMap:w}),i(Xn(e,{columns:b,filters:C,tableMap:w}))},[i,e,o,r,l]),d=S.exports.useCallback((b,C)=>{wo.debug2("handleColumnsChanged",b,C),o.set(b,[].concat(C)),a()},[o,a]),c=S.exports.useCallback((b,C)=>{wo.debug2("handleFiltersChanged",b,C),r.set(b,[].concat(C)),a()},[r,a]),u=S.exports.useCallback((b,C)=>{wo.debug2("handleTableChanged",b,C),l.set(ne.getIdFromPanel(b),C),a()},[l,a]),m=S.exports.useCallback(b=>{wo.debug2("handlePanelUnmount",b),o.delete(b),r.delete(b),l.delete(ne.getIdFromPanel(b)),a()},[o,r,l,a]),p=S.exports.useCallback(({title:b="DropdownFilter",metadata:C={},panelState:w=null,id:T=ze.generate(),focusElement:y=ne.DEFAULT_FOCUS_SELECTOR,createNewStack:E=!1,dragEvent:I=null})=>{const D={type:"react-component",component:ci.COMPONENT,props:{id:T,metadata:C,panelState:w,localDashboardId:e},title:b,id:T},{root:F}=n;ne.openComponent({root:F,config:D,focusElement:y,createNewStack:E,dragEvent:I})},[n,e]),g=S.exports.useCallback(({title:b="InputFilter",metadata:C={},panelState:w=null,id:T=ze.generate(),focusElement:y=ne.DEFAULT_FOCUS_SELECTOR,createNewStack:E=!1,dragEvent:I=null})=>{const D={type:"react-component",component:_o.COMPONENT,props:{id:T,metadata:C,panelState:w,localDashboardId:e},title:b,id:T},{root:F}=n;ne.openComponent({root:F,config:D,focusElement:y,createNewStack:E,dragEvent:I})},[n,e]),f=S.exports.useCallback(({title:b="FilterSets",metadata:C={},panelState:w=null,id:T=ze.generate(),focusElement:y=ne.DEFAULT_FOCUS_SELECTOR,createNewStack:E=!1,dragEvent:I=null})=>{const D={type:"react-component",component:wa.COMPONENT,props:{id:T,metadata:C,panelState:w,localDashboardId:e},title:b,id:T},{root:F}=n;ne.openComponent({root:F,config:D,focusElement:y,createNewStack:E,dragEvent:I})},[n,e]);return S.exports.useEffect(function(){const C=[s(ci.COMPONENT,ci),s(_o.COMPONENT,_o),s(wa.COMPONENT,wa)];return()=>{C.forEach(w=>w())}},[s]),Ke(n.eventHub,Pe.COLUMNS_CHANGED,d),Ke(n.eventHub,Pe.FILTERS_CHANGED,c),Ke(n.eventHub,Pe.TABLE_CHANGED,u),Ke(n.eventHub,Pe.OPEN_DROPDOWN,p),Ke(n.eventHub,Pe.OPEN_INPUT,g),Ke(n.eventHub,Pe.OPEN_FILTER_SET_MANAGER,f),Ke(n.eventHub,Ne.UNMOUNT,m),null}const r1=[dh.VariableType.TABLE,dh.VariableType.TREETABLE];function l1(t){Vs(t);const{getDownloadWorker:e,loadPlugin:n,id:s,layout:i,registerComponent:o,hydrate:r,theme:l}=t,a=S.exports.useCallback(({dragEvent:d,fetch:c,panelId:u=ze.generate(),widget:m})=>{const{name:p,type:g}=m;if(!r1.includes(g))return;const f={name:p,table:p},b=()=>c().then(T=>qd.makeModel(T)),C={type:"react-component",component:hi.COMPONENT,props:{getDownloadWorker:e,loadPlugin:n,localDashboardId:s,id:u,metadata:f,makeModel:b,theme:l},title:p,id:u},{root:w}=i;ne.openComponent({root:w,config:C,dragEvent:d})},[e,s,i,n,l]);return S.exports.useEffect(function(){const c=[o(hi.COMPONENT,hi,r)];return()=>{c.forEach(u=>u())}},[r,o]),Ke(i.eventHub,Ne.OPEN,a),null}function Up(t){return typeof t.getCoordinateForColumn=="function"}function Wh(t){const e=t;return Up(t)&&typeof e.setFilterMap=="function"&&typeof e.unsetFilterValue=="function"}const vo=X.module("LinkerUtils"),Bp=class{static getLinkType(t,e,n){var l;if((t==null?void 0:t.panelId)==null||(e==null?void 0:e.panelId)==null||t.panelId===e.panelId||n!=null&&n!==t.panelId&&n!==e.panelId)return vo.debug2("Incompatible panel ids",t,e,n),"invalid";if(t.panelComponent==null||e.panelComponent==null)return vo.error("PanelComponent should not be null",t,e),"invalid";const s=(l=Bp.ALLOWED_LINKS.get(t.panelComponent))==null?void 0:l.includes(e.panelComponent);if(s===void 0||!s)return vo.debug2("Incompatible panel components",t,e),"invalid";const{columnType:i}=t,{columnType:o}=e;if(!(o===null||L.isCompatibleType(i,o)))return vo.debug2("Incompatible type",i,o),"invalid";switch(e.panelComponent){case ne.getComponentName(Bi):case ne.getComponentName(hi):return"tableLink";case ne.getComponentName(ci):return"filterSource"}return vo.debug2("Incompatible target panel component",e.panelComponent),"invalid"}static findColumn(t,{columnName:e,columnType:n}){return t.find(({name:s,type:i})=>s===e&&i===n)}static cloneLinksForPanel(t,e,n){const s=[];return t.forEach(i=>{var o;i.start.panelId===e&&i.type!=="filterSource"?s.push({...i,id:ze.generate(),start:{...i.start,panelId:n}}):((o=i.end)==null?void 0:o.panelId)===e&&s.push({...i,id:ze.generate(),end:{...i.end,panelId:n}})}),s}};let ni=Bp;ni.ALLOWED_LINKS=new Map([[ne.getComponentName(hi),[ne.getComponentName(hi),ne.getComponentName(Bi),ne.getComponentName(ci)]]]);const a1=X.module("LinkerLink"),zh=.015,Gh=1.5,$p=12,Wp=12,Kh=2,xr=Math.sqrt((Wp*.5)**2+$p**2),qh=Math.asin(Wp*.5/$p),Yh=15,xs=Math.PI*.5,$r=class extends S.exports.Component{constructor(t){super(t),this.getOperators=pe((e,n)=>{const{onOperatorChanged:s}=this.props;let i=L.getFilterTypes(n);return L.isBooleanType(n)&&(i=[q.eq,q.notEq]),i.flatMap((o,r)=>{if(o==="eqIgnoreCase"||o==="notEqIgnoreCase")return[];let l="";return o==="startsWith"?l="a*":o==="endsWith"?l="*z":l=L.getFilterOperatorString(o),[{title:$r.getLabelForLinkFilter(n,o),icon:h("b",{children:l}),action:()=>s(e,o),order:r}]})}),this.handleClick=this.handleClick.bind(this),this.handleMouseEnter=this.handleMouseEnter.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleDelete=this.handleDelete.bind(this),this.getDropdownActions=this.getDropdownActions.bind(this),this.state={isHovering:void 0}}static makeCirclePath(t,e,n){return`M ${t} ${e} m -${n},0 a ${n},${n} 0 1,0 ${n*2},0 a ${n},${n} 0 1,0 -${n*2},0 z`}static getLabelForLinkFilter(t,e){try{if(L.isNumberType(t)||L.isCharType(t))return cm(e);if(L.isTextType(t))return dm(e);if(L.isDateType(t))return hm(e);if(L.isBooleanType(t)){if(e===q.eq)return"is equal to";if(e===q.notEq)return"is not equal to"}throw new Error(`Unrecognized column type: ${t}`)}catch(n){return a1.warn(n),""}}handleClick(t){t.stopPropagation(),t.preventDefault();const{id:e,onClick:n,onDelete:s}=this.props;t.altKey?s(e):n(e)}handleMouseEnter(){this.setState({isHovering:!0})}handleMouseLeave(){this.setState({isHovering:!1})}handleDelete(){const{id:t,onDelete:e}=this.props;e(t)}getDropdownActions(){const{id:t,startColumnType:e}=this.props;return e!=null?this.getOperators(t,e):[]}render(){const{className:t,operator:e,isSelected:n,x1:s,y1:i,x2:o,y2:r,id:l,startColumnType:a}=this.props,{isHovering:d}=this.state,c=Math.sqrt((s-o)**2+(i-r)**2),u=Math.atan2(r-i,o-s),m=Math.sin(u),p=Math.cos(u)+2,g=window.innerWidth,f=window.innerHeight,b=0,C=0,w=Math.max(b,Math.min(s+(o-s)/2+m*(c*zh)**Gh,g)),T=Math.max(C,Math.min(i+(r-i)/2+p*(c*zh)**Gh,f)),y=`M ${s} ${i} Q ${w} ${T} ${o} ${r}`,E=`M ${b} ${C} L ${b} ${f} L ${g} ${f} L ${g} ${C} z
38
+ ${l} does not exist yet.`}if(i){const{widgetName:r}=this.props;return`${r} is unavailable.`}}handleSessionClosed(...e){const{onSessionClose:n}=this.props;this.setState({isPanelDisconnected:!0,isWaitingForReconnect:!1}),n(...e)}handleSessionOpened(...e){const{onSessionOpen:n}=this.props;n(...e)}render(){const{children:e,className:n,componentPanel:s,isLoaded:i,isLoading:o,glContainer:r,glEventHub:l,isDisconnected:a,isClonable:d,isRenamable:c,showTabTooltip:u,renderTabTooltip:m,widgetType:p,widgetName:g,description:f,onClearAllFilters:b,onHide:C,onFocus:w,onBlur:T,onResize:y,onShow:E,onTabBlur:I,onTabFocus:D,onTabClicked:F}=this.props,{isPanelDisconnected:x,isWidgetDisconnected:U,isPanelInactive:B}=this.state,_=this.getErrorMessage(),H=m!=null?m:this.getCachedRenderTabTooltip(u,r,p,g,f),A=[{title:`Copy ${p} Name`,group:oe.groups.medium,order:20,action:this.handleCopyName}];return v(jn,{className:W(n,{disconnected:x||U||a,inactive:B}),componentPanel:s,glContainer:r,glEventHub:l,onClearAllFilters:b,onHide:C,onFocus:w,onBlur:T,onResize:y,onShow:E,onSessionClose:this.handleSessionClosed,onSessionOpen:this.handleSessionOpened,onTabBlur:I,onTabFocus:D,onTabClicked:F,renderTabTooltip:H,errorMessage:_,isLoaded:i,isLoading:o,isClonable:d,isRenamable:c,additionalActions:A,children:[e,B&&h("div",{className:"fill-parent-absolute"})]})}}Ul.defaultProps={className:"",errorMessage:null,isClonable:!0,isDisconnected:!1,isLoading:!1,isLoaded:!0,isRenamable:!0,showTabTooltip:!0,widgetName:"Widget",widgetType:"Widget",renderTabTooltip:null,description:"",onFocus:()=>{},onBlur:()=>{},onHide:()=>{},onClearAllFilters:()=>{},onResize:()=>{},onSessionClose:()=>{},onSessionOpen:()=>{},onShow:()=>{},onTabBlur:()=>{},onTabFocus:()=>{},onTabClicked:()=>{}};const hn=Object.freeze({DEFAULT:"DEFAULT",LINKER:"LINKER"}),aE="SET_SESSION_WRAPPER",dE=Hs(aE,null),cE={sessionWrapper:dE},hE=new Map,Bl=Object.freeze([]),Fp=(t,e)=>{var n;return(n=jt(t,e).columns)!=null?n:Bl},uE=(t,e)=>{var n;return(n=jt(t,e).filterSets)!=null?n:Bl},Xd=(t,e)=>{var n;return(n=jt(t,e).filters)!=null?n:Bl},jd=(t,e)=>{var n;return(n=jt(t,e).tableMap)!=null?n:hE},Qd=(t,e)=>jt(t,e).isolatedLinkerPanelId,oo=(t,e)=>{var n;return(n=jt(t,e).links)!=null?n:Bl},Zd=(t,e)=>jt(t,e).columnSelectionValidator,mE=(t,e)=>jt(t,e).connection,gi=(t,e)=>jt(t,e).sessionWrapper,pE=(t,e)=>n=>n(Xn(t,{connection:e})),gE=(t,e)=>n=>n(Xn(t,{sessionWrapper:e})),Jd=(t,e)=>n=>n(Xn(t,{links:e})),fE=(t,e)=>(n,s)=>{const i=oo(s(),t),o=e.filter(r=>i.findIndex(l=>ht(l.start,r.start)&&ht(l.end,r.end))<0);return n(Jd(t,i.concat(o)))},CE=(t,e)=>(n,s)=>{const o=oo(s(),t).filter(r=>!e.includes(r.id));return n(Jd(t,o))},xp=(t,e)=>n=>n(Xn(t,{isolatedLinkerPanelId:e})),bE=(t,e)=>n=>n(Xn(t,{columnSelectionValidator:e})),SE=(t,e)=>n=>n(Xn(t,{consoleSettings:e})),wE=(t,e)=>n=>n(Xn(t,{filterSets:e}));Object.entries(cE).map(([t,e])=>eo.register(t,e));function _p({columnMap:t,inputFilterMap:e,linkedColumnMap:n,onAdd:s,onOpenLinker:i,waitingFilterMap:o,waitingInputMap:r}){const l=S.exports.useMemo(()=>{const p=Array.from(r.keys()),g=p.find(C=>e.get(C)!=null),f=p.find(C=>n.get(C)!=null),b=sn.join(p.map(C=>`"${C}"`));return g!=null&&g&&f!=null&&f?`Use a filter control or linked table to set a value for ${b}`:g!=null&&g?`Set a filter control value for ${b}`:`Double click a row in a linked table to set a value for ${b}`},[e,n,r]),a=S.exports.useMemo(()=>Array.from(t.values()),[t]),d=S.exports.useCallback(p=>{p.stopPropagation(),p.preventDefault(),s(Array.from(o.values()))},[s,o]),c=S.exports.useCallback(p=>{p.stopPropagation(),p.preventDefault(),i()},[i]),u=o.size>0,m=!u&&r.size>0;return h("div",{className:"chart-panel-overlay chart-filter-overlay",children:v("div",{className:W("chart-panel-overlay-content chart-filter-overlay-content",{"chart-filter-waiting-filter":u},{"chart-filter-waiting-input":m}),children:[u&&v(ye,{children:[h("div",{className:"info-message",children:"This plot requires a filter control to be added to the layout or a table link to be created on the following columns:"}),h("div",{className:"waiting-filter-list",children:a.map(p=>{const g=o.has(p.name),f=g?cs:ad;return v("div",{className:W("waiting-filter-item",{"is-invalid":g}),children:[h(j,{icon:f}),p.name]},p.name)})}),v("div",{children:[h(Ao,{onClick:d,className:"btn-primary",children:"Add Input Filters"}),h(Ao,{onClick:c,className:"btn-primary",children:"Open Linker Tool"})]})]}),m&&v(ye,{children:[h("div",{className:"info-message",children:"Waiting for User Input"}),h("div",{className:"",children:l})]})]})})}_p.propTypes={columnMap:R.exports.instanceOf(Map).isRequired,inputFilterMap:R.exports.instanceOf(Map).isRequired,linkedColumnMap:R.exports.instanceOf(Map).isRequired,onAdd:R.exports.func.isRequired,onOpenLinker:R.exports.func.isRequired,waitingFilterMap:R.exports.instanceOf(Map).isRequired,waitingInputMap:R.exports.instanceOf(Map).isRequired};function Vo({columns:t,onColumnSelected:e,onMouseEnter:n,onMouseLeave:s}){return h("div",{className:"chart-panel-overlay chart-column-selector-overlay",children:v("div",{className:W("chart-panel-overlay-content"),children:[h("div",{className:"info-message",children:"This plot requires a filter control to be added to the layout or a table link to be created on the following columns:"}),h("div",{className:"waiting-column-select-list",children:t.map(i=>h(Tl,{className:W("btn-chart-column-selector",Vo.makeButtonClassName(i.name)),onClick:()=>e(i.name),onMouseEnter:()=>{n&&n(i)},onMouseLeave:s,disabled:!i.isValid,isLinked:i.isActive,children:i.name},i.name))})]})})}Vo.makeButtonClassName=t=>`btn-chart-column-selector-${t}`;Vo.defaultProps={onMouseEnter:()=>{},onMouseLeave:()=>{}};const tn=X.module("ChartPanel"),vE=150;function Hr(t){return t.settings!==void 0}function TE(t){return t.inputFilters!=null}function EE(t){return t.panelState!=null}class $l extends S.exports.Component{constructor(e){super(e),this.getWaitingInputMap=pe((r,l,a)=>{if(!r)return new Map;const d=new Map(l);return a.forEach((c,u)=>{d.delete(u)}),d}),this.getWaitingFilterMap=pe((r,l,a,d,c)=>{if(!r)return new Map;const u=new Map(l);return a.forEach((m,p)=>{u.delete(p)}),c.forEach((m,p)=>{u.delete(p)}),d.forEach((m,p)=>{u.delete(p)}),u}),this.getInputFilterColumnMap=pe((r,l)=>{const a=new Map;for(let d=0;d<l.length;d+=1){const c=l[d],{name:u,type:m}=c,p=r.get(u);p!=null&&p.type===m&&a.set(u,c)}return a}),this.getLinkedColumnMap=pe((r,l)=>{const a=new Map,d=ne.getIdFromPanel(this);for(let c=0;c<l.length;c+=1){const u=l[c];let m=null;if(u.start!=null&&u.start.panelId===d&&r.has(u.start.columnName)?m=u.start.columnName:u.end&&u.end.panelId===d&&r.has(u.end.columnName)&&(m=u.end.columnName),m!=null&&r.has(m)){const p=r.get(m);P(p),a.set(m,p)}}return a}),this.getSelectorColumns=pe((r,l,a)=>Array.from(r.values()).map(d=>({name:d.name,type:d.type,isValid:a?a(this,d):!1,isActive:l.has(d.name)}))),this.handleColumnSelected=this.handleColumnSelected.bind(this),this.handleColumnMouseEnter=this.handleColumnMouseEnter.bind(this),this.handleColumnMouseLeave=this.handleColumnMouseLeave.bind(this),this.handleDisconnect=this.handleDisconnect.bind(this),this.handleReconnect=this.handleReconnect.bind(this),this.handleFilterAdd=this.handleFilterAdd.bind(this),this.handleHide=this.handleHide.bind(this),this.handleError=this.handleError.bind(this),this.handleLoadError=this.handleLoadError.bind(this),this.handleLoadSuccess=this.handleLoadSuccess.bind(this),this.handleResize=this.handleResize.bind(this),this.handleSettingsChanged=this.handleSettingsChanged.bind(this),this.handleOpenLinker=this.handleOpenLinker.bind(this),this.handleShow=this.handleShow.bind(this),this.handleSourceColumnChange=this.handleSourceColumnChange.bind(this),this.handleSourceFilterChange=this.handleSourceFilterChange.bind(this),this.handleSourceSortChange=this.handleSourceSortChange.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleUpdate=this.handleUpdate.bind(this),this.updateModelFromSource=je(this.updateModelFromSource.bind(this),vE),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.panelContainer=Y.createRef(),this.chart=Y.createRef(),this.pending=new fs;const{metadata:n,panelState:s}=e,{filterValueMap:i=[],settings:o={}}=s!=null?s:{};this.state={settings:o,error:void 0,isActive:!1,isDisconnected:!1,isLoading:!1,isLoaded:!1,isLinked:n!=null&&Hr(n)&&n.settings.isLinked,filterMap:new Map(i),filterValueMap:new Map(i),model:void 0,columnMap:new Map,panelState:s}}componentDidMount(){this.isHidden()||(this.setState({isActive:!0}),this.initModel())}componentDidUpdate(e,n){const{inputFilters:s,source:i}=this.props,{columnMap:o,model:r,filterMap:l,filterValueMap:a,isLinked:d,settings:c}=this.state;!r||(o!==n.columnMap&&this.pruneFilterMaps(),s!==e.inputFilters&&this.updateChangedInputFilters(s,e.inputFilters),l!==n.filterMap?this.updateFilters():a!==n.filterValueMap&&this.updatePanelState(),c!==n.settings&&ah(r)&&(r.updateSettings(c),this.updatePanelState()),d!==n.isLinked?i&&(d?(this.startListeningToSource(i),this.updateModelFromSource()):this.stopListeningToSource(i)):d&&i!==e.source&&(e.source&&this.stopListeningToSource(e.source),i&&(this.startListeningToSource(i),this.updateModelFromSource())))}componentWillUnmount(){this.pending.cancel();const{source:e}=this.props;e&&this.stopListeningToSource(e)}initModel(){this.setState({isLoading:!0,isLoaded:!1,error:void 0});const{makeModel:e}=this.props;this.pending.add(e(),n=>{n.close()}).then(this.handleLoadSuccess,this.handleLoadError)}startListeningToSource(e){tn.debug("startListeningToSource",e),e.addEventListener(M.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleSourceColumnChange),e.addEventListener(M.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.addEventListener(M.Table.EVENT_SORTCHANGED,this.handleSourceSortChange)}stopListeningToSource(e){tn.debug("stopListeningToSource",e),e.removeEventListener(M.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleSourceColumnChange),e.removeEventListener(M.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.removeEventListener(M.Table.EVENT_SORTCHANGED,this.handleSourceSortChange)}loadModelIfNecessary(){const{isActive:e,isLoaded:n,isLoading:s}=this.state;e&&!n&&!s&&this.initModel()}isHidden(){const{glContainer:e}=this.props,{isHidden:n}=e;return n}handleColumnSelected(e){const{glEventHub:n}=this.props,{columnMap:s}=this.state;n.emit(Ki.COLUMN_SELECTED,this,s.get(e))}handleColumnMouseEnter({type:e,name:n}){const{columnSelectionValidator:s}=this.props;tn.debug("handleColumnMouseEnter",s,e,n),s&&s(this,{type:e,name:n})}handleColumnMouseLeave(){const{columnSelectionValidator:e}=this.props;tn.debug("handleColumnMouseLeave",e),e&&e(this,void 0)}handleDisconnect(){this.setState({error:new Error("Figure disconnected"),isDisconnected:!0})}handleFilterAdd(e){for(let n=0;n<e.length;n+=1)this.openInputFilter(e[n])}handleOpenLinker(){const{localDashboardId:e,setActiveTool:n,setDashboardIsolatedLinkerPanelId:s}=this.props;s(e,void 0),n(hn.LINKER)}handleReconnect(){this.setState({isDisconnected:!1,error:void 0}),this.sendColumnChange(),this.updateColumnFilters()}handleLoadSuccess(e){tn.debug("handleLoadSuccess");const{model:n}=this.state;this.setState({model:e,isLoaded:!0},()=>{const{inputFilters:s,source:i}=this.props,{filterMap:o,isLinked:r}=this.state;e!==n&&(this.sendColumnChange(),this.updateColumnFilters(),this.updateInputFilters(s,o.size>0||e.isFilterRequired()),i&&r&&(this.startListeningToSource(i),this.updateModelFromSource()))})}handleLoadError(e){Te.isCanceled(e)||(tn.error("handleLoadError",e),this.setState({error:e,isLoading:!1}))}handleSourceColumnChange(){this.updateModelFromSource()}handleSourceFilterChange(){this.updateModelFromSource()}handleSourceSortChange(){this.updateModelFromSource()}updateModelFromSource(){const{metadata:e,source:n}=this.props,{isLinked:s,model:i}=this.state;if(!s||!i||!n){tn.debug2("updateModelFromSource ignoring",s,i,n);return}if(this.pending.cancel(),Hr(e)){const{settings:o}=e;this.pending.add(M.plot.Figure.create(xe.makeFigureSettings(o,n))).then(r=>{ah(i)&&i.setFigure(r)}).catch(this.handleLoadError)}this.updatePanelState()}updatePanelState(){const{sourcePanel:e}=this.props,{panelState:n,filterValueMap:s,settings:i}=this.state;let{tableSettings:o}=n!=null?n:{};if(e&&TE(e.props)&&EE(e.state)){const{inputFilters:r}=e.props,{panelState:l}=e.state;l!=null&&(o=te.extractTableSettings(l,r))}this.setState({panelState:{settings:i,tableSettings:o,filterValueMap:Array.from(s)}})}handleError(){this.setState({isLoading:!1})}handleResize(){this.updateChart()}handleSettingsChanged(e){this.setState(({settings:n})=>{const s={...n,...e};return tn.debug("Updated settings",s),{settings:s}})}handleHide(){this.setActive(!1)}handleShow(){this.setActive(!0)}handleTabBlur(){this.setActive(!1)}handleTabFocus(){const e=this.isHidden();this.setActive(!e)}handleUpdate(){this.setState({isLoading:!1})}handleClearAllFilters(){this.setState({filterValueMap:new Map,filterMap:new Map}),this.updatePanelState()}openInputFilter(e){const{glEventHub:n}=this.props,{name:s,type:i}=e;n.emit(Pe.OPEN_INPUT,{title:`${s} Filter`,panelState:{name:s,type:i,isValueShown:!0},createNewStack:!0,focusElement:"input"})}setActive(e){this.setState({isActive:e},()=>{e&&(this.loadModelIfNecessary(),this.updateChart())})}sendColumnChange(){const{model:e}=this.state;if(!e)return;const{glEventHub:n}=this.props;n.emit(Pe.COLUMNS_CHANGED,this,Array.from(e.getFilterColumnMap().values()))}getCoordinateForColumn(e){var l;const n=Vo.makeButtonClassName(e);if(!this.panelContainer.current)return null;const s=this.panelContainer.current.querySelector(`.${n}`),i=(l=s==null?void 0:s.getBoundingClientRect())!=null?l:null;if(i==null||i.width<=0||i.height<=0)return null;const o=i.left+i.width/2,r=i.bottom;return[o,r]}setFilterMap(e){tn.debug("setFilterMap",e),this.setState(n=>{const{columnMap:s,filterMap:i}=n;let o=null;const r=new Map(n.filterValueMap);return e.forEach(({columnType:l,value:a},d)=>{const c=s.get(d);c==null||c.type!==l||(r.set(d,a),i.get(d)!==a&&(o===null&&(o=new Map(i)),o.set(d,a)))}),{filterValueMap:r,filterMap:o!=null?o:i}})}unsetFilterValue(e){this.setState(n=>{var a;const{inputFilters:s}=this.props,{columnMap:i}=n;let{filterMap:o,filterValueMap:r}=n;if(!r.has(e))return null;r=new Map(n.filterValueMap),r.delete(e);const l=this.getInputFilterColumnMap(i,s);if(l.has(e)){const d=o.get(e),c=(a=l.get(e))==null?void 0:a.value;c!=null&&d!==c&&(o=new Map(n.filterMap),c.length>0?o.set(e,c):o.delete(e))}else o=new Map(n.filterMap),o.delete(e);return{filterMap:o,filterValueMap:r}})}updateChangedInputFilters(e,n){const s=n.filter(o=>e.find(r=>r.name===o.name&&r.type===o.type)===void 0);s.length>0&&this.deleteInputFilters(s);const i=e.filter(o=>!n.includes(o));i.length>0&&this.updateInputFilters(i)}updateInputFilters(e,n=!1){this.setState(s=>{const{columnMap:i}=s,o=new Map(s.filterValueMap),r=new Map(s.filterMap),l=n?{filterMap:r,filterValueMap:o}:{};for(let a=0;a<e.length;a+=1){const{name:d,type:c,value:u}=e[a],m=i.get(d);m!=null&&m.type===c&&(u!=null&&r.get(d)!==u&&(u===""?r.delete(d):r.set(d,u),l.filterMap=r),o.has(d)&&(o.delete(d),l.filterValueMap=o))}return tn.debug("updateInputFilters",l),l})}deleteInputFilters(e,n=!1){this.setState(s=>{const{columnMap:i,filterValueMap:o}=s,r=new Map(s.filterMap);let l=n;for(let a=0;a<e.length;a+=1){const{name:d,type:c}=e[a],u=i.get(d);if(u!=null&&u.type===c&&r.has(d)){const m=r.get(d);if(o.has(d)){const p=o.get(d);p!==m&&p!=null&&(l=!0,r.set(d,p))}else l=!0,r.delete(d)}}return tn.debug("deleteInputFilters",l),l?{filterMap:r}:null})}updateColumnFilters(){this.setState(({model:e})=>e?{columnMap:e.getFilterColumnMap()}:null)}updateFilters(){const{columnMap:e,filterMap:n,model:s}=this.state;P(s);const i=this.getWaitingInputMap(s.isFilterRequired(),e,n);if(s.setFilter(n),n.size>0&&i.size===0){const o=s.getDefaultTitle(),r=sn.join(Array.from(n.entries()).map(([l,a])=>`${l}: ${a}`));o?s.setTitle(`${o}<br><span style="font-size: smaller">${r}</span>`):s.setTitle(r),tn.debug2("updateFilters filters set",n),this.setState({isLoading:!0})}else tn.debug2("updateFilters waiting on inputs",i),s.setTitle(s.getDefaultTitle()),this.setState({isLoading:!1});this.updatePanelState()}pruneFilterMaps(){this.setState(e=>{const{columnMap:n}=e,s=new Map(e.filterMap),i=new Map(e.filterValueMap),o={};return e.filterValueMap.forEach((r,l)=>{n.has(l)||(i.delete(l),o.filterValueMap=i)}),e.filterMap.forEach((r,l)=>{n.has(l)||(s.delete(l),o.filterMap=s)}),o})}updateChart(){this.chart.current&&this.chart.current.updateDimensions()}render(){const{columnSelectionValidator:e,glContainer:n,glEventHub:s,inputFilters:i,isLinkerActive:o,links:r,metadata:l,settings:a}=this.props,{columnMap:d,filterMap:c,error:u,model:m,isActive:p,isDisconnected:g,isLoaded:f,isLoading:b}=this.state;let C;Hr(l)?C=l.table:C=l.figure;const w=this.getInputFilterColumnMap(d,i),T=this.getLinkedColumnMap(d,r),y=m!=null?this.getWaitingInputMap(m.isFilterRequired(),d,c):new Map,E=m!=null?this.getWaitingFilterMap(m.isFilterRequired(),d,c,T,w):new Map,I=u!=null?`Unable to open chart. ${u}`:void 0,D=y.size>0,F=d.size>0&&o;return h(Ul,{className:W("iris-chart-panel",{"input-required":D}),componentPanel:this,glContainer:n,glEventHub:s,onHide:this.handleHide,onClearAllFilters:this.handleClearAllFilters,onResize:this.handleResize,onShow:this.handleShow,onTabBlur:this.handleTabBlur,onTabFocus:this.handleTabFocus,errorMessage:I,isDisconnected:g,isLoading:b,isLoaded:f,widgetName:C,widgetType:"Chart",children:v("div",{ref:this.panelContainer,className:"chart-panel-container h-100 w-100",children:[h("div",{className:"chart-container h-100 w-100",children:f&&m&&h(mm,{isActive:p,model:m,settings:a,ref:this.chart,onDisconnect:this.handleDisconnect,onReconnect:this.handleReconnect,onUpdate:this.handleUpdate,onError:this.handleError,onSettingsChanged:this.handleSettingsChanged})}),h(ut,{in:D&&!F&&!b,timeout:yt.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:h(_p,{inputFilterMap:w,linkedColumnMap:T,onAdd:this.handleFilterAdd,onOpenLinker:this.handleOpenLinker,columnMap:d,waitingFilterMap:E,waitingInputMap:y})}),h(ut,{in:F,timeout:yt.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:h(Vo,{columns:this.getSelectorColumns(d,T,e),onColumnSelected:this.handleColumnSelected,onMouseEnter:this.handleColumnMouseEnter,onMouseLeave:this.handleColumnMouseLeave})})]})})}}$l.defaultProps={columnSelectionValidator:null,isLinkerActive:!1,source:null,sourcePanel:null,panelState:null,settings:{}};$l.displayName="ChartPanel";$l.COMPONENT="ChartPanel";const yE=(t,e)=>{const{localDashboardId:n,metadata:s}=e;let i;s!=null&&(i=s.sourcePanelId);const o=jd(t,n),r=jm(t,n),l=Nl(t),a=Qd(t,n),d=l===hn.LINKER&&a===void 0;return{columnSelectionValidator:Zd(t,n),isLinkerActive:d,inputFilters:Xd(t,n),links:oo(t,n),source:i!=null?o.get(i):void 0,sourcePanel:i!=null?r.get(i):void 0,settings:Ft(t)}},Bi=Nt(yE,{setActiveTool:Fl,setDashboardIsolatedLinkerPanelId:xp},null,{forwardRef:!0})($l);const Mr=X.module("CommandHistoryPanel"),kp=class extends S.exports.Component{constructor(t){super(t),this.handleFocusHistory=this.handleFocusHistory.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleSendToConsole=this.handleSendToConsole.bind(this),this.handleSendToNotebook=this.handleSendToNotebook.bind(this),this.container=Y.createRef(),this.pending=new fs;const{session:e,sessionId:n,language:s}=t;this.state={panelState:{},session:e,sessionId:n,language:s,contextActions:[{action:this.handleFocusHistory,shortcut:Ut.COMMAND_HISTORY.FOCUS_HISTORY}]}}static handleError(t){Mr.error(t)}componentDidMount(){const{glEventHub:t,session:e}=this.props;t.on(Ct.FOCUS_HISTORY,this.handleFocusHistory),e!=null&&this.loadTable()}componentWillUnmount(){const{glEventHub:t}=this.props;t.off(Ct.FOCUS_HISTORY,this.handleFocusHistory),this.pending.cancel()}handleFocusHistory(){this.container.current&&this.container.current.focus()}handleShow(){var t;(t=this.container.current)==null||t.restoreScrollPosition()}handleSessionOpened(t,{language:e,sessionId:n}){this.setState({session:t,sessionId:n,language:e},()=>{this.loadTable()})}handleSessionClosed(){this.pending.cancel(),this.setState({session:void 0,language:void 0,table:void 0})}handleSendToNotebook(t,e=!1){const{session:n,language:s}=this.state;if(Mr.debug("handleSendToNotebook",n,t),!n){Mr.error("Session is not connected.");return}const{glEventHub:i}=this.props;i.emit(e?He.CREATE_NOTEBOOK:He.SEND_TO_NOTEBOOK,n,s,t)}handleSendToConsole(t,e=!0,n=!1){Mr.debug("handleSendToConsole",t);const{glEventHub:s}=this.props;s.emit(Ct.SEND_COMMAND,t,e,n)}loadTable(){const{commandHistoryStorage:t}=this.props,{language:e,sessionId:n}=this.state;P(e),P(n),this.pending.add(t.getTable(e,n,Date.now()),s=>s.close()).then(s=>{this.setState({table:s})}).catch(kp.handleError)}render(){const{glContainer:t,glEventHub:e,commandHistoryStorage:n}=this.props,{language:s,contextActions:i,table:o}=this.state;return v(jn,{className:"command-history-pane",componentPanel:this,glContainer:t,glEventHub:e,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onShow:this.handleShow,children:[!o&&h("div",{className:"command-history-disconnected-message",children:"Waiting for console connection"}),o&&s!=null&&v(ye,{children:[h(Rl,{ref:this.container,language:s,sendToNotebook:this.handleSendToNotebook,sendToConsole:this.handleSendToConsole,table:o,commandHistoryStorage:n}),h(oe,{actions:i})]})]})}};let ec=kp;ec.COMPONENT="CommandHistoryPanel";ec.TITLE="Command History";const IE=(t,e)=>{const n=fm(t),s=gi(t,e.localDashboardId),{session:i,config:o}=s!=null?s:{},{type:r,id:l}=o!=null?o:{};return{commandHistoryStorage:n,language:r,session:i,sessionId:l}},il=Nt(IE,null,null,{forwardRef:!0})(ec);const Nr=X.module("ConsolePanel"),RE=500,DE=Object.freeze({consoleSettings:{},itemIds:[]});class tc extends S.exports.PureComponent{constructor(e){super(e),this.savePanelState=je(()=>{const{consoleSettings:r,itemIds:l}=this.state,a={consoleSettings:r,itemIds:[...l]};Nr.debug("Saving panel state",a),this.setState({panelState:a})},RE),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=Y.createRef();const{panelState:n}=e,s={...DE,...n||{}},{consoleSettings:i,itemIds:o}=s;this.state={consoleSettings:i,itemIds:new Map(o),objectMap:new Map,error:void 0,panelState:s}}componentDidMount(){const{glEventHub:e}=this.props;this.closeDisconnectedPanels(),e.on(Ne.MOUNT,this.handlePanelMount),this.subscribeToFieldUpdates()}componentDidUpdate(e,n){const{consoleSettings:s,itemIds:i}=this.state;(n.consoleSettings!==s||n.itemIds!==i)&&this.savePanelState()}componentWillUnmount(){var n;const{glEventHub:e}=this.props;this.savePanelState.flush(),e.off(Ne.MOUNT,this.handlePanelMount),(n=this.objectSubscriptionCleanup)==null||n.call(this)}subscribeToFieldUpdates(){const{sessionWrapper:e}=this.props,{session:n}=e;this.objectSubscriptionCleanup=n.subscribeToFieldUpdates(s=>{Nr.debug("Got updates",s),this.setState(({objectMap:i})=>{const{updated:o,created:r,removed:l}=s,a=[...o,...l],d=new Map(i);return a.forEach(u=>{const{title:m}=u;m!==void 0&&d.delete(m)}),[...o,...r].forEach(u=>{u.title!==void 0&&d.set(u.title,u)}),{objectMap:d}})})}setItemId(e,n){this.setState(({itemIds:s})=>{const i=new Map(s);return i.set(e,n),{itemIds:i}})}getItemId(e,n=!0){const{itemIds:s}=this.state;let i=s.get(e);return i==null&&n&&(i=ze.generate(),this.setItemId(e,i)),i}handleTabFocus(){var e;(e=this.consoleRef.current)==null||e.focus()}handlePanelMount(e){var o,r,l;const{itemIds:n}=this.state,s=(o=e==null?void 0:e.props)==null?void 0:o.id,i=(l=(r=e==null?void 0:e.props)==null?void 0:r.metadata)==null?void 0:l.sourcePanelId;s&&i&&new Set(n.values()).has(i)&&this.setItemId(s,s)}handleFocusCommandHistory(){const{glEventHub:e}=this.props;e.emit(Ct.FOCUS_HISTORY)}handleResize(){this.updateDimensions()}handleShow(){this.updateDimensions()}handleOpenObject(e){const{sessionWrapper:n}=this.props,{session:s}=n;this.openWidget(e,s)}handleCloseObject(e){const{title:n}=e;if(n!==void 0){const s=this.getItemId(n,!1),{glEventHub:i}=this.props;i.emit(Ne.CLOSE,s)}}handleSettingsChange(e){const{glEventHub:n}=this.props;Nr.debug("handleSettingsChange",e),this.setState({consoleSettings:e}),n.emit(Ct.SETTINGS_CHANGED,e)}openWidget(e,n){const{glEventHub:s}=this.props,{title:i}=e;P(i);const o=this.getItemId(i),r={fetch:()=>n.getObject(e),panelId:o,widget:e};Nr.debug("openWidget",r),s.emit(Ne.OPEN,r)}addCommand(e,n=!0,s=!1){var i;(i=this.consoleRef.current)==null||i.addCommand(e,n,s)}closeDisconnectedPanels(e=!1){const{consoleSettings:n,itemIds:s}=this.state,{isClosePanelsOnDisconnectEnabled:i=!0}=n;if(!i&&!e)return;const o=[...s.values()],{glEventHub:r}=this.props;o.forEach(l=>{r.emit(Ne.CLOSE,l)}),this.setState({itemIds:new Map})}updateDimensions(){var e;(e=this.consoleRef.current)==null||e.updateDimensions()}render(){const{commandHistoryStorage:e,glContainer:n,glEventHub:s,sessionWrapper:i,timeZone:o,unzip:r}=this.props,{consoleSettings:l,error:a,objectMap:d}=this.state,{config:c,session:u,connection:m}=i,{id:p,type:g}=c;return h(jn,{componentPanel:this,glContainer:n,glEventHub:s,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleTabFocus,errorMessage:a!=null?`${a}`:void 0,children:u!=null&&h(Sd,{ref:this.consoleRef,settings:l,session:u,focusCommandHistory:this.handleFocusCommandHistory,openObject:this.handleOpenObject,closeObject:this.handleCloseObject,commandHistoryStorage:e,onSettingsChange:this.handleSettingsChange,language:g,statusBarChildren:v(ye,{children:[h("div",{children:"\xA0"}),h("div",{children:Ku.LANGUAGE_MAP.get(g)}),h("div",{children:"\xA0"}),h("div",{children:h(CS,{connection:m,defaultUpdateInterval:10*1e3,hoverUpdateInterval:3*1e3,monitorDuration:10*60*1e3})}),h("div",{children:"\xA0"})]}),scope:p,timeZone:o,objectMap:d,unzip:r})})}}tc.COMPONENT="ConsolePanel";tc.TITLE="Console";const ME=(t,e)=>({commandHistoryStorage:fm(t),sessionWrapper:gi(t,e.localDashboardId),timeZone:Ml(t)}),Li=Nt(ME,null,null,{forwardRef:!0})(tc);const bo=X.module("DropdownFilter"),NE=150,Vr=class extends S.exports.Component{constructor(t){super(t),this.getCompatibleColumns=pe((i,o)=>i!=null?o.filter(({type:r})=>r!==void 0&&L.isCompatibleType(r,i.columnType)):[]),this.getColumnOptions=pe((i,o)=>{let r=-1;const l=[];return l.push(h("option",{value:"-1",children:"Select a column"},"placeholder")),i.forEach((a,d)=>{l.push(h("option",{value:d,children:this.getItemLabel(i,d)},`${a.name}/${a.type}`)),o!==null&&a.name===o.name&&a.type===o.type&&(r=d)}),[l,r]}),this.getSelectedOptionIndex=pe((i,o)=>i.indexOf(o)),this.getValueOptions=pe(i=>[h("option",{value:"-1",children:Vr.PLACEHOLDER},"-1"),...i.map((o,r)=>h("option",{value:r,children:o},`${r}/${o}`))]),this.getItemLabel=ve((i,o)=>{const{name:r,type:l}=i[o];if(o>0&&i[o-1].name===r||o<i.length-1&&i[o+1].name===r){const a=l.substring(l.lastIndexOf(".")+1);return`${r} (${a})`}return r}),this.sendUpdate=je(()=>{const{onChange:i}=this.props,{column:o,value:r,isValueShown:l}=this.state;i({column:o,isValueShown:l,value:r!=null?r:void 0})},NE),this.handleColumnChange=this.handleColumnChange.bind(this),this.handleSettingsCancel=this.handleSettingsCancel.bind(this),this.handleSettingsClick=this.handleSettingsClick.bind(this),this.handleSettingsSave=this.handleSettingsSave.bind(this),this.handleBackgroundClick=this.handleBackgroundClick.bind(this),this.handleDropdownKeyPress=this.handleDropdownKeyPress.bind(this),this.handleValueChange=this.handleValueChange.bind(this),this.dropdownRef=Y.createRef();const{column:e,isValueShown:n,value:s}=t;this.state={column:e,selectedColumn:e,disableCancel:!n,isValueShown:n,value:s}}componentDidUpdate(t,e){const{source:n,values:s,isLoaded:i}=this.props,{column:o,value:r,isValueShown:l}=this.state;i&&(n!==t.source&&this.sourceUpdated(),s!==t.values&&r!==""&&!s.includes(r)&&this.resetValue(),l!==e.isValueShown&&l&&this.focusInput(),(o!==e.column||r!==e.value||l!==e.isValueShown)&&this.sendUpdate())}componentWillUnmount(){this.sendUpdate.flush()}handleColumnChange(t){const{value:e}=t.target;if(bo.debug2("handleColumnChange",e),e!=null&&parseInt(e,10)<0){this.setState({selectedColumn:null});return}const{columns:n,source:s}=this.props,i=this.getCompatibleColumns(s,n);this.setState({selectedColumn:i[parseInt(e,10)]})}handleDropdownKeyPress(t){t.key==="Enter"&&(t.preventDefault(),t.stopPropagation(),bo.debug2("handleDropdownKeyPress"),this.sendUpdate(),this.sendUpdate.flush())}handleValueChange(t){const{value:e}=t.target,n=parseInt(e,10);let s="";const{values:i}=this.props;if(n===-1)bo.debug2("Selected default item");else if(n>=0&&n<i.length)s=i[n];else{bo.error("Invalid index",n,i);return}bo.debug2("handleValueChange",s),this.setState({value:s})}handleSettingsCancel(){this.setState(({column:t})=>({selectedColumn:t,isValueShown:!0}))}handleSettingsSave(){this.setState(({column:t,selectedColumn:e,value:n})=>({column:e,value:t===e?n:"",isValueShown:!0,disableCancel:!1}))}handleSettingsClick(t){t.stopPropagation(),this.showSettings()}handleBackgroundClick(t){t.target!==this.dropdownRef.current&&this.focusInput()}handleMouseEnter(){const{onSourceMouseEnter:t}=this.props;t()}handleMouseLeave(){const{onSourceMouseLeave:t}=this.props;t()}sourceUpdated(){this.setState({column:null,selectedColumn:null,isValueShown:!1,disableCancel:!0,value:""})}showSettings(){const{column:t}=this.state;this.setState({selectedColumn:t,isValueShown:!1})}focusInput(){this.dropdownRef.current!==null&&this.dropdownRef.current.focus()}resetValue(){this.setState({value:""})}clearFilter(){this.resetValue()}setFilterState({name:t,type:e,value:n,isValueShown:s}){const i=t!=null&&e!=null?{name:t,type:e}:null;this.setState({column:i,value:n,isValueShown:s})}render(){var U;const{columns:t,disableLinking:e,isLinkerActive:n,isLoaded:s,source:i,onColumnSelected:o,onSourceMouseEnter:r,onSourceMouseLeave:l,values:a,settingsError:d}=this.props,{column:c,disableCancel:u,isValueShown:m,selectedColumn:p,value:g}=this.state,f=i===null,b=this.getCompatibleColumns(i,t),C=i!=null,w=(U=i==null?void 0:i.columnName)!=null?U:Vr.SOURCE_BUTTON_PLACEHOLDER,T=c!=null?`${c.name} Filter`:null,[y,E]=this.getColumnOptions(b,p),I=this.getValueOptions(a),D=this.getSelectedOptionIndex(a,g),F=!C||p==null;return v(rd,{className:"dropdown-filter fill-parent-absolute",isFlipped:m&&!n,children:[h("div",{className:"dropdown-filter-settings-card",children:v("div",{className:"dropdown-filter-card-content",children:[v("div",{className:"dropdown-filter-settings-grid",children:[h("label",{children:"Source Column"}),h(Tl,{isLinked:C,onClick:o,onMouseEnter:r,onMouseLeave:l,className:Vr.SOURCE_BUTTON_CLASS_NAME,disabled:e,children:w}),h("div",{className:"text-muted small",children:"Select a source column for the list by linking to a table."}),h("label",{children:"Filter Column"}),h("select",{value:E,className:"custom-select",onChange:this.handleColumnChange,disabled:f,children:y}),h("div",{className:"text-muted small",children:"Dropdown filter control will apply its filter to all columns matching this name in this dashboard."})]}),d&&h("div",{className:"error-message text-center",children:d}),C&&v("div",{className:"dropdown-filter-settings-buttons",children:[h(z,{kind:"secondary",type:"button",onClick:this.handleSettingsCancel,disabled:u||m||n,tooltip:n?"Cancel disabled while linker open":void 0,children:"Cancel"}),h(z,{kind:"primary",type:"button",className:"ml-2",onClick:this.handleSettingsSave,disabled:F||m||n,tooltip:n?"Save disabled while linker open":void 0,children:"Save"})]})]})}),h("div",{className:"dropdown-filter-value-card",onClick:this.handleBackgroundClick,children:s&&v(ye,{children:[h("div",{className:"dropdown-filter-column",children:h("div",{className:"dropdown-filter-column-title",children:T})}),v("div",{className:"dropdown-filter-card-content",children:[h("div",{className:"dropdown-filter-value-input d-flex flex-column justify-content-center",children:h("select",{className:"custom-select",value:D,ref:this.dropdownRef,onChange:this.handleValueChange,onKeyPress:this.handleDropdownKeyPress,children:I})}),d&&h("div",{className:"error-message mt-3 text-center",children:d})]}),h("div",{className:"dropdown-filter-menu",children:h(z,{kind:"ghost",className:"m-2 px-2",onClick:this.handleSettingsClick,icon:h(j,{icon:Go,transform:"grow-4"}),tooltip:"Dropdown Filter Settings"})})]})})]})}};let qi=Vr;qi.defaultProps={column:null,disableLinking:!1,isLinkerActive:!1,isLoaded:!1,isValueShown:!1,settingsError:null,source:null,value:"",values:[],onColumnSelected:()=>{},onSourceMouseEnter:()=>{},onSourceMouseLeave:()=>{}};qi.PLACEHOLDER="Select a value...";qi.SOURCE_BUTTON_CLASS_NAME="btn-dropdown-filter-selector";qi.SOURCE_BUTTON_PLACEHOLDER="Select a column";const nt=X.module("DropdownFilterPanel"),FE=250,ti=class extends S.exports.Component{constructor(t){super(t),this.getCachedValues=pe((d,{type:c,name:u},m)=>c!==void 0&&L.isDateType(c)?d.map(p=>ti.DATETIME_FORMATTER.format(p)):d.map(p=>p!=null&&c!=null?m.getFormattedString(p,c,u):null)),this.getCachedPanelLinks=pe((d,c)=>{const u=ne.getIdFromPanel(c);return nt.debug("getCachedPanelLinks",d,u),d.filter(m=>{var p;return((p=m.end)==null?void 0:p.panelId)===u})}),this.getCachedSource=pe(d=>{nt.debug("getCachedSource",d);let c;if(d.length>0){const[u]=d;c=u.start,d.length>1&&nt.error("Filter has more that one link",d)}return c}),this.getCachedSourceTable=pe((d,c)=>{var m;if(nt.debug("getCachedSourceTable",d,c),c==null)return null;const{panelId:u}=c;return(m=d.get(u))!=null?m:null}),this.getCachedSourceColumn=pe((d,c)=>{var u;return nt.debug("getCachedSourceColumn",d,c),d==null||c==null?null:(u=d.columns.find(({name:m,type:p})=>m===c.columnName&&p===c.columnType))!=null?u:null}),this.handleChange=je(this.handleChange.bind(this),FE),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=Y.createRef(),this.panelContainer=Y.createRef(),this.pending=new fs;const{panelState:e,settings:n}=t;this.columnFormats=hs.getColumnFormats(n);const{value:s="",isValueShown:i=!1,name:o,type:r,timestamp:l}=e!=null?e:{},a=o!=null&&r!=null?{name:o,type:r}:void 0;this.state={column:a,formatter:new un(this.columnFormats),valuesTable:void 0,valuesColumn:void 0,sourceSize:0,value:s,timestamp:l,values:[],isValueShown:i,wasFlipped:!1,skipUpdate:!1,panelState:e,isDisconnected:!1,isLoading:!1,isLoaded:!1,error:null}}componentDidMount(){this.updateValuesTable();const{column:t,value:e,timestamp:n}=this.state,s=this.getSourceTable();if(s!==null&&this.startListeningToSource(s),t!=null){const{name:i,type:o}=t;this.sendUpdate(i,o,e,n)}}componentDidUpdate(t,e){const{valuesTable:n}=this.state,{settings:s}=this.props,i=this.getSource(),o=this.getSourceTable(),r=this.getSource(t),l=this.getSourceTable(t);s!==t.settings&&s!==void 0&&this.updateFormatterSettings(s),n!==e.valuesTable&&e.valuesTable!=null&&(nt.debug("Table in state modified, closing the old table."),e.valuesTable.close()),(o!==l||i!==r)&&this.updateValuesTable(),o!==l&&(l!==null&&this.stopListeningToSource(l),o!==null&&this.startListeningToSource(o))}componentWillUnmount(){const{valuesTable:t}=this.state,e=this.getSourceTable();this.pending.cancel(),e!==null&&this.stopListeningToSource(e),this.cleanup&&this.cleanup(),t!=null&&t.close()}getCoordinateForColumn(){var i;if(this.panelContainer.current==null)return null;const t=this.panelContainer.current.querySelector(`.${qi.SOURCE_BUTTON_CLASS_NAME}`),e=(i=t==null?void 0:t.getBoundingClientRect())!=null?i:null;if(e==null||e.width<=0||e.height<=0)return null;const n=e.left+e.width/2,s=e.bottom;return[n,s]}getSettingsErrorMessage(){const{sourceSize:t}=this.state;if(t>ti.MAX_TABLE_SIZE)return`Table too large, must have fewer than ${ti.MAX_TABLE_SIZE} options.`}getPanelErrorMessage(){const{error:t}=this.state;return t!=null?`${t}`:void 0}getSource(t=this.props){const{dashboardLinks:e}=t,n=this.getCachedPanelLinks(e,this);return this.getCachedSource(n)}getSourceTable(t=this.props){const{panelTableMap:e}=t,n=this.getSource(t);return this.getCachedSourceTable(e,n)}getValuesColumn(t){const e=this.getSource();return this.getCachedSourceColumn(t,e)}startListeningToSource(t){nt.debug("startListeningToSource"),t.addEventListener(M.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),t.addEventListener(M.Table.EVENT_SORTCHANGED,this.handleSourceSortChange),t.addEventListener(M.Table.EVENT_SIZECHANGED,this.handleSourceSizeChange),t.addEventListener(M.Table.EVENT_DISCONNECT,this.handleDisconnect),t.addEventListener(M.Table.EVENT_RECONNECT,this.handleReconnect)}stopListeningToSource(t){nt.debug("stopListeningToSource"),t.removeEventListener(M.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),t.removeEventListener(M.Table.EVENT_SORTCHANGED,this.handleSourceSortChange),t.removeEventListener(M.Table.EVENT_SIZECHANGED,this.handleSourceSizeChange),t.removeEventListener(M.Table.EVENT_DISCONNECT,this.handleDisconnect),t.removeEventListener(M.Table.EVENT_RECONNECT,this.handleReconnect)}handleChange({column:t,isValueShown:e=!1,value:n}){const{name:s=void 0,type:i=void 0}=t!=null?t:{};let o=!0,r=Date.now();this.setState(({panelState:l,timestamp:a,wasFlipped:d,skipUpdate:c})=>{var m;const u=l!=null&&e!==l.isValueShown&&s===l.name&&i===l.type&&n===l.value;return o=(m=!c&&e&&(!u||!d))!=null?m:!1,o||(r=a),{panelState:{isValueShown:e,name:s,type:i,value:n,timestamp:r!=null?r:void 0},timestamp:r,wasFlipped:u,skipUpdate:!1}},()=>{o&&this.sendUpdate(s!=null?s:null,i,n,r)})}handleDisconnect(){this.setState({error:new Error("Table disconnected"),isDisconnected:!0,isLoading:!1})}handleReconnect(){this.setState({isDisconnected:!1,error:null})}handleSourceFilterChange(){this.applySourceFilters()}handleSourceSortChange(){this.applySourceSorts()}handleSourceSizeChange({detail:t}){this.setState({sourceSize:t})}handleColumnSelected(){nt.debug("handleColumnSelected");const{glEventHub:t}=this.props;t.emit(Pe.COLUMN_SELECTED,this,ti.SOURCE_COLUMN)}handleClearAllFilters(){var t,e;(e=(t=this.dropdownFilterRef)==null?void 0:t.current)==null||e.clearFilter()}setPanelState(t,e=!1){var n,s;if(this.getSource()==null){nt.debug("Ignore state update for unlinked filter",t);return}this.setState({skipUpdate:!e}),(s=(n=this.dropdownFilterRef)==null?void 0:n.current)==null||s.setFilterState(t)}sendUpdate(t,e,n,s){var l;const{glEventHub:i}=this.props,o=(l=this.getSource())==null?void 0:l.panelId,r=o===null?[]:[o];nt.debug("sendUpdate",{name:t,type:e,value:n,timestamp:s,excludePanelIds:r}),i.emit(Pe.FILTERS_CHANGED,this,{name:t,type:e,value:n!=null?n:"=null",timestamp:s,excludePanelIds:r})}updateValuesTable(){const t=this.getSource(),e=this.getSourceTable();if(nt.debug("updateValuesTable",t,e),this.setState({values:[],valuesTable:void 0,error:null}),t==null){nt.debug("Filter unlinked."),this.setState({isLoading:!1,isLoaded:!0,isValueShown:!1,sourceSize:0});return}this.setState({isLoading:!0}),e!=null&&(this.setState({isLoaded:!1,sourceSize:e.size}),this.pending.add(e.copy(),n=>n.close()).then(n=>{this.updateViewportListener(n),this.setState({valuesTable:n})}).catch(n=>{Te.isCanceled(n)||(nt.error(n),this.setState({isLoading:!1,error:n}))}))}applySourceSorts(){const{valuesTable:t}=this.state,e=this.getSourceTable();if(nt.debug("applySourceSorts",e==null?void 0:e.sort),t==null||e==null){nt.debug("Table not initialized");return}const n=[...e.sort];t.applySort(n),this.setViewport(t)}applySourceFilters(){const{valuesTable:t}=this.state,e=this.getSourceTable();if(nt.debug("applySourceFilters",e==null?void 0:e.filter),t==null||e==null){nt.debug("Table not initialized");return}const n=[...e.filter];t.applyFilter(n),this.setViewport(t)}updateViewportListener(t){if(nt.debug("updateViewportListener",t==null?void 0:t.size),this.cleanup&&this.cleanup(),t==null){this.cleanup=void 0;return}this.cleanup=t.addEventListener(M.Table.EVENT_UPDATED,this.handleValuesTableUpdate),this.setViewport(t)}setViewport(t){const e=this.getValuesColumn(t);if(!e){nt.error("values column is null");return}t.setViewport(0,ti.MAX_TABLE_SIZE-1,[e])}updateFormatterSettings(t){const e=hs.getColumnFormats(t);ht(this.columnFormats,e)||(this.columnFormats=e,this.setState({formatter:new un(e)}))}handleValuesTableUpdate({detail:t}){const{rows:e}=t,{valuesTable:n}=this.state;if(!n){nt.error("valuesTable is null");return}const s=this.getValuesColumn(n);if(!s){nt.error("Values column not found");return}const i=e.map(o=>o.get(s));this.setState({values:i,isLoading:!1,isLoaded:!0,valuesColumn:s})}handleSourceMouseEnter(){const{columnSelectionValidator:t}=this.props;!t||t(this,ti.SOURCE_COLUMN)}handleSourceMouseLeave(){const{columnSelectionValidator:t}=this.props;!t||t(this,void 0)}render(){const{columns:t,disableLinking:e,glContainer:n,glEventHub:s,isLinkerActive:i}=this.props,{column:o,formatter:r,isDisconnected:l,isValueShown:a,value:d,values:c,valuesColumn:u,isLoading:m,isLoaded:p}=this.state,g=this.getSource(),f=this.getSettingsErrorMessage(),b=this.getPanelErrorMessage(),C=p&&u!=null?this.getCachedValues(c,u,r):[];return h(Ul,{errorMessage:b,isLoading:m,isLoaded:p,isDisconnected:l,className:"iris-dropdown-filter-panel",componentPanel:this,glContainer:n,glEventHub:s,onClearAllFilters:this.handleClearAllFilters,widgetName:"Dropdown Filter",widgetType:"DropdownFilter",children:h("div",{ref:this.panelContainer,className:"dropdown-filter-container h-100 w-100 container",children:h(qi,{ref:this.dropdownFilterRef,column:o,columns:t,isValueShown:a,isLinkerActive:i,disableLinking:e,isLoaded:p,settingsError:f,source:g,value:d,values:C,onChange:this.handleChange,onColumnSelected:this.handleColumnSelected,onSourceMouseEnter:this.handleSourceMouseEnter,onSourceMouseLeave:this.handleSourceMouseLeave})})})}};let ro=ti;ro.displayName="DropdownFilterPanel";ro.COMPONENT="DropdownFilterPanel";ro.MAX_TABLE_SIZE=256;ro.DATETIME_FORMATTER=new dt({showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:"yyyy-MM-dd HH:mm:ss.SSSSSSSSS"});ro.SOURCE_COLUMN=Object.freeze({name:"FilterSource",type:null});const xE=(t,e)=>{const{localDashboardId:n}=e,s=ne.getIdFromPanel({props:e}),i=jd(t,n),o=oo(t,n),r=Nl(t),l=Qd(t,n),a=r===hn.LINKER&&(l===void 0||l===s),d=r===hn.LINKER&&l!==void 0&&l!==s;return{columns:Fp(t,n),columnSelectionValidator:Zd(t,n),isLinkerActive:a,disableLinking:d,settings:Ft(t),panelTableMap:i,dashboardLinks:o}},ci=Nt(xE,null,null,{forwardRef:!0})(ro);function qn(t){return t.type==="directory"}var Op=(t=>(t.GROOVY="text/x-groovy",t.PLAIN_TEXT="text/plain",t.PYTHON="text/x-python",t.PYTHON_COMPILED="application/x-python-code",t.SCALA="text/x-scala",t.UNKNOWN="",t))(Op||{});class ce{static fileExtensionToString(e=""){return e.length===0?"":`.${e}`}static getDepth(e){var s;if(!ce.hasPath(e))throw new Error(`Invalid path provided: ${e}`);return((s=e.match(/\//g))!=null?s:[]).length-1}static getExtension(e){var s;const n=this.getBaseName(e).split(".");return n.length>1&&(s=n.pop())!=null?s:""}static getBaseName(e){var n;return(n=e.split("/").pop())!=null?n:""}static getCopyFileName(e){const n=e.lastIndexOf(".");let s=null,i=null;n<0?i=e:(i=e.substring(0,n),s=e.substring(n+1));const o=i?`${i}-copy`:"Copy";return s!==null?`${o}.${s}`:o}static getMimeType(e){switch(this.getExtension(e).toLowerCase()){case"groovy":return"text/x-groovy";case"py":return"text/x-python";case"pyc":return"application/x-python-code";case"scala":return"text/x-scala";case"txt":return"text/plain";default:return""}}static getParent(e){if(!ce.hasPath(e))throw new Error(`Invalid name provided: ${e}`);const n=e.split("/");for(;n.pop()==="";);if(n.length===0)throw new Error(`No parent for path provided: ${e}`);return`${n.join("/")}/`}static getPath(e){if(!ce.hasPath(e))throw new Error(`Invalid filename provided: ${e}`);const n=e.split("/");return n.pop(),`${n.join("/")}/`}static hasPath(e){return e.startsWith("/")}static isPath(e){return e.startsWith("/")&&e.endsWith("/")}static makePath(e){return e.endsWith("/")?e:`${e}/`}static replaceExtension(e,n=""){const s=e.lastIndexOf("."),i=s>-1?e.substring(0,s):e,o=ce.fileExtensionToString(n);return`${i}${o}`}static validateName(e){var o,r;const n=[".",".."],s=/[\\/\0]/g,i=new Map([["\0","null"]]);if(!e)throw new Hi("Name cannot be empty");if(n.includes(e))throw new Hi(`"${e}" is a reserved name`);if(s.test(e))throw new Hi(`Invalid characters in name: "${(r=(o=e.match(s))==null?void 0:o.reduce((l,a)=>l.includes(a)?l:[...l,a],[]).map(l=>i.has(l)?i.get(l):l).join('", "'))!=null?r:""}"`)}static reducePaths(e){const n=e.filter(s=>ce.isPath(s));return e.filter(s=>!n.some(i=>s!==i&&s.startsWith(i)))}static removeRoot(e,n){if(e.length===0)return n;if(!n.startsWith(e))throw new Error(`Filename ${n} does not start with expected root ${e}`);return n.substring(e.length)}static addRoot(e,n){return`${e}${n}`}}const Lt=X.module("FileList"),Ga=t=>qn(t)?ce.makePath(t.filename):ce.getPath(t.filename),nc=26,_E=500,kh="item-list-scroll-pane",Ka=t=>{var I;const{children:e,draggedItems:n,isDragInProgress:s,isDropTargetValid:i,isSelected:o,item:r,itemIndex:l,dropTargetItem:a,onDragStart:d,onDragOver:c,onDragEnd:u,onDrop:m}=t,p=(I=n==null?void 0:n.some(D=>D.id===r.id))!=null?I:!1,g=Ga(r),f=s&&a?Ga(a):null,b=s&&i&&qn(r)&&f===g,C=s&&i&&f===g,w=s&&!i&&f===g,T=kE(r),y=ce.getDepth(r.filename),E=Array(y).fill(null).map((D,F)=>h("span",{className:"file-list-depth-line"},F));return v("div",{className:W("d-flex w-100 align-items-center","file-list-item",{"is-dragged":p,"is-exact-drop-target":b,"is-in-drop-target":C,"is-invalid-drop-target":w,"is-selected":o}),onDragStart:D=>d(l,D),onDragOver:D=>c(l,D),onDragEnd:D=>u(l,D),onDrop:D=>m(l,D),draggable:!0,role:"presentation","aria-label":r.basename,children:[E," ",h(j,{icon:T,className:"item-icon",fixedWidth:!0})," ",v("span",{className:"truncation-wrapper",children:[e!=null?e:r.basename,h($e,{options:{modifiers:{preventOverflow:{boundariesElement:"window"}},placement:"left"},children:e!=null?e:r.basename})]})]})};function kE(t){if(qn(t))return t.isExpanded?Rf:Df;switch(ce.getMimeType(t.basename)){case Op.PYTHON:return lC;default:return Tf}}function Oh(t,e){if(t.length===0||e==null)throw new Error("No items to move");const n=Ga(e);if(t.some(({filename:s})=>ce.getPath(s)===n))throw new Error("File already in the destination folder");if(t.some(s=>qn(s)&&n.startsWith(ce.makePath(s.filename))))throw new Error("Destination folder cannot be a child of a dragged folder");return{files:t,targetPath:n}}function OE(t){const{isMultiSelect:e=!1,table:n,onFocusChange:s=()=>{},onMove:i,onSelect:o,onSelectionChange:r=()=>{},renderItem:l=Ka,rowHeight:a=nc,overscanCount:d=bn.DEFAULT_OVERSCAN}=t,[c,u]=S.exports.useState(()=>({items:[],offset:0,itemCount:0})),[m,p]=S.exports.useState({top:0,bottom:0}),[g,f]=S.exports.useState(),[b,C]=S.exports.useState(),[w,T]=S.exports.useState(),[y,E]=S.exports.useState([]),I=S.exports.useRef(null),D=S.exports.useRef(null),F=S.exports.useCallback(ee=>{if(ee.length===0||c==null)return[];const ue=[];for(let Se=0;Se<ee.length;Se+=1){const De=ee[Se];for(let qe=De[0];qe<=De[1];qe+=1)qe>=c.offset&&qe<c.offset+c.items.length&&ue.push(c.items[qe-c.offset])}return ue},[c]),x=S.exports.useCallback(ee=>{const ue=F([[ee,ee]]);if(ue.length>0)return ue[0]},[F]),U=S.exports.useCallback(()=>{const ee=fn.count(y);if(ee===0)return null;if(ee===1){const ue=y[0][0],Se=x(ue);if(Se!=null)return Se.filename}return`${ee} items`},[x,y]),B=S.exports.useCallback(ee=>{var ue;if(!(!b||!g)){Lt.debug("dropItems",b,"to",ee);try{const{files:Se,targetPath:De}=Oh(b,g);i(Se,De),ee!=null&&(E([[ee,ee]]),(ue=I.current)==null||ue.focusItem(ee))}catch(Se){Lt.error("Unable to complete move",Se)}}},[b,g,i]),_=S.exports.useCallback((ee,ue)=>{const Se=c.items[ee-c.offset];Se!==void 0&&(Lt.debug("handleItemClick",Se),o(Se,ue),qn(Se)&&(n==null||n.setExpanded(Se.filename,!Se.isExpanded)))},[c,o,n]),H=S.exports.useCallback((ee,ue)=>{var qe;Lt.debug2("handleItemDragStart",ee,y);let Se=y;fn.isSelected(y,ee)||(Se=[[ee,ee]],E(Se)),C(F(Se)),(qe=I.current)==null||qe.resetMouseState();const De=document.createElement("div");De.innerHTML=`<div class="dnd-placeholder-content">${U()}</div>`,De.className="file-list-dnd-placeholder",document.body.appendChild(De),ue.dataTransfer.setDragImage(De,0,0),ue.dataTransfer.effectAllowed="move",T(De)},[U,F,y]),A=S.exports.useCallback((ee,ue)=>{ue.preventDefault(),Lt.debug2("handleItemDragOver",ue),f(x(ee))},[x]),N=S.exports.useCallback((ee,ue)=>{Lt.debug("handleItemDragEnd",ee),w==null||w.remove(),C(void 0),f(void 0),T(void 0)},[w]),k=S.exports.useCallback((ee,ue)=>{B(ee)},[B]),O=S.exports.useCallback(()=>{Lt.debug2("handleItemDragExit"),f(void 0)},[]),V=S.exports.useCallback(ee=>{ee.target instanceof Element&&ee.target.classList.contains(kh)&&(ee.preventDefault(),Lt.debug2("handleListDragOver",ee),f({type:"directory",filename:"/",basename:"/",id:"/"}))},[]),G=S.exports.useCallback(ee=>{ee.target instanceof Element&&ee.target.classList.contains(kh)&&(Lt.debug("handleListDrop"),B())},[B]),Q=S.exports.useCallback(ee=>{if(Lt.debug2("handleSelectionChange",ee),ee!==y){E(ee);const ue=F(ee);r(ue)}},[F,r,y]),Z=S.exports.useCallback(ee=>{if(Lt.debug2("handleFocusChange",ee),ee!=null){const[ue]=F([[ee,ee]]);s(ue)}else s()},[F,s]),be=S.exports.useCallback((ee,ue)=>{Lt.debug("handleViewportChange",ee,ue),(ee!==m.top||ue!==m.bottom)&&p({top:ee,bottom:ue})},[m]),le=S.exports.useMemo(()=>{if(!b||!g)return!1;try{return Oh(b,g),Lt.debug("handleValidateDropTarget true"),!0}catch{return Lt.debug("handleValidateDropTarget false"),!1}},[b,g]),{focusedPath:he}=t;S.exports.useEffect(()=>{he!==void 0&&(he==="/"?n.collapseAll():(n.setExpanded(he,!1),n.setExpanded(he,!0)))},[n,he]),S.exports.useEffect(function(){Lt.debug("updating table viewport",m),n==null||n.setViewport({top:Math.max(0,m.top-d),bottom:m.bottom+d})},[d,n,m]),S.exports.useEffect(function(){const ue=n.onUpdate(Se=>{u({items:Se.items.map(De=>({...De,itemName:De.basename})),offset:Se.offset,itemCount:n.size})});return()=>{ue()}},[n]),S.exports.useEffect(function(){if(g!=null&&qn(g)&&g.filename!=="/"){const ue=setTimeout(()=>{g.isExpanded||n==null||n.setExpanded(g.filename,!0)},_E);return()=>clearTimeout(ue)}},[g,n]);const Re=S.exports.useCallback(ee=>l({...ee,isDragInProgress:b!=null,dropTargetItem:g,draggedItems:b,isDropTargetValid:le,onDragStart:H,onDragEnd:N,onDragOver:A,onDragExit:O,onDrop:k}),[N,O,A,H,k,b,g,le,l]);return h("div",{ref:D,className:W("file-list",{"is-dragging":b!=null}),onDragOver:V,onDrop:G,children:h(bn,{ref:I,items:c.items,itemCount:c.itemCount,offset:c.offset,onFocusChange:Z,onSelect:_,onSelectionChange:Q,onViewportChange:be,selectedRanges:y,renderItem:Re,rowHeight:a,isMultiSelect:e,isDragSelect:!1,isDeselectOnClick:!1})})}const LE={name:"File Explorer",DELETE:Ae.createAndAdd({id:"FILE_EXPLORER.DELETE",name:"Delete",shortcut:[me.DELETE],macShortcut:[de.CMD,me.BACKSPACE]}),RENAME:Ae.createAndAdd({id:"FILE_EXPLORER.RENAME",name:"Rename",shortcut:[me.ENTER],macShortcut:[me.ENTER]})},Lh={FILE_EXPLORER:LE};const Ah=X.module("FileListItemEditor"),AE=()=>Promise.resolve();function PE({item:t,onCancel:e,onSubmit:n,validate:s=AE}){const i=S.exports.useRef(null),[o,r]=S.exports.useState(t.basename),[l,a]=S.exports.useState(),[d,c]=S.exports.useState(Promise.resolve()),u=S.exports.useCallback(()=>{var C;(C=i.current)==null||C.focus()},[i]),m=S.exports.useCallback(C=>C.stopPropagation(),[]),p=S.exports.useCallback(()=>{d.then(()=>{n(o)}).catch(C=>Ah.info("Unable to validate name",C))},[n,o,d]);S.exports.useEffect(function(){const w=Te.makeCancelable(s(o));return w.then(()=>a(void 0)).catch(T=>{Te.isCanceled(T)||a(T)}),c(w),()=>w.cancel()},[s,o]),S.exports.useEffect(function(){u()},[u]);const g=S.exports.useCallback(()=>{Ah.debug2("handleBlur"),p()},[p]),f=S.exports.useCallback(C=>{const{value:w}=C.target;r(w)},[]),b=S.exports.useCallback(C=>{C.stopPropagation();const{key:w}=C;switch(w){case"Enter":{p();break}case"Escape":{e();break}}},[e,p]);return v("div",{className:"file-list-item-editor",children:[h("input",{type:"text",className:W("form-control file-list-item-editor-input",{"is-invalid":l}),value:o,ref:i,onBlur:g,onKeyDown:b,onChange:f,onClick:m,onDoubleClick:m,onMouseDown:m}),l&&h("div",{className:"invalid-feedback",children:`${l}`})]})}function Lp(t){const{isMultiSelect:e=!1,focusedPath:n,showContextMenu:s=!1,onCreateFile:i,onCreateFolder:o,onCopy:r,onDelete:l,onMove:a=()=>{},onRename:d,onSelect:c,onSelectionChange:u,table:m,rowHeight:p=nc,validateRename:g=()=>Promise.resolve()}=t,[f,b]=S.exports.useState(),[C,w]=S.exports.useState([]),[T,y]=S.exports.useState(),E=S.exports.useCallback(O=>{w(O),u==null||u(O)},[u]),I=S.exports.useCallback(O=>{y(O)},[]),D=S.exports.useCallback(()=>{T&&(r==null||r(T))},[T,r]),F=S.exports.useCallback(()=>{C.length>0&&(l==null||l(C))},[l,C]),x=S.exports.useCallback(()=>{i==null||i()},[i]),U=S.exports.useCallback(()=>{T&&(o==null||o(ce.getPath(T.filename)))},[T,o]),B=S.exports.useCallback(()=>{T&&b(T)},[T]),_=S.exports.useCallback(()=>{b(void 0)},[]),H=S.exports.useCallback(O=>{f&&(d==null||d(f,O),b(void 0))},[d,f]),A=S.exports.useMemo(()=>{if(f)return[];const O=[];return i&&O.push({title:"New File",description:"Create new file",action:x,group:oe.groups.medium}),o&&O.push({title:"New Folder",description:"Create new folder",action:U,group:oe.groups.medium}),r&&O.push({title:"Copy",description:"Copy",action:D,group:oe.groups.low,disabled:T==null||qn(T)}),l&&C.length>0&&O.push({title:"Delete",description:"Delete",shortcut:Lh.FILE_EXPLORER.DELETE,action:F,group:oe.groups.low}),d&&O.push({title:"Rename",description:"Rename",shortcut:Lh.FILE_EXPLORER.RENAME,action:B,group:oe.groups.low,disabled:T==null}),O},[D,F,x,U,B,T,r,i,o,l,d,C,f]),N=S.exports.useCallback(O=>f?g(f,O):Promise.reject(new Error("No rename item")),[f,g]),k=S.exports.useCallback(O=>{const{item:V}=O;return f&&f.filename===V.filename?Ka({...O,children:h(PE,{item:V,validate:N,onSubmit:H,onCancel:_})}):Ka(O)},[_,H,f,N]);return v("div",{className:"file-list-container",children:[m!=null&&h(OE,{onMove:a,onSelect:c,onSelectionChange:E,onFocusChange:I,renderItem:k,rowHeight:p,table:m,isMultiSelect:e,focusedPath:n}),s&&h(oe,{actions:A})]})}Lp.displayName="FileListContainer";class Ur extends Hi{constructor(e){super("Name already exists"),this.isExistingFile=!0,this.info=e}}class sc extends Error{constructor(){super("No file exists at the path specified"),this.isFileNotFound=!0}}const Ks=X.module("FileExplorer");function ic(t){const{storage:e,isMultiSelect:n=!1,focusedPath:s,onDelete:i=()=>{},onRename:o=()=>{},onSelect:r,onSelectionChange:l,rowHeight:a=nc}=t,[d,c]=S.exports.useState([]),[u,m]=S.exports.useState();S.exports.useEffect(function(){let D;async function F(){Ks.debug("initTable"),D=Te.makeCancelable(e.getTable(),x=>x.close());try{m(await D)}catch(x){Te.isCanceled(x)||Ks.error("Unable to initialize table",x)}}return F(),()=>{D.cancel()}},[e]);const p=S.exports.useCallback(I=>{Te.isCanceled(I)||Ks.error(I)},[]),g=S.exports.useCallback(I=>{Ks.debug("handleDelete, pending confirmation",I),c(I)},[]),f=S.exports.useCallback(()=>{Ks.debug("handleDeleteConfirm",d),d.forEach(I=>e.deleteFile(qn(I)?ce.makePath(I.filename):I.filename)),i(d),c([])},[d,i,e]),b=S.exports.useCallback(()=>{Ks.debug("handleDeleteCancel"),c([])},[]),C=S.exports.useCallback((I,D)=>{ce.reducePaths(I.map(x=>qn(x)?ce.makePath(x.filename):x.filename)).forEach(x=>{const U=ce.isPath(x)?`${D}${ce.getBaseName(x.substring(0,x.length-1))}/`:`${D}${ce.getBaseName(x)}`;e.moveFile(x,U).then(()=>{o(x,U)}).catch(p)})},[p,o,e]),w=S.exports.useCallback((I,D)=>{let F=I.filename;const x=qn(I);x&&!F.endsWith("/")&&(F=`${F}/`);let U=`${ce.getParent(F)}${D}`;x&&!U.endsWith("/")&&(U=`${U}/`),Ks.debug2("handleRename",F,U),e.moveFile(F,U).catch(p),o(F,U)},[p,o,e]),T=S.exports.useCallback(async(I,D)=>{if(D===I.basename)return;ce.validateName(D);const F=`${ce.getPath(I.filename)}${D}`;try{const x=await e.info(F);throw new Ur(x)}catch(x){if(!(x instanceof sc))throw x}},[e]),y=d.length>0,E=S.exports.useMemo(()=>d.length===1?`Are you sure you want to delete "${d[0].filename}"?`:"Are you sure you want to delete the selected files?",[d]);return v("div",{className:"file-explorer",children:[u&&h(Lp,{isMultiSelect:n,focusedPath:s,showContextMenu:!0,onMove:C,onDelete:g,onRename:w,onSelect:r,onSelectionChange:l,rowHeight:a,table:u,validateRename:T}),h($i,{isOpen:y,headerText:E,bodyText:"You cannot undo this action.",onCancel:b,onConfirm:f,confirmButtonText:"Delete"})]})}ic.displayName="FileExplorer";const qs=X.module("NewItemModal"),Br=class extends S.exports.PureComponent{constructor(t){super(t),this.inputRef=Y.createRef(),this.pending=new fs,this.pathMap=new Map,this.isInitialLoad=!0,this.handleModalSubmit=this.handleModalSubmit.bind(this),this.handleModalOpened=this.handleModalOpened.bind(this),this.handleSelect=this.handleSelect.bind(this),this.handleChange=this.handleChange.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleValidationError=this.handleValidationError.bind(this),this.handleOverwriteCancel=this.handleOverwriteCancel.bind(this),this.handleOverwriteConfirm=this.handleOverwriteConfirm.bind(this),this.handleExtensionChangeCancel=this.handleExtensionChangeCancel.bind(this),this.handleExtensionChangeConfirm=this.handleExtensionChangeConfirm.bind(this),this.handleBreadcrumbSelect=this.handleBreadcrumbSelect.bind(this);const{defaultValue:e}=t,n=ce.hasPath(e)?ce.getPath(e):"/";this.state={isSubmitting:!1,path:n,prevExtension:ce.getExtension(e),showExtensionChangeModal:!1,showOverwriteModal:!1,value:ce.getBaseName(e)}}static getValidationMessage(t){return t instanceof Ur&&t.info.type==="directory"?"Error: Cannot overwrite existing directory":`${t}`}static handleError(t){Te.isCanceled(t)||qs.error(t)}componentDidUpdate(t,e){const{isOpen:n}=this.props,{isOpen:s}=t,{value:i,path:o}=this.state;!s&&n&&(this.resetValue(),this.isInitialLoad=!0),s&&n&&(!this.isInitialLoad&&(o!==e.path||i!==e.value)&&this.updateValidationStatus(o,i),this.isInitialLoad=!1)}componentWillUnmount(){this.pending.cancel(),this.cancelableValidatePromise&&this.cancelableValidatePromise.cancel(),this.cancelableExistingItemPromise&&this.cancelableExistingItemPromise.cancel()}resetValue(){const{defaultValue:t}=this.props,e=ce.hasPath(t)?ce.getPath(t):"/";this.setState({path:e,value:ce.getBaseName(t),validationError:void 0,prevExtension:ce.getExtension(t),isSubmitting:!1})}getValidationPromise(t,e,n=!1){return this.cancelableValidatePromise&&this.cancelableValidatePromise.cancel(),this.cancelableValidatePromise=Te.makeCancelable(this.validateName(t,e,n)),this.cancelableValidatePromise}async validateName(t,e,n){ce.validateName(e);const{defaultValue:s,storage:i}=this.props;if(n){const o=`${t}${e}`;if(o!==s)try{const r=await i.info(o);throw new Ur(r)}catch(r){if(!(r instanceof sc))throw r}}return e}updateValidationStatus(t,e){this.getValidationPromise(t,e).then(()=>{this.setState({validationError:void 0})}).catch(this.handleValidationError).catch(Br.handleError)}handleModalOpened(){this.focusRenameInput()}handleModalSubmit(){this.submitModal()}handleChange(t){const{value:e}=t.target;this.setState({value:e})}handleSelect(t){if(qs.debug("handleSelect",t),t.type==="directory")this.setState({path:ce.makePath(t.filename)});else{const e=t.basename,n=ce.getPath(t.filename);this.setState({value:e,path:n},()=>{this.focusRenameInput()})}}handleKeyDown(t){const{key:e}=t;switch(t.stopPropagation(),e){case"Enter":{t.preventDefault(),this.submitModal();break}case"Escape":{t.preventDefault();const{onCancel:n}=this.props;n();break}}}handleValidationError(t){if(!(t instanceof Hi))throw t;qs.debug("Validation error",t),this.setState({validationError:t})}handleOverwriteCancel(){this.setState({showOverwriteModal:!1,isSubmitting:!1})}handleOverwriteConfirm(){this.setState({showOverwriteModal:!1});const{onSubmit:t}=this.props,{path:e,value:n}=this.state;qs.debug("handleOverwriteConfirm",e,n),t(`${e}${n}`)}handleExtensionChangeCancel(){qs.debug("handleExtensionChangeCancel"),this.setState(({value:t,prevExtension:e})=>{const n=ce.replaceExtension(t,e);return{showExtensionChangeModal:!1,value:n}}),this.submitModal(!0)}handleExtensionChangeConfirm(){qs.debug("handleExtensionChangeConfirm"),this.setState({showExtensionChangeModal:!1}),this.submitModal(!0)}focusRenameInput(){const t=this.inputRef.current;if(t){const{type:e}=this.props,{value:n}=t,s=e==="directory"?n.length:n.lastIndexOf(".");t.focus(),t.setSelectionRange(0,s>0?s:n.length)}}submitModal(t=!1){this.setState(({prevExtension:e,value:n,path:s})=>{const{notifyOnExtensionChange:i,type:o}=this.props;qs.debug("submitModal",e,n);const r=ce.getExtension(n);return i&&!t&&e!==null&&e!==r?{isSubmitting:!1,showExtensionChangeModal:!0,newExtension:r}:(this.getValidationPromise(s,n,!0).then(l=>{const{onSubmit:a}=this.props;a(`${s}${n}`)}).catch(l=>{if(l instanceof Ur&&o!=="directory"&&l.info.type!=="directory"){this.setState({showOverwriteModal:!0});return}throw l}).catch(l=>{throw Te.isCanceled(l)&&this.setState({isSubmitting:!1}),l}).catch(this.handleValidationError).catch(Br.handleError),{isSubmitting:!0,showExtensionChangeModal:!1,newExtension:void 0})})}handleBreadcrumbSelect(t){this.setState({path:t})}renderPathButtons(t){const e=t.split("/");return e.pop(),e.map((n,s)=>{let i="";for(let o=0;o<s;o+=1)i+=`${e[o]}/`;return i+=`${n}/`,v(Y.Fragment,{children:[h(z,{kind:"ghost",className:"directory-breadcrumbs",onClick:()=>this.handleBreadcrumbSelect(i),"aria-label":s===0?"Home":void 0,icon:s===0?h(j,{icon:Mf,transform:"right-1.6"}):void 0,tooltip:s===0?"Home":void 0,children:n}),"/"]},i)})}render(){const{storage:t,isOpen:e,onCancel:n,placeholder:s,title:i,type:o}=this.props,{isSubmitting:r,path:l,showExtensionChangeModal:a,showOverwriteModal:d,validationError:c,value:u,prevExtension:m,newExtension:p}=this.state,g=o==="directory",f=ce.fileExtensionToString(m),b=ce.fileExtensionToString(p),C=g?"Create":"Save",w=g?"New folder name":"Save file as";return v(ye,{children:[v($o,{isOpen:e,toggle:n,onOpened:this.handleModalOpened,className:"modal-dialog-centered new-file-modal theme-bg-dark",children:[h(zo,{toggle:n,children:i}),h(Wo,{children:h("form",{children:v("div",{className:"d-flex flex-column new-file-modal-content",children:[v("div",{className:"flex-grow-0 mb-4",children:[h("label",{htmlFor:"file-name-input",children:w}),h("input",{id:"file-name-input",type:"text",autoComplete:"off",autoCapitalize:"none",autoCorrect:"off",spellCheck:"false",className:W("form-control",{"is-invalid":c}),value:u,placeholder:s,ref:this.inputRef,onKeyDown:this.handleKeyDown,onChange:this.handleChange}),c&&h("div",{className:"invalid-feedback",children:Br.getValidationMessage(c)})]}),v("div",{className:"flex-grow-0",children:[h("label",{children:"Directory: /"}),this.renderPathButtons(l)]}),h("div",{className:"flex-grow-1 file-explorer-container",children:h(ic,{onSelect:this.handleSelect,storage:t,focusedPath:l})})]})})}),v(od,{children:[h(z,{kind:"secondary",onClick:n,children:"Cancel"}),h(z,{kind:"primary",disabled:r,onClick:this.handleModalSubmit,children:C})]})]}),h($i,{isOpen:d,headerText:"Confirm overwrite",bodyText:"File with this name already exists, are you sure you want to overwrite it?",onCancel:this.handleOverwriteCancel,onConfirm:this.handleOverwriteConfirm,cancelButtonText:"Cancel",confirmButtonText:"Overwrite"}),h($i,{isOpen:a,headerText:"Confirm extension change",bodyText:`Are you sure you want to change extension from "${f}" to "${b}"?`,onCancel:this.handleExtensionChangeCancel,onConfirm:this.handleExtensionChangeConfirm,cancelButtonText:`Keep "${f}"`,confirmButtonText:`Use "${b}"`})]})}};let Wl=Br;Wl.propTypes={isOpen:R.exports.bool,title:R.exports.string.isRequired,defaultValue:R.exports.string,type:R.exports.oneOf(["file","directory"]).isRequired,onSubmit:R.exports.func,onCancel:R.exports.func,placeholder:R.exports.string,storage:R.exports.shape({}).isRequired,notifyOnExtensionChange:R.exports.bool};Wl.defaultProps={isOpen:!1,defaultValue:"/",notifyOnExtensionChange:!1,placeholder:"",onSubmit:t=>{},onCancel:()=>{}};function HE({createFile:t,createFolder:e,onSearchChange:n,defaultSearchText:s=""}){return v("div",{className:"file-explorer-toolbar",children:[v("div",{className:"file-explorer-toolbar-buttons",children:[h(z,{kind:"ghost",icon:Cu,tooltip:"New notebook",onClick:t,"aria-label":"New notebook"}),h(z,{kind:"ghost",icon:Pf,tooltip:"New folder",onClick:e,"aria-label":"New folder"})]}),n&&h("div",{className:"file-explorer-toolbar-search",children:h(Pu,{value:s,onChange:n,placeholder:"Search by name"})})]})}const Di=X.module("FileExplorerPanel"),VE=(t,e)=>{const n=Cm(t),s=gi(t,e.localDashboardId),{session:i,config:o}=s!=null?s:{},r=o==null?void 0:o.type;return{fileStorage:n,language:r,session:i}},UE=Nt(VE,null,null,{forwardRef:!0});function BE(t){const e=t;return e!=null&&typeof e.button=="number"}const qa=class extends Y.Component{static handleError(t){Di.error(t)}static isFocusEvent(t){return BE(t)?t.detail>=2:!0}constructor(t){super(t),this.handleFileSelect=this.handleFileSelect.bind(this),this.handleCreateFile=this.handleCreateFile.bind(this),this.handleCreateDirectory=this.handleCreateDirectory.bind(this),this.handleCreateDirectoryCancel=this.handleCreateDirectoryCancel.bind(this),this.handleCreateDirectorySubmit=this.handleCreateDirectorySubmit.bind(this),this.handleDelete=this.handleDelete.bind(this),this.handleRename=this.handleRename.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleSelectionChange=this.handleSelectionChange.bind(this);const{session:e,language:n}=t;this.state={isShown:!1,language:n,session:e,showCreateFolder:!1,focusedFilePath:"/"}}componentDidMount(){this.isHidden()||this.setState({isShown:!0})}handleCreateFile(){const{glEventHub:t}=this.props,{session:e,language:n}=this.state,s={language:n,value:""};Di.debug("handleCreateFile",e,n,s),t.emit(He.CREATE_NOTEBOOK,e,n,s)}handleCreateDirectory(t){this.setState({showCreateFolder:!0})}handleCreateDirectoryCancel(){Di.debug("handleCreateDirectoryCancel"),this.setState({showCreateFolder:!1})}handleCreateDirectorySubmit(t){Di.debug("handleCreateDirectorySubmit",t),this.setState({showCreateFolder:!1});const{fileStorage:e}=this.props;e.createDirectory(t).catch(qa.handleError)}handleDelete(t){const{glEventHub:e}=this.props;t.forEach(n=>{e.emit(He.CLOSE_FILE,{id:n.filename,itemName:n.filename})})}handleSelectionChange(t){let e="/";t.length===1&&(t[0].type==="directory"?e=ce.makePath(t[0].filename):e=ce.getPath(t[0].filename)),this.setState({focusedFilePath:e})}handleFileSelect(t,e){if(Di.debug("fileSelect",t),t.type==="directory")return;const n=qa.isFocusEvent(e),s={id:t.filename,itemName:t.filename},{glEventHub:i}=this.props,{session:o,language:r}=this.state,l={value:null,language:r};i.emit(He.SELECT_NOTEBOOK,o,r,l,s,n)}handleRename(t,e){const{glEventHub:n}=this.props;Di.debug("handleRename",t,e),n.emit(He.RENAME_FILE,t,e)}handleSessionOpened(t,{language:e}){this.setState({session:t,language:e})}handleSessionClosed(){this.setState({session:void 0,language:void 0})}handleShow(){this.setState({isShown:!0})}isHidden(){const{glContainer:t}=this.props,{isHidden:e}=t;return e}render(){const{fileStorage:t,glContainer:e,glEventHub:n}=this.props,{isShown:s,showCreateFolder:i,focusedFilePath:o}=this.state;return v(jn,{className:"file-explorer-panel",componentPanel:this,glContainer:e,glEventHub:n,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onShow:this.handleShow,children:[h(HE,{createFile:this.handleCreateFile,createFolder:this.handleCreateDirectory}),s&&h(ic,{isMultiSelect:!0,storage:t,onDelete:this.handleDelete,onRename:this.handleRename,onSelect:this.handleFileSelect,onSelectionChange:this.handleSelectionChange}),h(Wl,{isOpen:i,type:"directory",title:"Create New Folder",storage:t,onSubmit:this.handleCreateDirectorySubmit,onCancel:this.handleCreateDirectoryCancel,defaultValue:o})]})}};let oc=qa;oc.COMPONENT="FileExplorerPanel";oc.TITLE="File Explorer";const ol=UE(oc);const lt=X.module("FilterSetManager"),$E="Enter name...",Ph="No Available Filter Sets";class rl extends S.exports.Component{constructor(e){super(e),this.renameInputRef=Y.createRef(),this.dropdownRef=Y.createRef(),this.editDropdownRef=Y.createRef(),this.isRenamingExistingSet=pe((n,s)=>s!==void 0&&n.some(({id:i})=>i===s.id)),this.handleSettingsCancel=this.handleSettingsCancel.bind(this),this.handleSettingsClick=this.handleSettingsClick.bind(this),this.handleSettingsSave=this.handleSettingsSave.bind(this),this.handleBackgroundClick=this.handleBackgroundClick.bind(this),this.handleEditDropdownChange=this.handleEditDropdownChange.bind(this),this.handleFilterChange=this.handleFilterChange.bind(this),this.handleFilterApply=this.handleFilterApply.bind(this),this.handleCaptureNewSet=this.handleCaptureNewSet.bind(this),this.handleNameInputChange=this.handleNameInputChange.bind(this),this.handleNameInputKeyPress=this.handleNameInputKeyPress.bind(this),this.handleRenameConfirm=this.handleRenameConfirm.bind(this),this.handleRenameCancel=this.handleRenameCancel.bind(this),this.handleRestoreFullStateChange=this.handleRestoreFullStateChange.bind(this),this.handleSetDelete=this.handleSetDelete.bind(this),this.handleSetEdit=this.handleSetEdit.bind(this),this.handleSetUpdate=this.handleSetUpdate.bind(this),this.state={editId:void 0,renameSet:void 0,nameInputValue:"",nameInputError:void 0,modifiedFilterSets:[],restoreFullState:!1}}static animateScreenFlash(){var n;const e=document.createElement("div");e.classList.add("screen-flash-overlay"),e.addEventListener("animationend",()=>{e.remove()}),(n=document.querySelector("body"))==null||n.appendChild(e)}componentDidMount(){const{isValueShown:e}=this.props;e?this.updateSelectedId():this.initSettingsScreen()}componentDidUpdate(e,n){const{isValueShown:s,filterSets:i}=this.props,{modifiedFilterSets:o}=this.state;if(e.isValueShown&&!s&&this.initSettingsScreen(),this.isNameInputScreen()&&!this.isNameInputScreen(n)&&this.focusRenameInput(),i!==e.filterSets)if(!s&&i.length>0&&e.filterSets.length===0&&o.length===0){const{onChange:r}=this.props;r({isValueShown:!0,selectedId:i[0].id})}else this.updateSelectedId()}initSettingsScreen(){const{filterSets:e,selectedId:n}=this.props;lt.debug("initSettingsScreen",e,n),this.setState({modifiedFilterSets:[...e],editId:n})}updateSelectedId(){const{isValueShown:e,filterSets:n,selectedId:s,onChange:i}=this.props;if(lt.debug("updateSelectedId",n,s),!!e&&!n.some(({id:o})=>o===s)){const o=n.length===0;i({isValueShown:!o,selectedId:o?void 0:n[0].id})}}handleEditDropdownChange(e){const{value:n}=e.target;this.setState({editId:n})}handleFilterChange(e){const{value:n}=e.target,{isValueShown:s,onChange:i}=this.props;this.applyFilterSet(n),i({isValueShown:s,selectedId:n})}handleFilterApply(){const{selectedId:e}=this.props;this.applyFilterSet(e)}handleSettingsCancel(){const{onChange:e,selectedId:n,filterSets:s}=this.props;this.setState({modifiedFilterSets:[]}),s.length>0&&e({isValueShown:!0,selectedId:n})}handleSettingsSave(){const{onChange:e,onUpdateSets:n}=this.props,{modifiedFilterSets:s,editId:i}=this.state;this.setState({modifiedFilterSets:[]}),lt.debug("Update sets",s,i),n(s),s.length>0&&e({isValueShown:!0,selectedId:i})}handleCaptureNewSet(){const{getFilterState:e}=this.props;rl.animateScreenFlash();const n=ze(),s=e(),i={id:n,title:"",panels:s};lt.debug("handleSetCreate",i),this.setState({nameInputValue:"",nameInputError:void 0,renameSet:i})}handleRenameCancel(){this.setState({renameSet:void 0})}handleRestoreFullStateChange(e){this.setState({restoreFullState:e.target.value==="true"})}getNameError(e){var o;const{renameSet:n,modifiedFilterSets:s}=this.state,i=(o=e==null?void 0:e.trim())!=null?o:"";if(i.length===0)return lt.debug("Name cannot be empty",i),"Name cannot be empty";if(n!==void 0&&s.some(({title:r,id:l})=>r===i&&l!==n.id))return lt.debug("Set with this name already exists",i),"Set with this name already exists"}handleRenameConfirm(){var c;const{nameInputValue:e,renameSet:n,modifiedFilterSets:s,restoreFullState:i}=this.state;if(n===void 0){lt.error("Renamed set undefined.");return}const o=this.getNameError(e);if(lt.debug("handleRenameConfirm",e,o),o!==void 0){this.setState({nameInputError:o});return}const r=(c=e==null?void 0:e.trim())!=null?c:"",l={...n,title:r,restoreFullState:i},a=s.findIndex(({id:u})=>u===n.id),d=[...s];a>=0?(d[a]=l,lt.debug("Renamed existing set",d)):(d.push(l),lt.debug("Added new set to modified sets",d)),this.setState({editId:l.id,modifiedFilterSets:d,renameSet:void 0})}handleSetDelete(){this.setState(e=>{const{editId:n,modifiedFilterSets:s}=e,i=s.findIndex(({id:a})=>a===n);if(i<0)return lt.error("Unable to find selected filterSet index",s,n),null;const o=s.filter(({id:a})=>a!==n),r=Math.max(0,Math.min(o.length-1,i-1)),l=o.length>0?o[r].id:void 0;return lt.debug("Deleted selected set",n,s,o),lt.debug("New selection",r,l),{modifiedFilterSets:o,editId:l}})}handleSetUpdate(){const{getFilterState:e}=this.props;rl.animateScreenFlash();const n=e();this.setState(({modifiedFilterSets:s,editId:i})=>{if(i===void 0)return lt.error("Filter for update not selected."),null;const o=[...s],r=o.findIndex(({id:l})=>l===i);return r<0?(lt.error("Selected set for update not found."),null):(o[r]={...o[r],panels:n},lt.debug("Update set",o,n),{modifiedFilterSets:o})})}handleSetEdit(){this.setState(({editId:e,modifiedFilterSets:n})=>{const s=n.find(({id:r})=>r===e);if(s===void 0)return lt.error("Could not find selected set",e,n),null;const{title:i,restoreFullState:o=!1}=s;return{nameInputValue:i,nameInputError:void 0,renameSet:s,restoreFullState:o}})}handleSettingsClick(e){e.stopPropagation();const{onChange:n,selectedId:s}=this.props;n({isValueShown:!1,selectedId:s})}handleBackgroundClick(e){lt.debug("handleBackgroundClick"),e.target!==this.dropdownRef.current&&this.focusInput()}handleNameInputChange(e){const{value:n}=e.target,s=this.getNameError(n);this.setState({nameInputValue:n,nameInputError:s})}handleNameInputKeyPress(e){const{key:n}=e;n==="Enter"&&(e.preventDefault(),this.handleRenameConfirm())}isNameInputScreen(e=this.state){const{renameSet:n}=e;return n!==void 0}applyFilterSet(e){const{onApply:n,filterSets:s}=this.props;if(e===void 0){lt.debug("No filter selected");return}const i=s.find(({id:o})=>o===e);if(i===void 0){lt.debug("Selected id not found in filterSets",e,s);return}lt.debug("Apply filterSet",i),n(i)}focusInput(){var e;(e=this.dropdownRef.current)==null||e.focus()}focusRenameInput(){var e;(e=this.renameInputRef.current)==null||e.focus()}render(){const{nameInputValue:e,nameInputError:n,editId:s,renameSet:i,modifiedFilterSets:o,restoreFullState:r}=this.state,{isValueShown:l,filterSets:a,selectedId:d}=this.props,c=this.isNameInputScreen(),u=this.isRenamingExistingSet(o,i),m=o.length===0,p=!c&&m&&a.length===0,g=!c&&!p,f=v("div",{className:"fa-layers mr-3",children:[h(j,{icon:Po,mask:Da,transform:"shrink-1 down-5 right-7"}),h(j,{icon:Ps,className:"text-primary",transform:"shrink-6 down-5 right-7"})]}),b=v("div",{className:"fa-layers",children:[h(j,{icon:Po,mask:Da,transform:"shrink-1 down-5 right-7"}),h(j,{icon:Ra,transform:"shrink-1 down-5 right-7"})]});return h("div",{className:"filter-set-manager fill-parent-absolute",children:v(rd,{className:"w-100 h-100",isFlipped:l,children:[h("div",{className:"filter-set-manager-settings-card fill-parent-absolute",children:v("div",{className:"filter-set-manager-card-content",children:[p&&v("div",{children:[h(z,{kind:"ghost",className:"btn btn-link no-underline",onClick:this.handleCaptureNewSet,icon:f,children:"Capture filter set"}),h("div",{className:"py-3 text-muted small",children:"Takes a snapshot of the currently applied filters on all panels, allowing you to restore saved filter sets later."})]}),c&&v("div",{className:"d-flex flex-column justify-content-center","data-testid":"edit-filter-set-container",children:[v("div",{className:"form-group",children:[h("label",{children:u?"Edit set":"Name captured set"}),v("div",{className:"name-input-container",children:[h("input",{type:"text",className:"input-set-name form-control",placeholder:$E,value:e,ref:this.renameInputRef,onChange:this.handleNameInputChange,onKeyPress:this.handleNameInputKeyPress,spellCheck:"false"}),h(z,{"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:bu}),h(z,{"data-testid":"rename-cancel-button",kind:"ghost",className:"btn btn-link no-underline pt-2 pb-2",onClick:this.handleRenameCancel,tooltip:"Cancel",icon:wf})]}),n!==void 0&&h("div",{className:"error-message",children:n})]}),h("div",{className:"form-group",children:v(vl,{onChange:this.handleRestoreFullStateChange,value:`${r}`,children:[h(xn,{value:"false",children:"Restore only filters"}),h(xn,{value:"true",children:"Restore full table state"})]})})]}),g&&v("div",{className:"filter-set-manager-settings-grid-1",children:[v("div",{className:"form-group",children:[h("label",{children:"Edit filter sets"}),v("div",{className:"filter-select-container",children:[v("select",{"data-testid":"settings-card-filter-select",ref:this.editDropdownRef,value:s!=null?s:"-1",className:"custom-select filter-value-select",onChange:this.handleEditDropdownChange,disabled:m,children:[m&&h("option",{value:"-1",disabled:!0,children:Ph}),o.map(({id:C,title:w})=>h("option",{value:C,children:w},C))]}),h(z,{kind:"ghost",onClick:this.handleSetUpdate,disabled:m,icon:b,tooltip:"Update"}),h(z,{kind:"ghost",onClick:this.handleSetEdit,disabled:m,icon:ml,tooltip:"Edit"}),h(z,{kind:"ghost",onClick:this.handleSetDelete,disabled:m,icon:wn,tooltip:"Delete"})]})]}),h("div",{children:h(z,{kind:"ghost",className:"btn btn-link no-underline",onClick:this.handleCaptureNewSet,icon:f,children:"Capture new filter set"})}),v("div",{className:"py-3 text-right",children:[h(z,{kind:"secondary",onClick:this.handleSettingsCancel,children:"Cancel"}),"\xA0",h(z,{kind:"primary",onClick:this.handleSettingsSave,children:"Save"})]})]})]})},"front"),v("div",{className:"filter-set-manager-value-card fill-parent-absolute",onClick:this.handleBackgroundClick,children:[h("div",{className:"filter-set-manager-column",children:h("div",{className:"filter-set-manager-column-title",children:"Filter sets"})}),h("div",{className:"filter-set-manager-card-content",children:h("div",{className:"filter-set-manager-value-input",children:v("div",{className:"filter-select-container",children:[v("select",{"data-testid":"value-card-filter-select",ref:this.dropdownRef,value:d,className:"custom-select filter-value-select",onChange:this.handleFilterChange,children:[a.length===0&&h("option",{value:"-1",disabled:!0,children:Ph}),a.map(({id:C,title:w})=>h("option",{value:C,children:w},C))]}),h(z,{"data-testid":"filter-apply-button",kind:"ghost",onClick:this.handleFilterApply,icon:cd,tooltip:"Apply Filter Set"})]})})}),h("div",{className:"filter-set-manager-menu",children:h(z,{kind:"ghost",className:"btn btn-link btn-link-icon m-2 px-2",onClick:this.handleSettingsClick,tooltip:"Settings",icon:h(j,{icon:Go,transform:"grow-4"})})})]},"back")]})})}}function rc(t){var l,a;const{model:e,widgetName:n,glContainer:s,description:i}=t,o=((l=e==null?void 0:e.rowCount)!=null?l:0)-((a=e==null?void 0:e.pendingRowCount)!=null?a:0),r=e==null?void 0:e.displayString(o,"long");return h(Vl,{widgetType:"Table",widgetName:n,glContainer:s,description:i,children:v("div",{className:"column-statistics-grid",children:[h("span",{className:"column-statistic-operation",children:"Number of Rows"}),h("span",{className:"column-statistic-value",children:r})]})})}rc.propTypes={glContainer:kd.Container.isRequired,widgetName:R.exports.string.isRequired,description:R.exports.string};rc.defaultProps={description:null};const Un=X.module("IrisGridPanel"),WE=500,zE={IrisGrid:io,IrisGridTableModel:yp,ContextMenuRoot:Du};class Yi extends S.exports.PureComponent{constructor(e){super(e),this.getGridInputFilters=pe((s,i)=>te.getInputFiltersForColumns(s,i.filter(({value:o,excludePanelIds:r})=>{const l=ne.getIdFromPanel(this);return o!=null&&(r==null||l!=null&&!r.includes(l))}))),this.getAlwaysFetchColumns=pe((s,i)=>{const o=ne.getIdFromPanel(this),r=new Set(i);for(let l=0;l<s.length;l+=1){const{start:a}=s[l];a!=null&&a.panelId===o&&r.add(a.columnName)}return[...r]}),this.getPluginContent=pe((s,i,o,r,l)=>!i||!li(i)||s==null||i.table==null?null:h("div",{className:"iris-grid-plugin",children:h(s,{ref:this.pluginRef,filter:this.handlePluginFilter,onFilter:this.handlePluginFilter,fetchColumns:this.handlePluginFetchColumns,onFetchColumns:this.handlePluginFetchColumns,table:i.table,user:o,panel:this,workspace:r,components:zE,onStateChange:this.handlePluginStateChange,pluginState:l})})),this.getDehydratedIrisGridPanelState=pe((s,i,o,r,l)=>te.dehydrateIrisGridPanelState(s,{isSelectingPartition:i,partition:o,partitionColumn:r,advancedSettings:l})),this.getDehydratedIrisGridState=pe((s,i,o,r,l,a,d,c,u,m,p,g,f,b,C,w,T,y,E,I)=>te.dehydrateIrisGridState(s,{advancedFilters:o,aggregationSettings:T,customColumnFormatMap:r,isFilterBarShown:l,metrics:{userColumnWidths:C,userRowHeights:w},quickFilters:a,customColumns:d,reverseType:c,rollupConfig:u,showSearchBar:m,searchValue:p,selectDistinctColumns:g,selectedSearchColumns:f,sorts:i,invertSearchColumns:b,pendingDataMap:y,frozenColumns:E,conditionalFormats:I})),this.getDehydratedGridState=pe((s,i,o,r,l)=>te.dehydrateGridState(s,{isStuckToBottom:r,isStuckToRight:l,movedColumns:i,movedRows:o})),this.getCachedPanelState=pe((s,i,o,r)=>({irisGridPanelState:s,irisGridState:i,gridState:o,pluginState:r})),this.savePanelState=je(()=>{const{irisGridState:s,gridState:i,pluginState:o}=this;P(s);const{onPanelStateUpdate:r}=this.props,{model:l,panelState:a,isSelectingPartition:d,partition:c,partitionColumn:u,advancedSettings:m}=this.state,{advancedFilters:p,aggregationSettings:g,customColumnFormatMap:f,isFilterBarShown:b,quickFilters:C,customColumns:w,reverseType:T,rollupConfig:y,showSearchBar:E,searchValue:I,selectDistinctColumns:D,selectedSearchColumns:F,sorts:x,invertSearchColumns:U,metrics:B,pendingDataMap:_,frozenColumns:H,conditionalFormats:A}=s;P(l),P(B);const{userColumnWidths:N,userRowHeights:k}=B;P(i);const{isStuckToBottom:O,isStuckToRight:V,movedColumns:G,movedRows:Q}=i,Z=this.getCachedPanelState(this.getDehydratedIrisGridPanelState(l,d,c,u,m),this.getDehydratedIrisGridState(l,x,p,f,b,C,w,T,y,E,I,D,F,U,N,k,g,_,H,A),this.getDehydratedGridState(l,G,Q,O,V),o);Z!==a&&(Un.debug("Saving panel state",this,Z),this.setState({panelState:Z}),r==null||r(Z))},WE),this.handleAdvancedSettingsChange=this.handleAdvancedSettingsChange.bind(this),this.handleColumnsChanged=this.handleColumnsChanged.bind(this),this.handleTableChanged=this.handleTableChanged.bind(this),this.handleColumnSelected=this.handleColumnSelected.bind(this),this.handleDataSelected=this.handleDataSelected.bind(this),this.handleError=this.handleError.bind(this),this.handleGridStateChange=this.handleGridStateChange.bind(this),this.handlePluginStateChange=this.handlePluginStateChange.bind(this),this.handlePartitionAppend=this.handlePartitionAppend.bind(this),this.handleCreateChart=this.handleCreateChart.bind(this),this.handleResize=this.handleResize.bind(this),this.handleShow=this.handleShow.bind(this),this.handleTabClicked=this.handleTabClicked.bind(this),this.handleDisconnect=this.handleDisconnect.bind(this),this.handleReconnect=this.handleReconnect.bind(this),this.handleLoadSuccess=this.handleLoadSuccess.bind(this),this.handleLoadError=this.handleLoadError.bind(this),this.isColumnSelectionValid=this.isColumnSelectionValid.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.handlePluginFilter=this.handlePluginFilter.bind(this),this.handlePluginFetchColumns=this.handlePluginFetchColumns.bind(this),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.irisGrid=Y.createRef(),this.pluginRef=Y.createRef();const{panelState:n}=e;this.pluginState=null,this.state={error:null,isDisconnected:!1,isLoaded:!1,isLoading:!0,isModelReady:!1,model:void 0,advancedFilters:new Map,aggregationSettings:{aggregations:[],showOnTop:!1},advancedSettings:new Map(rp.DEFAULTS),customColumns:[],customColumnFormatMap:new Map,isFilterBarShown:!1,quickFilters:new Map,sorts:[],userColumnWidths:new Map,userRowHeights:new Map,reverseType:L.REVERSE_TYPE.NONE,movedColumns:[],movedRows:[],isSelectingPartition:!1,partition:void 0,partitionColumn:void 0,rollupConfig:void 0,showSearchBar:!1,searchValue:"",selectedSearchColumns:void 0,invertSearchColumns:!0,Plugin:void 0,pluginFilters:[],pluginFetchColumns:[],modelQueue:[],pendingDataMap:new Map,frozenColumns:void 0,panelState:n,irisGridStateOverrides:{},gridStateOverrides:{},isStuckToBottom:!1,isStuckToRight:!1,conditionalFormats:[],selectDistinctColumns:[]}}componentDidMount(){this.initModel()}componentDidUpdate(e,n){const{model:s}=this.state;s!==n.model&&(n.model!=null&&(this.stopModelListening(n.model),n.model.close()),s!=null&&this.startModelListening(s))}componentWillUnmount(){this.savePanelState.cancel(),this.modelPromise!=null&&(this.modelPromise.cancel(),this.modelPromise=void 0);const{model:e}=this.state;e&&(this.stopModelListening(e),e.close())}getTableName(){const{metadata:e}=this.props;return e.table}initModel(){this.setState({isModelReady:!1,isLoading:!0,error:null});const{makeModel:e}=this.props;this.modelPromise!=null&&this.modelPromise.cancel(),this.modelPromise=Te.makeCancelable(e(),n=>n.close()),this.modelPromise.then(this.handleLoadSuccess).catch(this.handleLoadError)}handleLoadSuccess(e){const n=e,{panelState:s,irisGridStateOverrides:i}=this.state,o=[];if(s!=null){const{irisGridState:r}=s,{aggregationSettings:l,customColumns:a,selectDistinctColumns:d=[],rollupConfig:c}={...r,...i};a.length>0&&o.push(u=>{u.customColumns=a}),c!=null&&c.columns.length>0&&o.push(u=>{u.rollupConfig=te.getModelRollupConfig(u.originalColumns,c,l)}),d.length>0&&o.push(u=>{u.selectDistinctColumns=d})}this.setState({model:n,modelQueue:o}),this.initModelQueue(n,o)}initModelQueue(e,n){const s=e;if(n.length===0){this.modelInitialized(s);return}const i=n.shift();Un.debug("initModelQueue",i),i&&i(s),this.setState({modelQueue:n})}handleAdvancedSettingsChange(e,n){Un.debug("handleAdvancedSettingsChange",e,n),this.setState(({advancedSettings:s})=>s.get(e)===n?null:{advancedSettings:new Map(s).set(e,n)})}handlePluginFilter(e){const{model:n}=this.state;P(n);const{columns:s,formatter:i}=n,o=te.getFiltersFromInputFilters(s,e,i.timeZone);this.setState({pluginFilters:o})}handlePluginFetchColumns(e){this.setState({pluginFetchColumns:e})}handleContextMenu(e){var n,s,i;return(i=(s=(n=this.pluginRef.current)==null?void 0:n.getMenu)==null?void 0:s.call(n,e))!=null?i:[]}isColumnSelectionValid(e){const{columnSelectionValidator:n}=this.props;return n&&e?n(this,e):!1}handleGridStateChange(e,n){this.irisGridState=e,this.gridState=n,this.setState({isLoaded:!0,isLoading:!1}),this.savePanelState();const{glEventHub:s,onStateChange:i}=this.props;s.emit(Tt.STATE_CHANGED,this),i==null||i(e,n)}handlePluginStateChange(e){const{irisGridState:n,gridState:s}=this;this.pluginState=e,n!==null&&s!==null&&this.savePanelState()}handleColumnsChanged(e){const{isModelReady:n,model:s,modelQueue:i}=this.state;n?this.sendColumnsChange(e.detail):(P(s),this.initModelQueue(s,i))}handleTableChanged(e){Un.debug("handleTableChanged",e);const{glEventHub:n}=this.props,{detail:s}=e;n.emit(Pe.TABLE_CHANGED,this,s)}handlePartitionAppend(e,n){const{glEventHub:s}=this.props,{name:i}=e,o=this.getTableName(),r=`${o} = ${o}.where("${i}=\`${n}\`")`;s.emit(Ct.SEND_COMMAND,r,!1,!0)}handleCreateChart(e,n){this.savePanelState.flush(),this.setState(()=>null,()=>{const{glEventHub:s,inputFilters:i,metadata:o}=this.props,{table:r}=o,{panelState:l}=this.state,a=ne.getIdFromPanel(this);let d;l&&(d=te.extractTableSettings(l,i)),s.emit(Tt.CREATE_CHART,{metadata:{settings:e,sourcePanelId:a,table:r,tableSettings:d},table:li(n)?n.table:void 0})})}handleColumnSelected(e){const{glEventHub:n}=this.props;n.emit(Tt.COLUMN_SELECTED,this,e)}handleDataSelected(e,n){const{glEventHub:s}=this.props;s.emit(Tt.DATA_SELECTED,this,n)}handleResize(){this.updateGrid()}handleShow(){this.updateGrid()}handleTabClicked(){this.irisGrid.current&&this.irisGrid.current.focus()}handleError(e){Un.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){Te.isCanceled(e)||this.handleError(e)}modelInitialized(e){const{glEventHub:n,loadPlugin:s}=this.props;if(this.modelPromise=void 0,this.loadPanelState(e),this.setState({isModelReady:!0}),li(e)){const{table:i}=e,{pluginName:o}=i;if(o!==""&&s!=null&&o!=null){const r=s(o);this.setState({Plugin:r})}n.emit(Pe.TABLE_CHANGED,this,i)}this.sendColumnsChange(e.columns)}handleClearAllFilters(){const e=this.irisGrid.current,{isDisconnected:n}=this.state;e!=null&&!n&&e.clearAllFilters()}sendColumnsChange(e){Un.debug2("sendColumnsChange",e);const{glEventHub:n}=this.props;n.emit(Pe.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){var w,T,y;const{model:n}=this.state;if(!n)return null;const s=this.irisGrid.current,{gridWrapper:i}=s||{},o=(w=i==null?void 0:i.getBoundingClientRect())!=null?w:null;if(o==null||o.width<=0||o.height<=0)return null;P(s);const{metrics:r}=s.state;P(r);const{columnHeaderHeight:l,visibleColumnXs:a,visibleColumnWidths:d,right:c,columnHeaderMaxDepth:u}=r,m=n.getColumnIndexByName(e);P(m);const p=s.getVisibleColumn(m),g=(T=a.get(p))!=null?T:0,f=(y=d.get(p))!=null?y:0,b=Math.max(o.left,Math.min(p>c?o.right:o.left+g+f*.5,o.right)),C=o.top+l*u;return[b,C]}setFilterMap(e){const n=this.irisGrid.current;n!=null&&n.setFilterMap(e)}setAdvancedFilterMap(e){const n=this.irisGrid.current;n!=null&&n.setAdvancedFilterMap(e)}setFilters({quickFilters:e,advancedFilters:n}){Un.debug("setFilters",e,n);const{model:s,isDisconnected:i}=this.state,o=this.irisGrid.current;if(o==null||i){Un.debug("Ignore setFilters, model disconnected");return}P(s);const{columns:r,formatter:l}=s,a=te.changeFilterColumnNamesToIndexes(s.columns,e).filter(([c])=>s.isFilterable(c)),d=te.changeFilterColumnNamesToIndexes(s.columns,n).filter(([c])=>s.isFilterable(c));o.clearAllFilters(),o.setFilters({quickFilters:te.hydrateQuickFilters(r,a,l.timeZone),advancedFilters:te.hydrateAdvancedFilters(r,d,l.timeZone)})}setStateOverrides(e){Un.debug("setStateOverrides",e);const{irisGridState:n,gridState:s}=e;this.setState({irisGridStateOverrides:n,gridStateOverrides:s},()=>{this.initModel()})}unsetFilterValue(){}loadPanelState(e){const{panelState:n,irisGridStateOverrides:s,gridStateOverrides:i}=this.state;if(n!=null)try{const{gridState:o,irisGridState:r,irisGridPanelState:l}=n,a={...s},{quickFilters:d,advancedFilters:c}=a;d&&(a.quickFilters=te.changeFilterColumnNamesToIndexes(e.columns,d)),c&&(a.advancedFilters=te.changeFilterColumnNamesToIndexes(e.columns,c));const{isSelectingPartition:u,partition:m,partitionColumn:p,advancedSettings:g}=te.hydrateIrisGridPanelState(e,l),{advancedFilters:f,customColumns:b,customColumnFormatMap:C,isFilterBarShown:w,quickFilters:T,reverseType:y,rollupConfig:E,aggregationSettings:I,sorts:D,userColumnWidths:F,userRowHeights:x,showSearchBar:U,searchValue:B,selectDistinctColumns:_,selectedSearchColumns:H,invertSearchColumns:A,pendingDataMap:N,frozenColumns:k,conditionalFormats:O}=te.hydrateIrisGridState(e,{...r,...a}),{isStuckToBottom:V,isStuckToRight:G,movedColumns:Q,movedRows:Z}=te.hydrateGridState(e,{...o,...i},r.customColumns);this.setState({advancedFilters:f,advancedSettings:g,conditionalFormats:O,customColumns:b,customColumnFormatMap:C,isFilterBarShown:w,isSelectingPartition:u,movedColumns:Q,movedRows:Z,partition:m,partitionColumn:p,quickFilters:T,reverseType:y,rollupConfig:E,aggregationSettings:I,sorts:D,userColumnWidths:F,userRowHeights:x,showSearchBar:U,searchValue:B,selectDistinctColumns:_,selectedSearchColumns:H,invertSearchColumns:A,pendingDataMap:N,frozenColumns:k,isStuckToBottom:V,isStuckToRight:G})}catch(o){Un.error("loadPanelState failed to load panelState",n,o)}}updateGrid(){var n,s;const e=(s=(n=this.irisGrid.current)==null?void 0:n.grid)!=null?s:null;!e||e.handleResize()}render(){var Ln,$t;const{children:e,glContainer:n,glEventHub:s,columnSelectionValidator:i,getDownloadWorker:o,inputFilters:r,links:l,metadata:a,panelState:d,user:c,workspace:u,settings:m,theme:p}=this.props,{advancedFilters:g,aggregationSettings:f,advancedSettings:b,conditionalFormats:C,customColumns:w,customColumnFormatMap:T,error:y,isDisconnected:E,isFilterBarShown:I,isSelectingPartition:D,isStuckToBottom:F,isStuckToRight:x,isLoaded:U,isLoading:B,isModelReady:_,model:H,movedColumns:A,movedRows:N,partition:k,partitionColumn:O,quickFilters:V,reverseType:G,rollupConfig:Q,sorts:Z,userColumnWidths:be,userRowHeights:le,showSearchBar:he,searchValue:Re,selectDistinctColumns:ee,selectedSearchColumns:ue,invertSearchColumns:Se,Plugin:De,pluginFilters:qe,pluginFetchColumns:ke,pendingDataMap:Qn,frozenColumns:vn}=this.state,St=y!=null?`Unable to open table. ${y}`:void 0,{table:Ie}=a,ot=(Ln=H==null?void 0:H.description)!=null?Ln:void 0,rt=($t=d==null?void 0:d.pluginState)!=null?$t:null,xt=e!=null?e:this.getPluginContent(De,H,c,u,rt),{permissions:Qt}=c,{canCopy:Zt,canDownloadCsv:_t}=Qt;return h(Ul,{errorMessage:St,isDisconnected:E,isLoading:B,isLoaded:U,className:"iris-grid-panel",glContainer:n,glEventHub:s,onClearAllFilters:this.handleClearAllFilters,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleShow,onTabClicked:this.handleTabClicked,widgetName:Ie,widgetType:"Table",description:ot,componentPanel:this,renderTabTooltip:()=>h(rc,{model:H,widgetName:Ie,glContainer:n,description:ot}),children:_&&H&&h(io,{advancedFilters:g,aggregationSettings:f,advancedSettings:b,alwaysFetchColumns:this.getAlwaysFetchColumns(l,ke),columnAllowedCursor:"linker",columnNotAllowedCursor:"not-allowed",customColumns:w,customColumnFormatMap:T,columnSelectionValidator:this.isColumnSelectionValid,conditionalFormats:C,inputFilters:this.getGridInputFilters(H.columns,r),applyInputFiltersOnInit:d==null,isFilterBarShown:I,isSelectingColumn:i!=null,isSelectingPartition:D,isStuckToBottom:F,isStuckToRight:x,movedColumns:A,movedRows:N,partition:k,partitionColumn:O,quickFilters:V,reverseType:G,rollupConfig:Q,settings:m,sorts:Z,userColumnWidths:be,userRowHeights:le,model:H,showSearchBar:he,searchValue:Re,selectedSearchColumns:ue,selectDistinctColumns:ee,invertSearchColumns:Se,onColumnSelected:this.handleColumnSelected,onCreateChart:this.handleCreateChart,onDataSelected:this.handleDataSelected,onError:this.handleError,onPartitionAppend:this.handlePartitionAppend,onStateChange:this.handleGridStateChange,onContextMenu:this.handleContextMenu,onAdvancedSettingsChange:this.handleAdvancedSettingsChange,customFilters:qe,pendingDataMap:Qn,canCopy:Zt,canDownloadCsv:_t,ref:this.irisGrid,getDownloadWorker:o,frozenColumns:vn,theme:p,children:xt})})}}Yi.defaultProps={onStateChange:()=>{},onPanelStateUpdate:()=>{}};Yi.displayName="IrisGridPanel";Yi.COMPONENT="IrisGridPanel";const GE=(t,{localDashboardId:e=Mn})=>({inputFilters:Xd(t,e),links:oo(t,e),columnSelectionValidator:Zd(t,e),user:gm(t),workspace:Dl(t),settings:Ft(t)}),hi=Nt(GE,null,null,{forwardRef:!0})(Yi);const Hh=X.module("InputFilter"),KE=150,Ya=class extends S.exports.Component{constructor(t){super(t),this.getItemLabel=ve((i,o)=>{const{name:r,type:l}=i[o];if(o>0&&i[o-1].name===r||o<i.length-1&&i[o+1].name===r){const a=l.substring(l.lastIndexOf(".")+1);return`${r} (${a})`}return r}),this.sendUpdate=je(()=>{const{onChange:i}=this.props,{column:o,value:r,isValueShown:l}=this.state;i({column:o,isValueShown:l,value:r})},KE),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=Y.createRef();const{column:e,isValueShown:n,value:s}=t;this.state={column:e,selectedColumn:e,value:s,isValueShown:n}}componentDidUpdate(t,e){const{column:n}=this.props,{column:s,value:i,isValueShown:o}=this.state;n!==t.column&&this.setState({column:n,selectedColumn:n}),o!==void 0&&o&&o!==e.isValueShown&&this.focusInput(),(s!==e.column||i!==e.value||o!==e.isValueShown)&&this.sendUpdate()}componentWillUnmount(){this.sendUpdate.flush()}handleColumnChange(t){const{columns:e}=this.props,{value:n}=t.target,s=e[parseInt(n,10)];Hh.debug2("handleColumnChange",s),this.setState({selectedColumn:s,value:void 0})}handleInputKeyPress(t){t.key==="Enter"&&(t.preventDefault(),t.stopPropagation(),this.setState(({value:e})=>e==null?{value:""}:null,()=>{this.sendUpdate(),this.sendUpdate.flush()}))}handleValueChange(t){const{value:e}=t.target;Hh.debug2("handleValueChange",e),this.setState({value:e})}handleSettingsCancel(){const{column:t}=this.state;this.setState({selectedColumn:t,isValueShown:!0})}handleSettingsSave(){const{selectedColumn:t}=this.state;this.setState({column:t,isValueShown:!0})}handleSettingsClick(t){const{column:e}=this.state;this.setState({selectedColumn:e,isValueShown:!1}),t.stopPropagation()}handleBackgroundClick(t){t.target!==this.inputRef.current&&this.focusInput()}focusInput(){this.inputRef.current!==null&&(this.inputRef.current.select(),this.inputRef.current.focus())}clearFilter(){this.setState({value:""})}setFilterState({name:t,type:e,value:n,isValueShown:s}){const i=t!=null&&e!=null?{name:t,type:e}:void 0,o=s===void 0?{column:i,value:n}:{column:i,value:n,isValueShown:s};this.setState(o)}render(){const{columns:t}=this.props,{column:e,isValueShown:n,selectedColumn:s,value:i}=this.state,o=i==null||i.length===0?Ya.PLACEHOLDER.length:i.length;let r=null;if(e!=null){const l=t.findIndex(a=>a.name===e.name&&a.type===e.type);r=l>=0?this.getItemLabel(t,l):e.name}return v(rd,{className:"input-filter fill-parent-absolute",isFlipped:n!=null?n:!1,children:[h("div",{className:"input-filter-settings-card",children:v("div",{className:"input-filter-settings-content",children:[v("div",{className:"input-filter-settings-grid",children:[h("label",{children:"Filter Column"}),v("select",{value:t.findIndex(l=>l.name===(s==null?void 0:s.name)&&l.type===(s==null?void 0:s.type)),className:"custom-select",onChange:this.handleColumnChange,children:[t.map((l,a)=>h("option",{value:a,children:this.getItemLabel(t,a)},`${l.name}/${l.type}`)),t.length===0&&h("option",{value:"-1",disabled:!0,children:"No Available Columns"})]}),h("div",{className:"text-muted small",children:"Input filter control will apply its filter to all columns matching this name in this dashboard."})]}),v("div",{className:"input-filter-settings-buttons",children:[h(z,{kind:"secondary",onClick:this.handleSettingsCancel,disabled:e==null,children:"Cancel"}),h(z,{kind:"primary",className:"ml-2",onClick:this.handleSettingsSave,disabled:s==null,children:"Save"})]})]})}),v("div",{className:"input-filter-value-card",onClick:this.handleBackgroundClick,children:[h("div",{className:"input-filter-column",children:v("div",{className:"input-filter-column-title",children:[r," Filter"]})}),h("div",{className:"d-flex justify-content-center align-items-center h-100 w-100",children:h("div",{className:"input-filter-value-input d-flex flex-column justify-content-center",children:h("input",{type:"text",ref:this.inputRef,placeholder:Ya.PLACEHOLDER,value:i!=null?i:"",onChange:this.handleValueChange,onKeyPress:this.handleInputKeyPress,style:{width:`${o+3}ch`},spellCheck:"false"})})}),h("div",{className:"input-filter-menu",children:h(z,{kind:"ghost",className:"m-2 px-2",onClick:this.handleSettingsClick,icon:h(j,{icon:Go,transform:"grow-4"}),tooltip:"Input Filter Settings"})})]})]})}};let lc=Ya;lc.PLACEHOLDER="Enter value...";lc.defaultProps={column:null,isValueShown:!1,value:null};const qE=250;class zl extends S.exports.Component{constructor(e){super(e),this.handleChange=je(this.handleChange.bind(this),qE),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.inputFilterRef=Y.createRef();const{panelState:n}=e,{value:s,isValueShown:i=!1,name:o,type:r,timestamp:l}=n!=null?n:{};this.state={columns:[],column:o!=null&&r!=null?{name:o,type:r}:void 0,value:s,timestamp:l,isValueShown:i,wasFlipped:!1,skipUpdate:!1,panelState:n}}componentDidMount(){this.updateColumns();const{column:e,value:n,timestamp:s}=this.state;if(e!=null){const{name:i,type:o}=e;this.sendUpdate(i,o,n,s)}}componentDidUpdate(e){const{columns:n}=this.props;n!==e.columns&&this.updateColumns()}handleChange({column:e,isValueShown:n=!1,value:s}){let i,o;e!=null&&({name:i,type:o}=e);let r=!0,l=Date.now();this.setState(({panelState:a,timestamp:d,wasFlipped:c,skipUpdate:u})=>{var p;const m=a!=null&&n!==a.isValueShown&&i===a.name&&o===a.type&&s===a.value;return r=(p=!u&&n&&(!m||!c))!=null?p:!1,r||(l=d),{panelState:{isValueShown:n,name:i,type:o,value:s,timestamp:l},timestamp:l,wasFlipped:m,skipUpdate:!1}},()=>{r&&this.sendUpdate(i,o,s,l)})}handleClearAllFilters(){var e;(e=this.inputFilterRef.current)==null||e.clearFilter()}sendUpdate(e,n,s,i){const{glEventHub:o}=this.props;o.emit(Pe.FILTERS_CHANGED,this,{name:e,type:n,value:s,timestamp:i})}setPanelState(e,n=!1){var s;this.setState({skipUpdate:!n}),(s=this.inputFilterRef.current)==null||s.setFilterState(e)}updateColumns(){const{columns:e}=this.props;e!=null&&this.setState(n=>{const{column:s}=n;return s==null&&e.length>0?{columns:[...e],column:e[0]}:s!=null&&!e.find(({name:i,type:o})=>s.name===i&&s.type===o)?{columns:[...e,s]}:{columns:[...e]}})}render(){const{glContainer:e,glEventHub:n}=this.props,{column:s,columns:i,isValueShown:o,value:r}=this.state;return h(jn,{className:"iris-input-filter-panel",componentPanel:this,glContainer:e,glEventHub:n,onClearAllFilters:this.handleClearAllFilters,isClonable:!0,isRenamable:!0,children:h(lc,{ref:this.inputFilterRef,column:s,columns:i,onChange:this.handleChange,isValueShown:o,value:r})})}}zl.defaultProps={panelState:null};zl.COMPONENT="InputFilterPanel";zl.displayName="InputFilterPanel";const YE=(t,e)=>{const{localDashboardId:n}=e;return{columns:Fp(t,n)}},_o=Nt(YE,null,null,{forwardRef:!0})(zl);const Dt=X.module("FilterSetManagerPanel");function XE(t){return t.setPanelState!=null}const Xa=class extends S.exports.Component{static changeFilterIndexesToColumnNames(t,e){return e.map(([n,s])=>{if(n>=t.columns.length)return null;const{name:i}=t.columns[n];return{name:i,filter:s}}).filter(n=>n!=null)}constructor(t){super(t),this.handleChange=this.handleChange.bind(this),this.handleFilterApply=this.handleFilterApply.bind(this),this.handleSetsUpdate=this.handleSetsUpdate.bind(this),this.handleGetFilterState=this.handleGetFilterState.bind(this);const{panelState:e,filterSets:n}=t,{selectedId:s=n.length>0?n[0].id:void 0,isValueShown:i=!1}=e!=null?e:{};this.state={selectedId:s,isValueShown:i,panelState:e}}getFilterState(){const{dashboardOpenedPanelMap:t}=this.props,e=[];return[...t.keys()].forEach(n=>{const s=t.get(n);if(s===void 0){Dt.error("Could not get panel",s);return}const i=ne.getComponentNameFromPanel(s),o=ne.getIdFromPanel(s);Dt.debug("Panel:",s,i);const{glContainer:r=null}=s.props;if(r==null){Dt.error("Could not get panel container",s);return}const l=ne.getComponentConfigFromContainer(r);if(l==null){Dt.error("Could not get component config from container",r);return}const a=ne.getPanelComponentState(l);if(a==null){Dt.debug(`Panel state is null ${o}`);return}switch(i){case ne.getComponentName(Yi):{let d;o!=null&&(d=this.getIrisGridPanelFilters(o,a)),d!=null&&e.push({panelId:o,type:i,state:d});break}case ne.getComponentName(_o):case ne.getComponentName(ci):{const{isValueShown:d,name:c,type:u,value:m}=a;e.push({panelId:o,type:i,state:{isValueShown:d,name:c,type:u,value:m}});break}}}),e}getIrisGridPanelFilters(t,e){const{panelTableMap:n}=this.props,s=n.get(t);if(s==null)return Dt.error(`Unable to get table for panel ${t}.`),null;const{irisGridState:i={advancedFilters:void 0,quickFilters:void 0},gridState:o={}}=e,{advancedFilters:r,quickFilters:l}=i;let a;r&&(a=Xa.changeFilterIndexesToColumnNames(s,r));let d;return l&&(d=Xa.changeFilterIndexesToColumnNames(s,l)),{irisGridState:{...i,advancedFilters:a,quickFilters:d},gridState:{...o}}}handleGetFilterState(){return this.getFilterState()}handleChange({isValueShown:t,selectedId:e}){Dt.debug("handleChange",t,e),this.setState({isValueShown:t,selectedId:e}),this.updatePanelState()}handleFilterApply(t){const{dashboardOpenedPanelMap:e}=this.props,{panels:n,restoreFullState:s=!1}=t;Dt.debug("Apply filters from filter set",t),n.forEach(({panelId:i,type:o,state:r})=>{if(i==null){Dt.debug("panel is null",i);return}if(!e.has(i)){Dt.debug("Ignore closed panel",i);return}Dt.debug("Apply panel filters",i,o,r);const l=e.get(i);switch(o){case ne.getComponentName(Yi):this.restoreIrisGridFilters(l,r,s);break;case ne.getComponentName(_o):case ne.getComponentName(ci):this.restoreInputFilterState(l,r);break}})}handleSetsUpdate(t){const{setDashboardFilterSets:e,localDashboardId:n}=this.props;Dt.debug("Saving updated sets",t),e(n,[...t])}updatePanelState(){this.setState(({selectedId:t,isValueShown:e})=>({panelState:{selectedId:t,isValueShown:e}}))}restoreIrisGridFilters(t,e,n){const{irisGridState:s={},advancedFilters:i=[],quickFilters:o=[]}=e,{advancedFilters:r=i,quickFilters:l=o}=s,{panelTableMap:a}=this.props,d=ne.getIdFromPanel(t);if(d==null){Dt.error("Panel Id is null.");return}if(a.get(d)==null){Dt.error(`Unable to get table for panel ${d}.`);return}Dt.debug("restoreIrisGridFilters",d,e,n),n?t.setStateOverrides(e):t.setFilters({quickFilters:l,advancedFilters:r})}restoreInputFilterState(t,e){const n={...e};delete n.isValueShown,Dt.debug("restoreInputFilterState",t,n),t&&XE(t)&&t.setPanelState(n)}render(){const{glContainer:t,glEventHub:e,filterSets:n}=this.props,{isValueShown:s,selectedId:i}=this.state;return h(jn,{className:"filter-set-manager-panel",componentPanel:this,glContainer:t,glEventHub:e,isClonable:!0,isRenamable:!0,children:h("div",{className:"input-filter-container h-100 w-100 container",children:h(rl,{onChange:this.handleChange,onApply:this.handleFilterApply,onUpdateSets:this.handleSetsUpdate,isValueShown:s,filterSets:n,selectedId:i,getFilterState:this.handleGetFilterState})})})}};let ac=Xa;ac.defaultProps={panelState:null};ac.COMPONENT="FilterSetManagerPanel";const jE=(t,e)=>{const{localDashboardId:n}=e;return{filterSets:uE(t,n),dashboardOpenedPanelMap:jm(t,n),dashboardInputFilters:Xd(t,n),panelTableMap:jd(t,n)}},wa=Nt(jE,{setDashboardFilterSets:wE},null,{forwardRef:!0})(ac);const Vh=X.module("LogPanel");class Gl extends S.exports.PureComponent{constructor(e){super(e),this.handleResize=this.handleResize.bind(this),this.handleShow=this.handleShow.bind(this),this.handleHide=this.handleHide.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.isBottomVisible=!0,this.logView=null;const{session:n}=this.props;this.state={session:n}}handleResize(){this.updateDimensions()}handleShow(){this.updateDimensions(),this.logView&&(this.logView.triggerFindWidget(),this.isBottomVisible&&this.logView.scrollToBottom())}handleHide(){this.logView&&(this.isBottomVisible=this.logView.isBottomVisible())}handleSessionOpened(e){Vh.debug("Session opened",[e]),this.setState({session:e})}handleSessionClosed(e){Vh.debug("Session closed",e)}updateDimensions(){this.logView&&this.logView.updateDimensions()}render(){const{glContainer:e,glEventHub:n}=this.props,{session:s}=this.state;return v(jn,{componentPanel:this,glContainer:e,glEventHub:n,onResize:this.handleResize,onHide:this.handleHide,onShow:this.handleShow,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,children:[s==null&&h("div",{className:"log-panel-disconnected-message",children:"Waiting for session connection"}),s!=null&&h(Ji,{session:s,ref:i=>{this.logView=i}})]})}}Gl.defaultProps={session:null};Gl.COMPONENT="LogPanel";Gl.TITLE="Log";const QE=(t,e)=>{var n;return{session:(n=gi(t,e.localDashboardId))==null?void 0:n.session}},ll=Nt(QE,null,null,{forwardRef:!0})(Gl);class Ap extends S.exports.PureComponent{render(){const{isEditing:e,children:n,onDoubleClick:s}=this.props;return v("div",{className:"markdown-editor-container h-100 w-100",onDoubleClick:s,children:[h("div",{className:W("text-muted","edit-hint",{viewing:e===void 0||!e}),children:v("span",{children:["double-click to edit ",h(j,{icon:ml})]})}),n]})}}Ap.defaultProps={isEditing:!1};const ZE=X.module("MarkdownStartPage");class Pp extends S.exports.PureComponent{constructor(e){super(e),this.handleDeleteButtonClick=this.handleDeleteButtonClick.bind(this),this.handleDeleteModalClose=this.handleDeleteModalClose.bind(this),this.state={isDeleteModalShown:!1}}handleDeleteButtonClick(e){this.setState({isDeleteModalShown:!0,toBeDeleted:e})}handleDeleteModalClose(){this.setState({isDeleteModalShown:!1,toBeDeleted:void 0})}handleDeleteMarkdown(e){if(ZE.debug("delete markdown: ",e),e!==void 0){const{onDelete:n}=this.props;n(e)}this.setState({isDeleteModalShown:!1,toBeDeleted:void 0})}render(){const{closedMarkdowns:e,onOpen:n,onCreate:s}=this.props,{isDeleteModalShown:i,toBeDeleted:o}=this.state;return h("div",{className:"markdown-panel-start-page h-100 w-100",children:v("div",{className:"markdown-panel-start-page-container",children:[v("div",{className:"markdown-panel-start-list",children:[h("h3",{className:"list-title",children:"Start"}),h("div",{className:"list-item",children:h(z,{kind:"ghost",className:"title",onClick:s,children:"New Markdown Note"})})]}),v("div",{className:"markdown-panel-start-list",children:[h("h3",{className:"list-title",children:"Recently Closed from Dashboard"}),e.map(r=>v("div",{className:"list-item",children:[h(z,{kind:"ghost",className:"title",onClick:()=>n(r),children:r.title}),h("button",{className:"btn-link icon",type:"button",onClick:()=>{this.handleDeleteButtonClick(r)},children:h(j,{icon:wn})})]},r.id)),v($o,{isOpen:i,toggle:this.handleDeleteModalClose,className:"modal-dialog-centered markdown-delete-modal theme-bg-light",children:[h(zo,{children:"Are you sure you want to permanently delete this note?"}),h(Wo,{children:"You can't undo this action."}),v(od,{children:[h(z,{kind:"secondary",onClick:this.handleDeleteModalClose,children:"Cancel"}),h(z,{kind:"danger",onClick:()=>{this.handleDeleteMarkdown(o)},children:"Delete"})]})]})]})]})})}}Pp.defaultProps={closedMarkdowns:[],onOpen:()=>{},onCreate:()=>{},onDelete:()=>{}};const JE=t=>{const{children:e,className:n}=t,s=n!==void 0&&(n==null?void 0:n.startsWith("language-"))?n.substring(9):"plaintext";return h("pre",{children:h("code",{children:h(yl,{language:s,children:Y.Children.map(e,i=>typeof i=="string"?i.trim():i)})})})};class Hp extends S.exports.PureComponent{constructor(e){super(e),this.container=null}render(){const{isEditing:e,content:n,onEditorInitialized:s}=this.props;return h("div",{className:"markdown-editor-container",ref:i=>{this.container=i},children:e?h(Il,{settings:{language:"markdown",value:n,lineNumbers:"off"},onEditorInitialized:s}):h(ou,{components:{code:JE},children:n})})}}Hp.defaultProps={isEditing:!1,content:""};const Fr=X.module("MarkdownPanel");class dc extends S.exports.Component{constructor(e){super(e),this.getClosedMarkdowns=pe(i=>i.filter(o=>o.component==="MarkdownPanel").reverse()),this.handleContainerDoubleClick=this.handleContainerDoubleClick.bind(this),this.handleCreateMarkdown=this.handleCreateMarkdown.bind(this),this.handleDeleteMarkdown=this.handleDeleteMarkdown.bind(this),this.handleOpenMarkdown=this.handleOpenMarkdown.bind(this),this.handleEditorInitialized=this.handleEditorInitialized.bind(this),this.handleEditorBlur=this.handleEditorBlur.bind(this),this.handleEditorResize=this.handleEditorResize.bind(this);const{panelState:n}=e;let s=null;n!=null&&n.content!=null&&({content:s}=n),this.state={isStartPageShown:s==null,isEditing:!1,content:s,panelState:n},this.markdownEditor=null}setEditorPosition(e){var s,i;P(this.markdownEditor);const{container:n}=this.markdownEditor;if(this.editor&&n){const o=n.getBoundingClientRect().top,r=n.scrollTop,l=n.scrollHeight,a=(i=(s=this.editor.getModel())==null?void 0:s.getLineCount())!=null?i:0;let d=Math.round((r+e-o)/l*a);d>a&&(d=a),this.editor.revealLine(d),this.editor.setPosition({lineNumber:d,column:1}),this.editor.focus()}}handleContainerDoubleClick(e){const{isEditing:n}=this.state,s=e.clientY;n||this.setState({isEditing:!0},()=>{this.setEditorPosition(s)})}handleEditorInitialized(e){Fr.debug("Markdown Editor Initialized..."),this.editor=e}handleCreateMarkdown(){Fr.debug("create markdown..."),this.setState({isStartPageShown:!1,content:"",isEditing:!0,panelState:{content:""}},()=>{this.editor!=null&&this.editor.focus!=null&&this.editor.focus()})}handleOpenMarkdown(e){Fr.debug("open markdown...",e);const{glContainer:n,glEventHub:s}=this.props,i=ne.getComponentConfigFromContainer(n);s.emit(Ne.REOPEN,e,i)}handleDeleteMarkdown(e){const{glEventHub:n}=this.props;n.emit(Ne.DELETE,e)}handleEditorBlur(e){var i;Fr.debug("markdown content changed, saving...");const{isEditing:n}=this.state;if(!n||this.markdownEditor!=null&&this.markdownEditor.container!=null&&this.markdownEditor.container.contains(e.relatedTarget))return;const s=(i=this.editor)==null?void 0:i.getValue();this.setState({content:s,isEditing:!1,panelState:{content:s}})}handleEditorResize(){const{isEditing:e}=this.state;e&&this.editor&&this.editor.layout()}render(){const{glContainer:e,glEventHub:n,closedPanels:s}=this.props,{isEditing:i,isStartPageShown:o,content:r}=this.state,l=this.getClosedMarkdowns(s);return h(jn,{glContainer:e,glEventHub:n,className:"markdown-panel",componentPanel:this,onResize:this.handleEditorResize,onBlur:this.handleEditorBlur,isClonable:!0,isRenamable:!0,children:o?h(Pp,{closedMarkdowns:l,onCreate:this.handleCreateMarkdown,onOpen:this.handleOpenMarkdown,onDelete:this.handleDeleteMarkdown}):h(Ap,{isEditing:i,onDoubleClick:this.handleContainerDoubleClick,children:h(Hp,{ref:a=>{this.markdownEditor=a},isEditing:i,content:r!=null?r:void 0,onEditorInitialized:this.handleEditorInitialized})})})}}dc.defaultProps={panelState:null};dc.COMPONENT="MarkdownPanel";const e1=(t,e)=>{const{localDashboardId:n}=e;return{closedPanels:ww(t,n)}},So=Nt(e1,null,null,{forwardRef:!0})(dc);class Vp extends S.exports.PureComponent{constructor(e){super(e),this.handleRunSelected=this.handleRunSelected.bind(this),this.renderCodeBlock=this.renderCodeBlock.bind(this),this.renderLink=this.renderLink.bind(this),this.commands=new Map,this.codeElements=new Map,this.editorScrollView=Y.createRef(),this.state={hasCode:!1,hasRunCode:!1,nextStartLine:null}}componentDidMount(){this.updateHasCode()}componentDidUpdate(){this.updateHasCode()}updateHasCode(){const{hasCode:e}=this.state;this.commands.size===0&&e?this.setState({hasCode:!1}):this.commands.size>0&&!e&&this.setState({hasCode:!0})}getNextStartLine(e){const n=[...this.commands.keys()],s=n.findIndex(i=>i===e)+1;return s>=n.length?null:n[s]}handleRunSelected(e){var c,u,m;e.preventDefault(),e.stopPropagation();const{nextStartLine:n}=this.state,s=[...this.commands.keys()],i=s.findIndex(p=>p===n||n==null);if(i<0)return;const o=s[i],r=this.commands.get(o),l=this.getNextStartLine(o),a=(c=this.codeElements.get(o))==null?void 0:c.current,d=(u=a==null?void 0:a.parentElement)==null?void 0:u.nextElementSibling;if(d!=null){const{offsetTop:p}=d,g=p;(m=this.editorScrollView.current)==null||m.scroll({top:g,left:0})}this.runCode(r),this.setState({nextStartLine:l})}runCode(e){const{onRunCode:n}=this.props;n(e),this.setState({hasRunCode:!0})}renderCodeBlock(e){const{children:n,className:s,inline:i,node:o}=e,{hasRunCode:r,nextStartLine:l}=this.state,{children:a,position:d}=o;P(d);const{start:c}=d,{line:u}=c,m=a[0].value,p=Y.createRef(),g=this.commands.size===0,f=l===u||g&&l==null&&!r,b=s!==void 0&&s.startsWith("language-")?s.substring(9):"plaintext";return i!=null&&i?h("code",{className:s,children:n}):(this.commands.set(u,m),this.codeElements.set(u,p),v("div",{className:W("markdown-notebook-code-block",{"is-selected":f}),ref:p,onClick:()=>{this.setState({nextStartLine:u})},role:"presentation",children:[h(z,{kind:"ghost",icon:qr,className:"btn-play-block",onClick:C=>{C.stopPropagation(),C.preventDefault(),this.runCode(m),this.setState({nextStartLine:u})},tooltip:"Run code"}),h("code",{children:h(yl,{language:b,children:Y.Children.map(n,C=>typeof C=="string"?C.trim():C)})})]}))}renderLink(e){const{onLinkClick:n}=this.props,{href:s,children:i,target:o}=e;return h("a",{href:s,onClick:n,target:o,children:i})}render(){const{content:e,transformImageUri:n,transformLinkUri:s}=this.props,{hasCode:i,hasRunCode:o,nextStartLine:r}=this.state;return v("div",{className:"markdown-notebook",children:[h("div",{className:"markdown-notebook-toolbar",children:h(z,{className:W("btn-play-selected-cell",{flashing:i&&!o}),kind:"ghost",icon:qr,onClick:this.handleRunSelected,tooltip:"Run code and select next",disabled:o&&r==null||!i,children:"Run Selected Code"})}),h("div",{className:"markdown-notebook-content",ref:this.editorScrollView,children:h(ou,{components:{code:this.renderCodeBlock,a:this.renderLink},linkTarget:"_blank",remarkPlugins:[fg],transformLinkUri:s,transformImageUri:n,includeElementIndex:!0,children:e})})]})}}Vp.defaultProps={onRunCode:()=>{}};const Ue=X.module("NotebookPanel"),Uh=400,_i=class extends S.exports.Component{constructor(t){super(t),this.getSettings=pe((u,m)=>({...u,minimap:{enabled:m}})),this.getOverflowActions=pe((u,m)=>[{title:"Find",icon:Zf,action:this.handleFind,group:oe.groups.high,shortcut:Ut.NOTEBOOK.FIND,order:10},{title:"Show Minimap",icon:u?ds:void 0,action:this.handleMinimapChange,group:oe.groups.medium,shortcut:Ut.NOTEBOOK.MINIMAP,order:20},{title:"Word Wrap",icon:m?ds:void 0,action:this.handleWordWrapChange,group:oe.groups.medium,shortcut:Ut.NOTEBOOK.WORDWRAP,order:30}]),this.handleBlur=this.handleBlur.bind(this),this.handleCloseCancel=this.handleCloseCancel.bind(this),this.handleCloseDiscard=this.handleCloseDiscard.bind(this),this.handleCloseSave=this.handleCloseSave.bind(this),this.handleCopy=this.handleCopy.bind(this),this.handleEditorInitialized=this.handleEditorInitialized.bind(this),this.handleEditorWillDestroy=this.handleEditorWillDestroy.bind(this),this.handleEditorChange=this.handleEditorChange.bind(this),this.handleFind=this.handleFind.bind(this),this.handleMinimapChange=this.handleMinimapChange.bind(this),this.handleWordWrapChange=this.handleWordWrapChange.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleLinkClick=this.handleLinkClick.bind(this),this.handleLoadSuccess=this.handleLoadSuccess.bind(this),this.handleLoadError=this.handleLoadError.bind(this),this.handlePanelTabClick=this.handlePanelTabClick.bind(this),this.handleRenameFile=this.handleRenameFile.bind(this),this.handleResize=this.handleResize.bind(this),this.handleRunCommand=this.handleRunCommand.bind(this),this.handleRunAll=this.handleRunAll.bind(this),this.handleRunSelected=this.handleRunSelected.bind(this),this.handleSave=this.handleSave.bind(this),this.handleSaveAsCancel=this.handleSaveAsCancel.bind(this),this.handleSaveAsSubmit=this.handleSaveAsSubmit.bind(this),this.handleSaveError=this.handleSaveError.bind(this),this.handleSaveSuccess=this.handleSaveSuccess.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleShowRename=this.handleShowRename.bind(this),this.handleTab=this.handleTab.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTransformLinkUri=this.handleTransformLinkUri.bind(this),this.getDropdownOverflowActions=this.getDropdownOverflowActions.bind(this),this.pending=new fs,this.debouncedSavePanelState=je(this.savePanelState.bind(this),Uh),this.debouncedLoad=je(this.load.bind(this),Uh),this.notebook=null,this.tabTitleElement=null,this.tabInitOnce=!1,this.shouldPromptClose=!0;const{isDashboardActive:e,session:n,sessionLanguage:s,panelState:i}=t;let o={value:"",language:"",wordWrap:"off"},r=null,{isPreview:l}=t;i!=null&&({fileMetadata:r=r,isPreview:l=l,settings:o=o}=i);const a=r!=null&&ce.hasPath(r.itemName),c=a===!0&&o.value!=null||!a&&o.value!=null&&o.value.length>0?1:0;this.state={error:void 0,isDashboardActive:e,isFocused:!1,isLoading:!0,isLoaded:!1,isPreview:l,savedChangeCount:0,changeCount:c,fileMetadata:r,settings:o,session:n,sessionLanguage:s,panelState:{fileMetadata:r,settings:o},showCloseModal:!1,showSaveAsModal:!1,scriptCode:""},Ue.debug("constructor",t,this.state)}static handleError(t){Te.isCanceled(t)||Ue.error(t)}static languageFromFileName(t){switch(ce.getExtension(t).toLowerCase()){case"py":case"python":return"python";case"groovy":return"groovy";case"scala":return"scala";default:return null}}componentDidMount(){const{glContainer:t,glEventHub:e}=this.props,{tab:n}=t;n!=null&&this.initTab(n),this.initNotebookContent(),e.on(He.RENAME_FILE,this.handleRenameFile),t.on("tabClicked",this.handlePanelTabClick)}componentDidUpdate(t,e){const{isPreview:n,settings:s}=this.state,{wordWrap:i}=s,{defaultNotebookSettings:o}=this.props;n!==e.isPreview&&this.setPreviewStatus(),i!==e.settings.wordWrap&&(this.updateEditorWordWrap(),this.debouncedSavePanelState()),o.isMinimapEnabled!==t.defaultNotebookSettings.isMinimapEnabled&&this.updateEditorMinimap()}componentWillUnmount(){this.debouncedSavePanelState.flush(),this.pending.cancel();const{glContainer:t,glEventHub:e}=this.props,{fileMetadata:n,isPreview:s}=this.state;e.off(He.RENAME_FILE,this.handleRenameFile),t.off("tabClicked",this.handlePanelTabClick),e.emit(He.UNREGISTER_FILE,n,s)}initTab(t){this.tabInitOnce||(this.tabInitOnce=!0,this.initTabCloseOverride()),this.initTabClasses(t)}initTabCloseOverride(){const{glContainer:t}=this.props,e=t.close.bind(t);t.close=()=>{const{changeCount:n,savedChangeCount:s}=this.state;return n!==s&&this.shouldPromptClose?this.setState({showCloseModal:!0}):e(),!0}}initTabClasses(t){const e=t.element.get(0);P(e);const n=e.querySelector(".lm_title");this.tabTitleElement=n,n==null||n.classList.add("notebook-title"),this.setPreviewStatus()}getNotebookValue(){const{changeCount:t,savedChangeCount:e,settings:n}=this.state,{value:s}=n;if(t!==e&&this.notebook){const i=this.notebook.getValue();return i!=null?i:s}return s}initNotebookContent(){const{fileMetadata:t,settings:e,isPreview:n}=this.state;if(t&&t.id){Ue.debug("Init content from file"),this.registerFileMetadata(t,n),this.load();return}if(e.value!=null){Ue.debug("Use content passed in the settings prop"),this.handleLoadSuccess();return}this.handleLoadError(new Error("Missing file metadata"))}closeFileTabById(t){const{glEventHub:e}=this.props;e.emit(He.CLOSE_FILE,{id:t})}registerFileMetadata(t,e){const{glEventHub:n,metadata:s}=this.props,{id:i}=s;n.emit(He.REGISTER_FILE,i,t,e)}renameTab(t,e){const{glEventHub:n}=this.props;n.emit(He.RENAME,t,e)}load(){const{fileMetadata:t,settings:e}=this.state;P(t);const{id:n}=t,{fileStorage:s}=this.props;this.pending.add(s.loadFile(n)).then(i=>{var a;Ue.debug("Loaded file",i);const{filename:o}=i,{itemName:r}=this.state;if(o!==r){const{metadata:d}=this.props,{id:c}=d;this.renameTab(c,ce.getBaseName(o))}const l={...e,language:(a=_i.languageFromFileName(o))!=null?a:""};e.value==null&&(l.value=i.content),e.wordWrap===void 0&&(e.wordWrap="off"),this.setState({fileMetadata:{id:o,itemName:o},settings:l}),this.debouncedSavePanelState()}).then(this.handleLoadSuccess).catch(this.handleLoadError)}save(){const{fileMetadata:t}=this.state;if(t&&ce.hasPath(t.itemName)){const e=this.getNotebookValue();return e!==void 0?(this.saveContent(t.itemName,e),!0):!1}return this.setState({showSaveAsModal:!0}),!1}saveContent(t,e){Ue.debug("saveContent",t,e),this.updateSavedChangeCount();const{fileStorage:n}=this.props;this.pending.add(n.saveFile({filename:t,content:e,basename:t})).then(this.handleSaveSuccess).catch(this.handleSaveError)}updateSavedChangeCount(){this.setState(({changeCount:t})=>({savedChangeCount:t}))}setPreviewStatus(){if(!this.tabTitleElement)return;const{isPreview:t}=this.state;Ue.debug("setPreviewStatus",this.tabTitleElement,t),t?this.tabTitleElement.classList.add("is-preview"):this.tabTitleElement.classList.remove("is-preview")}savePanelState(){this.setState(t=>{const{changeCount:e,savedChangeCount:n,fileMetadata:s,isPreview:i,settings:o}=t,r=this.getNotebookValue(),l=e!==n?r:void 0,a={...o,value:r},c={settings:{...o,value:l},fileMetadata:s,isPreview:i};return Ue.debug("Saving panel state",c),{settings:a,panelState:c}})}handleCloseDiscard(){this.shouldPromptClose=!1,this.setState({showCloseModal:!1});const{glContainer:t}=this.props;t.close()}handleCloseSave(){if(this.shouldPromptClose=!1,this.setState({showCloseModal:!1}),this.save()){const{glContainer:t}=this.props;t.close()}}handleCloseCancel(){this.shouldPromptClose=!0,this.setState({showCloseModal:!1})}handleCopy(){const{fileMetadata:t,settings:e}=this.state;P(t);const n=this.getNotebookValue(),{language:s}=e,{itemName:i}=t,o=ce.getCopyFileName(i);Ue.debug("handleCopy",t,i,o),this.createNotebook(o,s,n)}handleEditorInitialized(t){this.editor=t}handleEditorWillDestroy(){this.editor=void 0}handleEditorChange(t){Ue.debug2("handleEditorChanged",t),this.removePreviewStatus(),this.setState(e=>{const{changeCount:n,savedChangeCount:s}=e,{isUndoing:i,isRedoing:o}=t;return i?{changeCount:n-1,savedChangeCount:s}:!o&&n<s?{changeCount:n+1,savedChangeCount:0}:{changeCount:n+1,savedChangeCount:s}}),this.debouncedSavePanelState()}handleFind(){this.notebook&&this.notebook.toggleFind()}updateEditorMinimap(){if(this.editor){const{defaultNotebookSettings:t}=this.props;this.editor.updateOptions({minimap:{enabled:t.isMinimapEnabled}})}}handleMinimapChange(){const{settings:t,defaultNotebookSettings:e,saveSettings:n}=this.props,s={...t,defaultNotebookSettings:{isMinimapEnabled:!e.isMinimapEnabled}};n(s)}updateEditorWordWrap(){if(this.editor){const{settings:t}=this.state,{wordWrap:e}=t;this.editor.updateOptions({wordWrap:e})}}handleWordWrapChange(){this.editor&&this.setState(t=>{const{settings:e}=t,n=e.wordWrap==="on"?"off":"on";return{settings:{...e,wordWrap:n}}})}handleBlur(){Ue.debug("handleBlur"),this.setState({isFocused:!1})}handleFocus(){Ue.debug("handleFocus"),this.setState({isFocused:!0})}handleLinkClick(t){const{notebooksUrl:e,session:n,sessionLanguage:s}=this.props,{href:i}=t.currentTarget;if(!i||!i.startsWith(e))return;t.stopPropagation(),t.preventDefault();const o=`/${i.substring(e.length)}`.replace(/%20/g," ");if(o==="/"){Ue.debug("Ignoring invalid notebook link",o);return}Ue.debug("Notebook link clicked, opening",o);const{glEventHub:r}=this.props,l={value:null,language:s},a={id:o,itemName:o};r.emit(He.SELECT_NOTEBOOK,n,s,l,a)}handleLoadSuccess(){this.setState({error:void 0,isLoaded:!0,isLoading:!1})}handleLoadError(t){let e=t;Te.isCanceled(e)||(Te.isTimedOut(e)&&(e=new Error("File not found.")),Ue.error(e),this.setState({error:e,isLoading:!1}))}handleSave(){Ue.debug("handleSave"),this.save()}handleSaveSuccess(t){var i;const{fileStorage:e}=this.props,n={id:t.filename,itemName:t.filename},s=(i=_i.languageFromFileName(t.filename))!=null?i:"";this.setState(o=>{const{fileMetadata:r}=o,l={...o.settings,language:s};return Ue.debug("handleSaveSuccess",n,r,l),r&&ce.hasPath(r.itemName)&&r.itemName!==n.itemName&&(Ue.debug("handleSaveSuccess deleting old file",r.itemName),e.deleteFile(r.itemName).catch(_i.handleError)),{fileMetadata:n,settings:l,isPreview:!1}}),this.debouncedSavePanelState(),this.registerFileMetadata(n,!1)}handleSaveError(t){Te.isCanceled(t)||(this.setState({savedChangeCount:0}),Ue.error(t))}handleSaveAsCancel(){this.setState({showSaveAsModal:!1})}handleSaveAsSubmit(t){var i;Ue.debug("handleSaveAsSubmit",t);const{fileMetadata:e}=this.state;if(!e)return;const{itemName:n}=e,s=(i=this.getNotebookValue())!=null?i:"";if(this.setState({showSaveAsModal:!1}),ce.getBaseName(n)!==ce.getBaseName(t)){const{metadata:o}=this.props,{id:r}=o;this.renameTab(r,ce.getBaseName(t))}this.saveContent(t,s)}handleRenameFile(t,e){const{fileMetadata:n}=this.state;n&&n.id===t&&(this.setState({fileMetadata:{id:e,itemName:e}}),this.debouncedSavePanelState())}handleResize(){var t;(t=this.notebook)==null||t.updateDimensions()}handleRunCommand(t){this.runCommand(t)}handleRunAll(){var t;if(!this.notebook){Ue.error("Editor is not initialized.");return}this.runCommand((t=this.notebook.getValue())!=null?t:void 0)}handleRunSelected(){if(!this.notebook){Ue.error("Editor is not initialized.");return}this.runCommand(this.notebook.getSelectedCommand())}handleSessionOpened(t,{language:e}){this.setState({session:t,sessionLanguage:e})}handleSessionClosed(){this.setState({session:void 0,sessionLanguage:void 0})}handleShow(){var t;Ue.debug("handleShow"),(t=this.notebook)==null||t.updateDimensions()}handleShowRename(){this.setState({showSaveAsModal:!0})}handleTab(t){Ue.debug("NotebookPanel tab event",t),this.initTab(t)}handleTabFocus(...t){Ue.debug("handleTabFocus",...t);const{glContainer:e}=this.props;this.setState({isDashboardActive:!0}),this.notebook&&!e.isHidden&&this.notebook.updateDimensions()}handleTabBlur(){Ue.debug("handleTabBlur"),this.setState({isDashboardActive:!1})}handlePanelTabClick(){Ue.debug("handlePanelTabClick"),this.focus()}handleTransformLinkUri(t){const{notebooksUrl:e}=this.props,{fileMetadata:n}=this.state;if(t.endsWith("/"))return t;if(t.startsWith("/"))return`${e}${t.substring(1)}`;let s=n==null?void 0:n.itemName;if(s===void 0)return t;s.charAt(0)==="/"&&(s=s.substring(1));const i=new URL(s,e);return new URL(t,i).href}focus(){requestAnimationFrame(()=>{this.notebook&&this.notebook.focus()})}createNotebook(t,e,n=""){const{glEventHub:s}=this.props,{session:i,sessionLanguage:o,settings:r}=this.state,l={...r,language:e,value:n},a={id:null,itemName:t};Ue.debug("handleCreateNotebook",i,o,l,a),s.emit(He.CREATE_NOTEBOOK,i,o,l,a)}runCommand(t){if(t===void 0){Ue.debug("Ignoring empty command.");return}this.removePreviewStatus();const{glEventHub:e}=this.props;e.emit(Ct.SEND_COMMAND,t,!1,!0)}removePreviewStatus(){this.setState(({isPreview:t})=>{if(t){const{fileMetadata:e}=this.state;return e&&this.registerFileMetadata(e,!1),{isPreview:!1}}return null})}getDropdownOverflowActions(){const{defaultNotebookSettings:t}=this.props,{settings:e}=this.state;return this.getOverflowActions(t.isMinimapEnabled,this.getSettings(e,t.isMinimapEnabled).wordWrap==="on")}render(){var k,O;const{fileStorage:t,glContainer:e,glContainer:{tab:n},glEventHub:s,defaultNotebookSettings:i}=this.props,{changeCount:o,savedChangeCount:r,error:l,isDashboardActive:a,isLoaded:d,isLoading:c,isPreview:u,fileMetadata:m,session:p,sessionLanguage:g,settings:f,showCloseModal:b,showSaveAsModal:C}=this.state,w=a&&!e.isHidden&&!u,T=(k=m==null?void 0:m.itemName)!=null?k:_i.DEFAULT_NAME,y=T.endsWith(".md"),E=(m==null?void 0:m.id)!=null,I=this.getSettings(f,i.isMinimapEnabled),D=p!=null,F=g===I.language,x=!d||!D||!F,U=!d,B=[{action:this.handleSave,shortcut:ms.SAVE},{action:this.handleMinimapChange,shortcut:Ut.NOTEBOOK.MINIMAP},{action:this.handleWordWrapChange,shortcut:Ut.NOTEBOOK.WORDWRAP}],_=nh.getDisabledRunTooltip(D,F,"Notebook extension","Run"),H=nh.getDisabledRunTooltip(D,F,"Notebook extension","Run Selected"),A=[{title:E?"Rename":"Save As\u2026",order:10,group:oe.groups.high,action:this.handleShowRename},{title:"Copy File",action:this.handleCopy,group:oe.groups.high,order:20}],N=n==null?void 0:n.element.find(".lm_title_before").get(0);return v(ye,{children:[N&&ui.createPortal(h("span",{className:W("editor-unsaved-indicator",{"is-unsaved":o!==r})}),N),v(jn,{className:"notebook-container",componentPanel:this,glContainer:e,glEventHub:s,onTab:this.handleTab,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleTabFocus,onTabBlur:this.handleTabBlur,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onFocus:this.handleFocus,onBlur:this.handleBlur,additionalActions:A,renderTabTooltip:()=>T,children:[!y&&v(ye,{children:[v("div",{className:"notebook-toolbar",children:[v("span",{children:[h(z,{kind:"ghost",className:"btn-play",onClick:this.handleRunAll,disabled:x,icon:h(j,{icon:qr,transform:"grow-4"}),tooltip:`Run ${Ut.NOTEBOOK.RUN.getDisplayText()}`,"aria-label":"Run"}),_!=null&&h($e,{children:_})]}),v("span",{children:[h(z,{kind:"ghost",className:"btn-play",onClick:this.handleRunSelected,disabled:x,icon:h(j,{icon:dC,transform:"grow-4"}),tooltip:`Run Selected ${Ut.NOTEBOOK.RUN_SELECTED.getDisplayText()}`,"aria-label":"Run Selected"}),H!=null&&h($e,{children:H})]}),h(z,{kind:"ghost",className:"mr-auto",disabled:U,onClick:this.handleSave,icon:bu,tooltip:`Save ${ms.SAVE.getDisplayText()}`,"aria-label":"Save"}),h(z,{kind:"ghost",className:"btn-overflow btn-link-icon",disabled:U,icon:gu,tooltip:"More Actions...",onClick:()=>{},children:h(Fn,{actions:this.getDropdownOverflowActions,popperOptions:_i.POPPER_OPTIONS})})]}),h(om,{isLoaded:d,isLoading:c,error:l,onChange:this.handleEditorChange,onRunCommand:this.handleRunCommand,session:p,sessionLanguage:g,onEditorInitialized:this.handleEditorInitialized,onEditorWillDestroy:this.handleEditorWillDestroy,settings:I,focusOnMount:w,ref:V=>{this.notebook=V}})]}),y&&h(Vp,{content:(O=I.value)!=null?O:"",onLinkClick:this.handleLinkClick,onRunCode:this.handleRunCommand,transformImageUri:this.handleTransformLinkUri,transformLinkUri:this.handleTransformLinkUri}),h(Wl,{isOpen:C,type:"file",defaultValue:T,title:E?"Rename":"Save file as",onSubmit:this.handleSaveAsSubmit,onCancel:this.handleSaveAsCancel,notifyOnExtensionChange:!0,storage:t}),h($i,{isOpen:b,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"}),h(oe,{actions:B})]})]})}};let Zo=_i;Zo.COMPONENT="NotebookPanel";Zo.POPPER_OPTIONS={placement:"bottom-end"};Zo.DEFAULT_NAME="Untitled";Zo.defaultProps={isDashboardActive:!0,isPreview:!1,session:null,sessionLanguage:null,defaultNotebookSettings:null};const t1=(t,e)=>{const n=Cm(t),s=Ft(t),i=MS(t),o=gi(t,e.localDashboardId),{session:r,config:l}=o!=null?o:{},{type:a}=l!=null?l:{};return{fileStorage:n,settings:s,defaultNotebookSettings:i,session:r,sessionLanguage:a}},Ys=Nt(t1,{saveSettings:Td},null,{forwardRef:!0})(Zo);class ko extends S.exports.Component{constructor(e){super(e),this.irisGridRef=Y.createRef(),this.buttonRef=Y.createRef(),this.handleReload=this.handleReload.bind(this),this.handleGridStateChange=this.handleGridStateChange.bind(this),this.handlePanelStateUpdate=this.handlePanelStateUpdate.bind(this);const{panelState:n}=e;this.state={shouldFocusGrid:!1,panelState:n}}handleReload(){var e,n;(e=this.irisGridRef.current)==null||e.initModel(),(n=this.buttonRef.current)==null||n.blur(),this.setState({shouldFocusGrid:!0})}handleGridStateChange(){var n,s,i;const{shouldFocusGrid:e}=this.state;e&&((i=(s=(n=this.irisGridRef.current)==null?void 0:n.irisGrid)==null?void 0:s.current)==null?void 0:i.grid)&&(this.irisGridRef.current.irisGrid.current.grid.focus(),this.setState({shouldFocusGrid:!1}))}handlePanelStateUpdate(e){this.setState({panelState:e})}render(){const{...e}=this.props;return h(hi,{ref:this.irisGridRef,onStateChange:this.handleGridStateChange,onPanelStateUpdate:this.handlePanelStateUpdate,...e,children:v(z,{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",v("span",{children:[h(j,{icon:cd,transform:"shrink-1",className:"mr-1"}),"Reload"]})]})})}}ko.defaultProps={panelState:null};ko.COMPONENT="PandasPanel";function n1(t){Vs(t);const{id:e,layout:n,registerComponent:s,hydrate:i}=t,o=S.exports.useCallback(({dragEvent:r,fetch:l,panelId:a=ze.generate(),widget:d})=>{const{name:c,type:u}=d;if(u!==dh.VariableType.FIGURE)return;const m={name:c,figure:c},p=()=>l().then(b=>zi.makeModel(void 0,b)),g={type:"react-component",component:Bi.COMPONENT,props:{localDashboardId:e,id:a,metadata:m,makeModel:p},title:c,id:a},{root:f}=n;ne.openComponent({root:f,config:g,dragEvent:r})},[e,n]);return S.exports.useEffect(function(){const l=[s(Bi.COMPONENT,Bi,i)];return()=>{l.forEach(a=>a())}},[i,s]),Ke(n.eventHub,Ne.OPEN,o),null}function s1(t){Vs(t);const{id:e,layout:n}=t,s=S.exports.useCallback(({metadata:i,panelId:o=ze.generate(),table:r})=>{const{settings:l}=i,a=()=>zi.makeModelFromSettings(l,r),d=xe.titleFromSettings(l),c={type:"react-component",component:Bi.COMPONENT,props:{localDashboardId:e,id:o,metadata:i,makeModel:a},title:d,id:o},{root:u}=n;ne.openComponent({root:u,config:c})},[e,n]);return Ke(n.eventHub,Tt.CREATE_CHART,s),null}const ct=X.module("ConsolePlugin");function Bh(t){return t.notebook!==void 0}function i1(t){Vs(t)}function o1(t){i1(t);const{id:e,hydrateConsole:n,layout:s,panelManager:i,registerComponent:o,notebooksUrl:r}=t,l=S.exports.useRef(0),[a]=S.exports.useState(new Map),[d]=S.exports.useState(new Map),c=nd(),u=S.exports.useCallback(()=>i.getLastUsedPanelOfType(Li),[i]),m=S.exports.useCallback((N,k=!0,O=!0)=>{if(!(N&&N.trim()))ct.info("Ignoring empty code");else{const G=u();if(!G||!(G instanceof Li.WrappedComponent)){ct.error("Console panel not found");return}ct.debug("Send command: ",N,k,O),G.addCommand(N,k,O)}},[u]),p=S.exports.useCallback(N=>{c(SE(e,N))},[c,e]),g=S.exports.useCallback(({language:N})=>{const k=N==="python"?"py":N;let O=null;return k==null?(ct.debug("No extension for language",N),O=`Untitled-${l.current}`):O=`Untitled-${l.current}.${k}`,l.current+=1,O},[]),f=S.exports.useCallback((N,k=!0)=>{const{id:O}=N;return O!=null&&a.has(O)?a.get(O):O!=null&&d.has(O)?d.get(O):k?ze.generate():null},[a,d]),b=S.exports.useCallback((N,k)=>{ne.renameComponent(s.root,{id:N},k)},[s.root]),C=S.exports.useCallback((N,k)=>{ct.debug("Rename file panel",N,k);let O;if(a.has(N)&&(O=a.get(N),a.delete(N),O!=null&&a.set(k,O)),d.has(N)&&(O=d.get(N),d.delete(N),O!=null&&d.set(k,O)),O===void 0){ct.debug2(`File ${N} isn't open, no need to rename the tab`);return}b(O,ce.getBaseName(k))},[a,d,b]),w=S.exports.useCallback(N=>{const k=f(N,!1);if(k==null){ct.error("Could not find panel id for file metadata",N);return}ne.activateTab(s.root,{id:k})},[f,s.root]),T=S.exports.useCallback((N,k,O)=>{if(ct.debug("registerFilePanel",N,k,O),k==null||k.id==null){ct.debug("Ignore empty file id",k);return}const{id:V}=k;if(O){d.set(V,N);return}if(a.has(V)){const G=a.get(V);if(N===G){ct.debug(`Update tab title for file ${V}`);const{itemName:Q}=k;C(V,ce.getBaseName(Q))}else ct.error(`File ${V} already associated with a different tab ${G}`);return}a.set(V,N),d.has(V)&&d.delete(V)},[a,d,C]),y=S.exports.useCallback((N,k)=>{if(ct.debug("unregisterFileTab",N,k),N==null||N.id==null){ct.debug("Ignore empty file id",N);return}const{id:O}=N;if(k){d.delete(O);return}a.delete(O)},[a,d]),E=S.exports.useCallback(N=>{ct.debug("closeFilePanel",N);const{id:k}=N;let O=null,V=!1;if(a.has(k))O=a.get(k);else if(d.has(k))O=d.get(k),V=!0;else{ct.debug(`File ${k} isn't open, ignore close event`);return}y(N,V),ne.closeComponent(s.root,{id:O})},[s.root,a,d,y]),I=S.exports.useCallback(N=>{const{itemName:k}=N;return ce.getBaseName(k)},[]),D=S.exports.useCallback(N=>{const{id:k}=N;return ct.debug("fileIsOpen",N,k,a),k!=null&&a.has(k)},[a]),F=S.exports.useCallback(N=>{const{id:k}=N;return ct.debug("fileIsOpenAsPreview",N,k,d),k!=null&&d.has(k)},[d]),x=S.exports.useCallback(N=>{if(N==null)return;const k=i.getOpenedPanelById(N);k&&Bh(k)&&k.focus()},[i]),U=S.exports.useCallback(({id:N,settings:k,fileMetadata:O,session:V,sessionLanguage:G,isPreview:Q=!1})=>{const Z={settings:k,fileMetadata:O},be=I(O);return{type:"react-component",component:Ys.COMPONENT,isFocusOnShow:!1,props:{localDashboardId:e,metadata:{id:N},session:V,sessionLanguage:G,panelState:Z,isPreview:Q,notebooksUrl:r},title:be,id:N}},[I,e,r]),B=S.exports.useCallback((N,k,O,V={id:null,itemName:g(O)})=>{const G=f(V);if(D(V)&&G!=null){ct.debug("File is already open, focus panel"),w(V),x(G);return}const Q=ne.getStackForComponentTypes(s.root,[Ys.COMPONENT]),Z=U({id:G,settings:O,fileMetadata:V,session:N,sessionLanguage:k});ct.debug("createNotebook",Z,a),ne.openComponentInStack(Q,Z)},[D,x,g,f,s.root,U,a,w]),_=S.exports.useCallback((N,k,O,V,G=!1)=>{ct.debug("selectNotebook",V,G);const Q=D(V),Z=F(V);if(Q){if(w(V),G){const ee=f(V);x(ee)}return}if(Z&&!G){w(V);return}const[be]=Array.from(d.values());let le=null,he=null;be!=null&&(le=be,he=ne.getStackForConfig(s.root,{component:Ys.COMPONENT,id:le})),he==null&&(le=f(V),he=ne.getStackForComponentTypes(s.root,[Ys.COMPONENT]));const Re=U({id:le,settings:O,fileMetadata:V,session:N,sessionLanguage:k,isPreview:!G});ne.openComponentInStack(he,Re),G&&x(le)},[w,D,F,x,f,s.root,U,d]),H=S.exports.useCallback((N,k,O={},V=!0)=>{const G=i.getLastUsedPanelOfType(Ys);G&&Bh(G)?O!=null&&O.value!=null&&G.notebook!=null&&G.notebook.append(O.value):V&&B(N,k,O)},[B,i]),A=S.exports.useCallback((N,k)=>Ua.hydrate({...N,notebooksUrl:r},k),[r]);return S.exports.useEffect(function(){const k=[o(Li.COMPONENT,Li,n),o(il.COMPONENT,il),o(ol.COMPONENT,ol),o(ll.COMPONENT,ll),o(Ys.COMPONENT,Ys,A)];return()=>{k.forEach(O=>O())}},[o,n,A]),Ke(s.eventHub,Ct.SEND_COMMAND,m),Ke(s.eventHub,Ct.SETTINGS_CHANGED,p),Ke(s.eventHub,He.CLOSE_FILE,E),Ke(s.eventHub,He.CREATE_NOTEBOOK,B),Ke(s.eventHub,He.SELECT_NOTEBOOK,_),Ke(s.eventHub,He.RENAME,b),Ke(s.eventHub,He.RENAME_FILE,C),Ke(s.eventHub,He.SEND_TO_NOTEBOOK,H),Ke(s.eventHub,He.REGISTER_FILE,T),Ke(s.eventHub,He.UNREGISTER_FILE,y),null}const wo=X.module("FilterPlugin");function $h(t,e){return t.concat(e)}function r1(t){Vs(t);const{id:e,layout:n,registerComponent:s}=t,i=nd(),[o]=S.exports.useState(()=>new Map),[r]=S.exports.useState(()=>new Map),[l]=S.exports.useState(()=>new Map),a=S.exports.useCallback(()=>{const b=Array.from(o.values()).reduce($h,[]).sort((T,y)=>{const E=sn.toLower(T.name),I=sn.toLower(y.name);if(E!==I)return E>I?1:-1;const D=sn.toLower(T.type),F=sn.toLower(y.type);return D!==F?D>F?1:-1:0}).reduce((T,y)=>((T.length===0||sn.toLower(T[T.length-1].name)!==sn.toLower(y.name)||sn.toLower(T[T.length-1].type)!==sn.toLower(y.type))&&T.push(y),T),[]),C=Array.from(r.values()).reduce($h,[]).sort((T,y)=>T.timestamp-y.timestamp),w=new Map(l);wo.debug("sendUpdate",{columns:b,filters:C,tableMap:w}),i(Xn(e,{columns:b,filters:C,tableMap:w}))},[i,e,o,r,l]),d=S.exports.useCallback((b,C)=>{wo.debug2("handleColumnsChanged",b,C),o.set(b,[].concat(C)),a()},[o,a]),c=S.exports.useCallback((b,C)=>{wo.debug2("handleFiltersChanged",b,C),r.set(b,[].concat(C)),a()},[r,a]),u=S.exports.useCallback((b,C)=>{wo.debug2("handleTableChanged",b,C),l.set(ne.getIdFromPanel(b),C),a()},[l,a]),m=S.exports.useCallback(b=>{wo.debug2("handlePanelUnmount",b),o.delete(b),r.delete(b),l.delete(ne.getIdFromPanel(b)),a()},[o,r,l,a]),p=S.exports.useCallback(({title:b="DropdownFilter",metadata:C={},panelState:w=null,id:T=ze.generate(),focusElement:y=ne.DEFAULT_FOCUS_SELECTOR,createNewStack:E=!1,dragEvent:I=null})=>{const D={type:"react-component",component:ci.COMPONENT,props:{id:T,metadata:C,panelState:w,localDashboardId:e},title:b,id:T},{root:F}=n;ne.openComponent({root:F,config:D,focusElement:y,createNewStack:E,dragEvent:I})},[n,e]),g=S.exports.useCallback(({title:b="InputFilter",metadata:C={},panelState:w=null,id:T=ze.generate(),focusElement:y=ne.DEFAULT_FOCUS_SELECTOR,createNewStack:E=!1,dragEvent:I=null})=>{const D={type:"react-component",component:_o.COMPONENT,props:{id:T,metadata:C,panelState:w,localDashboardId:e},title:b,id:T},{root:F}=n;ne.openComponent({root:F,config:D,focusElement:y,createNewStack:E,dragEvent:I})},[n,e]),f=S.exports.useCallback(({title:b="FilterSets",metadata:C={},panelState:w=null,id:T=ze.generate(),focusElement:y=ne.DEFAULT_FOCUS_SELECTOR,createNewStack:E=!1,dragEvent:I=null})=>{const D={type:"react-component",component:wa.COMPONENT,props:{id:T,metadata:C,panelState:w,localDashboardId:e},title:b,id:T},{root:F}=n;ne.openComponent({root:F,config:D,focusElement:y,createNewStack:E,dragEvent:I})},[n,e]);return S.exports.useEffect(function(){const C=[s(ci.COMPONENT,ci),s(_o.COMPONENT,_o),s(wa.COMPONENT,wa)];return()=>{C.forEach(w=>w())}},[s]),Ke(n.eventHub,Pe.COLUMNS_CHANGED,d),Ke(n.eventHub,Pe.FILTERS_CHANGED,c),Ke(n.eventHub,Pe.TABLE_CHANGED,u),Ke(n.eventHub,Pe.OPEN_DROPDOWN,p),Ke(n.eventHub,Pe.OPEN_INPUT,g),Ke(n.eventHub,Pe.OPEN_FILTER_SET_MANAGER,f),Ke(n.eventHub,Ne.UNMOUNT,m),null}const l1=[dh.VariableType.TABLE,dh.VariableType.TREETABLE];function a1(t){Vs(t);const{getDownloadWorker:e,loadPlugin:n,id:s,layout:i,registerComponent:o,hydrate:r,theme:l}=t,a=S.exports.useCallback(({dragEvent:d,fetch:c,panelId:u=ze.generate(),widget:m})=>{const{name:p,type:g}=m;if(!l1.includes(g))return;const f={name:p,table:p},b=()=>c().then(T=>qd.makeModel(T)),C={type:"react-component",component:hi.COMPONENT,props:{getDownloadWorker:e,loadPlugin:n,localDashboardId:s,id:u,metadata:f,makeModel:b,theme:l},title:p,id:u},{root:w}=i;ne.openComponent({root:w,config:C,dragEvent:d})},[e,s,i,n,l]);return S.exports.useEffect(function(){const c=[o(hi.COMPONENT,hi,r)];return()=>{c.forEach(u=>u())}},[r,o]),Ke(i.eventHub,Ne.OPEN,a),null}function Up(t){return typeof t.getCoordinateForColumn=="function"}function Wh(t){const e=t;return Up(t)&&typeof e.setFilterMap=="function"&&typeof e.unsetFilterValue=="function"}const vo=X.module("LinkerUtils"),Bp=class{static getLinkType(t,e,n){var l;if((t==null?void 0:t.panelId)==null||(e==null?void 0:e.panelId)==null||t.panelId===e.panelId||n!=null&&n!==t.panelId&&n!==e.panelId)return vo.debug2("Incompatible panel ids",t,e,n),"invalid";if(t.panelComponent==null||e.panelComponent==null)return vo.error("PanelComponent should not be null",t,e),"invalid";const s=(l=Bp.ALLOWED_LINKS.get(t.panelComponent))==null?void 0:l.includes(e.panelComponent);if(s===void 0||!s)return vo.debug2("Incompatible panel components",t,e),"invalid";const{columnType:i}=t,{columnType:o}=e;if(!(o===null||L.isCompatibleType(i,o)))return vo.debug2("Incompatible type",i,o),"invalid";switch(e.panelComponent){case ne.getComponentName(Bi):case ne.getComponentName(hi):return"tableLink";case ne.getComponentName(ci):return"filterSource"}return vo.debug2("Incompatible target panel component",e.panelComponent),"invalid"}static findColumn(t,{columnName:e,columnType:n}){return t.find(({name:s,type:i})=>s===e&&i===n)}static cloneLinksForPanel(t,e,n){const s=[];return t.forEach(i=>{var o;i.start.panelId===e&&i.type!=="filterSource"?s.push({...i,id:ze.generate(),start:{...i.start,panelId:n}}):((o=i.end)==null?void 0:o.panelId)===e&&s.push({...i,id:ze.generate(),end:{...i.end,panelId:n}})}),s}};let ni=Bp;ni.ALLOWED_LINKS=new Map([[ne.getComponentName(hi),[ne.getComponentName(hi),ne.getComponentName(Bi),ne.getComponentName(ci)]]]);const d1=X.module("LinkerLink"),zh=.015,Gh=1.5,$p=12,Wp=12,Kh=2,xr=Math.sqrt((Wp*.5)**2+$p**2),qh=Math.asin(Wp*.5/$p),Yh=15,xs=Math.PI*.5,$r=class extends S.exports.Component{constructor(t){super(t),this.getOperators=pe((e,n)=>{const{onOperatorChanged:s}=this.props;let i=L.getFilterTypes(n);return L.isBooleanType(n)&&(i=[q.eq,q.notEq]),i.flatMap((o,r)=>{if(o==="eqIgnoreCase"||o==="notEqIgnoreCase")return[];let l="";return o==="startsWith"?l="a*":o==="endsWith"?l="*z":l=L.getFilterOperatorString(o),[{title:$r.getLabelForLinkFilter(n,o),icon:h("b",{children:l}),action:()=>s(e,o),order:r}]})}),this.handleClick=this.handleClick.bind(this),this.handleMouseEnter=this.handleMouseEnter.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleDelete=this.handleDelete.bind(this),this.getDropdownActions=this.getDropdownActions.bind(this),this.state={isHovering:void 0}}static makeCirclePath(t,e,n){return`M ${t} ${e} m -${n},0 a ${n},${n} 0 1,0 ${n*2},0 a ${n},${n} 0 1,0 -${n*2},0 z`}static getLabelForLinkFilter(t,e){try{if(L.isNumberType(t)||L.isCharType(t))return cm(e);if(L.isTextType(t))return dm(e);if(L.isDateType(t))return hm(e);if(L.isBooleanType(t)){if(e===q.eq)return"is equal to";if(e===q.notEq)return"is not equal to"}throw new Error(`Unrecognized column type: ${t}`)}catch(n){return d1.warn(n),""}}handleClick(t){t.stopPropagation(),t.preventDefault();const{id:e,onClick:n,onDelete:s}=this.props;t.altKey?s(e):n(e)}handleMouseEnter(){this.setState({isHovering:!0})}handleMouseLeave(){this.setState({isHovering:!1})}handleDelete(){const{id:t,onDelete:e}=this.props;e(t)}getDropdownActions(){const{id:t,startColumnType:e}=this.props;return e!=null?this.getOperators(t,e):[]}render(){const{className:t,operator:e,isSelected:n,x1:s,y1:i,x2:o,y2:r,id:l,startColumnType:a}=this.props,{isHovering:d}=this.state,c=Math.sqrt((s-o)**2+(i-r)**2),u=Math.atan2(r-i,o-s),m=Math.sin(u),p=Math.cos(u)+2,g=window.innerWidth,f=window.innerHeight,b=0,C=0,w=Math.max(b,Math.min(s+(o-s)/2+m*(c*zh)**Gh,g)),T=Math.max(C,Math.min(i+(r-i)/2+p*(c*zh)**Gh,f)),y=`M ${s} ${i} Q ${w} ${T} ${o} ${r}`,E=`M ${b} ${C} L ${b} ${f} L ${g} ${f} L ${g} ${C} z
39
39
  ${$r.makeCirclePath(s,i,Yh)}
40
- ${$r.makeCirclePath(o,r,Yh)}`,I=`link-select-clip-${l}`,D=Math.atan2(r-T,o-w),F=D-qh+Math.PI,x=D+qh+Math.PI,U=o+Math.cos(D)*Kh,B=r+Math.sin(D)*Kh,_=U+Math.cos(F)*xr,H=B+Math.sin(F)*xr,A=U+Math.cos(x)*xr,N=B+Math.sin(x)*xr,k=`${U},${B} ${_},${H} ${A},${N}`,O=.25*s+.5*w+.25*o,V=.25*i+.5*T+.25*r,G=w-s+(o-w),Z=(T-i+(r-T))/G;let le=20/Math.sqrt(1+Z**2),he=le*Z,Re=le*-1,ee=he*-1;Number.isFinite(Z)?Z>0?(le*=-1,he*=-1,Re*=-1,ee*=-1,Re-=50-10*(Math.abs(u)%xs),ee+=10*(Math.abs(u)%xs),le-=50-10*(Math.abs(u)%xs),he+=10*(Math.abs(u)%xs)):Z<0?(Re+=10*(Math.abs(u)%xs),ee+=10*(Math.abs(u)%xs),le+=10*(Math.abs(u)%xs),he+=10*(Math.abs(u)%xs)):(Re=15,ee=10,le=-25,he=10):(Re=10,ee=5,le=10,he=-35);let ue="";return e!==void 0&&(e==="startsWith"?ue="a*":e==="endsWith"?ue="*z":ue=L.getFilterOperatorString(e)),v(ye,{children:[v("svg",{className:W(t,{hovering:d}),children:[h("clipPath",{id:I,children:h("path",{d:E,clipRule:"evenodd"})}),h("path",{className:"link-select",d:y,onClick:this.handleClick,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,clipPath:`url(#${I})`}),h("path",{className:"link-background",d:y}),h("path",{className:"link-foreground",d:y}),h("circle",{className:"link-dot",cx:s,cy:i,r:"5"}),h("polygon",{className:"link-triangle",points:k})]}),a!=null&&n&&v(ye,{children:[h(z,{kind:"primary",className:"btn-fab btn-operator",style:{top:V+(Z>=0?he:ee),left:O+(Z>=0?le:Re)},onClick:()=>{},icon:v("div",{className:"fa-md fa-layers",children:[h("b",{children:ue}),h(j,{icon:Gn,transform:"right-8 down-9 shrink-5"})]}),tooltip:"Change comparison operator",children:h(Fn,{actions:this.getDropdownActions,popperOptions:{placement:"bottom-start"}})}),h(z,{kind:"primary",className:"btn-fab btn-delete",style:{top:V+(Z<0?he:ee),left:O+(Z<0?le:Re)},onClick:this.handleDelete,icon:wn,tooltip:"Delete"})]})]})}};let zp=$r;zp.defaultProps={className:"",isSelected:!1,onClick(){},onDelete(){}};const va=X.module("LinkerOverlayContent");class Gp extends S.exports.Component{constructor(e){super(e),this.handleBlur=this.handleBlur.bind(this),this.handleMouseMove=this.handleMouseMove.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.state={mouseX:void 0,mouseY:void 0,mode:"select"}}componentDidMount(){window.addEventListener("blur",this.handleBlur,!0),window.addEventListener("mousemove",this.handleMouseMove,!0),window.addEventListener("keydown",this.handleKeyDown,!0),window.addEventListener("keyup",this.handleKeyUp,!0)}componentDidCatch(e,n){va.error("componentDidCatch",e,n)}componentWillUnmount(){window.removeEventListener("blur",this.handleBlur,!0),window.removeEventListener("mousemove",this.handleMouseMove,!0),window.removeEventListener("keydown",this.handleKeyDown,!0),window.removeEventListener("keyup",this.handleKeyUp,!0)}getPointFromLinkPoint(e){const{panelManager:n}=this.props,{panelId:s,columnName:i}=e,o=n.getOpenedPanelById(s);if(o!=null){if(!Up(o))throw new Error(`Panel does not have getCoordinateForColumn method: ${s}`);try{const l=o.getCoordinateForColumn(i);if(l!=null)return l}catch{va.error("Could not get coordinate for column",i,o)}}const r=n.getContainerByPanelId(s);if(r==null)throw new Error(`Unable to find panel container for id: ${s}`);return ne.getTabPoint(r)}handleOperatorChanged(e,n){const{links:s,onLinksUpdated:i}=this.props,o=s.map(r=>r.id===e?{...r,operator:n}:r);i(o)}handleBlur(){this.setState({mode:"select"})}handleMouseMove(e){this.setState({mouseX:e.clientX,mouseY:e.clientY})}handleKeyDown(e){e.key==="Alt"&&(e.preventDefault(),this.setState({mode:"delete"}))}handleKeyUp(e){e.key==="Alt"&&(e.preventDefault(),this.setState({mode:"select"}))}handleEscapePressed(){const{onCancel:e}=this.props;e()}render(){const{disabled:e,links:n,selectedIds:s,messageText:i,onLinkSelected:o,onLinkDeleted:r,onAllLinksDeleted:l,onDone:a}=this.props,{mouseX:d,mouseY:c,mode:u}=this.state,m=n.map(p=>{try{const{id:g,type:f,isReversed:b,start:C,end:w,operator:T}=p,y=C.columnType;let[E,I]=this.getPointFromLinkPoint(C),D=d!=null?d:E,F=c!=null?c:I;if(w!=null&&([D,F]=this.getPointFromLinkPoint(w)),b!=null&&b){const[U,B]=[E,I];[E,I]=[D,F],[D,F]=[U,B]}const x=W("linker-link",{disabled:e},{"link-filter-source":f==="filterSource"},{"link-invalid":f==="invalid"},{interactive:p.end==null},{"link-is-selected":s.has(g)},{"danger-delete":u==="delete"});return{x1:E,y1:I,x2:D,y2:F,id:g,className:x,operator:T,startColumnType:y}}catch(g){return va.error("Unable to get point for link",p,g),null}}).filter(p=>p!=null);return v("div",{className:W("linker-overlay",{"danger-delete":u==="delete"}),children:[m.map(({x1:p,y1:g,x2:f,y2:b,id:C,className:w,operator:T,startColumnType:y})=>h(zp,{className:w,id:C,x1:p,y1:g,x2:f,y2:b,onClick:o,onDelete:r,isSelected:s.has(C),operator:T,startColumnType:y,onOperatorChanged:this.handleOperatorChanged},C)),v("div",{className:"linker-toast-dialog",children:[h("div",{className:"toast-body",children:i}),v("div",{className:"toast-footer",children:[h(z,{kind:"secondary",onClick:l,children:"Clear All"}),h(z,{kind:"primary",onClick:a,children:"Done"})]})]}),h(oe,{actions:[{action:this.handleEscapePressed,shortcut:ms.LINKER_CLOSE,isGlobal:!0}]})]})}}Gp.defaultProps={disabled:"false"};const zt=X.module("Linker"),d1=(t,e)=>({activeTool:Nl(t),isolatedLinkerPanelId:Qd(t,e.localDashboardId),links:oo(t,e.localDashboardId),timeZone:Ml(t)}),c1=Nt(d1,{setActiveTool:Fl,setDashboardLinks:Jd,addDashboardLinks:fE,deleteDashboardLinks:CE,setDashboardIsolatedLinkerPanelId:xp,setDashboardColumnSelectionValidator:bE});class h1 extends S.exports.Component{constructor(e){super(e),this.getCachedLinks=pe((n,s,i)=>{const o=[...n];return s!=null&&s.start!=null&&o.push(s),i!==void 0?o.filter(r=>{var l,a;return((l=r==null?void 0:r.start)==null?void 0:l.panelId)===i||((a=r==null?void 0:r.end)==null?void 0:a.panelId)===i||(r==null?void 0:r.end)==null}):o}),this.handleCancel=this.handleCancel.bind(this),this.handleDone=this.handleDone.bind(this),this.handlePanelCloned=this.handlePanelCloned.bind(this),this.handleFilterColumnSelect=this.handleFilterColumnSelect.bind(this),this.handleColumnsChanged=this.handleColumnsChanged.bind(this),this.handlePanelClosed=this.handlePanelClosed.bind(this),this.handleLayoutStateChanged=this.handleLayoutStateChanged.bind(this),this.handleAllLinksDeleted=this.handleAllLinksDeleted.bind(this),this.handleLinkDeleted=this.handleLinkDeleted.bind(this),this.handleLinksUpdated=this.handleLinksUpdated.bind(this),this.handleChartColumnSelect=this.handleChartColumnSelect.bind(this),this.handleGridColumnSelect=this.handleGridColumnSelect.bind(this),this.handleUpdateValues=this.handleUpdateValues.bind(this),this.handleStateChange=this.handleStateChange.bind(this),this.handleExited=this.handleExited.bind(this),this.handleLinkSelected=this.handleLinkSelected.bind(this),this.isColumnSelectionValid=this.isColumnSelectionValid.bind(this),this.state={linkInProgress:void 0,selectedIds:new Set}}componentDidMount(){const{layout:e}=this.props;this.startListening(e),this.updateSelectionValidators()}componentDidUpdate(e){const{activeTool:n,layout:s}=this.props;s!==e.layout&&(this.stopListening(e.layout),this.startListening(s)),n!==e.activeTool&&this.updateSelectionValidators()}componentDidCatch(e,n){zt.error("componentDidCatch",e,n)}componentWillUnmount(){const{layout:e}=this.props;this.stopListening(e)}startListening(e){e.on("stateChanged",this.handleLayoutStateChanged);const{eventHub:n}=e;n.on(Tt.COLUMN_SELECTED,this.handleGridColumnSelect),n.on(Tt.DATA_SELECTED,this.handleUpdateValues),n.on(Tt.STATE_CHANGED,this.handleStateChange),n.on(Ki.COLUMN_SELECTED,this.handleChartColumnSelect),n.on(Ne.CLONED,this.handlePanelCloned),n.on(Pe.COLUMN_SELECTED,this.handleFilterColumnSelect),n.on(Pe.COLUMNS_CHANGED,this.handleColumnsChanged),n.on(Ne.CLOSED,this.handlePanelClosed)}stopListening(e){e.off("stateChanged",this.handleLayoutStateChanged);const{eventHub:n}=e;n.off(Tt.COLUMN_SELECTED,this.handleGridColumnSelect),n.off(Tt.DATA_SELECTED,this.handleUpdateValues),n.off(Tt.STATE_CHANGED,this.handleStateChange),n.off(Ki.COLUMN_SELECTED,this.handleChartColumnSelect),n.off(Ne.CLONED,this.handlePanelCloned),n.off(Pe.COLUMN_SELECTED,this.handleFilterColumnSelect),n.off(Pe.COLUMNS_CHANGED,this.handleColumnsChanged),n.off(Ne.CLOSED,this.handlePanelClosed)}handleCancel(){const{linkInProgress:e}=this.state;if(e==null){const{setActiveTool:n}=this.props;n(hn.DEFAULT)}this.setState({linkInProgress:void 0})}handleDone(){const{setActiveTool:e}=this.props;e(hn.DEFAULT),this.setState({linkInProgress:void 0,selectedIds:new Set})}handleChartColumnSelect(e,n){this.columnSelected(e,n,!0)}handleFilterColumnSelect(e,n){zt.debug("handleFilterColumnSelect",this.isOverlayShown());const{links:s,localDashboardId:i,setActiveTool:o,setDashboardIsolatedLinkerPanelId:r}=this.props,l=ne.getIdFromPanel(e),a=s.filter(d=>{var c,u;return((c=d.start)==null?void 0:c.panelId)===l||((u=d.end)==null?void 0:u.panelId)===l});if(!this.isOverlayShown()&&l!=null){o(hn.LINKER),r(i,l),a.length===0&&this.columnSelected(e,n,!0,l);return}this.columnSelected(e,n,!0)}handleColumnsChanged(e,n){zt.debug("handleColumnsChanged",e,n);const{links:s}=this.props,i=ne.getIdFromPanel(e);if(i==null){zt.error("Invalid panelId",e);return}const o=s.filter(({start:r,end:l})=>r.panelId===i&&ni.findColumn(n,r)==null||l!=null&&l.panelId===i&&ni.findColumn(n,l)==null);this.deleteLinks(o)}handleGridColumnSelect(e,n){this.columnSelected(e,n)}columnSelected(e,n,s=!1,i){if(i===void 0&&!this.isOverlayShown())return;const{isolatedLinkerPanelId:o}=this.props,{linkInProgress:r}=this.state,l=ne.getIdFromPanel(e);if(l==null)return;const a=ne.getComponentNameFromPanel(e),{name:d,type:c}=n;if(r==null||r.start==null){const u={id:ze.generate(),start:{panelId:l,panelComponent:a,columnName:d,columnType:c},type:"invalid",isReversed:s};zt.debug("starting link",u),this.setState({linkInProgress:u})}else{const{links:u}=this.props,{start:m,id:p,isReversed:g}=r,f={panelId:l,panelComponent:a,columnName:d,columnType:c},b=ni.getLinkType(g!==void 0&&g?f:m,g!==void 0&&g?m:f,i!=null?i:o);switch(b){case"invalid":zt.debug("Ignore invalid link connection",r,f);return;case"filterSource":{const w=g!==void 0&&g?m.panelId:f.panelId,T=u.filter(({end:y})=>(y==null?void 0:y.panelId)===w);this.deleteLinks(T);break}}const C={start:g!==void 0&&g?f:m,end:g!==void 0&&g?m:f,id:p,type:b,operator:q.eq};zt.info("creating link",C),this.setState({linkInProgress:void 0,selectedIds:new Set([p])},()=>{this.addLinks([C])})}}unsetFilterValueForLink(e){const{panelManager:n}=this.props;if(e.end){const{end:s}=e,{panelId:i,columnName:o,columnType:r}=s,l=n.getOpenedPanelById(i);l?Wh(l)?l.unsetFilterValue(o,r):zt.debug("endPanel.unsetFilterValue not implemented",l):zt.debug("endPanel no longer exists, ignoring unsetFilterValue",i)}}setPanelFilterMap(e,n){zt.debug("Set filter data for panel:",e,n);const{panelManager:s}=this.props,i=s.getOpenedPanelById(e);i?Wh(i)?i.setFilterMap(n):zt.debug("panel.setFilterMap not implemented",e,i):zt.debug("panel no longer exists, ignoring setFilterMap",e)}addLinks(e){const{addDashboardLinks:n,localDashboardId:s}=this.props;n(s,e)}deleteLinks(e,n=!1){const{localDashboardId:s}=this.props;if(e.forEach(i=>this.unsetFilterValueForLink(i)),n){const{setDashboardLinks:i}=this.props;i(s,[])}else if(e.length>0){const{deleteDashboardLinks:i}=this.props;i(s,e.map(({id:o})=>o))}}handleAllLinksDeleted(){const{links:e,isolatedLinkerPanelId:n}=this.props;if(n===void 0)this.deleteLinks(e,!0);else{const s=e.filter(i=>{var o,r;return((o=i==null?void 0:i.start)==null?void 0:o.panelId)===n||((r=i==null?void 0:i.end)==null?void 0:r.panelId)===n});this.deleteLinks(s)}this.setState({linkInProgress:void 0})}handleLinkDeleted(e){const{links:n}=this.props,s=n.find(i=>i.id===e);s?this.deleteLinks([s]):zt.error("Unable to find link to delete",e)}handleUpdateValues(e,n){const s=ne.getIdFromPanel(e),{links:i,timeZone:o}=this.props,r=new Map;for(let l=0;l<i.length;l+=1){const{start:a,end:d,operator:c}=i[l];if(a.panelId===s&&d!=null){const{panelId:u,columnName:m,columnType:p}=d,g=r.has(u)?r.get(u):new Map,f=g.has(m)===!0?g.get(m).filterList:[],{visibleIndex:b,isExpandable:C,isGrouped:w}=n[a.columnName];let{value:T}=n[a.columnName],y=`${T}`;T===null&&C&&w&&(T=void 0),p!=null&&L.isDateType(p)&&(y=new dt({timeZone:o,showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:ps.FULL_DATE_FORMAT}).format(T));const E={operator:c,text:y,value:T,startColumnIndex:b};f.push(E),g.set(m,{columnType:p,filterList:f}),r.set(u,g)}}r.forEach((l,a)=>{this.setPanelFilterMap(a,l)})}handlePanelCloned(e,n){const{links:s}=this.props,i=ne.getIdFromPanel(e),o=n.id;if(i!=null){const r=ni.cloneLinksForPanel(s,i,o);this.addLinks(r)}}handlePanelClosed(e){zt.debug(`Panel ${e} closed, deleting links.`),this.deleteLinksForPanelId(e)}handleLinkSelected(e){this.setState({selectedIds:new Set([e])})}handleLinksUpdated(e){const{localDashboardId:n,setDashboardLinks:s}=this.props;s(n,e)}handleLayoutStateChanged(){this.forceUpdate()}handleStateChange(){this.forceUpdate()}handleExited(){const{localDashboardId:e,setDashboardIsolatedLinkerPanelId:n}=this.props;n(e,void 0)}deleteLinksForPanelId(e){const{links:n}=this.props;for(let s=0;s<n.length;s+=1){const i=n[s],{start:o,end:r,id:l}=i;(o.panelId===e||(r==null?void 0:r.panelId)===e)&&this.handleLinkDeleted(l)}}isOverlayShown(){const{activeTool:e}=this.props;return e===hn.LINKER}updateSelectionValidators(){const{activeTool:e,setDashboardColumnSelectionValidator:n,localDashboardId:s}=this.props;switch(e){case hn.LINKER:n(s,this.isColumnSelectionValid);break;default:n(s,void 0);break}}updateLinkInProgressType(e,n="invalid"){this.setState({linkInProgress:{...e,type:n}})}isColumnSelectionValid(e,n){const{linkInProgress:s}=this.state,{isolatedLinkerPanelId:i}=this.props;if((s==null?void 0:s.start)==null)return!0;if(n==null)return this.updateLinkInProgressType(s),!1;const{isReversed:o,start:r}=s,l=ne.getIdFromPanel(e);if(l==null)return!1;const a={panelId:l,panelComponent:ne.getComponentNameFromPanel(e),columnName:n.name,columnType:n.type},d=o!==void 0&&o?ni.getLinkType(a,r,i):ni.getLinkType(r,a,i);return this.updateLinkInProgressType(s,d),d!=="invalid"}render(){const{links:e,isolatedLinkerPanelId:n,panelManager:s}=this.props,{linkInProgress:i,selectedIds:o}=this.state,r=this.isOverlayShown(),l=i!=null&&i.start!=null,a=n===void 0?"Click a column source, then click a column target to create a filter link. Remove a filter link by clicking again to erase. Click done when finished.":"Create a link between the source column button and a table column by clicking on one, then the other. Remove the link by clicking it directly. Click done when finished.";return h(ut,{in:r,timeout:yt.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,onExited:this.handleExited,children:h(Gp,{disabled:l,panelManager:s,links:this.getCachedLinks(e,i,n),selectedIds:o,messageText:a,onLinkSelected:this.handleLinkSelected,onLinkDeleted:this.handleLinkDeleted,onAllLinksDeleted:this.handleAllLinksDeleted,onLinksUpdated:this.handleLinksUpdated,onDone:this.handleDone,onCancel:this.handleCancel})})}}const u1=c1(h1);function m1(t){Vs(t);const{id:e,layout:n,panelManager:s}=t;return h(u1,{layout:n,localDashboardId:e,panelManager:s})}const ja=class{static getNewMarkdownTitle(t){let e=`${ja.DEFAULT_TITLE}`,n=0;for(;t.indexOf(e)>=0;)n+=1,e=`${ja.DEFAULT_TITLE}-${n}`;return e}};let Oo=ja;Oo.DEFAULT_TITLE="Note";Oo.DEFAULT_CONTENT=`# Markdown Note
40
+ ${$r.makeCirclePath(o,r,Yh)}`,I=`link-select-clip-${l}`,D=Math.atan2(r-T,o-w),F=D-qh+Math.PI,x=D+qh+Math.PI,U=o+Math.cos(D)*Kh,B=r+Math.sin(D)*Kh,_=U+Math.cos(F)*xr,H=B+Math.sin(F)*xr,A=U+Math.cos(x)*xr,N=B+Math.sin(x)*xr,k=`${U},${B} ${_},${H} ${A},${N}`,O=.25*s+.5*w+.25*o,V=.25*i+.5*T+.25*r,G=w-s+(o-w),Z=(T-i+(r-T))/G;let le=20/Math.sqrt(1+Z**2),he=le*Z,Re=le*-1,ee=he*-1;Number.isFinite(Z)?Z>0?(le*=-1,he*=-1,Re*=-1,ee*=-1,Re-=50-10*(Math.abs(u)%xs),ee+=10*(Math.abs(u)%xs),le-=50-10*(Math.abs(u)%xs),he+=10*(Math.abs(u)%xs)):Z<0?(Re+=10*(Math.abs(u)%xs),ee+=10*(Math.abs(u)%xs),le+=10*(Math.abs(u)%xs),he+=10*(Math.abs(u)%xs)):(Re=15,ee=10,le=-25,he=10):(Re=10,ee=5,le=10,he=-35);let ue="";return e!==void 0&&(e==="startsWith"?ue="a*":e==="endsWith"?ue="*z":ue=L.getFilterOperatorString(e)),v(ye,{children:[v("svg",{className:W(t,{hovering:d}),children:[h("clipPath",{id:I,children:h("path",{d:E,clipRule:"evenodd"})}),h("path",{className:"link-select",d:y,onClick:this.handleClick,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,clipPath:`url(#${I})`}),h("path",{className:"link-background",d:y}),h("path",{className:"link-foreground",d:y}),h("circle",{className:"link-dot",cx:s,cy:i,r:"5"}),h("polygon",{className:"link-triangle",points:k})]}),a!=null&&n&&v(ye,{children:[h(z,{kind:"primary",className:"btn-fab btn-operator",style:{top:V+(Z>=0?he:ee),left:O+(Z>=0?le:Re)},onClick:()=>{},icon:v("div",{className:"fa-md fa-layers",children:[h("b",{children:ue}),h(j,{icon:Gn,transform:"right-8 down-9 shrink-5"})]}),tooltip:"Change comparison operator",children:h(Fn,{actions:this.getDropdownActions,popperOptions:{placement:"bottom-start"}})}),h(z,{kind:"primary",className:"btn-fab btn-delete",style:{top:V+(Z<0?he:ee),left:O+(Z<0?le:Re)},onClick:this.handleDelete,icon:wn,tooltip:"Delete"})]})]})}};let zp=$r;zp.defaultProps={className:"",isSelected:!1,onClick(){},onDelete(){}};const va=X.module("LinkerOverlayContent");class Gp extends S.exports.Component{constructor(e){super(e),this.handleBlur=this.handleBlur.bind(this),this.handleMouseMove=this.handleMouseMove.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.state={mouseX:void 0,mouseY:void 0,mode:"select"}}componentDidMount(){window.addEventListener("blur",this.handleBlur,!0),window.addEventListener("mousemove",this.handleMouseMove,!0),window.addEventListener("keydown",this.handleKeyDown,!0),window.addEventListener("keyup",this.handleKeyUp,!0)}componentDidCatch(e,n){va.error("componentDidCatch",e,n)}componentWillUnmount(){window.removeEventListener("blur",this.handleBlur,!0),window.removeEventListener("mousemove",this.handleMouseMove,!0),window.removeEventListener("keydown",this.handleKeyDown,!0),window.removeEventListener("keyup",this.handleKeyUp,!0)}getPointFromLinkPoint(e){const{panelManager:n}=this.props,{panelId:s,columnName:i}=e,o=n.getOpenedPanelById(s);if(o!=null){if(!Up(o))throw new Error(`Panel does not have getCoordinateForColumn method: ${s}`);try{const l=o.getCoordinateForColumn(i);if(l!=null)return l}catch{va.error("Could not get coordinate for column",i,o)}}const r=n.getContainerByPanelId(s);if(r==null)throw new Error(`Unable to find panel container for id: ${s}`);return ne.getTabPoint(r)}handleOperatorChanged(e,n){const{links:s,onLinksUpdated:i}=this.props,o=s.map(r=>r.id===e?{...r,operator:n}:r);i(o)}handleBlur(){this.setState({mode:"select"})}handleMouseMove(e){this.setState({mouseX:e.clientX,mouseY:e.clientY})}handleKeyDown(e){e.key==="Alt"&&(e.preventDefault(),this.setState({mode:"delete"}))}handleKeyUp(e){e.key==="Alt"&&(e.preventDefault(),this.setState({mode:"select"}))}handleEscapePressed(){const{onCancel:e}=this.props;e()}render(){const{disabled:e,links:n,selectedIds:s,messageText:i,onLinkSelected:o,onLinkDeleted:r,onAllLinksDeleted:l,onDone:a}=this.props,{mouseX:d,mouseY:c,mode:u}=this.state,m=n.map(p=>{try{const{id:g,type:f,isReversed:b,start:C,end:w,operator:T}=p,y=C.columnType;let[E,I]=this.getPointFromLinkPoint(C),D=d!=null?d:E,F=c!=null?c:I;if(w!=null&&([D,F]=this.getPointFromLinkPoint(w)),b!=null&&b){const[U,B]=[E,I];[E,I]=[D,F],[D,F]=[U,B]}const x=W("linker-link",{disabled:e},{"link-filter-source":f==="filterSource"},{"link-invalid":f==="invalid"},{interactive:p.end==null},{"link-is-selected":s.has(g)},{"danger-delete":u==="delete"});return{x1:E,y1:I,x2:D,y2:F,id:g,className:x,operator:T,startColumnType:y}}catch(g){return va.error("Unable to get point for link",p,g),null}}).filter(p=>p!=null);return v("div",{className:W("linker-overlay",{"danger-delete":u==="delete"}),children:[m.map(({x1:p,y1:g,x2:f,y2:b,id:C,className:w,operator:T,startColumnType:y})=>h(zp,{className:w,id:C,x1:p,y1:g,x2:f,y2:b,onClick:o,onDelete:r,isSelected:s.has(C),operator:T,startColumnType:y,onOperatorChanged:this.handleOperatorChanged},C)),v("div",{className:"linker-toast-dialog",children:[h("div",{className:"toast-body",children:i}),v("div",{className:"toast-footer",children:[h(z,{kind:"secondary",onClick:l,children:"Clear All"}),h(z,{kind:"primary",onClick:a,children:"Done"})]})]}),h(oe,{actions:[{action:this.handleEscapePressed,shortcut:ms.LINKER_CLOSE,isGlobal:!0}]})]})}}Gp.defaultProps={disabled:"false"};const zt=X.module("Linker"),c1=(t,e)=>({activeTool:Nl(t),isolatedLinkerPanelId:Qd(t,e.localDashboardId),links:oo(t,e.localDashboardId),timeZone:Ml(t)}),h1=Nt(c1,{setActiveTool:Fl,setDashboardLinks:Jd,addDashboardLinks:fE,deleteDashboardLinks:CE,setDashboardIsolatedLinkerPanelId:xp,setDashboardColumnSelectionValidator:bE});class u1 extends S.exports.Component{constructor(e){super(e),this.getCachedLinks=pe((n,s,i)=>{const o=[...n];return s!=null&&s.start!=null&&o.push(s),i!==void 0?o.filter(r=>{var l,a;return((l=r==null?void 0:r.start)==null?void 0:l.panelId)===i||((a=r==null?void 0:r.end)==null?void 0:a.panelId)===i||(r==null?void 0:r.end)==null}):o}),this.handleCancel=this.handleCancel.bind(this),this.handleDone=this.handleDone.bind(this),this.handlePanelCloned=this.handlePanelCloned.bind(this),this.handleFilterColumnSelect=this.handleFilterColumnSelect.bind(this),this.handleColumnsChanged=this.handleColumnsChanged.bind(this),this.handlePanelClosed=this.handlePanelClosed.bind(this),this.handleLayoutStateChanged=this.handleLayoutStateChanged.bind(this),this.handleAllLinksDeleted=this.handleAllLinksDeleted.bind(this),this.handleLinkDeleted=this.handleLinkDeleted.bind(this),this.handleLinksUpdated=this.handleLinksUpdated.bind(this),this.handleChartColumnSelect=this.handleChartColumnSelect.bind(this),this.handleGridColumnSelect=this.handleGridColumnSelect.bind(this),this.handleUpdateValues=this.handleUpdateValues.bind(this),this.handleStateChange=this.handleStateChange.bind(this),this.handleExited=this.handleExited.bind(this),this.handleLinkSelected=this.handleLinkSelected.bind(this),this.isColumnSelectionValid=this.isColumnSelectionValid.bind(this),this.state={linkInProgress:void 0,selectedIds:new Set}}componentDidMount(){const{layout:e}=this.props;this.startListening(e),this.updateSelectionValidators()}componentDidUpdate(e){const{activeTool:n,layout:s}=this.props;s!==e.layout&&(this.stopListening(e.layout),this.startListening(s)),n!==e.activeTool&&this.updateSelectionValidators()}componentDidCatch(e,n){zt.error("componentDidCatch",e,n)}componentWillUnmount(){const{layout:e}=this.props;this.stopListening(e)}startListening(e){e.on("stateChanged",this.handleLayoutStateChanged);const{eventHub:n}=e;n.on(Tt.COLUMN_SELECTED,this.handleGridColumnSelect),n.on(Tt.DATA_SELECTED,this.handleUpdateValues),n.on(Tt.STATE_CHANGED,this.handleStateChange),n.on(Ki.COLUMN_SELECTED,this.handleChartColumnSelect),n.on(Ne.CLONED,this.handlePanelCloned),n.on(Pe.COLUMN_SELECTED,this.handleFilterColumnSelect),n.on(Pe.COLUMNS_CHANGED,this.handleColumnsChanged),n.on(Ne.CLOSED,this.handlePanelClosed)}stopListening(e){e.off("stateChanged",this.handleLayoutStateChanged);const{eventHub:n}=e;n.off(Tt.COLUMN_SELECTED,this.handleGridColumnSelect),n.off(Tt.DATA_SELECTED,this.handleUpdateValues),n.off(Tt.STATE_CHANGED,this.handleStateChange),n.off(Ki.COLUMN_SELECTED,this.handleChartColumnSelect),n.off(Ne.CLONED,this.handlePanelCloned),n.off(Pe.COLUMN_SELECTED,this.handleFilterColumnSelect),n.off(Pe.COLUMNS_CHANGED,this.handleColumnsChanged),n.off(Ne.CLOSED,this.handlePanelClosed)}handleCancel(){const{linkInProgress:e}=this.state;if(e==null){const{setActiveTool:n}=this.props;n(hn.DEFAULT)}this.setState({linkInProgress:void 0})}handleDone(){const{setActiveTool:e}=this.props;e(hn.DEFAULT),this.setState({linkInProgress:void 0,selectedIds:new Set})}handleChartColumnSelect(e,n){this.columnSelected(e,n,!0)}handleFilterColumnSelect(e,n){zt.debug("handleFilterColumnSelect",this.isOverlayShown());const{links:s,localDashboardId:i,setActiveTool:o,setDashboardIsolatedLinkerPanelId:r}=this.props,l=ne.getIdFromPanel(e),a=s.filter(d=>{var c,u;return((c=d.start)==null?void 0:c.panelId)===l||((u=d.end)==null?void 0:u.panelId)===l});if(!this.isOverlayShown()&&l!=null){o(hn.LINKER),r(i,l),a.length===0&&this.columnSelected(e,n,!0,l);return}this.columnSelected(e,n,!0)}handleColumnsChanged(e,n){zt.debug("handleColumnsChanged",e,n);const{links:s}=this.props,i=ne.getIdFromPanel(e);if(i==null){zt.error("Invalid panelId",e);return}const o=s.filter(({start:r,end:l})=>r.panelId===i&&ni.findColumn(n,r)==null||l!=null&&l.panelId===i&&ni.findColumn(n,l)==null);this.deleteLinks(o)}handleGridColumnSelect(e,n){this.columnSelected(e,n)}columnSelected(e,n,s=!1,i){if(i===void 0&&!this.isOverlayShown())return;const{isolatedLinkerPanelId:o}=this.props,{linkInProgress:r}=this.state,l=ne.getIdFromPanel(e);if(l==null)return;const a=ne.getComponentNameFromPanel(e),{name:d,type:c}=n;if(r==null||r.start==null){const u={id:ze.generate(),start:{panelId:l,panelComponent:a,columnName:d,columnType:c},type:"invalid",isReversed:s};zt.debug("starting link",u),this.setState({linkInProgress:u})}else{const{links:u}=this.props,{start:m,id:p,isReversed:g}=r,f={panelId:l,panelComponent:a,columnName:d,columnType:c},b=ni.getLinkType(g!==void 0&&g?f:m,g!==void 0&&g?m:f,i!=null?i:o);switch(b){case"invalid":zt.debug("Ignore invalid link connection",r,f);return;case"filterSource":{const w=g!==void 0&&g?m.panelId:f.panelId,T=u.filter(({end:y})=>(y==null?void 0:y.panelId)===w);this.deleteLinks(T);break}}const C={start:g!==void 0&&g?f:m,end:g!==void 0&&g?m:f,id:p,type:b,operator:q.eq};zt.info("creating link",C),this.setState({linkInProgress:void 0,selectedIds:new Set([p])},()=>{this.addLinks([C])})}}unsetFilterValueForLink(e){const{panelManager:n}=this.props;if(e.end){const{end:s}=e,{panelId:i,columnName:o,columnType:r}=s,l=n.getOpenedPanelById(i);l?Wh(l)?l.unsetFilterValue(o,r):zt.debug("endPanel.unsetFilterValue not implemented",l):zt.debug("endPanel no longer exists, ignoring unsetFilterValue",i)}}setPanelFilterMap(e,n){zt.debug("Set filter data for panel:",e,n);const{panelManager:s}=this.props,i=s.getOpenedPanelById(e);i?Wh(i)?i.setFilterMap(n):zt.debug("panel.setFilterMap not implemented",e,i):zt.debug("panel no longer exists, ignoring setFilterMap",e)}addLinks(e){const{addDashboardLinks:n,localDashboardId:s}=this.props;n(s,e)}deleteLinks(e,n=!1){const{localDashboardId:s}=this.props;if(e.forEach(i=>this.unsetFilterValueForLink(i)),n){const{setDashboardLinks:i}=this.props;i(s,[])}else if(e.length>0){const{deleteDashboardLinks:i}=this.props;i(s,e.map(({id:o})=>o))}}handleAllLinksDeleted(){const{links:e,isolatedLinkerPanelId:n}=this.props;if(n===void 0)this.deleteLinks(e,!0);else{const s=e.filter(i=>{var o,r;return((o=i==null?void 0:i.start)==null?void 0:o.panelId)===n||((r=i==null?void 0:i.end)==null?void 0:r.panelId)===n});this.deleteLinks(s)}this.setState({linkInProgress:void 0})}handleLinkDeleted(e){const{links:n}=this.props,s=n.find(i=>i.id===e);s?this.deleteLinks([s]):zt.error("Unable to find link to delete",e)}handleUpdateValues(e,n){const s=ne.getIdFromPanel(e),{links:i,timeZone:o}=this.props,r=new Map;for(let l=0;l<i.length;l+=1){const{start:a,end:d,operator:c}=i[l];if(a.panelId===s&&d!=null){const{panelId:u,columnName:m,columnType:p}=d,g=r.has(u)?r.get(u):new Map,f=g.has(m)===!0?g.get(m).filterList:[],{visibleIndex:b,isExpandable:C,isGrouped:w}=n[a.columnName];let{value:T}=n[a.columnName],y=`${T}`;T===null&&C&&w&&(T=void 0),p!=null&&L.isDateType(p)&&(y=new dt({timeZone:o,showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:ps.FULL_DATE_FORMAT}).format(T));const E={operator:c,text:y,value:T,startColumnIndex:b};f.push(E),g.set(m,{columnType:p,filterList:f}),r.set(u,g)}}r.forEach((l,a)=>{this.setPanelFilterMap(a,l)})}handlePanelCloned(e,n){const{links:s}=this.props,i=ne.getIdFromPanel(e),o=n.id;if(i!=null){const r=ni.cloneLinksForPanel(s,i,o);this.addLinks(r)}}handlePanelClosed(e){zt.debug(`Panel ${e} closed, deleting links.`),this.deleteLinksForPanelId(e)}handleLinkSelected(e){this.setState({selectedIds:new Set([e])})}handleLinksUpdated(e){const{localDashboardId:n,setDashboardLinks:s}=this.props;s(n,e)}handleLayoutStateChanged(){this.forceUpdate()}handleStateChange(){this.forceUpdate()}handleExited(){const{localDashboardId:e,setDashboardIsolatedLinkerPanelId:n}=this.props;n(e,void 0)}deleteLinksForPanelId(e){const{links:n}=this.props;for(let s=0;s<n.length;s+=1){const i=n[s],{start:o,end:r,id:l}=i;(o.panelId===e||(r==null?void 0:r.panelId)===e)&&this.handleLinkDeleted(l)}}isOverlayShown(){const{activeTool:e}=this.props;return e===hn.LINKER}updateSelectionValidators(){const{activeTool:e,setDashboardColumnSelectionValidator:n,localDashboardId:s}=this.props;switch(e){case hn.LINKER:n(s,this.isColumnSelectionValid);break;default:n(s,void 0);break}}updateLinkInProgressType(e,n="invalid"){this.setState({linkInProgress:{...e,type:n}})}isColumnSelectionValid(e,n){const{linkInProgress:s}=this.state,{isolatedLinkerPanelId:i}=this.props;if((s==null?void 0:s.start)==null)return!0;if(n==null)return this.updateLinkInProgressType(s),!1;const{isReversed:o,start:r}=s,l=ne.getIdFromPanel(e);if(l==null)return!1;const a={panelId:l,panelComponent:ne.getComponentNameFromPanel(e),columnName:n.name,columnType:n.type},d=o!==void 0&&o?ni.getLinkType(a,r,i):ni.getLinkType(r,a,i);return this.updateLinkInProgressType(s,d),d!=="invalid"}render(){const{links:e,isolatedLinkerPanelId:n,panelManager:s}=this.props,{linkInProgress:i,selectedIds:o}=this.state,r=this.isOverlayShown(),l=i!=null&&i.start!=null,a=n===void 0?"Click a column source, then click a column target to create a filter link. Remove a filter link by clicking again to erase. Click done when finished.":"Create a link between the source column button and a table column by clicking on one, then the other. Remove the link by clicking it directly. Click done when finished.";return h(ut,{in:r,timeout:yt.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,onExited:this.handleExited,children:h(Gp,{disabled:l,panelManager:s,links:this.getCachedLinks(e,i,n),selectedIds:o,messageText:a,onLinkSelected:this.handleLinkSelected,onLinkDeleted:this.handleLinkDeleted,onAllLinksDeleted:this.handleAllLinksDeleted,onLinksUpdated:this.handleLinksUpdated,onDone:this.handleDone,onCancel:this.handleCancel})})}}const m1=h1(u1);function p1(t){Vs(t);const{id:e,layout:n,panelManager:s}=t;return h(m1,{layout:n,localDashboardId:e,panelManager:s})}const ja=class{static getNewMarkdownTitle(t){let e=`${ja.DEFAULT_TITLE}`,n=0;for(;t.indexOf(e)>=0;)n+=1,e=`${ja.DEFAULT_TITLE}-${n}`;return e}};let Oo=ja;Oo.DEFAULT_TITLE="Note";Oo.DEFAULT_CONTENT=`# Markdown Note
41
41
 
42
- This note can be edited using **markdown** for styling.`;function p1(t){Vs(t);const{id:e,layout:n,panelManager:s,registerComponent:i}=t,o=S.exports.useCallback(l=>{const{title:a,componentState:d,props:c}=l;let{panelState:u=null}=c;return d!=null&&({panelState:u=null}=d),a==null||u==null||u.content==null||u.content.length===0||u.content===Oo.DEFAULT_CONTENT?null:xd(l)},[]),r=S.exports.useCallback(({title:l="",metadata:a={},id:d=ze.generate(),focusElement:c=ne.DEFAULT_FOCUS_SELECTOR,createNewStack:u=!1,dragEvent:m=null}={})=>{const p=s.getOpenedPanelConfigsOfType(So.COMPONENT),g=s.getClosedPanelConfigsOfType(So.COMPONENT),f=p.map(y=>{var E;return(E=y.title)!=null?E:""}),b=l!=null&&l!==""?l:Oo.getNewMarkdownTitle(f),C=g.length>0?null:Oo.DEFAULT_CONTENT,w={type:"react-component",component:So.COMPONENT,props:{id:d,metadata:a,panelState:{content:C},localDashboardId:e},title:b,id:d},{root:T}=n;ne.openComponent({root:T,config:w,focusElement:c,createNewStack:u,dragEvent:m})},[e,n,s]);return S.exports.useEffect(function(){const a=[i(So.COMPONENT,So,_d,o)];return()=>{a.forEach(d=>d())}},[o,i]),Ke(n.eventHub,Dp.OPEN,r),null}function g1(t){Vs(t);const{hydrate:e,id:n,layout:s,registerComponent:i}=t,o=S.exports.useCallback(({dragEvent:r,fetch:l,panelId:a=ze.generate(),widget:d})=>{const{name:c,type:u}=d;if(u!==dh.VariableType.PANDAS)return;const m={name:c,table:c},p=()=>l().then(b=>qd.makeModel(b)),g={type:"react-component",component:ko.COMPONENT,props:{localDashboardId:n,id:a,metadata:m,makeModel:p},title:c,id:a},{root:f}=s;ne.openComponent({root:f,config:g,dragEvent:r})},[n,s]);return S.exports.useEffect(function(){const l=[i(ko.COMPONENT,ko,e)];return()=>{l.forEach(a=>a())}},[e,i]),Ke(s.eventHub,Ne.OPEN,o),null}class Cn{}Cn.DROPDOWN_FILTER="ControlType.DROPDOWN_FILTER";Cn.INPUT_FILTER="ControlType.INPUT_FILTER";Cn.MARKDOWN="ControlType.MARKDOWN";Cn.FILTER_SET_MANAGER="ControlType.FILTER_SET_MANAGER";const f1=R.exports.shape({state:R.exports.shape({panelState:R.exports.shape({})})}),C1=R.exports.shape({panelId:R.exports.string.isRequired,columnName:R.exports.string.isRequired,columnType:R.exports.string.isRequired}),Xh=R.exports.shape({panelId:R.exports.string.isRequired,columnName:R.exports.string.isRequired}),Kp=R.exports.shape({start:Xh,end:Xh,id:R.exports.string,isReversed:R.exports.bool}),b1=R.exports.arrayOf(Kp),S1=R.exports.shape({name:R.exports.string.isRequired,operateAs:R.exports.string.isRequired,groups:R.exports.arrayOf(R.exports.string).isRequired,permissions:R.exports.shape({isSuperUser:R.exports.bool.isRequired,isQueryViewOnly:R.exports.bool.isRequired,isNonInteractive:R.exports.bool.isRequired,canUsePanels:R.exports.bool.isRequired,canCreateDashboard:R.exports.bool.isRequired,canCreateCodeStudio:R.exports.bool.isRequired,canCreateQueryMonitor:R.exports.bool.isRequired,canCopy:R.exports.bool.isRequired,canDownloadCsv:R.exports.bool.isRequired}).isRequired});Object.freeze({LinkPoint:C1,Link:Kp,Links:b1,Panel:f1,User:S1});const w1=(t,e)=>t[e]===null?null:R.exports.bool,v1=(t,e)=>t[e]===null?null:R.exports.string;Object.freeze({nullableBoolean:w1,nullableString:v1});X.module("StorageTableViewportUpdater");class jh{static makeSortConfig(e,n){return{column:e,direction:n}}static makeFilterConfig(e){const n=[],s=[];return e.forEach((i,o)=>{n.push(i),o>0&&s.push(Yt.and)}),{filterItems:n,filterOperators:s}}static combineFilterConfigs(e,n,s=Yt.and){return{filterItems:[...e.filterItems,...n.filterItems],filterOperators:[...e.filterOperators,s,...n.filterOperators]}}static makeFilterItem(e,n,s){return{columnName:e,type:n,value:s}}}const Ta=X.module("PouchStorageTable"),T1="Deephaven.";ru.plugin(Cg);function E1(t,e){switch(t){case q.in:case q.contains:return{$regex:new RegExp(`${e}`)};case q.inIgnoreCase:return{$regex:new RegExp(`${e}`,"i")};case q.eq:return{$eq:e};case q.notEq:return{$neq:e};case q.greaterThan:return{$gt:e};case q.greaterThanOrEqualTo:return{$gte:e};case q.lessThan:return{$lt:e};case q.lessThanOrEqualTo:return{$lte:e};case q.startsWith:return{$regex:new RegExp(`^(?${e}).*`)};default:throw new Error(`Unsupported type: ${t}`)}}function y1(t){const{filterItems:e,filterOperators:n}=t;let s=null;for(let i=0;i<e.length;i+=1){const o=e[i],{columnName:r,type:l,value:a}=o,d={[r]:E1(l,a)};if(i===0)s=d;else if(s!==null&&i-1<n.length){const c=n[i-1];if(c===Yt.and)s={$and:[s,d]};else if(c===Yt.or)s={$or:[s,d]};else throw new Error(`Unexpected filter operator ${c}, ${d}`)}}if(s==null)throw new Error(`Invalid filter config ${t}`);return s}function Ea(t=[]){return{$and:[...t.map(e=>y1(e)),{name:{$gt:null}},{id:{$gt:null}}]}}function I1(t,e=!1){var n;return[{id:e?"desc":"asc"},...(n=t==null?void 0:t.map(s=>({[s.column]:s.direction})))!=null?n:[]]}class R1{constructor(e){this.listeners=[],this.itemListeners=new Map,this.currentSize=0,this.currentReverse=!1,this.currentFilter=null,this.currentSort=null,this.db=new ru(`${T1}${e}`),this.db._remote=!1,this.db.changes({live:!0,since:"now",include_docs:!0}).on("change",this.dbUpdate.bind(this)),this.db.createIndex({index:{fields:["id","name"]}}),this.refreshInfo()}onUpdate(e){return this.listeners=[...this.listeners,e],()=>{this.listeners=this.listeners.filter(n=>n!==e)}}onItemUpdate(e,n){return this.itemListeners.has(e)||this.itemListeners.set(e,[]),this.itemListeners.set(e,[...this.itemListeners.get(e),n]),this.refreshItem(e),()=>{this.itemListeners.set(e,this.itemListeners.get(e).filter(s=>s!==n))}}close(){this.listeners=[]}get size(){return this.currentSize}get viewport(){return this.currentViewport}setReversed(e){this.currentReverse=e,this.currentViewportData=void 0,this.refreshData()}setViewport(e){this.currentViewport=e,this.refreshInfo(),this.refreshData()}setSorts(e){this.currentSort=e,this.currentViewportData=void 0,this.refreshData()}setFilters(e){this.currentFilter=e,this.currentViewportData=void 0,this.refreshInfo(),this.refreshData()}get data(){return this.currentViewportData}async getViewportData(){var e;return this.viewportUpdatePromise||this.refreshData(),(e=this.viewportUpdatePromise)!=null?e:Promise.resolve({items:[],offset:0})}async put(e){const n={...e,_id:e.id};return await this.db.put(n),n}sendUpdate(){var s;const{listeners:e}=this,n=(s=this.currentViewportData)!=null?s:{items:[],offset:0};for(let i=0;i<e.length;i+=1)e[i](n)}sendItemUpdate(e){const n=this.itemListeners.get(e.id);if(n!==void 0)for(let s=0;s<n.length;s+=1)n[s](e)}dbUpdate(e){Ta.debug("Update received",e),this.refreshInfo(),e.doc!==void 0&&this.sendItemUpdate(e.doc),this.refreshData()}async refreshInfo(){var e,n;try{(e=this.infoUpdatePromise)==null||e.cancel(),this.infoUpdatePromise=Te.makeCancelable(this.db.find({selector:Ea((n=this.currentFilter)!=null?n:[]),fields:[]}));const s=await this.infoUpdatePromise;this.currentSize=s.docs.length,this.sendUpdate()}catch(s){if(!Te.isCanceled(s))throw Ta.error("Unable to refreshInfo",s),s}}async refreshData(){var e,n;if(!!this.currentViewport)try{const{currentViewport:s}=this,i=I1(this.currentSort,this.currentReverse);(e=this.viewportUpdatePromise)==null||e.cancel(),this.viewportUpdatePromise=Te.makeCancelable(this.db.find({selector:Ea((n=this.currentFilter)!=null?n:[]),skip:s.top,limit:s.bottom-s.top+1,sort:i,fields:["id","name"]}).then(r=>({items:r.docs,offset:s.top})));const o=await this.viewportUpdatePromise;return this.currentViewportData=o,this.sendUpdate(),o}catch(s){if(!Te.isCanceled(s))throw Ta.error("Unable to refreshData",s),s}}async refreshItem(e){const s=(await this.db.find({selector:{id:e},limit:1})).docs[0];return s!==void 0&&this.sendItemUpdate(s),s}async getSnapshot(e){const n=new Map,s=[{id:this.currentReverse?"desc":"asc"}];return await Promise.all(e.map(async([i,o])=>{var l;const r=o-i+1;return this.db.find({selector:Ea((l=this.currentFilter)!=null?l:[]),skip:i,limit:r,sort:s,fields:["id","name"]}).then(a=>{for(let d=0;d<r;d+=1){const c=i+d;n.set(c,a.docs[d])}})})),n}}class Qh extends R1{constructor(e){super(`CommandHistoryStorage.${e}`)}setSearch(e){this.setFilters(e?[jh.makeFilterConfig([jh.makeFilterItem("name",q.contains,e)])]:[])}}const Zh=X.module("PouchCommandHistoryStorage");class D1{constructor(){this.updateTableMap=new Map}getUpdateTable(e){return this.updateTableMap.has(e)||this.updateTableMap.set(e,new Qh(e)),this.updateTableMap.get(e)}async getTable(e){return new Qh(e)}async addItem(e,n,s,i){return this.updateItem(e,{id:`${new Date().getTime()}`,name:s,data:i})}async updateItem(e,n){const s=this.getUpdateTable(e),i=await s.refreshItem(n.id),o={...i!=null?i:{},...n};return Zh.debug("Updating item",o),await s.put(o),Zh.debug("Update saved"),n}listenItem(e,n,s){return this.getUpdateTable(e).onItemUpdate(n,s)}}const qp="SET_LAYOUT_STORAGE",M1=t=>({type:qp,payload:t}),Yp="/ide/assets/community-wordmark-app.d2c5c1eb.svg";const _s=X.module("FormattingSectionContent");function N1(t){return t.formatString!=null}const at=class extends S.exports.PureComponent{constructor(t){super(t),this.getCachedColumnTypeOptions=ve(()=>at.renderColumnTypeOptions()),this.getCachedDateTimeFormatOptions=ve((c,u,m,p=!1,g)=>{const{timestampAtMenuOpen:f}=this.state;return at.renderDateTimeOptions(f,c,u,m,p,g)}),this.debouncedCommitChanges=je(this.commitChanges.bind(this),at.inputDebounceTime),this.handleDefaultDateTimeFormatChange=this.handleDefaultDateTimeFormatChange.bind(this),this.handleDefaultDecimalFormatChange=this.handleDefaultDecimalFormatChange.bind(this),this.handleDefaultIntegerFormatChange=this.handleDefaultIntegerFormatChange.bind(this),this.handleFormatRuleEntered=this.handleFormatRuleEntered.bind(this),this.handleFormatRuleChange=this.handleFormatRuleChange.bind(this),this.handleFormatRuleCreate=this.handleFormatRuleCreate.bind(this),this.handleFormatRuleDelete=this.handleFormatRuleDelete.bind(this),this.handleShowTimeZoneChange=this.handleShowTimeZoneChange.bind(this),this.handleShowTSeparatorChange=this.handleShowTSeparatorChange.bind(this),this.handleTimeZoneChange=this.handleTimeZoneChange.bind(this),this.handleResetDateTimeFormat=this.handleResetDateTimeFormat.bind(this),this.handleResetDecimalFormat=this.handleResetDecimalFormat.bind(this),this.handleResetIntegerFormat=this.handleResetIntegerFormat.bind(this),this.handleResetTimeZone=this.handleResetTimeZone.bind(this),this.handleTruncateNumbersWithPoundChange=this.handleTruncateNumbersWithPoundChange.bind(this);const{formatter:e,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,showTimeZone:o,showTSeparator:r,timeZone:l,truncateNumbersWithPound:a}=t,d=e.map((c,u)=>({...c,id:u}));this.containerRef=Y.createRef(),this.addFormatRuleButtonRef=Y.createRef(),this.lastFormatRuleIndex=d.length,this.state={formatSettings:d,formatRulesChanged:!1,showTimeZone:o,showTSeparator:r,timeZone:l,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,truncateNumbersWithPound:a,timestampAtMenuOpen:new Date}}static focusFirstInputInContainer(t){const e=t==null?void 0:t.querySelector("input, select, textarea");e&&e.focus()}static isSameOptions(t,e){return t.defaultFormatString===e.defaultFormatString}static isSameDecimalOptions(t,e){return at.isSameOptions(t,e)}static isSameIntegerOptions(t,e){return at.isSameOptions(t,e)}static isValidColumnName(t){return t!==""&&gs.isValidColumnName(t)}static isValidFormat(t,e){if(!t||e.formatString==null||!N1(e))return!1;switch(t){case"datetime":return dt.isValid(e);case"decimal":return Le.isValid(e);case"int":return it.isValid(e);default:return _s.warn("Trying to validate format of unknown type"),!0}}static removeFormatRuleExtraProps(t){const{id:e,isNewRule:n,...s}=t;return s}static isFormatRuleValidForSave(t){return at.isValidColumnName(t.columnName)&&at.isValidFormat(t.columnType,t.format)}static renderTimeZoneOptions(){return Dn.TIME_ZONES.map(e=>{const{label:n,value:s}=e;return h("option",{value:s,children:n},s)})}static renderColumnTypeOptions(){const e=[{value:L.dataType.DATETIME,label:"DateTime"},{value:L.dataType.DECIMAL,label:"Decimal"},{value:L.dataType.INT,label:"Integer"}].map(n=>h("option",{value:n.value,children:n.label},`key-columnType-${n.value}`));return v(ye,{children:[h("option",{disabled:!0,value:"",children:"Select Type"},"key-columnType-placeholder"),e]})}static renderDateTimeOptions(t,e,n,s,i,o){const r=new un([],{timeZone:e,showTimeZone:n,showTSeparator:s}),l=i?dt.getGlobalFormats(n,s):dt.getFormats(n,s);return o!=null&&!l.includes(o)&&l.unshift(o),l.map(a=>{const d=dt.makeFormat("",a,dt.TYPE_GLOBAL);return h("option",{value:a,children:r.getFormattedString(t,L.dataType.DATETIME,"",d)},a)})}componentDidMount(){at.focusFirstInputInContainer(this.containerRef.current)}componentWillUnmount(){this.debouncedCommitChanges.flush()}isDuplicateRule(t){var n;const{formatSettings:e}=this.state;return(n=e.some(s=>s.id!==t.id&&s.columnName===t.columnName&&s.columnType===t.columnType))!=null?n:!1}getAutoIncrementFormatRuleIndex(){const{lastFormatRuleIndex:t}=this;return this.lastFormatRuleIndex+=1,t}handleDefaultDateTimeFormatChange(t){_s.debug("handleDefaultDateTimeFormatChange",t.target.value),this.setState({defaultDateTimeFormat:t.target.value},()=>{this.debouncedCommitChanges()})}handleDefaultDecimalFormatChange(t){_s.debug("handleDefaultDecimalFormatChange",t.target.value),this.setState({defaultDecimalFormatOptions:{defaultFormatString:t.target.value}},()=>{this.debouncedCommitChanges()})}handleDefaultIntegerFormatChange(t){_s.debug("handleDefaultIntegerFormatChange",t.target.value),this.setState({defaultIntegerFormatOptions:{defaultFormatString:t.target.value}},()=>{this.debouncedCommitChanges()})}handleFormatRuleChange(t,e,n){this.setState(s=>{const{formatSettings:i}=s;P(i);const o=[...i];let r={};e==="columnType"&&(r={format:""});const l={...o[t],...r,[e]:n};return o[t]=l,{formatSettings:o}},()=>{this.debouncedCommitChanges()})}handleFormatRuleCreate(){this.setState(t=>{const{formatSettings:e}=t,n={columnType:L.dataType.DATETIME,columnName:"",format:{},id:this.getAutoIncrementFormatRuleIndex(),isNewRule:!0};return{formatSettings:e!=null?[...e,n]:[n],formatRulesChanged:!0}})}handleFormatRuleDelete(t){this.setState(e=>{const{formatSettings:n}=e;return{formatSettings:n.filter((i,o)=>o!==t),formatRulesChanged:!0}},()=>{this.debouncedCommitChanges()})}handleShowTimeZoneChange(){this.setState(t=>({showTimeZone:!t.showTimeZone}),()=>{this.debouncedCommitChanges()})}handleShowTSeparatorChange(){this.setState(t=>({showTSeparator:!t.showTSeparator}),()=>{this.debouncedCommitChanges()})}handleTimeZoneChange(t){this.setState({timeZone:t.target.value},()=>{this.debouncedCommitChanges()})}handleResetDateTimeFormat(){const{defaults:t}=this.props,{defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s}=t;_s.debug("handleResetDateTimeFormat"),this.setState({defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s},()=>{this.debouncedCommitChanges()})}handleResetTimeZone(){const{defaults:t}=this.props,{timeZone:e}=t;_s.debug("handleResetTimeZone"),this.setState({timeZone:e},()=>{this.debouncedCommitChanges()})}handleResetDecimalFormat(){const{defaults:t}=this.props,{defaultDecimalFormatOptions:e}=t;_s.debug("handleResetDecimalFormat"),this.setState({defaultDecimalFormatOptions:e},()=>{this.debouncedCommitChanges()})}handleResetIntegerFormat(){const{defaults:t}=this.props,{defaultIntegerFormatOptions:e}=t;_s.debug("handleResetIntegerFormat"),this.setState({defaultIntegerFormatOptions:e},()=>{this.debouncedCommitChanges()})}handleTruncateNumbersWithPoundChange(){this.setState(t=>({truncateNumbersWithPound:!t.truncateNumbersWithPound}),()=>{this.debouncedCommitChanges()})}handleFormatRuleEntered(t){this.scrollToFormatBlockBottom(),at.focusFirstInputInContainer(t)}commitChanges(){var m;const{formatSettings:t,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,defaultDecimalFormatOptions:o,defaultIntegerFormatOptions:r,truncateNumbersWithPound:l}=this.state,a=(m=t.filter(at.isFormatRuleValidForSave).map(at.removeFormatRuleExtraProps))!=null?m:[],{settings:d,saveSettings:c}=this.props,u={...d,formatter:a,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,truncateNumbersWithPound:l};at.isValidFormat(L.dataType.DECIMAL,Le.makeCustomFormat(o.defaultFormatString))&&(u.defaultDecimalFormatOptions=o),at.isValidFormat(L.dataType.INT,it.makeCustomFormat(r.defaultFormatString))&&(u.defaultIntegerFormatOptions=r),c(u)}scrollToFormatBlockBottom(){var e,n,s,i;const{scrollTo:t}=this.props;t(0,((n=(e=this.addFormatRuleButtonRef.current)==null?void 0:e.offsetHeight)!=null?n:0)+((i=(s=this.addFormatRuleButtonRef.current)==null?void 0:s.offsetTop)!=null?i:0))}getRuleError(t){const e={hasColumnNameError:!1,hasFormatError:!1,message:""},n=[];return t.isNewRule!==void 0&&t.isNewRule||(this.isDuplicateRule(t)&&(e.hasColumnNameError=!0,n.push("Duplicate column name/type combo.")),at.isValidColumnName(t.columnName)||(e.hasColumnNameError=!0,n.push("Column names must start with a letter or underscore and contain only alphanumeric characters or underscores.")),t.format.formatString!==void 0&&t.format.formatString.length===0?(e.hasFormatError=!0,n.push("Empty formatting rule.")):at.isValidFormat(t.columnType,t.format)||(e.hasFormatError=!0,n.push("Invalid formatting rule.")),e.message=n.join(`
43
- `)),e}renderFormatRule(t,e){const n=`input-${t}-columnName`,s=`input-${t}-columnType`,i=`input-${t}-format`,o=this.getCachedColumnTypeOptions(),r=c=>this.handleFormatRuleChange(t,"columnName",c.target.value),l=()=>this.handleFormatRuleChange(t,"isNewRule",!1),a=c=>this.handleFormatRuleChange(t,"columnType",c.target.value),d=this.getRuleError(e);return v("fieldset",{className:"container-fluid format-rule-container",children:[v("div",{className:"form-row",children:[v("div",{className:"form-group col-7 mb-2",children:[h("label",{htmlFor:n,children:"Column Name"}),h("input",{id:n,className:W("form-control",{"is-invalid":d.hasColumnNameError}),"data-lpignore":!0,type:"text",value:e.columnName,onChange:r,onBlur:l})]}),v("div",{className:"form-group col mb-2",children:[h(z,{kind:"ghost",className:"btn-delete-format-rule float-right",tabIndex:-1,onClick:()=>this.handleFormatRuleDelete(t),icon:wn,tooltip:"Delete"}),h("label",{htmlFor:s,children:"Column Type"}),h("select",{id:s,className:"custom-select",value:e.columnType,onChange:a,children:o})]})]}),h("div",{className:"form-row",children:v("div",{className:"form-group col-12 d-flex mb-2",children:[h("label",{className:"flex-shrink-0 col-form-label mr-3",htmlFor:i,children:"Formatting Rule"}),this.renderFormatRuleInput(t,e.columnType,i,e.format,d.hasFormatError)]})}),h("div",{className:"form-row",children:h("div",{className:"form-group col-12 d-flex mb-2",children:d.message&&h("p",{className:"text-danger",children:d.message})})})]},t)}renderFormatRuleInput(t,e,n,s,i){switch(L.getNormalizedType(e)){case L.dataType.DATETIME:return this.renderDateTimeFormatRuleInput(t,n,s,i);case L.dataType.DECIMAL:return this.renderDecimalFormatRuleInput(t,n,s,i);case L.dataType.INT:return this.renderIntegerFormatRuleInput(t,n,s,i);default:return null}}renderDateTimeFormatRuleInput(t,e,n,s){var a;const{showTimeZone:i,showTSeparator:o,timeZone:r}=this.state,l=(a=n.formatString)!=null?a:"";return v("select",{className:W("custom-select",{"is-invalid":s}),value:l,id:e,onChange:d=>{const c=dt.makeFormat("",d.target.value,dt.TYPE_GLOBAL);this.handleFormatRuleChange(t,"format",c)},children:[h("option",{value:"",disabled:!0,children:"Select format"},"default"),this.getCachedDateTimeFormatOptions(r,i,o)]})}renderIntegerFormatRuleInput(t,e,n,s){var o;const i=(o=n.formatString)!=null?o:"";return h("input",{className:W("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:e,placeholder:it.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:r=>{const l=it.makeFormat("",r.target.value,it.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(t,"format",l)}})}renderDecimalFormatRuleInput(t,e,n,s){var o;const i=(o=n.formatString)!=null?o:"";return h("input",{className:W("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:e,placeholder:Le.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:r=>{const l=Le.makeFormat("",r.target.value,Le.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(t,"format",l)}})}render(){const{defaults:t}=this.props,{formatRulesChanged:e,formatSettings:n,defaultDateTimeFormat:s,defaultDecimalFormatOptions:i,defaultIntegerFormatOptions:o,timeZone:r,showTimeZone:l,showTSeparator:a,truncateNumbersWithPound:d}=this.state,{defaultFormatString:c=Le.DEFAULT_FORMAT_STRING}=i!=null?i:{},{defaultFormatString:u=it.DEFAULT_FORMAT_STRING}=o!=null?o:{},m=n.map((w,T)=>h(ut,{classNames:"fade",timeout:yt.transitionMs,onEnter:this.handleFormatRuleEntered,children:this.renderFormatRule(T,w)},w.id)),p=h(z,{kind:"ghost",className:"mb-3",onClick:this.handleFormatRuleCreate,ref:this.addFormatRuleButtonRef,icon:Ps,children:"Add New Rule"}),g=r===t.timeZone,f=a===t.showTSeparator&&l===t.showTimeZone&&s===t.defaultDateTimeFormat,b=at.isSameDecimalOptions(i,t.defaultDecimalFormatOptions),C=at.isSameIntegerOptions(o,t.defaultIntegerFormatOptions);return v("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:[v("div",{className:"container-fluid p-0",children:[h("div",{children:"Default formatting for column types"}),h("div",{className:"app-settings-menu-description mb-3",children:"Applies a formatting rule to all columns of a set type."}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"select-reset-timezone",children:"Time zone"}),h("div",{className:"col pr-0",children:h("select",{className:"custom-select",value:r,onChange:this.handleTimeZoneChange,id:"select-reset-timezone",children:at.renderTimeZoneOptions()})}),h("div",{className:"col-1 btn-col",children:h(z,{kind:"ghost",icon:ki,onClick:this.handleResetTimeZone,tooltip:"Reset Time Zone",className:W("btn-reset","btn-reset-time-zone",{hidden:g})})})]}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"select-default-time-format",children:"DateTime"}),h("div",{className:"col pr-0",children:h("select",{className:"custom-select",value:s,onChange:this.handleDefaultDateTimeFormatChange,id:"select-default-time-format",children:this.getCachedDateTimeFormatOptions(r,l,a,!0,s)})}),h("div",{className:"col-1 btn-col",children:h(z,{kind:"ghost",icon:ki,onClick:this.handleResetDateTimeFormat,tooltip:"Reset DateTime Options",className:W("btn-reset","btn-reset-date-time",{hidden:f})})})]}),h("div",{className:"form-row",children:h("div",{className:"offset-3 col-9",children:h(bt,{checked:l!=null?l:null,onChange:this.handleShowTimeZoneChange,children:"Show time zone in dates"})})}),h("div",{className:"form-row mb-3",children:h("div",{className:"offset-3 col-9",children:h(bt,{checked:a!=null?a:null,onChange:this.handleShowTSeparatorChange,children:"Show 'T' separator"})})}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"default-decimal-format-input",children:"Decimal"}),h("div",{className:"col pr-0",children:h("input",{className:W("form-control","flex-grow-1","default-decimal-format-input",{"is-invalid":!at.isValidFormat(L.dataType.DECIMAL,Le.makeCustomFormat(c))}),"data-lpignore":!0,placeholder:Le.DEFAULT_FORMAT_STRING,type:"text",id:"default-decimal-format-input",value:c,onChange:this.handleDefaultDecimalFormatChange})}),h("div",{className:"col-1 btn-col",children:h(z,{kind:"ghost",icon:ki,onClick:this.handleResetDecimalFormat,tooltip:"Reset Decimal Formatting",className:W("btn-reset","btn-reset-decimal",{hidden:b}),"data-testid":"btn-reset-decimal"})})]}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"default-integer-format-input",children:"Integer"}),h("div",{className:"col pr-0",children:h("input",{className:W("form-control","flex-grow-1","default-integer-format-input",{"is-invalid":!at.isValidFormat(L.dataType.INT,it.makeCustomFormat(u))}),"data-lpignore":!0,placeholder:it.DEFAULT_FORMAT_STRING,type:"text",id:"default-integer-format-input",value:u,onChange:this.handleDefaultIntegerFormatChange})}),h("div",{className:"col-1 btn-col",children:h(z,{kind:"ghost",icon:ki,onClick:this.handleResetIntegerFormat,tooltip:"Reset Integer Formatting",className:W("btn-reset","btn-reset-integer",{hidden:C}),"data-testid":"btn-reset-integer"})})]}),h("div",{className:"form-row mb-3",children:h("div",{className:"offset-3 col-9",children:h(bt,{checked:d!=null?d:null,onChange:this.handleTruncateNumbersWithPoundChange,children:"Truncate numbers with #"})})})]}),h("div",{children:"Default formatting for matched column names"}),h("div",{className:"app-settings-menu-description mb-3",children:"Applies a formatting rule to all columns that match a specified name and type."}),h(bg,{appear:e,enter:e,exit:e,children:m}),p]})}};let cc=at;cc.defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:dt.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:Le.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:it.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:dt.DEFAULT_TIME_ZONE_ID}};cc.inputDebounceTime=250;const F1=t=>({formatter:ES(t),defaultDateTimeFormat:wS(t),defaultDecimalFormatOptions:vS(t),defaultIntegerFormatOptions:TS(t),showTimeZone:yS(t),showTSeparator:IS(t),truncateNumbersWithPound:RS(t),timeZone:Ml(t),settings:Ft(t)}),x1=Nt(F1,{saveSettings:Td})(cc);function _1(){const[t,e]=S.exports.useState(!1),n=()=>{e(!t)};return v(z,{kind:"ghost",onClick:n,icon:xf,children:["Legal Notices",v($o,{isOpen:t,toggle:n,className:"theme-bg-light",children:[h(zo,{toggle:n,children:"Legal Notice"}),v(Wo,{children:[h("p",{children:"Deephaven software is protected by U.S. Patent Nos. 9,612,959; 9,613,018; 9,613,109; 9,619,210; 9,633,060; 9,639,570; 9,672,238; 9,679,006; 9,690,821; 9,710,511; 9,760,591; 9,805,084; 9,836,495; 9,836,494; 9,886,469; 9,898,496; 9,934,266; 10,002,153; 10,002,154; 10,002,155; 10,003,673; 10,019,138; 10,069,943; 10,176,211; 10,198,465; 10,198,466; 10,198,469; 10,212,257; 10,241,960; 10,241,965; 10,242,040; 10,242,041; 10,353,893; 10,346,394; 10,452,649; 10,496,639; 10,540,351; 10,552,412; 10,565,194; 10,565,206; 10,572,474; 10,621,168; 10,642,829; 10,657,184; 10,678,787; 10,691,686; and 10,783,191. Other patents pending."}),v("p",{children:["\xA9 2016-",new Date().getFullYear()," Deephaven Data Labs LLC. Patent Pending."]})]})]})]})}function al(t){const{children:e,isExpanded:n,sectionKey:s,title:i,onToggle:o}=t;return v(ye,{children:[h("div",{children:v(z,{kind:"ghost",className:"btn-collapse-trigger",onClick:()=>o(s),children:[h("div",{className:"flex-grow-1",children:i}),h("div",{className:"flex-shrink-0",children:h(j,{transform:n?"flip-v":"",icon:Gn})})]})}),h(gd,{in:n,autoFocusOnShow:!0,children:e})]})}al.propTypes={children:R.exports.node,isExpanded:R.exports.bool.isRequired,sectionKey:R.exports.string.isRequired,title:R.exports.node.isRequired,onToggle:R.exports.func};al.defaultProps={children:null,onToggle:()=>{}};function k1({shortcut:t,displayText:e,categoryName:n,onChange:s}){const[i,o]=S.exports.useState(e),[r,l]=S.exports.useState(t.getKeyState()),[a,d]=S.exports.useState(!1),[c,u]=S.exports.useState("");S.exports.useEffect(function(){o(e),l(t.getKeyState())},[e,t]),S.exports.useEffect(function(){o(Kt.getDisplayText(r)),t.matchesKeyState(r)&&d(!1)},[r,t]),S.exports.useEffect(function(){if(a){if(!Kt.isValidKeyState(r)){Kt.isAllowedKey(r.keyValue)?u("Must contain a modifier key"):u("Must contain an allowed action key");return}const y=Ae.getConflictingShortcuts(r).filter(E=>E.id.startsWith(n)&&E!==t).map(E=>E.name);if(y.length){u(`Conflicts with ${y.join(", ")}`);return}u("")}else u("")},[a,r,n,t]);function m(T){if(T.stopPropagation(),T.preventDefault(),t.isEditable&&!T.repeat){const y=Kt.getKeyStateFromEvent(T),E=Kt.createKeyState([me.BACKSPACE]);Kt.doKeyStatesMatch(y,E)?l(Kt.NULL_KEY_STATE):l(y)}}function p(T){T.stopPropagation(),T.preventDefault(),t.matchesKeyState(r)||d(!0)}function g(){We.disableAllActions()}function f(){We.enableAllActions()}function b(){t.setKeyState(r),d(!1),s(t)}function C(){const T=t.getKeyState();l(T),d(!1)}function w(){d(!0),l(t.getDefaultKeyState())}return v(ye,{children:[v("div",{className:"shortcut-item-container",children:[v("label",{className:"shortcut-item-name",children:[t.name,t.tooltip!==void 0&&h($e,{children:t.tooltip})]}),v("div",{className:"shortcut-item-input-container",children:[h("input",{className:W("form-control",{"is-invalid":c}),onKeyDown:m,onKeyUp:p,onFocus:g,onBlur:f,disabled:!t.isEditable,value:i,readOnly:!0}),!Kt.doKeyStatesMatch(r,t.getDefaultKeyState())&&!c&&h(z,{className:"reset-to-default-button",kind:"ghost",icon:h(j,{icon:ki,transform:{rotate:90,flipX:!0}}),tooltip:"Reset to default",onClick:w})]})]}),a&&v("div",{className:W("shortcut-item-message-container",{"is-invalid":c}),children:[h("div",{className:"shortcut-item-message",children:c}),v("div",{className:"shortcut-item-message-buttons",children:[Kt.isValidKeyState(r)&&h(z,{kind:"ghost",onClick:b,children:"Confirm"}),h(z,{kind:"ghost",onClick:C,children:"Undo"})]})]})]})}function O1({shortcutOverrides:t={},settings:e,saveSettings:n}){const s=S.exports.useCallback(l=>{const a=Kt.isMacPlatform,d={mac:{...t.mac},windows:{...t.windows}},c=a?d.mac:d.windows;l.forEach(u=>{u.isDefault()?delete c[u.id]:c[u.id]=u.getKeyState()}),n({...e,shortcutOverrides:d})},[e,n,t]);let i=Array.from(Ae.shortcutsByCategory.entries()).map(([l,a])=>({name:l,shortcuts:a}));const o=i.findIndex(l=>l.name.toUpperCase()==="GLOBAL"),r=i.splice(o,1);return i=i.concat(r),v(ye,{children:[h("div",{className:"app-settings-menu-description",children:"Customize shortcuts below. Assigning shortcuts that conflict with the browser or IDE shortcuts may cause unintended behavior"}),i.map(l=>h(L1,{name:l.name,shortcuts:l.shortcuts,saveShortcutOverrides:s},l.name))]})}function L1({name:t,shortcuts:e,saveShortcutOverrides:n}){function s(a){return a.split("_").map(d=>`${d[0].toUpperCase()}${d.slice(1).toLowerCase()}`).join(" ")}const[i,o]=S.exports.useState(e);function r(a){const d=i.filter(u=>u!==a&&!u.isNull()&&u.matchesKeyState(a.getKeyState()));d.forEach(u=>u.setToNull());const c=[a,...d];n(c),o(u=>[...u])}const l=S.exports.useMemo(()=>i.map(a=>a.getDisplayText()),[i]);return v("div",{className:"mt-3",children:[h("div",{className:"font-weight-bold",children:s(t)}),i.map((a,d)=>h(k1,{shortcut:a,displayText:l[d],categoryName:t,onChange:r},a.id))]})}const A1=t=>({settings:Ft(t),shortcutOverrides:DS(t)}),P1={saveSettings:Td},H1=Nt(A1,P1)(O1),Qa=new of,Za=new Gr(Qa);function V1(){X.setLogLevel(parseInt("2",10)),Qa.enable(),Za.enable(),window!=null&&(window.DHLog=X,window.DHLogProxy=Qa,window.DHLogHistory=Za)}const U1="yyyy-MM-dd-HHmmss";function Xp(t,e="root",n=new Map([[t,""]])){const s={};return Object.entries(t).forEach(([i,o])=>{try{JSON.stringify(o),s[i]=o}catch{const l=o;if(typeof o=="bigint")s[i]=o.toString();else if(n.has(l))s[i]=`Circular ref to ${n.get(l)}`;else{const a=`${e}.${i}`;n.set(l,a),s[i]=Xp(o,a,n)}}}),s}function B1(){const t=xl.getState();return JSON.stringify(Xp(t),null,2)}function $1(t){const e={uiVersion:"0.23.0",userAgent:navigator.userAgent,...t};return JSON.stringify(e,null,2)}async function W1(t=`${M.i18n.DateTimeFormat.format(U1,new Date)}_support_logs`,e){const n=new lu,s=n.folder(t);s.file("console.txt",Za.getFormattedHistory()),s.file("redux.json",B1()),s.file("metadata.json",$1(e));const i=await n.generateAsync({type:"blob"}),o=document.createElement("a");o.href=URL.createObjectURL(i),o.download=`${t}.zip`,o.click()}const si=class extends S.exports.Component{constructor(t){super(t),this.handleClose=this.handleClose.bind(this),this.handleScrollTo=this.handleScrollTo.bind(this),this.handleSectionToggle=this.handleSectionToggle.bind(this),this.handleExportSupportLogs=this.handleExportSupportLogs.bind(this),this.menuContentRef=Y.createRef(),this.state={expandedSectionKey:si.FORMATTING_SECTION_KEY}}static focusFirstInputInContainer(t){const e=t==null?void 0:t.querySelector("input, select, textarea");e&&e.focus()}componentDidMount(){si.focusFirstInputInContainer(this.menuContentRef.current)}isSectionExpanded(t){const{expandedSectionKey:e}=this.state;return e===t}handleScrollTo(t,e){var n;(n=this.menuContentRef.current)==null||n.scrollTo(t,e)}handleSectionToggle(t){this.setState(e=>({expandedSectionKey:e.expandedSectionKey===t?void 0:t}))}handleClose(){const{onDone:t}=this.props;t()}handleExportSupportLogs(){const{serverConfigValues:t}=this.props;W1(void 0,Object.fromEntries(t))}render(){const t="0.23.0",e="https://github.com/deephaven/web-client-ui/",n="https://deephaven.io/core/docs/",{serverConfigValues:s}=this.props,i=s.get("barrage.version"),o=s.get("java.version"),r=s.get("deephaven.version"),l=(a,d)=>v(ye,{children:[h("div",{children:a}),h("div",{children:d})]});return v("div",{className:"app-settings-menu",children:[v("header",{className:"app-settings-menu-header",children:[h("div",{className:"flex-spacer"}),h(z,{kind:"ghost",className:"btn-close-settings-menu",onClick:this.handleClose,icon:h(j,{icon:Xi,transform:"grow-4"}),tooltip:"Close"})]}),v("div",{className:"app-settings-menu-content",ref:this.menuContentRef,children:[h("h5",{children:"Settings"}),h("hr",{className:"my-0"}),h(al,{sectionKey:si.FORMATTING_SECTION_KEY,isExpanded:this.isSectionExpanded(si.FORMATTING_SECTION_KEY),title:v(ye,{children:[h(j,{icon:Gf,transform:"grow-4",className:"mr-2"}),"Formatting & Time zone"]}),onToggle:this.handleSectionToggle,children:h(x1,{scrollTo:this.handleScrollTo})}),h(al,{sectionKey:si.SHORTCUT_SECTION_KEY,isExpanded:this.isSectionExpanded(si.SHORTCUT_SECTION_KEY),title:v(ye,{children:[h(j,{icon:Vf,transform:"grow-2"})," ","Keyboard Shortcuts"]}),onToggle:this.handleSectionToggle,children:h(H1,{})}),v("div",{className:"app-settings-footer",children:[v("div",{className:"app-settings-footer-section",children:[v("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Support"}),v("div",{children:["GitHub:\xA0",h("a",{href:e,className:"custom-link",target:"_blank",rel:"noopener noreferrer",children:e})]}),h(z,{kind:"tertiary",className:"mt-2 py-2",onClick:this.handleExportSupportLogs,children:"Export Logs"})]}),v("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Documentation"}),h("a",{target:"_blank",rel:"noreferrer noopener",href:n,className:"custom-link",children:n})]}),v("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Version"}),v("span",{className:"d-inline-block text-muted",children:[r," ",h(j,{icon:Nf}),v($e,{interactive:!0,children:[v("div",{className:"detailed-server-config",children:[l("Engine Version",r),l("Web UI Version",t),l("Java Version",o),l("Barrage Version",i)]}),h(bl,{tooltip:"Copy version numbers",copy:`Engine Version: ${r}
42
+ This note can be edited using **markdown** for styling.`;function g1(t){Vs(t);const{id:e,layout:n,panelManager:s,registerComponent:i}=t,o=S.exports.useCallback(l=>{const{title:a,componentState:d,props:c}=l;let{panelState:u=null}=c;return d!=null&&({panelState:u=null}=d),a==null||u==null||u.content==null||u.content.length===0||u.content===Oo.DEFAULT_CONTENT?null:xd(l)},[]),r=S.exports.useCallback(({title:l="",metadata:a={},id:d=ze.generate(),focusElement:c=ne.DEFAULT_FOCUS_SELECTOR,createNewStack:u=!1,dragEvent:m=null}={})=>{const p=s.getOpenedPanelConfigsOfType(So.COMPONENT),g=s.getClosedPanelConfigsOfType(So.COMPONENT),f=p.map(y=>{var E;return(E=y.title)!=null?E:""}),b=l!=null&&l!==""?l:Oo.getNewMarkdownTitle(f),C=g.length>0?null:Oo.DEFAULT_CONTENT,w={type:"react-component",component:So.COMPONENT,props:{id:d,metadata:a,panelState:{content:C},localDashboardId:e},title:b,id:d},{root:T}=n;ne.openComponent({root:T,config:w,focusElement:c,createNewStack:u,dragEvent:m})},[e,n,s]);return S.exports.useEffect(function(){const a=[i(So.COMPONENT,So,_d,o)];return()=>{a.forEach(d=>d())}},[o,i]),Ke(n.eventHub,Dp.OPEN,r),null}function f1(t){Vs(t);const{hydrate:e,id:n,layout:s,registerComponent:i}=t,o=S.exports.useCallback(({dragEvent:r,fetch:l,panelId:a=ze.generate(),widget:d})=>{const{name:c,type:u}=d;if(u!==dh.VariableType.PANDAS)return;const m={name:c,table:c},p=()=>l().then(b=>qd.makeModel(b)),g={type:"react-component",component:ko.COMPONENT,props:{localDashboardId:n,id:a,metadata:m,makeModel:p},title:c,id:a},{root:f}=s;ne.openComponent({root:f,config:g,dragEvent:r})},[n,s]);return S.exports.useEffect(function(){const l=[i(ko.COMPONENT,ko,e)];return()=>{l.forEach(a=>a())}},[e,i]),Ke(s.eventHub,Ne.OPEN,o),null}class Cn{}Cn.DROPDOWN_FILTER="ControlType.DROPDOWN_FILTER";Cn.INPUT_FILTER="ControlType.INPUT_FILTER";Cn.MARKDOWN="ControlType.MARKDOWN";Cn.FILTER_SET_MANAGER="ControlType.FILTER_SET_MANAGER";const C1=R.exports.shape({state:R.exports.shape({panelState:R.exports.shape({})})}),b1=R.exports.shape({panelId:R.exports.string.isRequired,columnName:R.exports.string.isRequired,columnType:R.exports.string.isRequired}),Xh=R.exports.shape({panelId:R.exports.string.isRequired,columnName:R.exports.string.isRequired}),Kp=R.exports.shape({start:Xh,end:Xh,id:R.exports.string,isReversed:R.exports.bool}),S1=R.exports.arrayOf(Kp),w1=R.exports.shape({name:R.exports.string.isRequired,operateAs:R.exports.string.isRequired,groups:R.exports.arrayOf(R.exports.string).isRequired,permissions:R.exports.shape({isSuperUser:R.exports.bool.isRequired,isQueryViewOnly:R.exports.bool.isRequired,isNonInteractive:R.exports.bool.isRequired,canUsePanels:R.exports.bool.isRequired,canCreateDashboard:R.exports.bool.isRequired,canCreateCodeStudio:R.exports.bool.isRequired,canCreateQueryMonitor:R.exports.bool.isRequired,canCopy:R.exports.bool.isRequired,canDownloadCsv:R.exports.bool.isRequired}).isRequired});Object.freeze({LinkPoint:b1,Link:Kp,Links:S1,Panel:C1,User:w1});const v1=(t,e)=>t[e]===null?null:R.exports.bool,T1=(t,e)=>t[e]===null?null:R.exports.string;Object.freeze({nullableBoolean:v1,nullableString:T1});X.module("StorageTableViewportUpdater");class jh{static makeSortConfig(e,n){return{column:e,direction:n}}static makeFilterConfig(e){const n=[],s=[];return e.forEach((i,o)=>{n.push(i),o>0&&s.push(Yt.and)}),{filterItems:n,filterOperators:s}}static combineFilterConfigs(e,n,s=Yt.and){return{filterItems:[...e.filterItems,...n.filterItems],filterOperators:[...e.filterOperators,s,...n.filterOperators]}}static makeFilterItem(e,n,s){return{columnName:e,type:n,value:s}}}const Ta=X.module("PouchStorageTable"),E1="Deephaven.";ru.plugin(Cg);function y1(t,e){switch(t){case q.in:case q.contains:return{$regex:new RegExp(`${e}`)};case q.inIgnoreCase:return{$regex:new RegExp(`${e}`,"i")};case q.eq:return{$eq:e};case q.notEq:return{$neq:e};case q.greaterThan:return{$gt:e};case q.greaterThanOrEqualTo:return{$gte:e};case q.lessThan:return{$lt:e};case q.lessThanOrEqualTo:return{$lte:e};case q.startsWith:return{$regex:new RegExp(`^(?${e}).*`)};default:throw new Error(`Unsupported type: ${t}`)}}function I1(t){const{filterItems:e,filterOperators:n}=t;let s=null;for(let i=0;i<e.length;i+=1){const o=e[i],{columnName:r,type:l,value:a}=o,d={[r]:y1(l,a)};if(i===0)s=d;else if(s!==null&&i-1<n.length){const c=n[i-1];if(c===Yt.and)s={$and:[s,d]};else if(c===Yt.or)s={$or:[s,d]};else throw new Error(`Unexpected filter operator ${c}, ${d}`)}}if(s==null)throw new Error(`Invalid filter config ${t}`);return s}function Ea(t=[]){return{$and:[...t.map(e=>I1(e)),{name:{$gt:null}},{id:{$gt:null}}]}}function R1(t,e=!1){var n;return[{id:e?"desc":"asc"},...(n=t==null?void 0:t.map(s=>({[s.column]:s.direction})))!=null?n:[]]}class D1{constructor(e){this.listeners=[],this.itemListeners=new Map,this.currentSize=0,this.currentReverse=!1,this.currentFilter=null,this.currentSort=null,this.db=new ru(`${E1}${e}`),this.db._remote=!1,this.db.changes({live:!0,since:"now",include_docs:!0}).on("change",this.dbUpdate.bind(this)),this.db.createIndex({index:{fields:["id","name"]}}),this.refreshInfo()}onUpdate(e){return this.listeners=[...this.listeners,e],()=>{this.listeners=this.listeners.filter(n=>n!==e)}}onItemUpdate(e,n){return this.itemListeners.has(e)||this.itemListeners.set(e,[]),this.itemListeners.set(e,[...this.itemListeners.get(e),n]),this.refreshItem(e),()=>{this.itemListeners.set(e,this.itemListeners.get(e).filter(s=>s!==n))}}close(){this.listeners=[]}get size(){return this.currentSize}get viewport(){return this.currentViewport}setReversed(e){this.currentReverse=e,this.currentViewportData=void 0,this.refreshData()}setViewport(e){this.currentViewport=e,this.refreshInfo(),this.refreshData()}setSorts(e){this.currentSort=e,this.currentViewportData=void 0,this.refreshData()}setFilters(e){this.currentFilter=e,this.currentViewportData=void 0,this.refreshInfo(),this.refreshData()}get data(){return this.currentViewportData}async getViewportData(){var e;return this.viewportUpdatePromise||this.refreshData(),(e=this.viewportUpdatePromise)!=null?e:Promise.resolve({items:[],offset:0})}async put(e){const n={...e,_id:e.id};return await this.db.put(n),n}sendUpdate(){var s;const{listeners:e}=this,n=(s=this.currentViewportData)!=null?s:{items:[],offset:0};for(let i=0;i<e.length;i+=1)e[i](n)}sendItemUpdate(e){const n=this.itemListeners.get(e.id);if(n!==void 0)for(let s=0;s<n.length;s+=1)n[s](e)}dbUpdate(e){Ta.debug("Update received",e),this.refreshInfo(),e.doc!==void 0&&this.sendItemUpdate(e.doc),this.refreshData()}async refreshInfo(){var e,n;try{(e=this.infoUpdatePromise)==null||e.cancel(),this.infoUpdatePromise=Te.makeCancelable(this.db.find({selector:Ea((n=this.currentFilter)!=null?n:[]),fields:[]}));const s=await this.infoUpdatePromise;this.currentSize=s.docs.length,this.sendUpdate()}catch(s){if(!Te.isCanceled(s))throw Ta.error("Unable to refreshInfo",s),s}}async refreshData(){var e,n;if(!!this.currentViewport)try{const{currentViewport:s}=this,i=R1(this.currentSort,this.currentReverse);(e=this.viewportUpdatePromise)==null||e.cancel(),this.viewportUpdatePromise=Te.makeCancelable(this.db.find({selector:Ea((n=this.currentFilter)!=null?n:[]),skip:s.top,limit:s.bottom-s.top+1,sort:i,fields:["id","name"]}).then(r=>({items:r.docs,offset:s.top})));const o=await this.viewportUpdatePromise;return this.currentViewportData=o,this.sendUpdate(),o}catch(s){if(!Te.isCanceled(s))throw Ta.error("Unable to refreshData",s),s}}async refreshItem(e){const s=(await this.db.find({selector:{id:e},limit:1})).docs[0];return s!==void 0&&this.sendItemUpdate(s),s}async getSnapshot(e){const n=new Map,s=[{id:this.currentReverse?"desc":"asc"}];return await Promise.all(e.map(async([i,o])=>{var l;const r=o-i+1;return this.db.find({selector:Ea((l=this.currentFilter)!=null?l:[]),skip:i,limit:r,sort:s,fields:["id","name"]}).then(a=>{for(let d=0;d<r;d+=1){const c=i+d;n.set(c,a.docs[d])}})})),n}}class Qh extends D1{constructor(e){super(`CommandHistoryStorage.${e}`)}setSearch(e){this.setFilters(e?[jh.makeFilterConfig([jh.makeFilterItem("name",q.contains,e)])]:[])}}const Zh=X.module("PouchCommandHistoryStorage");class M1{constructor(){this.updateTableMap=new Map}getUpdateTable(e){return this.updateTableMap.has(e)||this.updateTableMap.set(e,new Qh(e)),this.updateTableMap.get(e)}async getTable(e){return new Qh(e)}async addItem(e,n,s,i){return this.updateItem(e,{id:`${new Date().getTime()}`,name:s,data:i})}async updateItem(e,n){const s=this.getUpdateTable(e),i=await s.refreshItem(n.id),o={...i!=null?i:{},...n};return Zh.debug("Updating item",o),await s.put(o),Zh.debug("Update saved"),n}listenItem(e,n,s){return this.getUpdateTable(e).onItemUpdate(n,s)}}const qp="SET_LAYOUT_STORAGE",N1=t=>({type:qp,payload:t}),Yp="/ide/assets/community-wordmark-app.d2c5c1eb.svg";const _s=X.module("FormattingSectionContent");function F1(t){return t.formatString!=null}const at=class extends S.exports.PureComponent{constructor(t){super(t),this.getCachedColumnTypeOptions=ve(()=>at.renderColumnTypeOptions()),this.getCachedDateTimeFormatOptions=ve((c,u,m,p=!1,g)=>{const{timestampAtMenuOpen:f}=this.state;return at.renderDateTimeOptions(f,c,u,m,p,g)}),this.debouncedCommitChanges=je(this.commitChanges.bind(this),at.inputDebounceTime),this.handleDefaultDateTimeFormatChange=this.handleDefaultDateTimeFormatChange.bind(this),this.handleDefaultDecimalFormatChange=this.handleDefaultDecimalFormatChange.bind(this),this.handleDefaultIntegerFormatChange=this.handleDefaultIntegerFormatChange.bind(this),this.handleFormatRuleEntered=this.handleFormatRuleEntered.bind(this),this.handleFormatRuleChange=this.handleFormatRuleChange.bind(this),this.handleFormatRuleCreate=this.handleFormatRuleCreate.bind(this),this.handleFormatRuleDelete=this.handleFormatRuleDelete.bind(this),this.handleShowTimeZoneChange=this.handleShowTimeZoneChange.bind(this),this.handleShowTSeparatorChange=this.handleShowTSeparatorChange.bind(this),this.handleTimeZoneChange=this.handleTimeZoneChange.bind(this),this.handleResetDateTimeFormat=this.handleResetDateTimeFormat.bind(this),this.handleResetDecimalFormat=this.handleResetDecimalFormat.bind(this),this.handleResetIntegerFormat=this.handleResetIntegerFormat.bind(this),this.handleResetTimeZone=this.handleResetTimeZone.bind(this),this.handleTruncateNumbersWithPoundChange=this.handleTruncateNumbersWithPoundChange.bind(this);const{formatter:e,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,showTimeZone:o,showTSeparator:r,timeZone:l,truncateNumbersWithPound:a}=t,d=e.map((c,u)=>({...c,id:u}));this.containerRef=Y.createRef(),this.addFormatRuleButtonRef=Y.createRef(),this.lastFormatRuleIndex=d.length,this.state={formatSettings:d,formatRulesChanged:!1,showTimeZone:o,showTSeparator:r,timeZone:l,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,truncateNumbersWithPound:a,timestampAtMenuOpen:new Date}}static focusFirstInputInContainer(t){const e=t==null?void 0:t.querySelector("input, select, textarea");e&&e.focus()}static isSameOptions(t,e){return t.defaultFormatString===e.defaultFormatString}static isSameDecimalOptions(t,e){return at.isSameOptions(t,e)}static isSameIntegerOptions(t,e){return at.isSameOptions(t,e)}static isValidColumnName(t){return t!==""&&gs.isValidColumnName(t)}static isValidFormat(t,e){if(!t||e.formatString==null||!F1(e))return!1;switch(t){case"datetime":return dt.isValid(e);case"decimal":return Le.isValid(e);case"int":return it.isValid(e);default:return _s.warn("Trying to validate format of unknown type"),!0}}static removeFormatRuleExtraProps(t){const{id:e,isNewRule:n,...s}=t;return s}static isFormatRuleValidForSave(t){return at.isValidColumnName(t.columnName)&&at.isValidFormat(t.columnType,t.format)}static renderTimeZoneOptions(){return Dn.TIME_ZONES.map(e=>{const{label:n,value:s}=e;return h("option",{value:s,children:n},s)})}static renderColumnTypeOptions(){const e=[{value:L.dataType.DATETIME,label:"DateTime"},{value:L.dataType.DECIMAL,label:"Decimal"},{value:L.dataType.INT,label:"Integer"}].map(n=>h("option",{value:n.value,children:n.label},`key-columnType-${n.value}`));return v(ye,{children:[h("option",{disabled:!0,value:"",children:"Select Type"},"key-columnType-placeholder"),e]})}static renderDateTimeOptions(t,e,n,s,i,o){const r=new un([],{timeZone:e,showTimeZone:n,showTSeparator:s}),l=i?dt.getGlobalFormats(n,s):dt.getFormats(n,s);return o!=null&&!l.includes(o)&&l.unshift(o),l.map(a=>{const d=dt.makeFormat("",a,dt.TYPE_GLOBAL);return h("option",{value:a,children:r.getFormattedString(t,L.dataType.DATETIME,"",d)},a)})}componentDidMount(){at.focusFirstInputInContainer(this.containerRef.current)}componentWillUnmount(){this.debouncedCommitChanges.flush()}isDuplicateRule(t){var n;const{formatSettings:e}=this.state;return(n=e.some(s=>s.id!==t.id&&s.columnName===t.columnName&&s.columnType===t.columnType))!=null?n:!1}getAutoIncrementFormatRuleIndex(){const{lastFormatRuleIndex:t}=this;return this.lastFormatRuleIndex+=1,t}handleDefaultDateTimeFormatChange(t){_s.debug("handleDefaultDateTimeFormatChange",t.target.value),this.setState({defaultDateTimeFormat:t.target.value},()=>{this.debouncedCommitChanges()})}handleDefaultDecimalFormatChange(t){_s.debug("handleDefaultDecimalFormatChange",t.target.value),this.setState({defaultDecimalFormatOptions:{defaultFormatString:t.target.value}},()=>{this.debouncedCommitChanges()})}handleDefaultIntegerFormatChange(t){_s.debug("handleDefaultIntegerFormatChange",t.target.value),this.setState({defaultIntegerFormatOptions:{defaultFormatString:t.target.value}},()=>{this.debouncedCommitChanges()})}handleFormatRuleChange(t,e,n){this.setState(s=>{const{formatSettings:i}=s;P(i);const o=[...i];let r={};e==="columnType"&&(r={format:""});const l={...o[t],...r,[e]:n};return o[t]=l,{formatSettings:o}},()=>{this.debouncedCommitChanges()})}handleFormatRuleCreate(){this.setState(t=>{const{formatSettings:e}=t,n={columnType:L.dataType.DATETIME,columnName:"",format:{},id:this.getAutoIncrementFormatRuleIndex(),isNewRule:!0};return{formatSettings:e!=null?[...e,n]:[n],formatRulesChanged:!0}})}handleFormatRuleDelete(t){this.setState(e=>{const{formatSettings:n}=e;return{formatSettings:n.filter((i,o)=>o!==t),formatRulesChanged:!0}},()=>{this.debouncedCommitChanges()})}handleShowTimeZoneChange(){this.setState(t=>({showTimeZone:!t.showTimeZone}),()=>{this.debouncedCommitChanges()})}handleShowTSeparatorChange(){this.setState(t=>({showTSeparator:!t.showTSeparator}),()=>{this.debouncedCommitChanges()})}handleTimeZoneChange(t){this.setState({timeZone:t.target.value},()=>{this.debouncedCommitChanges()})}handleResetDateTimeFormat(){const{defaults:t}=this.props,{defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s}=t;_s.debug("handleResetDateTimeFormat"),this.setState({defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s},()=>{this.debouncedCommitChanges()})}handleResetTimeZone(){const{defaults:t}=this.props,{timeZone:e}=t;_s.debug("handleResetTimeZone"),this.setState({timeZone:e},()=>{this.debouncedCommitChanges()})}handleResetDecimalFormat(){const{defaults:t}=this.props,{defaultDecimalFormatOptions:e}=t;_s.debug("handleResetDecimalFormat"),this.setState({defaultDecimalFormatOptions:e},()=>{this.debouncedCommitChanges()})}handleResetIntegerFormat(){const{defaults:t}=this.props,{defaultIntegerFormatOptions:e}=t;_s.debug("handleResetIntegerFormat"),this.setState({defaultIntegerFormatOptions:e},()=>{this.debouncedCommitChanges()})}handleTruncateNumbersWithPoundChange(){this.setState(t=>({truncateNumbersWithPound:!t.truncateNumbersWithPound}),()=>{this.debouncedCommitChanges()})}handleFormatRuleEntered(t){this.scrollToFormatBlockBottom(),at.focusFirstInputInContainer(t)}commitChanges(){var m;const{formatSettings:t,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,defaultDecimalFormatOptions:o,defaultIntegerFormatOptions:r,truncateNumbersWithPound:l}=this.state,a=(m=t.filter(at.isFormatRuleValidForSave).map(at.removeFormatRuleExtraProps))!=null?m:[],{settings:d,saveSettings:c}=this.props,u={...d,formatter:a,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,truncateNumbersWithPound:l};at.isValidFormat(L.dataType.DECIMAL,Le.makeCustomFormat(o.defaultFormatString))&&(u.defaultDecimalFormatOptions=o),at.isValidFormat(L.dataType.INT,it.makeCustomFormat(r.defaultFormatString))&&(u.defaultIntegerFormatOptions=r),c(u)}scrollToFormatBlockBottom(){var e,n,s,i;const{scrollTo:t}=this.props;t(0,((n=(e=this.addFormatRuleButtonRef.current)==null?void 0:e.offsetHeight)!=null?n:0)+((i=(s=this.addFormatRuleButtonRef.current)==null?void 0:s.offsetTop)!=null?i:0))}getRuleError(t){const e={hasColumnNameError:!1,hasFormatError:!1,message:""},n=[];return t.isNewRule!==void 0&&t.isNewRule||(this.isDuplicateRule(t)&&(e.hasColumnNameError=!0,n.push("Duplicate column name/type combo.")),at.isValidColumnName(t.columnName)||(e.hasColumnNameError=!0,n.push("Column names must start with a letter or underscore and contain only alphanumeric characters or underscores.")),t.format.formatString!==void 0&&t.format.formatString.length===0?(e.hasFormatError=!0,n.push("Empty formatting rule.")):at.isValidFormat(t.columnType,t.format)||(e.hasFormatError=!0,n.push("Invalid formatting rule.")),e.message=n.join(`
43
+ `)),e}renderFormatRule(t,e){const n=`input-${t}-columnName`,s=`input-${t}-columnType`,i=`input-${t}-format`,o=this.getCachedColumnTypeOptions(),r=c=>this.handleFormatRuleChange(t,"columnName",c.target.value),l=()=>this.handleFormatRuleChange(t,"isNewRule",!1),a=c=>this.handleFormatRuleChange(t,"columnType",c.target.value),d=this.getRuleError(e);return v("fieldset",{className:"container-fluid format-rule-container",children:[v("div",{className:"form-row",children:[v("div",{className:"form-group col-7 mb-2",children:[h("label",{htmlFor:n,children:"Column Name"}),h("input",{id:n,className:W("form-control",{"is-invalid":d.hasColumnNameError}),"data-lpignore":!0,type:"text",value:e.columnName,onChange:r,onBlur:l})]}),v("div",{className:"form-group col mb-2",children:[h(z,{kind:"ghost",className:"btn-delete-format-rule float-right",tabIndex:-1,onClick:()=>this.handleFormatRuleDelete(t),icon:wn,tooltip:"Delete"}),h("label",{htmlFor:s,children:"Column Type"}),h("select",{id:s,className:"custom-select",value:e.columnType,onChange:a,children:o})]})]}),h("div",{className:"form-row",children:v("div",{className:"form-group col-12 d-flex mb-2",children:[h("label",{className:"flex-shrink-0 col-form-label mr-3",htmlFor:i,children:"Formatting Rule"}),this.renderFormatRuleInput(t,e.columnType,i,e.format,d.hasFormatError)]})}),h("div",{className:"form-row",children:h("div",{className:"form-group col-12 d-flex mb-2",children:d.message&&h("p",{className:"text-danger",children:d.message})})})]},t)}renderFormatRuleInput(t,e,n,s,i){switch(L.getNormalizedType(e)){case L.dataType.DATETIME:return this.renderDateTimeFormatRuleInput(t,n,s,i);case L.dataType.DECIMAL:return this.renderDecimalFormatRuleInput(t,n,s,i);case L.dataType.INT:return this.renderIntegerFormatRuleInput(t,n,s,i);default:return null}}renderDateTimeFormatRuleInput(t,e,n,s){var a;const{showTimeZone:i,showTSeparator:o,timeZone:r}=this.state,l=(a=n.formatString)!=null?a:"";return v("select",{className:W("custom-select",{"is-invalid":s}),value:l,id:e,onChange:d=>{const c=dt.makeFormat("",d.target.value,dt.TYPE_GLOBAL);this.handleFormatRuleChange(t,"format",c)},children:[h("option",{value:"",disabled:!0,children:"Select format"},"default"),this.getCachedDateTimeFormatOptions(r,i,o)]})}renderIntegerFormatRuleInput(t,e,n,s){var o;const i=(o=n.formatString)!=null?o:"";return h("input",{className:W("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:e,placeholder:it.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:r=>{const l=it.makeFormat("",r.target.value,it.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(t,"format",l)}})}renderDecimalFormatRuleInput(t,e,n,s){var o;const i=(o=n.formatString)!=null?o:"";return h("input",{className:W("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:e,placeholder:Le.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:r=>{const l=Le.makeFormat("",r.target.value,Le.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(t,"format",l)}})}render(){const{defaults:t}=this.props,{formatRulesChanged:e,formatSettings:n,defaultDateTimeFormat:s,defaultDecimalFormatOptions:i,defaultIntegerFormatOptions:o,timeZone:r,showTimeZone:l,showTSeparator:a,truncateNumbersWithPound:d}=this.state,{defaultFormatString:c=Le.DEFAULT_FORMAT_STRING}=i!=null?i:{},{defaultFormatString:u=it.DEFAULT_FORMAT_STRING}=o!=null?o:{},m=n.map((w,T)=>h(ut,{classNames:"fade",timeout:yt.transitionMs,onEnter:this.handleFormatRuleEntered,children:this.renderFormatRule(T,w)},w.id)),p=h(z,{kind:"ghost",className:"mb-3",onClick:this.handleFormatRuleCreate,ref:this.addFormatRuleButtonRef,icon:Ps,children:"Add New Rule"}),g=r===t.timeZone,f=a===t.showTSeparator&&l===t.showTimeZone&&s===t.defaultDateTimeFormat,b=at.isSameDecimalOptions(i,t.defaultDecimalFormatOptions),C=at.isSameIntegerOptions(o,t.defaultIntegerFormatOptions);return v("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:[v("div",{className:"container-fluid p-0",children:[h("div",{children:"Default formatting for column types"}),h("div",{className:"app-settings-menu-description mb-3",children:"Applies a formatting rule to all columns of a set type."}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"select-reset-timezone",children:"Time zone"}),h("div",{className:"col pr-0",children:h("select",{className:"custom-select",value:r,onChange:this.handleTimeZoneChange,id:"select-reset-timezone",children:at.renderTimeZoneOptions()})}),h("div",{className:"col-1 btn-col",children:h(z,{kind:"ghost",icon:ki,onClick:this.handleResetTimeZone,tooltip:"Reset Time Zone",className:W("btn-reset","btn-reset-time-zone",{hidden:g})})})]}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"select-default-time-format",children:"DateTime"}),h("div",{className:"col pr-0",children:h("select",{className:"custom-select",value:s,onChange:this.handleDefaultDateTimeFormatChange,id:"select-default-time-format",children:this.getCachedDateTimeFormatOptions(r,l,a,!0,s)})}),h("div",{className:"col-1 btn-col",children:h(z,{kind:"ghost",icon:ki,onClick:this.handleResetDateTimeFormat,tooltip:"Reset DateTime Options",className:W("btn-reset","btn-reset-date-time",{hidden:f})})})]}),h("div",{className:"form-row",children:h("div",{className:"offset-3 col-9",children:h(bt,{checked:l!=null?l:null,onChange:this.handleShowTimeZoneChange,children:"Show time zone in dates"})})}),h("div",{className:"form-row mb-3",children:h("div",{className:"offset-3 col-9",children:h(bt,{checked:a!=null?a:null,onChange:this.handleShowTSeparatorChange,children:"Show 'T' separator"})})}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"default-decimal-format-input",children:"Decimal"}),h("div",{className:"col pr-0",children:h("input",{className:W("form-control","flex-grow-1","default-decimal-format-input",{"is-invalid":!at.isValidFormat(L.dataType.DECIMAL,Le.makeCustomFormat(c))}),"data-lpignore":!0,placeholder:Le.DEFAULT_FORMAT_STRING,type:"text",id:"default-decimal-format-input",value:c,onChange:this.handleDefaultDecimalFormatChange})}),h("div",{className:"col-1 btn-col",children:h(z,{kind:"ghost",icon:ki,onClick:this.handleResetDecimalFormat,tooltip:"Reset Decimal Formatting",className:W("btn-reset","btn-reset-decimal",{hidden:b}),"data-testid":"btn-reset-decimal"})})]}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"default-integer-format-input",children:"Integer"}),h("div",{className:"col pr-0",children:h("input",{className:W("form-control","flex-grow-1","default-integer-format-input",{"is-invalid":!at.isValidFormat(L.dataType.INT,it.makeCustomFormat(u))}),"data-lpignore":!0,placeholder:it.DEFAULT_FORMAT_STRING,type:"text",id:"default-integer-format-input",value:u,onChange:this.handleDefaultIntegerFormatChange})}),h("div",{className:"col-1 btn-col",children:h(z,{kind:"ghost",icon:ki,onClick:this.handleResetIntegerFormat,tooltip:"Reset Integer Formatting",className:W("btn-reset","btn-reset-integer",{hidden:C}),"data-testid":"btn-reset-integer"})})]}),h("div",{className:"form-row mb-3",children:h("div",{className:"offset-3 col-9",children:h(bt,{checked:d!=null?d:null,onChange:this.handleTruncateNumbersWithPoundChange,children:"Truncate numbers with #"})})})]}),h("div",{children:"Default formatting for matched column names"}),h("div",{className:"app-settings-menu-description mb-3",children:"Applies a formatting rule to all columns that match a specified name and type."}),h(bg,{appear:e,enter:e,exit:e,children:m}),p]})}};let cc=at;cc.defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:dt.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:Le.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:it.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:dt.DEFAULT_TIME_ZONE_ID}};cc.inputDebounceTime=250;const x1=t=>({formatter:ES(t),defaultDateTimeFormat:wS(t),defaultDecimalFormatOptions:vS(t),defaultIntegerFormatOptions:TS(t),showTimeZone:yS(t),showTSeparator:IS(t),truncateNumbersWithPound:RS(t),timeZone:Ml(t),settings:Ft(t)}),_1=Nt(x1,{saveSettings:Td})(cc);function k1(){const[t,e]=S.exports.useState(!1),n=()=>{e(!t)};return v(z,{kind:"ghost",onClick:n,icon:xf,children:["Legal Notices",v($o,{isOpen:t,toggle:n,className:"theme-bg-light",children:[h(zo,{toggle:n,children:"Legal Notice"}),v(Wo,{children:[h("p",{children:"Deephaven software is protected by U.S. Patent Nos. 9,612,959; 9,613,018; 9,613,109; 9,619,210; 9,633,060; 9,639,570; 9,672,238; 9,679,006; 9,690,821; 9,710,511; 9,760,591; 9,805,084; 9,836,495; 9,836,494; 9,886,469; 9,898,496; 9,934,266; 10,002,153; 10,002,154; 10,002,155; 10,003,673; 10,019,138; 10,069,943; 10,176,211; 10,198,465; 10,198,466; 10,198,469; 10,212,257; 10,241,960; 10,241,965; 10,242,040; 10,242,041; 10,353,893; 10,346,394; 10,452,649; 10,496,639; 10,540,351; 10,552,412; 10,565,194; 10,565,206; 10,572,474; 10,621,168; 10,642,829; 10,657,184; 10,678,787; 10,691,686; and 10,783,191. Other patents pending."}),v("p",{children:["\xA9 2016-",new Date().getFullYear()," Deephaven Data Labs LLC. Patent Pending."]})]})]})]})}function al(t){const{children:e,isExpanded:n,sectionKey:s,title:i,onToggle:o}=t;return v(ye,{children:[h("div",{children:v(z,{kind:"ghost",className:"btn-collapse-trigger",onClick:()=>o(s),children:[h("div",{className:"flex-grow-1",children:i}),h("div",{className:"flex-shrink-0",children:h(j,{transform:n?"flip-v":"",icon:Gn})})]})}),h(gd,{in:n,autoFocusOnShow:!0,children:e})]})}al.propTypes={children:R.exports.node,isExpanded:R.exports.bool.isRequired,sectionKey:R.exports.string.isRequired,title:R.exports.node.isRequired,onToggle:R.exports.func};al.defaultProps={children:null,onToggle:()=>{}};function O1({shortcut:t,displayText:e,categoryName:n,onChange:s}){const[i,o]=S.exports.useState(e),[r,l]=S.exports.useState(t.getKeyState()),[a,d]=S.exports.useState(!1),[c,u]=S.exports.useState("");S.exports.useEffect(function(){o(e),l(t.getKeyState())},[e,t]),S.exports.useEffect(function(){o(Kt.getDisplayText(r)),t.matchesKeyState(r)&&d(!1)},[r,t]),S.exports.useEffect(function(){if(a){if(!Kt.isValidKeyState(r)){Kt.isAllowedKey(r.keyValue)?u("Must contain a modifier key"):u("Must contain an allowed action key");return}const y=Ae.getConflictingShortcuts(r).filter(E=>E.id.startsWith(n)&&E!==t).map(E=>E.name);if(y.length){u(`Conflicts with ${y.join(", ")}`);return}u("")}else u("")},[a,r,n,t]);function m(T){if(T.stopPropagation(),T.preventDefault(),t.isEditable&&!T.repeat){const y=Kt.getKeyStateFromEvent(T),E=Kt.createKeyState([me.BACKSPACE]);Kt.doKeyStatesMatch(y,E)?l(Kt.NULL_KEY_STATE):l(y)}}function p(T){T.stopPropagation(),T.preventDefault(),t.matchesKeyState(r)||d(!0)}function g(){We.disableAllActions()}function f(){We.enableAllActions()}function b(){t.setKeyState(r),d(!1),s(t)}function C(){const T=t.getKeyState();l(T),d(!1)}function w(){d(!0),l(t.getDefaultKeyState())}return v(ye,{children:[v("div",{className:"shortcut-item-container",children:[v("label",{className:"shortcut-item-name",children:[t.name,t.tooltip!==void 0&&h($e,{children:t.tooltip})]}),v("div",{className:"shortcut-item-input-container",children:[h("input",{className:W("form-control",{"is-invalid":c}),onKeyDown:m,onKeyUp:p,onFocus:g,onBlur:f,disabled:!t.isEditable,value:i,readOnly:!0}),!Kt.doKeyStatesMatch(r,t.getDefaultKeyState())&&!c&&h(z,{className:"reset-to-default-button",kind:"ghost",icon:h(j,{icon:ki,transform:{rotate:90,flipX:!0}}),tooltip:"Reset to default",onClick:w})]})]}),a&&v("div",{className:W("shortcut-item-message-container",{"is-invalid":c}),children:[h("div",{className:"shortcut-item-message",children:c}),v("div",{className:"shortcut-item-message-buttons",children:[Kt.isValidKeyState(r)&&h(z,{kind:"ghost",onClick:b,children:"Confirm"}),h(z,{kind:"ghost",onClick:C,children:"Undo"})]})]})]})}function L1({shortcutOverrides:t={},settings:e,saveSettings:n}){const s=S.exports.useCallback(l=>{const a=Kt.isMacPlatform,d={mac:{...t.mac},windows:{...t.windows}},c=a?d.mac:d.windows;l.forEach(u=>{u.isDefault()?delete c[u.id]:c[u.id]=u.getKeyState()}),n({...e,shortcutOverrides:d})},[e,n,t]);let i=Array.from(Ae.shortcutsByCategory.entries()).map(([l,a])=>({name:l,shortcuts:a}));const o=i.findIndex(l=>l.name.toUpperCase()==="GLOBAL"),r=i.splice(o,1);return i=i.concat(r),v(ye,{children:[h("div",{className:"app-settings-menu-description",children:"Customize shortcuts below. Assigning shortcuts that conflict with the browser or IDE shortcuts may cause unintended behavior"}),i.map(l=>h(A1,{name:l.name,shortcuts:l.shortcuts,saveShortcutOverrides:s},l.name))]})}function A1({name:t,shortcuts:e,saveShortcutOverrides:n}){function s(a){return a.split("_").map(d=>`${d[0].toUpperCase()}${d.slice(1).toLowerCase()}`).join(" ")}const[i,o]=S.exports.useState(e);function r(a){const d=i.filter(u=>u!==a&&!u.isNull()&&u.matchesKeyState(a.getKeyState()));d.forEach(u=>u.setToNull());const c=[a,...d];n(c),o(u=>[...u])}const l=S.exports.useMemo(()=>i.map(a=>a.getDisplayText()),[i]);return v("div",{className:"mt-3",children:[h("div",{className:"font-weight-bold",children:s(t)}),i.map((a,d)=>h(O1,{shortcut:a,displayText:l[d],categoryName:t,onChange:r},a.id))]})}const P1=t=>({settings:Ft(t),shortcutOverrides:DS(t)}),H1={saveSettings:Td},V1=Nt(P1,H1)(L1),Qa=new of,Za=new Gr(Qa);function U1(){X.setLogLevel(parseInt("2",10)),Qa.enable(),Za.enable(),window!=null&&(window.DHLog=X,window.DHLogProxy=Qa,window.DHLogHistory=Za)}const B1="yyyy-MM-dd-HHmmss";function Xp(t,e="root",n=new Map([[t,""]])){const s={};return Object.entries(t).forEach(([i,o])=>{try{JSON.stringify(o),s[i]=o}catch{const l=o;if(typeof o=="bigint")s[i]=o.toString();else if(n.has(l))s[i]=`Circular ref to ${n.get(l)}`;else{const a=`${e}.${i}`;n.set(l,a),s[i]=Xp(o,a,n)}}}),s}function $1(){const t=xl.getState();return JSON.stringify(Xp(t),null,2)}function W1(t){const e={uiVersion:"0.23.0",userAgent:navigator.userAgent,...t};return JSON.stringify(e,null,2)}async function z1(t=`${M.i18n.DateTimeFormat.format(B1,new Date)}_support_logs`,e){const n=new lu,s=n.folder(t);s.file("console.txt",Za.getFormattedHistory()),s.file("redux.json",$1()),s.file("metadata.json",W1(e));const i=await n.generateAsync({type:"blob"}),o=document.createElement("a");o.href=URL.createObjectURL(i),o.download=`${t}.zip`,o.click()}const si=class extends S.exports.Component{constructor(t){super(t),this.handleClose=this.handleClose.bind(this),this.handleScrollTo=this.handleScrollTo.bind(this),this.handleSectionToggle=this.handleSectionToggle.bind(this),this.handleExportSupportLogs=this.handleExportSupportLogs.bind(this),this.menuContentRef=Y.createRef(),this.state={expandedSectionKey:si.FORMATTING_SECTION_KEY}}static focusFirstInputInContainer(t){const e=t==null?void 0:t.querySelector("input, select, textarea");e&&e.focus()}componentDidMount(){si.focusFirstInputInContainer(this.menuContentRef.current)}isSectionExpanded(t){const{expandedSectionKey:e}=this.state;return e===t}handleScrollTo(t,e){var n;(n=this.menuContentRef.current)==null||n.scrollTo(t,e)}handleSectionToggle(t){this.setState(e=>({expandedSectionKey:e.expandedSectionKey===t?void 0:t}))}handleClose(){const{onDone:t}=this.props;t()}handleExportSupportLogs(){const{serverConfigValues:t}=this.props;z1(void 0,Object.fromEntries(t))}render(){const t="0.23.0",e="https://github.com/deephaven/web-client-ui/",n="https://deephaven.io/core/docs/",{serverConfigValues:s}=this.props,i=s.get("barrage.version"),o=s.get("java.version"),r=s.get("deephaven.version"),l=(a,d)=>v(ye,{children:[h("div",{children:a}),h("div",{children:d})]});return v("div",{className:"app-settings-menu",children:[v("header",{className:"app-settings-menu-header",children:[h("div",{className:"flex-spacer"}),h(z,{kind:"ghost",className:"btn-close-settings-menu",onClick:this.handleClose,icon:h(j,{icon:Xi,transform:"grow-4"}),tooltip:"Close"})]}),v("div",{className:"app-settings-menu-content",ref:this.menuContentRef,children:[h("h5",{children:"Settings"}),h("hr",{className:"my-0"}),h(al,{sectionKey:si.FORMATTING_SECTION_KEY,isExpanded:this.isSectionExpanded(si.FORMATTING_SECTION_KEY),title:v(ye,{children:[h(j,{icon:Gf,transform:"grow-4",className:"mr-2"}),"Formatting & Time zone"]}),onToggle:this.handleSectionToggle,children:h(_1,{scrollTo:this.handleScrollTo})}),h(al,{sectionKey:si.SHORTCUT_SECTION_KEY,isExpanded:this.isSectionExpanded(si.SHORTCUT_SECTION_KEY),title:v(ye,{children:[h(j,{icon:Vf,transform:"grow-2"})," ","Keyboard Shortcuts"]}),onToggle:this.handleSectionToggle,children:h(V1,{})}),v("div",{className:"app-settings-footer",children:[v("div",{className:"app-settings-footer-section",children:[v("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Support"}),v("div",{children:["GitHub:\xA0",h("a",{href:e,className:"custom-link",target:"_blank",rel:"noopener noreferrer",children:e})]}),h(z,{kind:"tertiary",className:"mt-2 py-2",onClick:this.handleExportSupportLogs,children:"Export Logs"})]}),v("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Documentation"}),h("a",{target:"_blank",rel:"noreferrer noopener",href:n,className:"custom-link",children:n})]}),v("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Version"}),v("span",{className:"d-inline-block text-muted",children:[r," ",h(j,{icon:Nf}),v($e,{interactive:!0,children:[v("div",{className:"detailed-server-config",children:[l("Engine Version",r),l("Web UI Version",t),l("Java Version",o),l("Barrage Version",i)]}),h(bl,{tooltip:"Copy version numbers",copy:`Engine Version: ${r}
44
44
  Web UI Version: ${t}
45
45
  Java Version: ${o}
46
- Barrage Version: ${i}`,children:"Copy Versions"})]})]})]}),h("div",{className:"app-settings-footer-item",children:h(_1,{})})]}),h("div",{className:"app-settings-footer-section",children:h("div",{className:"logo",children:h("a",{target:"_blank",rel:"noreferrer noopener",href:"https://deephaven.io",className:"d-inline-block custom-link p-1",children:h("img",{src:Yp,alt:"Deephaven Data Labs",width:"230px"})})})})]})]})]})}};let Jo=si;Jo.defaultProps={onDone:()=>{}};Jo.FORMATTING_SECTION_KEY="SettingsMenu.formatting";Jo.APPLICATION_SECTION_KEY="ApplicationMenu.settings";Jo.SHORTCUT_SECTION_KEY="SettingsMenu.shortcuts";const Jh=10;function Ai(t){const{forwardedProps:{menuItem:{action:e,title:n,disabled:s},iconElement:i,displayShortcut:o,isMouseSelected:r,isKeyboardSelected:l,closeMenu:a}}=t,d=S.exports.useRef(),c=S.exports.useRef(),u=S.exports.useRef(null),[m,p]=S.exports.useState(!1),g=S.exports.useCallback(C=>{d.current!=null&&c.current!=null&&u.current&&(Math.abs(d.current-C.clientX)>=Jh||Math.abs(c.current-C.clientY)>=Jh)&&(p(!0),window.removeEventListener("mousemove",g),a(),e(C),u.current=null)},[e,a]);function f(C){d.current=C.clientX,c.current=C.clientY,u.current=C.target,window.addEventListener("mousemove",g)}function b(C){u.current===C.target&&(p(!0),a(),e(),window.removeEventListener("mousemove",g)),u.current=null}return S.exports.useEffect(function(){return function(){return window.removeEventListener("mousemove",g)}},[g]),v("button",{type:"button",className:W("btn-context-menu",{disabled:s},{active:r&&!s},{"keyboard-active":l&&!s}),onMouseDown:f,onMouseUp:b,disabled:m,children:[h("span",{className:W("icon"),children:i}),h("span",{className:"title",children:n}),h("span",{className:"shortcut",children:o})]})}function hc(t){const{handleControlSelect:e,handleToolSelect:n,onClearFilter:s}=t,i=S.exports.useMemo(()=>[{title:"Input Filter",icon:iC,menuElement:h(Ai,{}),action:o=>{e(Cn.INPUT_FILTER,o)},order:10},{title:"Dropdown Filter",icon:vu,menuElement:h(Ai,{}),action:o=>{e(Cn.DROPDOWN_FILTER,o)},order:15},{title:"Markdown Widget",icon:Lf,menuElement:h(Ai,{}),action:o=>{e(Cn.MARKDOWN,o)},order:20},{title:"Filter Sets",icon:Da,menuElement:h(Ai,{}),action:o=>{e(Cn.FILTER_SET_MANAGER,o)},order:25},{disabled:!0,menuElement:h("div",{className:"context-menu-group-header",children:"Tools"}),order:30},{title:"Linker",icon:ld,action:()=>{n(hn.LINKER)},order:40,shortcut:ms.LINKER},{disabled:!0,menuElement:h("div",{className:"context-menu-group-header",children:"Actions"}),order:50},{title:"Clear All Filters",icon:eC,action:()=>{s()},order:60,shortcut:dn.TABLE.CLEAR_ALL_FILTERS}],[e,n,s]);return h(Fn,{popperClassName:"controls-menu-popper",actions:i})}hc.propTypes={handleControlSelect:R.exports.func,handleToolSelect:R.exports.func,onClearFilter:R.exports.func};hc.defaultProps={handleControlSelect:()=>{},handleToolSelect:()=>{},onClearFilter:()=>{}};Ai.propTypes={forwardedProps:R.exports.shape({iconElement:R.exports.node,displayShortcut:R.exports.string,isMouseSelected:R.exports.bool.isRequired,isKeyboardSelected:R.exports.bool.isRequired,closeMenu:R.exports.func.isRequired,menuItem:R.exports.shape({action:R.exports.func,title:R.exports.string,disabled:R.exports.bool}).isRequired})};Ai.defaultProps={forwardedProps:null};const z1=Hs(qp,null),G1={layoutStorage:z1},K1=t=>t.layoutStorage,q1=t=>t.serverConfigValues;Object.entries(G1).map(([t,e])=>eo.register(t,e));const eu=10;function Y1(t){const{onExportLayout:e,onImportLayout:n,onResetLayout:s,onSelect:i,widgets:o=[]}=t,[r,l]=S.exports.useState(!1),[a,d]=S.exports.useState(""),c=S.exports.useRef(null),u=S.exports.useRef(),m=S.exports.useCallback((y,E)=>{y!=null&&i(y,E)},[i]),p=S.exports.useCallback(y=>{d(y.target.value)},[]),g=S.exports.useCallback(y=>{u.current!=null&&(Math.abs(u.current.x-y.clientX)>=eu||Math.abs(u.current.y-y.clientY)>=eu)&&(l(!0),window.removeEventListener("mousemove",g),m(u.current.widget,y),u.current=void 0)},[u,m]),f=S.exports.useCallback((y,E)=>{u.current={x:y.clientX,y:y.clientY,widget:E},window.addEventListener("mousemove",g)},[g]),b=S.exports.useCallback((y,E)=>{var I;window.removeEventListener("mousemove",g),((I=u.current)==null?void 0:I.widget)===E&&(l(!0),m(E)),u.current=void 0},[g,u,m]),C=S.exports.useMemo(()=>o.filter(y=>{var E;return a?(E=y.name)==null?void 0:E.toLowerCase().includes(a.toLowerCase()):!0}),[a,o]).sort((y,E)=>{var I,D,F;return(F=(D=y.name)==null?void 0:D.localeCompare((I=E.name)!=null?I:""))!=null?F:0}),w=S.exports.useMemo(()=>C.map(y=>{var E,I;return h("li",{children:v(z,{kind:"ghost","data-testid":`panel-list-item-${(E=y.name)!=null?E:""}-button`,onMouseDown:D=>{f(D,y)},onMouseUp:D=>{b(D,y)},onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&m(y)},disabled:r,onClick:()=>{},children:[h(Gu,{type:y.type})," ",(I=y.name)!=null?I:""]})},y.name)}),[C,r,f,b,m]),T=S.exports.useMemo(()=>w.length===0?h("span",{children:"No bound variables found."}):null,[w]);return v("div",{className:"widget-list-container d-flex flex-column",children:[h("div",{className:"widget-list-header",children:h(Cs,{value:a,placeholder:"Find Table, Plot or Widget",onChange:p,ref:c})}),v("ul",{className:"widget-list flex-grow-1",children:[T&&h("li",{className:"widget-list-message",children:T}),!T&&w]}),h("div",{children:h("hr",{})}),v("div",{className:"widget-list-footer",children:[v(z,{kind:"ghost",onClick:e,children:[v("div",{className:"fa-md fa-layers",children:[h(j,{mask:Ma,icon:Dc,transform:"right-5 down-5"}),h(j,{icon:Dc,transform:"right-8 down-6"})]}),"Export Layout"]}),v(z,{kind:"ghost",onClick:n,children:[v("div",{className:"fa-md fa-layers",children:[h(j,{mask:Ma,icon:Ra,transform:"right-5 down-5"}),h(j,{icon:Ra,transform:"right-8 down-6"})]}),"Import Layout"]}),h(z,{kind:"ghost",icon:ki,onClick:s,tooltip:"Reset Layout"})]})]})}const X1=async(t,e,n)=>{let s,i,o,r;if(Hr(e)?(s=e.settings,i=e.table,o=void 0,r=e.tableSettings):(s={},i="",o=e.figure,r={}),n!==void 0&&(n.tableSettings!=null&&(r=n.tableSettings),n.table!=null&&(i=n.table),n.figure!=null&&(o=n.figure),n.settings!=null&&(s={...s,...n.settings})),o!==void 0){const d={title:o,name:o,type:M.VariableType.FIGURE},c=await t.getObject(d);return zi.makeModel(s,c)}const l={title:o,name:i,type:M.VariableType.TABLE},a=await t.getObject(l);return te.applyTableSettings(a,r,Ml(xl.getState())),zi.makeModelFromSettings(s,a)},j1=async(t,e,n=M.VariableType.TABLE)=>{const{table:s}=e,i={title:s,name:s,type:n},o=await t.getObject(i);return qd.makeModel(o)};function Q1({onAutoFillClick:t=()=>{}}){return v("div",{className:"empty-dashboard-container",children:[v("div",{className:"hint-container",children:[h(j,{icon:gf})," ",h("br",{}),"Use the panel list to add objects from a query."]}),v("div",{className:"empty-dashboard",children:[h("div",{className:"add-panels-hint",children:"Drag Panels Here"}),h(z,{kind:"tertiary",onClick:t,children:"Auto fill objects"})]})]})}function Z1(t){return t.version===2}function J1(t){return Array.isArray(t)}const _r=X.module("UserLayoutUtils"),e2={layoutConfig:[{type:"column",content:[{type:"row",height:40,content:[{type:"stack",content:[{type:"react-component",component:Li.COMPONENT,title:Li.TITLE,isClosable:!1},{type:"react-component",component:ll.COMPONENT,title:ll.TITLE,isClosable:!1}]},{type:"stack",width:25,content:[{type:"react-component",component:il.COMPONENT,title:il.TITLE,isClosable:!1},{type:"react-component",component:ol.COMPONENT,title:ol.TITLE,isClosable:!1}]}]},{type:"row",content:[{type:"stack",title:"Notebooks",content:[]}]}]}],links:[],filterSets:[],version:2},t2={layoutConfig:[],links:[],filterSets:[],version:2};function jp(t){if(Z1(t))return t;if(J1(t))return{layoutConfig:t,links:[],filterSets:[],version:2};throw new Error(`Unexpected layout import format: ${t}`)}async function n2(t,e=!0){try{const n=await t.getLayouts();if(n.length>0)try{const s=await t.getLayout(n[0]);return jp(s)}catch(s){_r.error("Unable to load layout",n[0],":",s),_r.warn("No valid layouts found, falling back to default layout")}}catch(n){_r.error("Unable to fetch layout list",n),_r.warn("Falling back to default layout")}return e?e2:t2}function s2(t){const{filterSets:e,layoutConfig:n,links:s}=t;return{filterSets:e,layoutConfig:n,links:s,version:2}}const Wr={exportLayout:s2,getDefaultLayout:n2,normalizeLayout:jp},kr=X.module("DownloadServiceWorkerUtils"),Qp=class{static registerOnLoaded(){new URL("/ide/",window.location.href).origin===window.location.origin&&("serviceWorker"in navigator?window.addEventListener("load",()=>{const e=new URL("/ide/download/serviceWorker.js",window.location.href);navigator.serviceWorker.register(e).then(n=>{n.update(),kr.info("Registering service worker on ",e,n)}).catch(n=>{kr.error("Failed to register service worker",n)})}):kr.info("Service worker is not supported."))}static async getServiceWorker(){if("serviceWorker"in navigator){const e=(await navigator.serviceWorker.getRegistrations()).find(n=>n.scope.endsWith(Qp.DOWNLOAD_PATH));if(e&&e.active)return kr.info("Download service worker is active."),e.active;throw new Error("Can not find download service worker.")}throw new Error("Download service worker is not available.")}static unregisterSW(){}};let dl=Qp;dl.DOWNLOAD_PATH="/download/";const Zp={react:Y},i2=Sg(Zp),o2=wg({requires:i2}),r2=vg.createRequires(Zp),l2=Tg({requires:r2}),a2=X.module("PluginUtils");class Ja{static loadComponentPlugin(e){if("".split(",").includes(e)){const o=Y.lazy(()=>Dg(()=>import(`./internal/${e}`),[])),r=Y.forwardRef((l,a)=>h(S.exports.Suspense,{fallback:h("div",{children:"Loading Plugin..."}),children:h(o,{ref:a,...l})}));return r.pluginName=e,r.displayName="Local Plugin",r}const n=new URL("/ide/plugins/",`${window.location}`),s=new URL(`${e}.js`,n),i=Y.forwardRef((o,r)=>h(o2,{url:s,render:({err:l,Component:a})=>{if(l!=null&&l!==""){const d=`Error loading plugin ${e} from ${s} due to ${l}`;return a2.error(d),h("div",{className:"error-message",children:`${d}`})}return h(a,{ref:r,...o})}}));return i.pluginName=e,i.displayName="Plugin",i}static async loadModulePlugin(e){return await l2(e)}static async loadJson(e){return new Promise((n,s)=>{const i=new XMLHttpRequest;i.addEventListener("load",()=>{try{const o=JSON.parse(i.responseText);n(o)}catch(o){s(o)}}),i.addEventListener("error",o=>{s(o)}),i.open("GET",e),i.send()})}}const At=X.module("AppMainContainer");class Lo extends S.exports.Component{constructor(e){super(e),this.getDashboardPlugins=pe(n=>[...n.entries()].filter(([,s])=>s.DashboardPlugin!=null).map(([s,{DashboardPlugin:i}])=>h(i,{},s))),this.handleSettingsMenuHide=this.handleSettingsMenuHide.bind(this),this.handleSettingsMenuShow=this.handleSettingsMenuShow.bind(this),this.handleError=this.handleError.bind(this),this.handleControlSelect=this.handleControlSelect.bind(this),this.handleToolSelect=this.handleToolSelect.bind(this),this.handleClearFilter=this.handleClearFilter.bind(this),this.handleDataChange=this.handleDataChange.bind(this),this.handleAutoFillClick=this.handleAutoFillClick.bind(this),this.handleGoldenLayoutChange=this.handleGoldenLayoutChange.bind(this),this.handleLayoutConfigChange=this.handleLayoutConfigChange.bind(this),this.handleExportLayoutClick=this.handleExportLayoutClick.bind(this),this.handleImportLayoutClick=this.handleImportLayoutClick.bind(this),this.handleImportLayoutFiles=this.handleImportLayoutFiles.bind(this),this.handleLoadTablePlugin=this.handleLoadTablePlugin.bind(this),this.handleResetLayoutClick=this.handleResetLayoutClick.bind(this),this.handleWidgetMenuClick=this.handleWidgetMenuClick.bind(this),this.handleWidgetsMenuClose=this.handleWidgetsMenuClose.bind(this),this.handleWidgetSelect=this.handleWidgetSelect.bind(this),this.handlePaste=this.handlePaste.bind(this),this.hydrateChart=this.hydrateChart.bind(this),this.hydrateGrid=this.hydrateGrid.bind(this),this.hydratePandas=this.hydratePandas.bind(this),this.hydrateDefault=this.hydrateDefault.bind(this),this.openNotebookFromURL=this.openNotebookFromURL.bind(this),this.importElement=Y.createRef(),this.state={contextActions:[{action:()=>{this.handleToolSelect(hn.LINKER)},shortcut:ms.LINKER,isGlobal:!0},{action:()=>{this.sendClearFilter()},shortcut:dn.TABLE.CLEAR_ALL_FILTERS,isGlobal:!0},{action:()=>{At.debug("Consume unhandled save shortcut")},shortcut:ms.SAVE,isGlobal:!0}],isPanelsMenuShown:!1,isSettingsMenuShown:!1,widgets:[]}}static handleWindowBeforeUnload(e){e.preventDefault(),e.returnValue=""}static hydrateConsole(e,n){return Ua.hydrate({...e,unzip:s=>lu.loadAsync(s).then(i=>Object.values(i.files))},n)}componentDidMount(){this.initWidgets(),window.addEventListener("beforeunload",Lo.handleWindowBeforeUnload)}componentDidUpdate(e){const{dashboardData:n}=this.props;e.dashboardData!==n&&this.handleDataChange(n)}componentWillUnmount(){this.deinitWidgets(),window.removeEventListener("beforeunload",Lo.handleWindowBeforeUnload)}initWidgets(){const{connection:e}=this.props;if(e.subscribeToFieldUpdates==null){At.warn("subscribeToFieldUpdates not supported, not initializing widgets");return}this.widgetListenerRemover=e.subscribeToFieldUpdates(n=>{At.debug("Got updates",n),this.setState(({widgets:s})=>{const{updated:i,created:o,removed:r}=n,l=[...i,...r],a=s.filter(c=>!l.some(u=>u.name===c.name));return[...i,...o].forEach(c=>{c.name!=null&&c.name!==""&&a.push(c)}),{widgets:a}})})}deinitWidgets(){var e;(e=this.widgetListenerRemover)==null||e.call(this)}openNotebookFromURL(){const{match:e}=this.props,{notebookPath:n}=e.params;if(n){const{session:s,sessionConfig:i}=this.props;if(s==null||i==null){At.error("No session available to open notebook URL",n);return}const o={id:`/${n}`,itemName:`/${n}`},r=i.type,l={value:null,language:r};this.emitLayoutEvent(He.SELECT_NOTEBOOK,s,r,l,o,!0)}}sendClearFilter(){this.emitLayoutEvent(Pe.CLEAR_ALL_FILTERS)}emitLayoutEvent(e,...n){var s;(s=this.goldenLayout)==null||s.eventHub.emit(e,...n)}handleError(e){Te.isCanceled(e)||At.error(e)}handleSettingsMenuHide(){this.setState({isSettingsMenuShown:!1})}handleSettingsMenuShow(){this.setState({isSettingsMenuShown:!0})}handleControlSelect(e,n=null){switch(At.debug("handleControlSelect",e),e){case Cn.DROPDOWN_FILTER:this.emitLayoutEvent(Pe.OPEN_DROPDOWN,{title:"DropdownFilter",type:e,createNewStack:!0,dragEvent:n});break;case Cn.INPUT_FILTER:this.emitLayoutEvent(Pe.OPEN_INPUT,{title:"InputFilter",type:e,createNewStack:!0,dragEvent:n});break;case Cn.MARKDOWN:this.emitLayoutEvent(Dp.OPEN,{title:"Markdown",type:e,dragEvent:n});break;case Cn.FILTER_SET_MANAGER:this.emitLayoutEvent(Pe.OPEN_FILTER_SET_MANAGER,{title:"FilterSets",type:e,dragEvent:n});break;default:throw new Error(`Unrecognized control type ${e}`)}}handleToolSelect(e){At.debug("handleToolSelect",e);const{activeTool:n,setActiveTool:s}=this.props;s(n===e?hn.DEFAULT:e)}handleClearFilter(){this.sendClearFilter()}handleDataChange(e){const{updateWorkspaceData:n}=this.props,{closed:s,filterSets:i,links:o}=e;n({closed:s,filterSets:i,links:o})}handleGoldenLayoutChange(e){this.goldenLayout=e}handleLayoutConfigChange(e){const{updateWorkspaceData:n}=this.props;n({layoutConfig:e})}handleWidgetMenuClick(){this.setState(({isPanelsMenuShown:e})=>({isPanelsMenuShown:!e}))}handleWidgetSelect(e,n){this.setState({isPanelsMenuShown:!1}),At.debug("handleWidgetSelect",e,n),this.openWidget(e,n)}handleWidgetsMenuClose(){this.setState({isPanelsMenuShown:!1})}handleAutoFillClick(){const{widgets:e}=this.state;At.debug("handleAutoFillClick",e);const n=e.sort((s,i)=>s.title!=null&&i.title!=null?s.title.localeCompare(i.title):0);for(let s=0;s<n.length;s+=1)this.openWidget(n[s])}handleExportLayoutClick(){At.info("handleExportLayoutClick"),this.setState({isPanelsMenuShown:!1});try{const{workspace:e}=this.props,{data:n}=e,s=Wr.exportLayout(n);At.info("handleExportLayoutClick exportedConfig",s);const i=new Blob([JSON.stringify(s)],{type:"application/json"}),o=M.i18n.DateTimeFormat.format("yyyy-MM-dd-HHmmss",new Date),r=document.createElement("a");r.href=URL.createObjectURL(i),r.download=`deephaven-app-layout-${o}.json`,r.click()}catch(e){At.error("Unable to export layout",e)}}handleImportLayoutClick(){At.info("handleImportLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.importElement.current!=null&&(this.importElement.current.value="",this.importElement.current.click())}handleResetLayoutClick(){At.info("handleResetLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.resetLayout()}handleImportLayoutFiles(e){var n;e.stopPropagation(),e.preventDefault(),e.target.files!=null&&this.importLayoutFile((n=e.target.files)==null?void 0:n[0])}async importLayoutFile(e){try{const{updateDashboardData:n,updateWorkspaceData:s}=this.props,i=await e.text(),o=JSON.parse(i),{filterSets:r,layoutConfig:l,links:a}=Wr.normalizeLayout(o);s({layoutConfig:l}),n(Mn,{filterSets:r,links:a})}catch(n){At.error("Unable to import layout",n)}}async resetLayout(){const{layoutStorage:e,session:n}=this.props,{filterSets:s,layoutConfig:i,links:o}=await Wr.getDefaultLayout(e,n!==void 0),{updateDashboardData:r,updateWorkspaceData:l}=this.props;l({layoutConfig:i}),r(Mn,{filterSets:s,links:o})}handlePaste(e){let n=e.currentTarget.parentElement;for(;n!=null;){if(n.classList.contains("monaco-editor"))return;n=n.parentElement}const{clipboardData:s}=e,i=s.getData("Text"),o=/“|”/g;o.test(i)&&(e.preventDefault(),e.stopPropagation(),document.execCommand("insertText",!1,i.replace(o,'"')))}handleLoadTablePlugin(e){const{plugins:n}=this.props,s=n.get(e);return s!=null&&s.TablePlugin!=null?s.TablePlugin:Ja.loadComponentPlugin(e)}hydrateDefault(e,n){const{connection:s}=this.props,{metadata:i}=e;if((i==null?void 0:i.type)!=null&&((i==null?void 0:i.id)!=null||(i==null?void 0:i.name)!=null)){const o=i.id!=null?{type:i.type,id:i.id}:{type:i.type,name:i.name,title:i.name};return{fetch:()=>s.getObject(o),localDashboardId:n,...e}}return Ua.hydrate(e,n)}hydrateGrid(e,n){return this.hydrateTable(e,n,M.VariableType.TABLE)}hydratePandas(e,n){return this.hydrateTable(e,n,M.VariableType.PANDAS)}hydrateTable(e,n,s=M.VariableType.TABLE){const{connection:i}=this.props;return{...e,getDownloadWorker:dl.getServiceWorker,loadPlugin:this.handleLoadTablePlugin,localDashboardId:n,makeModel:()=>j1(i,e.metadata,s)}}hydrateChart(e,n){const{connection:s}=this.props;return{...e,localDashboardId:n,makeModel:()=>{const{metadata:i,panelState:o}=e;return X1(s,i,o)}}}openWidget(e,n){const{connection:s}=this.props;this.emitLayoutEvent(Ne.OPEN,{dragEvent:n,fetch:()=>s.getObject(e),widget:e})}render(){const{activeTool:e,plugins:n,user:s,workspace:i,serverConfigValues:o}=this.props,{data:r}=i,{layoutConfig:l}=r,{permissions:a}=s,{canUsePanels:d}=a,{contextActions:c,isPanelsMenuShown:u,isSettingsMenuShown:m,widgets:p}=this.state,g=this.getDashboardPlugins(n);return v("div",{className:W("app-main-tabs","w-100","h-100","d-flex","flex-column",e?`active-tool-${e.toLowerCase()}`:""),onPaste:this.handlePaste,tabIndex:-1,children:[h("nav",{className:"nav-container",children:v("div",{className:"app-main-top-nav-menus",children:[h("img",{src:Yp,alt:"Deephaven Data Labs",width:"115px",className:"ml-1"}),v("div",{children:[v(z,{kind:"ghost",className:"btn-panels-menu",icon:cC,onClick:()=>{},children:["Controls",h(hc,{handleControlSelect:this.handleControlSelect,handleToolSelect:this.handleToolSelect,onClearFilter:this.handleClearFilter})]}),d&&v(z,{kind:"ghost",className:"btn-panels-menu btn-show-panels","data-testid":"app-main-panels-button",onClick:this.handleWidgetMenuClick,icon:rC,children:["Panels",h(kn,{isShown:u,className:"panels-menu-popper",onExited:this.handleWidgetsMenuClose,closeOnBlur:!0,interactive:!0,children:h(Y1,{widgets:p,onExportLayout:this.handleExportLayoutClick,onImportLayout:this.handleImportLayoutClick,onResetLayout:this.handleResetLayoutClick,onSelect:this.handleWidgetSelect})})]}),h(z,{kind:"ghost",className:W("btn-settings-menu",{"text-warning":s.operateAs!==s.name}),onClick:this.handleSettingsMenuShow,icon:h(j,{icon:Go,transform:"grow-3 right-1 down-1"}),tooltip:"User Settings"})]})]})}),v(Iw,{emptyDashboard:h(Q1,{onAutoFillClick:this.handleAutoFillClick}),id:Mn,layoutConfig:l,onGoldenLayoutChange:this.handleGoldenLayoutChange,onLayoutConfigChange:this.handleLayoutConfigChange,onLayoutInitialized:this.openNotebookFromURL,hydrate:this.hydrateDefault,children:[h(l1,{hydrate:this.hydrateGrid,getDownloadWorker:dl.getServiceWorker,loadPlugin:this.handleLoadTablePlugin}),h(t1,{hydrate:this.hydrateChart}),h(n1,{}),h(i1,{hydrateConsole:Lo.hydrateConsole,notebooksUrl:new URL("/notebooks/",`${window.location}`).href}),h(o1,{}),h(g1,{hydrate:this.hydratePandas}),h(p1,{}),h(m1,{}),g]}),h(ut,{in:m,timeout:yt.transitionMidMs,classNames:"slide-left",mountOnEnter:!0,unmountOnExit:!0,children:h(Jo,{serverConfigValues:o,onDone:this.handleSettingsMenuHide})}),h(oe,{actions:c}),h("input",{ref:this.importElement,type:"file",accept:".json",style:{display:"none"},onChange:this.handleImportLayoutFiles})]})}}const d2=t=>{var e,n;return{activeTool:Nl(t),dashboardData:jt(t,Mn),layoutStorage:K1(t),plugins:NS(t),connection:mE(t,Mn),session:(e=gi(t,Mn))==null?void 0:e.session,sessionConfig:(n=gi(t,Mn))==null?void 0:n.config,user:gm(t),workspace:Dl(t),serverConfigValues:q1(t)}},c2=Nt(d2,{setActiveTool:Fl,updateDashboardData:Xn,updateWorkspaceData:Dm})(Eg(Lo));function h2(){return v("div",{className:"app",children:[h(c2,{}),h(Du,{})]})}const u2=X.module("LocalWorkspaceStorage"),Fo=class{static async makeDefaultWorkspaceData(t,e){const{filterSets:n,links:s,layoutConfig:i}=await Wr.getDefaultLayout(t,e==null?void 0:e.isConsoleAvailable);return{settings:{defaultDateTimeFormat:dt.DEFAULT_DATETIME_FORMAT_STRING,formatter:[],timeZone:dt.DEFAULT_TIME_ZONE_ID,showTimeZone:!1,showTSeparator:!0,disableMoveConfirmation:!1,defaultDecimalFormatOptions:{defaultFormatString:Le.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:it.DEFAULT_FORMAT_STRING},truncateNumbersWithPound:!1,defaultNotebookSettings:{isMinimapEnabled:!1}},layoutConfig:i,closed:[{}],links:s,filterSets:n}}static async makeDefaultWorkspace(t,e){return{data:await Fo.makeDefaultWorkspaceData(t,e)}}constructor(t){this.layoutStorage=t}async load(t){var e;try{return JSON.parse((e=localStorage.getItem(Fo.STORAGE_KEY))!=null?e:"")}catch{return u2.info("Unable to load workspace data, initializing to default data"),Fo.makeDefaultWorkspace(this.layoutStorage,t)}}async save(t){return localStorage.setItem(Fo.STORAGE_KEY,JSON.stringify(t)),t}};let Jp=Fo;Jp.STORAGE_KEY="deephaven.WorkspaceStorage";class m2 extends Error{constructor(){super(...arguments),this.isNoConsolesError=!0}}function p2(t){return t.isNoConsolesError}const Pi=X.module("SessionUtils");function g2(){return new URL("/jsapi",`${window.location}`)}function eg(){const t=g2();return`${t.protocol}//${t.host}`}function f2(){const t=eg();return Pi.info(`Starting connection to '${t}'...`),new M.IdeConnection(t)}async function C2(t){Pi.info("Getting console types...");const e=await t.getConsoleTypes();if(Pi.info("Available types:",e),e.length===0)throw new m2("No console types available");const n=e[0];Pi.info("Starting session with type",n);const s=await t.startSession(n),i={type:n,id:ze.generate()};return Pi.info("Console session established",i),{session:s,config:i,connection:t}}function b2(){const t=eg();return Pi.info("createCoreClient",t),new M.CoreClient(t)}class S2{constructor(e,n=""){this.storageService=e,this.root=n}async getLayouts(){return(await this.storageService.listItems(this.root,"*.json")).map(n=>n.basename)}async getLayout(e){const s=await(await this.storageService.loadFile(`${this.root}/${e}`)).text();return JSON.parse(s)}}const To=X.module("GrpcFileStorageTable"),ed=class{constructor(t,e="",n=e){this.currentSize=0,this.listeners=[],this.childTables=new Map,this.storageService=t,this.baseRoot=e,this.root=n,n===e&&(this.doRefresh=je(this.doRefresh.bind(this),ed.REFRESH_DEBOUNCE))}removeBaseRoot(t){return ce.removeRoot(this.baseRoot,t)}getViewportData(){var t;return this.viewportUpdatePromise||this.refreshInternal(),(t=this.viewportUpdatePromise)!=null?t:Promise.resolve({items:[],offset:0})}getSnapshot(t){throw new Error("Method not implemented.")}get size(){return this.currentSize}setExpanded(t,e){const n=t.split("/");let s=n.shift();if((s===void 0||s==="")&&(s=n.shift()),s===void 0||s==="")throw new Error(`Invalid path: ${t}`);const i=n.join("/");if(e){if(!this.childTables.has(s)){const o=new ed(this.storageService,this.baseRoot,`${this.root}/${s}`);this.childTables.set(s,o)}if(i){const o=this.childTables.get(s);o==null||o.setExpanded(i,e)}}else if(this.childTables.has(s))if(i){const o=this.childTables.get(s);o==null||o.setExpanded(i,e)}else this.childTables.delete(s);this.currentViewport&&this.refreshInternal()}collapseAll(){this.childTables.clear(),this.currentViewport&&this.refreshInternal()}setSearch(t){throw new Error("Method not implemented.")}setViewport(t){this.currentViewport=t,this.refreshInternal()}setFilters(){throw new Error("Method not implemented.")}setSorts(){throw new Error("Method not implemented.")}setReversed(){throw new Error("Method not implemented.")}close(){this.listeners=[]}onUpdate(t){return this.listeners=[...this.listeners,t],()=>{this.listeners=this.listeners.filter(e=>e!==t)}}doRefresh(t){To.debug2("doRefresh",this.root),t(this.fetchData())}refresh(){var n;To.debug2("refresh",this.root),(n=this.viewportUpdatePromise)==null||n.cancel();const t=new Promise(s=>{this.doRefresh(s)}),e=Te.makeCancelable(t.then(s=>{if(this.viewportUpdatePromise!==e)throw new di;return this.currentViewportData=s,this.sendUpdate(),s}));e.catch(s=>{Te.isCanceled(s)||To.error("Error updating viewport",s)}),this.viewportUpdatePromise=e}refreshInternal(){try{this.refresh()}catch(t){Te.isCanceled(t)||To.error("Unable to refresh data",t)}}async fetchData(){const{currentViewport:t}=this;if(!t)throw new Error("No viewport set");let n=(await this.storageService.listItems(this.root)).map(s=>({type:s.type,filename:this.removeBaseRoot(s.filename),basename:s.basename,id:this.removeBaseRoot(s.filename),isExpanded:s.type==="directory"?this.childTables.has(s.basename):void 0})).sort((s,i)=>s.type!==i.type?s.type==="directory"?-1:1:s.basename.localeCompare(i.basename));for(let s=0;s<n.length;s+=1){const i=n[s],{basename:o,filename:r}=i;if(r===this.removeBaseRoot(`${this.root}/${o}`)&&i.type==="directory"){const l=this.childTables.get(o);if(l!=null){l.setViewport({top:0,bottom:t.bottom-s});const a=await l.getViewportData();n.splice(s+1,0,...a.items)}}}return this.currentSize=n.length,To.debug2(this.root,"items",n,t),n=n.slice(t.top,t.bottom),{items:n,offset:t.top}}sendUpdate(){var n;const{listeners:t}=this,e=(n=this.currentViewportData)!=null?n:{items:[],offset:0};for(let s=0;s<t.length;s+=1)t[s](e)}};let tg=ed;tg.REFRESH_DEBOUNCE=50;const w2=X.module("GrpcFileStorage"),ng=class{constructor(t,e=""){this.tables=[],this.refreshTables=us(()=>{this.tables.forEach(n=>n.refresh())},ng.REFRESH_THROTTLE),this.storageService=t,this.root=e}removeRoot(t){return ce.removeRoot(this.root,t)}addRoot(t){return ce.addRoot(this.root,t)}async createDirectory(t){return await this.storageService.createDirectory(this.addRoot(t)),this.refreshTables(),{type:"directory",id:t,filename:t,basename:ce.getBaseName(t)}}async getTable(){const t=new tg(this.storageService,this.root);return this.tables.push(t),t}async saveFile(t){const e=dh.storage.FileContents.text(t.content);return await this.storageService.saveFile(this.addRoot(t.filename),e,!0),this.refreshTables(),t}async loadFile(t){const n=await(await this.storageService.loadFile(this.addRoot(t))).text();return{filename:t,basename:ce.getBaseName(t),content:n}}async deleteFile(t){await this.storageService.deleteItem(this.addRoot(t)),this.refreshTables()}async moveFile(t,e){await this.storageService.moveItem(this.addRoot(t),this.addRoot(e)),this.refreshTables()}async info(t){const e=await this.storageService.listItems(this.addRoot(ce.getPath(t)),ce.getBaseName(t));if(e.length===0)throw new sc;if(e.length>1)throw w2.error("More than one matching file found, should never happen.",e),new Error("More than one matching file found");const n=e[0];return{filename:this.removeRoot(n.filename),basename:this.removeRoot(n.basename),id:this.removeRoot(n.filename),type:n.type}}};let sg=ng;sg.REFRESH_THROTTLE=150;const ai=X.module("AppInit");async function v2(){ai.debug("Loading plugins...");try{const t=await Ja.loadJson("/js-plugins/manifest.json");ai.debug("Plugin manifest loaded:",t);const e=[];for(let i=0;i<t.plugins.length;i+=1){const{name:o,main:r}=t.plugins[i],l=`/js-plugins/${o}/${r}`;e.push(Ja.loadModulePlugin(l))}const n=await Promise.all(e),s=new Map;for(let i=0;i<n.length;i+=1){const{name:o}=t.plugins[i];s.set(o,n[i])}return ai.info("Plugins loaded:",s),s}catch(t){return ai.error("Unable to load plugins:",t),new Map}}async function T2(t){let e;try{e=await C2(t)}catch(n){if(!p2(n))throw n}return e}function uc(t){const{workspace:e,setActiveTool:n,setCommandHistoryStorage:s,setDashboardData:i,setFileStorage:o,setLayoutStorage:r,setDashboardConnection:l,setDashboardSessionWrapper:a,setPlugins:d,setUser:c,setWorkspace:u,setWorkspaceStorage:m,setServerConfigValues:p}=t,[g,f]=S.exports.useState(),[b,C]=S.exports.useState(!0),w=S.exports.useCallback(async()=>{var D,F;try{ai.info("Initializing Web UI","0.23.0",navigator.userAgent);const x=await v2(),U=f2(),B=await T2(U);U.addEventListener(M.IdeConnection.HACK_CONNECTION_FAILURE,De=>{var ke;const{detail:qe}=De;ai.error("Connection failure",`${JSON.stringify(qe)}`),f(`Unable to connect: ${(ke=qe.details)!=null?ke:"Unknown Error"}`)});const _="user",H=b2();await H.login({type:M.CoreClient.LOGIN_TYPE_ANONYMOUS});const A=H.getStorageService(),N=new S2(A,"/layouts"),k=new sg(A,"/notebooks"),O=new Jp(N),V=new D1,G=await O.load({isConsoleAvailable:B!==void 0}),{data:Q}=G,{settings:Z}=Q;Z.defaultDecimalFormatOptions===void 0&&(Z.defaultDecimalFormatOptions={defaultFormatString:Le.DEFAULT_FORMAT_STRING}),Z.defaultIntegerFormatOptions===void 0&&(Z.defaultIntegerFormatOptions={defaultFormatString:it.DEFAULT_FORMAT_STRING}),Z.truncateNumbersWithPound===void 0&&(Z.truncateNumbersWithPound=!1);const{shortcutOverrides:be={}}=Z,he=Kt.isMacPlatform?(D=be.mac)!=null?D:{}:(F=be.windows)!=null?F:{};Object.entries(he).forEach(([De,qe])=>{var ke;(ke=Ae.get(De))==null||ke.setKeyState(qe)});const Re={filterSets:Q.filterSets,links:Q.links},ee=await H.getServerConfigValues(),ue=new Map(ee),Se={name:_,operateAs:_,groups:[],permissions:{isSuperUser:!1,isQueryViewOnly:!1,isNonInteractive:!1,canUsePanels:!0,canCreateDashboard:!0,canCreateCodeStudio:!0,canCreateQueryMonitor:!0,canCopy:ue.get("internal.webClient.appInit.canCopy")!=="false",canDownloadCsv:ue.get("internal.webClient.appInit.canDownloadCsv")!=="false"}};n(hn.DEFAULT),p(ue),s(V),i(Mn,Re),o(k),r(N),l(Mn,U),B!==void 0&&a(Mn,B),d(x),c(Se),m(O),u(G)}catch(x){ai.error(x),f(x)}},[n,s,i,o,r,l,a,d,c,u,m,p]),T=S.exports.useCallback(()=>{document.fonts!=null?document.fonts.ready.then(()=>{C(!1)}):C(!1)},[]);S.exports.useEffect(function(){w(),T()},[w,T]);const y=e==null&&g==null||b,E=!y&&g==null,I=g!=null?`${g}`:null;return v(ye,{children:[E&&h(h2,{}),h(wl,{isLoading:y,isLoaded:E,errorMessage:I}),v("div",{id:"preload-fonts",style:{visibility:"hidden",position:"absolute",top:-1e4},children:[h("p",{className:"fira-sans-regular",children:"preload"}),h("p",{className:"fira-sans-semibold",children:"preload"}),h("p",{className:"fira-mono",children:"preload"})]})]})}uc.propTypes={workspace:R.exports.shape({}),workspaceStorage:R.exports.shape({close:R.exports.func}),setActiveTool:R.exports.func.isRequired,setCommandHistoryStorage:R.exports.func.isRequired,setDashboardData:R.exports.func.isRequired,setFileStorage:R.exports.func.isRequired,setLayoutStorage:R.exports.func.isRequired,setDashboardConnection:R.exports.func.isRequired,setDashboardSessionWrapper:R.exports.func.isRequired,setPlugins:R.exports.func.isRequired,setUser:R.exports.func.isRequired,setWorkspace:R.exports.func.isRequired,setWorkspaceStorage:R.exports.func.isRequired};uc.defaultProps={workspace:null,workspaceStorage:null};const E2=t=>({workspace:Dl(t),workspaceStorage:SS(t)}),tu=Nt(E2,{setActiveTool:Fl,setCommandHistoryStorage:_S,setDashboardData:Qm,setFileStorage:kS,setLayoutStorage:M1,setDashboardConnection:pE,setDashboardSessionWrapper:gE,setPlugins:LS,setUser:FS,setWorkspace:Rm,setWorkspaceStorage:xS,setServerConfigValues:AS})(uc);function y2(){return h(yg,{basename:"/ide/",children:v(Ig,{children:[h(Ec,{exact:!0,path:"/",component:tu}),h(Ec,{path:"/notebook/:notebookPath+",component:tu}),h(Rg,{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 I2(){"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(t=>{t.forEach(e=>{e.scope.endsWith("/download/")||e.unregister()})})}V1();ui.render(h(iu,{store:xl,children:h(y2,{})}),document.getElementById("root"));I2();dl.registerOnLoaded();st.init({getWorker:()=>new Mg});window["__react-beautiful-dnd-disable-dev-warnings"]=!0;
47
- //# sourceMappingURL=index.3f6bd83c.js.map
46
+ Barrage Version: ${i}`,children:"Copy Versions"})]})]})]}),h("div",{className:"app-settings-footer-item",children:h(k1,{})})]}),h("div",{className:"app-settings-footer-section",children:h("div",{className:"logo",children:h("a",{target:"_blank",rel:"noreferrer noopener",href:"https://deephaven.io",className:"d-inline-block custom-link p-1",children:h("img",{src:Yp,alt:"Deephaven Data Labs",width:"230px"})})})})]})]})]})}};let Jo=si;Jo.defaultProps={onDone:()=>{}};Jo.FORMATTING_SECTION_KEY="SettingsMenu.formatting";Jo.APPLICATION_SECTION_KEY="ApplicationMenu.settings";Jo.SHORTCUT_SECTION_KEY="SettingsMenu.shortcuts";const Jh=10;function Ai(t){const{forwardedProps:{menuItem:{action:e,title:n,disabled:s},iconElement:i,displayShortcut:o,isMouseSelected:r,isKeyboardSelected:l,closeMenu:a}}=t,d=S.exports.useRef(),c=S.exports.useRef(),u=S.exports.useRef(null),[m,p]=S.exports.useState(!1),g=S.exports.useCallback(C=>{d.current!=null&&c.current!=null&&u.current&&(Math.abs(d.current-C.clientX)>=Jh||Math.abs(c.current-C.clientY)>=Jh)&&(p(!0),window.removeEventListener("mousemove",g),a(),e(C),u.current=null)},[e,a]);function f(C){d.current=C.clientX,c.current=C.clientY,u.current=C.target,window.addEventListener("mousemove",g)}function b(C){u.current===C.target&&(p(!0),a(),e(),window.removeEventListener("mousemove",g)),u.current=null}return S.exports.useEffect(function(){return function(){return window.removeEventListener("mousemove",g)}},[g]),v("button",{type:"button",className:W("btn-context-menu",{disabled:s},{active:r&&!s},{"keyboard-active":l&&!s}),onMouseDown:f,onMouseUp:b,disabled:m,children:[h("span",{className:W("icon"),children:i}),h("span",{className:"title",children:n}),h("span",{className:"shortcut",children:o})]})}function hc(t){const{handleControlSelect:e,handleToolSelect:n,onClearFilter:s}=t,i=S.exports.useMemo(()=>[{title:"Input Filter",icon:iC,menuElement:h(Ai,{}),action:o=>{e(Cn.INPUT_FILTER,o)},order:10},{title:"Dropdown Filter",icon:vu,menuElement:h(Ai,{}),action:o=>{e(Cn.DROPDOWN_FILTER,o)},order:15},{title:"Markdown Widget",icon:Lf,menuElement:h(Ai,{}),action:o=>{e(Cn.MARKDOWN,o)},order:20},{title:"Filter Sets",icon:Da,menuElement:h(Ai,{}),action:o=>{e(Cn.FILTER_SET_MANAGER,o)},order:25},{disabled:!0,menuElement:h("div",{className:"context-menu-group-header",children:"Tools"}),order:30},{title:"Linker",icon:ld,action:()=>{n(hn.LINKER)},order:40,shortcut:ms.LINKER},{disabled:!0,menuElement:h("div",{className:"context-menu-group-header",children:"Actions"}),order:50},{title:"Clear All Filters",icon:eC,action:()=>{s()},order:60,shortcut:dn.TABLE.CLEAR_ALL_FILTERS}],[e,n,s]);return h(Fn,{popperClassName:"controls-menu-popper",actions:i})}hc.propTypes={handleControlSelect:R.exports.func,handleToolSelect:R.exports.func,onClearFilter:R.exports.func};hc.defaultProps={handleControlSelect:()=>{},handleToolSelect:()=>{},onClearFilter:()=>{}};Ai.propTypes={forwardedProps:R.exports.shape({iconElement:R.exports.node,displayShortcut:R.exports.string,isMouseSelected:R.exports.bool.isRequired,isKeyboardSelected:R.exports.bool.isRequired,closeMenu:R.exports.func.isRequired,menuItem:R.exports.shape({action:R.exports.func,title:R.exports.string,disabled:R.exports.bool}).isRequired})};Ai.defaultProps={forwardedProps:null};const G1=Hs(qp,null),K1={layoutStorage:G1},q1=t=>t.layoutStorage,Y1=t=>t.serverConfigValues;Object.entries(K1).map(([t,e])=>eo.register(t,e));const eu=10;function X1(t){const{onExportLayout:e,onImportLayout:n,onResetLayout:s,onSelect:i,widgets:o=[]}=t,[r,l]=S.exports.useState(!1),[a,d]=S.exports.useState(""),c=S.exports.useRef(null),u=S.exports.useRef(),m=S.exports.useCallback((y,E)=>{y!=null&&i(y,E)},[i]),p=S.exports.useCallback(y=>{d(y.target.value)},[]),g=S.exports.useCallback(y=>{u.current!=null&&(Math.abs(u.current.x-y.clientX)>=eu||Math.abs(u.current.y-y.clientY)>=eu)&&(l(!0),window.removeEventListener("mousemove",g),m(u.current.widget,y),u.current=void 0)},[u,m]),f=S.exports.useCallback((y,E)=>{u.current={x:y.clientX,y:y.clientY,widget:E},window.addEventListener("mousemove",g)},[g]),b=S.exports.useCallback((y,E)=>{var I;window.removeEventListener("mousemove",g),((I=u.current)==null?void 0:I.widget)===E&&(l(!0),m(E)),u.current=void 0},[g,u,m]),C=S.exports.useMemo(()=>o.filter(y=>{var E;return a?(E=y.name)==null?void 0:E.toLowerCase().includes(a.toLowerCase()):!0}),[a,o]).sort((y,E)=>{var I,D,F;return(F=(D=y.name)==null?void 0:D.localeCompare((I=E.name)!=null?I:""))!=null?F:0}),w=S.exports.useMemo(()=>C.map(y=>{var E,I;return h("li",{children:v(z,{kind:"ghost","data-testid":`panel-list-item-${(E=y.name)!=null?E:""}-button`,onMouseDown:D=>{f(D,y)},onMouseUp:D=>{b(D,y)},onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&m(y)},disabled:r,onClick:()=>{},children:[h(Gu,{type:y.type})," ",(I=y.name)!=null?I:""]})},y.name)}),[C,r,f,b,m]),T=S.exports.useMemo(()=>w.length===0?h("span",{children:"No bound variables found."}):null,[w]);return v("div",{className:"widget-list-container d-flex flex-column",children:[h("div",{className:"widget-list-header",children:h(Cs,{value:a,placeholder:"Find Table, Plot or Widget",onChange:p,ref:c})}),v("ul",{className:"widget-list flex-grow-1",children:[T&&h("li",{className:"widget-list-message",children:T}),!T&&w]}),h("div",{children:h("hr",{})}),v("div",{className:"widget-list-footer",children:[v(z,{kind:"ghost",onClick:e,children:[v("div",{className:"fa-md fa-layers",children:[h(j,{mask:Ma,icon:Dc,transform:"right-5 down-5"}),h(j,{icon:Dc,transform:"right-8 down-6"})]}),"Export Layout"]}),v(z,{kind:"ghost",onClick:n,children:[v("div",{className:"fa-md fa-layers",children:[h(j,{mask:Ma,icon:Ra,transform:"right-5 down-5"}),h(j,{icon:Ra,transform:"right-8 down-6"})]}),"Import Layout"]}),h(z,{kind:"ghost",icon:ki,onClick:s,tooltip:"Reset Layout"})]})]})}const j1=async(t,e,n)=>{let s,i,o,r;if(Hr(e)?(s=e.settings,i=e.table,o=void 0,r=e.tableSettings):(s={},i="",o=e.figure,r={}),n!==void 0&&(n.tableSettings!=null&&(r=n.tableSettings),n.table!=null&&(i=n.table),n.figure!=null&&(o=n.figure),n.settings!=null&&(s={...s,...n.settings})),o!==void 0){const d={title:o,name:o,type:M.VariableType.FIGURE},c=await t.getObject(d);return zi.makeModel(s,c)}const l={title:o,name:i,type:M.VariableType.TABLE},a=await t.getObject(l);return te.applyTableSettings(a,r,Ml(xl.getState())),zi.makeModelFromSettings(s,a)},Q1=async(t,e,n=M.VariableType.TABLE)=>{const{table:s}=e,i={title:s,name:s,type:n},o=await t.getObject(i);return qd.makeModel(o)};function Z1({onAutoFillClick:t=()=>{}}){return v("div",{className:"empty-dashboard-container",children:[v("div",{className:"hint-container",children:[h(j,{icon:gf})," ",h("br",{}),"Use the panel list to add objects from a query."]}),v("div",{className:"empty-dashboard",children:[h("div",{className:"add-panels-hint",children:"Drag Panels Here"}),h(z,{kind:"tertiary",onClick:t,children:"Auto fill objects"})]})]})}function J1(t){return t.version===2}function e2(t){return Array.isArray(t)}const _r=X.module("UserLayoutUtils"),t2={layoutConfig:[{type:"column",content:[{type:"row",height:40,content:[{type:"stack",content:[{type:"react-component",component:Li.COMPONENT,title:Li.TITLE,isClosable:!1},{type:"react-component",component:ll.COMPONENT,title:ll.TITLE,isClosable:!1}]},{type:"stack",width:25,content:[{type:"react-component",component:il.COMPONENT,title:il.TITLE,isClosable:!1},{type:"react-component",component:ol.COMPONENT,title:ol.TITLE,isClosable:!1}]}]},{type:"row",content:[{type:"stack",title:"Notebooks",content:[]}]}]}],links:[],filterSets:[],version:2},n2={layoutConfig:[],links:[],filterSets:[],version:2};function jp(t){if(J1(t))return t;if(e2(t))return{layoutConfig:t,links:[],filterSets:[],version:2};throw new Error(`Unexpected layout import format: ${t}`)}async function s2(t,e=!0){try{const n=await t.getLayouts();if(n.length>0)try{const s=await t.getLayout(n[0]);return jp(s)}catch(s){_r.error("Unable to load layout",n[0],":",s),_r.warn("No valid layouts found, falling back to default layout")}}catch(n){_r.error("Unable to fetch layout list",n),_r.warn("Falling back to default layout")}return e?t2:n2}function i2(t){const{filterSets:e,layoutConfig:n,links:s}=t;return{filterSets:e,layoutConfig:n,links:s,version:2}}const Wr={exportLayout:i2,getDefaultLayout:s2,normalizeLayout:jp},kr=X.module("DownloadServiceWorkerUtils"),Qp=class{static registerOnLoaded(){new URL("/ide/",window.location.href).origin===window.location.origin&&("serviceWorker"in navigator?window.addEventListener("load",()=>{const e=new URL("/ide/download/serviceWorker.js",window.location.href);navigator.serviceWorker.register(e).then(n=>{n.update(),kr.info("Registering service worker on ",e,n)}).catch(n=>{kr.error("Failed to register service worker",n)})}):kr.info("Service worker is not supported."))}static async getServiceWorker(){if("serviceWorker"in navigator){const e=(await navigator.serviceWorker.getRegistrations()).find(n=>n.scope.endsWith(Qp.DOWNLOAD_PATH));if(e&&e.active)return kr.info("Download service worker is active."),e.active;throw new Error("Can not find download service worker.")}throw new Error("Download service worker is not available.")}static unregisterSW(){}};let dl=Qp;dl.DOWNLOAD_PATH="/download/";const Zp={react:Y},o2=Sg(Zp),r2=wg({requires:o2}),l2=vg.createRequires(Zp),a2=Tg({requires:l2}),d2=X.module("PluginUtils");class Ja{static loadComponentPlugin(e){if("".split(",").includes(e)){const o=Y.lazy(()=>Dg(()=>import(`./internal/${e}`),[])),r=Y.forwardRef((l,a)=>h(S.exports.Suspense,{fallback:h("div",{children:"Loading Plugin..."}),children:h(o,{ref:a,...l})}));return r.pluginName=e,r.displayName="Local Plugin",r}const n=new URL("/ide/plugins/",`${window.location}`),s=new URL(`${e}.js`,n),i=Y.forwardRef((o,r)=>h(r2,{url:s,render:({err:l,Component:a})=>{if(l!=null&&l!==""){const d=`Error loading plugin ${e} from ${s} due to ${l}`;return d2.error(d),h("div",{className:"error-message",children:`${d}`})}return h(a,{ref:r,...o})}}));return i.pluginName=e,i.displayName="Plugin",i}static async loadModulePlugin(e){return await a2(e)}static async loadJson(e){return new Promise((n,s)=>{const i=new XMLHttpRequest;i.addEventListener("load",()=>{try{const o=JSON.parse(i.responseText);n(o)}catch(o){s(o)}}),i.addEventListener("error",o=>{s(o)}),i.open("GET",e),i.send()})}}const At=X.module("AppMainContainer");class Lo extends S.exports.Component{constructor(e){super(e),this.getDashboardPlugins=pe(n=>[...n.entries()].filter(([,s])=>s.DashboardPlugin!=null).map(([s,{DashboardPlugin:i}])=>h(i,{},s))),this.handleSettingsMenuHide=this.handleSettingsMenuHide.bind(this),this.handleSettingsMenuShow=this.handleSettingsMenuShow.bind(this),this.handleError=this.handleError.bind(this),this.handleControlSelect=this.handleControlSelect.bind(this),this.handleToolSelect=this.handleToolSelect.bind(this),this.handleClearFilter=this.handleClearFilter.bind(this),this.handleDataChange=this.handleDataChange.bind(this),this.handleAutoFillClick=this.handleAutoFillClick.bind(this),this.handleGoldenLayoutChange=this.handleGoldenLayoutChange.bind(this),this.handleLayoutConfigChange=this.handleLayoutConfigChange.bind(this),this.handleExportLayoutClick=this.handleExportLayoutClick.bind(this),this.handleImportLayoutClick=this.handleImportLayoutClick.bind(this),this.handleImportLayoutFiles=this.handleImportLayoutFiles.bind(this),this.handleLoadTablePlugin=this.handleLoadTablePlugin.bind(this),this.handleResetLayoutClick=this.handleResetLayoutClick.bind(this),this.handleWidgetMenuClick=this.handleWidgetMenuClick.bind(this),this.handleWidgetsMenuClose=this.handleWidgetsMenuClose.bind(this),this.handleWidgetSelect=this.handleWidgetSelect.bind(this),this.handlePaste=this.handlePaste.bind(this),this.hydrateChart=this.hydrateChart.bind(this),this.hydrateGrid=this.hydrateGrid.bind(this),this.hydratePandas=this.hydratePandas.bind(this),this.hydrateDefault=this.hydrateDefault.bind(this),this.openNotebookFromURL=this.openNotebookFromURL.bind(this),this.importElement=Y.createRef(),this.state={contextActions:[{action:()=>{this.handleToolSelect(hn.LINKER)},shortcut:ms.LINKER,isGlobal:!0},{action:()=>{this.sendClearFilter()},shortcut:dn.TABLE.CLEAR_ALL_FILTERS,isGlobal:!0},{action:()=>{At.debug("Consume unhandled save shortcut")},shortcut:ms.SAVE,isGlobal:!0}],isPanelsMenuShown:!1,isSettingsMenuShown:!1,widgets:[]}}static handleWindowBeforeUnload(e){e.preventDefault(),e.returnValue=""}static hydrateConsole(e,n){return Ua.hydrate({...e,unzip:s=>lu.loadAsync(s).then(i=>Object.values(i.files))},n)}componentDidMount(){this.initWidgets(),window.addEventListener("beforeunload",Lo.handleWindowBeforeUnload)}componentDidUpdate(e){const{dashboardData:n}=this.props;e.dashboardData!==n&&this.handleDataChange(n)}componentWillUnmount(){this.deinitWidgets(),window.removeEventListener("beforeunload",Lo.handleWindowBeforeUnload)}initWidgets(){const{connection:e}=this.props;if(e.subscribeToFieldUpdates==null){At.warn("subscribeToFieldUpdates not supported, not initializing widgets");return}this.widgetListenerRemover=e.subscribeToFieldUpdates(n=>{At.debug("Got updates",n),this.setState(({widgets:s})=>{const{updated:i,created:o,removed:r}=n,l=[...i,...r],a=s.filter(c=>!l.some(u=>u.name===c.name));return[...i,...o].forEach(c=>{c.name!=null&&c.name!==""&&a.push(c)}),{widgets:a}})})}deinitWidgets(){var e;(e=this.widgetListenerRemover)==null||e.call(this)}openNotebookFromURL(){const{match:e}=this.props,{notebookPath:n}=e.params;if(n){const{session:s,sessionConfig:i}=this.props;if(s==null||i==null){At.error("No session available to open notebook URL",n);return}const o={id:`/${n}`,itemName:`/${n}`},r=i.type,l={value:null,language:r};this.emitLayoutEvent(He.SELECT_NOTEBOOK,s,r,l,o,!0)}}sendClearFilter(){this.emitLayoutEvent(Pe.CLEAR_ALL_FILTERS)}emitLayoutEvent(e,...n){var s;(s=this.goldenLayout)==null||s.eventHub.emit(e,...n)}handleError(e){Te.isCanceled(e)||At.error(e)}handleSettingsMenuHide(){this.setState({isSettingsMenuShown:!1})}handleSettingsMenuShow(){this.setState({isSettingsMenuShown:!0})}handleControlSelect(e,n=null){switch(At.debug("handleControlSelect",e),e){case Cn.DROPDOWN_FILTER:this.emitLayoutEvent(Pe.OPEN_DROPDOWN,{title:"DropdownFilter",type:e,createNewStack:!0,dragEvent:n});break;case Cn.INPUT_FILTER:this.emitLayoutEvent(Pe.OPEN_INPUT,{title:"InputFilter",type:e,createNewStack:!0,dragEvent:n});break;case Cn.MARKDOWN:this.emitLayoutEvent(Dp.OPEN,{title:"Markdown",type:e,dragEvent:n});break;case Cn.FILTER_SET_MANAGER:this.emitLayoutEvent(Pe.OPEN_FILTER_SET_MANAGER,{title:"FilterSets",type:e,dragEvent:n});break;default:throw new Error(`Unrecognized control type ${e}`)}}handleToolSelect(e){At.debug("handleToolSelect",e);const{activeTool:n,setActiveTool:s}=this.props;s(n===e?hn.DEFAULT:e)}handleClearFilter(){this.sendClearFilter()}handleDataChange(e){const{updateWorkspaceData:n}=this.props,{closed:s,filterSets:i,links:o}=e;n({closed:s,filterSets:i,links:o})}handleGoldenLayoutChange(e){this.goldenLayout=e}handleLayoutConfigChange(e){const{updateWorkspaceData:n}=this.props;n({layoutConfig:e})}handleWidgetMenuClick(){this.setState(({isPanelsMenuShown:e})=>({isPanelsMenuShown:!e}))}handleWidgetSelect(e,n){this.setState({isPanelsMenuShown:!1}),At.debug("handleWidgetSelect",e,n),this.openWidget(e,n)}handleWidgetsMenuClose(){this.setState({isPanelsMenuShown:!1})}handleAutoFillClick(){const{widgets:e}=this.state;At.debug("handleAutoFillClick",e);const n=e.sort((s,i)=>s.title!=null&&i.title!=null?s.title.localeCompare(i.title):0);for(let s=0;s<n.length;s+=1)this.openWidget(n[s])}handleExportLayoutClick(){At.info("handleExportLayoutClick"),this.setState({isPanelsMenuShown:!1});try{const{workspace:e}=this.props,{data:n}=e,s=Wr.exportLayout(n);At.info("handleExportLayoutClick exportedConfig",s);const i=new Blob([JSON.stringify(s)],{type:"application/json"}),o=M.i18n.DateTimeFormat.format("yyyy-MM-dd-HHmmss",new Date),r=document.createElement("a");r.href=URL.createObjectURL(i),r.download=`deephaven-app-layout-${o}.json`,r.click()}catch(e){At.error("Unable to export layout",e)}}handleImportLayoutClick(){At.info("handleImportLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.importElement.current!=null&&(this.importElement.current.value="",this.importElement.current.click())}handleResetLayoutClick(){At.info("handleResetLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.resetLayout()}handleImportLayoutFiles(e){var n;e.stopPropagation(),e.preventDefault(),e.target.files!=null&&this.importLayoutFile((n=e.target.files)==null?void 0:n[0])}async importLayoutFile(e){try{const{updateDashboardData:n,updateWorkspaceData:s}=this.props,i=await e.text(),o=JSON.parse(i),{filterSets:r,layoutConfig:l,links:a}=Wr.normalizeLayout(o);s({layoutConfig:l}),n(Mn,{filterSets:r,links:a})}catch(n){At.error("Unable to import layout",n)}}async resetLayout(){const{layoutStorage:e,session:n}=this.props,{filterSets:s,layoutConfig:i,links:o}=await Wr.getDefaultLayout(e,n!==void 0),{updateDashboardData:r,updateWorkspaceData:l}=this.props;l({layoutConfig:i}),r(Mn,{filterSets:s,links:o})}handlePaste(e){let n=e.currentTarget.parentElement;for(;n!=null;){if(n.classList.contains("monaco-editor"))return;n=n.parentElement}const{clipboardData:s}=e,i=s.getData("Text"),o=/“|”/g;o.test(i)&&(e.preventDefault(),e.stopPropagation(),document.execCommand("insertText",!1,i.replace(o,'"')))}handleLoadTablePlugin(e){const{plugins:n}=this.props,s=n.get(e);return s!=null&&s.TablePlugin!=null?s.TablePlugin:Ja.loadComponentPlugin(e)}hydrateDefault(e,n){const{connection:s}=this.props,{metadata:i}=e;if((i==null?void 0:i.type)!=null&&((i==null?void 0:i.id)!=null||(i==null?void 0:i.name)!=null)){const o=i.id!=null?{type:i.type,id:i.id}:{type:i.type,name:i.name,title:i.name};return{fetch:()=>s.getObject(o),localDashboardId:n,...e}}return Ua.hydrate(e,n)}hydrateGrid(e,n){return this.hydrateTable(e,n,M.VariableType.TABLE)}hydratePandas(e,n){return this.hydrateTable(e,n,M.VariableType.PANDAS)}hydrateTable(e,n,s=M.VariableType.TABLE){const{connection:i}=this.props;return{...e,getDownloadWorker:dl.getServiceWorker,loadPlugin:this.handleLoadTablePlugin,localDashboardId:n,makeModel:()=>Q1(i,e.metadata,s)}}hydrateChart(e,n){const{connection:s}=this.props;return{...e,localDashboardId:n,makeModel:()=>{const{metadata:i,panelState:o}=e;return j1(s,i,o)}}}openWidget(e,n){const{connection:s}=this.props;this.emitLayoutEvent(Ne.OPEN,{dragEvent:n,fetch:()=>s.getObject(e),widget:e})}render(){const{activeTool:e,plugins:n,user:s,workspace:i,serverConfigValues:o}=this.props,{data:r}=i,{layoutConfig:l}=r,{permissions:a}=s,{canUsePanels:d}=a,{contextActions:c,isPanelsMenuShown:u,isSettingsMenuShown:m,widgets:p}=this.state,g=this.getDashboardPlugins(n);return v("div",{className:W("app-main-tabs","w-100","h-100","d-flex","flex-column",e?`active-tool-${e.toLowerCase()}`:""),onPaste:this.handlePaste,tabIndex:-1,children:[h("nav",{className:"nav-container",children:v("div",{className:"app-main-top-nav-menus",children:[h("img",{src:Yp,alt:"Deephaven Data Labs",width:"115px",className:"ml-1"}),v("div",{children:[v(z,{kind:"ghost",className:"btn-panels-menu",icon:cC,onClick:()=>{},children:["Controls",h(hc,{handleControlSelect:this.handleControlSelect,handleToolSelect:this.handleToolSelect,onClearFilter:this.handleClearFilter})]}),d&&v(z,{kind:"ghost",className:"btn-panels-menu btn-show-panels","data-testid":"app-main-panels-button",onClick:this.handleWidgetMenuClick,icon:rC,children:["Panels",h(kn,{isShown:u,className:"panels-menu-popper",onExited:this.handleWidgetsMenuClose,closeOnBlur:!0,interactive:!0,children:h(X1,{widgets:p,onExportLayout:this.handleExportLayoutClick,onImportLayout:this.handleImportLayoutClick,onResetLayout:this.handleResetLayoutClick,onSelect:this.handleWidgetSelect})})]}),h(z,{kind:"ghost",className:W("btn-settings-menu",{"text-warning":s.operateAs!==s.name}),onClick:this.handleSettingsMenuShow,icon:h(j,{icon:Go,transform:"grow-3 right-1 down-1"}),tooltip:"User Settings"})]})]})}),v(Iw,{emptyDashboard:h(Z1,{onAutoFillClick:this.handleAutoFillClick}),id:Mn,layoutConfig:l,onGoldenLayoutChange:this.handleGoldenLayoutChange,onLayoutConfigChange:this.handleLayoutConfigChange,onLayoutInitialized:this.openNotebookFromURL,hydrate:this.hydrateDefault,children:[h(a1,{hydrate:this.hydrateGrid,getDownloadWorker:dl.getServiceWorker,loadPlugin:this.handleLoadTablePlugin}),h(n1,{hydrate:this.hydrateChart}),h(s1,{}),h(o1,{hydrateConsole:Lo.hydrateConsole,notebooksUrl:new URL("/notebooks/",`${window.location}`).href}),h(r1,{}),h(f1,{hydrate:this.hydratePandas}),h(g1,{}),h(p1,{}),g]}),h(ut,{in:m,timeout:yt.transitionMidMs,classNames:"slide-left",mountOnEnter:!0,unmountOnExit:!0,children:h(Jo,{serverConfigValues:o,onDone:this.handleSettingsMenuHide})}),h(oe,{actions:c}),h("input",{ref:this.importElement,type:"file",accept:".json",style:{display:"none"},onChange:this.handleImportLayoutFiles})]})}}const c2=t=>{var e,n;return{activeTool:Nl(t),dashboardData:jt(t,Mn),layoutStorage:q1(t),plugins:NS(t),connection:mE(t,Mn),session:(e=gi(t,Mn))==null?void 0:e.session,sessionConfig:(n=gi(t,Mn))==null?void 0:n.config,user:gm(t),workspace:Dl(t),serverConfigValues:Y1(t)}},h2=Nt(c2,{setActiveTool:Fl,updateDashboardData:Xn,updateWorkspaceData:Dm})(Eg(Lo));function u2(){return v("div",{className:"app",children:[h(h2,{}),h(Du,{})]})}const m2=X.module("LocalWorkspaceStorage"),Fo=class{static async makeDefaultWorkspaceData(t,e){const{filterSets:n,links:s,layoutConfig:i}=await Wr.getDefaultLayout(t,e==null?void 0:e.isConsoleAvailable);return{settings:{defaultDateTimeFormat:dt.DEFAULT_DATETIME_FORMAT_STRING,formatter:[],timeZone:dt.DEFAULT_TIME_ZONE_ID,showTimeZone:!1,showTSeparator:!0,disableMoveConfirmation:!1,defaultDecimalFormatOptions:{defaultFormatString:Le.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:it.DEFAULT_FORMAT_STRING},truncateNumbersWithPound:!1,defaultNotebookSettings:{isMinimapEnabled:!1}},layoutConfig:i,closed:[{}],links:s,filterSets:n}}static async makeDefaultWorkspace(t,e){return{data:await Fo.makeDefaultWorkspaceData(t,e)}}constructor(t){this.layoutStorage=t}async load(t){var e;try{return JSON.parse((e=localStorage.getItem(Fo.STORAGE_KEY))!=null?e:"")}catch{return m2.info("Unable to load workspace data, initializing to default data"),Fo.makeDefaultWorkspace(this.layoutStorage,t)}}async save(t){return localStorage.setItem(Fo.STORAGE_KEY,JSON.stringify(t)),t}};let Jp=Fo;Jp.STORAGE_KEY="deephaven.WorkspaceStorage";class p2 extends Error{constructor(){super(...arguments),this.isNoConsolesError=!0}}function g2(t){return t.isNoConsolesError}const Pi=X.module("SessionUtils");function f2(){return new URL("/jsapi",`${window.location}`)}function eg(){const t=f2();return`${t.protocol}//${t.host}`}function C2(){const t=eg();return Pi.info(`Starting connection to '${t}'...`),new M.IdeConnection(t)}async function b2(t){Pi.info("Getting console types...");const e=await t.getConsoleTypes();if(Pi.info("Available types:",e),e.length===0)throw new p2("No console types available");const n=e[0];Pi.info("Starting session with type",n);const s=await t.startSession(n),i={type:n,id:ze.generate()};return Pi.info("Console session established",i),{session:s,config:i,connection:t}}function S2(){const t=eg();return Pi.info("createCoreClient",t),new M.CoreClient(t)}class w2{constructor(e,n=""){this.storageService=e,this.root=n}async getLayouts(){return(await this.storageService.listItems(this.root,"*.json")).map(n=>n.basename)}async getLayout(e){const s=await(await this.storageService.loadFile(`${this.root}/${e}`)).text();return JSON.parse(s)}}const To=X.module("GrpcFileStorageTable"),ed=class{constructor(t,e="",n=e){this.currentSize=0,this.listeners=[],this.childTables=new Map,this.storageService=t,this.baseRoot=e,this.root=n,n===e&&(this.doRefresh=je(this.doRefresh.bind(this),ed.REFRESH_DEBOUNCE))}removeBaseRoot(t){return ce.removeRoot(this.baseRoot,t)}getViewportData(){var t;return this.viewportUpdatePromise||this.refreshInternal(),(t=this.viewportUpdatePromise)!=null?t:Promise.resolve({items:[],offset:0})}getSnapshot(t){throw new Error("Method not implemented.")}get size(){return this.currentSize}setExpanded(t,e){const n=t.split("/");let s=n.shift();if((s===void 0||s==="")&&(s=n.shift()),s===void 0||s==="")throw new Error(`Invalid path: ${t}`);const i=n.join("/");if(e){if(!this.childTables.has(s)){const o=new ed(this.storageService,this.baseRoot,`${this.root}/${s}`);this.childTables.set(s,o)}if(i){const o=this.childTables.get(s);o==null||o.setExpanded(i,e)}}else if(this.childTables.has(s))if(i){const o=this.childTables.get(s);o==null||o.setExpanded(i,e)}else this.childTables.delete(s);this.currentViewport&&this.refreshInternal()}collapseAll(){this.childTables.clear(),this.currentViewport&&this.refreshInternal()}setSearch(t){throw new Error("Method not implemented.")}setViewport(t){this.currentViewport=t,this.refreshInternal()}setFilters(){throw new Error("Method not implemented.")}setSorts(){throw new Error("Method not implemented.")}setReversed(){throw new Error("Method not implemented.")}close(){this.listeners=[]}onUpdate(t){return this.listeners=[...this.listeners,t],()=>{this.listeners=this.listeners.filter(e=>e!==t)}}doRefresh(t){To.debug2("doRefresh",this.root),t(this.fetchData())}refresh(){var n;To.debug2("refresh",this.root),(n=this.viewportUpdatePromise)==null||n.cancel();const t=new Promise(s=>{this.doRefresh(s)}),e=Te.makeCancelable(t.then(s=>{if(this.viewportUpdatePromise!==e)throw new di;return this.currentViewportData=s,this.sendUpdate(),s}));e.catch(s=>{Te.isCanceled(s)||To.error("Error updating viewport",s)}),this.viewportUpdatePromise=e}refreshInternal(){try{this.refresh()}catch(t){Te.isCanceled(t)||To.error("Unable to refresh data",t)}}async fetchData(){const{currentViewport:t}=this;if(!t)throw new Error("No viewport set");let n=(await this.storageService.listItems(this.root)).map(s=>({type:s.type,filename:this.removeBaseRoot(s.filename),basename:s.basename,id:this.removeBaseRoot(s.filename),isExpanded:s.type==="directory"?this.childTables.has(s.basename):void 0})).sort((s,i)=>s.type!==i.type?s.type==="directory"?-1:1:s.basename.localeCompare(i.basename));for(let s=0;s<n.length;s+=1){const i=n[s],{basename:o,filename:r}=i;if(r===this.removeBaseRoot(`${this.root}/${o}`)&&i.type==="directory"){const l=this.childTables.get(o);if(l!=null){l.setViewport({top:0,bottom:t.bottom-s});const a=await l.getViewportData();n.splice(s+1,0,...a.items)}}}return this.currentSize=n.length,To.debug2(this.root,"items",n,t),n=n.slice(t.top,t.bottom),{items:n,offset:t.top}}sendUpdate(){var n;const{listeners:t}=this,e=(n=this.currentViewportData)!=null?n:{items:[],offset:0};for(let s=0;s<t.length;s+=1)t[s](e)}};let tg=ed;tg.REFRESH_DEBOUNCE=50;const v2=X.module("GrpcFileStorage"),ng=class{constructor(t,e=""){this.tables=[],this.refreshTables=us(()=>{this.tables.forEach(n=>n.refresh())},ng.REFRESH_THROTTLE),this.storageService=t,this.root=e}removeRoot(t){return ce.removeRoot(this.root,t)}addRoot(t){return ce.addRoot(this.root,t)}async createDirectory(t){return await this.storageService.createDirectory(this.addRoot(t)),this.refreshTables(),{type:"directory",id:t,filename:t,basename:ce.getBaseName(t)}}async getTable(){const t=new tg(this.storageService,this.root);return this.tables.push(t),t}async saveFile(t){const e=dh.storage.FileContents.text(t.content);return await this.storageService.saveFile(this.addRoot(t.filename),e,!0),this.refreshTables(),t}async loadFile(t){const n=await(await this.storageService.loadFile(this.addRoot(t))).text();return{filename:t,basename:ce.getBaseName(t),content:n}}async deleteFile(t){await this.storageService.deleteItem(this.addRoot(t)),this.refreshTables()}async moveFile(t,e){await this.storageService.moveItem(this.addRoot(t),this.addRoot(e)),this.refreshTables()}async info(t){const e=await this.storageService.listItems(this.addRoot(ce.getPath(t)),ce.getBaseName(t));if(e.length===0)throw new sc;if(e.length>1)throw v2.error("More than one matching file found, should never happen.",e),new Error("More than one matching file found");const n=e[0];return{filename:this.removeRoot(n.filename),basename:this.removeRoot(n.basename),id:this.removeRoot(n.filename),type:n.type}}};let sg=ng;sg.REFRESH_THROTTLE=150;const ai=X.module("AppInit");async function T2(){ai.debug("Loading plugins...");try{const t=await Ja.loadJson("/js-plugins/manifest.json");ai.debug("Plugin manifest loaded:",t);const e=[];for(let i=0;i<t.plugins.length;i+=1){const{name:o,main:r}=t.plugins[i],l=`/js-plugins/${o}/${r}`;e.push(Ja.loadModulePlugin(l))}const n=await Promise.all(e),s=new Map;for(let i=0;i<n.length;i+=1){const{name:o}=t.plugins[i];s.set(o,n[i])}return ai.info("Plugins loaded:",s),s}catch(t){return ai.error("Unable to load plugins:",t),new Map}}async function E2(t){let e;try{e=await b2(t)}catch(n){if(!g2(n))throw n}return e}function uc(t){const{workspace:e,setActiveTool:n,setCommandHistoryStorage:s,setDashboardData:i,setFileStorage:o,setLayoutStorage:r,setDashboardConnection:l,setDashboardSessionWrapper:a,setPlugins:d,setUser:c,setWorkspace:u,setWorkspaceStorage:m,setServerConfigValues:p}=t,[g,f]=S.exports.useState(),[b,C]=S.exports.useState(!0),w=S.exports.useCallback(async()=>{var D,F;try{ai.info("Initializing Web UI","0.23.0",navigator.userAgent);const x=await T2(),U=C2(),B=await E2(U);U.addEventListener(M.IdeConnection.HACK_CONNECTION_FAILURE,De=>{var ke;const{detail:qe}=De;ai.error("Connection failure",`${JSON.stringify(qe)}`),f(`Unable to connect: ${(ke=qe.details)!=null?ke:"Unknown Error"}`)});const _="user",H=S2();await H.login({type:M.CoreClient.LOGIN_TYPE_ANONYMOUS});const A=H.getStorageService(),N=new w2(A,"/layouts"),k=new sg(A,"/notebooks"),O=new Jp(N),V=new M1,G=await O.load({isConsoleAvailable:B!==void 0}),{data:Q}=G,{settings:Z}=Q;Z.defaultDecimalFormatOptions===void 0&&(Z.defaultDecimalFormatOptions={defaultFormatString:Le.DEFAULT_FORMAT_STRING}),Z.defaultIntegerFormatOptions===void 0&&(Z.defaultIntegerFormatOptions={defaultFormatString:it.DEFAULT_FORMAT_STRING}),Z.truncateNumbersWithPound===void 0&&(Z.truncateNumbersWithPound=!1);const{shortcutOverrides:be={}}=Z,he=Kt.isMacPlatform?(D=be.mac)!=null?D:{}:(F=be.windows)!=null?F:{};Object.entries(he).forEach(([De,qe])=>{var ke;(ke=Ae.get(De))==null||ke.setKeyState(qe)});const Re={filterSets:Q.filterSets,links:Q.links},ee=await H.getServerConfigValues(),ue=new Map(ee),Se={name:_,operateAs:_,groups:[],permissions:{isSuperUser:!1,isQueryViewOnly:!1,isNonInteractive:!1,canUsePanels:!0,canCreateDashboard:!0,canCreateCodeStudio:!0,canCreateQueryMonitor:!0,canCopy:ue.get("internal.webClient.appInit.canCopy")!=="false",canDownloadCsv:ue.get("internal.webClient.appInit.canDownloadCsv")!=="false"}};n(hn.DEFAULT),p(ue),s(V),i(Mn,Re),o(k),r(N),l(Mn,U),B!==void 0&&a(Mn,B),d(x),c(Se),m(O),u(G)}catch(x){ai.error(x),f(x)}},[n,s,i,o,r,l,a,d,c,u,m,p]),T=S.exports.useCallback(()=>{document.fonts!=null?document.fonts.ready.then(()=>{C(!1)}):C(!1)},[]);S.exports.useEffect(function(){w(),T()},[w,T]);const y=e==null&&g==null||b,E=!y&&g==null,I=g!=null?`${g}`:null;return v(ye,{children:[E&&h(u2,{}),h(wl,{isLoading:y,isLoaded:E,errorMessage:I}),v("div",{id:"preload-fonts",style:{visibility:"hidden",position:"absolute",top:-1e4},children:[h("p",{className:"fira-sans-regular",children:"preload"}),h("p",{className:"fira-sans-semibold",children:"preload"}),h("p",{className:"fira-mono",children:"preload"})]})]})}uc.propTypes={workspace:R.exports.shape({}),workspaceStorage:R.exports.shape({close:R.exports.func}),setActiveTool:R.exports.func.isRequired,setCommandHistoryStorage:R.exports.func.isRequired,setDashboardData:R.exports.func.isRequired,setFileStorage:R.exports.func.isRequired,setLayoutStorage:R.exports.func.isRequired,setDashboardConnection:R.exports.func.isRequired,setDashboardSessionWrapper:R.exports.func.isRequired,setPlugins:R.exports.func.isRequired,setUser:R.exports.func.isRequired,setWorkspace:R.exports.func.isRequired,setWorkspaceStorage:R.exports.func.isRequired};uc.defaultProps={workspace:null,workspaceStorage:null};const y2=t=>({workspace:Dl(t),workspaceStorage:SS(t)}),tu=Nt(y2,{setActiveTool:Fl,setCommandHistoryStorage:_S,setDashboardData:Qm,setFileStorage:kS,setLayoutStorage:N1,setDashboardConnection:pE,setDashboardSessionWrapper:gE,setPlugins:LS,setUser:FS,setWorkspace:Rm,setWorkspaceStorage:xS,setServerConfigValues:AS})(uc);function I2(){return h(yg,{basename:"/ide/",children:v(Ig,{children:[h(Ec,{exact:!0,path:"/",component:tu}),h(Ec,{path:"/notebook/:notebookPath+",component:tu}),h(Rg,{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 R2(){"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(t=>{t.forEach(e=>{e.scope.endsWith("/download/")||e.unregister()})})}U1();ui.render(h(iu,{store:xl,children:h(I2,{})}),document.getElementById("root"));R2();dl.registerOnLoaded();st.init({getWorker:()=>new Mg});window["__react-beautiful-dnd-disable-dev-warnings"]=!0;
47
+ //# sourceMappingURL=index.6d7eb3ed.js.map