@deephaven/embed-grid 0.20.1-beta.2 → 0.20.1-beta.5
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.
|
@@ -22,11 +22,11 @@ ${o}`);for(let r=0;r<e;r+=1){const l=this.type.shouldTrim?t[i][r].trim():t[i][r]
|
|
|
22
22
|
${t}`):s.setValue(`${t}`);const o=s.getLineCount(),r=s.getLineLength(o)+1;this.editor.setPosition({lineNumber:o,column:r}),n&&this.editor.focus()}updateDimensions(){Et.debug("updateDimensions"),this.editor&&this.editor.layout()}focus(){Et.debug("focus"),this.editor&&this.editor.focus()}toggleFind(){this.editorComponent.current&&this.editorComponent.current.toggleFind()}setLanguage(t){this.editorComponent.current&&t!==void 0&&this.editorComponent.current.setLanguage(t)}render(){const{error:t,isLoaded:n,isLoading:s,session:i,sessionLanguage:o,settings:r}=this.props,{model:l}=this.state,a=t?`Unable to open document. ${t}`:null,c=r?r.language:null,d=l&&i&&c===o;return T(Fe,{children:[(t||s)&&u("div",{className:"h-100 w-100 position-relative",children:u(sa,{errorMessage:a,isLoading:s,isLoaded:n})}),n&&u("div",{className:"h-100 w-100 script-editor",children:r&&T(Fe,{children:[u(Cr,{ref:this.editorComponent,settings:r,onEditorInitialized:this.handleEditorInitialized,onEditorWillDestroy:this.handleEditorWillDestroy}),d!=null&&d&&u(_a,{model:l,language:c,session:i})]})})]})}}qp.defaultProps={error:null,isLoading:!1,isLoaded:!1,focusOnMount:!0,onChange:()=>{},session:null,sessionLanguage:null,settings:null};const Kp=250,Xp=2500,qa=class extends y.exports.Component{constructor(e){super(e),this.loadData=Tt(()=>{const{commandHistoryStorage:t,item:n,language:s}=this.props,{id:i}=n;this.cleanup=t.listenItem(s,i,this.handleUpdate,this.handleError)},Kp),this.getPreviewText=ue(t=>t.split(`
|
|
23
23
|
`,Xp).join(`
|
|
24
24
|
`),{max:1}),this.handleUpdate=this.handleUpdate.bind(this),this.handleError=this.handleError.bind(this),this.handleTimeout=this.handleTimeout.bind(this),this.state={currentTime:Date.now()}}static getTimeString(e,t){if(e==null||t===""||t===0)return null;const n=Math.round((new Date(t).valueOf()-new Date(e).valueOf())/1e3);return n<1?"<1s":Xt.formatElapsedTime(n)}componentDidMount(){this.loadData()}componentDidUpdate(e,t){var s;const{data:n}=this.state;this.timer==null&&!(n!=null&&n.result)&&Boolean(n==null?void 0:n.startTime)&&!(n==null||n.endTime===void 0)?this.startTimer():((n==null?void 0:n.result)&&!((s=t.data)!=null&&s.result)||Boolean(n==null?void 0:n.endTime)&&!(t.data==null||t.data.endTime===void 0))&&this.stopTimer()}componentWillUnmount(){this.loadData.cancel(),this.cleanup!=null&&this.cleanup(),this.stopTimer()}startTimer(){this.stopTimer(),this.timer=setInterval(this.handleTimeout,1e3)}stopTimer(){this.timer&&(clearInterval(this.timer),this.timer=void 0)}updateTime(){this.setState({currentTime:Date.now()})}handleError(e){this.setState({error:`${e}`})}handleUpdate(e){const{data:t}=e!=null?e:{};this.setState({data:t});const{onUpdate:n}=this.props;n==null||n(t)}handleTimeout(){this.updateTime()}render(){var m;const{item:{name:e},language:t}=this.props,{currentTime:n,data:s,error:i}=this.state,{result:o,startTime:r,endTime:l}=s!=null?s:{},a=(m=o==null?void 0:o.error)!=null?m:i,c=qa.getTimeString(r,l!=null?l:n),d=this.getPreviewText(e),h=Boolean(c);return T("div",{className:"command-history-item-tooltip",children:[T("div",{className:"scroll-container",children:[u(Oa,{language:t,children:d}),d.length<e.length&&u("p",{children:"Preview Truncated..."})]}),T("div",{className:"result-info",children:[T("div",{className:"d-flex justify-content-between",children:[Boolean(a)&&T("div",{className:"text-danger mr-1",children:[u(K,{icon:On})," Executed with errors"]}),T("div",{className:"time-wrapper",children:["Elapsed time:"," ",h?u("span",{className:"time-string",children:c}):u(Ht,{})]})]}),Boolean(a)&&u("div",{className:"error-message",children:a})]})]})}};let Ka=qa;Ka.defaultProps={onUpdate:()=>{}};const Yp=512,Xa=e=>{const{item:t,language:n,isSelected:s,commandHistoryStorage:i}=e,o=t.name.substring(0,Yp),r=y.exports.useRef(null),l=y.exports.useCallback(()=>{var a;(a=r.current)==null||a.update()},[r]);return T("div",{className:$("command-history-item",{selected:s}),children:[o,u(ge,{ref:r,interactive:!0,options:{placement:"left",modifiers:{preventOverflow:{enabled:!0,boundariesElement:"viewport",order:825}}},popperClassName:"command-history-item-popper",children:u(Ka,{item:t,language:n,onUpdate:l,commandHistoryStorage:i})})]})};Xa.defaultProps={isSelected:!1};class Wi extends y.exports.Component{static itemKey(t,n){return`${n.title}`}static renderContent(t){return t.selectionRequired!==void 0&&t.selectionRequired?T("div",{className:"fa-md fa-layers",children:[u(K,{icon:Go,mask:t.icon,transform:"right-5 down-5 shrink-4"}),u(K,{icon:Xc,transform:"shrink-3 right-7 down-6"})]}):u(K,{icon:t.icon})}render(){const{actions:t,hasSelection:n}=this.props;return u("div",{className:"command-history-actions",children:t.map((s,i)=>u(me,{kind:"inline",className:$(s.className),onClick:s.action,tooltip:s.description,disabled:s.selectionRequired!==void 0&&s.selectionRequired&&!n,icon:Wi.renderContent(s)},Wi.itemKey(i,s)))})}}const Qp=150,bl=3,wl=te.module("CommandHistoryViewportUpdater");function jp({table:e,columns:t,top:n=0,bottom:s=0,search:i,isReversed:o=!1,onUpdate:r}){const l=y.exports.useMemo(()=>Xs(a=>{const c=a.bottom-a.top,d=Math.max(0,a.top-c*bl),h=a.bottom+c*bl;e.setViewport({top:d,bottom:h,columns:a.columns})},Qp),[e]);return y.exports.useEffect(function(){const c=e.onUpdate(d=>{var h,m;r({items:(h=d.items)!=null?h:[],offset:(m=d.offset)!=null?m:0})});return()=>{wl.debug("onUpdate cleanup"),c()}},[e,r]),y.exports.useEffect(function(){e.setSearch(i!=null?i:"")},[e,i]),y.exports.useEffect(function(){l({top:n,bottom:s,columns:t})},[l,n,s,t,i,o]),y.exports.useEffect(()=>()=>{wl.debug2("Cancel throttledUpdateViewport"),l.cancel()},[l]),null}const Tn=te.module("CommandHistory"),dn=class extends y.exports.Component{constructor(e){super(e),this.copySelectedCommands=this.copySelectedCommands.bind(this),this.createNotebook=this.createNotebook.bind(this),this.sendToConsole=this.sendToConsole.bind(this),this.renderItem=this.renderItem.bind(this),this.runInConsole=this.runInConsole.bind(this),this.sendToNotebook=this.sendToNotebook.bind(this),this.handleSelect=this.handleSelect.bind(this),this.handleSelectionChange=this.handleSelectionChange.bind(this),this.handleSearchChange=this.handleSearchChange.bind(this),this.handleViewportChange=this.handleViewportChange.bind(this),this.handleViewportUpdate=this.handleViewportUpdate.bind(this),this.itemActions=[{title:"Copy Selection",description:"Copy selected commands to clipboard",icon:td,shortcut:sr.COPY,action:this.copySelectedCommands,group:se.groups.edit},{title:"Send to Console",description:"Open selected commands in the console",icon:kr,shortcut:as.COMMAND_HISTORY.SEND_TO_CONSOLE,action:this.sendToConsole,group:dn.menuGroups.send,order:10},{title:"Run in Console",description:"Run selected commands in the console",icon:dd,shortcut:as.COMMAND_HISTORY.RUN,action:this.runInConsole,group:dn.menuGroups.send,order:10},{title:"Send to Active Notebook",description:"Open selected commands in a notebook",icon:Ar,shortcut:as.COMMAND_HISTORY.SEND_TO_NOTEBOOK,action:this.sendToNotebook,group:dn.menuGroups.send,order:20},{title:"Send to New Notebook",description:"Open selected commands in a new notebook",icon:cd,action:this.createNotebook,group:dn.menuGroups.send,order:30}],this.historyActions=[{title:"Send to Console",icon:kr,selectionRequired:!0,description:"Open selected commands in the console",action:this.sendToConsole},{title:"Send to Notebook",icon:Ar,selectionRequired:!0,description:"Open selected commands in a notebook",action:this.sendToNotebook}],this.pending=new Yi,this.searchInputRef=Y.createRef();const{table:t}=e;this.state={actions:[],historyActions:this.historyActions,top:0,bottom:0,itemCount:t.size,items:[],offset:0,selectedRanges:[],searchText:""}}static getCommandsFromViewport(e,t,n){const s=[];for(let i=0;i<n.length;i+=1){const o=n[i];for(let r=o[0];r<=o[1];r+=1)if(r>=t&&r<t+e.length){const{name:l}=e[r-t];s.push(l)}}return s}static async getCommandsFromSnapshot(e,t){return[...(await e.getSnapshot(t)).values()].map(s=>s.name)}componentWillUnmount(){this.pending.cancel()}async getSelectedCommands(){const{items:e,offset:t,selectedRanges:n}=this.state,s=n.slice().sort((o,r)=>o[0]-r[0]);if(s.length===0)return[];if(s[0][0]>=t&&s[s.length-1][1]<t+e.length)return dn.getCommandsFromViewport(e,t,s);const{table:i}=this.props;return this.pending.add(dn.getCommandsFromSnapshot(i,s))}getSelectedCommandText(){return this.getSelectedCommands().then(e=>e.join(`
|
|
25
|
-
`))}updateActions(){this.setState(e=>{const{selectedRanges:t}=e,n=t.reduce((s,i)=>s+i[1]-i[0]+1,0);return n>0&&n<dn.MAX_SELECTION_COUNT?(Tn.debug("Updating actions",this.itemActions),{actions:this.itemActions}):(Tn.debug("Disabling actions",n),{actions:[]})})}copySelectedCommands(){this.getSelectedCommandText().then(ve.copyToClipboard).catch(Tn.error)}createNotebook(){this.getSelectedCommandText().then(e=>{const{language:t,sendToNotebook:n}=this.props;n({value:e,language:t},!0)}).catch(Tn.error)}sendToNotebook(){this.getSelectedCommandText().then(e=>{const{language:t,sendToNotebook:n}=this.props;n({value:e,language:t})}).catch(Tn.error)}sendToConsole(){const{sendToConsole:e}=this.props;this.getSelectedCommandText().then(e).catch(Tn.error)}runInConsole(){this.getSelectedCommandText().then(e=>{const{sendToConsole:t}=this.props;t(e,!0,!0)}).catch(Tn.error)}handleSelect(e){const{sendToConsole:t}=this.props,{items:n,offset:s}=this.state;if(e<s||e>=s+n.length){Tn.error("Invalid index!",e);return}const{name:i}=n[e-s];t(i)}handleSelectionChange(e){this.setState({selectedRanges:e}),this.updateActions()}handleViewportChange(e,t){this.setState({top:e,bottom:t})}handleSearchChange(e){this.setState({searchText:e.target.value,selectedRanges:[]})}handleViewportUpdate({items:e,offset:t}){const{table:n}=this.props,s=n.size;this.setState({items:e,itemCount:s,offset:t})}renderItem({item:e,itemIndex:t,isSelected:n}){const{language:s,commandHistoryStorage:i}=this.props;return u(Xa,{isSelected:n,item:e,language:s,commandHistoryStorage:i})}focus(){this.searchInputRef.current&&this.searchInputRef.current.focus()}render(){var m;const{language:e,table:t}=this.props,{actions:n,historyActions:s,searchText:i,top:o,bottom:r,items:l,itemCount:a,offset:c,selectedRanges:d}=this.state,h=(m=op.LANGUAGE_MAP.get(e))!=null?m:"";return T("div",{className:"command-history",children:[T("div",{className:"command-history-search-bar",children:[u(_n,{ref:this.searchInputRef,value:i,placeholder:`${h} Command History`,onChange:this.handleSearchChange}),u(Wi,{actions:s,hasSelection:d.length>0})]}),T("div",{className:"command-history-list",children:[u(Zt,{itemCount:a,items:l,offset:c,selectedRanges:d,onSelect:this.handleSelect,onSelectionChange:this.handleSelectionChange,onViewportChange:this.handleViewportChange,renderItem:this.renderItem,rowHeight:dn.ITEM_HEIGHT,isDoubleClickSelect:!0,isMultiSelect:!0,isStickyBottom:!0}),u(jp,{table:t,top:o,bottom:r,search:i,onUpdate:this.handleViewportUpdate}),u(se,{actions:n})]})]})}};let br=dn;br.ITEM_HEIGHT=29;br.MAX_SELECTION_COUNT=1e4;br.menuGroups={send:se.groups.medium+100};class Zp extends y.exports.PureComponent{constructor(t){super(t),this.handleSwitchClick=this.handleSwitchClick.bind(this)}handleSwitchClick(){const{logLevel:t,onClick:n}=this.props;n(t)}render(){const{logLevel:t,on:n}=this.props;return T("div",{className:$("log-level-menu-item",t),children:[u(ia,{on:n,onClick:this.handleSwitchClick}),t]})}}const st=class extends y.exports.PureComponent{constructor(e){super(e),this.handleClearClick=this.handleClearClick.bind(this),this.handleFlushTimeout=this.handleFlushTimeout.bind(this),this.handleLogMessage=this.handleLogMessage.bind(this),this.handleMenuItemClick=this.handleMenuItemClick.bind(this),this.handleResetClick=this.handleResetClick.bind(this),this.handleResize=this.handleResize.bind(this),this.handleToggleAllClick=this.handleToggleAllClick.bind(this),this.logLevelMenuItems={},this.editorContainer=null,this.bufferedMessages=[],this.messages=[],this.state={shownLogLevels:{}}}static getLogText(e){const t=new Date(e.micros/1e3);return`${Is.formatTimestamp(t)} ${e.logLevel} ${e.message}`}componentDidMount(){this.resetLogLevels(),this.initMonaco(),this.startListening(),window.addEventListener("resize",this.handleResize)}componentDidUpdate(e,t){this.updateDimensions();const{shownLogLevels:n}=this.state;t.shownLogLevels!==n&&this.refreshLogText();const{session:s}=this.props;e.session!==s&&(this.stopListening(),this.startListening(),this.clearLogs())}componentWillUnmount(){this.stopFlushTimer(),this.stopListening(),this.destroyMonaco(),window.removeEventListener("resize",this.handleResize)}getMenuActions(e){const t=[];t.push({menuElement:u("div",{className:"log-level-menu-title",children:"Display Log Levels"}),group:1,order:10});for(let n=0;n<st.AllLogLevels.length;n+=1){const s=st.AllLogLevels[n],i=e[s]!=null?e[s]:!1;t.push({title:s,group:1,order:n+100,menuElement:u(Zp,{logLevel:s,on:i,onClick:this.handleMenuItemClick,ref:o=>{o!=null&&(this.logLevelMenuItems[s]=o)}})})}return t.push({group:1,order:1e3,menuElement:T("div",{className:"log-level-menu-controls",children:[u(me,{kind:"ghost",className:"log-level-toggle-all",onClick:this.handleToggleAllClick,children:"Toggle All"}),u(me,{kind:"ghost",onClick:this.handleResetClick,children:"Reset"})]})}),t}resetLogLevels(){const e={};for(let t=0;t<st.AllLogLevels.length;t+=1){const n=st.AllLogLevels[t],s=st.DefaultLogLevels.indexOf(n)>=0;e[n]=s}this.setState({shownLogLevels:e})}startListening(){const{session:e}=this.props;this.cancelListener=e.onLogMessage(this.handleLogMessage)}stopListening(){this.cancelListener!=null&&(this.cancelListener(),this.cancelListener=void 0)}initMonaco(){O(this.editorContainer),this.editor=pn.create(this.editorContainer,{copyWithSyntaxHighlighting:!1,fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:"log",lineDecorationsWidth:0,lineNumbersMinChars:0,minimap:{enabled:!1},readOnly:!0,renderLineHighlight:"none",scrollBeyondLastLine:!1,value:"",wordWrap:"on"}),this.editor.addCommand(qt.Escape,()=>{}),this.editor.addCommand(yt.Shift|qt.Escape,()=>{}),this.editor.addCommand(qt.Escape,()=>{var t,n;const e=(t=this.editor)==null?void 0:t.getPosition();O(e),(n=this.editor)==null||n.setPosition(e)},"findWidgetVisible && editorTextFocus"),this.editor.addCommand(yt.Shift|qt.Escape,()=>{var t,n;const e=(t=this.editor)==null?void 0:t.getPosition();O(e),(n=this.editor)==null||n.setPosition(e)},"findWidgetVisible && editorTextFocus")}destroyMonaco(){this.editor&&(this.editor.dispose(),this.editor=void 0)}triggerFindWidget(){var e,t;(e=this.editor)==null||e.focus(),(t=this.editor)==null||t.trigger("keyboard","actions.find",void 0)}toggleAll(){const{shownLogLevels:e}=this.state;let t=!0;for(let n=0;n<st.AllLogLevels.length;n+=1){const s=st.AllLogLevels[n];if(!e[s]){t=!1;break}}if(t)this.setState({shownLogLevels:{}});else{const n={};for(let s=0;s<st.AllLogLevels.length;s+=1){const i=st.AllLogLevels[s];n[i]=!0}this.setState({shownLogLevels:n})}}toggleLogLevel(e){const{shownLogLevels:t}=this.state,n=t[e],s={};s[e]=!n,this.updateLogLevels(s)}updateLogLevels(e){let{shownLogLevels:t}=this.state;t={...t,...e},this.setState({shownLogLevels:t})}appendLogText(e){if(!this.editor)return;const t=this.editor.getModel();let n=t==null?void 0:t.getLineCount();O(n);let s=t==null?void 0:t.getLineLength(n);O(s);const i=this.isBottomVisible(),o=[];if(s>0&&(o.push({range:{startLineNumber:n,startColumn:s+1,endLineNumber:n,endColumn:s+1},text:`
|
|
25
|
+
`))}updateActions(){this.setState(e=>{const{selectedRanges:t}=e,n=t.reduce((s,i)=>s+i[1]-i[0]+1,0);return n>0&&n<dn.MAX_SELECTION_COUNT?(Tn.debug("Updating actions",this.itemActions),{actions:this.itemActions}):(Tn.debug("Disabling actions",n),{actions:[]})})}copySelectedCommands(){this.getSelectedCommandText().then(ve.copyToClipboard).catch(Tn.error)}createNotebook(){this.getSelectedCommandText().then(e=>{const{language:t,sendToNotebook:n}=this.props;n({value:e,language:t},!0)}).catch(Tn.error)}sendToNotebook(){this.getSelectedCommandText().then(e=>{const{language:t,sendToNotebook:n}=this.props;n({value:e,language:t})}).catch(Tn.error)}sendToConsole(){const{sendToConsole:e}=this.props;this.getSelectedCommandText().then(e).catch(Tn.error)}runInConsole(){this.getSelectedCommandText().then(e=>{const{sendToConsole:t}=this.props;t(e,!0,!0)}).catch(Tn.error)}handleSelect(e){const{sendToConsole:t}=this.props,{items:n,offset:s}=this.state;if(e<s||e>=s+n.length){Tn.error("Invalid index!",e);return}const{name:i}=n[e-s];t(i)}handleSelectionChange(e){this.setState({selectedRanges:e}),this.updateActions()}handleViewportChange(e,t){this.setState({top:e,bottom:t})}handleSearchChange(e){this.setState({searchText:e.target.value,selectedRanges:[]})}handleViewportUpdate({items:e,offset:t}){const{table:n}=this.props,s=n.size;this.setState({items:e,itemCount:s,offset:t})}renderItem({item:e,itemIndex:t,isSelected:n}){const{language:s,commandHistoryStorage:i}=this.props;return u(Xa,{isSelected:n,item:e,language:s,commandHistoryStorage:i})}focus(){this.searchInputRef.current&&this.searchInputRef.current.focus()}render(){var m;const{language:e,table:t}=this.props,{actions:n,historyActions:s,searchText:i,top:o,bottom:r,items:l,itemCount:a,offset:c,selectedRanges:d}=this.state,h=(m=op.LANGUAGE_MAP.get(e))!=null?m:"";return T("div",{className:"command-history",children:[T("div",{className:"command-history-search-bar",children:[u(_n,{ref:this.searchInputRef,value:i,placeholder:`${h} Command History`,onChange:this.handleSearchChange}),u(Wi,{actions:s,hasSelection:d.length>0})]}),T("div",{className:"command-history-list",children:[u(Zt,{itemCount:a,items:l,offset:c,selectedRanges:d,onSelect:this.handleSelect,onSelectionChange:this.handleSelectionChange,onViewportChange:this.handleViewportChange,renderItem:this.renderItem,rowHeight:dn.ITEM_HEIGHT,isDoubleClickSelect:!0,isMultiSelect:!0,isStickyBottom:!0}),u(jp,{table:t,top:o,bottom:r,search:i,onUpdate:this.handleViewportUpdate}),u(se,{actions:n})]})]})}};let br=dn;br.ITEM_HEIGHT=29;br.MAX_SELECTION_COUNT=1e4;br.menuGroups={send:se.groups.medium+100};class Zp extends y.exports.PureComponent{constructor(t){super(t),this.handleSwitchClick=this.handleSwitchClick.bind(this)}handleSwitchClick(){const{logLevel:t,onClick:n}=this.props;n(t)}render(){const{logLevel:t,on:n}=this.props;return T("div",{className:$("log-level-menu-item",t),children:[u(ia,{on:n,onClick:this.handleSwitchClick}),t]})}}const st=class extends y.exports.PureComponent{constructor(e){super(e),this.handleClearClick=this.handleClearClick.bind(this),this.handleFlushTimeout=this.handleFlushTimeout.bind(this),this.handleLogMessage=this.handleLogMessage.bind(this),this.handleMenuItemClick=this.handleMenuItemClick.bind(this),this.handleResetClick=this.handleResetClick.bind(this),this.handleResize=this.handleResize.bind(this),this.handleToggleAllClick=this.handleToggleAllClick.bind(this),this.logLevelMenuItems={},this.editorContainer=null,this.bufferedMessages=[],this.messages=[],this.state={shownLogLevels:{}}}static getLogText(e){const t=new Date(e.micros/1e3);return`${Is.formatTimestamp(t)} ${e.logLevel} ${e.message}`}componentDidMount(){this.resetLogLevels(),this.initMonaco(),this.startListening(),window.addEventListener("resize",this.handleResize)}componentDidUpdate(e,t){this.updateDimensions();const{shownLogLevels:n}=this.state;t.shownLogLevels!==n&&this.refreshLogText();const{session:s}=this.props;e.session!==s&&(this.stopListening(),this.startListening(),this.clearLogs())}componentWillUnmount(){this.stopFlushTimer(),this.stopListening(),this.destroyMonaco(),window.removeEventListener("resize",this.handleResize)}getMenuActions(e){const t=[];t.push({menuElement:u("div",{className:"log-level-menu-title",children:"Display Log Levels"}),group:1,order:10});for(let n=0;n<st.AllLogLevels.length;n+=1){const s=st.AllLogLevels[n],i=e[s]!=null?e[s]:!1;t.push({title:s,group:1,order:n+100,menuElement:u(Zp,{logLevel:s,on:i,onClick:this.handleMenuItemClick,ref:o=>{o!=null&&(this.logLevelMenuItems[s]=o)}})})}return t.push({group:1,order:1e3,menuElement:T("div",{className:"log-level-menu-controls",children:[u(me,{kind:"ghost",className:"log-level-toggle-all",onClick:this.handleToggleAllClick,children:"Toggle All"}),u(me,{kind:"ghost",onClick:this.handleResetClick,children:"Reset"})]})}),t}resetLogLevels(){const e={};for(let t=0;t<st.AllLogLevels.length;t+=1){const n=st.AllLogLevels[t],s=st.DefaultLogLevels.indexOf(n)>=0;e[n]=s}this.setState({shownLogLevels:e})}startListening(){const{session:e}=this.props;this.cancelListener=e.onLogMessage(this.handleLogMessage)}stopListening(){this.cancelListener!=null&&(this.cancelListener(),this.cancelListener=void 0)}initMonaco(){O(this.editorContainer),this.editor=pn.create(this.editorContainer,{copyWithSyntaxHighlighting:!1,fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:"log",lineDecorationsWidth:0,lineNumbers:"off",lineNumbersMinChars:0,minimap:{enabled:!1},readOnly:!0,renderLineHighlight:"none",scrollBeyondLastLine:!1,value:"",wordWrap:"on"}),this.editor.addCommand(qt.Escape,()=>{}),this.editor.addCommand(yt.Shift|qt.Escape,()=>{}),this.editor.addCommand(qt.Escape,()=>{var t,n;const e=(t=this.editor)==null?void 0:t.getPosition();O(e),(n=this.editor)==null||n.setPosition(e)},"findWidgetVisible && editorTextFocus"),this.editor.addCommand(yt.Shift|qt.Escape,()=>{var t,n;const e=(t=this.editor)==null?void 0:t.getPosition();O(e),(n=this.editor)==null||n.setPosition(e)},"findWidgetVisible && editorTextFocus")}destroyMonaco(){this.editor&&(this.editor.dispose(),this.editor=void 0)}triggerFindWidget(){var e,t;(e=this.editor)==null||e.focus(),(t=this.editor)==null||t.trigger("keyboard","actions.find",void 0)}toggleAll(){const{shownLogLevels:e}=this.state;let t=!0;for(let n=0;n<st.AllLogLevels.length;n+=1){const s=st.AllLogLevels[n];if(!e[s]){t=!1;break}}if(t)this.setState({shownLogLevels:{}});else{const n={};for(let s=0;s<st.AllLogLevels.length;s+=1){const i=st.AllLogLevels[s];n[i]=!0}this.setState({shownLogLevels:n})}}toggleLogLevel(e){const{shownLogLevels:t}=this.state,n=t[e],s={};s[e]=!n,this.updateLogLevels(s)}updateLogLevels(e){let{shownLogLevels:t}=this.state;t={...t,...e},this.setState({shownLogLevels:t})}appendLogText(e){if(!this.editor)return;const t=this.editor.getModel();let n=t==null?void 0:t.getLineCount();O(n);let s=t==null?void 0:t.getLineLength(n);O(s);const i=this.isBottomVisible(),o=[];if(s>0&&(o.push({range:{startLineNumber:n,startColumn:s+1,endLineNumber:n,endColumn:s+1},text:`
|
|
26
26
|
`,forceMoveMarkers:!0}),n+=1,s=0),o.push({range:{startLineNumber:n,startColumn:s,endLineNumber:n,endColumn:s},text:e,forceMoveMarkers:!0}),t==null||t.applyEdits(o),i){const r=t==null?void 0:t.getLineCount();O(r),this.editor.revealLine(r,1)}}refreshLogText(){var s;if(!this.editor)return;this.truncateLogIfNecessary();const{shownLogLevels:e}=this.state,t=this.isBottomVisible();let n="";for(let i=0;i<this.messages.length;i+=1){const o=this.messages[i];if(e[o.logLevel]){const r=st.getLogText(o);r.length>0&&(n+=r,r.charAt(r.length-1)!==`
|
|
27
27
|
`&&(n+=`
|
|
28
28
|
`))}}if(n=n.trimRight(),this.editor.setValue(n),t){const i=(s=this.editor.getModel())==null?void 0:s.getLineCount();O(i),this.editor.revealLine(i,1)}this.stopFlushTimer(),this.bufferedMessages=[]}truncateLogIfNecessary(){this.messages.length>st.maxLogSize&&(this.messages=this.messages.splice(this.messages.length-st.truncateSize))}scrollToBottom(){var t,n,s;if(!this.editor)return;const e=(s=(n=(t=this.editor)==null?void 0:t.getModel)==null?void 0:n.call(t))==null?void 0:s.getLineCount();O(e),this.editor.revealLine(e,1)}isBottomVisible(){if(!this.editor)return!0;const e=this.editor.getModel(),t=e==null?void 0:e.getLineCount();return O(t),this.isLineVisible(t)}isLineVisible(e){var n;const t=(n=this.editor)==null?void 0:n.getVisibleRanges();if(t==null||t.length===0)return!1;for(let s=0;s<t.length;s+=1){const i=t[s];if(i.startLineNumber<=e&&e<=i.endLineNumber)return!0}return!1}isLogItemVisible(e){const{shownLogLevels:t}=this.state;return t[e.logLevel]}flush(){let e="";for(let t=0;t<this.bufferedMessages.length;t+=1){const n=this.bufferedMessages[t],s=st.getLogText(n);e+=s,s.charAt(s.length-1)!==`
|
|
29
29
|
`&&(e+=`
|
|
30
30
|
`)}this.bufferedMessages=[],this.appendLogText(e)}queue(e){this.bufferedMessages.push(e),this.bufferedMessages.length===1&&(this.flushTimer=setTimeout(this.handleFlushTimeout,st.bufferTimeout))}stopFlushTimer(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=void 0)}updateDimensions(){this.editor&&this.editor.layout()}handleClearClick(){this.clearLogs()}clearLogs(){this.messages=[],this.refreshLogText()}handleFlushTimeout(){this.stopFlushTimer(),this.flush()}handleLogMessage(e){this.messages.push(e),this.editor&&this.isLogItemVisible(e)&&this.queue(e)}handleMenuItemClick(e){this.toggleLogLevel(e)}handleResetClick(){this.resetLogLevels()}handleResize(){this.updateDimensions()}handleToggleAllClick(){this.toggleAll()}render(){const e={placement:"bottom-end"},{shownLogLevels:t}=this.state,n=this.getMenuActions(t);return T("div",{className:"log-pane h-100 w-100",children:[T("div",{className:"log-pane-menu",children:[u(me,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:Od,tooltip:"Clear log"}),u(me,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:nd,tooltip:"Log Settings",onClick:()=>{},children:u(An,{actions:n,popperClassName:"log-level-menu-popper",popperOptions:e})})]}),u("div",{className:"log-pane-editor h-100 w-100",ref:s=>{this.editorContainer=s}})]})}};let ei=st;ei.DefaultLogLevels=[Ye.STDOUT,Ye.ERROR,Ye.FATAL,Ye.STDERR,Ye.WARN];ei.AllLogLevels=[Ye.INFO,Ye.STDOUT,Ye.ERROR,Ye.FATAL,Ye.STDERR,Ye.WARN,Ye.DEBUG,Ye.TRACE];ei.bufferTimeout=16;ei.maxLogSize=131072;ei.truncateSize=65536;Ai.register([oc,rc,lc,ac,cc,dc]);const Jp=typeof Co=="function"?Co(Ai):Co.default(Ai),hn=class{constructor(){this.listeners=[],this.isDownsamplingDisabled=!1}getData(){return[]}getDefaultTitle(){return""}getLayout(){return{}}getFilterColumnMap(){return new Map}isFilterRequired(){return!1}setFilter(e){}close(){}setFormatter(e){this.formatter=e}setDownsamplingDisabled(e){this.isDownsamplingDisabled=e}setDimensions(e){this.rect=e}setTitle(e){this.title=e}subscribe(e){this.listeners.push(e)}unsubscribe(e){this.listeners=this.listeners.filter(t=>t!==e)}fireEvent(e){for(let t=0;t<this.listeners.length;t+=1)this.listeners[t](e)}fireUpdate(e){this.fireEvent(new CustomEvent(hn.EVENT_UPDATED,{detail:e}))}fireDisconnect(){this.fireEvent(new CustomEvent(hn.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(hn.EVENT_RECONNECT))}fireDownsampleStart(e){this.fireEvent(new CustomEvent(hn.EVENT_DOWNSAMPLESTARTED,{detail:e}))}fireDownsampleFinish(e){this.fireEvent(new CustomEvent(hn.EVENT_DOWNSAMPLEFINISHED,{detail:e}))}fireDownsampleFail(e){this.fireEvent(new CustomEvent(hn.EVENT_DOWNSAMPLEFAILED,{detail:e}))}fireDownsampleNeeded(e){this.fireEvent(new CustomEvent(hn.EVENT_DOWNSAMPLENEEDED,{detail:e}))}fireLoadFinished(){this.fireEvent(new CustomEvent(hn.EVENT_LOADFINISHED))}};let Qe=hn;Qe.EVENT_UPDATED="ChartModel.EVENT_UPDATED";Qe.EVENT_DISCONNECT="ChartModel.EVENT_DISCONNECT";Qe.EVENT_RECONNECT="ChartModel.EVENT_RECONNECT";Qe.EVENT_DOWNSAMPLESTARTED="ChartModel.EVENT_DOWNSAMPLESTARTED";Qe.EVENT_DOWNSAMPLEFINISHED="ChartModel.EVENT_DOWNSAMPLEFINISHED";Qe.EVENT_DOWNSAMPLEFAILED="ChartModel.EVENT_DOWNSAMPLEFAILED";Qe.EVENT_DOWNSAMPLENEEDED="ChartModel.EVENT_DOWNSAMPLENEEDED";Qe.EVENT_LOADFINISHED="ChartModel.EVENT_LOADFINISHED";const eg="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",tg="#403e41",ng="#5b5a5c",sg="#c0bfbf",ig="#4878ea",og="rgba(91, 90, 92, 0.7)",Je={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:eg,gridcolor:tg,linecolor:ng,zerolinecolor:sg,activecolor:ig,rangebgcolor:og,"area-color":"#76d9e4","trend-color":"#d5f0c1","line-color":"#9edc6f","error-band-line-color":"white","error-band-fill-color":"rgba(213, 240, 193, 0.1)","ohlc-increasing":"#9edc6f","ohlc-decreasing":"#f95d84"},ns=Object.freeze({paper_bgcolor:Je["paper-bgcolor"],plot_bgcolor:Je["plot-bgcolor"],title_color:Je["title-color"],colorway:Je.colorway,gridcolor:Je.gridcolor,linecolor:Je.linecolor,zerolinecolor:Je.zerolinecolor,activecolor:Je.activecolor,rangebgcolor:Je.rangebgcolor,area_color:Je["area-color"],trend_color:Je["trend-color"],line_color:Je["line-color"],error_band_line_color:Je["error-band-line-color"],error_band_fill_color:Je["error-band-fill-color"],ohlc_increasing:Je["ohlc-increasing"],ohlc_decreasing:Je["ohlc-decreasing"]}),Di=te.module("ChartUtils"),En=Object.freeze(E.calendar.DayOfWeek.values()),Sl="io.deephaven.time.DateTime",rg=36e5,lg=1e6;function ag(e){return e.asDate!==void 0}function cg(e){return e.asNumber!==void 0}function vl(e){return e.dhTimeZone!==void 0}function dg(e){return e!=null&&e.range&&(e.autorange===!1||e.autorange===void 0)}const Z=class{static getPlotlyChartType(e,t){switch(e){case E.plot.SeriesPlotStyle.SCATTER:return t?"scatter":"scattergl";case E.plot.SeriesPlotStyle.LINE:return"scatter";case E.plot.SeriesPlotStyle.BAR:case E.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case E.plot.SeriesPlotStyle.PIE:return"pie";case E.plot.SeriesPlotStyle.TREEMAP:return"treemap";case E.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case E.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}static getPlotlyChartMode(e){switch(e){case E.plot.SeriesPlotStyle.SCATTER:return"markers";case E.plot.SeriesPlotStyle.LINE:return"lines";default:return}}static getPlotlyProperty(e,t){switch(e){case E.plot.SeriesPlotStyle.PIE:switch(t){case E.plot.SourceType.X:return"labels";case E.plot.SourceType.Y:return"values"}break;case E.plot.SeriesPlotStyle.OHLC:switch(t){case E.plot.SourceType.TIME:return"x"}break;case E.plot.SeriesPlotStyle.TREEMAP:switch(t){case E.plot.SourceType.X:return"ids";case E.plot.SourceType.Y:return"values";case E.plot.SourceType.LABEL:return"labels";case E.plot.SourceType.PARENT:return"parents";case E.plot.SourceType.COLOR:return"marker.colors"}break}switch(t){case E.plot.SourceType.X:return"x";case E.plot.SourceType.Y:return"y";case E.plot.SourceType.Z:return"z";case E.plot.SourceType.X_LOW:return"xLow";case E.plot.SourceType.X_HIGH:return"xHigh";case E.plot.SourceType.Y_LOW:return"yLow";case E.plot.SourceType.Y_HIGH:return"yHigh";case E.plot.SourceType.TIME:return"time";case E.plot.SourceType.OPEN:return"open";case E.plot.SourceType.HIGH:return"high";case E.plot.SourceType.LOW:return"low";case E.plot.SourceType.CLOSE:return"close";case E.plot.SourceType.SHAPE:return"shape";case E.plot.SourceType.SIZE:return"size";case E.plot.SourceType.LABEL:return"label";case E.plot.SourceType.COLOR:return"color";case E.plot.SourceType.PARENT:return"parent";case E.plot.SourceType.HOVER_TEXT:return"hovertext";case E.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${t}`)}}static getPlotlySeriesOrientation(e){var n,s;const{sources:t}=e;return t.length===2&&((s=(n=t[0])==null?void 0:n.axis)==null?void 0:s.type)===E.plot.AxisType.Y?Z.ORIENTATION.HORIZONTAL:Z.ORIENTATION.VERTICAL}static getPlotlyErrorBars(e,t,n){const s=n.map((o,r)=>o-e[r]),i=t.map((o,r)=>e[r]-o);return{type:"data",symmetric:!1,array:s,arrayminus:i}}static getPlotlyDateFormat(e,t,n){const s=n==null?void 0:n.replace("%","%%").replace(/S{9}/g,"%9f").replace(/S{8}/g,"%8f").replace(/S{7}/g,"%7f").replace(/S{6}/g,"%6f").replace(/S{5}/g,"%5f").replace(/S{4}/g,"%4f").replace(/S{3}/g,"%3f").replace(/S{2}/g,"%2f").replace(/S{1}/g,"%1f").replace(/y{4}/g,"%Y").replace(/y{2}/g,"%y").replace(/M{4}/g,"%B").replace(/M{3}/g,"%b").replace(/M{2}/g,"%m").replace(/M{1}/g,"%-m").replace(/E{4,}/g,"%A").replace(/E{1,}/g,"%a").replace(/d{2}/g,"%d").replace(/([^%]|^)d{1}/g,"$1%-d").replace(/H{2}/g,"%H").replace(/h{2}/g,"%I").replace(/h{1}/g,"%-I").replace(/m{2}/g,"%M").replace(/s{2}/g,"%S").replace("'T'","T").replace(" z","");let i;const o=e==null?void 0:e.getColumnTypeFormatter(t);return o!=null&&vl(o)&&o.dhTimeZone!=null&&o.showTimeZone&&(i=E.i18n.DateTimeFormat.format(" z",new Date,o.dhTimeZone)),{tickformat:s,ticksuffix:i,automargin:!0}}static convertNumberPrefix(e){return e.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(e,t,n){if(!n)return null;const i=n.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);O(i);const[,o,r,l,,a,c,d,h,m]=i,p=l.replace(",","").length,f=r.indexOf(",")>=0||l.indexOf(",")>=0?",":"",C=d!=null&&d!==""?"e":"f",b=h!==""?h:C,w=a.length+c.length,R=`0${p}${f}.${w}${b}`,v=Z.convertNumberPrefix(o),I=Z.convertNumberPrefix(m);return{tickformat:R,tickprefix:v,ticksuffix:I,automargin:!0}}static getPlotlyAxisFormat(e,t=null){const{axis:n,columnType:s}=e,{formatPattern:i}=n;let o=null;return x.isDateType(s)?(o=Z.getPlotlyDateFormat(t,s,i),o=Z.addTickSpacing(o,n,!0)):x.isNumberType(s)&&(o=Z.getPlotlyNumberFormat(t,s,i),o=Z.addTickSpacing(o,n,!1)),n.formatType===E.plot.AxisFormatType.CATEGORY&&(o?o.type="category":o={type:"category",tickformat:void 0,ticksuffix:void 0}),o}static addTickSpacing(e,t,n){const{gapBetweenMajorTicks:s}=t;if(s>0){const i=e||{};let o=s;return n&&(o=s/lg),t.log&&(o=Math.log(o)),i.tickmode="linear",i.dtick=o,i}return e}static getSourceForAxis(e,t){for(let n=0;n<e.series.length;n+=1){const s=e.series[n];for(let i=0;i<s.sources.length;i+=1){const o=s.sources[i];if(o.axis===t)return o}}return null}static getSeriesVisibility(e,t){return t!=null&&t.hiddenSeries!=null&&t.hiddenSeries.includes(e)?"legendonly":!0}static getHiddenLabels(e){return e!=null&&e.hiddenSeries?[...e.hiddenSeries]:[]}static makeSeriesData(e,t,n,s=Z.ORIENTATION.VERTICAL){return{type:e,mode:t,name:n,orientation:s}}static makeSeriesDataFromSeries(e,t,n,s=ns){const{name:i,plotStyle:o,lineColor:r,shapeColor:l,sources:a}=e,c=a.some(g=>{var f;return(f=g.axis)==null?void 0:f.businessCalendar}),d=Z.getChartType(o,c),h=Z.getPlotlyChartMode(o),m=Z.getPlotlySeriesOrientation(e),p=Z.makeSeriesData(d,h,i,m);return Z.addSourcesToSeriesData(p,o,a,t),Z.addStylingToSeriesData(p,o,s,r,l,n),p}static addSourcesToSeriesData(e,t,n,s){const i=e;for(let o=0;o<n.length;o+=1){const r=n[o],{axis:l,type:a}=r,c=Z.getPlotlyProperty(t,a);yl(i,c,[]);const d=l!=null?Z.getAxisPropertyName(l.type):null;if(d!=null){const h=s.get(l.type);if(h){const m=h.indexOf(l),p=m>0?`${m+1}`:"";i[`${d}axis`]=`${d}${p}`}}}}static addStylingToSeriesData(e,t,n=ns,s=null,i=null,o=null){const r=e;r.marker={line:{}},r.line={width:1},t===E.plot.SeriesPlotStyle.AREA?r.fill="tozeroy":t===E.plot.SeriesPlotStyle.STACKED_AREA?r.stackgroup="stack":t===E.plot.SeriesPlotStyle.STEP?r.line.shape="hv":t===E.plot.SeriesPlotStyle.HISTOGRAM?(r.width=[],r.marker.line!==void 0&&Object.assign(r.marker.line,{color:n.paper_bgcolor,width:1})):t===E.plot.SeriesPlotStyle.OHLC?(r.increasing={line:{color:n.ohlc_increasing}},r.decreasing={line:{color:n.ohlc_decreasing}}):t===E.plot.SeriesPlotStyle.PIE?(r.textinfo="label+percent",r.outsidetextfont={color:n.title_color}):t===E.plot.SeriesPlotStyle.TREEMAP&&(r.hoverinfo="text",r.textinfo="label+text",r.tiling={packing:"squarify",pad:0},r.textposition="middle center",r.outsidetextfont={color:n.title_color}),s!=null&&(t===E.plot.SeriesPlotStyle.BAR?r.marker.color=s:r.line.color=s),i!=null&&(r.marker.color=i),o!=null&&t!==E.plot.SeriesPlotStyle.PIE&&(r.visible=o)}static getAxisFormats(e,t){const n=new Map,s={tickformat:null,ticksuffix:null},{charts:i}=e;for(let o=0;o<i.length;o+=1){const r=i[o],l=Z.groupArray(r.axes,"type");for(let a=0;a<r.series.length;a+=1){const c=r.series[a],{sources:d}=c,h=d.filter(m=>m.axis);for(let m=0;m<h.length;m+=1){const p=h[m],{axis:g}=p,{type:f}=g,C=l.get(f);O(C);const b=C.indexOf(g),w=Z.getAxisPropertyName(f);if(w!=null){const S=Z.getAxisLayoutProperty(w,b);if(n.has(S))Di.debug(`${S} already added.`);else{Di.debug(`Adding ${S} to axisFormats.`);const R=Z.getPlotlyAxisFormat(p,t);if(R===null)n.set(S,s);else{n.set(S,R);const{businessCalendar:v}=g;if(v!=null){const I=[],{businessPeriods:M,businessDays:F,holidays:L,timeZone:W}=v,B=t==null?void 0:t.getColumnTypeFormatter(Sl);let N;vl(B)&&(N=B.dhTimeZone);const H=N?(W.standardOffset-N.standardOffset)/60:0;L.length>0&&I.push(...Z.createRangeBreakValuesFromHolidays(L,W,N)),M.forEach(k=>I.push({pattern:"hour",bounds:[Z.periodToDecimal(k.close)+H,Z.periodToDecimal(k.open)+H]})),F.length<En.length&&Z.createBoundsFromDays(F).forEach(k=>I.push({pattern:"day of week",bounds:k})),R.rangebreaks=I}if(n.size===r.axes.length)return n}}}}}}return n}static getChartType(e,t){switch(e){case E.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return Z.getPlotlyChartType(e,t)}}static getAxisPropertyName(e){switch(e){case E.plot.AxisType.X:return"x";case E.plot.AxisType.Y:return"y";default:return null}}static getAxisSide(e){switch(e){case E.plot.AxisPosition.BOTTOM:return"bottom";case E.plot.AxisPosition.TOP:return"top";case E.plot.AxisPosition.LEFT:return"left";case E.plot.AxisPosition.RIGHT:return"right";default:return}}static getChartForSeries(e,t){const{charts:n}=e;for(let s=0;s<n.length;s+=1){const i=n[s];for(let o=0;o<i.series.length;o+=1)if(t===i.series[o])return i}return null}static getLayoutRanges(e){const t={},n=Object.keys(e).filter(s=>s.indexOf("axis")>=0);for(let s=0;s<n.length;s+=1){const i=n[s],o=e[i];dg(o)&&(t[i]=[...o.range])}return t}static updateLayoutAxes(e,t,n=0,s=0,i=null,o=ns){const r=n>0?Math.max(Z.MIN_AXIS_SIZE,Math.min(Z.AXIS_SIZE_PX/s,Z.MAX_AXIS_SIZE)):Z.DEFAULT_AXIS_SIZE,l=s>0?Math.max(Z.MIN_AXIS_SIZE,Math.min(Z.AXIS_SIZE_PX/n,Z.MAX_AXIS_SIZE)):Z.DEFAULT_AXIS_SIZE,a={left:0,bottom:0,top:1,right:1},c=Z.groupArray(t,"position");(c.get(E.plot.AxisPosition.RIGHT)||[]).length>0&&(n>0?a.right=1-Math.max(0,Math.min(Z.LEGEND_WIDTH_PX/n,Z.MAX_LEGEND_SIZE)):a.right=1-Z.DEFAULT_AXIS_SIZE);const h=e,m=Z.groupArray(t,"type"),p=[...m.keys()];for(let g=0;g<p.length;g+=1){const f=p[g],C=Z.getAxisPropertyName(f);if(C!=null){const b=m.get(f),S=f===E.plot.AxisType.Y?s:n;O(b);let R=0;for(R=0;R<b.length;R+=1){const I=b[R],M=Z.getAxisLayoutProperty(C,R);h[M]==null&&(h[M]=Z.makeLayoutAxis(f,o));const F=h[M];if(F!=null){Z.updateLayoutAxis(F,I,R,c,r,l,a);const{range:L,autorange:W}=F;if(i!=null&&L!==void 0&&(W===void 0||W===!1)){const B=i(I),[N,H]=B(L);Di.debug("Setting downsample range",S,N,H),I.range(S,N,H)}else I.range(S)}}let v=Z.getAxisLayoutProperty(C,R);for(;h[v]!=null;)delete h[v],R+=1,v=Z.getAxisLayoutProperty(C,R)}}}static getAxisLayoutProperty(e,t){const n=t>0?`${t+1}`:"";return`${e!=null?e:""}axis${n}`}static updateLayoutAxis(e,t,n,s,i,o,r){var h,m,p;const a=t.type===E.plot.AxisType.Y?o:i,c=e,d=(h=t.label)!=null?h:"";if(c.title!==void 0&&typeof c.title!="string"?c.title.text=d:c.title={text:d},t.log&&(c.type="log"),c.side=Z.getAxisSide(t.position),n>0){c.overlaying=(m=Z.getAxisPropertyName(t.type))!=null?m:void 0;const g=(p=s.get(t.position))!=null?p:[],f=g.indexOf(t);f>0&&(c.anchor="free",t.position===E.plot.AxisPosition.RIGHT?c.position=r.right+(f-g.length+1)*a:t.position===E.plot.AxisPosition.TOP?c.position=r.top+(f-g.length+1)*a:t.position===E.plot.AxisPosition.BOTTOM?c.position=r.bottom+(g.length-f+1)*a:t.position===E.plot.AxisPosition.LEFT&&(c.position=r.left+(g.length-f+1)*a))}else if(t.type===E.plot.AxisType.X){const g=s.get(E.plot.AxisPosition.LEFT)||[],f=s.get(E.plot.AxisPosition.RIGHT)||[],C=Math.max(r.left,r.left+(g.length-1)*o),b=Math.min(r.right-(f.length-1)*o,r.right);c.domain=[C,b]}else if(t.type===E.plot.AxisType.Y){const g=s.get(E.plot.AxisPosition.BOTTOM)||[],f=s.get(E.plot.AxisPosition.TOP)||[],C=Math.max(r.bottom,r.bottom+(g.length-1)*i),b=Math.min(r.top-(f.length-1)*i,r.top);c.domain=[C,b]}}static periodToDecimal(e){const t=e.split(":");return Number(t[0])+Number(t[1])/60}static createBoundsFromDays(e){const t=e.map(o=>En.indexOf(o)),n=En.filter(o=>!e.includes(o)).map(o=>En.indexOf(o)),s=new Set;n.forEach(o=>{for(let r=o+1;r<o+En.length;r+=1){const l=r%En.length;if(t.includes(l)){s.add(l);break}}});const i=[];return s.forEach(o=>{for(let r=o-1;r>o-En.length;r-=1){const l=r<0?r+En.length:r;if(t.includes(l)){const a=(l+1)%7;i.push([a,o]);break}}}),i}static createRangeBreakValuesFromHolidays(e,t,n){const s=[],i=[];return e.forEach(o=>{o.businessPeriods.length>0?i.push(...Z.createPartialHoliday(o,t,n)):s.push(Z.createFullHoliday(o,t,n))}),[{values:s},...i]}static createFullHoliday(e,t,n){return Z.adjustDateForTimeZone(`${e.date.toString()} 00:00:00.000000`,t,n)}static createPartialHoliday(e,t,n){const s=e.date.toString(),i=["00:00"];e.businessPeriods.forEach(r=>{i.push(r.open),i.push(r.close)}),i.push("24:00");const o=[];for(let r=0;r<i.length;r+=2){const l=i[r],a=i[r+1];if(l!==a){const c=[Z.adjustDateForTimeZone(`${s} ${l}:00.000000`,t,n)],d=rg*(Z.periodToDecimal(a)-Z.periodToDecimal(l));o.push({values:c,dvalue:d})}}return o}static adjustDateForTimeZone(e,t,n){return n&&n.standardOffset!==t.standardOffset?Z.unwrapValue(Z.wrapValue(e,Sl,t),n):e}static groupArray(e,t){return e.reduce((n,s)=>{var r;const i=s[t],o=(r=n.get(i))!=null?r:[];return o.push(s),n.set(i,o),n},new Map)}static unwrapValue(e,t){if(e!=null){if(ag(e))return E.i18n.DateTimeFormat.format(Z.DATE_FORMAT,e,t);if(cg(e))return e.asNumber()}return e}static wrapValue(e,t,n=null){if(x.isDateType(t)&&typeof e=="string"){const s=e,i=Z.DATE_FORMAT.substr(0,e.length),o=E.i18n.DateTimeFormat.parse(i,s);if(!n)return o;const r=`${i} Z`,l=E.i18n.DateTimeFormat.format("Z",o,n),a=E.i18n.DateTimeFormat.parse(r,`${s} ${l}`),c=E.i18n.DateTimeFormat.format("Z",a,n);return E.i18n.DateTimeFormat.parse(r,`${s} ${c}`)}return e}static makeLayoutAxis(e,t=ns){const n={automargin:!0,gridcolor:t.gridcolor,linecolor:t.linecolor,rangeslider:{visible:!1},showline:!0,ticklen:5,tickcolor:t.paper_bgcolor,tickfont:{color:t.zerolinecolor},title:{font:{color:t.title_color}}};return e===E.plot.AxisType.X?Object.assign(n,{showgrid:!0}):e===E.plot.AxisType.Y&&Object.assign(n,{zerolinecolor:t.zerolinecolor,zerolinewidth:2}),n}static getColorwayFromTheme(e=ns){let t=[];return e.colorway&&(Array.isArray(e.colorway)?t=e.colorway:typeof e.colorway=="string"?t=e.colorway.split(" "):Di.warn(`Unable to handle colorway property: ${e.colorway}`)),t}static makeDefaultLayout(e=ns){const t={...e,autosize:!0,colorway:Z.getColorwayFromTheme(e),font:{family:"'Fira Sans', sans-serif"},title:{font:{color:e.title_color},yanchor:"top",pad:{...Z.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:e.title_color}},margin:{...Z.DEFAULT_MARGIN},xaxis:Z.makeLayoutAxis(E.plot.AxisType.X,e),yaxis:Z.makeLayoutAxis(E.plot.AxisType.Y,e)};return t.datarevision=0,t}static hydrateSettings(e){return{...e,type:E.plot.SeriesPlotStyle[e.type]}}static titleFromSettings(e){const{series:t,xAxis:n,title:s=`${t.join(", ")} by ${n}`}=e;return s}static makeFigureSettings(e,t){const{series:n,xAxis:s,type:i}=e,o=Z.titleFromSettings(e),r={formatType:`${E.plot.AxisFormatType.NUMBER}`,type:`${E.plot.AxisType.X}`,position:`${E.plot.AxisPosition.BOTTOM}`},l={formatType:`${E.plot.AxisFormatType.NUMBER}`,type:`${E.plot.AxisType.Y}`,position:`${E.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${E.plot.ChartType.XY}`,axes:[r,l],series:n.map(a=>({plotStyle:`${i}`,name:a,dataSources:[{type:`${E.plot.SourceType.X}`,columnName:s,axis:r,table:t},{type:`${E.plot.SourceType.Y}`,columnName:a,axis:l,table:t}]}))}],title:o}}};let ye=Z;ye.DEFAULT_AXIS_SIZE=.15;ye.MIN_AXIS_SIZE=.025;ye.MAX_AXIS_SIZE=.2;ye.AXIS_SIZE_PX=75;ye.LEGEND_WIDTH_PX=50;ye.MAX_LEGEND_SIZE=.25;ye.ORIENTATION=Object.freeze({HORIZONTAL:"h",VERTICAL:"v"});ye.DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSS";ye.DEFAULT_MARGIN=Object.freeze({l:60,r:50,t:30,b:60,pad:0});ye.DEFAULT_TITLE_PADDING=Object.freeze({t:8});ye.SUBTITLE_LINE_HEIGHT=25;const yn=te.module("Chart"),Gs=class extends y.exports.Component{constructor(e){super(e),this.getCachedConfig=Ne((t,n,s,i)=>{const o=[],r=Boolean(t);if(r&&o.push({name:`Downsampling failed: ${t}`,click:()=>{},icon:Gs.convertIcon(Ul),attr:"fill-warning"}),n||s||i||r){const l=Gs.downsampleButtonTitle(s,i),a=Gs.downsampleButtonAttr(s,i),c=s?Ll:Rd;o.push({name:l,icon:Gs.convertIcon(c),click:this.handleDownsampleClick,attr:a})}return{displaylogo:!1,displayModeBar:s||r?!0:"hover",modeBarButtons:[o,["toImage"],["zoom2d","pan2d"],["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]]}}),this.handleAfterPlot=this.handleAfterPlot.bind(this),this.handleDownsampleClick=this.handleDownsampleClick.bind(this),this.handleModelEvent=this.handleModelEvent.bind(this),this.handlePlotUpdate=this.handlePlotUpdate.bind(this),this.handleRelayout=this.handleRelayout.bind(this),this.handleRestyle=this.handleRestyle.bind(this),this.plot=Y.createRef(),this.plotWrapper=Y.createRef(),this.columnFormats=[],this.dateTimeFormatterOptions={},this.decimalFormatOptions={},this.integerFormatOptions={},this.isSubscribed=!1,this.isLoadedFired=!1,this.currentSeries=0,this.state={data:null,downsamplingError:null,isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,layout:{datarevision:0},revision:0}}static convertIcon(e){const[t,,,,n]=e.icon,s=`${n}`;return{width:t,path:s,ascent:t,descent:0,transform:"matrix(1, 0, 0, 1, 0, 0)"}}static downsampleButtonTitle(e,t){return e?"Downsampling in progress...":t?"Downsampling disabled, click to enable":"Downsampling enabled, click to disable"}static downsampleButtonAttr(e,t){return e?"animation-spin":t?void 0:"fill-active"}componentDidMount(){this.updateDimensions(),this.updateModelDimensions(),this.initData(),this.initFormatter();const{isActive:e}=this.props;e&&this.subscribe()}componentDidUpdate(e){const{isActive:t,settings:n}=this.props;this.updateFormatterSettings(n),t!==e.isActive&&(t?this.subscribe():this.unsubscribe())}componentWillUnmount(){this.unsubscribe()}getPlotRect(){var e,t;return(t=(e=this.plotWrapper.current)==null?void 0:e.getBoundingClientRect())!=null?t:null}initData(){const{model:e}=this.props,{layout:t}=this.state;this.setState({data:e.getData(),layout:{...t,...e.getLayout()}})}subscribe(){if(this.isSubscribed)return;const{model:e}=this.props;if(!this.rect||this.rect.width===0||this.rect.height===0){yn.debug2("Delaying subscription until model dimensions are set");return}e.subscribe(this.handleModelEvent),this.isSubscribed=!0}unsubscribe(){if(!this.isSubscribed)return;const{model:e}=this.props;e.unsubscribe(this.handleModelEvent),this.isSubscribed=!1}handleAfterPlot(){this.plot.current!=null}handleDownsampleClick(){this.setState(({isDownsamplingDisabled:e})=>({downsamplingError:null,isDownsampleInProgress:!1,isDownsampleFinished:!1,isDownsamplingDisabled:!e}),()=>{const{model:e}=this.props,{isDownsamplingDisabled:t}=this.state;e.setDownsamplingDisabled(t)})}handleModelEvent(e){var s;const{type:t,detail:n}=e;switch(yn.debug2("Received data update",t,n),t){case Qe.EVENT_UPDATED:{this.currentSeries+=1,this.setState(o=>{const{layout:r,revision:l}=o;return typeof r.datarevision=="number"&&(r.datarevision+=1),{data:n,layout:r,revision:l+1}});const{onUpdate:i}=this.props;i({isLoading:!this.isLoadedFired});break}case Qe.EVENT_LOADFINISHED:{const{onUpdate:i}=this.props;this.isLoadedFired=!0,i({isLoading:!1});break}case Qe.EVENT_DISCONNECT:{const{onDisconnect:i}=this.props;i();break}case Qe.EVENT_RECONNECT:{const{onReconnect:i}=this.props;i();break}case Qe.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case Qe.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case Qe.EVENT_DOWNSAMPLENEEDED:case Qe.EVENT_DOWNSAMPLEFAILED:{const i=(s=n.message)!=null?s:n;this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,downsamplingError:i});const{onError:o}=this.props;o(new Error(i));break}default:yn.debug("Unknown event type",t,e)}}handlePlotUpdate(e){const{layout:t}=e,n=ye.getLayoutRanges(t);!ct(n,this.ranges)&&(this.ranges=n,this.updateModelDimensions(!0))}handleRelayout(e){if(yn.debug("handleRelayout",e),e.hiddenlabels!=null){const{onSettingsChanged:t}=this.props,n=[...e.hiddenlabels];t({hiddenSeries:n})}this.updateModelDimensions()}handleRestyle([e,t]){if(yn.debug("handleRestyle",e,t),Object.keys(e).includes("visible")){const{data:n}=this.state,{onSettingsChanged:s}=this.props;if(n!=null){const i=n.reduce((o,{name:r,visible:l})=>r!=null&&l==="legendonly"?[...o,r]:o,[]);s({hiddenSeries:i})}}}updateModelDimensions(e=!1){const t=this.getPlotRect();if(!t){yn.warn("Unable to get plotting rect");return}if(!this.rect||this.rect.width!==t.width||this.rect.height!==t.height||e){this.rect=t;const{isActive:s,model:i}=this.props;i.setDimensions(t),s&&this.subscribe()}}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}updateFormatterSettings(e){const t=ls.getColumnFormats(e),n=ls.getDateTimeFormatterOptions(e),{decimalFormatOptions:s={},integerFormatOptions:i={}}=e;(!ct(this.columnFormats,t)||!ct(this.dateTimeFormatterOptions,n)||!ct(this.decimalFormatOptions,s)||!ct(this.integerFormatOptions,i))&&(this.columnFormats=ls.getColumnFormats(e),this.dateTimeFormatterOptions=n,this.decimalFormatOptions=s,this.integerFormatOptions=i,this.updateFormatter())}updateFormatter(){const e=new Qt(this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions),{model:t}=this.props;t.setFormatter(e)}updateDimensions(){const e=this.getPlotRect();this.plot.current!=null&&e!=null&&e.width>0&&e.height>0&&Ai.relayout(this.plot.current.el,{autosize:!0}).catch(t=>{yn.debug("Unable to resize, promise rejected",t)})}render(){const{data:e,downsamplingError:t,isDownsampleFinished:n,isDownsampleInProgress:s,isDownsamplingDisabled:i,layout:o,revision:r}=this.state,l=this.getCachedConfig(t,n,s,i),a=e!=null;return u("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:a&&u(Jp,{ref:this.plot,data:e,layout:o,revision:r,config:l,onAfterPlot:this.handleAfterPlot,onError:yn.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}};let hg=Gs;hg.defaultProps={isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:Ln.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}};const et=te.module("FigureChartModel"),Ya=class extends Qe{constructor(e,t={},n=ns){super(),this.addPendingSeries=Tt(()=>{const{pendingSeries:s}=this;for(let i=0;i<s.length;i+=1){const o=s[i];this.addSeries(o),o.subscribe()}this.pendingSeries=[]},Ya.ADD_SERIES_DEBOUNCE),this.getTimeZone=ue((s,i)=>{if(i!=null){const o=i.getColumnTypeFormatter(s);if(o!=null)return o.dhTimeZone}return null}),this.getValueTranslator=ue((s,i)=>{const o=this.getTimeZone(s,i);return r=>ye.unwrapValue(r,o)}),this.getValueParser=ue((s,i)=>{const o=this.getTimeZone(s,i);return r=>ye.wrapValue(r,s,o)}),this.getRangeParser=ue((s,i)=>o=>{let[r,l]=o;const a=this.getValueParser(s,i);return r=a(r),l=a(l),[r,l]}),this.getAxisRangeParser=ue((s,i)=>o=>{const r=ye.getSourceForAxis(s,o);return r?this.getRangeParser(r.columnType,i):l=>l}),this.handleFigureUpdated=this.handleFigureUpdated.bind(this),this.handleFigureDisconnected=this.handleFigureDisconnected.bind(this),this.handleFigureReconnected=this.handleFigureReconnected.bind(this),this.handleFigureSeriesAdded=this.handleFigureSeriesAdded.bind(this),this.handleDownsampleStart=this.handleDownsampleStart.bind(this),this.handleDownsampleFinish=this.handleDownsampleFinish.bind(this),this.handleDownsampleFail=this.handleDownsampleFail.bind(this),this.handleDownsampleNeeded=this.handleDownsampleNeeded.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.figure=e,this.settings=t,this.theme=n,this.data=[],this.layout=ye.makeDefaultLayout(n),this.seriesDataMap=new Map,this.pendingSeries=[],this.oneClicks=[],this.filterColumnMap=new Map,this.lastFilter=new Map,this.isConnected=!0,this.seriesToProcess=new Set,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure()}close(){this.figure.close(),this.addPendingSeries.cancel(),this.stopListeningFigure()}getDefaultTitle(){return this.figure.charts.length>0?this.figure.charts[0].title:""}initAllSeries(){this.oneClicks=[],this.filterColumnMap.clear();const{charts:e}=this.figure,t=[];for(let i=0;i<e.length;i+=1){const o=e[i];for(let r=0;r<o.series.length;r+=1){const l=o.series[r];t.push(l.name),this.addSeries(l)}}const s=[...this.seriesDataMap.keys()].filter(i=>t.indexOf(i)<0);for(let i=0;i<s.length;i+=1){const o=s[i];this.seriesDataMap.delete(o)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(e){const t=ye.getChartForSeries(this.figure,e);if(t==null){et.error("Unable to find matching chart for series",e);return}const n=ye.groupArray(t.axes,"type"),s=ye.makeSeriesDataFromSeries(e,n,ye.getSeriesVisibility(e.name,this.settings),this.theme);if(this.seriesDataMap.set(e.name,s),this.data=[...this.seriesDataMap.values()],e.plotStyle===E.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===E.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=ye.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===E.plot.SeriesPlotStyle.PIE,e.oneClick!=null){const{oneClick:i}=e,{columns:o}=i;for(let r=0;r<o.length;r+=1)this.filterColumnMap.set(o[r].name,o[r]);this.oneClicks.push(i)}this.updateLayoutFormats()}subscribe(e){super.subscribe(e),this.listeners.length===1&&(this.initAllSeries(),this.subscribeFigure())}unsubscribe(e){super.unsubscribe(e),this.listeners.length===0&&this.unsubscribeFigure()}subscribeFigure(){if(!this.isConnected){et.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?E.plot.DownsampleOptions.DISABLE:E.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){this.figure.addEventListener(E.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.addEventListener(E.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.addEventListener(E.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.addEventListener(E.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.addEventListener(E.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.addEventListener(E.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.addEventListener(E.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.addEventListener(E.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.addEventListener(E.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}stopListeningFigure(){this.figure.removeEventListener(E.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.removeEventListener(E.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.removeEventListener(E.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.removeEventListener(E.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.removeEventListener(E.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.removeEventListener(E.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.removeEventListener(E.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.removeEventListener(E.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.removeEventListener(E.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}handleDownsampleStart(e){et.debug("Downsample started",e),this.fireDownsampleStart(e.detail)}handleDownsampleFinish(e){et.debug("Downsample finished",e),this.fireDownsampleFinish(e.detail)}handleDownsampleFail(e){et.error("Downsample failed",e),this.fireDownsampleFail(e.detail)}handleDownsampleNeeded(e){et.info("Downsample needed",e),this.fireDownsampleNeeded(e.detail)}handleFigureUpdated(e){const{detail:t}=e,{series:n}=t;et.debug2("handleFigureUpdated",n);for(let i=0;i<n.length;i+=1){const o=n[i];et.debug2("handleFigureUpdated updating series",o.name);const{sources:r}=o;for(let l=0;l<r.length;l+=1){const a=r[l],{columnType:c,type:d}=a,h=this.getValueTranslator(c,this.formatter),m=t.getArray(o,d,h);this.setDataArrayForSeries(o,d,m)}this.seriesToProcess.delete(o.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(o)}const{data:s}=this;this.fireUpdate(s)}handleRequestFailed(e){et.error("Request failed",e)}resubscribe(){this.listeners.length>0&&(this.unsubscribeFigure(),this.subscribeFigure())}setFormatter(e){super.setFormatter(e),this.updateLayoutFormats(),this.resubscribe()}setDownsamplingDisabled(e){super.setDownsamplingDisabled(e),this.resubscribe()}handleFigureDisconnected(e){et.debug("Figure disconnected",e),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(e){et.debug("Figure reconnected",e),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(e){const{detail:t}=e;et.debug("handleFigureSeriesAdded",t),this.pendingSeries.push(t),this.addPendingSeries()}setDimensions(e){super.setDimensions(e),this.updateAxisPositions()}setTitle(e){var s,i;super.setTitle(e);const t=(i=(s=(e!=null?e:"").match(/<br>/g))==null?void 0:s.length)!=null?i:0,n=ye.DEFAULT_MARGIN.t+t*ye.SUBTITLE_LINE_HEIGHT;this.layout.margin?this.layout.margin.t=n:this.layout.margin={t:n},typeof this.layout.title=="string"?this.layout.title=e:(this.layout.title={...this.layout.title},this.layout.title.text=e,this.layout.title.pad={...this.layout.title.pad},this.layout.title.pad.t=ye.DEFAULT_TITLE_PADDING.t+t*ye.SUBTITLE_LINE_HEIGHT*.5)}getPlotWidth(){var e,t,n,s;return!this.rect||!this.rect.width?0:Math.max(this.rect.width-((t=(e=this.layout.margin)==null?void 0:e.l)!=null?t:0)-((s=(n=this.layout.margin)==null?void 0:n.r)!=null?s:0),0)}getPlotHeight(){var e,t,n,s;return!this.rect||!this.rect.height?0:Math.max(this.rect.height-((t=(e=this.layout.margin)==null?void 0:e.t)!=null?t:0)-((s=(n=this.layout.margin)==null?void 0:n.b)!=null?s:0),0)}updateAxisPositions(){const e=this.getPlotWidth(),t=this.getPlotHeight();for(let n=0;n<this.figure.charts.length;n+=1){const s=this.figure.charts[n],i=this.getAxisRangeParser(s,this.formatter);ye.updateLayoutAxes(this.layout,s.axes,e,t,i,this.theme)}}updateLayoutFormats(){if(!this.formatter)return;ye.getAxisFormats(this.figure,this.formatter).forEach((t,n)=>{et.debug(`Assigning ${n}`,this.layout[n],t);const s=this.layout[n];s!=null?Object.assign(s,t):et.debug(`Ignoring null layout.${n}`)})}setDataArrayForSeries(e,t,n){const{name:s,plotStyle:i}=e,o=this.seriesDataMap.get(s),r=ye.getPlotlyProperty(i,t);o&&yl(o,r,n)}cleanSeries(e){const{name:t,plotStyle:n}=e,s=this.seriesDataMap.get(t);if(s!=null){if(n===E.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:i,xHigh:o}=s;if(i&&o&&i.length===o.length){const r=[];for(let l=0;l<i.length;l+=1)r.push(o[l]-i[l]);s.width=r}}else if(n===E.plot.SeriesPlotStyle.LINE){const{x:i,xLow:o,xHigh:r,y:l,yLow:a,yHigh:c}=s;o&&r&&o!==i&&(s.error_x=ye.getPlotlyErrorBars(i,o,r)),a&&c&&a!==l&&(s.error_y=ye.getPlotlyErrorBars(l,a,c))}else if(n===E.plot.SeriesPlotStyle.TREEMAP){const{ids:i,labels:o}=s;i!==void 0&&o===void 0&&(s.labels=i)}}}getData(){return this.data}getLayout(){return this.layout}getFilterColumnMap(){return new Map(this.filterColumnMap)}isFilterRequired(){return this.oneClicks.find(e=>e.requireAllFiltersToDisplay)!=null}setFilter(e){if(this.oneClicks.length===0){et.warn("Trying to set a filter, but no one click!");return}et.debug("setFilter",e);for(let t=0;t<this.oneClicks.length;t+=1){const n=this.oneClicks[t],{columns:s}=n;new Set([...e.keys(),...this.lastFilter.keys()]).forEach(o=>{const r=e.get(o);this.lastFilter.get(o)!==r&&s.find(l=>l.name===o)!=null&&n.setValueForColumn(o,r)})}this.lastFilter=new Map(e)}setFigure(e){this.close(),this.figure=e,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure(),this.listeners.length>0&&this.subscribeFigure()}updateSettings(e){this.settings=e}};let ug=Ya;ug.ADD_SERIES_DEBOUNCE=50;function mg({text:e,isOpen:t,onClose:n}){const[s,i]=y.exports.useState(!1),[o,r]=y.exports.useState(0),[l,a]=y.exports.useState(!1),[c,d]=y.exports.useState(!1),[h,m]=y.exports.useState(!1),p=y.exports.useRef(),g=y.exports.useRef(null),[f,C]=y.exports.useState(!1);y.exports.useEffect(function(){if(!!t){try{JSON.parse(e),m(!0)}catch{m(!1)}d(!1)}},[t,e]),y.exports.useEffect(function(){p.current&&p.current.layout()},[o]),y.exports.useEffect(function(){p.current&&p.current.updateOptions({lineNumbers:l?"on":"off"})},[l]),y.exports.useEffect(()=>(g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{C(!1)},1e3),()=>{g.current&&clearTimeout(g.current)}),[f]);function b(){var M,F;ve.copyToClipboard((F=(M=p.current)==null?void 0:M.getValue())!=null?F:e).then(()=>{C(!0)})}function w(){a(!l)}function S(){var F;const M=(F=p.current)==null?void 0:F.getModel();!h||!M||(c?(M.setValue(e),d(!1)):(M.setValue(JSON.stringify(JSON.parse(e),void 0,2)),d(!0)),R())}function R(){var F,L;const M=p.current;!M||a(((L=(F=M.getModel())==null?void 0:F.getLineCount())!=null?L:0)>1)}function v(){s&&(p.current=void 0,n())}function I(M){p.current=M,M.onDidContentSizeChange(({contentHeight:F})=>r(F)),R()}return!t&&!s?null:T(zc,{isOpen:t,centered:!0,keyboard:!0,toggle:v,onOpened:()=>i(!0),onClosed:()=>{i(!1),r(0)},className:"theme-bg-dark cell-overflow-modal",children:[T(Gc,{toggle:n,children:[u("h5",{className:"overflow-modal-title",children:"Cell Contents"}),u(me,{kind:"inline",icon:f?Pl:xl,tooltip:f?"Copied contents":"Copy contents",onClick:b}),u(me,{kind:"inline",active:l,icon:rd,tooltip:"Toggle line numbers",onClick:w}),h&&u(me,{kind:"inline",icon:sd,active:c,tooltip:"Format as JSON",onClick:S})]}),u($c,{style:{height:o},children:u(Cr,{onEditorInitialized:I,settings:{value:e,readOnly:!0,wordWrap:"on",language:h?"typescript":"plaintext",folding:h,padding:{bottom:16},lineNumbers:l?"on":"off",overviewRulerLanes:0,renderLineHighlight:"none",find:{seedSearchStringFromSelection:"never"}}})})]})}const pg="###,##0",gg=({gotoRow:e,gotoRowError:t,onSubmit:n,isShown:s,onEntering:i,onEntered:o,onExiting:r,onExited:l,model:a,onGotoRowNumberChanged:c,onClose:d})=>{const h=y.exports.useRef(null),m="Row number",{rowCount:p}=a;return y.exports.useEffect(()=>{var g;document.activeElement!==h.current&&((g=h.current)==null||g.select())},[e]),u(eo,{isShown:s,className:$("goto-row"),onEntering:i,onEntered:()=>{var g;o(),(g=h.current)==null||g.select()},onExiting:r,onExited:l,children:T(Fe,{children:[T("div",{className:"goto-row-wrapper",children:[u("div",{className:"goto-row-text",children:"Go to row"}),u("div",{className:"goto-row-input",children:u("input",{ref:h,type:"number",onKeyDown:g=>{g.key==="Enter"&&(g.stopPropagation(),g.preventDefault(),n())},className:$("form-control",{"is-invalid":t!==""}),placeholder:m,onChange:g=>{c(g)},value:e})}),T("div",{className:"goto-row-text",children:["of ",dh.i18n.NumberFormat.format(pg,p)]}),t&&u("div",{className:"goto-row-error text-danger",children:t})]}),u("div",{className:"goto-row-close",children:u(me,{kind:"ghost",onClick:d,children:u(K,{icon:Gi,style:{marginRight:"0"}})})})]})})},oe=te.module("IrisGrid"),fg=500,Cg=250,bg=250,Qa=Object.freeze({aggregations:[],showOnTop:!1});function Tl({advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}){return e.size===0&&t.aggregations.length===0&&n.length===0&&s.size===0&&i===x.REVERSE_TYPE.NONE&&o==null&&r==null&&l.length===0&&a.length===0}const ss=class extends y.exports.Component{constructor(e){super(e),this.getAdvancedMenuOpenedHandler=ue(P=>this.handleAdvancedMenuOpened.bind(this,P),{max:100}),this.getCachedAdvancedFilterMenuActions=ue((P,_,V,G,Q)=>u(pr,{model:P,column:_,onFilterChange:this.handleAdvancedFilterChange,onSortChange:this.handleAdvancedFilterSortChange,onDone:this.handleAdvancedFilterDone,options:V,sortDirection:G,formatter:Q}),{max:50}),this.getCachedOptionItems=ue((P,_,V,G,Q,J,re,be,ce,Te,_e,Ke,Mt,Xe,Ze)=>{const Le=[];return P&&Le.push({type:we.CHART_BUILDER,title:"Chart Builder",icon:Id}),Le.push({type:we.VISIBILITY_ORDERING_BUILDER,title:"Column Visibility & Ordering",icon:ko}),V&&Le.push({type:we.CONDITIONAL_FORMATTING,title:"Conditional Formatting",icon:Ol}),_&&Le.push({type:we.CUSTOM_COLUMN_BUILDER,title:"Manage Custom Columns",icon:pd}),G&&Le.push({type:we.ROLLUP_ROWS,title:"Rollup Rows",icon:Ad}),Q&&Le.push({type:we.AGGREGATIONS,title:"Aggregate Columns",icon:gd}),J&&Le.push({type:we.SELECT_DISTINCT,title:"Select Distinct Values",icon:md}),re&&Mt&&Le.push({type:we.TABLE_EXPORTER,title:"Download CSV",icon:Jc}),Le.push({type:we.ADVANCED_SETTINGS,title:"Advanced Settings",icon:fd}),Le.push({type:we.QUICK_FILTERS,title:"Quick Filters",subtitle:be.shortcut.getDisplayText(),icon:ki,isOn:_e,onChange:be.action}),Xe&&Le.push({type:we.SEARCH_BAR,title:"Search Bar",subtitle:ce.shortcut.getDisplayText(),icon:_l,isOn:Ke,onChange:ce.action}),Le.push({type:we.GOTO,title:"Go to",subtitle:Te.shortcut.getDisplayText(),icon:ud,isOn:Ze,onChange:Te.action}),Le},{max:1}),this.getCachedHiddenColumns=ue(P=>P,{max:1,normalizer:([P])=>P.join()}),this.getAggregationMap=ue((P,_)=>{const V={};return _.forEach(({operation:G,selected:Q,invert:J})=>{V[G]=Fn.getOperationColumnNames(P,G,Q,J)}),V}),this.getOperationMap=ue((P,_)=>{const V={};return _.filter(G=>!Fn.isRollupOperation(G.operation)).forEach(({operation:G,selected:Q,invert:J})=>{Fn.getOperationColumnNames(P,G,Q,J).forEach(re=>{var ce;const be=[...(ce=V[re])!=null?ce:[],G];V[re]=be})}),V}),this.getOperationOrder=ue(P=>P.map(_=>_.operation).filter(_=>!Fn.isRollupOperation(_))),this.getCachedFormatColumns=ue((P,_)=>Ju(P,_)),this.getCachedModelColumns=ue((P,_)=>P.columns),this.getCachedPreviewFormatColumns=ue((P,_,V,G)=>{if(oe.debug("getCachedPreviewFormatColumns",_,V,G),V!==void 0&&G!==void 0){const Q=[..._];return Q[G]=V,this.getCachedFormatColumns(P,Q)}return this.getCachedFormatColumns(P,_)}),this.getModelRollupConfig=ue((P,_,V)=>ne.getModelRollupConfig(P,_,V)),this.getModelTotalsConfig=ue((P,_,V)=>{var be,ce,Te;const{aggregations:G,showOnTop:Q}=V;if(((ce=(be=_==null?void 0:_.columns)==null?void 0:be.length)!=null?ce:0)>0||((Te=G==null?void 0:G.length)!=null?Te:0)===0)return null;const J=this.getOperationMap(P,G),re=this.getOperationOrder(G);return{operationMap:J,operationOrder:re,showOnTop:Q}}),this.getCachedStateOverride=ue((P,_,V,G,Q,J,re,be,ce,Te)=>({hoverSelectColumn:P,isFilterBarShown:_,isSelectingColumn:V,loadingScrimProgress:G,quickFilters:Q,advancedFilters:J,sorts:re,reverseType:be,rollupConfig:ce,isMenuShown:Te}),{max:1}),this.getCachedFilter=ue((P,_,V,G,Q)=>[...P!=null?P:[],...G!=null?G:[],...ne.getFiltersFromFilterMap(_),...ne.getFiltersFromFilterMap(V),...Q!=null?Q:[]],{max:1}),this.getCachedTheme=ue((P,_)=>({...Ra,...P,autoSelectRow:!_}),{max:1}),this.getAlwaysFetchColumns=ue((P,_,V,G,Q,J)=>{const re=[];for(let ce=0;ce<G;ce+=1)re.push(_[U.getModelIndex(ce,V)].name);for(let ce=0;ce<Q;ce+=1)re.push(_[U.getModelIndex(_.length-1-ce,V)].name);if(J)for(let ce=J[0];ce<=J[1];ce+=1)re.push(_[U.getModelIndex(ce,V)].name);return[...new Set([...P,...re])]}),this.updateSearchFilter=Tt((P,_,V,G)=>{const Q=Ii.createSearchFilter(P,_,V,G);this.setState({searchFilter:Q})},Cg),this.handleConditionalFormatEditorUpdate=Tt(P=>{this.setState({conditionalFormatPreview:P})},bg),this.handleDownloadProgressUpdate=Xs((P,_)=>{const{tableDownloadStatus:V}=this.state;V===wt.DOWNLOAD_STATUS.DOWNLOADING&&this.setState({tableDownloadProgress:P,tableDownloadEstimatedTime:_})},fg),this.getOverflowButtonTooltip=ue(P=>{if(P==null)return null;const _={position:"absolute",...P,pointerEvents:"none"};return u("div",{style:_,children:u(ge,{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 Yi,this.globalColumnFormats=[],this.decimalFormatOptions={},this.integerFormatOptions={},this.truncateNumbersWithPound=!1,this.renderer=new Ks,this.tableSaver=null,this.crossColumnRef=Y.createRef(),this.isAnimating=!1,this.filterInputRef=Y.createRef(),this.toggleFilterBarAction={action:()=>this.toggleFilterBar(),shortcut:Lt.TABLE.TOGGLE_QUICK_FILTER},this.toggleSearchBarAction={action:()=>this.toggleSearchBar(),shortcut:Lt.TABLE.TOGGLE_SEARCH},this.toggleGotoRowAction={action:()=>this.toggleGotoRow(),shortcut:Lt.TABLE.GOTO_ROW},this.discardAction={action:()=>{const{model:P}=this.props;Ae(P)&&P.isEditable&&P.pendingDataMap.size>0&&this.discardPending().catch(oe.error)},shortcut:Lt.INPUT_TABLE.DISCARD},this.commitAction={action:()=>{const{model:P}=this.props;Ae(P)&&P.isEditable&&P.pendingDataMap.size>0&&P.pendingDataErrors.size===0&&this.commitPending().catch(oe.error)},shortcut:Lt.INPUT_TABLE.COMMIT},this.contextActions=[this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,this.discardAction,this.commitAction];const{aggregationSettings:t,conditionalFormats:n,customColumnFormatMap:s,isFilterBarShown:i,isSelectingPartition:o,model:r,movedColumns:l,movedRows:a,partition:c,partitionColumn:d,rollupConfig:h,userColumnWidths:m,userRowHeights:p,showSearchBar:g,searchValue:f,selectedSearchColumns:C,invertSearchColumns:b,advancedFilters:w,quickFilters:S,selectDistinctColumns:R,pendingDataMap:v,canCopy:I,frozenColumns:M}=e,F=[new lm(this),new am(this)];I&&F.push(new im(this));const L=[new cm(this),new dm(this),new hm(this),new gm(this),new pm(this),new Cn(this),new mm(this),new fm(this)],W=l.length>0?l:r.movedColumns,B=a.length>0?a:r.movedRows,N=new wm({userColumnWidths:new Map(m),userRowHeights:new Map(p),movedColumns:W}),H=C!=null?C:[],k=Ii.createSearchFilter(f,H,r.columns,b);this.state={isFilterBarShown:i,isSelectingPartition:o,focusedFilterBarColumn:null,metricCalculator:N,metrics:void 0,keyHandlers:F,mouseHandlers:L,partition:c,partitionColumn:d,partitionTable:null,partitionFilters:[],quickFilters:S?new Map(S):new Map,advancedFilters:new Map(w),shownAdvancedFilter:null,hoverAdvancedFilter:null,sorts:[],reverseType:x.REVERSE_TYPE.NONE,customColumns:[],selectDistinctColumns:R,selectedRanges:[],copyOperation:null,loadingText:null,loadingScrimProgress:null,loadingSpinnerShown:!1,movedColumns:W,movedRows:B,shownColumnTooltip:null,formatter:new Qt,isMenuShown:!1,customColumnFormatMap:new Map(s),conditionalFormats:n,conditionalFormatEditIndex:null,conditionalFormatPreview:void 0,hoverSelectColumn:null,isTableDownloading:!1,isReady:!1,tableDownloadStatus:"",tableDownloadProgress:0,tableDownloadEstimatedTime:0,showSearchBar:g,searchFilter:k,searchValue:f,selectedSearchColumns:H,invertSearchColumns:b,rollupConfig:h,rollupSelectedColumns:[],aggregationSettings:t,selectedAggregation:null,openOptions:[],pendingRowCount:0,pendingDataMap:v!=null?v:new Map,pendingDataErrors:new Map,pendingSavePromise:null,pendingSaveError:null,toastMessage:null,frozenColumns:M,showOverflowModal:!1,overflowText:"",overflowButtonTooltipProps:null,isGotoRowShown:!1,gotoRow:"",gotoRowError:""}}static makeQuickFilter(e,t,n){try{return x.makeQuickFilter(e,t,n)}catch(s){oe.error("Error creating quick filter",s)}return null}componentDidMount(){const{partitionColumn:e,model:t}=this.props,n=e!=null?e:t.columns.find(s=>s.isPartitionColumn);t.isFilterRequired&&t.isValuesTableAvailable&&n!=null?this.loadPartitionsTable(n):this.initState(),this.startListening(t)}componentDidUpdate(e){var d;const{inputFilters:t,isSelectingColumn:n,settings:s,model:i,customFilters:o,sorts:r}=this.props;i!==e.model&&(this.stopListening(e.model),this.startListening(i));const l=t!==e.inputFilters?t.filter(h=>!e.inputFilters.includes(h)):[];if(l.length>0){const{advancedSettings:h}=this.props,m=(d=h.get(cs.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS))!=null?d:!1;m&&(this.clearGridInputField(),this.clearCrossColumSearch()),this.startLoading("Filtering...",!0),this.applyInputFilters(l,m)}n!==e.isSelectingColumn&&this.resetColumnSelection(),s!==e.settings&&this.updateFormatterSettings(s),o!==e.customFilters&&this.startLoading("Filtering...",!0),r!==e.sorts&&this.updateSorts(r);const{loadingScrimStartTime:a,loadingScrimFinishTime:c}=this;a!=null&&c!=null&&window.requestAnimationFrame(()=>{const h=Date.now(),m=h-a,p=c-a,g=Math.min(m/p,1);c<h&&(this.loadingScrimStartTime=void 0,this.loadingScrimFinishTime=void 0),this.setState(f=>f.loadingScrimProgress==null?(oe.debug2("Ignoring scrim update because loading cancelled."),null):{loadingScrimProgress:g})}),this.sendStateChange()}componentWillUnmount(){const{model:e}=this.props;this.stopListening(e),this.pending.cancel(),this.updateSearchFilter.cancel(),this.loadingTimer&&clearTimeout(this.loadingTimer),this.handleDownloadProgressUpdate.cancel(),this.animationFrame!==void 0&&cancelAnimationFrame(this.animationFrame)}getValueForCell(e,t,n=!1){const{model:s}=this.props,i=this.getModelColumn(e),o=this.getModelRow(t);return n&&i!=null&&o!=null?s.valueForCell(i,o):n?null:i!=null&&o!=null?s.textForCell(i,o):""}getModelColumn(e){const{metrics:t}=this.state;O(t);const{modelColumns:n}=t;return n==null?null:e!=null?n.get(e):null}getModelRow(e){const{metrics:t}=this.state;O(t);const{modelRows:n}=t;return n==null?null:e!=null?n.get(e):null}getTheme(){var n;const{model:e,theme:t}=this.props;return this.getCachedTheme(t,(n=Ae(e)&&e.isEditable)!=null?n:!1)}getVisibleColumn(e){const{movedColumns:t}=this.state;return U.getVisibleIndex(e,t)}applyInputFilters(e,t=!1){const{model:n}=this.props,{advancedFilters:s,quickFilters:i}=this.state,o=t?new Map:new Map(s),r=t?new Map:new Map(i);let l=t&&s.size>0;e.forEach(({name:a,type:c,value:d})=>{const h=n.columns.findIndex(({name:m,type:p})=>m===a&&p===c);h>=0?(l=o.delete(h)||l,l=this.applyQuickFilter(h,d,r)||l):oe.error("Unable to find column for inputFilter",a,c,d)}),l&&this.setState({quickFilters:r,advancedFilters:o})}applyQuickFilter(e,t,n){const{model:s}=this.props,{formatter:i}=s,o=s.columns[e];if(t!=null&&`${t}`.trim().length>0){const r=n.get(e);if(r!=null){const{text:l}=r;if(l===t)return oe.debug2("Ignoring change to existing filter"),!1}return n.set(e,{text:t,filter:ss.makeQuickFilter(o,t,i.timeZone)}),!0}return n.delete(e)}setAdvancedFilterMap(e){this.setState({advancedFilters:e})}setAdvancedFilter(e,t,n){oe.debug("Setting advanced filter",e,t),this.startLoading("Filtering...",!0),this.setState(({advancedFilters:s})=>{const i=new Map(s);return t==null?i.delete(e):i.set(e,{filter:t,options:n}),{advancedFilters:i}})}setQuickFilter(e,t,n){oe.debug("Setting quick filter",e,t,n),this.startLoading("Filtering...",!0),this.setState(({quickFilters:s})=>{const i=new Map(s);return i.set(e,{filter:t,text:n}),{quickFilters:i}})}setFilterMap(e){var i;oe.debug("setFilterMap",e);const{advancedSettings:t}=this.props;((i=t.get(cs.LINK_CHANGE_CLEARS_ALL_FILTERS))!=null?i:!1)&&this.clearAllFilters();const{model:s}=this.props;e.forEach(({columnType:o,text:r,value:l},a)=>{const c=s.columns.find(h=>h.name===a&&h.type===o);if(c==null)return;const d=s.getColumnIndexByName(c.name);if(O(d),l===null)this.setQuickFilter(d,c.filter().isNull(),"=null");else{const h=x.isTextType(o)?E.FilterValue.ofString(l):E.FilterValue.ofNumber(l);this.setQuickFilter(d,c.filter().eq(h),`${r}`)}})}removeColumnFilter(e){this.startLoading("Filtering...",!0),this.setState(({advancedFilters:t,quickFilters:n})=>{const s=t?new Map(t):new Map,i=n?new Map(n):new Map;return i.delete(e),s.delete(e),{quickFilters:i,advancedFilters:s}})}clearAllFilters(){oe.debug("Clearing all filters");const{advancedFilters:e,quickFilters:t,searchFilter:n}=this.state;t.size===0&&e.size===0&&n===null||(this.clearGridInputField(),this.startLoading("Clearing Filters...",!0),this.setState({quickFilters:new Map,advancedFilters:new Map,searchValue:"",searchFilter:void 0}))}clearCrossColumSearch(){oe.debug("Clearing cross-column search"),this.setState({searchValue:"",searchFilter:void 0})}clearGridInputField(){this.filterInputRef.current!=null&&this.filterInputRef.current.setValue("")}rebuildFilters(){oe.debug("Rebuilding filters");const{model:e}=this.props,{advancedFilters:t,quickFilters:n}=this.state,{columns:s,formatter:i}=e,o=new Map,r=new Map;t.forEach((l,a)=>{const{options:c}=l,d=s[a],h=x.makeAdvancedFilter(d,c,i.timeZone);o.set(a,{options:c,filter:h})}),n.forEach((l,a)=>{const{text:c}=l,d=s[a];r.set(a,{text:c,filter:ss.makeQuickFilter(d,c,i.timeZone)})}),this.startLoading("Rebuilding filters...",!0),this.setState({quickFilters:r,advancedFilters:o})}setFilters({quickFilters:e,advancedFilters:t}){this.setState({quickFilters:e,advancedFilters:t})}updateFormatterSettings(e,t=!0){var m,p,g;const n=ls.getColumnFormats(e),s=ls.getDateTimeFormatterOptions(e),i=(m=e==null?void 0:e.defaultDecimalFormatOptions)!=null?m:{},o=(p=e==null?void 0:e.defaultIntegerFormatOptions)!=null?p:{},r=(g=e==null?void 0:e.truncateNumbersWithPound)!=null?g:!1,l=!ct(this.globalColumnFormats,n),a=!ct(this.dateTimeFormatterOptions,s),c=!ct(this.decimalFormatOptions,e==null?void 0:e.defaultDecimalFormatOptions),d=!ct(this.integerFormatOptions,o),h=this.truncateNumbersWithPound!==r;(l||a||c||d||h)&&(this.globalColumnFormats=n,this.dateTimeFormatterOptions=s,this.decimalFormatOptions=i,this.integerFormatOptions=o,this.truncateNumbersWithPound=r,this.updateFormatter({},t),a&&t&&this.rebuildFilters())}updateFormatter(e,t=!0){var r;const{customColumnFormatMap:n}=this.state,s={customColumnFormatMap:n,...e},i=[...(r=this.globalColumnFormats)!=null?r:[],...s.customColumnFormatMap.values()],o=new Qt(i,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions,this.truncateNumbersWithPound);oe.debug("updateFormatter",this.globalColumnFormats,i),this.setState({...s,formatter:o},()=>{t&&this.grid&&this.grid.forceUpdate()})}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}initState(){const{applyInputFiltersOnInit:e,inputFilters:t,sorts:n,model:s,reverseType:i,customColumns:o,searchValue:r,selectedSearchColumns:l,invertSearchColumns:a}=this.props,c=l!=null?l:[],d=Ii.createSearchFilter(r,c,s.columns,a);if(e){const h=t.filter(m=>m.value!=null);this.applyInputFilters(h)}this.setState({sorts:n,reverseType:i,customColumns:o,isReady:!0,searchFilter:d}),this.initFormatter()}async loadPartitionsTable(e){const{model:t}=this.props;this.setState({isSelectingPartition:!0});try{const n=await this.pending.add(t.valuesTable(e),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,e),this.setState({isSelectingPartition:!0})}else oe.info("Table does not have any data, just fetching all"),this.setState({isSelectingPartition:!1}),this.handlePartitionFetchAll();this.setState({partitionTable:n,partitionColumn:e},()=>{this.initState()})}catch(n){this.handleTableLoadError(n)}}updatePartition(e,t){const s=[t.filter().eq(E.FilterValue.ofString(e))];this.setState({partition:e,partitionFilters:s})}copyCell(e,t,n=!1){const{canCopy:s}=this.props;if(s){const i=String(this.getValueForCell(e,t,n));ve.copyToClipboard(i).catch(o=>oe.error("Unable to copy cell",o))}else oe.error("Attempted to copyCell for user without copy permission.")}copyRanges(e,t=!1,n=!0,s){const{model:i,canCopy:o}=this.props,{metricCalculator:r,movedColumns:l}=this.state,a=r.getUserColumnWidths();if(o){const c={ranges:j.boundedRanges(e,i.columnCount,i.rowCount),includeHeaders:t,formatValues:n,movedColumns:l,userColumnWidths:a,error:s};this.setState({copyOperation:c})}else oe.error("Attempted copyRanges for user without copy permission.")}startLoading(e,t=!1){var s,i;this.setState({loadingText:e});const n=this.getTheme();if(t&&this.grid&&(this.grid.clearSelectedRanges(),this.grid.setViewState({top:0},!0)),this.loadingScrimStartTime==null){const{minScrimTransitionTime:o,maxScrimTransitionTime:r}=n;O(o),O(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})},ss.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){oe.debug("loading last loading config",this.lastLoadedConfig);const{advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}=this.lastLoadedConfig;this.lastLoadedConfig=null,this.setState({advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a})}else oe.debug("remove all sorts, filters, and custom columns"),this.setState({advancedFilters:new Map,aggregationSettings:Qa,customColumns:[],quickFilters:new Map,reverseType:x.REVERSE_TYPE.NONE,rollupConfig:void 0,selectDistinctColumns:[],sorts:[]})}canRollback(){return this.lastLoadedConfig!=null||!Tl(this.state)}startListening(e){e.addEventListener(he.EVENT.UPDATED,this.handleUpdate),e.addEventListener(he.EVENT.REQUEST_FAILED,this.handleRequestFailed),e.addEventListener(he.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),e.addEventListener(he.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}stopListening(e){e.removeEventListener(he.EVENT.UPDATED,this.handleUpdate),e.removeEventListener(he.EVENT.REQUEST_FAILED,this.handleRequestFailed),e.removeEventListener(he.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),e.removeEventListener(he.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}focus(){var e;(e=this.grid)==null||e.focus()}focusFilterBar(e){var d,h,m;const{model:t}=this.props,{columnCount:n}=t,s=this.getModelColumn(e);if(e==null||s==null||e<0||n<=e||!t.isFilterable(s)){this.setState({focusedFilterBarColumn:null});return}const{metricCalculator:i,metrics:o}=this.state;O(o);const{gridX:r,left:l,rightVisible:a,lastLeft:c}=o;if(e<l)(d=this.grid)==null||d.setViewState({left:e},!0);else if(a<e){const p=(h=this.grid)==null?void 0:h.getMetricState();O(p);const g=i.getLastLeft(p,e,r);(m=this.grid)==null||m.setViewState({left:Math.min(g,c)},!0)}this.lastFocusedFilterBarColumn=e,this.setState({focusedFilterBarColumn:e,isFilterBarShown:!0})}hideColumnByVisibleIndex(e){var s;const{metricCalculator:t,movedColumns:n}=this.state;t.setColumnWidth(U.getModelIndex(e,n),0),(s=this.grid)==null||s.forceUpdate()}freezeColumnByColumnName(e){const{frozenColumns:t,movedColumns:n}=this.state,{model:s}=this.props;oe.debug2("freezing column",e);const i=t==null?new Set(s.frozenColumns):new Set(t);i.add(e);const o=s.getColumnIndexByName(e);O(o);const r=U.getVisibleIndex(o,n),l=U.moveItem(r,i.size-1,n);this.setState({frozenColumns:[...i],movedColumns:l})}unFreezeColumnByColumnName(e){const{frozenColumns:t,movedColumns:n}=this.state,{model:s}=this.props;oe.debug2("unfreezing column",e);const i=t==null?new Set(s.frozenColumns):new Set(t);i.delete(e);const o=s.getColumnIndexByName(e);O(o);const r=U.getVisibleIndex(o,n),l=U.moveItem(r,i.size+s.frontColumns.length,n);this.setState({frozenColumns:[...i],movedColumns:l})}handleColumnVisibilityChanged(e,t){var s;const{metricCalculator:n}=this.state;t===ds.VISIBILITY_OPTIONS.SHOW?e.forEach(i=>{n.resetColumnWidth(i)}):e.forEach(i=>{n.setColumnWidth(i,0)}),(s=this.grid)==null||s.forceUpdate()}handleCrossColumnSearch(e,t,n){const{model:s}=this.props;this.updateSearchFilter(e,t,s.columns,n),this.setState({searchValue:e,selectedSearchColumns:t,invertSearchColumns:n})}handleAnimationLoop(){var e,t;(e=this.grid)==null||e.updateCanvasScale(),(t=this.grid)==null||t.updateCanvas(),this.isAnimating&&(this.animationFrame=requestAnimationFrame(this.handleAnimationLoop))}handleAnimationStart(){oe.debug2("handleAnimationStart"),this.isAnimating=!0,this.animationFrame=requestAnimationFrame(this.handleAnimationLoop)}handleAnimationEnd(){oe.debug2("handleAnimationEnd"),this.isAnimating=!1}handlePartitionAppend(e){const{onPartitionAppend:t}=this.props,{partitionColumn:n}=this.state;t(n,e)}handlePartitionChange(e){const{partitionColumn:t}=this.state;this.updatePartition(e,t)}handlePartitionFetchAll(){this.setState({partitionFilters:[],isSelectingPartition:!1})}handlePartitionDone(){this.setState({isSelectingPartition:!1})}handleTableLoadError(e){if(He.isCanceled(e))return;oe.error(e);const{onError:t}=this.props;t(e)}showAllColumns(){var s;const{metricCalculator:e}=this.state,n=[...e.getUserColumnWidths().entries()];for(let i=0;i<n.length;i+=1){const[o,r]=n[i];r===0&&e.resetColumnWidth(o)}(s=this.grid)==null||s.forceUpdate()}toggleSort(e,t){oe.info("Toggling sort for column",e);const{model:n}=this.props,{sorts:s}=this.state,i=this.getModelColumn(e);O(i);const o=x.toggleSortForColumn(s,n.columns,i,t);this.updateSorts(o)}updateSorts(e){var t;this.startLoading("Sorting..."),this.setState({sorts:e}),(t=this.grid)==null||t.forceUpdate()}sortColumn(e,t=x.sortDirection.none,n=!1,s=!1){var r;O(e);const{model:i}=this.props,o=x.sortColumn(i.sort,i.columns,e,t,n,s);this.startLoading("Sorting..."),this.setState({sorts:o}),(r=this.grid)==null||r.forceUpdate()}reverse(e){var t;this.startLoading("Reversing..."),this.setState({reverseType:e}),(t=this.grid)==null||t.forceUpdate()}isReversible(){const{model:e}=this.props;return e.isReversible}toggleFilterBar(e=this.lastFocusedFilterBarColumn){var n;let{isFilterBarShown:t}=this.state;if(t=!t,this.setState({isFilterBarShown:t}),t)if(e!=null)this.focusFilterBar(e);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&&x.isTextType(a.type)){s=r;break}}}this.focusFilterBar(s)}else(n=this.grid)==null||n.focus()}isTableSearchAvailable(){var s,i,o;const{model:e,canToggleSearch:t}=this.props,n=(s=e==null?void 0:e.layoutHints)==null?void 0:s.searchDisplayMode;return n===((i=E.SearchDisplayMode)==null?void 0:i.SEARCH_DISPLAY_HIDE)?!1:n===((o=E.SearchDisplayMode)==null?void 0:o.SEARCH_DISPLAY_SHOW)?!0:t}toggleSearchBar(){const{showSearchBar:e}=this.state;if(!this.isTableSearchAvailable())return;const t=!e;this.setState({showSearchBar:t},()=>{var n,s,i;t&&((n=this.crossColumnRef)==null?void 0:n.current)?(s=this.crossColumnRef)==null||s.current.focus():(i=this.grid)==null||i.focus()})}toggleGotoRow(e=""){const{isGotoRowShown:t}=this.state;if(e){this.setState({isGotoRowShown:!0,gotoRow:e,gotoRowError:""});return}this.setState({isGotoRowShown:!t,gotoRow:"",gotoRowError:""})}async commitPending(){var i,o;const{model:e}=this.props;if(!Ae(e)||!e.isEditable)throw new Error("Cannot save, table is not editable");const{pendingSavePromise:t}=this.state;if(t!=null)throw new Error("Save already in progress");const n=(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 Wd("Current input is invalid");(o=this.grid)==null||o.focus()}const s=this.pending.add(e.commitPending()).then(()=>{this.setState({pendingSaveError:null,pendingSavePromise:null})}).catch(r=>{He.isCanceled(r)||this.setState({pendingSaveError:r,pendingSavePromise:null})});return this.setState({pendingSavePromise:s}),s}async discardPending(){const{pendingSavePromise:e}=this.state;if(e!=null)throw new Error("Cannot cancel a save in progress");this.setState({pendingSavePromise:null,pendingSaveError:null,pendingDataMap:new Map,pendingDataErrors:new Map})}selectColumn(e){const{onColumnSelected:t}=this.props;t(e)}selectData(e,t){const{model:n}=this.props,{columns:s}=n,i={};for(let r=0;r<s.length;r+=1){const l=s[r],{name:a,type:c}=l,d=n.valueForCell(r,t),h=n.textForCell(r,t);i[a]={value:d,text:h,type:c}}const{onDataSelected:o}=this.props;o(t,i)}handleAdvancedFilterChange(e,t,n){const{model:s}=this.props,i=s.getColumnIndexByName(e.name);O(i),this.setAdvancedFilter(i,t,n)}handleAdvancedFilterSortChange(e,t,n=!1){var a;const{model:s}=this.props,i=s.getColumnIndexByName(e.name);O(i);const o=x.getSortForColumn(s.sort,i);let r=null;(o==null||o.direction!==t)&&(t===x.sortDirection.descending?r=e.sort().desc():r=e.sort().asc());const l=x.setSortForColumn(s.sort,i,r,n);oe.info("Setting table sorts",l),this.startLoading("Sorting..."),this.setState({sorts:l}),(a=this.grid)==null||a.forceUpdate()}handleAdvancedFilterDone(){var e;(e=this.grid)==null||e.focus()}handleAdvancedMenuOpened(e){this.setState({shownAdvancedFilter:e})}handleGotoRowOpened(){this.setState({isGotoRowShown:!0})}handleGotoRowClosed(){this.setState({isGotoRowShown:!1})}handleAdvancedMenuClosed(e){var s,i;const{focusedFilterBarColumn:t,isFilterBarShown:n}=this.state;n&&t===e&&((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(e){const{model:t,onCreateChart:n}=this.props;n(e,t)}handleGridError(e){oe.warn("Grid Error",e),this.setState({toastMessage:u("div",{className:"error-message",children:`${e}`})})}handleFilterBarChange(e){this.startLoading("Filtering...",!0),this.setState(({focusedFilterBarColumn:t,quickFilters:n})=>{const s=new Map(n);if(t!=null){const i=this.getModelColumn(t);O(i),this.applyQuickFilter(i,e,s)}return{quickFilters:s}})}handleFilterBarDone(e=!0,t=!0){var n;e&&((n=this.grid)==null||n.focus()),t&&this.setState({focusedFilterBarColumn:null})}handleFilterBarTab(e){const{focusedFilterBarColumn:t}=this.state;O(t),e?this.focusFilterBar(t-1):this.focusFilterBar(t+1)}handleFormatSelection(e,t){const{model:n}=this.props,s=n.columns[e],{customColumnFormatMap:i}=this.state,o=new Map(i);if(t!=null){const r=x.getNormalizedType(s.type);O(r);const l=Qt.makeColumnFormattingRule(r,s.name,t);o.set(s.name,l)}else o.delete(s.name);this.updateFormatter({customColumnFormatMap:o})}handleMenu(e){e.stopPropagation(),this.setState({isMenuShown:!0})}handleMenuClose(){this.setState({isMenuShown:!1,openOptions:[]})}handleMenuBack(){this.setState(({openOptions:e})=>{const t=[...e];return t.pop(),{openOptions:t}})}handleMenuSelect(e){this.setState(({openOptions:t})=>({openOptions:[...t,e]}))}handleRequestFailed(e){const t=e;if(oe.error("request failed:",t.detail),this.stopLoading(),this.canRollback())this.startLoading("Rolling back changes...",!0),this.rollback();else{oe.error("Table failed and unable to rollback");const{onError:n}=this.props;n(new Error(`Error displaying table: ${t.detail}`))}}handleUpdate(){var d;this.stopLoading(),oe.debug2("Received model update");const{advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}=this.state,c={advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a};Tl(c)?this.lastLoadedConfig=null:this.lastLoadedConfig=c,(d=this.grid)==null||d.forceUpdate()}handleViewChanged(e){var i,o;const{model:t}=this.props,{selectionEndRow:n=0}=(o=(i=this.grid)==null?void 0:i.state)!=null?o:{};let s=0;if(Ae(t)&&t.isEditable){O(e);const{bottomViewport:r}=e,l=t.rowCount-t.floatingBottomRowCount;n===l-1?s=t.pendingRowCount+1:n===l-2?s=t.pendingRowCount:s=Math.max(0,r-(t.rowCount-t.pendingRowCount)-t.floatingTopRowCount-t.floatingBottomRowCount-1)}this.setState({metrics:e,pendingRowCount:s})}handleSelectionChanged(e){O(e);const{onSelectionChanged:t}=this.props,{copyOperation:n}=this.state;this.setState({selectedRanges:e}),n!=null&&this.setState({copyOperation:null}),t(e)}handleMovedColumnsChanged(e,t=()=>null){this.setState({movedColumns:e},t)}handleTooltipRef(e){e!=null&&e.startTimer(),this.tooltip=e}handleConditionalFormatsChange(e){oe.debug("Updated conditional formats",e),this.setState({conditionalFormats:e})}handleConditionalFormatCreate(){oe.debug("Create new conditional format");const{openOptions:e,conditionalFormats:t}=this.state;this.setState({openOptions:[...e,{type:we.CONDITIONAL_FORMATTING_EDIT,title:"Create Formatting Rule"}],conditionalFormatEditIndex:t.length,conditionalFormatPreview:void 0})}handleConditionalFormatEdit(e){oe.debug("Edit conditional format",e);const{openOptions:t,conditionalFormats:n}=this.state;this.setState({openOptions:[...t,{type:we.CONDITIONAL_FORMATTING_EDIT,title:"Edit Formatting Rule"}],conditionalFormatEditIndex:e,conditionalFormatPreview:{...n[e]}})}handleConditionalFormatEditorSave(e){oe.debug("Save conditional format changes",e),this.setState(t=>{if(t.conditionalFormatEditIndex===null)return oe.debug("Invalid format index"),null;const n=[...t.conditionalFormats];return n[t.conditionalFormatEditIndex]=e,{conditionalFormats:n}},()=>{this.handleMenuBack()})}handleConditionalFormatEditorCancel(){this.handleMenuBack(),this.setState({conditionalFormatEditIndex:null})}handleUpdateCustomColumns(e){oe.info("handleUpdateCustomColumns:",e);const{model:t}=this.props,{movedColumns:n,sorts:s,quickFilters:i,advancedFilters:o,selectDistinctColumns:r}=this.state,{columns:l}=t,a=t.customColumns.map(d=>`${d}`),c=ne.getRemovedCustomColumnNames(a,e);if(c.length>0){const d=ne.removeSortsInColumns(s,c),h=ne.removeFiltersInColumns(l,i,c),m=ne.removeFiltersInColumns(l,o,c),p=ne.removeColumnFromMovedColumns(l,n,c),g=ne.removeColumnsFromSelectDistinctColumns(r,c);d.length!==s.length&&(oe.debug("removing sorts from removed custom columns..."),this.setState({sorts:d})),(h.size!==i.size||m.size!==o.size)&&(oe.debug("removing filters from removed custom columns..."),this.setState({quickFilters:h,advancedFilters:m})),ct(n,p)||(oe.debug("change moved columns for removed custom columns",p),this.setState({movedColumns:p})),ct(r,g)||(oe.debug("change selectDistinct columns for removed custom columns",p),this.setState({selectDistinctColumns:g}))}this.setState({customColumns:e}),this.startLoading("Applying custom columns...")}handleCustomColumnsChanged(){var t;oe.debug("custom columns changed");const{isReady:e}=this.state;e?(this.stopLoading(),(t=this.grid)==null||t.forceUpdate()):this.initState()}handlePendingCommitClicked(){return this.commitPending()}handlePendingDiscardClicked(){return this.discardPending()}handlePendingDataUpdated(){var s;oe.debug("pending data updated");const{model:e}=this.props,{pendingDataMap:t,pendingDataErrors:n}=e;this.setState({pendingDataMap:t,pendingDataErrors:n,pendingSaveError:null}),(s=this.grid)==null||s.forceUpdate()}handleAggregationsChange(e){oe.debug("handleAggregationsChange",e),this.startLoading(`Aggregating ${e.aggregations.map(t=>t.operation).join(", ")}...`),this.setState({aggregationSettings:e})}handleAggregationChange(e){oe.debug("handleAggregationChange",e),this.startLoading(`Aggregating ${e.operation}...`),this.setState(({aggregationSettings:t})=>({selectedAggregation:e,aggregationSettings:{...t,aggregations:t.aggregations.map(n=>n.operation===e.operation?e:n)}}))}handleAggregationEdit(e){oe.debug("handleAggregationEdit",e);const{openOptions:t}=this.state;this.setState({openOptions:[...t,{type:we.AGGREGATION_EDIT,title:`Edit Columns to ${e.operation}`}],selectedAggregation:e})}handleRollupChange(e){var t,n;oe.info("Rollup change",e),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Grouping by columns ${(n=(t=e==null?void 0:e.columns)==null?void 0:t.join(", "))!=null?n:""}...`),this.setState({rollupConfig:e,movedColumns:[],sorts:[],reverseType:x.REVERSE_TYPE.NONE,selectDistinctColumns:[]})}handleSelectDistinctChanged(e){oe.debug("SelectDistinct change",e),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Selecting distinct values in ${e.length>0?e.join(", "):""}...`),this.setState({selectDistinctColumns:e,movedColumns:[],sorts:[],reverseType:x.REVERSE_TYPE.NONE})}handleDownloadTableStart(){const{canDownloadCsv:e}=this.props;e?this.setState({isTableDownloading:!0,tableDownloadProgress:0,tableDownloadEstimatedTime:null,tableDownloadStatus:wt.DOWNLOAD_STATUS.INITIATING}):oe.error("Attempted to handleDownloadTableStart for user without download CSV permission.")}handleDownloadTable(e,t,n,s){const{canDownloadCsv:i}=this.props;i?(oe.info("start table downloading",e,t,n,s),this.setState(()=>(this.tableSaver&&this.tableSaver.startDownload(e,t,n,s),{tableDownloadStatus:wt.DOWNLOAD_STATUS.DOWNLOADING}))):oe.error("Attempted to handleDownloadTable for user without download CSV permission.")}handleCancelDownloadTable(){var e;(e=this.tableSaver)==null||e.cancelDownload(),this.setState({isTableDownloading:!1})}handleDownloadCompleted(){this.setState({isTableDownloading:!1,tableDownloadProgress:100,tableDownloadStatus:wt.DOWNLOAD_STATUS.FINISHED})}handleDownloadCanceled(){this.setState({isTableDownloading:!1,tableDownloadProgress:0,tableDownloadStatus:wt.DOWNLOAD_STATUS.CANCELED})}deleteRanges(e){const{model:t}=this.props;this.pending.add(t.delete(e)).catch(n=>{He.isCanceled(n)||oe.error("Unable to delete ranges",e,n)})}resetColumnSelection(){if(this.grid==null)return;const{isSelectingColumn:e}=this.props;if(e){const{columnAllowedCursor:t}=this.props;this.grid.setState({cursor:t})}else this.grid.setState({cursor:null}),this.setState({hoverSelectColumn:null})}resetGridViewState(e=!0){!this.grid||(this.grid.clearSelectedRanges(),this.grid.setViewState({left:0,top:0,topOffset:0,leftOffset:0},e))}sendStateChange(){if(!this.grid)return;const{state:e}=this,{state:t}=this.grid,{onStateChange:n}=this.props;n(e,t)}handleOverflowClose(){this.setState({showOverflowModal:!1})}getColumnBoundingRect(){var m;const{metrics:e,shownColumnTooltip:t}=this.state;O(e),O(t);const n=(m=this.gridWrapper)==null?void 0:m.getBoundingClientRect(),s=20;O(n);const{columnHeaderHeight:i,visibleColumnXs:o,visibleColumnWidths:r,width:l,columnHeaderMaxDepth:a}=e,c=o.get(t),d=r.get(t);O(c),O(d);const h=n.left+rt(c+d/2,s,l-s);return{top:n.top+(a-1)*i,left:n.left+rt(c+d/2,s,l-s),bottom:n.top+a*i,right:n.left+rt(c+d/2,s,l-s)+1,width:1,height:i,x:h,y:n.top,toJSON:()=>{throw new Error("not implemented")}}}handleGotoRowSelectedRowNumberSubmit(){const{gotoRow:e}=this.state;this.focusRowInGrid(e)}focusRowInGrid(e){var i,o,r;const{model:t}=this.props,{rowCount:n}=t;if(this.setState({gotoRow:e}),e===""){this.setState({gotoRowError:""});return}const s=parseInt(e,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(e){const t=e.target.value;this.focusRowInGrid(t)}getColumnTooltip(e,t,n){const{columnHeaderHeight:s,columnHeaderMaxDepth:i,visibleColumnXs:o,visibleColumnWidths:r,width:l}=t,a=o.get(e),c=r.get(e);if(a==null||c==null)return null;const d=Math.max(0,a);let h=c;a+c>l?h=l-a:a<0&&(h=c-Math.abs(a));const m={position:"absolute",top:(i-1)*s,left:d,width:h,height:s,pointerEvents:"none"},p={clientWidth:1,clientHeight:s,getBoundingClientRect:this.getColumnBoundingRect},g={placement:"bottom",modifiers:{flip:{behavior:["bottom","top"]}}},f=this.getModelColumn(e);if(f==null)return null;const C=n.columns[f];return C==null?null:u("div",{style:m,children:u(ge,{timeout:400,interactive:!0,options:g,ref:this.handleTooltipRef,referenceObject:p,onExited:()=>{this.setState({shownColumnTooltip:null})},children:u(Ia,{model:n,column:C,onStatistics:()=>{var b;(b=this.tooltip)==null||b.update()}})},C.name)})}render(){var Be,ms,Sr,vr,Tr,Er,yr,Rr,Ir;const{children:e,customFilters:t,getDownloadWorker:n,isSelectingColumn:s,isStuckToBottom:i,isStuckToRight:o,model:r,name:l,onlyFetchVisibleColumns:a,alwaysFetchColumns:c,advancedSettings:d,onAdvancedSettingsChange:h,canDownloadCsv:m,onCreateChart:p}=this.props,{metricCalculator:g,metrics:f,isFilterBarShown:C,isSelectingPartition:b,isMenuShown:w,isReady:S,copyOperation:R,focusedFilterBarColumn:v,loadingText:I,loadingScrimProgress:M,loadingSpinnerShown:F,keyHandlers:L,mouseHandlers:W,shownColumnTooltip:B,hoverAdvancedFilter:N,shownAdvancedFilter:H,hoverSelectColumn:k,quickFilters:P,advancedFilters:_,partition:V,partitionFilters:G,partitionTable:Q,partitionColumn:J,searchFilter:re,selectDistinctColumns:be,movedColumns:ce,movedRows:Te,formatter:_e,conditionalFormats:Ke,conditionalFormatPreview:Mt,conditionalFormatEditIndex:Xe,sorts:Ze,reverseType:Le,customColumns:_t,selectedRanges:Vn,isTableDownloading:en,tableDownloadStatus:nt,tableDownloadProgress:pe,tableDownloadEstimatedTime:ze,showSearchBar:Ue,searchValue:ht,selectedSearchColumns:Dt,invertSearchColumns:Nt,aggregationSettings:ut,selectedAggregation:Un,rollupConfig:Ft,openOptions:xt,pendingSavePromise:Bn,pendingSaveError:io,pendingRowCount:oo,pendingDataErrors:ro,pendingDataMap:ni,toastMessage:si,frozenColumns:ii,showOverflowModal:oi,overflowText:ri,overflowButtonTooltipProps:li,isGotoRowShown:ai,gotoRow:lo,gotoRowError:ao}=this.state;if(!S)return null;const Wn=this.getTheme(),co=this.getCachedFilter(t,P,_,G,re),us=g.getUserColumnWidths(),As=this.getCachedStateOverride(k,C,s,M,P,_,Ze,Le,Ft,w),ci=f?f.top:0,di=f?f.bottomViewport:0;let ks=null,Ls=null;a&&(ks=f?f.left:0,Ls=f?f.right:0);const ho=f!=null&&f.width>0&&f.height>0,uo=((ms=(Be=Ft==null?void 0:Ft.columns)==null?void 0:Be.length)!=null?ms:0)>0;let hi=null;const mo=f?Math.min(Math.max(ss.minDebounce,Math.round(f.rowCount/200)),ss.maxDebounce):ss.maxDebounce;if(C&&v!=null&&f!=null){const{gridX:xe,gridY:mt,visibleColumnXs:Vt,visibleColumnWidths:zn}=f,$n=Vt.get(v),Ut=zn.get(v);if($n!=null&&Ut!=null){const pt=xe+$n,lt=mt-((Sr=Wn.filterBarHeight)!=null?Sr:0),tn=Ut+1,Gn=((vr=Wn.filterBarHeight)!=null?vr:0)-1,qn={top:lt,left:pt,minWidth:tn,height:Gn};let ps="",nn=!0;const Kn=this.getModelColumn(v);O(Kn);const Xn=P.get(Kn),Ps=_.get(Kn);Xn!=null&&(ps=Xn.text,nn=Xn.filter!=null);const Yn=P.size!==0||_.size!==0;hi=u(va,{ref:this.filterInputRef,style:qn,className:$({error:!nn,active:ps!==""||Ps!=null,"iris-grid-has-filter":Yn}),isAdvancedFilterSet:Ps!=null,onAdvancedFiltersTriggered:()=>{this.setState({shownAdvancedFilter:v})},onChange:this.handleFilterBarChange,onDone:this.handleFilterBarDone,onTab:this.handleFilterBarTab,onContextMenu:(Tr=this.grid)==null?void 0:Tr.handleContextMenu,debounceMs:mo,value:ps},v)}}let ui=null;if(I!=null){const xe=u("div",{className:"iris-grid-loading-status",children:I}),mt=u(lh,{show:F}),Vt=u("button",{type:"button",onClick:this.handleCancel,className:$("btn btn-secondary btn-cancelable iris-grid-btn-cancel",{show:F}),children:"Cancel"}),zn=f?f.gridY:0;ui=T("div",{className:"iris-grid-loading",style:{top:zn},children:[xe,mt,Vt]})}let mi=null;B!=null&&f&&(mi=this.getColumnTooltip(B,f,r),(Er=this.tooltip)==null||Er.update());const pi=[];if(f&&C){const{gridX:xe,gridY:mt,visibleColumns:Vt,visibleColumnXs:zn,visibleColumnWidths:$n}=f,{filterBarHeight:Ut}=Wn;for(let pt=0;pt<Vt.length;pt+=1){const lt=Vt[pt],tn=zn.get(lt),Gn=$n.get(lt),qn=this.getModelColumn(lt);if(qn!=null&&r.isFilterable(qn)&&tn!=null&&Gn!=null&&Gn>0){const nn=xe+tn+Gn-24,Kn=mt-(Ut!=null?Ut:0)+2,Xn={position:"absolute",top:Kn,left:nn},Yn=_.get(qn)!=null,Ci=lt===N||lt===v||Yn,fo=u("div",{className:$("advanced-filter-button-container",{hidden:!Ci}),style:Xn,children:Ci&&u("button",{type:"button",className:$("btn btn-link btn-link-icon advanced-filter-button",{"filter-set":Yn}),onClick:()=>{this.setState({shownAdvancedFilter:lt})},onContextMenu:Za=>{var Mr;(Mr=this.grid)==null||Mr.handleContextMenu(Za)},onMouseEnter:()=>{this.setState({hoverAdvancedFilter:lt})},onMouseLeave:()=>{this.setState({hoverAdvancedFilter:null})},children:T("div",{className:"fa-layers",children:[u(K,{icon:qo,className:"filter-solid"}),u(K,{icon:ki,className:"filter-light"})]})})},lt);pi.push(fo)}}}const gi=[];if(f){const{gridX:xe,visibleColumns:mt,visibleColumnXs:Vt,visibleColumnWidths:zn,columnHeaderHeight:$n}=f;for(let Ut=0;Ut<mt.length;Ut+=1){const pt=mt[Ut],lt=Vt.get(pt),tn=zn.get(pt);if(lt!=null&&tn!=null&&tn>0){const Gn=xe+lt,qn=xe+lt+tn-20,ps=C?{position:"absolute",top:$n,left:qn,width:20,height:Wn.filterBarHeight}:{position:"absolute",top:0,left:Gn,width:tn,height:$n},nn=this.getModelColumn(pt);if(nn!=null){const Kn=r.columns[nn],Xn=_.get(nn),{options:Ps}=Xn||{},Yn=x.getSortForColumn(r.sort,nn),Ci=Yn?Yn.direction:null,fo=u("div",{className:"advanced-filter-menu-container",style:ps,children:u(fn,{className:"advanced-filter-menu-popper",onEntered:this.getAdvancedMenuOpenedHandler(pt),onExited:()=>{this.handleAdvancedMenuClosed(pt)},isShown:H===pt,interactive:!0,closeOnBlur:!0,children:this.getCachedAdvancedFilterMenuActions(r,Kn,Ps,Ci,_e)})},pt);gi.push(fo)}}}}const fi=this.getCachedOptionItems(p!==void 0&&r.isChartBuilderAvailable,r.isCustomColumnsAvailable,r.isFormatColumnsAvailable,r.isRollupAvailable,r.isTotalsAvailable,r.isSelectDistinctAvailable,r.isExportAvailable,this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,C,Ue,m,this.isTableSearchAvailable(),ai),po=xt.map(xe=>{switch(xe.type){case we.CHART_BUILDER:return u(da,{model:r,onChange:this.handleChartChange,onSubmit:this.handleChartCreate},we.CHART_BUILDER);case we.VISIBILITY_ORDERING_BUILDER:return u(ds,{model:r,movedColumns:ce,userColumnWidths:us,onColumnVisibilityChanged:this.handleColumnVisibilityChanged,onMovedColumnsChanged:this.handleMovedColumnsChanged},we.VISIBILITY_ORDERING_BUILDER);case we.CONDITIONAL_FORMATTING:return u(Fm,{rules:Ke,onChange:this.handleConditionalFormatsChange,onCreate:this.handleConditionalFormatCreate,onSelect:this.handleConditionalFormatEdit});case we.CONDITIONAL_FORMATTING_EDIT:return O(r.columns),O(this.handleConditionalFormatEditorUpdate),u(sp,{columns:r.columns,rule:Mt,onUpdate:this.handleConditionalFormatEditorUpdate,onSave:this.handleConditionalFormatEditorSave,onCancel:this.handleConditionalFormatEditorCancel});case we.CUSTOM_COLUMN_BUILDER:return u(dr,{model:r,customColumns:_t,onSave:this.handleUpdateCustomColumns,onCancel:this.handleMenuBack},we.CUSTOM_COLUMN_BUILDER);case we.ROLLUP_ROWS:return u(hr,{model:r,onChange:this.handleRollupChange,config:Ft},we.ROLLUP_ROWS);case we.AGGREGATIONS:return u($h,{settings:ut,isRollup:uo,onChange:this.handleAggregationsChange,onEdit:this.handleAggregationEdit});case we.AGGREGATION_EDIT:return Un&&u(qh,{aggregation:Un,columns:r.originalColumns,onChange:this.handleAggregationChange});case we.TABLE_EXPORTER:return u(wt,{model:r,name:l,isDownloading:en,tableDownloadStatus:nt,tableDownloadProgress:pe,tableDownloadEstimatedTime:ze!=null?ze:void 0,onDownload:this.handleDownloadTable,onDownloadStart:this.handleDownloadTableStart,onCancel:this.handleCancelDownloadTable,selectedRanges:Vn},we.TABLE_EXPORTER);case we.SELECT_DISTINCT:return u(Na,{model:r,selectDistinctColumns:be,onChange:this.handleSelectDistinctChanged});case we.ADVANCED_SETTINGS:return u(gr,{items:d,onChange:h});default:throw Error(`Unexpected option type ${xe.type}`)}}),go=this.getCachedHiddenColumns(ne.getHiddenColumns(us));return T("div",{className:"iris-grid",role:"presentation",children:[T("div",{className:"iris-grid-column",children:[e!=null&&u("div",{className:"iris-grid-bar",children:e}),u(ot,{in:b,timeout:Rt.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:u("div",{className:"iris-grid-partition-selector-wrapper iris-grid-bar iris-grid-bar-primary",children:Q&&J&&u(Da,{table:Q,getFormattedString:(xe,mt,Vt)=>r.displayString(xe,mt,Vt),columnName:J.name,partition:V,onChange:this.handlePartitionChange,onFetchAll:this.handlePartitionFetchAll,onAppend:this.handlePartitionAppend,onDone:this.handlePartitionDone})})}),u(ot,{in:Ue,timeout:Rt.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:u("div",{className:"iris-grid-bar",children:u(Ii,{value:ht,selectedColumns:Dt,invertSelection:Nt,onChange:this.handleCrossColumnSearch,columns:r.columns,ref:this.crossColumnRef})})}),T("div",{className:"grid-wrapper",ref:xe=>{this.gridWrapper=xe},children:[u(Fs,{ref:xe=>{this.grid=xe},isStickyBottom:!Ae(r)||!r.isEditable,isStuckToBottom:i,isStuckToRight:o,metricCalculator:g,model:r,keyHandlers:L,mouseHandlers:W,movedColumns:ce,movedRows:Te,onError:this.handleGridError,onViewChanged:this.handleViewChanged,onSelectionChanged:this.handleSelectionChanged,onMovedColumnsChanged:this.handleMovedColumnsChanged,renderer:this.renderer,stateOverride:As,theme:Wn}),u(mg,{isOpen:oi,text:ri,onClose:this.handleOverflowClose}),ho&&u(ya,{model:r,modelColumns:r.columns,top:ci,bottom:di,left:ks,right:Ls,filter:co,formatter:_e,sorts:Ze,reverseType:Le,movedColumns:ce,customColumns:_t,hiddenColumns:go,alwaysFetchColumns:this.getAlwaysFetchColumns(c,r.columns,ce,r.floatingLeftColumnCount,r.floatingRightColumnCount,(Rr=(yr=this.grid)==null?void 0:yr.state.draggingColumn)==null?void 0:Rr.range),formatColumns:this.getCachedPreviewFormatColumns(this.getCachedModelColumns(r,_t),Ke,Mt,((Ir=xt[xt.length-1])==null?void 0:Ir.type)===we.CONDITIONAL_FORMATTING_EDIT&&Xe!=null?Xe:void 0),rollupConfig:this.getModelRollupConfig(r.originalColumns,Ft,ut),totalsConfig:this.getModelTotalsConfig(r.columns,Ft,ut),selectDistinctColumns:be,pendingRowCount:oo,pendingDataMap:ni,frozenColumns:ii}),!w&&u("div",{className:"grid-settings-button",children:u("button",{type:"button","data-testid":`btn-iris-grid-settings-button-${l}`,className:"btn btn-link btn-link-icon",onClick:this.handleMenu,children:u(K,{icon:ad,transform:"up-1"})})}),hi,ui,pi,mi,gi,li&&this.getOverflowButtonTooltip(li)]}),u(gg,{model:r,isShown:ai,gotoRow:lo,gotoRowError:ao,onSubmit:this.handleGotoRowSelectedRowNumberSubmit,onGotoRowNumberChanged:this.handleGotoRowSelectedRowNumberChanged,onClose:this.handleGotoRowClosed,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:()=>{this.handleAnimationStart(),this.focus()},onExited:this.handleAnimationEnd}),u(sm,{error:io,isSaving:Bn!=null,saveTooltip:`Commit (${this.commitAction.shortcut.getDisplayText()})`,discardTooltip:`Discard (${this.discardAction.shortcut.getDisplayText()})`,pendingDataErrors:ro,pendingDataMap:ni,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,onSave:this.handlePendingCommitClicked,onDiscard:this.handlePendingDiscardClicked}),u(bm,{children:si}),u(Os,{model:r,copyOperation:R!=null?R:void 0,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd}),u(xs,{ref:xe=>{this.tableSaver=xe},getDownloadWorker:n,onDownloadCompleted:this.handleDownloadCompleted,onDownloadCanceled:this.handleDownloadCanceled,onDownloadProgressUpdate:this.handleDownloadProgressUpdate,isDownloading:nt===wt.DOWNLOAD_STATUS.DOWNLOADING,formatter:_e})]}),u(ot,{in:w,timeout:Rt.transitionMidMs,classNames:"slide-left",onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:u("div",{className:"table-sidebar",children:T(uh,{children:[u($r,{title:"Table Options",onClose:this.handleMenuClose,children:u(oa,{onSelect:xe=>this.handleMenuSelect(fi[xe]),items:fi})}),po.map((xe,mt)=>u($r,{title:xt[mt].title,onBack:this.handleMenuBack,onClose:this.handleMenuClose,children:xe},xt[mt].type))]})})}),u(se,{actions:this.contextActions})]})}};let ti=ss;ti.minDebounce=150;ti.maxDebounce=500;ti.loadingSpinnerDelay=800;ti.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:x.REVERSE_TYPE.NONE,customColumns:[],aggregationSettings:Qa,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:Ln.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,truncateNumbersWithPound:!1,formatter:[],decimalFormatOptions:D.exports.shape({defaultFormatString:D.exports.string}),integerFormatOptions:D.exports.shape({defaultFormatString:D.exports.string})},canCopy:!0,canDownloadCsv:!0,frozenColumns:null,theme:Ra,canToggleSearch:!0};class wg extends Error{constructor(t,n){super(`${n} can't be empty (on pending row ${t+1})`),this.isMissingKey=!0,this.rowIndex=t,this.columnName=n}}const Sg=te.module("ColumnHeaderGroup");function El(e){return e instanceof ja}class ja{constructor({name:t,children:n,color:s,depth:i,childIndexes:o}){this.getVisibleRange=Ne(r=>{const l=this.childIndexes.flat(),a=U.getVisibleIndexes(l,r),c=Math.min(...a),d=Math.max(...a);return d-c!==l.length-1&&Sg.warn(`Column header group ${this.name} is not contiguous`),[c,d]}),this.name=t,this.children=n,this.color=s,this.depth=i,this.childIndexes=o}}const Pe=te.module("IrisGridTableModel"),vg=150,Tg=0;function Ni(e){return e.table!==void 0}const Uo=class extends he{constructor(e,t=new Qt,n=null){super(),this.pendingNewRowCount=0,this.columnHeaderGroupMap=new Map,this.columnHeaderParentMap=new Map,this._columnHeaderMaxDepth=null,this._columnHeaderGroups=[],this.getMemoizedColumnMap=Ne(s=>{const i=new Map;return s.forEach(o=>i.set(o.name,o)),i}),this.getColumnIndicesByNameMap=Ne(s=>{const i=new Map;return s.forEach(({name:o},r)=>i.set(o,r)),i}),this.setViewport=Xs((s,i,o)=>{if(i<s){Pe.error("Invalid viewport",s,i);return}const{viewport:r}=this;if(r!=null&&r.top===s&&r.bottom===i&&r.columns===o){Pe.debug2("Ignoring duplicate viewport",r);return}this.viewport={top:s,bottom:i,columns:o},Pe.debug2("setViewport",this.viewport),this.applyViewport()},vg),this.applyViewport=Xs(()=>{if(!this.viewport)return;Pe.debug2("applyViewport",this.viewport);const{top:s,bottom:i,columns:o}=this.viewport,[r,l]=this.getCachedViewportRowRange(s,i);this.applyBufferedViewport(r,l,o)},Tg,{leading:!1}),this.getCachedFormattedString=St((s,i,o,r,l)=>s.getFormattedString(i,o,r,l),{max:1e4}),this.getCachedCustomColumnFormatFlag=St(ls.isCustomColumnFormatDefined,{max:1e4}),this.getCachedViewportRowRange=Ne((s,i)=>{const o=i-s,r=Math.max(0,s-o*Uo.ROW_BUFFER_PAGES),l=i+o*Uo.ROW_BUFFER_PAGES;return[r,l]}),this.getCachedPendingErrors=Ne((s,i,o)=>{const r=new Map;return s.forEach((l,a)=>{var d;const{data:c}=l;for(let h=0;h<o;h+=1)c.has(h)||(r.has(a)||r.set(a,[]),(d=r.get(a))==null||d.push(new wg(a,i[h].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=t,this.inputTable=n,this.subscription=null,this.table=e,this.viewport=null,this.viewportData=null,this.formattedStringData=[],this.pendingStringData=[],this.isSaveInProgress=!1,this.totalsTable=null,this.totalsTablePromise=null,this.totals=null,this.totalsDataMap=null,this.pendingNewDataMap=new Map,this.pendingNewDataErrors=null,this.pendingNewRowCount=0}export(){throw new Error("Method not implemented.")}columnStatistics(e){throw new Error("Method not implemented.")}get customColumns(){return[]}set customColumns(e){throw new Error("Method not implemented.")}get formatColumns(){return[]}set formatColumns(e){throw new Error("Method not implemented.")}updateFrozenColumns(e){throw new Error("Method not implemented.")}get rollupConfig(){throw new Error("Method not implemented.")}set rollupConfig(e){throw new Error("Method not implemented.")}get selectDistinctColumns(){throw new Error("Method not implemented.")}set selectDistinctColumns(e){throw new Error("Method not implemented.")}get columns(){return this.table.columns}close(){this.table.close(),this.totalsTable!==null&&this.totalsTable.close(),this.totalsTablePromise!==null&&this.totalsTablePromise.cancel()}startListening(){super.startListening(),this.table.addEventListener(E.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.addEventListener(E.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.addEventListener(E.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.addEventListener(E.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.addEventListener(E.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable),this.applyViewport()}stopListening(){super.stopListening(),this.table.removeEventListener(E.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.removeEventListener(E.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.removeEventListener(E.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.removeEventListener(E.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.removeEventListener(E.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.removeTotalsListeners(this.totalsTable),this.closeSubscription()}addTotalsListeners(e){e.addEventListener(E.Table.EVENT_UPDATED,this.handleTotalsUpdate),e.setViewport(0,0)}removeTotalsListeners(e){e.removeEventListener(E.Table.EVENT_UPDATED,this.handleTotalsUpdate)}handleTableDisconnect(){this.dispatchEvent(new Re(he.EVENT.DISCONNECT))}handleTableReconnect(){this.dispatchEvent(new Re(he.EVENT.RECONNECT))}handleTableUpdate(e){this.copyViewportData(e.detail),this.dispatchEvent(new Re(he.EVENT.UPDATED))}handleTotalsUpdate(e){this.copyTotalsData(e.detail),this.dispatchEvent(new Re(he.EVENT.UPDATED))}handleRequestFailed(e){this.dispatchEvent(new Re(he.EVENT.REQUEST_FAILED,e))}handleCustomColumnsChanged(){this.dispatchEvent(new Re(he.EVENT.COLUMNS_CHANGED,{detail:this.columns}))}get rowCount(){var e,t,n;return this.table.size+this.pendingNewRowCount+((n=(t=(e=this.totals)==null?void 0:e.operationOrder)==null?void 0:t.length)!=null?n:0)}get pendingDataErrors(){var e,t;return this.getCachedPendingErrors(this.pendingNewDataMap,this.columns,(t=(e=this.inputTable)==null?void 0:e.keyColumns.length)!=null?t:0)}get pendingDataMap(){return this.pendingNewDataMap}set pendingDataMap(e){e!==this.pendingNewDataMap&&(e.forEach((t,n)=>{if(!ne.isValidIndex(n))throw new Error(`Invalid rowIndex ${n}`);const{data:s}=t;s.forEach((i,o)=>{if(!ne.isValidIndex(o))throw new Error(`Invalid columnIndex ${o}`)})}),this.pendingNewDataMap=e,this.pendingNewRowCount=Math.max(this.pendingNewRowCount,this.maxPendingDataRow),this.formattedStringData=[],this.dispatchEvent(new Re(he.EVENT.PENDING_DATA_UPDATED)))}get pendingRowCount(){return this.pendingNewRowCount}set pendingRowCount(e){e!==this.pendingNewRowCount&&(this.pendingNewRowCount=Math.max(0,e,this.maxPendingDataRow),this.dispatchEvent(new Re(he.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 e,t,n;return this.totals!=null&&this.totals.showOnTop?0:(n=(t=(e=this.totals)==null?void 0:e.operationOrder)==null?void 0:t.length)!=null?n:0}get floatingTopRowCount(){var e,t,n;return this.totals!=null&&this.totals.showOnTop&&(n=(t=(e=this.totals)==null?void 0:e.operationOrder)==null?void 0:t.length)!=null?n:0}get isChartBuilderAvailable(){return!0}get isTotalsAvailable(){return this.table.getTotalsTable!=null}get isEditable(){return!this.isSaveInProgress&&this.inputTable!=null}cacheFormattedValue(e,t,n){this.formattedStringData[e]==null&&(this.formattedStringData[e]=[]),this.formattedStringData[e][t]=n}cachePendingValue(e,t,n){this.pendingStringData[e]==null&&(this.pendingStringData[e]=[]),this.pendingStringData[e][t]=n}clearPendingValue(e,t){const n=this.pendingStringData[e];n!=null&&delete n[t]}textValueForCell(e,t){var n,s,i;if(((n=this.pendingStringData[e])==null?void 0:n[t])!==void 0)return this.pendingStringData[e][t];if(((s=this.formattedStringData[e])==null?void 0:s[t])===void 0){const o=this.valueForCell(e,t);if(o==null)return null;const r=(i=this.totalsColumn(e,t))!=null?i:this.columns[e],l=this.getCachedCustomColumnFormatFlag(this.formatter,r.name,r.type);let a;if(!l){const d=this.formatForCell(e,t);(d==null?void 0:d.formatString)!=null&&(a=d)}const c=this.displayString(o,r.type,r.name,a);this.cacheFormattedValue(e,t,c)}return this.formattedStringData[e][t]}textForCell(e,t){const n=this.textValueForCell(e,t);if(n==null&&this.isKeyColumn(e)){const s=this.pendingRow(t);if(s!=null&&this.pendingDataMap.has(s))return"*"}return n!=null?n:""}truncationCharForCell(e){const t=this.columns[e],{type:n}=t;if(x.isNumberType(n)&&this.formatter.truncateNumbersWithPound)return"#"}colorForCell(e,t,n){var i;const s=this.dataForCell(e,t);if(s){const{format:o,value:r}=s;if(r==null||r==="")return O(n.nullStringColor),n.nullStringColor;if(o&&o.color)return o.color;if(this.isPendingRow(t))return O(n.pendingTextColor),n.pendingTextColor;if(r!=null){const l=(i=this.totalsColumn(e,t))!=null?i:this.columns[e];if(x.isDateType(l.type)||l.name==="Date")return O(n.dateColor),n.dateColor;if(x.isNumberType(l.type))return r>0?(O(n.positiveNumberColor),n.positiveNumberColor):r<0?(O(n.negativeNumberColor),n.negativeNumberColor):(O(n.zeroNumberColor),n.zeroNumberColor)}}else if(this.isPendingRow(t)&&this.isKeyColumn(e))return O(n.errorTextColor),n.errorTextColor;return n.textColor}backgroundColorForCell(e,t){var n,s;return(s=(n=this.formatForCell(e,t))==null?void 0:n.backgroundColor)!=null?s:null}textAlignForCell(e){const t=this.columns[e],{type:n}=t;return x.isNumberType(n)?"right":x.isDateType(n)||t.name==="Date"?"center":"left"}textForColumnHeader(e,t=0){var n,s;return(s=(n=this.columnAtDepth(e,t))==null?void 0:n.name)!=null?s:void 0}colorForColumnHeader(e,t=0){var s;const n=this.columnAtDepth(e,t);return El(n)&&(s=n.color)!=null?s:null}getColumnHeaderGroup(e,t){const n=this.columnAtDepth(e,t);if(El(n))return n}getColumnHeaderParentGroup(e,t){var n,s;return this.columnHeaderParentMap.get((s=(n=this.columnAtDepth(e,t))==null?void 0:n.name)!=null?s:"")}columnAtDepth(e,t=0){var o;if(t===0)return this.columns[e];const n=(o=this.columns[e])==null?void 0:o.name;let s=this.columnHeaderParentMap.get(n);if(!s)return;let i=s.depth;for(;i<t;){if(s=this.columnHeaderParentMap.get(s.name),!s)return;i=s.depth}if(s.depth===t)return s}textForRowFooter(e){const t=this.totalsRow(e);return t!=null&&this.totals?this.totals.operationOrder[t]:""}get movedColumns(){var i;let e=[];const t=(o,r)=>{const l=this.getColumnIndexByName(o);if(l==null)throw new Error(`Unknown layout hint column: ${o}`);const a=U.getVisibleIndex(l,e);e=U.moveItem(a,r,e)},n=(o,r)=>{const l=this.columnHeaderGroupMap.get(o);if(!l)throw new Error(`Unknown layout hint group: ${o}`);const a=l.getVisibleRange(e);e=U.moveRange(a,r,e)};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}`);t(a,r),r+=1}),this.frontColumns.forEach(a=>{if(o.has(a))throw new Error(`Column specified in multiple layout hints: ${a}`);t(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}`);t(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 c;if(a!=null)c=U.getVisibleIndex(a,e);else{const d=this.columnHeaderGroupMap.get(l);if(!d)throw new Error(`Unknown column ${l} in group ${r.name}`);[,c]=d.getVisibleRange(e)}for(let d=1;d<r.children.length;d+=1){const h=r.children[d],m=this.columnHeaderGroupMap.get(h),p=this.getColumnIndexByName(h);if(m){const f=m.getVisibleRange(e)[0]<c?c-m.childIndexes.length+1:c+1;n(h,f),c=f+m.childIndexes.length-1}else if(p!=null){const f=U.getVisibleIndex(p,e)<c?c:c+1;t(h,f),c=f}}})}return e}get columnMap(){return this.getMemoizedColumnMap(this.table.columns)}get columnHeaderMaxDepth(){var e,t;return this._columnHeaderMaxDepth==null&&this.setColumnHeaderGroups((e=this.layoutHints)==null?void 0:e.columnGroups),(t=this._columnHeaderMaxDepth)!=null?t:1}set columnHeaderMaxDepth(e){this._columnHeaderMaxDepth=e}setColumnHeaderGroups(e){if(e===this._columnHeaderGroups||(this._columnHeaderGroups=e!=null?e:[],this.columnHeaderMaxDepth=1,this.columnHeaderParentMap=new Map,this.columnHeaderGroupMap=new Map,!e||e.length===0))return;const t=new Map(e.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 c=1;o.children.forEach(h=>{if(n.has(h))throw new Error(`Column group child ${h} specified in multiple groups`);n.add(h);const m=t.get(h),p=this.getColumnIndexByName(h);if(m){const g=s(m);a.push(g.childIndexes.flat()),c=Math.max(c,g.depth+1)}else if(p!=null)a.push(p),c=Math.max(c,1);else throw new Error(`Unknown child ${h} in group ${r}`)});const d=new ja({...o,depth:c,childIndexes:a});return this.columnHeaderGroupMap.set(r,d),o.children.forEach(h=>this.columnHeaderParentMap.set(h,d)),this.columnHeaderMaxDepth=Math.max(this.columnHeaderMaxDepth,d.depth+1),d},i=new Set;e.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(e){var l,a,c,d,h,m,p,g,f,C,b,w,S,R;const t=(c=(a=(l=this.totals)==null?void 0:l.operationOrder)==null?void 0:a.length)!=null?c:0,n=(h=(d=this.totals)==null?void 0:d.showOnTop)!=null?h:!1,s=this.totalsRow(e);if(s!=null){const v=(m=this.totals)==null?void 0:m.operationOrder[s];return O(v),(g=(p=this.totalsDataMap)==null?void 0:p.get(v))!=null?g:null}const i=this.pendingRow(e);if(i!=null)return(f=this.pendingNewDataMap.get(i))!=null?f:null;const o=(b=(C=this.viewportData)==null?void 0:C.offset)!=null?b:0,r=(n?e-t:e)-o;return(R=(S=(w=this.viewportData)==null?void 0:w.rows)==null?void 0:S[r])!=null?R:null}totalsColumn(e,t){var r,l,a,c;const n=this.totalsRow(t);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:Se.SUM,o=this.columns[e];return(c=this.totalsTable)==null?void 0:c.columns.find(d=>{var h;return d.name===`${o.name}__${s}`||(s===i||((h=this.totals)==null?void 0:h.operationOrder.length)===1)&&d.name===o.name})}totalsRow(e){var i,o,r,l,a;const t=(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)?e:e-this.table.size;return s>=0&&s<t?s:null}pendingRow(e){const t=e-this.floatingTopRowCount-this.table.size;return t>=0&&t<this.pendingNewRowCount?t:null}isTotalsRow(e){return this.totalsRow(e)!=null}isPendingRow(e){return this.pendingRow(e)!=null}dataForCell(e,t){var n;return(n=this.row(t))==null?void 0:n.data.get(e)}formatForCell(e,t){var n;return(n=this.dataForCell(e,t))==null?void 0:n.format}valueForCell(e,t){var s;const n=this.dataForCell(e,t);if(n)return(s=n.value)!=null?s:null}copyViewportData(e){if(e==null){Pe.warn("invalid data!");return}this.viewportData=this.extractViewportData(e),this.formattedStringData=[]}copyTotalsData(e){var l,a,c,d,h;if(e==null){Pe.warn("invalid data!");return}const{columns:t,rows:n}=e;if(n.length!==1){Pe.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:Se.SUM,r=(c=this.totals)==null?void 0:c.operationMap;for(let m=0;m<t.length;m+=1){const p=t[m],[g,f=(h=(d=r==null?void 0:r[g])==null?void 0:d[0])!=null?h:o]=p.name.split("__");s.has(f)||s.set(f,{data:new Map});const{data:C}=s.get(f),b=this.columns.findIndex(w=>w.name===g);C.set(b,{value:i.get(p),format:i.getFormat(p)})}Pe.debug2("copyTotalsData",s),this.totalsDataMap=s,this.formattedStringData=[]}getColumnIndexByName(e){return this.getColumnIndicesByNameMap(this.columns).get(e)}extractViewportData(e){const t={offset:e.offset,rows:[]},{columns:n}=e;for(let s=0;s<e.rows.length;s+=1){const i=e.rows[s],o=this.extractViewportRow(i,n);t.rows.push(o)}return t}extractViewportRow(e,t){const n=new Map;for(let s=0;s<t.length;s+=1){const i=t[s],o=this.getColumnIndexByName(i.name);O(o),n.set(o,{value:e.get(i),format:e.getFormat(i)})}return{data:n}}closeSubscription(){Pe.debug2("closeSubscription",this.subscription),this.subscription&&(this.subscription.close(),this.subscription=null),this.setViewport.cancel(),this.applyViewport.cancel()}get filter(){return this.table.filter}set filter(e){this.closeSubscription(),this.table.applyFilter(e),this.applyViewport()}get formatter(){return this.irisFormatter}set formatter(e){this.irisFormatter=e,this.formattedStringData=[],this.dispatchEvent(new Re(he.EVENT.FORMATTER_UPDATED))}displayString(e,t,n="",s){return this.getCachedFormattedString(this.formatter,e,t,n,s)}get sort(){return this.table.sort}set sort(e){this.closeSubscription(),this.table.applySort(e),this.applyViewport()}set totalsConfig(e){if(Pe.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 Re(he.EVENT.UPDATED));return}this.totalsTablePromise=He.makeCancelable(this.table.getTotalsTable(e),t=>t.close()),this.totalsTablePromise.then(t=>{this.totalsTablePromise=null,this.setTotalsTable(t)}).catch(t=>{He.isCanceled(t)||(Pe.error("Unable to set next totalsTable",t),this.totalsTablePromise=null,this.dispatchEvent(new Re(he.EVENT.REQUEST_FAILED,{detail:t})))})}}setTotalsTable(e){Pe.debug("setTotalsTable",e),this.totalsTable!==null&&(this.listenerCount>0&&this.removeTotalsListeners(this.totalsTable),this.totalsTable.close()),this.totalsTable=e,this.totalsDataMap=null,this.listenerCount>0&&this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable)}applyBufferedViewport(e,t,n){Pe.debug2("applyBufferedViewport",e,t,n),this.subscription==null?(Pe.debug2("applyBufferedViewport creating new subscription"),this.subscription=this.table.setViewport(e,t,n)):(Pe.debug2("applyBufferedViewport using existing subscription"),this.subscription.setViewport(e,t,n))}async snapshot(e,t=!1,n=s=>s){if(this.subscription==null)throw new Error("No subscription available");const s=j.consolidate(e);if(!ne.isValidSnapshotRanges(s))throw new Error(`Invalid snapshot ranges ${e}`);const i=new Set,o=[],r=new Set;for(let h=0;h<s.length;h+=1){const m=s[h];O(m.endRow),O(m.startRow);for(let p=m.startRow;p<=m.endRow&&p<this.floatingTopRowCount;p+=1)i.add(p);m.endRow>=this.floatingTopRowCount&&m.startRow<=this.floatingTopRowCount+this.table.size&&o.push(new j(m.startColumn,Math.min(Math.max(0,m.startRow-this.floatingTopRowCount)),m.endColumn,Math.min(Math.max(0,m.endRow-this.floatingTopRowCount),this.table.size-this.floatingTopRowCount)));for(let p=Math.max(m.startRow,this.floatingTopRowCount+this.table.size);p<=m.endRow&&p<this.floatingTopRowCount+this.table.size+this.floatingBottomRowCount;p+=1)r.add(p)}const l=ne.columnsFromRanges(s,this.columns),a=[];t&&a.push(l.map(h=>h.name));const c=[...i].sort();for(let h=0;h<c.length;h+=1){const m=c[h],p=l.map(g=>{const f=this.getColumnIndexByName(g.name);return O(f),n(this.valueForCell(f,m),g)});t&&p.push(this.textForRowFooter(m)),a.push(p)}if(o.length>0){const h=ne.rangeSetFromRanges(o),m=await this.subscription.snapshot(h,l);a.push(...m.rows.map(p=>l.map(g=>n(p.get(g),g))))}const d=[...r].sort();for(let h=0;h<d.length;h+=1){const m=d[h],p=l.map(g=>{const f=this.getColumnIndexByName(g.name);return O(f),n(this.valueForCell(f,m),g)});t&&p.push(this.textForRowFooter(m)),a.push(p)}return a}async textSnapshot(e,t=!1,n=s=>`${s}`){return Pe.debug2("textSnapshot",e,t),(await this.snapshot(e,t,n)).map(i=>i.join(" ")).join(`
|
|
31
31
|
`)}async valuesTable(e){let t=null;try{return t=await this.table.copy(),t.applyFilter([]),t.applySort([]),t.selectDistinct([e])}finally{t!=null&&t.close()}}isColumnMovable(e,t){if(e<0||e>=this.columnCount)return!1;if(t>0)return!0;const n=this.columns[e].name;return this.frontColumns.includes(n)||this.backColumns.includes(n)||this.frozenColumns.includes(n)||!n?!1:!this.isKeyColumn(e)}isKeyColumn(e){var t,n;return e<((n=(t=this.inputTable)==null?void 0:t.keyColumns.length)!=null?n:0)}isRowMovable(){return!1}isEditableRange(e){return this.inputTable!=null&&j.isBounded(e)&&(this.isPendingRow(e.startRow)&&this.isPendingRow(e.endRow)||e.startColumn>=this.inputTable.keyColumns.length&&e.endColumn>=this.inputTable.keyColumns.length)&&e.startRow>=this.floatingTopRowCount&&e.startRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount&&e.endRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount}isDeletableRange(e){return this.inputTable!=null&&e.startRow!=null&&e.endRow!=null&&e.startRow>=this.floatingTopRowCount&&e.startRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount&&e.endRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount}isEditableRanges(e){return e.every(t=>this.isEditableRange(t))}isDeletableRanges(e){return e.every(t=>this.isDeletableRange(t))}getTableAreaRange(){return new j(null,this.floatingTopRowCount,null,this.floatingTopRowCount+this.table.size-1)}getPendingAreaRange(){return new j(null,this.floatingTopRowCount+this.table.size,null,this.floatingTopRowCount+this.table.size+this.pendingNewRowCount-1)}async setValueForCell(e,t,n){return this.setValueForRanges([new j(e,t,e,t)],n)}async setValueForRanges(e,t){var n;if(!this.isEditableRanges(e))throw new Error(`Uneditable ranges ${e}`);try{const s=new Set,i=[];j.forEachCell(e,(c,d)=>{const h=this.columns[c];if(s.add(h),i[c]===void 0){const m=x.makeValue(h.type,t,this.formatter.timeZone);i[c]=m!=null?this.displayString(m,h.type,h.name):null}this.cachePendingValue(c,d,i[c])});const o=this.getPendingAreaRange(),r=e.map(c=>j.intersection(o,c)).filter(c=>c!=null).map(c=>(O(c),j.offset(c,0,-(this.floatingTopRowCount+this.table.size))));if(r.length>0){const c=new Map(this.pendingNewDataMap);j.forEachCell(r,(d,h)=>{c.has(h)||c.set(h,{data:new Map});const m=this.columns[d],p=c.get(h);O(p);const{data:g}=p,f=new Map(g),C=x.makeValue(m.type,t,this.formatter.timeZone);C!=null?f.set(d,{value:C}):f.delete(d),f.size>0?c.set(h,{...p,data:f}):c.delete(h)}),this.pendingDataMap=c}this.dispatchEvent(new Re(he.EVENT.UPDATED));const l=this.getTableAreaRange(),a=e.map(c=>j.intersection(l,c)).filter(c=>c!=null);if(a.length>0){const d=(await this.snapshot(a.map(m=>{var p,g;return new j(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]=x.makeValue(g.type,t,this.formatter.timeZone)}),p}),h=await((n=this.inputTable)==null?void 0:n.addRows(d));Pe.debug("setValueForRanges(",e,",",t,") set tableRanges",a,"result",h)}j.forEachCell(e,(c,d)=>{const h=i[c];O(h),this.cacheFormattedValue(c,d,h)})}catch(s){Pe.error("Unable to set ranges",e,t,s)}finally{j.forEachCell(e,(s,i)=>{this.clearPendingValue(s,i)})}}async setValues(e=[]){var t;if(Pe.debug("setValues(",e,")"),!e.every(n=>{var s,i;return this.isEditableRange(j.makeCell((s=n.column)!=null?s:n.x,(i=n.row)!=null?i:n.y))}))throw new Error(`Uneditable ranges ${e}`);try{const n=new Map(this.pendingNewDataMap);e.forEach(l=>{var f,C;const{text:a}=l,c=(f=l.column)!=null?f:l.x,d=(C=l.row)!=null?C:l.y,h=this.columns[c],m=x.makeValue(h.type,a,this.formatter.timeZone),p=m!=null?this.displayString(m,h.type,h.name):null;this.cachePendingValue(c,d,p);const g=this.pendingRow(d);if(g!=null){n.has(g)||n.set(g,{data:new Map});const b=n.get(g);O(b);const{data:w}=b,S=new Map(w);m!=null?S.set(c,{value:m}):S.delete(c),S.size>0?n.set(g,{...b,data:S}):n.delete(g)}}),this.pendingDataMap=n,this.dispatchEvent(new Re(he.EVENT.UPDATED));const s=e.reduce((l,a)=>{var d,h;const c=(d=a.row)!=null?d:a.y;return l.has(c)||l.set(c,[]),(h=l.get(c))==null||h.push(a),l},new Map),i=j.consolidate(e.map(l=>{var a,c;return j.makeCell((a=l.column)!=null?a:l.x,(c=l.row)!=null?c:l.y)})),o=this.getTableAreaRange(),r=i.map(l=>j.intersection(o,l)).filter(l=>l!=null);if(r.length>0){const a=(await this.snapshot(r.map(d=>(O(d),new j(null,d.startRow,null,d.endRow))))).map((d,h)=>{let m=null,p=h;for(let C=0;C<r.length;C+=1){const b=r[C];O(b);const w=j.rowCount([b]);if(p<w){O(b.startRow),m=b.startRow+p;break}p-=w}const g={};for(let C=0;C<this.columns.length;C+=1)g[this.columns[C].name]=d[C];O(m);const f=s.get(m);return f!=null&&f.forEach(C=>{var w;const b=this.columns[(w=C.column)!=null?w:C.x];g[b.name]=x.makeValue(b.type,C.text,this.formatter.timeZone)}),g});Pe.info("setValues setting tableRanges",r);const c=await((t=this.inputTable)==null?void 0:t.addRows(a));Pe.info("setValues set tableRanges",r,"SUCCESS",c)}e.forEach(l=>{var g,f;const{text:a}=l,c=(g=l.column)!=null?g:l.x,d=(f=l.row)!=null?f:l.y,h=this.columns[c],m=x.makeValue(h.type,a,this.formatter.timeZone),p=m!=null?this.displayString(m,h.type,h.name):null;this.cacheFormattedValue(c,d,p)})}finally{e.forEach(n=>{this.clearPendingValue(n.column,n.row)})}}async commitPending(){var e,t,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 c=this.columns[a];r[c.name]=l}),s.push(r)});const i=await((e=this.inputTable)==null?void 0:e.addRows(s));Pe.debug("commitPending()",this.pendingNewDataMap,"result",i),this.pendingNewDataMap=new Map,this.pendingNewDataErrors=new Map,this.pendingNewRowCount=Math.max(0,((n=(t=this.viewport)==null?void 0:t.bottom)!=null?n:0)-this.table.size),this.formattedStringData=[],this.dispatchEvent(new Re(he.EVENT.PENDING_DATA_UPDATED))}finally{this.isSaveInProgress=!1}}editValueForCell(e,t){return this.textValueForCell(e,t)}async delete(e){if(!this.isDeletableRanges(e))throw new Error(`Undeletable ranges ${e}`);O(this.inputTable);const{keyColumns:t}=this.inputTable;if(t.length===0)throw new Error("No key columns to allow deletion");const n=this.getPendingAreaRange(),s=e.map(d=>j.intersection(n,d)).filter(d=>d!=null).map(d=>(O(d),j.offset(d,0,-(this.floatingTopRowCount+this.table.size))));if(s.length>0){const d=new Map(this.pendingNewDataMap);for(let h=0;h<s.length;h+=1){const m=s[h];O(m.startRow),O(m.endRow);for(let p=m.startRow;p<=m.endRow;p+=1)d.delete(p)}this.pendingNewDataMap=d,this.formattedStringData=[],this.dispatchEvent(new Re(he.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new Re(he.EVENT.UPDATED))}const i=this.getTableAreaRange(),o=e.map(d=>j.intersection(i,d)).filter(d=>d!=null);if(o.length<=0)return;const[r,l]=await Promise.all([this.snapshot(o.map(d=>(O(d),new j(0,d.startRow,t.length-1,d.endRow)))),this.table.copy()]),c=r.map(d=>{const h=[];for(let m=0;m<t.length;m+=1){const p=t[m],g=d[m],f=x.makeFilterRawValue(p.type,g),C=p.filter().eq(f);h.push(C)}return h.reduce((m,p)=>{var g;return(g=m==null?void 0:m.and(p))!=null?g:p})}).reduce((d,h)=>{var m;return(m=d==null?void 0:d.or(h))!=null?m:h});l.applyFilter([c]),l.close()}isValidForCell(e,t,n){try{const s=this.columns[e];return x.makeValue(s.type,n,this.formatter.timeZone),!0}catch{return!1}}};let wr=Uo;wr.ROW_BUFFER_PAGES=1;const Rn=te.module("IrisGridTableModel"),Fo=Object.freeze([]);class Eg extends wr{constructor(t,n=new Qt,s=null){super(t,n,s),this.getMemoizedFrontColumns=Ne(i=>i!=null?i:Fo),this.getMemoizedBackColumns=Ne(i=>i!=null?i:Fo),this.getMemoizedFrozenColumns=Ne((i,o)=>{var r;return(r=o!=null?o:i)!=null?r:Fo}),this.getCachedFilterableColumnSet=Ne(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 t;return this.getMemoizedFrontColumns((t=this.layoutHints)==null?void 0:t.frontColumns)}get backColumns(){var t;return this.getMemoizedBackColumns((t=this.layoutHints)==null?void 0:t.backColumns)}get frozenColumns(){var t;return this.getMemoizedFrozenColumns((t=this.layoutHints)==null?void 0:t.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(t){if(Rn.debug2("set customColumns",t,this.customColumnList,t===this.customColumnList),this.customColumnList.length===0&&t.length===0){Rn.debug("Ignore empty initial customColumns"),this.customColumnList=t;return}if(this.customColumnList===t){Rn.debug("Ignore same customColumns");return}this.closeSubscription(),this.customColumnList=t,this.table.applyCustomColumns([...t,...this.formatColumns]),this.applyViewport()}get formatColumns(){return this.formatColumnList}set formatColumns(t){if(Rn.debug2("set formatColumns",t,this.formatColumnList,t===this.formatColumnList),this.formatColumnList.length===0&&t.length===0){Rn.debug("Ignore empty initial formatColumns"),this.formatColumnList=t;return}if(this.formatColumnList===t){Rn.debug("Ignore same formatColumns");return}this.closeSubscription(),this.formatColumnList=t,this.table.applyCustomColumns([...this.customColumns,...t]),this.applyViewport()}updateFrozenColumns(t){this.userFrozenColumns=t,this.dispatchEvent(new Re(he.EVENT.TABLE_CHANGED,{detail:this.table}))}set totalsConfig(t){if(Rn.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 Re(he.EVENT.UPDATED));return}this.totalsTablePromise=He.makeCancelable(this.table.getTotalsTable(t),n=>n.close()),this.totalsTablePromise.then(n=>{this.totalsTablePromise=null,this.setTotalsTable(n)}).catch(n=>{He.isCanceled(n)||(Rn.error("Unable to set next totalsTable",n),this.totalsTablePromise=null,this.dispatchEvent(new Re(he.EVENT.REQUEST_FAILED,{detail:n})))})}}get isFilterRequired(){return this.table.isUncoalesced}isFilterable(t){return this.getCachedFilterableColumnSet(this.columns).has(t)}async export(){return this.table.freeze()}columnStatistics(t){return this.table.getColumnStatistics(t)}isColumnMovable(t){const n=this.columns[t].name;return this.frontColumns.includes(n)||this.backColumns.includes(n)||this.frozenColumns.includes(n)?!1:!this.isKeyColumn(t)}isColumnFrozen(t){return this.frozenColumns.includes(this.columns[t].name)}async delete(t){var h;if(!this.isDeletableRanges(t))throw new Error(`Undeletable ranges ${t}`);O(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=t.map(m=>j.intersection(s,m)).filter(m=>m!=null).map(m=>(O(m),j.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];O(g.startRow),O(g.endRow);for(let f=g.startRow;f<=g.endRow;f+=1)m.delete(f)}super.pendingDataMap=m,this.formattedStringData=[],this.dispatchEvent(new Re(he.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new Re(he.EVENT.UPDATED))}const o=this.getTableAreaRange(),r=t.map(m=>j.intersection(o,m)).filter(m=>m!=null);if(r.length<=0)return;const[l,a]=await Promise.all([this.snapshot(r.map(m=>(O(m),new j(0,m.startRow,n.length-1,m.endRow)))),this.table.copy()]),d=l.map(m=>{const p=[];for(let g=0;g<n.length;g+=1){const f=n[g],C=m[g],b=x.makeFilterRawValue(f.type,C),w=f.filter().eq(b);p.push(w)}return p.reduce((g,f)=>{var C;return(C=g==null?void 0:g.and(f))!=null?C:f})}).reduce((m,p)=>{var g;return(g=m==null?void 0:m.or(p))!=null?g:p});a.applyFilter([d]),await((h=this.inputTable)==null?void 0:h.deleteTable(a)),a.close()}}class yg extends wr{constructor(){super(...arguments),this.getCachedFilterableColumnSet=Ne((t,n)=>new Set(((n==null?void 0:n.length)>0?n:t).map(s=>t.findIndex(i=>s.name===i.name))))}applyBufferedViewport(t,n,s){this.table.setViewport(t,n,s)}textForCell(t,n){const s=this.columns[t],i=this.row(n);if(i!=null&&s!=null&&!i.hasChildren&&s.constituentType!=null){const o=this.valueForCell(t,n);return this.displayString(o,s.constituentType,s.name)}return super.textForCell(t,n)}extractViewportRow(t,n){const{isExpanded:s,hasChildren:i,depth:o}=t;return{...super.extractViewportRow(t,n),isExpanded:s,hasChildren:i,depth:o}}async snapshot(t,n,s){var l,a,c,d;O(this.viewport),O(this.viewportData);const{columns:i}=this.viewport,o=[];n!=null&&n&&o.push(i.map(h=>h.name));const r=new j(0,(l=this.viewportData)==null?void 0:l.offset,i.length,((a=this.viewportData)==null?void 0:a.offset)+((c=this.viewportData)==null?void 0:c.rows.length));for(let h=0;h<t.length;h+=1){const m=j.intersection(r,t[h]);O(m),O(m.startRow),O(m.endRow);for(let p=m.startRow;p<=m.endRow;p+=1){const g=[],f=this.viewportData.rows[p-this.viewportData.offset];O(m.startColumn),O(m.endColumn);for(let C=m.startColumn;C<=m.endColumn;C+=1)O(s),g.push(s((d=f.data.get(C))==null?void 0:d.value,this.columns[C]));o.push(g)}}return o}get groupedColumns(){return[]}get hasExpandableRows(){return!0}get isChartBuilderAvailable(){return!1}get isSelectDistinctAvailable(){return!1}get isReversible(){return!1}isFilterable(t){return this.getCachedFilterableColumnSet(this.columns,this.groupedColumns).has(t)}isColumnMovable(t){return t>=this.groupedColumns.length}isRowExpandable(t){var s;const n=this.row(t);return(s=n==null?void 0:n.hasChildren)!=null?s:!1}isRowExpanded(t){var s;const n=this.row(t);return(s=n==null?void 0:n.isExpanded)!=null?s:!1}setRowExpanded(t,n){this.table.setExpanded(t,n)}depthForRow(t){var s;const n=this.row(t);return((s=n==null?void 0:n.depth)!=null?s:1)-1}}const In=te.module("IrisGridProxyModel");function xo(e,t,n){return x.isTreeTable(e)?new yg(e,t):new Eg(e,t,n)}class Rg extends he{constructor(t,n=new Qt,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)=>qe(this.model)?this.model.isRowExpandable(...o):!1,this.isRowExpanded=(...o)=>qe(this.model)?this.model.isRowExpanded(...o):!1,this.setRowExpanded=(...o)=>{if(qe(this.model))return this.model.setRowExpanded(...o);throw Error("Function setRowExpanded does not exist on IrisGridTableModel")},this.depthForRow=(...o)=>qe(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)=>Ae(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)=>(Ae(this.model)&&this.model.editValueForCell(...o),""),this.setValueForCell=(...o)=>Ae(this.model)?this.model.setValueForCell(...o):Promise.reject(new Error("Model is not editable")),this.setValueForRanges=(...o)=>Ae(this.model)?this.model.setValueForRanges(...o):Promise.reject(new Error("Model is not editable")),this.setValues=(...o)=>Ae(this.model)?this.model.setValues(...o):Promise.resolve(),this.isValidForCell=(...o)=>Ae(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=xo(t,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(t){In.debug2("handleModelEvent",t);const{detail:n,type:s}=t;this.dispatchEvent(new Re(s,{detail:n}))}setModel(t){In.debug("setModel",t);const n=this.model;n!==this.originalModel&&n.close(),this.model=t,this.listenerCount>0&&this.addListeners(t),this.dispatchEvent(new Re(he.EVENT.COLUMNS_CHANGED,{detail:t.columns})),Ni(t)&&this.dispatchEvent(new Re(he.EVENT.TABLE_CHANGED,{detail:t.table}))}setNextModel(t){In.debug2("setNextModel"),this.modelPromise&&this.modelPromise.cancel(),this.listenerCount>0&&this.removeListeners(this.model),this.modelPromise=He.makeCancelable(t,n=>n.close()),this.modelPromise.then(n=>{this.modelPromise=null,this.setModel(n)}).catch(n=>{if(He.isCanceled(n)){In.debug2("setNextModel cancelled");return}In.error("Unable to set next model",n),this.modelPromise=null,this.dispatchEvent(new Re(he.EVENT.REQUEST_FAILED,{detail:n}))})}startListening(){super.startListening(),this.addListeners(this.model)}stopListening(){super.stopListening(),this.removeListeners(this.model)}addListeners(t){const n=Object.keys(he.EVENT);for(let s=0;s<n.length;s+=1)t.addEventListener(n[s],this.handleModelEvent)}removeListeners(t){const n=Object.keys(he.EVENT);for(let s=0;s<n.length;s+=1)t.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(t){return this.model.isColumnFrozen(t)}get hasExpandableRows(){return qe(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(t){return this.model.updateFrozenColumns(t)}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(t){this.model.filter=t}get formatter(){return this.model.formatter}set formatter(t){this.model.formatter=t}get sort(){return this.model.sort}set sort(t){this.model.sort=t}get customColumns(){return this.model.customColumns}set customColumns(t){this.model.customColumns=t}get formatColumns(){return this.model.formatColumns}set formatColumns(t){this.model.formatColumns=t}get rollupConfig(){return this.rollup}set rollupConfig(t){if(In.debug("set rollupConfig",t),!this.isRollupAvailable)throw new Error("Rollup Rows are not available");if(ct(t,this.rollup))return;this.rollup=t;let n=Promise.resolve(this.originalModel);Ni(this.originalModel)&&t!=null&&(n=this.originalModel.table.rollup(t).then(s=>xo(s,this.formatter))),this.setNextModel(n)}get selectDistinctColumns(){return this.selectDistinct}set selectDistinctColumns(t){if(In.debug("set selectDistinctColumns",t),!this.isSelectDistinctAvailable)throw new Error("Select distinct is not available");if(t===this.selectDistinctColumns||t.length===0&&this.selectDistinctColumns.length===0){In.debug("Ignore same selectDistinctColumns",t);return}this.selectDistinct=t;const n=t.map(i=>this.originalColumns.find(o=>o.name===i)).filter(i=>i!=null);let s=Promise.resolve(this.originalModel);Ni(this.originalModel)&&n.length>0&&(s=this.originalModel.table.selectDistinct(n).then(i=>xo(i,this.formatter))),this.setNextModel(s)}get table(){if(Ni(this.model))return this.model.table}get totalsConfig(){return this.model.totalsConfig}set totalsConfig(t){this.model.totalsConfig=t}get isFilterRequired(){return this.model.isFilterRequired}get isEditable(){return Ae(this.model)&&this.model.isEditable}export(){if(x.isTreeTable(this.model))throw new Error("TreeTable has no 'export' property");return this.model.export()}columnStatistics(t){if(x.isTreeTable(this.model))throw new Error("TreeTable has no 'columnStatistics' function");return this.model.columnStatistics(t)}get pendingDataMap(){return this.model.pendingDataMap}set pendingDataMap(t){this.model.pendingDataMap=t}get pendingRowCount(){return this.model.pendingRowCount}set pendingRowCount(t){this.model.pendingRowCount=t}get pendingDataErrors(){return this.model.pendingDataErrors}getColumnIndexByName(t){return this.model.getColumnIndexByName(t)}}class Ig{static async makeModel(t,n=new Qt){let s=null;return!x.isTreeTable(t)&&t.hasInputTable&&(s=await t.inputTable()),new Rg(t,n,s)}}te.setLogLevel(parseInt("2",10));const Ts=te.module("EmbedGrid.App");async function Mg(e,t){Ts.info(`Fetching table ${t}...`);const n={name:t,type:E.VariableType.TABLE};return e.getObject(n)}function Dg(){const[e,t]=y.exports.useState(),[n,s]=y.exports.useState(),[i,o]=y.exports.useState(),[r,l]=y.exports.useState(),[a,c]=y.exports.useState(!0),d=y.exports.useMemo(()=>new URLSearchParams(window.location.search),[]),h=d.get("canCopy")!=null,m=d.get("canDownloadCsv")!=null;y.exports.useEffect(function(){async function f(){try{const C=d.get("name");if(C==null)throw new Error("No name param provided");const b=new URL("/jsapi",`${window.location}`),w=`${b.protocol}//${b.host}`;Ts.debug("Starting connection...");const S=new E.IdeConnection(w);Ts.debug("Loading table",C,"...");const R=await Mg(S,C);Ts.debug("Creating model...");const v=await Ig.makeModel(R);t(v),Ts.debug("Table successfully loaded!")}catch(C){Ts.error("Unable to load table",C),s(`${C}`)}c(!1)}f()},[d]),y.exports.useEffect(function(){function f(C){const{command:b,value:w}=C.data;switch(b){case"filter":{const R=w.map(({name:v,value:I})=>{const M=e==null?void 0:e.columns.find(F=>F.name===v);if(M==null)throw new Error(`Could not find column named ${v}`);return{name:v,value:I,type:x.getNormalizedType(M.type)}});o(R);break}case"sort":{const R=w.map(({name:v,direction:I})=>{const M=e==null?void 0:e.columns.find(F=>F.name===v);if(M==null)throw new Error(`Could not find column named ${v}`);return I==="DESC"?M.sort().desc():M.sort().asc()});l(R);break}}}return window.addEventListener("message",f),()=>{window.removeEventListener("message",f)}},[e]);const p=e!=null;return T("div",{className:"App",children:[p&&u(ti,{canCopy:h,canDownloadCsv:m,model:e,inputFilters:i,sorts:r}),!p&&u(sa,{isLoaded:p,isLoading:a,errorMessage:n!=null?n:null}),u(zd,{})]})}Bo.render(u(Dg,{}),document.getElementById("root"));
|
|
32
|
-
//# sourceMappingURL=index.
|
|
32
|
+
//# sourceMappingURL=index.5d9f3765.js.map
|