@deephaven/code-studio 0.21.1-beta.1 → 0.21.2-beta.0
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.
|
@@ -19,7 +19,7 @@ ${e}`):s.setValue(`${e}`);const o=s.getLineCount(),r=s.getLineLength(o)+1;this.e
|
|
|
19
19
|
`&&(n+=`
|
|
20
20
|
`))}}if(n=n.trimRight(),this.editor.setValue(n),e){const i=(s=this.editor.getModel())==null?void 0:s.getLineCount();A(i),this.editor.revealLine(i,1)}this.stopFlushTimer(),this.bufferedMessages=[]}truncateLogIfNecessary(){this.messages.length>Ot.maxLogSize&&(this.messages=this.messages.splice(this.messages.length-Ot.truncateSize))}scrollToBottom(){var e,n,s;if(!this.editor)return;const t=(s=(n=(e=this.editor)==null?void 0:e.getModel)==null?void 0:n.call(e))==null?void 0:s.getLineCount();A(t),this.editor.revealLine(t,1)}isBottomVisible(){if(!this.editor)return!0;const t=this.editor.getModel(),e=t==null?void 0:t.getLineCount();return A(e),this.isLineVisible(e)}isLineVisible(t){var n;const e=(n=this.editor)==null?void 0:n.getVisibleRanges();if(e==null||e.length===0)return!1;for(let s=0;s<e.length;s+=1){const i=e[s];if(i.startLineNumber<=t&&t<=i.endLineNumber)return!0}return!1}isLogItemVisible(t){const{shownLogLevels:e}=this.state;return e[t.logLevel]}flush(){let t="";for(let e=0;e<this.bufferedMessages.length;e+=1){const n=this.bufferedMessages[e],s=Ot.getLogText(n);t+=s,s.charAt(s.length-1)!==`
|
|
21
21
|
`&&(t+=`
|
|
22
|
-
`)}this.bufferedMessages=[],this.appendLogText(t)}queue(t){this.bufferedMessages.push(t),this.bufferedMessages.length===1&&(this.flushTimer=setTimeout(this.handleFlushTimeout,Ot.bufferTimeout))}stopFlushTimer(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=void 0)}updateDimensions(){this.editor&&this.editor.layout()}handleClearClick(){this.clearLogs()}clearLogs(){this.messages=[],this.refreshLogText()}handleFlushTimeout(){this.stopFlushTimer(),this.flush()}handleLogMessage(t){this.messages.push(t),this.editor&&this.isLogItemVisible(t)&&this.queue(t)}handleMenuItemClick(t){this.toggleLogLevel(t)}handleResetClick(){this.resetLogLevels()}handleResize(){this.updateDimensions()}handleToggleAllClick(){this.toggleAll()}render(){const t={placement:"bottom-end"},{shownLogLevels:e}=this.state,n=this.getMenuActions(e);return v("div",{className:"log-pane h-100 w-100",children:[v("div",{className:"log-pane-menu",children:[h(Q,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:rC,tooltip:"Clear log"}),h(Q,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:zo,tooltip:"Log Settings",onClick:()=>{},children:h(Wn,{actions:n,popperClassName:"log-level-menu-popper",popperOptions:t})})]}),h("div",{className:"log-pane-editor h-100 w-100",ref:s=>{this.editorContainer=s}})]})}};let Qi=Ot;Qi.DefaultLogLevels=[bt.STDOUT,bt.ERROR,bt.FATAL,bt.STDERR,bt.WARN];Qi.AllLogLevels=[bt.INFO,bt.STDOUT,bt.ERROR,bt.FATAL,bt.STDERR,bt.WARN,bt.DEBUG,bt.TRACE];Qi.bufferTimeout=16;Qi.maxLogSize=131072;Qi.truncateSize=65536;class Je{static isValid(e){return!0}static isSameFormat(e,n){throw new Error("isSameFormat not implemented")}static makeFormat(e,n,s){return{label:e,formatString:n,type:s}}format(e,n){return""}}Je.TYPE_GLOBAL="type-global";Je.TYPE_CONTEXT_PRESET="type-context-preset";Je.TYPE_CONTEXT_CUSTOM="type-context-custom";class Vb extends Je{format(e){switch(e){case 1:case!0:return"true";case 0:case!1:return"false";default:return""}}}class Ub extends Je{format(e){return String.fromCharCode(e)}}const nh=X.module("DateTimeColumnFormatter"),js=class extends Je{constructor({timeZone:t="",showTimeZone:e=!0,showTSeparator:n=!1,defaultDateTimeFormatString:s=js.DEFAULT_DATETIME_FORMAT_STRING}={}){super();const i=t||js.DEFAULT_TIME_ZONE_ID;try{this.dhTimeZone=M.i18n.TimeZone.getTimeZone(i)}catch{nh.error("Unsupported time zone id",i),this.dhTimeZone=M.i18n.TimeZone.getTimeZone(js.DEFAULT_TIME_ZONE_ID)}this.defaultDateTimeFormatString=s,this.showTimeZone=e,this.showTSeparator=n,this.formatStringMap=js.makeFormatStringMap(e,n)}static isValid(t){try{return M.i18n.DateTimeFormat.format(t.formatString,new Date),!0}catch{return!1}}static makeFormat(t,e,n=Je.TYPE_CONTEXT_PRESET){return{label:t,formatString:e,type:n}}static isSameFormat(t,e){return t===e||t!==null&&e!==null&&t.type===e.type&&t.formatString===e.formatString}static makeGlobalFormatStringMap(t,e){const n=e?"'T'":" ",s=t?" z":"";return new Map([["yyyy-MM-dd HH:mm:ss",`yyyy-MM-dd${n}HH:mm:ss${s}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${n}HH:mm:ss.SSS${s}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${n}HH:mm:ss.SSSSSSSSS${s}`]])}static getGlobalFormats(t,e){return[...js.makeGlobalFormatStringMap(t,e).keys()]}static makeFormatStringMap(t,e){const n=e!==void 0&&e?"'T'":" ",s=t!==void 0&&t?" z":"";return new Map([["yyyy-MM-dd",`yyyy-MM-dd${s}`],["MM-dd-yyyy",`MM-dd-yyyy${s}`],["HH:mm:ss",`HH:mm:ss${s}`],["HH:mm:ss.SSS",`HH:mm:ss.SSS${s}`],["HH:mm:ss.SSSSSSSSS",`HH:mm:ss.SSSSSSSSS${s}`],["yyyy-MM-dd HH:mm:ss",`yyyy-MM-dd${n}HH:mm:ss${s}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${n}HH:mm:ss.SSS${s}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${n}HH:mm:ss.SSSSSSSSS${s}`]])}static getFormats(t,e){return[...js.makeFormatStringMap(t,e).keys()]}getEffectiveFormatString(t){var e;return(e=this.formatStringMap.get(t))!=null?e:t}format(t,e){const n=e&&e.formatString||this.defaultDateTimeFormatString,s=this.getEffectiveFormatString(n);try{return M.i18n.DateTimeFormat.format(s,t,this.dhTimeZone)}catch{nh.error("Invalid format arguments")}return""}};let at=js;at.DEFAULT_DATETIME_FORMAT_STRING="yyyy-MM-dd HH:mm:ss.SSS";at.DEFAULT_TIME_ZONE_ID="America/New_York";const Bb=X.module("DecimalColumnFormatter"),Fn=class extends Je{constructor({defaultFormatString:t=Fn.DEFAULT_FORMAT_STRING}={}){super(),this.defaultFormatString=t}static isValid(t){try{return M.i18n.NumberFormat.format(t.formatString,0),!0}catch{return!1}}static makeFormat(t,e,n=Je.TYPE_CONTEXT_PRESET,s){return{label:t,type:n,formatString:e,multiplier:s}}static makePresetFormat(t,e="",n){return Fn.makeFormat(t,e,Je.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(t="",e){return Fn.makeFormat("Custom Format",t,Je.TYPE_CONTEXT_CUSTOM,e)}static isSameFormat(t,e){return t===e||t!=null&&e!=null&&t.type===e.type&&t.formatString===e.formatString&&t.multiplier===e.multiplier}format(t,e){const n=e&&e.formatString||this.defaultFormatString,s=e&&e.multiplier!==void 0&&e.multiplier!==0?t*e.multiplier:t;try{return M.i18n.NumberFormat.format(n,s)}catch{Bb.error("Invalid format arguments")}return""}};let Pe=Fn;Pe.DEFAULT_FORMAT_STRING="###,##0.0000";Pe.FORMAT_PERCENT=Fn.makePresetFormat("Percent","##0.00%");Pe.FORMAT_BASIS_POINTS=Fn.makePresetFormat("Basis Points","###,##0 bp",1e4);Pe.FORMAT_MILLIONS=Fn.makePresetFormat("Millions","###,##0.000 mm",1e-6);Pe.FORMAT_SCIENTIFIC_NOTATION=Fn.makePresetFormat("Scientific Notation","0.0000E0");Pe.FORMAT_ROUND=Fn.makePresetFormat("Round","###,##0");Pe.FORMAT_ROUND_TWO_DECIMALS=Fn.makePresetFormat("0.00","###,##0.00");Pe.FORMAT_ROUND_FOUR_DECIMALS=Fn.makePresetFormat("0.0000","###,##0.0000");class $b extends Je{format(e){return`${e}`}}const zb=X.module("IntegerColumnFormatter"),Hi=class extends Je{constructor({defaultFormatString:t=Hi.DEFAULT_FORMAT_STRING}={}){super(),this.defaultFormatString=t}static isValid(t){try{return M.i18n.NumberFormat.format(t.formatString,0),!0}catch{return!1}}static makeFormat(t,e,n=Je.TYPE_CONTEXT_PRESET,s){return{label:t,type:n,formatString:e,multiplier:s}}static makePresetFormat(t,e="",n){return Hi.makeFormat(t,e,Je.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(t="",e){return Hi.makeFormat("Custom Format",t,Je.TYPE_CONTEXT_CUSTOM,e)}static isSameFormat(t,e){return t===e||t!=null&&e!=null&&t.type===e.type&&t.formatString===e.formatString&&t.multiplier===e.multiplier}format(t,e){const n=e&&e.formatString||this.defaultFormatString,s=e&&e.multiplier!==void 0&&e.multiplier!==0?t*e.multiplier:t;try{return M.i18n.NumberFormat.format(n,s)}catch{zb.error("Invalid format arguments")}return""}};let nt=Hi;nt.DEFAULT_FORMAT_STRING="###,##0";nt.FORMAT_MILLIONS=Hi.makePresetFormat("Millions","###,##0.000 mm",1e-6);nt.FORMAT_SCIENTIFIC_NOTATION=Hi.makePresetFormat("Scientific Notation","0.0000E0");class Wb extends Je{format(e){return e}}const Bt=class{static makeDateWrapper(t,e,n=0,s=1,i=0,o=0,r=0,l=0){if(!t)throw new Error("No timezone provided");const a=`${e}`.padStart(4,"0"),d=`${n+1}`.padStart(2,"0"),c=`${s}`.padStart(2,"0"),u=`${i}`.padStart(2,"0"),m=`${o}`.padStart(2,"0"),p=`${r}`.padStart(2,"0"),g=`${l}`.padStart(9,"0"),f=`${a}-${d}-${c} ${u}:${m}:${p}.${g}`;return M.i18n.DateTimeFormat.parse(Bt.FULL_DATE_FORMAT,f,M.i18n.TimeZone.getTimeZone(t))}static getNextNanos(t){const e=parseInt(t,10),n="0".repeat(9-t.length),s=`${e+1}${n}`;return parseInt(s,10)}static getNextDate(t,e,n){let{year:s,month:i,date:o,hours:r,minutes:l,seconds:a,nanos:d}=e;if(t.nanos!=null){if(t.nanos.length===9)return null;d=Bt.getNextNanos(t.nanos),d>999999999&&(a+=1,d=0)}else t.seconds!=null?a+=1:t.minutes!=null?l+=1:t.hours!=null?r+=1:t.date!=null?o+=1:t.month!=null?i+=1:s+=1;const c=new Date(s,i,o,r,l,a);return Bt.makeDateWrapper(n,c.getFullYear(),c.getMonth(),c.getDate(),c.getHours(),c.getMinutes(),c.getSeconds(),d)}static parseMonth(t){const e=parseInt(t,10);if(!Number.isNaN(e))return e>=1&&e<=12?e-1:NaN;const n=t.trim().toLowerCase();if(n.length>=3){for(let s=0;s<Bt.months.length;s+=1)if(Bt.months[s].startsWith(n))return s}return NaN}static parseDateValues(t,e,n,s,i,o,r){const l=parseInt(t,10),a=e!=null?this.parseMonth(e):0,d=n!=null?parseInt(n,10):1,c=s!=null?parseInt(s,10):0,u=i!=null?parseInt(i,10):0,m=o!=null?parseInt(o,10):0,p=r!=null?parseInt(r.padEnd(9,"0"),10):0;return Number.isNaN(l)||Number.isNaN(a)||Number.isNaN(d)||Number.isNaN(c)||Number.isNaN(u)||Number.isNaN(m)||Number.isNaN(p)?null:{year:l,month:a,date:d,hours:c,minutes:u,seconds:m,nanos:p}}static parseDateTimeString(t){const n=/\s*(\d{4})([-./]([\da-z]+))?([-./](\d{1,2}))?([tT\s](\d{2})([:](\d{2}))?([:](\d{2}))?([.](\d{1,9}))?)?(.*)/.exec(t);if(n==null)throw new Error(`Unexpected date string: ${t}`);const[,s,,i,,o,,r,,l,,a,,d,c]=n;if(c!=null&&c.length>0)throw new Error(`Unexpected characters after date string '${t}': ${c}`);return{year:s,month:i,date:o,hours:r,minutes:l,seconds:a,nanos:d}}static parseDateRange(t,e){const n=t.trim().toLowerCase();if(n.length===0)throw new Error("Cannot parse date range from empty string");if(n==="null")return[null,null];if(n==="today"){const l=new Date(Date.now()),a=Bt.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()),d=Bt.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()+1);return[a,d]}if(n==="yesterday"){const l=new Date(Date.now()),a=Bt.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()-1),d=Bt.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate());return[a,d]}if(n==="now"){const l=new Date(Date.now());return[M.DateWrapper.ofJsDate(l),null]}const s=Bt.parseDateTimeString(n);if(s.year==null&&s.month==null&&s.date==null)throw new Error(`Unable to extract year, month, or day ${n}`);const i=Bt.parseDateValues(s.year,s.month,s.date,s.hours,s.minutes,s.seconds,s.nanos);if(i==null)throw new Error(`Unable to extract date values from ${s}`);const o=Bt.makeDateWrapper(e,i.year,i.month,i.date,i.hours,i.minutes,i.seconds,i.nanos),r=Bt.getNextDate(s,i,e);return[o,r]}static getJsDate(t){return typeof t=="number"?new Date(t):t.asDate()}};let us=Bt;us.FULL_DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSSSSS";us.months=["january","february","march","april","may","june","july","august","september","october","november","december"];class Wt{}Wt.not="not";Wt.and="and";Wt.or="or";function Gb(t){if(!(t==="not"||t==="and"||t==="or"))throw new Error("operator is not a valid FilterOperatorValue")}class q{}q.eq="eq";q.eqIgnoreCase="eqIgnoreCase";q.notEq="notEq";q.notEqIgnoreCase="notEqIgnoreCase";q.greaterThan="greaterThan";q.greaterThanOrEqualTo="greaterThanOrEqualTo";q.lessThan="lessThan";q.lessThanOrEqualTo="lessThanOrEqualTo";q.in="in";q.inIgnoreCase="inIgnoreCase";q.notIn="notIn";q.notInIgnoreCase="notInIgnoreCase";q.isTrue="isTrue";q.isFalse="isFalse";q.isNull="isNull";q.invoke="invoke";q.contains="contains";q.notContains="notContains";q.startsWith="startsWith";q.endsWith="endsWith";q.containsAny="containsAny";function Kb(t){switch(t){case q.eq:return"is exactly";case q.eqIgnoreCase:return"is exactly (ignore case)";case q.notEq:return"is not exactly";case q.notEqIgnoreCase:return"is not exactly (ignore case)";case q.contains:return"contains";case q.notContains:return"does not contain";case q.startsWith:return"starts with";case q.endsWith:return"ends with";default:throw new Error(`Unrecognized text filter type ${t}`)}}function qb(t){switch(t){case q.eq:return"is equal to";case q.notEq:return"is not equal to";case q.greaterThan:return"greater than";case q.greaterThanOrEqualTo:return"greater than or equal to";case q.lessThan:return"less than";case q.lessThanOrEqualTo:return"less than or equal to";default:throw new Error(`Unrecognized number filter type ${t}`)}}function Yb(t){switch(t){case q.eq:return"date is";case q.notEq:return"date is not";case q.notEqIgnoreCase:case q.greaterThan:return"date is after";case q.greaterThanOrEqualTo:return"date is after or equal";case q.lessThan:return"date is before";case q.lessThanOrEqualTo:return"date is before or equal";default:throw new Error(`Unrecognized date filter type ${t}`)}}function Xb(t){switch(t){case q.isTrue:return"Is True";case q.isFalse:return"Is False";case q.isNull:return"Is Null";default:throw new Error(`Unrecognized boolean filter type ${t}`)}}const Jn=X.module("TableUtils"),ne=class{static getSortIndex(t,e){var n;for(let s=0;s<t.length;s+=1)if(((n=t[s].column)==null?void 0:n.index)===e)return s;return null}static getSortForColumn(t,e){const n=ne.getSortIndex(t,e);return n!=null?t[n]:null}static getFilterText(t){return t?t.toString():null}static getFilterTypes(t){return ne.isBooleanType(t)?[q.isTrue,q.isFalse,q.isNull]:ne.isCharType(t)||ne.isNumberType(t)||ne.isDateType(t)?[q.eq,q.notEq,q.greaterThan,q.greaterThanOrEqualTo,q.lessThan,q.lessThanOrEqualTo]:ne.isTextType(t)?[q.eq,q.eqIgnoreCase,q.notEq,q.notEqIgnoreCase,q.contains,q.notContains,q.startsWith,q.endsWith]:[]}static getNextSort(t,e,n){if(t==null||n<0||n>=t.length)return null;const s=ne.getSortForColumn(e,n);return s===null?t[n].sort().asc():s.direction===ne.sortDirection.ascending?s.desc():null}static makeColumnSort(t,e,n,s){if(t==null||e<0||e>=t.length||n===ne.sortDirection.none)return null;let i=t[e].sort();switch(n){case ne.sortDirection.ascending:i=i.asc();break;case ne.sortDirection.descending:i=i.desc();break}return s&&(i=i.abs()),i}static toggleSortForColumn(t,e,n,s=!1){if(n<0||n>=e.length)return[];const i=ne.getNextSort(e,t,n);return ne.setSortForColumn(t,n,i,s)}static sortColumn(t,e,n,s,i,o){if(t==null||n<0||n>=e.length)return[];const r=ne.makeColumnSort(e,n,s,i);return ne.setSortForColumn(t,n,r,o)}static setSortForColumn(t,e,n,s=!1){const i=ne.getSortIndex(t,e);let o=[];return s&&(o=o.concat(t.filter(({direction:r})=>r!==ne.sortDirection.reverse)),i!==null&&o.splice(i,1)),n!==null&&o.push(n),o}static getNormalizedType(t){switch(t){case"boolean":case"java.lang.Boolean":case ne.dataType.BOOLEAN:return ne.dataType.BOOLEAN;case"char":case"java.lang.Character":case ne.dataType.CHAR:return ne.dataType.CHAR;case"java.lang.String":case ne.dataType.STRING:return ne.dataType.STRING;case"io.deephaven.db.tables.utils.DBDateTime":case"io.deephaven.time.DateTime":case"com.illumon.iris.db.tables.utils.DBDateTime":case ne.dataType.DATETIME:return ne.dataType.DATETIME;case"double":case"java.lang.Double":case"float":case"java.lang.Float":case"java.math.BigDecimal":case ne.dataType.DECIMAL:return ne.dataType.DECIMAL;case"int":case"java.lang.Integer":case"long":case"java.lang.Long":case"short":case"java.lang.Short":case"byte":case"java.lang.Byte":case"java.math.BigInteger":case ne.dataType.INT:return ne.dataType.INT;default:return ne.dataType.UNKNOWN}}static isLongType(t){switch(t){case"long":case"java.lang.Long":return!0;default:return!1}}static isDateType(t){switch(t){case"io.deephaven.db.tables.utils.DBDateTime":case"io.deephaven.time.DateTime":case"com.illumon.iris.db.tables.utils.DBDateTime":return!0;default:return!1}}static isNumberType(t){return ne.isIntegerType(t)||ne.isDecimalType(t)}static isIntegerType(t){switch(t){case"int":case"java.lang.Integer":case"java.math.BigInteger":case"long":case"java.lang.Long":case"short":case"java.lang.Short":case"byte":case"java.lang.Byte":return!0;default:return!1}}static isDecimalType(t){switch(t){case"double":case"java.lang.Double":case"java.math.BigDecimal":case"float":case"java.lang.Float":return!0;default:return!1}}static isBooleanType(t){switch(t){case"boolean":case"java.lang.Boolean":return!0;default:return!1}}static isCharType(t){switch(t){case"char":case"java.lang.Character":return!0;default:return!1}}static isStringType(t){switch(t){case"java.lang.String":return!0;default:return!1}}static isTextType(t){return this.isStringType(t)||this.isCharType(t)}static getBaseType(t){return t.split("[]")[0]}static isCompatibleType(t,e){return ne.getNormalizedType(t)===ne.getNormalizedType(e)}static makeQuickFilter(t,e,n){const s=e.split("||");let i=null;for(let o=0;o<s.length;o+=1){const l=s[o].split("&&");let a=null;for(let d=0;d<l.length;d+=1){const c=l[d].trim();if(c.length>0){const u=ne.makeQuickFilterFromComponent(t,c,n);if(u)a?a=a.and(u):a=u;else throw new Error(`Unable to parse quick filter from text ${e}`)}}i&&a?i=i.or(a):i=a}return i}static makeQuickFilterFromComponent(t,e,n){const{type:s}=t;return ne.isNumberType(s)?this.makeQuickNumberFilter(t,e):ne.isBooleanType(s)?this.makeQuickBooleanFilter(t,e):n!=null&&ne.isDateType(s)?this.makeQuickDateFilter(t,e,n):ne.isCharType(s)?this.makeQuickCharFilter(t,e):this.makeQuickTextFilter(t,e)}static makeQuickNumberFilter(t,e){if(e==null)return null;const n=t.filter();let s=null;const o=/\s*(>=|<=|=>|=<|>|<|!=|=|!)?(\s*-\s*)?(\s*\d*(?:,\d{3})*(?:\.\d*)?\s*)?(null|nan|infinity|inf|\u221E)?(.*)/i.exec(e);let r=null,l=null,a=null,d=null,c=null;if(o!==null&&o.length>3&&([,r,l,a,d,c]=o),c!=null&&c.trim().length>0)return null;if(r==null&&(r="="),d!=null){if(!(r==="="||r==="!"||r==="!="))return null;switch(d=d.trim().toLowerCase(),d){case"null":s=n.isNull();break;case"nan":s=M.FilterCondition.invoke("isNaN",n);break;case"infinity":case"inf":case"\u221E":l!=null?s=M.FilterCondition.invoke("isInf",n).and(n.lessThan(M.FilterValue.ofNumber(0))):s=M.FilterCondition.invoke("isInf",n).and(n.greaterThan(M.FilterValue.ofNumber(0)));break}return s!==null&&(r==="!"||r==="!=")&&(s=s.not()),s}if(a==null)return null;if(a=ne.removeCommas(a),ne.isLongType(t.type))try{a=M.FilterValue.ofNumber(M.LongWrapper.ofString(`${l!=null?"-":""}${a}`))}catch(u){return Jn.warn("Unable to create long filter",u),null}else{if(a=parseFloat(a),a==null||Number.isNaN(a))return null;a=M.FilterValue.ofNumber(l!=null?0-a:a)}return s=t.filter(),ne.makeRangeFilterWithOperation(s,r,a)}static makeQuickTextFilter(t,e){if(e==null)return null;const n=`${e}`.trim(),i=/^(!~|!=|~|=|!)?(.*)/.exec(n);let o=null,r=null;if(i!==null&&i.length>2&&([,o,r]=i,r!=null&&(r=r.trim())),r==null||r.length===0)return null;o==null&&(o="=");const l=t.filter();if(r.toLowerCase()==="null")switch(o){case"=":return l.isNull();case"!=":case"!":return l.isNull().not();default:return null}let a=null,d=null;switch(r.startsWith("*")?(a="*",r=r.substring(1)):r.endsWith("*")&&!r.endsWith("\\*")&&(d="*",r=r.substring(0,r.length-1)),r=r.replace("\\",""),o){case"~":return l.isNull().not().and(l.invoke("matches",M.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E.*`)));case"!~":return l.isNull().or(l.invoke("matches",M.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E.*`)).not());case"!=":return a==="*"?l.isNull().or(l.invoke("matches",M.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E$`)).not()):d==="*"?l.isNull().or(l.invoke("matches",M.FilterValue.ofString(`(?s)(?i)^\\Q${r}\\E.*`)).not()):l.notEqIgnoreCase(M.FilterValue.ofString(r.toLowerCase()));case"=":return a==="*"?l.isNull().not().and(l.invoke("matches",M.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E$`))):d==="*"?l.isNull().not().and(l.invoke("matches",M.FilterValue.ofString(`(?s)(?i)^\\Q${r}\\E.*`))):l.eqIgnoreCase(M.FilterValue.ofString(r.toLowerCase()))}return null}static makeQuickBooleanFilter(t,e){if(e==null)return null;const s=/^(!=|=|!)?(.*)/.exec(`${e}`.trim());if(s===null)return null;const[,i,o]=s,r=i==="!"||i==="!=",l=o.trim().toLowerCase();let a=t.filter();try{const d=ne.makeBooleanValue(l);return d!=null&&d?a=a.isTrue():d===null?a=a.isNull():a=a.isFalse(),r?a.not():a}catch{return null}}static makeQuickDateFilter(t,e,n){const s=e.trim(),o=/\s*(>=|<=|=>|=<|>|<|!=|!|=)?(.*)/.exec(s);if(o==null||o.length<=2)throw new Error(`Unable to parse date filter: ${e}`);let r=null,l=null;[,r,l]=o;let a=q.eq;switch(r){case"<":a=q.lessThan;break;case"<=":case"=<":a=q.lessThanOrEqualTo;break;case">":a=q.greaterThan;break;case">=":case"=>":a=q.greaterThanOrEqualTo;break;case"!=":case"!":a=q.notEq;break;case"=":case"==":default:a=q.eq;break}return ne.makeQuickDateFilterWithOperation(t,l,a,n)}static makeQuickDateFilterWithOperation(t,e,n=q.eq,s){if(t==null)throw new Error("Column is null");const[i,o]=us.parseDateRange(e,s),r=i!=null?M.FilterValue.ofNumber(i):null,l=o!=null?M.FilterValue.ofNumber(o):null,a=t.filter();if(r==null)return n===q.notEq?a.isNull().not():a.isNull();switch(n){case q.eq:{if(l!=null){const d=a.greaterThanOrEqualTo(r),c=a.lessThan(l);return d.and(c)}return a.eq(r)}case q.lessThan:return a.lessThan(r);case q.lessThanOrEqualTo:return l!=null?a.lessThan(l):a.lessThanOrEqualTo(r);case q.greaterThan:return l!=null?a.greaterThanOrEqualTo(l):a.greaterThan(r);case q.greaterThanOrEqualTo:return a.greaterThanOrEqualTo(r);case q.notEq:{if(l!=null){const d=a.lessThan(r),c=a.greaterThanOrEqualTo(l);return d.or(c)}return a.notEq(r)}default:throw new Error(`Invalid operator: ${n}`)}}static quoteValue(t){return t.length>=2&&(t.charAt(0)==='"'&&t.charAt(t.length-1)==='"'||t.charAt(0)==="'"&&t.charAt(t.length-1)==="'")?t:`"${t}"`}static isRangeOperation(t){switch(t){case"<":case"<=":case"=<":case">":case">=":case"=>":return!0;default:return!1}}static makeQuickCharFilter(t,e){if(e==null)return null;const n=`${e}`.trim(),i=/^(>=|<=|=>|=<|>|<|!=|=|!)?(null|"."|'.'|.)?(.*)/.exec(n);let o=null,r=null,l=null;if(i!==null&&i.length>3&&([,o,r,l]=i),l!=null&&l.trim().length>0||r==null||r.length===0)return null;o==null&&(o="=");const a=t.filter();if(r.toLowerCase()==="null")switch(o){case"=":return a.isNull();case"!=":case"!":return a.isNull().not();default:return null}const d=M.FilterValue.ofString(ne.isRangeOperation(o)?ne.quoteValue(r):r);return ne.makeRangeFilterWithOperation(a,o,d)}static makeRangeFilterWithOperation(t,e,n){switch(e){case"=":return t.eq(n);case"<":return t.lessThan(n);case"<=":case"=<":return t.lessThanOrEqualTo(n);case">":return t.greaterThan(n);case">=":case"=>":return t.greaterThanOrEqualTo(n);case"!=":case"!":return t.notEq(n);default:return null}}static makeCancelableTablePromise(t){return Ee.makeCancelable(t,e=>{e.close()})}static makeCancelableTableEventPromise(t,e,n=0,s=null){let i,o,r=!0;const l=new Promise((a,d)=>{o=setTimeout(()=>{i(),r=!1,d(new vu(`Event "${e}" timed out.`))},n),i=t.addEventListener(e,c=>{if(s!=null&&!s(c)){Jn.debug2("Event triggered, but matcher returned false.");return}Jn.debug2("Event triggered, resolving."),i(),clearTimeout(o),r=!1,a(c)})});return l.cancel=()=>{if(r){Jn.debug2("Pending promise cleanup."),i(),clearTimeout(o),r=!1;return}Jn.debug2("Ignoring non-pending promise cancel.")},l}static makeAdvancedFilter(t,e,n){const{filterItems:s,filterOperators:i,invertSelection:o,selectedValues:r}=e;let l=null;for(let d=0;d<s.length;d+=1){const c=s[d],{selectedType:u,value:m}=c;if(u!=null&&u.length>0&&m!=null&&m.length>0)try{const p=ne.makeAdvancedValueFilter(t,u,m,n);if(p!=null){if(d===0)l=p;else if(l!==null&&d-1<i.length){const g=i[d-1];if(g===Wt.and)l=l.and(p);else if(g===Wt.or)l=l.or(p);else{Jn.error("Unexpected filter operator",g,p),l=null;break}}}else Jn.debug2("Empty filter ignored for",u,m)}catch(p){Jn.error("Unable to create filter",p),l=null;break}}const a=ne.makeSelectValueFilter(t,r,o);return a!=null&&(l!=null?l=l.and(a):l=a),l}static removeCommas(t){return t.replace(/[\s|,]/g,"")}static makeFilterValue(t,e){const n=ne.getBaseType(t);return ne.isTextType(n)?M.FilterValue.ofString(e):ne.isLongType(n)?M.FilterValue.ofNumber(M.LongWrapper.ofString(ne.removeCommas(e))):M.FilterValue.ofNumber(ne.removeCommas(e))}static makeFilterRawValue(t,e){return ne.isTextType(t)?M.FilterValue.ofString(e):ne.isBooleanType(t)?M.FilterValue.ofBoolean(e):M.FilterValue.ofNumber(e)}static makeValue(t,e,n){if(e==null||e==="null")return null;if(ne.isTextType(t))return e;if(ne.isLongType(t))return M.LongWrapper.ofString(ne.removeCommas(e));if(ne.isBooleanType(t))return ne.makeBooleanValue(e,!0);if(ne.isDateType(t)){const[s]=us.parseDateRange(e,n);return s}return ne.isNumberType(t)?ne.makeNumberValue(e):(Jn.error("Unexpected column type",t),null)}static makeBooleanValue(t,e=!1){if(t===""&&e)return null;switch(t==null?void 0:t.toLowerCase()){case"null":return null;case"0":case"f":case"fa":case"fal":case"fals":case"false":case"n":case"no":return!1;case"1":case"t":case"tr":case"tru":case"true":case"y":case"ye":case"yes":return!0;default:throw new Error(`Invalid boolean '${t}'`)}}static makeNumberValue(t){if(t==null||t==="null"||t==="")return null;const e=t.toLowerCase().trim();if(e==="\u221E"||e==="infinity"||e==="inf")return Number.POSITIVE_INFINITY;if(e==="-\u221E"||e==="-infinity"||e==="-inf")return Number.NEGATIVE_INFINITY;const n=ne.removeCommas(e);if(ne.NUMBER_REGEX.test(n))return parseFloat(n);throw new Error(`Invalid number '${t}'`)}static getFilterOperatorString(t){switch(t){case q.eq:return"=";case q.notEq:return"!=";case q.greaterThan:return">";case q.greaterThanOrEqualTo:return">=";case q.lessThan:return"<";case q.lessThanOrEqualTo:return"<=";case q.contains:return"~";case q.notContains:return"!~";default:throw new Error(`Unexpected filter type ${t}`)}}static makeAdvancedValueFilter(t,e,n,s){if(ne.isDateType(t.type))return ne.makeQuickDateFilterWithOperation(t,n,e,s);if(ne.isNumberType(t.type)||ne.isCharType(t.type))return ne.makeQuickFilter(t,`${ne.getFilterOperatorString(e)}${n}`);const i=ne.makeFilterValue(t.type,n),o=t.filter();switch(e){case q.eq:return o.eq(i);case q.eqIgnoreCase:return o.eqIgnoreCase(i);case q.notEq:return o.notEq(i);case q.notEqIgnoreCase:return o.notEqIgnoreCase(i);case q.greaterThan:return o.greaterThan(i);case q.greaterThanOrEqualTo:return o.greaterThanOrEqualTo(i);case q.lessThan:return o.lessThan(i);case q.lessThanOrEqualTo:return o.lessThanOrEqualTo(i);case q.isTrue:return o.isTrue();case q.isFalse:return o.isFalse();case q.isNull:return o.isNull();case q.contains:return o.isNull().not().and(o.invoke("matches",M.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)));case q.notContains:return o.isNull().or(o.invoke("matches",M.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)).not());case q.startsWith:return o.isNull().not().and(o.invoke("matches",M.FilterValue.ofString(`(?s)(?i)^\\Q${n}\\E.*`)));case q.endsWith:return o.isNull().not().and(o.invoke("matches",M.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E$`)));case q.in:case q.inIgnoreCase:case q.notIn:case q.notInIgnoreCase:case q.invoke:default:throw new Error(`Unexpected filter operation: ${e}`)}}static makeSelectValueFilter(t,e,n){if(e.length===0){if(n)return null;let o=null;ne.isTextType(t.type)?o=M.FilterValue.ofString("a"):ne.isBooleanType(t.type)?o=M.FilterValue.ofBoolean(!0):ne.isDateType(t.type)?o=M.FilterValue.ofNumber(M.DateWrapper.ofJsDate(new Date)):o=M.FilterValue.ofNumber(0);const r=t.filter().eq(o),l=t.filter().notEq(o);return r.and(l)}const s=[];let i=!1;for(let o=0;o<e.length;o+=1){const r=e[o];r==null?i=!0:ne.isTextType(t.type)?s.push(M.FilterValue.ofString(typeof r=="number"?String.fromCharCode(r):r)):ne.isBooleanType(t.type)?s.push(M.FilterValue.ofBoolean(Boolean(r))):s.push(M.FilterValue.ofNumber(r))}return i?s.length>0?n?t.filter().isNull().not().and(t.filter().notIn(s)):t.filter().isNull().or(t.filter().in(s)):n?t.filter().isNull().not():t.filter().isNull():n?t.filter().notIn(s):t.filter().in(s)}static isTreeTable(t){return t!=null&&t.expand!==void 0&&t.collapse!==void 0}static sortColumns(t,e=!0){return[...t].sort((n,s)=>{const i=n.name.toUpperCase(),o=s.name.toUpperCase();return tn.sort(i,o,e)})}};let P=ne;P.dataType={BOOLEAN:"boolean",CHAR:"char",DATETIME:"datetime",DECIMAL:"decimal",INT:"int",STRING:"string",UNKNOWN:"unknown"};P.sortDirection={ascending:"ASC",descending:"DESC",reverse:"REVERSE",none:null};P.REVERSE_TYPE=Object.freeze({NONE:"none",PRE_SORT:"pre-sort",POST_SORT:"post-sort"});P.NUMBER_REGEX=/^-?\d+(\.\d+)?$/;class cn{static makeColumnFormatMap(e){return e==null?new Map:e.reduce((n,s)=>{const i=P.getNormalizedType(s.columnType);if(i===null)return n;n.has(i)||n.set(i,new Map);const o=n.get(i);return o==null||o.set(s.columnName,s.format),n},new Map)}static makeColumnFormattingRule(e,n,s){return{columnType:e,columnName:n,format:s}}constructor(e=[],n,s,i,o=!1){this.defaultColumnFormatter=new $b,this.typeFormatterMap=new Map([[P.dataType.BOOLEAN,new Vb],[P.dataType.CHAR,new Ub],[P.dataType.DATETIME,new at(n)],[P.dataType.DECIMAL,new Pe(s)],[P.dataType.INT,new nt(i)],[P.dataType.STRING,new Wb]]),this.columnFormatMap=cn.makeColumnFormatMap(e),this.truncateNumbersWithPound=o}getColumnFormatMapForType(e,n=!1){const s=P.getNormalizedType(e);if(s!==null)return n&&!this.columnFormatMap.has(s)&&this.columnFormatMap.set(s,new Map),this.columnFormatMap.get(s)}getColumnFormat(e,n){var i;const s=this.getColumnFormatMapForType(e);return(i=s==null?void 0:s.get(n))!=null?i:null}getColumnTypeFormatter(e){var i;const n=P.getNormalizedType(e);let s=this.defaultColumnFormatter;return n&&(s=(i=this.typeFormatterMap.get(n))!=null?i:s),s}getFormattedString(e,n,s="",i){if(e==null)return"";const o=this.getColumnTypeFormatter(n),r=i||this.getColumnFormat(n,s);return o.format(e,r!=null?r:void 0)}get timeZone(){var n;const e=this.typeFormatterMap.get(P.dataType.DATETIME);return(n=e==null?void 0:e.dhTimeZone)==null?void 0:n.id}}function jb(t){if(t&&t.formatter){const{formatter:e}=t;return e}}function Qb(t){return{timeZone:t==null?void 0:t.timeZone,defaultDateTimeFormatString:t==null?void 0:t.defaultDateTimeFormat,showTimeZone:t==null?void 0:t.showTimeZone,showTSeparator:t==null?void 0:t.showTSeparator}}function Zb(t,e,n){const s=t.getColumnFormat(n,e);return s!=null&&(s.type===Je.TYPE_CONTEXT_PRESET||s.type===Je.TYPE_CONTEXT_CUSTOM)}const cs={getColumnFormats:jb,getDateTimeFormatterOptions:Qb,isCustomColumnFormatDefined:Zb};$r.register([Tg,Eg,yg,Ig,Rg,Dg]);const rm=typeof ta=="function"?ta($r):ta.default($r),is=class{constructor(){this.listeners=[],this.isDownsamplingDisabled=!1}getData(){return[]}getDefaultTitle(){return""}getLayout(){return{}}getFilterColumnMap(){return new Map}isFilterRequired(){return!1}setFilter(t){}close(){}setFormatter(t){this.formatter=t}setDownsamplingDisabled(t){this.isDownsamplingDisabled=t}setDimensions(t){this.rect=t}setTitle(t){this.title=t}subscribe(t){this.listeners.push(t)}unsubscribe(t){this.listeners=this.listeners.filter(e=>e!==t)}fireEvent(t){for(let e=0;e<this.listeners.length;e+=1)this.listeners[e](t)}fireUpdate(t){this.fireEvent(new CustomEvent(is.EVENT_UPDATED,{detail:t}))}fireDisconnect(){this.fireEvent(new CustomEvent(is.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(is.EVENT_RECONNECT))}fireDownsampleStart(t){this.fireEvent(new CustomEvent(is.EVENT_DOWNSAMPLESTARTED,{detail:t}))}fireDownsampleFinish(t){this.fireEvent(new CustomEvent(is.EVENT_DOWNSAMPLEFINISHED,{detail:t}))}fireDownsampleFail(t){this.fireEvent(new CustomEvent(is.EVENT_DOWNSAMPLEFAILED,{detail:t}))}fireDownsampleNeeded(t){this.fireEvent(new CustomEvent(is.EVENT_DOWNSAMPLENEEDED,{detail:t}))}fireLoadFinished(){this.fireEvent(new CustomEvent(is.EVENT_LOADFINISHED))}};let St=is;St.EVENT_UPDATED="ChartModel.EVENT_UPDATED";St.EVENT_DISCONNECT="ChartModel.EVENT_DISCONNECT";St.EVENT_RECONNECT="ChartModel.EVENT_RECONNECT";St.EVENT_DOWNSAMPLESTARTED="ChartModel.EVENT_DOWNSAMPLESTARTED";St.EVENT_DOWNSAMPLEFINISHED="ChartModel.EVENT_DOWNSAMPLEFINISHED";St.EVENT_DOWNSAMPLEFAILED="ChartModel.EVENT_DOWNSAMPLEFAILED";St.EVENT_DOWNSAMPLENEEDED="ChartModel.EVENT_DOWNSAMPLENEEDED";St.EVENT_LOADFINISHED="ChartModel.EVENT_LOADFINISHED";const Jb="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",eS="#403e41",tS="#5b5a5c",nS="#c0bfbf",sS="#4878ea",iS="rgba(91, 90, 92, 0.7)",yt={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:Jb,gridcolor:eS,linecolor:tS,zerolinecolor:nS,activecolor:sS,rangebgcolor:iS,"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"},zt=Object.freeze({paper_bgcolor:yt["paper-bgcolor"],plot_bgcolor:yt["plot-bgcolor"],title_color:yt["title-color"],colorway:yt.colorway,gridcolor:yt.gridcolor,linecolor:yt.linecolor,zerolinecolor:yt.zerolinecolor,activecolor:yt.activecolor,rangebgcolor:yt.rangebgcolor,area_color:yt["area-color"],trend_color:yt["trend-color"],line_color:yt["line-color"],error_band_line_color:yt["error-band-line-color"],error_band_fill_color:yt["error-band-fill-color"],ohlc_increasing:yt["ohlc-increasing"],ohlc_decreasing:yt["ohlc-decreasing"]}),Cr=X.module("ChartUtils"),ws=Object.freeze(M.calendar.DayOfWeek.values()),sh="io.deephaven.time.DateTime",oS=36e5,rS=1e6;function lS(t){return t.asDate!==void 0}function aS(t){return t.asNumber!==void 0}function ih(t){return t.dhTimeZone!==void 0}function dS(t){return t!=null&&t.range&&(t.autorange===!1||t.autorange===void 0)}const ie=class{static getPlotlyChartType(t,e){switch(t){case M.plot.SeriesPlotStyle.SCATTER:return e?"scatter":"scattergl";case M.plot.SeriesPlotStyle.LINE:return"scatter";case M.plot.SeriesPlotStyle.BAR:case M.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case M.plot.SeriesPlotStyle.PIE:return"pie";case M.plot.SeriesPlotStyle.TREEMAP:return"treemap";case M.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case M.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}static getPlotlyChartMode(t){switch(t){case M.plot.SeriesPlotStyle.SCATTER:return"markers";case M.plot.SeriesPlotStyle.LINE:return"lines";default:return}}static getPlotlyProperty(t,e){switch(t){case M.plot.SeriesPlotStyle.PIE:switch(e){case M.plot.SourceType.X:return"labels";case M.plot.SourceType.Y:return"values"}break;case M.plot.SeriesPlotStyle.OHLC:switch(e){case M.plot.SourceType.TIME:return"x"}break;case M.plot.SeriesPlotStyle.TREEMAP:switch(e){case M.plot.SourceType.X:return"ids";case M.plot.SourceType.Y:return"values";case M.plot.SourceType.LABEL:return"labels";case M.plot.SourceType.PARENT:return"parents";case M.plot.SourceType.COLOR:return"marker.colors"}break}switch(e){case M.plot.SourceType.X:return"x";case M.plot.SourceType.Y:return"y";case M.plot.SourceType.Z:return"z";case M.plot.SourceType.X_LOW:return"xLow";case M.plot.SourceType.X_HIGH:return"xHigh";case M.plot.SourceType.Y_LOW:return"yLow";case M.plot.SourceType.Y_HIGH:return"yHigh";case M.plot.SourceType.TIME:return"time";case M.plot.SourceType.OPEN:return"open";case M.plot.SourceType.HIGH:return"high";case M.plot.SourceType.LOW:return"low";case M.plot.SourceType.CLOSE:return"close";case M.plot.SourceType.SHAPE:return"shape";case M.plot.SourceType.SIZE:return"size";case M.plot.SourceType.LABEL:return"label";case M.plot.SourceType.COLOR:return"color";case M.plot.SourceType.PARENT:return"parent";case M.plot.SourceType.HOVER_TEXT:return"hovertext";case M.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${e}`)}}static getPlotlySeriesOrientation(t){var n,s;const{sources:e}=t;return e.length===2&&((s=(n=e[0])==null?void 0:n.axis)==null?void 0:s.type)===M.plot.AxisType.Y?ie.ORIENTATION.HORIZONTAL:ie.ORIENTATION.VERTICAL}static getPlotlyErrorBars(t,e,n){const s=n.map((o,r)=>o-t[r]),i=e.map((o,r)=>t[r]-o);return{type:"data",symmetric:!1,array:s,arrayminus:i}}static getPlotlyDateFormat(t,e,n){const s=n==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=t==null?void 0:t.getColumnTypeFormatter(e);return o!=null&&ih(o)&&o.dhTimeZone!=null&&o.showTimeZone&&(i=M.i18n.DateTimeFormat.format(" z",new Date,o.dhTimeZone)),{tickformat:s,ticksuffix:i,automargin:!0}}static convertNumberPrefix(t){return t.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(t,e,n){if(!n)return null;const i=n.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);A(i);const[,o,r,l,,a,d,c,u,m]=i,p=l.replace(",","").length,f=r.indexOf(",")>=0||l.indexOf(",")>=0?",":"",b=c!=null&&c!==""?"e":"f",C=u!==""?u:b,w=a.length+d.length,y=`0${p}${f}.${w}${C}`,E=ie.convertNumberPrefix(o),I=ie.convertNumberPrefix(m);return{tickformat:y,tickprefix:E,ticksuffix:I,automargin:!0}}static getPlotlyAxisFormat(t,e=null){const{axis:n,columnType:s}=t,{formatPattern:i}=n;let o=null;return P.isDateType(s)?(o=ie.getPlotlyDateFormat(e,s,i),o=ie.addTickSpacing(o,n,!0)):P.isNumberType(s)&&(o=ie.getPlotlyNumberFormat(e,s,i),o=ie.addTickSpacing(o,n,!1)),n.formatType===M.plot.AxisFormatType.CATEGORY&&(o?o.type="category":o={type:"category",tickformat:void 0,ticksuffix:void 0}),o}static addTickSpacing(t,e,n){const{gapBetweenMajorTicks:s}=e;if(s>0){const i=t||{};let o=s;return n&&(o=s/rS),e.log&&(o=Math.log(o)),i.tickmode="linear",i.dtick=o,i}return t}static getSourceForAxis(t,e){for(let n=0;n<t.series.length;n+=1){const s=t.series[n];for(let i=0;i<s.sources.length;i+=1){const o=s.sources[i];if(o.axis===e)return o}}return null}static getSeriesVisibility(t,e){return e!=null&&e.hiddenSeries!=null&&e.hiddenSeries.includes(t)?"legendonly":!0}static getHiddenLabels(t){return t!=null&&t.hiddenSeries?[...t.hiddenSeries]:[]}static makeSeriesData(t,e,n,s=ie.ORIENTATION.VERTICAL){return{type:t,mode:e,name:n,orientation:s}}static makeSeriesDataFromSeries(t,e,n,s=zt){const{name:i,plotStyle:o,lineColor:r,shapeColor:l,sources:a}=t,d=a.some(g=>{var f;return(f=g.axis)==null?void 0:f.businessCalendar}),c=ie.getChartType(o,d),u=ie.getPlotlyChartMode(o),m=ie.getPlotlySeriesOrientation(t),p=ie.makeSeriesData(c,u,i,m);return ie.addSourcesToSeriesData(p,o,a,e),ie.addStylingToSeriesData(p,o,s,r,l,n),p}static addSourcesToSeriesData(t,e,n,s){const i=t;for(let o=0;o<n.length;o+=1){const r=n[o],{axis:l,type:a}=r,d=ie.getPlotlyProperty(e,a);eu(i,d,[]);const c=l!=null?ie.getAxisPropertyName(l.type):null;if(c!=null){const u=s.get(l.type);if(u){const m=u.indexOf(l),p=m>0?`${m+1}`:"";i[`${c}axis`]=`${c}${p}`}}}}static addStylingToSeriesData(t,e,n=zt,s=null,i=null,o=null){const r=t;r.marker={line:{}},r.line={width:1},e===M.plot.SeriesPlotStyle.AREA?r.fill="tozeroy":e===M.plot.SeriesPlotStyle.STACKED_AREA?r.stackgroup="stack":e===M.plot.SeriesPlotStyle.STEP?r.line.shape="hv":e===M.plot.SeriesPlotStyle.HISTOGRAM?(r.width=[],r.marker.line!==void 0&&Object.assign(r.marker.line,{color:n.paper_bgcolor,width:1})):e===M.plot.SeriesPlotStyle.OHLC?(r.increasing={line:{color:n.ohlc_increasing}},r.decreasing={line:{color:n.ohlc_decreasing}}):e===M.plot.SeriesPlotStyle.PIE?(r.textinfo="label+percent",r.outsidetextfont={color:n.title_color}):e===M.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&&(e===M.plot.SeriesPlotStyle.BAR?r.marker.color=s:r.line.color=s),i!=null&&(r.marker.color=i),o!=null&&e!==M.plot.SeriesPlotStyle.PIE&&(r.visible=o)}static getAxisFormats(t,e){const n=new Map,s={tickformat:null,ticksuffix:null},i=ie.getAllAxes(t),o=ie.groupArray(i,"type"),{charts:r}=t;for(let l=0;l<r.length;l+=1){const a=r[l];for(let d=0;d<a.series.length;d+=1){const c=a.series[d],{sources:u}=c,m=u.filter(p=>p.axis);for(let p=0;p<m.length;p+=1){const g=m[p],{axis:f}=g,{type:b}=f,C=o.get(b);A(C);const w=C.indexOf(f),T=ie.getAxisPropertyName(b);if(T!=null){const y=ie.getAxisLayoutProperty(T,w);if(n.has(y))Cr.debug(`${y} already added.`);else{Cr.debug(`Adding ${y} to axisFormats.`);const E=ie.getPlotlyAxisFormat(g,e);if(E===null)n.set(y,s);else{n.set(y,E);const{businessCalendar:I}=f;if(I!=null){const R=[],{businessPeriods:F,businessDays:x,holidays:U,timeZone:$}=I,O=e==null?void 0:e.getColumnTypeFormatter(sh);let H;ih(O)&&(H=O.dhTimeZone);const L=H?($.standardOffset-H.standardOffset)/60:0;U.length>0&&R.push(...ie.createRangeBreakValuesFromHolidays(U,$,H)),F.forEach(N=>R.push({pattern:"hour",bounds:[ie.periodToDecimal(N.close)+L,ie.periodToDecimal(N.open)+L]})),x.length<ws.length&&ie.createBoundsFromDays(x).forEach(N=>R.push({pattern:"day of week",bounds:N})),E.rangebreaks=R}if(n.size===a.axes.length)return n}}}}}}return n}static getChartType(t,e){switch(t){case M.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return ie.getPlotlyChartType(t,e)}}static getAxisPropertyName(t){switch(t){case M.plot.AxisType.X:return"x";case M.plot.AxisType.Y:return"y";default:return null}}static getAxisSide(t){switch(t){case M.plot.AxisPosition.BOTTOM:return"bottom";case M.plot.AxisPosition.TOP:return"top";case M.plot.AxisPosition.LEFT:return"left";case M.plot.AxisPosition.RIGHT:return"right";default:return}}static getAllAxes(t){return t.charts.reduce((e,n)=>[...e,...n.axes],[])}static getChartForSeries(t,e){const{charts:n}=t;for(let s=0;s<n.length;s+=1){const i=n[s];for(let o=0;o<i.series.length;o+=1)if(e===i.series[o])return i}return null}static getLayoutRanges(t){const e={},n=Object.keys(t).filter(s=>s.indexOf("axis")>=0);for(let s=0;s<n.length;s+=1){const i=n[s],o=t[i];dS(o)&&(e[i]=[...o.range])}return e}static updateFigureAxes(t,e,n,s=0,i=0,o=zt){const r=t,l=ie.getAllAxes(e);for(let a=0;a<e.charts.length;a+=1){const d=e.charts[a],c=n==null?void 0:n(d),u=ie.getChartBounds(e,d,s,i);ie.updateLayoutAxes(r,d.axes,l,s,i,u,c,o)}ie.removeStaleAxes(r,l)}static getChartBounds(t,e,n=0,s=0){var T;const{cols:i,rows:o}=t,{column:r,colspan:l,row:a,rowspan:d}=e,c=r+l,u=a+d,m=1/i,p=1/o,g=ie.AXIS_SIZE_PX/n,f=ie.AXIS_SIZE_PX/s,b={left:r*m+(r>0?g/2:0),bottom:a*p+(a>0?f/2:0),top:u*p-(u<o?f/2:0),right:c*m-(c<i?g/2:0)};return((T=ie.groupArray(e.axes,"position").get(M.plot.AxisPosition.RIGHT))!=null?T:[]).length>0&&(n>0?b.right-=(b.right-b.left)*Math.max(0,Math.min(ie.LEGEND_WIDTH_PX/n,ie.MAX_LEGEND_SIZE)):b.right-=(b.right-b.left)*ie.DEFAULT_AXIS_SIZE),b}static updateLayoutAxes(t,e,n,s=0,i=0,o={left:0,top:0,right:1,bottom:1},r,l=zt){const a=s>0?Math.max(ie.MIN_AXIS_SIZE,Math.min(ie.AXIS_SIZE_PX/i,ie.MAX_AXIS_SIZE)):ie.DEFAULT_AXIS_SIZE,d=i>0?Math.max(ie.MIN_AXIS_SIZE,Math.min(ie.AXIS_SIZE_PX/s,ie.MAX_AXIS_SIZE)):ie.DEFAULT_AXIS_SIZE,c=t,u=ie.groupArray(e,"position"),m=ie.groupArray(e,"type"),p=[...m.keys()],g=ie.groupArray(n,"type");for(let f=0;f<p.length;f+=1){const b=p[f],C=ie.getAxisPropertyName(b);if(C!=null){const w=m.get(b),T=g.get(b),E=b===M.plot.AxisType.Y?i:s;A(w),A(T);for(let I=0;I<w.length;I+=1){const R=w[I],F=T.indexOf(R),x=ie.getAxisLayoutProperty(C,F);c[x]==null&&(c[x]=ie.makeLayoutAxis(b,l));const U=c[x];if(U!=null){ie.updateLayoutAxis(U,R,I,u,a,d,o);const{range:$,autorange:O}=U;if(r!=null&&$!==void 0&&(O===void 0||O===!1)){const H=r(R),[L,N]=H($);Cr.debug("Setting downsample range",E,L,N),R.range(E,L,N)}else R.range(E)}}}}}static removeStaleAxes(t,e){const n=t,s=ie.groupArray(e,"type"),i=[...s.keys()];for(let o=0;o<i.length;o+=1){const r=i[o],l=s.get(r);A(l);let a=l.length;const d=ie.getAxisPropertyName(r);if(d!=null){let c=ie.getAxisLayoutProperty(d,a);for(;n[c]!=null;)delete n[c],a+=1,c=ie.getAxisLayoutProperty(d,a)}}}static getAxisLayoutProperty(t,e){const n=e>0?`${e+1}`:"";return`${t!=null?t:""}axis${n}`}static updateLayoutAxis(t,e,n,s,i,o,r){var u,m,p;const a=e.type===M.plot.AxisType.Y?o:i,d=t,c=(u=e.label)!=null?u:"";if(d.title!==void 0&&typeof d.title!="string"?d.title.text=c:d.title={text:c},e.log&&(d.type="log"),d.side=ie.getAxisSide(e.position),n>0){d.overlaying=(m=ie.getAxisPropertyName(e.type))!=null?m:void 0;const g=(p=s.get(e.position))!=null?p:[],f=g.indexOf(e);f>0&&(d.anchor="free",e.position===M.plot.AxisPosition.RIGHT?d.position=r.right+(f-g.length+1)*a:e.position===M.plot.AxisPosition.TOP?d.position=r.top+(f-g.length+1)*a:e.position===M.plot.AxisPosition.BOTTOM?d.position=r.bottom+(g.length-f+1)*a:e.position===M.plot.AxisPosition.LEFT&&(d.position=r.left+(g.length-f+1)*a))}else if(e.type===M.plot.AxisType.X){const g=s.get(M.plot.AxisPosition.LEFT)||[],f=s.get(M.plot.AxisPosition.RIGHT)||[],b=Math.max(r.left,r.left+(g.length-1)*o),C=Math.min(r.right-(f.length-1)*o,r.right);d.domain=[b,C]}else if(e.type===M.plot.AxisType.Y){const g=s.get(M.plot.AxisPosition.BOTTOM)||[],f=s.get(M.plot.AxisPosition.TOP)||[],b=Math.max(r.bottom,r.bottom+(g.length-1)*i),C=Math.min(r.top-(f.length-1)*i,r.top);d.domain=[b,C]}}static periodToDecimal(t){const e=t.split(":");return Number(e[0])+Number(e[1])/60}static createBoundsFromDays(t){const e=t.map(o=>ws.indexOf(o)),n=ws.filter(o=>!t.includes(o)).map(o=>ws.indexOf(o)),s=new Set;n.forEach(o=>{for(let r=o+1;r<o+ws.length;r+=1){const l=r%ws.length;if(e.includes(l)){s.add(l);break}}});const i=[];return s.forEach(o=>{for(let r=o-1;r>o-ws.length;r-=1){const l=r<0?r+ws.length:r;if(e.includes(l)){const a=(l+1)%7;i.push([a,o]);break}}}),i}static createRangeBreakValuesFromHolidays(t,e,n){const s=[],i=[];return t.forEach(o=>{o.businessPeriods.length>0?i.push(...ie.createPartialHoliday(o,e,n)):s.push(ie.createFullHoliday(o,e,n))}),[{values:s},...i]}static createFullHoliday(t,e,n){return ie.adjustDateForTimeZone(`${t.date.toString()} 00:00:00.000000`,e,n)}static createPartialHoliday(t,e,n){const s=t.date.toString(),i=["00:00"];t.businessPeriods.forEach(r=>{i.push(r.open),i.push(r.close)}),i.push("24:00");const o=[];for(let r=0;r<i.length;r+=2){const l=i[r],a=i[r+1];if(l!==a){const d=[ie.adjustDateForTimeZone(`${s} ${l}:00.000000`,e,n)],c=oS*(ie.periodToDecimal(a)-ie.periodToDecimal(l));o.push({values:d,dvalue:c})}}return o}static adjustDateForTimeZone(t,e,n){return n&&n.standardOffset!==e.standardOffset?ie.unwrapValue(ie.wrapValue(t,sh,e),n):t}static groupArray(t,e){return t.reduce((n,s)=>{var r;const i=s[e],o=(r=n.get(i))!=null?r:[];return o.push(s),n.set(i,o),n},new Map)}static unwrapValue(t,e){if(t!=null){if(lS(t))return M.i18n.DateTimeFormat.format(ie.DATE_FORMAT,t,e);if(aS(t))return t.asNumber()}return t}static wrapValue(t,e,n=null){if(P.isDateType(e)&&typeof t=="string"){const s=t,i=ie.DATE_FORMAT.substr(0,t.length),o=M.i18n.DateTimeFormat.parse(i,s);if(!n)return o;const r=`${i} Z`,l=M.i18n.DateTimeFormat.format("Z",o,n),a=M.i18n.DateTimeFormat.parse(r,`${s} ${l}`),d=M.i18n.DateTimeFormat.format("Z",a,n);return M.i18n.DateTimeFormat.parse(r,`${s} ${d}`)}return t}static makeLayoutAxis(t,e=zt){const n={automargin:!0,gridcolor:e.gridcolor,linecolor:e.linecolor,rangeslider:{visible:!1},showline:!0,ticklen:5,tickcolor:e.paper_bgcolor,tickfont:{color:e.zerolinecolor},title:{font:{color:e.title_color}}};return t===M.plot.AxisType.X?Object.assign(n,{showgrid:!0}):t===M.plot.AxisType.Y&&Object.assign(n,{zerolinecolor:e.zerolinecolor,zerolinewidth:2}),n}static getColorwayFromTheme(t=zt){let e=[];return t.colorway&&(Array.isArray(t.colorway)?e=t.colorway:typeof t.colorway=="string"?e=t.colorway.split(" "):Cr.warn(`Unable to handle colorway property: ${t.colorway}`)),e}static makeDefaultLayout(t=zt){const e={...t,autosize:!0,colorway:ie.getColorwayFromTheme(t),font:{family:"'Fira Sans', sans-serif"},title:{font:{color:t.title_color},yanchor:"top",pad:{...ie.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:t.title_color}},margin:{...ie.DEFAULT_MARGIN},xaxis:ie.makeLayoutAxis(M.plot.AxisType.X,t),yaxis:ie.makeLayoutAxis(M.plot.AxisType.Y,t)};return e.datarevision=0,e}static hydrateSettings(t){return{...t,type:M.plot.SeriesPlotStyle[t.type]}}static titleFromSettings(t){const{series:e,xAxis:n,title:s=`${e.join(", ")} by ${n}`}=t;return s}static makeFigureSettings(t,e){const{series:n,xAxis:s,type:i}=t,o=ie.titleFromSettings(t),r={formatType:`${M.plot.AxisFormatType.NUMBER}`,type:`${M.plot.AxisType.X}`,position:`${M.plot.AxisPosition.BOTTOM}`},l={formatType:`${M.plot.AxisFormatType.NUMBER}`,type:`${M.plot.AxisType.Y}`,position:`${M.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${M.plot.ChartType.XY}`,axes:[r,l],series:n.map(a=>({plotStyle:`${i}`,name:a,dataSources:[{type:`${M.plot.SourceType.X}`,columnName:s,axis:r,table:e},{type:`${M.plot.SourceType.Y}`,columnName:a,axis:l,table:e}]}))}],title:o}}};let _e=ie;_e.DEFAULT_AXIS_SIZE=.15;_e.MIN_AXIS_SIZE=.025;_e.MAX_AXIS_SIZE=.2;_e.AXIS_SIZE_PX=75;_e.LEGEND_WIDTH_PX=50;_e.MAX_LEGEND_SIZE=.25;_e.ORIENTATION=Object.freeze({HORIZONTAL:"h",VERTICAL:"v"});_e.DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSS";_e.DEFAULT_MARGIN=Object.freeze({l:60,r:50,t:30,b:60,pad:0});_e.DEFAULT_TITLE_PADDING=Object.freeze({t:8});_e.SUBTITLE_LINE_HEIGHT=25;const vs=X.module("Chart"),yo=class extends S.exports.Component{constructor(t){super(t),this.getCachedConfig=he((e,n,s,i)=>{const o=[],r=Boolean(e);if(r&&o.push({name:`Downsampling failed: ${e}`,click:()=>{},icon:yo.convertIcon(Su),attr:"fill-warning"}),n||s||i||r){const l=yo.downsampleButtonTitle(s,i),a=yo.downsampleButtonAttr(s,i),d=s?mu:Xf;o.push({name:l,icon:yo.convertIcon(d),click:this.handleDownsampleClick,attr:a})}return{displaylogo:!1,displayModeBar:s||r?!0:"hover",modeBarButtons:[o,["toImage"],["zoom2d","pan2d"],["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]]}}),this.handleAfterPlot=this.handleAfterPlot.bind(this),this.handleDownsampleClick=this.handleDownsampleClick.bind(this),this.handleModelEvent=this.handleModelEvent.bind(this),this.handlePlotUpdate=this.handlePlotUpdate.bind(this),this.handleRelayout=this.handleRelayout.bind(this),this.handleRestyle=this.handleRestyle.bind(this),this.plot=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(t){const[e,,,,n]=t.icon,s=`${n}`;return{width:e,path:s,ascent:e,descent:0,transform:"matrix(1, 0, 0, 1, 0, 0)"}}static downsampleButtonTitle(t,e){return t?"Downsampling in progress...":e?"Downsampling disabled, click to enable":"Downsampling enabled, click to disable"}static downsampleButtonAttr(t,e){return t?"animation-spin":e?void 0:"fill-active"}componentDidMount(){this.updateDimensions(),this.updateModelDimensions(),this.initData(),this.initFormatter();const{isActive:t}=this.props;t&&this.subscribe()}componentDidUpdate(t){const{isActive:e,settings:n}=this.props;this.updateFormatterSettings(n),e!==t.isActive&&(e?this.subscribe():this.unsubscribe())}componentWillUnmount(){this.unsubscribe()}getPlotRect(){var t,e;return(e=(t=this.plotWrapper.current)==null?void 0:t.getBoundingClientRect())!=null?e:null}initData(){const{model:t}=this.props,{layout:e}=this.state;this.setState({data:t.getData(),layout:{...e,...t.getLayout()}})}subscribe(){if(this.isSubscribed)return;const{model:t}=this.props;if(!this.rect||this.rect.width===0||this.rect.height===0){vs.debug2("Delaying subscription until model dimensions are set");return}t.subscribe(this.handleModelEvent),this.isSubscribed=!0}unsubscribe(){if(!this.isSubscribed)return;const{model:t}=this.props;t.unsubscribe(this.handleModelEvent),this.isSubscribed=!1}handleAfterPlot(){this.plot.current!=null}handleDownsampleClick(){this.setState(({isDownsamplingDisabled:t})=>({downsamplingError:null,isDownsampleInProgress:!1,isDownsampleFinished:!1,isDownsamplingDisabled:!t}),()=>{const{model:t}=this.props,{isDownsamplingDisabled:e}=this.state;t.setDownsamplingDisabled(e)})}handleModelEvent(t){var s;const{type:e,detail:n}=t;switch(vs.debug2("Received data update",e,n),e){case St.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 St.EVENT_LOADFINISHED:{const{onUpdate:i}=this.props;this.isLoadedFired=!0,i({isLoading:!1});break}case St.EVENT_DISCONNECT:{const{onDisconnect:i}=this.props;i();break}case St.EVENT_RECONNECT:{const{onReconnect:i}=this.props;i();break}case St.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case St.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case St.EVENT_DOWNSAMPLENEEDED:case St.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:vs.debug("Unknown event type",e,t)}}handlePlotUpdate(t){const{layout:e}=t,n=_e.getLayoutRanges(e);!ct(n,this.ranges)&&(this.ranges=n,this.updateModelDimensions(!0))}handleRelayout(t){if(vs.debug("handleRelayout",t),t.hiddenlabels!=null){const{onSettingsChanged:e}=this.props,n=[...t.hiddenlabels];e({hiddenSeries:n})}this.updateModelDimensions()}handleRestyle([t,e]){if(vs.debug("handleRestyle",t,e),Object.keys(t).includes("visible")){const{data:n}=this.state,{onSettingsChanged:s}=this.props;if(n!=null){const i=n.reduce((o,{name:r,visible:l})=>r!=null&&l==="legendonly"?[...o,r]:o,[]);s({hiddenSeries:i})}}}updateModelDimensions(t=!1){const e=this.getPlotRect();if(!e){vs.warn("Unable to get plotting rect");return}if(!this.rect||this.rect.width!==e.width||this.rect.height!==e.height||t){this.rect=e;const{isActive:s,model:i}=this.props;i.setDimensions(e),s&&this.subscribe()}}initFormatter(){const{settings:t}=this.props;this.updateFormatterSettings(t)}updateFormatterSettings(t){const e=cs.getColumnFormats(t),n=cs.getDateTimeFormatterOptions(t),{decimalFormatOptions:s={},integerFormatOptions:i={}}=t;(!ct(this.columnFormats,e)||!ct(this.dateTimeFormatterOptions,n)||!ct(this.decimalFormatOptions,s)||!ct(this.integerFormatOptions,i))&&(this.columnFormats=cs.getColumnFormats(t),this.dateTimeFormatterOptions=n,this.decimalFormatOptions=s,this.integerFormatOptions=i,this.updateFormatter())}updateFormatter(){const t=new cn(this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions),{model:e}=this.props;e.setFormatter(t)}updateDimensions(){const t=this.getPlotRect();this.plot.current!=null&&t!=null&&t.width>0&&t.height>0&&$r.relayout(this.plot.current.el,{autosize:!0}).catch(e=>{vs.debug("Unable to resize, promise rejected",e)})}render(){const{data:t,downsamplingError:e,isDownsampleFinished:n,isDownsampleInProgress:s,isDownsamplingDisabled:i,layout:o,revision:r}=this.state,l=this.getCachedConfig(e,n,s,i),a=t!=null;return h("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:a&&h(rm,{ref:this.plot,data:t,layout:o,revision:r,config:l,onAfterPlot:this.handleAfterPlot,onError:vs.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}};let lm=yo;lm.defaultProps={isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:us.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}};const Ft=X.module("FigureChartModel"),am=class extends St{constructor(t,e={},n=zt){super(),this.addPendingSeries=Xe(()=>{const i=_e.getAllAxes(this.figure),{pendingSeries:o}=this;for(let r=0;r<o.length;r+=1){const l=o[r];this.addSeries(l,i),l.subscribe()}this.pendingSeries=[]},am.ADD_SERIES_DEBOUNCE),this.getTimeZone=Te((i,o)=>{if(o!=null){const r=o.getColumnTypeFormatter(i);if(r!=null)return r.dhTimeZone}return null}),this.getValueTranslator=Te((i,o)=>{const r=this.getTimeZone(i,o);return l=>_e.unwrapValue(l,r)}),this.getValueParser=Te((i,o)=>{const r=this.getTimeZone(i,o);return l=>_e.wrapValue(l,i,r)}),this.getRangeParser=Te((i,o)=>r=>{let[l,a]=r;const d=this.getValueParser(i,o);return l=d(l),a=d(a),[l,a]}),this.getAxisRangeParser=Te((i,o)=>r=>{const l=_e.getSourceForAxis(i,r);return l?this.getRangeParser(l.columnType,o):a=>a}),this.handleFigureUpdated=this.handleFigureUpdated.bind(this),this.handleFigureDisconnected=this.handleFigureDisconnected.bind(this),this.handleFigureReconnected=this.handleFigureReconnected.bind(this),this.handleFigureSeriesAdded=this.handleFigureSeriesAdded.bind(this),this.handleDownsampleStart=this.handleDownsampleStart.bind(this),this.handleDownsampleFinish=this.handleDownsampleFinish.bind(this),this.handleDownsampleFail=this.handleDownsampleFail.bind(this),this.handleDownsampleNeeded=this.handleDownsampleNeeded.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.figure=t,this.settings=e,this.theme=n,this.data=[];const s={data:{},layout:_e.makeDefaultLayout(n)};this.layout={grid:{rows:t.rows,columns:t.cols,pattern:"independent"},template:s},this.seriesDataMap=new Map,this.pendingSeries=[],this.oneClicks=[],this.filterColumnMap=new Map,this.lastFilter=new Map,this.isConnected=!0,this.seriesToProcess=new Set,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure()}close(){this.figure.close(),this.addPendingSeries.cancel(),this.stopListeningFigure()}getDefaultTitle(){return this.figure.charts.length>0?this.figure.charts[0].title:""}initAllSeries(){this.oneClicks=[],this.filterColumnMap.clear();const{charts:t}=this.figure,e=_e.getAllAxes(this.figure),n=[];for(let o=0;o<t.length;o+=1){const r=t[o];for(let l=0;l<r.series.length;l+=1){const a=r.series[l];n.push(a.name),this.addSeries(a,e)}}const i=[...this.seriesDataMap.keys()].filter(o=>n.indexOf(o)<0);for(let o=0;o<i.length;o+=1){const r=i[o];this.seriesDataMap.delete(r)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(t,e){const n=_e.groupArray(e,"type"),s=_e.makeSeriesDataFromSeries(t,n,_e.getSeriesVisibility(t.name,this.settings),this.theme);if(this.seriesDataMap.set(t.name,s),this.data=[...this.seriesDataMap.values()],t.plotStyle===M.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":t.plotStyle===M.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=_e.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||t.plotStyle===M.plot.SeriesPlotStyle.PIE,t.oneClick!=null){const{oneClick:i}=t,{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(t){super.subscribe(t),this.listeners.length===1&&(this.initAllSeries(),this.subscribeFigure())}unsubscribe(t){super.unsubscribe(t),this.listeners.length===0&&this.unsubscribeFigure()}subscribeFigure(){if(!this.isConnected){Ft.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?M.plot.DownsampleOptions.DISABLE:M.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){this.figure.addEventListener(M.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.addEventListener(M.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.addEventListener(M.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.addEventListener(M.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.addEventListener(M.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.addEventListener(M.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.addEventListener(M.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.addEventListener(M.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.addEventListener(M.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}stopListeningFigure(){this.figure.removeEventListener(M.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.removeEventListener(M.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.removeEventListener(M.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.removeEventListener(M.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.removeEventListener(M.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.removeEventListener(M.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.removeEventListener(M.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.removeEventListener(M.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.removeEventListener(M.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}handleDownsampleStart(t){Ft.debug("Downsample started",t),this.fireDownsampleStart(t.detail)}handleDownsampleFinish(t){Ft.debug("Downsample finished",t),this.fireDownsampleFinish(t.detail)}handleDownsampleFail(t){Ft.error("Downsample failed",t),this.fireDownsampleFail(t.detail)}handleDownsampleNeeded(t){Ft.info("Downsample needed",t),this.fireDownsampleNeeded(t.detail)}handleFigureUpdated(t){const{detail:e}=t,{series:n}=e;Ft.debug2("handleFigureUpdated",n);for(let i=0;i<n.length;i+=1){const o=n[i];Ft.debug2("handleFigureUpdated updating series",o.name);const{sources:r}=o;for(let l=0;l<r.length;l+=1){const a=r[l],{columnType:d,type:c}=a,u=this.getValueTranslator(d,this.formatter),m=e.getArray(o,c,u);this.setDataArrayForSeries(o,c,m)}this.seriesToProcess.delete(o.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(o)}const{data:s}=this;this.fireUpdate(s)}handleRequestFailed(t){Ft.error("Request failed",t)}resubscribe(){this.listeners.length>0&&(this.unsubscribeFigure(),this.subscribeFigure())}setFormatter(t){super.setFormatter(t),this.updateLayoutFormats(),this.resubscribe()}setDownsamplingDisabled(t){super.setDownsamplingDisabled(t),this.resubscribe()}handleFigureDisconnected(t){Ft.debug("Figure disconnected",t),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(t){Ft.debug("Figure reconnected",t),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(t){const{detail:e}=t;Ft.debug("handleFigureSeriesAdded",e),this.pendingSeries.push(e),this.addPendingSeries()}setDimensions(t){super.setDimensions(t),this.updateAxisPositions()}setTitle(t){var s,i;super.setTitle(t);const e=(i=(s=(t!=null?t:"").match(/<br>/g))==null?void 0:s.length)!=null?i:0,n=_e.DEFAULT_MARGIN.t+e*_e.SUBTITLE_LINE_HEIGHT;this.layout.margin?this.layout.margin.t=n:this.layout.margin={t:n},typeof this.layout.title=="string"?this.layout.title=t:(this.layout.title={...this.layout.title},this.layout.title.text=t,this.layout.title.pad={...this.layout.title.pad},this.layout.title.pad.t=_e.DEFAULT_TITLE_PADDING.t+e*_e.SUBTITLE_LINE_HEIGHT*.5)}getPlotWidth(){var t,e,n,s;return!this.rect||!this.rect.width?0:Math.max(this.rect.width-((e=(t=this.layout.margin)==null?void 0:t.l)!=null?e:0)-((s=(n=this.layout.margin)==null?void 0:n.r)!=null?s:0),0)}getPlotHeight(){var t,e,n,s;return!this.rect||!this.rect.height?0:Math.max(this.rect.height-((e=(t=this.layout.margin)==null?void 0:t.t)!=null?e:0)-((s=(n=this.layout.margin)==null?void 0:n.b)!=null?s:0),0)}updateAxisPositions(){const t=this.getPlotWidth(),e=this.getPlotHeight();_e.updateFigureAxes(this.layout,this.figure,n=>this.getAxisRangeParser(n,this.formatter),t,e,this.theme)}updateLayoutFormats(){if(!this.formatter)return;_e.getAxisFormats(this.figure,this.formatter).forEach((e,n)=>{Ft.debug(`Assigning ${n}`,this.layout[n],e);const s=this.layout[n];s!=null?Object.assign(s,e):Ft.debug(`Ignoring null layout.${n}`)})}setDataArrayForSeries(t,e,n){const{name:s,plotStyle:i}=t,o=this.seriesDataMap.get(s),r=_e.getPlotlyProperty(i,e);o&&eu(o,r,n)}cleanSeries(t){const{name:e,plotStyle:n}=t,s=this.seriesDataMap.get(e);if(s!=null){if(n===M.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===M.plot.SeriesPlotStyle.LINE){const{x:i,xLow:o,xHigh:r,y:l,yLow:a,yHigh:d}=s;o&&r&&o!==i&&(s.error_x=_e.getPlotlyErrorBars(i,o,r)),a&&d&&a!==l&&(s.error_y=_e.getPlotlyErrorBars(l,a,d))}else if(n===M.plot.SeriesPlotStyle.TREEMAP){const{ids:i,labels:o}=s;i!==void 0&&o===void 0&&(s.labels=i)}}}getData(){return this.data}getLayout(){return this.layout}getFilterColumnMap(){return new Map(this.filterColumnMap)}isFilterRequired(){return this.oneClicks.find(t=>t.requireAllFiltersToDisplay)!=null}setFilter(t){if(this.oneClicks.length===0){Ft.warn("Trying to set a filter, but no one click!");return}Ft.debug("setFilter",t);for(let e=0;e<this.oneClicks.length;e+=1){const n=this.oneClicks[e],{columns:s}=n;new Set([...t.keys(),...this.lastFilter.keys()]).forEach(o=>{const r=t.get(o);this.lastFilter.get(o)!==r&&s.find(l=>l.name===o)!=null&&n.setValueForColumn(o,r)})}this.lastFilter=new Map(t)}setFigure(t){this.close(),this.figure=t,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure(),this.listeners.length>0&&this.subscribeFigure()}updateSettings(t){this.settings=t}};let Fa=am;Fa.ADD_SERIES_DEBOUNCE=50;class zi{static async makeModelFromSettings(e,n,s=zt){const i=await zi.makeFigureFromSettings(e,n);return new Fa(i,e,s)}static async makeFigureFromSettings(e,n){const s=await n.copy();return s.applyCustomColumns(n.customColumns),s.applyFilter(n.filter),s.applySort(n.sort),M.plot.Figure.create(_e.makeFigureSettings(e,s))}static async makeModel(e,n,s=zt){return new Fa(n,e,s)}}function oh(t){return t.setFigure!==void 0}const cS=({connection:t,defaultUpdateInterval:e,hoverUpdateInterval:n,bgMonitoring:s=!0,monitorDuration:i})=>{var U;const[o,r]=S.exports.useState({freeMemory:0,maximumHeapSize:999,totalHeapSize:0}),[l,a]=S.exports.useState(!1),d=S.exports.useRef({timestamps:[],usages:[]});S.exports.useEffect(function(){const O=async()=>{const L=await t.getWorkerHeapInfo();if(r(L),s||l){const N=(L.totalHeapSize-L.freeMemory)/L.maximumHeapSize,_=Date.now(),{timestamps:k,usages:V}=d.current;for(;k.length!==0&&_-k[0]>i*1.5;)k.shift(),V.shift();k.push(_),V.push(N)}else d.current={timestamps:[],usages:[]}};O();const H=setInterval(O,l?n:e);return()=>{clearInterval(H)}},[l,n,t,e,i,s]);const c=($,O)=>Math.round($*10**O)/10**O,u=2,m=1024**3,{freeMemory:p,totalHeapSize:g,maximumHeapSize:f}=o,b=c(p/m,u),C=c(g/m,u),w=c(f/m,u),T=C-b,y=($,O,H=!1)=>v("div",{className:z("heap-usage-info-row",{"heading-bottom-border":H}),children:[h("div",{className:"font-weight-bold",children:$}),h("div",{children:O})]}),{timestamps:E,usages:I}=d.current,R=(U=E[E.length-1])!=null?U:0,F=g/f,x=(g-p)/f;return v(ue,{children:[v("div",{className:"max-memory",children:[h("div",{className:"total-memory",style:{width:`calc(${F*100}% - ${F*2}px`}}),h("div",{className:z("used-memory",{"heap-overflow":(g-p)/f>.95}),style:{width:`calc(${x*100}% - ${x*2}px`}}),v("div",{className:"memory-text",children:[w.toFixed(1)," GB"]})]}),h(Ie,{onEntered:()=>a(!0),onExited:()=>a(!1),interactive:!0,children:v("div",{className:"heap-tooltip",children:[y("In use:",`${T.toFixed(u)} of ${w.toFixed(u)} GB`,!0),y("Free:",`${b.toFixed(u)} GB`),y("Total:",`${C.toFixed(u)} GB`),y("Max:",`${w.toFixed(u)} GB`),h("div",{className:"heap-plot",children:h(rm,{data:[{x:[...E],y:[...I],type:"scatter",mode:"lines"}],config:{staticPlot:!0,responsive:!0},style:{width:"196px",height:"100px"},layout:{legend:!1,margin:{l:2,t:2,r:2,b:2},plot_bgcolor:"transparent",paper_bgcolor:"transparent",colorway:["#4878ea"],xaxis:{dtick:Math.round(i/6),gridcolor:zt.linecolor,range:[R-i,R],linecolor:zt.linecolor,linewidth:2,mirror:!0},yaxis:{dtick:.2,gridcolor:zt.linecolor,range:[0,1],linecolor:zt.linecolor,linewidth:2,mirror:!0}}})}),v("div",{className:"heap-utilisation-text",children:["% utilization over ",Math.round(i/1e3/60)," min."]})]})})]})},dm=Object.freeze({}),hS=new Map,cm=t=>t.user,wd=t=>t.storage,hm=t=>wd(t).commandHistoryStorage,um=t=>wd(t).fileStorage,uS=t=>wd(t).workspaceStorage,yl=t=>t.workspace,Kt=t=>yl(t).data.settings,mS=t=>Kt(t).defaultDateTimeFormat,pS=t=>{var e;return(e=Kt(t).defaultDecimalFormatOptions)!=null?e:dm},gS=t=>{var e;return(e=Kt(t).defaultIntegerFormatOptions)!=null?e:dm},fS=t=>Kt(t).formatter,Il=t=>Kt(t).timeZone,CS=t=>Kt(t).showTimeZone,bS=t=>Kt(t).showTSeparator,SS=t=>Kt(t).truncateNumbersWithPound,wS=t=>Kt(t).shortcutOverrides,Rl=t=>t.activeTool,vS=t=>{var e;return(e=t.plugins)!=null?e:hS},mm="SET_ACTIVE_TOOL",pm="SET_COMMAND_HISTORY_STORAGE",gm="SET_FILE_STORAGE",fm="SET_PLUGINS",Cm="SET_USER",bm="SET_WORKSPACE",Sm="SET_WORKSPACE_STORAGE",TS=t=>({type:Cm,payload:t}),wm=t=>({type:bm,payload:t}),ES=t=>({type:Sm,payload:t}),yS=t=>({type:pm,payload:t}),IS=t=>({type:gm,payload:t}),RS=t=>(e,n)=>{e(wm(t));const{storage:s}=n(),{workspaceStorage:i}=s;return i.save(t)},vm=t=>(e,n)=>{const{workspace:s}=n(),{data:i}=s,o={...s,data:{...i,...t}};return e(RS(o))},Tm=t=>e=>e(vm({settings:t})),Dl=t=>({type:mm,payload:t}),DS=t=>({type:fm,payload:t});function Em(t,e){return(n=e,s)=>{switch(s.type){case t:{const i=s.payload;return i==null?null:n!=null?{...n,...i}:{...i}}default:return n}}}function MS(t,e={},n=!0){return(s=e,i)=>{switch(i.type){case t:{const{id:o,payload:r}=i;return n&&ct({payload:r},{payload:s[o]})?s:{...s,[o]:r}}default:return s}}}function fi(t,e){return(n=e,s)=>{switch(s.type){case t:return s.payload;default:return n}}}const NS=fi(mm,null),FS=fi(fm,null),xS=fi(pm,null),_S=fi(gm,null),kS=fi(Sm,null),OS=Ja({commandHistoryStorage:xS,fileStorage:_S,workspaceStorage:kS}),LS=Em(Cm,null),AS=Em(bm,null),PS={activeTool:NS,plugins:FS,storage:OS,user:LS,workspace:AS};class HS{constructor(){this.reducers={},this.listener=null}register(e,n){var s;this.reducers={...this.reducers,[e]:n},(s=this.listener)==null||s.call(this,this.reducers)}setListener(e){this.listener=e}}const Zi=new HS,rh=X.module("redux-logger"),VS=t=>e=>n=>{rh.debug("dispatching",n);const s=e(n);return rh.debug("next state",t.getState()),s},US=X.module("redux-crashReporter"),BS=t=>e=>n=>{try{return e(n)}catch(s){throw US.error("Error executing",n," with state ",t.getState(),":",s),s}},$S=[VS,BS,sg];Object.entries(PS).map(([t,e])=>Zi.register(t,e));var Jh;const zS=(Jh=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__)!=null?Jh:rg,Ml=ig(Ja(Zi.reducers),zS(og(...$S)));Zi.setListener(t=>{Ml.replaceReducer(Ja(t))});const ym=Object.freeze({openPopouts:[],settings:{hasHeaders:!0,constrainDragToContainer:!0,reorderEnabled:!0,selectionEnabled:!1,popoutWholeStack:!1,blockedPopoutsThrowError:!0,closePopoutsOnUnload:!0,showPopoutIcon:!0,showMaximiseIcon:!0,showCloseIcon:!0,responsiveMode:"onload",tabOverlapAllowance:0,tabControlOffset:10},dimensions:{borderWidth:5,borderGrabWidth:10,minItemHeight:10,minItemWidth:10,headerHeight:20,dragProxyWidth:300,dragProxyHeight:200},labels:{close:"Close",maximise:"Maximize",minimise:"Minimize",popout:"Open in new window",popin:"Pop in",tabDropdown:"Additional tabs",tabNextLabel:"Next",tabPreviousLabel:"Previous"},content:[]});function Im(t){return t.componentName!==void 0}function WS(t){return t.component!==void 0}const Rm=Object.freeze({type:"default",isClosable:!0,isFocusOnShow:!0,reorderEnabled:!0,title:""}),GS=Object.freeze(Object.defineProperty({__proto__:null,defaultConfig:ym,isGLComponentConfig:Im,isReactComponentConfig:WS,itemDefaultConfig:Rm},Symbol.toStringTag,{value:"Module"})),xa=class{constructor(){this.off=this.unbind,this.trigger=this.emit,this._mSubscriptions={},this._mSubscriptions[xa.ALL_EVENT]=[]}on(t,e,n){if(typeof e!="function")throw new Error("Tried to listen to event "+t+" with non-function callback "+e);this._mSubscriptions[t]||(this._mSubscriptions[t]=[]),this._mSubscriptions[t].push({fn:e,ctx:n})}emit(t,...e){const n=this._mSubscriptions[t];if(n)for(let i=0;i<n.length;i++){const o=n[i].ctx||{};n[i].fn.apply(o,e)}e.unshift(t);const s=this._mSubscriptions[xa.ALL_EVENT];for(let i=0;i<s.length;i++){const o=s[i].ctx||{};s[i].fn.apply(o,e)}}unbind(t,e,n){if(!this._mSubscriptions[t])throw new Error("No subscribtions to unsubscribe for event "+t);let s=!1;for(let i=0;i<this._mSubscriptions[t].length;i++)(!e||this._mSubscriptions[t][i].fn===e)&&(!n||n===this._mSubscriptions[t][i].ctx)&&(this._mSubscriptions[t].splice(i,1),s=!0);if(s===!1)throw new Error("Nothing to unbind for "+t)}};let bn=xa;bn.ALL_EVENT="__all";class _a extends bn{constructor(e,n,s){super(),this.isHidden=!1,this._element=ce(['<div class="lm_item_container">','<div class="lm_content" tabindex="-1"></div>',"</div>"].join("")),this.title=Im(e)?e.componentName:"",this.parent=n,this.layoutManager=s,this._config=e,this._contentElement=this._element.find(".lm_content")}getElement(){return this._contentElement}hide(){this.emit("hide"),this.isHidden=!0,this._element.hide()}show(){this.emit("show"),this.isHidden=!1,this._element.show(),(this.height!=0||this.width!=0)&&this.emit("shown")}setSize(e,n){var c,u,m,p;let s=this.parent,i=null;for(;s&&!s.isColumn&&!s.isRow;)if(i=s,s=s.parent,s!=null&&s.isRoot)return!1;if(!s||!i)return!1;const o=s.isColumn?"height":"width",r=o==="height"?n:e,l=((c=this[o])!=null?c:0)*(1/(((u=i.config[o])!=null?u:0)/100)),a=r/l*100,d=(((m=i.config[o])!=null?m:0)-a)/(s.contentItems.length-1);for(let g=0;g<s.contentItems.length;g++)s.contentItems[g]===i?s.contentItems[g].config[o]=a:s.contentItems[g].config[o]=((p=s.contentItems[g].config[o])!=null?p:0)+d;return s.callDownwards("setSize"),!0}close(){this._config.isClosable&&(this.emit("close"),this.parent.close())}getState(){return this._config.componentState}extendState(e){this.setState(ce.extend(!0,this.getState(),e))}setState(e){this._config.componentState=e,this.parent.emitBubblingEvent("stateChanged")}setTitle(e){this.parent.setTitle(e)}_$setSize(e=0,n=0){if(e!==this.width||n!==this.height){this.width=e,this.height=n;var s=this._contentElement[0],i=s.offsetWidth-s.clientWidth,o=s.offsetHeight-s.clientHeight;this._contentElement.width(this.width-i).height(this.height-o),this.emit("resize")}}}const KS=Object.freeze(Object.defineProperty({__proto__:null,ItemContainer:_a,Container:_a},Symbol.toStringTag,{value:"Module"}));function Dm(t){var e=location.hash.match(new RegExp(t+"=([^&]*)"));return e?e[1]:null}function Mm(t){if(window.location.hash)return Dm(t);if(!window.location.search)return null;var e=window.location.search.substr(1).split("&"),n={},s,i;for(i=0;i<e.length;i++)s=e[i].split("="),n[s[0]]=s[1];return n[t]||null}function Nl(t){return window.requestAnimationFrame(t)}function qS(t,e){var n=e.indexOf(t);if(n===-1)throw new Error("Can't remove item from array. Item is not in the array");e.splice(n,1)}function vd(){return(Math.random()*1e15).toString(36).replace(".","")}function YS(t,e){var n=t.replace(/javascript/gi,"javascript").replace(/expression/gi,"expression").replace(/onload/gi,"onload").replace(/script/gi,"script").replace(/onerror/gi,"onerror");return e===!0?n:n.replace(/>/g,">").replace(/</g,"<")}function Td(t){return ce.trim(t.replace(/(<([^>]+)>)/gi,""))}class Wo extends bn{constructor(e,n=!1){var s;super(),this._nDelay=400,this._nDistance=10,this._nX=0,this._nY=0,this._nOriginalX=0,this._nOriginalY=0,this._bDragging=!1,this._eElement=e,this._oDocument=ce(document),this._eBody=ce(document.body),this._destroyAfterMouseUp=n,this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this._startDrag=this._startDrag.bind(this),(s=this._eElement)==null||s.on("mousedown",this.onMouseDown)}destroy(){var e,n;(e=this._eElement)==null||e.unbind("mousedown",this.onMouseDown),(n=this._oDocument)==null||n.unbind("mouseup",this.onMouseUp),this._eElement=void 0,this._oDocument=void 0,this._eBody=void 0,clearTimeout(this._timeout),this._timeout=void 0}onMouseDown(e){var s,i,o,r;if(e.preventDefault(),e.button===0){var n=this._getCoordinates(e);this._nOriginalX=(s=n.x)!=null?s:0,this._nOriginalY=(i=n.y)!=null?i:0,(o=this._oDocument)==null||o.on("mousemove",this.onMouseMove),(r=this._oDocument)==null||r.on("mouseup",this.onMouseUp),this._timeout=window.setTimeout(this._startDrag,this._nDelay)}}onMouseMove(e){var s,i;if(this._timeout!=null){e.preventDefault();var n=this._getCoordinates(e);this._nX=((s=n.x)!=null?s:0)-this._nOriginalX,this._nY=((i=n.y)!=null?i:0)-this._nOriginalY,this._bDragging===!1&&(Math.abs(this._nX)>this._nDistance||Math.abs(this._nY)>this._nDistance)&&this._startDrag(),this._bDragging&&this.emit("drag",this._nX,this._nY,e)}}onMouseUp(e){var n,s,i,o,r,l;this._timeout!=null&&(clearTimeout(this._timeout),(n=this._oDocument)==null||n.unbind("mousemove",this.onMouseMove),(s=this._oDocument)==null||s.unbind("mouseup",this.onMouseUp),(o=(i=this._oDocument)==null?void 0:i.find("iframe"))==null||o.css("pointer-events",""),this._bDragging===!0&&(this._bDragging=!1,this.emit("dragStop",e,this._nOriginalX+this._nX)),(r=this._eBody)==null||r.removeClass("lm_dragging"),this._eElement instanceof Window||(l=this._eElement)==null||l.removeClass("lm_dragging"),this._destroyAfterMouseUp&&this.destroy())}_startDrag(){var e,n,s,i;window.clearTimeout(this._timeout),this._bDragging=!0,(e=this._eBody)==null||e.addClass("lm_dragging"),(n=this._eElement)==null||n.addClass("lm_dragging"),(i=(s=this._oDocument)==null?void 0:s.find("iframe"))==null||i.css("pointer-events","none"),this.emit("dragStart",this._nOriginalX,this._nOriginalY)}_getCoordinates(e){const n=e.originalEvent instanceof TouchEvent?e.originalEvent.touches[0]:e;return{x:n.pageX,y:n.pageY}}}class Nm{constructor(e,n){this._reactComponent=null,this._originalComponentWillUpdate=null,this._reactComponent=null,this._originalComponentWillUpdate=null,this._container=e,this._initialState=n,this._reactClass=this._getReactClass(),this._container.on("open",this._render,this),this._container.on("destroy",this._destroy,this)}_render(){ui.render(this._getReactComponent(),this._container.getElement()[0])}_gotReactComponent(e){if(!e)return;this._reactComponent=e,this._originalComponentWillUpdate=this._reactComponent.componentWillUpdate||function(){},this._reactComponent.componentWillUpdate=this._onUpdate.bind(this);const n=this._container.getState();n&&this._reactComponent.setState(n)}_destroy(){ui.unmountComponentAtNode(this._container.getElement()[0]),this._container.off("open",this._render,this),this._container.off("destroy",this._destroy,this)}_onUpdate(e,n){var s;this._container.setState(n),(s=this._originalComponentWillUpdate)==null||s.call(this._reactComponent,e,n)}_getReactClass(){var e=this._container._config.component;if(!e)throw new Error("No react component name. type: react-component needs a field `component`");const n=this._container.layoutManager.getComponent(e)||this._container.layoutManager.getFallbackComponent();if(!n)throw new Error('React component "'+e+'" not found. Please register all components with GoldenLayout using `registerComponent(name, component)`');return n}_getReactComponent(){var e={glEventHub:this._container.layoutManager.eventHub,glContainer:this._container,ref:this._gotReactComponent.bind(this)},n=ce.extend(e,this._container._config.props);return Y.createElement(this._reactClass,n)}}const Qr=["settings","hasHeaders","constrainDragToContainer","selectionEnabled","dimensions","borderWidth","minItemHeight","minItemWidth","headerHeight","dragProxyWidth","dragProxyHeight","labels","close","maximise","minimise","popout","content","componentName","componentState","id","width","type","height","isClosable","title","popoutWholeStack","openPopouts","parentId","activeItemIndex","reorderEnabled","borderGrabWidth"],XS=[!0,!1,"row","column","stack","component","close","maximise","minimise","open in new window"];function Ed(t){if(Qr.length>36)throw new Error("Too many keys in config minifier map");const e={};return yd(t,e,"_min"),e}function ka(t){if(Qr.length>36)throw new Error("Too many keys in config minifier map");const e={};return yd(t,e,"_max"),e}function yd(t,e,n){const s=n==="_min"?jS:QS;for(let i in t){if(!t.hasOwnProperty(i))continue;const o=Array.isArray(t)?t[Number.parseInt(i,10)]:t[i];if(typeof o=="object"&&o!=null){const r=o instanceof Array?[]:{};if(Array.isArray(e))e[Number.parseInt(i,10)]=r;else{const l=s(i,Qr);e[l]=r}yd(o,r,n)}else{const r=s(o,XS);if(Array.isArray(e))e[Number.parseInt(i,10)]=r;else{const l=s(i,Qr);e[l]=r}}}}function jS(t,e){if(typeof t=="string"&&t.length===1)return"___"+t;var n=e.indexOf(t);return n===-1?t:n.toString(36)}function QS(t,e){return typeof t=="string"&&t.length===1?e[parseInt(t,36)]:typeof t=="string"&&t.substr(0,3)==="___"?t[3]:t}class Oa{constructor(e,n){this.name=e,this.origin=n,this.isPropagationStopped=!1}stopPropagation(){this.isPropagationStopped=!0}}class Fm extends bn{constructor(e){super(),this._layoutManager=e,this._dontPropagateToParent=null,this._childEventSource=null,this.on(bn.ALL_EVENT,this._onEventFromThis.bind(this)),this._boundOnEventFromChild=this._onEventFromChild.bind(this),ce(window).on("gl_child_event",this._boundOnEventFromChild)}_onEventFromThis(...e){this._layoutManager.isSubWindow&&e[0]!==this._dontPropagateToParent&&this._propagateToParent(e),this._propagateToChildren(e),this._dontPropagateToParent=null,this._childEventSource=null}_$onEventFromParent(e){this._dontPropagateToParent=e[0],this.emit.apply(this,e)}_onEventFromChild(e){this._childEventSource=e.originalEvent.__gl,this.emit.apply(this,e.originalEvent.__glArgs)}_propagateToParent(e){var i;const n="gl_child_event",s=(i=window.opener)==null?void 0:i.document.createEvent("HTMLEvents");s.initEvent(n,!0,!0),s.eventName=n,s.__glArgs=e,s.__gl=this._layoutManager,window.opener.dispatchEvent(s)}_propagateToChildren(e){for(let n=0;n<this._layoutManager.openPopouts.length;n++){const s=this._layoutManager.openPopouts[n].getGlInstance();s&&s!==this._childEventSource&&s.eventHub._$onEventFromParent(e)}}destroy(){ce(window).off("gl_child_event",this._boundOnEventFromChild)}}const ZS=Object.freeze(Object.defineProperty({__proto__:null,EventEmitter:bn,DragListener:Wo,ReactComponentHandler:Nm,BubblingEvent:Oa,EventHub:Fm,getHashValue:Dm,getQueryStringParam:Mm,animFrame:Nl,removeFromArray:qS,getUniqueId:vd,filterXss:YS,stripTags:Td,minifyConfig:Ed,unminifyConfig:ka},Symbol.toStringTag,{value:"Module"}));class xm extends bn{constructor(e,n,s,i,o){super(),this.isInitialised=!1,this._popoutWindow=null,this._id=null,this._config=e,this._dimensions=n,this._parentId=s,this._indexInParent=i,this._layoutManager=o,this._createWindow()}toConfig(){var e,n,s,i,o,r,l,a,d,c,u;if(this.isInitialised===!1)throw new Error("Can't create config, layout not yet initialised");return{dimensions:{width:(e=this.getGlInstance())==null?void 0:e.width,height:(n=this.getGlInstance())==null?void 0:n.height,left:(r=(o=(s=this._popoutWindow)==null?void 0:s.screenX)!=null?o:(i=this._popoutWindow)==null?void 0:i.screenLeft)!=null?r:0,top:(c=(d=(l=this._popoutWindow)==null?void 0:l.screenY)!=null?d:(a=this._popoutWindow)==null?void 0:a.screenTop)!=null?c:0},content:(u=this.getGlInstance())==null?void 0:u.toConfig().content,parentId:this._parentId,indexInParent:this._indexInParent}}getGlInstance(){var e;return(e=this._popoutWindow)==null?void 0:e.__glInstance}getWindow(){return this._popoutWindow}close(){var e,n;if(this.getGlInstance())(e=this.getGlInstance())==null||e._$closeWindow();else try{(n=this.getWindow())==null||n.close()}catch{}}popIn(){var s,i;this._indexInParent;let e=null,n=null;this._parentId&&(e=ce.extend(!0,{},(s=this.getGlInstance())==null?void 0:s.toConfig()).content[0],n=this._layoutManager.root.getItemsById(this._parentId)[0],n||(((i=this._layoutManager.root.contentItems.length)!=null?i:0)>0?n=this._layoutManager.root.contentItems[0]:n=this._layoutManager.root)),e&&(n==null||n.addChild(e,this._indexInParent),this.close())}_createWindow(){const e=this._createUrl(),n=Math.floor(Math.random()*1e6).toString(36),s=this._serializeWindowOptions({width:this._dimensions.width,height:this._dimensions.height,innerWidth:this._dimensions.width,innerHeight:this._dimensions.height,menubar:"no",toolbar:"no",location:"no",personalbar:"no",resizable:"yes",scrollbars:"no",status:"no"});if(this._popoutWindow=window.open(e,n,s),!this._popoutWindow)if(this._layoutManager.config.settings.blockedPopoutsThrowError===!0){const o=new Error("Popout blocked");throw o.type="popoutBlocked",o}else return;ce(this._popoutWindow).on("load",this._positionWindow.bind(this)).on("unload beforeunload",this._onClose.bind(this));let i=window.setInterval(()=>{var o;((o=this._popoutWindow)==null?void 0:o.__glInstance)&&this._popoutWindow.__glInstance.isInitialised&&(this._onInitialised(),window.clearInterval(i))},10)}_serializeWindowOptions(e){var n=[],s;for(s in e)n.push(s+"="+e[s]);return n.join(",")}_createUrl(){var e={content:this._config};const n="gl-window-config-"+vd();e=Ed(e);try{localStorage.setItem(n,JSON.stringify(e))}catch(i){throw new Error("Error while writing to localStorage "+i.toString())}const s=document.location.href.split("?");return s.length===1?s[0]+"?gl-window="+n:document.location.href+"&gl-window="+n}_positionWindow(){var e,n;(e=this._popoutWindow)==null||e.moveTo(this._dimensions.left,this._dimensions.top),(n=this._popoutWindow)==null||n.focus()}_onInitialised(){var e;this.isInitialised=!0,(e=this.getGlInstance())==null||e.on("popIn",this.popIn,this),this.emit("initialised")}_onClose(){setTimeout(this.emit.bind(this,"closed"),50)}}const _m=class extends bn{constructor(t,e,n,s,i,o){var l,a,d,c,u,m,p,g,f,b,C,w;super(),this._area=null,this._lastValidArea=null,this._dragListener=n,this._layoutManager=s,this._contentItem=i,this._originalParent=o,this._dragListener.on("drag",this._onDrag,this),this._dragListener.on("dragStop",this._onDrop,this),this._contentItem.tab&&this._contentItem.tab.element&&(this._layoutManager.tabDropPlaceholder.width((l=this._contentItem.tab.element.outerWidth(!0))!=null?l:0),this._layoutManager.tabDropPlaceholder.height((a=this._contentItem.tab.element.outerHeight(!0))!=null?a:0)),this.element=ce(_m._template),o&&o._side&&(this._sided=o._sided,this.element.addClass("lm_"+o._side),["right","bottom"].indexOf(o._side.toString())>=0&&this.element.find(".lm_content").after(this.element.find(".lm_header"))),this.element.css({left:t,top:e}),this._proxyTab=this.element.find(".lm_tab"),this._proxyTab.attr("title",Td((d=this._contentItem.config.title)!=null?d:"")),this.element.find(".lm_title").html((c=this._contentItem.config.title)!=null?c:""),this.childElementContainer=this.element.find(".lm_content"),this.childElementContainer.append(i.element),this._updateTree(),this._layoutManager._$calculateItemAreas(),this._setDimensions(),ce(document.body).append(this.element),!this._contentItem.tab&&this._proxyTab.length&&(this._layoutManager.tabDropPlaceholder.width((u=this._proxyTab.outerWidth(!0))!=null?u:0),this._layoutManager.tabDropPlaceholder.height((m=this._proxyTab.outerHeight(!0))!=null?m:0));var r=this._layoutManager.container.offset();this._minX=(p=r==null?void 0:r.left)!=null?p:0,this._minY=(g=r==null?void 0:r.top)!=null?g:0,this._maxX=((f=this._layoutManager.container.width())!=null?f:0)+this._minX,this._maxY=((b=this._layoutManager.container.height())!=null?b:0)+this._minY,this._width=(C=this.element.width())!=null?C:0,this._height=(w=this.element.height())!=null?w:0,this._setDropPosition(t,e),this._layoutManager.emit("itemPickedUp",this._contentItem)}_onDrag(t,e,n){var l,a;const s=n.originalEvent instanceof TouchEvent?n.originalEvent.touches[0]:n,i=(l=s.pageX)!=null?l:0,o=(a=s.pageY)!=null?a:0;!(i>this._minX&&i<this._maxX&&o>this._minY&&o<this._maxY)&&this._layoutManager.config.settings.constrainDragToContainer===!0||this._setDropPosition(i,o)}_setDropPosition(t,e){this.element.css({left:t,top:e}),this._area=this._layoutManager._$getArea(t,e),this._area!==null&&(this._lastValidArea=this._area,this._area.contentItem._$highlightDropZone(t,e,this._area))}_onDrop(){var t;(t=this._layoutManager.dropTargetIndicator)==null||t.hide(),this._area!==null?this._area.contentItem._$onDrop(this._contentItem,this._area):this._lastValidArea!==null?this._lastValidArea.contentItem._$onDrop(this._contentItem,this._lastValidArea):this._originalParent?this._originalParent.addChild(this._contentItem):this._contentItem._$destroy(),this._dragListener.off("drag",this._onDrag,this),this._dragListener.off("dragStop",this._onDrop,this),this.element.remove(),this._layoutManager.emit("itemDropped",this._contentItem)}_updateTree(){this._contentItem.parent&&this._contentItem.parent.removeChild(this._contentItem,!0),this._contentItem._$setParent(null)}_setDimensions(){const t=this._layoutManager.config.dimensions;let e=t.dragProxyWidth,n=t.dragProxyHeight;this.element.width(e),this.element.height(n),e-=this._sided?t.headerHeight:0,n-=this._sided?0:t.headerHeight,this.childElementContainer.width(e),this.childElementContainer.height(n),this._contentItem.element.width(e),this._contentItem.element.height(n),this._contentItem.callDownwards("_$show"),this._contentItem.callDownwards("setSize")}};let Go=_m;Go._template='<div class="lm_dragProxy"><div class="lm_header"><ul class="lm_tabs"><li class="lm_tab lm_active"><i class="lm_left"></i><span class="lm_title"></span><i class="lm_right"></i></li></ul></div><div class="lm_content"></div></div>';class km{constructor(e,n,s){this._element=e,this._itemConfig=n,this._layoutManager=s,this._dragListener=this._createDragListener()}_createDragListener(){return this._dragListener=new Wo(this._element,!0),this._dragListener.on("dragStart",this._onDragStart,this),this._dragListener.on("dragStop",this._createDragListener,this),this._dragListener}_onDragStart(e,n){var r;let s=this._itemConfig;typeof s=="function"&&(s=s());const i=this._layoutManager._$normalizeContentItem(ce.extend(!0,{},s)),o=new Go(e,n,this._dragListener,this._layoutManager,i,null);(r=this._layoutManager.transitionIndicator)==null||r.transitionElements(this._element,o.element)}}class Om{constructor(e,n,s){this._element=ce(window),this._itemConfig=e,this._layoutManager=n,this._createDragListener(s)}_createDragListener(e){this._dragListener&&this._dragListener.destroy(),this._element&&(this._dragListener=new Wo(this._element,!0),this._dragListener.on("dragStart",this._onDragStart,this),this._dragListener.on("dragStop",this._destroy,this),this._dragListener.onMouseDown(e),this._dragListener._startDrag())}_destroy(){this._dragListener=void 0,this._element=void 0,this._itemConfig=void 0,this._layoutManager=void 0}_onDragStart(e,n){if(!(!this._dragListener||!this._layoutManager)){var s=this._itemConfig;typeof s=="function"&&(s=s());var i=this._layoutManager._$normalizeContentItem(ce.extend(!0,{},s));new Go(e,n,this._dragListener,this._layoutManager,i,null)}}}const Lm=class{constructor(){this.element=ce(Lm._template),ce(document.body).append(this.element)}destroy(){this.element.remove()}highlightArea(t){this.element.css({left:t.x1,top:t.y1,width:Math.floor(t.x2-t.x1),height:Math.floor(t.y2-t.y1)}).show()}hide(){this.element.hide()}};let Id=Lm;Id._template='<div class="lm_dropTargetIndicator"><div class="lm_inner"></div></div>';class Io{constructor(e,n,s,i){this._header=e,this.element=ce('<li class="'+s+'" title="'+n+'"></li>'),this._header.on("destroy",this._$destroy,this),this._action=i,this.element.on("click",this._action),this._header.controlsContainer.append(this.element)}_$destroy(){this.element.off(),this.element.remove()}}class ii extends Error{constructor(e,n){super(),this.name="Configuration Error",this.message=e,this.node=n}}const JS=Object.freeze(Object.defineProperty({__proto__:null,ConfigurationError:ii},Symbol.toStringTag,{value:"Module"}));function Ao(t){return t.isStack}function yn(t){return t.isComponent}function Am(t){return t.isRoot}class vt extends bn{constructor(e,n,s,i){super(),this.isInitialised=!1,this.isMaximised=!1,this.isRoot=!1,this.isRow=!1,this.isColumn=!1,this.isStack=!1,this.isComponent=!1,this.element=i,this.config=this._extendItemNode(n),this.type=n.type,this.contentItems=[],this.parent=s,this.layoutManager=e,this._pendingEventPropagations={},this._throttledEvents=["stateChanged"],this.on(bn.ALL_EVENT,this._propagateEvent,this),n.content&&this._createContentItems(n)}callDownwards(e,n=[],s=!1,i=!1){s!==!0&&i!==!0&&this[e].apply(this,n);for(let o=0;o<this.contentItems.length;o++)this.contentItems[o].callDownwards(e,n,s);s===!0&&i!==!0&&this[e].apply(this,n)}removeChild(e,n=!1){var i,o;const s=this.contentItems.indexOf(e);if(s===-1)throw new Error("Can't remove child item. Unknown content item");n!==!0&&this.contentItems[s]._$destroy(),this.contentItems.splice(s,1),(i=this.config.content)==null||i.splice(s,1),this.contentItems.length>0?this.callDownwards("setSize"):this.type!=="root"&&this.config.isClosable&&((o=this.parent)==null||o.removeChild(this))}addChild(e,n){e=this.layoutManager._$normalizeContentItem(e,this),n===void 0&&(n=this.contentItems.length),this.contentItems.splice(n,0,e),this.config.content===void 0&&(this.config.content=[]),this.config.content.splice(n,0,e.config),e.parent=this,e.parent.isInitialised===!0&&e.isInitialised===!1&&e._$init()}replaceChild(e,n,s=!1){n=this.layoutManager._$normalizeContentItem(n);const i=this.contentItems.indexOf(e),o=e.element[0].parentNode;if(i===-1)throw new Error("Can't replace child. oldChild is not child of this");o==null||o.replaceChild(n.element[0],e.element[0]),s===!0&&(e.parent=null,e._$destroy()),this.contentItems[i]=n,n.parent=this,Ao(this)&&(this.header.tabs[i].contentItem=n),n.parent.isInitialised===!0&&n.isInitialised===!1&&n._$init(),this.callDownwards("setSize")}remove(){var e;(e=this.parent)==null||e.removeChild(this)}popout(){var e=this.layoutManager.createPopout(this);return this.emitBubblingEvent("stateChanged"),e}toggleMaximise(e){e&&e.preventDefault(),this.isMaximised===!0?this.layoutManager._$minimiseItem(this):this.layoutManager._$maximiseItem(this),this.isMaximised=!this.isMaximised,this.emitBubblingEvent("stateChanged")}select(){this.layoutManager.selectedItem!==this&&(this.layoutManager.selectItem(this,!0),this.element.addClass("lm_selected"))}deselect(){this.layoutManager.selectedItem===this&&(this.layoutManager.selectedItem=null,this.element.removeClass("lm_selected"))}setTitle(e){this.config.title=e,this.emit("titleChanged",e),this.emitBubblingEvent("stateChanged")}hasId(e){if(this.config.id){if(typeof this.config.id=="string")return this.config.id===e;if(this.config.id instanceof Array)return this.config.id.indexOf(e)!==-1}else return!1}addId(e){this.hasId(e)||(this.config.id?typeof this.config.id=="string"?this.config.id=[this.config.id,e]:this.config.id instanceof Array&&this.config.id.push(e):this.config.id=e)}removeId(e){if(!this.hasId(e))throw new Error("Id not found");if(typeof this.config.id=="string")delete this.config.id;else if(this.config.id instanceof Array){var n=this.config.id.indexOf(e);this.config.id.splice(n,1)}}getItemsByFilter(e){const n=[],s=function(i){for(let o=0;o<i.contentItems.length;o++)e(i.contentItems[o])===!0&&n.push(i.contentItems[o]),s(i.contentItems[o])};return s(this),n}getItemsById(e){return this.getItemsByFilter(function(n){return n.config.id instanceof Array?n.config.id.indexOf(e)!==-1:n.config.id===e})}getItemsByType(e){return this._$getItemsByProperty("type",e)}getComponentsByName(e){const n=this._$getItemsByProperty("componentName",e),s=[];for(let i=0;i<n.length;i++)s.push(n[i].instance);return s}_$getItemsByProperty(e,n){return this.getItemsByFilter(function(s){return s[e]===n})}_$setParent(e){this.parent=e}_$highlightDropZone(e,n,s){var i;(i=this.layoutManager.dropTargetIndicator)==null||i.highlightArea(s)}_$onDrop(e,n){this.addChild(e)}_$hide(){this._callOnActiveComponents("hide"),this.element.hide(),this.layoutManager.updateSize()}_$show(){this._callOnActiveComponents("show"),this.element.show(),this.layoutManager.updateSize()}_callOnActiveComponents(e){const n=this.getItemsByType("stack");let s=null;for(let i=0;i<n.length;i++)s=n[i].getActiveContentItem(),s&&yn(s)&&s.container[e]()}_$destroy(){this.emitBubblingEvent("beforeItemDestroyed"),this.callDownwards("_$destroy",[],!0,!0),this.element.remove(),this.emitBubblingEvent("itemDestroyed")}_$getArea(e){var o,r,l;e=e||this.element;const n=(o=e.offset())!=null?o:{left:0,top:0},s=(r=e.width())!=null?r:0,i=(l=e.height())!=null?l:0;return{x1:n.left,y1:n.top,x2:n.left+s,y2:n.top+i,surface:s*i,contentItem:this,side:""}}_$init(){var e;this.setSize();for(let n=0;n<this.contentItems.length;n++)(e=this.childElementContainer)==null||e.append(this.contentItems[n].element);this.isInitialised=!0,this.emitBubblingEvent("itemCreated"),this.emitBubblingEvent(this.type+"Created")}emitBubblingEvent(e){var n=new Oa(e,this);this.emit(e,n)}_createContentItems(e){var n;if(!(e.content instanceof Array))throw new ii("content must be an Array",e);for(let s=0;s<e.content.length;s++)n=this.layoutManager.createContentItem(e.content[s],this),this.contentItems.push(n)}_extendItemNode(e){for(let[n,s]of Object.entries(Rm)){const i=n;e[i]===void 0&&(e[i]=s)}return e}_propagateEvent(e,n){n instanceof Oa&&n.isPropagationStopped===!1&&this.isInitialised===!0&&(this.isRoot===!1&&this.parent?this.parent.emit.apply(this.parent,[e,n]):this._scheduleEventPropagationToLayoutManager(e,n))}_scheduleEventPropagationToLayoutManager(e,n){this._throttledEvents.indexOf(e)===-1?this.layoutManager.emit(e,n.origin):this._pendingEventPropagations[e]!==!0&&(this._pendingEventPropagations[e]=!0,Nl(this._propagateEventToLayoutManager.bind(this,e,n)))}_propagateEventToLayoutManager(e,n){this._pendingEventPropagations[e]=!1,this.layoutManager.emit(e,n)}}class Pm extends vt{constructor(e,n,s){super(e,n,s,ce()),this.config=n,this.parent=s;const i=e.getComponent(this.config.componentName)||e.getFallbackComponent(),o=ce.extend(!0,{},this.config.componentState||{});if(i==null)throw new ii('Unknown component "'+this.config.componentName+'"');o.componentName=this.config.componentName,this.componentName=this.config.componentName,this.config.title===""&&(this.config.title=this.config.componentName),this.isComponent=!0,this.container=new _a(this.config,this,e),this.instance=new i(this.container,o),this.element=this.container._element}close(){this.parent.removeChild(this)}setSize(){this.element.is(":visible")&&this.container._$setSize(this.element.width(),this.element.height())}_$init(){vt.prototype._$init.call(this),this.container.emit("open")}_$hide(){this.container.hide(),vt.prototype._$hide.call(this)}_$show(){this.container.show(),this.container._config.isFocusOnShow&&this.container._contentElement[0].focus({preventScroll:!0}),vt.prototype._$show.call(this)}_$destroy(){this.container.emit("destroy",this),vt.prototype._$destroy.call(this)}_$getArea(){return null}}class Zr extends vt{constructor(e,n,s,i){super(n,s,i,ce('<div class="lm_item lm_'+(e?"column":"row")+'"></div>')),this._splitter=[],this._splitterPosition=null,this._splitterMinPosition=null,this._splitterMaxPosition=null,this.parent=i,this.isRow=!e,this.isColumn=e,this.childElementContainer=this.element,this._splitterSize=n.config.dimensions.borderWidth,this._splitterGrabSize=n.config.dimensions.borderGrabWidth,this._isColumn=e,this._dimension=e?"height":"width",this._splitterPosition=null,this._splitterMinPosition=null,this._splitterMaxPosition=null}addChild(e,n,s){var a;var i,o,r,l;if(e=this.layoutManager._$normalizeContentItem(e,this),n===void 0&&(n=this.contentItems.length),this.contentItems.length>0?(l=this._createSplitter(Math.max(0,n-1)).element,n>0?(this.contentItems[n-1].element.after(l),l.after(e.element)):(this.contentItems[0].element.before(l),l.before(e.element))):this.childElementContainer.append(e.element),vt.prototype.addChild.call(this,e,n),i=1/this.contentItems.length*100,s===!0){this.emitBubblingEvent("stateChanged");return}for(r=0;r<this.contentItems.length;r++)this.contentItems[r]===e?e.config[this._dimension]=i:(o=((a=this.contentItems[r].config[this._dimension])!=null?a:0)*(100-i)/100,this.contentItems[r].config[this._dimension]=o);this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged")}removeChild(e,n){var a,d;var s=(a=e.config[this._dimension])!=null?a:0,i=this.contentItems.indexOf(e),o=Math.max(i-1,0),r,l;if(i===-1)throw new Error("Can't remove child. ContentItem is not child of this Row or Column");for(this._splitter[o]&&(this._splitter[o]._$destroy(),this._splitter.splice(o,1)),r=0;r<this.contentItems.length;r++)this.contentItems[r]!==e&&(this.contentItems[r].config[this._dimension]=((d=this.contentItems[r].config[this._dimension])!=null?d:0)+s/(this.contentItems.length-1));vt.prototype.removeChild.call(this,e,n),this.contentItems.length===1&&this.config.isClosable===!0?(l=this.contentItems[0],this.contentItems=[],this.parent.replaceChild(this,l,!0)):(this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged"))}replaceChild(e,n){var s=e.config[this._dimension];super.replaceChild(e,n),n.config[this._dimension]=s,this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged")}setSize(){this.contentItems.length>0&&(this._calculateRelativeSizes(),this._setAbsoluteSizes()),this.emitBubblingEvent("stateChanged"),this.emit("resize")}_$init(){if(this.isInitialised!==!0){var e;for(vt.prototype._$init.call(this),e=0;e<this.contentItems.length-1;e++)this.contentItems[e].element.after(this._createSplitter(e).element)}}_setAbsoluteSizes(){var e,n=this._calculateAbsoluteSizes();for(e=0;e<this.contentItems.length;e++)n.additionalPixel-e>0&&n.itemSizes[e]++,this._isColumn?(this.contentItems[e].element.width(n.totalWidth),this.contentItems[e].element.height(n.itemSizes[e])):(this.contentItems[e].element.width(n.itemSizes[e]),this.contentItems[e].element.height(n.totalHeight))}_calculateAbsoluteSizes(){var l,a,d,c;const e=(this.contentItems.length-1)*this._splitterSize;let n=(l=this.element.width())!=null?l:0,s=(a=this.element.height())!=null?a:0,i=0;const o=[];this._isColumn?s-=e:n-=e;for(let u=0;u<this.contentItems.length;u++){const m=this._isColumn?Math.floor(s*(((d=this.contentItems[u].config.height)!=null?d:0)/100)):Math.floor(n*(((c=this.contentItems[u].config.width)!=null?c:0)/100));i+=m,o.push(m)}const r=Math.floor((this._isColumn?s:n)-i);return{itemSizes:o,additionalPixel:r,totalWidth:n,totalHeight:s}}_calculateRelativeSizes(){var i,o;let e=0;const n=[],s=this._isColumn?"height":"width";for(let r=0;r<this.contentItems.length;r++)this.contentItems[r].config[s]!==void 0?e+=(i=this.contentItems[r].config[s])!=null?i:0:n.push(this.contentItems[r]);if(Math.round(e)===100){this._respectMinItemWidth();return}if(Math.round(e)<100&&n.length>0){for(let r=0;r<n.length;r++)n[r].config[s]=(100-e)/n.length;this._respectMinItemWidth();return}if(Math.round(e)>100)for(let r=0;r<n.length;r++)n[r].config[s]=50,e+=50;for(let r=0;r<this.contentItems.length;r++)this.contentItems[r].config[s]=((o=this.contentItems[r].config[s])!=null?o:0)/e*100;this._respectMinItemWidth()}_respectMinItemWidth(){var c;const e=this.layoutManager.config.dimensions&&(c=this.layoutManager.config.dimensions.minItemWidth)!=null?c:0,n=[];let s=0,i=0,o=0;const r=[];let l;if(this._isColumn||!e||this.contentItems.length<=1)return;const a=this._calculateAbsoluteSizes();for(let u=0;u<this.contentItems.length;u++){this.contentItems[u];const m=a.itemSizes[u];m<e?(i+=e-m,l={width:e}):(s+=m-e,l={width:m},n.push(l)),r.push(l)}if(i===0||i>s)return;const d=i/s;o=i;for(let u=0;u<n.length;u++){l=n[u];const m=Math.round((l.width-e)*d);o-=m,l.width-=m}o!==0&&(r[r.length-1].width-=o);for(let u=0;u<this.contentItems.length;u++)this.contentItems[u].config.width=r[u].width/a.totalWidth*100}_createSplitter(e){var n;return n=new Vm(this._isColumn,this._splitterSize,this._splitterGrabSize),n.on("drag",this._onSplitterDrag.bind(this,n),this),n.on("dragStop",this._onSplitterDragStop.bind(this,n),this),n.on("dragStart",this._onSplitterDragStart.bind(this,n),this),this._splitter.splice(e,0,n),n}_getItemsForSplitter(e){const n=this._splitter.indexOf(e);if(n<0)throw new Error("Splitter not found in RowOrColumn");return{before:this.contentItems[n],after:this.contentItems[n+1]}}_getMinimumDimensions(e){var o,r;for(var n=0,s=0,i=0;i<e.length;++i)n=Math.max((o=e[i].minWidth)!=null?o:0,n),s=Math.max((r=e[i].minHeight)!=null?r:0,s);return{horizontal:n,vertical:s}}_onSplitterDragStart(e){var a,d,c,u;const n=this._getItemsForSplitter(e),s=this.layoutManager.config.dimensions[this._isColumn?"minItemHeight":"minItemWidth"];var i=this._getMinimumDimensions((a=n.before.config.content)!=null?a:[]),o=this._isColumn?i.vertical:i.horizontal,r=this._getMinimumDimensions((d=n.after.config.content)!=null?d:[]),l=this._isColumn?r.vertical:r.horizontal;this._splitterPosition=0,this._splitterMinPosition=-1*(((c=n.before.element[this._dimension]())!=null?c:0)-(o||s)),this._splitterMaxPosition=((u=n.after.element[this._dimension]())!=null?u:0)-(l||s)}_onSplitterDrag(e,n,s){const i=this._isColumn?s:n;this._splitterMaxPosition==null||this._splitterMinPosition==null||i>this._splitterMinPosition&&i<this._splitterMaxPosition&&(this._splitterPosition=i,e.element.css(this._isColumn?"top":"left",i))}_onSplitterDragStop(e){var l,a,d,c,u;const n=this._getItemsForSplitter(e),s=(l=n.before.element[this._dimension]())!=null?l:0,i=(a=n.after.element[this._dimension]())!=null?a:0,o=(((d=this._splitterPosition)!=null?d:0)+s)/(s+i),r=((c=n.before.config[this._dimension])!=null?c:0)+((u=n.after.config[this._dimension])!=null?u:0);n.before.config[this._dimension]=o*r,n.after.config[this._dimension]=(1-o)*r,e.element.css({top:0,left:0}),Nl(this.callDownwards.bind(this,"setSize",void 0,void 0,void 0))}}class La extends vt{constructor(e,n,s){super(e,{...n,type:"root"},null,ce('<div class="lm_goldenlayout lm_item lm_root"></div>')),this.isRoot=!0,this.type="root",this.childElementContainer=this.element,this._containerElement=s,this._containerElement.append(this.element)}addChild(e,n){if(this.contentItems.length>0)throw new Error("Root node can only have a single child");e=this.layoutManager._$normalizeContentItem(e,this),this.childElementContainer.append(e.element),super.addChild(e,n),this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged")}setSize(e,n){var s,i;e=typeof e>"u"?(s=this._containerElement.width())!=null?s:0:e,n=typeof n>"u"?(i=this._containerElement.height())!=null?i:0:n,this.element.width(e),this.element.height(n),this.contentItems[0]&&(this.contentItems[0].element.width(e),this.contentItems[0].element.height(n))}_$getArea(){const e=super._$getArea();if(e==null)throw new Error("Unable to get root area");return e}_$highlightDropZone(e,n,s){this.layoutManager.tabDropPlaceholder.remove(),super._$highlightDropZone(e,n,s)}_$onDrop(e,n){var i;var s;if(yn(e)&&(s=this.layoutManager.createContentItem({type:"stack",header:e.config.header||{}},this),s._$init(),s.addChild(e),e=s),!this.contentItems.length)this.addChild(e);else{const{side:o}=n,r=o==="left"||o==="right"?"row":"column",l=o==="left"||o==="right"?"width":"height",a=o==="left"||o==="top",d=this.contentItems[0];if(!(d instanceof Zr)||d.type!=r){const c=this.layoutManager.createContentItem({type:r},this);this.replaceChild(d,c),c.addChild(e,a?0:void 0,!0),c.addChild(d,a?void 0:0,!0),d.config[l]=50,e.config[l]=50,c.callDownwards("setSize")}else{const c=d.contentItems[a?0:d.contentItems.length-1];d.addChild(e,a?0:void 0,!0),c.config[l]=((i=c.config[l])!=null?i:0)*.5,e.config[l]=c.config[l],d.callDownwards("setSize")}}}}class Aa extends vt{constructor(e,n,s){var o,r,l,a,d,c,u,m,p;super(e,n,s,ce('<div class="lm_item lm_stack"></div>')),this._activeContentItem=null,this.childElementContainer=ce('<div class="lm_items"></div>'),this.isStack=!0,this._dropZones={},this._dropSegment=null,this._contentAreaDimensions=null,this._sided=!1,this.parent=s,this.config=n;const i=e.config;this._side=!1,this._header={show:((o=i.settings)==null?void 0:o.hasHeaders)&&n.hasHeaders!==!1,popout:(r=i.settings)!=null&&r.showPopoutIcon?(l=i.labels)==null?void 0:l.popout:void 0,maximise:(a=i.settings)!=null&&a.showMaximiseIcon?(d=i.labels)==null?void 0:d.maximise:void 0,close:(c=i.settings)!=null&&c.showCloseIcon?(u=i.labels)==null?void 0:u.close:void 0,minimise:(p=(m=i.labels)==null?void 0:m.minimise)!=null?p:void 0},i.header&&(this._header={...this._header,...i.header}),n.header&&(this._header={...this._header,...n.header}),n.content&&n.content[0]&&n.content[0].header&&(this._header={...this._header,...n.content[0].header}),this.header=new Ko(e,this),this.element.append(this.header.element),this.element.append(this.childElementContainer),this._setupHeaderPosition(),this._$validateClosability()}setSize(){var o,r,l,a;var e,n=this._header.show&&(r=(o=this.layoutManager.config.dimensions)==null?void 0:o.headerHeight)!=null?r:0,s=((l=this.element.width())!=null?l:0)-(this._sided?n:0),i=((a=this.element.height())!=null?a:0)-(this._sided?0:n);for(this.childElementContainer.width(s),this.childElementContainer.height(i),e=0;e<this.contentItems.length;e++)this.contentItems[e].element.width(s).height(i);this.emit("resize"),this.emitBubblingEvent("stateChanged")}_$init(){if(this.isInitialised!==!0){this.header._attachWheelListener(),super._$init();for(let e=0;e<this.contentItems.length;e++)this.header.createTab(this.contentItems[e]),this.contentItems[e]._$hide();if(this.contentItems.length>0){const e=this.contentItems[this.config.activeItemIndex||0];if(!e)throw new Error("Configured activeItemIndex out of bounds");this.setActiveContentItem(e)}}}setActiveContentItem(e){if(this.contentItems.indexOf(e)===-1)throw new Error("contentItem is not a child of this stack");this._activeContentItem!==null&&this._activeContentItem._$hide(),this._activeContentItem=e,this.header.setActiveContentItem(e),e._$show(),this.emit("activeContentItemChanged",e),this.layoutManager.emit("activeContentItemChanged",e),this.emitBubblingEvent("stateChanged")}getActiveContentItem(){return this.header.activeContentItem}addChild(e,n){e=this.layoutManager._$normalizeContentItem(e,this),super.addChild(e,n),this.childElementContainer.append(e.element),this.header.createTab(e,n),this.setActiveContentItem(e),this.callDownwards("setSize"),this._$validateClosability(),this.emitBubblingEvent("stateChanged")}removeChild(e,n=!1){var s=this.contentItems.indexOf(e);super.removeChild(e,n),this.header.removeTab(e),this.header.activeContentItem===e&&(this.contentItems.length>0?this.setActiveContentItem(this.contentItems[Math.max(s-1,0)]):this._activeContentItem=null),this._$validateClosability(),this.emitBubblingEvent("stateChanged")}_$validateClosability(){var n;let e=this.header._isClosable();for(let s=0,i=this.contentItems.length;s<i&&e;s++)e=(n=this.contentItems[s].config.isClosable)!=null?n:!1;this.header._$setClosable(e)}_$destroy(){vt.prototype._$destroy.call(this),this.header._$destroy()}_$onDrop(e){var a;if(this._dropSegment==="header"){this._resetHeaderDropZone(),this.addChild(e,this._dropIndex);return}if(this._dropSegment==="body"){this.addChild(e);return}const n=this._dropSegment==="top"||this._dropSegment==="bottom",s=this._dropSegment==="left"||this._dropSegment==="right",i=this._dropSegment==="top"||this._dropSegment==="left",o=n&&this.parent.isColumn||s&&this.parent.isRow,r=n?"column":"row",l=n?"height":"width";if(yn(e)){const d=this.layoutManager.createContentItem({type:"stack",header:e.config.header||{}},this);d._$init(),d.addChild(e),e=d}if(o){const d=this.parent.contentItems.indexOf(this);this.parent.addChild(e,i?d:d+1,!0),this.config[l]=((a=this.config[l])!=null?a:0)*.5,e.config[l]=this.config[l],this.parent.callDownwards("setSize")}else{const d=this.layoutManager.createContentItem({type:r},this);this.parent.replaceChild(this,d),d.addChild(e,i?0:void 0,!0),d.addChild(this,i?void 0:0,!0),this.config[l]=50,e.config[l]=50,d.callDownwards("setSize")}}_$highlightDropZone(e,n){if(!!this._contentAreaDimensions)for(let[s,i]of Object.entries(this._contentAreaDimensions)){const o=i.hoverArea;if(o.x1<e&&o.x2>e&&o.y1<n&&o.y2>n){s==="header"?(this._dropSegment="header",this._highlightHeaderDropZone(e)):(this._resetHeaderDropZone(),this._highlightBodyDropZone(s));return}}}_$getArea(){if(this.element.is(":visible")===!1)return null;const e=super._$getArea(this.header.element),n=super._$getArea(this.childElementContainer);if(e==null||n==null)return null;const s=n.x2-n.x1,i=n.y2-n.y1;return this._contentAreaDimensions={header:{hoverArea:{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2},highlightArea:{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2}}},this._activeContentItem&&this._activeContentItem.isComponent===!1?e:this.contentItems.length===0?(this._contentAreaDimensions.body={hoverArea:{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2},highlightArea:{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2}},super._$getArea(this.element)):(this._contentAreaDimensions.left={hoverArea:{x1:n.x1,y1:n.y1,x2:n.x1+s*.25,y2:n.y2},highlightArea:{x1:n.x1,y1:n.y1,x2:n.x1+s*.5,y2:n.y2}},this._contentAreaDimensions.top={hoverArea:{x1:n.x1+s*.25,y1:n.y1,x2:n.x1+s*.75,y2:n.y1+i*.5},highlightArea:{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y1+i*.5}},this._contentAreaDimensions.right={hoverArea:{x1:n.x1+s*.75,y1:n.y1,x2:n.x2,y2:n.y2},highlightArea:{x1:n.x1+s*.5,y1:n.y1,x2:n.x2,y2:n.y2}},this._contentAreaDimensions.bottom={hoverArea:{x1:n.x1+s*.25,y1:n.y1+i*.5,x2:n.x1+s*.75,y2:n.y2},highlightArea:{x1:n.x1,y1:n.y1+i*.5,x2:n.x2,y2:n.y2}},super._$getArea(this.element))}_highlightHeaderDropZone(e){var u,m,p,g,f,b,C,w,T,y,E,I,R,F,x,U,$,O,H,L,N,_,k,V,W,j;const n=this.header.tabs.length;if(n===0){const ee=this.header.element.offset();(w=this.layoutManager.dropTargetIndicator)==null||w.highlightArea({x1:(u=ee==null?void 0:ee.left)!=null?u:0,x2:((m=ee==null?void 0:ee.left)!=null?m:0)+100,y1:(g=(p=this.header.element.offset())==null?void 0:p.top)!=null?g:0,y2:((b=(f=this.header.element.offset())==null?void 0:f.top)!=null?b:0)+((C=this.header.element.innerHeight())!=null?C:0)});return}const i=(T=this.header.tabsContainer.get(0))==null?void 0:T.getBoundingClientRect(),o=(y=this.layoutManager.tabDropPlaceholder.get(0))==null?void 0:y.getBoundingClientRect();if(!i||!o)return;e<i.left?e=i.left+1:e>i.right&&(e=i.right-1);let r,l;if(!(o.left<e&&e<o.right)){for(var a=0;a<n;a++)if(r=this.header.tabs[a].element,l=(E=r.get(0))==null?void 0:E.getBoundingClientRect(),l&&l.left<e&&e<l.right){this._dropIndex=a;break}r&&l&&e<l.left+l.width*.5?r.before(this.layoutManager.tabDropPlaceholder):r&&(this._dropIndex=Math.min(((I=this._dropIndex)!=null?I:0)+1,n),r.after(this.layoutManager.tabDropPlaceholder))}let d=(F=(R=this.layoutManager.tabDropPlaceholder.offset())==null?void 0:R.left)!=null?F:0;d=Math.max(d,(U=(x=this.header.tabsContainer.offset())==null?void 0:x.left)!=null?U:0);var c=d+(($=this.layoutManager.tabDropPlaceholder.width())!=null?$:0);c=Math.min(c,((H=(O=this.header.tabsContainer.offset())==null?void 0:O.left)!=null?H:0)+((L=this.header.tabsContainer.innerWidth())!=null?L:0)),(j=this.layoutManager.dropTargetIndicator)==null||j.highlightArea({x1:d,x2:c,y1:(_=(N=this.header.element.offset())==null?void 0:N.top)!=null?_:0,y2:((V=(k=this.header.element.offset())==null?void 0:k.top)!=null?V:0)+((W=this.header.element.innerHeight())!=null?W:0)})}_resetHeaderDropZone(){this.layoutManager.tabDropPlaceholder.remove()}_setupHeaderPosition(){const e=["right","left","bottom"].some(n=>n===this._header.show)?this._header.show:void 0;if(!!e&&(this.header.element.toggle(!!this._header.show),this._side=e,this._sided=["right","left"].indexOf(this._side.toString())>=0,this.element.removeClass("lm_left lm_right lm_bottom"),this._side&&this.element.addClass("lm_"+this._side),this.element.find(".lm_header").length&&this.childElementContainer)){const n=["right","bottom"].indexOf(this._side.toString())>=0?"before":"after";this.header.element[n](this.childElementContainer),this.callDownwards("setSize")}}_highlightBodyDropZone(e){var s,i,o;const n=(i=(s=this._contentAreaDimensions)==null?void 0:s[e])==null?void 0:i.highlightArea;n&&((o=this.layoutManager.dropTargetIndicator)==null||o.highlightArea(n)),this._dropSegment=e}}const ew=Object.freeze(Object.defineProperty({__proto__:null,AbstractContentItem:vt,ContentItem:vt,Component:Pm,Root:La,RowOrColumn:Zr,Stack:Aa,isStack:Ao,isComponent:yn,isRoot:Am},Symbol.toStringTag,{value:"Module"})),Hm=class{constructor(t,e){var n;this.element=ce(Hm._template),this.isActive=!1,this.header=t,this.contentItem=e,this.titleElement=this.element.find(".lm_title"),this.closeElement=this.element.find(".lm_close_tab"),this.closeElement[e.config.isClosable?"show":"hide"](),this.setTitle(e.config.title),this.contentItem.on("titleChanged",this.setTitle,this),this._layoutManager=this.contentItem.layoutManager,((n=this._layoutManager.config.settings)==null?void 0:n.reorderEnabled)&&e.config.reorderEnabled&&(this._dragListener=new Wo(this.element),this._dragListener.on("dragStart",this._onDragStart,this),this.contentItem.on("destroy",this._dragListener.destroy,this._dragListener)),this._onTabClick=this._onTabClick.bind(this),this._onCloseClick=this._onCloseClick.bind(this),this._onTabContentFocusIn=this._onTabContentFocusIn.bind(this),this._onTabContentFocusOut=this._onTabContentFocusOut.bind(this),this.element.on("click",this._onTabClick),this.element.on("auxclick",this._onTabClick),this.contentItem.config.isClosable?(this.closeElement.on("click",this._onCloseClick),this.closeElement.on("mousedown",this._onCloseMousedown)):this.closeElement.remove(),this.contentItem.tab=this,this.contentItem.emit("tab",this),this.contentItem.layoutManager.emit("tabCreated",this),yn(this.contentItem)&&(this.contentItem.container._contentElement.on("focusin click",this._onTabContentFocusIn).on("focusout",this._onTabContentFocusOut),this.contentItem.container.tab=this,this.contentItem.container.emit("tab",this))}setTitle(t=""){this.titleElement.html(t)}setActive(t){t!==this.isActive&&(this.isActive=t,t?this.element.addClass("lm_active"):this.element.removeClass("lm_active"))}_$destroy(){this.element.off("click",this._onTabClick),this.element.off("auxclick",this._onTabClick),this.closeElement.off("click",this._onCloseClick),yn(this.contentItem)&&this.contentItem.container._contentElement.off(),this._dragListener&&(this.contentItem.off("destroy",this._dragListener.destroy,this._dragListener),this._dragListener.off("dragStart",this._onDragStart),this._dragListener=void 0),this.element.remove()}_onDragStart(t,e){var n;(n=this.contentItem.parent)!=null&&n.isMaximised&&this.contentItem.parent.toggleMaximise(),this._dragListener&&new Go(t,e,this._dragListener,this._layoutManager,this.contentItem,this.header.parent)}_onTabContentFocusIn(){yn(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&this.contentItem.container._contentElement[0].focus(),this.element.addClass("lm_focusin")}_onTabContentFocusOut(){yn(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&this.element.removeClass("lm_focusin")}_onTabClick(t){var n;if(!t||t.button===0){var e=this.header.parent.getActiveContentItem();this.contentItem!==e&&yn(this.contentItem)?(this.header.parent.setActiveContentItem(this.contentItem),this.contentItem.container.emit("tabClicked")):yn(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&(this.contentItem.container._contentElement.focus(),this.contentItem.container.emit("tabClicked")),this.header._hideAdditionalTabsDropdown(),(n=this.element.get(0))==null||n.scrollIntoView({inline:"nearest"})}else t.button===1&&this.contentItem.config.isClosable&&this._onCloseClick(t)}_onCloseClick(t){t.stopPropagation(),yn(this.contentItem)?this.contentItem.container.close():this.header.parent.removeChild(this.contentItem)}_onCloseMousedown(t){t.stopPropagation()}};let Rd=Hm;Rd._template=['<li class="lm_tab">','<span class="lm_title_before"></span>','<span class="lm_title"></span>','<div class="lm_close_tab"></div>',"</li>"].join("");const Ar=class extends bn{constructor(t,e){var n,s;super(),this.element=ce(Ar._template),this.tabDropdownList=null,this.tabs=[],this.activeContentItem=null,this.closeButton=null,this.tabDropdownButton=null,this.tabNextButton=ce(Ar._nextButtonTemplate),this.tabPreviousButton=ce(Ar._previousButtonTemplate),this.holdTimer=null,this.rAF=null,this.CLICK_TIMEOUT=500,this.START_SPEED=.01,this.ACCELERATION=5e-4,this.SCROLL_LEFT="left",this.SCROLL_RIGHT="right",this.isDraggingTab=!1,this.isOverflowing=!1,this.isDropdownShown=!1,this.dropdownKeyIndex=0,this._lastVisibleTabIndex=-1,this.layoutManager=t,(n=this.layoutManager.config.settings)!=null&&n.selectionEnabled&&(this.element.addClass("lm_selectable"),this.element.on("click",this._onHeaderClick.bind(this))),this.tabsContainer=this.element.find(".lm_tabs"),this.tabDropdownContainer=this.element.find(".lm_tabdropdown_list"),this.tabDropdownContainer.hide(),this.tabDropdownSearch=this.element.find(".lm_tabdropdown_search input"),this._handleFilterInput=this._handleFilterInput.bind(this),this._handleFilterKeydown=this._handleFilterKeydown.bind(this),this.tabDropdownSearch.on("input",this._handleFilterInput),this.tabDropdownSearch.on("keydown",this._handleFilterKeydown),this.controlsContainer=this.element.find(".lm_controls"),this.parent=e,this.parent.on("resize",this._updateTabSizes,this),this._handleItemPickedUp=this._handleItemPickedUp.bind(this),this._handleItemDropped=this._handleItemDropped.bind(this),this._handleNextMouseEnter=this._handleNextMouseEnter.bind(this),this._handleNextMouseLeave=this._handleNextMouseLeave.bind(this),this._handlePreviousMouseEnter=this._handlePreviousMouseEnter.bind(this),this._handlePreviousMouseLeave=this._handlePreviousMouseLeave.bind(this),this._handleScrollRepeat=this._handleScrollRepeat.bind(this),this._handleNextButtonMouseDown=this._handleNextButtonMouseDown.bind(this),this._handlePreviousButtonMouseDown=this._handlePreviousButtonMouseDown.bind(this),this._handleScrollButtonMouseDown=this._handleScrollButtonMouseDown.bind(this),this._handleScrollButtonMouseUp=this._handleScrollButtonMouseUp.bind(this),this._handleScrollEvent=this._handleScrollEvent.bind(this),this.tabNextButton.on("mousedown",this._handleNextButtonMouseDown),this.tabPreviousButton.on("mousedown",this._handlePreviousButtonMouseDown),this.tabsContainer.on("scroll",this._handleScrollEvent),this.layoutManager.on("itemPickedUp",this._handleItemPickedUp),this.layoutManager.on("itemDropped",this._handleItemDropped),this.tabsContainer.before(this.tabPreviousButton),this.tabPreviousButton=this.tabPreviousButton.find(">:first-child"),this.tabPreviousButton.hide(),this._showAdditionalTabsDropdown=this._showAdditionalTabsDropdown.bind(this),this._hideAdditionalTabsDropdown=this._hideAdditionalTabsDropdown.bind(this),this._tabControlOffset=(s=this.layoutManager.config.settings)==null?void 0:s.tabControlOffset,this._createControls()}createTab(t,e){for(let s=0;s<this.tabs.length;s++)if(this.tabs[s].contentItem===t)return;const n=new Rd(this,t);if(this.tabs.length===0){this.tabs.push(n),this.tabsContainer.append(n.element);return}e===void 0&&(e=this.tabs.length),e>0?this.tabs[e-1].element.after(n.element):this.tabs[0].element.before(n.element),this.tabs.splice(e,0,n),this._updateTabSizes()}removeTab(t){for(var e=0;e<this.tabs.length;e++)if(this.tabs[e].contentItem===t){this.tabs[e]._$destroy(),this.tabs.splice(e,1);return}throw new Error("contentItem is not controlled by this header")}setActiveContentItem(t){var s,i;for(var e,n=0;n<this.tabs.length;n++)e=this.tabs[n].contentItem===t,this.tabs[n].setActive(e),e===!0&&(this.activeContentItem=t,this.parent.config.activeItemIndex=n);(i=this.tabs[(s=this.parent.config.activeItemIndex)!=null?s:0].element.get(0))==null||i.scrollIntoView({inline:"nearest"}),this._hideAdditionalTabsDropdown(),this._updateTabSizes(),this.parent.emitBubblingEvent("stateChanged")}position(t){let e=this.parent._header.show;return e&&!this.parent._side&&(e="top"),t!==void 0&&this.parent._header.show!==t&&(this.parent._header.show=t,this.parent._setupHeaderPosition()),e}_attachWheelListener(){var t;(t=this.tabsContainer.get(0))==null||t.addEventListener("wheel",this._handleWheelEvent,{passive:!0})}_detachWheelListener(){var t;(t=this.tabsContainer.get(0))==null||t.removeEventListener("wheel",this._handleWheelEvent)}_handleWheelEvent(t){var s;const e=t.currentTarget;if(!(e instanceof HTMLElement))return;let n=Math.abs(t.deltaY)>Math.abs(t.deltaX)?t.deltaY:t.deltaX;t.deltaMode===WheelEvent.DOM_DELTA_PAGE?n*=(s=this.tabsContainer.innerWidth())!=null?s:1:t.deltaMode===WheelEvent.DOM_DELTA_LINE&&(n*=100/3),e.scrollLeft+=Math.round(n)}_handleScrollEvent(){this._checkScrollArrows()}_handleItemPickedUp(){this.isDraggingTab=!0,this.controlsContainer.on("mouseenter",this._handleNextMouseEnter),this.tabPreviousButton.on("mouseenter",this._handlePreviousMouseEnter)}_handleItemDropped(){var t;this.isDraggingTab=!1,window.cancelAnimationFrame((t=this.rAF)!=null?t:-1),this.rAF=null,this.controlsContainer.off("mouseenter",this._handleNextMouseEnter),this.controlsContainer.off("mouseleave",this._handleNextMouseLeave),this.tabPreviousButton.off("mouseenter",this._handlePreviousMouseEnter),this.tabPreviousButton.off("mouseleave",this._handlePreviousMouseLeave)}_handleNextMouseEnter(){var t;this.controlsContainer.on("mouseleave",this._handleNextMouseLeave),this._handleScrollRepeat(this.SCROLL_RIGHT,(t=this.tabsContainer.scrollLeft())!=null?t:0)}_handlePreviousMouseEnter(){var t;this.tabPreviousButton.on("mouseleave",this._handlePreviousMouseLeave),this._handleScrollRepeat(this.SCROLL_LEFT,(t=this.tabsContainer.scrollLeft())!=null?t:0)}_handleNextMouseLeave(){var t;window.cancelAnimationFrame((t=this.rAF)!=null?t:-1),this.rAF=null,this.controlsContainer.off("mouseleave",this._handleNextMouseLeave)}_handlePreviousMouseLeave(){var t;window.cancelAnimationFrame((t=this.rAF)!=null?t:-1),this.rAF=null,this.tabPreviousButton.off("mouseleave",this._handlePreviousMouseLeave)}_handleNextButtonMouseDown(){var e,n,s,i,o,r,l;var t;for(let a=0;a<this.tabs.length;a+=1)if(((n=(e=this.tabs[a].element.get(0))==null?void 0:e.offsetLeft)!=null?n:0)>((i=(s=this.tabsContainer.get(0))==null?void 0:s.offsetWidth)!=null?i:0)+((o=this.tabsContainer.scrollLeft())!=null?o:0)){t=this.tabs[a].element.get(0);break}if(t)t.scrollIntoView({behavior:"smooth",inline:"nearest"}),this._handleScrollButtonMouseDown(this.SCROLL_RIGHT);else{const a=this.tabsContainer.get(0);a&&(a.scrollLeft=(l=(r=this.tabsContainer.get(0))==null?void 0:r.scrollWidth)!=null?l:0)}}_handlePreviousButtonMouseDown(){var n,s,i;for(var t,e=this.tabs.length-1;e>=0;e-=1)if(((s=(n=this.tabs[e].element.get(0))==null?void 0:n.offsetLeft)!=null?s:0)<((i=this.tabsContainer.scrollLeft())!=null?i:0)){t=this.tabs[e].element.get(0);break}if(t)t.scrollIntoView({behavior:"smooth",inline:"start"}),this._handleScrollButtonMouseDown(this.SCROLL_LEFT);else{const o=this.tabsContainer.get(0);o&&(o.scrollLeft=0)}}_handleScrollButtonMouseDown(t){this.holdTimer=window.setTimeout(()=>{var e;this._handleScrollRepeat(t,(e=this.tabsContainer.scrollLeft())!=null?e:0,100)},this.CLICK_TIMEOUT),window.addEventListener("mouseup",this._handleScrollButtonMouseUp)}_handleScrollButtonMouseUp(){var t,e;clearTimeout((t=this.holdTimer)!=null?t:-1),this.holdTimer=null,cancelAnimationFrame((e=this.rAF)!=null?e:-1),this.rAF=null,window.removeEventListener("mouseup",this._handleScrollButtonMouseUp)}_checkScrollArrows(){var t,e,n;this.tabsContainer.scrollLeft()===0?this.tabPreviousButton.first().prop("disabled",!0):((t=this.tabsContainer.scrollLeft())!=null?t:0)+((e=this.tabsContainer.innerWidth())!=null?e:0)===((n=this.tabsContainer.get(0))==null?void 0:n.scrollWidth)?this.tabNextButton.prop("disabled",!0):(this.tabNextButton.prop("disabled",!1),this.tabPreviousButton.first().prop("disabled",!1))}_handleScrollRepeat(t,e,n=0,s){var r,l,a;const i=this.tabsContainer.get(0);if(!i)return;const o=i.getBoundingClientRect();if(t===this.SCROLL_LEFT){if(this.tabsContainer.scrollLeft(e-n),this.isDraggingTab&&this.parent._highlightHeaderDropZone(o.left-1),this.tabsContainer.scrollLeft()===0){this._checkScrollArrows();return}}else if(t===this.SCROLL_RIGHT&&(this.tabsContainer.scrollLeft(e+n),this.isDraggingTab&&this.parent._highlightHeaderDropZone(o.right+1),((r=this.tabsContainer.scrollLeft())!=null?r:0)+((l=this.tabsContainer.innerWidth())!=null?l:0)===i.scrollWidth)){this._checkScrollArrows();return}window.cancelAnimationFrame((a=this.rAF)!=null?a:-1),this.rAF=window.requestAnimationFrame(d=>{var p,g;var c=s||d,u=d-c,m=this.START_SPEED*u+.5*this.ACCELERATION*(u*u);m=Math.min(m,(g=(p=this.tabsContainer.get(0))==null?void 0:p.scrollWidth)!=null?g:1/0),this._handleScrollRepeat(t,e,m,c)})}_$setClosable(t){return this.closeButton&&this._isClosable()?(this.closeButton.element[t?"show":"hide"](),!0):!1}_$destroy(){this.emit("destroy",this);for(var t=0;t<this.tabs.length;t++)this.tabs[t]._$destroy();this._detachWheelListener(),this._handleItemDropped(),ce(document).off("mouseup",this._hideAdditionalTabsDropdown),this.tabDropdownSearch.off("input",this._handleFilterInput),this.tabDropdownSearch.off("keydown",this._handleFilterKeydown),this.element.remove()}_getHeaderSetting(t){if(t in this.parent._header)return this.parent._header[t]}_createControls(){var t,e,n,s,i;if(i=this.layoutManager.config.labels.tabDropdown,this.layoutManager.config.labels.tabNextLabel,this.layoutManager.config.labels.tabPreviousLabel,this.tabDropdownButton=new Io(this,i,"lm_tabdropdown",this._showAdditionalTabsDropdown),this.tabDropdownButton.element.hide(),this.controlsContainer.prepend(this.tabNextButton),this.tabNextButton.hide(),this._getHeaderSetting("popout")&&(e=this._onPopoutClick.bind(this),n=this._getHeaderSetting("popout"),new Io(this,n,"lm_popout",e)),this._getHeaderSetting("maximise")){s=this.parent.toggleMaximise.bind(this.parent);const o=this._getHeaderSetting("maximise"),r=this._getHeaderSetting("minimise"),l=new Io(this,o,"lm_maximise",s);this.parent.on("maximised",function(){l.element.attr("title",r!=null?r:"")}),this.parent.on("minimised",function(){l.element.attr("title",o!=null?o:"")})}this._isClosable()&&(t=this.parent.remove.bind(this.parent),n=this._getHeaderSetting("close"),this.closeButton=new Io(this,n,"lm_close",t))}_showAdditionalTabsDropdown(){if(this.isDropdownShown){this._hideAdditionalTabsDropdown();return}this.tabDropdownList=this.tabsContainer.clone(!0).appendTo(this.tabDropdownContainer).children().removeClass("lm_active"),this.tabDropdownContainer.show(),this.isDropdownShown=!0,this.element.addClass("lm_dropdown_open"),this.tabDropdownSearch.val("").focus(),this.dropdownKeyIndex=0,this.tabDropdownList.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active"),ce(document).on("mousedown",this._hideAdditionalTabsDropdown),this._updateAdditionalTabsDropdown()}_handleFilterKeydown(t){var n,s,i,o;if(this.dropdownKeyIndex===-1)return;if(t.key==="Escape"){this._hideAdditionalTabsDropdown();return}if(t.key==="Enter"||t.key===" "){this._hideAdditionalTabsDropdown(),this.tabs[this.dropdownKeyIndex]._onTabClick();return}function e(r,l,a){if(a==null||a.length<2)return-1;for(var d=(r+l+a.length)%a.length;d!==r;){if(a.eq(d).css("display")!=="none")return d;d=(d+l+a.length)%a.length}return r}t.key==="ArrowDown"||t.key==="Tab"&&t.shiftKey===!1?(t.preventDefault(),(n=this.tabDropdownList)==null||n.eq(this.dropdownKeyIndex).removeClass("lm_keyboard_active"),this.dropdownKeyIndex=e(this.dropdownKeyIndex,1,this.tabDropdownList),(s=this.tabDropdownList)==null||s.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active")):(t.key==="ArrowUp"||t.key==="Tab")&&(t.preventDefault(),(i=this.tabDropdownList)==null||i.eq(this.dropdownKeyIndex).removeClass("lm_keyboard_active"),this.dropdownKeyIndex=e(this.dropdownKeyIndex,-1,this.tabDropdownList),(o=this.tabDropdownList)==null||o.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active"))}_handleFilterInput(t){var n,s;if(this.tabDropdownList!=null){this.tabDropdownList.eq(this.dropdownKeyIndex).removeClass("lm_keyboard_active"),this.dropdownKeyIndex=-1;for(var e=0;e<this.tabDropdownList.length;e++)((s=(n=this.tabs[e].contentItem.config.title)==null?void 0:n.toLowerCase().indexOf(t.target.value.toLowerCase()))!=null?s:-1)!==-1?(this.tabDropdownList.eq(e).css("display",""),this.dropdownKeyIndex===-1&&(this.dropdownKeyIndex=e)):this.tabDropdownList.eq(e).css("display","none");this.dropdownKeyIndex!==-1&&this.tabDropdownList.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active")}}_hideAdditionalTabsDropdown(t){var e,n;!this.isDropdownShown||t&&((e=this.tabDropdownContainer.get(0))==null?void 0:e.contains(t.target))||t&&((n=this.tabDropdownButton)==null?void 0:n.element.get(0))===t.target||(this.element.removeClass("lm_dropdown_open"),this.tabDropdownContainer.hide(),this.isDropdownShown=!1,this.tabDropdownContainer.find(".lm_tabs").remove(),ce(document).off("mousedown",this._hideAdditionalTabsDropdown))}_updateAdditionalTabsDropdown(){var n,s,i,o,r;this.tabDropdownContainer.css("max-height","");const t=this.tabDropdownContainer[0].scrollHeight;if(t===0)return;const e=((s=(n=this.tabDropdownContainer.offset())==null?void 0:n.top)!=null?s:0)-((i=ce(window).scrollTop())!=null?i:0);e+t>((o=ce(window).height())!=null?o:0)&&this.tabDropdownContainer.css("max-height",((r=ce(window).height())!=null?r:0)-e-10)}_isClosable(){return Boolean(this.parent.config.isClosable&&this.layoutManager.config.settings.showCloseIcon)}_onPopoutClick(){var t;this.layoutManager.config.settings.popoutWholeStack===!0?this.parent.popout():(t=this.activeContentItem)==null||t.popout()}_onHeaderClick(t){t.target===this.element[0]&&this.parent.select()}_updateTabSizes(){var e,n;if(this.tabs.length===0)return;const t=this.tabsContainer.get(0);!t||(!this.isOverflowing&&t.scrollWidth>t.clientWidth?((e=this.tabDropdownButton)==null||e.element.show(),this.tabNextButton.show(),this.tabPreviousButton.show(),this.isOverflowing=!0):this.isOverflowing&&t.scrollWidth<=t.clientWidth&&((n=this.tabDropdownButton)==null||n.element.hide(),this.tabNextButton.hide(),this.tabPreviousButton.hide(),this.isOverflowing=!1),this.isOverflowing&&this._checkScrollArrows())}};let Ko=Ar;Ko._template=['<div class="lm_header">','<ul class="lm_tabs"></ul>','<ul class="lm_controls"></ul>','<ul class="lm_tabdropdown_list">','<li class="lm_tabdropdown_search"><input type="text" placeholder="Find tab..."></li>',"</ul>","</div>"].join("");Ko._previousButtonTemplate=['<ul class="lm_controls">','<li class="lm_tabpreviousbutton"></li>',"</ul>"].join("");Ko._nextButtonTemplate=['<li class="lm_tabnextbutton"></li>'].join("");class Vm{constructor(e,n,s){this._isVertical=e,this._size=n,this._grabSize=s<n?n:s,this.element=this._createElement(),this._dragListener=new Wo(this.element)}on(e,n,s){var i;(i=this._dragListener)==null||i.on(e,n,s)}_$destroy(){var e;(e=this._dragListener)==null||e.destroy(),this._dragListener=null,this.element.remove()}_createElement(){var e=ce('<div class="lm_drag_handle"></div>'),n=ce('<div class="lm_splitter"></div>');n.append(e);var s=this._grabSize-this._size,i=s/2;return this._isVertical?(e.css("top",-i),e.css("height",this._size+s),n.addClass("lm_vertical"),n.height(this._size)):(e.css("left",-i),e.css("width",this._size+s),n.addClass("lm_horizontal"),n.width(this._size)),n}}class Um{constructor(){this._element=ce('<div class="lm_transition_indicator"></div>'),this._toElement=null,this._fromDimensions={},this._totalAnimationDuration=200,this._animationStartTime=null,ce(document.body).append(this._element)}destroy(){this._element.remove()}transitionElements(e,n){}_nextAnimationFrame(){var o,r,l;if(!this._toElement||this._animationStartTime==null)return;const e=this._measure(this._toElement),n=(Date.now()-this._animationStartTime)/this._totalAnimationDuration,s={};if(n>=1){this._element.hide();return}e.opacity=0;const i=Object.keys(this._fromDimensions);for(let a of i)s[a]=((o=this._fromDimensions[a])!=null?o:0)+(((r=e[a])!=null?r:0)-((l=this._fromDimensions[a])!=null?l:0))*n;this._element.css(s),Nl(this._nextAnimationFrame.bind(this))}_measure(e){const n=e.offset();return{left:n==null?void 0:n.left,top:n==null?void 0:n.top,width:e.outerWidth(),height:e.outerHeight()}}}const tw=Object.freeze(Object.defineProperty({__proto__:null,BrowserPopout:xm,DragProxy:Go,DragSource:km,DragSourceFromEvent:Om,DropTargetIndicator:Id,Header:Ko,HeaderButton:Io,Splitter:Vm,Tab:Rd,TransitionIndicator:Um},Symbol.toStringTag,{value:"Module"})),nw={config:GS,container:KS,controls:tw,errors:JS,items:ew,utils:ZS};class Dd extends bn{constructor(e,n){super(),this.isInitialised=!1,this._isFullPage=!1,this._components={"lm-react-component":Nm},this._itemAreas=[],this._maximisedItem=null,this._maximisePlaceholder=ce('<div class="lm_maximise_place"></div>'),this._creationTimeoutPassed=!1,this._subWindowsCreated=!1,this._dragSources=[],this._updatingColumnsResponsive=!1,this._firstLoad=!0,this.width=null,this.height=null,this.openPopouts=[],this.selectedItem=null,this.isSubWindow=!1,this.eventHub=new Fm(this),this.dropTargetIndicator=null,this.transitionIndicator=null,this.tabDropPlaceholder=ce('<div class="lm_drop_tab_placeholder"></div>'),this._onResize=this._onResize.bind(this),this._onUnload=this._onUnload.bind(this),this._windowBlur=this._windowBlur.bind(this),this._windowFocus=this._windowFocus.bind(this),this.config=this._createConfig(e),this._originalContainer=n,this.container=this._getContainer(),this.isSubWindow&&ce("body").css("visibility","hidden"),this._typeToItem={column:Zr.bind(this,!0),row:Zr.bind(this,!1),stack:Aa,component:Pm}}static minifyConfig(e){return Ed(e)}static unminifyConfig(e){return ka(e)}registerComponent(e,n){if(typeof n!="function"&&(n==null||n.render==null||typeof n.render!="function"))throw new Error("Please register a constructor function");if(this._components[e]!==void 0)throw new Error("Component "+e+" is already registered");return this._components[e]=n,()=>{if(this._components[e]===void 0)throw new Error("Component "+e+" is not registered");delete this._components[e]}}setFallbackComponent(e){this._fallbackComponent=e}toConfig(e){if(this.isInitialised===!1)throw new Error("Can't create config, layout not yet initialised");if(e&&!(e instanceof vt))throw new Error("Root must be a ContentItem");const n={settings:{...this.config.settings},dimensions:{...this.config.dimensions},labels:{...this.config.labels},content:[]},s=function(i,o){for(let r in o.config)r!=="content"&&(i[r]=o.config[r]);if(i.componentName==="lm-react-component"&&(i.type="react-component"),o.contentItems.length){i.content=[];for(let r=0;r<o.contentItems.length;r++)i.content[r]={},s(i.content[r],o.contentItems[r])}};e?s(n,{contentItems:[e]}):s(n,this.root),this._$reconcilePopoutWindows(),n.openPopouts=[];for(let i=0;i<this.openPopouts.length;i++)n.openPopouts.push(this.openPopouts[i].toConfig());return n.maximisedItemId=this._maximisedItem?"__glMaximised":void 0,n}getComponent(e){return this._components[e]}getFallbackComponent(){return this._fallbackComponent}init(){if(this._subWindowsCreated===!1&&(this._createSubWindows(),this._subWindowsCreated=!0),document.readyState==="loading"||document.body===null){ce(document).ready(this.init.bind(this));return}if(this.isSubWindow===!0&&this._creationTimeoutPassed===!1){setTimeout(this.init.bind(this),7),this._creationTimeoutPassed=!0;return}this.isSubWindow===!0&&this._adjustToWindowMode(),this._setContainer(),this.dropTargetIndicator=new Id,this.transitionIndicator=new Um,this.updateSize(),this._create(this.config),this._bindEvents(),this.isInitialised=!0,this._adjustColumnsResponsive(),this.emit("initialised")}updateSize(e,n){var s,i,o,r;this.width=(s=e!=null?e:this.container.width())!=null?s:0,this.height=(i=n!=null?n:this.container.height())!=null?i:0,this.isInitialised===!0&&(this.root.callDownwards("setSize",[this.width,this.height]),this._maximisedItem&&(this._maximisedItem.element.width((o=this.container.width())!=null?o:0),this._maximisedItem.element.height((r=this.container.height())!=null?r:0),this._maximisedItem.callDownwards("setSize")),this._adjustColumnsResponsive())}destroy(){var e,n;this.isInitialised===!1||!this.root||(this._onUnload(),ce(window).off("resize",this._onResize),ce(window).off("unload beforeunload",this._onUnload),ce(window).off("blur.lm").off("focus.lm"),this.root.callDownwards("_$destroy",[],!0),this.root.contentItems=[],this.tabDropPlaceholder.remove(),(e=this.dropTargetIndicator)==null||e.destroy(),(n=this.transitionIndicator)==null||n.destroy(),this.eventHub.destroy(),this._dragSources.forEach(function(s){s._dragListener.destroy()}),this._dragSources=[])}createContentItem(e,n){var s,i;if(typeof e.type!="string")throw new ii("Missing parameter 'type'",e);if(e.type==="react-component"&&(e.type="component",e.componentName="lm-react-component"),!this._typeToItem[e.type])throw s="Unknown type '"+e.type+"'. Valid types are "+Object.keys(this._typeToItem).join(","),new ii(s);return e.type==="component"&&!(n instanceof Aa)&&!!n&&!(this.isSubWindow===!0&&n instanceof La)&&(e={type:"stack",width:e.width,height:e.height,content:[e]}),i=new this._typeToItem[e.type](this,e,n),i}createPopout(e,n,s,i){var d,c,u;let o=[];const r=e instanceof vt,l=this;if(r){o=this.toConfig(e).content,s=vd();let m=e.parent,p=e;for(;(m==null?void 0:m.contentItems.length)===1&&!m.isRoot;)p=m,m=m.parent;m==null||m.addId(s),(i==null||Number.isNaN(i))&&(i=m==null?void 0:m.contentItems.indexOf(p))}else e instanceof Array?o=e:o=[e];if(!n&&r){const m=window.screenX||window.screenLeft,p=window.screenY||window.screenTop,g=(d=e.element.offset())!=null?d:{left:0,top:0};n={left:m+g.left,top:p+g.top,width:(c=e.element.width())!=null?c:0,height:(u=e.element.height())!=null?u:0}}if(!n&&!r&&(n={left:window.screenX||window.screenLeft+20,top:window.screenY||window.screenTop+20,width:500,height:309}),r&&e.remove(),!n||!s||i===void 0)return;const a=new xm(o,n,s,i,this);return a.on("initialised",function(){l.emit("windowOpened",a)}),a.on("closed",function(){l._$reconcilePopoutWindows()}),this.openPopouts.push(a),a}createDragSource(e,n){this.config.settings.constrainDragToContainer=!1;var s=new km(e,n,this);return this._dragSources.push(s),s}createDragSourceFromEvent(e,n){return this.config.settings.constrainDragToContainer=!1,new Om(e,this,n)}selectItem(e,n){if(this.config.settings.selectionEnabled!==!0)throw new Error("Please set selectionEnabled to true to use this feature");e!==this.selectedItem&&(this.selectedItem!==null&&this.selectedItem.deselect(),e&&n!==!0&&e.select(),this.selectedItem=e,this.emit("selectionChanged",e))}_$maximiseItem(e){var n,s;this._maximisedItem!==null&&this._$minimiseItem(this._maximisedItem),this._maximisedItem=e,this._maximisedItem.addId("__glMaximised"),e.element.addClass("lm_maximised"),e.element.after(this._maximisePlaceholder),this.root.element.prepend(e.element),e.element.width((n=this.container.width())!=null?n:0),e.element.height((s=this.container.height())!=null?s:0),e.callDownwards("setSize"),this._maximisedItem.emit("maximised"),this.emit("stateChanged")}_$minimiseItem(e){var n;e.element.removeClass("lm_maximised"),e.removeId("__glMaximised"),this._maximisePlaceholder.after(e.element),this._maximisePlaceholder.remove(),(n=e.parent)==null||n.callDownwards("setSize"),this._maximisedItem=null,e.emit("minimised"),this.emit("stateChanged")}_$closeWindow(){window.setTimeout(function(){window.close()},1)}_$getArea(e,n){let s=1/0,i=null;for(let o=0;o<this._itemAreas.length;o++){const r=this._itemAreas[o];e>r.x1&&e<r.x2&&n>r.y1&&n<r.y2&&s>r.surface&&(s=r.surface,i=r)}return i}_$createRootItemAreas(){const n={...this.root._$getArea()},s=[{...n,side:"left",x2:n.x1+50},{...n,side:"right",x1:n.x2-50},{...n,side:"top",y2:n.y1+50},{...n,side:"bottom",y1:n.y2-50}];s.forEach(i=>{i.surface=(i.x2-i.x1)*(i.y2-i.y1)}),this._itemAreas.push(...s)}_$calculateItemAreas(){var n;const e=this._getAllContentItems();if(this._itemAreas=[],e.length===1){this._itemAreas.push(this.root._$getArea());return}this._$createRootItemAreas();for(let s=0;s<e.length;s++){const i=e[s];if(!Ao(i))continue;const o=i._$getArea();if(o!==null)if(o instanceof Array)this._itemAreas=this._itemAreas.concat(o);else{this._itemAreas.push(o);let r={...o,...(n=o.contentItem._contentAreaDimensions)==null?void 0:n.header.highlightArea};r.surface=(r.x2-r.x1)*(r.y2-r.y1),this._itemAreas.push(r)}}}_$normalizeContentItem(e,n){if(!e)throw new Error("No content item defined");if(typeof e=="function"&&(e=e()),e instanceof vt)return e;if(ce.isPlainObject(e)&&e.type){var s=this.createContentItem(e,n);return s.callDownwards("_$init"),s}else throw new Error("Invalid contentItem")}_$reconcilePopoutWindows(){var n;const e=[];for(let s=0;s<this.openPopouts.length;s++)((n=this.openPopouts[s].getWindow())==null?void 0:n.closed)===!1?e.push(this.openPopouts[s]):this.emit("windowClosed",this.openPopouts[s]);this.openPopouts.length!==e.length&&(this.emit("stateChanged"),this.openPopouts=e)}_getAllContentItems(){const e=[],n=s=>{if(e.push(s),s.contentItems instanceof Array)for(let i=0;i<s.contentItems.length;i++)n(s.contentItems[i])};return n(this.root),e}_bindEvents(){this._isFullPage&&ce(window).resize(this._onResize),ce(window).on("unload beforeunload",this._onUnload).on("blur.lm",this._windowBlur).on("focus.lm",this._windowFocus)}_windowBlur(){this.root.element.addClass("lm_window_blur")}_windowFocus(){this.root.element.removeClass("lm_window_blur")}_onResize(){clearTimeout(this._resizeTimeoutId),this._resizeTimeoutId=window.setTimeout(this.updateSize.bind(this),100)}_createConfig(e){var i;var n=Mm("gl-window");n&&(this.isSubWindow=!0,e=JSON.parse(localStorage.getItem(n)||"{}"),e=ka(e),localStorage.removeItem(n)),e=ce.extend(!0,{},ym,e);var s=function(o){for(var r in o){const l=o[r];r!=="props"&&typeof l=="object"&&l!=null?s(l):r==="type"&&l==="react-component"&&(o.type="component",o.componentName="lm-react-component")}};return s(e),((i=e.settings)==null?void 0:i.hasHeaders)===!1&&(e.dimensions.headerHeight=0),e}_adjustToWindowMode(){var n;var e=ce('<div class="lm_popin" title="'+this.config.labels.popin+'"><div class="lm_icon"></div><div class="lm_bg"></div></div>');e.click(()=>{this.emit("popIn")}),document.title=Td((n=this.config.content[0].title)!=null?n:""),ce("head").append(ce("body link, body style, template, .gl_keep")),this.container=ce("body").html("").css("visibility","visible").append(e),document.body.offsetHeight,window.__glInstance=this}_createSubWindows(){if(!!this.config.openPopouts)for(let e=0;e<this.config.openPopouts.length;e++){const n=this.config.openPopouts[e];this.createPopout(n.content,n.dimensions,n.parentId,n.indexInParent)}}_getContainer(){const e=this._originalContainer?ce(this._originalContainer):ce("body");if(e.length===0)throw new Error("GoldenLayout container not found");if(e.length>1)throw new Error("GoldenLayout more than one container element specified");return e}_setContainer(){const e=this._getContainer();e[0]===document.body&&(this._isFullPage=!0,ce("html, body").css({height:"100%",margin:0,padding:0,overflow:"hidden"})),this.container=e}_create(e){var n;if(!(e.content instanceof Array))throw e.content===void 0?n="Missing setting 'content' on top level of configuration":n="Configuration parameter 'content' must be an array",new ii(n,e);if(e.content.length>1)throw n="Top level content can't contain more then one element.",new ii(n,e);this.root=new La(this,{content:e.content},this.container),this.root.callDownwards("_$init"),e.maximisedItemId==="__glMaximised"&&this.root.getItemsById(e.maximisedItemId)[0].toggleMaximise()}_onUnload(){if(this.config.settings.closePopoutsOnUnload===!0)for(var e=0;e<this.openPopouts.length;e++)this.openPopouts[e].close()}_adjustColumnsResponsive(){if(!this._useResponsiveLayout()||this._updatingColumnsResponsive||!this.config.dimensions||!this.config.dimensions.minItemWidth||this.root.contentItems.length===0||!this.root.contentItems[0].isRow){this._firstLoad=!1;return}this._firstLoad=!1;var e=this.root.contentItems[0].contentItems.length;if(!(e<=1)){var n=this.config.dimensions.minItemWidth,s=e*n;if(!(this.width==null||s<=this.width)){this._updatingColumnsResponsive=!0;for(var i=Math.max(Math.floor(this.width/n),1),o=e-i,r=this.root.contentItems[0],l=this._findAllStackContainers()[0],a=0;a<o;a++){var d=r.contentItems[r.contentItems.length-1];this._addChildContentItemsToContainer(l,d)}this._updatingColumnsResponsive=!1}}}_useResponsiveLayout(){return this.config.settings&&(this.config.settings.responsiveMode=="always"||this.config.settings.responsiveMode=="onload"&&this._firstLoad)}_addChildContentItemsToContainer(e,n){n.type==="stack"?n.contentItems.forEach(function(s){e.addChild(s),n.removeChild(s,!0)}):n.contentItems.forEach(s=>{this._addChildContentItemsToContainer(e,s)})}_findAllStackContainers(){const e=[];return this._findAllStackContainersRecursive(e,this.root),e}_findAllStackContainersRecursive(e,n){n.contentItems.forEach(s=>{Ao(s)?e.push(s):s.isComponent||this._findAllStackContainersRecursive(e,s)})}}Dd.__lm=nw;const sw="_lm_root_1mdia_1",iw="_lm_row_1mdia_5",ow="_lm_item_1mdia_5",rw="_lm_content_1mdia_9",lw="_lm_dragging_1mdia_15",aw="_lm_maximised_1mdia_21",dw="_lm_maximise_placeholder_1mdia_28",cw="_lm_splitter_1mdia_32",hw="_lm_vertical_1mdia_39",uw="_lm_drag_handle_1mdia_39",mw="_lm_horizontal_1mdia_44",pw="_lm_header_1mdia_54",gw="_lm_dropdown_open_1mdia_61",fw="_lm_controls_1mdia_67",Cw="_lm_tabs_1mdia_87",bw="_lm_tab_1mdia_87",Sw="_lm_title_1mdia_102",ww="_lm_close_tab_1mdia_109",vw="_lm_stack_1mdia_118",Tw="_lm_left_1mdia_118",Ew="_lm_right_1mdia_119",yw="_lm_dragProxy_1mdia_123",Iw="_lm_items_1mdia_146",Rw="_lm_tabdropdown_list_1mdia_163",Dw="_lm_bottom_1mdia_190",Mw="_lm_drop_tab_placeholder_1mdia_205",Nw="_lm_tabdropdown_1mdia_163",Fw="_lm_dropTargetIndicator_1mdia_256",xw="_lm_inner_1mdia_262",_w="_lm_transition_indicator_1mdia_270",kw="_lm_popin_1mdia_280",Ow="_lm_bg_1mdia_295",Lw="_lm_icon_1mdia_298",Aw="_lm_goldenlayout_1mdia_302",Pw="_lm_selectable_1mdia_338",Hw="_lm_active_1mdia_368",Vw="_lm_selected_1mdia_386",Uw="_lm_keyboard_active_1mdia_395",Bw="_lm_popout_1mdia_414",$w="_lm_maximise_1mdia_21",zw="_lm_close_1mdia_109",Ww="_lm_tabnextbutton_1mdia_423",Gw="_lm_tabpreviousbutton_1mdia_426",Kw="_lm_title_before_1mdia_542",qw="_lm_focusin_1mdia_566",Yw="_lm_window_blur_1mdia_571",Xw="_lm_tabdropdown_search_1mdia_629",jw="_march_1mdia_1",Qw="_app_1mdia_710",Zw="_plotly_1mdia_719",lh={"tab-height":"28px","drag-border-width":"5px",lm_root:sw,lm_row:iw,lm_item:ow,lm_content:rw,lm_dragging:lw,lm_maximised:aw,lm_maximise_placeholder:dw,lm_splitter:cw,lm_vertical:hw,lm_drag_handle:uw,lm_horizontal:mw,lm_header:pw,lm_dropdown_open:gw,lm_controls:fw,lm_tabs:Cw,lm_tab:bw,lm_title:Sw,lm_close_tab:ww,lm_stack:vw,lm_left:Tw,lm_right:Ew,lm_dragProxy:yw,lm_items:Iw,lm_tabdropdown_list:Rw,lm_bottom:Dw,lm_drop_tab_placeholder:Mw,lm_tabdropdown:Nw,lm_dropTargetIndicator:Fw,lm_inner:xw,lm_transition_indicator:_w,lm_popin:kw,lm_bg:Ow,lm_icon:Lw,lm_goldenlayout:Aw,lm_selectable:Pw,lm_active:Hw,lm_selected:Vw,lm_keyboard_active:Uw,lm_popout:Bw,lm_maximise:$w,lm_close:zw,lm_tabnextbutton:Ww,lm_tabpreviousbutton:Gw,lm_title_before:Kw,"editor-unsaved-indicator":"_editor-unsaved-indicator_1mdia_546","is-unsaved":"_is-unsaved_1mdia_554",lm_focusin:qw,lm_window_blur:Yw,lm_tabdropdown_search:Xw,march:jw,app:Qw,"js-plotly-plot":"_js-plotly-plot_1mdia_719",plotly:Zw},ah=Object.freeze({tabHeight:parseInt(lh["tab-height"],10),dragBorderWidth:parseInt(lh["drag-border-width"],10)}),Ts=X.module("LayoutUtils");function Bm(t){return t.componentName!==void 0}function _i(t){const e=t;return(Bm(t)&&t.componentName==="lm-react-component"||t.type==="react-component")&&e.component!==void 0}function br(t){return t.focus!==void 0}function ch(t){return t.type==="stack"}const ze=class{static activateTab(t,e){const n=ze.getStackForRoot(t,e,!1);if(!n){Ts.error("Could not find stack for config",e);return}const s=ze.getContentItemInStack(n,e);s&&n.setActiveContentItem(s)}static isActiveTab(t,e){const n=ze.getStackForRoot(t,e,!1);if(!n)return Ts.error("Could not find stack for config",e),!1;const s=ze.getContentItemInStack(n,e);return n.getActiveContentItem()===s}static addStack(t,e=!0){const n=e?"column":"row";if(Am(t)){(t.contentItems==null||t.contentItems.length===0)&&t.addChild({type:n});const o=t.contentItems[0];if(!(e?o.isColumn:o.isRow)){t.removeChild(o,!0),t.addChild({type:n});const l=document.activeElement;t.contentItems[0].addChild(o),l&&l.focus!=null&&l.focus()}return this.addStack(t.contentItems[0],e)}if(t.contentItems.length<2)return t.addChild({type:"stack"}),t.contentItems[t.contentItems.length-1];let s=t.contentItems[t.contentItems.length-1];return(e?s.isRow:s.isColumn)||(t.addChild({type:e?"row":"column"}),t.removeChild(s,!0),t.contentItems[t.contentItems.length-1].addChild(s),s=t.contentItems[t.contentItems.length-1]),this.addStack(s,!e)}static getStackForConfig(t,e={},n=!1){if(n&&Ao(t)&&t.contentItems.length===0)return t;if(t.contentItems==null)return null;for(let s=0;s<t.contentItems.length;s+=1){const i=t.contentItems[s];if(i.isComponent&&i.config!=null&&Sc(i.config,e))return t;const o=this.getStackForConfig(i,e,n);if(o)return o}return null}static getStackForRoot(t,e,n=!0,s=!0,i=!0){let o=this.getStackForConfig(t,e);return!o&&s&&(o=this.getStackForConfig(t,{component:e.component},i)),!o&&n&&(o=this.addStack(t)),o}static getStackForComponentTypes(t,e,n=!0,s=!0,i=!0){for(let o=0;o<e.length;o+=1){const r=e[o],l=o===e.length-1,a=ze.getStackForRoot(t,{component:r},n&&l,s,i);if(a)return a}return null}static getContentItemInStack(t,e){if(!t)return null;for(let n=0;n<t.contentItems.length;n+=1){const s=t.contentItems[n];if(s.isComponent&&s.config!=null&&Sc(s.config,e))return s}return null}static dehydrateLayoutConfig(t,e){if(t==null||!t.length)return[];const n=[];for(let s=0;s<t.length;s+=1){const i=t[s],{component:o,content:r}=i;if(o){const l=e(o,i);l!=null?n.push(l):Ts.debug2(`dehydrateLayoutConfig: skipping unmapped component "${o}"`)}else if(r){const l={...i,content:ze.dehydrateLayoutConfig(r,e)};n.push(l)}else n.push(i)}return n}static getTabPoint(t){const{tab:e}=t;if(e==null)throw new Error(`Cannot get tab for panel container ${t}`);const n=e.element[0].getBoundingClientRect();return[n.left+n.width*.5,n.bottom-8]}static dropLayoutMinorChange(t){for(let e=0;e<t.length;e+=1){const n=t[e],{content:s}=n;s!==void 0?(ch(n)&&delete n.activeItemIndex,ze.dropLayoutMinorChange(s)):_i(n)&&n.component==="IrisGridPanel"&&n.props.panelState!=null&&(delete n.id,n.props.panelState.irisGridState.sorts=[],n.props.panelState.irisGridState.quickFilters=[])}}static isEqual(t,e,n=!1){if(n){const s=ze.cloneLayout(t),i=ze.cloneLayout(e);return ze.dropLayoutMinorChange(s),ze.dropLayoutMinorChange(i),ct(s,i)}return ct(t,e)}static cloneLayout(t){return JSON.parse(JSON.stringify(t))}static hydrateLayoutConfig(t,e){var s;if(t==null||!t.length)return[];const n=[];for(let i=0;i<t.length;i+=1){const o=t[i];if(_i(o)){const{component:r,props:l={}}=o;n.push({...o,id:(s=o==null?void 0:o.id)!=null?s:We(),props:e(r,l)})}else if(o.content!==void 0){const r=ze.hydrateLayoutConfig(o.content,e);ch(o)&&o.activeItemIndex!=null&&o.activeItemIndex>=r.length&&(Ts.warn("Fixing bad activeItemIndex!",o.activeItemIndex,o),o.activeItemIndex=0),n.push({...o,content:r})}else n.push(o)}return n}static openComponent({root:t,config:e,replaceExisting:n=!0,replaceConfig:s=void 0,createNewStack:i=!1,focusElement:o=void 0,dragEvent:r=void 0}={}){const l=document.activeElement,a={...e};if(a.id==null&&(a.id=We.generate()),r){t==null||t.layoutManager.createDragSourceFromEvent(a,r);return}const d=s||{id:a.id,component:a.component};A(t);const c=i?ze.addStack(t):ze.getStackForRoot(t,d);A(c);const u=ze.getContentItemInStack(c,d);if(o!=null){const m=p=>{Ts.debug("Component created, focusing element",o),c.off("componentCreated",m);const{element:g}=p.origin;requestAnimationFrame(()=>{ze.focusElement(g[0],o)})};c.on("componentCreated",m)}if(n&&u){const m=c.contentItems.indexOf(u);c.addChild(a,m+1),c.removeChild(u),c.setActiveContentItem(c.contentItems[m])}else c.addChild(a);o==null&&l&&br(l)&&l.focus()}static openComponentInStack(t,e,n=!0){const s=document.activeElement,i={id:e.id},o=ze.getContentItemInStack(t,i);if(n&&o&&t){const r=t==null?void 0:t.contentItems.indexOf(o);t.addChild(e,r+1),t.removeChild(o),t.setActiveContentItem(t.contentItems[r])}else t==null||t.addChild(e);s&&br(s)&&s.focus()}static closeComponent(t,e){const n=ze.getStackForRoot(t,e,!1,!1,!1);if(!n){Ts.warn("Cannot find stack for component, ignoring close",e);return}const s=ze.getContentItemInStack(n,e),i=document.activeElement;s&&(s.isComponent?s.container.close():n.removeChild(s)),i&&document.contains(i)&&br(i)&&i.focus()}static renameComponent(t,e,n){const s=ze.getStackForRoot(t,e,!1);if(!s){Ts.error("Could not find stack for config",e);return}const i=ze.getContentItemInStack(s,e);i&&i.setTitle(n)}static cloneComponent(t,e){const n=ze.getStackForRoot(t,e,!1);if(!n)return Ts.error("Could not find stack for config",e),null;const{props:s={}}=e,i=ze.getPanelComponentState(e),o={type:"react-component",component:e.component,props:{...s,panelState:i},title:`${e.title} Copy`,id:We.generate()};return ze.openComponentInStack(n,o),o}static getPanelComponentState(t){var e,n;return Bm(t)?(e=t.componentState)==null?void 0:e.panelState:_i(t)?(n=t.props)==null?void 0:n.panelState:null}static makeDefaultLayout(){return{dimensions:{headerHeight:ah.tabHeight,borderWidth:ah.dragBorderWidth,borderGrabWidth:10},settings:{showPopoutIcon:!1,showCloseIcon:!1,constrainDragToContainer:!1}}}static getRootFromContainer(t){return t.layoutManager.root}static getComponentConfigFromContainer(t){return t?t.tab!=null&&t.tab.contentItem!=null?t.tab.contentItem.config:t._config:null}static getTitleFromContainer(t){return t!=null&&t.tab!=null&&t.tab.contentItem!=null?t.tab.contentItem.config.title:null}static getTitleFromTab(t){return t!=null&&t.contentItem!=null?t.contentItem.config.title:null}static getIdFromContainer(t){const e=ze.getComponentConfigFromContainer(t);return e?e.id:null}static getIdFromPanel(t){const{glContainer:e}=t.props;return ze.getIdFromContainer(e)}static getComponentNameFromPanel(t){var s;const{glContainer:e}=t.props,n=ze.getComponentConfigFromContainer(e);return n&&_i(n)&&(s=n.component)!=null?s:null}static getComponentName(t){var n,s;const e=(s=(n=t.WrappedComponent)==null?void 0:n.displayName)!=null?s:t.displayName;if(e==null)throw new Error(`Component displayName not defined ${t}`);return e}static focusElement(t,e=ze.DEFAULT_FOCUS_SELECTOR){if(t==null)return null;const n=t.querySelector(e);return n==null?null:(br(n)&&n.focus(),n)}static onInitialized(t){return new Promise(e=>{if(t.isInitialised){e();return}const n=()=>{t.off("initialised",n),e()};t.on("initialised",n)})}};let te=ze;te.DEFAULT_FOCUS_SELECTOR="input, select, textarea, button";const Jw=Y.forwardRef((t,e)=>{const n=te.getComponentNameFromPanel({props:t});return v("div",{ref:e,className:"panel-placeholder",children:['Component "',n,'" is not registered.']})}),Me=Object.freeze({FOCUS:"PanelEvent.FOCUS",MOUNT:"PanelEvent.MOUNT",UNMOUNT:"PanelEvent.UNMOUNT",TITLE_CHANGED:"PanelEvent.TITLE_CHANGED",REOPEN:"PanelEvent.REOPEN",DELETE:"PanelEvent.DELETE",CLONED:"PanelEvent.CLONED",CLOSED:"PanelEvent.CLOSED",OPEN:"PanelEvent.OPEN",CLOSE:"PanelEvent.CLOSE"});function hh(t){return(t==null?void 0:t.WrappedComponent)!==void 0}function e0(t){return typeof t.id=="string"&&t.layout instanceof Dd&&t.panelManager instanceof Md&&typeof t.registerComponent=="function"}function As(t){if(!e0(t))throw new Error(`Expected dashboard plugin props, but instead received ${t}`)}const mn=X.module("PanelManager");class Md{constructor(e,n=(l,a)=>a,s=(l,a)=>a,i=new Map,o=[],r=()=>{}){this.handleFocus=this.handleFocus.bind(this),this.handleMount=this.handleMount.bind(this),this.handleUnmount=this.handleUnmount.bind(this),this.handleReopen=this.handleReopen.bind(this),this.handleDeleted=this.handleDeleted.bind(this),this.handleClosed=this.handleClosed.bind(this),this.handleControlClose=this.handleControlClose.bind(this),this.layout=e,this.hydrateComponent=n,this.dehydrateComponent=s,this.onPanelsUpdated=r,this.openedMap=new Map(i),this.closed=[...o],this.startListening()}startListening(){const{eventHub:e}=this.layout;e.on(Me.FOCUS,this.handleFocus),e.on(Me.MOUNT,this.handleMount),e.on(Me.UNMOUNT,this.handleUnmount),e.on(Me.REOPEN,this.handleReopen),e.on(Me.DELETE,this.handleDeleted),e.on(Me.CLOSED,this.handleClosed),e.on(Me.CLOSE,this.handleControlClose)}stopListening(){const{eventHub:e}=this.layout;e.off(Me.FOCUS,this.handleFocus),e.off(Me.MOUNT,this.handleMount),e.off(Me.UNMOUNT,this.handleUnmount),e.off(Me.REOPEN,this.handleReopen),e.off(Me.DELETE,this.handleDeleted),e.off(Me.CLOSED,this.handleClosed),e.off(Me.CLOSE,this.handleControlClose)}getClosedPanelConfigsOfType(e){return this.closed.filter(n=>n.component===e)}getOpenedPanels(){return Array.from(this.openedMap.values())}getOpenedPanelConfigs(){return this.getOpenedPanels().map(e=>{const{glContainer:n}=e.props;return te.getComponentConfigFromContainer(n)})}getOpenedPanelConfigsOfType(e){return this.getOpenedPanelConfigs().filter(n=>n!=null&&_i(n)&&n.component===e)}getOpenedPanelById(e){return this.openedMap.get(e)}getContainerByPanelId(e){var s;const n=te.getStackForConfig(this.layout.root,{id:e});return(s=n&&te.getContentItemInStack(n,{id:e}))!=null?s:null}getLastUsedPanel(e){const n=this.getOpenedPanels();for(let s=n.length-1;s>=0;s-=1){const i=n[s];if(e==null||e(i))return i}}getLastUsedPanelOfType(e){return this.getLastUsedPanelOfTypes([e])}getLastUsedPanelOfTypes(e){return this.getLastUsedPanel(n=>e.some(s=>hh(s)&&n instanceof s.WrappedComponent||!hh(s)&&n instanceof s))}updatePanel(e){const n=te.getIdFromPanel(e);if(n==null){mn.error("updatePanel Panel did not have an ID",e);return}mn.debug2(`Updating panel ID ${n} in open panels map`),this.openedMap.delete(n),this.openedMap.set(n,e)}removePanel(e){const n=te.getIdFromPanel(e);if(n==null){mn.error("removePanel Panel did not have an ID",e);return}if(!this.openedMap.has(n)){mn.error(`Missing panel ID ${n} in open panels map`);return}if(this.openedMap.get(n)!==e){mn.debug(`Panel argument doesn't match the open panels map entry for ${n}, removePanel ignored`);return}mn.debug2(`Removing panel ID ${n} from open panels map`),this.openedMap.delete(n)}removeClosedPanelConfig(e){const n=this.closed.findIndex(s=>s===e||s.id!=null&&e.id&&s.id===e.id);n>=0&&this.closed.splice(n,1)}handleFocus(e){mn.debug2("Focus: ",e),this.updatePanel(e)}handleMount(e){mn.debug2("Mount: ",e),this.updatePanel(e),this.sendUpdate()}handleUnmount(e){mn.debug2("Unmount: ",e),this.removePanel(e),this.sendUpdate()}handleReopen(e,n){mn.debug2("Reopen:",e,n),this.removeClosedPanelConfig(e);const{component:s}=e;let{props:i}=e;i=this.hydrateComponent(s,i);const o={...e,props:i},{root:r}=this.layout;te.openComponent({root:r,config:o,replaceConfig:n})}handleDeleted(e){mn.debug2("Deleted:",e),this.removeClosedPanelConfig(e),this.sendUpdate()}handleClosed(e,n){mn.debug2("Closed: ",e),this.addClosedPanel(n),this.sendUpdate()}handleControlClose(e){const n={id:e},{root:s}=this.layout;te.closeComponent(s,n)}addClosedPanel(e){const n=te.getComponentConfigFromContainer(e);if(n&&_i(n)){const s=this.dehydrateComponent(n.component,n);s!=null&&this.closed.push(s)}}sendUpdate(){const{closed:e,openedMap:n}=this;this.onPanelsUpdated({closed:[...e],openedMap:new Map(n)})}}Md.MAX_CLOSED_PANEL_COUNT=100;const t0=X.module("PanelErrorBoundary");class n0 extends S.exports.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}componentWillUnmount(){const{glContainer:e,glEventHub:n}=this.props,s=te.getIdFromContainer(e);t0.debug("componentWillUnmount",s),n.emit(Me.CLOSED,s,e)}render(){const{children:e}=this.props,{error:n}=this.state;return n!=null?h("div",{className:"panel-error-boundary",children:h(Cl,{errorMessage:`${n}`,isLoading:!1,isLoaded:!1})}):e}}function Nd(t){const{props:e,componentState:n}=t,{metadata:s}=e;let{panelState:i=null}=e;n&&({panelState:i}=n);const o={};return s!=null&&(o.metadata=s),i!=null&&(o.panelState=i),{...t,componentState:null,props:o,type:"react-component"}}function Fd(t,e=""){return{metadata:{},...t,localDashboardId:e}}const Pa={dehydrate:Nd,hydrate:Fd},s0=D.exports.shape({on:D.exports.func,off:D.exports.func,isHidden:D.exports.bool,tab:D.exports.shape({header:D.exports.shape({tabs:D.exports.arrayOf(D.exports.shape({contentItem:D.exports.shape({})}))})}),title:D.exports.string,setTitle:D.exports.func,close:D.exports.func}),$m=D.exports.shape({on:D.exports.func,off:D.exports.func,emit:D.exports.func}),i0=D.exports.shape({registerComponent:D.exports.func,root:D.exports.shape({addChild:D.exports.func}),on:D.exports.func,off:D.exports.func,eventHub:$m}),xd=Object.freeze({Container:s0,EventHub:$m,Layout:i0}),Ke=(t,e,n)=>S.exports.useEffect(function(){return t.on(e,n),()=>{t.off(e,n)}},[t,e,n]),zm="SET_DASHBOARD_DATA",o0=MS(zm,{},!1),r0={dashboardData:o0},l0=new Map,a0=Object.freeze({}),d0=Object.freeze([]),c0=t=>t.dashboardData,qt=(t,e)=>{var n;return(n=c0(t)[e])!=null?n:a0},h0=(t,e)=>{var n;return(n=qt(t,e).closed)!=null?n:d0},Wm=(t,e)=>{var n;return(n=qt(t,e).openedMap)!=null?n:l0},Gm=(t,e)=>({type:zm,id:t,payload:e}),qn=(t,e)=>(n,s)=>n(Gm(t,{...qt(s(),t),...e}));Object.entries(r0).map(([t,e])=>Zi.register(t,e));const Sr=X.module("DashboardLayout"),u0=Object.freeze({}),m0=[],uh=()=>{},mh=t=>t,Km=({id:t,children:e,emptyDashboard:n=h("div",{children:"Dashboard is empty."}),layout:s,layoutConfig:i=m0,onLayoutChange:o=uh,onLayoutInitialized:r=uh,hydrate:l=Fd,dehydrate:a=Nd})=>{var _,k;const d=ed(),c=(_=lg(V=>qt(V,t)))!=null?_:u0,[u,m]=S.exports.useState(!1),[p,g]=S.exports.useState(!1),[f,b]=S.exports.useState(),[C]=S.exports.useState((k=c==null?void 0:c.closed)!=null?k:[]),[w,T]=S.exports.useState(!1),y=S.exports.useMemo(()=>new Map,[]),E=S.exports.useMemo(()=>new Map,[]),I=ag(),R=S.exports.useCallback((V,W,j=l,ee=a)=>{Sr.debug2("registerComponent",V,W,j,ee);function ve(Le,J){const pe=W,{glContainer:fe,glEventHub:xe}=Le;return h(tu,{store:I,children:h(n0,{glContainer:fe,glEventHub:xe,children:h(pe,{...Le,ref:J})})})}const le=Y.forwardRef(ve),Se=s.registerComponent(V,le);return y.set(V,j),E.set(V,ee),Se},[l,a,y,E,s,I]),F=S.exports.useCallback((V,W)=>{var j;return((j=y.get(V))!=null?j:mh)(W,t)},[y,t]),x=S.exports.useCallback((V,W)=>{var j;return((j=E.get(V))!=null?j:mh)(W,t)},[E,t]),U=S.exports.useMemo(()=>new Md(s,F,x,new Map,C,({closed:V,openedMap:W})=>{d(qn(t,{closed:V,openedMap:W}))}),[x,d,F,t,C,s]),$=S.exports.useCallback(()=>{if(p)return;w||(r(),T(!0));const W=s.toConfig().content,j=te.dehydrateLayoutConfig(W,x),ee=f==null||!te.isEqual(f,j);Sr.debug("handleLayoutStateChanged",ee,W,j),ee&&(m(s.root.contentItems.length===0),b(j),o(j))},[x,w,p,f,s,o,r]),O=S.exports.useCallback(()=>{g(!0)},[]),H=S.exports.useCallback(()=>{g(!1)},[]),L=S.exports.useCallback(V=>{if(Sr.debug2("handleComponentCreated",V),V==null||V.config==null||V.config.component==null||V.element==null)return;const j=`${V.config.component.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}-component`;V.element.addClass(j)},[]);Ke(s,"stateChanged",$),Ke(s,"itemPickedUp",O),Ke(s,"itemDropped",H),Ke(s,"componentCreated",L),Ke(s.eventHub,Me.TITLE_CHANGED,$);const N=gl(i);return S.exports.useEffect(function(){if(N!==i&&i!==f){Sr.debug("Setting new layout content...");const W=te.hydrateLayoutConfig(i,F);for(;s.root.contentItems.length>0;)s.root.contentItems[0].remove();for(let j=0;j<W.length;j+=1)s.root.addChild(W[j]);m(s.root.contentItems.length===0)}},[F,s,i,f,U,N]),v(ue,{children:[u&&n,Y.Children.map(e,V=>V!=null?Y.cloneElement(V,{id:t,layout:s,panelManager:U,registerComponent:R}):null)]})};Km.propTypes={id:D.exports.string.isRequired,children:D.exports.node,data:D.exports.shape({}),emptyDashboard:D.exports.node,layout:xd.Layout.isRequired,layoutConfig:D.exports.arrayOf(D.exports.shape({})),onLayoutChange:D.exports.func,onLayoutInitialized:D.exports.func};const p0=100,la=()=>{},g0=Object.freeze({}),f0=({id:t="default",children:e,emptyDashboard:n,layoutConfig:s,layoutSettings:i=g0,onLayoutConfigChange:o=la,onGoldenLayoutChange:r=la,onLayoutInitialized:l=la,fallbackComponent:a=Jw,hydrate:d,dehydrate:c})=>{const u=S.exports.useRef(null),[m,p]=S.exports.useState(!1),[g,f]=S.exports.useState();S.exports.useEffect(function(){if(!u.current){f(void 0);return}const w={...te.makeDefaultLayout()};w.settings===void 0&&(w.settings={}),Object.assign(w.settings,i),w.content=[];const T=new Dd(w,u.current),y=()=>{T.off("initialised",y),p(!0)};return T.on("initialised",y),a!=null&&T.setFallbackComponent(a),T.init(),f(T),r(T),()=>{T.destroy()}},[i,a,r,p,f]);const b=S.exports.useMemo(()=>hs(()=>{g!=null&&g.isInitialised&&(g==null||g.updateSize())},p0),[g]);return S.exports.useEffect(function(){return window.addEventListener("resize",b),()=>{window.removeEventListener("resize",b)}},[b]),v("div",{className:"dashboard-container w-100 h-100",children:[h("div",{className:"w-100 h-100",ref:u}),m&&g&&h(Km,{emptyDashboard:n,id:t,layout:g,layoutConfig:s,onLayoutChange:o,onLayoutInitialized:l,hydrate:d,dehydrate:c,children:e})]})},Rn="default";var mi=(t=>(t.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS="filter-control-change-clears-all-filters",t.LINK_CHANGE_CLEARS_ALL_FILTERS="link-change-clears-all-filters",t))(mi||{});const C0=Object.freeze([[mi.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS,!1],[mi.LINK_CHANGE_CLEARS_ALL_FILTERS,!1]]),b0={DEFAULTS:C0};var Ae=(t=>(t.COUNT="Count",t.MIN="Min",t.MAX="Max",t.SUM="Sum",t.ABS_SUM="AbsSum",t.VAR="Var",t.AVG="Avg",t.STD="Std",t.FIRST="First",t.LAST="Last",t.SKIP="Skip",t.COUNT_DISTINCT="CountDistinct",t.DISTINCT="Distinct",t.UNIQUE="Unique",t))(Ae||{});const S0=t=>{switch(t){default:return!1}},w0=(t,e)=>{switch(t){case Ae.COUNT:case Ae.FIRST:case Ae.LAST:case Ae.COUNT_DISTINCT:case Ae.DISTINCT:case Ae.UNIQUE:return!0;case Ae.MIN:case Ae.MAX:return P.isNumberType(e)||P.isDateType(e)||P.isTextType(e);case Ae.SUM:case Ae.ABS_SUM:case Ae.VAR:case Ae.AVG:case Ae.STD:return P.isNumberType(e);case Ae.SKIP:return!1}},_d=(t,e)=>t.filter(n=>w0(e,n.type)),v0=(t,e,n,s)=>_d(t,e).map(({name:i})=>i).filter(i=>n.includes(i)?!s:s),ks={isRollupOperation:S0,filterValidColumns:_d,getOperationColumnNames:v0};const ph=X.module("Aggregations"),T0=[Ae.SUM,Ae.ABS_SUM,Ae.MIN,Ae.MAX,Ae.VAR,Ae.AVG,Ae.STD,Ae.FIRST,Ae.LAST,Ae.COUNT_DISTINCT,Ae.DISTINCT,Ae.COUNT,Ae.UNIQUE],E0=({isRollup:t,settings:e,onChange:n,onEdit:s})=>{const{aggregations:i,showOnTop:o}=e,r=S.exports.useMemo(()=>T0.filter(x=>!i.some(U=>U.operation===x)),[i]),[l,a]=S.exports.useState(r[0]),[d,c]=S.exports.useState([]),u=S.exports.useCallback(x=>{n({...e,...x})},[n,e]),m=S.exports.useCallback(x=>{u({aggregations:x})},[u]),p=S.exports.useCallback(x=>{u({showOnTop:x})},[u]),g=S.exports.useCallback(()=>{ph.debug("handleDragStart"),Gt.startDragging()},[]),f=S.exports.useCallback(({destination:x,source:U})=>{if(ph.debug("handleDragEnd",x,U),Gt.stopDragging(),x===null)return;let $=x.index;U.index<x.index&&($+=1);const O=[...i],H=Gt.reorder(O,d,O,$),L=Gt.adjustDestinationIndex($,d),N=[[L,L+H.length-1]];m(O),c(N)},[m,i,d,c]),b=S.exports.useCallback(x=>{a(x)},[a]),C=S.exports.useCallback(()=>{m([...i,{operation:l,selected:[],invert:!0}])},[i,l,m]),w=S.exports.useCallback(x=>{m(i.filter((U,$)=>$!==x))},[i,m]),T=S.exports.useCallback(x=>{c(x)},[c]),y=S.exports.useCallback(x=>{const U=i[x];ks.isRollupOperation(U.operation)||s(U)},[i,s]),E=S.exports.useCallback(x=>{p(x.target.value==="true")},[p]);S.exports.useEffect(function(){r.length>0&&!r.includes(l)&&a(r[0])},[r,l]);const I=S.exports.useCallback(({item:x,itemIndex:U,isClone:$=!1,selectedCount:O})=>{const H=x.operation,L=$?`${O}`:void 0,N=$?"item-list-item-clone":void 0,_=ks.isRollupOperation(x.operation),k=!$&&!_;return v(ue,{children:[v("div",{className:z("item-list-item-content","draggable-item-list-item-content",N),children:[v("span",{className:"title",children:[H,!t&&_&&v("span",{className:"small text-warning",children:[h(K,{icon:Su})," Requires rollup"]})]}),nn.renderBadge({text:L}),nn.renderHandle()]}),!$&&v(ue,{children:[h(Q,{kind:"ghost",className:"btn-edit",icon:hl,tooltip:"Edit Columns",onClick:()=>s(x),disabled:!k}),h(Q,{kind:"ghost",className:"btn-delete",icon:_n,tooltip:"Delete Aggregation",onClick:()=>w(U)})]})]})},[w,s,t]),R=r.length>0,F=i.length>0;return v("div",{className:"aggregations",children:[R&&v("div",{className:"form-inline",children:[h(OC,{onChange:b,value:l,children:r.map(x=>h(kC,{value:x,children:x},x))}),v("button",{type:"button",className:"btn btn-link btn-add",onClick:C,children:[h(K,{icon:Ls}),"Add Aggregation"]})]}),R&&F&&h("hr",{}),F&&v(ue,{children:[!t&&v("div",{className:"form-inline",children:[h("label",{children:"Placement:\xA0"}),v(bl,{onChange:E,value:`${o}`,children:[h(Mn,{value:"true",children:"Top"}),h(Mn,{value:"false",children:"Bottom"})]})]}),h(Vo,{onDragStart:g,onDragEnd:f,children:h(nn,{className:"selected-aggregations",itemCount:i.length,items:i,renderItem:I,offset:0,onSelectionChange:T,onSelect:y,selectedRanges:d,isMultiSelect:!0})})]})]})};const y0=30,I0=({aggregation:t,columns:e,onChange:n})=>{const[s,i]=S.exports.useState(-1),[o,r]=S.exports.useState(-1),[l,a]=S.exports.useState(0),{invert:d,selected:c}=t,u=S.exports.useRef(null),m=S.exports.useCallback(E=>c.includes(E)?!d:d,[d,c]),p=S.exports.useMemo(()=>{let E=_d(e,t.operation);return l!==0&&(E=P.sortColumns(E,l===1)),E},[e,t.operation,l]),g=S.exports.useMemo(()=>s>=0?p.slice(s,o+1).map(E=>({value:E.name,displayValue:E.name,isSelected:m(E.name)})):[],[p,m,o,s]),f=S.exports.useCallback(E=>{const{name:I}=p[E],R=c.indexOf(I);let F=[...c],x=d;R>=0?F.splice(R,1):(F.push(I),F.length===p.length&&(F=[],x=!d)),n({...t,selected:F,invert:x})},[t,d,p,c,n]),b=S.exports.useCallback(()=>{a(0),n({...t,selected:[],invert:!0})},[t,n]),C=S.exports.useCallback((E,I)=>{i(E),r(I)},[i,r]),w=S.exports.useCallback(()=>{c.length===0?n({...t,invert:!d}):n({...t,selected:[],invert:!0})},[t,d,n,c]),T=c.length===0?d:null,y=c.length!==0||!d||l!==0;return v("div",{role:"menu",className:"aggregation-edit",children:[h("div",{className:"top-menu",children:v("div",{className:"form-inline",children:[h(Pt,{checked:T,onChange:w,children:"Toggle All"}),h("div",{className:"spacer"}),h(ht,{in:y,timeout:Tt.transitionSlowMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:h(Q,{kind:"ghost",className:"btn-reset",onClick:b,children:"Reset"})}),h(Q,{kind:"ghost",className:z({active:l===1}),icon:hd,tooltip:"Sort ascending",onClick:()=>a(1)}),h(Q,{kind:"ghost",className:z({active:l===2}),icon:ud,tooltip:"Sort descending",onClick:()=>a(2)})]})}),h("div",{className:"aggregation-edit-item-list",children:h(Cn,{itemCount:p.length,items:g,offset:s,renderItem:({item:E})=>h(Pt,{checked:m(E.value),children:E.displayValue}),onSelect:f,onViewportChange:C,rowHeight:y0,focusSelector:"input",ref:u})})]})};function R0(t){return h("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...t,children:v("g",{fill:"none",fillRule:"evenodd",children:[h("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),h("path",{fill:"#7DA4FF",d:"M8 26h4v15H8zM15 17h4v24h-4zM22 21h4v20h-4zM29 17h4v24h-4zM36 11h4v30h-4z"})]})})}function D0(t){return h("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...t,children:v("g",{fill:"none",fillRule:"evenodd",children:[h("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),h("path",{fill:"#7DA4FF",d:"M7 34h4v8H7zM12 31h4v11h-4zM17 27h4v15h-4zM22 22h4v20h-4zM27 27h4v15h-4zM32 29h4v13h-4zM37 31h4v11h-4z"})]})})}function M0(t){return h("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...t,children:v("g",{fill:"none",fillRule:"evenodd",children:[h("path",{fill:"#C1C0C0",d:"M4 4h1v40H4zM44 43v1H5v-1z"}),h("path",{stroke:"#7DA4FF",d:"M7.984 32.44l7.982-11.378 5.273 3.739 9.952-10.838 2.826 1.894 7.45-5.802"}),h("path",{stroke:"#BECDEF",d:"M8.244 37.926L17 33.496l5 .87 10.637-10.35 10.615-1.381"})]})})}function N0(t){return h("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...t,children:v("g",{fill:"none",fillRule:"evenodd",children:[h("path",{d:"M24 10c7.732 0 14 6.268 14 14s-6.268 14-14 14-14-6.268-14-14h14V10z",fill:"#80A6FF"}),h("path",{d:"M10 24c0-7.732 6.268-14 14-14v14H10z",fill:"#C1C0C0"})]})})}function F0(t){return h("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...t,children:v("g",{fill:"none",fillRule:"evenodd",children:[h("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),h("path",{fill:"#939293",d:"M44 34v1H4v-1zM44 25v1H4v-1zM44 16v1H4v-1z"}),h("circle",{fill:"#7DA4FF",cx:9.5,cy:37.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:16.5,cy:30.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:22.5,cy:36.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:28.5,cy:30.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:15.5,cy:38.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:23.5,cy:25.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:19.5,cy:19.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:29.5,cy:19.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:32.5,cy:26.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:36.5,cy:13.5,r:1.5})]})})}function x0(t){return v("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[h("rect",{width:"48",height:"48",fill:"none"}),h("rect",{x:"26",y:"10",width:"15",height:"4",fill:"#9FDE70"}),h("rect",{x:"26",y:"22",width:"15",height:"4",fill:"#9FDE70"}),h("rect",{x:"26",y:"28",width:"15",height:"4",fill:"#FFD95C"}),h("rect",{x:"26",y:"34",width:"15",height:"4",fill:"#9FDE70"})]})}function _0(t){return v("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[h("rect",{width:"48",height:"48",fill:"none"}),h("rect",{x:"4",y:"16",width:"40",height:"4",fill:"#FFD95C"}),h("rect",{x:"4",y:"10",width:"40",height:"4",fill:"#78DCE8"}),h("rect",{x:"4",y:"34",width:"40",height:"4",fill:"#78DCE8"})]})}const gh=X.module("ChartBuilder"),pt=class extends S.exports.PureComponent{static getTypeName(t){switch(t){case M.plot.SeriesPlotStyle.LINE:return"Line";case M.plot.SeriesPlotStyle.BAR:return"Bar";case M.plot.SeriesPlotStyle.SCATTER:return"Scatter";case M.plot.SeriesPlotStyle.PIE:return"Pie";case M.plot.SeriesPlotStyle.HISTOGRAM:return"Histogram";default:return t}}static getTypeIcon(t){switch(t){case M.plot.SeriesPlotStyle.LINE:return h(M0,{});case M.plot.SeriesPlotStyle.BAR:return h(R0,{});case M.plot.SeriesPlotStyle.SCATTER:return h(F0,{});case M.plot.SeriesPlotStyle.PIE:return h(N0,{});case M.plot.SeriesPlotStyle.HISTOGRAM:return h(D0,{});default:return null}}static getMaxSeriesCount(t){switch(t){case M.plot.SeriesPlotStyle.PIE:return 1;case M.plot.SeriesPlotStyle.HISTOGRAM:return 0;default:return 100}}static getXAxisLabel(t){switch(t){case M.plot.SeriesPlotStyle.PIE:return"Labels";case M.plot.SeriesPlotStyle.HISTOGRAM:return"Data";default:return"X-Axis"}}static getSeriesLabel(t){switch(t){case M.plot.SeriesPlotStyle.PIE:return"Values";default:return"Series"}}static makeSeriesItem(t){return{id:We.generate(),value:t}}static makeDefaultSeriesItems(t,e){if(pt.getMaxSeriesCount(t)===0||e==null||e.length===0)return[];const s=e.length>1?e[1].name:e[0].name;return[pt.makeSeriesItem(s)]}static getDefaultXAxis(t,e){return e!=null&&e.length>0?e[0].name:null}constructor(t){super(t),this.handleAddSeries=this.handleAddSeries.bind(this),this.handleLinkStateChange=this.handleLinkStateChange.bind(this),this.handleReset=this.handleReset.bind(this),this.handleSeriesChange=this.handleSeriesChange.bind(this),this.handleSeriesDeleteClick=this.handleSeriesDeleteClick.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleTypeClick=this.handleTypeClick.bind(this),this.handleXAxisChange=this.handleXAxisChange.bind(this),this.sendChange=this.sendChange.bind(this);const{model:e}=t,{columns:n}=e,s=pt.types[0],i=pt.getDefaultXAxis(s,n),o=pt.makeDefaultSeriesItems(s,n);this.state={type:s,seriesItems:o,xAxis:i,isLinked:!0}}handleAddSeries(){this.setState(t=>{let{seriesItems:e}=t;e=[...e];const{model:n}=this.props,{columns:s}=n;return e.push({id:We.generate(),value:s[0].name}),{seriesItems:e}},this.sendChange)}handleLinkStateChange(t){this.setState({isLinked:t.target.value==="true"},this.sendChange)}handleReset(){const{model:t}=this.props,{columns:e}=t,n=pt.types[0],s=pt.getDefaultXAxis(n,e),i=pt.makeDefaultSeriesItems(n,e),o=!0;this.setState({type:n,seriesItems:i,xAxis:s,isLinked:o},this.sendChange)}handleSeriesChange(t){const{value:e}=t.target,n=t.target.getAttribute("data-index"),s=parseInt(n,10);this.setState(i=>{let{seriesItems:o}=i;return o=[...o],o[s].value=e,{seriesItems:o}},this.sendChange)}handleSeriesDeleteClick(t){const n=t.target.getAttribute("data-index"),s=parseInt(n,10);this.setState(i=>{let{seriesItems:o}=i;return o=[...o],o.splice(s,1),{seriesItems:o}},this.sendChange)}handleSubmit(t){t.preventDefault();const{onSubmit:e}=this.props,{type:n,seriesItems:s,xAxis:i,isLinked:o}=this.state,r=s.map(l=>l.value);e({type:`${n}`,series:r,xAxis:i,isLinked:o})}handleTypeClick(t){const n=t.target.getAttribute("data-index"),s=parseInt(n,10),i=pt.types[s];gh.debug2("handleTypeSelect",i),this.setState(o=>{const r=pt.getMaxSeriesCount(i);let{seriesItems:l}=o;if(l=l.slice(0,r),l.length===0&&r>0){const{model:a}=this.props,{columns:d}=a;l=pt.makeDefaultSeriesItems(i,d)}return{type:i,seriesItems:l}},this.sendChange)}handleXAxisChange(t){const e=t.target.value;gh.debug2("x-axis change",e),this.setState({xAxis:e},this.sendChange)}sendChange(){const{onChange:t}=this.props,{isLinked:e,type:n,seriesItems:s,xAxis:i}=this.state,o=s.map(r=>r.value);t({type:n,series:o,xAxis:i,isLinked:e})}render(){const{model:t}=this.props,{columns:e}=t,{seriesItems:n,type:s,xAxis:i,isLinked:o}=this.state,r=pt.getMaxSeriesCount(s),l=pt.getXAxisLabel(s),a=pt.getSeriesLabel(s),d=n.length>0,c=n.length<r;return h("div",{className:"chart-builder",children:v("form",{onSubmit:this.handleSubmit,children:[v("div",{className:"form-row",children:[h("label",{children:"Select Chart Type"}),h("div",{className:"form-row",children:pt.types.map((u,m)=>{const p=u;return h("div",{className:"col col-chart-type",children:v("button",{type:"button",className:z("btn","btn-icon","btn-chart-type",{active:u===s}),"data-index":m,onClick:this.handleTypeClick,children:[pt.getTypeIcon(u),pt.getTypeName(u)]})},p)})})]}),h("hr",{}),v("div",{className:"form-row form-inline",children:[h("label",{className:"col-2 label-left",children:l}),h("select",{className:"form-control custom-select select-x-axis col",value:i,onChange:this.handleXAxisChange,children:e.map(u=>h("option",{value:u.name,children:u.name},u.name))})]}),d&&h("hr",{}),n.map((u,m)=>v("div",{className:"form-row form-inline form-series-item","data-testid":`form-series-item-${m}`,children:[h("label",{className:"col-2 label-left",children:m===0?a:""}),h("select",{className:"form-control custom-select select-series col",value:u.value,onChange:this.handleSeriesChange,"data-testid":`select-series-item-${m}`,"data-index":m,children:e.map(p=>h("option",{value:p.name,"data-index":m,children:p.name},p.name))}),n.length>1&&h("button",{type:"button",className:"btn btn-link btn-link-icon btn-delete-series ml-2 px-2","data-index":m,"data-testid":`delete-series-${m}`,onClick:this.handleSeriesDeleteClick,children:h(K,{icon:_n})})]},u.id)),c&&v("div",{className:"form-row",children:[h("div",{className:"col-2"}),v("button",{type:"button",className:"btn btn-link btn-add-series mt-1",onClick:this.handleAddSeries,children:[h(K,{icon:Ls}),"Add Series"]})]}),v("div",{className:"form-row chart-builder-link",children:[h("label",{className:"col-2 label-right",children:v("div",{className:"fa-md fa-layers",children:[h(K,{mask:pd,icon:Lo,transform:"right-5 down-5"}),h(K,{icon:o?rd:lC,transform:"grow-2 right-8 down-6"})]})}),v(bl,{onChange:this.handleLinkStateChange,value:`${o}`,children:[h(Mn,{value:"true",children:"Sync State"}),h(Mn,{value:"false",children:"Freeze State"})]})]}),v("div",{className:"form-row",children:[h("div",{className:"col-2 label-right"}),h("div",{className:"col chart-builder-link-info",children:o?"Charts with synced state will update to match any filters or user modifications applied to the parent table.":"Freeze State disconnects the chart state from the parent table. New filters or user modifications on the parent table will not be applied."})]}),v("div",{className:z("form-row","justify-content-end","my-3"),children:[h("button",{type:"button",className:"btn btn-outline-primary btn-reset",onClick:this.handleReset,children:"Reset"}),h("button",{type:"submit",className:"btn btn-primary btn-submit",children:"Create"})]})]})})}};let qm=pt;qm.types=[M.plot.SeriesPlotStyle.LINE,M.plot.SeriesPlotStyle.BAR,M.plot.SeriesPlotStyle.SCATTER,M.plot.SeriesPlotStyle.PIE];class Ym extends S.exports.Component{constructor(e){super(e),this.handleContentChanged=this.handleContentChanged.bind(this),this.handleEditorFocus=this.handleEditorFocus.bind(this),this.handleEditorBlur=this.handleEditorBlur.bind(this),this.handleContainerClick=this.handleContainerClick.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.state={isEditorFocused:!1,isEditorEmpty:!0},this.editorContainer=null}componentDidMount(){this.initEditor()}componentWillUnmount(){this.destroyEditor()}initEditor(){var i;const{value:e,editorSettings:n}=this.props,s={copyWithSyntaxHighlighting:"false",fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:"groovyDB",lineDecorationsWidth:8,lineNumbers:"off",minimap:{enabled:!1},renderLineHighlight:"none",scrollbar:{arrowSize:0,horizontal:"hidden",horizontalScrollbarSize:0},scrollBeyondLastLine:!1,padding:{top:6,bottom:6},tabCompletion:"off",useTabStops:!0,value:e,wordWrap:"on",automaticLayout:!0,...n};if(!this.editorContainer)throw new Error("editorContainer is null");this.editor=as.create(this.editorContainer,s),this.editor.layout(),(i=this.editor.getModel())==null||i.updateOptions({tabSize:0}),this.editor.onDidChangeModelContent(this.handleContentChanged),this.editor.onDidFocusEditorText(this.handleEditorFocus),this.editor.onDidBlurEditorText(this.handleEditorBlur)}destroyEditor(){var e;(e=this.editor)==null||e.dispose(),this.editor=void 0}handleContentChanged(){var s,i;const{onContentChanged:e}=this.props,n=(i=(s=this.editor)==null?void 0:s.getModel())==null?void 0:i.getValue();n!==""&&n!==void 0&&this.setState({isEditorEmpty:n.length===0}),e(n)}handleEditorFocus(){this.setState({isEditorFocused:!0})}handleEditorBlur(){var n,s;const e=(s=(n=this.editor)==null?void 0:n.getModel())==null?void 0:s.getValue();if(e===void 0||e==="")throw new Error("value is undefined");this.setState({isEditorEmpty:e.length===0,isEditorFocused:!1})}handleContainerClick(){var n;const{isEditorFocused:e}=this.state;e||(n=this.editor)==null||n.focus()}handleKeyDown(e){const{onTab:n,editorIndex:s}=this.props;e.key==="Tab"&&n(s,e.shiftKey)}render(){const{value:e,invalid:n}=this.props,{isEditorFocused:s,isEditorEmpty:i}=this.state;return v("div",{className:z("input-editor-wrapper",{focused:s,invalid:n}),onKeyDown:this.handleKeyDown,role:"presentation",onClick:this.handleContainerClick,children:[h("div",{className:"editor-container",ref:o=>{this.editorContainer=o}}),i&&!e&&h("div",{className:"editor-placeholder text-muted",children:"Column Formula"})]})}}Ym.defaultProps={value:"",onContentChanged:()=>{},editorSettings:{},editorIndex:0,onTab:()=>{},invalid:!1};const Ha=class extends S.exports.PureComponent{constructor(t){super(t),this.handleFormulaEditorContentChanged=this.handleFormulaEditorContentChanged.bind(this)}handleFormulaEditorContentChanged(t){const{onChange:e,eventKey:n}=this.props;t!==void 0&&t!==""&&(t.replace(/(\r\n|\n|\r)/gm,""),e(n,Ha.INPUT_TYPE.FORMULA,t))}render(){const{eventKey:t,name:e,formula:n,onChange:s,onDeleteColumn:i,inputIndex:o,onTabInEditor:r,invalid:l}=this.props;return h(dl,{draggableId:t,index:o,disableInteractiveElementBlocking:!0,children:(a,d)=>v("div",{className:z("draggable-container",{dragging:d.isDragging}),ref:a.innerRef,...a.draggableProps,children:[v("div",{className:"custom-column-input-container",children:[v("div",{className:"d-flex flex-row pb-3 custom-column-name",children:[h("input",{className:z("form-control custom-column-input",{"is-invalid":l}),placeholder:"Column Name",value:e,onChange:c=>{s(t,Ha.INPUT_TYPE.NAME,c.target.value)}}),v("button",{type:"button",className:"btn btn-link btn-link-icon ml-1 px-2",onClick:()=>{i(t)},children:[h(Ie,{children:"Delete custom column"}),h(K,{icon:_n})]}),v("button",{type:"button",className:"btn btn-link btn-link-icon px-2 btn-drag-handle",...a.dragHandleProps,children:[h(Ie,{children:"Drag column to re-order"}),h(K,{icon:ul})]})]}),h(Ym,{editorSettings:{language:"deephavenDb"},editorIndex:o,value:n,onContentChanged:this.handleFormulaEditorContentChanged,onTab:r,invalid:l})]}),h("hr",{})]})})}};let kd=Ha;kd.INPUT_TYPE={NAME:"name",FORMULA:"formula"};kd.defaultProps={name:"",inputIndex:0,formula:"",onChange:()=>{},onDeleteColumn:()=>{},onTabInEditor:()=>{},invalid:!1};class Xm extends Error{constructor(){super(...arguments),this.isAssertionFailed=!0}}function fh(t){if(t==null)throw new Xm(`Expected 'val' to be defined, but received ${t}`)}class aa extends Error{constructor(){super(...arguments),this.isPasteError=!0}}function Ze(t){return(t==null?void 0:t.isEditable)!==void 0}function Ch(t){if(!Ze(t))throw new Xm(`Expected 'model' to be editable, but received ${t}`)}function gt(t){return(t==null?void 0:t.hasExpandableRows)!==void 0}var Dn=(t=>(t.DOWN="DOWN",t.UP="UP",t.LEFT="LEFT",t.RIGHT="RIGHT",t))(Dn||{});const ye=class{static normalize(t,e,n,s){let i=t,o=e,r=n,l=s;return i!=null&&r!=null&&r<i&&(i=r,r=t),o!=null&&l!=null&&l<o&&(o=l,l=e),[i,o,r,l]}static makeNormalized(t,e,n,s){return new ye(...ye.normalize(t,e,n,s))}static makeCell(t,e){return new ye(t,e,t,e)}static makeColumn(t){return new ye(t,null,t,null)}static makeRow(t){return new ye(null,t,null,t)}static minOrNull(t,e){return t==null||e==null?null:Math.min(t,e)}static maxOrNull(t,e){return t==null||e==null?null:Math.max(t,e)}static consolidate(t){const e=t.slice();let n=!0;for(;n;){n=!1;for(let s=0;s<e.length&&!n;s+=1){const i=e[s];for(let o=e.length-1;o>s;o-=1){const r=e[o];if(i.contains(r))e.splice(o,1);else if(r.contains(i)){n=!0,e[s]=r,e.splice(o,1);break}else if(i.startRow===r.startRow&&i.endRow===r.endRow){if(i.touches(r)){const{startRow:l,endRow:a}=i,d=ye.minOrNull(i.startColumn,r.startColumn),c=ye.maxOrNull(i.endColumn,r.endColumn);n=!0,e[s]=new ye(d,l,c,a),e.splice(o,1);break}}else if(i.startColumn===r.startColumn&&i.endColumn===r.endColumn&&i.touches(r)){const{startColumn:l,endColumn:a}=i,d=ye.minOrNull(i.startRow,r.startRow),c=ye.maxOrNull(i.endRow,r.endRow);n=!0,e[s]=new ye(l,d,a,c),e.splice(o,1);break}}}}return e}static isAxisRangeTouching(t,e,n,s){return t==null?e==null||n==null?!0:n<=e+1:e==null?s==null?!0:s>=t-1:n==null?s==null?!0:t<=s+1:s==null?e>=n-1:n>=t-1?n<=e+1:s>=t-1}static rangeArraysEqual(t,e){if(t===e)return!0;if(t==null||e==null||t.length!==e.length)return!1;for(let n=0;n<t.length;n+=1)if(!t[n].equals(e[n]))return!1;return!0}static intersection(t,e){if(t.equals(e))return t;let{startColumn:n,startRow:s,endColumn:i,endRow:o}=t;return n=n!=null&&e.startColumn!=null?Math.max(n,e.startColumn):n!=null?n:e.startColumn,i=i!=null&&e.endColumn!=null?Math.min(i,e.endColumn):i!=null?i:e.endColumn,s=s!=null&&e.startRow!=null?Math.max(s,e.startRow):s!=null?s:e.startRow,o=o!=null&&e.endRow!=null?Math.min(o,e.endRow):o!=null?o:e.endRow,n!=null&&n>(i!=null?i:-1)||s!=null&&s>(o!=null?o:-1)?null:new ye(n,s,i,o)}static subtractFromRange(t,e){const n=[],s=ye.intersection(t,e);return s==null?[t]:(s.startRow!=null&&(t.startRow==null||t.startRow<s.startRow)&&n.push(new ye(t.startColumn,t.startRow,t.endColumn,s.startRow-1)),s.startColumn!=null&&(t.startColumn==null||t.startColumn<s.startColumn)&&n.push(new ye(t.startColumn,s.startRow,s.startColumn-1,s.endRow)),s.endColumn!=null&&(t.endColumn==null||t.endColumn>s.endColumn)&&n.push(new ye(s.endColumn+1,s.startRow,t.endColumn,s.endRow)),s.endRow!=null&&(t.endRow==null||t.endRow>s.endRow)&&n.push(new ye(t.startColumn,s.endRow+1,t.endColumn,t.endRow)),n)}static subtractFromRanges(t,e){const n=[];for(let s=0;s<t.length;s+=1)n.push(...ye.subtractFromRange(t[s],e));return n}static subtractRangesFromRanges(t,e){if(e==null||e.length===0)return t;let n=[...t];for(let s=0;s<e.length;s+=1)n=ye.subtractFromRanges(n,e[s]);return n}static isBounded(t){return t.startRow!=null&&t.startColumn!=null&&t.endRow!=null&&t.endColumn!=null}static boundedRange(t,e,n){var s,i,o,r;return ye.isBounded(t)?t:new ye((s=t.startColumn)!=null?s:0,(i=t.startRow)!=null?i:0,(o=t.endColumn)!=null?o:e-1,(r=t.endRow)!=null?r:n-1)}static boundedRanges(t,e,n){return t.map(s=>ye.boundedRange(s,e,n))}static offset(t,e,n){return new ye(t.startColumn!=null?t.startColumn+e:null,t.startRow!=null?t.startRow+n:null,t.endColumn!=null?t.endColumn+e:null,t.endRow!=null?t.endRow+n:null)}static nextCell(t,e=null,n=null,s=ye.SELECTION_DIRECTION.DOWN){if(t.length===0)return null;let i=-1;if(e!=null&&n!=null&&(i=t.findIndex(o=>o.containsCell(e,n)),i>=0)){const r=t[i].nextCell(e,n,s);if(r!=null)return r}switch(s){case ye.SELECTION_DIRECTION.DOWN:case ye.SELECTION_DIRECTION.RIGHT:{const o=i<t.length-1?i+1:0;return t[o].startCell(s)}case ye.SELECTION_DIRECTION.LEFT:case ye.SELECTION_DIRECTION.UP:{const o=i>0?i-1:t.length-1;return t[o].startCell(s)}default:throw new Error(`Invalid direction: ${s}`)}}static cellCount(t){return t.reduce((e,n)=>{var s,i,o,r;return e+(((s=n.endRow)!=null?s:NaN)-((i=n.startRow)!=null?i:NaN)+1)*(((o=n.endColumn)!=null?o:NaN)-((r=n.startColumn)!=null?r:NaN)+1)},0)}static rowCount(t){return t.reduce((e,n)=>{var s,i;return e+((s=n.endRow)!=null?s:NaN)-((i=n.startRow)!=null?i:NaN)+1},0)}static columnCount(t){return t.reduce((e,n)=>{var s,i;return e+((s=n.endColumn)!=null?s:NaN)-((i=n.startColumn)!=null?i:NaN)+1},0)}static containsCell(t,e,n){for(let s=0;s<t.length;s+=1)if(t[s].containsCell(e,n))return!0;return!1}static forEachCell(t,e,n=ye.SELECTION_DIRECTION.RIGHT){for(let s=0;s<t.length;s+=1)t[s].forEach(e,n)}constructor(t,e,n,s){this.startColumn=t,this.startRow=e,this.endColumn=n,this.endRow=s}equals(t){return this.startColumn===t.startColumn&&this.startRow===t.startRow&&this.endColumn===t.endColumn&&this.endRow===t.endRow}contains(t){return(this.startColumn==null||t.startColumn!=null&&this.startColumn<=t.startColumn)&&(this.startRow==null||t.startRow!=null&&this.startRow<=t.startRow)&&(this.endColumn==null||t.endColumn!=null&&this.endColumn>=t.endColumn)&&(this.endRow==null||t.endRow!=null&&this.endRow>=t.endRow)}containsCell(t,e){return t==null||e==null?!1:(this.startColumn==null||this.startColumn<=t)&&(this.endColumn==null||this.endColumn>=t)&&(this.startRow==null||this.startRow<=e)&&(this.endRow==null||this.endRow>=e)}touches(t){return ye.isAxisRangeTouching(this.startRow,this.endRow,t.startRow,t.endRow)&&ye.isAxisRangeTouching(this.startColumn,this.endColumn,t.startColumn,t.endColumn)}subtract(t){return ye.subtractFromRange(this,t)}startCell(t=ye.SELECTION_DIRECTION.DOWN){if(!ye.isBounded(this))throw new Error("Cannot get the startCell of an unbounded range");switch(t){case ye.SELECTION_DIRECTION.DOWN:case ye.SELECTION_DIRECTION.RIGHT:return{column:this.startColumn,row:this.startRow};case ye.SELECTION_DIRECTION.LEFT:case ye.SELECTION_DIRECTION.UP:return{column:this.endColumn,row:this.endRow};default:throw new Error(`Invalid direction: ${t}`)}}nextCell(t,e,n){if(!ye.isBounded(this))throw new Error("Bounded range required");if(t==null||e==null)throw new Error("Require a non-null cursor");const{startColumn:s,endColumn:i,startRow:o,endRow:r}=this;switch(n){case ye.SELECTION_DIRECTION.DOWN:if(e<r)return{column:t,row:Math.max(e+1,o)};if(t<i)return{column:Math.max(t+1,s),row:o};break;case ye.SELECTION_DIRECTION.UP:if(e>o)return{column:t,row:Math.min(e-1,r)};if(t>s)return{column:Math.min(t-1,i),row:r};break;case ye.SELECTION_DIRECTION.RIGHT:if(t<i)return{column:Math.max(t+1,s),row:e};if(e<r)return{column:s,row:Math.max(e+1,o)};break;case ye.SELECTION_DIRECTION.LEFT:if(t>s)return{column:Math.min(t-1,i),row:e};if(e>o)return{column:i,row:Math.min(e-1,r)};break;default:throw new Error(`Invalid direction: ${n}`)}return null}forEach(t,e=ye.SELECTION_DIRECTION.RIGHT){var o;let n=0,{column:s,row:i}=this.startCell(e);for(;s!=null&&i!=null;)t(s,i,n),n+=1,{column:s,row:i}=(o=this.nextCell(s,i,e))!=null?o:{}}};let re=ye;re.SELECTION_DIRECTION=Dn;function k0(t){return Array.isArray(t)&&t.length===2&&(t[0]===null||typeof t[0]=="number")&&(t[1]===null||typeof t[1]=="number")}function da(t){return k0(t)&&t[0]!=null&&t[1]!=null}const Fe=class{static getGridPointFromXY(t,e,n){const s=Fe.getColumnAtX(t,n),i=Fe.getRowAtY(e,n),o=Fe.getColumnHeaderDepthAtY(e,n);return{x:t,y:e,row:i,column:s,columnHeaderDepth:o}}static getCellInfoFromXY(t,e,n){const{row:s,column:i}=Fe.getGridPointFromXY(t,e,n),{visibleColumnWidths:o,visibleRowHeights:r,visibleColumnXs:l,visibleRowYs:a,modelColumns:d,modelRows:c}=n,u=s!==null?c.get(s):null,m=i!==null?d.get(i):null,p=i!==null?l.get(i):null,g=s!==null?a.get(s):null,f=i!==null?o.get(i):null,b=s!==null?r.get(s):null;return{row:s,column:i,modelRow:u!=null?u:null,modelColumn:m!=null?m:null,left:p!=null?p:null,top:g!=null?g:null,columnWidth:f!=null?f:null,rowHeight:b!=null?b:null}}static getColumnHeaderDepthAtY(t,e){const n=Fe.getRowAtY(t,e),{columnHeaderHeight:s,columnHeaderMaxDepth:i}=e;if(n===null&&t<=s*i)return At(i-Math.ceil(t/s),0,i-1)}static iterateFloatingStart(t,e,n){for(let s=0;s<t&&s<e;s+=1){const i=n(s);if(i!==void 0)return i}}static iterateFloatingEnd(t,e,n){for(let s=0;s<t&&e-(t-s)>=0;s+=1){const i=n(e-(t-s));if(i!==void 0)return i}}static iterateFloating(t,e,n,s){const i=Fe.iterateFloatingStart(t,n,s);return i!==void 0?i:Fe.iterateFloatingEnd(e,n,s)}static iterateAllItems(t,e,n,s,i,o){const r=Math.max(t,n),l=Math.min(e,i-s-1);let a=Fe.iterateFloating(n,s,i,o);if(a!==void 0)return a;for(let d=r;d<=l;d+=1)if(a=o(d),a!==void 0)return a}static isInItem(t,e,n,s){var r,l;const i=(r=e.get(t))!=null?r:0,o=(l=n.get(t))!=null?l:0;return i<=s&&s<=i+o}static getItemAtOffset(t,e,n,s,i,o,r,l=!1){const a=l?void 0:Fe.iterateFloating(n,s,e,d=>{if(Fe.isInItem(d,o,r,t))return d});if(!l&&a!==void 0)return a;for(let d=0;d<i.length;d+=1){const c=i[d];if(Fe.isInItem(c,o,r,t))return c}return null}static getColumnAtX(t,e,n=!1){const{columnCount:s,floatingLeftColumnCount:i,floatingRightColumnCount:o,visibleColumns:r,visibleColumnXs:l,visibleColumnWidths:a,gridX:d}=e;return t<d?null:this.getItemAtOffset(t-d,s,i,o,r,l,a,n)}static getRowAtY(t,e){const{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:i,visibleRows:o,visibleRowYs:r,visibleRowHeights:l,gridY:a}=e;return t<a?null:this.getItemAtOffset(t-a,i,n,s,o,r,l)}static getNextShownItem(t,e,n,s){let i=n.findIndex(o=>o===t)||0;for(i-=1;i!=null&&i>=0;){const o=n[i],r=e.get(o);if(r!=null&&s.get(r)!==0)return o;i-=1}return null}static getNextShownColumn(t,e){const{modelColumns:n,visibleColumns:s,userColumnWidths:i}=e;return Fe.getNextShownItem(t,n,s,i)}static getNextShownRow(t,e){const{modelRows:n,visibleRows:s,userRowHeights:i}=e;return Fe.getNextShownItem(t,n,s,i)}static getColumnSeparatorIndex(t,e,n,s){var C,w,T,y;const{rowHeaderWidth:i,columnHeaderHeight:o,floatingColumns:r,floatingLeftWidth:l,visibleColumns:a,visibleColumnXs:d,visibleColumnWidths:c,columnHeaderMaxDepth:u}=n,{allowColumnResize:m,headerSeparatorHandleSize:p}=s;if(u*o<e||!m||p<=0)return null;const g=t-i,f=p*.5;let b=!1;for(let E=r.length-1;E>=0;E-=1){const I=r[E],R=(C=d.get(I))!=null?C:0,F=(w=c.get(I))!=null?w:0,x=F===0;if(!b||!x){let U=R+F;x?U+=f:b&&(U-=f);const $=U-f,O=U+f;if($<=g&&g<=O)return I;b=x}}b=!1;for(let E=a.length-1;E>=0;E-=1){const I=a[E],R=(T=d.get(I))!=null?T:0,F=(y=c.get(I))!=null?y:0,x=F===0;if(R<l-F)return null;if(!b||!x){let U=R+F;x?U+=f:b&&(U-=f);const $=U-f,O=U+f;if($<=g&&g<=O)return I;b=x}}return null}static isItemHidden(t,e){return e.get(t)===0}static isColumnHidden(t,e){const{visibleColumnWidths:n}=e;return Fe.isItemHidden(t,n)}static isFloatingRow(t,e){if(t==null)return!1;const{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:i}=e;return t<n||t>=i-s}static isFloatingColumn(t,e){if(t==null)return!1;const{floatingLeftColumnCount:n,floatingRightColumnCount:s,columnCount:i}=e;return t<n||t>=i-s}static getHiddenItems(t,e,n){if(!Fe.isItemHidden(t,e))return[];const s=[t],i=n.findIndex(o=>o===t);for(let o=i-1;o>=0;o-=1){const r=n[o];if(!Fe.isItemHidden(r,e))break;s.push(r)}return s}static getHiddenColumns(t,e){const{visibleColumns:n,visibleColumnWidths:s}=e;return Fe.getHiddenItems(t,s,n)}static getRowSeparatorIndex(t,e,n,s){var g,f;const{rowHeaderWidth:i,columnHeaderHeight:o,visibleRows:r,visibleRowYs:l,visibleRowHeights:a}=n,{allowRowResize:d,headerSeparatorHandleSize:c}=s;if(i<t||!d||c<=0)return null;const u=e-o,m=c*.5;let p=!1;for(let b=r.length-1;b>=0;b-=1){const C=r[b],w=(g=l.get(C))!=null?g:0,T=(f=a.get(C))!=null?f:0,y=T===0;if(!p||!y){let E=w+T;y?E+=m:p&&(E-=m);const I=E-m,R=E+m;if(I<=u&&u<=R)return C;p=y}}return null}static isRowHidden(t,e){const{visibleRowHeights:n}=e;return Fe.isItemHidden(t,n)}static getHiddenRows(t,e){const{visibleRows:n,visibleRowHeights:s}=e;return Fe.getHiddenItems(t,s,n)}static moveItem(t,e,n){if(t===e)return n;const s=[...n],i=s[s.length-1];return i!=null&&!da(i.from)&&i.to===t?i.from===e?s.pop():s[s.length-1]={...i,to:e}:s.push({from:t,to:e}),s}static moveRange(t,e,n){if(t[0]===e)return n;const s=[...n],i=s[s.length-1];return i!=null&&da(i.from)&&i.from[1]-i.from[0]===t[1]-t[0]&&i.to===t[0]?i.from[0]===e?s.pop():s[s.length-1]={...i,to:e}:s.push({from:t,to:e}),s[s.length-1].from===s[s.length-1].to&&s.pop(),s}static applyItemMoves(t,e,n,s=!1){var o,r;let i=[[t,e]];for(let l=s?n.length-1:0;s?l>=0:l<n.length;s?l-=1:l+=1){const{from:a,to:d}=n[l];let c=1,u;da(a)?(c=a[1]-a[0]+1,[u]=a):u=a;const m=s?d:u,p=m+c-1,g=s?u:d,f=g-m,b=[];for(let C=0;C<i.length;C+=1){const w=(o=i[C][0])!=null?o:Number.NEGATIVE_INFINITY,T=(r=i[C][1])!=null?r:Number.POSITIVE_INFINITY;let y;const E=[[w,m-1],[m,p],[p+1,T]].map(([I,R])=>[Math.max(I,w),Math.min(R,T)]).filter(([I,R])=>I<=R).map(I=>{const[R,F]=I;return m<=R&&p>=F?(y=[R+f,F+f],y):p<R?[R-c,F-c]:I}).map(I=>{const[R,F]=I;return g>R&&g<=F?[[R,g-1],[g+c,F+c]]:I===y?[I]:g<=R?[[R+c,F+c]]:[I]}).flat();b.push(...E)}i=b.map(([C,w])=>[Number.isFinite(C)?C:null,Number.isFinite(w)?w:null])}return i}static translateRange(t,e,n,s){const i=Fe.applyItemMoves(t.startColumn,t.endColumn,e,s),o=Fe.applyItemMoves(t.startRow,t.endRow,n,s),r=[];for(let l=0;l<i.length;l+=1){const a=i[l];for(let d=0;d<o.length;d+=1){const c=o[d];r.push(new re(a[0],c[0],a[1],c[1]))}}return r}static getModelIndex(t,e){return Fe.applyItemMoves(t,t,e,!0)[0][0]}static getModelIndexes(t,e){return t.map(n=>Fe.getModelIndex(n,e))}static getModelRangeIndexes(t,e,n){return Fe.applyItemMoves(t,e,n,!0)}static getModelRange(t,e=[],n=[]){return Fe.translateRange(t,e,n,!0)}static getModelRanges(t,e=[],n=[]){const s=[];for(let i=0;i<t.length;i+=1)s.push(...Fe.getModelRange(t[i],e,n));return s}static getVisibleRangeIndexes(t,e,n){return Fe.applyItemMoves(t,e,n,!1)}static getVisibleRange(t,e=[],n=[]){return this.translateRange(t,e,n,!1)}static getVisibleRanges(t,e=[],n=[]){const s=[];for(let i=0;i<t.length;i+=1)s.push(...Fe.getVisibleRange(t[i],e,n));return s}static getVisibleIndex(t,e){return Fe.applyItemMoves(t,t,e)[0][0]}static getVisibleIndexes(t,e){return t.map(n=>Fe.getVisibleIndex(n,e))}static isMacPlatform(){const{platform:t}=window.navigator;return t.startsWith("Mac")}static getModifierKey(){return Fe.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(t){const e=Fe.getModifierKey();return t[e]}static checkColumnHidden(t,e){return e.get(t)===0}static checkAllColumnsHidden(t,e){return e.size===0?!1:t.every(n=>e.get(n)===0)}static getScrollDragBounds(t,e,n){const{gridX:s,gridY:i,width:o,height:r,floatingTopRowCount:l,floatingBottomRowCount:a,floatingLeftColumnCount:d,floatingRightColumnCount:c,floatingLeftWidth:u,floatingRightWidth:m,floatingTopHeight:p,floatingBottomHeight:g,columnCount:f,rowCount:b}=t;let C=s,w=i,T=o,y=r;return n!=null&&(n>d&&(C+=u),n<f-c&&(T-=m)),e!=null&&(e>l&&(w+=p),e<b-a&&(y-=g)),{x1:C,y1:w,x2:T,y2:y}}static getScrollDelta(t,e=1024,n=768,s=20,i=20){let{deltaX:o,deltaY:r}=t;return!Fe.isMacPlatform()&&t.shiftKey&&t.deltaX===0&&t.deltaY!==0&&(o=t.deltaY,r=t.deltaX),(t==null?void 0:t.deltaMode)===WheelEvent.DOM_DELTA_PAGE?(o*=e,r*=n):(t==null?void 0:t.deltaMode)===WheelEvent.DOM_DELTA_LINE&&(Fe.isMacPlatform()?(o=Math.round(o*s),r=Math.round(r*i)):(o=Math.round(o*this.PIXELS_PER_LINE),r=Math.round(r*this.PIXELS_PER_LINE))),{deltaX:o,deltaY:r}}static compareRanges(t,e){return t[0]==null||t[1]==null||e[0]==null||e[1]==null?0:t[0]!==e[0]?t[0]-e[0]:t[1]-e[1]}static mergeSortedRanges(t){const e=[];for(let n=0;n<t.length;n+=1){const s=t[n],i=s[0],o=s[1];n===0?e.push([i,o]):i-1<=e[e.length-1][1]?e[e.length-1][1]=Math.max(e[e.length-1][1],o):e.push([i,o])}return e}};let G=Fe;G.PIXELS_PER_LINE=100/3;function B(t,e,n=void 0){var i;const s=(i=t.get(e))!=null?i:n;if(s!==void 0)return s;throw new Error(`Missing value for key ${e}`)}function wr(t,e=qo.CACHE_SIZE,n=Math.floor(e/2)){if(t.size>e){const s=t.keys();for(;t.size>n;)t.delete(s.next().value)}}function bh(t,e,n,s,i){const o=new Map;let r=0;for(let l=0;l<t&&l<n;l+=1)o.set(l,r),r+=B(i,l);r=s;for(let l=0;l<e&&n-l-1>=0;l+=1)r-=B(i,n-l-1),o.set(n-l-1,r);return o}const jm=class{constructor({userColumnWidths:t=new Map,userRowHeights:e=new Map,calculatedColumnWidths:n=new Map,calculatedRowHeights:s=new Map,fontWidths:i=new Map,modelRows:o=new Map,modelColumns:r=new Map,movedRows:l=[],movedColumns:a=[]}={}){this.userColumnWidths=t,this.userRowHeights=e,this.calculatedRowHeights=s,this.calculatedColumnWidths=n,this.fontWidths=i,this.modelRows=o,this.modelColumns=r,this.movedRows=l,this.movedColumns=a}getMetrics(t){const{left:e,top:n,leftOffset:s,topOffset:i,width:o,height:r,theme:l,model:a,movedRows:d,movedColumns:c,draggingColumn:u}=t,{rowHeight:m,rowHeaderWidth:p,rowFooterWidth:g,columnWidth:f,columnHeaderHeight:b,minScrollHandleSize:C,scrollBarSize:w}=l;d!==this.movedRows&&(this.movedRows=d,this.modelRows.clear()),c!==this.movedColumns&&(this.movedColumns=c,this.modelColumns.clear());const{columnCount:T,rowCount:y,floatingTopRowCount:E,floatingBottomRowCount:I,floatingLeftColumnCount:R,floatingRightColumnCount:F,columnHeaderMaxDepth:x}=a,U=this.getFirstRow(t),$=this.getFirstColumn(t),O=this.getGridX(t),H=this.getGridY(t),L=gt(a)&&a.hasExpandableRows?this.calculateTreePaddingX(t):0,N=0;let _=this.getVisibleRowHeights(t),k=this.getVisibleColumnWidths(t,$,L);const V=Array.from(_.keys()),W=Array.from(k.keys());_=new Map([..._,...this.getFloatingRowHeights(t)]),k=new Map([...k,...this.getFloatingColumnWidths(t)]);let j=this.getVisibleColumnXs(k,W,s),ee=this.getVisibleRowYs(_,V,i);const ve=V.length>0?V[V.length-1]:n,le=W.length>0?W[W.length-1]:e,Se=this.getBottomViewport(t,V,ee,_),Le=this.getRightViewport(t,W,j,k),J=this.getFloatingTopHeight(t,_),pe=this.getFloatingBottomHeight(t,_),fe=this.getFloatingLeftWidth(t,k),xe=this.getFloatingRightWidth(t,k),ke=Array.from(k.values()),hn=Array.from(_.values()),Xn=ke.reduce((ut,Si)=>ut+Si,0)-s,Sn=hn.reduce((ut,Si)=>ut+Si,0)-i,Ct=this.getLastLeft(t,null,o-O-w-g),Re=this.getLastTop(t,null,r-H-w-pe),st=s+Xn+g,it=i+Sn,Mt=o-O,Yt=r-H,Xt=Ct>0||st>Mt,Nt=Xt?w:0,On=Re>0||it>Yt-Nt,Ht=On?w:0,wn=o-p-Ht,Ps=r-b-Nt,zl=p,Wl=b,Gl=T===1?wn/st:(T-Ct)/T,Zo=y===1?Ps/it:(y-Re)/y,Jo=Xt?At(wn*Gl,C,wn-1):0,er=On?At(Ps*Zo,C,Ps-1):0,tr=B(k,e,0),nr=B(_,n,0),sr=tr>0?s/tr:0,ir=nr>0?i/nr:0,Kl=T===1?s/(st-Mt):(e+sr)/Ct,ql=y===1?i/(it-Yt):(n+ir)/Re,Hs=Xt?Kl*(wn-Jo):0,Yl=On?ql*(Ps-er):0;let bi=[];(E>0||I>0)&&(bi=[...Array(E).keys(),...[...Array(I).keys()].map(ut=>y-ut-1)],ee=new Map([...ee,...this.getFloatingRowYs(t,_,Math.floor(r-H-Nt))]));let oo=[];(R>0||F>0)&&(oo=[...Array(R).keys(),...[...Array(F).keys()].map(ut=>T-ut-1)],j=new Map([...j,...this.getFloatingColumnXs(t,k,Math.floor(o-O-Ht))]));const or=[];if(u)for(let ut=u.range[0];ut<=u.range[1];ut+=1)or.push(ut),k.has(ut)||k.set(ut,this.getVisibleColumnWidth(ut,t)),j.has(ut)||j.set(ut,0);const rr=V.concat(bi),ro=W.concat(oo).concat(or),lo=this.getModelRows(rr,t),Xl=this.getModelColumns(ro,t),jl=this.getVisibleRowTreeBoxes(_,lo,t),lr=this.getTopVisible(t,ee,_,V),Ql=this.getLeftVisible(t,j,k,W),ar=Re>0?this.getBottomVisible(t,ee,_,V,H):ve,dr=Ct>0?this.getRightVisible(t,j,k,W,O):le,{fontWidths:cr,userColumnWidths:hr,userRowHeights:ur,calculatedRowHeights:Zl,calculatedColumnWidths:Jl}=this;return{rowHeight:m,rowHeaderWidth:p,rowFooterWidth:g,rowCount:y,columnWidth:f,columnCount:T,columnHeaderHeight:b,floatingTopRowCount:E,floatingBottomRowCount:I,floatingLeftColumnCount:R,floatingRightColumnCount:F,gridX:O,gridY:H,firstRow:U,firstColumn:$,treePaddingX:L,treePaddingY:N,left:e,top:n,bottom:ve,right:le,topOffset:i,leftOffset:s,topVisible:lr,leftVisible:Ql,bottomVisible:ar,rightVisible:dr,bottomViewport:Se,rightViewport:Le,width:o,height:r,maxX:Xn,maxY:Sn,lastLeft:Ct,lastTop:Re,barHeight:Ps,barTop:Wl,barWidth:wn,barLeft:zl,handleHeight:er,handleWidth:Jo,hasHorizontalBar:Xt,hasVerticalBar:On,verticalBarWidth:Ht,horizontalBarHeight:Nt,scrollX:Hs,scrollY:Yl,scrollableContentWidth:st,scrollableContentHeight:it,scrollableViewportWidth:Mt,scrollableViewportHeight:Yt,visibleRows:V,visibleColumns:W,floatingRows:bi,floatingColumns:oo,allRows:rr,allColumns:ro,visibleRowHeights:_,visibleColumnWidths:k,floatingTopHeight:J,floatingBottomHeight:pe,floatingLeftWidth:fe,floatingRightWidth:xe,visibleRowYs:ee,visibleColumnXs:j,visibleRowTreeBoxes:jl,modelRows:lo,modelColumns:Xl,movedRows:d,movedColumns:c,fontWidths:cr,userColumnWidths:hr,userRowHeights:ur,calculatedRowHeights:Zl,calculatedColumnWidths:Jl,columnHeaderMaxDepth:x}}getGridX(t){const{theme:e}=t,{rowHeaderWidth:n}=e;return n}getGridY(t){const{theme:e,model:n}=t,{columnHeaderHeight:s}=e,{columnHeaderMaxDepth:i}=n;return i*s}getVisibleHeight(t,e=this.getFloatingRowHeights(t)){const{height:n,theme:s}=t,{scrollBarSize:i}=s,o=this.getGridY(t),r=this.getFloatingBottomHeight(t,e),l=this.getFloatingTopHeight(t,e);return n-r-l-o-i}getVisibleWidth(t,e=this.getFloatingColumnWidths(t)){const{width:n,theme:s}=t,{scrollBarSize:i,rowFooterWidth:o}=s,r=this.getGridX(t),l=this.getFloatingRightWidth(t,e),a=this.getFloatingLeftWidth(t,e);return n-a-l-r-i-o}getFirstIndex(t,e,n){const s=t.size+1;for(let i=0;i<s;i+=1){const o=e(i,n);if(t.get(o)!==0)return i}return 0}getFirstColumn(t){return this.getFirstIndex(this.userColumnWidths,this.getModelColumn.bind(this),t)}getFirstRow(t){return this.getFirstIndex(this.userRowHeights,this.getModelRow.bind(this),t)}getLastLeft(t,e=null,n=this.getVisibleWidth(t)){const{model:s}=t,{columnCount:i}=s;let o=i-1;e!=null&&(o=e);let r=0;for(;o>=0;){if(r+=this.getVisibleColumnWidth(o,t),r>=n)return Math.min(o+1,i-1);o-=1}return 0}getLastTop(t,e=null,n=this.getVisibleHeight(t)){const{model:s}=t,{rowCount:i,floatingBottomRowCount:o}=s;let r=Math.max(0,i-o-1);e!=null&&(r=e);let l=0;for(;r>0;){if(l+=this.getVisibleRowHeight(r,t),l>=n)return Math.min(r+1,i-1);r-=1}return 0}getTopForTopVisible(t,e){const n=this.getFloatingTopHeight(t);let s=e,i=0;for(;s>0&&i<n;)s-=1,i+=this.getVisibleRowHeight(s,t);return s}getTopForBottomVisible(t,e){const{height:n}=t,s=this.getGridY(t),i=this.getFloatingBottomHeight(t),o=n-s-i;return this.getLastTop(t,e,o)}getLeftForLeftVisible(t,e){const n=this.getFloatingLeftWidth(t);let s=e,i=0;for(;s>0&&i<n;)s-=1,i+=this.getVisibleColumnWidth(s,t);return s}getLeftForRightVisible(t,e){const{width:n}=t,s=this.getGridX(t),i=this.getFloatingRightWidth(t),o=n-s-i;return this.getLastLeft(t,e,o)}getFloatingRowHeights(t){const{model:e}=t,{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:i}=e,o=new Map;for(let r=0;r<n&&r<i;r+=1)o.set(r,this.getVisibleRowHeight(r,t));for(let r=0;r<s&&i-r-1>=0;r+=1){const l=i-r-1;o.set(l,this.getVisibleRowHeight(l,t))}return o}getVisibleRowHeights(t){const{top:e,topOffset:n,height:s,model:i}=t;let o=0,r=e;const l=new Map,{rowCount:a}=i;for(;o<s+n&&r<a;){const d=this.getVisibleRowHeight(r,t);l.set(r,d),o+=d,r+=1}return l}getFloatingColumnWidths(t,e=this.getFirstColumn(t),n=this.calculateTreePaddingX(t)){const{model:s}=t,{columnCount:i,floatingLeftColumnCount:o,floatingRightColumnCount:r}=s,l=new Map;for(let a=0;a<o&&a<i;a+=1)l.set(a,this.getVisibleColumnWidth(a,t,e,n));for(let a=0;a<r&&i-a-1>=0;a+=1){const d=i-a-1;l.set(d,this.getVisibleColumnWidth(d,t,e,n))}return l}getVisibleColumnWidths(t,e=this.getFirstColumn(t),n=this.calculateTreePaddingX(t)){const{left:s,leftOffset:i,width:o,model:r}=t;let l=0,a=s;const d=new Map,{columnCount:c}=r;for(;l<o+i&&a<c;){const u=this.getVisibleColumnWidth(a,t,e,n);d.set(a,u),l+=u,a+=1}return d}getFloatingColumnXs(t,e,n){const{model:s}=t,{columnCount:i,floatingLeftColumnCount:o,floatingRightColumnCount:r}=s;return bh(o,r,i,n,e)}getVisibleColumnXs(t,e,n){const s=new Map;let i=-n;for(let o=0;o<e.length;o+=1){const r=e[o],l=B(t,r);s.set(r,i),i+=l}return s}getFloatingRowYs(t,e,n){const{model:s}=t,{floatingTopRowCount:i,floatingBottomRowCount:o,rowCount:r}=s;return bh(i,o,r,n,e)}getVisibleRowYs(t,e,n){const s=new Map;let i=-n;for(let o=0;o<e.length;o+=1){const r=e[o],l=B(t,r);s.set(r,i),i+=l}return s}getVisibleRowTreeBoxes(t,e,n){const s=new Map,{model:i,theme:o}=n,{treeDepthIndent:r,treeHorizontalPadding:l}=o;return gt(i)&&i.hasExpandableRows&&t.forEach((a,d)=>{const c=B(e,d);if(i.isRowExpandable(c)){const u=i.depthForRow(c),m=u*r+l,p=(u+1)*r+l,g=0,f=a;s.set(d,{x1:m,y1:g,x2:p,y2:f})}}),s}getFloatingLeftWidth(t,e=this.getFloatingColumnWidths(t)){const{model:n}=t,{floatingLeftColumnCount:s}=n;let i=0;for(let o=0;o<s;o+=1)i+=B(e,o);return i}getFloatingRightWidth(t,e=this.getFloatingColumnWidths(t)){const{model:n}=t,{floatingRightColumnCount:s,columnCount:i}=n;let o=0;for(let r=0;r<s;r+=1)o+=B(e,i-r-1);return o}getFloatingTopHeight(t,e=this.getFloatingRowHeights(t)){const{model:n}=t,{floatingTopRowCount:s}=n;let i=0;for(let o=0;o<s;o+=1)i+=B(e,o);return i}getFloatingBottomHeight(t,e=this.getFloatingRowHeights(t)){const{model:n}=t,{floatingBottomRowCount:s,rowCount:i}=n;let o=0;for(let r=0;r<s;r+=1)o+=B(e,i-r-1);return o}getTopVisible(t,e,n,s){const i=this.getFloatingTopHeight(t,n);for(let o=0;o<s.length;o+=1){const r=s[o];if(B(e,r)>=i)return r}return 0}getLeftVisible(t,e,n,s){const i=this.getFloatingLeftWidth(t,n);for(let o=0;o<s.length;o+=1){const r=s[o];if(B(e,r)>=i)return r}return 0}getBottomVisible(t,e,n,s,i){const{height:o,theme:r}=t,{scrollBarSize:l}=r,a=this.getFloatingBottomHeight(t,n),d=o-i-l-a;for(let c=s.length-1;c>=0;c-=1){const u=s[c],m=B(e,u),p=B(n,u);if(m+p<=d)return u}return 0}getRightVisible(t,e,n,s,i){const{width:o,theme:r}=t,{scrollBarSize:l}=r,a=this.getFloatingRightWidth(t,n),d=o-i-l-a;for(let c=s.length-1;c>=0;c-=1){const u=s[c],m=B(e,u),p=B(n,u);if(m+p<=d)return u}return 0}getBottomViewport(t,e,n,s){const{height:i,theme:o}=t,{rowHeight:r}=o;return this.getLastIndexViewport(e,n,s,i,r)}getRightViewport(t,e,n,s){const{width:i,theme:o}=t,{columnWidth:r}=o;return this.getLastIndexViewport(e,n,s,i,r)}getLastIndexViewport(t,e,n,s,i){let o=0,r=0;return t.length>0&&(o=t[t.length-1],r=B(e,o)+B(n,o)),r<s&&(o+=Math.ceil((s-r)/i)),o}getVisibleItemSize(t,e,n){var i;const s=n();return(i=e.get(t))!=null?i:s}getVisibleRowHeight(t,e){const n=this.getModelRow(t,e);return this.getVisibleItemSize(n,this.userRowHeights,()=>this.calculateRowHeight(t,n,e))}getVisibleColumnWidth(t,e,n=this.getFirstColumn(e),s=this.calculateTreePaddingX(e)){const i=this.getModelColumn(t,e);return this.getVisibleItemSize(i,this.userColumnWidths,()=>this.calculateColumnWidth(t,i,e,n,s))}getModelRows(t,e){const n=new Map;for(let s=0;s<t.length;s+=1){const i=t[s],o=this.getModelRow(i,e);n.set(i,o)}return n}getModelRow(t,e){if(this.modelRows.has(t))return B(this.modelRows,t);const{movedRows:n}=e,s=G.getModelIndex(t,n);return this.modelRows.set(t,s),s}getModelColumns(t,e){const n=new Map;for(let s=0;s<t.length;s+=1){const i=t[s],o=this.getModelColumn(i,e);n.set(i,o)}return n}getModelColumn(t,e){if(this.modelColumns.has(t))return B(this.modelColumns,t);const{movedColumns:s}=e,i=G.getModelIndex(t,s);return this.modelColumns.set(t,i),i}calculateRowHeight(t,e,n){const{theme:s}=n,{autoSizeRows:i,rowHeight:o}=s;if(!i)return o;const r=this.calculatedRowHeights.get(e);return r!=null?r:(this.calculatedRowHeights.set(e,Math.ceil(o)),wr(this.calculatedRowHeights),o)}calculateColumnWidth(t,e,n,s=this.getFirstColumn(n),i=this.calculateTreePaddingX(n)){const{theme:o}=n,{autoSizeColumns:r,minColumnWidth:l}=o;if(!r){const{columnWidth:m}=o;return m}const a=this.calculateColumnHeaderWidth(e,n),d=this.calculateColumnDataWidth(e,n),c=this.calculatedColumnWidths.get(e);let u=Math.ceil(Math.max(a,d));return u=Math.max(l,u),c!=null&&c>u?u=c:(this.calculatedColumnWidths.set(e,u),wr(this.calculatedColumnWidths)),t===s&&(u+=i),u}calculateColumnHeaderWidth(t,e){const{model:n,theme:s}=e,{headerFont:i,headerHorizontalPadding:o}=s,r=n.textForColumnHeader(t,0);if(r!==void 0&&r!==""){const l=this.getWidthForFont(i,e);return r.length*l+o*2}return o*2}calculateColumnDataWidth(t,e){const{top:n,height:s,width:i,model:o,theme:r}=e,{floatingTopRowCount:l,floatingBottomRowCount:a,rowCount:d}=o,{font:c,cellHorizontalPadding:u,rowHeight:m,rowHeaderWidth:p,rowFooterWidth:g,scrollBarSize:f}=r;let b=0;const C=this.getWidthForFont(c,e),w=s/m,T=Math.ceil(n+w);return G.iterateAllItems(n,T,l,a,d,y=>{const E=this.getModelRow(y,e),I=o.textForCell(t,E);if(I){const R=u*2;b=Math.max(b,I.length*C+R)}}),b=Math.max(Math.min(b,(i-p-f-g)*jm.MAX_COLUMN_WIDTH),u*2),b}calculateTreePaddingX(t){const{top:e,height:n,model:s,theme:i}=t,{rowHeight:o,treeDepthIndent:r}=i;if(!gt(s)||!s.hasExpandableRows)return 0;let l=0;const a=n/o,d=Math.ceil(e+a);for(let c=e;c<=d;c+=1){const u=this.getModelRow(c,t),m=s.depthForRow(u);l=Math.max(l,r*(m+1))}return l}getWidthForFont(t,e){if(this.fontWidths.has(t))return B(this.fontWidths,t);const{context:n}=e;n.font=t;const s=n.measureText("8"),{width:i}=s;return this.fontWidths.set(t,i),this.fontWidths.set(n.font,i),i}setColumnWidth(t,e){const n=new Map(this.userColumnWidths);n.set(t,Math.ceil(e)),wr(n),this.userColumnWidths=n}resetColumnWidth(t){const e=new Map(this.userColumnWidths);e.delete(t),this.userColumnWidths=e}setRowHeight(t,e){const n=new Map(this.userRowHeights);n.set(t,Math.ceil(e)),wr(n),this.userRowHeights=n}resetRowHeight(t){const e=new Map(this.userRowHeights);e.delete(t),this.userRowHeights=e,this.calculatedRowHeights.delete(t)}};let qo=jm;qo.CACHE_SIZE=1e4;qo.MAX_COLUMN_WIDTH=.8;const O0=Object.freeze({allowColumnResize:!0,allowRowResize:!0,autoSelectRow:!1,autoSelectColumn:!1,autoSizeColumns:!0,autoSizeRows:!0,backgroundColor:"#000000",black:"#000000",white:"#ffffff",cellHorizontalPadding:5,headerHorizontalPadding:5,font:"12px Arial, sans serif",gridColumnColor:"#8f8f8f66",gridRowColor:"#8f8f8f66",headerBackgroundColor:"#222222",headerSeparatorColor:"#000000",headerSeparatorHoverColor:"#888888",headerSeparatorHandleSize:5,headerHiddenSeparatorSize:5,headerHiddenSeparatorHoverColor:"#8888FF",headerColor:"#d5d5d5",headerFont:"10px Arial, sans serif",columnHoverBackgroundColor:"#444444",selectedColumnHoverBackgroundColor:"#494949",rowBackgroundColors:"#333333 #222222",rowHoverBackgroundColor:"#444444",selectedRowHoverBackgroundColor:"#494949",minScrollHandleSize:50,scrollBarBackgroundColor:"#111111",scrollBarHoverBackgroundColor:"#333333",scrollBarCasingColor:"#000000",scrollBarCornerColor:"#000000",scrollBarColor:"#555555",scrollBarHoverColor:"#888888",scrollBarActiveColor:"#AAAAAA",scrollBarSize:12,scrollBarHoverSize:16,scrollBarCasingWidth:1,scrollSnapToColumn:!1,scrollSnapToRow:!1,selectionColor:"#4286f433",selectionOutlineColor:"#4286f4",selectionOutlineCasingColor:"#222222",scrollBarSelectionTick:!0,scrollBarSelectionTickColor:"#4286f433",scrollBarActiveSelectionTickColor:"#4286f480",shadowBlur:8,shadowColor:"#000000",textColor:"#ffffff",maxDepth:6,treeDepthIndent:10,treeHorizontalPadding:5,treeLineColor:"#888888",treeMarkerColor:"#cccccc",treeMarkerHoverColor:"#ffffff",rowHeight:20,columnWidth:100,minRowHeight:20,minColumnWidth:55,columnHeaderHeight:20,rowHeaderWidth:30,rowFooterWidth:0,headerResizeSnapThreshold:10,headerResizeHiddenSnapThreshold:8,allowColumnReorder:!0,allowRowReorder:!0,reorderOffset:2,floatingGridColumnColor:"#8f8f8f66",floatingGridRowColor:"#8f8f8f66",floatingRowBackgroundColors:"#393939 #292929",floatingDividerOuterColor:"#000000",floatingDividerInnerColor:"#cccccc"}),rn=(t,e)=>{let n=!1;const s=Te(t,{...e,dispose:()=>{n||(n=!0,s.clear(),n=!1)}});return s};function L0(t,e,n=6){const s=Ta.hex.lab.raw(t);return s[0]=Math.max(s[0]-s[0]/n*e,0),`#${Ta.lab.hex(s)}`}function A0(t,e){const[n,s,i]=Ta.hex.rgb(t);return`rgba(${n}, ${s}, ${i}, ${e})`}const Sh={colorWithAlpha:A0,darkenForDepth:L0};class Et{constructor(e=5e3){this.cursor=null,this.order=e}onDown(e,n,s){return!1}onMove(e,n,s){return!1}onDrag(e,n,s){return!1}onLeave(e,n,s){return!1}onClick(e,n,s){return!1}onContextMenu(e,n,s){return!1}onDoubleClick(e,n,s){return!1}onUp(e,n,s){return!1}onWheel(e,n,s){return!1}}class Qm extends Et{constructor(){super(...arguments),this.resizingItems=[],this.hiddenItems=[],this.targetSizes=new Map,this.dragOffset=0}onDown(e,n){const{metrics:s}=n,{model:i}=n.props,o=n.getTheme();if(!s)throw new Error("metrics not set");const r=this.getSeparator(e,s,i,o);if(r!=null){const l=r.index;return this.dragOffset=0,this.draggingIndex=l,this.resizingItems=[l],this.hiddenItems=this.getHiddenItems(l,s).reverse(),this.targetSizes.clear(),this.addTargetSize(s,l),this.updateCursor(s,l),this.updateSeparator(n,r),!0}return!1}onMove(e,n){const{metrics:s}=n,{model:i}=n.props,o=n.getTheme();if(!s)throw new Error("metrics not set");const r=this.getSeparator(e,s,i,o);return r!=null?(this.updateCursor(s,r.index),!0):!1}onDrag(e,n){var f;if(this.draggingIndex==null)return!1;const s=e[this.pointProperty],{metricCalculator:i,metrics:o}=n;if(!o)throw new Error("metrics not set");const r=n.getTheme(),l=o[this.visibleOffsetProperty],a=o[this.marginProperty],d=o[this.calculatedSizesProperty],c=o[this.modelIndexesProperty],u=o[this.firstIndexProperty],m=o[this.treePaddingProperty],p=new Map;let g=this.resizingItems[this.resizingItems.length-1];for(;g!=null;){const b=B(l,g),C=s-a-b-this.dragOffset,w=B(c,g),T=this.targetSizes.get(w),y=this.resizingItems.length>1,E=this.hiddenItems.indexOf(g);let I=B(d,w);g===u&&(I+=m);let R=C;Math.abs(C-I)<=r.headerResizeSnapThreshold?R=null:T!==void 0&&C>T&&(y&&E!==0||E>0)?R=T:C<=r.headerResizeHiddenSnapThreshold&&(R=0),R!==I?p.set(w,R):p.set(w,null),C<-r.headerResizeSnapThreshold&&R===0?E>=0&&y?(this.resizingItems.pop(),this.removeTargetSize(o,g),g=this.resizingItems[this.resizingItems.length-1],this.dragOffset-=(f=this.targetSizes.get(B(c,g)))!=null?f:0):(g=this.getNextShownItem(g,o),g!==null&&(this.resizingItems.push(g),this.addTargetSize(o,g))):T!==void 0&&C>T+r.headerResizeSnapThreshold&&R===T?E>0?(this.dragOffset+=R,g=this.hiddenItems[E-1],this.resizingItems.push(g),this.addTargetSize(o,g)):y?(this.resizingItems.pop(),this.removeTargetSize(o,g),g=this.resizingItems[this.resizingItems.length-1]):g=null:g=null}return p.forEach((b,C)=>{b!==null?this.setSize(i,C,b):this.resetSize(i,C)}),this.updateCursor(o,this.draggingIndex),!0}onUp(e,n){return this.draggingIndex!=null&&(this.draggingIndex=void 0,this.resizingItems=[],this.hiddenItems=[],this.targetSizes.clear(),this.updateSeparator(n,null)),!1}onDoubleClick(e,n){const{metrics:s,metricCalculator:i}=n,{model:o}=n.props,r=n.getTheme();if(!s)throw new Error("metrics not set");const l=this.getSeparator(e,s,o,r);if(l!=null){const a=s[this.modelIndexesProperty],d=B(a,l.index);return this.resetSize(i,d),n.forceUpdate(),!0}return!1}updateCursor(e,n){const s=e[this.visibleSizesProperty];B(s,n)===0?this.cursor=this.hiddenCursor:this.cursor=this.defaultCursor}addTargetSize(e,n){const s=e[this.modelIndexesProperty],i=e[this.userSizesProperty],o=e[this.calculatedSizesProperty],r=n===0?e[this.treePaddingProperty]:0,l=B(s,n);let a=i.get(l);(a==null||a===0)&&(a=B(o,l)+r),this.targetSizes.set(l,a)}removeTargetSize(e,n){const s=e[this.modelIndexesProperty],i=B(s,n);this.targetSizes.delete(i)}}class Fl extends Qm{constructor(){super(...arguments),this.hiddenCursor="e-resize",this.defaultCursor="col-resize",this.pointProperty="x",this.userSizesProperty="userColumnWidths",this.visibleOffsetProperty="visibleColumnXs",this.visibleSizesProperty="visibleColumnWidths",this.marginProperty="rowHeaderWidth",this.calculatedSizesProperty="calculatedColumnWidths",this.modelIndexesProperty="modelColumns",this.firstIndexProperty="firstColumn",this.treePaddingProperty="treePaddingX",this.getHiddenItems=G.getHiddenColumns,this.getNextShownItem=G.getNextShownColumn,this.getSeparator=Fl.getColumnSeparator}static getColumnSeparator(e,n,s,i){if(!i.allowColumnResize)return null;const{x:o,y:r,columnHeaderDepth:l}=e,{modelColumns:a}=n,d=G.getColumnSeparatorIndex(o,r,n,i);return d==null||l==null||l>0?null:a.get(d)!=null?{index:d,depth:0}:null}setSize(e,n,s){e.setColumnWidth(n,s)}resetSize(e,n){e.resetColumnWidth(n)}updateSeparator(e,n){e.setState({draggingColumnSeparator:n,isDragging:n!==null})}}const os=class{constructor(){this.getCachedTruncatedString=rn((t,e,n,s,i)=>os.truncateToWidth(t,e,n,s,i),{max:1e4}),this.getCachedBackgroundColors=rn((t,e)=>t.split(" ").map(n=>{const s=[];for(let i=0;i<e;i+=1)s.push(Sh.darkenForDepth(n,i,e));return s}),{max:1e3}),this.getCachedColorWithAlpha=rn((t,e)=>Sh.colorWithAlpha(t,e),{max:1e3}),this.getCachedColorIsDark=rn(t=>pl.isDark(t),{max:1e3})}static truncate(t,e){return e<t.length?t.substr(0,e)+"\u2026":t}static binaryTruncateToWidth(t,e,n,s=0,i=e.length,o){if(i>=e.length&&t.measureText(e).width<=n)return e;if(o!==void 0){const d=t.measureText(o).width;return o.repeat(Math.max(1,Math.floor(n/d)))}let r=s,l=Math.min(e.length-1,i),a=e;for(;l>=r;){const d=Math.ceil((l+r)/2),c=os.truncate(e,d);if(t.measureText(c).width<=n){if(a=c,r===d)break;r=d}else if(d===0){a=c;break}else l=d-1}return a}static truncateToWidth(t,e,n,s=os.DEFAULT_FONT_WIDTH,i){if(n<=0||e.length<=0)return"";const o=Math.min(Math.max(0,Math.floor(n/s/2)-5),e.length),r=Math.min(Math.ceil(n/s*2),e.length);return os.binaryTruncateToWidth(t,e,n,o,r,i)}drawCanvas(t){const{context:e}=t;e.save(),this.configureContext(e,t),this.drawBackground(e,t),this.drawGrid(e,t),this.drawHeaders(e,t),this.drawFooters(e,t),this.drawDraggingColumn(e,t),this.drawDraggingRow(e,t),this.drawScrollBars(e,t),e.restore()}configureContext(t,e){const{theme:n}=e;t.font=n.font,t.textBaseline="middle",t.lineCap="butt"}drawBackground(t,e){const{theme:n,metrics:s}=e,{width:i,height:o}=s;t.fillStyle=n.backgroundColor,t.fillRect(0,0,i,o)}drawGrid(t,e){const{metrics:n,draggingRow:s,draggingColumn:i}=e,{gridX:o,gridY:r}=n;t.translate(o,r),this.drawGridBackground(t,e,s==null&&i==null),this.drawCellContents(t,e),this.drawFloatingRows(t,e),this.drawFloatingColumns(t,e),t.translate(-o,-r)}drawFloatingRows(t,e){const{draggingRow:n,draggingColumn:s,metrics:i,theme:o}=e,{floatingTopRowCount:r,floatingBottomRowCount:l,floatingRows:a,rowCount:d,visibleColumns:c,visibleRowYs:u,visibleRowHeights:m}=i;if(a.length!==0){o.floatingRowBackgroundColors&&this.drawRowStripesForRows(t,e,a,o.floatingRowBackgroundColors),n==null&&s==null&&this.drawFloatingMouseRowHover(t,e),this.drawGridLinesForItems(t,e,c,a,o.floatingGridColumnColor,o.floatingGridRowColor),this.drawCellBackgroundsForItems(t,e,c,a),this.drawFloatingBorders(t,e),r>0&&this.drawSelectedRanges(t,e,{top:0,bottom:r-1,maxY:B(u,r-1)+B(m,r-1)-.5}),l>0&&this.drawSelectedRanges(t,e,{top:d-l-1,bottom:d-1,minY:B(u,d-l)+.5,maxY:B(u,d-1)+B(m,d-1)-.5});for(let p=0;p<c.length;p+=1){const g=c[p];for(let f=0;f<a.length;f+=1){const b=a[f];this.drawCellContent(t,e,g,b)}}}}drawFloatingColumns(t,e){const{draggingRow:n,draggingColumn:s,metrics:i,theme:o}=e,{floatingLeftColumnCount:r,floatingRightColumnCount:l,floatingLeftWidth:a,floatingRightWidth:d,floatingColumns:c,gridX:u,maxX:m,columnCount:p,visibleRows:g,visibleColumnXs:f,visibleColumnWidths:b,width:C,height:w}=i;if(c.length!==0){o.floatingRowBackgroundColors&&(this.drawRowStripesForRows(t,e,g,o.floatingRowBackgroundColors,0,a),this.drawRowStripesForRows(t,e,g,o.floatingRowBackgroundColors,C-u-d,m)),n==null&&s==null&&this.drawFloatingMouseRowHover(t,e),t.save(),t.beginPath(),t.rect(0,0,a,w),t.clip(),this.drawGridLinesForItems(t,e,c,g,o.floatingGridColumnColor,o.floatingGridRowColor),t.restore(),this.drawCellBackgroundsForItems(t,e,c,g),this.drawFloatingBorders(t,e),r>0&&this.drawSelectedRanges(t,e,{left:0,maxX:B(f,r-1)+B(b,r-1)}),l>0&&this.drawSelectedRanges(t,e,{left:p-l,right:p-1,minX:B(f,p-l)+.5,maxX:B(f,p-1)+B(b,p-1)});for(let T=0;T<c.length;T+=1){const y=c[T];for(let E=0;E<g.length;E+=1){const I=g[E];this.drawCellContent(t,e,y,I)}}}}drawFloatingBorders(t,e){const{metrics:n,theme:s}=e,{floatingTopRowCount:i,floatingBottomRowCount:o,floatingLeftColumnCount:r,floatingRightColumnCount:l,rowCount:a,columnCount:d,visibleRowYs:c,visibleColumnXs:u,visibleRowHeights:m,visibleColumnWidths:p,maxX:g,maxY:f}=n,{floatingDividerOuterColor:b,floatingDividerInnerColor:C}=s;if(t.lineWidth=3,t.beginPath(),t.strokeStyle=b,i>0){const w=B(c,i-1)+B(m,i-1)+.5;t.moveTo(0,w),t.lineTo(g,w)}if(o>0){const w=B(c,a-o)-.5;t.moveTo(0,w),t.lineTo(g,w)}if(r>0){const w=B(u,r-1)+B(p,r-1)+.5;t.moveTo(w,0),t.lineTo(w,f)}if(l>0){const w=B(u,d-l)-.5;t.moveTo(w,0),t.lineTo(w,f)}if(t.stroke(),t.beginPath(),t.lineWidth=1,t.strokeStyle=C,i>0){const w=B(c,i-1)+B(m,i-1)+.5;t.moveTo(0,w),t.lineTo(g,w)}if(o>0){const w=B(c,a-o)-.5;t.moveTo(0,w),t.lineTo(g,w)}if(r>0){const w=B(u,r-1)+B(p,r-1)+.5;t.moveTo(w,0),t.lineTo(w,f)}if(l>0){const w=B(u,d-l)-.5;t.moveTo(w,0),t.lineTo(w,f)}t.stroke()}drawGridBackground(t,e,n=!1){this.drawRowStripes(t,e),n&&(this.drawMouseColumnHover(t,e),this.drawMouseRowHover(t,e)),this.drawGridLines(t,e),this.drawCellBackgrounds(t,e);const{metrics:s}=e,{bottom:i,right:o,floatingBottomRowCount:r,floatingLeftColumnCount:l,floatingRightColumnCount:a,floatingTopRowCount:d,columnCount:c,rowCount:u,visibleRowHeights:m,visibleRowYs:p,visibleColumnXs:g,visibleColumnWidths:f,width:b,height:C}=s;this.drawSelectedRanges(t,e,{bottom:Math.min(i,u-r-1),right:Math.min(o,c-a-1),minX:l>0&&g.has(l+1)?B(g,l+1):-10,minY:d>0&&p.has(d+1)?B(p,d+1):-10,maxX:a>0&&g.has(c-a-1)?B(g,c-a-1)+B(f,c-a-1)-.5:b+10,maxY:r>0&&p.has(u-r-1)?B(p,u-r-1)+B(m,u-r-1)-.5:C+10})}drawRowStripes(t,e){const{metrics:n,theme:s}=e,{visibleRows:i}=n,{rowBackgroundColors:o}=s;!o||this.drawRowStripesForRows(t,e,i,o)}drawRowStripesForRows(t,e,n,s,i=0,o=e.metrics.maxX){const{theme:r,metrics:l,model:a}=e,{maxDepth:d,shadowBlur:c,shadowColor:u}=r,m=this.getCachedBackgroundColors(s,d),{visibleRowYs:p,visibleRowHeights:g}=l,f=new Map,b=[],C=[],w=(T,y)=>{const E=gt(a)?a.depthForRow(T):0,I=m[T%m.length],R=I[Math.min(E,I.length-1)];if(f.has(R)||f.set(R,[]),f.get(R).push(T),y!=null){const F=gt(a)?a.depthForRow(y):0;F<E?b.push(T):F>E&&C.push(y)}};for(let T=0;T<n.length;T+=1){const y=n[T],E=T>0?n[T-1]:void 0;w(y,E)}if(f.forEach((T,y)=>{t.fillStyle=y,t.beginPath();for(let E=0;E<T.length;E+=1){const I=T[E],R=B(p,I),F=B(g,I);t.rect(i,R,o,F)}t.fill()}),b.length>0){t.save();const T=this.getCachedColorWithAlpha(u,.15),y=this.getCachedColorWithAlpha(u,0),E=t.createLinearGradient(0,0,0,c);E.addColorStop(0,T),E.addColorStop(1,y),t.fillStyle=E;for(let I=0;I<b.length;I+=1){const R=b[I],F=B(p,R);t.translate(0,F),t.fillRect(i,0,o,c),t.translate(0,-F)}t.restore()}if(C.length>0){t.save();const T=this.getCachedColorWithAlpha(u,0),y=this.getCachedColorWithAlpha(u,.15),E=t.createLinearGradient(0,0,0,c);E.addColorStop(0,T),E.addColorStop(1,y),t.fillStyle=E;for(let I=0;I<C.length;I+=1){const R=C[I],F=B(p,R),x=B(g,R),U=F+x-c;t.translate(0,U),t.fillRect(i,0,o,c),t.translate(0,-U)}t.restore()}}drawMouseColumnHover(t,e){const{mouseX:n,mouseY:s,theme:i,metrics:o}=e;if(n==null||s==null)return;const r=G.getColumnAtX(n,o);if(r==null||i.columnHoverBackgroundColor==null)return;const{visibleColumnWidths:l,visibleColumnXs:a,maxY:d}=o;if(s>d)return;const c=B(a,r),u=B(l,r);t.fillStyle=i.columnHoverBackgroundColor,t.fillRect(c,0,u,d)}drawMouseRowHover(t,e){const{mouseX:n,mouseY:s,theme:i,metrics:o}=e;if(n==null||s==null)return;const{maxX:r}=o;if(n>r||i.rowHoverBackgroundColor==null)return;const l=G.getRowAtY(s,o);l!=null&&this.drawMouseRowHoverForRow(t,e,l)}drawFloatingMouseRowHover(t,e){const{mouseX:n,mouseY:s,theme:i,metrics:o}=e,{maxX:r,floatingTopRowCount:l,floatingBottomRowCount:a,rowCount:d,rowFooterWidth:c}=o;if(n==null||s==null||n>r+c||i.rowHoverBackgroundColor==null)return;const u=G.getRowAtY(s,o);u!=null&&(u<l||d-a<=u)&&this.drawMouseRowHoverForRow(t,e,u)}drawMouseRowHoverForRow(t,e,n){const{metrics:s,selectedRanges:i,theme:o}=e,{visibleRowHeights:r,visibleRowYs:l,maxX:a}=s,d=B(l,n),c=B(r,n);o.rowHoverBackgroundColor!=null&&(t.fillStyle=o.rowHoverBackgroundColor);for(let u=0;u<i.length;u+=1){const{startRow:m,endRow:p}=i[u];if(m!=null&&p!=null&&m<=n&&p>=n){o.selectedRowHoverBackgroundColor!=null&&(t.fillStyle=o.selectedRowHoverBackgroundColor);break}}t.fillRect(0,d,a,c)}drawGridLines(t,e){const{metrics:n,theme:s}=e,{visibleColumns:i,visibleRows:o}=n;this.drawGridLinesForItems(t,e,i,o,s.gridColumnColor,s.gridRowColor)}drawGridLinesForItems(t,e,n,s,i,o){i==null&&o==null||(t.lineWidth=1,t.beginPath(),i!=null&&(t.strokeStyle=i,this.drawGridLinesForColumns(t,e,n)),o!=null&&(t.strokeStyle=o,this.drawGridLinesForRows(t,e,s)),t.stroke())}drawGridLinesForColumns(t,e,n){const{metrics:s}=e,{visibleColumnXs:i,maxY:o}=s;for(let r=0;r<n.length;r+=1){const l=n[r],a=B(i,l)+.5;t.moveTo(a,0),t.lineTo(a,o)}}drawGridLinesForRows(t,e,n){const{metrics:s}=e,{visibleRowYs:i,maxX:o}=s,r=o;for(let l=0;l<n.length;l+=1){const a=n[l],d=B(i,a)+.5;t.moveTo(.5,d),t.lineTo(r-.5,d)}}drawCellBackgrounds(t,e){const{metrics:n}=e,{visibleColumns:s,visibleRows:i}=n;this.drawCellBackgroundsForItems(t,e,s,i)}drawCellBackgroundsForItems(t,e,n,s){t.save();for(let i=0;i<n.length;i+=1){const o=n[i];for(let r=0;r<s.length;r+=1){const l=s[r],a=r+1<s.length?s[r+1]:void 0;this.drawCellBackground(t,e,o,l,a)}}t.restore()}drawCellBackground(t,e,n,s,i){const{metrics:o,model:r,theme:l}=e,{firstColumn:a,modelColumns:d,modelRows:c,visibleColumnXs:u,visibleColumnWidths:m,visibleRowYs:p,visibleRowHeights:g}=o,f=B(c,s),b=B(d,n),C=r.backgroundColorForCell(b,f,l),w=n===a,T=gt(r)&&r.hasExpandableRows;if(C!=null){const y=B(u,n)+1,E=B(p,s)+1,I=B(m,n)-1,R=B(g,s)-1;t.fillStyle=C,t.fillRect(y,E,I,R)}w&&T&&this.drawCellRowTreeDepthLines(t,e,s,i)}drawCellContents(t,e){const{metrics:n}=e,{visibleColumns:s}=n;for(let i=0;i<s.length;i+=1){const o=s[i];this.drawColumnCellContents(t,e,o)}}drawColumnCellContents(t,e,n){const{metrics:s}=e,{visibleColumnXs:i,visibleColumnWidths:o,visibleRows:r,height:l}=s,a=B(i,n),d=B(o,n);t.save(),t.beginPath(),t.rect(a,0,d,l),t.clip();for(let c=0;c<r.length;c+=1){const u=r[c];this.drawCellContent(t,e,n,u)}t.restore()}getTextRenderMetrics(t,e,n,s){const{textAlign:i}=t,{metrics:o,model:r,theme:l}=e,{firstColumn:a,visibleColumnXs:d,visibleColumnWidths:c,visibleRowYs:u,visibleRowHeights:m}=o,{cellHorizontalPadding:p,treeDepthIndent:g,treeHorizontalPadding:f}=l,b=B(d,n),C=B(u,s),w=B(c,n),T=B(m,s),y=n===a;let E=0;gt(r)&&r.hasExpandableRows&&y&&(E=g*(r.depthForRow(s)+1)+f);const I=w-E;let R=b+p;const F=C+T*.5;return i==="right"?R=b+I-p:i==="center"&&(R=b+I*.5),R+=E,{width:I-p*2,x:R,y:F}}drawCellContent(t,e,n,s,i){var y;const{metrics:o,model:r,theme:l}=e,{firstColumn:a,fontWidths:d,modelColumns:c,modelRows:u,visibleRowHeights:m}=o,{textColor:p}=l,g=B(m,s),f=B(u,s),b=B(c,n),C=i!=null?i:r.textForCell(b,f),w=r.truncationCharForCell(b,f),T=n===a;if(C&&g>0){const E=r.textAlignForCell(b,f)||"left";t.textAlign=E;const I=r.colorForCell(b,f,l)||p;t.fillStyle=I;const{width:R,x:F,y:x}=this.getTextRenderMetrics(t,e,n,s),U=(y=d.get(t.font))!=null?y:os.DEFAULT_FONT_WIDTH,$=this.getCachedTruncatedString(t,C,R,U,w);$&&t.fillText($,F,x)}T&>(r)&&r.hasExpandableRows&&this.drawCellRowTreeMarker(t,e,s)}drawCellRowTreeMarker(t,e,n){const{metrics:s,model:i,mouseX:o,mouseY:r,theme:l}=e,{firstColumn:a,gridX:d,gridY:c,visibleColumnXs:u,visibleColumnWidths:m,visibleRowYs:p,visibleRowHeights:g,visibleRowTreeBoxes:f}=s,{treeMarkerColor:b,treeMarkerHoverColor:C}=l,w=B(u,a),T=B(m,a),y=B(p,n),E=B(g,n);if(!gt(i)||!i.isRowExpandable(n))return;const I=B(f,n),R=o!=null&&r!=null&&o>=d+w&&o<=d+w+T&&r>=c+y&&r<=c+y+E?C:b;this.drawTreeMarker(t,e,w,y,I,R,i.isRowExpanded(n))}drawTreeMarker(t,e,n,s,i,o,r){const{x1:l,y1:a,x2:d,y2:c}=i,u=r?"\u229F":"\u229E",m=n+(l+d)*.5+.5,p=s+(a+c)*.5+.5;t.fillStyle=o,t.textAlign="center",t.fillText(u,m,p)}drawCellRowTreeDepthLines(t,e,n,s){const{metrics:i,model:o,theme:r}=e;if(!gt(o))return;const l=o.depthForRow(n);if(l===0)return;const{firstColumn:a,visibleColumnXs:d,visibleRowYs:c,visibleRowHeights:u}=i,{treeDepthIndent:m,treeHorizontalPadding:p,treeLineColor:g}=r,f=B(d,a),b=B(c,n),C=B(u,n),w=s!==void 0?o.depthForRow(s):0,T=l>w?l-w:0;if(t.strokeStyle=g,t.lineWidth=1,l-T>0){t.beginPath();for(let y=0;y<l-T;y+=1){const E=f+y*m+m*.5+p+.5;t.moveTo(E,b),t.lineTo(E,b+C)}t.stroke()}if(T>0){t.beginPath();for(let y=l-T;y<l;y+=1){const E=f+y*m+m*.5+p+.5;t.moveTo(E,b),t.lineTo(E,b+Math.ceil(C/2)),t.moveTo(E-.5,b+Math.ceil(C/2)+.5),t.lineTo(E+m-.5,b+Math.ceil(C/2)+.5)}t.stroke()}}drawHeaders(t,e){const{theme:n}=e;t.font=n.headerFont,this.drawColumnHeaders(t,e),this.drawRowHeaders(t,e)}drawFooters(t,e){const{theme:n}=e;t.font=n.headerFont,this.drawRowFooters(t,e)}drawColumnHeaders(t,e){const{mouseX:n,mouseY:s,theme:i,metrics:o,draggingColumnSeparator:r,isDragging:l,model:a}=e,{columnHeaderHeight:d,floatingColumns:c,gridX:u,width:m,visibleColumns:p,visibleColumnWidths:g,visibleColumnXs:f,floatingLeftColumnCount:b,floatingLeftWidth:C,floatingRightWidth:w,modelColumns:T,columnHeaderMaxDepth:y}=o;if(d<=0)return;const{headerHiddenSeparatorSize:E,headerHiddenSeparatorHoverColor:I,headerSeparatorColor:R,headerSeparatorHoverColor:F}=i,x=d*.5,U=d*(y-1)+d*.5-x*.5,$=b>0;if(t.save(),this.drawColumnHeadersForRange(t,e,[p[0],p[p.length-1]],{minX:u+C,maxX:m-w}),$&&this.drawColumnHeadersForRange(t,e,[c[0],c[c.length-1]],{minX:u,maxX:u+C}),R){t.strokeStyle=R;const O=[...g.entries()].filter(([H,L])=>L===0).map(([H])=>H);t.beginPath(),t.fillStyle=R;for(let H=0;H<O.length;H+=1){const L=O[H],N=B(f,L),_=B(g,L),k=u+N+_+.5-E*.5;t.rect(k,U,E,x)}t.fill()}if(F){let{index:O,depth:H}=r!=null?r:{};if(O==null&&n!=null&&s!=null){const N=Fl.getColumnSeparator(G.getGridPointFromXY(n,s,o),o,a,i);O=N==null?void 0:N.index,H=N==null?void 0:N.depth}let L;if(O==null)L=!1;else{const N=T.get(O),_=T.get(O+1);N==null||_==null?L=!1:L=a.textForColumnHeader(N,H)!==a.textForColumnHeader(_,H)}if(L&&O!=null&&H!=null&&(!l||r!=null)){t.strokeStyle=F;const N=B(f,O),_=B(g,O),k=u+N+_+.5,V=p.indexOf(O),W=V<p.length-1?p[V+1]:null,j=W!=null?g.get(W):null,ee=_===0,ve=j!=null&&j===0;ee?(t.strokeStyle=I,t.fillStyle=I,t.fillRect(k,U,E*.5,x)):ve&&(t.fillStyle=F,t.fillRect(k-E*.5,U,E*.5,x)),t.beginPath(),t.moveTo(k,(y-H-1)*d),t.lineTo(k,(y-H)*d-1),t.stroke()}}t.restore()}drawColumnHeadersForRange(t,e,n,s){const{model:i}=e,{columnHeaderMaxDepth:o}=i;if(o!==0)for(let r=0;r<=o;r+=1)this.drawColumnHeadersAtDepth(t,e,n,s,r)}drawColumnHeadersAtDepth(t,e,n,s,i){var R,F,x,U,$,O;const{metrics:o,model:r,theme:l}=e,{modelColumns:a,visibleColumnXs:d,gridX:c,calculatedColumnWidths:u,userColumnWidths:m,visibleColumnWidths:p,movedColumns:g}=o,{columnHeaderHeight:f,columnWidth:b}=l,{columnHeaderMaxDepth:C}=r,{minX:w,maxX:T}=s,y=T-w;if(C===0)return;const E=n[0],I=n[1];if(t.save(),t.translate(0,(C-i-1)*f),i===0){this.drawColumnHeader(t,e,"",w,T);for(let H=E;H<=I;H+=1)this.drawColumnHeaderAtIndex(t,e,H,s)}if(i>0){let H=E;for(;H<=I;){const{columnCount:L}=o,N=B(a,H),_=r.textForColumnHeader(N,i),k=r.colorForColumnHeader(N,i);let V=B(d,H)+c,W=V+B(p,H);if(_!=null){let j=H-1;for(;j>=0&&(W-V<y||V>w);){const Se=(R=a.get(j))!=null?R:G.getModelIndex(j,g);if(Se==null||r.textForColumnHeader(Se,i)!==_)break;V-=(x=(F=m.get(Se))!=null?F:u.get(Se))!=null?x:b,j-=1}let ee=H+1;for(;ee<L&&(W-V<y||W<T);){const Se=(U=a.get(ee))!=null?U:G.getModelIndex(ee,g);if(r.textForColumnHeader(Se,i)!==_)break;W+=(O=($=m.get(Se))!=null?$:u.get(Se))!=null?O:b,ee+=1}H=ee-1;const ve=W-V>=y;let le=V;ve&&(W<T?le=W-y:V<w&&(le=w)),this.drawColumnHeader(t,e,_,le,Math.min(W-V,y),{backgroundColor:k!=null?k:void 0},s)}H+=1}}t.restore()}drawColumnHeaderAtIndex(t,e,n,s){var g;const{metrics:i,model:o}=e,{modelColumns:r,visibleColumnWidths:l,visibleColumnXs:a,gridX:d}=i,c=B(l,n),u=B(a,n)+d,m=B(r,n),p=o.textForColumnHeader(m);p!=null&&this.drawColumnHeader(t,e,p,u,c,{backgroundColor:(g=o.colorForColumnHeader(m))!=null?g:void 0},s)}drawColumnHeader(t,e,n,s,i,o,r){var ee;if(i<=0)return;const{metrics:l,theme:a}=e,{headerHorizontalPadding:d,columnHeaderHeight:c,headerBackgroundColor:u,headerColor:m,headerSeparatorColor:p,black:g,white:f}=a,{fontWidths:b,width:C}=l,w=(ee=b.get(t.font))!=null?ee:os.DEFAULT_FONT_WIDTH,y=(i-d*2)/w,{backgroundColor:E=u,separatorColor:I=p}=o!=null?o:{};let{textColor:R=m}=o!=null?o:{};try{const ve=this.getCachedColorIsDark(E),le=this.getCachedColorIsDark(R);ve&&le?R=f:!ve&&!le&&(R=g)}catch{}let{minX:F=0,maxX:x=C}=r!=null?r:{};t.save(),t.rect(F,0,x-F,c),t.clip(),E!=null&&(t.fillStyle=E,t.fillRect(s,0,i,c)),I!=null&&(t.strokeStyle=I,t.beginPath(),s>0&&(t.moveTo(s+.5,0),t.lineTo(s+.5,c)),t.moveTo(s+i+.5,0),t.lineTo(s+i+.5,c),t.moveTo(s,c-.5),t.lineTo(s+i,c-.5),t.stroke()),t.beginPath(),t.rect(s,0,i,c),t.clip(),t.fillStyle=R;let U=n;y<=0?U="":U.length>y&&(U=`${U.substring(0,y-1)}\u2026`);const $=U.length*w;let O=s+i*.5;const H=c*.5;F+=d,x-=d;const L=s+d,N=At(L,F,x),_=s+i-d,V=At(_,F,x)-N,W=O-$*.5<F,j=O+$*.5>x;W?$<V?O=F+$*.5:O=_-$*.5:j&&($<V?O=x-$*.5:O=L+$*.5),t.textAlign="center",t.fillText(U,O,H),t.restore()}drawRowHeaders(t,e){const{mouseX:n,mouseY:s,metrics:i,theme:o,draggingRowSeparator:r}=e,{gridY:l,rowHeaderWidth:a,height:d,visibleRows:c,visibleRowHeights:u,visibleRowYs:m}=i;if(a<=0)return;const{headerBackgroundColor:p,headerColor:g,headerHiddenSeparatorSize:f,headerHiddenSeparatorHoverColor:b,headerSeparatorColor:C,headerSeparatorHoverColor:w}=o,T=a*.5,y=a*.5-T*.5;if(t.save(),t.beginPath(),t.fillStyle=p,t.fillRect(0,0,a,d),C){t.strokeStyle=C,t.beginPath(),t.moveTo(0,l+.5),t.lineTo(a,l+.5);const E=[];let I=!1;for(let R=0;R<c.length;R+=1){const F=c[R],x=B(m,F),U=B(u,F);if(U>0){const $=l+x+U+.5;t.moveTo(0,$),t.lineTo(a,$),I=!1}else I||(I=!0,E.push(F))}t.moveTo(a-.5,0),t.lineTo(a-.5,d),t.stroke(),t.beginPath(),t.fillStyle=C;for(let R=0;R<E.length;R+=1){const F=E[R],x=B(m,F),U=B(u,F),$=l+x+U+.5-f*.5;t.rect(y,$,T,f)}t.fill()}if(w){let{index:E=null}=r!=null?r:{};if(E==null&&n!=null&&s!=null&&(E=G.getRowSeparatorIndex(n,s,i,o)),E!=null){t.strokeStyle=w;const I=B(m,E),R=B(u,E),F=l+I+R+.5,x=c.indexOf(E),U=x<c.length-1?c[x+1]:null,$=U!=null?u.get(U):null,O=R===0,H=$!=null&&$===0;O?(t.strokeStyle=b,t.fillStyle=b,t.fillRect(y,F,T,f*.5)):H&&(t.fillStyle=w,t.fillRect(y,F-f*.5,T,f*.5)),t.beginPath(),t.moveTo(.5,F),t.lineTo(a+.5,F),t.stroke()}}t.beginPath(),t.rect(0,l,a,d),t.clip(),t.fillStyle=g,t.textAlign="right";for(let E=0;E<c.length;E+=1){const I=c[E],R=B(u,I),F=B(m,I)+l;this.drawRowHeader(t,e,I,F,R)}t.restore()}drawRowHeader(t,e,n,s,i){if(i<=0)return;const{metrics:o,model:r,theme:l}=e,{modelRows:a,rowHeaderWidth:d}=o,c=B(a,n),u=d-l.cellHorizontalPadding,m=s+i*.5;t.fillText(r.textForRowHeader(c),u,m)}drawRowFooters(t,e){const{mouseX:n,mouseY:s,metrics:i,model:o,theme:r,draggingRowSeparator:l}=e,{gridY:a,gridX:d,maxX:c,modelRows:u,rowFooterWidth:m,height:p,verticalBarWidth:g,visibleRows:f,visibleRowHeights:b,visibleRowYs:C,width:w}=i;if(m<=0)return;const{cellHorizontalPadding:T,headerBackgroundColor:y,headerColor:E,headerHiddenSeparatorSize:I,headerHiddenSeparatorHoverColor:R,headerSeparatorColor:F,headerSeparatorHoverColor:x}=r,U=m*.5,$=m*.5-U*.5,O=Math.min(d+c,w-m-g);if(t.save(),t.beginPath(),t.fillStyle=y,t.fillRect(O,a,m,p),F){t.strokeStyle=F,t.beginPath(),t.moveTo(O,a+.5),t.lineTo(m,a+.5);const L=[];let N=!1;for(let _=0;_<f.length;_+=1){const k=f[_],V=B(C,k),W=B(b,k);if(W>0){const j=a+V+W+.5;t.moveTo(O+.5,j),t.lineTo(O+m-.5,j),N=!1}else N||(N=!0,L.push(k))}t.moveTo(O+.5,a),t.lineTo(O+.5,p),t.stroke(),t.beginPath(),t.fillStyle=F;for(let _=0;_<L.length;_+=1){const k=L[_],V=B(C,k),W=B(b,k),j=a+V+W+.5-I*.5;t.rect(O+$,j,U,I)}t.fill()}if(x){let{index:L=null}=l!=null?l:{};if(L==null&&n!=null&&s!=null&&(L=G.getRowSeparatorIndex(n,s,i,r)),L!=null){t.strokeStyle=x;const N=B(C,L),_=B(b,L),k=a+N+_+.5,V=f.indexOf(L),W=V<f.length-1?f[V+1]:null,j=W!=null?b.get(W):null,ee=_===0,ve=j!=null&&j===0;ee?(t.strokeStyle=R,t.fillStyle=R,t.fillRect($,k,U,I*.5)):ve&&(t.fillStyle=x,t.fillRect($,k-I*.5,U,I*.5)),t.beginPath(),t.moveTo(O+.5,k),t.lineTo(O+m+.5,k),t.stroke()}}t.beginPath(),t.rect(O,a,m,p),t.clip(),t.fillStyle=E,t.textAlign="left";const H=O+T;for(let L=0;L<f.length;L+=1){const N=f[L],_=B(b,N);if(_>0){const k=B(C,N)+a,V=B(u,N),W=k+_*.5;t.fillText(o.textForRowFooter(V),H,W)}}t.restore()}drawSelectedRanges(t,e,n={}){const{cursorColumn:s,cursorRow:i,draggingRow:o,draggingColumn:r,editingCell:l,metrics:a,model:d,selectedRanges:c,theme:u}=e,{visibleColumnWidths:m,visibleColumnXs:p,visibleRowHeights:g,visibleRowYs:f,width:b,height:C}=a,{left:w=a.left,top:T=a.top,right:y=a.right,bottom:E=a.bottom,minY:I=-10,maxY:R=C+10,minX:F=-10,maxX:x=b+10}=n;if(c.length===0)return;const U=Ze(d)&&d.isEditable&&l==null&&o==null&&r==null&&s!=null&&i!=null&&p.has(s)&&f.has(i);if(U){const $=B(p,s),O=B(f,i),H=B(m,s),L=B(g,i);t.save(),t.beginPath(),t.rect(0,0,b,C),t.rect($,O,H,L),t.clip("evenodd")}t.beginPath();for(let $=0;$<c.length;$+=1){const O=c[$],H=O.startColumn!==null?O.startColumn:w,L=O.startRow!==null?O.startRow:T,N=O.endColumn!==null?O.endColumn:y,_=O.endRow!==null?O.endRow:E;if(_>=T&&E>=L&&N>=w&&y>=H){const k=H>=w&&p.has(H)?Math.round(B(p,H))+.5:F,V=L>=T&&f.has(L)?Math.max(Math.round(B(f,L))+.5,.5):I,W=N<=y&&p.has(N)?Math.round(B(p,N)+B(m,N))-.5:x,j=_<=E&&f.has(_)?Math.round(B(f,_)+B(g,_))-.5:R;t.rect(k,V,W-k,j-V)}t.fillStyle=u.selectionColor,t.fill(),t.save(),t.clip(),t.strokeStyle=u.selectionOutlineCasingColor,t.lineWidth=3,t.stroke(),t.restore(),t.strokeStyle=u.selectionOutlineColor,t.lineWidth=1,t.stroke()}U&&s!=null&&i!=null&&(t.restore(),this.drawActiveCell(t,e,s,i))}drawActiveCell(t,e,n,s,i=os.ACTIVE_CELL_BORDER_WIDTH){const{metrics:o,theme:r}=e,{visibleColumnWidths:l,visibleColumnXs:a,visibleRowHeights:d,visibleRowYs:c}=o,u=B(a,n),m=B(c,s),p=B(l,n),g=B(d,s);let f=u-i*.5,b=m-i*.5,C=p+i,w=g+i;f<=0&&(C+=f-1,f=1),b<=0&&(w+=b-1,b=1);const{lineWidth:T}=t;t.beginPath(),t.lineWidth=i,t.strokeStyle=r.selectionOutlineColor,this.drawRoundedRect(t,f,b,C,w),t.stroke(),t.lineWidth=T}drawRoundedRect(t,e,n,s,i,o=os.DEFAULT_EDGE_RADIUS){t.beginPath(),t.moveTo(e+o,n),t.lineTo(e+s-o,n),t.quadraticCurveTo(e+s,n,e+s,n+o),t.lineTo(e+s,n+i-o),t.quadraticCurveTo(e+s,n+i,e+s-o,n+i),t.lineTo(e+o,n+i),t.quadraticCurveTo(e,n+i,e,n+i-o),t.lineTo(e,n+o),t.quadraticCurveTo(e,n,e+o,n),t.closePath()}drawDraggingColumn(t,e){var j;const{draggingColumn:n,metrics:s,mouseX:i,theme:o,model:r}=e;if(n==null||i==null)return;const{range:l,depth:a}=n,{gridX:d,gridY:c,visibleColumnXs:u,visibleColumnWidths:m,height:p,width:g,columnHeaderMaxDepth:f,columnHeaderHeight:b,movedColumns:C,modelColumns:w,floatingLeftWidth:T}=s,y=(j=w.get(l[0]))!=null?j:G.getModelIndex(l[0],C),E=r.getColumnHeaderGroup(y,a);if(a>0&&!E)return;const[I,R]=l,F=B(u,I),U=B(u,R)+B(m,R)-F,$=n.left,{backgroundColor:O,font:H,headerFont:L,reorderOffset:N,shadowBlur:_,shadowColor:k}=o,V=(f-a-1)*b;t.save(),t.translate(d,0),t.save(),t.beginPath(),t.rect(T,0,g,p),t.clip(),t.fillStyle=O,t.fillRect(F,V,U,p),t.restore(),t.translate(0,N),t.save(),t.shadowColor=k,t.shadowBlur=_,t.fillStyle=O,t.fillRect(n.left,V+N,n.width,p),t.restore(),t.beginPath(),t.rect(n.left,V,n.width+1,p),t.clip(),t.translate($-F,0),t.font=L;const W=[];for(let ee=n.range[0];ee<=n.range[1];ee+=1)W.push(ee);this.drawColumnHeaders(t,e),this.drawColumnHeadersForRange(t,e,[W[0],W[W.length-1]],{minX:F,maxX:g}),t.translate(0,c),t.font=H,this.drawGridBackground(t,e);for(let ee=I;ee<=R;ee+=1)this.drawColumnCellContents(t,e,ee);t.restore()}drawDraggingRow(t,e){const{draggingRow:n,draggingRowOffset:s,metrics:i,mouseY:o,theme:r}=e;if(n==null||o==null)return;const{gridX:l,gridY:a,visibleRowYs:d,visibleRowHeights:c,width:u}=i,m=B(d,n),p=B(c,n)+1,{backgroundColor:g,font:f,headerFont:b,reorderOffset:C,shadowBlur:w,shadowColor:T}=r;t.save(),t.translate(0,a),t.fillStyle=g,t.fillRect(0,m,u,p),t.translate(l+C,o-m-a-(s!=null?s:0)),t.save(),t.shadowColor=T,t.shadowBlur=w,t.fillStyle=g,t.fillRect(-l,m,u,p),t.restore(),t.beginPath(),t.rect(-l,m,u,p),t.clip(),t.font=f,this.drawGridBackground(t,e),this.drawCellContents(t,e),t.translate(-l,-a),t.font=b,this.drawRowHeaders(t,e),t.restore()}drawScrollBars(t,e){const{isDraggingHorizontalScrollBar:n,isDraggingVerticalScrollBar:s,isDragging:i,metrics:o,mouseX:r,mouseY:l,theme:a}=e;if(a.scrollBarSize<=0)return;const{rowHeaderWidth:d,columnHeaderHeight:c,width:u,height:m,handleHeight:p,handleWidth:g,scrollX:f,scrollY:b,hasHorizontalBar:C,hasVerticalBar:w,barWidth:T,barHeight:y}=o,{scrollBarBackgroundColor:E,scrollBarHoverBackgroundColor:I,scrollBarCasingColor:R,scrollBarCornerColor:F,scrollBarColor:x,scrollBarHoverColor:U,scrollBarActiveColor:$,scrollBarSize:O,scrollBarHoverSize:H,scrollBarCasingWidth:L,scrollBarSelectionTick:N,scrollBarSelectionTickColor:_,scrollBarActiveSelectionTickColor:k,autoSelectRow:V,autoSelectColumn:W}=a,j=r!=null&&l!=null&&r<=u&&l<=m,ee=s||w&&!n&&!i&&r!=null&&l!=null&&r>=u-H&&l<=y+c&&j,ve=n||C&&!s&&!i&&!ee&&r!=null&&l!=null&&l>=m-H&&r<=T-d&&j,le=ve?H:O,Se=ee?H:O;if(t.translate(d,c),C&&w&&(t.fillStyle=R,t.fillRect(u-d-O,m-c-O,O,O),t.fillStyle=F,t.fillRect(u-d-O+L,m-c-O+L,O-L,O-L)),C){const Le=f,J=m-c-le;if(t.fillStyle=R,t.fillRect(0,J,T,le-L),t.fillStyle=ve?I:E,t.fillRect(0,J+L,T,le-L),n?t.fillStyle=$:ve?t.fillStyle=U:t.fillStyle=x,t.fillRect(Le,J+L,g,le-L),!V&&N&&_!=null&&k!=null){t.fillStyle=_;const{selectedRanges:pe,cursorColumn:fe}=e,{lastLeft:xe,columnCount:ke}=o,Xn=[...pe].filter(Re=>Re.startColumn!=null&&Re.endColumn!=null).map(Re=>[Re.startColumn,Re.endColumn]).sort(G.compareRanges),Sn=G.mergeSortedRanges(Xn),Ct=Re=>Re<=xe?Re/xe*(T-g):T-g+(Re-xe)/(ke-xe)*g;for(let Re=0;Re<Sn.length;Re+=1){const st=Sn[Re],it=st[0],Mt=st[1];if(it!=null&&Mt!=null&&(it!==fe||Mt!==fe)){const Yt=Ct(it),Xt=Math.max(1,Math.round(Ct(Mt+1)-Yt)),Nt=le-L;t.fillRect(Yt,J+L+Math.round(Nt/3),Xt,Math.round(Nt/3))}}if(fe!=null){const Re=Ct(fe),st=2,it=le-L;t.fillStyle=k,t.fillRect(Re,J+L,st,it)}}}if(w){const Le=u-d-Se,J=b;if(t.fillStyle=R,t.fillRect(Le,0,Se-L,y),t.fillStyle=ee?I:E,t.fillRect(Le+L,0,Se-L,y),s?t.fillStyle=$:ee?t.fillStyle=U:t.fillStyle=x,t.fillRect(Le+L,J,Se-L,p),!W&&N&&_!=null&&k!=null){const{selectedRanges:pe,cursorRow:fe}=e,{lastTop:xe,rowCount:ke}=o,hn=Re=>Re<=xe?Re/xe*(y-p):y-p+(Re-xe)/(ke-xe)*p;t.fillStyle=_;const Sn=[...pe].filter(Re=>Re.startRow!=null&&Re.endRow!=null).map(Re=>[Re.startRow,Re.endRow]).sort(G.compareRanges),Ct=G.mergeSortedRanges(Sn);for(let Re=0;Re<Ct.length;Re+=1){const st=Ct[Re],it=st[0],Mt=st[1];if(it!=null&&Mt!=null&&(it!==fe||Mt!==fe)){const Yt=hn(it),Xt=Se-L,Nt=Math.max(1,Math.round(hn(Mt+1)-Yt));t.fillRect(Le+L+Math.round(Xt/3),Yt,Math.round(Xt/3),Nt)}}if(fe!=null){const Re=Math.round(hn(fe)),st=Se-L,it=2;t.fillStyle=k,t.fillRect(Le+L,Re,st,it)}}}t.translate(-d,-c)}};let Wi=os;Wi.DEFAULT_FONT_WIDTH=10;Wi.DEFAULT_EDGE_RADIUS=2;Wi.ACTIVE_CELL_BORDER_WIDTH=2;const wh=100;class P0 extends Et{constructor(){super(...arguments),this.hasExtendedFloating=!1}onDown(e,n,s){const{x:i,y:o,column:r,row:l}=e,{metrics:a}=n;if(!a)throw new Error("metrics not set");const{gridX:d,gridY:c,maxX:u,maxY:m}=a,p=i-d,g=o-c;if(p<0||g<0||r==null&&p>u||l==null&&g>m)return!1;const f=G.isModifierKeyDown(s),b=s.shiftKey;f||(b?n.trimSelectedRanges():n.clearSelectedRanges());const C=n.getTheme(),{autoSelectRow:w,autoSelectColumn:T}=C;return(r!==null||!T)&&(l!==null||!w)&&(n.focus(),n.moveCursorToPosition(r,l,b,!1,b&&f)),this.startPoint=e,this.hasExtendedFloating=!1,this.dragBounds=G.getScrollDragBounds(a,l,r),!0}onDrag(e,n){if(this.startPoint===void 0)return!1;this.stopTimer();const{row:s,column:i}=this.startPoint,{x:o,y:r}=e;let{row:l,column:a}=e;const{metrics:d}=n;if(!d)throw new Error("metrics not set");const{left:c,lastLeft:u,top:m,lastTop:p,columnWidth:g,rowHeight:f}=d,b=G.getScrollDragBounds(d,s,i);let C=0,w=0;if(c<u&&(o<b.x1?C=o-b.x1:o>b.x2&&(C=o-b.x2)),m<p&&(r<b.y1?w=r-b.y1:r>b.y2&&(w=r-b.y2)),C!==0||w!==0)this.startTimer(n,e,C>0?Math.ceil(C/g):Math.floor(C/g),w>0?Math.ceil(w/f):Math.floor(w/f));else if(l!=null&&a!=null){const{floatingTopRowCount:T,floatingBottomRowCount:y,floatingLeftColumnCount:E,floatingRightColumnCount:I,columnCount:R,rowCount:F,bottom:x,right:U,topVisible:$,bottomVisible:O,leftVisible:H,rightVisible:L}=d;this.hasExtendedFloating||(s!==null&&s<T&&l>=T?(l=T,this.hasExtendedFloating=!0):s!==null&&s>=F-y&&l<F-y&&(l=F-y-1,this.hasExtendedFloating=!0),i!==null&&i<E&&a>=E?(a=E,this.hasExtendedFloating=!0):i!==null&&i>=R-I&&a<R-I&&(a=R-I-1,this.hasExtendedFloating=!0)),s!==null&&!G.isFloatingRow(s,d)&&G.isFloatingRow(l,d)&&(s>l&&l<m?l=$-1:s<l&&l>x&&(l=O+1)),i!==null&&!G.isFloatingColumn(i,d)&&G.isFloatingColumn(a,d)&&(i>a&&a<c?a=H-1:i<a&&a>U&&(a=L+1)),n.moveCursorToPosition(a,l,!0,!0)}return!0}onUp(e,n){return this.startPoint!==void 0&&(this.startPoint=void 0,this.dragBounds=void 0,this.stopTimer(),n.commitSelection()),!1}moveSelection(e,n,s,i){const{row:o,column:r}=n,{metrics:l}=e;if(!l)throw new Error("metrics not set");const{selectionEndRow:a,selectionEndColumn:d}=e.state;if(a==null||d==null)throw new Error("selection not set");const{rowCount:c,columnCount:u}=l,m=s<0&&r!=null?r:0,p=s>0&&r!=null?r:u-1,g=i<0&&o!=null?o:0,f=i>0&&o!=null?o:c-1;e.moveCursorToPosition(Math.min(Math.max(m,d+s),p),Math.min(Math.max(g,a+i),f),!0),this.lastTriggerTime=Date.now()}startTimer(e,n,s,i){this.stopTimer();const o=this.lastTriggerTime!=null?wh-Math.min(wh,Date.now()-this.lastTriggerTime):0;this.timer=setTimeout(()=>{this.moveSelection(e,n,s,i),this.startTimer(e,n,s,i)},o)}stopTimer(){this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0)}}const vh=5,H0=1e3/60,vr=10;function Es(t,e,n,s){var T,y,E,I,R,F,x;const{modelColumns:i,movedColumns:o,visibleColumnXs:r,columnCount:l,visibleColumnWidths:a,userColumnWidths:d,calculatedColumnWidths:c,floatingLeftWidth:u,maxX:m}=n;if(e==null||t==null||t>l||t<0)return null;const p=(T=i.get(t))!=null?T:G.getModelIndex(t,o),g=s.getColumnHeaderGroup(p,e),f=g!=null;let b,C,w;if(g!=null){const[U,$]=g.getVisibleRange(o);b=(y=r.get(U))!=null?y:u,C=((E=r.get($))!=null?E:m)+((I=a.get($))!=null?I:0),w=[U,$]}else{const U=r.get(t);if(U==null)return null;b=U,C=b+((x=(F=(R=a.get(t))!=null?R:d.get(p))!=null?F:c.get(p))!=null?x:0),w=[t,t]}return{visibleIndex:t,modelIndex:p,left:b,right:C,width:C-b,isColumnGroup:f,range:w,depth:e}}class V0 extends Et{constructor(){super(...arguments),this.cursor=null,this.draggingColumn=null}setScrollInterval(e,n){this.scrollingInterval!=null&&n===this.scrollingDirection||(this.scrollingDirection=n,this.scrollingInterval=window.setInterval(()=>{var f,b;const{metrics:s}=e;if(!s)return;const{left:i,lastLeft:o,leftOffset:r,userColumnWidths:l,calculatedColumnWidths:a,movedColumns:d,visibleColumnWidths:c}=s;let u=i,m=r;if(n==="left")for(m-=vr;m<0;){u-=1;const C=G.getModelIndex(i-1,d),w=(f=l.get(C))!=null?f:a.get(C);w===void 0?m=0:m+=w,u<0&&(m=0,u=0)}else{m+=vr;let C=c.get(i);for(;C!==void 0&&m>C;){u+=1,m-=C;const w=G.getModelIndex(i+1,d);C=(b=l.get(w))!=null?b:a.get(w),u>o&&(m=0,u=o)}}const{mouseX:p,mouseY:g}=e.state;s==null||p==null||g==null||(this.moveDraggingColumn(p,e,n==="left"?-vr:vr),e.setState({left:u,leftOffset:m}),(n==="left"&&u===0&&r===0||n==="right"&&u===o)&&this.clearScrollInterval())},H0))}clearScrollInterval(){this.scrollingDirection=void 0,window.clearInterval(this.scrollingInterval),this.scrollingInterval=void 0}onLeave(){return this.clearScrollInterval(),!1}onDown(e,n){const{model:s}=n.props,{x:i,column:o,columnHeaderDepth:r}=e,{metrics:l}=n;if(!l)throw new Error("Metrics not set");const a=Es(o,r,l,s);if(o==null||a==null||r==null||r>0&&!a.isColumnGroup)return!1;const{rowHeaderWidth:d}=l;return this.initialGridPoint=e,this.draggingColumn=null,this.cursor=null,a.modelIndex!=null&&r!=null&&s.isColumnMovable(a.modelIndex,r)&&(this.draggingOffset=i-a.left-d,this.initialOffset=this.draggingOffset),!1}onDrag(e,n,s){if(this.draggingOffset===void 0||this.initialGridPoint===void 0||this.initialOffset===void 0)return!1;const{x:i,y:o}=e,{columnHeaderDepth:r}=this.initialGridPoint,{model:l}=n.props;let{draggingColumn:a}=this;const{metrics:d}=n;if(!d)throw new Error("Metrics not set");if(!a&&Math.abs(this.initialGridPoint.x-i)<vh&&Math.abs(this.initialGridPoint.y-o)<vh)return!1;if(a==null){const c=Es(this.initialGridPoint.column,r,d,l);if(!c||r==null||!l.isColumnMovable(c.modelIndex)||r>0&&!c.isColumnGroup||c.range[0]==null)return!1;a={range:c.range,depth:r,left:c.left,width:c.width};const u=Es(a.range[0],0,d,l),m=Es(a.range[1],0,d,l);if(!u||!m)return!1;this.draggingColumn=a,n.setState({draggingColumn:a,isDragging:!0})}return this.cursor="move",this.moveDraggingColumn(e.x,n,s.movementX),!0}moveDraggingColumn(e,n,s){var R,F,x,U,$;if(this.draggingOffset===void 0||this.initialGridPoint===void 0||this.initialOffset===void 0||this.draggingColumn==null||s===0)return;if(this.initialOffset!==this.draggingOffset){this.draggingOffset<this.initialOffset&&this.initialOffset<this.draggingOffset+s||this.draggingOffset>this.initialOffset&&this.initialOffset>this.draggingOffset+s?this.draggingOffset=this.initialOffset:this.draggingOffset+=s,this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},n.setState({draggingColumn:this.draggingColumn});return}const{depth:i}=this.draggingColumn,{model:o}=n.props,{movedColumns:r}=n.state,{metrics:l}=n;if(!l)throw new Error("Metrics not set");const{floatingLeftWidth:a,width:d,columnHeaderMaxDepth:c,visibleColumnXs:u}=l,m=s<0,p=Es(this.draggingColumn.range[0],i,l,o);if(!p)return;const g=e-this.draggingOffset,f=g+p.width;this.draggingColumn={...this.draggingColumn,left:g},n.setState({draggingColumn:this.draggingColumn});const b=Es(G.getColumnAtX(At(m?g:f,a,d),l,!0),i,l,o),C=o.getColumnHeaderParentGroup(p.modelIndex,p.depth);if(!b)return;if(C!==void 0){const O=C.getVisibleRange(r);if(b.visibleIndex<O[0]){const H=this.moveColumn(p,O[0],r);this.draggingOffset=e-((R=u.get(O[0]))!=null?R:0),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},this.clearScrollInterval(),n.setState({draggingColumn:this.draggingColumn,movedColumns:H});return}if(b.visibleIndex>O[1]){const H=this.moveColumn(p,O[1]-(p.range[1]-p.range[0]),r),{right:L=0}=(F=Es(O[1],0,l,o))!=null?F:{};this.draggingOffset=e-(L-p.width),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},this.clearScrollInterval(),n.setState({draggingColumn:this.draggingColumn,movedColumns:H});return}}if(!o.isColumnMovable(b.modelIndex)){let O=b.visibleIndex;if(m)for(O+=1;O<p.visibleIndex&&!o.isColumnMovable(G.getModelIndex(O,r));)O+=1;else for(O-=1;O>p.visibleIndex&&!o.isColumnMovable(G.getModelIndex(O,r));)O-=1;if(O!==p.visibleIndex){m||(O-=p.range[1]-p.range[0]);const L=this.moveColumn(p,O,r);n.setState({movedColumns:L,draggingColumn:this.draggingColumn})}const H=Es(O,0,l,o);m?this.draggingOffset=e-((x=H==null?void 0:H.left)!=null?x:0):this.draggingOffset=e-(((U=H==null?void 0:H.right)!=null?U:0)-p.width),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},n.setState({draggingColumn:this.draggingColumn});return}if(g<=a?this.setScrollInterval(n,"left"):f>d?this.setScrollInterval(n,"right"):this.clearScrollInterval(),b.visibleIndex===p.visibleIndex||m&&p.visibleIndex<b.visibleIndex||!m&&p.visibleIndex>b.visibleIndex)return;const w=b.left+b.width*.5,T=o.getColumnHeaderParentGroup(p.modelIndex,p.depth);let y,E=(($=T==null?void 0:T.depth)!=null?$:c)-1;for(;E>=0&&y===void 0;)y=o.getColumnHeaderGroup(b.modelIndex,E),E-=1;let I;m&&g<w&&(!y||b.visibleIndex===y.getVisibleRange(r)[0])&&(I=this.moveColumn(p,b.range[0],r)),!m&&f>w&&(!y||b.visibleIndex===y.getVisibleRange(r)[1])&&(I=this.moveColumn(p,b.range[1]-(p.range[1]-p.range[0]),r)),I&&(this.draggingColumn={...this.draggingColumn,left:g},n.setState({movedColumns:I,draggingColumn:this.draggingColumn}))}moveColumn(e,n,s){const i=e.isColumnGroup?G.moveRange(e.range,n,s):G.moveItem(e.visibleIndex,n,s),o=n-e.range[0],r=[e.range[0]+o,e.range[1]+o];return this.draggingColumn&&(this.draggingColumn={...this.draggingColumn,range:r}),i}onUp(e,n){return this.cursor=null,this.clearScrollInterval(),this.draggingOffset!=null?(this.draggingOffset=void 0,n.setState({draggingColumn:null,isDragging:!1}),!0):!1}}class Od extends Et{constructor(){super(...arguments),this.cursor="default"}static getLeftWithOffsetFromRawLeft(e,n){const s=e.getTheme(),{metrics:i,metricCalculator:o}=e;if(!i)throw new Error("metrics not set");if(s.scrollSnapToColumn)return{left:Math.round(n),leftOffset:0};const r=Math.floor(n),l=n-r;let a=i.visibleColumnWidths.get(r);if(a==null){const c=e.getMetricState();a=o.getVisibleColumnWidth(r,c)}const d=a*l;return{left:r,leftOffset:d}}isInScrollBar(e,n){const s=n.getTheme(),{scrollBarSize:i,scrollBarHoverSize:o}=s,{metrics:r}=n;if(!r)throw new Error("metrics not set");const{x:l,y:a}=e,{barLeft:d,barWidth:c,height:u,hasHorizontalBar:m}=r;return m&&i>0&&a>=u-o&&a<u&&l>d&&l<d+c}getLeftWithOffset(e,n){var f;const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{x:i}=e,{barWidth:o,handleWidth:r,lastLeft:l,barLeft:a,columnCount:d,scrollableContentWidth:c,scrollableViewportWidth:u}=s,m=i-a,p=At((m-((f=this.dragOffset)!=null?f:0))/(o-r),0,1);if(d===1)return{left:0,leftOffset:p*(c-u)};const g=p*l;return Od.getLeftWithOffsetFromRawLeft(n,g)}onDown(e,n){const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{x:i}=e,{handleWidth:o,barLeft:r,scrollX:l}=s;if(!this.isInScrollBar(e,n))return!1;const a=i-r;if(a>=l&&a<=l+o)this.dragOffset=a-l,n.setState({isDraggingHorizontalScrollBar:!0});else{this.dragOffset=0;const{left:d,leftOffset:c}=this.getLeftWithOffset(e,n);n.setViewState({left:d,leftOffset:c,isDraggingHorizontalScrollBar:!0,isDragging:!0})}return!0}onDrag(e,n){if(this.dragOffset!=null){const{left:s,leftOffset:i}=this.getLeftWithOffset(e,n);return n.setViewState({left:s,leftOffset:i,isDraggingHorizontalScrollBar:!0,isDragging:!0}),!0}return!1}onMove(e,n){return this.isInScrollBar(e,n)}onUp(e,n){return this.dragOffset!==void 0&&(this.dragOffset=void 0,n.setState({isDraggingHorizontalScrollBar:!1,isDragging:!1})),this.isInScrollBar(e,n)}onClick(e,n){return this.isInScrollBar(e,n)}}class U0 extends Et{constructor(){super(...arguments),this.cursor="move"}onDown(e,n){const{model:s}=n.props,{x:i,y:o,row:r}=e,{metrics:l}=n;if(!l)throw new Error("metrics not set");const{columnHeaderHeight:a,rowHeaderWidth:d,visibleRowYs:c}=l;if(i<=d&&r!==null&&s.isRowMovable(r)){const u=B(c,r);this.draggingOffset=o-u-a,n.setState({draggingRowOffset:this.draggingOffset})}return!1}onDrag(e,n){if(this.draggingOffset==null)return!1;const{model:s}=n.props;let{draggingRow:i}=n.state;const{mouseX:o,mouseY:r}=n.state;if(o==null||r==null)return!1;if(i==null){const{row:I}=n.getGridPointFromXY(o,r);if(I!=null&&!s.isRowMovable(I)||(i=I,n.setState({draggingRow:i,isDragging:!0}),i==null))return!1}const{metrics:l}=n;if(!l)throw new Error("metrics not set");const{top:a,lastTop:d,bottom:c,bottomVisible:u,rowCount:m,columnHeaderHeight:p,visibleRowHeights:g,visibleRowYs:f,height:b}=l;let C=p;if(a<i){const I=i-1;C=B(f,I)+B(g,I)*.5+p}let w=b;if(i<c){const I=i+1;w=B(f,I)+B(g,I)*.5+p}let{movedRows:T}=n.state;r<C&&i>0&&s.isRowMovable(i-1)?(T=G.moveItem(i,i-1,T),i-=1):w<r&&i<m-1&&s.isRowMovable(i+1)&&(T=G.moveItem(i,i+1,T),i+=1),n.setState({movedRows:T,draggingRow:i});const y=p+B(g,a)*.5,E=p+B(f,u)+B(g,u)*.5;return r<y&&a>0?n.setState({top:a-1}):r>E&&a<d&&n.setState({top:a+1}),!0}onUp(e,n){return this.draggingOffset!==void 0?(this.draggingOffset=void 0,n.setState({draggingRowOffset:null,draggingRow:null,isDragging:!1}),!0):!1}}class Ld extends Qm{constructor(){super(...arguments),this.hiddenCursor="s-resize",this.defaultCursor="row-resize",this.pointProperty="y",this.userSizesProperty="userRowHeights",this.visibleOffsetProperty="visibleRowYs",this.visibleSizesProperty="visibleRowHeights",this.marginProperty="columnHeaderHeight",this.calculatedSizesProperty="calculatedRowHeights",this.modelIndexesProperty="modelRows",this.firstIndexProperty="firstRow",this.treePaddingProperty="treePaddingY",this.getHiddenItems=G.getHiddenRows,this.getNextShownItem=G.getNextShownRow,this.getSeparator=Ld.getRowSeparator}static getRowSeparator(e,n,s,i){if(!i.allowRowResize)return null;const{x:o,y:r}=e,l=G.getRowSeparatorIndex(o,r,n,i);return l!=null?{index:l,depth:0}:null}setSize(e,n,s){e.setRowHeight(n,s)}resetSize(e,n){e.resetRowHeight(n)}updateSeparator(e,n){e.setState({draggingRowSeparator:n,isDragging:n!==null})}}class Jr extends Et{static isInTreeBox(e,n){const{column:s,row:i,x:o,y:r}=e,{metrics:l}=n;if(!l)throw new Error("metrics not set");const{gridX:a,gridY:d,firstColumn:c,visibleColumnXs:u,visibleColumnWidths:m,visibleRowHeights:p,visibleRowYs:g,visibleRowTreeBoxes:f}=l;if(s===c&&i!=null&&f.get(i)!=null&&o>a&&r>d){const b=B(u,s),C=B(m,s),w=B(g,i),T=B(p,i);if(o>=a+b&&o<=a+b+C&&r>=d+w&&r<=d+w+T)return!0}return!1}onDown(e,n){return Jr.isInTreeBox(e,n)}onClick(e,n){if(Jr.isInTreeBox(e,n)){const{row:s}=e;if(s!==null)return n.toggleRowExpanded(s),!0}return!1}}class B0 extends Et{isInCorner(e,n){const s=n.getTheme(),{scrollBarSize:i}=s,{metrics:o}=n;if(!o)throw new Error("metrics not set");const{x:r,y:l}=e,{width:a,height:d,hasVerticalBar:c,hasHorizontalBar:u}=o;return i>0&&c&&u&&r>=a-i&&l>=d-i&&r<=a&&l<=d}onDown(e,n){return this.isInCorner(e,n)}onUp(e,n){return this.isInCorner(e,n)}onClick(e,n){return this.isInCorner(e,n)}}class Ad extends Et{constructor(){super(...arguments),this.cursor="default"}static getTopWithOffsetFromRawTop(e,n){const s=e.getTheme(),{metrics:i,metricCalculator:o}=e;if(!i)throw new Error("metrics not set");if(s.scrollSnapToRow)return{top:Math.round(n),topOffset:0};const r=Math.floor(n),l=n-r;let a=i.visibleRowHeights.get(r);if(a==null){const c=e.getMetricState();a=o.getVisibleRowHeight(r,c)}const d=a*l;return{top:r,topOffset:d}}isInScrollBar(e,n){const s=n.getTheme(),{scrollBarSize:i,scrollBarHoverSize:o}=s,{metrics:r}=n;if(!r)throw new Error("metrics not set");const{x:l,y:a}=e,{barTop:d,barHeight:c,width:u,hasVerticalBar:m}=r;return m&&i>0&&l>=u-o&&l<u&&a>d&&a<d+c}getTopWithOffset(e,n){var f;const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{y:i}=e,{barHeight:o,handleHeight:r,lastTop:l,barTop:a,rowCount:d,scrollableContentHeight:c,scrollableViewportHeight:u}=s,m=i-a,p=At((m-((f=this.dragOffset)!=null?f:0))/(o-r),0,1);if(d===1)return{top:0,topOffset:p*(c-u)};const g=p*l;return Ad.getTopWithOffsetFromRawTop(n,g)}onDown(e,n){const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{y:i}=e,{handleHeight:o,barTop:r,scrollY:l}=s;if(!this.isInScrollBar(e,n))return!1;const a=i-r;if(a>=l&&a<=l+o)this.dragOffset=a-l,n.setState({isDraggingVerticalScrollBar:!0});else{this.dragOffset=0;const{top:d,topOffset:c}=this.getTopWithOffset(e,n);n.setViewState({top:d,topOffset:c,isDraggingVerticalScrollBar:!0,isDragging:!0})}return!0}onMove(e,n){return this.isInScrollBar(e,n)}onDrag(e,n){if(this.dragOffset!=null){const{top:s,topOffset:i}=this.getTopWithOffset(e,n);return n.setViewState({top:s,topOffset:i,isDraggingVerticalScrollBar:!0,isDragging:!0}),!0}return!1}onUp(e,n){return this.dragOffset!==void 0&&(this.dragOffset=void 0,n.setState({isDraggingVerticalScrollBar:!1,isDragging:!1})),this.isInScrollBar(e,n)}onClick(e,n){return this.isInScrollBar(e,n)}}class $0 extends Et{onDoubleClick({column:e,row:n},s){const{model:i}=s.props;return Ze(i)&&e!=null&&n!=null&&i.isEditableRange(re.makeCell(e,n))?(s.startEditing(e,n),!0):!1}}class Ci{constructor(e=5e3){this.order=e}onDown(e,n){return!1}}class z0 extends Ci{onDown(e,n){switch(e.key){case"a":if(G.isModifierKeyDown(e))return n.selectAll(),!0;break;case"ArrowUp":return this.handleArrowMove(0,-1,e,n);case"ArrowDown":return this.handleArrowMove(0,1,e,n);case"ArrowRight":return this.handleArrowMove(1,0,e,n);case"ArrowLeft":return this.handleArrowMove(-1,0,e,n);case"k":case"K":return G.isModifierKeyDown(e)?!1:this.handlePageUp(e,n);case"j":case"J":return G.isModifierKeyDown(e)?!1:this.handlePageDown(e,n);case"h":case"H":return G.isModifierKeyDown(e)?!1:(e.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(0,n.state.cursorRow,e.shiftKey),!0);case"l":case"L":{if(G.isModifierKeyDown(e))return!1;const{model:s}=n.props,{columnCount:i}=s;return e.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(i-1,n.state.cursorRow,e.shiftKey),!0}case"PageDown":return this.handlePageDown(e,n);case"PageUp":return this.handlePageUp(e,n);case"Home":return e.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(G.isModifierKeyDown(e)?n.state.cursorColumn:0,G.isModifierKeyDown(e)?0:n.state.cursorRow,e.shiftKey,!0,!0),!0;case"End":{const{model:s}=n.props,{columnCount:i,rowCount:o}=s;return e.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(G.isModifierKeyDown(e)?n.state.cursorColumn:i-1,G.isModifierKeyDown(e)?o-1:n.state.cursorRow,e.shiftKey,!0,!0),!0}case"Escape":return n.clearSelectedRanges(),!0;case"Enter":if(n.state.selectedRanges.length>0)return n.moveCursorInDirection(e.shiftKey?re.SELECTION_DIRECTION.UP:re.SELECTION_DIRECTION.DOWN),!0;break;case"Tab":if(n.state.selectedRanges.length>0)return n.moveCursorInDirection(e.shiftKey?re.SELECTION_DIRECTION.LEFT:re.SELECTION_DIRECTION.RIGHT),!0;break}return!1}handleArrowMove(e,n,s,i){const o=s.shiftKey,r=G.isModifierKeyDown(s);o?i.trimSelectedRanges():i.clearSelectedRanges();const{cursorRow:l,cursorColumn:a,selectionEndColumn:d,selectionEndRow:c}=i.state,u=o?d:a,m=o?c:l;if(r){const{model:p}=i.props,{columnCount:g,rowCount:f}=p,b=r&&o;let C=null,w=null;e<0?(C=0,w=m):e>0?(C=g-1,w=m):n<0?(C=u,w=0):n>0&&(C=u,w=f-1),C!=null&&w!=null&&i.moveCursorToPosition(C,w,o,!0,b)}else{if(!i.metrics)throw new Error("grid.metrics are not set");const{theme:p}=i.props,{autoSelectRow:g=!1,autoSelectColumn:f=!1}=p;if(g&&e!==0){const{lastLeft:b}=i.metrics;let{left:C}=i.state;C=At(C+e,0,b),i.moveCursorToPosition(C,l,o,!1),i.setViewState({left:C})}else if(f&&n!==0){const{lastTop:b}=i.metrics;let{top:C}=i.state;C=At(C+n,0,b),i.moveCursorToPosition(C,a,o,!1),i.setViewState({top:C})}else i.moveCursor(e,n,o)}return!0}handlePageUp(e,n){const s=e.shiftKey;s?n.trimSelectedRanges():n.clearSelectedRanges();const{cursorColumn:i,selectionEndRow:o}=n.state,r=o,l=i;if(r==null)return!1;const a=n.getMetricState(),{metricCalculator:d}=n,{bottomVisible:c,topVisible:u,hasHorizontalBar:m}=d.getMetrics(a);let p=r-(c-u);p-=m?0:1,p=Math.max(p,0);const g=Math.max(p-(r-u),0);return n.moveCursorToPosition(l,p,s,!1),n.setViewState({top:g}),!0}handlePageDown(e,n){const s=e.shiftKey;s?n.trimSelectedRanges():n.clearSelectedRanges();const{selectionEndRow:i,cursorColumn:o}=n.state,r=i,l=o;if(r===null)return!1;const a=n.getMetricState(),{metricCalculator:d}=n,{bottomVisible:c,topVisible:u,hasHorizontalBar:m,rowCount:p,lastTop:g}=d.getMetrics(a),f=p-1;let b=c-u+r;b+=m?0:1,b=Math.min(b,f);const C=Math.min(g,b-(r-u));return n.moveCursorToPosition(l,b,s,!1),n.setViewState({top:C}),!0}}class W0 extends Ci{onDown(e,n){switch(e.key){case"Enter":case" ":return this.handleExpandKey(e,n)}return!1}handleExpandKey(e,n){const{selectedRanges:s}=n.state;if(s.length===1){const i=s[0];if(i.startRow===i.endRow&&i.startColumn===i.endColumn){if(!n.metrics)throw new Error("grid.metrics not set");const{model:o}=n.props,{startRow:r,startColumn:l}=i;if(r!=null){const a=n.getModelRow(r);if((l===0||l==null)&>(o)&&o.isRowExpandable(a))return n.toggleRowExpanded(r),!0}}}return!1}}class G0 extends Ci{onDown(e,n){if(G.isModifierKeyDown(e))return!1;const{model:s}=n.props,{cursorColumn:i,cursorRow:o}=n.state;if(i==null||o==null||!Ze(s)||!s.isEditableRange(re.makeCell(i,o)))return!1;const r=i,l=o;return r==null||l==null?!1:e.key.length===1?(n.startEditing(r,l,!0,[1,1],e.key),!0):e.key==="F2"?(n.startEditing(r,l),!0):e.key==="Backspace"?(n.startEditing(r,l,!0,void 0,""),!0):e.key==="Delete"?(n.setValueForCell(r,l,""),!0):!1}}function K0(t){var s,i;const e=[],n=t.querySelectorAll("tr");for(let o=0;o<n.length;o+=1){const l=n[o].querySelectorAll("td"),a=[];for(let d=0;d<l.length;d+=1){const c=l[d];a.push((i=(s=c.textContent)==null?void 0:s.trim())!=null?i:"")}e.push(a)}return e}function q0(t){const e=[];return t.forEach(n=>{var i;const s=(i=n.textContent)!=null?i:"";s.length>0&&e.push(s.split(/\t|\u00a0\u00a0 \u00a0/))}),e}function Y0(t){var s,i;const e=t.querySelector("table");if(e!=null)return K0(e);const n=(i=(s=t.textContent)==null?void 0:s.trim())!=null?i:"";if(n.length>0){const{childNodes:o}=t,r=n.includes(" "),l=n.includes("\xA0\xA0 \xA0");return r&&o.length!==0&&(o.length===1||o.length>1&&(o[0].textContent==null||!o[0].textContent.includes(" ")))?n.split(`
|
|
22
|
+
`)}this.bufferedMessages=[],this.appendLogText(t)}queue(t){this.bufferedMessages.push(t),this.bufferedMessages.length===1&&(this.flushTimer=setTimeout(this.handleFlushTimeout,Ot.bufferTimeout))}stopFlushTimer(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=void 0)}updateDimensions(){this.editor&&this.editor.layout()}handleClearClick(){this.clearLogs()}clearLogs(){this.messages=[],this.refreshLogText()}handleFlushTimeout(){this.stopFlushTimer(),this.flush()}handleLogMessage(t){this.messages.push(t),this.editor&&this.isLogItemVisible(t)&&this.queue(t)}handleMenuItemClick(t){this.toggleLogLevel(t)}handleResetClick(){this.resetLogLevels()}handleResize(){this.updateDimensions()}handleToggleAllClick(){this.toggleAll()}render(){const t={placement:"bottom-end"},{shownLogLevels:e}=this.state,n=this.getMenuActions(e);return v("div",{className:"log-pane h-100 w-100",children:[v("div",{className:"log-pane-menu",children:[h(Q,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:rC,tooltip:"Clear log"}),h(Q,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:zo,tooltip:"Log Settings",onClick:()=>{},children:h(Wn,{actions:n,popperClassName:"log-level-menu-popper",popperOptions:t})})]}),h("div",{className:"log-pane-editor h-100 w-100",ref:s=>{this.editorContainer=s}})]})}};let Qi=Ot;Qi.DefaultLogLevels=[bt.STDOUT,bt.ERROR,bt.FATAL,bt.STDERR,bt.WARN];Qi.AllLogLevels=[bt.INFO,bt.STDOUT,bt.ERROR,bt.FATAL,bt.STDERR,bt.WARN,bt.DEBUG,bt.TRACE];Qi.bufferTimeout=16;Qi.maxLogSize=131072;Qi.truncateSize=65536;class Je{static isValid(e){return!0}static isSameFormat(e,n){throw new Error("isSameFormat not implemented")}static makeFormat(e,n,s){return{label:e,formatString:n,type:s}}format(e,n){return""}}Je.TYPE_GLOBAL="type-global";Je.TYPE_CONTEXT_PRESET="type-context-preset";Je.TYPE_CONTEXT_CUSTOM="type-context-custom";class Vb extends Je{format(e){switch(e){case 1:case!0:return"true";case 0:case!1:return"false";default:return""}}}class Ub extends Je{format(e){return String.fromCharCode(e)}}const nh=X.module("DateTimeColumnFormatter"),js=class extends Je{constructor({timeZone:t="",showTimeZone:e=!0,showTSeparator:n=!1,defaultDateTimeFormatString:s=js.DEFAULT_DATETIME_FORMAT_STRING}={}){super();const i=t||js.DEFAULT_TIME_ZONE_ID;try{this.dhTimeZone=M.i18n.TimeZone.getTimeZone(i)}catch{nh.error("Unsupported time zone id",i),this.dhTimeZone=M.i18n.TimeZone.getTimeZone(js.DEFAULT_TIME_ZONE_ID)}this.defaultDateTimeFormatString=s,this.showTimeZone=e,this.showTSeparator=n,this.formatStringMap=js.makeFormatStringMap(e,n)}static isValid(t){try{return M.i18n.DateTimeFormat.format(t.formatString,new Date),!0}catch{return!1}}static makeFormat(t,e,n=Je.TYPE_CONTEXT_PRESET){return{label:t,formatString:e,type:n}}static isSameFormat(t,e){return t===e||t!==null&&e!==null&&t.type===e.type&&t.formatString===e.formatString}static makeGlobalFormatStringMap(t,e){const n=e?"'T'":" ",s=t?" z":"";return new Map([["yyyy-MM-dd HH:mm:ss",`yyyy-MM-dd${n}HH:mm:ss${s}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${n}HH:mm:ss.SSS${s}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${n}HH:mm:ss.SSSSSSSSS${s}`]])}static getGlobalFormats(t,e){return[...js.makeGlobalFormatStringMap(t,e).keys()]}static makeFormatStringMap(t,e){const n=e!==void 0&&e?"'T'":" ",s=t!==void 0&&t?" z":"";return new Map([["yyyy-MM-dd",`yyyy-MM-dd${s}`],["MM-dd-yyyy",`MM-dd-yyyy${s}`],["HH:mm:ss",`HH:mm:ss${s}`],["HH:mm:ss.SSS",`HH:mm:ss.SSS${s}`],["HH:mm:ss.SSSSSSSSS",`HH:mm:ss.SSSSSSSSS${s}`],["yyyy-MM-dd HH:mm:ss",`yyyy-MM-dd${n}HH:mm:ss${s}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${n}HH:mm:ss.SSS${s}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${n}HH:mm:ss.SSSSSSSSS${s}`]])}static getFormats(t,e){return[...js.makeFormatStringMap(t,e).keys()]}getEffectiveFormatString(t){var e;return(e=this.formatStringMap.get(t))!=null?e:t}format(t,e){const n=e&&e.formatString||this.defaultDateTimeFormatString,s=this.getEffectiveFormatString(n);try{return M.i18n.DateTimeFormat.format(s,t,this.dhTimeZone)}catch{nh.error("Invalid format arguments")}return""}};let at=js;at.DEFAULT_DATETIME_FORMAT_STRING="yyyy-MM-dd HH:mm:ss.SSS";at.DEFAULT_TIME_ZONE_ID="America/New_York";const Bb=X.module("DecimalColumnFormatter"),Fn=class extends Je{constructor({defaultFormatString:t=Fn.DEFAULT_FORMAT_STRING}={}){super(),this.defaultFormatString=t}static isValid(t){try{return M.i18n.NumberFormat.format(t.formatString,0),!0}catch{return!1}}static makeFormat(t,e,n=Je.TYPE_CONTEXT_PRESET,s){return{label:t,type:n,formatString:e,multiplier:s}}static makePresetFormat(t,e="",n){return Fn.makeFormat(t,e,Je.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(t="",e){return Fn.makeFormat("Custom Format",t,Je.TYPE_CONTEXT_CUSTOM,e)}static isSameFormat(t,e){return t===e||t!=null&&e!=null&&t.type===e.type&&t.formatString===e.formatString&&t.multiplier===e.multiplier}format(t,e){const n=e&&e.formatString||this.defaultFormatString,s=e&&e.multiplier!==void 0&&e.multiplier!==0?t*e.multiplier:t;try{return M.i18n.NumberFormat.format(n,s)}catch{Bb.error("Invalid format arguments")}return""}};let Pe=Fn;Pe.DEFAULT_FORMAT_STRING="###,##0.0000";Pe.FORMAT_PERCENT=Fn.makePresetFormat("Percent","##0.00%");Pe.FORMAT_BASIS_POINTS=Fn.makePresetFormat("Basis Points","###,##0 bp",1e4);Pe.FORMAT_MILLIONS=Fn.makePresetFormat("Millions","###,##0.000 mm",1e-6);Pe.FORMAT_SCIENTIFIC_NOTATION=Fn.makePresetFormat("Scientific Notation","0.0000E0");Pe.FORMAT_ROUND=Fn.makePresetFormat("Round","###,##0");Pe.FORMAT_ROUND_TWO_DECIMALS=Fn.makePresetFormat("0.00","###,##0.00");Pe.FORMAT_ROUND_FOUR_DECIMALS=Fn.makePresetFormat("0.0000","###,##0.0000");class $b extends Je{format(e){return`${e}`}}const zb=X.module("IntegerColumnFormatter"),Hi=class extends Je{constructor({defaultFormatString:t=Hi.DEFAULT_FORMAT_STRING}={}){super(),this.defaultFormatString=t}static isValid(t){try{return M.i18n.NumberFormat.format(t.formatString,0),!0}catch{return!1}}static makeFormat(t,e,n=Je.TYPE_CONTEXT_PRESET,s){return{label:t,type:n,formatString:e,multiplier:s}}static makePresetFormat(t,e="",n){return Hi.makeFormat(t,e,Je.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(t="",e){return Hi.makeFormat("Custom Format",t,Je.TYPE_CONTEXT_CUSTOM,e)}static isSameFormat(t,e){return t===e||t!=null&&e!=null&&t.type===e.type&&t.formatString===e.formatString&&t.multiplier===e.multiplier}format(t,e){const n=e&&e.formatString||this.defaultFormatString,s=e&&e.multiplier!==void 0&&e.multiplier!==0?t*e.multiplier:t;try{return M.i18n.NumberFormat.format(n,s)}catch{zb.error("Invalid format arguments")}return""}};let nt=Hi;nt.DEFAULT_FORMAT_STRING="###,##0";nt.FORMAT_MILLIONS=Hi.makePresetFormat("Millions","###,##0.000 mm",1e-6);nt.FORMAT_SCIENTIFIC_NOTATION=Hi.makePresetFormat("Scientific Notation","0.0000E0");class Wb extends Je{format(e){return e}}const Bt=class{static makeDateWrapper(t,e,n=0,s=1,i=0,o=0,r=0,l=0){if(!t)throw new Error("No timezone provided");const a=`${e}`.padStart(4,"0"),d=`${n+1}`.padStart(2,"0"),c=`${s}`.padStart(2,"0"),u=`${i}`.padStart(2,"0"),m=`${o}`.padStart(2,"0"),p=`${r}`.padStart(2,"0"),g=`${l}`.padStart(9,"0"),f=`${a}-${d}-${c} ${u}:${m}:${p}.${g}`;return M.i18n.DateTimeFormat.parse(Bt.FULL_DATE_FORMAT,f,M.i18n.TimeZone.getTimeZone(t))}static getNextNanos(t){const e=parseInt(t,10),n="0".repeat(9-t.length),s=`${e+1}${n}`;return parseInt(s,10)}static getNextDate(t,e,n){let{year:s,month:i,date:o,hours:r,minutes:l,seconds:a,nanos:d}=e;if(t.nanos!=null){if(t.nanos.length===9)return null;d=Bt.getNextNanos(t.nanos),d>999999999&&(a+=1,d=0)}else t.seconds!=null?a+=1:t.minutes!=null?l+=1:t.hours!=null?r+=1:t.date!=null?o+=1:t.month!=null?i+=1:s+=1;const c=new Date(s,i,o,r,l,a);return Bt.makeDateWrapper(n,c.getFullYear(),c.getMonth(),c.getDate(),c.getHours(),c.getMinutes(),c.getSeconds(),d)}static parseMonth(t){const e=parseInt(t,10);if(!Number.isNaN(e))return e>=1&&e<=12?e-1:NaN;const n=t.trim().toLowerCase();if(n.length>=3){for(let s=0;s<Bt.months.length;s+=1)if(Bt.months[s].startsWith(n))return s}return NaN}static parseDateValues(t,e,n,s,i,o,r){const l=parseInt(t,10),a=e!=null?this.parseMonth(e):0,d=n!=null?parseInt(n,10):1,c=s!=null?parseInt(s,10):0,u=i!=null?parseInt(i,10):0,m=o!=null?parseInt(o,10):0,p=r!=null?parseInt(r.padEnd(9,"0"),10):0;return Number.isNaN(l)||Number.isNaN(a)||Number.isNaN(d)||Number.isNaN(c)||Number.isNaN(u)||Number.isNaN(m)||Number.isNaN(p)?null:{year:l,month:a,date:d,hours:c,minutes:u,seconds:m,nanos:p}}static parseDateTimeString(t){const n=/\s*(\d{4})([-./]([\da-z]+))?([-./](\d{1,2}))?([tT\s](\d{2})([:](\d{2}))?([:](\d{2}))?([.](\d{1,9}))?)?(.*)/.exec(t);if(n==null)throw new Error(`Unexpected date string: ${t}`);const[,s,,i,,o,,r,,l,,a,,d,c]=n;if(c!=null&&c.length>0)throw new Error(`Unexpected characters after date string '${t}': ${c}`);return{year:s,month:i,date:o,hours:r,minutes:l,seconds:a,nanos:d}}static parseDateRange(t,e){const n=t.trim().toLowerCase();if(n.length===0)throw new Error("Cannot parse date range from empty string");if(n==="null")return[null,null];if(n==="today"){const l=new Date(Date.now()),a=Bt.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()),d=Bt.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()+1);return[a,d]}if(n==="yesterday"){const l=new Date(Date.now()),a=Bt.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()-1),d=Bt.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate());return[a,d]}if(n==="now"){const l=new Date(Date.now());return[M.DateWrapper.ofJsDate(l),null]}const s=Bt.parseDateTimeString(n);if(s.year==null&&s.month==null&&s.date==null)throw new Error(`Unable to extract year, month, or day ${n}`);const i=Bt.parseDateValues(s.year,s.month,s.date,s.hours,s.minutes,s.seconds,s.nanos);if(i==null)throw new Error(`Unable to extract date values from ${s}`);const o=Bt.makeDateWrapper(e,i.year,i.month,i.date,i.hours,i.minutes,i.seconds,i.nanos),r=Bt.getNextDate(s,i,e);return[o,r]}static getJsDate(t){return typeof t=="number"?new Date(t):t.asDate()}};let us=Bt;us.FULL_DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSSSSS";us.months=["january","february","march","april","may","june","july","august","september","october","november","december"];class Wt{}Wt.not="not";Wt.and="and";Wt.or="or";function Gb(t){if(!(t==="not"||t==="and"||t==="or"))throw new Error("operator is not a valid FilterOperatorValue")}class q{}q.eq="eq";q.eqIgnoreCase="eqIgnoreCase";q.notEq="notEq";q.notEqIgnoreCase="notEqIgnoreCase";q.greaterThan="greaterThan";q.greaterThanOrEqualTo="greaterThanOrEqualTo";q.lessThan="lessThan";q.lessThanOrEqualTo="lessThanOrEqualTo";q.in="in";q.inIgnoreCase="inIgnoreCase";q.notIn="notIn";q.notInIgnoreCase="notInIgnoreCase";q.isTrue="isTrue";q.isFalse="isFalse";q.isNull="isNull";q.invoke="invoke";q.contains="contains";q.notContains="notContains";q.startsWith="startsWith";q.endsWith="endsWith";q.containsAny="containsAny";function Kb(t){switch(t){case q.eq:return"is exactly";case q.eqIgnoreCase:return"is exactly (ignore case)";case q.notEq:return"is not exactly";case q.notEqIgnoreCase:return"is not exactly (ignore case)";case q.contains:return"contains";case q.notContains:return"does not contain";case q.startsWith:return"starts with";case q.endsWith:return"ends with";default:throw new Error(`Unrecognized text filter type ${t}`)}}function qb(t){switch(t){case q.eq:return"is equal to";case q.notEq:return"is not equal to";case q.greaterThan:return"greater than";case q.greaterThanOrEqualTo:return"greater than or equal to";case q.lessThan:return"less than";case q.lessThanOrEqualTo:return"less than or equal to";default:throw new Error(`Unrecognized number filter type ${t}`)}}function Yb(t){switch(t){case q.eq:return"date is";case q.notEq:return"date is not";case q.notEqIgnoreCase:case q.greaterThan:return"date is after";case q.greaterThanOrEqualTo:return"date is after or equal";case q.lessThan:return"date is before";case q.lessThanOrEqualTo:return"date is before or equal";default:throw new Error(`Unrecognized date filter type ${t}`)}}function Xb(t){switch(t){case q.isTrue:return"Is True";case q.isFalse:return"Is False";case q.isNull:return"Is Null";default:throw new Error(`Unrecognized boolean filter type ${t}`)}}const Jn=X.module("TableUtils"),ne=class{static getSortIndex(t,e){var n;for(let s=0;s<t.length;s+=1)if(((n=t[s].column)==null?void 0:n.index)===e)return s;return null}static getSortForColumn(t,e){const n=ne.getSortIndex(t,e);return n!=null?t[n]:null}static getFilterText(t){return t?t.toString():null}static getFilterTypes(t){return ne.isBooleanType(t)?[q.isTrue,q.isFalse,q.isNull]:ne.isCharType(t)||ne.isNumberType(t)||ne.isDateType(t)?[q.eq,q.notEq,q.greaterThan,q.greaterThanOrEqualTo,q.lessThan,q.lessThanOrEqualTo]:ne.isTextType(t)?[q.eq,q.eqIgnoreCase,q.notEq,q.notEqIgnoreCase,q.contains,q.notContains,q.startsWith,q.endsWith]:[]}static getNextSort(t,e,n){if(t==null||n<0||n>=t.length)return null;const s=ne.getSortForColumn(e,n);return s===null?t[n].sort().asc():s.direction===ne.sortDirection.ascending?s.desc():null}static makeColumnSort(t,e,n,s){if(t==null||e<0||e>=t.length||n===ne.sortDirection.none)return null;let i=t[e].sort();switch(n){case ne.sortDirection.ascending:i=i.asc();break;case ne.sortDirection.descending:i=i.desc();break}return s&&(i=i.abs()),i}static toggleSortForColumn(t,e,n,s=!1){if(n<0||n>=e.length)return[];const i=ne.getNextSort(e,t,n);return ne.setSortForColumn(t,n,i,s)}static sortColumn(t,e,n,s,i,o){if(t==null||n<0||n>=e.length)return[];const r=ne.makeColumnSort(e,n,s,i);return ne.setSortForColumn(t,n,r,o)}static setSortForColumn(t,e,n,s=!1){const i=ne.getSortIndex(t,e);let o=[];return s&&(o=o.concat(t.filter(({direction:r})=>r!==ne.sortDirection.reverse)),i!==null&&o.splice(i,1)),n!==null&&o.push(n),o}static getNormalizedType(t){switch(t){case"boolean":case"java.lang.Boolean":case ne.dataType.BOOLEAN:return ne.dataType.BOOLEAN;case"char":case"java.lang.Character":case ne.dataType.CHAR:return ne.dataType.CHAR;case"java.lang.String":case ne.dataType.STRING:return ne.dataType.STRING;case"io.deephaven.db.tables.utils.DBDateTime":case"io.deephaven.time.DateTime":case"com.illumon.iris.db.tables.utils.DBDateTime":case ne.dataType.DATETIME:return ne.dataType.DATETIME;case"double":case"java.lang.Double":case"float":case"java.lang.Float":case"java.math.BigDecimal":case ne.dataType.DECIMAL:return ne.dataType.DECIMAL;case"int":case"java.lang.Integer":case"long":case"java.lang.Long":case"short":case"java.lang.Short":case"byte":case"java.lang.Byte":case"java.math.BigInteger":case ne.dataType.INT:return ne.dataType.INT;default:return ne.dataType.UNKNOWN}}static isLongType(t){switch(t){case"long":case"java.lang.Long":return!0;default:return!1}}static isDateType(t){switch(t){case"io.deephaven.db.tables.utils.DBDateTime":case"io.deephaven.time.DateTime":case"com.illumon.iris.db.tables.utils.DBDateTime":return!0;default:return!1}}static isNumberType(t){return ne.isIntegerType(t)||ne.isDecimalType(t)}static isIntegerType(t){switch(t){case"int":case"java.lang.Integer":case"java.math.BigInteger":case"long":case"java.lang.Long":case"short":case"java.lang.Short":case"byte":case"java.lang.Byte":return!0;default:return!1}}static isDecimalType(t){switch(t){case"double":case"java.lang.Double":case"java.math.BigDecimal":case"float":case"java.lang.Float":return!0;default:return!1}}static isBooleanType(t){switch(t){case"boolean":case"java.lang.Boolean":return!0;default:return!1}}static isCharType(t){switch(t){case"char":case"java.lang.Character":return!0;default:return!1}}static isStringType(t){switch(t){case"java.lang.String":return!0;default:return!1}}static isTextType(t){return this.isStringType(t)||this.isCharType(t)}static getBaseType(t){return t.split("[]")[0]}static isCompatibleType(t,e){return ne.getNormalizedType(t)===ne.getNormalizedType(e)}static makeQuickFilter(t,e,n){const s=e.split("||");let i=null;for(let o=0;o<s.length;o+=1){const l=s[o].split("&&");let a=null;for(let d=0;d<l.length;d+=1){const c=l[d].trim();if(c.length>0){const u=ne.makeQuickFilterFromComponent(t,c,n);if(u)a?a=a.and(u):a=u;else throw new Error(`Unable to parse quick filter from text ${e}`)}}i&&a?i=i.or(a):i=a}return i}static makeQuickFilterFromComponent(t,e,n){const{type:s}=t;return ne.isNumberType(s)?this.makeQuickNumberFilter(t,e):ne.isBooleanType(s)?this.makeQuickBooleanFilter(t,e):n!=null&&ne.isDateType(s)?this.makeQuickDateFilter(t,e,n):ne.isCharType(s)?this.makeQuickCharFilter(t,e):this.makeQuickTextFilter(t,e)}static makeQuickNumberFilter(t,e){if(e==null)return null;const n=t.filter();let s=null;const o=/\s*(>=|<=|=>|=<|>|<|!=|=|!)?(\s*-\s*)?(\s*\d*(?:,\d{3})*(?:\.\d*)?\s*)?(null|nan|infinity|inf|\u221E)?(.*)/i.exec(e);let r=null,l=null,a=null,d=null,c=null;if(o!==null&&o.length>3&&([,r,l,a,d,c]=o),c!=null&&c.trim().length>0)return null;if(r==null&&(r="="),d!=null){if(!(r==="="||r==="!"||r==="!="))return null;switch(d=d.trim().toLowerCase(),d){case"null":s=n.isNull();break;case"nan":s=M.FilterCondition.invoke("isNaN",n);break;case"infinity":case"inf":case"\u221E":l!=null?s=M.FilterCondition.invoke("isInf",n).and(n.lessThan(M.FilterValue.ofNumber(0))):s=M.FilterCondition.invoke("isInf",n).and(n.greaterThan(M.FilterValue.ofNumber(0)));break}return s!==null&&(r==="!"||r==="!=")&&(s=s.not()),s}if(a==null)return null;if(a=ne.removeCommas(a),ne.isLongType(t.type))try{a=M.FilterValue.ofNumber(M.LongWrapper.ofString(`${l!=null?"-":""}${a}`))}catch(u){return Jn.warn("Unable to create long filter",u),null}else{if(a=parseFloat(a),a==null||Number.isNaN(a))return null;a=M.FilterValue.ofNumber(l!=null?0-a:a)}return s=t.filter(),ne.makeRangeFilterWithOperation(s,r,a)}static makeQuickTextFilter(t,e){if(e==null)return null;const n=`${e}`.trim(),i=/^(!~|!=|~|=|!)?(.*)/.exec(n);let o=null,r=null;if(i!==null&&i.length>2&&([,o,r]=i,r!=null&&(r=r.trim())),r==null||r.length===0)return null;o==null&&(o="=");const l=t.filter();if(r.toLowerCase()==="null")switch(o){case"=":return l.isNull();case"!=":case"!":return l.isNull().not();default:return null}let a=null,d=null;switch(r.startsWith("*")?(a="*",r=r.substring(1)):r.endsWith("*")&&!r.endsWith("\\*")&&(d="*",r=r.substring(0,r.length-1)),r=r.replace("\\",""),o){case"~":return l.isNull().not().and(l.invoke("matches",M.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E.*`)));case"!~":return l.isNull().or(l.invoke("matches",M.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E.*`)).not());case"!=":return a==="*"?l.isNull().or(l.invoke("matches",M.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E$`)).not()):d==="*"?l.isNull().or(l.invoke("matches",M.FilterValue.ofString(`(?s)(?i)^\\Q${r}\\E.*`)).not()):l.notEqIgnoreCase(M.FilterValue.ofString(r.toLowerCase()));case"=":return a==="*"?l.isNull().not().and(l.invoke("matches",M.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E$`))):d==="*"?l.isNull().not().and(l.invoke("matches",M.FilterValue.ofString(`(?s)(?i)^\\Q${r}\\E.*`))):l.eqIgnoreCase(M.FilterValue.ofString(r.toLowerCase()))}return null}static makeQuickBooleanFilter(t,e){if(e==null)return null;const s=/^(!=|=|!)?(.*)/.exec(`${e}`.trim());if(s===null)return null;const[,i,o]=s,r=i==="!"||i==="!=",l=o.trim().toLowerCase();let a=t.filter();try{const d=ne.makeBooleanValue(l);return d!=null&&d?a=a.isTrue():d===null?a=a.isNull():a=a.isFalse(),r?a.not():a}catch{return null}}static makeQuickDateFilter(t,e,n){const s=e.trim(),o=/\s*(>=|<=|=>|=<|>|<|!=|!|=)?(.*)/.exec(s);if(o==null||o.length<=2)throw new Error(`Unable to parse date filter: ${e}`);let r=null,l=null;[,r,l]=o;let a=q.eq;switch(r){case"<":a=q.lessThan;break;case"<=":case"=<":a=q.lessThanOrEqualTo;break;case">":a=q.greaterThan;break;case">=":case"=>":a=q.greaterThanOrEqualTo;break;case"!=":case"!":a=q.notEq;break;case"=":case"==":default:a=q.eq;break}return ne.makeQuickDateFilterWithOperation(t,l,a,n)}static makeQuickDateFilterWithOperation(t,e,n=q.eq,s){if(t==null)throw new Error("Column is null");const[i,o]=us.parseDateRange(e,s),r=i!=null?M.FilterValue.ofNumber(i):null,l=o!=null?M.FilterValue.ofNumber(o):null,a=t.filter();if(r==null)return n===q.notEq?a.isNull().not():a.isNull();switch(n){case q.eq:{if(l!=null){const d=a.greaterThanOrEqualTo(r),c=a.lessThan(l);return d.and(c)}return a.eq(r)}case q.lessThan:return a.lessThan(r);case q.lessThanOrEqualTo:return l!=null?a.lessThan(l):a.lessThanOrEqualTo(r);case q.greaterThan:return l!=null?a.greaterThanOrEqualTo(l):a.greaterThan(r);case q.greaterThanOrEqualTo:return a.greaterThanOrEqualTo(r);case q.notEq:{if(l!=null){const d=a.lessThan(r),c=a.greaterThanOrEqualTo(l);return d.or(c)}return a.notEq(r)}default:throw new Error(`Invalid operator: ${n}`)}}static quoteValue(t){return t.length>=2&&(t.charAt(0)==='"'&&t.charAt(t.length-1)==='"'||t.charAt(0)==="'"&&t.charAt(t.length-1)==="'")?t:`"${t}"`}static isRangeOperation(t){switch(t){case"<":case"<=":case"=<":case">":case">=":case"=>":return!0;default:return!1}}static makeQuickCharFilter(t,e){if(e==null)return null;const n=`${e}`.trim(),i=/^(>=|<=|=>|=<|>|<|!=|=|!)?(null|"."|'.'|.)?(.*)/.exec(n);let o=null,r=null,l=null;if(i!==null&&i.length>3&&([,o,r,l]=i),l!=null&&l.trim().length>0||r==null||r.length===0)return null;o==null&&(o="=");const a=t.filter();if(r.toLowerCase()==="null")switch(o){case"=":return a.isNull();case"!=":case"!":return a.isNull().not();default:return null}const d=M.FilterValue.ofString(ne.isRangeOperation(o)?ne.quoteValue(r):r);return ne.makeRangeFilterWithOperation(a,o,d)}static makeRangeFilterWithOperation(t,e,n){switch(e){case"=":return t.eq(n);case"<":return t.lessThan(n);case"<=":case"=<":return t.lessThanOrEqualTo(n);case">":return t.greaterThan(n);case">=":case"=>":return t.greaterThanOrEqualTo(n);case"!=":case"!":return t.notEq(n);default:return null}}static makeCancelableTablePromise(t){return Ee.makeCancelable(t,e=>{e.close()})}static makeCancelableTableEventPromise(t,e,n=0,s=null){let i,o,r=!0;const l=new Promise((a,d)=>{o=setTimeout(()=>{i(),r=!1,d(new vu(`Event "${e}" timed out.`))},n),i=t.addEventListener(e,c=>{if(s!=null&&!s(c)){Jn.debug2("Event triggered, but matcher returned false.");return}Jn.debug2("Event triggered, resolving."),i(),clearTimeout(o),r=!1,a(c)})});return l.cancel=()=>{if(r){Jn.debug2("Pending promise cleanup."),i(),clearTimeout(o),r=!1;return}Jn.debug2("Ignoring non-pending promise cancel.")},l}static makeAdvancedFilter(t,e,n){const{filterItems:s,filterOperators:i,invertSelection:o,selectedValues:r}=e;let l=null;for(let d=0;d<s.length;d+=1){const c=s[d],{selectedType:u,value:m}=c;if(u!=null&&u.length>0&&m!=null&&m.length>0)try{const p=ne.makeAdvancedValueFilter(t,u,m,n);if(p!=null){if(d===0)l=p;else if(l!==null&&d-1<i.length){const g=i[d-1];if(g===Wt.and)l=l.and(p);else if(g===Wt.or)l=l.or(p);else{Jn.error("Unexpected filter operator",g,p),l=null;break}}}else Jn.debug2("Empty filter ignored for",u,m)}catch(p){Jn.error("Unable to create filter",p),l=null;break}}const a=ne.makeSelectValueFilter(t,r,o);return a!=null&&(l!=null?l=l.and(a):l=a),l}static removeCommas(t){return t.replace(/[\s|,]/g,"")}static makeFilterValue(t,e){const n=ne.getBaseType(t);return ne.isTextType(n)?M.FilterValue.ofString(e):ne.isLongType(n)?M.FilterValue.ofNumber(M.LongWrapper.ofString(ne.removeCommas(e))):M.FilterValue.ofNumber(ne.removeCommas(e))}static makeFilterRawValue(t,e){return ne.isTextType(t)?M.FilterValue.ofString(e):ne.isBooleanType(t)?M.FilterValue.ofBoolean(e):M.FilterValue.ofNumber(e)}static makeValue(t,e,n){if(e==null||e==="null")return null;if(ne.isTextType(t))return e;if(ne.isLongType(t))return M.LongWrapper.ofString(ne.removeCommas(e));if(ne.isBooleanType(t))return ne.makeBooleanValue(e,!0);if(ne.isDateType(t)){const[s]=us.parseDateRange(e,n);return s}return ne.isNumberType(t)?ne.makeNumberValue(e):(Jn.error("Unexpected column type",t),null)}static makeBooleanValue(t,e=!1){if(t===""&&e)return null;switch(t==null?void 0:t.toLowerCase()){case"null":return null;case"0":case"f":case"fa":case"fal":case"fals":case"false":case"n":case"no":return!1;case"1":case"t":case"tr":case"tru":case"true":case"y":case"ye":case"yes":return!0;default:throw new Error(`Invalid boolean '${t}'`)}}static makeNumberValue(t){if(t==null||t==="null"||t==="")return null;const e=t.toLowerCase().trim();if(e==="\u221E"||e==="infinity"||e==="inf")return Number.POSITIVE_INFINITY;if(e==="-\u221E"||e==="-infinity"||e==="-inf")return Number.NEGATIVE_INFINITY;const n=ne.removeCommas(e);if(ne.NUMBER_REGEX.test(n))return parseFloat(n);throw new Error(`Invalid number '${t}'`)}static getFilterOperatorString(t){switch(t){case q.eq:return"=";case q.notEq:return"!=";case q.greaterThan:return">";case q.greaterThanOrEqualTo:return">=";case q.lessThan:return"<";case q.lessThanOrEqualTo:return"<=";case q.contains:return"~";case q.notContains:return"!~";default:throw new Error(`Unexpected filter type ${t}`)}}static makeAdvancedValueFilter(t,e,n,s){if(ne.isDateType(t.type))return ne.makeQuickDateFilterWithOperation(t,n,e,s);if(ne.isNumberType(t.type)||ne.isCharType(t.type))return ne.makeQuickFilter(t,`${ne.getFilterOperatorString(e)}${n}`);const i=ne.makeFilterValue(t.type,n),o=t.filter();switch(e){case q.eq:return o.eq(i);case q.eqIgnoreCase:return o.eqIgnoreCase(i);case q.notEq:return o.notEq(i);case q.notEqIgnoreCase:return o.notEqIgnoreCase(i);case q.greaterThan:return o.greaterThan(i);case q.greaterThanOrEqualTo:return o.greaterThanOrEqualTo(i);case q.lessThan:return o.lessThan(i);case q.lessThanOrEqualTo:return o.lessThanOrEqualTo(i);case q.isTrue:return o.isTrue();case q.isFalse:return o.isFalse();case q.isNull:return o.isNull();case q.contains:return o.isNull().not().and(o.invoke("matches",M.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)));case q.notContains:return o.isNull().or(o.invoke("matches",M.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)).not());case q.startsWith:return o.isNull().not().and(o.invoke("matches",M.FilterValue.ofString(`(?s)(?i)^\\Q${n}\\E.*`)));case q.endsWith:return o.isNull().not().and(o.invoke("matches",M.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E$`)));case q.in:case q.inIgnoreCase:case q.notIn:case q.notInIgnoreCase:case q.invoke:default:throw new Error(`Unexpected filter operation: ${e}`)}}static makeSelectValueFilter(t,e,n){if(e.length===0){if(n)return null;let o=null;ne.isTextType(t.type)?o=M.FilterValue.ofString("a"):ne.isBooleanType(t.type)?o=M.FilterValue.ofBoolean(!0):ne.isDateType(t.type)?o=M.FilterValue.ofNumber(M.DateWrapper.ofJsDate(new Date)):o=M.FilterValue.ofNumber(0);const r=t.filter().eq(o),l=t.filter().notEq(o);return r.and(l)}const s=[];let i=!1;for(let o=0;o<e.length;o+=1){const r=e[o];r==null?i=!0:ne.isTextType(t.type)?s.push(M.FilterValue.ofString(typeof r=="number"?String.fromCharCode(r):r)):ne.isBooleanType(t.type)?s.push(M.FilterValue.ofBoolean(Boolean(r))):s.push(M.FilterValue.ofNumber(r))}return i?s.length>0?n?t.filter().isNull().not().and(t.filter().notIn(s)):t.filter().isNull().or(t.filter().in(s)):n?t.filter().isNull().not():t.filter().isNull():n?t.filter().notIn(s):t.filter().in(s)}static isTreeTable(t){return t!=null&&t.expand!==void 0&&t.collapse!==void 0}static sortColumns(t,e=!0){return[...t].sort((n,s)=>{const i=n.name.toUpperCase(),o=s.name.toUpperCase();return tn.sort(i,o,e)})}};let P=ne;P.dataType={BOOLEAN:"boolean",CHAR:"char",DATETIME:"datetime",DECIMAL:"decimal",INT:"int",STRING:"string",UNKNOWN:"unknown"};P.sortDirection={ascending:"ASC",descending:"DESC",reverse:"REVERSE",none:null};P.REVERSE_TYPE=Object.freeze({NONE:"none",PRE_SORT:"pre-sort",POST_SORT:"post-sort"});P.NUMBER_REGEX=/^-?\d+(\.\d+)?$/;class cn{static makeColumnFormatMap(e){return e==null?new Map:e.reduce((n,s)=>{const i=P.getNormalizedType(s.columnType);if(i===null)return n;n.has(i)||n.set(i,new Map);const o=n.get(i);return o==null||o.set(s.columnName,s.format),n},new Map)}static makeColumnFormattingRule(e,n,s){return{columnType:e,columnName:n,format:s}}constructor(e=[],n,s,i,o=!1){this.defaultColumnFormatter=new $b,this.typeFormatterMap=new Map([[P.dataType.BOOLEAN,new Vb],[P.dataType.CHAR,new Ub],[P.dataType.DATETIME,new at(n)],[P.dataType.DECIMAL,new Pe(s)],[P.dataType.INT,new nt(i)],[P.dataType.STRING,new Wb]]),this.columnFormatMap=cn.makeColumnFormatMap(e),this.truncateNumbersWithPound=o}getColumnFormatMapForType(e,n=!1){const s=P.getNormalizedType(e);if(s!==null)return n&&!this.columnFormatMap.has(s)&&this.columnFormatMap.set(s,new Map),this.columnFormatMap.get(s)}getColumnFormat(e,n){var i;const s=this.getColumnFormatMapForType(e);return(i=s==null?void 0:s.get(n))!=null?i:null}getColumnTypeFormatter(e){var i;const n=P.getNormalizedType(e);let s=this.defaultColumnFormatter;return n&&(s=(i=this.typeFormatterMap.get(n))!=null?i:s),s}getFormattedString(e,n,s="",i){if(e==null)return"";const o=this.getColumnTypeFormatter(n),r=i||this.getColumnFormat(n,s);return o.format(e,r!=null?r:void 0)}get timeZone(){var n;const e=this.typeFormatterMap.get(P.dataType.DATETIME);return(n=e==null?void 0:e.dhTimeZone)==null?void 0:n.id}}function jb(t){if(t&&t.formatter){const{formatter:e}=t;return e}}function Qb(t){return{timeZone:t==null?void 0:t.timeZone,defaultDateTimeFormatString:t==null?void 0:t.defaultDateTimeFormat,showTimeZone:t==null?void 0:t.showTimeZone,showTSeparator:t==null?void 0:t.showTSeparator}}function Zb(t,e,n){const s=t.getColumnFormat(n,e);return s!=null&&(s.type===Je.TYPE_CONTEXT_PRESET||s.type===Je.TYPE_CONTEXT_CUSTOM)}const cs={getColumnFormats:jb,getDateTimeFormatterOptions:Qb,isCustomColumnFormatDefined:Zb};$r.register([Tg,Eg,yg,Ig,Rg,Dg]);const rm=typeof ta=="function"?ta($r):ta.default($r),is=class{constructor(){this.listeners=[],this.isDownsamplingDisabled=!1}getData(){return[]}getDefaultTitle(){return""}getLayout(){return{}}getFilterColumnMap(){return new Map}isFilterRequired(){return!1}setFilter(t){}close(){}setFormatter(t){this.formatter=t}setDownsamplingDisabled(t){this.isDownsamplingDisabled=t}setDimensions(t){this.rect=t}setTitle(t){this.title=t}subscribe(t){this.listeners.push(t)}unsubscribe(t){this.listeners=this.listeners.filter(e=>e!==t)}fireEvent(t){for(let e=0;e<this.listeners.length;e+=1)this.listeners[e](t)}fireUpdate(t){this.fireEvent(new CustomEvent(is.EVENT_UPDATED,{detail:t}))}fireDisconnect(){this.fireEvent(new CustomEvent(is.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(is.EVENT_RECONNECT))}fireDownsampleStart(t){this.fireEvent(new CustomEvent(is.EVENT_DOWNSAMPLESTARTED,{detail:t}))}fireDownsampleFinish(t){this.fireEvent(new CustomEvent(is.EVENT_DOWNSAMPLEFINISHED,{detail:t}))}fireDownsampleFail(t){this.fireEvent(new CustomEvent(is.EVENT_DOWNSAMPLEFAILED,{detail:t}))}fireDownsampleNeeded(t){this.fireEvent(new CustomEvent(is.EVENT_DOWNSAMPLENEEDED,{detail:t}))}fireLoadFinished(){this.fireEvent(new CustomEvent(is.EVENT_LOADFINISHED))}};let St=is;St.EVENT_UPDATED="ChartModel.EVENT_UPDATED";St.EVENT_DISCONNECT="ChartModel.EVENT_DISCONNECT";St.EVENT_RECONNECT="ChartModel.EVENT_RECONNECT";St.EVENT_DOWNSAMPLESTARTED="ChartModel.EVENT_DOWNSAMPLESTARTED";St.EVENT_DOWNSAMPLEFINISHED="ChartModel.EVENT_DOWNSAMPLEFINISHED";St.EVENT_DOWNSAMPLEFAILED="ChartModel.EVENT_DOWNSAMPLEFAILED";St.EVENT_DOWNSAMPLENEEDED="ChartModel.EVENT_DOWNSAMPLENEEDED";St.EVENT_LOADFINISHED="ChartModel.EVENT_LOADFINISHED";const Jb="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",eS="#403e41",tS="#5b5a5c",nS="#c0bfbf",sS="#4878ea",iS="rgba(91, 90, 92, 0.7)",yt={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:Jb,gridcolor:eS,linecolor:tS,zerolinecolor:nS,activecolor:sS,rangebgcolor:iS,"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"},zt=Object.freeze({paper_bgcolor:yt["paper-bgcolor"],plot_bgcolor:yt["plot-bgcolor"],title_color:yt["title-color"],colorway:yt.colorway,gridcolor:yt.gridcolor,linecolor:yt.linecolor,zerolinecolor:yt.zerolinecolor,activecolor:yt.activecolor,rangebgcolor:yt.rangebgcolor,area_color:yt["area-color"],trend_color:yt["trend-color"],line_color:yt["line-color"],error_band_line_color:yt["error-band-line-color"],error_band_fill_color:yt["error-band-fill-color"],ohlc_increasing:yt["ohlc-increasing"],ohlc_decreasing:yt["ohlc-decreasing"]}),Cr=X.module("ChartUtils"),ws=Object.freeze(M.calendar.DayOfWeek.values()),sh="io.deephaven.time.DateTime",oS=36e5,rS=1e6;function lS(t){return t.asDate!==void 0}function aS(t){return t.asNumber!==void 0}function ih(t){return t.dhTimeZone!==void 0}function dS(t){return t!=null&&t.range&&(t.autorange===!1||t.autorange===void 0)}const ie=class{static getPlotlyChartType(t,e){switch(t){case M.plot.SeriesPlotStyle.SCATTER:return e?"scatter":"scattergl";case M.plot.SeriesPlotStyle.LINE:return"scatter";case M.plot.SeriesPlotStyle.BAR:case M.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case M.plot.SeriesPlotStyle.PIE:return"pie";case M.plot.SeriesPlotStyle.TREEMAP:return"treemap";case M.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case M.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}static getPlotlyChartMode(t){switch(t){case M.plot.SeriesPlotStyle.SCATTER:return"markers";case M.plot.SeriesPlotStyle.LINE:return"lines";default:return}}static getPlotlyProperty(t,e){switch(t){case M.plot.SeriesPlotStyle.PIE:switch(e){case M.plot.SourceType.X:return"labels";case M.plot.SourceType.Y:return"values"}break;case M.plot.SeriesPlotStyle.OHLC:switch(e){case M.plot.SourceType.TIME:return"x"}break;case M.plot.SeriesPlotStyle.TREEMAP:switch(e){case M.plot.SourceType.X:return"ids";case M.plot.SourceType.Y:return"values";case M.plot.SourceType.LABEL:return"labels";case M.plot.SourceType.PARENT:return"parents";case M.plot.SourceType.COLOR:return"marker.colors"}break}switch(e){case M.plot.SourceType.X:return"x";case M.plot.SourceType.Y:return"y";case M.plot.SourceType.Z:return"z";case M.plot.SourceType.X_LOW:return"xLow";case M.plot.SourceType.X_HIGH:return"xHigh";case M.plot.SourceType.Y_LOW:return"yLow";case M.plot.SourceType.Y_HIGH:return"yHigh";case M.plot.SourceType.TIME:return"time";case M.plot.SourceType.OPEN:return"open";case M.plot.SourceType.HIGH:return"high";case M.plot.SourceType.LOW:return"low";case M.plot.SourceType.CLOSE:return"close";case M.plot.SourceType.SHAPE:return"shape";case M.plot.SourceType.SIZE:return"size";case M.plot.SourceType.LABEL:return"label";case M.plot.SourceType.COLOR:return"color";case M.plot.SourceType.PARENT:return"parent";case M.plot.SourceType.HOVER_TEXT:return"hovertext";case M.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${e}`)}}static getPlotlySeriesOrientation(t){var n,s;const{sources:e}=t;return e.length===2&&((s=(n=e[0])==null?void 0:n.axis)==null?void 0:s.type)===M.plot.AxisType.Y?ie.ORIENTATION.HORIZONTAL:ie.ORIENTATION.VERTICAL}static getPlotlyErrorBars(t,e,n){const s=n.map((o,r)=>o-t[r]),i=e.map((o,r)=>t[r]-o);return{type:"data",symmetric:!1,array:s,arrayminus:i}}static getPlotlyDateFormat(t,e,n){const s=n==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=t==null?void 0:t.getColumnTypeFormatter(e);return o!=null&&ih(o)&&o.dhTimeZone!=null&&o.showTimeZone&&(i=M.i18n.DateTimeFormat.format(" z",new Date,o.dhTimeZone)),{tickformat:s,ticksuffix:i,automargin:!0}}static convertNumberPrefix(t){return t.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(t,e,n){if(!n)return null;const i=n.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);A(i);const[,o,r,l,,a,d,c,u,m]=i,p=l.replace(",","").length,f=r.indexOf(",")>=0||l.indexOf(",")>=0?",":"",b=c!=null&&c!==""?"e":"f",C=u!==""?u:b,w=a.length+d.length,y=`0${p}${f}.${w}${C}`,E=ie.convertNumberPrefix(o),I=ie.convertNumberPrefix(m);return{tickformat:y,tickprefix:E,ticksuffix:I,automargin:!0}}static getPlotlyAxisFormat(t,e=null){const{axis:n,columnType:s}=t,{formatPattern:i}=n;let o=null;return P.isDateType(s)?(o=ie.getPlotlyDateFormat(e,s,i),o=ie.addTickSpacing(o,n,!0)):P.isNumberType(s)&&(o=ie.getPlotlyNumberFormat(e,s,i),o=ie.addTickSpacing(o,n,!1)),n.formatType===M.plot.AxisFormatType.CATEGORY&&(o?o.type="category":o={type:"category",tickformat:void 0,ticksuffix:void 0}),o}static addTickSpacing(t,e,n){const{gapBetweenMajorTicks:s}=e;if(s>0){const i=t||{};let o=s;return n&&(o=s/rS),e.log&&(o=Math.log(o)),i.tickmode="linear",i.dtick=o,i}return t}static getSourceForAxis(t,e){for(let n=0;n<t.series.length;n+=1){const s=t.series[n];for(let i=0;i<s.sources.length;i+=1){const o=s.sources[i];if(o.axis===e)return o}}return null}static getSeriesVisibility(t,e){return e!=null&&e.hiddenSeries!=null&&e.hiddenSeries.includes(t)?"legendonly":!0}static getHiddenLabels(t){return t!=null&&t.hiddenSeries?[...t.hiddenSeries]:[]}static makeSeriesData(t,e,n,s=ie.ORIENTATION.VERTICAL){return{type:t,mode:e,name:n,orientation:s}}static makeSeriesDataFromSeries(t,e,n,s=zt){const{name:i,plotStyle:o,lineColor:r,shapeColor:l,sources:a}=t,d=a.some(g=>{var f;return(f=g.axis)==null?void 0:f.businessCalendar}),c=ie.getChartType(o,d),u=ie.getPlotlyChartMode(o),m=ie.getPlotlySeriesOrientation(t),p=ie.makeSeriesData(c,u,i,m);return ie.addSourcesToSeriesData(p,o,a,e),ie.addStylingToSeriesData(p,o,s,r,l,n),p}static addSourcesToSeriesData(t,e,n,s){const i=t;for(let o=0;o<n.length;o+=1){const r=n[o],{axis:l,type:a}=r,d=ie.getPlotlyProperty(e,a);eu(i,d,[]);const c=l!=null?ie.getAxisPropertyName(l.type):null;if(c!=null){const u=s.get(l.type);if(u){const m=u.indexOf(l),p=m>0?`${m+1}`:"";i[`${c}axis`]=`${c}${p}`}}}}static addStylingToSeriesData(t,e,n=zt,s=null,i=null,o=null){const r=t;r.marker={line:{}},r.line={width:1},e===M.plot.SeriesPlotStyle.AREA?r.fill="tozeroy":e===M.plot.SeriesPlotStyle.STACKED_AREA?r.stackgroup="stack":e===M.plot.SeriesPlotStyle.STEP?r.line.shape="hv":e===M.plot.SeriesPlotStyle.HISTOGRAM?(r.width=[],r.marker.line!==void 0&&Object.assign(r.marker.line,{color:n.paper_bgcolor,width:1})):e===M.plot.SeriesPlotStyle.OHLC?(r.increasing={line:{color:n.ohlc_increasing}},r.decreasing={line:{color:n.ohlc_decreasing}}):e===M.plot.SeriesPlotStyle.PIE?(r.textinfo="label+percent",r.outsidetextfont={color:n.title_color}):e===M.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&&(e===M.plot.SeriesPlotStyle.BAR?r.marker.color=s:r.line.color=s),i!=null&&(r.marker.color=i),o!=null&&e!==M.plot.SeriesPlotStyle.PIE&&(r.visible=o)}static getAxisFormats(t,e){const n=new Map,s={tickformat:null,ticksuffix:null},i=ie.getAllAxes(t),o=ie.groupArray(i,"type"),{charts:r}=t;for(let l=0;l<r.length;l+=1){const a=r[l];for(let d=0;d<a.series.length;d+=1){const c=a.series[d],{sources:u}=c,m=u.filter(p=>p.axis);for(let p=0;p<m.length;p+=1){const g=m[p],{axis:f}=g,{type:b}=f,C=o.get(b);A(C);const w=C.indexOf(f),T=ie.getAxisPropertyName(b);if(T!=null){const y=ie.getAxisLayoutProperty(T,w);if(n.has(y))Cr.debug(`${y} already added.`);else{Cr.debug(`Adding ${y} to axisFormats.`);const E=ie.getPlotlyAxisFormat(g,e);if(E===null)n.set(y,s);else{n.set(y,E);const{businessCalendar:I}=f;if(I!=null){const R=[],{businessPeriods:F,businessDays:x,holidays:U,timeZone:$}=I,O=e==null?void 0:e.getColumnTypeFormatter(sh);let H;ih(O)&&(H=O.dhTimeZone);const L=H?($.standardOffset-H.standardOffset)/60:0;U.length>0&&R.push(...ie.createRangeBreakValuesFromHolidays(U,$,H)),F.forEach(N=>R.push({pattern:"hour",bounds:[ie.periodToDecimal(N.close)+L,ie.periodToDecimal(N.open)+L]})),x.length<ws.length&&ie.createBoundsFromDays(x).forEach(N=>R.push({pattern:"day of week",bounds:N})),E.rangebreaks=R}if(n.size===a.axes.length)return n}}}}}}return n}static getChartType(t,e){switch(t){case M.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return ie.getPlotlyChartType(t,e)}}static getAxisPropertyName(t){switch(t){case M.plot.AxisType.X:return"x";case M.plot.AxisType.Y:return"y";default:return null}}static getAxisSide(t){switch(t){case M.plot.AxisPosition.BOTTOM:return"bottom";case M.plot.AxisPosition.TOP:return"top";case M.plot.AxisPosition.LEFT:return"left";case M.plot.AxisPosition.RIGHT:return"right";default:return}}static getAllAxes(t){return t.charts.reduce((e,n)=>[...e,...n.axes],[])}static getChartForSeries(t,e){const{charts:n}=t;for(let s=0;s<n.length;s+=1){const i=n[s];for(let o=0;o<i.series.length;o+=1)if(e===i.series[o])return i}return null}static getLayoutRanges(t){const e={},n=Object.keys(t).filter(s=>s.indexOf("axis")>=0);for(let s=0;s<n.length;s+=1){const i=n[s],o=t[i];dS(o)&&(e[i]=[...o.range])}return e}static updateFigureAxes(t,e,n,s=0,i=0,o=zt){const r=t,l=ie.getAllAxes(e);for(let a=0;a<e.charts.length;a+=1){const d=e.charts[a],c=n==null?void 0:n(d),u=ie.getChartBounds(e,d,s,i);ie.updateLayoutAxes(r,d.axes,l,s,i,u,c,o)}ie.removeStaleAxes(r,l)}static getChartBounds(t,e,n=0,s=0){var T;const{cols:i,rows:o}=t,{column:r,colspan:l,row:a,rowspan:d}=e,c=r+l,u=a+d,m=1/i,p=1/o,g=ie.AXIS_SIZE_PX/n,f=ie.AXIS_SIZE_PX/s,b={left:r*m+(r>0?g/2:0),bottom:a*p+(a>0?f/2:0),top:u*p-(u<o?f/2:0),right:c*m-(c<i?g/2:0)};return((T=ie.groupArray(e.axes,"position").get(M.plot.AxisPosition.RIGHT))!=null?T:[]).length>0&&(n>0?b.right-=(b.right-b.left)*Math.max(0,Math.min(ie.LEGEND_WIDTH_PX/n,ie.MAX_LEGEND_SIZE)):b.right-=(b.right-b.left)*ie.DEFAULT_AXIS_SIZE),b}static updateLayoutAxes(t,e,n,s=0,i=0,o={left:0,top:0,right:1,bottom:1},r,l=zt){const a=s>0?Math.max(ie.MIN_AXIS_SIZE,Math.min(ie.AXIS_SIZE_PX/i,ie.MAX_AXIS_SIZE)):ie.DEFAULT_AXIS_SIZE,d=i>0?Math.max(ie.MIN_AXIS_SIZE,Math.min(ie.AXIS_SIZE_PX/s,ie.MAX_AXIS_SIZE)):ie.DEFAULT_AXIS_SIZE,c=t,u=ie.groupArray(e,"position"),m=ie.groupArray(e,"type"),p=[...m.keys()],g=ie.groupArray(n,"type");for(let f=0;f<p.length;f+=1){const b=p[f],C=ie.getAxisPropertyName(b);if(C!=null){const w=m.get(b),T=g.get(b),E=b===M.plot.AxisType.Y?i:s;A(w),A(T);for(let I=0;I<w.length;I+=1){const R=w[I],F=T.indexOf(R),x=ie.getAxisLayoutProperty(C,F);c[x]==null&&(c[x]=ie.makeLayoutAxis(b,l));const U=c[x];if(U!=null){ie.updateLayoutAxis(U,R,I,u,a,d,o);const{range:$,autorange:O}=U;if(r!=null&&$!==void 0&&(O===void 0||O===!1)){const H=r(R),[L,N]=H($);Cr.debug("Setting downsample range",E,L,N),R.range(E,L,N)}else R.range(E)}}}}}static removeStaleAxes(t,e){const n=t,s=ie.groupArray(e,"type"),i=[...s.keys()];for(let o=0;o<i.length;o+=1){const r=i[o],l=s.get(r);A(l);let a=l.length;const d=ie.getAxisPropertyName(r);if(d!=null){let c=ie.getAxisLayoutProperty(d,a);for(;n[c]!=null;)delete n[c],a+=1,c=ie.getAxisLayoutProperty(d,a)}}}static getAxisLayoutProperty(t,e){const n=e>0?`${e+1}`:"";return`${t!=null?t:""}axis${n}`}static updateLayoutAxis(t,e,n,s,i,o,r){var u,m,p;const a=e.type===M.plot.AxisType.Y?o:i,d=t,c=(u=e.label)!=null?u:"";if(d.title!==void 0&&typeof d.title!="string"?d.title.text=c:d.title={text:c},e.log&&(d.type="log"),d.side=ie.getAxisSide(e.position),n>0){d.overlaying=(m=ie.getAxisPropertyName(e.type))!=null?m:void 0;const g=(p=s.get(e.position))!=null?p:[],f=g.indexOf(e);f>0&&(d.anchor="free",e.position===M.plot.AxisPosition.RIGHT?d.position=r.right+(f-g.length+1)*a:e.position===M.plot.AxisPosition.TOP?d.position=r.top+(f-g.length+1)*a:e.position===M.plot.AxisPosition.BOTTOM?d.position=r.bottom+(g.length-f+1)*a:e.position===M.plot.AxisPosition.LEFT&&(d.position=r.left+(g.length-f+1)*a))}else if(e.type===M.plot.AxisType.X){const g=s.get(M.plot.AxisPosition.LEFT)||[],f=s.get(M.plot.AxisPosition.RIGHT)||[],b=Math.max(r.left,r.left+(g.length-1)*o),C=Math.min(r.right-(f.length-1)*o,r.right);d.domain=[b,C]}else if(e.type===M.plot.AxisType.Y){const g=s.get(M.plot.AxisPosition.BOTTOM)||[],f=s.get(M.plot.AxisPosition.TOP)||[],b=Math.max(r.bottom,r.bottom+(g.length-1)*i),C=Math.min(r.top-(f.length-1)*i,r.top);d.domain=[b,C]}}static periodToDecimal(t){const e=t.split(":");return Number(e[0])+Number(e[1])/60}static createBoundsFromDays(t){const e=t.map(o=>ws.indexOf(o)),n=ws.filter(o=>!t.includes(o)).map(o=>ws.indexOf(o)),s=new Set;n.forEach(o=>{for(let r=o+1;r<o+ws.length;r+=1){const l=r%ws.length;if(e.includes(l)){s.add(l);break}}});const i=[];return s.forEach(o=>{for(let r=o-1;r>o-ws.length;r-=1){const l=r<0?r+ws.length:r;if(e.includes(l)){const a=(l+1)%7;i.push([a,o]);break}}}),i}static createRangeBreakValuesFromHolidays(t,e,n){const s=[],i=[];return t.forEach(o=>{o.businessPeriods.length>0?i.push(...ie.createPartialHoliday(o,e,n)):s.push(ie.createFullHoliday(o,e,n))}),[{values:s},...i]}static createFullHoliday(t,e,n){return ie.adjustDateForTimeZone(`${t.date.toString()} 00:00:00.000000`,e,n)}static createPartialHoliday(t,e,n){const s=t.date.toString(),i=["00:00"];t.businessPeriods.forEach(r=>{i.push(r.open),i.push(r.close)}),i.push("24:00");const o=[];for(let r=0;r<i.length;r+=2){const l=i[r],a=i[r+1];if(l!==a){const d=[ie.adjustDateForTimeZone(`${s} ${l}:00.000000`,e,n)],c=oS*(ie.periodToDecimal(a)-ie.periodToDecimal(l));o.push({values:d,dvalue:c})}}return o}static adjustDateForTimeZone(t,e,n){return n&&n.standardOffset!==e.standardOffset?ie.unwrapValue(ie.wrapValue(t,sh,e),n):t}static groupArray(t,e){return t.reduce((n,s)=>{var r;const i=s[e],o=(r=n.get(i))!=null?r:[];return o.push(s),n.set(i,o),n},new Map)}static unwrapValue(t,e){if(t!=null){if(lS(t))return M.i18n.DateTimeFormat.format(ie.DATE_FORMAT,t,e);if(aS(t))return t.asNumber()}return t}static wrapValue(t,e,n=null){if(P.isDateType(e)&&typeof t=="string"){const s=t,i=ie.DATE_FORMAT.substr(0,t.length),o=M.i18n.DateTimeFormat.parse(i,s);if(!n)return o;const r=`${i} Z`,l=M.i18n.DateTimeFormat.format("Z",o,n),a=M.i18n.DateTimeFormat.parse(r,`${s} ${l}`),d=M.i18n.DateTimeFormat.format("Z",a,n);return M.i18n.DateTimeFormat.parse(r,`${s} ${d}`)}return t}static makeLayoutAxis(t,e=zt){const n={automargin:!0,gridcolor:e.gridcolor,linecolor:e.linecolor,rangeslider:{visible:!1},showline:!0,ticklen:5,tickcolor:e.paper_bgcolor,tickfont:{color:e.zerolinecolor},title:{font:{color:e.title_color}}};return t===M.plot.AxisType.X?Object.assign(n,{showgrid:!0}):t===M.plot.AxisType.Y&&Object.assign(n,{zerolinecolor:e.zerolinecolor,zerolinewidth:2}),n}static getColorwayFromTheme(t=zt){let e=[];return t.colorway&&(Array.isArray(t.colorway)?e=t.colorway:typeof t.colorway=="string"?e=t.colorway.split(" "):Cr.warn(`Unable to handle colorway property: ${t.colorway}`)),e}static makeDefaultLayout(t=zt){const e={...t,autosize:!0,colorway:ie.getColorwayFromTheme(t),font:{family:"'Fira Sans', sans-serif"},title:{font:{color:t.title_color},yanchor:"top",pad:{...ie.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:t.title_color}},margin:{...ie.DEFAULT_MARGIN},xaxis:ie.makeLayoutAxis(M.plot.AxisType.X,t),yaxis:ie.makeLayoutAxis(M.plot.AxisType.Y,t)};return e.datarevision=0,e}static hydrateSettings(t){return{...t,type:M.plot.SeriesPlotStyle[t.type]}}static titleFromSettings(t){const{series:e,xAxis:n,title:s=`${e.join(", ")} by ${n}`}=t;return s}static makeFigureSettings(t,e){const{series:n,xAxis:s,type:i}=t,o=ie.titleFromSettings(t),r={formatType:`${M.plot.AxisFormatType.NUMBER}`,type:`${M.plot.AxisType.X}`,position:`${M.plot.AxisPosition.BOTTOM}`},l={formatType:`${M.plot.AxisFormatType.NUMBER}`,type:`${M.plot.AxisType.Y}`,position:`${M.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${M.plot.ChartType.XY}`,axes:[r,l],series:n.map(a=>({plotStyle:`${i}`,name:a,dataSources:[{type:`${M.plot.SourceType.X}`,columnName:s,axis:r,table:e},{type:`${M.plot.SourceType.Y}`,columnName:a,axis:l,table:e}]}))}],title:o}}};let _e=ie;_e.DEFAULT_AXIS_SIZE=.15;_e.MIN_AXIS_SIZE=.025;_e.MAX_AXIS_SIZE=.2;_e.AXIS_SIZE_PX=75;_e.LEGEND_WIDTH_PX=50;_e.MAX_LEGEND_SIZE=.25;_e.ORIENTATION=Object.freeze({HORIZONTAL:"h",VERTICAL:"v"});_e.DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSS";_e.DEFAULT_MARGIN=Object.freeze({l:60,r:50,t:30,b:60,pad:0});_e.DEFAULT_TITLE_PADDING=Object.freeze({t:8});_e.SUBTITLE_LINE_HEIGHT=25;const vs=X.module("Chart"),yo=class extends S.exports.Component{constructor(t){super(t),this.getCachedConfig=he((e,n,s,i)=>{const o=[],r=Boolean(e);if(r&&o.push({name:`Downsampling failed: ${e}`,click:()=>{},icon:yo.convertIcon(Su),attr:"fill-warning"}),n||s||i||r){const l=yo.downsampleButtonTitle(s,i),a=yo.downsampleButtonAttr(s,i),d=s?mu:Xf;o.push({name:l,icon:yo.convertIcon(d),click:this.handleDownsampleClick,attr:a})}return{displaylogo:!1,displayModeBar:s||r?!0:"hover",modeBarButtons:[o,["toImage"],["zoom2d","pan2d"],["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]]}}),this.handleAfterPlot=this.handleAfterPlot.bind(this),this.handleDownsampleClick=this.handleDownsampleClick.bind(this),this.handleModelEvent=this.handleModelEvent.bind(this),this.handlePlotUpdate=this.handlePlotUpdate.bind(this),this.handleRelayout=this.handleRelayout.bind(this),this.handleRestyle=this.handleRestyle.bind(this),this.plot=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(t){const[e,,,,n]=t.icon,s=`${n}`;return{width:e,path:s,ascent:e,descent:0,transform:"matrix(1, 0, 0, 1, 0, 0)"}}static downsampleButtonTitle(t,e){return t?"Downsampling in progress...":e?"Downsampling disabled, click to enable":"Downsampling enabled, click to disable"}static downsampleButtonAttr(t,e){return t?"animation-spin":e?void 0:"fill-active"}componentDidMount(){this.updateDimensions(),this.updateModelDimensions(),this.initData(),this.initFormatter();const{isActive:t}=this.props;t&&this.subscribe()}componentDidUpdate(t){const{isActive:e,settings:n}=this.props;this.updateFormatterSettings(n),e!==t.isActive&&(e?this.subscribe():this.unsubscribe())}componentWillUnmount(){this.unsubscribe()}getPlotRect(){var t,e;return(e=(t=this.plotWrapper.current)==null?void 0:t.getBoundingClientRect())!=null?e:null}initData(){const{model:t}=this.props,{layout:e}=this.state;this.setState({data:t.getData(),layout:{...e,...t.getLayout()}})}subscribe(){if(this.isSubscribed)return;const{model:t}=this.props;if(!this.rect||this.rect.width===0||this.rect.height===0){vs.debug2("Delaying subscription until model dimensions are set");return}t.subscribe(this.handleModelEvent),this.isSubscribed=!0}unsubscribe(){if(!this.isSubscribed)return;const{model:t}=this.props;t.unsubscribe(this.handleModelEvent),this.isSubscribed=!1}handleAfterPlot(){this.plot.current!=null}handleDownsampleClick(){this.setState(({isDownsamplingDisabled:t})=>({downsamplingError:null,isDownsampleInProgress:!1,isDownsampleFinished:!1,isDownsamplingDisabled:!t}),()=>{const{model:t}=this.props,{isDownsamplingDisabled:e}=this.state;t.setDownsamplingDisabled(e)})}handleModelEvent(t){var s;const{type:e,detail:n}=t;switch(vs.debug2("Received data update",e,n),e){case St.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 St.EVENT_LOADFINISHED:{const{onUpdate:i}=this.props;this.isLoadedFired=!0,i({isLoading:!1});break}case St.EVENT_DISCONNECT:{const{onDisconnect:i}=this.props;i();break}case St.EVENT_RECONNECT:{const{onReconnect:i}=this.props;i();break}case St.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case St.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case St.EVENT_DOWNSAMPLENEEDED:case St.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:vs.debug("Unknown event type",e,t)}}handlePlotUpdate(t){const{layout:e}=t,n=_e.getLayoutRanges(e);!ct(n,this.ranges)&&(this.ranges=n,this.updateModelDimensions(!0))}handleRelayout(t){if(vs.debug("handleRelayout",t),t.hiddenlabels!=null){const{onSettingsChanged:e}=this.props,n=[...t.hiddenlabels];e({hiddenSeries:n})}this.updateModelDimensions()}handleRestyle([t,e]){if(vs.debug("handleRestyle",t,e),Object.keys(t).includes("visible")){const{data:n}=this.state,{onSettingsChanged:s}=this.props;if(n!=null){const i=n.reduce((o,{name:r,visible:l})=>r!=null&&l==="legendonly"?[...o,r]:o,[]);s({hiddenSeries:i})}}}updateModelDimensions(t=!1){const e=this.getPlotRect();if(!e){vs.warn("Unable to get plotting rect");return}if(!this.rect||this.rect.width!==e.width||this.rect.height!==e.height||t){this.rect=e;const{isActive:s,model:i}=this.props;i.setDimensions(e),s&&this.subscribe()}}initFormatter(){const{settings:t}=this.props;this.updateFormatterSettings(t)}updateFormatterSettings(t){const e=cs.getColumnFormats(t),n=cs.getDateTimeFormatterOptions(t),{decimalFormatOptions:s={},integerFormatOptions:i={}}=t;(!ct(this.columnFormats,e)||!ct(this.dateTimeFormatterOptions,n)||!ct(this.decimalFormatOptions,s)||!ct(this.integerFormatOptions,i))&&(this.columnFormats=cs.getColumnFormats(t),this.dateTimeFormatterOptions=n,this.decimalFormatOptions=s,this.integerFormatOptions=i,this.updateFormatter())}updateFormatter(){const t=new cn(this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions),{model:e}=this.props;e.setFormatter(t)}updateDimensions(){const t=this.getPlotRect();this.plot.current!=null&&t!=null&&t.width>0&&t.height>0&&$r.relayout(this.plot.current.el,{autosize:!0}).catch(e=>{vs.debug("Unable to resize, promise rejected",e)})}render(){const{data:t,downsamplingError:e,isDownsampleFinished:n,isDownsampleInProgress:s,isDownsamplingDisabled:i,layout:o,revision:r}=this.state,l=this.getCachedConfig(e,n,s,i),a=t!=null;return h("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:a&&h(rm,{ref:this.plot,data:t,layout:o,revision:r,config:l,onAfterPlot:this.handleAfterPlot,onError:vs.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}};let lm=yo;lm.defaultProps={isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:us.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}};const Ft=X.module("FigureChartModel"),am=class extends St{constructor(t,e={},n=zt){super(),this.addPendingSeries=Xe(()=>{const i=_e.getAllAxes(this.figure),{pendingSeries:o}=this;for(let r=0;r<o.length;r+=1){const l=o[r];this.addSeries(l,i),l.subscribe()}this.pendingSeries=[]},am.ADD_SERIES_DEBOUNCE),this.getTimeZone=Te((i,o)=>{if(o!=null){const r=o.getColumnTypeFormatter(i);if(r!=null)return r.dhTimeZone}return null}),this.getValueTranslator=Te((i,o)=>{const r=this.getTimeZone(i,o);return l=>_e.unwrapValue(l,r)}),this.getValueParser=Te((i,o)=>{const r=this.getTimeZone(i,o);return l=>_e.wrapValue(l,i,r)}),this.getRangeParser=Te((i,o)=>r=>{let[l,a]=r;const d=this.getValueParser(i,o);return l=d(l),a=d(a),[l,a]}),this.getAxisRangeParser=Te((i,o)=>r=>{const l=_e.getSourceForAxis(i,r);return l?this.getRangeParser(l.columnType,o):a=>a}),this.handleFigureUpdated=this.handleFigureUpdated.bind(this),this.handleFigureDisconnected=this.handleFigureDisconnected.bind(this),this.handleFigureReconnected=this.handleFigureReconnected.bind(this),this.handleFigureSeriesAdded=this.handleFigureSeriesAdded.bind(this),this.handleDownsampleStart=this.handleDownsampleStart.bind(this),this.handleDownsampleFinish=this.handleDownsampleFinish.bind(this),this.handleDownsampleFail=this.handleDownsampleFail.bind(this),this.handleDownsampleNeeded=this.handleDownsampleNeeded.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.figure=t,this.settings=e,this.theme=n,this.data=[];const s={data:{},layout:_e.makeDefaultLayout(n)};this.layout={grid:{rows:t.rows,columns:t.cols,pattern:"independent"},template:s},this.seriesDataMap=new Map,this.pendingSeries=[],this.oneClicks=[],this.filterColumnMap=new Map,this.lastFilter=new Map,this.isConnected=!0,this.seriesToProcess=new Set,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure()}close(){this.figure.close(),this.addPendingSeries.cancel(),this.stopListeningFigure()}getDefaultTitle(){return this.figure.charts.length>0?this.figure.charts[0].title:""}initAllSeries(){this.oneClicks=[],this.filterColumnMap.clear();const{charts:t}=this.figure,e=_e.getAllAxes(this.figure),n=[];for(let o=0;o<t.length;o+=1){const r=t[o];for(let l=0;l<r.series.length;l+=1){const a=r.series[l];n.push(a.name),this.addSeries(a,e)}}const i=[...this.seriesDataMap.keys()].filter(o=>n.indexOf(o)<0);for(let o=0;o<i.length;o+=1){const r=i[o];this.seriesDataMap.delete(r)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(t,e){const n=_e.groupArray(e,"type"),s=_e.makeSeriesDataFromSeries(t,n,_e.getSeriesVisibility(t.name,this.settings),this.theme);if(this.seriesDataMap.set(t.name,s),this.data=[...this.seriesDataMap.values()],t.plotStyle===M.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":t.plotStyle===M.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=_e.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||t.plotStyle===M.plot.SeriesPlotStyle.PIE,t.oneClick!=null){const{oneClick:i}=t,{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(t){super.subscribe(t),this.listeners.length===1&&(this.initAllSeries(),this.subscribeFigure())}unsubscribe(t){super.unsubscribe(t),this.listeners.length===0&&this.unsubscribeFigure()}subscribeFigure(){if(!this.isConnected){Ft.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?M.plot.DownsampleOptions.DISABLE:M.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){this.figure.addEventListener(M.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.addEventListener(M.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.addEventListener(M.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.addEventListener(M.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.addEventListener(M.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.addEventListener(M.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.addEventListener(M.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.addEventListener(M.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.addEventListener(M.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}stopListeningFigure(){this.figure.removeEventListener(M.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.removeEventListener(M.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.removeEventListener(M.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.removeEventListener(M.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.removeEventListener(M.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.removeEventListener(M.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.removeEventListener(M.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.removeEventListener(M.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.removeEventListener(M.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}handleDownsampleStart(t){Ft.debug("Downsample started",t),this.fireDownsampleStart(t.detail)}handleDownsampleFinish(t){Ft.debug("Downsample finished",t),this.fireDownsampleFinish(t.detail)}handleDownsampleFail(t){Ft.error("Downsample failed",t),this.fireDownsampleFail(t.detail)}handleDownsampleNeeded(t){Ft.info("Downsample needed",t),this.fireDownsampleNeeded(t.detail)}handleFigureUpdated(t){const{detail:e}=t,{series:n}=e;Ft.debug2("handleFigureUpdated",n);for(let i=0;i<n.length;i+=1){const o=n[i];Ft.debug2("handleFigureUpdated updating series",o.name);const{sources:r}=o;for(let l=0;l<r.length;l+=1){const a=r[l],{columnType:d,type:c}=a,u=this.getValueTranslator(d,this.formatter),m=e.getArray(o,c,u);this.setDataArrayForSeries(o,c,m)}this.seriesToProcess.delete(o.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(o)}const{data:s}=this;this.fireUpdate(s)}handleRequestFailed(t){Ft.error("Request failed",t)}resubscribe(){this.listeners.length>0&&(this.unsubscribeFigure(),this.subscribeFigure())}setFormatter(t){super.setFormatter(t),this.updateLayoutFormats(),this.resubscribe()}setDownsamplingDisabled(t){super.setDownsamplingDisabled(t),this.resubscribe()}handleFigureDisconnected(t){Ft.debug("Figure disconnected",t),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(t){Ft.debug("Figure reconnected",t),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(t){const{detail:e}=t;Ft.debug("handleFigureSeriesAdded",e),this.pendingSeries.push(e),this.addPendingSeries()}setDimensions(t){super.setDimensions(t),this.updateAxisPositions()}setTitle(t){var s,i;super.setTitle(t);const e=(i=(s=(t!=null?t:"").match(/<br>/g))==null?void 0:s.length)!=null?i:0,n=_e.DEFAULT_MARGIN.t+e*_e.SUBTITLE_LINE_HEIGHT;this.layout.margin?this.layout.margin.t=n:this.layout.margin={t:n},typeof this.layout.title=="string"?this.layout.title=t:(this.layout.title={...this.layout.title},this.layout.title.text=t,this.layout.title.pad={...this.layout.title.pad},this.layout.title.pad.t=_e.DEFAULT_TITLE_PADDING.t+e*_e.SUBTITLE_LINE_HEIGHT*.5)}getPlotWidth(){var t,e,n,s;return!this.rect||!this.rect.width?0:Math.max(this.rect.width-((e=(t=this.layout.margin)==null?void 0:t.l)!=null?e:0)-((s=(n=this.layout.margin)==null?void 0:n.r)!=null?s:0),0)}getPlotHeight(){var t,e,n,s;return!this.rect||!this.rect.height?0:Math.max(this.rect.height-((e=(t=this.layout.margin)==null?void 0:t.t)!=null?e:0)-((s=(n=this.layout.margin)==null?void 0:n.b)!=null?s:0),0)}updateAxisPositions(){const t=this.getPlotWidth(),e=this.getPlotHeight();_e.updateFigureAxes(this.layout,this.figure,n=>this.getAxisRangeParser(n,this.formatter),t,e,this.theme)}updateLayoutFormats(){if(!this.formatter)return;_e.getAxisFormats(this.figure,this.formatter).forEach((e,n)=>{Ft.debug(`Assigning ${n}`,this.layout[n],e);const s=this.layout[n];s!=null?Object.assign(s,e):Ft.debug(`Ignoring null layout.${n}`)})}setDataArrayForSeries(t,e,n){const{name:s,plotStyle:i}=t,o=this.seriesDataMap.get(s),r=_e.getPlotlyProperty(i,e);o&&eu(o,r,n)}cleanSeries(t){const{name:e,plotStyle:n}=t,s=this.seriesDataMap.get(e);if(s!=null){if(n===M.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===M.plot.SeriesPlotStyle.LINE){const{x:i,xLow:o,xHigh:r,y:l,yLow:a,yHigh:d}=s;o&&r&&o!==i&&(s.error_x=_e.getPlotlyErrorBars(i,o,r)),a&&d&&a!==l&&(s.error_y=_e.getPlotlyErrorBars(l,a,d))}else if(n===M.plot.SeriesPlotStyle.TREEMAP){const{ids:i,labels:o}=s;i!==void 0&&o===void 0&&(s.labels=i)}}}getData(){return this.data}getLayout(){return this.layout}getFilterColumnMap(){return new Map(this.filterColumnMap)}isFilterRequired(){return this.oneClicks.find(t=>t.requireAllFiltersToDisplay)!=null}setFilter(t){if(this.oneClicks.length===0){Ft.warn("Trying to set a filter, but no one click!");return}Ft.debug("setFilter",t);for(let e=0;e<this.oneClicks.length;e+=1){const n=this.oneClicks[e],{columns:s}=n;new Set([...t.keys(),...this.lastFilter.keys()]).forEach(o=>{const r=t.get(o);this.lastFilter.get(o)!==r&&s.find(l=>l.name===o)!=null&&n.setValueForColumn(o,r)})}this.lastFilter=new Map(t)}setFigure(t){this.close(),this.figure=t,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure(),this.listeners.length>0&&this.subscribeFigure()}updateSettings(t){this.settings=t}};let Fa=am;Fa.ADD_SERIES_DEBOUNCE=50;class zi{static async makeModelFromSettings(e,n,s=zt){const i=await zi.makeFigureFromSettings(e,n);return new Fa(i,e,s)}static async makeFigureFromSettings(e,n){const s=await n.copy();return s.applyCustomColumns(n.customColumns),s.applyFilter(n.filter),s.applySort(n.sort),M.plot.Figure.create(_e.makeFigureSettings(e,s))}static async makeModel(e,n,s=zt){return new Fa(n,e,s)}}function oh(t){return t.setFigure!==void 0}const cS=({connection:t,defaultUpdateInterval:e,hoverUpdateInterval:n,bgMonitoring:s=!0,monitorDuration:i})=>{var U;const[o,r]=S.exports.useState({freeMemory:0,maximumHeapSize:999,totalHeapSize:0}),[l,a]=S.exports.useState(!1),d=S.exports.useRef({timestamps:[],usages:[]});S.exports.useEffect(function(){const O=async()=>{const L=await t.getWorkerHeapInfo();if(r(L),s||l){const N=(L.totalHeapSize-L.freeMemory)/L.maximumHeapSize,_=Date.now(),{timestamps:k,usages:V}=d.current;for(;k.length!==0&&_-k[0]>i*1.5;)k.shift(),V.shift();k.push(_),V.push(N)}else d.current={timestamps:[],usages:[]}};O();const H=setInterval(O,l?n:e);return()=>{clearInterval(H)}},[l,n,t,e,i,s]);const c=($,O)=>Math.round($*10**O)/10**O,u=2,m=1024**3,{freeMemory:p,totalHeapSize:g,maximumHeapSize:f}=o,b=c(p/m,u),C=c(g/m,u),w=c(f/m,u),T=C-b,y=($,O,H=!1)=>v("div",{className:z("heap-usage-info-row",{"heading-bottom-border":H}),children:[h("div",{className:"font-weight-bold",children:$}),h("div",{children:O})]}),{timestamps:E,usages:I}=d.current,R=(U=E[E.length-1])!=null?U:0,F=g/f,x=(g-p)/f;return v(ue,{children:[v("div",{className:"max-memory",children:[h("div",{className:"total-memory",style:{width:`calc(${F*100}% - ${F*2}px`}}),h("div",{className:z("used-memory",{"heap-overflow":(g-p)/f>.95}),style:{width:`calc(${x*100}% - ${x*2}px`}}),v("div",{className:"memory-text",children:[w.toFixed(1)," GB"]})]}),h(Ie,{onEntered:()=>a(!0),onExited:()=>a(!1),interactive:!0,children:v("div",{className:"heap-tooltip",children:[y("In use:",`${T.toFixed(u)} of ${w.toFixed(u)} GB`,!0),y("Free:",`${b.toFixed(u)} GB`),y("Total:",`${C.toFixed(u)} GB`),y("Max:",`${w.toFixed(u)} GB`),h("div",{className:"heap-plot",children:h(rm,{data:[{x:[...E],y:[...I],type:"scatter",mode:"lines"}],config:{staticPlot:!0,responsive:!0},style:{width:"196px",height:"100px"},layout:{legend:!1,margin:{l:2,t:2,r:2,b:2},plot_bgcolor:"transparent",paper_bgcolor:"transparent",colorway:["#4878ea"],xaxis:{dtick:Math.round(i/6),gridcolor:zt.linecolor,range:[R-i,R],linecolor:zt.linecolor,linewidth:2,mirror:!0},yaxis:{dtick:.2,gridcolor:zt.linecolor,range:[0,1],linecolor:zt.linecolor,linewidth:2,mirror:!0}}})}),v("div",{className:"heap-utilisation-text",children:["% utilization over ",Math.round(i/1e3/60)," min."]})]})})]})},dm=Object.freeze({}),hS=new Map,cm=t=>t.user,wd=t=>t.storage,hm=t=>wd(t).commandHistoryStorage,um=t=>wd(t).fileStorage,uS=t=>wd(t).workspaceStorage,yl=t=>t.workspace,Kt=t=>yl(t).data.settings,mS=t=>Kt(t).defaultDateTimeFormat,pS=t=>{var e;return(e=Kt(t).defaultDecimalFormatOptions)!=null?e:dm},gS=t=>{var e;return(e=Kt(t).defaultIntegerFormatOptions)!=null?e:dm},fS=t=>Kt(t).formatter,Il=t=>Kt(t).timeZone,CS=t=>Kt(t).showTimeZone,bS=t=>Kt(t).showTSeparator,SS=t=>Kt(t).truncateNumbersWithPound,wS=t=>Kt(t).shortcutOverrides,Rl=t=>t.activeTool,vS=t=>{var e;return(e=t.plugins)!=null?e:hS},mm="SET_ACTIVE_TOOL",pm="SET_COMMAND_HISTORY_STORAGE",gm="SET_FILE_STORAGE",fm="SET_PLUGINS",Cm="SET_USER",bm="SET_WORKSPACE",Sm="SET_WORKSPACE_STORAGE",TS=t=>({type:Cm,payload:t}),wm=t=>({type:bm,payload:t}),ES=t=>({type:Sm,payload:t}),yS=t=>({type:pm,payload:t}),IS=t=>({type:gm,payload:t}),RS=t=>(e,n)=>{e(wm(t));const{storage:s}=n(),{workspaceStorage:i}=s;return i.save(t)},vm=t=>(e,n)=>{const{workspace:s}=n(),{data:i}=s,o={...s,data:{...i,...t}};return e(RS(o))},Tm=t=>e=>e(vm({settings:t})),Dl=t=>({type:mm,payload:t}),DS=t=>({type:fm,payload:t});function Em(t,e){return(n=e,s)=>{switch(s.type){case t:{const i=s.payload;return i==null?null:n!=null?{...n,...i}:{...i}}default:return n}}}function MS(t,e={},n=!0){return(s=e,i)=>{switch(i.type){case t:{const{id:o,payload:r}=i;return n&&ct({payload:r},{payload:s[o]})?s:{...s,[o]:r}}default:return s}}}function fi(t,e){return(n=e,s)=>{switch(s.type){case t:return s.payload;default:return n}}}const NS=fi(mm,null),FS=fi(fm,null),xS=fi(pm,null),_S=fi(gm,null),kS=fi(Sm,null),OS=Ja({commandHistoryStorage:xS,fileStorage:_S,workspaceStorage:kS}),LS=Em(Cm,null),AS=Em(bm,null),PS={activeTool:NS,plugins:FS,storage:OS,user:LS,workspace:AS};class HS{constructor(){this.reducers={},this.listener=null}register(e,n){var s;this.reducers={...this.reducers,[e]:n},(s=this.listener)==null||s.call(this,this.reducers)}setListener(e){this.listener=e}}const Zi=new HS,rh=X.module("redux-logger"),VS=t=>e=>n=>{rh.debug("dispatching",n);const s=e(n);return rh.debug("next state",t.getState()),s},US=X.module("redux-crashReporter"),BS=t=>e=>n=>{try{return e(n)}catch(s){throw US.error("Error executing",n," with state ",t.getState(),":",s),s}},$S=[VS,BS,sg];Object.entries(PS).map(([t,e])=>Zi.register(t,e));var Jh;const zS=(Jh=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__)!=null?Jh:rg,Ml=ig(Ja(Zi.reducers),zS(og(...$S)));Zi.setListener(t=>{Ml.replaceReducer(Ja(t))});const ym=Object.freeze({openPopouts:[],settings:{hasHeaders:!0,constrainDragToContainer:!0,reorderEnabled:!0,selectionEnabled:!1,popoutWholeStack:!1,blockedPopoutsThrowError:!0,closePopoutsOnUnload:!0,showPopoutIcon:!0,showMaximiseIcon:!0,showCloseIcon:!0,responsiveMode:"onload",tabOverlapAllowance:0,tabControlOffset:10},dimensions:{borderWidth:5,borderGrabWidth:10,minItemHeight:10,minItemWidth:10,headerHeight:20,dragProxyWidth:300,dragProxyHeight:200},labels:{close:"Close",maximise:"Maximize",minimise:"Minimize",popout:"Open in new window",popin:"Pop in",tabDropdown:"Additional tabs",tabNextLabel:"Next",tabPreviousLabel:"Previous"},content:[]});function Im(t){return t.componentName!==void 0}function WS(t){return t.component!==void 0}const Rm=Object.freeze({type:"default",isClosable:!0,isFocusOnShow:!0,reorderEnabled:!0,title:""}),GS=Object.freeze(Object.defineProperty({__proto__:null,defaultConfig:ym,isGLComponentConfig:Im,isReactComponentConfig:WS,itemDefaultConfig:Rm},Symbol.toStringTag,{value:"Module"})),xa=class{constructor(){this.off=this.unbind,this.trigger=this.emit,this._mSubscriptions={},this._mSubscriptions[xa.ALL_EVENT]=[]}on(t,e,n){if(typeof e!="function")throw new Error("Tried to listen to event "+t+" with non-function callback "+e);this._mSubscriptions[t]||(this._mSubscriptions[t]=[]),this._mSubscriptions[t].push({fn:e,ctx:n})}emit(t,...e){const n=this._mSubscriptions[t];if(n)for(let i=0;i<n.length;i++){const o=n[i].ctx||{};n[i].fn.apply(o,e)}e.unshift(t);const s=this._mSubscriptions[xa.ALL_EVENT];for(let i=0;i<s.length;i++){const o=s[i].ctx||{};s[i].fn.apply(o,e)}}unbind(t,e,n){if(!this._mSubscriptions[t])throw new Error("No subscribtions to unsubscribe for event "+t);let s=!1;for(let i=0;i<this._mSubscriptions[t].length;i++)(!e||this._mSubscriptions[t][i].fn===e)&&(!n||n===this._mSubscriptions[t][i].ctx)&&(this._mSubscriptions[t].splice(i,1),s=!0);if(s===!1)throw new Error("Nothing to unbind for "+t)}};let bn=xa;bn.ALL_EVENT="__all";class _a extends bn{constructor(e,n,s){super(),this.isHidden=!1,this._element=ce(['<div class="lm_item_container">','<div class="lm_content" tabindex="-1"></div>',"</div>"].join("")),this.title=Im(e)?e.componentName:"",this.parent=n,this.layoutManager=s,this._config=e,this._contentElement=this._element.find(".lm_content")}getElement(){return this._contentElement}hide(){this.emit("hide"),this.isHidden=!0,this._element.hide()}show(){this.emit("show"),this.isHidden=!1,this._element.show(),(this.height!=0||this.width!=0)&&this.emit("shown")}setSize(e,n){var c,u,m,p;let s=this.parent,i=null;for(;s&&!s.isColumn&&!s.isRow;)if(i=s,s=s.parent,s!=null&&s.isRoot)return!1;if(!s||!i)return!1;const o=s.isColumn?"height":"width",r=o==="height"?n:e,l=((c=this[o])!=null?c:0)*(1/(((u=i.config[o])!=null?u:0)/100)),a=r/l*100,d=(((m=i.config[o])!=null?m:0)-a)/(s.contentItems.length-1);for(let g=0;g<s.contentItems.length;g++)s.contentItems[g]===i?s.contentItems[g].config[o]=a:s.contentItems[g].config[o]=((p=s.contentItems[g].config[o])!=null?p:0)+d;return s.callDownwards("setSize"),!0}close(){this._config.isClosable&&(this.emit("close"),this.parent.close())}getState(){return this._config.componentState}extendState(e){this.setState(ce.extend(!0,this.getState(),e))}setState(e){this._config.componentState=e,this.parent.emitBubblingEvent("stateChanged")}setTitle(e){this.parent.setTitle(e)}_$setSize(e=0,n=0){if(e!==this.width||n!==this.height){this.width=e,this.height=n;var s=this._contentElement[0],i=s.offsetWidth-s.clientWidth,o=s.offsetHeight-s.clientHeight;this._contentElement.width(this.width-i).height(this.height-o),this.emit("resize")}}}const KS=Object.freeze(Object.defineProperty({__proto__:null,ItemContainer:_a,Container:_a},Symbol.toStringTag,{value:"Module"}));function Dm(t){var e=location.hash.match(new RegExp(t+"=([^&]*)"));return e?e[1]:null}function Mm(t){if(window.location.hash)return Dm(t);if(!window.location.search)return null;var e=window.location.search.substr(1).split("&"),n={},s,i;for(i=0;i<e.length;i++)s=e[i].split("="),n[s[0]]=s[1];return n[t]||null}function Nl(t){return window.requestAnimationFrame(t)}function qS(t,e){var n=e.indexOf(t);if(n===-1)throw new Error("Can't remove item from array. Item is not in the array");e.splice(n,1)}function vd(){return(Math.random()*1e15).toString(36).replace(".","")}function YS(t,e){var n=t.replace(/javascript/gi,"javascript").replace(/expression/gi,"expression").replace(/onload/gi,"onload").replace(/script/gi,"script").replace(/onerror/gi,"onerror");return e===!0?n:n.replace(/>/g,">").replace(/</g,"<")}function Td(t){return ce.trim(t.replace(/(<([^>]+)>)/gi,""))}class Wo extends bn{constructor(e,n=!1){var s;super(),this._nDelay=400,this._nDistance=10,this._nX=0,this._nY=0,this._nOriginalX=0,this._nOriginalY=0,this._bDragging=!1,this._eElement=e,this._oDocument=ce(document),this._eBody=ce(document.body),this._destroyAfterMouseUp=n,this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this._startDrag=this._startDrag.bind(this),(s=this._eElement)==null||s.on("mousedown",this.onMouseDown)}destroy(){var e,n;(e=this._eElement)==null||e.unbind("mousedown",this.onMouseDown),(n=this._oDocument)==null||n.unbind("mouseup",this.onMouseUp),this._eElement=void 0,this._oDocument=void 0,this._eBody=void 0,clearTimeout(this._timeout),this._timeout=void 0}onMouseDown(e){var s,i,o,r;if(e.preventDefault(),e.button===0){var n=this._getCoordinates(e);this._nOriginalX=(s=n.x)!=null?s:0,this._nOriginalY=(i=n.y)!=null?i:0,(o=this._oDocument)==null||o.on("mousemove",this.onMouseMove),(r=this._oDocument)==null||r.on("mouseup",this.onMouseUp),this._timeout=window.setTimeout(this._startDrag,this._nDelay)}}onMouseMove(e){var s,i;if(this._timeout!=null){e.preventDefault();var n=this._getCoordinates(e);this._nX=((s=n.x)!=null?s:0)-this._nOriginalX,this._nY=((i=n.y)!=null?i:0)-this._nOriginalY,this._bDragging===!1&&(Math.abs(this._nX)>this._nDistance||Math.abs(this._nY)>this._nDistance)&&this._startDrag(),this._bDragging&&this.emit("drag",this._nX,this._nY,e)}}onMouseUp(e){var n,s,i,o,r,l;this._timeout!=null&&(clearTimeout(this._timeout),(n=this._oDocument)==null||n.unbind("mousemove",this.onMouseMove),(s=this._oDocument)==null||s.unbind("mouseup",this.onMouseUp),(o=(i=this._oDocument)==null?void 0:i.find("iframe"))==null||o.css("pointer-events",""),this._bDragging===!0&&(this._bDragging=!1,this.emit("dragStop",e,this._nOriginalX+this._nX)),(r=this._eBody)==null||r.removeClass("lm_dragging"),this._eElement instanceof Window||(l=this._eElement)==null||l.removeClass("lm_dragging"),this._destroyAfterMouseUp&&this.destroy())}_startDrag(){var e,n,s,i;window.clearTimeout(this._timeout),this._bDragging=!0,(e=this._eBody)==null||e.addClass("lm_dragging"),(n=this._eElement)==null||n.addClass("lm_dragging"),(i=(s=this._oDocument)==null?void 0:s.find("iframe"))==null||i.css("pointer-events","none"),this.emit("dragStart",this._nOriginalX,this._nOriginalY)}_getCoordinates(e){var n,s;return{x:(n=e.pageX)!=null?n:0,y:(s=e.pageY)!=null?s:0}}}class Nm{constructor(e,n){this._reactComponent=null,this._originalComponentWillUpdate=null,this._reactComponent=null,this._originalComponentWillUpdate=null,this._container=e,this._initialState=n,this._reactClass=this._getReactClass(),this._container.on("open",this._render,this),this._container.on("destroy",this._destroy,this)}_render(){ui.render(this._getReactComponent(),this._container.getElement()[0])}_gotReactComponent(e){if(!e)return;this._reactComponent=e,this._originalComponentWillUpdate=this._reactComponent.componentWillUpdate||function(){},this._reactComponent.componentWillUpdate=this._onUpdate.bind(this);const n=this._container.getState();n&&this._reactComponent.setState(n)}_destroy(){ui.unmountComponentAtNode(this._container.getElement()[0]),this._container.off("open",this._render,this),this._container.off("destroy",this._destroy,this)}_onUpdate(e,n){var s;this._container.setState(n),(s=this._originalComponentWillUpdate)==null||s.call(this._reactComponent,e,n)}_getReactClass(){var e=this._container._config.component;if(!e)throw new Error("No react component name. type: react-component needs a field `component`");const n=this._container.layoutManager.getComponent(e)||this._container.layoutManager.getFallbackComponent();if(!n)throw new Error('React component "'+e+'" not found. Please register all components with GoldenLayout using `registerComponent(name, component)`');return n}_getReactComponent(){var e={glEventHub:this._container.layoutManager.eventHub,glContainer:this._container,ref:this._gotReactComponent.bind(this)},n=ce.extend(e,this._container._config.props);return Y.createElement(this._reactClass,n)}}const Qr=["settings","hasHeaders","constrainDragToContainer","selectionEnabled","dimensions","borderWidth","minItemHeight","minItemWidth","headerHeight","dragProxyWidth","dragProxyHeight","labels","close","maximise","minimise","popout","content","componentName","componentState","id","width","type","height","isClosable","title","popoutWholeStack","openPopouts","parentId","activeItemIndex","reorderEnabled","borderGrabWidth"],XS=[!0,!1,"row","column","stack","component","close","maximise","minimise","open in new window"];function Ed(t){if(Qr.length>36)throw new Error("Too many keys in config minifier map");const e={};return yd(t,e,"_min"),e}function ka(t){if(Qr.length>36)throw new Error("Too many keys in config minifier map");const e={};return yd(t,e,"_max"),e}function yd(t,e,n){const s=n==="_min"?jS:QS;for(let i in t){if(!t.hasOwnProperty(i))continue;const o=Array.isArray(t)?t[Number.parseInt(i,10)]:t[i];if(typeof o=="object"&&o!=null){const r=o instanceof Array?[]:{};if(Array.isArray(e))e[Number.parseInt(i,10)]=r;else{const l=s(i,Qr);e[l]=r}yd(o,r,n)}else{const r=s(o,XS);if(Array.isArray(e))e[Number.parseInt(i,10)]=r;else{const l=s(i,Qr);e[l]=r}}}}function jS(t,e){if(typeof t=="string"&&t.length===1)return"___"+t;var n=e.indexOf(t);return n===-1?t:n.toString(36)}function QS(t,e){return typeof t=="string"&&t.length===1?e[parseInt(t,36)]:typeof t=="string"&&t.substr(0,3)==="___"?t[3]:t}class Oa{constructor(e,n){this.name=e,this.origin=n,this.isPropagationStopped=!1}stopPropagation(){this.isPropagationStopped=!0}}class Fm extends bn{constructor(e){super(),this._layoutManager=e,this._dontPropagateToParent=null,this._childEventSource=null,this.on(bn.ALL_EVENT,this._onEventFromThis.bind(this)),this._boundOnEventFromChild=this._onEventFromChild.bind(this),ce(window).on("gl_child_event",this._boundOnEventFromChild)}_onEventFromThis(...e){this._layoutManager.isSubWindow&&e[0]!==this._dontPropagateToParent&&this._propagateToParent(e),this._propagateToChildren(e),this._dontPropagateToParent=null,this._childEventSource=null}_$onEventFromParent(e){this._dontPropagateToParent=e[0],this.emit.apply(this,e)}_onEventFromChild(e){this._childEventSource=e.originalEvent.__gl,this.emit.apply(this,e.originalEvent.__glArgs)}_propagateToParent(e){var i;const n="gl_child_event",s=(i=window.opener)==null?void 0:i.document.createEvent("HTMLEvents");s.initEvent(n,!0,!0),s.eventName=n,s.__glArgs=e,s.__gl=this._layoutManager,window.opener.dispatchEvent(s)}_propagateToChildren(e){for(let n=0;n<this._layoutManager.openPopouts.length;n++){const s=this._layoutManager.openPopouts[n].getGlInstance();s&&s!==this._childEventSource&&s.eventHub._$onEventFromParent(e)}}destroy(){ce(window).off("gl_child_event",this._boundOnEventFromChild)}}const ZS=Object.freeze(Object.defineProperty({__proto__:null,EventEmitter:bn,DragListener:Wo,ReactComponentHandler:Nm,BubblingEvent:Oa,EventHub:Fm,getHashValue:Dm,getQueryStringParam:Mm,animFrame:Nl,removeFromArray:qS,getUniqueId:vd,filterXss:YS,stripTags:Td,minifyConfig:Ed,unminifyConfig:ka},Symbol.toStringTag,{value:"Module"}));class xm extends bn{constructor(e,n,s,i,o){super(),this.isInitialised=!1,this._popoutWindow=null,this._id=null,this._config=e,this._dimensions=n,this._parentId=s,this._indexInParent=i,this._layoutManager=o,this._createWindow()}toConfig(){var e,n,s,i,o,r,l,a,d,c,u;if(this.isInitialised===!1)throw new Error("Can't create config, layout not yet initialised");return{dimensions:{width:(e=this.getGlInstance())==null?void 0:e.width,height:(n=this.getGlInstance())==null?void 0:n.height,left:(r=(o=(s=this._popoutWindow)==null?void 0:s.screenX)!=null?o:(i=this._popoutWindow)==null?void 0:i.screenLeft)!=null?r:0,top:(c=(d=(l=this._popoutWindow)==null?void 0:l.screenY)!=null?d:(a=this._popoutWindow)==null?void 0:a.screenTop)!=null?c:0},content:(u=this.getGlInstance())==null?void 0:u.toConfig().content,parentId:this._parentId,indexInParent:this._indexInParent}}getGlInstance(){var e;return(e=this._popoutWindow)==null?void 0:e.__glInstance}getWindow(){return this._popoutWindow}close(){var e,n;if(this.getGlInstance())(e=this.getGlInstance())==null||e._$closeWindow();else try{(n=this.getWindow())==null||n.close()}catch{}}popIn(){var s,i;this._indexInParent;let e=null,n=null;this._parentId&&(e=ce.extend(!0,{},(s=this.getGlInstance())==null?void 0:s.toConfig()).content[0],n=this._layoutManager.root.getItemsById(this._parentId)[0],n||(((i=this._layoutManager.root.contentItems.length)!=null?i:0)>0?n=this._layoutManager.root.contentItems[0]:n=this._layoutManager.root)),e&&(n==null||n.addChild(e,this._indexInParent),this.close())}_createWindow(){const e=this._createUrl(),n=Math.floor(Math.random()*1e6).toString(36),s=this._serializeWindowOptions({width:this._dimensions.width,height:this._dimensions.height,innerWidth:this._dimensions.width,innerHeight:this._dimensions.height,menubar:"no",toolbar:"no",location:"no",personalbar:"no",resizable:"yes",scrollbars:"no",status:"no"});if(this._popoutWindow=window.open(e,n,s),!this._popoutWindow)if(this._layoutManager.config.settings.blockedPopoutsThrowError===!0){const o=new Error("Popout blocked");throw o.type="popoutBlocked",o}else return;ce(this._popoutWindow).on("load",this._positionWindow.bind(this)).on("unload beforeunload",this._onClose.bind(this));let i=window.setInterval(()=>{var o;((o=this._popoutWindow)==null?void 0:o.__glInstance)&&this._popoutWindow.__glInstance.isInitialised&&(this._onInitialised(),window.clearInterval(i))},10)}_serializeWindowOptions(e){var n=[],s;for(s in e)n.push(s+"="+e[s]);return n.join(",")}_createUrl(){var e={content:this._config};const n="gl-window-config-"+vd();e=Ed(e);try{localStorage.setItem(n,JSON.stringify(e))}catch(i){throw new Error("Error while writing to localStorage "+i.toString())}const s=document.location.href.split("?");return s.length===1?s[0]+"?gl-window="+n:document.location.href+"&gl-window="+n}_positionWindow(){var e,n;(e=this._popoutWindow)==null||e.moveTo(this._dimensions.left,this._dimensions.top),(n=this._popoutWindow)==null||n.focus()}_onInitialised(){var e;this.isInitialised=!0,(e=this.getGlInstance())==null||e.on("popIn",this.popIn,this),this.emit("initialised")}_onClose(){setTimeout(this.emit.bind(this,"closed"),50)}}const _m=class extends bn{constructor(t,e,n,s,i,o){var l,a,d,c,u,m,p,g,f,b,C,w;super(),this._area=null,this._lastValidArea=null,this._dragListener=n,this._layoutManager=s,this._contentItem=i,this._originalParent=o,this._dragListener.on("drag",this._onDrag,this),this._dragListener.on("dragStop",this._onDrop,this),this._contentItem.tab&&this._contentItem.tab.element&&(this._layoutManager.tabDropPlaceholder.width((l=this._contentItem.tab.element.outerWidth(!0))!=null?l:0),this._layoutManager.tabDropPlaceholder.height((a=this._contentItem.tab.element.outerHeight(!0))!=null?a:0)),this.element=ce(_m._template),o&&o._side&&(this._sided=o._sided,this.element.addClass("lm_"+o._side),["right","bottom"].indexOf(o._side.toString())>=0&&this.element.find(".lm_content").after(this.element.find(".lm_header"))),this.element.css({left:t,top:e}),this._proxyTab=this.element.find(".lm_tab"),this._proxyTab.attr("title",Td((d=this._contentItem.config.title)!=null?d:"")),this.element.find(".lm_title").html((c=this._contentItem.config.title)!=null?c:""),this.childElementContainer=this.element.find(".lm_content"),this.childElementContainer.append(i.element),this._updateTree(),this._layoutManager._$calculateItemAreas(),this._setDimensions(),ce(document.body).append(this.element),!this._contentItem.tab&&this._proxyTab.length&&(this._layoutManager.tabDropPlaceholder.width((u=this._proxyTab.outerWidth(!0))!=null?u:0),this._layoutManager.tabDropPlaceholder.height((m=this._proxyTab.outerHeight(!0))!=null?m:0));var r=this._layoutManager.container.offset();this._minX=(p=r==null?void 0:r.left)!=null?p:0,this._minY=(g=r==null?void 0:r.top)!=null?g:0,this._maxX=((f=this._layoutManager.container.width())!=null?f:0)+this._minX,this._maxY=((b=this._layoutManager.container.height())!=null?b:0)+this._minY,this._width=(C=this.element.width())!=null?C:0,this._height=(w=this.element.height())!=null?w:0,this._setDropPosition(t,e),this._layoutManager.emit("itemPickedUp",this._contentItem)}_onDrag(t,e,n){var r,l;const s=(r=n.pageX)!=null?r:0,i=(l=n.pageY)!=null?l:0;!(s>this._minX&&s<this._maxX&&i>this._minY&&i<this._maxY)&&this._layoutManager.config.settings.constrainDragToContainer===!0||this._setDropPosition(s,i)}_setDropPosition(t,e){this.element.css({left:t,top:e}),this._area=this._layoutManager._$getArea(t,e),this._area!==null&&(this._lastValidArea=this._area,this._area.contentItem._$highlightDropZone(t,e,this._area))}_onDrop(){var t;(t=this._layoutManager.dropTargetIndicator)==null||t.hide(),this._area!==null?this._area.contentItem._$onDrop(this._contentItem,this._area):this._lastValidArea!==null?this._lastValidArea.contentItem._$onDrop(this._contentItem,this._lastValidArea):this._originalParent?this._originalParent.addChild(this._contentItem):this._contentItem._$destroy(),this._dragListener.off("drag",this._onDrag,this),this._dragListener.off("dragStop",this._onDrop,this),this.element.remove(),this._layoutManager.emit("itemDropped",this._contentItem)}_updateTree(){this._contentItem.parent&&this._contentItem.parent.removeChild(this._contentItem,!0),this._contentItem._$setParent(null)}_setDimensions(){const t=this._layoutManager.config.dimensions;let e=t.dragProxyWidth,n=t.dragProxyHeight;this.element.width(e),this.element.height(n),e-=this._sided?t.headerHeight:0,n-=this._sided?0:t.headerHeight,this.childElementContainer.width(e),this.childElementContainer.height(n),this._contentItem.element.width(e),this._contentItem.element.height(n),this._contentItem.callDownwards("_$show"),this._contentItem.callDownwards("setSize")}};let Go=_m;Go._template='<div class="lm_dragProxy"><div class="lm_header"><ul class="lm_tabs"><li class="lm_tab lm_active"><i class="lm_left"></i><span class="lm_title"></span><i class="lm_right"></i></li></ul></div><div class="lm_content"></div></div>';class km{constructor(e,n,s){this._element=e,this._itemConfig=n,this._layoutManager=s,this._dragListener=this._createDragListener()}_createDragListener(){return this._dragListener=new Wo(this._element,!0),this._dragListener.on("dragStart",this._onDragStart,this),this._dragListener.on("dragStop",this._createDragListener,this),this._dragListener}_onDragStart(e,n){var r;let s=this._itemConfig;typeof s=="function"&&(s=s());const i=this._layoutManager._$normalizeContentItem(ce.extend(!0,{},s)),o=new Go(e,n,this._dragListener,this._layoutManager,i,null);(r=this._layoutManager.transitionIndicator)==null||r.transitionElements(this._element,o.element)}}class Om{constructor(e,n,s){this._element=ce(window),this._itemConfig=e,this._layoutManager=n,this._createDragListener(s)}_createDragListener(e){this._dragListener&&this._dragListener.destroy(),this._element&&(this._dragListener=new Wo(this._element,!0),this._dragListener.on("dragStart",this._onDragStart,this),this._dragListener.on("dragStop",this._destroy,this),this._dragListener.onMouseDown(e),this._dragListener._startDrag())}_destroy(){this._dragListener=void 0,this._element=void 0,this._itemConfig=void 0,this._layoutManager=void 0}_onDragStart(e,n){if(!(!this._dragListener||!this._layoutManager)){var s=this._itemConfig;typeof s=="function"&&(s=s());var i=this._layoutManager._$normalizeContentItem(ce.extend(!0,{},s));new Go(e,n,this._dragListener,this._layoutManager,i,null)}}}const Lm=class{constructor(){this.element=ce(Lm._template),ce(document.body).append(this.element)}destroy(){this.element.remove()}highlightArea(t){this.element.css({left:t.x1,top:t.y1,width:Math.floor(t.x2-t.x1),height:Math.floor(t.y2-t.y1)}).show()}hide(){this.element.hide()}};let Id=Lm;Id._template='<div class="lm_dropTargetIndicator"><div class="lm_inner"></div></div>';class Io{constructor(e,n,s,i){this._header=e,this.element=ce('<li class="'+s+'" title="'+n+'"></li>'),this._header.on("destroy",this._$destroy,this),this._action=i,this.element.on("click",this._action),this._header.controlsContainer.append(this.element)}_$destroy(){this.element.off(),this.element.remove()}}class ii extends Error{constructor(e,n){super(),this.name="Configuration Error",this.message=e,this.node=n}}const JS=Object.freeze(Object.defineProperty({__proto__:null,ConfigurationError:ii},Symbol.toStringTag,{value:"Module"}));function Ao(t){return t.isStack}function yn(t){return t.isComponent}function Am(t){return t.isRoot}class vt extends bn{constructor(e,n,s,i){super(),this.isInitialised=!1,this.isMaximised=!1,this.isRoot=!1,this.isRow=!1,this.isColumn=!1,this.isStack=!1,this.isComponent=!1,this.element=i,this.config=this._extendItemNode(n),this.type=n.type,this.contentItems=[],this.parent=s,this.layoutManager=e,this._pendingEventPropagations={},this._throttledEvents=["stateChanged"],this.on(bn.ALL_EVENT,this._propagateEvent,this),n.content&&this._createContentItems(n)}callDownwards(e,n=[],s=!1,i=!1){s!==!0&&i!==!0&&this[e].apply(this,n);for(let o=0;o<this.contentItems.length;o++)this.contentItems[o].callDownwards(e,n,s);s===!0&&i!==!0&&this[e].apply(this,n)}removeChild(e,n=!1){var i,o;const s=this.contentItems.indexOf(e);if(s===-1)throw new Error("Can't remove child item. Unknown content item");n!==!0&&this.contentItems[s]._$destroy(),this.contentItems.splice(s,1),(i=this.config.content)==null||i.splice(s,1),this.contentItems.length>0?this.callDownwards("setSize"):this.type!=="root"&&this.config.isClosable&&((o=this.parent)==null||o.removeChild(this))}addChild(e,n){e=this.layoutManager._$normalizeContentItem(e,this),n===void 0&&(n=this.contentItems.length),this.contentItems.splice(n,0,e),this.config.content===void 0&&(this.config.content=[]),this.config.content.splice(n,0,e.config),e.parent=this,e.parent.isInitialised===!0&&e.isInitialised===!1&&e._$init()}replaceChild(e,n,s=!1){n=this.layoutManager._$normalizeContentItem(n);const i=this.contentItems.indexOf(e),o=e.element[0].parentNode;if(i===-1)throw new Error("Can't replace child. oldChild is not child of this");o==null||o.replaceChild(n.element[0],e.element[0]),s===!0&&(e.parent=null,e._$destroy()),this.contentItems[i]=n,n.parent=this,Ao(this)&&(this.header.tabs[i].contentItem=n),n.parent.isInitialised===!0&&n.isInitialised===!1&&n._$init(),this.callDownwards("setSize")}remove(){var e;(e=this.parent)==null||e.removeChild(this)}popout(){var e=this.layoutManager.createPopout(this);return this.emitBubblingEvent("stateChanged"),e}toggleMaximise(e){e&&e.preventDefault(),this.isMaximised===!0?this.layoutManager._$minimiseItem(this):this.layoutManager._$maximiseItem(this),this.isMaximised=!this.isMaximised,this.emitBubblingEvent("stateChanged")}select(){this.layoutManager.selectedItem!==this&&(this.layoutManager.selectItem(this,!0),this.element.addClass("lm_selected"))}deselect(){this.layoutManager.selectedItem===this&&(this.layoutManager.selectedItem=null,this.element.removeClass("lm_selected"))}setTitle(e){this.config.title=e,this.emit("titleChanged",e),this.emitBubblingEvent("stateChanged")}hasId(e){if(this.config.id){if(typeof this.config.id=="string")return this.config.id===e;if(this.config.id instanceof Array)return this.config.id.indexOf(e)!==-1}else return!1}addId(e){this.hasId(e)||(this.config.id?typeof this.config.id=="string"?this.config.id=[this.config.id,e]:this.config.id instanceof Array&&this.config.id.push(e):this.config.id=e)}removeId(e){if(!this.hasId(e))throw new Error("Id not found");if(typeof this.config.id=="string")delete this.config.id;else if(this.config.id instanceof Array){var n=this.config.id.indexOf(e);this.config.id.splice(n,1)}}getItemsByFilter(e){const n=[],s=function(i){for(let o=0;o<i.contentItems.length;o++)e(i.contentItems[o])===!0&&n.push(i.contentItems[o]),s(i.contentItems[o])};return s(this),n}getItemsById(e){return this.getItemsByFilter(function(n){return n.config.id instanceof Array?n.config.id.indexOf(e)!==-1:n.config.id===e})}getItemsByType(e){return this._$getItemsByProperty("type",e)}getComponentsByName(e){const n=this._$getItemsByProperty("componentName",e),s=[];for(let i=0;i<n.length;i++)s.push(n[i].instance);return s}_$getItemsByProperty(e,n){return this.getItemsByFilter(function(s){return s[e]===n})}_$setParent(e){this.parent=e}_$highlightDropZone(e,n,s){var i;(i=this.layoutManager.dropTargetIndicator)==null||i.highlightArea(s)}_$onDrop(e,n){this.addChild(e)}_$hide(){this._callOnActiveComponents("hide"),this.element.hide(),this.layoutManager.updateSize()}_$show(){this._callOnActiveComponents("show"),this.element.show(),this.layoutManager.updateSize()}_callOnActiveComponents(e){const n=this.getItemsByType("stack");let s=null;for(let i=0;i<n.length;i++)s=n[i].getActiveContentItem(),s&&yn(s)&&s.container[e]()}_$destroy(){this.emitBubblingEvent("beforeItemDestroyed"),this.callDownwards("_$destroy",[],!0,!0),this.element.remove(),this.emitBubblingEvent("itemDestroyed")}_$getArea(e){var o,r,l;e=e||this.element;const n=(o=e.offset())!=null?o:{left:0,top:0},s=(r=e.width())!=null?r:0,i=(l=e.height())!=null?l:0;return{x1:n.left,y1:n.top,x2:n.left+s,y2:n.top+i,surface:s*i,contentItem:this,side:""}}_$init(){var e;this.setSize();for(let n=0;n<this.contentItems.length;n++)(e=this.childElementContainer)==null||e.append(this.contentItems[n].element);this.isInitialised=!0,this.emitBubblingEvent("itemCreated"),this.emitBubblingEvent(this.type+"Created")}emitBubblingEvent(e){var n=new Oa(e,this);this.emit(e,n)}_createContentItems(e){var n;if(!(e.content instanceof Array))throw new ii("content must be an Array",e);for(let s=0;s<e.content.length;s++)n=this.layoutManager.createContentItem(e.content[s],this),this.contentItems.push(n)}_extendItemNode(e){for(let[n,s]of Object.entries(Rm)){const i=n;e[i]===void 0&&(e[i]=s)}return e}_propagateEvent(e,n){n instanceof Oa&&n.isPropagationStopped===!1&&this.isInitialised===!0&&(this.isRoot===!1&&this.parent?this.parent.emit.apply(this.parent,[e,n]):this._scheduleEventPropagationToLayoutManager(e,n))}_scheduleEventPropagationToLayoutManager(e,n){this._throttledEvents.indexOf(e)===-1?this.layoutManager.emit(e,n.origin):this._pendingEventPropagations[e]!==!0&&(this._pendingEventPropagations[e]=!0,Nl(this._propagateEventToLayoutManager.bind(this,e,n)))}_propagateEventToLayoutManager(e,n){this._pendingEventPropagations[e]=!1,this.layoutManager.emit(e,n)}}class Pm extends vt{constructor(e,n,s){super(e,n,s,ce()),this.config=n,this.parent=s;const i=e.getComponent(this.config.componentName)||e.getFallbackComponent(),o=ce.extend(!0,{},this.config.componentState||{});if(i==null)throw new ii('Unknown component "'+this.config.componentName+'"');o.componentName=this.config.componentName,this.componentName=this.config.componentName,this.config.title===""&&(this.config.title=this.config.componentName),this.isComponent=!0,this.container=new _a(this.config,this,e),this.instance=new i(this.container,o),this.element=this.container._element}close(){this.parent.removeChild(this)}setSize(){this.element.is(":visible")&&this.container._$setSize(this.element.width(),this.element.height())}_$init(){vt.prototype._$init.call(this),this.container.emit("open")}_$hide(){this.container.hide(),vt.prototype._$hide.call(this)}_$show(){this.container.show(),this.container._config.isFocusOnShow&&this.container._contentElement[0].focus({preventScroll:!0}),vt.prototype._$show.call(this)}_$destroy(){this.container.emit("destroy",this),vt.prototype._$destroy.call(this)}_$getArea(){return null}}class Zr extends vt{constructor(e,n,s,i){super(n,s,i,ce('<div class="lm_item lm_'+(e?"column":"row")+'"></div>')),this._splitter=[],this._splitterPosition=null,this._splitterMinPosition=null,this._splitterMaxPosition=null,this.parent=i,this.isRow=!e,this.isColumn=e,this.childElementContainer=this.element,this._splitterSize=n.config.dimensions.borderWidth,this._splitterGrabSize=n.config.dimensions.borderGrabWidth,this._isColumn=e,this._dimension=e?"height":"width",this._splitterPosition=null,this._splitterMinPosition=null,this._splitterMaxPosition=null}addChild(e,n,s){var a;var i,o,r,l;if(e=this.layoutManager._$normalizeContentItem(e,this),n===void 0&&(n=this.contentItems.length),this.contentItems.length>0?(l=this._createSplitter(Math.max(0,n-1)).element,n>0?(this.contentItems[n-1].element.after(l),l.after(e.element)):(this.contentItems[0].element.before(l),l.before(e.element))):this.childElementContainer.append(e.element),vt.prototype.addChild.call(this,e,n),i=1/this.contentItems.length*100,s===!0){this.emitBubblingEvent("stateChanged");return}for(r=0;r<this.contentItems.length;r++)this.contentItems[r]===e?e.config[this._dimension]=i:(o=((a=this.contentItems[r].config[this._dimension])!=null?a:0)*(100-i)/100,this.contentItems[r].config[this._dimension]=o);this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged")}removeChild(e,n){var a,d;var s=(a=e.config[this._dimension])!=null?a:0,i=this.contentItems.indexOf(e),o=Math.max(i-1,0),r,l;if(i===-1)throw new Error("Can't remove child. ContentItem is not child of this Row or Column");for(this._splitter[o]&&(this._splitter[o]._$destroy(),this._splitter.splice(o,1)),r=0;r<this.contentItems.length;r++)this.contentItems[r]!==e&&(this.contentItems[r].config[this._dimension]=((d=this.contentItems[r].config[this._dimension])!=null?d:0)+s/(this.contentItems.length-1));vt.prototype.removeChild.call(this,e,n),this.contentItems.length===1&&this.config.isClosable===!0?(l=this.contentItems[0],this.contentItems=[],this.parent.replaceChild(this,l,!0)):(this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged"))}replaceChild(e,n){var s=e.config[this._dimension];super.replaceChild(e,n),n.config[this._dimension]=s,this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged")}setSize(){this.contentItems.length>0&&(this._calculateRelativeSizes(),this._setAbsoluteSizes()),this.emitBubblingEvent("stateChanged"),this.emit("resize")}_$init(){if(this.isInitialised!==!0){var e;for(vt.prototype._$init.call(this),e=0;e<this.contentItems.length-1;e++)this.contentItems[e].element.after(this._createSplitter(e).element)}}_setAbsoluteSizes(){var e,n=this._calculateAbsoluteSizes();for(e=0;e<this.contentItems.length;e++)n.additionalPixel-e>0&&n.itemSizes[e]++,this._isColumn?(this.contentItems[e].element.width(n.totalWidth),this.contentItems[e].element.height(n.itemSizes[e])):(this.contentItems[e].element.width(n.itemSizes[e]),this.contentItems[e].element.height(n.totalHeight))}_calculateAbsoluteSizes(){var l,a,d,c;const e=(this.contentItems.length-1)*this._splitterSize;let n=(l=this.element.width())!=null?l:0,s=(a=this.element.height())!=null?a:0,i=0;const o=[];this._isColumn?s-=e:n-=e;for(let u=0;u<this.contentItems.length;u++){const m=this._isColumn?Math.floor(s*(((d=this.contentItems[u].config.height)!=null?d:0)/100)):Math.floor(n*(((c=this.contentItems[u].config.width)!=null?c:0)/100));i+=m,o.push(m)}const r=Math.floor((this._isColumn?s:n)-i);return{itemSizes:o,additionalPixel:r,totalWidth:n,totalHeight:s}}_calculateRelativeSizes(){var i,o;let e=0;const n=[],s=this._isColumn?"height":"width";for(let r=0;r<this.contentItems.length;r++)this.contentItems[r].config[s]!==void 0?e+=(i=this.contentItems[r].config[s])!=null?i:0:n.push(this.contentItems[r]);if(Math.round(e)===100){this._respectMinItemWidth();return}if(Math.round(e)<100&&n.length>0){for(let r=0;r<n.length;r++)n[r].config[s]=(100-e)/n.length;this._respectMinItemWidth();return}if(Math.round(e)>100)for(let r=0;r<n.length;r++)n[r].config[s]=50,e+=50;for(let r=0;r<this.contentItems.length;r++)this.contentItems[r].config[s]=((o=this.contentItems[r].config[s])!=null?o:0)/e*100;this._respectMinItemWidth()}_respectMinItemWidth(){var c;const e=this.layoutManager.config.dimensions&&(c=this.layoutManager.config.dimensions.minItemWidth)!=null?c:0,n=[];let s=0,i=0,o=0;const r=[];let l;if(this._isColumn||!e||this.contentItems.length<=1)return;const a=this._calculateAbsoluteSizes();for(let u=0;u<this.contentItems.length;u++){this.contentItems[u];const m=a.itemSizes[u];m<e?(i+=e-m,l={width:e}):(s+=m-e,l={width:m},n.push(l)),r.push(l)}if(i===0||i>s)return;const d=i/s;o=i;for(let u=0;u<n.length;u++){l=n[u];const m=Math.round((l.width-e)*d);o-=m,l.width-=m}o!==0&&(r[r.length-1].width-=o);for(let u=0;u<this.contentItems.length;u++)this.contentItems[u].config.width=r[u].width/a.totalWidth*100}_createSplitter(e){var n;return n=new Vm(this._isColumn,this._splitterSize,this._splitterGrabSize),n.on("drag",this._onSplitterDrag.bind(this,n),this),n.on("dragStop",this._onSplitterDragStop.bind(this,n),this),n.on("dragStart",this._onSplitterDragStart.bind(this,n),this),this._splitter.splice(e,0,n),n}_getItemsForSplitter(e){const n=this._splitter.indexOf(e);if(n<0)throw new Error("Splitter not found in RowOrColumn");return{before:this.contentItems[n],after:this.contentItems[n+1]}}_getMinimumDimensions(e){var o,r;for(var n=0,s=0,i=0;i<e.length;++i)n=Math.max((o=e[i].minWidth)!=null?o:0,n),s=Math.max((r=e[i].minHeight)!=null?r:0,s);return{horizontal:n,vertical:s}}_onSplitterDragStart(e){var a,d,c,u;const n=this._getItemsForSplitter(e),s=this.layoutManager.config.dimensions[this._isColumn?"minItemHeight":"minItemWidth"];var i=this._getMinimumDimensions((a=n.before.config.content)!=null?a:[]),o=this._isColumn?i.vertical:i.horizontal,r=this._getMinimumDimensions((d=n.after.config.content)!=null?d:[]),l=this._isColumn?r.vertical:r.horizontal;this._splitterPosition=0,this._splitterMinPosition=-1*(((c=n.before.element[this._dimension]())!=null?c:0)-(o||s)),this._splitterMaxPosition=((u=n.after.element[this._dimension]())!=null?u:0)-(l||s)}_onSplitterDrag(e,n,s){const i=this._isColumn?s:n;this._splitterMaxPosition==null||this._splitterMinPosition==null||i>this._splitterMinPosition&&i<this._splitterMaxPosition&&(this._splitterPosition=i,e.element.css(this._isColumn?"top":"left",i))}_onSplitterDragStop(e){var l,a,d,c,u;const n=this._getItemsForSplitter(e),s=(l=n.before.element[this._dimension]())!=null?l:0,i=(a=n.after.element[this._dimension]())!=null?a:0,o=(((d=this._splitterPosition)!=null?d:0)+s)/(s+i),r=((c=n.before.config[this._dimension])!=null?c:0)+((u=n.after.config[this._dimension])!=null?u:0);n.before.config[this._dimension]=o*r,n.after.config[this._dimension]=(1-o)*r,e.element.css({top:0,left:0}),Nl(this.callDownwards.bind(this,"setSize",void 0,void 0,void 0))}}class La extends vt{constructor(e,n,s){super(e,{...n,type:"root"},null,ce('<div class="lm_goldenlayout lm_item lm_root"></div>')),this.isRoot=!0,this.type="root",this.childElementContainer=this.element,this._containerElement=s,this._containerElement.append(this.element)}addChild(e,n){if(this.contentItems.length>0)throw new Error("Root node can only have a single child");e=this.layoutManager._$normalizeContentItem(e,this),this.childElementContainer.append(e.element),super.addChild(e,n),this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged")}setSize(e,n){var s,i;e=typeof e>"u"?(s=this._containerElement.width())!=null?s:0:e,n=typeof n>"u"?(i=this._containerElement.height())!=null?i:0:n,this.element.width(e),this.element.height(n),this.contentItems[0]&&(this.contentItems[0].element.width(e),this.contentItems[0].element.height(n))}_$getArea(){const e=super._$getArea();if(e==null)throw new Error("Unable to get root area");return e}_$highlightDropZone(e,n,s){this.layoutManager.tabDropPlaceholder.remove(),super._$highlightDropZone(e,n,s)}_$onDrop(e,n){var i;var s;if(yn(e)&&(s=this.layoutManager.createContentItem({type:"stack",header:e.config.header||{}},this),s._$init(),s.addChild(e),e=s),!this.contentItems.length)this.addChild(e);else{const{side:o}=n,r=o==="left"||o==="right"?"row":"column",l=o==="left"||o==="right"?"width":"height",a=o==="left"||o==="top",d=this.contentItems[0];if(!(d instanceof Zr)||d.type!=r){const c=this.layoutManager.createContentItem({type:r},this);this.replaceChild(d,c),c.addChild(e,a?0:void 0,!0),c.addChild(d,a?void 0:0,!0),d.config[l]=50,e.config[l]=50,c.callDownwards("setSize")}else{const c=d.contentItems[a?0:d.contentItems.length-1];d.addChild(e,a?0:void 0,!0),c.config[l]=((i=c.config[l])!=null?i:0)*.5,e.config[l]=c.config[l],d.callDownwards("setSize")}}}}class Aa extends vt{constructor(e,n,s){var o,r,l,a,d,c,u,m,p;super(e,n,s,ce('<div class="lm_item lm_stack"></div>')),this._activeContentItem=null,this.childElementContainer=ce('<div class="lm_items"></div>'),this.isStack=!0,this._dropZones={},this._dropSegment=null,this._contentAreaDimensions=null,this._sided=!1,this.parent=s,this.config=n;const i=e.config;this._side=!1,this._header={show:((o=i.settings)==null?void 0:o.hasHeaders)&&n.hasHeaders!==!1,popout:(r=i.settings)!=null&&r.showPopoutIcon?(l=i.labels)==null?void 0:l.popout:void 0,maximise:(a=i.settings)!=null&&a.showMaximiseIcon?(d=i.labels)==null?void 0:d.maximise:void 0,close:(c=i.settings)!=null&&c.showCloseIcon?(u=i.labels)==null?void 0:u.close:void 0,minimise:(p=(m=i.labels)==null?void 0:m.minimise)!=null?p:void 0},i.header&&(this._header={...this._header,...i.header}),n.header&&(this._header={...this._header,...n.header}),n.content&&n.content[0]&&n.content[0].header&&(this._header={...this._header,...n.content[0].header}),this.header=new Ko(e,this),this.element.append(this.header.element),this.element.append(this.childElementContainer),this._setupHeaderPosition(),this._$validateClosability()}setSize(){var o,r,l,a;var e,n=this._header.show&&(r=(o=this.layoutManager.config.dimensions)==null?void 0:o.headerHeight)!=null?r:0,s=((l=this.element.width())!=null?l:0)-(this._sided?n:0),i=((a=this.element.height())!=null?a:0)-(this._sided?0:n);for(this.childElementContainer.width(s),this.childElementContainer.height(i),e=0;e<this.contentItems.length;e++)this.contentItems[e].element.width(s).height(i);this.emit("resize"),this.emitBubblingEvent("stateChanged")}_$init(){if(this.isInitialised!==!0){this.header._attachWheelListener(),super._$init();for(let e=0;e<this.contentItems.length;e++)this.header.createTab(this.contentItems[e]),this.contentItems[e]._$hide();if(this.contentItems.length>0){const e=this.contentItems[this.config.activeItemIndex||0];if(!e)throw new Error("Configured activeItemIndex out of bounds");this.setActiveContentItem(e)}}}setActiveContentItem(e){if(this.contentItems.indexOf(e)===-1)throw new Error("contentItem is not a child of this stack");this._activeContentItem!==null&&this._activeContentItem._$hide(),this._activeContentItem=e,this.header.setActiveContentItem(e),e._$show(),this.emit("activeContentItemChanged",e),this.layoutManager.emit("activeContentItemChanged",e),this.emitBubblingEvent("stateChanged")}getActiveContentItem(){return this.header.activeContentItem}addChild(e,n){e=this.layoutManager._$normalizeContentItem(e,this),super.addChild(e,n),this.childElementContainer.append(e.element),this.header.createTab(e,n),this.setActiveContentItem(e),this.callDownwards("setSize"),this._$validateClosability(),this.emitBubblingEvent("stateChanged")}removeChild(e,n=!1){var s=this.contentItems.indexOf(e);super.removeChild(e,n),this.header.removeTab(e),this.header.activeContentItem===e&&(this.contentItems.length>0?this.setActiveContentItem(this.contentItems[Math.max(s-1,0)]):this._activeContentItem=null),this._$validateClosability(),this.emitBubblingEvent("stateChanged")}_$validateClosability(){var n;let e=this.header._isClosable();for(let s=0,i=this.contentItems.length;s<i&&e;s++)e=(n=this.contentItems[s].config.isClosable)!=null?n:!1;this.header._$setClosable(e)}_$destroy(){vt.prototype._$destroy.call(this),this.header._$destroy()}_$onDrop(e){var a;if(this._dropSegment==="header"){this._resetHeaderDropZone(),this.addChild(e,this._dropIndex);return}if(this._dropSegment==="body"){this.addChild(e);return}const n=this._dropSegment==="top"||this._dropSegment==="bottom",s=this._dropSegment==="left"||this._dropSegment==="right",i=this._dropSegment==="top"||this._dropSegment==="left",o=n&&this.parent.isColumn||s&&this.parent.isRow,r=n?"column":"row",l=n?"height":"width";if(yn(e)){const d=this.layoutManager.createContentItem({type:"stack",header:e.config.header||{}},this);d._$init(),d.addChild(e),e=d}if(o){const d=this.parent.contentItems.indexOf(this);this.parent.addChild(e,i?d:d+1,!0),this.config[l]=((a=this.config[l])!=null?a:0)*.5,e.config[l]=this.config[l],this.parent.callDownwards("setSize")}else{const d=this.layoutManager.createContentItem({type:r},this);this.parent.replaceChild(this,d),d.addChild(e,i?0:void 0,!0),d.addChild(this,i?void 0:0,!0),this.config[l]=50,e.config[l]=50,d.callDownwards("setSize")}}_$highlightDropZone(e,n){if(!!this._contentAreaDimensions)for(let[s,i]of Object.entries(this._contentAreaDimensions)){const o=i.hoverArea;if(o.x1<e&&o.x2>e&&o.y1<n&&o.y2>n){s==="header"?(this._dropSegment="header",this._highlightHeaderDropZone(e)):(this._resetHeaderDropZone(),this._highlightBodyDropZone(s));return}}}_$getArea(){if(this.element.is(":visible")===!1)return null;const e=super._$getArea(this.header.element),n=super._$getArea(this.childElementContainer);if(e==null||n==null)return null;const s=n.x2-n.x1,i=n.y2-n.y1;return this._contentAreaDimensions={header:{hoverArea:{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2},highlightArea:{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2}}},this._activeContentItem&&this._activeContentItem.isComponent===!1?e:this.contentItems.length===0?(this._contentAreaDimensions.body={hoverArea:{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2},highlightArea:{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2}},super._$getArea(this.element)):(this._contentAreaDimensions.left={hoverArea:{x1:n.x1,y1:n.y1,x2:n.x1+s*.25,y2:n.y2},highlightArea:{x1:n.x1,y1:n.y1,x2:n.x1+s*.5,y2:n.y2}},this._contentAreaDimensions.top={hoverArea:{x1:n.x1+s*.25,y1:n.y1,x2:n.x1+s*.75,y2:n.y1+i*.5},highlightArea:{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y1+i*.5}},this._contentAreaDimensions.right={hoverArea:{x1:n.x1+s*.75,y1:n.y1,x2:n.x2,y2:n.y2},highlightArea:{x1:n.x1+s*.5,y1:n.y1,x2:n.x2,y2:n.y2}},this._contentAreaDimensions.bottom={hoverArea:{x1:n.x1+s*.25,y1:n.y1+i*.5,x2:n.x1+s*.75,y2:n.y2},highlightArea:{x1:n.x1,y1:n.y1+i*.5,x2:n.x2,y2:n.y2}},super._$getArea(this.element))}_highlightHeaderDropZone(e){var u,m,p,g,f,b,C,w,T,y,E,I,R,F,x,U,$,O,H,L,N,_,k,V,W,j;const n=this.header.tabs.length;if(n===0){const ee=this.header.element.offset();(w=this.layoutManager.dropTargetIndicator)==null||w.highlightArea({x1:(u=ee==null?void 0:ee.left)!=null?u:0,x2:((m=ee==null?void 0:ee.left)!=null?m:0)+100,y1:(g=(p=this.header.element.offset())==null?void 0:p.top)!=null?g:0,y2:((b=(f=this.header.element.offset())==null?void 0:f.top)!=null?b:0)+((C=this.header.element.innerHeight())!=null?C:0)});return}const i=(T=this.header.tabsContainer.get(0))==null?void 0:T.getBoundingClientRect(),o=(y=this.layoutManager.tabDropPlaceholder.get(0))==null?void 0:y.getBoundingClientRect();if(!i||!o)return;e<i.left?e=i.left+1:e>i.right&&(e=i.right-1);let r,l;if(!(o.left<e&&e<o.right)){for(var a=0;a<n;a++)if(r=this.header.tabs[a].element,l=(E=r.get(0))==null?void 0:E.getBoundingClientRect(),l&&l.left<e&&e<l.right){this._dropIndex=a;break}r&&l&&e<l.left+l.width*.5?r.before(this.layoutManager.tabDropPlaceholder):r&&(this._dropIndex=Math.min(((I=this._dropIndex)!=null?I:0)+1,n),r.after(this.layoutManager.tabDropPlaceholder))}let d=(F=(R=this.layoutManager.tabDropPlaceholder.offset())==null?void 0:R.left)!=null?F:0;d=Math.max(d,(U=(x=this.header.tabsContainer.offset())==null?void 0:x.left)!=null?U:0);var c=d+(($=this.layoutManager.tabDropPlaceholder.width())!=null?$:0);c=Math.min(c,((H=(O=this.header.tabsContainer.offset())==null?void 0:O.left)!=null?H:0)+((L=this.header.tabsContainer.innerWidth())!=null?L:0)),(j=this.layoutManager.dropTargetIndicator)==null||j.highlightArea({x1:d,x2:c,y1:(_=(N=this.header.element.offset())==null?void 0:N.top)!=null?_:0,y2:((V=(k=this.header.element.offset())==null?void 0:k.top)!=null?V:0)+((W=this.header.element.innerHeight())!=null?W:0)})}_resetHeaderDropZone(){this.layoutManager.tabDropPlaceholder.remove()}_setupHeaderPosition(){const e=["right","left","bottom"].some(n=>n===this._header.show)?this._header.show:void 0;if(!!e&&(this.header.element.toggle(!!this._header.show),this._side=e,this._sided=["right","left"].indexOf(this._side.toString())>=0,this.element.removeClass("lm_left lm_right lm_bottom"),this._side&&this.element.addClass("lm_"+this._side),this.element.find(".lm_header").length&&this.childElementContainer)){const n=["right","bottom"].indexOf(this._side.toString())>=0?"before":"after";this.header.element[n](this.childElementContainer),this.callDownwards("setSize")}}_highlightBodyDropZone(e){var s,i,o;const n=(i=(s=this._contentAreaDimensions)==null?void 0:s[e])==null?void 0:i.highlightArea;n&&((o=this.layoutManager.dropTargetIndicator)==null||o.highlightArea(n)),this._dropSegment=e}}const ew=Object.freeze(Object.defineProperty({__proto__:null,AbstractContentItem:vt,ContentItem:vt,Component:Pm,Root:La,RowOrColumn:Zr,Stack:Aa,isStack:Ao,isComponent:yn,isRoot:Am},Symbol.toStringTag,{value:"Module"})),Hm=class{constructor(t,e){var n;this.element=ce(Hm._template),this.isActive=!1,this.header=t,this.contentItem=e,this.titleElement=this.element.find(".lm_title"),this.closeElement=this.element.find(".lm_close_tab"),this.closeElement[e.config.isClosable?"show":"hide"](),this.setTitle(e.config.title),this.contentItem.on("titleChanged",this.setTitle,this),this._layoutManager=this.contentItem.layoutManager,((n=this._layoutManager.config.settings)==null?void 0:n.reorderEnabled)&&e.config.reorderEnabled&&(this._dragListener=new Wo(this.element),this._dragListener.on("dragStart",this._onDragStart,this),this.contentItem.on("destroy",this._dragListener.destroy,this._dragListener)),this._onTabClick=this._onTabClick.bind(this),this._onCloseClick=this._onCloseClick.bind(this),this._onTabContentFocusIn=this._onTabContentFocusIn.bind(this),this._onTabContentFocusOut=this._onTabContentFocusOut.bind(this),this.element.on("click",this._onTabClick),this.element.on("auxclick",this._onTabClick),this.contentItem.config.isClosable?(this.closeElement.on("click",this._onCloseClick),this.closeElement.on("mousedown",this._onCloseMousedown)):this.closeElement.remove(),this.contentItem.tab=this,this.contentItem.emit("tab",this),this.contentItem.layoutManager.emit("tabCreated",this),yn(this.contentItem)&&(this.contentItem.container._contentElement.on("focusin click",this._onTabContentFocusIn).on("focusout",this._onTabContentFocusOut),this.contentItem.container.tab=this,this.contentItem.container.emit("tab",this))}setTitle(t=""){this.titleElement.html(t)}setActive(t){t!==this.isActive&&(this.isActive=t,t?this.element.addClass("lm_active"):this.element.removeClass("lm_active"))}_$destroy(){this.element.off("click",this._onTabClick),this.element.off("auxclick",this._onTabClick),this.closeElement.off("click",this._onCloseClick),yn(this.contentItem)&&this.contentItem.container._contentElement.off(),this._dragListener&&(this.contentItem.off("destroy",this._dragListener.destroy,this._dragListener),this._dragListener.off("dragStart",this._onDragStart),this._dragListener=void 0),this.element.remove()}_onDragStart(t,e){var n;(n=this.contentItem.parent)!=null&&n.isMaximised&&this.contentItem.parent.toggleMaximise(),this._dragListener&&new Go(t,e,this._dragListener,this._layoutManager,this.contentItem,this.header.parent)}_onTabContentFocusIn(){yn(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&this.contentItem.container._contentElement[0].focus(),this.element.addClass("lm_focusin")}_onTabContentFocusOut(){yn(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&this.element.removeClass("lm_focusin")}_onTabClick(t){var n;if(!t||t.button===0){var e=this.header.parent.getActiveContentItem();this.contentItem!==e&&yn(this.contentItem)?(this.header.parent.setActiveContentItem(this.contentItem),this.contentItem.container.emit("tabClicked")):yn(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&(this.contentItem.container._contentElement.focus(),this.contentItem.container.emit("tabClicked")),this.header._hideAdditionalTabsDropdown(),(n=this.element.get(0))==null||n.scrollIntoView({inline:"nearest"})}else t.button===1&&this.contentItem.config.isClosable&&this._onCloseClick(t)}_onCloseClick(t){t.stopPropagation(),yn(this.contentItem)?this.contentItem.container.close():this.header.parent.removeChild(this.contentItem)}_onCloseMousedown(t){t.stopPropagation()}};let Rd=Hm;Rd._template=['<li class="lm_tab">','<span class="lm_title_before"></span>','<span class="lm_title"></span>','<div class="lm_close_tab"></div>',"</li>"].join("");const Ar=class extends bn{constructor(t,e){var n,s;super(),this.element=ce(Ar._template),this.tabDropdownList=null,this.tabs=[],this.activeContentItem=null,this.closeButton=null,this.tabDropdownButton=null,this.tabNextButton=ce(Ar._nextButtonTemplate),this.tabPreviousButton=ce(Ar._previousButtonTemplate),this.holdTimer=null,this.rAF=null,this.CLICK_TIMEOUT=500,this.START_SPEED=.01,this.ACCELERATION=5e-4,this.SCROLL_LEFT="left",this.SCROLL_RIGHT="right",this.isDraggingTab=!1,this.isOverflowing=!1,this.isDropdownShown=!1,this.dropdownKeyIndex=0,this._lastVisibleTabIndex=-1,this.layoutManager=t,(n=this.layoutManager.config.settings)!=null&&n.selectionEnabled&&(this.element.addClass("lm_selectable"),this.element.on("click",this._onHeaderClick.bind(this))),this.tabsContainer=this.element.find(".lm_tabs"),this.tabDropdownContainer=this.element.find(".lm_tabdropdown_list"),this.tabDropdownContainer.hide(),this.tabDropdownSearch=this.element.find(".lm_tabdropdown_search input"),this._handleFilterInput=this._handleFilterInput.bind(this),this._handleFilterKeydown=this._handleFilterKeydown.bind(this),this.tabDropdownSearch.on("input",this._handleFilterInput),this.tabDropdownSearch.on("keydown",this._handleFilterKeydown),this.controlsContainer=this.element.find(".lm_controls"),this.parent=e,this.parent.on("resize",this._updateTabSizes,this),this._handleItemPickedUp=this._handleItemPickedUp.bind(this),this._handleItemDropped=this._handleItemDropped.bind(this),this._handleNextMouseEnter=this._handleNextMouseEnter.bind(this),this._handleNextMouseLeave=this._handleNextMouseLeave.bind(this),this._handlePreviousMouseEnter=this._handlePreviousMouseEnter.bind(this),this._handlePreviousMouseLeave=this._handlePreviousMouseLeave.bind(this),this._handleScrollRepeat=this._handleScrollRepeat.bind(this),this._handleNextButtonMouseDown=this._handleNextButtonMouseDown.bind(this),this._handlePreviousButtonMouseDown=this._handlePreviousButtonMouseDown.bind(this),this._handleScrollButtonMouseDown=this._handleScrollButtonMouseDown.bind(this),this._handleScrollButtonMouseUp=this._handleScrollButtonMouseUp.bind(this),this._handleScrollEvent=this._handleScrollEvent.bind(this),this.tabNextButton.on("mousedown",this._handleNextButtonMouseDown),this.tabPreviousButton.on("mousedown",this._handlePreviousButtonMouseDown),this.tabsContainer.on("scroll",this._handleScrollEvent),this.layoutManager.on("itemPickedUp",this._handleItemPickedUp),this.layoutManager.on("itemDropped",this._handleItemDropped),this.tabsContainer.before(this.tabPreviousButton),this.tabPreviousButton=this.tabPreviousButton.find(">:first-child"),this.tabPreviousButton.hide(),this._showAdditionalTabsDropdown=this._showAdditionalTabsDropdown.bind(this),this._hideAdditionalTabsDropdown=this._hideAdditionalTabsDropdown.bind(this),this._tabControlOffset=(s=this.layoutManager.config.settings)==null?void 0:s.tabControlOffset,this._createControls()}createTab(t,e){for(let s=0;s<this.tabs.length;s++)if(this.tabs[s].contentItem===t)return;const n=new Rd(this,t);if(this.tabs.length===0){this.tabs.push(n),this.tabsContainer.append(n.element);return}e===void 0&&(e=this.tabs.length),e>0?this.tabs[e-1].element.after(n.element):this.tabs[0].element.before(n.element),this.tabs.splice(e,0,n),this._updateTabSizes()}removeTab(t){for(var e=0;e<this.tabs.length;e++)if(this.tabs[e].contentItem===t){this.tabs[e]._$destroy(),this.tabs.splice(e,1);return}throw new Error("contentItem is not controlled by this header")}setActiveContentItem(t){var s,i;for(var e,n=0;n<this.tabs.length;n++)e=this.tabs[n].contentItem===t,this.tabs[n].setActive(e),e===!0&&(this.activeContentItem=t,this.parent.config.activeItemIndex=n);(i=this.tabs[(s=this.parent.config.activeItemIndex)!=null?s:0].element.get(0))==null||i.scrollIntoView({inline:"nearest"}),this._hideAdditionalTabsDropdown(),this._updateTabSizes(),this.parent.emitBubblingEvent("stateChanged")}position(t){let e=this.parent._header.show;return e&&!this.parent._side&&(e="top"),t!==void 0&&this.parent._header.show!==t&&(this.parent._header.show=t,this.parent._setupHeaderPosition()),e}_attachWheelListener(){var t;(t=this.tabsContainer.get(0))==null||t.addEventListener("wheel",this._handleWheelEvent,{passive:!0})}_detachWheelListener(){var t;(t=this.tabsContainer.get(0))==null||t.removeEventListener("wheel",this._handleWheelEvent)}_handleWheelEvent(t){var s;const e=t.currentTarget;if(!(e instanceof HTMLElement))return;let n=Math.abs(t.deltaY)>Math.abs(t.deltaX)?t.deltaY:t.deltaX;t.deltaMode===WheelEvent.DOM_DELTA_PAGE?n*=(s=this.tabsContainer.innerWidth())!=null?s:1:t.deltaMode===WheelEvent.DOM_DELTA_LINE&&(n*=100/3),e.scrollLeft+=Math.round(n)}_handleScrollEvent(){this._checkScrollArrows()}_handleItemPickedUp(){this.isDraggingTab=!0,this.controlsContainer.on("mouseenter",this._handleNextMouseEnter),this.tabPreviousButton.on("mouseenter",this._handlePreviousMouseEnter)}_handleItemDropped(){var t;this.isDraggingTab=!1,window.cancelAnimationFrame((t=this.rAF)!=null?t:-1),this.rAF=null,this.controlsContainer.off("mouseenter",this._handleNextMouseEnter),this.controlsContainer.off("mouseleave",this._handleNextMouseLeave),this.tabPreviousButton.off("mouseenter",this._handlePreviousMouseEnter),this.tabPreviousButton.off("mouseleave",this._handlePreviousMouseLeave)}_handleNextMouseEnter(){var t;this.controlsContainer.on("mouseleave",this._handleNextMouseLeave),this._handleScrollRepeat(this.SCROLL_RIGHT,(t=this.tabsContainer.scrollLeft())!=null?t:0)}_handlePreviousMouseEnter(){var t;this.tabPreviousButton.on("mouseleave",this._handlePreviousMouseLeave),this._handleScrollRepeat(this.SCROLL_LEFT,(t=this.tabsContainer.scrollLeft())!=null?t:0)}_handleNextMouseLeave(){var t;window.cancelAnimationFrame((t=this.rAF)!=null?t:-1),this.rAF=null,this.controlsContainer.off("mouseleave",this._handleNextMouseLeave)}_handlePreviousMouseLeave(){var t;window.cancelAnimationFrame((t=this.rAF)!=null?t:-1),this.rAF=null,this.tabPreviousButton.off("mouseleave",this._handlePreviousMouseLeave)}_handleNextButtonMouseDown(){var e,n,s,i,o,r,l;var t;for(let a=0;a<this.tabs.length;a+=1)if(((n=(e=this.tabs[a].element.get(0))==null?void 0:e.offsetLeft)!=null?n:0)>((i=(s=this.tabsContainer.get(0))==null?void 0:s.offsetWidth)!=null?i:0)+((o=this.tabsContainer.scrollLeft())!=null?o:0)){t=this.tabs[a].element.get(0);break}if(t)t.scrollIntoView({behavior:"smooth",inline:"nearest"}),this._handleScrollButtonMouseDown(this.SCROLL_RIGHT);else{const a=this.tabsContainer.get(0);a&&(a.scrollLeft=(l=(r=this.tabsContainer.get(0))==null?void 0:r.scrollWidth)!=null?l:0)}}_handlePreviousButtonMouseDown(){var n,s,i;for(var t,e=this.tabs.length-1;e>=0;e-=1)if(((s=(n=this.tabs[e].element.get(0))==null?void 0:n.offsetLeft)!=null?s:0)<((i=this.tabsContainer.scrollLeft())!=null?i:0)){t=this.tabs[e].element.get(0);break}if(t)t.scrollIntoView({behavior:"smooth",inline:"start"}),this._handleScrollButtonMouseDown(this.SCROLL_LEFT);else{const o=this.tabsContainer.get(0);o&&(o.scrollLeft=0)}}_handleScrollButtonMouseDown(t){this.holdTimer=window.setTimeout(()=>{var e;this._handleScrollRepeat(t,(e=this.tabsContainer.scrollLeft())!=null?e:0,100)},this.CLICK_TIMEOUT),window.addEventListener("mouseup",this._handleScrollButtonMouseUp)}_handleScrollButtonMouseUp(){var t,e;clearTimeout((t=this.holdTimer)!=null?t:-1),this.holdTimer=null,cancelAnimationFrame((e=this.rAF)!=null?e:-1),this.rAF=null,window.removeEventListener("mouseup",this._handleScrollButtonMouseUp)}_checkScrollArrows(){var t,e,n;this.tabsContainer.scrollLeft()===0?this.tabPreviousButton.first().prop("disabled",!0):((t=this.tabsContainer.scrollLeft())!=null?t:0)+((e=this.tabsContainer.innerWidth())!=null?e:0)===((n=this.tabsContainer.get(0))==null?void 0:n.scrollWidth)?this.tabNextButton.prop("disabled",!0):(this.tabNextButton.prop("disabled",!1),this.tabPreviousButton.first().prop("disabled",!1))}_handleScrollRepeat(t,e,n=0,s){var r,l,a;const i=this.tabsContainer.get(0);if(!i)return;const o=i.getBoundingClientRect();if(t===this.SCROLL_LEFT){if(this.tabsContainer.scrollLeft(e-n),this.isDraggingTab&&this.parent._highlightHeaderDropZone(o.left-1),this.tabsContainer.scrollLeft()===0){this._checkScrollArrows();return}}else if(t===this.SCROLL_RIGHT&&(this.tabsContainer.scrollLeft(e+n),this.isDraggingTab&&this.parent._highlightHeaderDropZone(o.right+1),((r=this.tabsContainer.scrollLeft())!=null?r:0)+((l=this.tabsContainer.innerWidth())!=null?l:0)===i.scrollWidth)){this._checkScrollArrows();return}window.cancelAnimationFrame((a=this.rAF)!=null?a:-1),this.rAF=window.requestAnimationFrame(d=>{var p,g;var c=s||d,u=d-c,m=this.START_SPEED*u+.5*this.ACCELERATION*(u*u);m=Math.min(m,(g=(p=this.tabsContainer.get(0))==null?void 0:p.scrollWidth)!=null?g:1/0),this._handleScrollRepeat(t,e,m,c)})}_$setClosable(t){return this.closeButton&&this._isClosable()?(this.closeButton.element[t?"show":"hide"](),!0):!1}_$destroy(){this.emit("destroy",this);for(var t=0;t<this.tabs.length;t++)this.tabs[t]._$destroy();this._detachWheelListener(),this._handleItemDropped(),ce(document).off("mouseup",this._hideAdditionalTabsDropdown),this.tabDropdownSearch.off("input",this._handleFilterInput),this.tabDropdownSearch.off("keydown",this._handleFilterKeydown),this.element.remove()}_getHeaderSetting(t){if(t in this.parent._header)return this.parent._header[t]}_createControls(){var t,e,n,s,i;if(i=this.layoutManager.config.labels.tabDropdown,this.layoutManager.config.labels.tabNextLabel,this.layoutManager.config.labels.tabPreviousLabel,this.tabDropdownButton=new Io(this,i,"lm_tabdropdown",this._showAdditionalTabsDropdown),this.tabDropdownButton.element.hide(),this.controlsContainer.prepend(this.tabNextButton),this.tabNextButton.hide(),this._getHeaderSetting("popout")&&(e=this._onPopoutClick.bind(this),n=this._getHeaderSetting("popout"),new Io(this,n,"lm_popout",e)),this._getHeaderSetting("maximise")){s=this.parent.toggleMaximise.bind(this.parent);const o=this._getHeaderSetting("maximise"),r=this._getHeaderSetting("minimise"),l=new Io(this,o,"lm_maximise",s);this.parent.on("maximised",function(){l.element.attr("title",r!=null?r:"")}),this.parent.on("minimised",function(){l.element.attr("title",o!=null?o:"")})}this._isClosable()&&(t=this.parent.remove.bind(this.parent),n=this._getHeaderSetting("close"),this.closeButton=new Io(this,n,"lm_close",t))}_showAdditionalTabsDropdown(){if(this.isDropdownShown){this._hideAdditionalTabsDropdown();return}this.tabDropdownList=this.tabsContainer.clone(!0).appendTo(this.tabDropdownContainer).children().removeClass("lm_active"),this.tabDropdownContainer.show(),this.isDropdownShown=!0,this.element.addClass("lm_dropdown_open"),this.tabDropdownSearch.val("").focus(),this.dropdownKeyIndex=0,this.tabDropdownList.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active"),ce(document).on("mousedown",this._hideAdditionalTabsDropdown),this._updateAdditionalTabsDropdown()}_handleFilterKeydown(t){var n,s,i,o;if(this.dropdownKeyIndex===-1)return;if(t.key==="Escape"){this._hideAdditionalTabsDropdown();return}if(t.key==="Enter"||t.key===" "){this._hideAdditionalTabsDropdown(),this.tabs[this.dropdownKeyIndex]._onTabClick();return}function e(r,l,a){if(a==null||a.length<2)return-1;for(var d=(r+l+a.length)%a.length;d!==r;){if(a.eq(d).css("display")!=="none")return d;d=(d+l+a.length)%a.length}return r}t.key==="ArrowDown"||t.key==="Tab"&&t.shiftKey===!1?(t.preventDefault(),(n=this.tabDropdownList)==null||n.eq(this.dropdownKeyIndex).removeClass("lm_keyboard_active"),this.dropdownKeyIndex=e(this.dropdownKeyIndex,1,this.tabDropdownList),(s=this.tabDropdownList)==null||s.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active")):(t.key==="ArrowUp"||t.key==="Tab")&&(t.preventDefault(),(i=this.tabDropdownList)==null||i.eq(this.dropdownKeyIndex).removeClass("lm_keyboard_active"),this.dropdownKeyIndex=e(this.dropdownKeyIndex,-1,this.tabDropdownList),(o=this.tabDropdownList)==null||o.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active"))}_handleFilterInput(t){var n,s;if(this.tabDropdownList!=null){this.tabDropdownList.eq(this.dropdownKeyIndex).removeClass("lm_keyboard_active"),this.dropdownKeyIndex=-1;for(var e=0;e<this.tabDropdownList.length;e++)((s=(n=this.tabs[e].contentItem.config.title)==null?void 0:n.toLowerCase().indexOf(t.target.value.toLowerCase()))!=null?s:-1)!==-1?(this.tabDropdownList.eq(e).css("display",""),this.dropdownKeyIndex===-1&&(this.dropdownKeyIndex=e)):this.tabDropdownList.eq(e).css("display","none");this.dropdownKeyIndex!==-1&&this.tabDropdownList.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active")}}_hideAdditionalTabsDropdown(t){var e,n;!this.isDropdownShown||t&&((e=this.tabDropdownContainer.get(0))==null?void 0:e.contains(t.target))||t&&((n=this.tabDropdownButton)==null?void 0:n.element.get(0))===t.target||(this.element.removeClass("lm_dropdown_open"),this.tabDropdownContainer.hide(),this.isDropdownShown=!1,this.tabDropdownContainer.find(".lm_tabs").remove(),ce(document).off("mousedown",this._hideAdditionalTabsDropdown))}_updateAdditionalTabsDropdown(){var n,s,i,o,r;this.tabDropdownContainer.css("max-height","");const t=this.tabDropdownContainer[0].scrollHeight;if(t===0)return;const e=((s=(n=this.tabDropdownContainer.offset())==null?void 0:n.top)!=null?s:0)-((i=ce(window).scrollTop())!=null?i:0);e+t>((o=ce(window).height())!=null?o:0)&&this.tabDropdownContainer.css("max-height",((r=ce(window).height())!=null?r:0)-e-10)}_isClosable(){return Boolean(this.parent.config.isClosable&&this.layoutManager.config.settings.showCloseIcon)}_onPopoutClick(){var t;this.layoutManager.config.settings.popoutWholeStack===!0?this.parent.popout():(t=this.activeContentItem)==null||t.popout()}_onHeaderClick(t){t.target===this.element[0]&&this.parent.select()}_updateTabSizes(){var e,n;if(this.tabs.length===0)return;const t=this.tabsContainer.get(0);!t||(!this.isOverflowing&&t.scrollWidth>t.clientWidth?((e=this.tabDropdownButton)==null||e.element.show(),this.tabNextButton.show(),this.tabPreviousButton.show(),this.isOverflowing=!0):this.isOverflowing&&t.scrollWidth<=t.clientWidth&&((n=this.tabDropdownButton)==null||n.element.hide(),this.tabNextButton.hide(),this.tabPreviousButton.hide(),this.isOverflowing=!1),this.isOverflowing&&this._checkScrollArrows())}};let Ko=Ar;Ko._template=['<div class="lm_header">','<ul class="lm_tabs"></ul>','<ul class="lm_controls"></ul>','<ul class="lm_tabdropdown_list">','<li class="lm_tabdropdown_search"><input type="text" placeholder="Find tab..."></li>',"</ul>","</div>"].join("");Ko._previousButtonTemplate=['<ul class="lm_controls">','<li class="lm_tabpreviousbutton"></li>',"</ul>"].join("");Ko._nextButtonTemplate=['<li class="lm_tabnextbutton"></li>'].join("");class Vm{constructor(e,n,s){this._isVertical=e,this._size=n,this._grabSize=s<n?n:s,this.element=this._createElement(),this._dragListener=new Wo(this.element)}on(e,n,s){var i;(i=this._dragListener)==null||i.on(e,n,s)}_$destroy(){var e;(e=this._dragListener)==null||e.destroy(),this._dragListener=null,this.element.remove()}_createElement(){var e=ce('<div class="lm_drag_handle"></div>'),n=ce('<div class="lm_splitter"></div>');n.append(e);var s=this._grabSize-this._size,i=s/2;return this._isVertical?(e.css("top",-i),e.css("height",this._size+s),n.addClass("lm_vertical"),n.height(this._size)):(e.css("left",-i),e.css("width",this._size+s),n.addClass("lm_horizontal"),n.width(this._size)),n}}class Um{constructor(){this._element=ce('<div class="lm_transition_indicator"></div>'),this._toElement=null,this._fromDimensions={},this._totalAnimationDuration=200,this._animationStartTime=null,ce(document.body).append(this._element)}destroy(){this._element.remove()}transitionElements(e,n){}_nextAnimationFrame(){var o,r,l;if(!this._toElement||this._animationStartTime==null)return;const e=this._measure(this._toElement),n=(Date.now()-this._animationStartTime)/this._totalAnimationDuration,s={};if(n>=1){this._element.hide();return}e.opacity=0;const i=Object.keys(this._fromDimensions);for(let a of i)s[a]=((o=this._fromDimensions[a])!=null?o:0)+(((r=e[a])!=null?r:0)-((l=this._fromDimensions[a])!=null?l:0))*n;this._element.css(s),Nl(this._nextAnimationFrame.bind(this))}_measure(e){const n=e.offset();return{left:n==null?void 0:n.left,top:n==null?void 0:n.top,width:e.outerWidth(),height:e.outerHeight()}}}const tw=Object.freeze(Object.defineProperty({__proto__:null,BrowserPopout:xm,DragProxy:Go,DragSource:km,DragSourceFromEvent:Om,DropTargetIndicator:Id,Header:Ko,HeaderButton:Io,Splitter:Vm,Tab:Rd,TransitionIndicator:Um},Symbol.toStringTag,{value:"Module"})),nw={config:GS,container:KS,controls:tw,errors:JS,items:ew,utils:ZS};class Dd extends bn{constructor(e,n){super(),this.isInitialised=!1,this._isFullPage=!1,this._components={"lm-react-component":Nm},this._itemAreas=[],this._maximisedItem=null,this._maximisePlaceholder=ce('<div class="lm_maximise_place"></div>'),this._creationTimeoutPassed=!1,this._subWindowsCreated=!1,this._dragSources=[],this._updatingColumnsResponsive=!1,this._firstLoad=!0,this.width=null,this.height=null,this.openPopouts=[],this.selectedItem=null,this.isSubWindow=!1,this.eventHub=new Fm(this),this.dropTargetIndicator=null,this.transitionIndicator=null,this.tabDropPlaceholder=ce('<div class="lm_drop_tab_placeholder"></div>'),this._onResize=this._onResize.bind(this),this._onUnload=this._onUnload.bind(this),this._windowBlur=this._windowBlur.bind(this),this._windowFocus=this._windowFocus.bind(this),this.config=this._createConfig(e),this._originalContainer=n,this.container=this._getContainer(),this.isSubWindow&&ce("body").css("visibility","hidden"),this._typeToItem={column:Zr.bind(this,!0),row:Zr.bind(this,!1),stack:Aa,component:Pm}}static minifyConfig(e){return Ed(e)}static unminifyConfig(e){return ka(e)}registerComponent(e,n){if(typeof n!="function"&&(n==null||n.render==null||typeof n.render!="function"))throw new Error("Please register a constructor function");if(this._components[e]!==void 0)throw new Error("Component "+e+" is already registered");return this._components[e]=n,()=>{if(this._components[e]===void 0)throw new Error("Component "+e+" is not registered");delete this._components[e]}}setFallbackComponent(e){this._fallbackComponent=e}toConfig(e){if(this.isInitialised===!1)throw new Error("Can't create config, layout not yet initialised");if(e&&!(e instanceof vt))throw new Error("Root must be a ContentItem");const n={settings:{...this.config.settings},dimensions:{...this.config.dimensions},labels:{...this.config.labels},content:[]},s=function(i,o){for(let r in o.config)r!=="content"&&(i[r]=o.config[r]);if(i.componentName==="lm-react-component"&&(i.type="react-component"),o.contentItems.length){i.content=[];for(let r=0;r<o.contentItems.length;r++)i.content[r]={},s(i.content[r],o.contentItems[r])}};e?s(n,{contentItems:[e]}):s(n,this.root),this._$reconcilePopoutWindows(),n.openPopouts=[];for(let i=0;i<this.openPopouts.length;i++)n.openPopouts.push(this.openPopouts[i].toConfig());return n.maximisedItemId=this._maximisedItem?"__glMaximised":void 0,n}getComponent(e){return this._components[e]}getFallbackComponent(){return this._fallbackComponent}init(){if(this._subWindowsCreated===!1&&(this._createSubWindows(),this._subWindowsCreated=!0),document.readyState==="loading"||document.body===null){ce(document).ready(this.init.bind(this));return}if(this.isSubWindow===!0&&this._creationTimeoutPassed===!1){setTimeout(this.init.bind(this),7),this._creationTimeoutPassed=!0;return}this.isSubWindow===!0&&this._adjustToWindowMode(),this._setContainer(),this.dropTargetIndicator=new Id,this.transitionIndicator=new Um,this.updateSize(),this._create(this.config),this._bindEvents(),this.isInitialised=!0,this._adjustColumnsResponsive(),this.emit("initialised")}updateSize(e,n){var s,i,o,r;this.width=(s=e!=null?e:this.container.width())!=null?s:0,this.height=(i=n!=null?n:this.container.height())!=null?i:0,this.isInitialised===!0&&(this.root.callDownwards("setSize",[this.width,this.height]),this._maximisedItem&&(this._maximisedItem.element.width((o=this.container.width())!=null?o:0),this._maximisedItem.element.height((r=this.container.height())!=null?r:0),this._maximisedItem.callDownwards("setSize")),this._adjustColumnsResponsive())}destroy(){var e,n;this.isInitialised===!1||!this.root||(this._onUnload(),ce(window).off("resize",this._onResize),ce(window).off("unload beforeunload",this._onUnload),ce(window).off("blur.lm").off("focus.lm"),this.root.callDownwards("_$destroy",[],!0),this.root.contentItems=[],this.tabDropPlaceholder.remove(),(e=this.dropTargetIndicator)==null||e.destroy(),(n=this.transitionIndicator)==null||n.destroy(),this.eventHub.destroy(),this._dragSources.forEach(function(s){s._dragListener.destroy()}),this._dragSources=[])}createContentItem(e,n){var s,i;if(typeof e.type!="string")throw new ii("Missing parameter 'type'",e);if(e.type==="react-component"&&(e.type="component",e.componentName="lm-react-component"),!this._typeToItem[e.type])throw s="Unknown type '"+e.type+"'. Valid types are "+Object.keys(this._typeToItem).join(","),new ii(s);return e.type==="component"&&!(n instanceof Aa)&&!!n&&!(this.isSubWindow===!0&&n instanceof La)&&(e={type:"stack",width:e.width,height:e.height,content:[e]}),i=new this._typeToItem[e.type](this,e,n),i}createPopout(e,n,s,i){var d,c,u;let o=[];const r=e instanceof vt,l=this;if(r){o=this.toConfig(e).content,s=vd();let m=e.parent,p=e;for(;(m==null?void 0:m.contentItems.length)===1&&!m.isRoot;)p=m,m=m.parent;m==null||m.addId(s),(i==null||Number.isNaN(i))&&(i=m==null?void 0:m.contentItems.indexOf(p))}else e instanceof Array?o=e:o=[e];if(!n&&r){const m=window.screenX||window.screenLeft,p=window.screenY||window.screenTop,g=(d=e.element.offset())!=null?d:{left:0,top:0};n={left:m+g.left,top:p+g.top,width:(c=e.element.width())!=null?c:0,height:(u=e.element.height())!=null?u:0}}if(!n&&!r&&(n={left:window.screenX||window.screenLeft+20,top:window.screenY||window.screenTop+20,width:500,height:309}),r&&e.remove(),!n||!s||i===void 0)return;const a=new xm(o,n,s,i,this);return a.on("initialised",function(){l.emit("windowOpened",a)}),a.on("closed",function(){l._$reconcilePopoutWindows()}),this.openPopouts.push(a),a}createDragSource(e,n){this.config.settings.constrainDragToContainer=!1;var s=new km(e,n,this);return this._dragSources.push(s),s}createDragSourceFromEvent(e,n){return this.config.settings.constrainDragToContainer=!1,new Om(e,this,n)}selectItem(e,n){if(this.config.settings.selectionEnabled!==!0)throw new Error("Please set selectionEnabled to true to use this feature");e!==this.selectedItem&&(this.selectedItem!==null&&this.selectedItem.deselect(),e&&n!==!0&&e.select(),this.selectedItem=e,this.emit("selectionChanged",e))}_$maximiseItem(e){var n,s;this._maximisedItem!==null&&this._$minimiseItem(this._maximisedItem),this._maximisedItem=e,this._maximisedItem.addId("__glMaximised"),e.element.addClass("lm_maximised"),e.element.after(this._maximisePlaceholder),this.root.element.prepend(e.element),e.element.width((n=this.container.width())!=null?n:0),e.element.height((s=this.container.height())!=null?s:0),e.callDownwards("setSize"),this._maximisedItem.emit("maximised"),this.emit("stateChanged")}_$minimiseItem(e){var n;e.element.removeClass("lm_maximised"),e.removeId("__glMaximised"),this._maximisePlaceholder.after(e.element),this._maximisePlaceholder.remove(),(n=e.parent)==null||n.callDownwards("setSize"),this._maximisedItem=null,e.emit("minimised"),this.emit("stateChanged")}_$closeWindow(){window.setTimeout(function(){window.close()},1)}_$getArea(e,n){let s=1/0,i=null;for(let o=0;o<this._itemAreas.length;o++){const r=this._itemAreas[o];e>r.x1&&e<r.x2&&n>r.y1&&n<r.y2&&s>r.surface&&(s=r.surface,i=r)}return i}_$createRootItemAreas(){const n={...this.root._$getArea()},s=[{...n,side:"left",x2:n.x1+50},{...n,side:"right",x1:n.x2-50},{...n,side:"top",y2:n.y1+50},{...n,side:"bottom",y1:n.y2-50}];s.forEach(i=>{i.surface=(i.x2-i.x1)*(i.y2-i.y1)}),this._itemAreas.push(...s)}_$calculateItemAreas(){var n;const e=this._getAllContentItems();if(this._itemAreas=[],e.length===1){this._itemAreas.push(this.root._$getArea());return}this._$createRootItemAreas();for(let s=0;s<e.length;s++){const i=e[s];if(!Ao(i))continue;const o=i._$getArea();if(o!==null)if(o instanceof Array)this._itemAreas=this._itemAreas.concat(o);else{this._itemAreas.push(o);let r={...o,...(n=o.contentItem._contentAreaDimensions)==null?void 0:n.header.highlightArea};r.surface=(r.x2-r.x1)*(r.y2-r.y1),this._itemAreas.push(r)}}}_$normalizeContentItem(e,n){if(!e)throw new Error("No content item defined");if(typeof e=="function"&&(e=e()),e instanceof vt)return e;if(ce.isPlainObject(e)&&e.type){var s=this.createContentItem(e,n);return s.callDownwards("_$init"),s}else throw new Error("Invalid contentItem")}_$reconcilePopoutWindows(){var n;const e=[];for(let s=0;s<this.openPopouts.length;s++)((n=this.openPopouts[s].getWindow())==null?void 0:n.closed)===!1?e.push(this.openPopouts[s]):this.emit("windowClosed",this.openPopouts[s]);this.openPopouts.length!==e.length&&(this.emit("stateChanged"),this.openPopouts=e)}_getAllContentItems(){const e=[],n=s=>{if(e.push(s),s.contentItems instanceof Array)for(let i=0;i<s.contentItems.length;i++)n(s.contentItems[i])};return n(this.root),e}_bindEvents(){this._isFullPage&&ce(window).resize(this._onResize),ce(window).on("unload beforeunload",this._onUnload).on("blur.lm",this._windowBlur).on("focus.lm",this._windowFocus)}_windowBlur(){this.root.element.addClass("lm_window_blur")}_windowFocus(){this.root.element.removeClass("lm_window_blur")}_onResize(){clearTimeout(this._resizeTimeoutId),this._resizeTimeoutId=window.setTimeout(this.updateSize.bind(this),100)}_createConfig(e){var i;var n=Mm("gl-window");n&&(this.isSubWindow=!0,e=JSON.parse(localStorage.getItem(n)||"{}"),e=ka(e),localStorage.removeItem(n)),e=ce.extend(!0,{},ym,e);var s=function(o){for(var r in o){const l=o[r];r!=="props"&&typeof l=="object"&&l!=null?s(l):r==="type"&&l==="react-component"&&(o.type="component",o.componentName="lm-react-component")}};return s(e),((i=e.settings)==null?void 0:i.hasHeaders)===!1&&(e.dimensions.headerHeight=0),e}_adjustToWindowMode(){var n;var e=ce('<div class="lm_popin" title="'+this.config.labels.popin+'"><div class="lm_icon"></div><div class="lm_bg"></div></div>');e.click(()=>{this.emit("popIn")}),document.title=Td((n=this.config.content[0].title)!=null?n:""),ce("head").append(ce("body link, body style, template, .gl_keep")),this.container=ce("body").html("").css("visibility","visible").append(e),document.body.offsetHeight,window.__glInstance=this}_createSubWindows(){if(!!this.config.openPopouts)for(let e=0;e<this.config.openPopouts.length;e++){const n=this.config.openPopouts[e];this.createPopout(n.content,n.dimensions,n.parentId,n.indexInParent)}}_getContainer(){const e=this._originalContainer?ce(this._originalContainer):ce("body");if(e.length===0)throw new Error("GoldenLayout container not found");if(e.length>1)throw new Error("GoldenLayout more than one container element specified");return e}_setContainer(){const e=this._getContainer();e[0]===document.body&&(this._isFullPage=!0,ce("html, body").css({height:"100%",margin:0,padding:0,overflow:"hidden"})),this.container=e}_create(e){var n;if(!(e.content instanceof Array))throw e.content===void 0?n="Missing setting 'content' on top level of configuration":n="Configuration parameter 'content' must be an array",new ii(n,e);if(e.content.length>1)throw n="Top level content can't contain more then one element.",new ii(n,e);this.root=new La(this,{content:e.content},this.container),this.root.callDownwards("_$init"),e.maximisedItemId==="__glMaximised"&&this.root.getItemsById(e.maximisedItemId)[0].toggleMaximise()}_onUnload(){if(this.config.settings.closePopoutsOnUnload===!0)for(var e=0;e<this.openPopouts.length;e++)this.openPopouts[e].close()}_adjustColumnsResponsive(){if(!this._useResponsiveLayout()||this._updatingColumnsResponsive||!this.config.dimensions||!this.config.dimensions.minItemWidth||this.root.contentItems.length===0||!this.root.contentItems[0].isRow){this._firstLoad=!1;return}this._firstLoad=!1;var e=this.root.contentItems[0].contentItems.length;if(!(e<=1)){var n=this.config.dimensions.minItemWidth,s=e*n;if(!(this.width==null||s<=this.width)){this._updatingColumnsResponsive=!0;for(var i=Math.max(Math.floor(this.width/n),1),o=e-i,r=this.root.contentItems[0],l=this._findAllStackContainers()[0],a=0;a<o;a++){var d=r.contentItems[r.contentItems.length-1];this._addChildContentItemsToContainer(l,d)}this._updatingColumnsResponsive=!1}}}_useResponsiveLayout(){return this.config.settings&&(this.config.settings.responsiveMode=="always"||this.config.settings.responsiveMode=="onload"&&this._firstLoad)}_addChildContentItemsToContainer(e,n){n.type==="stack"?n.contentItems.forEach(function(s){e.addChild(s),n.removeChild(s,!0)}):n.contentItems.forEach(s=>{this._addChildContentItemsToContainer(e,s)})}_findAllStackContainers(){const e=[];return this._findAllStackContainersRecursive(e,this.root),e}_findAllStackContainersRecursive(e,n){n.contentItems.forEach(s=>{Ao(s)?e.push(s):s.isComponent||this._findAllStackContainersRecursive(e,s)})}}Dd.__lm=nw;const sw="_lm_root_1mdia_1",iw="_lm_row_1mdia_5",ow="_lm_item_1mdia_5",rw="_lm_content_1mdia_9",lw="_lm_dragging_1mdia_15",aw="_lm_maximised_1mdia_21",dw="_lm_maximise_placeholder_1mdia_28",cw="_lm_splitter_1mdia_32",hw="_lm_vertical_1mdia_39",uw="_lm_drag_handle_1mdia_39",mw="_lm_horizontal_1mdia_44",pw="_lm_header_1mdia_54",gw="_lm_dropdown_open_1mdia_61",fw="_lm_controls_1mdia_67",Cw="_lm_tabs_1mdia_87",bw="_lm_tab_1mdia_87",Sw="_lm_title_1mdia_102",ww="_lm_close_tab_1mdia_109",vw="_lm_stack_1mdia_118",Tw="_lm_left_1mdia_118",Ew="_lm_right_1mdia_119",yw="_lm_dragProxy_1mdia_123",Iw="_lm_items_1mdia_146",Rw="_lm_tabdropdown_list_1mdia_163",Dw="_lm_bottom_1mdia_190",Mw="_lm_drop_tab_placeholder_1mdia_205",Nw="_lm_tabdropdown_1mdia_163",Fw="_lm_dropTargetIndicator_1mdia_256",xw="_lm_inner_1mdia_262",_w="_lm_transition_indicator_1mdia_270",kw="_lm_popin_1mdia_280",Ow="_lm_bg_1mdia_295",Lw="_lm_icon_1mdia_298",Aw="_lm_goldenlayout_1mdia_302",Pw="_lm_selectable_1mdia_338",Hw="_lm_active_1mdia_368",Vw="_lm_selected_1mdia_386",Uw="_lm_keyboard_active_1mdia_395",Bw="_lm_popout_1mdia_414",$w="_lm_maximise_1mdia_21",zw="_lm_close_1mdia_109",Ww="_lm_tabnextbutton_1mdia_423",Gw="_lm_tabpreviousbutton_1mdia_426",Kw="_lm_title_before_1mdia_542",qw="_lm_focusin_1mdia_566",Yw="_lm_window_blur_1mdia_571",Xw="_lm_tabdropdown_search_1mdia_629",jw="_march_1mdia_1",Qw="_app_1mdia_710",Zw="_plotly_1mdia_719",lh={"tab-height":"28px","drag-border-width":"5px",lm_root:sw,lm_row:iw,lm_item:ow,lm_content:rw,lm_dragging:lw,lm_maximised:aw,lm_maximise_placeholder:dw,lm_splitter:cw,lm_vertical:hw,lm_drag_handle:uw,lm_horizontal:mw,lm_header:pw,lm_dropdown_open:gw,lm_controls:fw,lm_tabs:Cw,lm_tab:bw,lm_title:Sw,lm_close_tab:ww,lm_stack:vw,lm_left:Tw,lm_right:Ew,lm_dragProxy:yw,lm_items:Iw,lm_tabdropdown_list:Rw,lm_bottom:Dw,lm_drop_tab_placeholder:Mw,lm_tabdropdown:Nw,lm_dropTargetIndicator:Fw,lm_inner:xw,lm_transition_indicator:_w,lm_popin:kw,lm_bg:Ow,lm_icon:Lw,lm_goldenlayout:Aw,lm_selectable:Pw,lm_active:Hw,lm_selected:Vw,lm_keyboard_active:Uw,lm_popout:Bw,lm_maximise:$w,lm_close:zw,lm_tabnextbutton:Ww,lm_tabpreviousbutton:Gw,lm_title_before:Kw,"editor-unsaved-indicator":"_editor-unsaved-indicator_1mdia_546","is-unsaved":"_is-unsaved_1mdia_554",lm_focusin:qw,lm_window_blur:Yw,lm_tabdropdown_search:Xw,march:jw,app:Qw,"js-plotly-plot":"_js-plotly-plot_1mdia_719",plotly:Zw},ah=Object.freeze({tabHeight:parseInt(lh["tab-height"],10),dragBorderWidth:parseInt(lh["drag-border-width"],10)}),Ts=X.module("LayoutUtils");function Bm(t){return t.componentName!==void 0}function _i(t){const e=t;return(Bm(t)&&t.componentName==="lm-react-component"||t.type==="react-component")&&e.component!==void 0}function br(t){return t.focus!==void 0}function ch(t){return t.type==="stack"}const ze=class{static activateTab(t,e){const n=ze.getStackForRoot(t,e,!1);if(!n){Ts.error("Could not find stack for config",e);return}const s=ze.getContentItemInStack(n,e);s&&n.setActiveContentItem(s)}static isActiveTab(t,e){const n=ze.getStackForRoot(t,e,!1);if(!n)return Ts.error("Could not find stack for config",e),!1;const s=ze.getContentItemInStack(n,e);return n.getActiveContentItem()===s}static addStack(t,e=!0){const n=e?"column":"row";if(Am(t)){(t.contentItems==null||t.contentItems.length===0)&&t.addChild({type:n});const o=t.contentItems[0];if(!(e?o.isColumn:o.isRow)){t.removeChild(o,!0),t.addChild({type:n});const l=document.activeElement;t.contentItems[0].addChild(o),l&&l.focus!=null&&l.focus()}return this.addStack(t.contentItems[0],e)}if(t.contentItems.length<2)return t.addChild({type:"stack"}),t.contentItems[t.contentItems.length-1];let s=t.contentItems[t.contentItems.length-1];return(e?s.isRow:s.isColumn)||(t.addChild({type:e?"row":"column"}),t.removeChild(s,!0),t.contentItems[t.contentItems.length-1].addChild(s),s=t.contentItems[t.contentItems.length-1]),this.addStack(s,!e)}static getStackForConfig(t,e={},n=!1){if(n&&Ao(t)&&t.contentItems.length===0)return t;if(t.contentItems==null)return null;for(let s=0;s<t.contentItems.length;s+=1){const i=t.contentItems[s];if(i.isComponent&&i.config!=null&&Sc(i.config,e))return t;const o=this.getStackForConfig(i,e,n);if(o)return o}return null}static getStackForRoot(t,e,n=!0,s=!0,i=!0){let o=this.getStackForConfig(t,e);return!o&&s&&(o=this.getStackForConfig(t,{component:e.component},i)),!o&&n&&(o=this.addStack(t)),o}static getStackForComponentTypes(t,e,n=!0,s=!0,i=!0){for(let o=0;o<e.length;o+=1){const r=e[o],l=o===e.length-1,a=ze.getStackForRoot(t,{component:r},n&&l,s,i);if(a)return a}return null}static getContentItemInStack(t,e){if(!t)return null;for(let n=0;n<t.contentItems.length;n+=1){const s=t.contentItems[n];if(s.isComponent&&s.config!=null&&Sc(s.config,e))return s}return null}static dehydrateLayoutConfig(t,e){if(t==null||!t.length)return[];const n=[];for(let s=0;s<t.length;s+=1){const i=t[s],{component:o,content:r}=i;if(o){const l=e(o,i);l!=null?n.push(l):Ts.debug2(`dehydrateLayoutConfig: skipping unmapped component "${o}"`)}else if(r){const l={...i,content:ze.dehydrateLayoutConfig(r,e)};n.push(l)}else n.push(i)}return n}static getTabPoint(t){const{tab:e}=t;if(e==null)throw new Error(`Cannot get tab for panel container ${t}`);const n=e.element[0].getBoundingClientRect();return[n.left+n.width*.5,n.bottom-8]}static dropLayoutMinorChange(t){for(let e=0;e<t.length;e+=1){const n=t[e],{content:s}=n;s!==void 0?(ch(n)&&delete n.activeItemIndex,ze.dropLayoutMinorChange(s)):_i(n)&&n.component==="IrisGridPanel"&&n.props.panelState!=null&&(delete n.id,n.props.panelState.irisGridState.sorts=[],n.props.panelState.irisGridState.quickFilters=[])}}static isEqual(t,e,n=!1){if(n){const s=ze.cloneLayout(t),i=ze.cloneLayout(e);return ze.dropLayoutMinorChange(s),ze.dropLayoutMinorChange(i),ct(s,i)}return ct(t,e)}static cloneLayout(t){return JSON.parse(JSON.stringify(t))}static hydrateLayoutConfig(t,e){var s;if(t==null||!t.length)return[];const n=[];for(let i=0;i<t.length;i+=1){const o=t[i];if(_i(o)){const{component:r,props:l={}}=o;n.push({...o,id:(s=o==null?void 0:o.id)!=null?s:We(),props:e(r,l)})}else if(o.content!==void 0){const r=ze.hydrateLayoutConfig(o.content,e);ch(o)&&o.activeItemIndex!=null&&o.activeItemIndex>=r.length&&(Ts.warn("Fixing bad activeItemIndex!",o.activeItemIndex,o),o.activeItemIndex=0),n.push({...o,content:r})}else n.push(o)}return n}static openComponent({root:t,config:e,replaceExisting:n=!0,replaceConfig:s=void 0,createNewStack:i=!1,focusElement:o=void 0,dragEvent:r=void 0}={}){const l=document.activeElement,a={...e};if(a.id==null&&(a.id=We.generate()),r){t==null||t.layoutManager.createDragSourceFromEvent(a,r);return}const d=s||{id:a.id,component:a.component};A(t);const c=i?ze.addStack(t):ze.getStackForRoot(t,d);A(c);const u=ze.getContentItemInStack(c,d);if(o!=null){const m=p=>{Ts.debug("Component created, focusing element",o),c.off("componentCreated",m);const{element:g}=p.origin;requestAnimationFrame(()=>{ze.focusElement(g[0],o)})};c.on("componentCreated",m)}if(n&&u){const m=c.contentItems.indexOf(u);c.addChild(a,m+1),c.removeChild(u),c.setActiveContentItem(c.contentItems[m])}else c.addChild(a);o==null&&l&&br(l)&&l.focus()}static openComponentInStack(t,e,n=!0){const s=document.activeElement,i={id:e.id},o=ze.getContentItemInStack(t,i);if(n&&o&&t){const r=t==null?void 0:t.contentItems.indexOf(o);t.addChild(e,r+1),t.removeChild(o),t.setActiveContentItem(t.contentItems[r])}else t==null||t.addChild(e);s&&br(s)&&s.focus()}static closeComponent(t,e){const n=ze.getStackForRoot(t,e,!1,!1,!1);if(!n){Ts.warn("Cannot find stack for component, ignoring close",e);return}const s=ze.getContentItemInStack(n,e),i=document.activeElement;s&&(s.isComponent?s.container.close():n.removeChild(s)),i&&document.contains(i)&&br(i)&&i.focus()}static renameComponent(t,e,n){const s=ze.getStackForRoot(t,e,!1);if(!s){Ts.error("Could not find stack for config",e);return}const i=ze.getContentItemInStack(s,e);i&&i.setTitle(n)}static cloneComponent(t,e){const n=ze.getStackForRoot(t,e,!1);if(!n)return Ts.error("Could not find stack for config",e),null;const{props:s={}}=e,i=ze.getPanelComponentState(e),o={type:"react-component",component:e.component,props:{...s,panelState:i},title:`${e.title} Copy`,id:We.generate()};return ze.openComponentInStack(n,o),o}static getPanelComponentState(t){var e,n;return Bm(t)?(e=t.componentState)==null?void 0:e.panelState:_i(t)?(n=t.props)==null?void 0:n.panelState:null}static makeDefaultLayout(){return{dimensions:{headerHeight:ah.tabHeight,borderWidth:ah.dragBorderWidth,borderGrabWidth:10},settings:{showPopoutIcon:!1,showCloseIcon:!1,constrainDragToContainer:!1}}}static getRootFromContainer(t){return t.layoutManager.root}static getComponentConfigFromContainer(t){return t?t.tab!=null&&t.tab.contentItem!=null?t.tab.contentItem.config:t._config:null}static getTitleFromContainer(t){return t!=null&&t.tab!=null&&t.tab.contentItem!=null?t.tab.contentItem.config.title:null}static getTitleFromTab(t){return t!=null&&t.contentItem!=null?t.contentItem.config.title:null}static getIdFromContainer(t){const e=ze.getComponentConfigFromContainer(t);return e?e.id:null}static getIdFromPanel(t){const{glContainer:e}=t.props;return ze.getIdFromContainer(e)}static getComponentNameFromPanel(t){var s;const{glContainer:e}=t.props,n=ze.getComponentConfigFromContainer(e);return n&&_i(n)&&(s=n.component)!=null?s:null}static getComponentName(t){var n,s;const e=(s=(n=t.WrappedComponent)==null?void 0:n.displayName)!=null?s:t.displayName;if(e==null)throw new Error(`Component displayName not defined ${t}`);return e}static focusElement(t,e=ze.DEFAULT_FOCUS_SELECTOR){if(t==null)return null;const n=t.querySelector(e);return n==null?null:(br(n)&&n.focus(),n)}static onInitialized(t){return new Promise(e=>{if(t.isInitialised){e();return}const n=()=>{t.off("initialised",n),e()};t.on("initialised",n)})}};let te=ze;te.DEFAULT_FOCUS_SELECTOR="input, select, textarea, button";const Jw=Y.forwardRef((t,e)=>{const n=te.getComponentNameFromPanel({props:t});return v("div",{ref:e,className:"panel-placeholder",children:['Component "',n,'" is not registered.']})}),Me=Object.freeze({FOCUS:"PanelEvent.FOCUS",MOUNT:"PanelEvent.MOUNT",UNMOUNT:"PanelEvent.UNMOUNT",TITLE_CHANGED:"PanelEvent.TITLE_CHANGED",REOPEN:"PanelEvent.REOPEN",DELETE:"PanelEvent.DELETE",CLONED:"PanelEvent.CLONED",CLOSED:"PanelEvent.CLOSED",OPEN:"PanelEvent.OPEN",CLOSE:"PanelEvent.CLOSE"});function hh(t){return(t==null?void 0:t.WrappedComponent)!==void 0}function e0(t){return typeof t.id=="string"&&t.layout instanceof Dd&&t.panelManager instanceof Md&&typeof t.registerComponent=="function"}function As(t){if(!e0(t))throw new Error(`Expected dashboard plugin props, but instead received ${t}`)}const mn=X.module("PanelManager");class Md{constructor(e,n=(l,a)=>a,s=(l,a)=>a,i=new Map,o=[],r=()=>{}){this.handleFocus=this.handleFocus.bind(this),this.handleMount=this.handleMount.bind(this),this.handleUnmount=this.handleUnmount.bind(this),this.handleReopen=this.handleReopen.bind(this),this.handleDeleted=this.handleDeleted.bind(this),this.handleClosed=this.handleClosed.bind(this),this.handleControlClose=this.handleControlClose.bind(this),this.layout=e,this.hydrateComponent=n,this.dehydrateComponent=s,this.onPanelsUpdated=r,this.openedMap=new Map(i),this.closed=[...o],this.startListening()}startListening(){const{eventHub:e}=this.layout;e.on(Me.FOCUS,this.handleFocus),e.on(Me.MOUNT,this.handleMount),e.on(Me.UNMOUNT,this.handleUnmount),e.on(Me.REOPEN,this.handleReopen),e.on(Me.DELETE,this.handleDeleted),e.on(Me.CLOSED,this.handleClosed),e.on(Me.CLOSE,this.handleControlClose)}stopListening(){const{eventHub:e}=this.layout;e.off(Me.FOCUS,this.handleFocus),e.off(Me.MOUNT,this.handleMount),e.off(Me.UNMOUNT,this.handleUnmount),e.off(Me.REOPEN,this.handleReopen),e.off(Me.DELETE,this.handleDeleted),e.off(Me.CLOSED,this.handleClosed),e.off(Me.CLOSE,this.handleControlClose)}getClosedPanelConfigsOfType(e){return this.closed.filter(n=>n.component===e)}getOpenedPanels(){return Array.from(this.openedMap.values())}getOpenedPanelConfigs(){return this.getOpenedPanels().map(e=>{const{glContainer:n}=e.props;return te.getComponentConfigFromContainer(n)})}getOpenedPanelConfigsOfType(e){return this.getOpenedPanelConfigs().filter(n=>n!=null&&_i(n)&&n.component===e)}getOpenedPanelById(e){return this.openedMap.get(e)}getContainerByPanelId(e){var s;const n=te.getStackForConfig(this.layout.root,{id:e});return(s=n&&te.getContentItemInStack(n,{id:e}))!=null?s:null}getLastUsedPanel(e){const n=this.getOpenedPanels();for(let s=n.length-1;s>=0;s-=1){const i=n[s];if(e==null||e(i))return i}}getLastUsedPanelOfType(e){return this.getLastUsedPanelOfTypes([e])}getLastUsedPanelOfTypes(e){return this.getLastUsedPanel(n=>e.some(s=>hh(s)&&n instanceof s.WrappedComponent||!hh(s)&&n instanceof s))}updatePanel(e){const n=te.getIdFromPanel(e);if(n==null){mn.error("updatePanel Panel did not have an ID",e);return}mn.debug2(`Updating panel ID ${n} in open panels map`),this.openedMap.delete(n),this.openedMap.set(n,e)}removePanel(e){const n=te.getIdFromPanel(e);if(n==null){mn.error("removePanel Panel did not have an ID",e);return}if(!this.openedMap.has(n)){mn.error(`Missing panel ID ${n} in open panels map`);return}if(this.openedMap.get(n)!==e){mn.debug(`Panel argument doesn't match the open panels map entry for ${n}, removePanel ignored`);return}mn.debug2(`Removing panel ID ${n} from open panels map`),this.openedMap.delete(n)}removeClosedPanelConfig(e){const n=this.closed.findIndex(s=>s===e||s.id!=null&&e.id&&s.id===e.id);n>=0&&this.closed.splice(n,1)}handleFocus(e){mn.debug2("Focus: ",e),this.updatePanel(e)}handleMount(e){mn.debug2("Mount: ",e),this.updatePanel(e),this.sendUpdate()}handleUnmount(e){mn.debug2("Unmount: ",e),this.removePanel(e),this.sendUpdate()}handleReopen(e,n){mn.debug2("Reopen:",e,n),this.removeClosedPanelConfig(e);const{component:s}=e;let{props:i}=e;i=this.hydrateComponent(s,i);const o={...e,props:i},{root:r}=this.layout;te.openComponent({root:r,config:o,replaceConfig:n})}handleDeleted(e){mn.debug2("Deleted:",e),this.removeClosedPanelConfig(e),this.sendUpdate()}handleClosed(e,n){mn.debug2("Closed: ",e),this.addClosedPanel(n),this.sendUpdate()}handleControlClose(e){const n={id:e},{root:s}=this.layout;te.closeComponent(s,n)}addClosedPanel(e){const n=te.getComponentConfigFromContainer(e);if(n&&_i(n)){const s=this.dehydrateComponent(n.component,n);s!=null&&this.closed.push(s)}}sendUpdate(){const{closed:e,openedMap:n}=this;this.onPanelsUpdated({closed:[...e],openedMap:new Map(n)})}}Md.MAX_CLOSED_PANEL_COUNT=100;const t0=X.module("PanelErrorBoundary");class n0 extends S.exports.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}componentWillUnmount(){const{glContainer:e,glEventHub:n}=this.props,s=te.getIdFromContainer(e);t0.debug("componentWillUnmount",s),n.emit(Me.CLOSED,s,e)}render(){const{children:e}=this.props,{error:n}=this.state;return n!=null?h("div",{className:"panel-error-boundary",children:h(Cl,{errorMessage:`${n}`,isLoading:!1,isLoaded:!1})}):e}}function Nd(t){const{props:e,componentState:n}=t,{metadata:s}=e;let{panelState:i=null}=e;n&&({panelState:i}=n);const o={};return s!=null&&(o.metadata=s),i!=null&&(o.panelState=i),{...t,componentState:null,props:o,type:"react-component"}}function Fd(t,e=""){return{metadata:{},...t,localDashboardId:e}}const Pa={dehydrate:Nd,hydrate:Fd},s0=D.exports.shape({on:D.exports.func,off:D.exports.func,isHidden:D.exports.bool,tab:D.exports.shape({header:D.exports.shape({tabs:D.exports.arrayOf(D.exports.shape({contentItem:D.exports.shape({})}))})}),title:D.exports.string,setTitle:D.exports.func,close:D.exports.func}),$m=D.exports.shape({on:D.exports.func,off:D.exports.func,emit:D.exports.func}),i0=D.exports.shape({registerComponent:D.exports.func,root:D.exports.shape({addChild:D.exports.func}),on:D.exports.func,off:D.exports.func,eventHub:$m}),xd=Object.freeze({Container:s0,EventHub:$m,Layout:i0}),Ke=(t,e,n)=>S.exports.useEffect(function(){return t.on(e,n),()=>{t.off(e,n)}},[t,e,n]),zm="SET_DASHBOARD_DATA",o0=MS(zm,{},!1),r0={dashboardData:o0},l0=new Map,a0=Object.freeze({}),d0=Object.freeze([]),c0=t=>t.dashboardData,qt=(t,e)=>{var n;return(n=c0(t)[e])!=null?n:a0},h0=(t,e)=>{var n;return(n=qt(t,e).closed)!=null?n:d0},Wm=(t,e)=>{var n;return(n=qt(t,e).openedMap)!=null?n:l0},Gm=(t,e)=>({type:zm,id:t,payload:e}),qn=(t,e)=>(n,s)=>n(Gm(t,{...qt(s(),t),...e}));Object.entries(r0).map(([t,e])=>Zi.register(t,e));const Sr=X.module("DashboardLayout"),u0=Object.freeze({}),m0=[],uh=()=>{},mh=t=>t,Km=({id:t,children:e,emptyDashboard:n=h("div",{children:"Dashboard is empty."}),layout:s,layoutConfig:i=m0,onLayoutChange:o=uh,onLayoutInitialized:r=uh,hydrate:l=Fd,dehydrate:a=Nd})=>{var _,k;const d=ed(),c=(_=lg(V=>qt(V,t)))!=null?_:u0,[u,m]=S.exports.useState(!1),[p,g]=S.exports.useState(!1),[f,b]=S.exports.useState(),[C]=S.exports.useState((k=c==null?void 0:c.closed)!=null?k:[]),[w,T]=S.exports.useState(!1),y=S.exports.useMemo(()=>new Map,[]),E=S.exports.useMemo(()=>new Map,[]),I=ag(),R=S.exports.useCallback((V,W,j=l,ee=a)=>{Sr.debug2("registerComponent",V,W,j,ee);function ve(Le,J){const pe=W,{glContainer:fe,glEventHub:xe}=Le;return h(tu,{store:I,children:h(n0,{glContainer:fe,glEventHub:xe,children:h(pe,{...Le,ref:J})})})}const le=Y.forwardRef(ve),Se=s.registerComponent(V,le);return y.set(V,j),E.set(V,ee),Se},[l,a,y,E,s,I]),F=S.exports.useCallback((V,W)=>{var j;return((j=y.get(V))!=null?j:mh)(W,t)},[y,t]),x=S.exports.useCallback((V,W)=>{var j;return((j=E.get(V))!=null?j:mh)(W,t)},[E,t]),U=S.exports.useMemo(()=>new Md(s,F,x,new Map,C,({closed:V,openedMap:W})=>{d(qn(t,{closed:V,openedMap:W}))}),[x,d,F,t,C,s]),$=S.exports.useCallback(()=>{if(p)return;w||(r(),T(!0));const W=s.toConfig().content,j=te.dehydrateLayoutConfig(W,x),ee=f==null||!te.isEqual(f,j);Sr.debug("handleLayoutStateChanged",ee,W,j),ee&&(m(s.root.contentItems.length===0),b(j),o(j))},[x,w,p,f,s,o,r]),O=S.exports.useCallback(()=>{g(!0)},[]),H=S.exports.useCallback(()=>{g(!1)},[]),L=S.exports.useCallback(V=>{if(Sr.debug2("handleComponentCreated",V),V==null||V.config==null||V.config.component==null||V.element==null)return;const j=`${V.config.component.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}-component`;V.element.addClass(j)},[]);Ke(s,"stateChanged",$),Ke(s,"itemPickedUp",O),Ke(s,"itemDropped",H),Ke(s,"componentCreated",L),Ke(s.eventHub,Me.TITLE_CHANGED,$);const N=gl(i);return S.exports.useEffect(function(){if(N!==i&&i!==f){Sr.debug("Setting new layout content...");const W=te.hydrateLayoutConfig(i,F);for(;s.root.contentItems.length>0;)s.root.contentItems[0].remove();for(let j=0;j<W.length;j+=1)s.root.addChild(W[j]);m(s.root.contentItems.length===0)}},[F,s,i,f,U,N]),v(ue,{children:[u&&n,Y.Children.map(e,V=>V!=null?Y.cloneElement(V,{id:t,layout:s,panelManager:U,registerComponent:R}):null)]})};Km.propTypes={id:D.exports.string.isRequired,children:D.exports.node,data:D.exports.shape({}),emptyDashboard:D.exports.node,layout:xd.Layout.isRequired,layoutConfig:D.exports.arrayOf(D.exports.shape({})),onLayoutChange:D.exports.func,onLayoutInitialized:D.exports.func};const p0=100,la=()=>{},g0=Object.freeze({}),f0=({id:t="default",children:e,emptyDashboard:n,layoutConfig:s,layoutSettings:i=g0,onLayoutConfigChange:o=la,onGoldenLayoutChange:r=la,onLayoutInitialized:l=la,fallbackComponent:a=Jw,hydrate:d,dehydrate:c})=>{const u=S.exports.useRef(null),[m,p]=S.exports.useState(!1),[g,f]=S.exports.useState();S.exports.useEffect(function(){if(!u.current){f(void 0);return}const w={...te.makeDefaultLayout()};w.settings===void 0&&(w.settings={}),Object.assign(w.settings,i),w.content=[];const T=new Dd(w,u.current),y=()=>{T.off("initialised",y),p(!0)};return T.on("initialised",y),a!=null&&T.setFallbackComponent(a),T.init(),f(T),r(T),()=>{T.destroy()}},[i,a,r,p,f]);const b=S.exports.useMemo(()=>hs(()=>{g!=null&&g.isInitialised&&(g==null||g.updateSize())},p0),[g]);return S.exports.useEffect(function(){return window.addEventListener("resize",b),()=>{window.removeEventListener("resize",b)}},[b]),v("div",{className:"dashboard-container w-100 h-100",children:[h("div",{className:"w-100 h-100",ref:u}),m&&g&&h(Km,{emptyDashboard:n,id:t,layout:g,layoutConfig:s,onLayoutChange:o,onLayoutInitialized:l,hydrate:d,dehydrate:c,children:e})]})},Rn="default";var mi=(t=>(t.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS="filter-control-change-clears-all-filters",t.LINK_CHANGE_CLEARS_ALL_FILTERS="link-change-clears-all-filters",t))(mi||{});const C0=Object.freeze([[mi.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS,!1],[mi.LINK_CHANGE_CLEARS_ALL_FILTERS,!1]]),b0={DEFAULTS:C0};var Ae=(t=>(t.COUNT="Count",t.MIN="Min",t.MAX="Max",t.SUM="Sum",t.ABS_SUM="AbsSum",t.VAR="Var",t.AVG="Avg",t.STD="Std",t.FIRST="First",t.LAST="Last",t.SKIP="Skip",t.COUNT_DISTINCT="CountDistinct",t.DISTINCT="Distinct",t.UNIQUE="Unique",t))(Ae||{});const S0=t=>{switch(t){default:return!1}},w0=(t,e)=>{switch(t){case Ae.COUNT:case Ae.FIRST:case Ae.LAST:case Ae.COUNT_DISTINCT:case Ae.DISTINCT:case Ae.UNIQUE:return!0;case Ae.MIN:case Ae.MAX:return P.isNumberType(e)||P.isDateType(e)||P.isTextType(e);case Ae.SUM:case Ae.ABS_SUM:case Ae.VAR:case Ae.AVG:case Ae.STD:return P.isNumberType(e);case Ae.SKIP:return!1}},_d=(t,e)=>t.filter(n=>w0(e,n.type)),v0=(t,e,n,s)=>_d(t,e).map(({name:i})=>i).filter(i=>n.includes(i)?!s:s),ks={isRollupOperation:S0,filterValidColumns:_d,getOperationColumnNames:v0};const ph=X.module("Aggregations"),T0=[Ae.SUM,Ae.ABS_SUM,Ae.MIN,Ae.MAX,Ae.VAR,Ae.AVG,Ae.STD,Ae.FIRST,Ae.LAST,Ae.COUNT_DISTINCT,Ae.DISTINCT,Ae.COUNT,Ae.UNIQUE],E0=({isRollup:t,settings:e,onChange:n,onEdit:s})=>{const{aggregations:i,showOnTop:o}=e,r=S.exports.useMemo(()=>T0.filter(x=>!i.some(U=>U.operation===x)),[i]),[l,a]=S.exports.useState(r[0]),[d,c]=S.exports.useState([]),u=S.exports.useCallback(x=>{n({...e,...x})},[n,e]),m=S.exports.useCallback(x=>{u({aggregations:x})},[u]),p=S.exports.useCallback(x=>{u({showOnTop:x})},[u]),g=S.exports.useCallback(()=>{ph.debug("handleDragStart"),Gt.startDragging()},[]),f=S.exports.useCallback(({destination:x,source:U})=>{if(ph.debug("handleDragEnd",x,U),Gt.stopDragging(),x===null)return;let $=x.index;U.index<x.index&&($+=1);const O=[...i],H=Gt.reorder(O,d,O,$),L=Gt.adjustDestinationIndex($,d),N=[[L,L+H.length-1]];m(O),c(N)},[m,i,d,c]),b=S.exports.useCallback(x=>{a(x)},[a]),C=S.exports.useCallback(()=>{m([...i,{operation:l,selected:[],invert:!0}])},[i,l,m]),w=S.exports.useCallback(x=>{m(i.filter((U,$)=>$!==x))},[i,m]),T=S.exports.useCallback(x=>{c(x)},[c]),y=S.exports.useCallback(x=>{const U=i[x];ks.isRollupOperation(U.operation)||s(U)},[i,s]),E=S.exports.useCallback(x=>{p(x.target.value==="true")},[p]);S.exports.useEffect(function(){r.length>0&&!r.includes(l)&&a(r[0])},[r,l]);const I=S.exports.useCallback(({item:x,itemIndex:U,isClone:$=!1,selectedCount:O})=>{const H=x.operation,L=$?`${O}`:void 0,N=$?"item-list-item-clone":void 0,_=ks.isRollupOperation(x.operation),k=!$&&!_;return v(ue,{children:[v("div",{className:z("item-list-item-content","draggable-item-list-item-content",N),children:[v("span",{className:"title",children:[H,!t&&_&&v("span",{className:"small text-warning",children:[h(K,{icon:Su})," Requires rollup"]})]}),nn.renderBadge({text:L}),nn.renderHandle()]}),!$&&v(ue,{children:[h(Q,{kind:"ghost",className:"btn-edit",icon:hl,tooltip:"Edit Columns",onClick:()=>s(x),disabled:!k}),h(Q,{kind:"ghost",className:"btn-delete",icon:_n,tooltip:"Delete Aggregation",onClick:()=>w(U)})]})]})},[w,s,t]),R=r.length>0,F=i.length>0;return v("div",{className:"aggregations",children:[R&&v("div",{className:"form-inline",children:[h(OC,{onChange:b,value:l,children:r.map(x=>h(kC,{value:x,children:x},x))}),v("button",{type:"button",className:"btn btn-link btn-add",onClick:C,children:[h(K,{icon:Ls}),"Add Aggregation"]})]}),R&&F&&h("hr",{}),F&&v(ue,{children:[!t&&v("div",{className:"form-inline",children:[h("label",{children:"Placement:\xA0"}),v(bl,{onChange:E,value:`${o}`,children:[h(Mn,{value:"true",children:"Top"}),h(Mn,{value:"false",children:"Bottom"})]})]}),h(Vo,{onDragStart:g,onDragEnd:f,children:h(nn,{className:"selected-aggregations",itemCount:i.length,items:i,renderItem:I,offset:0,onSelectionChange:T,onSelect:y,selectedRanges:d,isMultiSelect:!0})})]})]})};const y0=30,I0=({aggregation:t,columns:e,onChange:n})=>{const[s,i]=S.exports.useState(-1),[o,r]=S.exports.useState(-1),[l,a]=S.exports.useState(0),{invert:d,selected:c}=t,u=S.exports.useRef(null),m=S.exports.useCallback(E=>c.includes(E)?!d:d,[d,c]),p=S.exports.useMemo(()=>{let E=_d(e,t.operation);return l!==0&&(E=P.sortColumns(E,l===1)),E},[e,t.operation,l]),g=S.exports.useMemo(()=>s>=0?p.slice(s,o+1).map(E=>({value:E.name,displayValue:E.name,isSelected:m(E.name)})):[],[p,m,o,s]),f=S.exports.useCallback(E=>{const{name:I}=p[E],R=c.indexOf(I);let F=[...c],x=d;R>=0?F.splice(R,1):(F.push(I),F.length===p.length&&(F=[],x=!d)),n({...t,selected:F,invert:x})},[t,d,p,c,n]),b=S.exports.useCallback(()=>{a(0),n({...t,selected:[],invert:!0})},[t,n]),C=S.exports.useCallback((E,I)=>{i(E),r(I)},[i,r]),w=S.exports.useCallback(()=>{c.length===0?n({...t,invert:!d}):n({...t,selected:[],invert:!0})},[t,d,n,c]),T=c.length===0?d:null,y=c.length!==0||!d||l!==0;return v("div",{role:"menu",className:"aggregation-edit",children:[h("div",{className:"top-menu",children:v("div",{className:"form-inline",children:[h(Pt,{checked:T,onChange:w,children:"Toggle All"}),h("div",{className:"spacer"}),h(ht,{in:y,timeout:Tt.transitionSlowMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:h(Q,{kind:"ghost",className:"btn-reset",onClick:b,children:"Reset"})}),h(Q,{kind:"ghost",className:z({active:l===1}),icon:hd,tooltip:"Sort ascending",onClick:()=>a(1)}),h(Q,{kind:"ghost",className:z({active:l===2}),icon:ud,tooltip:"Sort descending",onClick:()=>a(2)})]})}),h("div",{className:"aggregation-edit-item-list",children:h(Cn,{itemCount:p.length,items:g,offset:s,renderItem:({item:E})=>h(Pt,{checked:m(E.value),children:E.displayValue}),onSelect:f,onViewportChange:C,rowHeight:y0,focusSelector:"input",ref:u})})]})};function R0(t){return h("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...t,children:v("g",{fill:"none",fillRule:"evenodd",children:[h("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),h("path",{fill:"#7DA4FF",d:"M8 26h4v15H8zM15 17h4v24h-4zM22 21h4v20h-4zM29 17h4v24h-4zM36 11h4v30h-4z"})]})})}function D0(t){return h("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...t,children:v("g",{fill:"none",fillRule:"evenodd",children:[h("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),h("path",{fill:"#7DA4FF",d:"M7 34h4v8H7zM12 31h4v11h-4zM17 27h4v15h-4zM22 22h4v20h-4zM27 27h4v15h-4zM32 29h4v13h-4zM37 31h4v11h-4z"})]})})}function M0(t){return h("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...t,children:v("g",{fill:"none",fillRule:"evenodd",children:[h("path",{fill:"#C1C0C0",d:"M4 4h1v40H4zM44 43v1H5v-1z"}),h("path",{stroke:"#7DA4FF",d:"M7.984 32.44l7.982-11.378 5.273 3.739 9.952-10.838 2.826 1.894 7.45-5.802"}),h("path",{stroke:"#BECDEF",d:"M8.244 37.926L17 33.496l5 .87 10.637-10.35 10.615-1.381"})]})})}function N0(t){return h("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...t,children:v("g",{fill:"none",fillRule:"evenodd",children:[h("path",{d:"M24 10c7.732 0 14 6.268 14 14s-6.268 14-14 14-14-6.268-14-14h14V10z",fill:"#80A6FF"}),h("path",{d:"M10 24c0-7.732 6.268-14 14-14v14H10z",fill:"#C1C0C0"})]})})}function F0(t){return h("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...t,children:v("g",{fill:"none",fillRule:"evenodd",children:[h("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),h("path",{fill:"#939293",d:"M44 34v1H4v-1zM44 25v1H4v-1zM44 16v1H4v-1z"}),h("circle",{fill:"#7DA4FF",cx:9.5,cy:37.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:16.5,cy:30.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:22.5,cy:36.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:28.5,cy:30.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:15.5,cy:38.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:23.5,cy:25.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:19.5,cy:19.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:29.5,cy:19.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:32.5,cy:26.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:36.5,cy:13.5,r:1.5})]})})}function x0(t){return v("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[h("rect",{width:"48",height:"48",fill:"none"}),h("rect",{x:"26",y:"10",width:"15",height:"4",fill:"#9FDE70"}),h("rect",{x:"26",y:"22",width:"15",height:"4",fill:"#9FDE70"}),h("rect",{x:"26",y:"28",width:"15",height:"4",fill:"#FFD95C"}),h("rect",{x:"26",y:"34",width:"15",height:"4",fill:"#9FDE70"})]})}function _0(t){return v("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[h("rect",{width:"48",height:"48",fill:"none"}),h("rect",{x:"4",y:"16",width:"40",height:"4",fill:"#FFD95C"}),h("rect",{x:"4",y:"10",width:"40",height:"4",fill:"#78DCE8"}),h("rect",{x:"4",y:"34",width:"40",height:"4",fill:"#78DCE8"})]})}const gh=X.module("ChartBuilder"),pt=class extends S.exports.PureComponent{static getTypeName(t){switch(t){case M.plot.SeriesPlotStyle.LINE:return"Line";case M.plot.SeriesPlotStyle.BAR:return"Bar";case M.plot.SeriesPlotStyle.SCATTER:return"Scatter";case M.plot.SeriesPlotStyle.PIE:return"Pie";case M.plot.SeriesPlotStyle.HISTOGRAM:return"Histogram";default:return t}}static getTypeIcon(t){switch(t){case M.plot.SeriesPlotStyle.LINE:return h(M0,{});case M.plot.SeriesPlotStyle.BAR:return h(R0,{});case M.plot.SeriesPlotStyle.SCATTER:return h(F0,{});case M.plot.SeriesPlotStyle.PIE:return h(N0,{});case M.plot.SeriesPlotStyle.HISTOGRAM:return h(D0,{});default:return null}}static getMaxSeriesCount(t){switch(t){case M.plot.SeriesPlotStyle.PIE:return 1;case M.plot.SeriesPlotStyle.HISTOGRAM:return 0;default:return 100}}static getXAxisLabel(t){switch(t){case M.plot.SeriesPlotStyle.PIE:return"Labels";case M.plot.SeriesPlotStyle.HISTOGRAM:return"Data";default:return"X-Axis"}}static getSeriesLabel(t){switch(t){case M.plot.SeriesPlotStyle.PIE:return"Values";default:return"Series"}}static makeSeriesItem(t){return{id:We.generate(),value:t}}static makeDefaultSeriesItems(t,e){if(pt.getMaxSeriesCount(t)===0||e==null||e.length===0)return[];const s=e.length>1?e[1].name:e[0].name;return[pt.makeSeriesItem(s)]}static getDefaultXAxis(t,e){return e!=null&&e.length>0?e[0].name:null}constructor(t){super(t),this.handleAddSeries=this.handleAddSeries.bind(this),this.handleLinkStateChange=this.handleLinkStateChange.bind(this),this.handleReset=this.handleReset.bind(this),this.handleSeriesChange=this.handleSeriesChange.bind(this),this.handleSeriesDeleteClick=this.handleSeriesDeleteClick.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleTypeClick=this.handleTypeClick.bind(this),this.handleXAxisChange=this.handleXAxisChange.bind(this),this.sendChange=this.sendChange.bind(this);const{model:e}=t,{columns:n}=e,s=pt.types[0],i=pt.getDefaultXAxis(s,n),o=pt.makeDefaultSeriesItems(s,n);this.state={type:s,seriesItems:o,xAxis:i,isLinked:!0}}handleAddSeries(){this.setState(t=>{let{seriesItems:e}=t;e=[...e];const{model:n}=this.props,{columns:s}=n;return e.push({id:We.generate(),value:s[0].name}),{seriesItems:e}},this.sendChange)}handleLinkStateChange(t){this.setState({isLinked:t.target.value==="true"},this.sendChange)}handleReset(){const{model:t}=this.props,{columns:e}=t,n=pt.types[0],s=pt.getDefaultXAxis(n,e),i=pt.makeDefaultSeriesItems(n,e),o=!0;this.setState({type:n,seriesItems:i,xAxis:s,isLinked:o},this.sendChange)}handleSeriesChange(t){const{value:e}=t.target,n=t.target.getAttribute("data-index"),s=parseInt(n,10);this.setState(i=>{let{seriesItems:o}=i;return o=[...o],o[s].value=e,{seriesItems:o}},this.sendChange)}handleSeriesDeleteClick(t){const n=t.target.getAttribute("data-index"),s=parseInt(n,10);this.setState(i=>{let{seriesItems:o}=i;return o=[...o],o.splice(s,1),{seriesItems:o}},this.sendChange)}handleSubmit(t){t.preventDefault();const{onSubmit:e}=this.props,{type:n,seriesItems:s,xAxis:i,isLinked:o}=this.state,r=s.map(l=>l.value);e({type:`${n}`,series:r,xAxis:i,isLinked:o})}handleTypeClick(t){const n=t.target.getAttribute("data-index"),s=parseInt(n,10),i=pt.types[s];gh.debug2("handleTypeSelect",i),this.setState(o=>{const r=pt.getMaxSeriesCount(i);let{seriesItems:l}=o;if(l=l.slice(0,r),l.length===0&&r>0){const{model:a}=this.props,{columns:d}=a;l=pt.makeDefaultSeriesItems(i,d)}return{type:i,seriesItems:l}},this.sendChange)}handleXAxisChange(t){const e=t.target.value;gh.debug2("x-axis change",e),this.setState({xAxis:e},this.sendChange)}sendChange(){const{onChange:t}=this.props,{isLinked:e,type:n,seriesItems:s,xAxis:i}=this.state,o=s.map(r=>r.value);t({type:n,series:o,xAxis:i,isLinked:e})}render(){const{model:t}=this.props,{columns:e}=t,{seriesItems:n,type:s,xAxis:i,isLinked:o}=this.state,r=pt.getMaxSeriesCount(s),l=pt.getXAxisLabel(s),a=pt.getSeriesLabel(s),d=n.length>0,c=n.length<r;return h("div",{className:"chart-builder",children:v("form",{onSubmit:this.handleSubmit,children:[v("div",{className:"form-row",children:[h("label",{children:"Select Chart Type"}),h("div",{className:"form-row",children:pt.types.map((u,m)=>{const p=u;return h("div",{className:"col col-chart-type",children:v("button",{type:"button",className:z("btn","btn-icon","btn-chart-type",{active:u===s}),"data-index":m,onClick:this.handleTypeClick,children:[pt.getTypeIcon(u),pt.getTypeName(u)]})},p)})})]}),h("hr",{}),v("div",{className:"form-row form-inline",children:[h("label",{className:"col-2 label-left",children:l}),h("select",{className:"form-control custom-select select-x-axis col",value:i,onChange:this.handleXAxisChange,children:e.map(u=>h("option",{value:u.name,children:u.name},u.name))})]}),d&&h("hr",{}),n.map((u,m)=>v("div",{className:"form-row form-inline form-series-item","data-testid":`form-series-item-${m}`,children:[h("label",{className:"col-2 label-left",children:m===0?a:""}),h("select",{className:"form-control custom-select select-series col",value:u.value,onChange:this.handleSeriesChange,"data-testid":`select-series-item-${m}`,"data-index":m,children:e.map(p=>h("option",{value:p.name,"data-index":m,children:p.name},p.name))}),n.length>1&&h("button",{type:"button",className:"btn btn-link btn-link-icon btn-delete-series ml-2 px-2","data-index":m,"data-testid":`delete-series-${m}`,onClick:this.handleSeriesDeleteClick,children:h(K,{icon:_n})})]},u.id)),c&&v("div",{className:"form-row",children:[h("div",{className:"col-2"}),v("button",{type:"button",className:"btn btn-link btn-add-series mt-1",onClick:this.handleAddSeries,children:[h(K,{icon:Ls}),"Add Series"]})]}),v("div",{className:"form-row chart-builder-link",children:[h("label",{className:"col-2 label-right",children:v("div",{className:"fa-md fa-layers",children:[h(K,{mask:pd,icon:Lo,transform:"right-5 down-5"}),h(K,{icon:o?rd:lC,transform:"grow-2 right-8 down-6"})]})}),v(bl,{onChange:this.handleLinkStateChange,value:`${o}`,children:[h(Mn,{value:"true",children:"Sync State"}),h(Mn,{value:"false",children:"Freeze State"})]})]}),v("div",{className:"form-row",children:[h("div",{className:"col-2 label-right"}),h("div",{className:"col chart-builder-link-info",children:o?"Charts with synced state will update to match any filters or user modifications applied to the parent table.":"Freeze State disconnects the chart state from the parent table. New filters or user modifications on the parent table will not be applied."})]}),v("div",{className:z("form-row","justify-content-end","my-3"),children:[h("button",{type:"button",className:"btn btn-outline-primary btn-reset",onClick:this.handleReset,children:"Reset"}),h("button",{type:"submit",className:"btn btn-primary btn-submit",children:"Create"})]})]})})}};let qm=pt;qm.types=[M.plot.SeriesPlotStyle.LINE,M.plot.SeriesPlotStyle.BAR,M.plot.SeriesPlotStyle.SCATTER,M.plot.SeriesPlotStyle.PIE];class Ym extends S.exports.Component{constructor(e){super(e),this.handleContentChanged=this.handleContentChanged.bind(this),this.handleEditorFocus=this.handleEditorFocus.bind(this),this.handleEditorBlur=this.handleEditorBlur.bind(this),this.handleContainerClick=this.handleContainerClick.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.state={isEditorFocused:!1,isEditorEmpty:!0},this.editorContainer=null}componentDidMount(){this.initEditor()}componentWillUnmount(){this.destroyEditor()}initEditor(){var i;const{value:e,editorSettings:n}=this.props,s={copyWithSyntaxHighlighting:"false",fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:"groovyDB",lineDecorationsWidth:8,lineNumbers:"off",minimap:{enabled:!1},renderLineHighlight:"none",scrollbar:{arrowSize:0,horizontal:"hidden",horizontalScrollbarSize:0},scrollBeyondLastLine:!1,padding:{top:6,bottom:6},tabCompletion:"off",useTabStops:!0,value:e,wordWrap:"on",automaticLayout:!0,...n};if(!this.editorContainer)throw new Error("editorContainer is null");this.editor=as.create(this.editorContainer,s),this.editor.layout(),(i=this.editor.getModel())==null||i.updateOptions({tabSize:0}),this.editor.onDidChangeModelContent(this.handleContentChanged),this.editor.onDidFocusEditorText(this.handleEditorFocus),this.editor.onDidBlurEditorText(this.handleEditorBlur)}destroyEditor(){var e;(e=this.editor)==null||e.dispose(),this.editor=void 0}handleContentChanged(){var s,i;const{onContentChanged:e}=this.props,n=(i=(s=this.editor)==null?void 0:s.getModel())==null?void 0:i.getValue();n!==""&&n!==void 0&&this.setState({isEditorEmpty:n.length===0}),e(n)}handleEditorFocus(){this.setState({isEditorFocused:!0})}handleEditorBlur(){var n,s;const e=(s=(n=this.editor)==null?void 0:n.getModel())==null?void 0:s.getValue();if(e===void 0||e==="")throw new Error("value is undefined");this.setState({isEditorEmpty:e.length===0,isEditorFocused:!1})}handleContainerClick(){var n;const{isEditorFocused:e}=this.state;e||(n=this.editor)==null||n.focus()}handleKeyDown(e){const{onTab:n,editorIndex:s}=this.props;e.key==="Tab"&&n(s,e.shiftKey)}render(){const{value:e,invalid:n}=this.props,{isEditorFocused:s,isEditorEmpty:i}=this.state;return v("div",{className:z("input-editor-wrapper",{focused:s,invalid:n}),onKeyDown:this.handleKeyDown,role:"presentation",onClick:this.handleContainerClick,children:[h("div",{className:"editor-container",ref:o=>{this.editorContainer=o}}),i&&!e&&h("div",{className:"editor-placeholder text-muted",children:"Column Formula"})]})}}Ym.defaultProps={value:"",onContentChanged:()=>{},editorSettings:{},editorIndex:0,onTab:()=>{},invalid:!1};const Ha=class extends S.exports.PureComponent{constructor(t){super(t),this.handleFormulaEditorContentChanged=this.handleFormulaEditorContentChanged.bind(this)}handleFormulaEditorContentChanged(t){const{onChange:e,eventKey:n}=this.props;t!==void 0&&t!==""&&(t.replace(/(\r\n|\n|\r)/gm,""),e(n,Ha.INPUT_TYPE.FORMULA,t))}render(){const{eventKey:t,name:e,formula:n,onChange:s,onDeleteColumn:i,inputIndex:o,onTabInEditor:r,invalid:l}=this.props;return h(dl,{draggableId:t,index:o,disableInteractiveElementBlocking:!0,children:(a,d)=>v("div",{className:z("draggable-container",{dragging:d.isDragging}),ref:a.innerRef,...a.draggableProps,children:[v("div",{className:"custom-column-input-container",children:[v("div",{className:"d-flex flex-row pb-3 custom-column-name",children:[h("input",{className:z("form-control custom-column-input",{"is-invalid":l}),placeholder:"Column Name",value:e,onChange:c=>{s(t,Ha.INPUT_TYPE.NAME,c.target.value)}}),v("button",{type:"button",className:"btn btn-link btn-link-icon ml-1 px-2",onClick:()=>{i(t)},children:[h(Ie,{children:"Delete custom column"}),h(K,{icon:_n})]}),v("button",{type:"button",className:"btn btn-link btn-link-icon px-2 btn-drag-handle",...a.dragHandleProps,children:[h(Ie,{children:"Drag column to re-order"}),h(K,{icon:ul})]})]}),h(Ym,{editorSettings:{language:"deephavenDb"},editorIndex:o,value:n,onContentChanged:this.handleFormulaEditorContentChanged,onTab:r,invalid:l})]}),h("hr",{})]})})}};let kd=Ha;kd.INPUT_TYPE={NAME:"name",FORMULA:"formula"};kd.defaultProps={name:"",inputIndex:0,formula:"",onChange:()=>{},onDeleteColumn:()=>{},onTabInEditor:()=>{},invalid:!1};class Xm extends Error{constructor(){super(...arguments),this.isAssertionFailed=!0}}function fh(t){if(t==null)throw new Xm(`Expected 'val' to be defined, but received ${t}`)}class aa extends Error{constructor(){super(...arguments),this.isPasteError=!0}}function Ze(t){return(t==null?void 0:t.isEditable)!==void 0}function Ch(t){if(!Ze(t))throw new Xm(`Expected 'model' to be editable, but received ${t}`)}function gt(t){return(t==null?void 0:t.hasExpandableRows)!==void 0}var Dn=(t=>(t.DOWN="DOWN",t.UP="UP",t.LEFT="LEFT",t.RIGHT="RIGHT",t))(Dn||{});const ye=class{static normalize(t,e,n,s){let i=t,o=e,r=n,l=s;return i!=null&&r!=null&&r<i&&(i=r,r=t),o!=null&&l!=null&&l<o&&(o=l,l=e),[i,o,r,l]}static makeNormalized(t,e,n,s){return new ye(...ye.normalize(t,e,n,s))}static makeCell(t,e){return new ye(t,e,t,e)}static makeColumn(t){return new ye(t,null,t,null)}static makeRow(t){return new ye(null,t,null,t)}static minOrNull(t,e){return t==null||e==null?null:Math.min(t,e)}static maxOrNull(t,e){return t==null||e==null?null:Math.max(t,e)}static consolidate(t){const e=t.slice();let n=!0;for(;n;){n=!1;for(let s=0;s<e.length&&!n;s+=1){const i=e[s];for(let o=e.length-1;o>s;o-=1){const r=e[o];if(i.contains(r))e.splice(o,1);else if(r.contains(i)){n=!0,e[s]=r,e.splice(o,1);break}else if(i.startRow===r.startRow&&i.endRow===r.endRow){if(i.touches(r)){const{startRow:l,endRow:a}=i,d=ye.minOrNull(i.startColumn,r.startColumn),c=ye.maxOrNull(i.endColumn,r.endColumn);n=!0,e[s]=new ye(d,l,c,a),e.splice(o,1);break}}else if(i.startColumn===r.startColumn&&i.endColumn===r.endColumn&&i.touches(r)){const{startColumn:l,endColumn:a}=i,d=ye.minOrNull(i.startRow,r.startRow),c=ye.maxOrNull(i.endRow,r.endRow);n=!0,e[s]=new ye(l,d,a,c),e.splice(o,1);break}}}}return e}static isAxisRangeTouching(t,e,n,s){return t==null?e==null||n==null?!0:n<=e+1:e==null?s==null?!0:s>=t-1:n==null?s==null?!0:t<=s+1:s==null?e>=n-1:n>=t-1?n<=e+1:s>=t-1}static rangeArraysEqual(t,e){if(t===e)return!0;if(t==null||e==null||t.length!==e.length)return!1;for(let n=0;n<t.length;n+=1)if(!t[n].equals(e[n]))return!1;return!0}static intersection(t,e){if(t.equals(e))return t;let{startColumn:n,startRow:s,endColumn:i,endRow:o}=t;return n=n!=null&&e.startColumn!=null?Math.max(n,e.startColumn):n!=null?n:e.startColumn,i=i!=null&&e.endColumn!=null?Math.min(i,e.endColumn):i!=null?i:e.endColumn,s=s!=null&&e.startRow!=null?Math.max(s,e.startRow):s!=null?s:e.startRow,o=o!=null&&e.endRow!=null?Math.min(o,e.endRow):o!=null?o:e.endRow,n!=null&&n>(i!=null?i:-1)||s!=null&&s>(o!=null?o:-1)?null:new ye(n,s,i,o)}static subtractFromRange(t,e){const n=[],s=ye.intersection(t,e);return s==null?[t]:(s.startRow!=null&&(t.startRow==null||t.startRow<s.startRow)&&n.push(new ye(t.startColumn,t.startRow,t.endColumn,s.startRow-1)),s.startColumn!=null&&(t.startColumn==null||t.startColumn<s.startColumn)&&n.push(new ye(t.startColumn,s.startRow,s.startColumn-1,s.endRow)),s.endColumn!=null&&(t.endColumn==null||t.endColumn>s.endColumn)&&n.push(new ye(s.endColumn+1,s.startRow,t.endColumn,s.endRow)),s.endRow!=null&&(t.endRow==null||t.endRow>s.endRow)&&n.push(new ye(t.startColumn,s.endRow+1,t.endColumn,t.endRow)),n)}static subtractFromRanges(t,e){const n=[];for(let s=0;s<t.length;s+=1)n.push(...ye.subtractFromRange(t[s],e));return n}static subtractRangesFromRanges(t,e){if(e==null||e.length===0)return t;let n=[...t];for(let s=0;s<e.length;s+=1)n=ye.subtractFromRanges(n,e[s]);return n}static isBounded(t){return t.startRow!=null&&t.startColumn!=null&&t.endRow!=null&&t.endColumn!=null}static boundedRange(t,e,n){var s,i,o,r;return ye.isBounded(t)?t:new ye((s=t.startColumn)!=null?s:0,(i=t.startRow)!=null?i:0,(o=t.endColumn)!=null?o:e-1,(r=t.endRow)!=null?r:n-1)}static boundedRanges(t,e,n){return t.map(s=>ye.boundedRange(s,e,n))}static offset(t,e,n){return new ye(t.startColumn!=null?t.startColumn+e:null,t.startRow!=null?t.startRow+n:null,t.endColumn!=null?t.endColumn+e:null,t.endRow!=null?t.endRow+n:null)}static nextCell(t,e=null,n=null,s=ye.SELECTION_DIRECTION.DOWN){if(t.length===0)return null;let i=-1;if(e!=null&&n!=null&&(i=t.findIndex(o=>o.containsCell(e,n)),i>=0)){const r=t[i].nextCell(e,n,s);if(r!=null)return r}switch(s){case ye.SELECTION_DIRECTION.DOWN:case ye.SELECTION_DIRECTION.RIGHT:{const o=i<t.length-1?i+1:0;return t[o].startCell(s)}case ye.SELECTION_DIRECTION.LEFT:case ye.SELECTION_DIRECTION.UP:{const o=i>0?i-1:t.length-1;return t[o].startCell(s)}default:throw new Error(`Invalid direction: ${s}`)}}static cellCount(t){return t.reduce((e,n)=>{var s,i,o,r;return e+(((s=n.endRow)!=null?s:NaN)-((i=n.startRow)!=null?i:NaN)+1)*(((o=n.endColumn)!=null?o:NaN)-((r=n.startColumn)!=null?r:NaN)+1)},0)}static rowCount(t){return t.reduce((e,n)=>{var s,i;return e+((s=n.endRow)!=null?s:NaN)-((i=n.startRow)!=null?i:NaN)+1},0)}static columnCount(t){return t.reduce((e,n)=>{var s,i;return e+((s=n.endColumn)!=null?s:NaN)-((i=n.startColumn)!=null?i:NaN)+1},0)}static containsCell(t,e,n){for(let s=0;s<t.length;s+=1)if(t[s].containsCell(e,n))return!0;return!1}static forEachCell(t,e,n=ye.SELECTION_DIRECTION.RIGHT){for(let s=0;s<t.length;s+=1)t[s].forEach(e,n)}constructor(t,e,n,s){this.startColumn=t,this.startRow=e,this.endColumn=n,this.endRow=s}equals(t){return this.startColumn===t.startColumn&&this.startRow===t.startRow&&this.endColumn===t.endColumn&&this.endRow===t.endRow}contains(t){return(this.startColumn==null||t.startColumn!=null&&this.startColumn<=t.startColumn)&&(this.startRow==null||t.startRow!=null&&this.startRow<=t.startRow)&&(this.endColumn==null||t.endColumn!=null&&this.endColumn>=t.endColumn)&&(this.endRow==null||t.endRow!=null&&this.endRow>=t.endRow)}containsCell(t,e){return t==null||e==null?!1:(this.startColumn==null||this.startColumn<=t)&&(this.endColumn==null||this.endColumn>=t)&&(this.startRow==null||this.startRow<=e)&&(this.endRow==null||this.endRow>=e)}touches(t){return ye.isAxisRangeTouching(this.startRow,this.endRow,t.startRow,t.endRow)&&ye.isAxisRangeTouching(this.startColumn,this.endColumn,t.startColumn,t.endColumn)}subtract(t){return ye.subtractFromRange(this,t)}startCell(t=ye.SELECTION_DIRECTION.DOWN){if(!ye.isBounded(this))throw new Error("Cannot get the startCell of an unbounded range");switch(t){case ye.SELECTION_DIRECTION.DOWN:case ye.SELECTION_DIRECTION.RIGHT:return{column:this.startColumn,row:this.startRow};case ye.SELECTION_DIRECTION.LEFT:case ye.SELECTION_DIRECTION.UP:return{column:this.endColumn,row:this.endRow};default:throw new Error(`Invalid direction: ${t}`)}}nextCell(t,e,n){if(!ye.isBounded(this))throw new Error("Bounded range required");if(t==null||e==null)throw new Error("Require a non-null cursor");const{startColumn:s,endColumn:i,startRow:o,endRow:r}=this;switch(n){case ye.SELECTION_DIRECTION.DOWN:if(e<r)return{column:t,row:Math.max(e+1,o)};if(t<i)return{column:Math.max(t+1,s),row:o};break;case ye.SELECTION_DIRECTION.UP:if(e>o)return{column:t,row:Math.min(e-1,r)};if(t>s)return{column:Math.min(t-1,i),row:r};break;case ye.SELECTION_DIRECTION.RIGHT:if(t<i)return{column:Math.max(t+1,s),row:e};if(e<r)return{column:s,row:Math.max(e+1,o)};break;case ye.SELECTION_DIRECTION.LEFT:if(t>s)return{column:Math.min(t-1,i),row:e};if(e>o)return{column:i,row:Math.min(e-1,r)};break;default:throw new Error(`Invalid direction: ${n}`)}return null}forEach(t,e=ye.SELECTION_DIRECTION.RIGHT){var o;let n=0,{column:s,row:i}=this.startCell(e);for(;s!=null&&i!=null;)t(s,i,n),n+=1,{column:s,row:i}=(o=this.nextCell(s,i,e))!=null?o:{}}};let re=ye;re.SELECTION_DIRECTION=Dn;function k0(t){return Array.isArray(t)&&t.length===2&&(t[0]===null||typeof t[0]=="number")&&(t[1]===null||typeof t[1]=="number")}function da(t){return k0(t)&&t[0]!=null&&t[1]!=null}const Fe=class{static getGridPointFromXY(t,e,n){const s=Fe.getColumnAtX(t,n),i=Fe.getRowAtY(e,n),o=Fe.getColumnHeaderDepthAtY(e,n);return{x:t,y:e,row:i,column:s,columnHeaderDepth:o}}static getCellInfoFromXY(t,e,n){const{row:s,column:i}=Fe.getGridPointFromXY(t,e,n),{visibleColumnWidths:o,visibleRowHeights:r,visibleColumnXs:l,visibleRowYs:a,modelColumns:d,modelRows:c}=n,u=s!==null?c.get(s):null,m=i!==null?d.get(i):null,p=i!==null?l.get(i):null,g=s!==null?a.get(s):null,f=i!==null?o.get(i):null,b=s!==null?r.get(s):null;return{row:s,column:i,modelRow:u!=null?u:null,modelColumn:m!=null?m:null,left:p!=null?p:null,top:g!=null?g:null,columnWidth:f!=null?f:null,rowHeight:b!=null?b:null}}static getColumnHeaderDepthAtY(t,e){const n=Fe.getRowAtY(t,e),{columnHeaderHeight:s,columnHeaderMaxDepth:i}=e;if(n===null&&t<=s*i)return At(i-Math.ceil(t/s),0,i-1)}static iterateFloatingStart(t,e,n){for(let s=0;s<t&&s<e;s+=1){const i=n(s);if(i!==void 0)return i}}static iterateFloatingEnd(t,e,n){for(let s=0;s<t&&e-(t-s)>=0;s+=1){const i=n(e-(t-s));if(i!==void 0)return i}}static iterateFloating(t,e,n,s){const i=Fe.iterateFloatingStart(t,n,s);return i!==void 0?i:Fe.iterateFloatingEnd(e,n,s)}static iterateAllItems(t,e,n,s,i,o){const r=Math.max(t,n),l=Math.min(e,i-s-1);let a=Fe.iterateFloating(n,s,i,o);if(a!==void 0)return a;for(let d=r;d<=l;d+=1)if(a=o(d),a!==void 0)return a}static isInItem(t,e,n,s){var r,l;const i=(r=e.get(t))!=null?r:0,o=(l=n.get(t))!=null?l:0;return i<=s&&s<=i+o}static getItemAtOffset(t,e,n,s,i,o,r,l=!1){const a=l?void 0:Fe.iterateFloating(n,s,e,d=>{if(Fe.isInItem(d,o,r,t))return d});if(!l&&a!==void 0)return a;for(let d=0;d<i.length;d+=1){const c=i[d];if(Fe.isInItem(c,o,r,t))return c}return null}static getColumnAtX(t,e,n=!1){const{columnCount:s,floatingLeftColumnCount:i,floatingRightColumnCount:o,visibleColumns:r,visibleColumnXs:l,visibleColumnWidths:a,gridX:d}=e;return t<d?null:this.getItemAtOffset(t-d,s,i,o,r,l,a,n)}static getRowAtY(t,e){const{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:i,visibleRows:o,visibleRowYs:r,visibleRowHeights:l,gridY:a}=e;return t<a?null:this.getItemAtOffset(t-a,i,n,s,o,r,l)}static getNextShownItem(t,e,n,s){let i=n.findIndex(o=>o===t)||0;for(i-=1;i!=null&&i>=0;){const o=n[i],r=e.get(o);if(r!=null&&s.get(r)!==0)return o;i-=1}return null}static getNextShownColumn(t,e){const{modelColumns:n,visibleColumns:s,userColumnWidths:i}=e;return Fe.getNextShownItem(t,n,s,i)}static getNextShownRow(t,e){const{modelRows:n,visibleRows:s,userRowHeights:i}=e;return Fe.getNextShownItem(t,n,s,i)}static getColumnSeparatorIndex(t,e,n,s){var C,w,T,y;const{rowHeaderWidth:i,columnHeaderHeight:o,floatingColumns:r,floatingLeftWidth:l,visibleColumns:a,visibleColumnXs:d,visibleColumnWidths:c,columnHeaderMaxDepth:u}=n,{allowColumnResize:m,headerSeparatorHandleSize:p}=s;if(u*o<e||!m||p<=0)return null;const g=t-i,f=p*.5;let b=!1;for(let E=r.length-1;E>=0;E-=1){const I=r[E],R=(C=d.get(I))!=null?C:0,F=(w=c.get(I))!=null?w:0,x=F===0;if(!b||!x){let U=R+F;x?U+=f:b&&(U-=f);const $=U-f,O=U+f;if($<=g&&g<=O)return I;b=x}}b=!1;for(let E=a.length-1;E>=0;E-=1){const I=a[E],R=(T=d.get(I))!=null?T:0,F=(y=c.get(I))!=null?y:0,x=F===0;if(R<l-F)return null;if(!b||!x){let U=R+F;x?U+=f:b&&(U-=f);const $=U-f,O=U+f;if($<=g&&g<=O)return I;b=x}}return null}static isItemHidden(t,e){return e.get(t)===0}static isColumnHidden(t,e){const{visibleColumnWidths:n}=e;return Fe.isItemHidden(t,n)}static isFloatingRow(t,e){if(t==null)return!1;const{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:i}=e;return t<n||t>=i-s}static isFloatingColumn(t,e){if(t==null)return!1;const{floatingLeftColumnCount:n,floatingRightColumnCount:s,columnCount:i}=e;return t<n||t>=i-s}static getHiddenItems(t,e,n){if(!Fe.isItemHidden(t,e))return[];const s=[t],i=n.findIndex(o=>o===t);for(let o=i-1;o>=0;o-=1){const r=n[o];if(!Fe.isItemHidden(r,e))break;s.push(r)}return s}static getHiddenColumns(t,e){const{visibleColumns:n,visibleColumnWidths:s}=e;return Fe.getHiddenItems(t,s,n)}static getRowSeparatorIndex(t,e,n,s){var g,f;const{rowHeaderWidth:i,columnHeaderHeight:o,visibleRows:r,visibleRowYs:l,visibleRowHeights:a}=n,{allowRowResize:d,headerSeparatorHandleSize:c}=s;if(i<t||!d||c<=0)return null;const u=e-o,m=c*.5;let p=!1;for(let b=r.length-1;b>=0;b-=1){const C=r[b],w=(g=l.get(C))!=null?g:0,T=(f=a.get(C))!=null?f:0,y=T===0;if(!p||!y){let E=w+T;y?E+=m:p&&(E-=m);const I=E-m,R=E+m;if(I<=u&&u<=R)return C;p=y}}return null}static isRowHidden(t,e){const{visibleRowHeights:n}=e;return Fe.isItemHidden(t,n)}static getHiddenRows(t,e){const{visibleRows:n,visibleRowHeights:s}=e;return Fe.getHiddenItems(t,s,n)}static moveItem(t,e,n){if(t===e)return n;const s=[...n],i=s[s.length-1];return i!=null&&!da(i.from)&&i.to===t?i.from===e?s.pop():s[s.length-1]={...i,to:e}:s.push({from:t,to:e}),s}static moveRange(t,e,n){if(t[0]===e)return n;const s=[...n],i=s[s.length-1];return i!=null&&da(i.from)&&i.from[1]-i.from[0]===t[1]-t[0]&&i.to===t[0]?i.from[0]===e?s.pop():s[s.length-1]={...i,to:e}:s.push({from:t,to:e}),s[s.length-1].from===s[s.length-1].to&&s.pop(),s}static applyItemMoves(t,e,n,s=!1){var o,r;let i=[[t,e]];for(let l=s?n.length-1:0;s?l>=0:l<n.length;s?l-=1:l+=1){const{from:a,to:d}=n[l];let c=1,u;da(a)?(c=a[1]-a[0]+1,[u]=a):u=a;const m=s?d:u,p=m+c-1,g=s?u:d,f=g-m,b=[];for(let C=0;C<i.length;C+=1){const w=(o=i[C][0])!=null?o:Number.NEGATIVE_INFINITY,T=(r=i[C][1])!=null?r:Number.POSITIVE_INFINITY;let y;const E=[[w,m-1],[m,p],[p+1,T]].map(([I,R])=>[Math.max(I,w),Math.min(R,T)]).filter(([I,R])=>I<=R).map(I=>{const[R,F]=I;return m<=R&&p>=F?(y=[R+f,F+f],y):p<R?[R-c,F-c]:I}).map(I=>{const[R,F]=I;return g>R&&g<=F?[[R,g-1],[g+c,F+c]]:I===y?[I]:g<=R?[[R+c,F+c]]:[I]}).flat();b.push(...E)}i=b.map(([C,w])=>[Number.isFinite(C)?C:null,Number.isFinite(w)?w:null])}return i}static translateRange(t,e,n,s){const i=Fe.applyItemMoves(t.startColumn,t.endColumn,e,s),o=Fe.applyItemMoves(t.startRow,t.endRow,n,s),r=[];for(let l=0;l<i.length;l+=1){const a=i[l];for(let d=0;d<o.length;d+=1){const c=o[d];r.push(new re(a[0],c[0],a[1],c[1]))}}return r}static getModelIndex(t,e){return Fe.applyItemMoves(t,t,e,!0)[0][0]}static getModelIndexes(t,e){return t.map(n=>Fe.getModelIndex(n,e))}static getModelRangeIndexes(t,e,n){return Fe.applyItemMoves(t,e,n,!0)}static getModelRange(t,e=[],n=[]){return Fe.translateRange(t,e,n,!0)}static getModelRanges(t,e=[],n=[]){const s=[];for(let i=0;i<t.length;i+=1)s.push(...Fe.getModelRange(t[i],e,n));return s}static getVisibleRangeIndexes(t,e,n){return Fe.applyItemMoves(t,e,n,!1)}static getVisibleRange(t,e=[],n=[]){return this.translateRange(t,e,n,!1)}static getVisibleRanges(t,e=[],n=[]){const s=[];for(let i=0;i<t.length;i+=1)s.push(...Fe.getVisibleRange(t[i],e,n));return s}static getVisibleIndex(t,e){return Fe.applyItemMoves(t,t,e)[0][0]}static getVisibleIndexes(t,e){return t.map(n=>Fe.getVisibleIndex(n,e))}static isMacPlatform(){const{platform:t}=window.navigator;return t.startsWith("Mac")}static getModifierKey(){return Fe.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(t){const e=Fe.getModifierKey();return t[e]}static checkColumnHidden(t,e){return e.get(t)===0}static checkAllColumnsHidden(t,e){return e.size===0?!1:t.every(n=>e.get(n)===0)}static getScrollDragBounds(t,e,n){const{gridX:s,gridY:i,width:o,height:r,floatingTopRowCount:l,floatingBottomRowCount:a,floatingLeftColumnCount:d,floatingRightColumnCount:c,floatingLeftWidth:u,floatingRightWidth:m,floatingTopHeight:p,floatingBottomHeight:g,columnCount:f,rowCount:b}=t;let C=s,w=i,T=o,y=r;return n!=null&&(n>d&&(C+=u),n<f-c&&(T-=m)),e!=null&&(e>l&&(w+=p),e<b-a&&(y-=g)),{x1:C,y1:w,x2:T,y2:y}}static getScrollDelta(t,e=1024,n=768,s=20,i=20){let{deltaX:o,deltaY:r}=t;return!Fe.isMacPlatform()&&t.shiftKey&&t.deltaX===0&&t.deltaY!==0&&(o=t.deltaY,r=t.deltaX),(t==null?void 0:t.deltaMode)===WheelEvent.DOM_DELTA_PAGE?(o*=e,r*=n):(t==null?void 0:t.deltaMode)===WheelEvent.DOM_DELTA_LINE&&(Fe.isMacPlatform()?(o=Math.round(o*s),r=Math.round(r*i)):(o=Math.round(o*this.PIXELS_PER_LINE),r=Math.round(r*this.PIXELS_PER_LINE))),{deltaX:o,deltaY:r}}static compareRanges(t,e){return t[0]==null||t[1]==null||e[0]==null||e[1]==null?0:t[0]!==e[0]?t[0]-e[0]:t[1]-e[1]}static mergeSortedRanges(t){const e=[];for(let n=0;n<t.length;n+=1){const s=t[n],i=s[0],o=s[1];n===0?e.push([i,o]):i-1<=e[e.length-1][1]?e[e.length-1][1]=Math.max(e[e.length-1][1],o):e.push([i,o])}return e}};let G=Fe;G.PIXELS_PER_LINE=100/3;function B(t,e,n=void 0){var i;const s=(i=t.get(e))!=null?i:n;if(s!==void 0)return s;throw new Error(`Missing value for key ${e}`)}function wr(t,e=qo.CACHE_SIZE,n=Math.floor(e/2)){if(t.size>e){const s=t.keys();for(;t.size>n;)t.delete(s.next().value)}}function bh(t,e,n,s,i){const o=new Map;let r=0;for(let l=0;l<t&&l<n;l+=1)o.set(l,r),r+=B(i,l);r=s;for(let l=0;l<e&&n-l-1>=0;l+=1)r-=B(i,n-l-1),o.set(n-l-1,r);return o}const jm=class{constructor({userColumnWidths:t=new Map,userRowHeights:e=new Map,calculatedColumnWidths:n=new Map,calculatedRowHeights:s=new Map,fontWidths:i=new Map,modelRows:o=new Map,modelColumns:r=new Map,movedRows:l=[],movedColumns:a=[]}={}){this.userColumnWidths=t,this.userRowHeights=e,this.calculatedRowHeights=s,this.calculatedColumnWidths=n,this.fontWidths=i,this.modelRows=o,this.modelColumns=r,this.movedRows=l,this.movedColumns=a}getMetrics(t){const{left:e,top:n,leftOffset:s,topOffset:i,width:o,height:r,theme:l,model:a,movedRows:d,movedColumns:c,draggingColumn:u}=t,{rowHeight:m,rowHeaderWidth:p,rowFooterWidth:g,columnWidth:f,columnHeaderHeight:b,minScrollHandleSize:C,scrollBarSize:w}=l;d!==this.movedRows&&(this.movedRows=d,this.modelRows.clear()),c!==this.movedColumns&&(this.movedColumns=c,this.modelColumns.clear());const{columnCount:T,rowCount:y,floatingTopRowCount:E,floatingBottomRowCount:I,floatingLeftColumnCount:R,floatingRightColumnCount:F,columnHeaderMaxDepth:x}=a,U=this.getFirstRow(t),$=this.getFirstColumn(t),O=this.getGridX(t),H=this.getGridY(t),L=gt(a)&&a.hasExpandableRows?this.calculateTreePaddingX(t):0,N=0;let _=this.getVisibleRowHeights(t),k=this.getVisibleColumnWidths(t,$,L);const V=Array.from(_.keys()),W=Array.from(k.keys());_=new Map([..._,...this.getFloatingRowHeights(t)]),k=new Map([...k,...this.getFloatingColumnWidths(t)]);let j=this.getVisibleColumnXs(k,W,s),ee=this.getVisibleRowYs(_,V,i);const ve=V.length>0?V[V.length-1]:n,le=W.length>0?W[W.length-1]:e,Se=this.getBottomViewport(t,V,ee,_),Le=this.getRightViewport(t,W,j,k),J=this.getFloatingTopHeight(t,_),pe=this.getFloatingBottomHeight(t,_),fe=this.getFloatingLeftWidth(t,k),xe=this.getFloatingRightWidth(t,k),ke=Array.from(k.values()),hn=Array.from(_.values()),Xn=ke.reduce((ut,Si)=>ut+Si,0)-s,Sn=hn.reduce((ut,Si)=>ut+Si,0)-i,Ct=this.getLastLeft(t,null,o-O-w-g),Re=this.getLastTop(t,null,r-H-w-pe),st=s+Xn+g,it=i+Sn,Mt=o-O,Yt=r-H,Xt=Ct>0||st>Mt,Nt=Xt?w:0,On=Re>0||it>Yt-Nt,Ht=On?w:0,wn=o-p-Ht,Ps=r-b-Nt,zl=p,Wl=b,Gl=T===1?wn/st:(T-Ct)/T,Zo=y===1?Ps/it:(y-Re)/y,Jo=Xt?At(wn*Gl,C,wn-1):0,er=On?At(Ps*Zo,C,Ps-1):0,tr=B(k,e,0),nr=B(_,n,0),sr=tr>0?s/tr:0,ir=nr>0?i/nr:0,Kl=T===1?s/(st-Mt):(e+sr)/Ct,ql=y===1?i/(it-Yt):(n+ir)/Re,Hs=Xt?Kl*(wn-Jo):0,Yl=On?ql*(Ps-er):0;let bi=[];(E>0||I>0)&&(bi=[...Array(E).keys(),...[...Array(I).keys()].map(ut=>y-ut-1)],ee=new Map([...ee,...this.getFloatingRowYs(t,_,Math.floor(r-H-Nt))]));let oo=[];(R>0||F>0)&&(oo=[...Array(R).keys(),...[...Array(F).keys()].map(ut=>T-ut-1)],j=new Map([...j,...this.getFloatingColumnXs(t,k,Math.floor(o-O-Ht))]));const or=[];if(u)for(let ut=u.range[0];ut<=u.range[1];ut+=1)or.push(ut),k.has(ut)||k.set(ut,this.getVisibleColumnWidth(ut,t)),j.has(ut)||j.set(ut,0);const rr=V.concat(bi),ro=W.concat(oo).concat(or),lo=this.getModelRows(rr,t),Xl=this.getModelColumns(ro,t),jl=this.getVisibleRowTreeBoxes(_,lo,t),lr=this.getTopVisible(t,ee,_,V),Ql=this.getLeftVisible(t,j,k,W),ar=Re>0?this.getBottomVisible(t,ee,_,V,H):ve,dr=Ct>0?this.getRightVisible(t,j,k,W,O):le,{fontWidths:cr,userColumnWidths:hr,userRowHeights:ur,calculatedRowHeights:Zl,calculatedColumnWidths:Jl}=this;return{rowHeight:m,rowHeaderWidth:p,rowFooterWidth:g,rowCount:y,columnWidth:f,columnCount:T,columnHeaderHeight:b,floatingTopRowCount:E,floatingBottomRowCount:I,floatingLeftColumnCount:R,floatingRightColumnCount:F,gridX:O,gridY:H,firstRow:U,firstColumn:$,treePaddingX:L,treePaddingY:N,left:e,top:n,bottom:ve,right:le,topOffset:i,leftOffset:s,topVisible:lr,leftVisible:Ql,bottomVisible:ar,rightVisible:dr,bottomViewport:Se,rightViewport:Le,width:o,height:r,maxX:Xn,maxY:Sn,lastLeft:Ct,lastTop:Re,barHeight:Ps,barTop:Wl,barWidth:wn,barLeft:zl,handleHeight:er,handleWidth:Jo,hasHorizontalBar:Xt,hasVerticalBar:On,verticalBarWidth:Ht,horizontalBarHeight:Nt,scrollX:Hs,scrollY:Yl,scrollableContentWidth:st,scrollableContentHeight:it,scrollableViewportWidth:Mt,scrollableViewportHeight:Yt,visibleRows:V,visibleColumns:W,floatingRows:bi,floatingColumns:oo,allRows:rr,allColumns:ro,visibleRowHeights:_,visibleColumnWidths:k,floatingTopHeight:J,floatingBottomHeight:pe,floatingLeftWidth:fe,floatingRightWidth:xe,visibleRowYs:ee,visibleColumnXs:j,visibleRowTreeBoxes:jl,modelRows:lo,modelColumns:Xl,movedRows:d,movedColumns:c,fontWidths:cr,userColumnWidths:hr,userRowHeights:ur,calculatedRowHeights:Zl,calculatedColumnWidths:Jl,columnHeaderMaxDepth:x}}getGridX(t){const{theme:e}=t,{rowHeaderWidth:n}=e;return n}getGridY(t){const{theme:e,model:n}=t,{columnHeaderHeight:s}=e,{columnHeaderMaxDepth:i}=n;return i*s}getVisibleHeight(t,e=this.getFloatingRowHeights(t)){const{height:n,theme:s}=t,{scrollBarSize:i}=s,o=this.getGridY(t),r=this.getFloatingBottomHeight(t,e),l=this.getFloatingTopHeight(t,e);return n-r-l-o-i}getVisibleWidth(t,e=this.getFloatingColumnWidths(t)){const{width:n,theme:s}=t,{scrollBarSize:i,rowFooterWidth:o}=s,r=this.getGridX(t),l=this.getFloatingRightWidth(t,e),a=this.getFloatingLeftWidth(t,e);return n-a-l-r-i-o}getFirstIndex(t,e,n){const s=t.size+1;for(let i=0;i<s;i+=1){const o=e(i,n);if(t.get(o)!==0)return i}return 0}getFirstColumn(t){return this.getFirstIndex(this.userColumnWidths,this.getModelColumn.bind(this),t)}getFirstRow(t){return this.getFirstIndex(this.userRowHeights,this.getModelRow.bind(this),t)}getLastLeft(t,e=null,n=this.getVisibleWidth(t)){const{model:s}=t,{columnCount:i}=s;let o=i-1;e!=null&&(o=e);let r=0;for(;o>=0;){if(r+=this.getVisibleColumnWidth(o,t),r>=n)return Math.min(o+1,i-1);o-=1}return 0}getLastTop(t,e=null,n=this.getVisibleHeight(t)){const{model:s}=t,{rowCount:i,floatingBottomRowCount:o}=s;let r=Math.max(0,i-o-1);e!=null&&(r=e);let l=0;for(;r>0;){if(l+=this.getVisibleRowHeight(r,t),l>=n)return Math.min(r+1,i-1);r-=1}return 0}getTopForTopVisible(t,e){const n=this.getFloatingTopHeight(t);let s=e,i=0;for(;s>0&&i<n;)s-=1,i+=this.getVisibleRowHeight(s,t);return s}getTopForBottomVisible(t,e){const{height:n}=t,s=this.getGridY(t),i=this.getFloatingBottomHeight(t),o=n-s-i;return this.getLastTop(t,e,o)}getLeftForLeftVisible(t,e){const n=this.getFloatingLeftWidth(t);let s=e,i=0;for(;s>0&&i<n;)s-=1,i+=this.getVisibleColumnWidth(s,t);return s}getLeftForRightVisible(t,e){const{width:n}=t,s=this.getGridX(t),i=this.getFloatingRightWidth(t),o=n-s-i;return this.getLastLeft(t,e,o)}getFloatingRowHeights(t){const{model:e}=t,{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:i}=e,o=new Map;for(let r=0;r<n&&r<i;r+=1)o.set(r,this.getVisibleRowHeight(r,t));for(let r=0;r<s&&i-r-1>=0;r+=1){const l=i-r-1;o.set(l,this.getVisibleRowHeight(l,t))}return o}getVisibleRowHeights(t){const{top:e,topOffset:n,height:s,model:i}=t;let o=0,r=e;const l=new Map,{rowCount:a}=i;for(;o<s+n&&r<a;){const d=this.getVisibleRowHeight(r,t);l.set(r,d),o+=d,r+=1}return l}getFloatingColumnWidths(t,e=this.getFirstColumn(t),n=this.calculateTreePaddingX(t)){const{model:s}=t,{columnCount:i,floatingLeftColumnCount:o,floatingRightColumnCount:r}=s,l=new Map;for(let a=0;a<o&&a<i;a+=1)l.set(a,this.getVisibleColumnWidth(a,t,e,n));for(let a=0;a<r&&i-a-1>=0;a+=1){const d=i-a-1;l.set(d,this.getVisibleColumnWidth(d,t,e,n))}return l}getVisibleColumnWidths(t,e=this.getFirstColumn(t),n=this.calculateTreePaddingX(t)){const{left:s,leftOffset:i,width:o,model:r}=t;let l=0,a=s;const d=new Map,{columnCount:c}=r;for(;l<o+i&&a<c;){const u=this.getVisibleColumnWidth(a,t,e,n);d.set(a,u),l+=u,a+=1}return d}getFloatingColumnXs(t,e,n){const{model:s}=t,{columnCount:i,floatingLeftColumnCount:o,floatingRightColumnCount:r}=s;return bh(o,r,i,n,e)}getVisibleColumnXs(t,e,n){const s=new Map;let i=-n;for(let o=0;o<e.length;o+=1){const r=e[o],l=B(t,r);s.set(r,i),i+=l}return s}getFloatingRowYs(t,e,n){const{model:s}=t,{floatingTopRowCount:i,floatingBottomRowCount:o,rowCount:r}=s;return bh(i,o,r,n,e)}getVisibleRowYs(t,e,n){const s=new Map;let i=-n;for(let o=0;o<e.length;o+=1){const r=e[o],l=B(t,r);s.set(r,i),i+=l}return s}getVisibleRowTreeBoxes(t,e,n){const s=new Map,{model:i,theme:o}=n,{treeDepthIndent:r,treeHorizontalPadding:l}=o;return gt(i)&&i.hasExpandableRows&&t.forEach((a,d)=>{const c=B(e,d);if(i.isRowExpandable(c)){const u=i.depthForRow(c),m=u*r+l,p=(u+1)*r+l,g=0,f=a;s.set(d,{x1:m,y1:g,x2:p,y2:f})}}),s}getFloatingLeftWidth(t,e=this.getFloatingColumnWidths(t)){const{model:n}=t,{floatingLeftColumnCount:s}=n;let i=0;for(let o=0;o<s;o+=1)i+=B(e,o);return i}getFloatingRightWidth(t,e=this.getFloatingColumnWidths(t)){const{model:n}=t,{floatingRightColumnCount:s,columnCount:i}=n;let o=0;for(let r=0;r<s;r+=1)o+=B(e,i-r-1);return o}getFloatingTopHeight(t,e=this.getFloatingRowHeights(t)){const{model:n}=t,{floatingTopRowCount:s}=n;let i=0;for(let o=0;o<s;o+=1)i+=B(e,o);return i}getFloatingBottomHeight(t,e=this.getFloatingRowHeights(t)){const{model:n}=t,{floatingBottomRowCount:s,rowCount:i}=n;let o=0;for(let r=0;r<s;r+=1)o+=B(e,i-r-1);return o}getTopVisible(t,e,n,s){const i=this.getFloatingTopHeight(t,n);for(let o=0;o<s.length;o+=1){const r=s[o];if(B(e,r)>=i)return r}return 0}getLeftVisible(t,e,n,s){const i=this.getFloatingLeftWidth(t,n);for(let o=0;o<s.length;o+=1){const r=s[o];if(B(e,r)>=i)return r}return 0}getBottomVisible(t,e,n,s,i){const{height:o,theme:r}=t,{scrollBarSize:l}=r,a=this.getFloatingBottomHeight(t,n),d=o-i-l-a;for(let c=s.length-1;c>=0;c-=1){const u=s[c],m=B(e,u),p=B(n,u);if(m+p<=d)return u}return 0}getRightVisible(t,e,n,s,i){const{width:o,theme:r}=t,{scrollBarSize:l}=r,a=this.getFloatingRightWidth(t,n),d=o-i-l-a;for(let c=s.length-1;c>=0;c-=1){const u=s[c],m=B(e,u),p=B(n,u);if(m+p<=d)return u}return 0}getBottomViewport(t,e,n,s){const{height:i,theme:o}=t,{rowHeight:r}=o;return this.getLastIndexViewport(e,n,s,i,r)}getRightViewport(t,e,n,s){const{width:i,theme:o}=t,{columnWidth:r}=o;return this.getLastIndexViewport(e,n,s,i,r)}getLastIndexViewport(t,e,n,s,i){let o=0,r=0;return t.length>0&&(o=t[t.length-1],r=B(e,o)+B(n,o)),r<s&&(o+=Math.ceil((s-r)/i)),o}getVisibleItemSize(t,e,n){var i;const s=n();return(i=e.get(t))!=null?i:s}getVisibleRowHeight(t,e){const n=this.getModelRow(t,e);return this.getVisibleItemSize(n,this.userRowHeights,()=>this.calculateRowHeight(t,n,e))}getVisibleColumnWidth(t,e,n=this.getFirstColumn(e),s=this.calculateTreePaddingX(e)){const i=this.getModelColumn(t,e);return this.getVisibleItemSize(i,this.userColumnWidths,()=>this.calculateColumnWidth(t,i,e,n,s))}getModelRows(t,e){const n=new Map;for(let s=0;s<t.length;s+=1){const i=t[s],o=this.getModelRow(i,e);n.set(i,o)}return n}getModelRow(t,e){if(this.modelRows.has(t))return B(this.modelRows,t);const{movedRows:n}=e,s=G.getModelIndex(t,n);return this.modelRows.set(t,s),s}getModelColumns(t,e){const n=new Map;for(let s=0;s<t.length;s+=1){const i=t[s],o=this.getModelColumn(i,e);n.set(i,o)}return n}getModelColumn(t,e){if(this.modelColumns.has(t))return B(this.modelColumns,t);const{movedColumns:s}=e,i=G.getModelIndex(t,s);return this.modelColumns.set(t,i),i}calculateRowHeight(t,e,n){const{theme:s}=n,{autoSizeRows:i,rowHeight:o}=s;if(!i)return o;const r=this.calculatedRowHeights.get(e);return r!=null?r:(this.calculatedRowHeights.set(e,Math.ceil(o)),wr(this.calculatedRowHeights),o)}calculateColumnWidth(t,e,n,s=this.getFirstColumn(n),i=this.calculateTreePaddingX(n)){const{theme:o}=n,{autoSizeColumns:r,minColumnWidth:l}=o;if(!r){const{columnWidth:m}=o;return m}const a=this.calculateColumnHeaderWidth(e,n),d=this.calculateColumnDataWidth(e,n),c=this.calculatedColumnWidths.get(e);let u=Math.ceil(Math.max(a,d));return u=Math.max(l,u),c!=null&&c>u?u=c:(this.calculatedColumnWidths.set(e,u),wr(this.calculatedColumnWidths)),t===s&&(u+=i),u}calculateColumnHeaderWidth(t,e){const{model:n,theme:s}=e,{headerFont:i,headerHorizontalPadding:o}=s,r=n.textForColumnHeader(t,0);if(r!==void 0&&r!==""){const l=this.getWidthForFont(i,e);return r.length*l+o*2}return o*2}calculateColumnDataWidth(t,e){const{top:n,height:s,width:i,model:o,theme:r}=e,{floatingTopRowCount:l,floatingBottomRowCount:a,rowCount:d}=o,{font:c,cellHorizontalPadding:u,rowHeight:m,rowHeaderWidth:p,rowFooterWidth:g,scrollBarSize:f}=r;let b=0;const C=this.getWidthForFont(c,e),w=s/m,T=Math.ceil(n+w);return G.iterateAllItems(n,T,l,a,d,y=>{const E=this.getModelRow(y,e),I=o.textForCell(t,E);if(I){const R=u*2;b=Math.max(b,I.length*C+R)}}),b=Math.max(Math.min(b,(i-p-f-g)*jm.MAX_COLUMN_WIDTH),u*2),b}calculateTreePaddingX(t){const{top:e,height:n,model:s,theme:i}=t,{rowHeight:o,treeDepthIndent:r}=i;if(!gt(s)||!s.hasExpandableRows)return 0;let l=0;const a=n/o,d=Math.ceil(e+a);for(let c=e;c<=d;c+=1){const u=this.getModelRow(c,t),m=s.depthForRow(u);l=Math.max(l,r*(m+1))}return l}getWidthForFont(t,e){if(this.fontWidths.has(t))return B(this.fontWidths,t);const{context:n}=e;n.font=t;const s=n.measureText("8"),{width:i}=s;return this.fontWidths.set(t,i),this.fontWidths.set(n.font,i),i}setColumnWidth(t,e){const n=new Map(this.userColumnWidths);n.set(t,Math.ceil(e)),wr(n),this.userColumnWidths=n}resetColumnWidth(t){const e=new Map(this.userColumnWidths);e.delete(t),this.userColumnWidths=e}setRowHeight(t,e){const n=new Map(this.userRowHeights);n.set(t,Math.ceil(e)),wr(n),this.userRowHeights=n}resetRowHeight(t){const e=new Map(this.userRowHeights);e.delete(t),this.userRowHeights=e,this.calculatedRowHeights.delete(t)}};let qo=jm;qo.CACHE_SIZE=1e4;qo.MAX_COLUMN_WIDTH=.8;const O0=Object.freeze({allowColumnResize:!0,allowRowResize:!0,autoSelectRow:!1,autoSelectColumn:!1,autoSizeColumns:!0,autoSizeRows:!0,backgroundColor:"#000000",black:"#000000",white:"#ffffff",cellHorizontalPadding:5,headerHorizontalPadding:5,font:"12px Arial, sans serif",gridColumnColor:"#8f8f8f66",gridRowColor:"#8f8f8f66",headerBackgroundColor:"#222222",headerSeparatorColor:"#000000",headerSeparatorHoverColor:"#888888",headerSeparatorHandleSize:5,headerHiddenSeparatorSize:5,headerHiddenSeparatorHoverColor:"#8888FF",headerColor:"#d5d5d5",headerFont:"10px Arial, sans serif",columnHoverBackgroundColor:"#444444",selectedColumnHoverBackgroundColor:"#494949",rowBackgroundColors:"#333333 #222222",rowHoverBackgroundColor:"#444444",selectedRowHoverBackgroundColor:"#494949",minScrollHandleSize:50,scrollBarBackgroundColor:"#111111",scrollBarHoverBackgroundColor:"#333333",scrollBarCasingColor:"#000000",scrollBarCornerColor:"#000000",scrollBarColor:"#555555",scrollBarHoverColor:"#888888",scrollBarActiveColor:"#AAAAAA",scrollBarSize:12,scrollBarHoverSize:16,scrollBarCasingWidth:1,scrollSnapToColumn:!1,scrollSnapToRow:!1,selectionColor:"#4286f433",selectionOutlineColor:"#4286f4",selectionOutlineCasingColor:"#222222",scrollBarSelectionTick:!0,scrollBarSelectionTickColor:"#4286f433",scrollBarActiveSelectionTickColor:"#4286f480",shadowBlur:8,shadowColor:"#000000",textColor:"#ffffff",maxDepth:6,treeDepthIndent:10,treeHorizontalPadding:5,treeLineColor:"#888888",treeMarkerColor:"#cccccc",treeMarkerHoverColor:"#ffffff",rowHeight:20,columnWidth:100,minRowHeight:20,minColumnWidth:55,columnHeaderHeight:20,rowHeaderWidth:30,rowFooterWidth:0,headerResizeSnapThreshold:10,headerResizeHiddenSnapThreshold:8,allowColumnReorder:!0,allowRowReorder:!0,reorderOffset:2,floatingGridColumnColor:"#8f8f8f66",floatingGridRowColor:"#8f8f8f66",floatingRowBackgroundColors:"#393939 #292929",floatingDividerOuterColor:"#000000",floatingDividerInnerColor:"#cccccc"}),rn=(t,e)=>{let n=!1;const s=Te(t,{...e,dispose:()=>{n||(n=!0,s.clear(),n=!1)}});return s};function L0(t,e,n=6){const s=Ta.hex.lab.raw(t);return s[0]=Math.max(s[0]-s[0]/n*e,0),`#${Ta.lab.hex(s)}`}function A0(t,e){const[n,s,i]=Ta.hex.rgb(t);return`rgba(${n}, ${s}, ${i}, ${e})`}const Sh={colorWithAlpha:A0,darkenForDepth:L0};class Et{constructor(e=5e3){this.cursor=null,this.order=e}onDown(e,n,s){return!1}onMove(e,n,s){return!1}onDrag(e,n,s){return!1}onLeave(e,n,s){return!1}onClick(e,n,s){return!1}onContextMenu(e,n,s){return!1}onDoubleClick(e,n,s){return!1}onUp(e,n,s){return!1}onWheel(e,n,s){return!1}}class Qm extends Et{constructor(){super(...arguments),this.resizingItems=[],this.hiddenItems=[],this.targetSizes=new Map,this.dragOffset=0}onDown(e,n){const{metrics:s}=n,{model:i}=n.props,o=n.getTheme();if(!s)throw new Error("metrics not set");const r=this.getSeparator(e,s,i,o);if(r!=null){const l=r.index;return this.dragOffset=0,this.draggingIndex=l,this.resizingItems=[l],this.hiddenItems=this.getHiddenItems(l,s).reverse(),this.targetSizes.clear(),this.addTargetSize(s,l),this.updateCursor(s,l),this.updateSeparator(n,r),!0}return!1}onMove(e,n){const{metrics:s}=n,{model:i}=n.props,o=n.getTheme();if(!s)throw new Error("metrics not set");const r=this.getSeparator(e,s,i,o);return r!=null?(this.updateCursor(s,r.index),!0):!1}onDrag(e,n){var f;if(this.draggingIndex==null)return!1;const s=e[this.pointProperty],{metricCalculator:i,metrics:o}=n;if(!o)throw new Error("metrics not set");const r=n.getTheme(),l=o[this.visibleOffsetProperty],a=o[this.marginProperty],d=o[this.calculatedSizesProperty],c=o[this.modelIndexesProperty],u=o[this.firstIndexProperty],m=o[this.treePaddingProperty],p=new Map;let g=this.resizingItems[this.resizingItems.length-1];for(;g!=null;){const b=B(l,g),C=s-a-b-this.dragOffset,w=B(c,g),T=this.targetSizes.get(w),y=this.resizingItems.length>1,E=this.hiddenItems.indexOf(g);let I=B(d,w);g===u&&(I+=m);let R=C;Math.abs(C-I)<=r.headerResizeSnapThreshold?R=null:T!==void 0&&C>T&&(y&&E!==0||E>0)?R=T:C<=r.headerResizeHiddenSnapThreshold&&(R=0),R!==I?p.set(w,R):p.set(w,null),C<-r.headerResizeSnapThreshold&&R===0?E>=0&&y?(this.resizingItems.pop(),this.removeTargetSize(o,g),g=this.resizingItems[this.resizingItems.length-1],this.dragOffset-=(f=this.targetSizes.get(B(c,g)))!=null?f:0):(g=this.getNextShownItem(g,o),g!==null&&(this.resizingItems.push(g),this.addTargetSize(o,g))):T!==void 0&&C>T+r.headerResizeSnapThreshold&&R===T?E>0?(this.dragOffset+=R,g=this.hiddenItems[E-1],this.resizingItems.push(g),this.addTargetSize(o,g)):y?(this.resizingItems.pop(),this.removeTargetSize(o,g),g=this.resizingItems[this.resizingItems.length-1]):g=null:g=null}return p.forEach((b,C)=>{b!==null?this.setSize(i,C,b):this.resetSize(i,C)}),this.updateCursor(o,this.draggingIndex),!0}onUp(e,n){return this.draggingIndex!=null&&(this.draggingIndex=void 0,this.resizingItems=[],this.hiddenItems=[],this.targetSizes.clear(),this.updateSeparator(n,null)),!1}onDoubleClick(e,n){const{metrics:s,metricCalculator:i}=n,{model:o}=n.props,r=n.getTheme();if(!s)throw new Error("metrics not set");const l=this.getSeparator(e,s,o,r);if(l!=null){const a=s[this.modelIndexesProperty],d=B(a,l.index);return this.resetSize(i,d),n.forceUpdate(),!0}return!1}updateCursor(e,n){const s=e[this.visibleSizesProperty];B(s,n)===0?this.cursor=this.hiddenCursor:this.cursor=this.defaultCursor}addTargetSize(e,n){const s=e[this.modelIndexesProperty],i=e[this.userSizesProperty],o=e[this.calculatedSizesProperty],r=n===0?e[this.treePaddingProperty]:0,l=B(s,n);let a=i.get(l);(a==null||a===0)&&(a=B(o,l)+r),this.targetSizes.set(l,a)}removeTargetSize(e,n){const s=e[this.modelIndexesProperty],i=B(s,n);this.targetSizes.delete(i)}}class Fl extends Qm{constructor(){super(...arguments),this.hiddenCursor="e-resize",this.defaultCursor="col-resize",this.pointProperty="x",this.userSizesProperty="userColumnWidths",this.visibleOffsetProperty="visibleColumnXs",this.visibleSizesProperty="visibleColumnWidths",this.marginProperty="rowHeaderWidth",this.calculatedSizesProperty="calculatedColumnWidths",this.modelIndexesProperty="modelColumns",this.firstIndexProperty="firstColumn",this.treePaddingProperty="treePaddingX",this.getHiddenItems=G.getHiddenColumns,this.getNextShownItem=G.getNextShownColumn,this.getSeparator=Fl.getColumnSeparator}static getColumnSeparator(e,n,s,i){if(!i.allowColumnResize)return null;const{x:o,y:r,columnHeaderDepth:l}=e,{modelColumns:a}=n,d=G.getColumnSeparatorIndex(o,r,n,i);return d==null||l==null||l>0?null:a.get(d)!=null?{index:d,depth:0}:null}setSize(e,n,s){e.setColumnWidth(n,s)}resetSize(e,n){e.resetColumnWidth(n)}updateSeparator(e,n){e.setState({draggingColumnSeparator:n,isDragging:n!==null})}}const os=class{constructor(){this.getCachedTruncatedString=rn((t,e,n,s,i)=>os.truncateToWidth(t,e,n,s,i),{max:1e4}),this.getCachedBackgroundColors=rn((t,e)=>t.split(" ").map(n=>{const s=[];for(let i=0;i<e;i+=1)s.push(Sh.darkenForDepth(n,i,e));return s}),{max:1e3}),this.getCachedColorWithAlpha=rn((t,e)=>Sh.colorWithAlpha(t,e),{max:1e3}),this.getCachedColorIsDark=rn(t=>pl.isDark(t),{max:1e3})}static truncate(t,e){return e<t.length?t.substr(0,e)+"\u2026":t}static binaryTruncateToWidth(t,e,n,s=0,i=e.length,o){if(i>=e.length&&t.measureText(e).width<=n)return e;if(o!==void 0){const d=t.measureText(o).width;return o.repeat(Math.max(1,Math.floor(n/d)))}let r=s,l=Math.min(e.length-1,i),a=e;for(;l>=r;){const d=Math.ceil((l+r)/2),c=os.truncate(e,d);if(t.measureText(c).width<=n){if(a=c,r===d)break;r=d}else if(d===0){a=c;break}else l=d-1}return a}static truncateToWidth(t,e,n,s=os.DEFAULT_FONT_WIDTH,i){if(n<=0||e.length<=0)return"";const o=Math.min(Math.max(0,Math.floor(n/s/2)-5),e.length),r=Math.min(Math.ceil(n/s*2),e.length);return os.binaryTruncateToWidth(t,e,n,o,r,i)}drawCanvas(t){const{context:e}=t;e.save(),this.configureContext(e,t),this.drawBackground(e,t),this.drawGrid(e,t),this.drawHeaders(e,t),this.drawFooters(e,t),this.drawDraggingColumn(e,t),this.drawDraggingRow(e,t),this.drawScrollBars(e,t),e.restore()}configureContext(t,e){const{theme:n}=e;t.font=n.font,t.textBaseline="middle",t.lineCap="butt"}drawBackground(t,e){const{theme:n,metrics:s}=e,{width:i,height:o}=s;t.fillStyle=n.backgroundColor,t.fillRect(0,0,i,o)}drawGrid(t,e){const{metrics:n,draggingRow:s,draggingColumn:i}=e,{gridX:o,gridY:r}=n;t.translate(o,r),this.drawGridBackground(t,e,s==null&&i==null),this.drawCellContents(t,e),this.drawFloatingRows(t,e),this.drawFloatingColumns(t,e),t.translate(-o,-r)}drawFloatingRows(t,e){const{draggingRow:n,draggingColumn:s,metrics:i,theme:o}=e,{floatingTopRowCount:r,floatingBottomRowCount:l,floatingRows:a,rowCount:d,visibleColumns:c,visibleRowYs:u,visibleRowHeights:m}=i;if(a.length!==0){o.floatingRowBackgroundColors&&this.drawRowStripesForRows(t,e,a,o.floatingRowBackgroundColors),n==null&&s==null&&this.drawFloatingMouseRowHover(t,e),this.drawGridLinesForItems(t,e,c,a,o.floatingGridColumnColor,o.floatingGridRowColor),this.drawCellBackgroundsForItems(t,e,c,a),this.drawFloatingBorders(t,e),r>0&&this.drawSelectedRanges(t,e,{top:0,bottom:r-1,maxY:B(u,r-1)+B(m,r-1)-.5}),l>0&&this.drawSelectedRanges(t,e,{top:d-l-1,bottom:d-1,minY:B(u,d-l)+.5,maxY:B(u,d-1)+B(m,d-1)-.5});for(let p=0;p<c.length;p+=1){const g=c[p];for(let f=0;f<a.length;f+=1){const b=a[f];this.drawCellContent(t,e,g,b)}}}}drawFloatingColumns(t,e){const{draggingRow:n,draggingColumn:s,metrics:i,theme:o}=e,{floatingLeftColumnCount:r,floatingRightColumnCount:l,floatingLeftWidth:a,floatingRightWidth:d,floatingColumns:c,gridX:u,maxX:m,columnCount:p,visibleRows:g,visibleColumnXs:f,visibleColumnWidths:b,width:C,height:w}=i;if(c.length!==0){o.floatingRowBackgroundColors&&(this.drawRowStripesForRows(t,e,g,o.floatingRowBackgroundColors,0,a),this.drawRowStripesForRows(t,e,g,o.floatingRowBackgroundColors,C-u-d,m)),n==null&&s==null&&this.drawFloatingMouseRowHover(t,e),t.save(),t.beginPath(),t.rect(0,0,a,w),t.clip(),this.drawGridLinesForItems(t,e,c,g,o.floatingGridColumnColor,o.floatingGridRowColor),t.restore(),this.drawCellBackgroundsForItems(t,e,c,g),this.drawFloatingBorders(t,e),r>0&&this.drawSelectedRanges(t,e,{left:0,maxX:B(f,r-1)+B(b,r-1)}),l>0&&this.drawSelectedRanges(t,e,{left:p-l,right:p-1,minX:B(f,p-l)+.5,maxX:B(f,p-1)+B(b,p-1)});for(let T=0;T<c.length;T+=1){const y=c[T];for(let E=0;E<g.length;E+=1){const I=g[E];this.drawCellContent(t,e,y,I)}}}}drawFloatingBorders(t,e){const{metrics:n,theme:s}=e,{floatingTopRowCount:i,floatingBottomRowCount:o,floatingLeftColumnCount:r,floatingRightColumnCount:l,rowCount:a,columnCount:d,visibleRowYs:c,visibleColumnXs:u,visibleRowHeights:m,visibleColumnWidths:p,maxX:g,maxY:f}=n,{floatingDividerOuterColor:b,floatingDividerInnerColor:C}=s;if(t.lineWidth=3,t.beginPath(),t.strokeStyle=b,i>0){const w=B(c,i-1)+B(m,i-1)+.5;t.moveTo(0,w),t.lineTo(g,w)}if(o>0){const w=B(c,a-o)-.5;t.moveTo(0,w),t.lineTo(g,w)}if(r>0){const w=B(u,r-1)+B(p,r-1)+.5;t.moveTo(w,0),t.lineTo(w,f)}if(l>0){const w=B(u,d-l)-.5;t.moveTo(w,0),t.lineTo(w,f)}if(t.stroke(),t.beginPath(),t.lineWidth=1,t.strokeStyle=C,i>0){const w=B(c,i-1)+B(m,i-1)+.5;t.moveTo(0,w),t.lineTo(g,w)}if(o>0){const w=B(c,a-o)-.5;t.moveTo(0,w),t.lineTo(g,w)}if(r>0){const w=B(u,r-1)+B(p,r-1)+.5;t.moveTo(w,0),t.lineTo(w,f)}if(l>0){const w=B(u,d-l)-.5;t.moveTo(w,0),t.lineTo(w,f)}t.stroke()}drawGridBackground(t,e,n=!1){this.drawRowStripes(t,e),n&&(this.drawMouseColumnHover(t,e),this.drawMouseRowHover(t,e)),this.drawGridLines(t,e),this.drawCellBackgrounds(t,e);const{metrics:s}=e,{bottom:i,right:o,floatingBottomRowCount:r,floatingLeftColumnCount:l,floatingRightColumnCount:a,floatingTopRowCount:d,columnCount:c,rowCount:u,visibleRowHeights:m,visibleRowYs:p,visibleColumnXs:g,visibleColumnWidths:f,width:b,height:C}=s;this.drawSelectedRanges(t,e,{bottom:Math.min(i,u-r-1),right:Math.min(o,c-a-1),minX:l>0&&g.has(l+1)?B(g,l+1):-10,minY:d>0&&p.has(d+1)?B(p,d+1):-10,maxX:a>0&&g.has(c-a-1)?B(g,c-a-1)+B(f,c-a-1)-.5:b+10,maxY:r>0&&p.has(u-r-1)?B(p,u-r-1)+B(m,u-r-1)-.5:C+10})}drawRowStripes(t,e){const{metrics:n,theme:s}=e,{visibleRows:i}=n,{rowBackgroundColors:o}=s;!o||this.drawRowStripesForRows(t,e,i,o)}drawRowStripesForRows(t,e,n,s,i=0,o=e.metrics.maxX){const{theme:r,metrics:l,model:a}=e,{maxDepth:d,shadowBlur:c,shadowColor:u}=r,m=this.getCachedBackgroundColors(s,d),{visibleRowYs:p,visibleRowHeights:g}=l,f=new Map,b=[],C=[],w=(T,y)=>{const E=gt(a)?a.depthForRow(T):0,I=m[T%m.length],R=I[Math.min(E,I.length-1)];if(f.has(R)||f.set(R,[]),f.get(R).push(T),y!=null){const F=gt(a)?a.depthForRow(y):0;F<E?b.push(T):F>E&&C.push(y)}};for(let T=0;T<n.length;T+=1){const y=n[T],E=T>0?n[T-1]:void 0;w(y,E)}if(f.forEach((T,y)=>{t.fillStyle=y,t.beginPath();for(let E=0;E<T.length;E+=1){const I=T[E],R=B(p,I),F=B(g,I);t.rect(i,R,o,F)}t.fill()}),b.length>0){t.save();const T=this.getCachedColorWithAlpha(u,.15),y=this.getCachedColorWithAlpha(u,0),E=t.createLinearGradient(0,0,0,c);E.addColorStop(0,T),E.addColorStop(1,y),t.fillStyle=E;for(let I=0;I<b.length;I+=1){const R=b[I],F=B(p,R);t.translate(0,F),t.fillRect(i,0,o,c),t.translate(0,-F)}t.restore()}if(C.length>0){t.save();const T=this.getCachedColorWithAlpha(u,0),y=this.getCachedColorWithAlpha(u,.15),E=t.createLinearGradient(0,0,0,c);E.addColorStop(0,T),E.addColorStop(1,y),t.fillStyle=E;for(let I=0;I<C.length;I+=1){const R=C[I],F=B(p,R),x=B(g,R),U=F+x-c;t.translate(0,U),t.fillRect(i,0,o,c),t.translate(0,-U)}t.restore()}}drawMouseColumnHover(t,e){const{mouseX:n,mouseY:s,theme:i,metrics:o}=e;if(n==null||s==null)return;const r=G.getColumnAtX(n,o);if(r==null||i.columnHoverBackgroundColor==null)return;const{visibleColumnWidths:l,visibleColumnXs:a,maxY:d}=o;if(s>d)return;const c=B(a,r),u=B(l,r);t.fillStyle=i.columnHoverBackgroundColor,t.fillRect(c,0,u,d)}drawMouseRowHover(t,e){const{mouseX:n,mouseY:s,theme:i,metrics:o}=e;if(n==null||s==null)return;const{maxX:r}=o;if(n>r||i.rowHoverBackgroundColor==null)return;const l=G.getRowAtY(s,o);l!=null&&this.drawMouseRowHoverForRow(t,e,l)}drawFloatingMouseRowHover(t,e){const{mouseX:n,mouseY:s,theme:i,metrics:o}=e,{maxX:r,floatingTopRowCount:l,floatingBottomRowCount:a,rowCount:d,rowFooterWidth:c}=o;if(n==null||s==null||n>r+c||i.rowHoverBackgroundColor==null)return;const u=G.getRowAtY(s,o);u!=null&&(u<l||d-a<=u)&&this.drawMouseRowHoverForRow(t,e,u)}drawMouseRowHoverForRow(t,e,n){const{metrics:s,selectedRanges:i,theme:o}=e,{visibleRowHeights:r,visibleRowYs:l,maxX:a}=s,d=B(l,n),c=B(r,n);o.rowHoverBackgroundColor!=null&&(t.fillStyle=o.rowHoverBackgroundColor);for(let u=0;u<i.length;u+=1){const{startRow:m,endRow:p}=i[u];if(m!=null&&p!=null&&m<=n&&p>=n){o.selectedRowHoverBackgroundColor!=null&&(t.fillStyle=o.selectedRowHoverBackgroundColor);break}}t.fillRect(0,d,a,c)}drawGridLines(t,e){const{metrics:n,theme:s}=e,{visibleColumns:i,visibleRows:o}=n;this.drawGridLinesForItems(t,e,i,o,s.gridColumnColor,s.gridRowColor)}drawGridLinesForItems(t,e,n,s,i,o){i==null&&o==null||(t.lineWidth=1,t.beginPath(),i!=null&&(t.strokeStyle=i,this.drawGridLinesForColumns(t,e,n)),o!=null&&(t.strokeStyle=o,this.drawGridLinesForRows(t,e,s)),t.stroke())}drawGridLinesForColumns(t,e,n){const{metrics:s}=e,{visibleColumnXs:i,maxY:o}=s;for(let r=0;r<n.length;r+=1){const l=n[r],a=B(i,l)+.5;t.moveTo(a,0),t.lineTo(a,o)}}drawGridLinesForRows(t,e,n){const{metrics:s}=e,{visibleRowYs:i,maxX:o}=s,r=o;for(let l=0;l<n.length;l+=1){const a=n[l],d=B(i,a)+.5;t.moveTo(.5,d),t.lineTo(r-.5,d)}}drawCellBackgrounds(t,e){const{metrics:n}=e,{visibleColumns:s,visibleRows:i}=n;this.drawCellBackgroundsForItems(t,e,s,i)}drawCellBackgroundsForItems(t,e,n,s){t.save();for(let i=0;i<n.length;i+=1){const o=n[i];for(let r=0;r<s.length;r+=1){const l=s[r],a=r+1<s.length?s[r+1]:void 0;this.drawCellBackground(t,e,o,l,a)}}t.restore()}drawCellBackground(t,e,n,s,i){const{metrics:o,model:r,theme:l}=e,{firstColumn:a,modelColumns:d,modelRows:c,visibleColumnXs:u,visibleColumnWidths:m,visibleRowYs:p,visibleRowHeights:g}=o,f=B(c,s),b=B(d,n),C=r.backgroundColorForCell(b,f,l),w=n===a,T=gt(r)&&r.hasExpandableRows;if(C!=null){const y=B(u,n)+1,E=B(p,s)+1,I=B(m,n)-1,R=B(g,s)-1;t.fillStyle=C,t.fillRect(y,E,I,R)}w&&T&&this.drawCellRowTreeDepthLines(t,e,s,i)}drawCellContents(t,e){const{metrics:n}=e,{visibleColumns:s}=n;for(let i=0;i<s.length;i+=1){const o=s[i];this.drawColumnCellContents(t,e,o)}}drawColumnCellContents(t,e,n){const{metrics:s}=e,{visibleColumnXs:i,visibleColumnWidths:o,visibleRows:r,height:l}=s,a=B(i,n),d=B(o,n);t.save(),t.beginPath(),t.rect(a,0,d,l),t.clip();for(let c=0;c<r.length;c+=1){const u=r[c];this.drawCellContent(t,e,n,u)}t.restore()}getTextRenderMetrics(t,e,n,s){const{textAlign:i}=t,{metrics:o,model:r,theme:l}=e,{firstColumn:a,visibleColumnXs:d,visibleColumnWidths:c,visibleRowYs:u,visibleRowHeights:m}=o,{cellHorizontalPadding:p,treeDepthIndent:g,treeHorizontalPadding:f}=l,b=B(d,n),C=B(u,s),w=B(c,n),T=B(m,s),y=n===a;let E=0;gt(r)&&r.hasExpandableRows&&y&&(E=g*(r.depthForRow(s)+1)+f);const I=w-E;let R=b+p;const F=C+T*.5;return i==="right"?R=b+I-p:i==="center"&&(R=b+I*.5),R+=E,{width:I-p*2,x:R,y:F}}drawCellContent(t,e,n,s,i){var y;const{metrics:o,model:r,theme:l}=e,{firstColumn:a,fontWidths:d,modelColumns:c,modelRows:u,visibleRowHeights:m}=o,{textColor:p}=l,g=B(m,s),f=B(u,s),b=B(c,n),C=i!=null?i:r.textForCell(b,f),w=r.truncationCharForCell(b,f),T=n===a;if(C&&g>0){const E=r.textAlignForCell(b,f)||"left";t.textAlign=E;const I=r.colorForCell(b,f,l)||p;t.fillStyle=I;const{width:R,x:F,y:x}=this.getTextRenderMetrics(t,e,n,s),U=(y=d.get(t.font))!=null?y:os.DEFAULT_FONT_WIDTH,$=this.getCachedTruncatedString(t,C,R,U,w);$&&t.fillText($,F,x)}T&>(r)&&r.hasExpandableRows&&this.drawCellRowTreeMarker(t,e,s)}drawCellRowTreeMarker(t,e,n){const{metrics:s,model:i,mouseX:o,mouseY:r,theme:l}=e,{firstColumn:a,gridX:d,gridY:c,visibleColumnXs:u,visibleColumnWidths:m,visibleRowYs:p,visibleRowHeights:g,visibleRowTreeBoxes:f}=s,{treeMarkerColor:b,treeMarkerHoverColor:C}=l,w=B(u,a),T=B(m,a),y=B(p,n),E=B(g,n);if(!gt(i)||!i.isRowExpandable(n))return;const I=B(f,n),R=o!=null&&r!=null&&o>=d+w&&o<=d+w+T&&r>=c+y&&r<=c+y+E?C:b;this.drawTreeMarker(t,e,w,y,I,R,i.isRowExpanded(n))}drawTreeMarker(t,e,n,s,i,o,r){const{x1:l,y1:a,x2:d,y2:c}=i,u=r?"\u229F":"\u229E",m=n+(l+d)*.5+.5,p=s+(a+c)*.5+.5;t.fillStyle=o,t.textAlign="center",t.fillText(u,m,p)}drawCellRowTreeDepthLines(t,e,n,s){const{metrics:i,model:o,theme:r}=e;if(!gt(o))return;const l=o.depthForRow(n);if(l===0)return;const{firstColumn:a,visibleColumnXs:d,visibleRowYs:c,visibleRowHeights:u}=i,{treeDepthIndent:m,treeHorizontalPadding:p,treeLineColor:g}=r,f=B(d,a),b=B(c,n),C=B(u,n),w=s!==void 0?o.depthForRow(s):0,T=l>w?l-w:0;if(t.strokeStyle=g,t.lineWidth=1,l-T>0){t.beginPath();for(let y=0;y<l-T;y+=1){const E=f+y*m+m*.5+p+.5;t.moveTo(E,b),t.lineTo(E,b+C)}t.stroke()}if(T>0){t.beginPath();for(let y=l-T;y<l;y+=1){const E=f+y*m+m*.5+p+.5;t.moveTo(E,b),t.lineTo(E,b+Math.ceil(C/2)),t.moveTo(E-.5,b+Math.ceil(C/2)+.5),t.lineTo(E+m-.5,b+Math.ceil(C/2)+.5)}t.stroke()}}drawHeaders(t,e){const{theme:n}=e;t.font=n.headerFont,this.drawColumnHeaders(t,e),this.drawRowHeaders(t,e)}drawFooters(t,e){const{theme:n}=e;t.font=n.headerFont,this.drawRowFooters(t,e)}drawColumnHeaders(t,e){const{mouseX:n,mouseY:s,theme:i,metrics:o,draggingColumnSeparator:r,isDragging:l,model:a}=e,{columnHeaderHeight:d,floatingColumns:c,gridX:u,width:m,visibleColumns:p,visibleColumnWidths:g,visibleColumnXs:f,floatingLeftColumnCount:b,floatingLeftWidth:C,floatingRightWidth:w,modelColumns:T,columnHeaderMaxDepth:y}=o;if(d<=0)return;const{headerHiddenSeparatorSize:E,headerHiddenSeparatorHoverColor:I,headerSeparatorColor:R,headerSeparatorHoverColor:F}=i,x=d*.5,U=d*(y-1)+d*.5-x*.5,$=b>0;if(t.save(),this.drawColumnHeadersForRange(t,e,[p[0],p[p.length-1]],{minX:u+C,maxX:m-w}),$&&this.drawColumnHeadersForRange(t,e,[c[0],c[c.length-1]],{minX:u,maxX:u+C}),R){t.strokeStyle=R;const O=[...g.entries()].filter(([H,L])=>L===0).map(([H])=>H);t.beginPath(),t.fillStyle=R;for(let H=0;H<O.length;H+=1){const L=O[H],N=B(f,L),_=B(g,L),k=u+N+_+.5-E*.5;t.rect(k,U,E,x)}t.fill()}if(F){let{index:O,depth:H}=r!=null?r:{};if(O==null&&n!=null&&s!=null){const N=Fl.getColumnSeparator(G.getGridPointFromXY(n,s,o),o,a,i);O=N==null?void 0:N.index,H=N==null?void 0:N.depth}let L;if(O==null)L=!1;else{const N=T.get(O),_=T.get(O+1);N==null||_==null?L=!1:L=a.textForColumnHeader(N,H)!==a.textForColumnHeader(_,H)}if(L&&O!=null&&H!=null&&(!l||r!=null)){t.strokeStyle=F;const N=B(f,O),_=B(g,O),k=u+N+_+.5,V=p.indexOf(O),W=V<p.length-1?p[V+1]:null,j=W!=null?g.get(W):null,ee=_===0,ve=j!=null&&j===0;ee?(t.strokeStyle=I,t.fillStyle=I,t.fillRect(k,U,E*.5,x)):ve&&(t.fillStyle=F,t.fillRect(k-E*.5,U,E*.5,x)),t.beginPath(),t.moveTo(k,(y-H-1)*d),t.lineTo(k,(y-H)*d-1),t.stroke()}}t.restore()}drawColumnHeadersForRange(t,e,n,s){const{model:i}=e,{columnHeaderMaxDepth:o}=i;if(o!==0)for(let r=0;r<=o;r+=1)this.drawColumnHeadersAtDepth(t,e,n,s,r)}drawColumnHeadersAtDepth(t,e,n,s,i){var R,F,x,U,$,O;const{metrics:o,model:r,theme:l}=e,{modelColumns:a,visibleColumnXs:d,gridX:c,calculatedColumnWidths:u,userColumnWidths:m,visibleColumnWidths:p,movedColumns:g}=o,{columnHeaderHeight:f,columnWidth:b}=l,{columnHeaderMaxDepth:C}=r,{minX:w,maxX:T}=s,y=T-w;if(C===0)return;const E=n[0],I=n[1];if(t.save(),t.translate(0,(C-i-1)*f),i===0){this.drawColumnHeader(t,e,"",w,T);for(let H=E;H<=I;H+=1)this.drawColumnHeaderAtIndex(t,e,H,s)}if(i>0){let H=E;for(;H<=I;){const{columnCount:L}=o,N=B(a,H),_=r.textForColumnHeader(N,i),k=r.colorForColumnHeader(N,i);let V=B(d,H)+c,W=V+B(p,H);if(_!=null){let j=H-1;for(;j>=0&&(W-V<y||V>w);){const Se=(R=a.get(j))!=null?R:G.getModelIndex(j,g);if(Se==null||r.textForColumnHeader(Se,i)!==_)break;V-=(x=(F=m.get(Se))!=null?F:u.get(Se))!=null?x:b,j-=1}let ee=H+1;for(;ee<L&&(W-V<y||W<T);){const Se=(U=a.get(ee))!=null?U:G.getModelIndex(ee,g);if(r.textForColumnHeader(Se,i)!==_)break;W+=(O=($=m.get(Se))!=null?$:u.get(Se))!=null?O:b,ee+=1}H=ee-1;const ve=W-V>=y;let le=V;ve&&(W<T?le=W-y:V<w&&(le=w)),this.drawColumnHeader(t,e,_,le,Math.min(W-V,y),{backgroundColor:k!=null?k:void 0},s)}H+=1}}t.restore()}drawColumnHeaderAtIndex(t,e,n,s){var g;const{metrics:i,model:o}=e,{modelColumns:r,visibleColumnWidths:l,visibleColumnXs:a,gridX:d}=i,c=B(l,n),u=B(a,n)+d,m=B(r,n),p=o.textForColumnHeader(m);p!=null&&this.drawColumnHeader(t,e,p,u,c,{backgroundColor:(g=o.colorForColumnHeader(m))!=null?g:void 0},s)}drawColumnHeader(t,e,n,s,i,o,r){var ee;if(i<=0)return;const{metrics:l,theme:a}=e,{headerHorizontalPadding:d,columnHeaderHeight:c,headerBackgroundColor:u,headerColor:m,headerSeparatorColor:p,black:g,white:f}=a,{fontWidths:b,width:C}=l,w=(ee=b.get(t.font))!=null?ee:os.DEFAULT_FONT_WIDTH,y=(i-d*2)/w,{backgroundColor:E=u,separatorColor:I=p}=o!=null?o:{};let{textColor:R=m}=o!=null?o:{};try{const ve=this.getCachedColorIsDark(E),le=this.getCachedColorIsDark(R);ve&&le?R=f:!ve&&!le&&(R=g)}catch{}let{minX:F=0,maxX:x=C}=r!=null?r:{};t.save(),t.rect(F,0,x-F,c),t.clip(),E!=null&&(t.fillStyle=E,t.fillRect(s,0,i,c)),I!=null&&(t.strokeStyle=I,t.beginPath(),s>0&&(t.moveTo(s+.5,0),t.lineTo(s+.5,c)),t.moveTo(s+i+.5,0),t.lineTo(s+i+.5,c),t.moveTo(s,c-.5),t.lineTo(s+i,c-.5),t.stroke()),t.beginPath(),t.rect(s,0,i,c),t.clip(),t.fillStyle=R;let U=n;y<=0?U="":U.length>y&&(U=`${U.substring(0,y-1)}\u2026`);const $=U.length*w;let O=s+i*.5;const H=c*.5;F+=d,x-=d;const L=s+d,N=At(L,F,x),_=s+i-d,V=At(_,F,x)-N,W=O-$*.5<F,j=O+$*.5>x;W?$<V?O=F+$*.5:O=_-$*.5:j&&($<V?O=x-$*.5:O=L+$*.5),t.textAlign="center",t.fillText(U,O,H),t.restore()}drawRowHeaders(t,e){const{mouseX:n,mouseY:s,metrics:i,theme:o,draggingRowSeparator:r}=e,{gridY:l,rowHeaderWidth:a,height:d,visibleRows:c,visibleRowHeights:u,visibleRowYs:m}=i;if(a<=0)return;const{headerBackgroundColor:p,headerColor:g,headerHiddenSeparatorSize:f,headerHiddenSeparatorHoverColor:b,headerSeparatorColor:C,headerSeparatorHoverColor:w}=o,T=a*.5,y=a*.5-T*.5;if(t.save(),t.beginPath(),t.fillStyle=p,t.fillRect(0,0,a,d),C){t.strokeStyle=C,t.beginPath(),t.moveTo(0,l+.5),t.lineTo(a,l+.5);const E=[];let I=!1;for(let R=0;R<c.length;R+=1){const F=c[R],x=B(m,F),U=B(u,F);if(U>0){const $=l+x+U+.5;t.moveTo(0,$),t.lineTo(a,$),I=!1}else I||(I=!0,E.push(F))}t.moveTo(a-.5,0),t.lineTo(a-.5,d),t.stroke(),t.beginPath(),t.fillStyle=C;for(let R=0;R<E.length;R+=1){const F=E[R],x=B(m,F),U=B(u,F),$=l+x+U+.5-f*.5;t.rect(y,$,T,f)}t.fill()}if(w){let{index:E=null}=r!=null?r:{};if(E==null&&n!=null&&s!=null&&(E=G.getRowSeparatorIndex(n,s,i,o)),E!=null){t.strokeStyle=w;const I=B(m,E),R=B(u,E),F=l+I+R+.5,x=c.indexOf(E),U=x<c.length-1?c[x+1]:null,$=U!=null?u.get(U):null,O=R===0,H=$!=null&&$===0;O?(t.strokeStyle=b,t.fillStyle=b,t.fillRect(y,F,T,f*.5)):H&&(t.fillStyle=w,t.fillRect(y,F-f*.5,T,f*.5)),t.beginPath(),t.moveTo(.5,F),t.lineTo(a+.5,F),t.stroke()}}t.beginPath(),t.rect(0,l,a,d),t.clip(),t.fillStyle=g,t.textAlign="right";for(let E=0;E<c.length;E+=1){const I=c[E],R=B(u,I),F=B(m,I)+l;this.drawRowHeader(t,e,I,F,R)}t.restore()}drawRowHeader(t,e,n,s,i){if(i<=0)return;const{metrics:o,model:r,theme:l}=e,{modelRows:a,rowHeaderWidth:d}=o,c=B(a,n),u=d-l.cellHorizontalPadding,m=s+i*.5;t.fillText(r.textForRowHeader(c),u,m)}drawRowFooters(t,e){const{mouseX:n,mouseY:s,metrics:i,model:o,theme:r,draggingRowSeparator:l}=e,{gridY:a,gridX:d,maxX:c,modelRows:u,rowFooterWidth:m,height:p,verticalBarWidth:g,visibleRows:f,visibleRowHeights:b,visibleRowYs:C,width:w}=i;if(m<=0)return;const{cellHorizontalPadding:T,headerBackgroundColor:y,headerColor:E,headerHiddenSeparatorSize:I,headerHiddenSeparatorHoverColor:R,headerSeparatorColor:F,headerSeparatorHoverColor:x}=r,U=m*.5,$=m*.5-U*.5,O=Math.min(d+c,w-m-g);if(t.save(),t.beginPath(),t.fillStyle=y,t.fillRect(O,a,m,p),F){t.strokeStyle=F,t.beginPath(),t.moveTo(O,a+.5),t.lineTo(m,a+.5);const L=[];let N=!1;for(let _=0;_<f.length;_+=1){const k=f[_],V=B(C,k),W=B(b,k);if(W>0){const j=a+V+W+.5;t.moveTo(O+.5,j),t.lineTo(O+m-.5,j),N=!1}else N||(N=!0,L.push(k))}t.moveTo(O+.5,a),t.lineTo(O+.5,p),t.stroke(),t.beginPath(),t.fillStyle=F;for(let _=0;_<L.length;_+=1){const k=L[_],V=B(C,k),W=B(b,k),j=a+V+W+.5-I*.5;t.rect(O+$,j,U,I)}t.fill()}if(x){let{index:L=null}=l!=null?l:{};if(L==null&&n!=null&&s!=null&&(L=G.getRowSeparatorIndex(n,s,i,r)),L!=null){t.strokeStyle=x;const N=B(C,L),_=B(b,L),k=a+N+_+.5,V=f.indexOf(L),W=V<f.length-1?f[V+1]:null,j=W!=null?b.get(W):null,ee=_===0,ve=j!=null&&j===0;ee?(t.strokeStyle=R,t.fillStyle=R,t.fillRect($,k,U,I*.5)):ve&&(t.fillStyle=x,t.fillRect($,k-I*.5,U,I*.5)),t.beginPath(),t.moveTo(O+.5,k),t.lineTo(O+m+.5,k),t.stroke()}}t.beginPath(),t.rect(O,a,m,p),t.clip(),t.fillStyle=E,t.textAlign="left";const H=O+T;for(let L=0;L<f.length;L+=1){const N=f[L],_=B(b,N);if(_>0){const k=B(C,N)+a,V=B(u,N),W=k+_*.5;t.fillText(o.textForRowFooter(V),H,W)}}t.restore()}drawSelectedRanges(t,e,n={}){const{cursorColumn:s,cursorRow:i,draggingRow:o,draggingColumn:r,editingCell:l,metrics:a,model:d,selectedRanges:c,theme:u}=e,{visibleColumnWidths:m,visibleColumnXs:p,visibleRowHeights:g,visibleRowYs:f,width:b,height:C}=a,{left:w=a.left,top:T=a.top,right:y=a.right,bottom:E=a.bottom,minY:I=-10,maxY:R=C+10,minX:F=-10,maxX:x=b+10}=n;if(c.length===0)return;const U=Ze(d)&&d.isEditable&&l==null&&o==null&&r==null&&s!=null&&i!=null&&p.has(s)&&f.has(i);if(U){const $=B(p,s),O=B(f,i),H=B(m,s),L=B(g,i);t.save(),t.beginPath(),t.rect(0,0,b,C),t.rect($,O,H,L),t.clip("evenodd")}t.beginPath();for(let $=0;$<c.length;$+=1){const O=c[$],H=O.startColumn!==null?O.startColumn:w,L=O.startRow!==null?O.startRow:T,N=O.endColumn!==null?O.endColumn:y,_=O.endRow!==null?O.endRow:E;if(_>=T&&E>=L&&N>=w&&y>=H){const k=H>=w&&p.has(H)?Math.round(B(p,H))+.5:F,V=L>=T&&f.has(L)?Math.max(Math.round(B(f,L))+.5,.5):I,W=N<=y&&p.has(N)?Math.round(B(p,N)+B(m,N))-.5:x,j=_<=E&&f.has(_)?Math.round(B(f,_)+B(g,_))-.5:R;t.rect(k,V,W-k,j-V)}t.fillStyle=u.selectionColor,t.fill(),t.save(),t.clip(),t.strokeStyle=u.selectionOutlineCasingColor,t.lineWidth=3,t.stroke(),t.restore(),t.strokeStyle=u.selectionOutlineColor,t.lineWidth=1,t.stroke()}U&&s!=null&&i!=null&&(t.restore(),this.drawActiveCell(t,e,s,i))}drawActiveCell(t,e,n,s,i=os.ACTIVE_CELL_BORDER_WIDTH){const{metrics:o,theme:r}=e,{visibleColumnWidths:l,visibleColumnXs:a,visibleRowHeights:d,visibleRowYs:c}=o,u=B(a,n),m=B(c,s),p=B(l,n),g=B(d,s);let f=u-i*.5,b=m-i*.5,C=p+i,w=g+i;f<=0&&(C+=f-1,f=1),b<=0&&(w+=b-1,b=1);const{lineWidth:T}=t;t.beginPath(),t.lineWidth=i,t.strokeStyle=r.selectionOutlineColor,this.drawRoundedRect(t,f,b,C,w),t.stroke(),t.lineWidth=T}drawRoundedRect(t,e,n,s,i,o=os.DEFAULT_EDGE_RADIUS){t.beginPath(),t.moveTo(e+o,n),t.lineTo(e+s-o,n),t.quadraticCurveTo(e+s,n,e+s,n+o),t.lineTo(e+s,n+i-o),t.quadraticCurveTo(e+s,n+i,e+s-o,n+i),t.lineTo(e+o,n+i),t.quadraticCurveTo(e,n+i,e,n+i-o),t.lineTo(e,n+o),t.quadraticCurveTo(e,n,e+o,n),t.closePath()}drawDraggingColumn(t,e){var j;const{draggingColumn:n,metrics:s,mouseX:i,theme:o,model:r}=e;if(n==null||i==null)return;const{range:l,depth:a}=n,{gridX:d,gridY:c,visibleColumnXs:u,visibleColumnWidths:m,height:p,width:g,columnHeaderMaxDepth:f,columnHeaderHeight:b,movedColumns:C,modelColumns:w,floatingLeftWidth:T}=s,y=(j=w.get(l[0]))!=null?j:G.getModelIndex(l[0],C),E=r.getColumnHeaderGroup(y,a);if(a>0&&!E)return;const[I,R]=l,F=B(u,I),U=B(u,R)+B(m,R)-F,$=n.left,{backgroundColor:O,font:H,headerFont:L,reorderOffset:N,shadowBlur:_,shadowColor:k}=o,V=(f-a-1)*b;t.save(),t.translate(d,0),t.save(),t.beginPath(),t.rect(T,0,g,p),t.clip(),t.fillStyle=O,t.fillRect(F,V,U,p),t.restore(),t.translate(0,N),t.save(),t.shadowColor=k,t.shadowBlur=_,t.fillStyle=O,t.fillRect(n.left,V+N,n.width,p),t.restore(),t.beginPath(),t.rect(n.left,V,n.width+1,p),t.clip(),t.translate($-F,0),t.font=L;const W=[];for(let ee=n.range[0];ee<=n.range[1];ee+=1)W.push(ee);this.drawColumnHeaders(t,e),this.drawColumnHeadersForRange(t,e,[W[0],W[W.length-1]],{minX:F,maxX:g}),t.translate(0,c),t.font=H,this.drawGridBackground(t,e);for(let ee=I;ee<=R;ee+=1)this.drawColumnCellContents(t,e,ee);t.restore()}drawDraggingRow(t,e){const{draggingRow:n,draggingRowOffset:s,metrics:i,mouseY:o,theme:r}=e;if(n==null||o==null)return;const{gridX:l,gridY:a,visibleRowYs:d,visibleRowHeights:c,width:u}=i,m=B(d,n),p=B(c,n)+1,{backgroundColor:g,font:f,headerFont:b,reorderOffset:C,shadowBlur:w,shadowColor:T}=r;t.save(),t.translate(0,a),t.fillStyle=g,t.fillRect(0,m,u,p),t.translate(l+C,o-m-a-(s!=null?s:0)),t.save(),t.shadowColor=T,t.shadowBlur=w,t.fillStyle=g,t.fillRect(-l,m,u,p),t.restore(),t.beginPath(),t.rect(-l,m,u,p),t.clip(),t.font=f,this.drawGridBackground(t,e),this.drawCellContents(t,e),t.translate(-l,-a),t.font=b,this.drawRowHeaders(t,e),t.restore()}drawScrollBars(t,e){const{isDraggingHorizontalScrollBar:n,isDraggingVerticalScrollBar:s,isDragging:i,metrics:o,mouseX:r,mouseY:l,theme:a}=e;if(a.scrollBarSize<=0)return;const{rowHeaderWidth:d,columnHeaderHeight:c,width:u,height:m,handleHeight:p,handleWidth:g,scrollX:f,scrollY:b,hasHorizontalBar:C,hasVerticalBar:w,barWidth:T,barHeight:y}=o,{scrollBarBackgroundColor:E,scrollBarHoverBackgroundColor:I,scrollBarCasingColor:R,scrollBarCornerColor:F,scrollBarColor:x,scrollBarHoverColor:U,scrollBarActiveColor:$,scrollBarSize:O,scrollBarHoverSize:H,scrollBarCasingWidth:L,scrollBarSelectionTick:N,scrollBarSelectionTickColor:_,scrollBarActiveSelectionTickColor:k,autoSelectRow:V,autoSelectColumn:W}=a,j=r!=null&&l!=null&&r<=u&&l<=m,ee=s||w&&!n&&!i&&r!=null&&l!=null&&r>=u-H&&l<=y+c&&j,ve=n||C&&!s&&!i&&!ee&&r!=null&&l!=null&&l>=m-H&&r<=T-d&&j,le=ve?H:O,Se=ee?H:O;if(t.translate(d,c),C&&w&&(t.fillStyle=R,t.fillRect(u-d-O,m-c-O,O,O),t.fillStyle=F,t.fillRect(u-d-O+L,m-c-O+L,O-L,O-L)),C){const Le=f,J=m-c-le;if(t.fillStyle=R,t.fillRect(0,J,T,le-L),t.fillStyle=ve?I:E,t.fillRect(0,J+L,T,le-L),n?t.fillStyle=$:ve?t.fillStyle=U:t.fillStyle=x,t.fillRect(Le,J+L,g,le-L),!V&&N&&_!=null&&k!=null){t.fillStyle=_;const{selectedRanges:pe,cursorColumn:fe}=e,{lastLeft:xe,columnCount:ke}=o,Xn=[...pe].filter(Re=>Re.startColumn!=null&&Re.endColumn!=null).map(Re=>[Re.startColumn,Re.endColumn]).sort(G.compareRanges),Sn=G.mergeSortedRanges(Xn),Ct=Re=>Re<=xe?Re/xe*(T-g):T-g+(Re-xe)/(ke-xe)*g;for(let Re=0;Re<Sn.length;Re+=1){const st=Sn[Re],it=st[0],Mt=st[1];if(it!=null&&Mt!=null&&(it!==fe||Mt!==fe)){const Yt=Ct(it),Xt=Math.max(1,Math.round(Ct(Mt+1)-Yt)),Nt=le-L;t.fillRect(Yt,J+L+Math.round(Nt/3),Xt,Math.round(Nt/3))}}if(fe!=null){const Re=Ct(fe),st=2,it=le-L;t.fillStyle=k,t.fillRect(Re,J+L,st,it)}}}if(w){const Le=u-d-Se,J=b;if(t.fillStyle=R,t.fillRect(Le,0,Se-L,y),t.fillStyle=ee?I:E,t.fillRect(Le+L,0,Se-L,y),s?t.fillStyle=$:ee?t.fillStyle=U:t.fillStyle=x,t.fillRect(Le+L,J,Se-L,p),!W&&N&&_!=null&&k!=null){const{selectedRanges:pe,cursorRow:fe}=e,{lastTop:xe,rowCount:ke}=o,hn=Re=>Re<=xe?Re/xe*(y-p):y-p+(Re-xe)/(ke-xe)*p;t.fillStyle=_;const Sn=[...pe].filter(Re=>Re.startRow!=null&&Re.endRow!=null).map(Re=>[Re.startRow,Re.endRow]).sort(G.compareRanges),Ct=G.mergeSortedRanges(Sn);for(let Re=0;Re<Ct.length;Re+=1){const st=Ct[Re],it=st[0],Mt=st[1];if(it!=null&&Mt!=null&&(it!==fe||Mt!==fe)){const Yt=hn(it),Xt=Se-L,Nt=Math.max(1,Math.round(hn(Mt+1)-Yt));t.fillRect(Le+L+Math.round(Xt/3),Yt,Math.round(Xt/3),Nt)}}if(fe!=null){const Re=Math.round(hn(fe)),st=Se-L,it=2;t.fillStyle=k,t.fillRect(Le+L,Re,st,it)}}}t.translate(-d,-c)}};let Wi=os;Wi.DEFAULT_FONT_WIDTH=10;Wi.DEFAULT_EDGE_RADIUS=2;Wi.ACTIVE_CELL_BORDER_WIDTH=2;const wh=100;class P0 extends Et{constructor(){super(...arguments),this.hasExtendedFloating=!1}onDown(e,n,s){const{x:i,y:o,column:r,row:l}=e,{metrics:a}=n;if(!a)throw new Error("metrics not set");const{gridX:d,gridY:c,maxX:u,maxY:m}=a,p=i-d,g=o-c;if(p<0||g<0||r==null&&p>u||l==null&&g>m)return!1;const f=G.isModifierKeyDown(s),b=s.shiftKey;f||(b?n.trimSelectedRanges():n.clearSelectedRanges());const C=n.getTheme(),{autoSelectRow:w,autoSelectColumn:T}=C;return(r!==null||!T)&&(l!==null||!w)&&(n.focus(),n.moveCursorToPosition(r,l,b,!1,b&&f)),this.startPoint=e,this.hasExtendedFloating=!1,this.dragBounds=G.getScrollDragBounds(a,l,r),!0}onDrag(e,n){if(this.startPoint===void 0)return!1;this.stopTimer();const{row:s,column:i}=this.startPoint,{x:o,y:r}=e;let{row:l,column:a}=e;const{metrics:d}=n;if(!d)throw new Error("metrics not set");const{left:c,lastLeft:u,top:m,lastTop:p,columnWidth:g,rowHeight:f}=d,b=G.getScrollDragBounds(d,s,i);let C=0,w=0;if(c<u&&(o<b.x1?C=o-b.x1:o>b.x2&&(C=o-b.x2)),m<p&&(r<b.y1?w=r-b.y1:r>b.y2&&(w=r-b.y2)),C!==0||w!==0)this.startTimer(n,e,C>0?Math.ceil(C/g):Math.floor(C/g),w>0?Math.ceil(w/f):Math.floor(w/f));else if(l!=null&&a!=null){const{floatingTopRowCount:T,floatingBottomRowCount:y,floatingLeftColumnCount:E,floatingRightColumnCount:I,columnCount:R,rowCount:F,bottom:x,right:U,topVisible:$,bottomVisible:O,leftVisible:H,rightVisible:L}=d;this.hasExtendedFloating||(s!==null&&s<T&&l>=T?(l=T,this.hasExtendedFloating=!0):s!==null&&s>=F-y&&l<F-y&&(l=F-y-1,this.hasExtendedFloating=!0),i!==null&&i<E&&a>=E?(a=E,this.hasExtendedFloating=!0):i!==null&&i>=R-I&&a<R-I&&(a=R-I-1,this.hasExtendedFloating=!0)),s!==null&&!G.isFloatingRow(s,d)&&G.isFloatingRow(l,d)&&(s>l&&l<m?l=$-1:s<l&&l>x&&(l=O+1)),i!==null&&!G.isFloatingColumn(i,d)&&G.isFloatingColumn(a,d)&&(i>a&&a<c?a=H-1:i<a&&a>U&&(a=L+1)),n.moveCursorToPosition(a,l,!0,!0)}return!0}onUp(e,n){return this.startPoint!==void 0&&(this.startPoint=void 0,this.dragBounds=void 0,this.stopTimer(),n.commitSelection()),!1}moveSelection(e,n,s,i){const{row:o,column:r}=n,{metrics:l}=e;if(!l)throw new Error("metrics not set");const{selectionEndRow:a,selectionEndColumn:d}=e.state;if(a==null||d==null)throw new Error("selection not set");const{rowCount:c,columnCount:u}=l,m=s<0&&r!=null?r:0,p=s>0&&r!=null?r:u-1,g=i<0&&o!=null?o:0,f=i>0&&o!=null?o:c-1;e.moveCursorToPosition(Math.min(Math.max(m,d+s),p),Math.min(Math.max(g,a+i),f),!0),this.lastTriggerTime=Date.now()}startTimer(e,n,s,i){this.stopTimer();const o=this.lastTriggerTime!=null?wh-Math.min(wh,Date.now()-this.lastTriggerTime):0;this.timer=setTimeout(()=>{this.moveSelection(e,n,s,i),this.startTimer(e,n,s,i)},o)}stopTimer(){this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0)}}const vh=5,H0=1e3/60,vr=10;function Es(t,e,n,s){var T,y,E,I,R,F,x;const{modelColumns:i,movedColumns:o,visibleColumnXs:r,columnCount:l,visibleColumnWidths:a,userColumnWidths:d,calculatedColumnWidths:c,floatingLeftWidth:u,maxX:m}=n;if(e==null||t==null||t>l||t<0)return null;const p=(T=i.get(t))!=null?T:G.getModelIndex(t,o),g=s.getColumnHeaderGroup(p,e),f=g!=null;let b,C,w;if(g!=null){const[U,$]=g.getVisibleRange(o);b=(y=r.get(U))!=null?y:u,C=((E=r.get($))!=null?E:m)+((I=a.get($))!=null?I:0),w=[U,$]}else{const U=r.get(t);if(U==null)return null;b=U,C=b+((x=(F=(R=a.get(t))!=null?R:d.get(p))!=null?F:c.get(p))!=null?x:0),w=[t,t]}return{visibleIndex:t,modelIndex:p,left:b,right:C,width:C-b,isColumnGroup:f,range:w,depth:e}}class V0 extends Et{constructor(){super(...arguments),this.cursor=null,this.draggingColumn=null}setScrollInterval(e,n){this.scrollingInterval!=null&&n===this.scrollingDirection||(this.scrollingDirection=n,this.scrollingInterval=window.setInterval(()=>{var f,b;const{metrics:s}=e;if(!s)return;const{left:i,lastLeft:o,leftOffset:r,userColumnWidths:l,calculatedColumnWidths:a,movedColumns:d,visibleColumnWidths:c}=s;let u=i,m=r;if(n==="left")for(m-=vr;m<0;){u-=1;const C=G.getModelIndex(i-1,d),w=(f=l.get(C))!=null?f:a.get(C);w===void 0?m=0:m+=w,u<0&&(m=0,u=0)}else{m+=vr;let C=c.get(i);for(;C!==void 0&&m>C;){u+=1,m-=C;const w=G.getModelIndex(i+1,d);C=(b=l.get(w))!=null?b:a.get(w),u>o&&(m=0,u=o)}}const{mouseX:p,mouseY:g}=e.state;s==null||p==null||g==null||(this.moveDraggingColumn(p,e,n==="left"?-vr:vr),e.setState({left:u,leftOffset:m}),(n==="left"&&u===0&&r===0||n==="right"&&u===o)&&this.clearScrollInterval())},H0))}clearScrollInterval(){this.scrollingDirection=void 0,window.clearInterval(this.scrollingInterval),this.scrollingInterval=void 0}onLeave(){return this.clearScrollInterval(),!1}onDown(e,n){const{model:s}=n.props,{x:i,column:o,columnHeaderDepth:r}=e,{metrics:l}=n;if(!l)throw new Error("Metrics not set");const a=Es(o,r,l,s);if(o==null||a==null||r==null||r>0&&!a.isColumnGroup)return!1;const{rowHeaderWidth:d}=l;return this.initialGridPoint=e,this.draggingColumn=null,this.cursor=null,a.modelIndex!=null&&r!=null&&s.isColumnMovable(a.modelIndex,r)&&(this.draggingOffset=i-a.left-d,this.initialOffset=this.draggingOffset),!1}onDrag(e,n,s){if(this.draggingOffset===void 0||this.initialGridPoint===void 0||this.initialOffset===void 0)return!1;const{x:i,y:o}=e,{columnHeaderDepth:r}=this.initialGridPoint,{model:l}=n.props;let{draggingColumn:a}=this;const{metrics:d}=n;if(!d)throw new Error("Metrics not set");if(!a&&Math.abs(this.initialGridPoint.x-i)<vh&&Math.abs(this.initialGridPoint.y-o)<vh)return!1;if(a==null){const c=Es(this.initialGridPoint.column,r,d,l);if(!c||r==null||!l.isColumnMovable(c.modelIndex)||r>0&&!c.isColumnGroup||c.range[0]==null)return!1;a={range:c.range,depth:r,left:c.left,width:c.width};const u=Es(a.range[0],0,d,l),m=Es(a.range[1],0,d,l);if(!u||!m)return!1;this.draggingColumn=a,n.setState({draggingColumn:a,isDragging:!0})}return this.cursor="move",this.moveDraggingColumn(e.x,n,s.movementX),!0}moveDraggingColumn(e,n,s){var R,F,x,U,$;if(this.draggingOffset===void 0||this.initialGridPoint===void 0||this.initialOffset===void 0||this.draggingColumn==null||s===0)return;if(this.initialOffset!==this.draggingOffset){this.draggingOffset<this.initialOffset&&this.initialOffset<this.draggingOffset+s||this.draggingOffset>this.initialOffset&&this.initialOffset>this.draggingOffset+s?this.draggingOffset=this.initialOffset:this.draggingOffset+=s,this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},n.setState({draggingColumn:this.draggingColumn});return}const{depth:i}=this.draggingColumn,{model:o}=n.props,{movedColumns:r}=n.state,{metrics:l}=n;if(!l)throw new Error("Metrics not set");const{floatingLeftWidth:a,width:d,columnHeaderMaxDepth:c,visibleColumnXs:u}=l,m=s<0,p=Es(this.draggingColumn.range[0],i,l,o);if(!p)return;const g=e-this.draggingOffset,f=g+p.width;this.draggingColumn={...this.draggingColumn,left:g},n.setState({draggingColumn:this.draggingColumn});const b=Es(G.getColumnAtX(At(m?g:f,a,d),l,!0),i,l,o),C=o.getColumnHeaderParentGroup(p.modelIndex,p.depth);if(!b)return;if(C!==void 0){const O=C.getVisibleRange(r);if(b.visibleIndex<O[0]){const H=this.moveColumn(p,O[0],r);this.draggingOffset=e-((R=u.get(O[0]))!=null?R:0),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},this.clearScrollInterval(),n.setState({draggingColumn:this.draggingColumn,movedColumns:H});return}if(b.visibleIndex>O[1]){const H=this.moveColumn(p,O[1]-(p.range[1]-p.range[0]),r),{right:L=0}=(F=Es(O[1],0,l,o))!=null?F:{};this.draggingOffset=e-(L-p.width),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},this.clearScrollInterval(),n.setState({draggingColumn:this.draggingColumn,movedColumns:H});return}}if(!o.isColumnMovable(b.modelIndex)){let O=b.visibleIndex;if(m)for(O+=1;O<p.visibleIndex&&!o.isColumnMovable(G.getModelIndex(O,r));)O+=1;else for(O-=1;O>p.visibleIndex&&!o.isColumnMovable(G.getModelIndex(O,r));)O-=1;if(O!==p.visibleIndex){m||(O-=p.range[1]-p.range[0]);const L=this.moveColumn(p,O,r);n.setState({movedColumns:L,draggingColumn:this.draggingColumn})}const H=Es(O,0,l,o);m?this.draggingOffset=e-((x=H==null?void 0:H.left)!=null?x:0):this.draggingOffset=e-(((U=H==null?void 0:H.right)!=null?U:0)-p.width),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},n.setState({draggingColumn:this.draggingColumn});return}if(g<=a?this.setScrollInterval(n,"left"):f>d?this.setScrollInterval(n,"right"):this.clearScrollInterval(),b.visibleIndex===p.visibleIndex||m&&p.visibleIndex<b.visibleIndex||!m&&p.visibleIndex>b.visibleIndex)return;const w=b.left+b.width*.5,T=o.getColumnHeaderParentGroup(p.modelIndex,p.depth);let y,E=(($=T==null?void 0:T.depth)!=null?$:c)-1;for(;E>=0&&y===void 0;)y=o.getColumnHeaderGroup(b.modelIndex,E),E-=1;let I;m&&g<w&&(!y||b.visibleIndex===y.getVisibleRange(r)[0])&&(I=this.moveColumn(p,b.range[0],r)),!m&&f>w&&(!y||b.visibleIndex===y.getVisibleRange(r)[1])&&(I=this.moveColumn(p,b.range[1]-(p.range[1]-p.range[0]),r)),I&&(this.draggingColumn={...this.draggingColumn,left:g},n.setState({movedColumns:I,draggingColumn:this.draggingColumn}))}moveColumn(e,n,s){const i=e.isColumnGroup?G.moveRange(e.range,n,s):G.moveItem(e.visibleIndex,n,s),o=n-e.range[0],r=[e.range[0]+o,e.range[1]+o];return this.draggingColumn&&(this.draggingColumn={...this.draggingColumn,range:r}),i}onUp(e,n){return this.cursor=null,this.clearScrollInterval(),this.draggingOffset!=null?(this.draggingOffset=void 0,n.setState({draggingColumn:null,isDragging:!1}),!0):!1}}class Od extends Et{constructor(){super(...arguments),this.cursor="default"}static getLeftWithOffsetFromRawLeft(e,n){const s=e.getTheme(),{metrics:i,metricCalculator:o}=e;if(!i)throw new Error("metrics not set");if(s.scrollSnapToColumn)return{left:Math.round(n),leftOffset:0};const r=Math.floor(n),l=n-r;let a=i.visibleColumnWidths.get(r);if(a==null){const c=e.getMetricState();a=o.getVisibleColumnWidth(r,c)}const d=a*l;return{left:r,leftOffset:d}}isInScrollBar(e,n){const s=n.getTheme(),{scrollBarSize:i,scrollBarHoverSize:o}=s,{metrics:r}=n;if(!r)throw new Error("metrics not set");const{x:l,y:a}=e,{barLeft:d,barWidth:c,height:u,hasHorizontalBar:m}=r;return m&&i>0&&a>=u-o&&a<u&&l>d&&l<d+c}getLeftWithOffset(e,n){var f;const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{x:i}=e,{barWidth:o,handleWidth:r,lastLeft:l,barLeft:a,columnCount:d,scrollableContentWidth:c,scrollableViewportWidth:u}=s,m=i-a,p=At((m-((f=this.dragOffset)!=null?f:0))/(o-r),0,1);if(d===1)return{left:0,leftOffset:p*(c-u)};const g=p*l;return Od.getLeftWithOffsetFromRawLeft(n,g)}onDown(e,n){const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{x:i}=e,{handleWidth:o,barLeft:r,scrollX:l}=s;if(!this.isInScrollBar(e,n))return!1;const a=i-r;if(a>=l&&a<=l+o)this.dragOffset=a-l,n.setState({isDraggingHorizontalScrollBar:!0});else{this.dragOffset=0;const{left:d,leftOffset:c}=this.getLeftWithOffset(e,n);n.setViewState({left:d,leftOffset:c,isDraggingHorizontalScrollBar:!0,isDragging:!0})}return!0}onDrag(e,n){if(this.dragOffset!=null){const{left:s,leftOffset:i}=this.getLeftWithOffset(e,n);return n.setViewState({left:s,leftOffset:i,isDraggingHorizontalScrollBar:!0,isDragging:!0}),!0}return!1}onMove(e,n){return this.isInScrollBar(e,n)}onUp(e,n){return this.dragOffset!==void 0&&(this.dragOffset=void 0,n.setState({isDraggingHorizontalScrollBar:!1,isDragging:!1})),this.isInScrollBar(e,n)}onClick(e,n){return this.isInScrollBar(e,n)}}class U0 extends Et{constructor(){super(...arguments),this.cursor="move"}onDown(e,n){const{model:s}=n.props,{x:i,y:o,row:r}=e,{metrics:l}=n;if(!l)throw new Error("metrics not set");const{columnHeaderHeight:a,rowHeaderWidth:d,visibleRowYs:c}=l;if(i<=d&&r!==null&&s.isRowMovable(r)){const u=B(c,r);this.draggingOffset=o-u-a,n.setState({draggingRowOffset:this.draggingOffset})}return!1}onDrag(e,n){if(this.draggingOffset==null)return!1;const{model:s}=n.props;let{draggingRow:i}=n.state;const{mouseX:o,mouseY:r}=n.state;if(o==null||r==null)return!1;if(i==null){const{row:I}=n.getGridPointFromXY(o,r);if(I!=null&&!s.isRowMovable(I)||(i=I,n.setState({draggingRow:i,isDragging:!0}),i==null))return!1}const{metrics:l}=n;if(!l)throw new Error("metrics not set");const{top:a,lastTop:d,bottom:c,bottomVisible:u,rowCount:m,columnHeaderHeight:p,visibleRowHeights:g,visibleRowYs:f,height:b}=l;let C=p;if(a<i){const I=i-1;C=B(f,I)+B(g,I)*.5+p}let w=b;if(i<c){const I=i+1;w=B(f,I)+B(g,I)*.5+p}let{movedRows:T}=n.state;r<C&&i>0&&s.isRowMovable(i-1)?(T=G.moveItem(i,i-1,T),i-=1):w<r&&i<m-1&&s.isRowMovable(i+1)&&(T=G.moveItem(i,i+1,T),i+=1),n.setState({movedRows:T,draggingRow:i});const y=p+B(g,a)*.5,E=p+B(f,u)+B(g,u)*.5;return r<y&&a>0?n.setState({top:a-1}):r>E&&a<d&&n.setState({top:a+1}),!0}onUp(e,n){return this.draggingOffset!==void 0?(this.draggingOffset=void 0,n.setState({draggingRowOffset:null,draggingRow:null,isDragging:!1}),!0):!1}}class Ld extends Qm{constructor(){super(...arguments),this.hiddenCursor="s-resize",this.defaultCursor="row-resize",this.pointProperty="y",this.userSizesProperty="userRowHeights",this.visibleOffsetProperty="visibleRowYs",this.visibleSizesProperty="visibleRowHeights",this.marginProperty="columnHeaderHeight",this.calculatedSizesProperty="calculatedRowHeights",this.modelIndexesProperty="modelRows",this.firstIndexProperty="firstRow",this.treePaddingProperty="treePaddingY",this.getHiddenItems=G.getHiddenRows,this.getNextShownItem=G.getNextShownRow,this.getSeparator=Ld.getRowSeparator}static getRowSeparator(e,n,s,i){if(!i.allowRowResize)return null;const{x:o,y:r}=e,l=G.getRowSeparatorIndex(o,r,n,i);return l!=null?{index:l,depth:0}:null}setSize(e,n,s){e.setRowHeight(n,s)}resetSize(e,n){e.resetRowHeight(n)}updateSeparator(e,n){e.setState({draggingRowSeparator:n,isDragging:n!==null})}}class Jr extends Et{static isInTreeBox(e,n){const{column:s,row:i,x:o,y:r}=e,{metrics:l}=n;if(!l)throw new Error("metrics not set");const{gridX:a,gridY:d,firstColumn:c,visibleColumnXs:u,visibleColumnWidths:m,visibleRowHeights:p,visibleRowYs:g,visibleRowTreeBoxes:f}=l;if(s===c&&i!=null&&f.get(i)!=null&&o>a&&r>d){const b=B(u,s),C=B(m,s),w=B(g,i),T=B(p,i);if(o>=a+b&&o<=a+b+C&&r>=d+w&&r<=d+w+T)return!0}return!1}onDown(e,n){return Jr.isInTreeBox(e,n)}onClick(e,n){if(Jr.isInTreeBox(e,n)){const{row:s}=e;if(s!==null)return n.toggleRowExpanded(s),!0}return!1}}class B0 extends Et{isInCorner(e,n){const s=n.getTheme(),{scrollBarSize:i}=s,{metrics:o}=n;if(!o)throw new Error("metrics not set");const{x:r,y:l}=e,{width:a,height:d,hasVerticalBar:c,hasHorizontalBar:u}=o;return i>0&&c&&u&&r>=a-i&&l>=d-i&&r<=a&&l<=d}onDown(e,n){return this.isInCorner(e,n)}onUp(e,n){return this.isInCorner(e,n)}onClick(e,n){return this.isInCorner(e,n)}}class Ad extends Et{constructor(){super(...arguments),this.cursor="default"}static getTopWithOffsetFromRawTop(e,n){const s=e.getTheme(),{metrics:i,metricCalculator:o}=e;if(!i)throw new Error("metrics not set");if(s.scrollSnapToRow)return{top:Math.round(n),topOffset:0};const r=Math.floor(n),l=n-r;let a=i.visibleRowHeights.get(r);if(a==null){const c=e.getMetricState();a=o.getVisibleRowHeight(r,c)}const d=a*l;return{top:r,topOffset:d}}isInScrollBar(e,n){const s=n.getTheme(),{scrollBarSize:i,scrollBarHoverSize:o}=s,{metrics:r}=n;if(!r)throw new Error("metrics not set");const{x:l,y:a}=e,{barTop:d,barHeight:c,width:u,hasVerticalBar:m}=r;return m&&i>0&&l>=u-o&&l<u&&a>d&&a<d+c}getTopWithOffset(e,n){var f;const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{y:i}=e,{barHeight:o,handleHeight:r,lastTop:l,barTop:a,rowCount:d,scrollableContentHeight:c,scrollableViewportHeight:u}=s,m=i-a,p=At((m-((f=this.dragOffset)!=null?f:0))/(o-r),0,1);if(d===1)return{top:0,topOffset:p*(c-u)};const g=p*l;return Ad.getTopWithOffsetFromRawTop(n,g)}onDown(e,n){const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{y:i}=e,{handleHeight:o,barTop:r,scrollY:l}=s;if(!this.isInScrollBar(e,n))return!1;const a=i-r;if(a>=l&&a<=l+o)this.dragOffset=a-l,n.setState({isDraggingVerticalScrollBar:!0});else{this.dragOffset=0;const{top:d,topOffset:c}=this.getTopWithOffset(e,n);n.setViewState({top:d,topOffset:c,isDraggingVerticalScrollBar:!0,isDragging:!0})}return!0}onMove(e,n){return this.isInScrollBar(e,n)}onDrag(e,n){if(this.dragOffset!=null){const{top:s,topOffset:i}=this.getTopWithOffset(e,n);return n.setViewState({top:s,topOffset:i,isDraggingVerticalScrollBar:!0,isDragging:!0}),!0}return!1}onUp(e,n){return this.dragOffset!==void 0&&(this.dragOffset=void 0,n.setState({isDraggingVerticalScrollBar:!1,isDragging:!1})),this.isInScrollBar(e,n)}onClick(e,n){return this.isInScrollBar(e,n)}}class $0 extends Et{onDoubleClick({column:e,row:n},s){const{model:i}=s.props;return Ze(i)&&e!=null&&n!=null&&i.isEditableRange(re.makeCell(e,n))?(s.startEditing(e,n),!0):!1}}class Ci{constructor(e=5e3){this.order=e}onDown(e,n){return!1}}class z0 extends Ci{onDown(e,n){switch(e.key){case"a":if(G.isModifierKeyDown(e))return n.selectAll(),!0;break;case"ArrowUp":return this.handleArrowMove(0,-1,e,n);case"ArrowDown":return this.handleArrowMove(0,1,e,n);case"ArrowRight":return this.handleArrowMove(1,0,e,n);case"ArrowLeft":return this.handleArrowMove(-1,0,e,n);case"k":case"K":return G.isModifierKeyDown(e)?!1:this.handlePageUp(e,n);case"j":case"J":return G.isModifierKeyDown(e)?!1:this.handlePageDown(e,n);case"h":case"H":return G.isModifierKeyDown(e)?!1:(e.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(0,n.state.cursorRow,e.shiftKey),!0);case"l":case"L":{if(G.isModifierKeyDown(e))return!1;const{model:s}=n.props,{columnCount:i}=s;return e.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(i-1,n.state.cursorRow,e.shiftKey),!0}case"PageDown":return this.handlePageDown(e,n);case"PageUp":return this.handlePageUp(e,n);case"Home":return e.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(G.isModifierKeyDown(e)?n.state.cursorColumn:0,G.isModifierKeyDown(e)?0:n.state.cursorRow,e.shiftKey,!0,!0),!0;case"End":{const{model:s}=n.props,{columnCount:i,rowCount:o}=s;return e.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(G.isModifierKeyDown(e)?n.state.cursorColumn:i-1,G.isModifierKeyDown(e)?o-1:n.state.cursorRow,e.shiftKey,!0,!0),!0}case"Escape":return n.clearSelectedRanges(),!0;case"Enter":if(n.state.selectedRanges.length>0)return n.moveCursorInDirection(e.shiftKey?re.SELECTION_DIRECTION.UP:re.SELECTION_DIRECTION.DOWN),!0;break;case"Tab":if(n.state.selectedRanges.length>0)return n.moveCursorInDirection(e.shiftKey?re.SELECTION_DIRECTION.LEFT:re.SELECTION_DIRECTION.RIGHT),!0;break}return!1}handleArrowMove(e,n,s,i){const o=s.shiftKey,r=G.isModifierKeyDown(s);o?i.trimSelectedRanges():i.clearSelectedRanges();const{cursorRow:l,cursorColumn:a,selectionEndColumn:d,selectionEndRow:c}=i.state,u=o?d:a,m=o?c:l;if(r){const{model:p}=i.props,{columnCount:g,rowCount:f}=p,b=r&&o;let C=null,w=null;e<0?(C=0,w=m):e>0?(C=g-1,w=m):n<0?(C=u,w=0):n>0&&(C=u,w=f-1),C!=null&&w!=null&&i.moveCursorToPosition(C,w,o,!0,b)}else{if(!i.metrics)throw new Error("grid.metrics are not set");const{theme:p}=i.props,{autoSelectRow:g=!1,autoSelectColumn:f=!1}=p;if(g&&e!==0){const{lastLeft:b}=i.metrics;let{left:C}=i.state;C=At(C+e,0,b),i.moveCursorToPosition(C,l,o,!1),i.setViewState({left:C})}else if(f&&n!==0){const{lastTop:b}=i.metrics;let{top:C}=i.state;C=At(C+n,0,b),i.moveCursorToPosition(C,a,o,!1),i.setViewState({top:C})}else i.moveCursor(e,n,o)}return!0}handlePageUp(e,n){const s=e.shiftKey;s?n.trimSelectedRanges():n.clearSelectedRanges();const{cursorColumn:i,selectionEndRow:o}=n.state,r=o,l=i;if(r==null)return!1;const a=n.getMetricState(),{metricCalculator:d}=n,{bottomVisible:c,topVisible:u,hasHorizontalBar:m}=d.getMetrics(a);let p=r-(c-u);p-=m?0:1,p=Math.max(p,0);const g=Math.max(p-(r-u),0);return n.moveCursorToPosition(l,p,s,!1),n.setViewState({top:g}),!0}handlePageDown(e,n){const s=e.shiftKey;s?n.trimSelectedRanges():n.clearSelectedRanges();const{selectionEndRow:i,cursorColumn:o}=n.state,r=i,l=o;if(r===null)return!1;const a=n.getMetricState(),{metricCalculator:d}=n,{bottomVisible:c,topVisible:u,hasHorizontalBar:m,rowCount:p,lastTop:g}=d.getMetrics(a),f=p-1;let b=c-u+r;b+=m?0:1,b=Math.min(b,f);const C=Math.min(g,b-(r-u));return n.moveCursorToPosition(l,b,s,!1),n.setViewState({top:C}),!0}}class W0 extends Ci{onDown(e,n){switch(e.key){case"Enter":case" ":return this.handleExpandKey(e,n)}return!1}handleExpandKey(e,n){const{selectedRanges:s}=n.state;if(s.length===1){const i=s[0];if(i.startRow===i.endRow&&i.startColumn===i.endColumn){if(!n.metrics)throw new Error("grid.metrics not set");const{model:o}=n.props,{startRow:r,startColumn:l}=i;if(r!=null){const a=n.getModelRow(r);if((l===0||l==null)&>(o)&&o.isRowExpandable(a))return n.toggleRowExpanded(r),!0}}}return!1}}class G0 extends Ci{onDown(e,n){if(G.isModifierKeyDown(e))return!1;const{model:s}=n.props,{cursorColumn:i,cursorRow:o}=n.state;if(i==null||o==null||!Ze(s)||!s.isEditableRange(re.makeCell(i,o)))return!1;const r=i,l=o;return r==null||l==null?!1:e.key.length===1?(n.startEditing(r,l,!0,[1,1],e.key),!0):e.key==="F2"?(n.startEditing(r,l),!0):e.key==="Backspace"?(n.startEditing(r,l,!0,void 0,""),!0):e.key==="Delete"?(n.setValueForCell(r,l,""),!0):!1}}function K0(t){var s,i;const e=[],n=t.querySelectorAll("tr");for(let o=0;o<n.length;o+=1){const l=n[o].querySelectorAll("td"),a=[];for(let d=0;d<l.length;d+=1){const c=l[d];a.push((i=(s=c.textContent)==null?void 0:s.trim())!=null?i:"")}e.push(a)}return e}function q0(t){const e=[];return t.forEach(n=>{var i;const s=(i=n.textContent)!=null?i:"";s.length>0&&e.push(s.split(/\t|\u00a0\u00a0 \u00a0/))}),e}function Y0(t){var s,i;const e=t.querySelector("table");if(e!=null)return K0(e);const n=(i=(s=t.textContent)==null?void 0:s.trim())!=null?i:"";if(n.length>0){const{childNodes:o}=t,r=n.includes(" "),l=n.includes("\xA0\xA0 \xA0");return r&&o.length!==0&&(o.length===1||o.length>1&&(o[0].textContent==null||!o[0].textContent.includes(" ")))?n.split(`
|
|
23
23
|
`).map(a=>a.split(" ")):o.length>1||l?q0(t.childNodes):n}return null}class X0 extends Ci{onDown(e,n){switch(e.key){case"v":if(G.isModifierKeyDown(e)){const s=document.createElement("div");document.body.appendChild(s),s.setAttribute("contenteditable","true"),s.setAttribute("style",'clip-path: "inset(50%)"; height: 1px; width: 1px; margin: -1px; overflow: hidden; padding 0; position: absolute;');const i=()=>{s.removeEventListener("input",i),s.remove(),n.focus();const o=Y0(s);o!=null&&n.pasteValue(o)};return s.addEventListener("input",i),s.focus(),{preventDefault:!1,stopPropagation:!0}}break}return!1}}const j0=t=>{switch(t){case"ArrowDown":return Dn.DOWN;case"ArrowUp":return Dn.UP;case"ArrowLeft":return Dn.LEFT;case"ArrowRight":return Dn.RIGHT;default:return}},Pd=({selectionRange:t=void 0,className:e="",disabled:n=!1,value:s="",isQuickEdit:i=!0,onChange:o=()=>{},onCancel:r=()=>{},onDone:l=()=>{},onContextMenu:a=()=>{},style:d={}})=>{const c=S.exports.useRef(null),u=S.exports.useRef(!1),[m]=S.exports.useState(s),[p,g]=S.exports.useState(!1),[f,b]=S.exports.useState(i),[C,w]=S.exports.useState(s);S.exports.useEffect(function(){const{current:O}=c;O!=null&&(O.focus(),t?O.setSelectionRange(t[0],t[1]):O.setSelectionRange(O.value.length,O.value.length))},[t]);const T=S.exports.useCallback($=>{o($)},[o]),y=S.exports.useCallback($=>{const{value:O}=$.target;w(O),g(!0),T(O)},[T,w,g]),E=S.exports.useCallback(()=>{u.current=!0,p&&T(m),g(!1),r()},[m,p,r,T]),I=S.exports.useCallback(()=>{b(!1)},[b]),R=S.exports.useCallback(($,O=!1)=>{l(C,{direction:$,fillRange:O})},[l,C]),F=S.exports.useCallback(()=>{u.current||R(null)},[u,R]),x=S.exports.useCallback($=>{switch($.stopPropagation(),$.key){case"Escape":$.preventDefault(),E();break;case"Enter":if($.preventDefault(),G.isModifierKeyDown($))R(void 0,!0);else if($.altKey){const O=`${C}
|
|
24
24
|
`;w(O),g(!0),T(O)}else R($.shiftKey?Dn.UP:Dn.DOWN);break;case"Tab":$.preventDefault(),R($.shiftKey?Dn.LEFT:Dn.RIGHT);break;case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":f&&($.preventDefault(),R(j0($.key)));break}},[E,R,f,w,g,T,C]),U=S.exports.useCallback($=>{a($)},[a]);return h("textarea",{ref:c,className:z("grid-cell-input-field",e),value:C,onBlur:F,onChange:y,onKeyDown:x,onContextMenu:U,onClick:I,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false",disabled:n,style:d})};Pd.propTypes={selectionRange:D.exports.arrayOf(D.exports.number),className:D.exports.string,disabled:D.exports.bool,isQuickEdit:D.exports.bool,value:D.exports.string,onChange:D.exports.func,onCancel:D.exports.func,onDone:D.exports.func,onContextMenu:D.exports.func,style:D.exports.shape({})};Pd.defaultProps={selectionRange:null,className:"",disabled:!1,value:"",isQuickEdit:!0,onChange:()=>{},onCancel:()=>{},onDone:()=>{},onContextMenu:()=>{},style:{}};const Q0=Y.createContext({}),Qs=class extends S.exports.PureComponent{constructor(t){super(t),this.getCachedKeyHandlers=he(l=>[...l,...this.keyHandlers].sort((a,d)=>a.order-d.order)),this.getCachedMouseHandlers=he(l=>[...l,...this.mouseHandlers].sort((a,d)=>a.order-d.order)),this.handleClick=this.handleClick.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.handleEditCellCancel=this.handleEditCellCancel.bind(this),this.handleEditCellChange=this.handleEditCellChange.bind(this),this.handleEditCellCommit=this.handleEditCellCommit.bind(this),this.handleDoubleClick=this.handleDoubleClick.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseDrag=this.handleMouseDrag.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this.handleResize=this.handleResize.bind(this),this.handleWheel=this.handleWheel.bind(this);const{isStuckToBottom:e,isStuckToRight:n,metricCalculator:s,movedColumns:i,movedRows:o,renderer:r}=t;this.renderer=r||new Wi,this.metricCalculator=s||new qo,this.canvas=null,this.canvasContext=null,this.animationFrame=null,this.prevMetrics=null,this.metrics=null,this.documentCursor=null,this.dragTimer=null,this.keyHandlers=[new G0(400),new X0(450),new z0(500),new W0(900)],this.mouseHandlers=[new Ld(100),new Fl(200),new U0(300),new V0(400),new $0(450),new Ad(500),new Od(600),new B0(700),new Jr(800),new P0(900)],this.state={top:0,left:0,topOffset:0,leftOffset:0,draggingColumn:null,draggingRow:null,draggingRowOffset:null,draggingColumnSeparator:null,draggingRowSeparator:null,isDraggingHorizontalScrollBar:!1,isDraggingVerticalScrollBar:!1,isDragging:!1,mouseX:null,mouseY:null,movedColumns:i,movedRows:o,cursorRow:null,cursorColumn:null,selectionStartRow:null,selectionStartColumn:null,selectionEndRow:null,selectionEndColumn:null,selectedRanges:[],lastSelectedRanges:[],cursor:null,editingCell:null,isStuckToBottom:e,isStuckToRight:n}}static getScale(t){const e=window.devicePixelRatio||1,n=t,s=n.webkitBackingStorePixelRatio||n.mozBackingStorePixelRatio||n.msBackingStorePixelRatio||n.oBackingStorePixelRatio||n.backingStorePixelRatio||1;return e/s}static getCursorClassName(t){return t!=null&&t!==""?`grid-cursor-${t}`:null}componentDidMount(){var t;this.initContext(),(t=this.canvas)==null||t.addEventListener("wheel",this.handleWheel,{passive:!1}),window.addEventListener("resize",this.handleResize),this.updateCanvasScale(),this.updateCanvas()}componentDidUpdate(t,e){const{isStickyBottom:n,isStickyRight:s,movedColumns:i,movedRows:o,onMovedColumnsChanged:r,onMoveColumnComplete:l,onMovedRowsChanged:a,onMoveRowComplete:d}=this.props,{isStickyBottom:c,isStickyRight:u,movedColumns:m,movedRows:p}=t,{movedColumns:g,movedRows:f}=e,{draggingColumn:b,draggingRow:C,movedColumns:w,movedRows:T}=this.state;if(m!==i&&this.setState({movedColumns:i}),p!==o&&this.setState({movedRows:o}),g!==w&&r(w),e.draggingColumn!=null&&b==null&&l(w),f!==T&&a(T),e.draggingRow!=null&&C==null&&d(T),n!==c&&this.setState({isStuckToBottom:!1}),s!==u&&this.setState({isStuckToRight:!1}),this.updateMetrics(),this.requestUpdateCanvas(),!this.metrics||!this.prevMetrics)return;const{bottomVisible:y,rightVisible:E,rowCount:I,columnCount:R,top:F,left:x,height:U,width:$}=this.metrics,{rowCount:O,columnCount:H,height:L,width:N}=this.prevMetrics,_=this.getMetricState();if(O!==I||U!==L){const k=this.metricCalculator.getLastTop(_),{isStuckToBottom:V}=this.state;(V&&y<I-1&&y>0||F>k)&&this.setState({top:k})}if(H!==R||$!==N){const k=this.metricCalculator.getLastLeft(_),{isStuckToRight:V}=this.state;(V&&E<R-1&&E>0||x>k)&&this.setState({left:k})}this.validateSelection()&&this.checkSelectionChange(e)}componentWillUnmount(){var t;this.animationFrame!=null&&cancelAnimationFrame(this.animationFrame),(t=this.canvas)==null||t.removeEventListener("wheel",this.handleWheel),window.removeEventListener("mousemove",this.handleMouseDrag,!0),window.removeEventListener("mouseup",this.handleMouseUp,!0),window.removeEventListener("resize",this.handleResize),this.stopDragTimer()}getTheme(){const{theme:t}=this.props;return Qs.getTheme(this.context,t)}getGridPointFromEvent(t){fh(this.canvas);const e=this.canvas.getBoundingClientRect(),n=t.clientX-e.left,s=t.clientY-e.top;return this.getGridPointFromXY(n,s)}getGridPointFromXY(t,e){if(!this.metrics)throw new Error("metrics must be set");return G.getGridPointFromXY(t,e,this.metrics)}getMetricState(t=this.state){const e=this.getTheme(),{model:n,stateOverride:s}=this.props;if(!this.canvasContext||!this.canvas)throw new Error("Canvas and context must be defined to get metrics");const i=this.canvasContext,o=this.canvas.clientWidth,r=this.canvas.clientHeight,{left:l,top:a,leftOffset:d,topOffset:c,movedColumns:u,movedRows:m,isDraggingHorizontalScrollBar:p,isDraggingVerticalScrollBar:g,draggingColumn:f}=t;return{left:l,top:a,leftOffset:d,topOffset:c,width:o,height:r,context:i,theme:e,model:n,movedColumns:u,movedRows:m,isDraggingHorizontalScrollBar:p,isDraggingVerticalScrollBar:g,draggingColumn:f,...s}}getKeyHandlers(){const{keyHandlers:t}=this.props;return this.getCachedKeyHandlers(t)}getMouseHandlers(){const{mouseHandlers:t}=this.props;return this.getCachedMouseHandlers(t)}getModelColumn(t){var n,s;const e=(s=(n=this.metrics)==null?void 0:n.modelColumns)==null?void 0:s.get(t);if(e===void 0)throw new Error(`Unable to get ModelIndex for column ${t}`);return e}getModelRow(t){var n,s;const e=(s=(n=this.metrics)==null?void 0:n.modelRows)==null?void 0:s.get(t);if(e===void 0)throw new Error(`Unable to get ModelIndex for row ${t}`);return e}toggleRowExpanded(t){const e=this.getModelRow(t),{model:n}=this.props;gt(n)&&n.isRowExpandable(e)&&n.setRowExpanded(e,!n.isRowExpanded(e)),this.clearSelectedRanges(),this.commitSelection(),this.moveCursorToPosition(0,t),this.commitSelection(),this.setState({isStuckToBottom:!1})}setSelectedRanges(t){const{model:e}=this.props,{columnCount:n,rowCount:s}=e,{cursorRow:i,cursorColumn:o,selectedRanges:r}=this.state;if(this.setState({selectedRanges:t,lastSelectedRanges:r}),t.length>0){const l=re.boundedRange(t[0],n,s);let a=i,d=o;l.containsCell(o,i)||({row:a,column:d}=l.startCell()),this.setState({selectionStartColumn:l.startColumn,selectionStartRow:l.startRow,selectionEndColumn:l.endColumn,selectionEndRow:l.endRow,cursorColumn:d,cursorRow:a})}}initContext(){const{canvas:t}=this,{canvasOptions:e}=this.props;if(!t)throw new Error("Canvas not set");this.canvasContext=t.getContext("2d",e)}requestUpdateCanvas(){this.animationFrame==null&&(this.animationFrame=requestAnimationFrame(()=>{if(this.animationFrame=null,!this.metrics)throw new Error("Metrics not set");this.updateCanvas(this.metrics)}))}updateCanvas(t=this.updateMetrics()){this.updateCanvasScale();const{onViewChanged:e}=this.props;e(t),this.drawCanvas(t)}updateCanvasScale(){const{canvas:t,canvasContext:e}=this;if(!t)throw new Error("canvas not set");if(!e)throw new Error("canvasContext not set");if(!t.parentElement)throw new Error("Canvas has no parent element");const n=Qs.getScale(e),s=t.parentElement.getBoundingClientRect(),i=Math.floor(s.width),o=Math.floor(s.height);t.style.width=`${i}px`,t.style.height=`${o}px`,t.width=i*n,t.height=o*n,e.scale(n,n)}updateMetrics(t=this.state){this.prevMetrics=this.metrics;const{metricCalculator:e}=this,n=this.getMetricState(t);return this.metrics=e.getMetrics(n),this.metrics}checkSelectionChange(t){const{selectedRanges:e}=t,{selectedRanges:n}=this.state;if(n!==e){const{onSelectionChanged:s}=this.props;s(n)}}validateSelection(){const{model:t}=this.props,{selectedRanges:e}=this.state,{columnCount:n,rowCount:s}=t;for(let i=0;i<e.length;i+=1){const o=e[i];if(o.endColumn!=null&&o.endColumn>=n||o.endRow!=null&&o.endRow>=s)return this.setState({selectedRanges:[],lastSelectedRanges:[]}),!1}return!0}clearSelectedRanges(){const{selectedRanges:t}=this.state;this.setState({selectedRanges:[],lastSelectedRanges:t})}trimSelectedRanges(){const{selectedRanges:t}=this.state;t.length>0&&this.setState({selectedRanges:t.slice(t.length-1)})}beginSelection(t,e){this.setState({selectionStartColumn:t,selectionStartRow:e,selectionEndColumn:t,selectionEndRow:e,cursorColumn:t,cursorRow:e})}moveSelection(t,e,n=!1,s=!1){this.setState(i=>{var g,f,b,C;const{selectedRanges:o,selectionStartRow:r,selectionStartColumn:l}=i,{theme:a}=this.props,{autoSelectRow:d,autoSelectColumn:c}=a;if(n&&o.length>0){const w=o[o.length-1];let T=null,y=null,E=null,I=null;s?(T=d!==void 0&&d?null:Math.min(t!=null?t:0,(g=w.startColumn)!=null?g:0),y=c!==void 0&&c?null:Math.min(e!=null?e:0,(f=w.startRow)!=null?f:0),E=d!==void 0&&d?null:Math.max(t!=null?t:0,(b=w.endColumn)!=null?b:0),I=c!==void 0&&c?null:Math.max(e!=null?e:0,(C=w.endRow)!=null?C:0)):(T=w.startColumn,y=w.startRow,(l!=null||r!=null)&&((d===void 0||!d)&&(T=l),(c===void 0||!c)&&(y=r)),E=d!==void 0&&d?null:t,I=c!==void 0&&c?null:e);const R=re.makeNormalized(T,y,E,I);if(w.equals(R))return null;const F=[...o];return F[F.length-1]=R,{selectedRanges:F,selectionEndColumn:t,selectionEndRow:e}}const u=[...o],m=d!==void 0&&d?null:t,p=c!==void 0&&c?null:e;return u.push(re.makeNormalized(m,p,m,p)),{selectedRanges:u,selectionEndColumn:t,selectionEndRow:e}})}commitSelection(){this.setState(t=>{const{theme:e}=this.props,{autoSelectRow:n}=e,{selectedRanges:s,lastSelectedRanges:i,cursorRow:o,cursorColumn:r}=t;if(s.length===1&&(n!==void 0&&n?re.rowCount(s)===1:re.cellCount(s)===1)&&re.rangeArraysEqual(s,i))return{selectedRanges:[],lastSelectedRanges:[],cursorColumn:r,cursorRow:o};let l=s.slice();if(l.length>1){const c=l[l.length-1];for(let u=0;u<l.length-1;u+=1){const m=l[u];if(m.contains(c)){const p=m.subtract(c);l.pop(),l.splice(u,1),l=l.concat(p);break}}l=re.consolidate(l)}let a=r,d=o;if(!re.containsCell(l,r,o)){const{model:c}=this.props,{columnCount:u,rowCount:m}=c,p=re.nextCell(re.boundedRanges(s,u,m));p!=null?{column:a,row:d}=p:(a=null,d=null)}return{cursorRow:d,cursorColumn:a,selectedRanges:l,lastSelectedRanges:s}})}setFocusRow(t){var u;if(!this.metrics||!this.prevMetrics)return;const{gridY:e,height:n,lastTop:s,userRowHeights:i,rowHeight:o}=this.metrics,r=n-e,l=Math.round(r/2)+((u=i.get(t))!=null?u:o),a=this.getMetricState(),d=this.metricCalculator.getLastTop(a,t+1,l);this.setState({top:Math.min(s,d),selectedRanges:[new re(null,t,null,t)]});const{cursorColumn:c}=this.state;this.moveCursorToPosition(c,t,!1,!1)}selectAll(){const{model:t,theme:e}=this.props,{autoSelectRow:n,autoSelectColumn:s}=e,i=s!==void 0&&s?null:0,o=s!==void 0&&s?null:t.rowCount-1,r=n!==void 0&&n?null:0,l=n!==void 0&&n?null:t.columnCount-1;this.setSelectedRanges([new re(r,i,l,o)])}moveCursor(t,e,n){const{cursorRow:s,cursorColumn:i,selectionEndColumn:o,selectionEndRow:r}=this.state,l=n?o:i,a=n?r:s;if(a===null||l===null){const{left:d,top:c}=this.state;this.moveCursorToPosition(d,c,n)}else{const{model:d}=this.props,{columnCount:c,rowCount:u}=d,m=At(l+t,0,c-1),p=At(a+e,0,u-1);this.moveCursorToPosition(m,p,n)}}moveCursorInDirection(t=re.SELECTION_DIRECTION.DOWN){var d;const{model:e}=this.props,{columnCount:n,rowCount:s}=e,{cursorRow:i,cursorColumn:o,selectedRanges:r}=this.state,l=r.length>0?r:[re.makeCell(o,i)];let a=null;if(l.length===1&&re.cellCount(l)===1){const c=new re(0,0,n-1,s-1);a=(d=c.nextCell(o,i,t))!=null?d:c.startCell(t)}else a=re.nextCell(re.boundedRanges(l,n,s),o,i,t);if(a!=null){const{column:c,row:u}=a;this.setState({cursorColumn:c,cursorRow:u}),re.containsCell(r,c,u)||this.setState({selectedRanges:[re.makeCell(c,u)],selectionStartColumn:c,selectionStartRow:u,selectionEndColumn:c,selectionEndRow:u}),this.moveViewToCell(a.column,a.row)}}moveCursorToPosition(t,e,n=!1,s=!0,i=!1){n||this.beginSelection(t,e),this.moveSelection(t,e,n,i),s&&this.moveViewToCell(t,e)}moveViewToCell(t,e){if(!this.metrics)throw new Error("metrics not set");const{metricCalculator:n}=this,{bottomVisible:s,rightVisible:i,topVisible:o,leftVisible:r}=this.metrics,l=this.getMetricState(this.state);let{top:a,left:d,topOffset:c,leftOffset:u}=this.state;e!=null&&!G.isFloatingRow(e,this.metrics)&&(e<o?(a=n.getTopForTopVisible(l,e),c=0):e>s&&(a=n.getTopForBottomVisible(l,e),c=0)),t!=null&&!G.isFloatingColumn(t,this.metrics)&&(t<r?(d=n.getLeftForLeftVisible(l,t),u=0):t>i&&(d=n.getLeftForRightVisible(l,t),u=0)),this.setViewState({top:a,left:d,topOffset:c,leftOffset:u})}setViewState(t,e=!1){if(!this.metrics)throw new Error("metrics not set");const{isStickyBottom:n,isStickyRight:s}=this.props,{top:i,left:o}=t,{lastTop:r,lastLeft:l}=this.metrics;i!=null&&this.setState({isStuckToBottom:n&&i>=r}),o!=null&&this.setState({isStuckToRight:s&&o>=l}),this.setState(t),e&&this.forceUpdate()}startEditing(t,e,n=!1,s,i){const{model:o}=this.props;if(!Ze(o))throw new Error("model is not editable");const r=this.getModelColumn(t),l=this.getModelRow(e),a={column:t,row:e,selectionRange:s,value:i!==void 0?i:o.editValueForCell(r,l),isQuickEdit:n};this.setState({editingCell:a,cursorColumn:t,cursorRow:e}),this.moveViewToCell(t,e)}isValidForCell(t,e,n){const{model:s}=this.props,i=this.getModelColumn(t),o=this.getModelRow(e);return Ze(s)&&s.isValidForCell(i,o,n)}async pasteValue(t){const{model:e}=this.props,{movedColumns:n,movedRows:s,selectedRanges:i}=this.state;try{if(Ch(e),!e.isEditable||!i.every(u=>e.isEditableRange(u)))throw new aa("Can't paste in to read-only area.");if(i.length<=0)throw new aa("Select an area to paste to.");if(typeof t=="string"){const u=[],m=G.getModelRanges(i,n,s);re.forEachCell(m,(p,g)=>{u.push({column:p,row:g,text:t})}),await e.setValues(u);return}const o=t.length,r=t[0].length,{columnCount:l,rowCount:a}=e;let d=i;if(d.every(u=>{var m,p;return re.cellCount([u])===1&&((m=u.startColumn)!=null?m:0)+r<=l&&((p=u.startRow)!=null?p:0)+o<=a})&&(d=d.map(u=>{var m,p;return new re(u.startColumn,u.startRow,((m=u.startColumn)!=null?m:0)+r-1,((p=u.startRow)!=null?p:0)+o-1)}),this.setSelectedRanges(d)),!d.every(u=>re.rowCount([u])===o&&re.columnCount([u])===r))throw new aa("Copy and paste area are not same size.");const c=[];d.forEach(u=>{var m,p;for(let g=0;g<r;g+=1)for(let f=0;f<o;f+=1)c.push({column:((m=u.startColumn)!=null?m:0)+g,row:((p=u.startRow)!=null?p:0)+f,text:t[f][g]})}),await e.setValues(c)}catch(o){const{onError:r}=this.props;r(o instanceof Error?o:new Error(`${o}`))}}setValueForCell(t,e,n){const{model:s}=this.props;Ch(s);const i=this.getModelColumn(t),o=this.getModelRow(e);return s.isValidForCell(i,o,n)?(s.setValueForCell(i,o,n),!0):!1}setValueForRanges(t,e){const{model:n}=this.props,{movedColumns:s,movedRows:i}=this.state,o=G.getModelRanges(t,s,i);Ze(n)&&n.setValueForRanges(o,e)}isSelected(t,e){var s,i;const{selectedRanges:n}=this.state;for(let o=0;o<n.length;o+=1){const r=n[o],l=r.startRow===null||r.startRow<=t&&t<=((s=r.endRow)!=null?s:0),a=r.startColumn===null||r.startColumn<=e&&e<=((i=r.endColumn)!=null?i:0);if(l&&a)return!0}return!1}addDocumentCursor(t=null){this.documentCursor!==Qs.getCursorClassName(t)&&(this.documentCursor!=null&&document.documentElement.classList.remove(this.documentCursor),this.documentCursor=Qs.getCursorClassName(t),this.documentCursor!=null&&document.documentElement.classList.add(this.documentCursor),document.documentElement.classList.add("grid-block-events"))}removeDocumentCursor(){this.documentCursor!=null&&(document.documentElement.classList.remove(this.documentCursor),document.documentElement.classList.remove("grid-block-events"),this.documentCursor=null)}startDragTimer(t){this.stopDragTimer();const e=new MouseEvent("custom",t.nativeEvent);this.dragTimer=setTimeout(()=>{this.handleMouseDrag(e)},Qs.dragTimeout)}stopDragTimer(){this.dragTimer&&(clearTimeout(this.dragTimer),this.dragTimer=null)}drawCanvas(t=this.updateMetrics()){if(!this.canvas)throw new Error("canvas is not set");if(!this.canvasContext)throw new Error("context not set");const{left:e,top:n,cursorColumn:s,cursorRow:i,draggingColumn:o,draggingColumnSeparator:r,draggingRow:l,draggingRowOffset:a,draggingRowSeparator:d,editingCell:c,isDraggingHorizontalScrollBar:u,isDraggingVerticalScrollBar:m,isDragging:p,mouseX:g,mouseY:f,selectedRanges:b}=this.state,{model:C,stateOverride:w}=this.props,{renderer:T}=this,y=this.canvasContext,E=this.getTheme(),I=this.canvas.clientWidth,R=this.canvas.clientHeight,F={left:e,top:n,width:I,height:R,context:y,theme:E,model:C,metrics:t,mouseX:g,mouseY:f,selectedRanges:b,draggingColumn:o,draggingColumnSeparator:r,draggingRow:l,draggingRowOffset:a,draggingRowSeparator:d,editingCell:c,isDraggingHorizontalScrollBar:u,isDraggingVerticalScrollBar:m,isDragging:p,cursorColumn:s,cursorRow:i,...w};y.save(),T.drawCanvas(F),y.restore()}focus(){var t;(t=this.canvas)==null||t.focus()}isFocused(){return document.activeElement===this.canvas}handleClick(t){var s;const e=this.getGridPointFromEvent(t),n=this.getMouseHandlers();for(let i=0;i<n.length;i+=1)if(n[i].onClick(e,this,t)!==!1){t.stopPropagation(),t.preventDefault();break}(s=this.canvas)==null||s.focus()}handleContextMenu(t){const e=this.getGridPointFromEvent(t),n=this.getMouseHandlers();for(let s=0;s<n.length;s+=1)if(n[s].onContextMenu(e,this,t)!==!1){t.stopPropagation(),t.preventDefault();break}}handleKeyDown(t){var n,s;const e=this.getKeyHandlers();for(let i=0;i<e.length;i+=1){const r=e[i].onDown(t,this);if(r!==!1){const l=r;((n=l==null?void 0:l.stopPropagation)==null||n)&&t.stopPropagation(),((s=l==null?void 0:l.preventDefault)==null||s)&&t.preventDefault();break}}}notifyMouseHandlers(t,e,n=!0,s=!1){var l,a;const i=this.getGridPointFromEvent(e),o=this.getMouseHandlers();let r=null;for(let d=0;d<o.length;d+=1){const c=o[d],u=c[t]!=null&&c[t](i,this,e);if(u!==!1){c.cursor!=null&&({cursor:r}=c,s&&this.addDocumentCursor(r));const m=u;((l=m==null?void 0:m.stopPropagation)==null||l)&&e.stopPropagation(),((a=m==null?void 0:m.preventDefault)==null||a)&&e.preventDefault();break}}if(this.setState({cursor:r}),n){const{x:d,y:c}=i;this.setState({mouseX:d,mouseY:c})}}handleMouseDown(t){window.addEventListener("mousemove",this.handleMouseDrag,!0),window.addEventListener("mouseup",this.handleMouseUp,!0),!(t.button!=null&&t.button!==0)&&(this.notifyMouseHandlers("onDown",t),this.startDragTimer(t))}handleDoubleClick(t){this.notifyMouseHandlers("onDoubleClick",t)}handleMouseMove(t){this.notifyMouseHandlers("onMove",t)}handleMouseLeave(t){this.notifyMouseHandlers("onLeave",t,!1),this.setState({mouseX:null,mouseY:null})}handleMouseDrag(t){this.setState({isDragging:!0}),this.notifyMouseHandlers("onDrag",t,!0,!0),this.stopDragTimer()}handleMouseUp(t){window.removeEventListener("mousemove",this.handleMouseDrag,!0),window.removeEventListener("mouseup",this.handleMouseUp,!0),!(t.button!=null&&t.button!==0)&&(this.notifyMouseHandlers("onUp",t,!1),this.stopDragTimer(),this.removeDocumentCursor())}handleResize(){if(this.updateCanvasScale(),this.updateCanvas(),!this.metrics)throw new Error("metrics not set");const{left:t,top:e}=this.state,{lastLeft:n,lastTop:s}=this.metrics;t>n&&this.setState({left:n,leftOffset:0}),e>s&&this.setState({top:s,topOffset:0}),this.forceUpdate()}handleWheel(t){var E,I,R,F;if(this.notifyMouseHandlers("onWheel",t),t.defaultPrevented)return;const{metricCalculator:e,metrics:n}=this,s=this.getMetricState();if(!n)throw new Error("metrics not set");const{lastTop:i,lastLeft:o,columnCount:r,rowCount:l,scrollableContentWidth:a,scrollableViewportWidth:d,scrollableContentHeight:c,scrollableViewportHeight:u,hasHorizontalBar:m,hasVerticalBar:p}=n;let{top:g,left:f,topOffset:b,leftOffset:C}=n;const w=this.getTheme();let{deltaX:T,deltaY:y}=G.getScrollDelta(t,n.barWidth,n.barHeight,n.rowHeight,n.rowHeight);for(;m&&T!==0;){if(C+=T,T=0,r>1){if(C>0&&f>=o||C<0&&f<=0){C=0;break}}else{if(C<=0){C=0;break}const x=a-d;if(C>=x){C=x;break}}if(C>0){const x=(E=n.visibleColumnWidths.get(f))!=null?E:e.getVisibleColumnWidth(f,s);C>=x?(T=C-x,C=0,f+=1):w.scrollSnapToColumn&&r>1&&(C=0,f+=1)}else if(C<0){const x=(I=n.visibleColumnWidths.get(f-1))!=null?I:e.getVisibleColumnWidth(f-1,s);Math.abs(C)<=x&&w.scrollSnapToColumn&&r>1?(C=0,f-=1):(T=C+x,C=0,f-=1)}}for(;p&&y!==0;){if(b+=y,y=0,l>1){if(b>0&&g>=i||b<0&&g<=0){b=0;break}}else{if(b<=0){b=0;break}const x=c-u;if(b>=x){b=x;break}}if(b>0){const x=(R=n.visibleRowHeights.get(g))!=null?R:e.getVisibleRowHeight(g,s);b>=x?(y=b-x,b=0,g+=1):w.scrollSnapToRow&&l>1&&(b=0,g+=1)}else if(b<0){const x=(F=n.visibleRowHeights.get(g-1))!=null?F:e.getVisibleRowHeight(g-1,s);Math.abs(b)<=x&&w.scrollSnapToRow&&l>1?(b=0,g-=1):(y=b+x,b=0,g-=1)}}this.setViewState({top:g,left:f,leftOffset:C,topOffset:b}),t.stopPropagation(),t.preventDefault()}handleEditCellCancel(){this.setState({editingCell:null}),this.focus()}handleEditCellChange(t){this.setState(({editingCell:e})=>{try{return fh(e),{editingCell:{...e,value:t}}}catch(n){const{onError:s}=this.props;return s(n instanceof Error?n:new Error(`${n}`)),null}})}handleEditCellCommit(t,{direction:e=Dn.DOWN,fillRange:n=!1}={}){const{editingCell:s,selectedRanges:i}=this.state;if(!s)throw new Error("editingCell not set");const{column:o,row:r}=s;if(!this.isValidForCell(o,r,t)){e===null&&this.setState({editingCell:null});return}n?this.setValueForRanges(i,t):this.setValueForCell(o,r,t),e!==null&&this.moveCursorInDirection(e),this.setState({editingCell:null}),this.focus()}renderInputField(){const{model:t}=this.props,{editingCell:e}=this.state,{metrics:n}=this;if(e==null||n==null||!Ze(t))return null;const{selectionRange:s,value:i,isQuickEdit:o}=e,{column:r,row:l}=e,{gridX:a,gridY:d,visibleColumnXs:c,visibleRowYs:u,visibleColumnWidths:m,visibleRowHeights:p}=n,g=c.get(r),f=u.get(l),b=m.get(r),C=p.get(l),w=g!=null&&f!=null&&b!=null&&C!=null?{position:"absolute",left:a+g,top:d+f,width:b,height:C}:{opacity:0},T=this.getModelColumn(r),y=this.getModelRow(l),E=T!=null&&y!=null?{textAlign:t.textAlignForCell(T,y)}:void 0,I=t.isValidForCell(T,y,i);return h("div",{style:w,children:h(Pd,{selectionRange:s,className:z({error:!I}),onCancel:this.handleEditCellCancel,onChange:this.handleEditCellChange,onDone:this.handleEditCellCommit,isQuickEdit:o,style:E,value:i},`${r},${l}`)})}render(){const{cursor:t}=this.state;return v(ue,{children:[h("canvas",{className:z("grid-canvas",Qs.getCursorClassName(t)),ref:e=>{this.canvas=e},onClick:this.handleClick,onContextMenu:this.handleContextMenu,onDoubleClick:this.handleDoubleClick,onKeyDown:this.handleKeyDown,onMouseDown:this.handleMouseDown,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,tabIndex:0,children:"Your browser does not support HTML canvas. Update your browser?"}),this.renderInputField()]})}};let Ji=Qs;Ji.contextType=Q0;Ji.defaultProps={canvasOptions:{alpha:!1},isStickyBottom:!1,isStickyRight:!1,isStuckToBottom:!1,isStuckToRight:!1,keyHandlers:[],mouseHandlers:[],movedColumns:[],movedRows:[],onError:()=>{},onSelectionChanged:()=>{},onMovedColumnsChanged:t=>{},onMoveColumnComplete:()=>{},onMovedRowsChanged:()=>{},onMoveRowComplete:()=>{},onViewChanged:()=>{},stateOverride:{},theme:{autoSelectColumn:!1,autoSelectRow:!1}};Ji.pixelsPerLine=100/3;Ji.dragTimeout=1e3;Ji.getTheme=he((t,e)=>({...O0,...t,...e}));class Zm extends al{get floatingTopRowCount(){return 0}get floatingBottomRowCount(){return 0}get floatingLeftColumnCount(){return 0}get floatingRightColumnCount(){return 0}get columnHeaderMaxDepth(){return 1}truncationCharForCell(e,n){}textAlignForCell(e,n){return"left"}colorForCell(e,n,s){return s.textColor}backgroundColorForCell(e,n,s){return null}colorForColumnHeader(e,n=0){return null}textForRowHeader(e){return""}textForRowFooter(e){return""}isColumnMovable(e,n=0){return!0}isRowMovable(e){return!0}getColumnHeaderGroup(e,n){}getColumnHeaderParentGroup(e,n){}}class Z0 extends Zm{constructor({rowCount:e=1e9,columnCount:n=100,floatingTopRowCount:s=0,floatingBottomRowCount:i=0,floatingLeftColumnCount:o=0,floatingRightColumnCount:r=0,isEditable:l=!1,editedData:a=[]}={}){super(),this.numRows=e,this.numColumns=n,this.floatingTop=s,this.floatingBottom=i,this.floatingLeft=o,this.floatingRight=r,this.editable=l,this.editedData=a}get rowCount(){return this.numRows}get columnCount(){return this.numColumns}get floatingTopRowCount(){return this.floatingTop}get floatingBottomRowCount(){return this.floatingBottom}get floatingLeftColumnCount(){return this.floatingLeft}get floatingRightColumnCount(){return this.floatingRight}get isEditable(){return this.editable}textForCell(e,n){var s,i;return(i=(s=this.editedData[e])==null?void 0:s[n])!=null?i:`${e},${n}`}colorForCell(e,n,s){return s.textColor}textForColumnHeader(e,n=0){return`${e}`}textForRowHeader(e){return`${e}`}textForRowFooter(e){return`${e}`}async setValueForCell(e,n,s){this.editedData[e]==null&&(this.editedData[e]=[]),this.editedData[e][n]=`${s}`}async setValueForRanges(e,n){re.forEachCell(e,(s,i)=>{this.setValueForCell(s,i,n)})}async setValues(e){var n,s;for(let i=0;i<e.length;i+=1){const o=e[i];this.setValueForCell((n=o.column)!=null?n:o.x,(s=o.row)!=null?s:o.y,o.text)}}editValueForCell(e,n){return this.textForCell(e,n)}isValidForCell(e,n,s){return!0}isEditableRange(e){return this.isEditable}delete(e){throw new Error("Method not implemented.")}}const Zs=class extends Z0{constructor({rowCount:t=Zs.DEFAULT_ROW_COUNT,columnCount:e=Zs.DEFAULT_COLUMN_COUNT,children:n=new Map,childRowCount:s=Math.ceil(Math.max(Zs.MIN_CHILD_ROW_COUNT,t*Zs.DEFAULT_CHILD_ROW_COUNT_FACTOR)),maxDepth:i=Zs.MAX_DEPTH}={}){super({rowCount:t,columnCount:e}),this.getCachedModelRowOffset=rn((o,r)=>{let l=null,a=r;const d=[...o].sort((c,u)=>c[0]-u[0]);for(let c=0;c<d.length;c+=1){const[u,m]=d[c];if(a<=u)break;const p=m.rowCount;if(a<=u+p){l=u,a=a-u-1;break}a-=p}return{key:l,offsetRow:a}}),this.getCachedTextForRowHeader=rn((o,r)=>{const{key:l,offsetRow:a}=this.getCachedModelRowOffset(o,r);if(l!=null){const d=o.get(l);if(d!==void 0)return`${l}.${d.textForRowHeader(a)}`}return`${a}`}),this.getCachedTextForCell=rn((o,r,l)=>{const{key:a,offsetRow:d}=this.getCachedModelRowOffset(o,l);if(a!=null){const c=o.get(a);if(c!==void 0)return`${a}.${c.textForCell(r,d)}`}return`${r},${d}`}),this.getCachedIsRowExpandable=rn((o,r,l)=>this.getCachedDepthForRow(o,r)<l),this.getCachedIsRowExpanded=rn((o,r)=>{const{key:l,offsetRow:a}=this.getCachedModelRowOffset(o,r);if(l!=null){const d=o.get(l);if(d!==void 0)return d.isRowExpanded(a)}return o.has(a)}),this.getCachedDepthForRow=rn((o,r)=>{const{key:l,offsetRow:a}=this.getCachedModelRowOffset(o,r);if(l!=null){const d=o.get(l);if(d!==void 0)return d.depthForRow(a)+1}return 0}),this.children=n,this.childRowCount=s,this.maxDepth=i}textForCell(t,e){return this.getCachedTextForCell(this.children,t,e)}textForRowHeader(t){return this.getCachedTextForRowHeader(this.children,t)}isRowMovable(t){return!1}get hasExpandableRows(){return!0}get floatingBottomRowCount(){return 0}isRowExpandable(t){return this.getCachedIsRowExpandable(this.children,t,this.maxDepth)}isRowExpanded(t){return this.getCachedIsRowExpanded(this.children,t)}setRowExpanded(t,e){const{key:n,offsetRow:s}=this.getCachedModelRowOffset(this.children,t),i=new Map(this.children);if(n!=null){const o=this.children.get(n);if(o!==void 0){const{rowCount:r}=o;o.setRowExpanded(s,e),this.numRows+=o.rowCount-r}}else if(e){const o=new Zs({rowCount:this.childRowCount,columnCount:this.numColumns});i.set(s,o),this.numRows+=o.rowCount}else{const o=i.get(s);o!==void 0&&(this.numRows-=o.rowCount,i.delete(s))}this.children=i}depthForRow(t){return this.getCachedDepthForRow(this.children,t)}};let Yo=Zs;Yo.DEFAULT_ROW_COUNT=1e9;Yo.DEFAULT_COLUMN_COUNT=100;Yo.DEFAULT_CHILD_ROW_COUNT_FACTOR=.01;Yo.MIN_CHILD_ROW_COUNT=10;Yo.MAX_DEPTH=10;class be extends Zm{constructor(){super(),this.listenerCount=0}addEventListener(e,n,s){super.addEventListener(e,n,s),this.listenerCount+=1,this.listenerCount===1&&this.startListening()}removeEventListener(e,n,s){super.removeEventListener(e,n,s),this.listenerCount-=1,this.listenerCount===0&&this.stopListening()}startListening(){}stopListening(){}get originalColumns(){return this.columns}get movedColumns(){return[]}get movedRows(){return[]}get layoutHints(){return null}get frontColumns(){return[]}get backColumns(){return[]}get frozenColumns(){return[]}isColumnFrozen(e){return!1}get isFilterRequired(){return!1}get isReversible(){return!0}get isColumnStatisticsAvailable(){return!1}get description(){return""}get isCustomColumnsAvailable(){return!1}get isFormatColumnsAvailable(){return!1}get isExportAvailable(){return!1}get isValuesTableAvailable(){return!1}get isChartBuilderAvailable(){return!1}get isRollupAvailable(){return!1}get isSelectDistinctAvailable(){return!1}get isTotalsAvailable(){return!1}isFilterable(e){return!1}close(){}isRowMovable(){return!1}}be.EVENT=Object.freeze({UPDATED:"UPDATED",FORMATTER_UPDATED:"FORMATTER_UPDATED",REQUEST_FAILED:"REQUEST_FAILED",COLUMNS_CHANGED:"COLUMNS_CHANGED",TABLE_CHANGED:"TABLE_CHANGED",FILTERS_CHANGED:"FILTERS_CHANGED",SORTS_CHANGED:"SORTS_CHANGED",DISCONNECT:"DISCONNECT",RECONNECT:"RECONNECT",TOTALS_UPDATED:"TOTALS_UPDATED",PENDING_DATA_UPDATED:"PENDING_DATA_UPDATED"});const Ni=class extends S.exports.Component{constructor(t){super(t),this.getInput=he((e,n)=>e.find(s=>s.eventKey===n)),this.getInputIndex=he((e,n)=>e.findIndex(s=>s.eventKey===n)),this.handleAddColumnClick=this.handleAddColumnClick.bind(this),this.handleSaveClick=this.handleSaveClick.bind(this),this.handleInputChange=this.handleInputChange.bind(this),this.handleDeleteColumn=this.handleDeleteColumn.bind(this),this.handleCustomColumnUpdated=this.handleCustomColumnUpdated.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.handleDragEnd=this.handleDragEnd.bind(this),this.resetRequestFailed=this.resetRequestFailed.bind(this),this.handleEditorTabNavigation=this.handleEditorTabNavigation.bind(this),this.state={inputs:[],isCustomColumnApplying:!1,errorMessage:null,hasRequestFailed:!1,isSuccessShowing:!1},this.container=null,this.successButtonTimer=null}static makeCustomColumnInputEventKey(){return We.generate()}static createCustomColumnInput(){return{eventKey:We.generate(),name:"",formula:""}}componentDidMount(){const{customColumns:t}=this.props;this.parseCustomColumns(t),this.startListening()}componentWillUnmount(){this.stopListening(),this.successButtonTimer&&clearTimeout(this.successButtonTimer)}resetErrorMessage(){this.setState({errorMessage:null})}startListening(){const{model:t}=this.props;t.addEventListener(be.EVENT.COLUMNS_CHANGED,this.handleCustomColumnUpdated),t.addEventListener(be.EVENT.UPDATED,this.handleCustomColumnUpdated),t.addEventListener(be.EVENT.REQUEST_FAILED,this.handleRequestFailed)}stopListening(){const{model:t}=this.props;t.removeEventListener(be.EVENT.COLUMNS_CHANGED,this.handleCustomColumnUpdated),t.removeEventListener(be.EVENT.UPDATED,this.handleCustomColumnUpdated),t.removeEventListener(be.EVENT.REQUEST_FAILED,this.handleRequestFailed)}parseCustomColumns(t){if(t.length>0){const e=t.map(n=>{const s=n.split(/=(.+)/,2);return{eventKey:Ni.makeCustomColumnInputEventKey(),name:s[0],formula:s[1]}});this.setState({inputs:e})}else this.setState({inputs:[Ni.createCustomColumnInput()]})}handleAddColumnClick(){const{inputs:t}=this.state,e=[...t];e.push(Ni.createCustomColumnInput()),this.setState({inputs:e})}handleDeleteColumn(t){const{inputs:e}=this.state,n=this.getInputIndex(e,t),s=[...e];s.splice(n,1),s.length===0&&s.push(Ni.createCustomColumnInput()),this.setState({inputs:s})}handleInputChange(t,e,n){const{inputs:s}=this.state,i=this.getInputIndex(s,t),r={...this.getInput(s,t)};r[e]=n;const l=[...s];l.splice(i,1,r),this.setState({inputs:l})}handleCustomColumnUpdated(){const{isCustomColumnApplying:t}=this.state;!t||this.setState({isCustomColumnApplying:!1,isSuccessShowing:!0},()=>{this.successButtonTimer=setTimeout(()=>this.setState({isSuccessShowing:!1}),Ni.SUCCESS_SHOW_DURATION)})}handleRequestFailed(t){const e=t,{isCustomColumnApplying:n}=this.state;!n||this.setState({isCustomColumnApplying:!1,errorMessage:v(ue,{children:[v("p",{children:[h(K,{icon:ds})," Failed to apply custom columns."]}),v("div",{className:"error-box",children:[e.detail.errorMessage,h("br",{}),"Table configuration:"," ",JSON.stringify(e.detail.configuration)]})]}),hasRequestFailed:!0})}handleDragEnd(t){if(Gt.stopDragging(),!t.destination)return;const{inputs:e}=this.state,n=t.source.index,s=t.destination.index,i=[...e],o=e[n];i.splice(n,1),i.splice(s,0,o),this.setState({inputs:i})}handleEditorTabNavigation(t,e){var s,i,o;const{inputs:n}=this.state;if(e){((s=this.container)==null?void 0:s.querySelectorAll(".btn-drag-handle")[t]).focus();return}if(t===n.length-1)((i=this.container)==null?void 0:i.querySelectorAll(".btn-add-column")[t]).focus();else{const r=t+1;((o=this.container)==null?void 0:o.querySelectorAll(".custom-column-input")[r]).focus()}}handleSaveClick(){const{onSave:t}=this.props,{inputs:e,isCustomColumnApplying:n}=this.state;if(n)return;const s=[];e.forEach(i=>{const{name:o,formula:r}=i;o&&r&&s.push(`${o}=${r}`)}),this.resetErrorMessage(),this.setState({isCustomColumnApplying:!0}),t(s)}resetRequestFailed(){this.setState(({hasRequestFailed:t})=>t?{hasRequestFailed:!1}:null)}renderInputs(){const{inputs:t,hasRequestFailed:e}=this.state;return t.map((n,s)=>{const{eventKey:i,name:o,formula:r}=n;return h(kd,{inputIndex:s,eventKey:i,name:o,formula:r,onChange:this.handleInputChange,onDeleteColumn:this.handleDeleteColumn,onTabInEditor:this.handleEditorTabNavigation,invalid:e},i)})}renderSaveButton(){const{inputs:t,isCustomColumnApplying:e,isSuccessShowing:n}=this.state,s=t.length>1?"Save Columns":"Save Column";return v("button",{type:"button",className:z("btn btn-apply",{"btn-spinner":e},n?"btn-success":"btn-primary"),disabled:n||e,onClick:this.handleSaveClick,children:[e&&v("span",{children:[h(kn,{}),h("span",{className:"btn-normal-content",children:"Applying"}),h("span",{className:"btn-hover-content",children:"Applying"})]}),!n&&!e&&s,n&&v(ue,{children:[h(K,{icon:ad})," Success"]})]})}render(){const{onCancel:t}=this.props,{errorMessage:e}=this.state;return v("div",{role:"presentation",className:"custom-column-builder-container",ref:n=>{this.container=n},onClick:this.resetRequestFailed,onFocus:this.resetRequestFailed,children:[h("div",{className:"section-title",children:"Custom Column Name and Formula"}),h("hr",{}),h(Vo,{onDragStart:Gt.startDragging,onDragEnd:this.handleDragEnd,children:h(Ho,{droppableId:"droppable-custom-columns",children:(n,s)=>v("div",{ref:n.innerRef,...n.droppableProps,className:z("droppable-container",{dragging:s.draggingFromThisWith}),children:[this.renderInputs(),n.placeholder]})})}),h("div",{className:"pt-1 px-3",children:v("button",{type:"button",className:"btn btn-link btn-add-column",onClick:this.handleAddColumnClick,children:[h(K,{icon:Ls}),"Add Another Column"]})}),v("div",{className:"custom-column-builder-footer",children:[e&&h("div",{className:"error-message",children:e}),v("div",{className:"d-flex justify-content-end",children:[h("button",{type:"button",className:"btn btn-outline-primary mr-2",onClick:t,children:"Cancel"}),this.renderSaveButton()]})]})]})}};let Hd=Ni;Hd.SUCCESS_SHOW_DURATION=750;Hd.defaultProps={customColumns:[],onSave:()=>{},onCancel:()=>{}};var Oe=(t=>(t.ADVANCED_SETTINGS="ADVANCED_SETTINGS",t.AGGREGATIONS="AGGREGATIONS",t.AGGREGATION_EDIT="AGGREGATIONS_EDIT",t.CHART_BUILDER="CHART_BUILDER",t.CUSTOM_COLUMN_BUILDER="CUSTOM_COLUMN_BUILDER",t.QUICK_FILTERS="QUICK_FILTERS",t.ROLLUP_ROWS="ROLLUP_ROWS",t.SEARCH_BAR="SEARCH_BAR",t.SELECT_DISTINCT="SELECT_DISTINCT",t.TABLE_EXPORTER="TABLE_EXPORTER",t.VISIBILITY_ORDERING_BUILDER="VISIBILITY_ORDERING_BUILDER",t.CONDITIONAL_FORMATTING="CONDITIONAL_FORMATTING",t.CONDITIONAL_FORMATTING_EDIT="CONDITIONAL_FORMATTING_EDIT",t.GOTO="GOTO",t))(Oe||{});const uo=X.module("RollupRows"),J0=150,Tr="grouped-rollup-rows",Er="ungrouped-rollup-rows",En=class extends S.exports.Component{constructor(t){super(t),this.search=Xe(o=>{const r=this.getSortedUngroupedColumns(),l=[];let a=null;for(let d=0;d<r.length;d+=1)r[d].name.toLowerCase().includes(o.toLowerCase())&&(a==null&&(a=d),l.push([d,d]));A(a),this.setState({ungroupedSelectedRanges:l}),l.length>0&&this.ungroupedList.current&&this.ungroupedList.current.scrollToItem(a)},J0),this.getCachedUngroupedColumns=Te((o,r)=>o.filter(l=>En.isGroupable(l)&&r.find(a=>a===l.name)!=null)),this.getCachedSortedColumns=Te((o,r)=>r==null?[...o]:P.sortColumns(o,r===En.SORT.ASCENDING)),this.search=this.search.bind(this),this.handleDeleteClicked=this.handleDeleteClicked.bind(this),this.handleSearchChange=this.handleSearchChange.bind(this),this.handleUngroupedSelect=this.handleUngroupedSelect.bind(this),this.handleUngroupedSelectionChange=this.handleUngroupedSelectionChange.bind(this),this.handleDragStart=this.handleDragStart.bind(this),this.handleDragEnd=this.handleDragEnd.bind(this),this.handleGroupedSelectionChange=this.handleGroupedSelectionChange.bind(this),this.handleShowConstituentsChange=this.handleShowConstituentsChange.bind(this),this.handleShowNonAggregatedColumnsChange=this.handleShowNonAggregatedColumnsChange.bind(this),this.handleSortAscending=this.handleSortAscending.bind(this),this.handleSortDescending=this.handleSortDescending.bind(this),this.renderGroupedItem=this.renderGroupedItem.bind(this),this.ungroupedList=Y.createRef(),this.groupedList=Y.createRef();const{config:e}=t,{columns:n=[],showConstituents:s=!0,showNonAggregatedColumns:i=!0}=e!=null?e:{};this.state={ungroupedSelectedRanges:[],columns:n,groupedSelectedRanges:[],searchFilter:"",showConstituents:s,showNonAggregatedColumns:i,dragSource:null,sort:null}}static renderColumn({item:t,isClone:e,selectedCount:n}){const s=t==null?void 0:t.name,i=e!==void 0&&e?`${n}`:void 0,o=e!==void 0&&e?"item-list-item-clone":"";return nn.renderTextItem({text:s,badgeText:i,className:o})}static addGroupings(t,e,n=t.length){if(e==null||e.length===0)return t;let s=n;const i=t.filter((o,r)=>e.includes(o)?(r<s&&(s-=1),!1):!0);return i.splice(s,0,...e),i}static isGroupable(t){return!P.isDecimalType(t.type)}componentDidUpdate(t,e){const{config:n}=this.props,{columns:s,showConstituents:i,showNonAggregatedColumns:o}=this.state;n!==t.config?this.updateFromConfig():(s!==e.columns||i!==e.showConstituents||o!==e.showNonAggregatedColumns)&&(n==null||s!==n.columns||i!==n.showConstituents||o!==n.showNonAggregatedColumns)&&this.sendChange()}componentWillUnmount(){this.search.cancel()}handleSearchChange(t){const e=t.target.value;if(this.setState({searchFilter:e}),!e){this.search.cancel(),this.resetSelection();return}this.search(e)}handleSortAscending(){this.setState(({sort:t})=>({sort:t===En.SORT.ASCENDING?null:En.SORT.ASCENDING}))}handleSortDescending(){this.setState(({sort:t})=>({sort:t===En.SORT.DESCENDING?null:En.SORT.DESCENDING}))}resetSelection(){this.setState({ungroupedSelectedRanges:[],groupedSelectedRanges:[]})}handleDragStart(t){uo.debug("handleDragStart",t),document.documentElement.classList.add("drag-pointer-events-none"),this.setState({dragSource:t.source})}handleDragEnd(t){uo.debug("handleDragEnd",t),document.documentElement.classList.remove("drag-pointer-events-none"),this.setState({dragSource:null});const{destination:e,source:n}=t;if(e==null||n==null)return;if(e.droppableId===Er){this.setState(({groupedSelectedRanges:o,columns:r})=>{const l=[...r];return Gt.reorder(l,o,[],0),{columns:l,ungroupedSelectedRanges:[],groupedSelectedRanges:[]}});return}const s=n.droppableId===Tr;let i=e.index;s&&n.index<e.index&&(i+=1),this.setState(({columns:o,ungroupedSelectedRanges:r,groupedSelectedRanges:l})=>{const a=[...o],d=s?a:this.getSortedUngroupedColumns().map(g=>g.name),c=s?l:r,u=Gt.reorder(d,c,a,i),m=s?Gt.adjustDestinationIndex(i,l):i,p=[[m,m+u.length-1]];return{columns:a,ungroupedSelectedRanges:[],groupedSelectedRanges:p}}),this.resetSelection()}handleUngroupedSelect(t){uo.debug("handleUngroupedSelect"),this.setState(({columns:e})=>({columns:En.addGroupings(e,[this.getSortedUngroupedColumns()[t].name]),ungroupedSelectedRanges:[],groupedSelectedRanges:[]}))}handleUngroupedSelectionChange(t){uo.debug2("handleUngroupedSelectionChange",t),this.setState(({ungroupedSelectedRanges:e})=>t===e?null:{ungroupedSelectedRanges:t,groupedSelectedRanges:[]})}handleGroupedSelectionChange(t){uo.debug2("handleGroupedSelectedRanges",t),this.setState(({groupedSelectedRanges:e})=>t===e?null:{groupedSelectedRanges:t,ungroupedSelectedRanges:[]})}handleDeleteClicked(t){this.setState(({columns:e})=>{const n=e.slice();return n.splice(t,1),{columns:n}})}handleShowConstituentsChange(){this.setState(({showConstituents:t})=>({showConstituents:!t}))}handleShowNonAggregatedColumnsChange(){this.setState(({showNonAggregatedColumns:t})=>({showNonAggregatedColumns:!t}))}updateFromConfig(){const{config:t}=this.props,{columns:e=[],showConstituents:n=!0,showNonAggregatedColumns:s=!0}=t!=null?t:{};this.setState({columns:e,showConstituents:n,showNonAggregatedColumns:s})}sendChange(){const{onChange:t}=this.props,{columns:e,showConstituents:n,showNonAggregatedColumns:s}=this.state;t({columns:e,showConstituents:n,showNonAggregatedColumns:s})}getUngroupedColumns(){const{model:t}=this.props,{columns:e}=this.state,{originalColumns:n}=t;return this.getCachedUngroupedColumns(n,e)}getSortedUngroupedColumns(){const{sort:t}=this.state,e=this.getUngroupedColumns();return this.getCachedSortedColumns(e,t)}renderGroupedItem({item:t,itemIndex:e,isClone:n,selectedCount:s}){const o=`${n!==void 0&&n?"":"\xA0\xA0".repeat(e)}${t}`,r=n!==void 0&&n?`${s}`:void 0,l=n!==void 0&&n?"item-list-item-clone":"";return v(ue,{children:[nn.renderTextItem({text:o,badgeText:r,className:l}),(n===void 0||!n)&&h(Q,{kind:"ghost",className:"btn btn-link btn-link-icon btn-delete-grouping float-right",onClick:()=>this.handleDeleteClicked(e),children:h(K,{icon:_n})})]})}render(){const{columns:t,dragSource:e,searchFilter:n,groupedSelectedRanges:s,ungroupedSelectedRanges:i,showConstituents:o,showNonAggregatedColumns:r,sort:l}=this.state,a=this.getSortedUngroupedColumns();let d=t.length*nn.DEFAULT_ROW_HEIGHT;(e==null?void 0:e.droppableId)===Er&&(d+=nn.DEFAULT_ROW_HEIGHT);const c=a.length*nn.DEFAULT_ROW_HEIGHT+10,u=Math.min(3*nn.DEFAULT_ROW_HEIGHT,c);return h("div",{role:"menu",className:z("rollup-rows",{"is-dragging":e!=null}),tabIndex:0,children:v(Vo,{onDragEnd:this.handleDragEnd,onDragStart:this.handleDragStart,children:[v("div",{className:"rollup-rows-group-by",children:[h("div",{className:"section-title",children:"Group By"}),t.length===0&&h(Ho,{isDropDisabled:!0,droppableId:"placeholder",children:(m,p)=>h("div",{className:z("placeholder","text-muted",{"is-dragging-from-this":p.draggingFromThisWith,"is-dragging-over":p.isDraggingOver,"is-dropping":p.draggingOverWith}),ref:m.innerRef,...m.droppableProps,children:"Create rollup by dragging columns here, from the available columns list below."})}),t.length>0&&h(nn,{draggingItemClassName:"rollup-rows-dragging-grouped-item",draggablePrefix:Tr,droppableId:Tr,itemCount:t.length,items:t,offset:0,onSelectionChange:this.handleGroupedSelectionChange,ref:this.groupedList,renderItem:this.renderGroupedItem,selectedRanges:s,style:{height:d},isMultiSelect:!0})]}),v("div",{className:"rollup-rows-available-columns",children:[h("div",{className:"section-title",children:"Available Grouping Columns"}),v("div",{className:"top-menu",children:[h(gs,{className:"w-100",value:n,matchCount:n?i.length:void 0,placeholder:"Find column...",onChange:this.handleSearchChange}),v(Q,{kind:"ghost",className:z("btn-link btn-link-icon",{active:l===En.SORT.ASCENDING}),onClick:this.handleSortAscending,children:[h(K,{icon:hd}),h(Ie,{children:"Sort ascending"})]}),v(Q,{kind:"ghost",className:z("btn-link btn-link-icon",{active:l===En.SORT.DESCENDING}),onClick:this.handleSortDescending,children:[h(K,{icon:ud}),h(Ie,{children:"Sort descending"})]})]}),h(nn,{className:"rollup-available-grouping-columns",draggablePrefix:Er,droppableId:Er,itemCount:a.length,items:a,renderItem:En.renderColumn,offset:0,onSelect:this.handleUngroupedSelect,onSelectionChange:this.handleUngroupedSelectionChange,ref:this.ungroupedList,selectedRanges:i,style:{maxHeight:c,minHeight:u},isDropDisabled:(e==null?void 0:e.droppableId)!==Tr,isMultiSelect:!0}),v("div",{className:"bottom-menu",children:[h("div",{className:"label",children:"Show:"}),h(Pt,{checked:o,onChange:this.handleShowConstituentsChange,children:"Constituents"}),h(Pt,{checked:r,onChange:this.handleShowNonAggregatedColumnsChange,children:"Non-Aggregated Columns"})]})]})]})})}};let Vd=En;Vd.SORT=Object.freeze({ASCENDING:"ASC",DESCENDING:"DESC"});Vd.defaultProps={config:null,onChange:()=>{}};const ev=X.module("TableCsvExporter"),qe=class extends S.exports.Component{static getDateString(){return M.i18n.DateTimeFormat.format(qe.FILENAME_DATE_FORMAT,new Date)}constructor(t){super(t),this.handleDownloadClick=this.handleDownloadClick.bind(this),this.handleDownloadOptionChanged=this.handleDownloadOptionChanged.bind(this),this.handleCustomizedDownloadOptionChanged=this.handleCustomizedDownloadOptionChanged.bind(this),this.handleCustomizedDownloadRowsChanged=this.handleCustomizedDownloadRowsChanged.bind(this);const{name:e}=t;this.state={fileName:`${e}-${qe.getDateString()}.csv`,downloadOption:qe.DOWNLOAD_OPTIONS.ALL_ROWS,customizedDownloadOption:qe.CUSTOMIZED_ROWS_OPTIONS.FIRST,customizedDownloadRows:qe.DEFAULT_DOWNLOAD_ROWS,errorMessage:null,id:We.generate()}}getSnapshotRanges(){const{model:t,selectedRanges:e}=this.props,{downloadOption:n,customizedDownloadOption:s,customizedDownloadRows:i}=this.state,{rowCount:o}=t;let r=[];switch(n){case qe.DOWNLOAD_OPTIONS.ALL_ROWS:r.push(new re(null,0,null,o-1));break;case qe.DOWNLOAD_OPTIONS.SELECTED_ROWS:r=[...e].sort((l,a)=>l.startRow!=null&&a.startRow!=null?l.startRow-a.startRow:0);break;case qe.DOWNLOAD_OPTIONS.CUSTOMIZED_ROWS:switch(s){case qe.CUSTOMIZED_ROWS_OPTIONS.FIRST:r.push(new re(null,0,null,Math.min(i-1,o-1)));break;case qe.CUSTOMIZED_ROWS_OPTIONS.LAST:r.push(new re(null,Math.max(0,o-i),null,o-1));break}break}return r}resetDownloadState(){this.setState({errorMessage:null})}async handleDownloadClick(){const{model:t,isDownloading:e,onDownloadStart:n,onDownload:s,onCancel:i}=this.props,{fileName:o}=this.state;if(e){i();return}this.resetDownloadState();const r=this.getSnapshotRanges();if(this.validateOptionInput()){n();try{const l=await t.export(),a=l.setViewport(0,0);await a.getViewportData(),s(o,l,a,r)}catch(l){ev.error("CSV download failed",l),this.setState({errorMessage:v("p",{children:[h(K,{icon:ds})," ",`${l}`]})}),i()}}}handleDownloadOptionChanged(t){this.setState({downloadOption:t.target.value})}handleCustomizedDownloadOptionChanged(t){this.setState({customizedDownloadOption:t.target.value})}handleCustomizedDownloadRowsChanged(t){this.setState({customizedDownloadRows:parseInt(t.target.value,10)})}validateOptionInput(){const{selectedRanges:t}=this.props,{downloadOption:e,customizedDownloadRows:n}=this.state;return e===qe.DOWNLOAD_OPTIONS.SELECTED_ROWS&&t.length===0?(this.setState({errorMessage:v("p",{children:[h(K,{icon:ds})," No rows selected. Please select some rows in the table."]})}),!1):e===qe.DOWNLOAD_OPTIONS.CUSTOMIZED_ROWS&&n<=0?(this.setState({errorMessage:v("p",{children:[h(K,{icon:ds})," Number of rows to output must be greater than 0"]})}),!1):!0}render(){const{model:t,isDownloading:e,tableDownloadProgress:n,tableDownloadEstimatedTime:s,selectedRanges:i,tableDownloadStatus:o}=this.props,{fileName:r,downloadOption:l,customizedDownloadOption:a,customizedDownloadRows:d,errorMessage:c,id:u}=this.state,{rowCount:m}=t;return v("div",{className:"table-csv-exporter",children:[h("div",{className:"section-title",children:"Download Rows"}),h("div",{className:"form-group",children:v(bl,{onChange:this.handleDownloadOptionChanged,value:l,disabled:e,children:[v(Mn,{value:qe.DOWNLOAD_OPTIONS.ALL_ROWS,"data-testid":"radio-csv-exporter-download-all",children:["All Rows",h("span",{className:"text-muted ml-2",children:`(${m.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")} rows)`})]}),v(Mn,{value:qe.DOWNLOAD_OPTIONS.SELECTED_ROWS,"data-testid":"radio-csv-exporter-only-selected",children:["Only Selected Rows",h("span",{className:"text-muted ml-2",children:i.length>0?`(${re.rowCount(i).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")} rows)`:null})]}),h(Mn,{value:qe.DOWNLOAD_OPTIONS.CUSTOMIZED_ROWS,"data-testid":"radio-csv-exporter-customized-rows",children:v("div",{className:"radio-input-row",role:"presentation",onClick:()=>{this.setState({downloadOption:qe.DOWNLOAD_OPTIONS.CUSTOMIZED_ROWS})},children:[v("select",{value:a,"data-testid":"select-csv-exporter-customized-rows",className:"custom-select",disabled:e,onChange:this.handleCustomizedDownloadOptionChanged,children:[h("option",{value:"FIRST",children:"First"}),h("option",{value:"LAST",children:"Last"})]}),h("input",{type:"number",className:"form-control",id:`customizedRows-${u}`,"data-testid":"input-csv-exporter-customized-rows",name:`customizedRows-${u}`,placeholder:"100",value:d,disabled:e,onChange:this.handleCustomizedDownloadRowsChanged}),h("div",{children:"Rows"})]})})]})}),v("div",{className:"form-group",children:[h("label",{htmlFor:`customizedRows-${u}`,children:"File Name"}),h("input",{type:"text",className:"form-control",id:`filename-${u}`,"data-testid":"input-csv-exporter-file-name",name:`filename-${u}`,value:r,onChange:p=>{this.setState({fileName:p.target.value})},disabled:e})]}),v("div",{className:"section-footer flex-column",children:[c!=null&&h("div",{className:"error-message",children:c}),o&&v("div",{className:"download-status",children:[(o===qe.DOWNLOAD_STATUS.DOWNLOADING||o===qe.DOWNLOAD_STATUS.INITIATING)&&v(ue,{children:[o===qe.DOWNLOAD_STATUS.INITIATING&&h("div",{className:"text-muted",children:"Starting Download..."}),o===qe.DOWNLOAD_STATUS.DOWNLOADING&&v("div",{className:"text-muted d-flex justify-content-between",children:[h("span",{children:s||s===0?`Estimated time: ${In.formatElapsedTime(s)}`:null}),h("span",{children:`${n}%`})]})]}),o===qe.DOWNLOAD_STATUS.FINISHED&&h("div",{className:"text-muted text-right",children:"Download Completed"}),o===qe.DOWNLOAD_STATUS.CANCELED&&h("div",{className:"text-muted",children:"Download Canceled"}),(o===qe.DOWNLOAD_STATUS.DOWNLOADING||o===qe.DOWNLOAD_STATUS.INITIATING)&&h("div",{className:"progress",children:h("div",{className:"progress-bar progress-bar-striped progress-bar-animated",style:{width:`${n}%`}})}),o===qe.DOWNLOAD_STATUS.FINISHED&&h("div",{className:"progress",children:h("div",{className:"progress-bar bg-success",style:{width:`${n}%`}})})]}),v("button",{type:"button","data-testid":"btn-csv-exporter-download",className:z("btn btn-primary btn-downloading",{"btn-spinner btn-cancelable":e}),onClick:this.handleDownloadClick,children:[e&&v("span",{children:[h(kn,{}),h("span",{className:"btn-normal-content",children:"Downloading"}),h("span",{className:"btn-hover-content",children:"Cancel"})]}),!e&&"Download"]})]})]})}};let on=qe;on.FILENAME_DATE_FORMAT="yyyy-MM-dd-HHmmss";on.DOWNLOAD_STATUS={INITIATING:"INITIATING",DOWNLOADING:"DOWNLOADING",FINISHED:"FINISHED",CANCELED:"CANCELED"};on.DOWNLOAD_OPTIONS={ALL_ROWS:"ALL_ROWS",SELECTED_ROWS:"SELECTED_ROWS",CUSTOMIZED_ROWS:"CUSTOMIZED_ROWS"};on.CUSTOMIZED_ROWS_OPTIONS={FIRST:"FIRST",LAST:"LAST"};on.DEFAULT_DOWNLOAD_ROWS=100;on.defaultProps={onDownloadStart:()=>{},isDownloading:!1,tableDownloadStatus:"",tableDownloadProgress:0,tableDownloadEstimatedTime:null,selectedRanges:[]};const es=X.module("TableSaver");function tv(t){return t.added!==void 0}function nv(t){if(!tv(t))throw new Error("event is not UpdateEventData")}const Fs=class extends S.exports.PureComponent{constructor(t){var e,n;super(t),this.WritableStream=(e=window.WritableStream)!=null?e:wc,this.getCachedCustomColumnFormatFlag=rn(cs.isCustomColumnFormatDefined,{max:1e4}),this.handlePortMessage=this.handlePortMessage.bind(this),this.handleSnapshotResolved=this.handleSnapshotResolved.bind(this),this.handleDownloadTimeout=this.handleDownloadTimeout.bind(this),this.state={},this.gridRanges=[],this.gridRangeCounter=0,this.rangedSnapshotsTotal=[],this.rangedSnapshotCounter=0,this.snapshotsTotal=0,this.snapshotCounter=0,this.snapshotsBuffer=new Map,this.currentSnapshotIndex=0,this.snapshotPending=0,this.cancelableSnapshots=[],this.WritableStream=(n=window.WritableStream)!=null?n:wc,this.iframes=[],this.useBlobFallback=!1}static csvEscapeString(t){return`"${t.replace(/"/g,'""')}"`}componentDidMount(){const{getDownloadWorker:t}=this.props;t().then(e=>{es.info("found active service worker"),this.sw=e,this.sw.postMessage("ping")}).catch(e=>{es.warn("Download csv is not optimized.",e),this.useBlobFallback=!0})}componentWillUnmount(){this.iframes.length>0&&this.iframes.forEach(t=>{t.remove()}),this.streamTimeout&&clearTimeout(this.streamTimeout),this.snapshotHandlerTimeout&&clearTimeout(this.snapshotHandlerTimeout)}createWriterStream(t){const e=this.useBlobFallback,n=[];let s=null;e&&(s=TextEncoder.prototype.encode.bind(new TextEncoder));const{fileName:i}=this,o={};return e?(o.write=r=>{A(s),r.header!==void 0&&n.push(s(r.header)),r.rows!==void 0&&n.push(s(r.rows))},o.close=()=>{A(i);const r=new Blob(n,{type:"application/octet-stream; charset=utf-8"}),l=document.createElement("a");l.href=URL.createObjectURL(r),l.download=i,l.click()},o.abort=()=>{t.postMessage({cancel:!0}),t.close()}):(o.write=r=>{t.postMessage(r)},o.close=()=>{t.postMessage({end:!0}),t.close()},o.abort=()=>{t.postMessage({cancel:!0}),t.close()}),new this.WritableStream(o)}startDownload(t,e,n,s){const{isDownloading:i}=this.props;if(i)return;this.downloadStartTime=Date.now(),es.info(`start downloading ${t}`),this.table=e,this.columns=e.columns,this.tableSubscription=n,this.gridRanges=s;const o=encodeURIComponent(t.replace(/\//g,":")).replace(/['()]/g,escape).replace(/\*/g,"%2A"),r=new MessageChannel;if(this.port=r.port1,this.fileName=t,this.fileWriter=this.createWriterStream(this.port).getWriter(),this.useBlobFallback){this.writeCsvTable();return}this.sw&&this.sw.postMessage({encodedFileName:o},[r.port2]),this.port.onmessage=this.handlePortMessage}finishDownload(){this.table&&this.table.close(),this.tableSubscription&&this.tableSubscription.close(),this.fileWriter&&this.fileWriter.close();const{onDownloadCompleted:t}=this.props;t(),this.resetTableSaver(),this.downloadStartTime!==void 0&&es.info(`download finished, total elapsed time ${(Date.now()-this.downloadStartTime)/1e3} seconds`)}cancelDownload(){this.table&&this.table.close(),this.tableSubscription&&this.tableSubscription.close(),this.fileWriter&&this.fileWriter.abort(),this.cancelableSnapshots.forEach(e=>{e&&(e.catch(()=>null),e.cancel())});const{onDownloadCanceled:t}=this.props;t(),this.resetTableSaver()}resetTableSaver(){this.table=void 0,this.tableSubscription=void 0,this.columns=void 0,this.chunkRows=void 0,this.gridRanges=[],this.gridRangeCounter=0,this.rangedSnapshotsTotal=[],this.rangedSnapshotCounter=0,this.snapshotsTotal=0,this.snapshotCounter=0,this.snapshotsBuffer=new Map,this.currentSnapshotIndex=0,this.snapshotPending=0,this.cancelableSnapshots=[],this.streamTimeout!=null&&clearTimeout(this.streamTimeout),this.snapshotHandlerTimeout!=null&&clearTimeout(this.snapshotHandlerTimeout),this.streamTimeout=void 0,this.snapshotHandlerTimeout=void 0}handleDownloadTimeout(){es.info("download canceled"),this.cancelDownload()}writeTableHeader(){var e;let t="";if(this.columns)for(let n=0;n<this.columns.length;n+=1)t+=this.columns[n].name,t+=n===this.columns.length-1?`
|
|
25
25
|
`:",";(e=this.fileWriter)==null||e.write({header:t}).then(()=>null)}startWriteTableBody(){this.columns&&this.gridRanges!=null&&(this.chunkRows=Math.floor(Fs.DOWNLOAD_CELL_CHUNK/this.columns.length),this.rangedSnapshotsTotal=this.gridRanges.map(t=>(A(t.endRow),A(t.startRow),A(this.chunkRows),Math.ceil((t.endRow-t.startRow+1)/this.chunkRows))),this.snapshotsTotal=this.rangedSnapshotsTotal.reduce((t,e)=>t+e),es.info("start writing table, total snapshots: ",this.snapshotsTotal),this.makeSnapshot(Math.min(Fs.SNAPSHOT_BUFFER_SIZE,this.snapshotsTotal)))}writeCsvTable(){this.writeTableHeader(),this.startWriteTableBody()}writeSnapshot(t,e,n){if(this.currentSnapshotIndex===t&&this.fileWriter){for(;this.snapshotsBuffer.has(this.currentSnapshotIndex);){const s=this.snapshotsBuffer.get(this.currentSnapshotIndex);A(s),this.fileWriter.write({rows:this.convertSnapshotIntoCsv(s)}),this.snapshotsBuffer.delete(this.currentSnapshotIndex),this.currentSnapshotIndex+=1,this.updateDownloadProgress(t)}if(this.snapshotsTotal&&this.currentSnapshotIndex>=this.snapshotsTotal){this.finishDownload();return}}this.snapshotCounter&&this.snapshotsTotal&&this.snapshotCounter<this.snapshotsTotal&&(es.debug2(`
|
|
@@ -31,7 +31,7 @@ ${e}`):s.setValue(`${e}`);const o=s.getLineCount(),r=s.getLineLength(o)+1;this.e
|
|
|
31
31
|
making ${Math.min(Fs.SNAPSHOT_BUFFER_SIZE-this.snapshotsBuffer.size-this.snapshotPending,this.snapshotsTotal-this.snapshotCounter)} more snapshots
|
|
32
32
|
`),this.makeSnapshot(Math.min(Fs.SNAPSHOT_BUFFER_SIZE-this.snapshotsBuffer.size-this.snapshotPending,this.snapshotsTotal-this.snapshotCounter)))}updateDownloadProgress(t){if(t!=null&&this.snapshotsTotal!=null&&this.downloadStartTime!=null){const{onDownloadProgressUpdate:e}=this.props,n=Math.floor(t*100/this.snapshotsTotal),s=t>1?Math.floor((Date.now()-this.downloadStartTime)*(this.snapshotsTotal-t)/t/1e3):null;e(n,s)}}convertSnapshotIntoCsv(t){var o;let e="";const n=t.added.iterator(),{formatter:s}=this.props,i=[];for(;n.hasNext();)i.push(n.next().value);A(this.columns);for(let r=0;r<i.length;r+=1){const l=i[r];for(let a=0;a<this.columns.length;a+=1){const{type:d,name:c}=this.columns[a],u=this.getCachedCustomColumnFormatFlag(s,c,d);let m=null;if(!u){const g=t.getFormat(l,this.columns[a]);m=(g==null?void 0:g.formatString)!=null?g:null}let p=null;m?p=s.getFormattedString(t.getData(l,this.columns[a]),d,c,m):p=s.getFormattedString(t.getData(l,this.columns[a]),d,c),e+=Fs.csvEscapeString(p),e+=a===((o=this.columns)==null?void 0:o.length)-1?`
|
|
33
33
|
`:","}}return e}makeSnapshot(t){if(t<=0)return;A(this.gridRangeCounter);let e=0,n=this.gridRanges[this.gridRangeCounter];for(A(this.tableSubscription),A(this.columns);e<t;){A(n),A(n.startRow),A(n.endRow),A(this.rangedSnapshotCounter),A(this.chunkRows);const s=n.startRow+this.rangedSnapshotCounter*this.chunkRows,i=Math.min(s+this.chunkRows-1,n.endRow),o=this.snapshotCounter;this.cancelableSnapshots.push(Ee.makeCancelable(this.tableSubscription.snapshot(M.RangeSet.ofRange(s,i),this.columns).then(r=>(nv(r),this.handleSnapshotResolved(r,o,s,i),o)).catch(r=>{es.error(r)}),r=>{es.info(`snapshot ${r} has been canceled`)})),this.rangedSnapshotCounter+=1,this.snapshotCounter+=1,this.snapshotPending+=1,this.rangedSnapshotCounter>=this.rangedSnapshotsTotal[this.gridRangeCounter]&&(this.gridRangeCounter+=1,this.rangedSnapshotCounter=0,n=this.gridRanges[this.gridRangeCounter]),e+=1}}handlePortMessage({data:t}){const{download:e,readableStreamPulling:n}=t;this.useBlobFallback||(e!=null&&(this.makeIframe(`${e}`),this.writeCsvTable()),n!=null&&(this.useBlobFallback||(this.streamTimeout!=null&&clearTimeout(this.streamTimeout),this.streamTimeout=setTimeout(this.handleDownloadTimeout,Fs.STREAM_TIMEOUT))))}handleSnapshotResolved(t,e,n,s){this.snapshotHandlerTimeout=setTimeout(()=>{this.snapshotsBuffer.set(e,t),this.snapshotPending-=1,this.writeSnapshot(e,n,s),this.cancelableSnapshots[e]=null},Fs.SNAPSHOT_HANDLER_TIMEOUT)}makeIframe(t){const e=document.createElement("iframe");e.hidden=!0,e.src=`download/${t}`,e.name="iframe",document.body.appendChild(e),this.iframes.push(e)}render(){return null}};let eo=Fs;eo.DOWNLOAD_CELL_CHUNK=6e3;eo.SNAPSHOT_BUFFER_SIZE=5;eo.STREAM_TIMEOUT=8e3;eo.SNAPSHOT_HANDLER_TIMEOUT=5;eo.defaultProps={getDownloadWorker:()=>Promise.reject(new Error("Download worker not provided")),isDownloading:!1,onDownloadCompleted:()=>{},onDownloadCanceled:()=>{},onDownloadProgressUpdate:()=>{}};const sv=X.module("VisibilityOrderingBuilder"),iv=150,Qe=class extends S.exports.Component{constructor(t){super(t),this.debouncedSearchColumns=Xe(this.searchColumns,iv),this.getFirstMovableIndex=Te((e,n)=>{for(let s=0;s<n.length;s+=1)if(e.isColumnMovable(s))return s;return null}),this.getLastMovableIndex=Te((e,n)=>{for(let s=n.length-1;s>=0;s-=1)if(e.isColumnMovable(s))return s;return null}),this.renderImmovableItem=Te(e=>h("div",{className:"visibility-ordering-list-item immovable",children:h("div",{className:"column-item",children:h("span",{className:"column-name",children:e})})},e)),this.renderVisibilityOrderingItem=Te((e,n,s,i,o,r,l,a)=>h(dl,{draggableId:`${n}`,index:s,disableInteractiveElementBlocking:!0,children:d=>v("div",{className:"visibility-ordering-list-item",ref:d.innerRef,...d.draggableProps,children:[h("button",{type:"button",className:"visibility btn btn-link btn-link-icon",onMouseDown:c=>{this.handleVisibilityDraggingStart(n,i?Qe.VISIBILITY_OPTIONS.SHOW:Qe.VISIBILITY_OPTIONS.HIDE,c)},onMouseEnter:c=>{this.handleMouseEnter(n,c)},onMouseUp:c=>{this.handleVisibilityDraggingEnd(c)},onClick:c=>{this.handleItemClick(n,c,!1)},onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(this.handleVisibilityKeyDown(n,i?Qe.VISIBILITY_OPTIONS.SHOW:Qe.VISIBILITY_OPTIONS.HIDE),c.stopPropagation(),c.preventDefault())},children:h(K,{icon:i?Nc:Ra})}),v("div",{role:"menuitem",tabIndex:0,className:z("ordering column-item",{isSelected:o},{isDragging:r},{isDragged:l},{"two-dragged":a===2},{"multiple-dragged":a!=null&&a>2}),onClick:c=>{this.handleItemClick(n,c)},...d.dragHandleProps,children:[h("span",{className:"column-name",children:e}),v("div",{children:[a!=null&&a!==0&&h("span",{className:"number-badge",children:a}),h(Ie,{children:"Drag to re-order"}),h(K,{icon:ul})]})]})]})},e)),this.handleSearchInputChange=this.handleSearchInputChange.bind(this),this.searchColumns=this.searchColumns.bind(this),this.handleOrderDraggingStart=this.handleOrderDraggingStart.bind(this),this.handleOrderDraggingEnd=this.handleOrderDraggingEnd.bind(this),this.state={selectedColumns:[],lastSelectedColumns:[],isDraggingVisibility:!1,visibilityDraggingOption:void 0,visibilityDraggingStartColumn:null,isDraggingOrder:!1,orderDraggingColumn:null,searchFilter:""},this.list=null}componentWillUnmount(){this.debouncedSearchColumns.cancel()}resetVisibilityOrdering(){const{model:t,onColumnVisibilityChanged:e,onMovedColumnsChanged:n}=this.props,{columns:s}=t;e(s.map(i=>{const o=t.getColumnIndexByName(i.name);return A(o),o}),Qe.VISIBILITY_OPTIONS.SHOW),this.setState({selectedColumns:[],lastSelectedColumns:[],searchFilter:""}),n([])}resetSelection(){const{isDraggingOrder:t}=this.state;t||this.setState({selectedColumns:[],lastSelectedColumns:[]})}handleSearchInputChange(t){const e=t.target.value;if(this.setState({searchFilter:e}),!e){this.debouncedSearchColumns.cancel(),this.resetSelection();return}this.debouncedSearchColumns(e)}searchColumns(t){var r;const{model:e,movedColumns:n}=this.props,{columns:s}=e,i=[];let o=s.length;if(s.forEach((l,a)=>{const d=l.name.toLowerCase();e.isColumnMovable(a)&&d.includes(t.toLowerCase())&&(i.push(a),o=Math.min(o,G.getVisibleIndex(a,n)))}),this.addColumnToSelected(i,!1),i.length>0){const l=(r=this.list)==null?void 0:r.querySelectorAll(".column-item")[o];l==null||l.scrollIntoView({block:"center"})}}handleVisibilityKeyDown(t,e){const{onColumnVisibilityChanged:n}=this.props;n([t],e)}handleVisibilityDraggingStart(t,e,n){const{onColumnVisibilityChanged:s,movedColumns:i}=this.props,o=G.isModifierKeyDown(n),r=n.shiftKey;if(o||r)return;s([t],e);const l=G.getVisibleIndex(t,i);this.setState({isDraggingVisibility:!0,visibilityDraggingOption:e,visibilityDraggingStartColumn:l}),this.addColumnToSelected([t])}handleVisibilityDraggingEnd(t=null){t&&t.target.focus();const{isDraggingVisibility:e}=this.state;e&&this.setState({isDraggingVisibility:!1,visibilityDraggingOption:void 0,visibilityDraggingStartColumn:null})}handleOrderDraggingStart(t){var o;document.documentElement.classList.add("drag-pointer-events-none");const{selectedColumns:e}=this.state,{draggableId:n,source:{index:s}}=t,i=parseInt(n,10);if(((o=this.list)==null?void 0:o.querySelectorAll(".column-item")[s]).focus(),!e.includes(i)){this.setState({isDraggingOrder:!0,orderDraggingColumn:i,selectedColumns:[i]});return}this.setState({isDraggingOrder:!0,orderDraggingColumn:i})}handleOrderDraggingEnd(t){document.documentElement.classList.remove("drag-pointer-events-none");const{movedColumns:e,onMovedColumnsChanged:n}=this.props,{selectedColumns:s,orderDraggingColumn:i}=this.state;if(this.setState({isDraggingOrder:!1,orderDraggingColumn:null}),!t.destination)return;const{index:o}=t.destination,r=[...s].sort((m,p)=>G.getVisibleIndex(m,e)-G.getVisibleIndex(p,e));let l=[...e];A(i);const a=G.getVisibleIndex(i,l),d=[],c=[];l=G.moveItem(a,o,l),r.forEach(m=>{const p=G.getVisibleIndex(m,l);m!==i&&(p<o?d.push(m):c.push(m))}),d.forEach(m=>{const p=G.getVisibleIndex(m,l);l=G.moveItem(p,o,l)});const u=d.length>0||a>o?o+1:o;c.reverse().forEach(m=>{const p=G.getVisibleIndex(m,l);l=G.moveItem(p,u,l)}),n(l),sv.debug("move column order by drag & drop",l)}handleMouseEnter(t,e){const{onColumnVisibilityChanged:n,movedColumns:s,userColumnWidths:i}=this.props,{isDraggingVisibility:o,visibilityDraggingOption:r,visibilityDraggingStartColumn:l}=this.state,a=G.getVisibleIndex(t,s),d=G.isModifierKeyDown(e),c=e.shiftKey;if(!o||d||c)return;e.target.focus();const u=[t];A(l);const m=a>l;for(let p=l;m?p<a:p>a;m?p+=1:p-=1){const g=G.getModelIndex(p,s),f=G.checkColumnHidden(g,i);(f&&r===Qe.VISIBILITY_OPTIONS.SHOW||!f&&r===Qe.VISIBILITY_OPTIONS.HIDE)&&u.push(g)}this.addColumnToSelected(u,!0),n(u,r)}handleMoveColumns(t){const{movedColumns:e,onMovedColumnsChanged:n,model:s}=this.props,{columns:i}=s,{selectedColumns:o}=this.state;if(o.length===0)return;const r=this.getFirstMovableIndex(s,i),l=this.getLastMovableIndex(s,i);if(r==null||l==null)return;const a=[...o].sort((u,m)=>t===Qe.MOVE_OPTIONS.TOP||t===Qe.MOVE_OPTIONS.UP?G.getVisibleIndex(u,e)-G.getVisibleIndex(m,e):G.getVisibleIndex(m,e)-G.getVisibleIndex(u,e));let d=[],c=()=>{};switch(t){case Qe.MOVE_OPTIONS.TOP:a.forEach((u,m)=>{const p=G.getVisibleIndex(u,e);d=G.moveItem(p,r+m,d)}),c=()=>{A(this.list),this.list.scrollTop=0};break;case Qe.MOVE_OPTIONS.BOTTOM:a.forEach((u,m)=>{const p=G.getVisibleIndex(u,e);d=G.moveItem(p,l-m,d)}),c=()=>{A(this.list),this.list.scrollTop=this.list.scrollHeight};break;case Qe.MOVE_OPTIONS.UP:G.getVisibleIndex(a[0],e)!==r&&a.forEach(u=>{const m=G.getVisibleIndex(u,e);d=G.moveItem(m,m-1,d)});break;case Qe.MOVE_OPTIONS.DOWN:G.getVisibleIndex(a[0],e)!==l&&a.forEach(u=>{const m=G.getVisibleIndex(u,e);d=G.moveItem(m,m+1,d)});break}d.length>0&&n(e.concat(d),c)}handleSortColumns(t){const{model:e,onMovedColumnsChanged:n}=this.props,{columns:s}=e,i=[],o=[];for(let c=0;c<s.length;c+=1)e.isColumnMovable(c)?i.push(c):o.push(c);const r=i.sort((c,u)=>{const m=t===Qe.SORTING_OPTIONS.ASC,p=s[c].name.toUpperCase(),g=s[u].name.toUpperCase();return tn.sort(p,g,m)}),l=[];for(let c=0;c<o.length;c+=1){const u=o[c];l[u]=u}let a=0;for(let c=0;c<r.length;c+=1){for(;l[a]!=null;)a+=1;l[a]=r[c]}let d=[];l.forEach((c,u)=>{const m=G.getVisibleIndex(c,d);d=G.moveItem(m,u,d)}),n(d)}handleItemClick(t,e,n=!0){e.stopPropagation(),e.currentTarget.focus();const{selectedColumns:s,lastSelectedColumns:i}=this.state,o=G.isModifierKeyDown(e),r=e.shiftKey,l=s.includes(t),a=[t];if(l&&o){this.removeColumnFromSelected(t);return}if(l&&s.length===1&&n){this.removeColumnFromSelected(t);return}if(r){const{movedColumns:d}=this.props,c=i[i.length-1],u=G.getVisibleIndex(c,d),m=G.getVisibleIndex(t,d),p=m>u,g=[];for(let f=u;p?f<m:f>m;p?f+=1:f-=1)g.push(G.getModelIndex(f,d));g.forEach(f=>{s.includes(f)||a.push(f)})}this.addColumnToSelected(a,o||r)}addColumnToSelected(t,e=!1){const{selectedColumns:n,lastSelectedColumns:s}=this.state,i=e?n.concat(t):t,o=e?s.concat(t):t;this.setState({selectedColumns:i,lastSelectedColumns:o})}removeColumnFromSelected(t){const{selectedColumns:e,lastSelectedColumns:n}=this.state,s=[...e];s.splice(s.findIndex(r=>r===t),1);const i=n[n.length-1],o=[...n];i===t&&o.pop(),this.setState({selectedColumns:s,lastSelectedColumns:o})}makeVisibilityOrderingList(){const{model:t,userColumnWidths:e,movedColumns:n}=this.props,{columns:s}=t,{selectedColumns:i,isDraggingOrder:o,orderDraggingColumn:r}=this.state,l=[];let a=!1;for(let d=0;d<s.length;d+=1){const c=G.getModelIndex(d,n),u=s[c],m=t.isColumnMovable(c);if(d>0&&m!==a&&l.push(h("hr",{})),m){const p=e.get(c)===0,g=i.includes(c),f=r===c,b=o&&f&&i.length>1?i.length:null;l.push(this.renderVisibilityOrderingItem(u.name,c,d,p,g,o,f,b))}else l.push(this.renderImmovableItem(u.name));a=m}return l}render(){const{model:t,userColumnWidths:e,onColumnVisibilityChanged:n}=this.props,{selectedColumns:s,searchFilter:i}=this.state,{columns:o}=t,r=s.length===0,l=r?o.map((u,m)=>m).filter(u=>t.isColumnMovable(u)):[...s],a=G.checkAllColumnsHidden(l,e),d=a?"Show Selected":"Hide Selected",c=this.makeVisibilityOrderingList();return v("div",{role:"menu",className:"visibility-ordering-builder",tabIndex:0,onMouseUp:()=>{this.handleVisibilityDraggingEnd()},onMouseLeave:()=>{this.handleVisibilityDraggingEnd()},children:[v("div",{className:"top-menu",children:[v("button",{type:"button",className:"btn btn-link",onClick:()=>{n(l,a?Qe.VISIBILITY_OPTIONS.SHOW:Qe.VISIBILITY_OPTIONS.HIDE)},children:[h(K,{icon:a?Nc:Ra}),h(Ie,{children:"Toggle column visibility"}),r?"Toggle All":d]}),v("div",{children:[v("button",{type:"button",className:"btn btn-link text-muted",onClick:()=>{this.resetVisibilityOrdering()},children:["Reset",h(Ie,{children:"Reset to default"})]}),v("button",{type:"button",className:"btn btn-link btn-link-icon",onClick:()=>{this.handleSortColumns(Qe.SORTING_OPTIONS.ASC)},children:[h(K,{icon:hd}),h(Ie,{children:"Sort ascending"})]}),v("button",{type:"button",className:"btn btn-link btn-link-icon",onClick:()=>{this.handleSortColumns(Qe.SORTING_OPTIONS.DSC)},children:[h(K,{icon:ud}),h(Ie,{children:"Sort descending"})]}),h("span",{className:"vertical-divider"}),v("button",{type:"button",className:"btn btn-link btn-link-icon",onClick:()=>{this.handleMoveColumns(Qe.MOVE_OPTIONS.UP)},disabled:r,children:[h(K,{icon:pf}),h(Ie,{children:"Move selection up"})]}),v("button",{type:"button",className:"btn btn-link btn-link-icon",onClick:()=>{this.handleMoveColumns(Qe.MOVE_OPTIONS.DOWN)},disabled:r,children:[h(K,{icon:uf}),h(Ie,{children:"Move selection down"})]}),v("button",{type:"button",className:"btn btn-link btn-link-icon",onClick:()=>{this.handleMoveColumns(Qe.MOVE_OPTIONS.TOP)},disabled:r,children:[h(K,{icon:Uf}),h(Ie,{children:"Move selection to top"})]}),v("button",{type:"button",className:"btn btn-link btn-link-icon",onClick:()=>{this.handleMoveColumns(Qe.MOVE_OPTIONS.BOTTOM)},disabled:r,children:[h(K,{icon:Vf}),h(Ie,{children:"Move selection to bottom"})]})]})]}),h("div",{className:"top-menu",children:h(gs,{className:"w-100",value:i,matchCount:i?s.length:void 0,onChange:this.handleSearchInputChange})}),h(Vo,{onDragStart:this.handleOrderDraggingStart,onDragEnd:this.handleOrderDraggingEnd,children:h(Ho,{droppableId:"droppable-visibility-order-list",children:(u,m)=>h("div",{role:"menu",className:z("visibility-ordering-list",{isDragging:m.draggingFromThisWith}),ref:u.innerRef,...u.droppableProps,children:v("div",{className:"column-list",ref:p=>{this.list=p},children:[c,u.placeholder]})})})})]})}};let pi=Qe;pi.VISIBILITY_OPTIONS={SHOW:"SHOW",HIDE:"HIDE"};pi.SORTING_OPTIONS={DSC:"DSC",ASC:"ASC"};pi.MOVE_OPTIONS={TOP:"TOP",BOTTOM:"BOTTOM",UP:"UP",DOWN:"DOWN"};pi.COLUMN_CHANGE_OPTIONS={ALL:"ALL",SELECTION:"SELECTION"};pi.defaultProps={movedColumns:[],onColumnVisibilityChanged:()=>{},onMovedColumnsChanged:()=>{}};const yr=X.module("AdvancedFilterCreatorFilterItem");class Ud extends S.exports.PureComponent{constructor(e){super(e),this.getCachedIsValid=he((o,r,l,a)=>{try{return!l||P.makeAdvancedValueFilter(o,r,l,a)!=null}catch{return!1}}),this.handleDelete=this.handleDelete.bind(this),this.handleTypeChange=this.handleTypeChange.bind(this),this.handleValueChange=this.handleValueChange.bind(this),this.typeDropdown=null;const{value:n="",filterTypes:s,selectedType:i=s[0]}=e;this.state={selectedType:i,value:n}}static getLabelForFilter(e,n){try{if(P.isNumberType(e)||P.isCharType(e))return qb(n);if(P.isTextType(e))return Kb(n);if(P.isDateType(e))return Yb(n);if(P.isBooleanType(e))return Xb(n);throw new Error(`Unrecognized column type: ${e}`)}catch(s){return yr.warn(s),""}}componentDidMount(){var e;(e=this.typeDropdown)==null||e.focus()}componentDidUpdate(e){const{value:n,selectedType:s}=this.props;s!==void 0&&e.selectedType!==s&&this.setState({selectedType:s}),n!==void 0&&e.value!==n&&this.setState({value:n})}handleTypeChange(e){const n=e.target.value;yr.debug2("typeChange",n),this.setState({selectedType:n});const{onChange:s}=this.props,{value:i}=this.state;i!=null&&i.length>0&&s(n,i)}handleValueChange(e){yr.debug2("valueChange");const{value:n}=e.target;this.setState({value:n});const{onChange:s}=this.props,{selectedType:i}=this.state;i!=null&&s(i,n)}handleDelete(){yr.debug("delete");const{onDelete:e}=this.props;e()}render(){const{column:e,filterTypes:n,formatter:s}=this.props,{selectedType:i,value:o}=this.state,r=!P.isBooleanType(e.type),l=[],a=this.getCachedIsValid(e,i,o,s.timeZone);for(let d=0;d<n.length;d+=1){const c=n[d],u=Ud.getLabelForFilter(e.type,c),m=h("option",{value:c,children:u},c);l.push(m)}return h("div",{className:"advanced-filter-creator-filter-item",children:v("div",{className:"form-row",children:[h("div",{className:"form-group col",children:h("select",{className:"form-control custom-select",value:i,onChange:this.handleTypeChange,ref:d=>{this.typeDropdown=d},children:l})}),r&&h("div",{className:"form-group col",children:h("div",{className:"input-group",children:h("input",{type:"text",className:z("form-control",{error:!a}),placeholder:"Enter value",value:o,onChange:this.handleValueChange})})}),h("div",{className:"form-group col-1 px-0",children:v("button",{type:"button",className:"btn btn-link btn-link-icon w-100 h-100 p-0 m-0",onClick:this.handleDelete,children:[h(K,{icon:_n}),h(Ie,{children:"Remove Filter"})]})})]})})}}const Th=X.module("AdvancedFilterCreatorSelectValueList"),Va=class extends S.exports.PureComponent{constructor(t){super(t),this.handleSelect=this.handleSelect.bind(this),this.handleViewportChange=this.handleViewportChange.bind(this),this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.handleTableUpdate=this.handleTableUpdate.bind(this),this.list=null;const{selectedValues:e}=this.props;this.state={itemCount:0,items:[],offset:0,selectedValues:e,isLoading:!0}}static indexOf(t,e){for(let n=0;n<e.length;n+=1){const s=e[n];if(s===t||s!=null&&s.valueOf!=null&&t!=null&&t.valueOf!=null&&s.valueOf()===t.valueOf())return n}return-1}componentDidMount(){const{table:t}=this.props;t&&this.startListening(t)}componentDidUpdate(t){const{filters:e,invertSelection:n,selectedValues:s,table:i}=this.props;t.table!==i&&(t.table&&this.stopListening(t.table),i&&this.startListening(i),this.resetViewport()),t.invertSelection!==n&&this.setState({selectedValues:[]},this.handleSelectionUpdate),t.selectedValues!==s&&this.setState({selectedValues:s},this.handleSelectionUpdate),t.filters!==e&&(i==null||i.applyFilter(e),this.resetViewport())}componentWillUnmount(){const{table:t}=this.props;t&&this.stopListening(t)}handleSelect(t,e){const{invertSelection:n}=this.props;let{selectedValues:s}=this.state;s=[...s];const i=Va.indexOf(e,s);i>=0?s.splice(i,1):s.push(e);let o=i<0;n&&(o=!o);const{offset:r}=this.state;let{items:l}=this.state;l=[...l];const a=t-r;a>=0&&a<l.length&&(l[a].isSelected=o),this.setState({items:l,selectedValues:s});const{onChange:d}=this.props;d(s,n)}handleViewportChange(t,e){this.updateViewport(t,e)}handleSelectionUpdate(){this.updateItemSelection()}handleTableUpdate(t){const{table:e,formatter:n}=this.props;if(!e)return;const s=t.detail,{offset:i}=s,o=[],r=e.columns[0];for(let a=0;a<s.rows.length;a+=1){const c=s.rows[a].get(r),u=n.getFormattedString(c,r.type,r.name),m=this.isValueSelected(c);o.push({displayValue:u,value:c,isSelected:m})}Th.debug2("Received table update:",i,o.length);const l=e.size;this.setState({itemCount:l,items:o,offset:i,isLoading:!1})}isValueSelected(t){const{invertSelection:e}=this.props,{selectedValues:n}=this.state,s=Va.indexOf(t,n);return e?s<0:s>=0}startListening(t){t.addEventListener(M.Table.EVENT_UPDATED,this.handleTableUpdate)}stopListening(t){t.removeEventListener(M.Table.EVENT_UPDATED,this.handleTableUpdate)}resetViewport(){this.list&&this.list.topRow!=null&&this.list.bottomRow!=null&&this.updateViewport(this.list.topRow,this.list.bottomRow,!0)}updateItemSelection(){let{items:t}=this.state;t=[...t];for(let e=0;e<t.length;e+=1){const n=t[e],{value:s}=n;n.isSelected=this.isValueSelected(s)}this.setState({items:t})}updateViewport(t,e,n=!1){const{table:s}=this.props;if(s==null)return;n&&this.setState({isLoading:!0});const i=e-t+1,o=Math.max(0,t-i*3),r=Math.max(o,e+i*3);Th.debug2("Setting viewport",o,",",r),s.setViewport(o,r)}render(){const{offset:t,isLoading:e,items:n,itemCount:s}=this.state;return v("div",{className:"select-value-list-wrapper",children:[h(Vu,{itemCount:s,items:n,offset:t,onSelect:this.handleSelect,onViewportChange:this.handleViewportChange,ref:i=>{this.list=i}}),h(ht,{in:e,timeout:250,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"loading-list",children:h(kn,{className:"loading-spinner-large"})})})]})}};let Jm=Va;Jm.defaultProps={invertSelection:!0,selectedValues:[],onChange:()=>{}};const ep=class extends S.exports.PureComponent{constructor(t){super(t),this.handleSelectAllClick=this.handleSelectAllClick.bind(this),this.handleClearAllClick=this.handleClearAllClick.bind(this),this.handleListChange=this.handleListChange.bind(this),this.handleSearchChange=this.handleSearchChange.bind(this),this.handleUpdateFilterTimeout=this.handleUpdateFilterTimeout.bind(this);const{invertSelection:e,selectedValues:n}=t;this.state={filters:[],invertSelection:e,selectedValues:n,searchText:""}}componentDidMount(){this.initSearchTable()}componentDidUpdate(t,e){const{invertSelection:n,selectedValues:s,table:i}=this.props;t.table!==i&&this.initSearchTable(),t.invertSelection!==n&&this.setState({invertSelection:n}),t.selectedValues!==s&&this.setState({selectedValues:s});const{table:o,searchText:r}=this.state;o!==e.table&&(e.table!=null&&e.table.close(),o!=null&&this.startUpdateFilterTimer()),r!==e.searchText&&this.startUpdateFilterTimer()}componentWillUnmount(){const{table:t}=this.state;t!=null&&t.close(),this.searchTablePromise=void 0,this.stopUpdateFilterTimer()}getColumnName(){const{table:t}=this.props;return t!=null?t.columns[0].name:""}getDisplayedValuesCount(){const{invertSelection:t,selectedValues:e,table:n}=this.state;return n==null?null:t?n.totalSize-e.length:e.length}getDisplayedValueText(){const t=this.getDisplayedValuesCount(),{table:e}=this.state,{formatter:n}=this.props;if(t!=null&&e!=null){const s=n.getFormattedString(t,"long"),i=n.getFormattedString(e.totalSize,"long");let o="";return t<1e6&&(o="Displaying "),`${o}${s} of ${i}`}return null}initSearchTable(){const{table:t}=this.props;if(t==null)return;const e=t.copy();this.searchTablePromise=e,this.searchTablePromise.then(n=>{this.searchTablePromise===e?(this.setState({table:n}),this.searchTablePromise=void 0):n.close()})}handleListChange(t,e){this.setState({selectedValues:t,invertSelection:e});const{onChange:n}=this.props;n(t,e)}handleSearchChange(t){const e=t.target.value;this.setState({searchText:e})}handleSelectAllClick(){this.resetSelection(!0)}handleClearAllClick(){this.resetSelection(!1)}handleUpdateFilterTimeout(){this.updateFilterTimer=void 0,this.updateTableFilter()}resetSelection(t){const e=[];this.setState({invertSelection:t,selectedValues:e});const{onChange:n}=this.props;n(e,t)}startUpdateFilterTimer(){this.stopUpdateFilterTimer(),this.updateFilterTimer=setTimeout(this.handleUpdateFilterTimeout,ep.searchDebounceTime)}stopUpdateFilterTimer(){this.updateFilterTimer!=null&&(clearTimeout(this.updateFilterTimer),this.updateFilterTimer=void 0)}updateTableFilter(){const{table:t,searchText:e}=this.state,{timeZone:n}=this.props,s=t==null?void 0:t.columns[0],i=[];if(s==null)return;let o;if(e.length>0){let r=null;P.isCharType(s.type)?r=P.makeQuickFilter(s,e):P.isTextType(s.type)?r=P.makeQuickFilter(s,`~${e}`,n):r=P.makeQuickFilter(s,`>=${e}`,n),r!=null?i.push(r):o="Invalid search text"}this.setState({filters:i,error:o})}render(){const{error:t,filters:e,invertSelection:n,selectedValues:s,searchText:i,table:o}=this.state,{formatter:r,showSearch:l}=this.props,a=this.getColumnName(),d=this.getDisplayedValueText(),c=a?`Find ${a}...`:"";return v("div",{className:"advanced-filter-creator-select-value",children:[v("div",{className:l?"form-group":"",children:[h("label",{htmlFor:"advanced-filter-creator-select-value-input",children:"Select Values"}),l&&h("input",{type:"text",className:z("form-control",{"is-invalid":t!=null}),id:"advanced-filter-creator-select-value-input",placeholder:c,value:i,onChange:this.handleSearchChange})]}),h(Jm,{table:o,filters:e,invertSelection:n,selectedValues:s,formatter:r,onChange:this.handleListChange}),v("div",{className:"advanced-filter-creator-select-meta-row",children:[v("div",{children:[h("button",{type:"button",className:"btn btn-link",onClick:this.handleSelectAllClick,children:"Select All"}),h("button",{type:"button",className:"btn btn-link",onClick:this.handleClearAllClick,children:"Clear"})]}),h(ht,{in:d!=null,timeout:250,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"row-count-info",children:d})})]})]})}};let Bd=ep;Bd.searchDebounceTime=250;Bd.defaultProps={invertSelection:!0,selectedValues:[],onChange:()=>{},showSearch:!0};const mo=X.module("AdvancedFilterCreator"),Js=class extends S.exports.PureComponent{constructor(t){var r,l;super(t),this.getFilterTypes=he(a=>P.getFilterTypes(a)),this.handleAddAnd=this.handleAddAnd.bind(this),this.handleAddOr=this.handleAddOr.bind(this),this.handleChangeFilterOperator=this.handleChangeFilterOperator.bind(this),this.handleDone=this.handleDone.bind(this),this.handleFilterChange=this.handleFilterChange.bind(this),this.handleFilterDelete=this.handleFilterDelete.bind(this),this.handleSelectValueChange=this.handleSelectValueChange.bind(this),this.handleReset=this.handleReset.bind(this),this.handleSortDown=this.handleSortDown.bind(this),this.handleSortUp=this.handleSortUp.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleFocusTrapStart=this.handleFocusTrapStart.bind(this),this.handleFocusTrapEnd=this.handleFocusTrapEnd.bind(this),this.handleUpdateTimeout=this.handleUpdateTimeout.bind(this),this.focusTrapContainer=Y.createRef();const{options:e}=t;let{filterOperators:n,invertSelection:s,selectedValues:i}=e;const o=(l=(r=e.filterItems)==null?void 0:r.map(({selectedType:a,value:d})=>({selectedType:a,value:d,key:We()})))!=null?l:[];o.length===0&&o.push(Js.makeFilterItem()),n==null&&(n=[]),s==null&&(s=!0),i==null&&(i=[]),this.state={filterItems:o,filterOperators:n,invertSelection:s,selectedValues:i,valuesTableError:null,valuesTable:void 0}}static makeFilterItem(){return{key:We()}}componentDidMount(){this.initValuesTable()}componentWillUnmount(){this.debounceTimeout!=null&&(clearTimeout(this.debounceTimeout),this.sendUpdate()),this.valuesTablePromise!=null&&this.valuesTablePromise.cancel()}getFilterChangeHandler(t){return this.handleFilterChange.bind(this,t)}getFilterDeleteHandler(t){return this.handleFilterDelete.bind(this,t)}initValuesTable(){const{model:t,column:e}=this.props;if(!t.isValuesTableAvailable){mo.debug("No values table for this model, just ignore");return}this.valuesTablePromise=P.makeCancelableTablePromise(t.valuesTable(e)),this.valuesTablePromise.then(n=>{const s=n.columns[0].sort().asc();n.applySort([s]),this.setState({valuesTable:n})}).catch(n=>{Ee.isCanceled(n)||(mo.error("Unable to open values table",n),this.setState({valuesTableError:n}))})}handleFocusTrapEnd(){var t,e;((e=(t=this.focusTrapContainer)==null?void 0:t.current)==null?void 0:e.querySelector("button,select,input,textarea")).focus()}handleFocusTrapStart(){var e,n;const t=(n=(e=this.focusTrapContainer)==null?void 0:e.current)==null?void 0:n.querySelectorAll("button,select,input,textarea");t&&t.length>0&&t[t.length-1].focus()}handleAddAnd(){let{filterItems:t,filterOperators:e}=this.state;t=t.concat(Js.makeFilterItem()),e=e.concat(Wt.and),this.setState({filterItems:t,filterOperators:e})}handleAddOr(){let{filterItems:t,filterOperators:e}=this.state;t=t.concat(Js.makeFilterItem()),e=e.concat(Wt.or),this.setState({filterItems:t,filterOperators:e})}handleChangeFilterOperator(t){const e=t.currentTarget,{operator:n,index:s}=e.dataset;A(s);const i=parseInt(s,10);let{filterOperators:o}=this.state;o=[...o],Gb(n),o[i]=n,this.setState({filterOperators:o}),this.startUpdateTimer()}handleFilterChange(t,e,n){let{filterItems:s}=this.state;s=[...s];const{key:i}=s[t];s[t]={key:i,selectedType:e,value:n},this.setState({filterItems:s}),this.startUpdateTimer()}handleFilterDelete(t){let{filterItems:e,filterOperators:n}=this.state;e=[...e],n=[...n],t<e.length&&e.splice(t,1),t<n.length?n.splice(t,1):t===n.length&&n.splice(n.length-1,1),e.length===0&&e.push(Js.makeFilterItem()),this.setState({filterItems:e,filterOperators:n}),this.startUpdateTimer()}handleSelectValueChange(t,e){this.setState({selectedValues:t,invertSelection:e}),this.startUpdateTimer()}handleReset(){mo.debug("Resetting Advanced Filter"),this.setState({filterItems:[Js.makeFilterItem()],filterOperators:[],selectedValues:[],invertSelection:!0}),this.startUpdateTimer()}handleSortDown(t){const e=Ne.isModifierKeyDown(t);this.sortTable(P.sortDirection.descending,e)}handleSortUp(t){const e=Ne.isModifierKeyDown(t);this.sortTable(P.sortDirection.ascending,e)}handleSubmit(t){mo.debug("Submitting Advanced Filter"),this.stopUpdateTimer(),this.sendUpdate(),t.preventDefault()}handleDone(t){mo.debug("Submitting and Closing Advanced Filter"),this.stopUpdateTimer(),this.sendUpdate();const{onDone:e}=this.props;e(),t.preventDefault()}handleUpdateTimeout(){this.debounceTimeout=void 0,this.sendUpdate()}shouldShowAddFilter(){const{filterItems:t}=this.state;if(t.length===0)return!1;const e=t[t.length-1],{selectedType:n,value:s}=e;return n!=null&&n.length>0&&s!=null&&s.length>0}sortTable(t,e=!1){const{column:n,onSortChange:s}=this.props;s(n,t,e)}startUpdateTimer(){this.stopUpdateTimer(),this.debounceTimeout=setTimeout(this.handleUpdateTimeout,Js.debounceFilterUpdate)}stopUpdateTimer(){this.debounceTimeout!==void 0&&(clearTimeout(this.debounceTimeout),this.debounceTimeout=void 0)}sendUpdate(){const{filterItems:t,filterOperators:e,invertSelection:n,selectedValues:s}=this.state,{column:i,onFilterChange:o,model:r}=this.props,{formatter:l}=r,a=t.filter(({selectedType:m,value:p})=>m!=null&&p!=null&&p!==""),d=e.filter((m,p)=>m!=null&&t[p].selectedType!=null&&t[p].value!=null&&t[p].value!=="").slice(0,a.length-1),c={filterItems:a,filterOperators:d,invertSelection:n,selectedValues:s},u=P.makeAdvancedFilter(i,c,l.timeZone);o(i,u,c)}render(){const{column:t,model:e,sortDirection:n,formatter:s}=this.props,{filterItems:i,filterOperators:o,invertSelection:r,selectedValues:l,valuesTable:a,valuesTableError:d}=this.state,{isValuesTableAvailable:c}=e,u=P.isBooleanType(t.type),m=P.isDateType(t.type),p=this.getFilterTypes(t.type),g=t.type.substring(t.type.lastIndexOf(".")+1),f=[];if(!u&&p.length)for(let w=0;w<i.length;w+=1){const T=i[w],{key:y,selectedType:E,value:I}=T,R=h(Ud,{column:t,filterTypes:p,onChange:this.getFilterChangeHandler(w),onDelete:this.getFilterDeleteHandler(w),selectedType:E,value:I,formatter:s},y);if(f.push(R),w<o.length){const x=o[w]===Wt.and,U=v("div",{className:"form-row justify-content-end advanced-filter-creator-filter-operator",children:[h("button",{type:"button",className:z("btn btn-link filter-operator",{active:x}),onClick:this.handleChangeFilterOperator,"data-index":w,"data-operator":Wt.and,children:"AND"}),h("button",{type:"button",className:z("btn btn-link filter-operator",{active:!x}),onClick:this.handleChangeFilterOperator,"data-index":w,"data-operator":Wt.or,children:"OR"})]},`filterOperator${y}`);f.push(U)}}const b=this.shouldShowAddFilter(),C=v("div",{className:z("form-row justify-content-end add-filter-item",{hidden:!b}),children:[h("span",{className:"text-muted",children:h(K,{icon:Ls})}),v("button",{type:"button",className:"btn btn-link btn-filter-item",onClick:this.handleAddAnd,disabled:!b,children:["AND",h(Ie,{children:"Add filter with AND"})]}),v("button",{type:"button",className:"btn btn-link btn-filter-item",onClick:this.handleAddOr,disabled:!b,children:["OR",h(Ie,{children:"Add filter with OR"})]})]},"addFilterItem");return f.push(C),v("div",{className:"advanced-filter-creator",role:"presentation",children:[h("div",{tabIndex:0,onFocus:this.handleFocusTrapStart}),v("form",{onSubmit:this.handleSubmit,ref:this.focusTrapContainer,children:[v("div",{className:"title-bar",children:[h("h6",{className:"advanced-filter-title",children:"Advanced Filters"}),v("div",{className:"advanced-filter-menu-buttons",children:[v("button",{type:"button",className:z("btn btn-link btn-link-icon sort-operator",{active:n===P.sortDirection.descending}),onClick:this.handleSortDown,children:[h(K,{icon:Fc}),v(Ie,{children:["Sort ",t.name," Descending"]})]}),v("button",{type:"button",className:z("btn btn-link btn-link-icon sort-operator",{active:n===P.sortDirection.ascending}),onClick:this.handleSortUp,children:[h(K,{rotation:180,icon:Fc}),v(Ie,{children:["Sort ",t.name," Ascending"]})]})]})]}),h("hr",{}),v("div",{className:"advanced-filter-column-name",children:[t.name,"\xA0",v("span",{className:"column-type",children:["(",g,")"]})]}),f,c&&d==null&&v(ue,{children:[!u&&h("hr",{}),h("div",{className:"form-group",children:h(Bd,{table:a,onChange:this.handleSelectValueChange,invertSelection:r,selectedValues:l,formatter:s,showSearch:!m,timeZone:s.timeZone})})]}),v("div",{className:"form-row justify-content-end",children:[h("button",{type:"button",className:"btn btn-outline-primary mr-2",onClick:this.handleReset,children:"Reset"}),h("button",{type:"button",className:"btn btn-primary",onClick:this.handleDone,children:"Done"})]})]}),h("div",{tabIndex:0,onFocus:this.handleFocusTrapEnd})]})}};let $d=Js;$d.debounceFilterUpdate=250;$d.defaultProps={options:{filterItems:null,filterOperators:null,invertSelection:!0,selectedValues:[]},sortDirection:null};function ov(t,e){const n=av(t);return n===void 0?void 0:`${pv(t)} ? ${n} : ${e}`}function rv(t){return dh.Column.formatRowColor(t)}function lv(t,e){return t.formatColor(e)}const ca=X.module("ConditionalFormattingUtils");var Kn=(t=>(t.CONDITIONAL="conditional",t.ROWS="rows",t))(Kn||{}),Ye=(t=>(t.IS_EQUAL="is-equal",t.IS_NOT_EQUAL="is-not-equal",t.IS_BETWEEN="is-between",t.GREATER_THAN="greater-than",t.GREATER_THAN_OR_EQUAL="greater-than-or-equal",t.LESS_THAN="less-than",t.LESS_THAN_OR_EQUAL="less-than-or-equal",t.IS_NULL="is-null",t.IS_NOT_NULL="is-not-null",t))(Ye||{}),sn=(t=>(t.IS_EXACTLY="is-exactly",t.IS_NOT_EXACTLY="is-not-exactly",t.CONTAINS="contains",t.DOES_NOT_CONTAIN="does-not-contain",t.STARTS_WITH="starts-with",t.ENDS_WITH="ends-with",t.IS_NULL="is-null",t.IS_NOT_NULL="is-not-null",t))(sn||{}),Lt=(t=>(t.IS_EXACTLY="is-exactly",t.IS_NOT_EXACTLY="is-not-exactly",t.IS_BEFORE="is-before",t.IS_BEFORE_OR_EQUAL="is-before-or-equal",t.IS_AFTER="is-after",t.IS_AFTER_OR_EQUAL="is-after-or-equal",t.IS_NULL="is-null",t.IS_NOT_NULL="is-not-null",t))(Lt||{}),Ro=(t=>(t.IS_TRUE="is-true",t.IS_FALSE="is-false",t.IS_NULL="is-null",t.IS_NOT_NULL="is-not-null",t))(Ro||{}),oi=(t=>(t.IS_EQUAL="is-equal",t.IS_NOT_EQUAL="is-not-equal",t.IS_NULL="is-null",t.IS_NOT_NULL="is-not-null",t))(oi||{}),Vn=(t=>(t.NO_FORMATTING="no-formatting",t.POSITIVE="positive",t.NEGATIVE="negative",t.WARN="warn",t.NEUTRAL="neutral",t.ACCENT_1="accent-1",t.ACCENT_2="accent-2",t.CUSTOM="custom",t))(Vn||{});function Eh(t){switch(t){case"no-formatting":return"No formatting";case"positive":return"Positive";case"negative":return"Negative";case"warn":return"Warn";case"neutral":return"Neutral";case"accent-1":return"Accent 1";case"accent-2":return"Accent 2";case"custom":return"Custom..."}}function el(t){const{type:e,customConfig:n}=t;switch(e){case"no-formatting":return;case"positive":return"#9fde6f";case"negative":return"#ff6087";case"warn":return"#f67f40";case"neutral":return"#ffd95c";case"accent-1":return"#78dce8";case"accent-2":return"#ab9bf5";case"custom":return n==null?void 0:n.background;default:return}}function tl(t){const{type:e,customConfig:n}=t;switch(e){case"no-formatting":return;case"positive":return"#526a3f";case"negative":return"#802f44";case"warn":return"#663318";case"neutral":return"#63562b";case"accent-1":return"#3f6469";case"accent-2":return"#554d72";case"custom":return n==null?void 0:n.color;default:return}}function av(t){const e=tl(t.style),n=el(t.style);if(!(e===void 0||n===void 0))return`bgfg(\`${n}\`, \`${e}\`)`}function dv(t){const{column:e,value:n,start:s,end:i}=t;return Rv(e.name,t.condition,n,s,i)}function cv(t){const{column:e,value:n}=t;return Dv(e.name,t.condition,n)}function hv(t){const{column:e,value:n}=t;return Mv(e.name,t.condition,n)}function uv(t){const{column:e}=t;return Nv(e.name,t.condition)}function mv(t){const{column:e,value:n}=t;return Fv(e.name,t.condition,n)}function pv(t){const{column:e}=t;if(P.isNumberType(e.type))return dv(t);if(P.isCharType(e.type))return mv(t);if(P.isStringType(e.type))return cv(t);if(P.isDateType(e.type))return hv(t);if(P.isBooleanType(e.type))return uv(t);throw new Error("Invalid column type")}function gv(t){switch(t){case"is-equal":return"is equal to";case"is-not-equal":return"is not equal to";case"is-between":return"is between";case"greater-than":return"greater than";case"greater-than-or-equal":return"greater than or equal to";case"less-than":return"less than";case"less-than-or-equal":return"less than or equal to";case"is-null":return"is null";case"is-not-null":return"is not null"}}function fv(t){switch(t){case"is-exactly":return"is exactly";case"is-not-exactly":return"is not exactly";case"contains":return"contains";case"does-not-contain":return"does not contain";case"starts-with":return"starts with";case"ends-with":return"ends with";case"is-null":return"is null";case"is-not-null":return"is not null"}}function Cv(t){switch(t){case"is-exactly":return"is";case"is-not-exactly":return"is not";case"is-before":return"is before";case"is-before-or-equal":return"is before or equal";case"is-after":return"is after";case"is-after-or-equal":return"is after or equal";case"is-null":return"is null";case"is-not-null":return"is not null"}}function bv(t){switch(t){case"is-true":return"is true";case"is-false":return"is false";case"is-null":return"is null";case"is-not-null":return"is not null"}}function Sv(t){switch(t){case"is-equal":return"is";case"is-not-equal":return"is not";case"is-null":return"is null";case"is-not-null":return"is not null"}}function tp(t){if(P.isNumberType(t)||P.isCharType(t))return"is-equal";if(P.isStringType(t)||P.isDateType(t))return"is-exactly";if(P.isBooleanType(t))return"is-true";throw new Error("Invalid column type")}function wv(t){if(P.isCharType(t)||P.isStringType(t))return""}function np(t){const{condition:e,value:n,start:s,end:i}=t;return{condition:e,value:n,start:s,end:i}}function xl(t){return{condition:tp(t),value:wv(t),start:void 0,end:void 0}}function sp(){return{type:"no-formatting"}}function vv(t){switch(t){case"is-exactly":return"==";case"is-not-exactly":return"!=";case"contains":return"contains";case"does-not-contain":return"does not contain";case"starts-with":return"starts with";case"ends-with":return"ends with";case"is-null":return"is null";case"is-not-null":return"is not null"}}function Tv(t){switch(t){case"is-exactly":return"==";case"is-not-exactly":return"!=";case"is-before":return"<";case"is-before-or-equal":return"<=";case"is-after":return">";case"is-after-or-equal":return">=";case"is-null":return"is null";case"is-not-null":return"is not null"}}function Ev(t){switch(t){case"is-true":return"is true";case"is-false":return"is false";case"is-null":return"is null";case"is-not-null":return"is not null"}}function yv(t){switch(t){case"is-equal":return"==";case"is-not-equal":return"!=";case"is-null":return"is null";case"is-not-null":return"is not null"}}function Iv(t){switch(t){case"is-equal":return"==";case"is-not-equal":return"!=";case"is-between":return"==";case"greater-than":return">";case"greater-than-or-equal":return">=";case"less-than":return"<";case"less-than-or-equal":return"<=";case"is-null":return"is null";case"is-not-null":return"is not null"}}function Rv(t,e,n,s,i){switch(e){case"is-equal":return`${t} == ${n}`;case"is-not-equal":return`${t} != ${n}`;case"is-between":return`${t} > ${s} && ${t} < ${i}`;case"greater-than":return`${t} > ${n}`;case"greater-than-or-equal":return`${t} >= ${n}`;case"less-than":return`${t} < ${n}`;case"less-than-or-equal":return`${t} <= ${n}`;case"is-null":return`${t} == null`;case"is-not-null":return`${t} != null`}}function Dv(t,e,n){switch(e){case"is-exactly":return`${t} == "${n}"`;case"is-not-exactly":return`${t} != "${n}"`;case"contains":return`${t} != null && ${t}.contains("${n}")`;case"does-not-contain":return`${t} != null && !${t}.contains("${n}")`;case"starts-with":return`${t} != null && ${t}.startsWith("${n}")`;case"ends-with":return`${t} != null && ${t}.endsWith("${n}")`;case"is-null":return`${t} == null`;case"is-not-null":return`${t} != null`}}function Mv(t,e,n){switch(e){case"is-exactly":return`${t} == convertDateTime("${n}")`;case"is-not-exactly":return`${t} != convertDateTime(\`${n}\`)`;case"is-before":return`${t} < convertDateTime(\`${n}\`)`;case"is-before-or-equal":return`${t} <= convertDateTime("${n}")`;case"is-after":return`${t} > convertDateTime(\`${n}\`)`;case"is-after-or-equal":return`${t} >= convertDateTime(\`${n}\`)`;case"is-null":return`${t} == null`;case"is-not-null":return`${t} != null`}}function Nv(t,e){switch(e){case"is-true":return`${t} == true`;case"is-false":return`${t} == false`;case"is-null":return`${t} == null`;case"is-not-null":return`${t} != null`}}function Fv(t,e,n){switch(e){case"is-equal":return`${t} == '${n}'`;case"is-not-equal":return`${t} != '${n}'`;case"is-null":return`isNull(${t})`;case"is-not-null":return`!isNull(${t})`}}function xv(t,e){if(P.isNumberType(t))return Iv(e);if(P.isCharType(t))return yv(e);if(P.isStringType(t))return vv(e);if(P.isDateType(t))return Tv(e);if(P.isBooleanType(t))return Ev(e);throw new Error("Invalid column type")}function _v(t,e){if(e===void 0)return ca.debug("no rules passed."),[];const n=[];let s;const i=new Map;return e.forEach(({config:o,type:r})=>{var g;const{column:l}=o,a=t.find(({name:f,type:b})=>f===l.name&&b===l.type);if(a===void 0){ca.debug(`Column ${l.name}:${l.type} not found. Ignoring format rule.`,o);return}const[d,c]=(g=r==="conditional"?i.get(a.name):s)!=null?g:["null",void 0],u=ov(o,d);if(u===void 0){ca.debug("Ignoring format rule.",o);return}const m=c===void 0?-1:n.indexOf(c);m>-1&&n.splice(m,1);const p=r==="conditional"?lv(a,u):rv(u);n.push(p),r==="conditional"?i.set(a.name,[u,p]):s=[u,p]}),n}function kv({type:t}){return P.isNumberType(t)||P.isCharType(t)||P.isStringType(t)||P.isDateType(t)||P.isBooleanType(t)}const _l=({animation:t="iris-grid-bottom-bar-slide-up",children:e,className:n,isShown:s,onClick:i,onEntering:o,onEntered:r,onExiting:l,onExited:a})=>h(ht,{in:s,timeout:Tt.transitionMs,classNames:t,onEntering:o,onEntered:r,onExiting:l,onExited:a,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:z("iris-grid-bottom-bar",n),role:"presentation",onClick:i,onKeyPress:i,children:e})});const Ov=3e3,Lv=5,Av=({isSaving:t=!1,onSave:e,onDiscard:n,discardTooltip:s,saveTooltip:i,error:o,pendingDataErrors:r,pendingDataMap:l,onEntering:a,onEntered:d,onExiting:c,onExited:u})=>{const[m,p]=S.exports.useState(!1),[g,f]=S.exports.useState(!1),b=S.exports.useRef(),C=gl(t),w=S.exports.useMemo(()=>r.size===0?o:r.size<=Lv?`Key can't be empty (on pending row${r.size>1?"s":""} ${Array.from(r.keys()).join(", ").trim()})`:`Key can't be empty (on ${r.size} rows)`,[o,r]);S.exports.useEffect(function(){C!=null&&C&&!t&&w==null&&(p(!0),f(!0),b.current=setTimeout(()=>{p(!1)},Ov))},[w,t,C]),S.exports.useEffect(function(){b.current&&l.size>0&&(clearTimeout(b.current),p(!1),f(!1))},[l]),S.exports.useEffect(function(){return()=>b.current?clearTimeout(b.current):void 0},[]);const T=l.size;let y;return t?y=h(kn,{}):g&&(y=ad),v(_l,{className:"pending-data-bottom-bar",isShown:T>0||m||w!=null,onEntering:a,onEntered:d,onExiting:c,onExited:()=>{f(!1),u&&u()},children:[w!=null&&w!==""&&v("div",{className:"error-message",children:[h(K,{icon:ds}),h("span",{children:`${w}`})]}),(w==null||w==="")&&h("div",{className:"status-message",children:T>0&&h("span",{children:`${T} row${T>1?"s":""} pending`})}),v("div",{className:"buttons-container",children:[!t&&!g&&h(Q,{kind:"secondary",onClick:n,tooltip:s,children:"Discard"}),v(Q,{kind:g?"success":"primary",onClick:e,icon:y,disabled:t||g||w!=null,tooltip:i,children:[t&&"Committing...",!t&&g&&"Success",!t&&!g&&"Commit"]})]})]})},po=X.module("IrisGridUtils");function ys(t,e){return t>=0&&t<e.length}class se{static dehydrateGridState(e,n){const{isStuckToBottom:s,isStuckToRight:i,movedColumns:o,movedRows:r}=n,{columns:l}=e;return{isStuckToBottom:s,isStuckToRight:i,movedColumns:[...o].filter(({to:a,from:d})=>ys(a,l)&&(typeof d=="number"&&ys(d,l)||Array.isArray(d)&&ys(d[0],l)&&ys(d[1],l))).map(({to:a,from:d})=>({to:l[a].name,from:Array.isArray(d)?[l[d[0]].name,l[d[1]].name]:l[d].name})),movedRows:[...r]}}static hydrateGridState(e,n,s=[]){const{isStuckToBottom:i,isStuckToRight:o,movedColumns:r,movedRows:l}=n,{columns:a}=e,d=se.parseCustomColumnNames(s),c=a.map(({name:u})=>u).concat(d);return{isStuckToBottom:i,isStuckToRight:o,movedColumns:[...r].map(({to:u,from:m})=>{const p=g=>typeof g=="string"?c.findIndex(f=>f===g):g;return{to:p(u),from:Array.isArray(m)?[p(m[0]),p(m[1])]:p(m)}}).filter(({to:u,from:m})=>ys(u,c)&&(typeof m=="number"&&ys(m,c)||Array.isArray(m)&&ys(m[0],c)&&ys(m[1],c))),movedRows:[...l]}}static dehydrateIrisGridState(e,n){const{aggregationSettings:s={aggregations:[],showOnTop:!1},advancedFilters:i,customColumnFormatMap:o,isFilterBarShown:r,metrics:l,quickFilters:a,customColumns:d,conditionalFormats:c=[],reverseType:u,rollupConfig:m=void 0,showSearchBar:p,searchValue:g,selectDistinctColumns:f=[],selectedSearchColumns:b,sorts:C,invertSearchColumns:w,pendingDataMap:T=new Map,frozenColumns:y}=n;A(l);const{userColumnWidths:E,userRowHeights:I}=l,{columns:R}=e;return{advancedFilters:se.dehydrateAdvancedFilters(R,i),aggregationSettings:s,customColumnFormatMap:[...o],isFilterBarShown:r,quickFilters:se.dehydrateQuickFilters(a),sorts:se.dehydrateSort(C),userColumnWidths:[...E].filter(([F])=>F!=null&&F>=0&&F<R.length).map(([F,x])=>[R[F].name,x]),userRowHeights:[...I],customColumns:[...d],conditionalFormats:[...c],reverseType:u,rollupConfig:m,showSearchBar:p,searchValue:g,selectDistinctColumns:[...f],selectedSearchColumns:b,invertSearchColumns:w,pendingDataMap:se.dehydratePendingDataMap(R,T),frozenColumns:y}}static hydrateIrisGridState(e,n){const{advancedFilters:s,aggregationSettings:i={aggregations:[],showOnTop:!1},customColumnFormatMap:o,isFilterBarShown:r,quickFilters:l,sorts:a,customColumns:d,conditionalFormats:c,userColumnWidths:u,userRowHeights:m,reverseType:p,rollupConfig:g=void 0,showSearchBar:f,searchValue:b,selectDistinctColumns:C,selectedSearchColumns:w,invertSearchColumns:T=!0,pendingDataMap:y=[],frozenColumns:E}=n,{columns:I,formatter:R}=e;return{advancedFilters:se.hydrateAdvancedFilters(I,s,R.timeZone),aggregationSettings:i,customColumnFormatMap:new Map(o),isFilterBarShown:r,quickFilters:se.hydrateQuickFilters(I,l,R.timeZone),sorts:se.hydrateSort(I,a),userColumnWidths:new Map(u.map(([F,x])=>typeof F=="string"||F instanceof String?[I.findIndex(({name:U})=>U===F),x]:[F,x]).filter(([F])=>F!=null&&F>=0&&F<I.length)),customColumns:d,conditionalFormats:c,userRowHeights:new Map(m),reverseType:p,rollupConfig:g,showSearchBar:f,searchValue:b,selectDistinctColumns:C,selectedSearchColumns:w,invertSearchColumns:T,pendingDataMap:se.hydratePendingDataMap(I,y),frozenColumns:E}}static dehydrateIrisGridPanelState(e,n){const{isSelectingPartition:s,partition:i,partitionColumn:o}=n;return{isSelectingPartition:s,partition:i,partitionColumn:o!=null?o.name:null}}static hydrateIrisGridPanelState(e,n){const{isSelectingPartition:s,partition:i,partitionColumn:o}=n,{columns:r}=e;return{isSelectingPartition:s,partition:i,partitionColumn:o!=null?se.getColumnByName(r,o):void 0}}static dehydrateQuickFilters(e){return[...e].map(([n,s])=>{const{text:i}=s;return[n,{text:i}]})}static hydrateQuickFilters(e,n,s){const i=n.map(([o,r])=>{const{text:l}=r;let a=null;try{const d=se.getColumn(e,o);d!=null&&(a=P.makeQuickFilter(d,l,s))}catch(d){po.error("hydrateQuickFilters error with",l,d)}return[o,{text:l,filter:a}]});return new Map(i)}static dehydrateAdvancedFilters(e,n){return[...n].map(([s,i])=>{const o=se.getColumn(e,s);A(o);const r=se.dehydrateAdvancedFilterOptions(o,i.options);return[s,{options:r}]})}static hydrateAdvancedFilters(e,n,s){const i=n.map(([o,r])=>{const l=se.getColumn(e,o);A(l);const a=se.hydrateAdvancedFilterOptions(l,r.options);let d=null;try{se.getColumn(e,o)!=null&&(d=P.makeAdvancedFilter(l,a,s))}catch(c){po.error("hydrateAdvancedFilters error with",a,c)}return[o,{options:a,filter:d}]});return new Map(i)}static dehydrateAdvancedFilterOptions(e,n){const{selectedValues:s,...i}=n;return{selectedValues:s==null?void 0:s.map(o=>se.dehydrateValue(o,e==null?void 0:e.type)),...i}}static hydrateAdvancedFilterOptions(e,n){const{selectedValues:s,...i}=n;return{selectedValues:s==null?void 0:s.map(o=>se.hydrateValue(o,e==null?void 0:e.type)),...i}}static dehydratePendingDataMap(e,n){return[...n].map(([s,{data:i}])=>[s,{data:[...i].map(([o,r])=>[e[o].name,se.dehydrateValue(r,e[o].type)])}])}static hydratePendingDataMap(e,n){const s=new Map,i=o=>(s.has(o)||s.set(o,e.findIndex(({name:r})=>r===o)),s.get(o));return new Map(n.map(([o,{data:r}])=>[o,{data:new Map(r.map(([l,a])=>{var c;const d=i(l);return A(d),[(c=i(l))!=null?c:null,se.hydrateValue(a,e[d].type)]}))}]))}static dehydrateValue(e,n){return P.isDateType(n)?se.dehydrateDateTime(e):P.isLongType(n)?se.dehydrateLong(e):e}static hydrateValue(e,n){return P.isDateType(n)?se.hydrateDateTime(e):P.isLongType(n)?se.hydrateLong(e):e}static dehydrateDateTime(e){return e!=null?M.i18n.DateTimeFormat.format(us.FULL_DATE_FORMAT,e):null}static hydrateDateTime(e){return e!=null?M.i18n.DateTimeFormat.parse(us.FULL_DATE_FORMAT,e):null}static dehydrateLong(e){return e!=null?`${e}`:null}static hydrateLong(e){return e!=null?M.LongWrapper.ofString(e):null}static dehydrateSort(e){return e.map(n=>{const{column:s,isAbs:i,direction:o}=n;return{column:s.index,isAbs:i,direction:o}})}static hydrateSort(e,n){return n.map(s=>{const{column:i,isAbs:o,direction:r}=s;if(r===P.sortDirection.reverse)return M.Table.reverse();const l=se.getColumn(e,i);if(l!=null){let a=l.sort();return o&&(a=a.abs()),r===P.sortDirection.descending?a=a.desc():a=a.asc(),a}return null}).filter(s=>s!=null&&s.direction!==P.sortDirection.reverse)}static extractTableSettings(e,n=[]){const{irisGridPanelState:s,irisGridState:i}=e,{partitionColumn:o,partition:r}=s,{advancedFilters:l,quickFilters:a,sorts:d}=i;return{advancedFilters:l,inputFilters:n,partition:r,partitionColumn:o,quickFilters:a,sorts:d}}static applyTableSettings(e,n,s){const{columns:i}=e;let o=[];n.quickFilters&&(o=se.getFiltersFromFilterMap(se.hydrateQuickFilters(i,n.quickFilters,s)));let r=[];n.advancedFilters&&(r=se.getFiltersFromFilterMap(se.hydrateAdvancedFilters(i,n.advancedFilters,s)));const l=se.getFiltersFromInputFilters(i,n.inputFilters,s);let a=[];n.sorts&&(a=se.hydrateSort(i,n.sorts));let d=[...o,...r];const{partition:c,partitionColumn:u}=n;if(c!=null&&u!=null){const m=se.getColumnByName(i,u);m&&(d=[m.filter().eq(M.FilterValue.ofString(c)),...d])}d=[...l,...d],e.applyFilter(d),e.applySort(a)}static getInputFiltersForColumns(e,n=[]){return n.filter(({name:s,type:i})=>e.find(({name:o,type:r})=>o===s&&r===i))}static getFiltersFromInputFilters(e,n=[],s){return n.map(({name:i,type:o,value:r})=>{const l=e.find(({name:a,type:d})=>a===i&&d===o);if(l)try{return P.makeQuickFilter(l,r,s)}catch(a){po.debug("Unable to create input filter",a)}return null}).filter(i=>i!=null)}static getFiltersFromFilterMap(e){const n=[],s=Array.from(e.keys());for(let i=0;i<s.length;i+=1){const o=s[i],r=e.get(o);r&&r.filter!=null&&n.push(r.filter)}return n}static getHiddenColumns(e){return[...e.entries()].filter(([,n])=>n===0).map(([n])=>n)}static parseCustomColumnNames(e){return e.map(n=>n.split("=")[0])}static getRemovedCustomColumnNames(e,n){const s=se.parseCustomColumnNames(e),i=se.parseCustomColumnNames(n);return s.filter(o=>!i.includes(o))}static removeSortsInColumns(e,n){return e.filter(s=>!n.includes(s.column.name))}static removeFiltersInColumns(e,n,s){const i=e.map(({name:r})=>r),o=new Map(n);return s.forEach(r=>o.delete(i.indexOf(r))),o}static removeColumnFromMovedColumns(e,n,s){const i=e.map(({name:r})=>r);let o=[...n];for(let r=0;r<s.length;r+=1){const l=s[r];let a=i.findIndex(c=>c===l);const d=[];for(let c=0;c<o.length;c+=1){const u=o[c],m={...u};let[p,g]=Array.isArray(u.from)?u.from:[u.from,u.from];a<=u.to&&(m.to-=1),a<p&&(p-=1),a<=g&&(g-=1),p<=g&&p!==m.to&&(p===g?d.push({...m,from:p}):d.push({...m,from:[p,g]})),a=G.applyItemMoves(a,a,[u])[0][0]}o=d,i.splice(i.findIndex(c=>c===l),1)}return o}static removeColumnsFromSelectDistinctColumns(e,n){return e.filter(s=>!n.includes(s))}static getVisibleColumnsInRange(e,n,s,i,o){const r=[];for(let l=n;l<=s;l+=1){const a=G.getModelIndex(l,i);a>=0&&a<e.length&&!o.includes(a)&&r.push(e[a])}return r}static getPrevVisibleColumns(e,n,s,i,o){const r=[];let l=n;for(;l>=0&&r.length<s;){const a=G.getModelIndex(l,i);a>=0&&a<e.length&&!o.includes(a)&&r.unshift(e[a]),l-=1}return r}static getNextVisibleColumns(e,n,s,i,o){const r=[];let l=n;for(;l<e.length&&r.length<s;){const a=G.getModelIndex(l,i);a>=0&&a<e.length&&!o.includes(a)&&r.push(e[a]),l+=1}return r}static getColumnsToFetch(e,n,s){const i=[...n];return s.forEach(o=>{const r=e.find(({name:l})=>l===o);r!=null&&!n.includes(r)&&i.push(r)}),i}static getModelViewportColumns(e,n,s,i,o=[],r=[],l=0){if(n==null||s==null)return null;const a=se.getVisibleColumnsInRange(e,n,s,i,o),d=a.length*l,c=se.getPrevVisibleColumns(e,n-1,d,i,o),u=se.getNextVisibleColumns(e,s+1,d,i,o),m=[...c,...a,...u];return se.getColumnsToFetch(e,m,r)}static rangeSetFromRanges(e){const n=e.slice().sort((s,i)=>(A(s.startRow),A(i.startRow),s.startRow-i.startRow)).map(s=>{const{startRow:i,endRow:o}=s;return A(i),A(o),M.RangeSet.ofRange(i,o)});return M.RangeSet.ofRanges(n)}static isValidSnapshotRanges(e){if(e==null||e.length===0)return!1;const n=new Map;for(let o=0;o<e.length;o+=1){const r=e[o],l=`${r.startRow}:${r.endRow}`,a=`${r.startColumn}:${r.endColumn}`;n.has(l)||n.set(l,[]),n.get(l).push(a)}const s=[...n.keys()],i=n.get(s[0]).sort().join(",");for(let o=1;o<s.length;o+=1)if(n.get(s[o]).sort().join(",")!==i)return!1;return!0}static isValidIndex(e){return!Number.isInteger(e)||typeof e!="number"?!1:e>=0}static columnsFromRanges(e,n){var i,o;if(e==null||e.length===0)return[];if(e[0].startColumn===null&&e[0].endColumn===null)return n;const s=new Set;for(let r=0;r<e.length;r+=1){const l=e[r];A(l.startColumn),A(l.endColumn);for(let a=(i=l.startColumn)!=null?i:0;a<=((o=l.endColumn)!=null?o:n.length-1);a+=1)s.add(a)}return[...s].map(r=>n[r])}static snapshotDataToMatrix(e){const{columns:n,rows:s}=e,i=[];for(let o=0;o<s.length;o+=1){const r=s[o],l=[];for(let a=0;a<n.length;a+=1){const d=n[a],c=r.get(d);l.push(c)}i.push(l)}return i}static getModelRollupConfig(e,n,s){var u,m,p;if(((m=(u=n==null?void 0:n.columns)==null?void 0:u.length)!=null?m:0)===0)return null;const{columns:i=[],showConstituents:o=!0,showNonAggregatedColumns:r=!0,includeDescriptions:l=!0}=n!=null?n:{},{aggregations:a=[]}=s!=null?s:{},d=a.map(({operation:g,selected:f,invert:b})=>ks.isRollupOperation(g)?[]:ks.getOperationColumnNames(e,g,f,b)),c={};for(let g=0;g<a.length;g+=1)c[a[g].operation]=d[g];if(r){const g=new Set(e.map(f=>f.name).filter(f=>!i.includes(f)));if(d.forEach(f=>{f.forEach(b=>g.delete(b))}),g.size>0){const f=(p=c[Ae.FIRST])!=null?p:[];c[Ae.FIRST]=[...f,...g]}}return{groupingColumns:i,includeConstituents:o,includeDescriptions:l,aggregations:c}}static getPendingErrors(e){e.forEach((n,s)=>{if(!se.isValidIndex(s))throw new Error(`Invalid rowIndex ${s}`);const{data:i}=n;i.forEach((o,r)=>{if(!se.isValidIndex(r))throw new Error(`Invalid columnIndex ${r}`)})})}static getColumn(e,n){return n<e.length?e[n]:(po.error("Unable to retrieve column",n,">=",e.length),null)}static getColumnByName(e,n){const s=e.find(({name:i})=>i===n);return s==null&&po.error("Unable to retrieve column by name",n,e.map(({name:i})=>i)),s}static changeFilterColumnNamesToIndexes(e,n){return n.map(({name:s,filter:i})=>{const o=e.findIndex(r=>r.name===s);return o<0?null:[o,i]}).filter(s=>s!=null)}}const Zt=X.module("IrisGridCopyHandler"),Ue=class extends S.exports.Component{constructor(t){super(t),this.handleBackgroundClick=this.handleBackgroundClick.bind(this),this.handleCancelClick=this.handleCancelClick.bind(this),this.handleCopyClick=this.handleCopyClick.bind(this),this.handleHideTimeout=this.handleHideTimeout.bind(this),this.state={error:void 0,copyState:Ue.COPY_STATES.IDLE,buttonState:Ue.BUTTON_STATES.COPY,isShown:!1,rowCount:0}}static getStatusMessageText(t,e){switch(t){case Ue.COPY_STATES.CONFIRMATION_REQUIRED:return`Are you sure you want to copy ${e.toLocaleString()} rows to your clipboard?`;case Ue.COPY_STATES.CLICK_REQUIRED:return`Fetched ${e.toLocaleString()} rows!`;case Ue.COPY_STATES.FETCH_ERROR:return"Unable to copy data.";case Ue.COPY_STATES.FETCH_IN_PROGRESS:return`Fetching ${e.toLocaleString()} rows for clipboard...`;case Ue.COPY_STATES.DONE:return"Copied to Clipboard!";default:return""}}static getCopyButtonText(t){switch(t){case Ue.BUTTON_STATES.FETCH_IN_PROGRESS:return"Fetching";case Ue.BUTTON_STATES.CLICK_TO_COPY:return"Click to Copy";case Ue.BUTTON_STATES.RETRY:return"Retry";default:return"Copy"}}componentDidMount(){const{copyOperation:t}=this.props;t!=null&&this.startCopy()}componentDidUpdate(t){const{copyOperation:e}=this.props;t.copyOperation!==e&&this.startCopy()}componentWillUnmount(){this.stopCopy()}startCopy(){Zt.debug2("startCopy"),this.stopCopy();const{copyOperation:t}=this.props;if(t==null){Zt.debug2("No copy operation set, cancelling out"),this.setState({isShown:!1});return}const{ranges:e,error:n}=t;if(n!=null){Zt.debug("Showing copy error",n),this.setState({isShown:!0,copyState:Ue.COPY_STATES.DONE,error:n}),this.startHideTimer();return}const s=re.rowCount(e);this.setState({rowCount:s,isShown:!0,error:void 0}),s>Ue.NO_PROMPT_THRESHOLD?this.setState({buttonState:Ue.BUTTON_STATES.COPY,copyState:Ue.COPY_STATES.CONFIRMATION_REQUIRED}):this.startFetch()}stopCopy(){this.textData=void 0,this.stopFetch(),this.stopHideTimer()}handleBackgroundClick(){Zt.debug2("handleBackgroundClick");const{copyState:t}=this.state;t===Ue.COPY_STATES.DONE&&this.setState({isShown:!1})}handleCancelClick(){Zt.debug2("handleCancelClick"),this.stopFetch(),this.setState({isShown:!1})}handleCopyClick(){Zt.debug2("handleCopyClick"),this.textData!=null?this.copyText(this.textData):this.startFetch()}handleHideTimeout(){Zt.debug2("handleHideTimeout"),this.stopHideTimer(),this.setState({isShown:!1})}copyText(t){Zt.debug2("copyText",t),this.textData=t,Ne.copyToClipboard(t).then(()=>{this.setState({copyState:Ue.COPY_STATES.DONE}),this.startHideTimer()},e=>{Zt.error("copyText error",e),this.setState({buttonState:Ue.BUTTON_STATES.CLICK_TO_COPY,copyState:Ue.COPY_STATES.CLICK_REQUIRED})})}startFetch(){this.stopFetch(),this.setState({buttonState:Ue.BUTTON_STATES.FETCH_IN_PROGRESS,copyState:Ue.COPY_STATES.FETCH_IN_PROGRESS});const{model:t,copyOperation:e}=this.props,{ranges:n,includeHeaders:s,userColumnWidths:i,movedColumns:o,formatValues:r}=e;Zt.debug("startFetch",n);const l=se.getHiddenColumns(i);let a=G.getModelRanges(n,o);if(l.length>0){const c=l.map(re.makeColumn);a=re.subtractRangesFromRanges(a,c)}const d=r!=null&&r?(c,u)=>t.displayString(c,u.type,u.name):c=>`${c}`;this.fetchPromise=Ee.makeCancelable(t.textSnapshot(a,s,d)),this.fetchPromise.then(c=>{this.fetchPromise=void 0,this.copyText(c)}).catch(c=>{c instanceof di?Zt.debug("User cancelled copy."):(Zt.error("Error fetching contents",c),this.fetchPromise=void 0,this.setState({buttonState:Ue.BUTTON_STATES.RETRY,copyState:Ue.COPY_STATES.FETCH_ERROR}))})}stopFetch(){this.fetchPromise&&(Zt.debug2("stopFetch"),this.fetchPromise.cancel(),this.fetchPromise=void 0)}startHideTimer(){this.stopHideTimer(),this.hideTimer=setTimeout(this.handleHideTimeout,Ue.HIDE_TIMEOUT)}stopHideTimer(){this.hideTimer!=null&&(clearTimeout(this.hideTimer),this.hideTimer=void 0)}render(){const{onEntering:t,onEntered:e,onExiting:n,onExited:s}=this.props,{buttonState:i,copyState:o,isShown:r,rowCount:l,error:a}=this.state,d=o===Ue.COPY_STATES.DONE?"fade":"copy-slide-up",c=Ue.getCopyButtonText(i),u=a!=null?a:Ue.getStatusMessageText(o,l),m=o!==Ue.COPY_STATES.DONE,p=i===Ue.BUTTON_STATES.FETCH_IN_PROGRESS,g=o===Ue.COPY_STATES.DONE;return v(_l,{animation:d,isShown:r,className:z("iris-grid-copy-handler",{"copy-done":g}),onClick:this.handleBackgroundClick,onEntering:t,onEntered:e,onExiting:n,onExited:s,children:[h("div",{className:"status-message",children:h("span",{children:u})}),h(ht,{in:m,timeout:Tt.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:v("div",{className:"buttons-container",children:[h("button",{type:"button",className:"btn btn-outline-secondary btn-cancel",onClick:this.handleCancelClick,children:"Cancel"}),v("button",{type:"button",className:z("btn","btn-copy",{"btn-primary":!p,"btn-secondary":p,"btn-spinner":p}),onClick:this.handleCopyClick,disabled:p,children:[p&&h(kn,{}),c]})]})})]})}};let to=Ue;to.NO_PROMPT_THRESHOLD=1e4;to.HIDE_TIMEOUT=3e3;to.COPY_STATES={IDLE:"IDLE",CONFIRMATION_REQUIRED:"CONFIRMATION_REQUIRED",FETCH_IN_PROGRESS:"FETCH_IN_PROGRESS",FETCH_ERROR:"FETCH_ERROR",CLICK_REQUIRED:"CLICK_REQUIRED",DONE:"DONE"};to.BUTTON_STATES={COPY:"COPY",FETCH_IN_PROGRESS:"FETCH_IN_PROGRESS",CLICK_TO_COPY:"CLICK_TO_COPY",RETRY:"RETRY"};to.defaultProps={copyOperation:null,onEntering:()=>{},onEntered:()=>{},onExiting:()=>{},onExited:()=>{}};class ip extends S.exports.PureComponent{constructor(e){super(e);const{debounceMs:n}=e;this.debouncedSendUpdate=Xe(this.sendUpdate.bind(this),n),this.handleCancel=this.handleCancel.bind(this),this.handleChange=this.handleChange.bind(this),this.handleCommit=this.handleCommit.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.inputField=null;const{value:s}=e;this.initialValue=s,this.state={isChanged:!1,value:s}}componentDidMount(){var e;(e=this.inputField)==null||e.focus()}componentDidUpdate(e){const{debounceMs:n}=this.props;e.debounceMs!==n&&(this.debouncedSendUpdate.flush(),this.debouncedSendUpdate=Xe(this.sendUpdate.bind(this),n))}componentWillUnmount(){this.debouncedSendUpdate.cancel()}setValue(e){this.initialValue=e,this.setState({value:e})}focus(){var e;(e=this.inputField)==null||e.focus()}handleChange(e){const{value:n}=e.target;this.setState({value:n,isChanged:!0}),this.debouncedSendUpdate(n)}handleCancel(){this.debouncedSendUpdate.cancel();const{initialValue:e}=this,{isChanged:n}=this.state;n&&this.sendUpdate(e);const{onDone:s}=this.props;s()}handleCommit(e=!0,n=!0){this.debouncedSendUpdate.flush();const{onDone:s}=this.props;s(e,n)}handleFocus(){var e;(e=this.inputField)==null||e.select()}handleBlur(e){const{relatedTarget:n}=e;n!=null&&n.classList.contains("context-menu-container")?this.handleCommit(!1,!0):n!=null&&n.classList.contains("advanced-filter-button")?this.handleCommit(!1,!1):this.handleCommit(!0,!0)}handleTab(e=!1){this.debouncedSendUpdate.flush();const{onTab:n}=this.props;n(e)}handleKeyDown(e){switch(e.key){case"Escape":e.stopPropagation(),e.preventDefault(),this.handleCancel();break;case"Enter":e.stopPropagation(),e.preventDefault(),this.handleCommit();break;case"Tab":e.stopPropagation(),e.preventDefault(),this.handleTab(e.shiftKey);break}}handleContextMenu(e){const{onContextMenu:n}=this.props;n(e)}sendUpdate(e){const{onChange:n}=this.props;n(e)}render(){const{className:e,style:n,isAdvancedFilterSet:s,onAdvancedFiltersTriggered:i}=this.props,{value:o}=this.state;return v("div",{style:n,className:"iris-grid-input-autosized-wrapper","data-value":o,children:[h("input",{ref:r=>{this.inputField=r},className:z("iris-grid-input-field",e),type:"text",value:o,onBlur:this.handleBlur,onFocus:this.handleFocus,onChange:this.handleChange,onKeyDown:this.handleKeyDown,onContextMenu:this.handleContextMenu,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false"}),h("div",{className:"advanced-filter-button-container",children:h("button",{type:"button",className:z("btn btn-link btn-link-icon advanced-filter-button",{"filter-set":s}),onClick:i,onContextMenu:this.handleContextMenu,children:v("div",{className:"fa-layers ",children:[h(K,{icon:dd,className:"filter-solid"}),h(K,{icon:Wr,className:"filter-light"})]})})})]})}}ip.defaultProps={style:{},className:"",value:"",isAdvancedFilterSet:!1,onAdvancedFiltersTriggered:()=>{},onChange:()=>{},onDone:()=>{},onTab:()=>{},onContextMenu:()=>{},debounceMs:150};class Pv extends Ci{constructor(e){super(),this.irisGrid=e}onDown(e){const{selectedRanges:n}=this.irisGrid.state;return e.key==="c"&&Ne.isModifierKeyDown(e)?(se.isValidSnapshotRanges(n)?this.irisGrid.copyRanges(n):this.irisGrid.copyRanges(n,!1,!1,"Invalid copy ranges"),!0):!1}}const Hv={TOGGLE_QUICK_FILTER:Be.createAndAdd({id:"TABLE.TOGGLE_QUICK_FILTER",name:"Toggle Quick Filter",shortcut:[me.CTRL,ge.F],macShortcut:[me.CMD,ge.F]}),CLEAR_ALL_FILTERS:Be.createAndAdd({id:"TABLE.CLEAR_ALL_FILTERS",name:"Clear All Table Filters",shortcut:[me.CTRL,ge.E],macShortcut:[me.CMD,ge.E]}),CLEAR_FILTERS:Be.createAndAdd({id:"TABLE.CLEAR_FILTERS",name:"Clear Active Table Filters",shortcut:[me.CTRL,me.SHIFT,ge.E],macShortcut:[me.CMD,me.SHIFT,ge.E]}),REVERSE:Be.createAndAdd({id:"TABLE.REVERSE",name:"Reverse",shortcut:[me.CTRL,ge.I],macShortcut:[me.CMD,ge.I]}),TOGGLE_SEARCH:Be.createAndAdd({id:"TABLE.TOGGLE_SEARCH",name:"Toggle Search",shortcut:[me.CTRL,me.SHIFT,ge.F],macShortcut:[me.CMD,me.SHIFT,ge.F]}),GOTO_ROW:Be.createAndAdd({id:"TABLE.GOTO_ROW",name:"GOTO_ROW",shortcut:[me.CTRL,ge.G],macShortcut:[me.CMD,ge.G]})},Vv={COMMIT:Be.createAndAdd({id:"INPUT_TABLE.COMMIT",name:"Commit",shortcut:[me.CTRL,ge.S],macShortcut:[me.CMD,ge.S]}),DISCARD:Be.createAndAdd({id:"INPUT_TABLE.DISCARD",name:"Discard",shortcut:[me.CTRL,me.ALT,ge.S],macShortcut:[me.CMD,me.OPTION,ge.S]})},ln={TABLE:Hv,INPUT_TABLE:Vv};class Uv extends Ci{constructor(e){super(),this.irisGrid=e}onDown(e){if(ln.TABLE.REVERSE.matchesEvent(e)){if(!this.irisGrid.isReversible())return!1;const{reverseType:n}=this.irisGrid.state;return n===P.REVERSE_TYPE.NONE?this.irisGrid.reverse(P.REVERSE_TYPE.POST_SORT):this.irisGrid.reverse(P.REVERSE_TYPE.NONE),!0}return!1}}class Bv extends Ci{constructor(e){super(),this.irisGrid=e}onDown(e){return ln.TABLE.CLEAR_FILTERS.matchesEvent(e)?(this.irisGrid.clearAllFilters(),!0):!1}}class $v extends Et{constructor(e){super(850),this.irisGrid=e}destroyColumnTooltip(){this.irisGrid.setState({overflowButtonTooltipProps:null})}setCursor(e){return this.isHoveringOverflowButton(e)?(this.cursor="pointer",{stopPropagation:!1,preventDefault:!1}):(this.cursor=null,!1)}getButtonPosition({x:e,y:n,column:s,row:i}){if(s==null||i==null)return null;const{renderer:o,grid:r,state:l,props:a}=this.irisGrid;if(!r)return null;const{metrics:d}=l,{model:c}=a,{canvasContext:u}=r,m=r.getTheme(),p={context:u,mouseX:e,mouseY:n,metrics:d,model:c,theme:m},{left:g,top:f,width:b,height:C}=o.getCellOverflowButtonPosition(p);return g==null||b==null||f==null||C==null?null:{left:g,top:f,width:b,height:C}}isHoveringOverflowButton(e){var C;const{x:n,y:s}=e,{left:i,top:o,width:r,height:l}=(C=this.getButtonPosition(e))!=null?C:{};if(i==null||r==null||o==null||l==null)return!1;const{renderer:a,grid:d,state:c,props:u}=this.irisGrid;if(!d)return!1;const{metrics:m}=c,{model:p}=u,{canvasContext:g}=d,f=d.getTheme(),b={context:g,mouseX:n,mouseY:s,metrics:m,model:p,theme:f};return a.shouldRenderOverflowButton(b)&&n>=i&&n<=i+r&&s>=o&&s<=o+l}onMove(e){if(this.isHoveringOverflowButton(e)){const{overflowButtonTooltipProps:n}=this.irisGrid.state,s=this.getButtonPosition(e);ct(n,s)||this.irisGrid.setState({overflowButtonTooltipProps:s})}else this.destroyColumnTooltip();return this.setCursor(e)}onWheel(e){return this.destroyColumnTooltip(),this.onMove(e)}onDown(e){this.destroyColumnTooltip();const{column:n,row:s}=e;return this.isHoveringOverflowButton(e)&&this.irisGrid.setState({showOverflowModal:!0,overflowText:this.irisGrid.getValueForCell(n,s)}),!1}onContextMenu(){return this.destroyColumnTooltip(),!1}onLeave(){return this.destroyColumnTooltip(),!1}}class zv extends Et{constructor(e){super(),this.irisGrid=e,this.cursor=null}isActive(){const{isSelectingColumn:e}=this.irisGrid.props;return e}isValidColumn(e){if(e==null)return!1;const{columnSelectionValidator:n}=this.irisGrid.props;return n!=null?n(e):!0}updateColumnSelectionStatus(){const{columnSelectionValidator:e}=this.irisGrid.props;e!=null&&e(null)}getTableColumn(e){if(e==null)return null;const{model:n}=this.irisGrid.props,s=this.irisGrid.getModelColumn(e);return s==null?null:n.columns[s]}onMove(e){if(!this.isActive())return!1;const{columnAllowedCursor:n,columnNotAllowedCursor:s}=this.irisGrid.props,{column:i}=e,o=this.getTableColumn(i);return this.isValidColumn(o)?(this.cursor=n,this.irisGrid.setState({hoverSelectColumn:i})):(this.cursor=s,this.irisGrid.setState({hoverSelectColumn:null})),!0}onWheel(e){if(!this.isActive())return!1;const{columnAllowedCursor:n,columnNotAllowedCursor:s}=this.irisGrid.props,{column:i}=e,o=this.getTableColumn(i);return this.isValidColumn(o)?this.cursor=n:this.cursor=s,{preventDefault:!1,stopPropagation:!1}}onLeave(){return this.isActive()&&this.irisGrid.setState({hoverSelectColumn:null}),this.updateColumnSelectionStatus(),!1}onDown(){return this.isActive()}onClick(e){if(!this.isActive())return!1;const{column:n}=e,s=this.getTableColumn(n);return s!=null&&this.isValidColumn(s)&&this.irisGrid.selectColumn(s),!0}}class Wv extends Et{constructor(e){super(),this.irisGrid=e}hideColumnTooltip(){const{tooltip:e}=this.irisGrid;e&&(e.stopTimer(),e.hide())}onDown(){return this.hideColumnTooltip(),!1}onContextMenu(){return this.hideColumnTooltip(),!1}onWheel(){return this.hideColumnTooltip(),!1}onLeave(e,n,s){const{relatedTarget:i}=s instanceof MouseEvent?s:s.nativeEvent,{tooltip:o}=this.irisGrid;if(!o)return!1;const r=o.popper.current;return r&&i instanceof Element&&r.element.contains(i)||this.hideColumnTooltip(),!1}onMove(e){const{column:n,row:s,columnHeaderDepth:i}=e,{shownColumnTooltip:o}=this.irisGrid.state;let r=null;return n!==null&&s===null&&i===0&&(r=n),r!==o&&this.irisGrid.setState({shownColumnTooltip:r}),!1}}const op=class extends S.exports.Component{constructor(t=op.defaultProps){super(t),this.handleInputChange=this.handleInputChange.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.inputRef=Y.createRef()}handleInputChange(){const{onChange:t}=this.props;this.inputRef.current&&t(this.inputRef.current.value)}closeContextMenu(){const{forwardedProps:t}=this.props,{closeMenu:e}=t;e(!0)}revertToDefault(){const{onChange:t}=this.props;t(null)}returnFocusToContextMenu(){const t=pC.getClosestByClassName(this.inputRef.current,"context-menu-container");t instanceof HTMLElement&&t.focus()}handleKeyDown(t){switch(t.key){case"Enter":t.stopPropagation(),this.closeContextMenu();break;case"Escape":t.stopPropagation(),this.revertToDefault(),this.closeContextMenu();break;case"ArrowRight":case"ArrowLeft":t.stopPropagation();break;case"ArrowUp":case"ArrowDown":this.returnFocusToContextMenu();break;default:t.stopPropagation()}}render(){const{formatString:t,forwardedProps:e,placeholder:n,title:s}=this.props,{menuItem:{description:i},iconElement:o}=e;return v("div",{className:"form-group flex-grow mb-0",children:[v("div",{className:"custom-format-title",children:[h("span",{className:"icon",children:o}),v("label",{className:"title mb-0",htmlFor:"custom-format-input",children:[s,i!=null&&h(Ie,{children:i})]})]}),h("div",{className:"pl-2 pr-2 pb-2",children:h("input",{id:"custom-format-input",className:"form-control text-right mb-0",type:"text",defaultValue:t,ref:this.inputRef,placeholder:n,onKeyDown:this.handleKeyDown,onChange:this.handleInputChange,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false"})})]})}};let rp=op;rp.defaultProps={formatString:"",forwardedProps:{menuItem:{},closeMenu(t){},iconElement:null},placeholder:"",title:"",onChange(t){}};class an{static isDefaultSelected(e){return!e||![Je.TYPE_CONTEXT_CUSTOM,Je.TYPE_CONTEXT_PRESET].includes(e.type)}static isCustomSelected(e){return e!=null&&e.type===Je.TYPE_CONTEXT_CUSTOM}static makeOption(e,n,s,i){return{title:e,description:e,group:s,format:n,isSelected:i}}static makeCustomFormatOption(e,n,s,i,o){return{title:e.label,description:e.label,format:e,group:n,isSelected:i,menuElement:h(rp,{formatString:e.formatString,title:e.label,placeholder:s,onChange:o})}}}const Un=class{static getOptions(t,e){const n=new Date,i=[{group:Un.dateGroup,formatString:"yyyy-MM-dd"},{group:Un.dateGroup,formatString:"MM-dd-yyyy"},{group:Un.timeGroup,formatString:"HH:mm:ss"},{group:Un.timeGroup,formatString:"HH:mm:ss.SSS"},{group:Un.timeGroup,formatString:"HH:mm:ss.SSSSSSSSS"},{group:Un.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss"},{group:Un.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss.SSS"},{group:Un.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss.SSSSSSSSS"}].map(r=>{const l=at.makeFormat("",r.formatString,at.TYPE_CONTEXT_PRESET),a=t.getFormattedString(n,P.dataType.DATETIME,"",l);return an.makeOption(a,l,r.group,at.isSameFormat(l,e))});return[an.makeOption("Default",null,Un.dateGroup,an.isDefaultSelected(e)),...i]}};let kl=Un;kl.dateGroup=10;kl.timeGroup=20;kl.dateTimeGroup=30;const Bn=class{static getOptions(t,e){const n=[{format:Pe.FORMAT_PERCENT,group:Bn.presetGroup},{format:Pe.FORMAT_BASIS_POINTS,group:Bn.presetGroup},{format:Pe.FORMAT_MILLIONS,group:Bn.presetGroup},{format:Pe.FORMAT_SCIENTIFIC_NOTATION,group:Bn.presetGroup},{format:Pe.FORMAT_ROUND,group:Bn.presetRoundGroup},{format:Pe.FORMAT_ROUND_TWO_DECIMALS,group:Bn.presetRoundGroup},{format:Pe.FORMAT_ROUND_FOUR_DECIMALS,group:Bn.presetRoundGroup}],s=an.makeOption("Default",null,Bn.defaultGroup,an.isDefaultSelected(t)),i=n.map(a=>an.makeOption(a.format.label,a.format,a.group,Pe.isSameFormat(a.format,t))),o=an.isCustomSelected(t),r=o?t:Pe.makeCustomFormat(),l=an.makeCustomFormatOption(r,Bn.customGroup,Pe.DEFAULT_FORMAT_STRING,o,a=>{if(a!=null){const d=Pe.makeCustomFormat(a);Pe.isValid(d)&&e(d)}else e(null)});return[s,...i,l]}};let Xo=Bn;Xo.defaultGroup=10;Xo.presetGroup=20;Xo.presetRoundGroup=30;Xo.customGroup=40;const Do=class{static getOptions(t,e){const n=[{format:nt.FORMAT_MILLIONS,group:Do.presetGroup},{format:nt.FORMAT_SCIENTIFIC_NOTATION,group:Do.presetGroup}],s=an.makeOption("Default",null,Do.defaultGroup,an.isDefaultSelected(t)),i=n.map(a=>an.makeOption(a.format.label,a.format,a.group,nt.isSameFormat(a.format,t))),o=an.isCustomSelected(t),r=o?t:nt.makeCustomFormat(),l=an.makeCustomFormatOption(r,Do.customGroup,nt.DEFAULT_FORMAT_STRING,o,a=>{if(a!=null){const d=nt.makeCustomFormat(a);nt.isValid(d)&&e(d)}else e(null)});return[s,...i,l]}};let Ol=Do;Ol.defaultGroup=10;Ol.presetGroup=20;Ol.customGroup=30;const yh=X.module("IrisGridContextMenuHandler"),Gv=150,Ih="yyyy-MM-dd HH:mm:ss.SSSSSSSSS",Z=class extends Et{constructor(t){super(),this.debouncedUpdateCustomFormat=Xe(t.handleFormatSelection,Gv),this.irisGrid=t}static getQuickFilterCondition(t,e,n){return t&&n==="&&"?t.and(e):t&&n==="||"?t.or(e):e}static getQuickFilterText(t,e,n){return n&&t!=null?`${t} ${n} ${e}`:e}static getOperatorAsText(t){return t==="&&"?"And":"Or"}static getNumberValueEqualsFilter(t,e){const n=t.filter();if(e===Number.POSITIVE_INFINITY)return M.FilterCondition.invoke("isInf",n).and(n.greaterThan(M.FilterValue.ofNumber(0)));if(e===Number.NEGATIVE_INFINITY)return M.FilterCondition.invoke("isInf",n).and(n.lessThan(M.FilterValue.ofNumber(0)));if(Number.isNaN(e))return M.FilterCondition.invoke("isNaN",n);const s=Z.getFilterValueForNumberOrChar(t.type,e);return n.eq(s)}static getFilterValueForNumberOrChar(t,e){return P.isCharType(t)?M.FilterValue.ofString(String.fromCharCode(e)):M.FilterValue.ofNumber(e)}componentWillUnmount(){this.debouncedUpdateCustomFormat.flush()}getHeaderActions(t,e){var F;const{irisGrid:n}=this,{column:s}=e;A(s);const{model:i}=n.props,{columns:o}=i,r=o[t],l=[],{metrics:a,reverseType:d,quickFilters:c,advancedFilters:u,searchFilter:m}=n.state,p=n.getTheme();A(a);const{filterIconColor:g,filterBarActiveColor:f,contextMenuSortIconColor:b,contextMenuReverseIconColor:C}=p,w=i.sort,T=P.getSortForColumn(w,t),y=d!==P.REVERSE_TYPE.NONE,{userColumnWidths:E}=a,I=[...E.values()].some(x=>x===0),R=i.isColumnFrozen(s);return l.push({title:"Hide Column",group:Z.GROUP_HIDE_COLUMNS,action:()=>{this.irisGrid.hideColumnByVisibleIndex(s)}}),l.push({title:R?"Unfreeze Column":"Freeze Column",group:Z.GROUP_HIDE_COLUMNS,action:()=>{R?this.irisGrid.unFreezeColumnByColumnName(r.name):this.irisGrid.freezeColumnByColumnName(r.name)},order:10}),l.push({title:"Show All Columns",group:Z.GROUP_HIDE_COLUMNS,action:()=>{this.irisGrid.showAllColumns()},disabled:!I}),l.push({title:"Quick Filters",icon:Zn,iconColor:f,shortcut:ln.TABLE.TOGGLE_QUICK_FILTER,group:Z.GROUP_FILTER,order:10,action:()=>{this.irisGrid.toggleFilterBar(s)}}),l.push({title:"Advanced Filters",icon:u.get(t)?dd:Wr,iconColor:g,group:Z.GROUP_FILTER,order:20,action:()=>{this.irisGrid.handleAdvancedMenuOpened(s)}}),l.push({title:"Clear Table Filters",group:Z.GROUP_FILTER,order:40,shortcut:ln.TABLE.CLEAR_FILTERS,action:()=>{this.irisGrid.clearAllFilters()},disabled:!(c.size>0||u.size>0||m!=null)}),l.push({title:"Sort by",icon:Zn,iconColor:b,group:Z.GROUP_SORT,order:10,actions:this.sortByActions(r,t,T)}),l.push({title:"Add Additional Sort",disabled:T&&w.length===1||y&&w.length===1||T&&y&&w.length===2||w.length===0,group:Z.GROUP_SORT,order:20,actions:this.additionalSortActions(r,t)}),l.push({title:"Clear Table Sorting",disabled:w.length===0||y&&w.length===1,group:Z.GROUP_SORT,action:()=>{this.irisGrid.sortColumn(s,Z.COLUMN_SORT_DIRECTION.none)},order:30}),l.push({title:d===P.REVERSE_TYPE.NONE?"Reverse Table":"Clear Reverse Table",icon:Zn,iconColor:C,group:Z.GROUP_SORT,order:40,disabled:!i.isReversible,shortcut:ln.TABLE.REVERSE,action:()=>{d===P.REVERSE_TYPE.NONE?this.irisGrid.reverse(P.REVERSE_TYPE.POST_SORT):this.irisGrid.reverse(P.REVERSE_TYPE.NONE)}}),l.push({title:"Copy Column Name",group:Z.GROUP_COPY,action:()=>{var x;Ne.copyToClipboard((x=i.textForColumnHeader(t))!=null?x:"").catch(U=>yh.error("Unable to copy header",U))}}),P.isDateType(r.type)?l.push({title:"Date/Time Format",group:Z.GROUP_FORMAT,actions:this.dateFormatActions(r)}):P.isNumberType(r.type)&&l.push({title:"Number Format",group:Z.GROUP_FORMAT,actions:(F=this.numberFormatActions(r))!=null?F:void 0}),l}getCellActions(t,e,n){A(t);const{irisGrid:s}=this,{column:i,row:o}=n,{model:r,canCopy:l}=s.props,{columns:a}=r,d=s.getModelRow(o);A(d);const c=r.valueForCell(t,d),u=r.textForCell(t,d),m=a[t],p=[],{quickFilters:g}=s.state,f=s.getTheme(),{filterIconColor:b}=f,{settings:C}=s.props,w=new at({timeZone:C==null?void 0:C.timeZone,showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:Ih}),T=new at({timeZone:C==null?void 0:C.timeZone,showTimeZone:C==null?void 0:C.showTimeZone,showTSeparator:C==null?void 0:C.showTSeparator,defaultDateTimeFormatString:Ih});if(m==null||o==null)return p;if(r.isFilterable(t)){const E={title:"Filter By Value",icon:Zn,iconColor:b,group:Z.GROUP_FILTER,order:10,actions:[]};if(c==null)g.get(t)&&E.actions.push({title:"And",actions:this.nullFilterActions(m,g.get(t),"&&"),order:2,group:oe.groups.high}),E.actions.push(...this.nullFilterActions(m));else if(P.isBooleanType(m.type))g.get(t)&&E.actions.push({title:"Or",actions:this.booleanFilterActions(m,u,g.get(t),"||"),order:2,group:oe.groups.high}),E.actions.push(...this.booleanFilterActions(m,u));else if(P.isNumberType(m.type)||P.isCharType(m.type)){A(t);const I=P.isCharType(m.type)?String.fromCharCode(c):`${c}`;g.get(t)&&E.actions.push({title:"And",actions:this.numberFilterActions(m,I,c,g.get(t),"&&"),order:2,group:oe.groups.high}),E.actions.push(...this.numberFilterActions(m,I,c,g.get(t)))}else if(P.isDateType(m.type)){const I=w.format(c),R=T.format(c);g.get(t)&&E.actions.push({title:"And",actions:this.dateFilterActions(m,I,R,c,g.get(t),"&&"),order:2,group:oe.groups.high}),E.actions.push(...this.dateFilterActions(m,I,R,c,g.get(t)))}else g.get(t)&&E.actions.push({title:"And",actions:this.stringFilterActions(m,u,c,g.get(t),"&&"),order:2,group:oe.groups.high}),E.actions.push(...this.stringFilterActions(m,u,c));E.actions!=null&&E.actions.length>0&&p.push(E)}const y={title:"Go to",iconColor:b,shortcut:ln.TABLE.GOTO_ROW,group:Z.GROUP_GOTO,order:10,action:()=>this.irisGrid.toggleGotoRow(`${o+1}`)};return p.push(y),l&&(p.push({title:"Copy Cell",group:Z.GROUP_COPY,order:10,action:()=>{s.copyCell(i,o)}}),p.push({title:"Copy Cell Unformatted",group:Z.GROUP_COPY,order:20,action:()=>{s.copyCell(i,o,!0)}})),p}onContextMenu(t,e,n){const{irisGrid:s}=this,{y:i,column:o,row:r,columnHeaderDepth:l}=t,a=s.getModelColumn(o),d=s.getModelRow(r),{model:c,canCopy:u}=s.props,{columns:m}=c,{metrics:p,isFilterBarShown:g,quickFilters:f,advancedFilters:b,selectedRanges:C}=s.state;A(p);const{columnHeaderHeight:w,gridY:T,columnHeaderMaxDepth:y}=p,E=[];if(a!=null&&d!=null){const I=c.valueForCell(a,d),R=c.textForCell(a,d),F=m[a],{onContextMenu:x}=s.props;F!=null&&E.push(x({model:c,value:I,valueText:R,column:F,rowIndex:r,columnIndex:o,modelRow:d,modelColumn:a}))}return a!=null&&c.isFilterable(a)&&E.push({title:"Clear Column Filter",group:Z.GROUP_FILTER,order:30,action:()=>{this.irisGrid.removeColumnFilter(a)},disabled:!(f.has(a)||b.has(a))}),(g?i<=T:i<=w*y&&l===0)?a!=null&&E.push(...this.getHeaderActions(a,t)):(a!=null&&d!=null&&E.push(...this.getCellActions(a,e,t)),u&&C.length>0&&(E.push({title:"Copy Selection",shortcut:Os.COPY,group:Z.GROUP_COPY,order:30,action:()=>{s.copyRanges(C)}}),E.push({title:"Copy Selection w/ Headers",group:Z.GROUP_COPY,order:40,action:()=>{s.copyRanges(C,!0)}})),Ze(c)&&c.isEditable&&C.length>0&&E.push({title:"Delete Selected Rows",group:Z.GROUP_EDIT,order:50,action:()=>{this.irisGrid.deleteRanges(C)}})),E.length===0?!1:(A(s.gridWrapper),oe.triggerMenu(s.gridWrapper,n.pageX,n.pageY,E),!0)}dateFormatActions(t){const{model:e}=this.irisGrid.props,{formatter:n}=e,s=n.getColumnFormat(t.type,t.name),i=kl.getOptions(n,s),o=[];for(let r=0;r<i.length;r+=1){const{description:l,format:a,group:d,isSelected:c,title:u}=i[r];o.push({title:u,description:l,icon:c?ai:void 0,group:d,order:r,action:()=>{const m=e.getColumnIndexByName(t.name);A(m),this.irisGrid.handleFormatSelection(m,a)}})}return o}numberFormatActions(t){const{model:e}=this.irisGrid.props,{formatter:n}=e,s=n.getColumnFormat(t.type,t.name);let i;const o=e.getColumnIndexByName(t.name);if(P.isDecimalType(t.type))i=Xo.getOptions(s,l=>{A(o),this.debouncedUpdateCustomFormat(o,l)});else if(P.isIntegerType(t.type))i=Ol.getOptions(s,l=>{A(o),this.debouncedUpdateCustomFormat(o,l)});else return yh.error("Invalid column type in numberFormatActions"),null;const r=[];for(let l=0;l<i.length;l+=1){const{format:a,isSelected:d}=i[l];r.push({...i[l],icon:d?ai:void 0,order:l,action:()=>{o===void 0&&a&&a.type===Je.TYPE_CONTEXT_CUSTOM||(A(o),this.irisGrid.handleFormatSelection(o,a))}})}return r}stringFilterActions(t,e,n,s,i){const o=M.FilterValue.ofString(n);let r=s;r||(r={filter:null,text:null});const{filter:l,text:a}=r,d=[],{model:c}=this.irisGrid.props,u=c.getColumnIndexByName(t.name);return A(u),d.push({menuElement:v("div",{className:"iris-grid-filter-menu-item-value",children:[i?Z.getOperatorAsText(i):""," ",'"',e,'"']}),order:1,group:oe.groups.high}),d.push({title:"text is exactly",description:`Show only rows where ${t.name} is ${n} (case sensitive)`,action:()=>{this.irisGrid.setQuickFilter(u,Z.getQuickFilterCondition(l,t.filter().eq(o),i),Z.getQuickFilterText(a,`=${e}`,i))},order:10,group:oe.groups.low}),d.push({title:"text is not exactly",description:`Show only rows where ${t.name} is not ${e} (case sensitive)`,action:()=>{this.irisGrid.setQuickFilter(u,Z.getQuickFilterCondition(l,t.filter().notEq(o),i),Z.getQuickFilterText(a,`!=${e}`,i))},order:20,group:oe.groups.low}),d.push({title:"text contains",description:`Show only rows where ${t.name} contains ${e}`,action:()=>{this.irisGrid.setQuickFilter(u,Z.getQuickFilterCondition(l,t.filter().contains(o),i),Z.getQuickFilterText(a,`~${e}`,i))},order:30,group:oe.groups.low}),d.push({title:"text does not contain",description:`Show only rows where ${t.name} does not contain ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,Z.getQuickFilterCondition(l,t.filter().contains(o).not(),i),Z.getQuickFilterText(a,`!~${e}`,i))},order:40,group:oe.groups.low}),d.push({title:"text starts with",description:`Show only rows where ${t.name} starts with ${e}`,action:()=>{this.irisGrid.setQuickFilter(u,Z.getQuickFilterCondition(l,t.filter().invoke("startsWith",o),i),Z.getQuickFilterText(a,`${e}*`,i))},order:50,group:oe.groups.low}),d.push({title:"text ends with",description:`Show only rows where ${t.name} ends with ${e}`,action:()=>{this.irisGrid.setQuickFilter(u,Z.getQuickFilterCondition(l,t.filter().invoke("endsWith",o),i),Z.getQuickFilterText(a,`*${e}`,i))},order:60,group:oe.groups.low}),d}numberFilterActions(t,e,n,s,i){const o=Z.getFilterValueForNumberOrChar(t.type,n);let r=null,l=null;s&&(r=s.filter,l=s.text);const a=[],d=n!==Number.POSITIVE_INFINITY&&n!==Number.NEGATIVE_INFINITY&&!Number.isNaN(n),{model:c}=this.irisGrid.props,u=c.getColumnIndexByName(t.name);return A(u),a.push({menuElement:v("div",{className:"iris-grid-filter-menu-item-value",children:[i?Z.getOperatorAsText(i):""," ",'"',e,'"']}),order:1,group:oe.groups.high}),a.push({title:"is equal to",description:`Show only rows where ${t.name} is ${e}`,action:()=>{const m=Z.getNumberValueEqualsFilter(t,n);this.irisGrid.setQuickFilter(u,Z.getQuickFilterCondition(r,m,i),Z.getQuickFilterText(l,`=${e}`,i))},order:10,group:oe.groups.low}),a.push({title:"is not equal to",description:`Show only rows where ${t.name} is not ${e}`,action:()=>{const m=Z.getNumberValueEqualsFilter(t,n).not();this.irisGrid.setQuickFilter(u,Z.getQuickFilterCondition(r,m,i),Z.getQuickFilterText(l,`!=${e}`,i))},order:20,group:oe.groups.low}),d&&!P.isCharType(t.type)&&(a.push({title:"greater than",description:`Show only rows where ${t.name} is greater than ${e}`,action:()=>{this.irisGrid.setQuickFilter(u,Z.getQuickFilterCondition(r,t.filter().greaterThan(o),i),Z.getQuickFilterText(l,`>${e}`,i))},order:30,group:oe.groups.low}),a.push({title:"greater than or equal to",description:`Show only rows where ${t.name} is greater than or equal to ${e}`,action:()=>{this.irisGrid.setQuickFilter(u,Z.getQuickFilterCondition(r,t.filter().greaterThanOrEqualTo(o),i),Z.getQuickFilterText(l,`>=${e}`,i))},order:40,group:oe.groups.low}),a.push({title:"less than",description:`Show only rows where ${t.name} is less than ${e}`,action:()=>{this.irisGrid.setQuickFilter(u,Z.getQuickFilterCondition(r,t.filter().lessThan(o),i),Z.getQuickFilterText(l,`<${e}`,i))},order:50,group:oe.groups.low}),a.push({title:"less than or equal to",description:`Show only rows where ${t.name} is less than or equal to ${e}`,action:()=>{this.irisGrid.setQuickFilter(u,Z.getQuickFilterCondition(r,t.filter().lessThanOrEqualTo(o),i),Z.getQuickFilterText(l,`<=${e}`,i))},order:60,group:oe.groups.low})),a}booleanFilterActions(t,e,n,s){const i=[],{model:o}=this.irisGrid.props,{filter:r,text:l}=n||{},a=o.getColumnIndexByName(t.name);return A(a),i.push({menuElement:v("div",{className:"iris-grid-filter-menu-item-value",children:[s?Z.getOperatorAsText(s):""," ",'"',e!=null?e:"null",'"']}),order:1,group:oe.groups.high}),i.push({title:"true",description:`Show only rows where ${t.name} is true`,action:()=>{this.irisGrid.setQuickFilter(a,Z.getQuickFilterCondition(r,t.filter().isTrue(),s),Z.getQuickFilterText(l,"true",s))},order:10,group:oe.groups.low}),i.push({title:"false",description:`Show only rows where ${t.name} is false`,action:()=>{this.irisGrid.setQuickFilter(a,Z.getQuickFilterCondition(r,t.filter().isFalse(),s),Z.getQuickFilterText(l,"false",s))},order:20,group:oe.groups.low}),i.push({title:"is null",description:`Show only rows where ${t.name} is null`,action:()=>{this.irisGrid.setQuickFilter(a,Z.getQuickFilterCondition(r,t.filter().isNull(),s),Z.getQuickFilterText(l,"null",s))},order:30,group:oe.groups.low}),i.push({title:"is not null",description:`Show only rows where ${t.name} is not null`,action:()=>{this.irisGrid.setQuickFilter(a,Z.getQuickFilterCondition(r,t.filter().isNull().not(),s),Z.getQuickFilterText(l,"!null",s))},order:40,group:oe.groups.low}),i}dateFilterActions(t,e,n,s,i,o){const r=M.FilterValue.ofNumber(s);let l=null,a=null;i&&(l=i.filter,a=i.text);const{model:d}=this.irisGrid.props,c=d.getColumnIndexByName(t.name);A(c);const u=[];return u.push({menuElement:v("div",{className:"iris-grid-filter-menu-item-value",children:[o?Z.getOperatorAsText(o):""," ",'"',n,'"']}),order:1,group:oe.groups.high}),u.push({title:"date is",description:`Show only rows where ${t.name} is ${n}`,action:()=>{this.irisGrid.setQuickFilter(c,Z.getQuickFilterCondition(l,t.filter().eq(r),o),Z.getQuickFilterText(a,`=${e}`,o))},order:10,group:oe.groups.low}),u.push({title:"date is not",description:`Show only rows where ${t.name} is not ${n}`,action:()=>{this.irisGrid.setQuickFilter(c,Z.getQuickFilterCondition(l,t.filter().notEq(r),o),Z.getQuickFilterText(a,`!=${e}`,o))},order:20,group:oe.groups.low}),u.push({title:"date is before",description:`Show only rows where ${t.name} is before ${n}`,action:()=>{this.irisGrid.setQuickFilter(c,Z.getQuickFilterCondition(l,t.filter().lessThan(r),o),Z.getQuickFilterText(a,`<${e}`,o))},order:30,group:oe.groups.low}),u.push({title:"date is before or equal",description:`Show only rows where ${t.name} is before or equal to ${n}`,action:()=>{this.irisGrid.setQuickFilter(c,Z.getQuickFilterCondition(l,t.filter().lessThanOrEqualTo(r),o),Z.getQuickFilterText(a,`<=${e}`,o))},order:40,group:oe.groups.low}),u.push({title:"date is after",description:`Show only rows where ${t.name} is greater than ${n}`,action:()=>{this.irisGrid.setQuickFilter(c,Z.getQuickFilterCondition(l,t.filter().greaterThan(r),o),Z.getQuickFilterText(a,`>${e}`,o))},order:50,group:oe.groups.low}),u.push({title:"date is after or equal",description:`Show only rows where ${t.name} is after or equal to ${n}`,action:()=>{this.irisGrid.setQuickFilter(c,Z.getQuickFilterCondition(l,t.filter().greaterThanOrEqualTo(r),o),Z.getQuickFilterText(a,`>=${e}`,o))},order:60,group:oe.groups.low}),u}nullFilterActions(t,e,n){let s=null,i=null;e&&(s=e.filter,i=e.text);const o=[],{model:r}=this.irisGrid.props,l=r.getColumnIndexByName(t.name);return A(l),o.push({menuElement:v("div",{className:"iris-grid-filter-menu-item-value",children:[n?Z.getOperatorAsText(n):""," ",'"null"']}),order:1,group:oe.groups.high}),o.push({title:"is null",description:`Show only rows where ${t.name} is null`,action:()=>{this.irisGrid.setQuickFilter(l,Z.getQuickFilterCondition(s,t.filter().isNull(),n),Z.getQuickFilterText(i,"null",n))},order:10,group:oe.groups.low}),o.push({title:"is not null",description:`Show only rows where ${t.name} is not null`,action:()=>{this.irisGrid.setQuickFilter(l,Z.getQuickFilterCondition(s,t.filter().isNull().not(),n),Z.getQuickFilterText(i,"!null",n))},order:20,group:oe.groups.low}),o}sortByActions(t,e,n){const s=this.irisGrid.getTheme(),{contextMenuSortIconColor:i}=s,o=[{title:`${t.name} Ascending`,order:10,action:()=>{this.irisGrid.sortColumn(e,Z.COLUMN_SORT_DIRECTION.ascending)},icon:this.checkColumnSort(n,Z.COLUMN_SORT_DIRECTION.ascending)?Zn:void 0,iconColor:i},{title:`${t.name} Descending`,order:20,action:()=>{this.irisGrid.sortColumn(e,Z.COLUMN_SORT_DIRECTION.descending)},icon:this.checkColumnSort(n,Z.COLUMN_SORT_DIRECTION.descending)?Zn:void 0,iconColor:i},{title:"Remove Sort",order:50,action:()=>{this.irisGrid.sortColumn(e,Z.COLUMN_SORT_DIRECTION.none,!1,!0)},disabled:!n}];return P.isNumberType(t.type)&&(o.push({title:`ABS(${t.name}) Ascending`,order:30,action:()=>{this.irisGrid.sortColumn(e,Z.COLUMN_SORT_DIRECTION.ascending,!0)},icon:this.checkColumnSort(n,Z.COLUMN_SORT_DIRECTION.ascending,!0)?Zn:void 0,iconColor:i}),o.push({title:`ABS(${t.name}) Descending`,order:40,action:()=>{this.irisGrid.sortColumn(e,Z.COLUMN_SORT_DIRECTION.descending,!0)},icon:this.checkColumnSort(n,Z.COLUMN_SORT_DIRECTION.descending,!0)?Zn:void 0,iconColor:i})),o}additionalSortActions(t,e){const n=this.irisGrid.getTheme(),{contextMenuSortIconColor:s}=n,i=[{title:"Add Sort By",menuElement:v("div",{className:"btn-context-menu menu-title",children:[h("span",{className:"icon",children:h(K,{icon:Zn,style:{color:s!=null?s:void 0}})}),h("span",{className:"title",children:"Add Additional Sort"}),h("span",{className:"shortcut",children:Ne.isMacPlatform()?"\u2318Click":"^Click"})]}),order:1},{title:`${t.name} Ascending`,order:10,action:()=>{this.irisGrid.sortColumn(e,Z.COLUMN_SORT_DIRECTION.ascending,!1,!0)}},{title:`${t.name} Descending`,order:20,action:()=>{this.irisGrid.sortColumn(e,Z.COLUMN_SORT_DIRECTION.descending,!1,!0)}}];return P.isNumberType(t.type)&&(i.push({title:`ABS(${t.name}) Ascending`,order:30,action:()=>{this.irisGrid.sortColumn(e,Z.COLUMN_SORT_DIRECTION.ascending,!0,!0)}}),i.push({title:`ABS(${t.name}) Descending`,order:40,action:()=>{this.irisGrid.sortColumn(e,Z.COLUMN_SORT_DIRECTION.descending,!0,!0)}})),i}checkColumnSort(t,e=null,n=!1){return t?t.direction===e&&t.isAbs===n:!1}};let fs=Z;fs.GROUP_EDIT=oe.groups.high+10;fs.GROUP_HIDE_COLUMNS=oe.groups.high+25;fs.GROUP_FILTER=oe.groups.high+50;fs.GROUP_GOTO=oe.groups.high+51;fs.GROUP_SORT=oe.groups.high+75;fs.GROUP_COPY=oe.groups.high+100;fs.GROUP_FORMAT=oe.groups.high+150;fs.COLUMN_SORT_DIRECTION={ascending:"ASC",descending:"DESC",none:null};class Kv extends Et{constructor(e){super(),this.irisGrid=e}onDoubleClick(e){const{column:n,row:s}=e;return s==null||n==null?!1:(this.irisGrid.selectData(n,s),!0)}}class qv extends Et{constructor(e){super(),this.irisGrid=e}onDown(e){const{y:n,column:s,row:i}=e;if(s!==null&&i===null){const{isFilterBarShown:o,metrics:r}=this.irisGrid.state;if(!r)throw new Error("Metrics not set");const{columnHeaderMaxDepth:l}=r,a=this.irisGrid.getTheme();if(o&&a.columnHeaderHeight!=null&&a.filterBarHeight!=null&&n>a.columnHeaderHeight*l&&n<=a.columnHeaderHeight*l+a.filterBarHeight)return this.irisGrid.focusFilterBar(s),!0}return!1}onMove(e){const{y:n,column:s}=e,{isFilterBarShown:i,hoverAdvancedFilter:o,metrics:r}=this.irisGrid.state;if(!r)throw new Error("Metrics not set");const{columnHeaderMaxDepth:l}=r,a=this.irisGrid.getTheme();let d=null;return i&&a.columnHeaderHeight!=null&&a.filterBarHeight!=null&&s!==null&&n>=a.columnHeaderHeight*l&&n<=a.columnHeaderHeight*l+a.filterBarHeight&&(d=s),d!==o&&this.irisGrid.setState({hoverAdvancedFilter:d}),!1}onLeave(e){const{column:n}=e,{hoverAdvancedFilter:s}=this.irisGrid.state;return s!==null&&n!==s&&this.irisGrid.setState({hoverAdvancedFilter:null}),!1}}class Yv extends Et{constructor(e){super(),this.column=null,this.irisGrid=e}getColumnFromGridPoint(e){const{column:n,row:s,columnHeaderDepth:i}=e;return n!==null&&s===null&&i===0?n:null}onDown(e){return this.column=this.getColumnFromGridPoint(e),!1}onClick(e,n,s){const i=this.getColumnFromGridPoint(e);if(i!=null&&i===this.column){const o=Ne.isModifierKeyDown(s);return this.irisGrid.toggleSort(i,o),!0}return!1}}class Xv extends Et{constructor(e){super(),this.irisGrid=e}onWheel(e,n,s){const{irisGrid:i}=this,{model:o}=i.props,{metrics:r,pendingRowCount:l}=i.state;A(r);const{bottom:a,rowCount:d,rowHeight:c}=r,{deltaY:u}=G.getScrollDelta(s);return Ze(o)&&o.isEditable&&a>=d-1&&u>0&&i.setState({pendingRowCount:l+Math.ceil(u/c)}),!1}}const jv=3e3,Qv=({children:t=null,onEntering:e,onEntered:n,onExiting:s,onExited:i})=>{const[o,r]=S.exports.useState(!1),l=S.exports.useRef(),a=gl(t),d=S.exports.useCallback(()=>{r(!0),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{r(!1)},jv)},[r,l]);return S.exports.useEffect(()=>{a!==t&&t!=null&&d()},[t,a,r,d]),S.exports.useEffect(()=>()=>l.current?clearTimeout(l.current):void 0,[]),h(_l,{className:"toast-bottom-bar",isShown:o,onEntering:e,onEntered:n,onExiting:s,onExited:i,children:t})};class Zv extends qo{getVisibleColumnWidth(e,n,s=this.getFirstColumn(n),i=this.calculateTreePaddingX(n)){var c,u,m;const{model:o}=n,r=(u=(c=o.layoutHints)==null?void 0:c.hiddenColumns)!=null?u:[],l=this.getModelColumn(e,n),a=super.getVisibleColumnWidth(e,n,s,i);return!this.userColumnWidths.has(l)&&r.includes((m=o.columns[l])==null?void 0:m.name)?0:a}getGridY(e){let n=super.getGridY(e);const{isFilterBarShown:s,theme:i,advancedFilters:o,quickFilters:r,sorts:l,reverseType:a}=e;return s?n+=i.filterBarHeight:(r!=null&&r.size>0||o!=null&&o.size>0)&&(n+=i.filterBarCollapsedHeight),a!==P.REVERSE_TYPE.NONE&&l!=null&&l.length>0&&(n+=i.reverseHeaderBarHeight),n}getUserColumnWidths(){return this.userColumnWidths}}const Jv=1,lp=Y.memo(({model:t,modelColumns:e,top:n,bottom:s,left:i,right:o,filter:r,formatter:l,reverseType:a=P.REVERSE_TYPE.NONE,sorts:d,customColumns:c,movedColumns:u,hiddenColumns:m,alwaysFetchColumns:p,rollupConfig:g=null,totalsConfig:f=null,selectDistinctColumns:b=[],pendingRowCount:C=0,pendingDataMap:w=new Map,frozenColumns:T,formatColumns:y})=>{const E=S.exports.useMemo(()=>se.getModelViewportColumns(e,i,o,u,m,p,Jv),[e,i,o,u,m,p]);return S.exports.useEffect(function(){t.filter=r},[t,r]),S.exports.useEffect(function(){const R=[...d];a!==P.REVERSE_TYPE.NONE&&R.push(M.Table.reverse()),t.sort=R},[t,d,a]),S.exports.useEffect(function(){t.formatter=l},[t,l]),S.exports.useEffect(function(){t.isCustomColumnsAvailable&&(t.customColumns=c)},[t,c]),S.exports.useEffect(function(){t.isFormatColumnsAvailable&&(t.formatColumns=y)},[t,y]),S.exports.useEffect(function(){t.setViewport(n,s,E)},[t,n,s,E]),S.exports.useEffect(function(){t.isRollupAvailable&&(t.rollupConfig=g)},[t,t.isRollupAvailable,g]),S.exports.useEffect(function(){t.isSelectDistinctAvailable&&(t.selectDistinctColumns=b)},[t,b]),S.exports.useEffect(function(){t.isTotalsAvailable&&(t.totalsConfig=f)},[t,t.isTotalsAvailable,f]),S.exports.useEffect(function(){t.pendingRowCount=C},[t,C]),S.exports.useEffect(function(){t.pendingDataMap=w},[t,w]),S.exports.useEffect(function(){T&&t.updateFrozenColumns(T)},[t,T]),null});lp.displayName="IrisGridModelUpdater";const Pn=Object.freeze({SORT_UP:"sortUp",SORT_DOWN:"sortDown",CARET_DOWN:"caretDown",CARET_RIGHT:"caretRight",CELL_OVERFLOW:"cellOverflow"}),ha=16;class Fo extends Wi{constructor(){super(),this.icons={},this.initIcons()}static isFilterValid(e,n){const s=e==null||e.filter!=null,i=n==null||n.filter!=null;return s&&i}initIcons(){this.setIcon(Pn.SORT_UP,oC),this.setIcon(Pn.SORT_DOWN,iC),this.setIcon(Pn.CARET_DOWN,ls),this.setIcon(Pn.CARET_RIGHT,Cu),this.setIcon(Pn.CELL_OVERFLOW,Rf)}setIcon(e,n){const s=Array.isArray(n.icon[4])?n.icon[4][0]:n.icon[4],i=new Path2D(s),o=new Path2D,r={a:ha/n.icon[0],d:ha/n.icon[1]};o.addPath(i,r),this.icons[e]=o}getIcon(e){return this.icons[e]}getSortIcon(e){return e?e.direction===P.sortDirection.ascending?this.getIcon(Pn.SORT_UP):e.direction===P.sortDirection.descending?this.getIcon(Pn.SORT_DOWN):null:null}drawCanvas(e){super.drawCanvas(e),this.drawScrim(e)}drawGrid(e,n){super.drawGrid(e,n),this.drawCellOverflowButton(n)}drawGridLines(e,n){super.drawGridLines(e,n),this.drawGroupedColumnLine(e,n),this.drawPendingRowLine(e,n)}drawCellContent(e,n,s,i){var m;const{metrics:o,model:r}=n,{modelColumns:l,modelRows:a}=o,d=B(a,i),c=l.get(s);if(c===void 0)return;const u=r.valueForCell(c,d);if(P.isTextType((m=r.columns[c])==null?void 0:m.type)&&(u===null||u==="")){const p=e.font;e.font=`italic ${p}`;const g=u===null?"null":"empty";super.drawCellContent(e,n,s,i,g),e.font=p;return}super.drawCellContent(e,n,s,i)}drawGroupedColumnLine(e,n){const{metrics:s,model:i,theme:o}=n,{groupedColumns:r,columns:l}=i,{maxY:a,visibleColumnWidths:d,visibleColumnXs:c}=s;if(r.length===0||o.groupedColumnDividerColor==null)return;const u=r[r.length-1],m=l.findIndex(b=>b.name===u.name),p=c.get(m),g=d.get(m);if(p==null||g==null)return;const f=p+g+.5;e.strokeStyle=o.groupedColumnDividerColor,e.lineWidth=1,e.beginPath(),e.moveTo(f,0),e.lineTo(f,a),e.stroke()}drawPendingRowLine(e,n){const{metrics:s,model:i,theme:o}=n,{visibleRowYs:r,maxX:l}=s,{pendingRowCount:a}=i;if(a<=0)return;const d=i.rowCount-i.pendingRowCount-i.floatingBottomRowCount;let c=r.get(d);c!=null&&(c-=.5,e.save(),e.setLineDash([4,2]),e.strokeStyle=o.pendingTextColor,e.lineWidth=1,e.beginPath(),e.moveTo(0,c),e.lineTo(l,c),e.stroke(),e.restore())}drawMouseColumnHover(e,n){const{theme:s,metrics:i,hoverSelectColumn:o}=n;if(o==null||s.linkerColumnHoverBackgroundColor==null)return;const{visibleColumnWidths:r,visibleColumnXs:l,maxY:a}=i,d=l.get(o),c=r.get(o);A(d),A(c),e.fillStyle=s.linkerColumnHoverBackgroundColor,e.fillRect(d,0,c,a)}drawMouseRowHover(e,n){const{isSelectingColumn:s}=n;s||super.drawMouseRowHover(e,n)}drawScrim(e){const{context:n,loadingScrimProgress:s,metrics:i,theme:o}=e;if(s==null)return;const{width:r,height:l,gridY:a}=i,{scrimBlurSize:d,scrimColor:c}=o;n.save(),n.globalCompositeOperation="color",n.filter=`blur(${d}px)`,c!=null&&(n.fillStyle=c),n.beginPath(),n.rect(0,a,r,l-a),n.clip(),n.fillRect(-d,-d+a,d*2+r,(d*2+(l-a))*s),n.globalCompositeOperation="overlay",n.filter=`blur(${d}px) opacity(15%)`,n.fillRect(-d,-d+a,d*2+r,(d*2+(l-a))*s),n.restore()}drawColumnHeaders(e,n){super.drawColumnHeaders(e,n);const{theme:s,metrics:i,model:o,reverseType:r}=n,{columnHeaderHeight:l}=i;if(this.drawFilterHeaders(e,n),l<=0)return;const{sort:a}=o;if(a.length===1){const d=r!==P.REVERSE_TYPE.NONE;let c;d?c=s.headerReverseBarColor:c=s.headerSortBarColor,this.drawHeaderBar(e,n,c,d?s.reverseHeaderBarHeight:s.sortHeaderBarHeight)}else a.length>1&&(r!==P.REVERSE_TYPE.NONE&&this.drawHeaderBar(e,n,s.headerReverseBarColor,s.reverseHeaderBarHeight,!1),this.drawHeaderBar(e,n,s.headerSortBarColor,s.sortHeaderBarHeight))}drawHeaderBar(e,n,s,i,o=!0){const{theme:r,metrics:l,model:a}=n,{columnHeaderHeight:d,width:c}=l;let u=0;o||(u=i),e.fillStyle=r.headerBarCasingColor,e.fillRect(0,a.columnHeaderMaxDepth*d-i-2+u,c,i+2),e.fillStyle=s,e.fillRect(0,a.columnHeaderMaxDepth*d-i-1+u,c,i)}drawColumnHeadersAtDepth(e,n,s,i,o){const{metrics:r,model:l,isMenuShown:a}=n,{columnHeaderMaxDepth:d}=l,{width:c}=r,u={...i,maxX:o===d-1&&i.maxX===c?c-(a?0:30):i.maxX};super.drawColumnHeadersAtDepth(e,n,s,u,o)}drawColumnHeaderAtIndex(e,n,s,i){var H;super.drawColumnHeaderAtIndex(e,n,s,i);const{metrics:o,model:r,theme:l}=n,{modelColumns:a,visibleColumnWidths:d,visibleColumnXs:c,gridX:u,columnHeaderHeight:m,fontWidths:p}=o,{headerHorizontalPadding:g}=l,f=B(d,s,0),b=B(c,s)+u,C=a.get(s);if(C==null)return;const w=P.getSortForColumn(r.sort,C);if(!w)return;const T=this.getSortIcon(w);if(!T)return;const y=r.textForColumnHeader(C);if(y===void 0)return;const E=(H=p.get(e.font))!=null?H:Wi.DEFAULT_FONT_WIDTH;A(E);const I=y.length*E,R=u+b+I+g;let{maxX:F}=i;F-=g;const x=u+b+f-g-1,U=R>F?R+1:Math.min(F,x),$=w.direction===P.sortDirection.ascending?-6:-12,O=m*.5+$;e.save(),e.beginPath(),e.rect(b,0,f,m),e.clip(),e.fillStyle=l.headerSortBarColor,e.translate(U,O),e.fill(T),e.restore()}drawFilterHeaders(e,n){const{isFilterBarShown:s,quickFilters:i,advancedFilters:o}=n;s?this.drawExpandedFilterHeaders(e,n):(i!=null&&i.size>0||o!=null&&o.size>0)&&this.drawCollapsedFilterHeaders(e,n)}drawExpandedFilterHeaders(e,n){const{metrics:s,model:i,theme:o,quickFilters:r,advancedFilters:l}=n,{filterBarHeight:a}=o;if(a<=0)return;const{gridX:d,gridY:c,maxX:u,modelColumns:m,visibleColumns:p,visibleColumnWidths:g,visibleColumnXs:f}=s,b=c-a;e.save(),e.font=o.font,e.textAlign="left",r!=null&&r.size>0||l!=null&&l.size>0?e.fillStyle=o.filterBarExpandedActiveBackgroundColor:e.fillStyle=o.filterBarExpandedBackgroundColor,e.fillRect(d,b,u,a-1),e.fillStyle=o.headerBarCasingColor,e.fillRect(d,b+a-1,u,1);const C=b;e.strokeStyle=o.filterBarSeparatorColor,e.beginPath();for(let w=0;w<p.length;w+=1){const T=p[w],y=B(m,T),E=B(f,T),I=B(g,T);if(i.isFilterable(y)&&I>0){const R=d+(E!=null?E:0);e.rect(R+.5,C+.5,I,a-2)}}e.stroke();for(let w=0;w<p.length;w+=1){const T=p[w],y=B(g,T),I=B(f,T)+d;this.drawExpandedFilterHeader(e,n,T,I,y)}e.restore()}drawExpandedFilterHeader(e,n,s,i,o){if(o<=0)return;const{metrics:r,theme:l,quickFilters:a,advancedFilters:d}=n,{modelColumns:c,gridY:u}=r,{filterBarHeight:m,filterBarExpandedActiveCellBackgroundColor:p,filterBarErrorColor:g,filterBarHorizontalPadding:f,headerColor:b}=l,C=u-m,w=c.get(s);if(w===void 0)return;const T=a.get(w),y=d.get(w);if(T==null&&y==null)return;let E=null;if(T!=null){const{text:R}=T;if(E=R,E||(E=P.getFilterText(T.filter)),E!=null){const{fontWidths:F}=r;let x=F.get(e.font);(x==null||x===0)&&(x=e.measureText("8").width,x||(x=10));const U=(o-f*2)/x;U<=0?E="":E.length>U&&(E=`${E.substring(0,U-1)}\u2026`)}}if(e.save(),Fo.isFilterValid(y,T)&&p!=null)e.fillStyle=p,e.fillRect(i+1,C+1,o-1,m-3);else if(g!=null){e.fillStyle=g,e.lineWidth=2,e.strokeStyle=g;const R=i+2,F=C+2,x=o-3,U=m-5;e.strokeRect(R,F,x,U)}if(E!=null&&E!==""){const R=i+f,F=C+m*.5+1;e.fillStyle=b,e.fillText(E,R,F)}e.restore()}drawCollapsedFilterHeaders(e,n){const{metrics:s,theme:i}=n,{headerSeparatorColor:o,filterBarCollapsedHeight:r}=i;if(r<=0)return;const{gridX:l,gridY:a,maxX:d,visibleColumns:c,visibleColumnWidths:u,visibleColumnXs:m}=s,p=a-r;e.save(),e.fillStyle=o,e.fillRect(l,p,d,r);for(let g=0;g<c.length;g+=1){const f=c[g],b=u.get(f),C=m.get(f);if(C!=null&&b!=null){const w=C+l;this.drawCollapsedFilterHeader(e,n,f,w,b)}}e.restore()}drawCollapsedFilterHeader(e,n,s,i,o){if(o<=0)return;const{metrics:r,theme:l,quickFilters:a,advancedFilters:d}=n,{modelColumns:c,gridY:u}=r,m=c.get(s);if(m===void 0)return;const p=a.get(m),g=d.get(m),{filterBarCollapsedHeight:f,filterBarActiveColor:b,filterBarActiveBackgroundColor:C,filterBarErrorColor:w}=l;e.save();const T=Fo.isFilterValid(g,p);C!=null&&p==null&&g==null?e.fillStyle=C:b!=null&&T?e.fillStyle=b:w!=null&&(e.fillStyle=w);const y=i+1,E=u-f,I=o-1,R=f-1;e.fillRect(y,E,I,R),e.restore()}drawTreeMarker(e,n,s,i,o,r,l){e.save();const{x1:a,y1:d}=o,c=l?this.getIcon(Pn.CARET_DOWN):this.getIcon(Pn.CARET_RIGHT),u=s+a-2,m=i+d+2.5;e.fillStyle=r,e.textAlign="center",e.translate(u,m),e.fill(c),e.restore()}drawRowFooters(e,n){const{metrics:s,model:i,mouseX:o,mouseY:r,theme:l}=n,{gridY:a,gridX:d,maxX:c,modelRows:u,floatingTopHeight:m,floatingBottomHeight:p,floatingRows:g,rowFooterWidth:f,height:b,horizontalBarHeight:C,verticalBarWidth:w,visibleRowHeights:T,visibleRowYs:y,width:E}=s;if(f<=0||g.length===0)return;const{cellHorizontalPadding:I,floatingGridRowColor:R,floatingRowBackgroundColors:F,headerColor:x,rowHoverBackgroundColor:U}=l;e.translate(d,a),e.beginPath();const $=Math.min(c,E-f-w-d);e.fillStyle=F,m>0&&e.rect($,0,f,m),p>0&&e.rect($,b-a-C-p,f,p),e.fill();const O=o!=null&&r!=null&&o>=d&&o<=c+f?G.getRowAtY(r,s):null;if(U!=null&&O!==null&&g.includes(O)){e.fillStyle=U;const L=y.get(O),N=T.get(O);A(L),A(N),e.fillRect($,L,f,N)}if(e.beginPath(),R!=null&&(e.strokeStyle=R),m>0&&(e.moveTo($+.5,.5),e.lineTo($+.5,m-.5)),p>0){const L=b-a-C-p;e.moveTo($-.5,L+.5),e.lineTo($-.5,L+p-.5)}e.stroke(),e.fillStyle=x,e.textAlign="left";const H=$+I;for(let L=0;L<g.length;L+=1){const N=g[L],_=T.get(N),k=y.get(N),V=u.get(N);if(k!=null&&_!=null&&V!=null){const W=k+_*.5;e.fillText(i.textForRowFooter(V),H,W)}}e.translate(-d,-a)}getTextRenderMetrics(e,n,s,i){const o=super.getTextRenderMetrics(e,n,s,i),{mouseX:r,mouseY:l,metrics:a}=n;if(r==null||l==null)return o;const{column:d,row:c}=G.getGridPointFromXY(r,l,a);if(s===d&&i===c){const{left:u}=this.getCellOverflowButtonPosition(n);this.shouldRenderOverflowButton(n)&&u!=null&&(o.width=u-a.gridX-o.x)}return o}shouldRenderOverflowButton(e){var b,C;const{context:n,mouseX:s,mouseY:i,metrics:o,model:r,theme:l}=e;if(s==null||i==null)return!1;const{row:a,column:d,modelRow:c,modelColumn:u}=G.getCellInfoFromXY(s,i,o);if(a==null||d==null||c==null||u==null||!P.isStringType(r.columns[u].type))return!1;const m=(b=r.textForCell(u,c))!=null?b:"",{width:p}=super.getTextRenderMetrics(n,e,d,a),g=(C=o.fontWidths.get(l.font))!=null?C:Fo.DEFAULT_FONT_WIDTH;n.save(),n.font=l.font;const f=this.getCachedTruncatedString(n,m,p,g,r.truncationCharForCell(u,c));return n.restore(),m!==""&&f!==m}getCellOverflowButtonPosition({mouseX:e,mouseY:n,metrics:s,theme:i}){const o={left:null,top:null,width:null,height:null};if(e==null||n==null||!s)return o;const{rowHeight:r,columnWidth:l,left:a,top:d}=G.getCellInfoFromXY(e,n,s);A(a),A(l),A(d);const{width:c,verticalBarWidth:u}=s,{cellHorizontalPadding:m}=i,p=ha+2*m,g=r,b=Math.min(s.gridX+a+l,c-u)-p,C=s.gridY+d;return{left:b,top:C,width:p,height:g}}drawCellOverflowButton(e){const{context:n,mouseX:s,mouseY:i,theme:o}=e;if(s==null||i==null||!this.shouldRenderOverflowButton(e))return;const{left:r,top:l,width:a,height:d}=this.getCellOverflowButtonPosition(e),{cellHorizontalPadding:c,overflowButtonColor:u,overflowButtonHoverColor:m}=o;n.save(),m!=null&&r!=null&&a!=null&&l!=null&&d!=null&&s>=r&&s<=r+a&&i>=l&&i<=l+d?n.fillStyle=m:u!=null&&(n.fillStyle=u);const p=this.getIcon(Pn.CELL_OVERFLOW);r!=null&&l!=null&&n.translate(r+c,l+2),n.fill(p),n.restore()}}const eT="12px Fira Sans, sans-serif",tT="#f0f0ee",nT="#1a171a",ae={"grid-bg":"#211f22",font:eT,white:tT,black:nT,"header-bg":"#2d2a2e","header-color":"#f0f0ee","header-height":"30px","header-separator-color":"#211f22","header-separator-hover-color":"#929192","header-hidden-separator-hover-color":"#4878ea","header-sort-bar-color":"#aa9af4","header-reverse-bar-color":"#548d29","header-bar-casing-color":"#211f22","header-font":"600 12px Fira Sans, sans-serif","row-height":"19px","row-background-colors":"#373438 #2d2a2e","selection-color":"rgba(118, 217, 228, 0.09)","selection-outline-color":"#76d9e4","selection-outline-casing-color":"#211f22","row-hover-bg":"#4b494c","selected-row-hover-bg":"rgba(118, 217, 228, 0.25)","scroll-bar-active-selection-tick-color":"rgba(118, 217, 228, 0.5)","scroll-bar-bg":"#322f33","scroll-bar-hover-bg":"#373438","scroll-bar-casing-color":"#555356","scroll-bar-corner-color":"#322f33","scroll-bar-color":"#5b5a5c","scroll-bar-hover-color":"#929192","scroll-bar-active-color":"#c0bfbf","text-color":"#f0f0ee","positive-number-color":"#9edc6f","negative-number-color":"#f95d84","zero-number-color":"#fcd65b","date-color":"#fcd65b","pending-text-color":"#fde38d","error-text-color":"#f95d84","null-string-color":"#929192","filter-bar-active-bg":"#425175","filter-bar-active-color":"#4878ea","filter-bar-expanded-bg":"#373438","filter-bar-expanded-active-bg":"#313849","filter-bar-expanded-active-cell-bg":"#374d80","filter-bar-separator-color":"#929192","filter-bar-error-color":"#f95d84","filter-icon-color":"#4878ea","scrim-color":"#211f22","context-menu-sort-icon-color":"#aa9af4","context-menu-reverse-icon-color":"#548d29","linker-column-hover-bg":"rgba(118, 217, 228, 0.09)","tree-line-color":"#5b5a5c","tree-marker-color":"#c0bfbf","tree-marker-hover-color":"#fcfcfa","grouped-column-divider-color":"#1a171a","floating-grid-row-color":"#555356","floating-row-background-colors":"#403e41","floating-divider-inner-color":"#403e41","floating-divider-outer-color":"#211f22","overflow-button-color":"#c0bfbf","overflow-button-hover-color":"#fcfcfa"},ap=Object.freeze({backgroundColor:ae["grid-bg"],white:ae.white,black:ae.black,font:ae.font,headerBackgroundColor:ae["header-bg"],headerColor:ae["header-color"],headerSeparatorColor:ae["header-separator-color"],headerSeparatorHoverColor:ae["header-separator-hover-color"],headerHiddenSeparatorHoverColor:ae["header-hidden-separator-hover-color"],headerSortBarColor:ae["header-sort-bar-color"],headerReverseBarColor:ae["header-reverse-bar-color"],headerBarCasingColor:ae["header-bar-casing-color"],headerFont:ae["header-font"],rowBackgroundColors:ae["row-background-colors"],rowHoverBackgroundColor:ae["row-hover-bg"],selectionColor:ae["selection-color"],selectionOutlineColor:ae["selection-outline-color"],selectionOutlineCasingColor:ae["selection-outline-casing-color"],selectedRowHoverBackgroundColor:ae["selected-row-hover-bg"],scrollBarBackgroundColor:ae["scroll-bar-bg"],scrollBarHoverBackgroundColor:ae["scroll-bar-hover-bg"],scrollBarCasingColor:ae["scroll-bar-casing-color"],scrollBarCornerColor:ae["scroll-bar-corner-color"],scrollBarColor:ae["scroll-bar-color"],scrollBarHoverColor:ae["scroll-bar-hover-color"],scrollBarActiveColor:ae["scroll-bar-active-color"],scrollBarSelectionTickColor:ae["selected-row-hover-bg"],scrollBarActiveSelectionTickColor:ae["scroll-bar-active-selection-tick-color"],textColor:ae["text-color"],positiveNumberColor:ae["positive-number-color"],negativeNumberColor:ae["negative-number-color"],zeroNumberColor:ae["zero-number-color"],dateColor:ae["date-color"],pendingTextColor:ae["pending-text-color"],errorTextColor:ae["error-text-color"],nullStringColor:ae["null-string-color"],filterBarActiveBackgroundColor:ae["filter-bar-active-bg"],filterBarExpandedBackgroundColor:ae["filter-bar-expanded-bg"],filterBarExpandedActiveBackgroundColor:ae["filter-bar-expanded-active-bg"],filterBarExpandedActiveCellBackgroundColor:ae["filter-bar-expanded-active-cell-bg"],filterBarSeparatorColor:ae["filter-bar-separator-color"],filterBarActiveColor:ae["filter-bar-active-color"],filterBarErrorColor:ae["filter-bar-error-color"],filterIconColor:ae["filter-icon-color"],scrimColor:ae["scrim-color"],contextMenuSortIconColor:ae["context-menu-sort-icon-color"],contextMenuReverseIconColor:ae["context-menu-reverse-icon-color"],allowRowResize:!1,autoSelectRow:!0,gridColumnColor:null,gridRowColor:null,groupedColumnDividerColor:ae["grouped-column-divider-color"],columnHoverBackgroundColor:null,headerHorizontalPadding:12,scrollBarSize:13,scrollBarHoverSize:16,minScrollHandleSize:24,rowHeight:parseInt(ae["row-height"],10)||19,columnWidth:100,rowHeaderWidth:0,rowFooterWidth:60,columnHeaderHeight:parseInt(ae["header-height"],10)||30,filterBarHeight:30,filterBarCollapsedHeight:5,sortHeaderBarHeight:2,reverseHeaderBarHeight:4,filterBarHorizontalPadding:4,scrimBlurSize:25,minScrimTransitionTime:150,maxScrimTransitionTime:350,scrollSnapToRow:!0,linkerColumnHoverBackgroundColor:ae["linker-column-hover-bg"],treeLineColor:ae["tree-line-color"],treeMarkerColor:ae["tree-marker-color"],treeMarkerHoverColor:ae["tree-marker-hover-color"],floatingGridColumnColor:null,floatingGridRowColor:ae["floating-grid-row-color"],floatingRowBackgroundColors:ae["floating-row-background-colors"],floatingDividerInnerColor:ae["floating-divider-inner-color"],floatingDividerOuterColor:ae["floating-divider-outer-color"],overflowButtonColor:ae["overflow-button-color"],overflowButtonHoverColor:ae["overflow-button-hover-color"]});const Ir=X.module("ColumnStatistics"),sT={SIZE:"Number of Rows"},Ua=class extends S.exports.Component{constructor(t){super(t),this.handleError=this.handleError.bind(this),this.handleGenerateStatistics=this.handleGenerateStatistics.bind(this),this.handleStatistics=this.handleStatistics.bind(this),this.handleCopyHeader=this.handleCopyHeader.bind(this),this.cancelablePromise=null,this.state={error:null,loading:!1,statistics:null,numRows:0,copied:!1}}static getStatsLabel(t){var e;return(e=sT[t])!=null?e:t.split(" ").map(n=>n[0].toUpperCase()+n.substr(1).toLowerCase()).join(" ")}componentDidMount(){this.maybeGenerateStatistics()}componentWillUnmount(){this.cancelablePromise&&this.cancelablePromise.cancel()}handleCopyHeader(){this.setState({copied:!0})}maybeGenerateStatistics(){const{model:t}=this.props,e=t.rowCount;this.setState({numRows:e}),t.isColumnStatisticsAvailable?e<Ua.AUTO_GENERATE_LIMIT&&this.handleGenerateStatistics():this.setState({loading:!1})}handleGenerateStatistics(){this.setState({loading:!0});const{column:t,model:e}=this.props;this.cancelablePromise=Ee.makeCancelable(e.columnStatistics(t)),this.cancelablePromise.then(this.handleStatistics).catch(this.handleError)}handleStatistics(t){Ir.debug("Received statistics",t);const{model:e,onStatistics:n}=this.props,s=[];t.statisticsMap.forEach((i,o)=>{s.push({operation:Ua.getStatsLabel(o),value:i,type:t.getType(o)})}),t.uniqueValues.forEach((i,o)=>{s.push({operation:o,className:"column-statistics-unique-value",value:i,type:"long"})}),this.setState({loading:!1,statistics:s,numRows:e.rowCount}),n()}handleError(t){if(t!=null&&Ee.isCanceled(t)){Ir.debug("Called handleError on a cancelled promise result");return}Ir.error("Error generating statistics",t),this.setState({error:t,loading:!1,statistics:null})}render(){const{column:t,model:e}=this.props,{error:n,loading:s,statistics:i,numRows:o,copied:r}=this.state,l=!s&&n==null&&i==null&&e.isColumnStatisticsAvailable,a=[],d=t.type.substring(t.type.lastIndexOf(".")+1),c=t.description===null?null:t.description;if(i!=null)for(let g=0;g<i.length;g+=1){const{operation:f,className:b,value:C,type:w}=i[g],T=w?e.displayString(C,w):e.displayString(C,t.type,t.name),y=v(Y.Fragment,{children:[h("div",{className:z("column-statistic-operation",b),children:f}),h("div",{className:"column-statistic-value",children:T})]},f);a.push(y)}const u=gt(e)&&e.hasExpandableRows?"Expanded Rows":"Number of Rows",m=e.displayString(o,"long"),p=e.getColumnIndexByName(t.name);return v("div",{className:"column-statistics",children:[v("div",{className:"column-statistics-title",children:[t.name,v("span",{className:"column-statistics-type",children:["\xA0(",d,")"]}),h(Q,{kind:"ghost",className:"column-statistics-copy",icon:r?ld:od,onClick:()=>{Ne.copyToClipboard(t.name).then(this.handleCopyHeader).catch(g=>Ir.error("Unable to column name",g))},tooltip:r?"Copied text":"Copy column name"})]}),c!=null&&h("div",{className:"column-statistics-description",children:c}),p!=null&&!e.isColumnMovable(p)&&v("div",{className:"column-statistics-status",children:[h(K,{icon:e.isColumnFrozen(p)?Yf:Mf,className:"mr-1"}),e.isColumnFrozen(p)?"Frozen":"Not movable"]}),v("div",{className:"column-statistics-grid",children:[i==null&&v(ue,{children:[h("div",{className:"column-statistic-operation",children:u}),h("div",{className:"column-statistic-value",children:m})]}),a]}),l&&h("button",{type:"button",className:"btn btn-link px-0",onClick:this.handleGenerateStatistics,children:"Generate Stats"}),n!=null&&h("div",{className:"error-message",children:`${n}`}),i&&!s&&v("button",{type:"button",className:"btn btn-link px-0",onClick:this.handleGenerateStatistics,children:[h(K,{icon:cd,className:"mr-1"}),"Refresh"]}),s&&v("div",{className:"column-statistics-loading",children:[h(kn,{className:"mr-2"}),"Calculating Stats..."]})]})}};let dp=Ua;dp.AUTO_GENERATE_LIMIT=1e5;class Rr extends S.exports.PureComponent{constructor(e){super(e),this.handleSearchValueChange=this.handleSearchValueChange.bind(this),this.toggleColumn=this.toggleColumn.bind(this),this.selectAll=this.selectAll.bind(this),this.clear=this.clear.bind(this),this.selectNumbers=this.selectNumbers.bind(this),this.searchField=Y.createRef(),this.state={isConfigureColumnsShown:!1}}static createSearchFilter(e,n,s,i){const o=i?s.filter(r=>!n.includes(r.name)).map(r=>r.name):n;if(e&&o.length>0){const r=M.FilterValue.ofString(e);return o.length===s.length?M.FilterCondition.search(r):M.FilterCondition.search(r,s.filter(a=>o.includes(a.name)).map(a=>a.filter()))}}focus(){var e;(e=this.searchField.current)==null||e.focus()}handleSearchValueChange(e){const{onChange:n,selectedColumns:s,invertSelection:i}=this.props;n(e.target.value,s,i)}sendColumnChange(e,n){const{onChange:s,value:i}=this.props;s(i,e,n)}setInvertSelection(e){const{onChange:n,value:s}=this.props;n(s,[],e)}toggleColumn(e){const{selectedColumns:n,invertSelection:s}=this.props;if(n.includes(e))this.sendColumnChange(n.filter(i=>i!==e),s);else{const i=n.slice();i.push(e),this.sendColumnChange(i,s)}}selectAll(){this.setInvertSelection(!0)}clear(){this.setInvertSelection(!1)}selectNumbers(){const{columns:e}=this.props;this.sendColumnChange(e.filter(n=>P.isNumberType(n.type)).map(n=>n.name),!1)}render(){const{value:e,selectedColumns:n,invertSelection:s,columns:i}=this.props,{isConfigureColumnsShown:o}=this.state,r=n.length===0&&s===!0||n.length===i.length&&s===!1,l=n.length===0&&s===!1||n.length===i.length&&s===!0;let a;return r?a=v(ue,{children:[h(K,{icon:xc,mask:sa,transform:"shrink-2 down-5 right-7"}),h(K,{icon:Bf,className:"text-primary",transform:"shrink-4 down-5 right-7"})]}):l?a=v(ue,{children:[h(K,{icon:Lo,mask:sa,transform:"shrink-1 down-5 right-7"}),h(K,{icon:_c,className:"text-danger",transform:"shrink-4 down-5 right-7"})]}):a=v(ue,{children:[h(K,{icon:xc,mask:sa,transform:"shrink-2 down-5 right-7"}),h(K,{icon:tC,className:"text-primary",transform:"shrink-4 down-5 right-7"})]}),v("div",{className:"cross-column-container",children:[h(gs,{className:"cross-column-search",placeholder:"Search Data...",value:e,onChange:this.handleSearchValueChange,ref:this.searchField}),v("button",{type:"button",className:"btn btn-link btn-link-icon px-2",onClick:()=>{o?this.setState({isConfigureColumnsShown:!1}):this.setState({isConfigureColumnsShown:!0})},children:[h("div",{className:"fa-layers",children:a}),h(Ie,{children:"Configure Columns"}),h(xn,{isShown:o,className:"cross-column-popper",onExited:()=>{this.setState({isConfigureColumnsShown:!1})},closeOnBlur:!0,interactive:!0,children:v("div",{className:"cross-column-popup",children:["Searched Columns",h("div",{className:"cross-column-scroll",children:i.map(d=>v(Y.Fragment,{children:[h(Pt,{className:"cross-column-checkbox",checked:s?!n.includes(d.name):n.includes(d.name),onChange:()=>this.toggleColumn(d.name),children:d.name}),d.type.substring(d.type.lastIndexOf(".")+1)]},d.name))}),v("div",{className:"cross-column-button-bar",children:[h("button",{type:"button",className:"btn btn-link",onClick:this.selectAll,children:"Select All"}),h("button",{type:"button",className:"btn btn-link",onClick:this.clear,children:"Clear"}),h("button",{type:"button",className:"btn btn-link",onClick:this.selectNumbers,children:"Numbers Only"})]}),l&&v("p",{className:"text-danger",children:[h(K,{icon:_c})," Select at least one column to search."]})]})})]})]})}}const Is=X.module("PartitionSelectorSearch"),iT=150,cp=class extends S.exports.Component{constructor(t){super(t),this.debounceUpdateFilter=Xe(()=>{this.updateFilter()},iT),this.handleFilterChange=this.handleFilterChange.bind(this),this.handleInputFocus=this.handleInputFocus.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleListKeydown=this.handleListKeydown.bind(this),this.handleSelect=this.handleSelect.bind(this),this.handleTableUpdate=this.handleTableUpdate.bind(this),this.handleTextChange=this.handleTextChange.bind(this),this.handleViewportChange=this.handleViewportChange.bind(this),this.itemList=null,this.searchInput=null,this.timer=null,this.state={offset:0,itemCount:0,items:[],text:"",isLoading:!0}}static handleError(t){t instanceof di||Is.error(t)}componentDidMount(){this.startListening()}componentDidUpdate(t,e){const{isLoading:n,itemCount:s}=this.state,{onListResized:i}=this.props;(s!==e.itemCount||n!==e.isLoading)&&i()}componentWillUnmount(){this.debounceUpdateFilter.cancel(),this.stopListening()}handleKeyDown(t){if(this.itemList==null)return!1;const{items:e,itemCount:n}=this.state;switch(t.key){case"Enter":{let s=null;if(e.length>0)s=e[0].value;else{const{text:i}=this.state;s=i.trim()}if(s.length>0){const{onSelect:i}=this.props;i(s)}return t.stopPropagation(),t.preventDefault(),!0}case"ArrowDown":return n>0&&this.itemList.focusItem(1),t.stopPropagation(),t.preventDefault(),!0;default:return!1}}handleListKeydown(t){switch(t.key){case"Escape":break;default:this.focus();break}}handleFilterChange(){Is.debug2("handleFilterChange");const{table:t}=this.props,e=t.size;this.setState({itemCount:e,isLoading:!0})}handleInputFocus(){this.itemList&&this.itemList.focusItem(0)}handleSelect(t){Is.debug2("handleSelect",t);const{onSelect:e}=this.props,{offset:n,items:s}=this.state,i=t-n;if(i<0||s.length<=i){Is.error("No data for item",t);return}const{value:o}=s[i];e(o)}handleTableUpdate(t){const e=t.detail,{offset:n}=e,s=[],{getFormattedString:i,table:o}=this.props,r=o.columns[0];for(let a=0;a<e.rows.length;a+=1){const c=e.rows[a].get(r),u=i(c,r.type,r.name);s.push({displayValue:u,value:c})}const l=o.size;Is.debug2("handleTableUpdate",l,n,s.length),this.setState({itemCount:l,items:s,offset:n,isLoading:!1})}handleTextChange(t){Is.debug2("handleTextChange");const{value:e}=t.target;this.setState({text:e}),this.debounceUpdateFilter()}handleViewportChange(t,e){Is.debug2("handleViewportChange",t,e);const n=Math.max(1,e-t),s=Math.max(0,t-n),i=e+n,{table:o}=this.props;o.setViewport(s,i)}focus(){this.searchInput&&this.searchInput.focus()}startListening(){const{initialPageSize:t,table:e}=this.props;e.addEventListener(M.Table.EVENT_UPDATED,this.handleTableUpdate),e.addEventListener(M.Table.EVENT_FILTERCHANGED,this.handleFilterChange),e.setViewport(0,t)}stopListening(){const{table:t}=this.props;t.removeEventListener(M.Table.EVENT_UPDATED,this.handleTableUpdate),t.removeEventListener(M.Table.EVENT_FILTERCHANGED,this.handleFilterChange)}updateFilter(){const{initialPageSize:t,table:e}=this.props,{text:n}=this.state,s=n.trim(),i=[];if(s.length>0){const r=e.columns[0].filter().invoke("matches",M.FilterValue.ofString(`(?s)(?i).*\\Q${s}\\E.*`));i.push(r)}Is.debug2("updateFilter",i),e.applyFilter(i),e.setViewport(0,t)}render(){const{isLoading:t,itemCount:e,items:n,offset:s,text:i}=this.state,o=Math.min(e,cp.MAX_VISIBLE_ITEMS)*Cn.DEFAULT_ROW_HEIGHT+11;return v("div",{className:"iris-grid-partition-selector-search",children:[h("div",{className:"search-container",children:h("input",{type:"text",ref:r=>{this.searchInput=r},value:i,placeholder:"Available Partitions",onChange:this.handleTextChange,onFocus:this.handleInputFocus,onKeyDown:this.handleKeyDown,className:"form-control input-partition"})}),!t&&e>0&&h("div",{className:"iris-grid-partition-selector-search-list",onKeyDown:this.handleListKeydown,role:"presentation",style:{height:o},children:h(Cn,{ref:r=>{this.itemList=r},itemCount:e,items:n,offset:s,onSelect:this.handleSelect,onViewportChange:this.handleViewportChange})}),!t&&e===0&&h("div",{className:"iris-grid-partition-selector-search-empty",children:"No results"}),t&&v("div",{className:"iris-grid-partition-selector-loading",children:[h(kn,{}),"\xA0Loading..."]})]})}};let Ll=cp;Ll.MAX_VISIBLE_ITEMS=12;Ll.defaultProps={initialPageSize:100,onSelect:()=>{},onListResized:()=>{}};Ll.propTypes={getFormattedString:D.exports.func.isRequired,table:D.exports.shape({addEventListener:D.exports.func.isRequired,removeEventListener:D.exports.func.isRequired,columns:D.exports.arrayOf(D.exports.shape({name:D.exports.string.isRequired,type:D.exports.string.isRequired,filter:D.exports.func.isRequired})),size:D.exports.number.isRequired,applyFilter:D.exports.func.isRequired,setViewport:D.exports.func.isRequired}).isRequired,initialPageSize:D.exports.number,onSelect:D.exports.func,onListResized:D.exports.func};const Ei=X.module("IrisGridPartitionSelector"),oT=250;class hp extends S.exports.Component{constructor(e){super(e),this.debounceUpdate=Xe(()=>{this.sendUpdate()},oT),this.handleAppendClick=this.handleAppendClick.bind(this),this.handleCloseClick=this.handleCloseClick.bind(this),this.handleIgnoreClick=this.handleIgnoreClick.bind(this),this.handlePartitionChange=this.handlePartitionChange.bind(this),this.handlePartitionSelect=this.handlePartitionSelect.bind(this),this.handlePartitionListResized=this.handlePartitionListResized.bind(this),this.handleSearchOpened=this.handleSearchOpened.bind(this),this.handleSearchClosed=this.handleSearchClosed.bind(this),this.searchMenu=null,this.selectorSearch=null;const{partition:n}=e;this.state={partition:n}}componentWillUnmount(){this.debounceUpdate.cancel()}handleAppendClick(){Ei.debug2("handleAppendClick");const{onAppend:e}=this.props,{partition:n}=this.state;e(n)}handleCloseClick(){Ei.debug2("handleCloseClick"),this.sendDone()}handleIgnoreClick(){Ei.debug2("handleIgnoreClick"),this.sendFetchAll()}handlePartitionChange(e){Ei.debug2("handlePartitionChange");const{value:n}=e.target;this.setState({partition:n}),this.debounceUpdate()}handlePartitionSelect(e){this.searchMenu&&this.searchMenu.closeMenu(),this.setState({partition:e},()=>{this.sendUpdate()})}handlePartitionListResized(){this.searchMenu&&this.searchMenu.scheduleUpdate()}handleSearchClosed(){const{table:e}=this.props;e.applyFilter([])}handleSearchOpened(){this.selectorSearch&&this.selectorSearch.focus()}sendDone(){this.debounceUpdate.flush();const{onDone:e}=this.props;e()}sendUpdate(){Ei.debug2("sendUpdate");const{onChange:e}=this.props,{partition:n}=this.state;e(n)}sendFetchAll(){Ei.debug2("sendFetchAll"),this.debounceUpdate.cancel();const{onFetchAll:e}=this.props;e()}render(){const{columnName:e,getFormattedString:n,onDone:s,table:i}=this.props,{partition:o}=this.state,r=h(Ll,{getFormattedString:n,table:i,onSelect:this.handlePartitionSelect,onListResized:this.handlePartitionListResized,ref:l=>{this.selectorSearch=l}},"search");return v("div",{className:"iris-grid-partition-selector",children:[h("div",{className:"status-message",children:v("span",{children:['Filtering "',e,'" partition to']})}),v("div",{className:"input-group",children:[h("input",{type:"text",value:o,onChange:this.handlePartitionChange,className:"form-control input-partition"}),h("div",{className:"input-group-append",children:v("button",{type:"button",className:"btn btn-outline-primary",children:[h(K,{icon:ls}),h(Ie,{children:"Partitions"}),h(Wn,{ref:l=>{this.searchMenu=l},actions:[{menuElement:r}],onMenuOpened:this.handleSearchOpened,onMenuClosed:this.handleSearchClosed})]})})]}),h("div",{className:"iris-grid-partition-selector-spacer"}),h("button",{type:"button",className:"btn btn-outline-primary btn-ignore",onClick:this.handleIgnoreClick,children:"Ignore & Fetch All"}),h("button",{type:"button",className:"btn btn-outline-primary btn-append",onClick:this.handleAppendClick,children:"Append Command"}),h("button",{type:"button",className:"btn btn-link btn-link-icon btn-close",onClick:s,children:h(K,{icon:Yi})})]})}}hp.defaultProps={onAppend:()=>{},onChange:()=>{},onFetchAll:()=>{},onDone:()=>{},partition:""};const rT=X.module("SelectDistinctBuilder");class up extends S.exports.Component{constructor(e){super(e),this.handleAddColumnClick=this.handleAddColumnClick.bind(this),this.handleDeleteColumn=this.handleDeleteColumn.bind(this),this.handleDropdownChanged=this.handleDropdownChanged.bind(this);const{model:n,selectDistinctColumns:s}=this.props;this.state={inputs:s.length>0?[...s]:[""],columns:n.originalColumns}}componentDidUpdate(e,n){const{inputs:s}=this.state,{onChange:i}=this.props;if(n.inputs!==s){const o=s.filter(r=>r!=="");ct(n.inputs.filter(r=>r!==""),o)||i(o)}}handleAddColumnClick(){this.setState(({inputs:e})=>({inputs:[...e,""]}))}handleDeleteColumn(e){this.setState(({inputs:n})=>({inputs:n.length===1&&e===0?[""]:n.filter((s,i)=>e!==i)}))}handleDropdownChanged(e,n){rT.debug("handleDropdownChanged",e,n);const{value:s}=n.target;this.setState(({inputs:i})=>{const o=[...i];return o[e]=s,{inputs:o}})}renderInputs(){const{columns:e,inputs:n}=this.state;return n.map((s,i)=>{const o=e.filter(({name:r})=>r===s||!n.includes(r)).map(({name:r})=>h("option",{value:r,children:r},r));return v("div",{className:"form-inline px-3 pb-3",children:[v("select",{className:"form-control custom-select col",value:s,onChange:r=>this.handleDropdownChanged(i,r),children:[h("option",{value:"",children:"Select a column"}),o]}),(n.length>1||s!=="")&&v("button",{type:"button",className:"btn btn-link btn-link-icon ml-1 px-2",onClick:()=>{this.handleDeleteColumn(i)},children:[h(Ie,{children:"Delete column"}),h(K,{icon:_n,transform:"grow-3"})]})]},i)})}render(){const{columns:e,inputs:n}=this.state,s=n.length>=e.length;return v("div",{role:"presentation",className:"select-distinct-builder-container h-100",children:[h("div",{className:"select-distinct-title",children:"Display Unique Values From"}),this.renderInputs(),h("hr",{}),h("div",{className:"pt-1 px-3",children:v("button",{type:"button",className:"btn btn-link btn-add-column",onClick:this.handleAddColumnClick,disabled:s,children:[h(K,{icon:Ls}),"Add Additional Column"]})}),h("div",{className:"select-distinct-builder-footer",children:v("div",{className:"select-distinct-builder-hint",children:["Modifies a table to show unique value from a column, same as"," ",h("span",{className:"inline-code-snippet",children:'selectDistinct("Column")'}),". Filters will be reset and the resulting table will contain only the selected columns above."]})})]})}}up.defaultProps={selectDistinctColumns:[],onChange:()=>{}};const zd=({items:t,onChange:e=()=>{}})=>h(Hu,{items:Array.from(t.entries()).map(([n,s])=>({title:zd.getAdvancedSettingsTitleForKey(n),isOn:s,onChange:i=>e(n,i)}))});zd.getAdvancedSettingsTitleForKey=t=>{switch(t){case mi.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS:return"Control filters clear existing table filters";case mi.LINK_CHANGE_CLEARS_ALL_FILTERS:return"Inbound links clear existing table filters"}};const Rh=X.module("ConditionalFormattingMenu"),ua=()=>{};function lT(t){const{column:{type:e}}=t;if(P.isNumberType(e))return t.condition===Ye.IS_NULL||t.condition===Ye.IS_NOT_NULL?"":`${t.value}`;if(P.isCharType(e))return t.condition===Lt.IS_NULL||t.condition===Lt.IS_NOT_NULL?"":`${t.value}`;if(P.isStringType(e))return t.condition===sn.IS_NULL||t.condition===sn.IS_NOT_NULL?"":`"${t.value}"`;if(P.isDateType(e))return t.condition===Lt.IS_NULL||t.condition===Lt.IS_NOT_NULL?"":`${t.value}`;if(P.isBooleanType(e))return"";throw new Error(`Invalid column type ${e} in getRuleValue`)}function aT(t){return P.isNumberType(t.column.type)&&t.condition===Ye.IS_BETWEEN?`${t.start} < ${t.column.name} < ${t.end}`:`${t.column.name} ${xv(t.column.type,t.condition)}
|
|
34
|
-
${lT(t)}`}const dT=t=>{const{rules:e=[],onChange:n=ua,onCreate:s=ua,onSelect:i=ua}=t,o=S.exports.useCallback((d,c,u)=>{d.stopPropagation(),Rh.debug("Rule clicked",c,u),i(u)},[i]),r=S.exports.useCallback((d,c,u)=>{d.stopPropagation(),Rh.debug("Delete button clicked",c,u);const m=[...e];m.splice(u,1),n(m)},[n,e]),l=S.exports.useCallback(d=>{d.stopPropagation()},[]),a=S.exports.useCallback(d=>{if(Gt.stopDragging(),d.destination==null)return;const c=d.source.index,u=d.destination.index,m=[...e],p=e[c];m.splice(c,1),m.splice(u,0,p),n(m)},[n,e]);return v("div",{className:"conditional-formatting-rules",children:[h(Vo,{onDragStart:Gt.startDragging,onDragEnd:a,children:h(Ho,{droppableId:"droppable-custom-columns",children:(d,c)=>v("div",{ref:d.innerRef,...d.droppableProps,className:z("droppable-container",{dragging:c.draggingFromThisWith}),children:[e.length===0&&h("div",{className:"text-muted pl-2",children:"No formats defined"}),e.map((u,m)=>h(dl,{draggableId:`${m}-${u.type}`,index:m,disableInteractiveElementBlocking:!0,children:(p,g)=>h("div",{role:"menuitem",tabIndex:0,onClick:f=>o(f,u,m),className:z("draggable-container",{dragging:g.isDragging}),ref:p.innerRef,...p.draggableProps,children:h("div",{className:"conditional-formatting-list-item",children:v("div",{className:"formatting-item",children:[h("div",{className:"rule-icon",children:h("span",{className:"rule-icon-bg",style:{backgroundColor:el(u.config.style),color:tl(u.config.style)},children:u.type===Kn.ROWS?"row":"col"})}),h("div",{className:"rule-title",children:aT(u.config)}),v("button",{type:"button",className:"btn btn-link btn-link-icon ml-1 px-2",onClick:f=>r(f,u,m),children:[h(Ie,{children:"Delete rule"}),h(K,{icon:_n})]}),v("button",{type:"button",className:"btn btn-link btn-link-icon px-2 btn-drag-handle",onClick:l,...p.dragHandleProps,children:[h(Ie,{children:"Drag to re-order"}),h(K,{icon:ul})]})]})})})},`${m}-${u.type}`)),d.placeholder]})})}),h("hr",{}),h(Q,{kind:"ghost",onClick:s,icon:Ls,children:"Add New Rule"})]})},yi=X.module("ConditionEditor"),cT=()=>{},hT=[Ye.IS_EQUAL,Ye.IS_NOT_EQUAL,Ye.IS_BETWEEN,Ye.GREATER_THAN,Ye.GREATER_THAN_OR_EQUAL,Ye.LESS_THAN,Ye.LESS_THAN_OR_EQUAL,Ye.IS_NULL,Ye.IS_NOT_NULL].map(t=>h("option",{value:t,children:gv(t)},t)),uT=[sn.IS_EXACTLY,sn.IS_NOT_EXACTLY,sn.CONTAINS,sn.DOES_NOT_CONTAIN,sn.STARTS_WITH,sn.ENDS_WITH,sn.IS_NULL,sn.IS_NOT_NULL].map(t=>h("option",{value:t,children:fv(t)},t)),mT=[Lt.IS_EXACTLY,Lt.IS_NOT_EXACTLY,Lt.IS_BEFORE,Lt.IS_BEFORE_OR_EQUAL,Lt.IS_AFTER,Lt.IS_AFTER_OR_EQUAL,Lt.IS_NULL,Lt.IS_NOT_NULL].map(t=>h("option",{value:t,children:Cv(t)},t)),pT=[Ro.IS_TRUE,Ro.IS_FALSE,Ro.IS_NULL,Ro.IS_NOT_NULL].map(t=>h("option",{value:t,children:bv(t)},t)),gT=[oi.IS_EQUAL,oi.IS_NOT_EQUAL,oi.IS_NULL,oi.IS_NOT_NULL].map(t=>h("option",{value:t,children:Sv(t)},t));function fT(t,e,n,s){return t===Ye.IS_NULL||t===Ye.IS_NOT_NULL||t===Ye.IS_BETWEEN&&n!=null&&n!==""&&!Number.isNaN(Number.parseFloat(n))&&s!=null&&s!==""&&!Number.isNaN(Number.parseFloat(s))||t!==Ye.IS_BETWEEN&&e!==void 0&&e!==""&&!Number.isNaN(Number.parseFloat(e))}function CT(t,e,n,s,i,o,r){switch(t){case Ye.IS_EQUAL:case Ye.IS_NOT_EQUAL:case Ye.GREATER_THAN:case Ye.GREATER_THAN_OR_EQUAL:case Ye.LESS_THAN:case Ye.LESS_THAN_OR_EQUAL:return h("input",{type:"number",className:"form-control",placeholder:"Enter value",value:i!=null?i:"",onChange:e});case Ye.IS_BETWEEN:return v("div",{className:"d-flex flex-row",children:[h("input",{type:"number",className:"form-control d-flex mr-2",placeholder:"Start value",value:o!=null?o:"",onChange:n}),h("input",{type:"number",className:"form-control d-flex",placeholder:"End value",value:r!=null?r:"",onChange:s})]});case Ye.IS_NULL:case Ye.IS_NOT_NULL:return null}}function bT(t,e,n){switch(t){case sn.IS_NULL:case sn.IS_NOT_NULL:return null;default:return h("input",{type:"text",className:"form-control",placeholder:"Enter value",value:n!=null?n:"",onChange:e})}}function ST(t,e,n){switch(t){case Lt.IS_NULL:case Lt.IS_NOT_NULL:return null;default:return h("input",{type:"text",className:"form-control",placeholder:"Enter value",value:n!=null?n:"",onChange:e})}}function wT(){return null}function vT(t,e,n){switch(t){case oi.IS_NULL:case oi.IS_NOT_NULL:return null;default:return h("input",{type:"text",className:"form-control",maxLength:1,placeholder:"Enter value",value:n!=null?n:"",onChange:e})}}const mp=t=>{const{column:e,config:n,onChange:s=cT}=t,i=e.type,[o,r]=S.exports.useState(i),[l,a]=S.exports.useState(n.condition),[d,c]=S.exports.useState(n.value),[u,m]=S.exports.useState(n.start),[p,g]=S.exports.useState(n.end);i!==o&&(a(tp(i)),c(void 0),m(void 0),g(void 0),r(i));const f=S.exports.useMemo(()=>{if(i===void 0)return[];if(P.isNumberType(i))return hT;if(P.isCharType(i))return gT;if(P.isStringType(i))return uT;if(P.isDateType(i))return mT;if(P.isBooleanType(i))return pT},[i]),b=S.exports.useCallback(E=>{const{value:I}=E.target;yi.debug("handleConditionChange",I),a(I)},[]),C=S.exports.useCallback(E=>{const{value:I}=E.target;yi.debug("handleValueChange",I),c(I)},[]),w=S.exports.useCallback(E=>{const{value:I}=E.target;yi.debug("handleStartValueChange",I),m(I)},[]),T=S.exports.useCallback(E=>{const{value:I}=E.target;yi.debug("handleEndValueChange",I),g(I)},[]);S.exports.useEffect(function(){let I=!0;l===void 0&&(yi.debug("Unable to create formatting rule. Condition is not selected."),I=!1),P.isNumberType(e.type)&&!fT(l,d,u,p)&&(yi.debug("Unable to create formatting rule. Invalid value",d),I=!1),s({condition:l,value:d,start:u,end:p},I)},[s,e.type,l,d,u,p]);const y=S.exports.useMemo(()=>{if(i===void 0)return null;if(P.isNumberType(i))return CT(l,C,w,T,d,u,p);if(P.isCharType(i))return vT(l,C,d);if(P.isStringType(i))return bT(l,C,d);if(P.isDateType(i))return ST(l,C,d);if(P.isBooleanType(i))return wT()},[i,l,d,u,p,C,w,T]);return v("div",{className:"condition-editor mb-2",children:[h("select",{value:l,id:"condition-select",className:"custom-select mb-2",onChange:b,children:f}),y]})};const TT=X.module("StyleEditor"),ET="#fcfcfa",yT="#f0f0ee",IT="#1a171a",RT=200,DT=()=>{},pp=t=>{var T,y;const{config:e,onChange:n=DT}=t,[s,i]=S.exports.useState(e.type),[o,r]=S.exports.useState((y=(T=e.customConfig)==null?void 0:T.background)!=null?y:ET),[l,a]=S.exports.useState(!1),[d,c]=S.exports.useState(RT),u=S.exports.useRef(null),m=S.exports.useCallback(E=>{const{value:I}=E.target;TT.debug("handleBackgroundChange",I),r(I)},[]),p=S.exports.useCallback(()=>{l&&a(!1)},[l]),g=S.exports.useCallback(()=>{l||b(),a(!l)},[l]),f=S.exports.useMemo(()=>[Vn.NO_FORMATTING,Vn.POSITIVE,Vn.NEGATIVE,Vn.WARN,Vn.NEUTRAL,Vn.ACCENT_1,Vn.ACCENT_2,Vn.CUSTOM],[]);function b(){u.current&&c(u.current.getBoundingClientRect().width)}S.exports.useEffect(function(){n({type:s,customConfig:{color:pl.isDark(o)?yT:IT,background:o}})},[n,s,o]);const C=S.exports.useCallback(()=>{const E=[];for(let I=0;I<f.length;I+=1){const R=f[I],F=`option-${I}-${R}`;E.push(v(Q,{kind:"inline",className:"style-option-btn",onClick:()=>{i(R),a(!1)},style:{color:tl({type:R}),background:el({type:R})},children:[R===s&&h(K,{icon:ai,className:"mr-2"}),R!==s&&h("span",{className:"mr-4"}),Eh(R)]},F))}return E},[f,s]),w=S.exports.useCallback(()=>h("div",{className:"style-menu-container",role:"presentation",style:{width:d},children:h("div",{className:"style-options",children:C()})}),[d,C]);return v("div",{className:"style-editor",children:[v("div",{className:"mb-2",ref:u,children:[h("label",{className:"mb-0",children:"Style"}),v(Q,{kind:"inline",className:"cs-dropdown",style:{color:tl({type:s}),background:el({type:s})},onClick:g,children:[Eh(s),h("span",{children:h(K,{icon:md,className:"cs-caret"})}),h(Wn,{isShown:l,actions:{menuElement:w()},popperOptions:{placement:"bottom-start"},popperClassName:"style-dropdown-menu",onMenuClosed:p,menuStyle:{maxWidth:"100rem"}})]})]}),s===Vn.CUSTOM&&v("div",{className:"mb-2",children:[h("label",{className:"mb-0",children:"Background"}),h("input",{type:"color",value:o,className:"custom-select color-select",onChange:m})]})]})},go=X.module("ColumnFormatEditor"),MT=()=>{};function NT(t){const{type:e,name:n}=t[0];return{column:{type:e,name:n},style:sp(),...xl(e)}}const FT=t=>{var b;const{columns:e,config:n=NT(e),onChange:s=MT}=t,[i,o]=S.exports.useState((b=e.find(C=>C.name===n.column.name&&C.type===n.column.type))!=null?b:e[0]),[r,l]=S.exports.useState(np(n)),[a,d]=S.exports.useState(!1),[c,u]=S.exports.useState(n.style),m=S.exports.useCallback(C=>{const w=e.find(({name:T})=>T===C);w!==void 0?(o(w),i.type!==w.type&&(l(xl(w.type)),d(!1))):go.error(`Column ${C} not found.`)},[e,i]),p=S.exports.useCallback((C,w)=>{go.debug("handleConditionChange",C,w),l(C),d(w)},[]),g=S.exports.useCallback(C=>{go.debug("handleStyleChange",C),u(C)},[]);S.exports.useEffect(function(){if(i===void 0){go.debug("Column is not selected, skip update.");return}if(c===void 0){go.debug("Style is not selected, skip update.");return}const{type:w,name:T}=i;s({column:{type:w,name:T},style:c,...r},a)},[s,i,c,r,a]);const f=e.map(({name:C})=>({title:C,value:C}));return v("div",{className:"conditional-rule-editor form",children:[v("div",{className:"mb-2",children:[h("label",{className:"mb-0",children:"Format Cell If"}),h(ji,{defaultValue:i==null?void 0:i.name,options:f,inputPlaceholder:"Select a column",spellCheck:!1,onChange:m,searchPlaceholder:"Filter columns"})]}),i!==void 0&&v(ue,{children:[h(mp,{column:i,config:r,onChange:p}),h(pp,{config:c,onChange:g})]})]})},fo=X.module("RowFormatEditor"),xT=()=>{};function _T(t){const{type:e,name:n}=t[0];return{column:{type:e,name:n},style:sp(),...xl(e)}}const kT=t=>{var b;const{columns:e,config:n=_T(e),onChange:s=xT}=t,[i,o]=S.exports.useState((b=e.find(C=>C.name===n.column.name&&C.type===n.column.type))!=null?b:e[0]),[r,l]=S.exports.useState(np(n)),[a,d]=S.exports.useState(!1),[c,u]=S.exports.useState(n.style),m=S.exports.useCallback(C=>{const w=e.find(({name:T})=>T===C);w!==void 0?(o(w),i.type!==w.type&&(l(xl(w.type)),d(!1))):fo.error(`Column ${C} not found.`)},[e,i]),p=S.exports.useCallback((C,w)=>{fo.debug("handleConditionChange",C,w),l(C),d(w)},[]),g=S.exports.useCallback(C=>{fo.debug("handleStyleChange",C),u(C)},[]);S.exports.useEffect(function(){if(i===void 0){fo.debug("Column is not selected, skip update.");return}if(c===void 0){fo.debug("Style is not selected, skip update.");return}const{type:w,name:T}=i;s({column:{type:w,name:T},style:c,...r},a)},[s,i,c,r,a]);const f=e.map(({name:C})=>({title:C,value:C}));return v("div",{className:"conditional-rule-editor form",children:[v("div",{className:"mb-2",children:[h("label",{className:"mb-0",children:"Format Row If"}),h(ji,{defaultValue:i==null?void 0:i.name,options:f,inputPlaceholder:"Select a column",spellCheck:!1,onChange:m,searchPlaceholder:"Filter columns"})]}),i!==void 0&&v(ue,{children:[h(mp,{column:i,config:r,onChange:p}),h(pp,{config:c,onChange:g})]})]})};const ma=X.module("ConditionalFormatEditor"),pa=()=>{};function OT(t){switch(t){case Kn.CONDITIONAL:return h(x0,{});case Kn.ROWS:return h(_0,{})}}function LT(t){switch(t){case Kn.CONDITIONAL:return"Conditional";case Kn.ROWS:return"Rows"}}const Dh=[Kn.CONDITIONAL,Kn.ROWS],AT=t=>{var C;const{columns:e,onSave:n=pa,onUpdate:s=pa,onCancel:i=pa,rule:o}=t,r=e.filter(kv),[l,a]=S.exports.useState((C=o==null?void 0:o.type)!=null?C:Dh[0]),[d,c]=S.exports.useState(o),[u,m]=S.exports.useState(!1),p=S.exports.useCallback(()=>{i()},[i]),g=S.exports.useCallback(()=>{if(d===void 0){ma.error("Rule is not defined.");return}n(d)},[n,d]),f=S.exports.useCallback(w=>{ma.debug("handleFormatterChange",w),a(w)},[]),b=S.exports.useCallback((w,T)=>{ma.debug("handleRuleChange",w,T,l);const y={type:l,config:w};c(y),m(T),s(T?y:void 0)},[s,l]);return v("div",{className:"conditional-format-editor form",children:[v("div",{className:"mb-2",children:[h("label",{className:"mb-0",htmlFor:"formatter-select",children:"Select Formatter"}),h("div",{className:"formatter-list",children:Dh.map((w,T)=>h("div",{className:"formatter-type",children:v("button",{type:"button",className:z("btn","btn-icon","btn-formatter-type",{active:w===l}),"data-index":T,onClick:()=>f(w),children:[OT(w),LT(w)]})},w))})]}),l===Kn.CONDITIONAL&&h(FT,{columns:r,config:d==null?void 0:d.config,onChange:b}),l===Kn.ROWS&&h(kT,{columns:r,config:d==null?void 0:d.config,onChange:b}),h("hr",{}),v("div",{className:"d-flex justify-content-end my-3",children:[h(Q,{kind:"secondary",onClick:p,className:"mr-2",children:"Cancel"}),h(Q,{kind:"primary",onClick:g,disabled:d===void 0||!u,children:"Done"})]})]})};function PT({text:t,isOpen:e,onClose:n}){const[s,i]=S.exports.useState(!1),[o,r]=S.exports.useState(0),[l,a]=S.exports.useState(!1),[d,c]=S.exports.useState(!1),[u,m]=S.exports.useState(!1),p=S.exports.useRef(),g=S.exports.useRef(null),[f,b]=S.exports.useState(!1);S.exports.useEffect(function(){if(!!e){try{JSON.parse(t),m(!0)}catch{m(!1)}c(!1)}},[e,t]),S.exports.useEffect(function(){p.current&&p.current.layout()},[o]),S.exports.useEffect(function(){p.current&&p.current.updateOptions({lineNumbers:l?"on":"off"})},[l]),S.exports.useEffect(()=>(g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{b(!1)},1e3),()=>{g.current&&clearTimeout(g.current)}),[f]);function C(){var R,F;Ne.copyToClipboard((F=(R=p.current)==null?void 0:R.getValue())!=null?F:t).then(()=>{b(!0)})}function w(){a(!l)}function T(){var F;const R=(F=p.current)==null?void 0:F.getModel();!u||!R||(d?(R.setValue(t),c(!1)):(R.setValue(JSON.stringify(JSON.parse(t),void 0,2)),c(!0)),y())}function y(){var F,x;const R=p.current;!R||a(((x=(F=R.getModel())==null?void 0:F.getLineCount())!=null?x:0)>1)}function E(){s&&(p.current=void 0,n())}function I(R){p.current=R,R.onDidContentSizeChange(({contentHeight:F})=>r(F)),y()}return!e&&!s?null:v(Uo,{isOpen:e,centered:!0,keyboard:!0,toggle:E,onOpened:()=>i(!0),onClosed:()=>{i(!1),r(0)},className:"theme-bg-dark cell-overflow-modal",children:[v($o,{toggle:n,children:[h("h5",{className:"overflow-modal-title",children:"Cell Contents"}),h(Q,{kind:"inline",icon:f?ld:od,tooltip:f?"Copied contents":"Copy contents",onClick:C}),h(Q,{kind:"inline",active:l,icon:Df,tooltip:"Toggle line numbers",onClick:w}),u&&h(Q,{kind:"inline",icon:yf,active:d,tooltip:"Format as JSON",onClick:T})]}),h(Bo,{style:{height:o},children:h(Tl,{onEditorInitialized:I,settings:{value:t,readOnly:!0,wordWrap:"on",language:u?"typescript":"plaintext",folding:u,padding:{bottom:16},lineNumbers:l?"on":"off",overviewRulerLanes:0,renderLineHighlight:"none",find:{seedSearchStringFromSelection:"never"}}})})]})}const HT="###,##0",VT=({gotoRow:t,gotoRowError:e,onSubmit:n,isShown:s,onEntering:i,onEntered:o,onExiting:r,onExited:l,model:a,onGotoRowNumberChanged:d,onClose:c})=>{const u=S.exports.useRef(null),m="Row number",{rowCount:p}=a;return S.exports.useEffect(()=>{var g;document.activeElement!==u.current&&((g=u.current)==null||g.select())},[t]),h(_l,{isShown:s,className:z("goto-row"),onEntering:i,onEntered:()=>{var g;o(),(g=u.current)==null||g.select()},onExiting:r,onExited:l,children:v(ue,{children:[v("div",{className:"goto-row-wrapper",children:[h("div",{className:"goto-row-text",children:"Go to row"}),h("div",{className:"goto-row-input",children:h("input",{ref:u,type:"number",onKeyDown:g=>{g.key==="Enter"&&(g.stopPropagation(),g.preventDefault(),n())},className:z("form-control",{"is-invalid":e!==""}),placeholder:m,onChange:g=>{d(g)},value:t})}),v("div",{className:"goto-row-text",children:["of ",dh.i18n.NumberFormat.format(HT,p)]}),e&&h("div",{className:"goto-row-error text-danger",children:e})]}),h("div",{className:"goto-row-close",children:h(Q,{kind:"ghost",onClick:c,children:h(K,{icon:Yi,style:{marginRight:"0"}})})})]})})},Ce=X.module("IrisGrid"),UT=500,BT=250,$T=250,gp=Object.freeze({aggregations:[],showOnTop:!1});function Mh({advancedFilters:t,aggregationSettings:e,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}){return t.size===0&&e.aggregations.length===0&&n.length===0&&s.size===0&&i===P.REVERSE_TYPE.NONE&&o==null&&r==null&&l.length===0&&a.length===0}const ei=class extends S.exports.Component{constructor(t){super(t),this.getAdvancedMenuOpenedHandler=Te(N=>this.handleAdvancedMenuOpened.bind(this,N),{max:100}),this.getCachedAdvancedFilterMenuActions=Te((N,_,k,V,W)=>h($d,{model:N,column:_,onFilterChange:this.handleAdvancedFilterChange,onSortChange:this.handleAdvancedFilterSortChange,onDone:this.handleAdvancedFilterDone,options:k,sortDirection:V,formatter:W}),{max:50}),this.getCachedOptionItems=Te((N,_,k,V,W,j,ee,ve,le,Se,Le,J,pe,fe,xe)=>{const ke=[];return N&&ke.push({type:Oe.CHART_BUILDER,title:"Chart Builder",icon:jf}),ke.push({type:Oe.VISIBILITY_ORDERING_BUILDER,title:"Column Visibility & Ordering",icon:Ra}),k&&ke.push({type:Oe.CONDITIONAL_FORMATTING,title:"Conditional Formatting",icon:hl}),_&&ke.push({type:Oe.CUSTOM_COLUMN_BUILDER,title:"Manage Custom Columns",icon:Lf}),V&&ke.push({type:Oe.ROLLUP_ROWS,title:"Rollup Rows",icon:bu}),W&&ke.push({type:Oe.AGGREGATIONS,title:"Aggregate Columns",icon:Af}),j&&ke.push({type:Oe.SELECT_DISTINCT,title:"Select Distinct Values",icon:Of}),ee&&pe&&ke.push({type:Oe.TABLE_EXPORTER,title:"Download CSV",icon:Cf}),ke.push({type:Oe.ADVANCED_SETTINGS,title:"Advanced Settings",icon:Pf}),ke.push({type:Oe.QUICK_FILTERS,title:"Quick Filters",subtitle:ve.shortcut.getDisplayText(),icon:Wr,isOn:Le,onChange:ve.action}),fe&&ke.push({type:Oe.SEARCH_BAR,title:"Search Bar",subtitle:le.shortcut.getDisplayText(),icon:fu,isOn:J,onChange:le.action}),ke.push({type:Oe.GOTO,title:"Go to",subtitle:Se.shortcut.getDisplayText(),icon:kf,isOn:xe,onChange:Se.action}),ke},{max:1}),this.getCachedHiddenColumns=Te(N=>N,{max:1,normalizer:([N])=>N.join()}),this.getAggregationMap=Te((N,_)=>{const k={};return _.forEach(({operation:V,selected:W,invert:j})=>{k[V]=ks.getOperationColumnNames(N,V,W,j)}),k}),this.getOperationMap=Te((N,_)=>{const k={};return _.filter(V=>!ks.isRollupOperation(V.operation)).forEach(({operation:V,selected:W,invert:j})=>{ks.getOperationColumnNames(N,V,W,j).forEach(ee=>{var le;const ve=[...(le=k[ee])!=null?le:[],V];k[ee]=ve})}),k}),this.getOperationOrder=Te(N=>N.map(_=>_.operation).filter(_=>!ks.isRollupOperation(_))),this.getCachedFormatColumns=Te((N,_)=>_v(N,_)),this.getCachedModelColumns=Te((N,_)=>N.columns),this.getCachedPreviewFormatColumns=Te((N,_,k,V)=>{if(Ce.debug("getCachedPreviewFormatColumns",_,k,V),k!==void 0&&V!==void 0){const W=[..._];return W[V]=k,this.getCachedFormatColumns(N,W)}return this.getCachedFormatColumns(N,_)}),this.getModelRollupConfig=Te((N,_,k)=>se.getModelRollupConfig(N,_,k)),this.getModelTotalsConfig=Te((N,_,k)=>{var ve,le,Se;const{aggregations:V,showOnTop:W}=k;if(((le=(ve=_==null?void 0:_.columns)==null?void 0:ve.length)!=null?le:0)>0||((Se=V==null?void 0:V.length)!=null?Se:0)===0)return null;const j=this.getOperationMap(N,V),ee=this.getOperationOrder(V);return{operationMap:j,operationOrder:ee,showOnTop:W}}),this.getCachedStateOverride=Te((N,_,k,V,W,j,ee,ve,le,Se)=>({hoverSelectColumn:N,isFilterBarShown:_,isSelectingColumn:k,loadingScrimProgress:V,quickFilters:W,advancedFilters:j,sorts:ee,reverseType:ve,rollupConfig:le,isMenuShown:Se}),{max:1}),this.getCachedFilter=Te((N,_,k,V,W)=>[...N!=null?N:[],...V!=null?V:[],...se.getFiltersFromFilterMap(_),...se.getFiltersFromFilterMap(k),...W!=null?W:[]],{max:1}),this.getCachedTheme=Te((N,_)=>({...ap,...N,autoSelectRow:!_}),{max:1}),this.getAlwaysFetchColumns=Te((N,_,k,V,W,j)=>{const ee=[];for(let le=0;le<V;le+=1)ee.push(_[G.getModelIndex(le,k)].name);for(let le=0;le<W;le+=1)ee.push(_[G.getModelIndex(_.length-1-le,k)].name);if(j)for(let le=j[0];le<=j[1];le+=1)ee.push(_[G.getModelIndex(le,k)].name);return[...new Set([...N,...ee])]}),this.updateSearchFilter=Xe((N,_,k,V)=>{const W=Rr.createSearchFilter(N,_,k,V);this.setState({searchFilter:W})},BT),this.handleConditionalFormatEditorUpdate=Xe(N=>{this.setState({conditionalFormatPreview:N})},$T),this.handleDownloadProgressUpdate=hs((N,_)=>{const{tableDownloadStatus:k}=this.state;k===on.DOWNLOAD_STATUS.DOWNLOADING&&this.setState({tableDownloadProgress:N,tableDownloadEstimatedTime:_})},UT),this.getOverflowButtonTooltip=Te(N=>{if(N==null)return null;const _={position:"absolute",...N,pointerEvents:"none"};return h("div",{style:_,children:h(Ie,{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 ps,this.globalColumnFormats=[],this.decimalFormatOptions={},this.integerFormatOptions={},this.truncateNumbersWithPound=!1,this.renderer=new Fo,this.tableSaver=null,this.crossColumnRef=Y.createRef(),this.isAnimating=!1,this.filterInputRef=Y.createRef(),this.toggleFilterBarAction={action:()=>this.toggleFilterBar(),shortcut:ln.TABLE.TOGGLE_QUICK_FILTER},this.toggleSearchBarAction={action:()=>this.toggleSearchBar(),shortcut:ln.TABLE.TOGGLE_SEARCH},this.toggleGotoRowAction={action:()=>this.toggleGotoRow(),shortcut:ln.TABLE.GOTO_ROW},this.discardAction={action:()=>{const{model:N}=this.props;Ze(N)&&N.isEditable&&N.pendingDataMap.size>0&&this.discardPending().catch(Ce.error)},shortcut:ln.INPUT_TABLE.DISCARD},this.commitAction={action:()=>{const{model:N}=this.props;Ze(N)&&N.isEditable&&N.pendingDataMap.size>0&&N.pendingDataErrors.size===0&&this.commitPending().catch(Ce.error)},shortcut:ln.INPUT_TABLE.COMMIT},this.contextActions=[this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,this.discardAction,this.commitAction];const{aggregationSettings:e,conditionalFormats:n,customColumnFormatMap:s,isFilterBarShown:i,isSelectingPartition:o,model:r,movedColumns:l,movedRows:a,partition:d,partitionColumn:c,rollupConfig:u,userColumnWidths:m,userRowHeights:p,showSearchBar:g,searchValue:f,selectedSearchColumns:b,invertSearchColumns:C,advancedFilters:w,quickFilters:T,selectDistinctColumns:y,pendingDataMap:E,canCopy:I,frozenColumns:R}=t,F=[new Uv(this),new Bv(this)];I&&F.push(new Pv(this));const x=[new $v(this),new zv(this),new Wv(this),new Yv(this),new qv(this),new fs(this),new Kv(this),new Xv(this)],U=l.length>0?l:r.movedColumns,$=a.length>0?a:r.movedRows,O=new Zv({userColumnWidths:new Map(m),userRowHeights:new Map(p),movedColumns:U}),H=b!=null?b:[],L=Rr.createSearchFilter(f,H,r.columns,C);this.state={isFilterBarShown:i,isSelectingPartition:o,focusedFilterBarColumn:null,metricCalculator:O,metrics:void 0,keyHandlers:F,mouseHandlers:x,partition:d,partitionColumn:c,partitionTable:null,partitionFilters:[],quickFilters:T?new Map(T):new Map,advancedFilters:new Map(w),shownAdvancedFilter:null,hoverAdvancedFilter:null,sorts:[],reverseType:P.REVERSE_TYPE.NONE,customColumns:[],selectDistinctColumns:y,selectedRanges:[],copyOperation:null,loadingText:null,loadingScrimProgress:null,loadingSpinnerShown:!1,movedColumns:U,movedRows:$,shownColumnTooltip:null,formatter:new cn,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:L,searchValue:f,selectedSearchColumns:H,invertSearchColumns:C,rollupConfig:u,rollupSelectedColumns:[],aggregationSettings:e,selectedAggregation:null,openOptions:[],pendingRowCount:0,pendingDataMap:E!=null?E:new Map,pendingDataErrors:new Map,pendingSavePromise:null,pendingSaveError:null,toastMessage:null,frozenColumns:R,showOverflowModal:!1,overflowText:"",overflowButtonTooltipProps:null,isGotoRowShown:!1,gotoRow:"",gotoRowError:""}}static makeQuickFilter(t,e,n){try{return P.makeQuickFilter(t,e,n)}catch(s){Ce.error("Error creating quick filter",s)}return null}componentDidMount(){const{partitionColumn:t,model:e}=this.props,n=t!=null?t:e.columns.find(s=>s.isPartitionColumn);e.isFilterRequired&&e.isValuesTableAvailable&&n!=null?this.loadPartitionsTable(n):this.initState(),this.startListening(e)}componentDidUpdate(t){var c;const{inputFilters:e,isSelectingColumn:n,settings:s,model:i,customFilters:o,sorts:r}=this.props;i!==t.model&&(this.stopListening(t.model),this.startListening(i));const l=e!==t.inputFilters?e.filter(u=>!t.inputFilters.includes(u)):[];if(l.length>0){const{advancedSettings:u}=this.props,m=(c=u.get(mi.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS))!=null?c:!1;m&&(this.clearGridInputField(),this.clearCrossColumSearch()),this.startLoading("Filtering...",!0),this.applyInputFilters(l,m)}n!==t.isSelectingColumn&&this.resetColumnSelection(),s!==t.settings&&this.updateFormatterSettings(s),o!==t.customFilters&&this.startLoading("Filtering...",!0),r!==t.sorts&&this.updateSorts(r);const{loadingScrimStartTime:a,loadingScrimFinishTime:d}=this;a!=null&&d!=null&&window.requestAnimationFrame(()=>{const u=Date.now(),m=u-a,p=d-a,g=Math.min(m/p,1);d<u&&(this.loadingScrimStartTime=void 0,this.loadingScrimFinishTime=void 0),this.setState(f=>f.loadingScrimProgress==null?(Ce.debug2("Ignoring scrim update because loading cancelled."),null):{loadingScrimProgress:g})}),this.sendStateChange()}componentWillUnmount(){const{model:t}=this.props;this.stopListening(t),this.pending.cancel(),this.updateSearchFilter.cancel(),this.loadingTimer&&clearTimeout(this.loadingTimer),this.handleDownloadProgressUpdate.cancel(),this.animationFrame!==void 0&&cancelAnimationFrame(this.animationFrame)}getValueForCell(t,e,n=!1){const{model:s}=this.props,i=this.getModelColumn(t),o=this.getModelRow(e);return n&&i!=null&&o!=null?s.valueForCell(i,o):n?null:i!=null&&o!=null?s.textForCell(i,o):""}getModelColumn(t){const{metrics:e}=this.state;A(e);const{modelColumns:n}=e;return n==null?null:t!=null?n.get(t):null}getModelRow(t){const{metrics:e}=this.state;A(e);const{modelRows:n}=e;return n==null?null:t!=null?n.get(t):null}getTheme(){var n;const{model:t,theme:e}=this.props;return this.getCachedTheme(e,(n=Ze(t)&&t.isEditable)!=null?n:!1)}getVisibleColumn(t){const{movedColumns:e}=this.state;return G.getVisibleIndex(t,e)}applyInputFilters(t,e=!1){const{model:n}=this.props,{advancedFilters:s,quickFilters:i}=this.state,o=e?new Map:new Map(s),r=e?new Map:new Map(i);let l=e&&s.size>0;t.forEach(({name:a,type:d,value:c})=>{const u=n.columns.findIndex(({name:m,type:p})=>m===a&&p===d);u>=0?(l=o.delete(u)||l,l=this.applyQuickFilter(u,c,r)||l):Ce.error("Unable to find column for inputFilter",a,d,c)}),l&&this.setState({quickFilters:r,advancedFilters:o})}applyQuickFilter(t,e,n){const{model:s}=this.props,{formatter:i}=s,o=s.columns[t];if(e!=null&&`${e}`.trim().length>0){const r=n.get(t);if(r!=null){const{text:l}=r;if(l===e)return Ce.debug2("Ignoring change to existing filter"),!1}return n.set(t,{text:e,filter:ei.makeQuickFilter(o,e,i.timeZone)}),!0}return n.delete(t)}setAdvancedFilterMap(t){this.setState({advancedFilters:t})}setAdvancedFilter(t,e,n){Ce.debug("Setting advanced filter",t,e),this.startLoading("Filtering...",!0),this.setState(({advancedFilters:s})=>{const i=new Map(s);return e==null?i.delete(t):i.set(t,{filter:e,options:n}),{advancedFilters:i}})}setQuickFilter(t,e,n){Ce.debug("Setting quick filter",t,e,n),this.startLoading("Filtering...",!0),this.setState(({quickFilters:s})=>{const i=new Map(s);return i.set(t,{filter:e,text:n}),{quickFilters:i}})}setFilterMap(t){var i;Ce.debug("setFilterMap",t);const{advancedSettings:e}=this.props;((i=e.get(mi.LINK_CHANGE_CLEARS_ALL_FILTERS))!=null?i:!1)&&this.clearAllFilters();const{model:s}=this.props;t.forEach(({columnType:o,text:r,value:l},a)=>{const d=s.columns.find(u=>u.name===a&&u.type===o);if(d==null)return;const c=s.getColumnIndexByName(d.name);if(A(c),l===null)this.setQuickFilter(c,d.filter().isNull(),"=null");else{const u=P.isTextType(o)?M.FilterValue.ofString(l):M.FilterValue.ofNumber(l);this.setQuickFilter(c,d.filter().eq(u),`${r}`)}})}removeColumnFilter(t){this.startLoading("Filtering...",!0),this.setState(({advancedFilters:e,quickFilters:n})=>{const s=e?new Map(e):new Map,i=n?new Map(n):new Map;return i.delete(t),s.delete(t),{quickFilters:i,advancedFilters:s}})}clearAllFilters(){Ce.debug("Clearing all filters");const{advancedFilters:t,quickFilters:e,searchFilter:n}=this.state;e.size===0&&t.size===0&&n===null||(this.clearGridInputField(),this.startLoading("Clearing Filters...",!0),this.setState({quickFilters:new Map,advancedFilters:new Map,searchValue:"",searchFilter:void 0}))}clearCrossColumSearch(){Ce.debug("Clearing cross-column search"),this.setState({searchValue:"",searchFilter:void 0})}clearGridInputField(){this.filterInputRef.current!=null&&this.filterInputRef.current.setValue("")}rebuildFilters(){Ce.debug("Rebuilding filters");const{model:t}=this.props,{advancedFilters:e,quickFilters:n}=this.state,{columns:s,formatter:i}=t,o=new Map,r=new Map;e.forEach((l,a)=>{const{options:d}=l,c=s[a],u=P.makeAdvancedFilter(c,d,i.timeZone);o.set(a,{options:d,filter:u})}),n.forEach((l,a)=>{const{text:d}=l,c=s[a];r.set(a,{text:d,filter:ei.makeQuickFilter(c,d,i.timeZone)})}),this.startLoading("Rebuilding filters...",!0),this.setState({quickFilters:r,advancedFilters:o})}setFilters({quickFilters:t,advancedFilters:e}){this.setState({quickFilters:t,advancedFilters:e})}updateFormatterSettings(t,e=!0){var m,p,g;const n=cs.getColumnFormats(t),s=cs.getDateTimeFormatterOptions(t),i=(m=t==null?void 0:t.defaultDecimalFormatOptions)!=null?m:{},o=(p=t==null?void 0:t.defaultIntegerFormatOptions)!=null?p:{},r=(g=t==null?void 0:t.truncateNumbersWithPound)!=null?g:!1,l=!ct(this.globalColumnFormats,n),a=!ct(this.dateTimeFormatterOptions,s),d=!ct(this.decimalFormatOptions,t==null?void 0:t.defaultDecimalFormatOptions),c=!ct(this.integerFormatOptions,o),u=this.truncateNumbersWithPound!==r;(l||a||d||c||u)&&(this.globalColumnFormats=n,this.dateTimeFormatterOptions=s,this.decimalFormatOptions=i,this.integerFormatOptions=o,this.truncateNumbersWithPound=r,this.updateFormatter({},e),a&&e&&this.rebuildFilters())}updateFormatter(t,e=!0){var r;const{customColumnFormatMap:n}=this.state,s={customColumnFormatMap:n,...t},i=[...(r=this.globalColumnFormats)!=null?r:[],...s.customColumnFormatMap.values()],o=new cn(i,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions,this.truncateNumbersWithPound);Ce.debug("updateFormatter",this.globalColumnFormats,i),this.setState({...s,formatter:o},()=>{e&&this.grid&&this.grid.forceUpdate()})}initFormatter(){const{settings:t}=this.props;this.updateFormatterSettings(t)}initState(){const{applyInputFiltersOnInit:t,inputFilters:e,sorts:n,model:s,reverseType:i,customColumns:o,searchValue:r,selectedSearchColumns:l,invertSearchColumns:a}=this.props,d=l!=null?l:[],c=Rr.createSearchFilter(r,d,s.columns,a);if(t){const u=e.filter(m=>m.value!=null);this.applyInputFilters(u)}this.setState({sorts:n,reverseType:i,customColumns:o,isReady:!0,searchFilter:c}),this.initFormatter()}async loadPartitionsTable(t){const{model:e}=this.props;this.setState({isSelectingPartition:!0});try{const n=await this.pending.add(e.valuesTable(t),r=>r.close()),s=n.columns[0],i=s.sort().desc();n.applySort([i]),n.setViewport(0,0,[s]);const o=await this.pending.add(n.getViewportData());if(o.rows.length>0){const l=o.rows[0].get(s);this.updatePartition(l,t),this.setState({isSelectingPartition:!0})}else Ce.info("Table does not have any data, just fetching all"),this.setState({isSelectingPartition:!1}),this.handlePartitionFetchAll();this.setState({partitionTable:n,partitionColumn:t},()=>{this.initState()})}catch(n){this.handleTableLoadError(n)}}updatePartition(t,e){const s=[e.filter().eq(M.FilterValue.ofString(t))];this.setState({partition:t,partitionFilters:s})}copyCell(t,e,n=!1){const{canCopy:s}=this.props;if(s){const i=String(this.getValueForCell(t,e,n));Ne.copyToClipboard(i).catch(o=>Ce.error("Unable to copy cell",o))}else Ce.error("Attempted to copyCell for user without copy permission.")}copyRanges(t,e=!1,n=!0,s){const{model:i,canCopy:o}=this.props,{metricCalculator:r,movedColumns:l}=this.state,a=r.getUserColumnWidths();if(o){const d={ranges:re.boundedRanges(t,i.columnCount,i.rowCount),includeHeaders:e,formatValues:n,movedColumns:l,userColumnWidths:a,error:s};this.setState({copyOperation:d})}else Ce.error("Attempted copyRanges for user without copy permission.")}startLoading(t,e=!1){var s,i;this.setState({loadingText:t});const n=this.getTheme();if(e&&this.grid&&(this.grid.clearSelectedRanges(),this.grid.setViewState({top:0},!0)),this.loadingScrimStartTime==null){const{minScrimTransitionTime:o,maxScrimTransitionTime:r}=n;A(o),A(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})},ei.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){Ce.debug("loading last loading config",this.lastLoadedConfig);const{advancedFilters:t,aggregationSettings:e,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}=this.lastLoadedConfig;this.lastLoadedConfig=null,this.setState({advancedFilters:t,aggregationSettings:e,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a})}else Ce.debug("remove all sorts, filters, and custom columns"),this.setState({advancedFilters:new Map,aggregationSettings:gp,customColumns:[],quickFilters:new Map,reverseType:P.REVERSE_TYPE.NONE,rollupConfig:void 0,selectDistinctColumns:[],sorts:[]})}canRollback(){return this.lastLoadedConfig!=null||!Mh(this.state)}startListening(t){t.addEventListener(be.EVENT.UPDATED,this.handleUpdate),t.addEventListener(be.EVENT.REQUEST_FAILED,this.handleRequestFailed),t.addEventListener(be.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),t.addEventListener(be.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}stopListening(t){t.removeEventListener(be.EVENT.UPDATED,this.handleUpdate),t.removeEventListener(be.EVENT.REQUEST_FAILED,this.handleRequestFailed),t.removeEventListener(be.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),t.removeEventListener(be.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}focus(){var t;(t=this.grid)==null||t.focus()}focusFilterBar(t){var c,u,m;const{model:e}=this.props,{columnCount:n}=e,s=this.getModelColumn(t);if(t==null||s==null||t<0||n<=t||!e.isFilterable(s)){this.setState({focusedFilterBarColumn:null});return}const{metricCalculator:i,metrics:o}=this.state;A(o);const{gridX:r,left:l,rightVisible:a,lastLeft:d}=o;if(t<l)(c=this.grid)==null||c.setViewState({left:t},!0);else if(a<t){const p=(u=this.grid)==null?void 0:u.getMetricState();A(p);const g=i.getLastLeft(p,t,r);(m=this.grid)==null||m.setViewState({left:Math.min(g,d)},!0)}this.lastFocusedFilterBarColumn=t,this.setState({focusedFilterBarColumn:t,isFilterBarShown:!0})}hideColumnByVisibleIndex(t){var s;const{metricCalculator:e,movedColumns:n}=this.state;e.setColumnWidth(G.getModelIndex(t,n),0),(s=this.grid)==null||s.forceUpdate()}freezeColumnByColumnName(t){const{frozenColumns:e,movedColumns:n}=this.state,{model:s}=this.props;Ce.debug2("freezing column",t);const i=e==null?new Set(s.frozenColumns):new Set(e);i.add(t);const o=s.getColumnIndexByName(t);A(o);const r=G.getVisibleIndex(o,n),l=G.moveItem(r,i.size-1,n);this.setState({frozenColumns:[...i],movedColumns:l})}unFreezeColumnByColumnName(t){const{frozenColumns:e,movedColumns:n}=this.state,{model:s}=this.props;Ce.debug2("unfreezing column",t);const i=e==null?new Set(s.frozenColumns):new Set(e);i.delete(t);const o=s.getColumnIndexByName(t);A(o);const r=G.getVisibleIndex(o,n),l=G.moveItem(r,i.size+s.frontColumns.length,n);this.setState({frozenColumns:[...i],movedColumns:l})}handleColumnVisibilityChanged(t,e){var s;const{metricCalculator:n}=this.state;e===pi.VISIBILITY_OPTIONS.SHOW?t.forEach(i=>{n.resetColumnWidth(i)}):t.forEach(i=>{n.setColumnWidth(i,0)}),(s=this.grid)==null||s.forceUpdate()}handleCrossColumnSearch(t,e,n){const{model:s}=this.props;this.updateSearchFilter(t,e,s.columns,n),this.setState({searchValue:t,selectedSearchColumns:e,invertSearchColumns:n})}handleAnimationLoop(){var t,e;(t=this.grid)==null||t.updateCanvasScale(),(e=this.grid)==null||e.updateCanvas(),this.isAnimating&&(this.animationFrame=requestAnimationFrame(this.handleAnimationLoop))}handleAnimationStart(){Ce.debug2("handleAnimationStart"),this.isAnimating=!0,this.animationFrame=requestAnimationFrame(this.handleAnimationLoop)}handleAnimationEnd(){Ce.debug2("handleAnimationEnd"),this.isAnimating=!1}handlePartitionAppend(t){const{onPartitionAppend:e}=this.props,{partitionColumn:n}=this.state;e(n,t)}handlePartitionChange(t){const{partitionColumn:e}=this.state;this.updatePartition(t,e)}handlePartitionFetchAll(){this.setState({partitionFilters:[],isSelectingPartition:!1})}handlePartitionDone(){this.setState({isSelectingPartition:!1})}handleTableLoadError(t){if(Ee.isCanceled(t))return;Ce.error(t);const{onError:e}=this.props;e(t)}showAllColumns(){var s;const{metricCalculator:t}=this.state,n=[...t.getUserColumnWidths().entries()];for(let i=0;i<n.length;i+=1){const[o,r]=n[i];r===0&&t.resetColumnWidth(o)}(s=this.grid)==null||s.forceUpdate()}toggleSort(t,e){Ce.info("Toggling sort for column",t);const{model:n}=this.props,{sorts:s}=this.state,i=this.getModelColumn(t);A(i);const o=P.toggleSortForColumn(s,n.columns,i,e);this.updateSorts(o)}updateSorts(t){var e;this.startLoading("Sorting..."),this.setState({sorts:t}),(e=this.grid)==null||e.forceUpdate()}sortColumn(t,e=P.sortDirection.none,n=!1,s=!1){var r;A(t);const{model:i}=this.props,o=P.sortColumn(i.sort,i.columns,t,e,n,s);this.startLoading("Sorting..."),this.setState({sorts:o}),(r=this.grid)==null||r.forceUpdate()}reverse(t){var e;this.startLoading("Reversing..."),this.setState({reverseType:t}),(e=this.grid)==null||e.forceUpdate()}isReversible(){const{model:t}=this.props;return t.isReversible}toggleFilterBar(t=this.lastFocusedFilterBarColumn){var n;let{isFilterBarShown:e}=this.state;if(e=!e,this.setState({isFilterBarShown:e}),e)if(t!=null)this.focusFilterBar(t);else{let s=0;const{model:i}=this.props,{columnCount:o}=i;for(let r=0;r<o;r+=1){const l=this.getModelColumn(r);if(l!=null){const a=i.columns[l];if(a!=null&&P.isTextType(a.type)){s=r;break}}}this.focusFilterBar(s)}else(n=this.grid)==null||n.focus()}isTableSearchAvailable(){var s,i,o;const{model:t,canToggleSearch:e}=this.props,n=(s=t==null?void 0:t.layoutHints)==null?void 0:s.searchDisplayMode;return n===((i=M.SearchDisplayMode)==null?void 0:i.SEARCH_DISPLAY_HIDE)?!1:n===((o=M.SearchDisplayMode)==null?void 0:o.SEARCH_DISPLAY_SHOW)?!0:e}toggleSearchBar(){const{showSearchBar:t}=this.state;if(!this.isTableSearchAvailable())return;const e=!t;this.setState({showSearchBar:e},()=>{var n,s,i;e&&((n=this.crossColumnRef)==null?void 0:n.current)?(s=this.crossColumnRef)==null||s.current.focus():(i=this.grid)==null||i.focus()})}toggleGotoRow(t=""){const{isGotoRowShown:e}=this.state;if(t){this.setState({isGotoRowShown:!0,gotoRow:t,gotoRowError:""});return}this.setState({isGotoRowShown:!e,gotoRow:"",gotoRowError:""})}async commitPending(){var i,o;const{model:t}=this.props;if(!Ze(t)||!t.isEditable)throw new Error("Cannot save, table is not editable");const{pendingSavePromise:e}=this.state;if(e!=null)throw new Error("Save already in progress");const n=(i=document==null?void 0:document.activeElement)==null?void 0:i.classList.contains("grid-cell-input-field");if(n!=null&&n){if(document.activeElement!=null&&document.activeElement.classList.contains("error"))throw new Ai("Current input is invalid");(o=this.grid)==null||o.focus()}const s=this.pending.add(t.commitPending()).then(()=>{this.setState({pendingSaveError:null,pendingSavePromise:null})}).catch(r=>{Ee.isCanceled(r)||this.setState({pendingSaveError:r,pendingSavePromise:null})});return this.setState({pendingSavePromise:s}),s}async discardPending(){const{pendingSavePromise:t}=this.state;if(t!=null)throw new Error("Cannot cancel a save in progress");this.setState({pendingSavePromise:null,pendingSaveError:null,pendingDataMap:new Map,pendingDataErrors:new Map})}selectColumn(t){const{onColumnSelected:e}=this.props;e(t)}selectData(t,e){const{model:n}=this.props,{columns:s}=n,i={};for(let r=0;r<s.length;r+=1){const l=s[r],{name:a,type:d}=l,c=n.valueForCell(r,e),u=n.textForCell(r,e);i[a]={value:c,text:u,type:d}}const{onDataSelected:o}=this.props;o(e,i)}handleAdvancedFilterChange(t,e,n){const{model:s}=this.props,i=s.getColumnIndexByName(t.name);A(i),this.setAdvancedFilter(i,e,n)}handleAdvancedFilterSortChange(t,e,n=!1){var a;const{model:s}=this.props,i=s.getColumnIndexByName(t.name);A(i);const o=P.getSortForColumn(s.sort,i);let r=null;(o==null||o.direction!==e)&&(e===P.sortDirection.descending?r=t.sort().desc():r=t.sort().asc());const l=P.setSortForColumn(s.sort,i,r,n);Ce.info("Setting table sorts",l),this.startLoading("Sorting..."),this.setState({sorts:l}),(a=this.grid)==null||a.forceUpdate()}handleAdvancedFilterDone(){var t;(t=this.grid)==null||t.focus()}handleAdvancedMenuOpened(t){this.setState({shownAdvancedFilter:t})}handleGotoRowOpened(){this.setState({isGotoRowShown:!0})}handleGotoRowClosed(){this.setState({isGotoRowShown:!1})}handleAdvancedMenuClosed(t){var s,i;const{focusedFilterBarColumn:e,isFilterBarShown:n}=this.state;n&&e===t&&((s=this.filterInputRef)==null?void 0:s.current)!==null?((i=this.filterInputRef)==null||i.current.focus(),this.setState({shownAdvancedFilter:null})):this.setState({focusedFilterBarColumn:null,shownAdvancedFilter:null})}handleCancel(){this.rollback()}handleChartChange(){}handleChartCreate(t){const{model:e,onCreateChart:n}=this.props;n(t,e)}handleGridError(t){Ce.warn("Grid Error",t),this.setState({toastMessage:h("div",{className:"error-message",children:`${t}`})})}handleFilterBarChange(t){this.startLoading("Filtering...",!0),this.setState(({focusedFilterBarColumn:e,quickFilters:n})=>{const s=new Map(n);if(e!=null){const i=this.getModelColumn(e);A(i),this.applyQuickFilter(i,t,s)}return{quickFilters:s}})}handleFilterBarDone(t=!0,e=!0){var n;t&&((n=this.grid)==null||n.focus()),e&&this.setState({focusedFilterBarColumn:null})}handleFilterBarTab(t){const{focusedFilterBarColumn:e}=this.state;A(e),t?this.focusFilterBar(e-1):this.focusFilterBar(e+1)}handleFormatSelection(t,e){const{model:n}=this.props,s=n.columns[t],{customColumnFormatMap:i}=this.state,o=new Map(i);if(e!=null){const r=P.getNormalizedType(s.type);A(r);const l=cn.makeColumnFormattingRule(r,s.name,e);o.set(s.name,l)}else o.delete(s.name);this.updateFormatter({customColumnFormatMap:o})}handleMenu(t){t.stopPropagation(),this.setState({isMenuShown:!0})}handleMenuClose(){this.setState({isMenuShown:!1,openOptions:[]})}handleMenuBack(){this.setState(({openOptions:t})=>{const e=[...t];return e.pop(),{openOptions:e}})}handleMenuSelect(t){this.setState(({openOptions:e})=>({openOptions:[...e,t]}))}handleRequestFailed(t){const e=t;if(Ce.error("request failed:",e.detail),this.stopLoading(),this.canRollback())this.startLoading("Rolling back changes...",!0),this.rollback();else{Ce.error("Table failed and unable to rollback");const{onError:n}=this.props;n(new Error(`Error displaying table: ${e.detail}`))}}handleUpdate(){var c;this.stopLoading(),Ce.debug2("Received model update");const{advancedFilters:t,aggregationSettings:e,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}=this.state,d={advancedFilters:t,aggregationSettings:e,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a};Mh(d)?this.lastLoadedConfig=null:this.lastLoadedConfig=d,(c=this.grid)==null||c.forceUpdate()}handleViewChanged(t){var i,o;const{model:e}=this.props,{selectionEndRow:n=0}=(o=(i=this.grid)==null?void 0:i.state)!=null?o:{};let s=0;if(Ze(e)&&e.isEditable){A(t);const{bottomViewport:r}=t,l=e.rowCount-e.floatingBottomRowCount;n===l-1?s=e.pendingRowCount+1:n===l-2?s=e.pendingRowCount:s=Math.max(0,r-(e.rowCount-e.pendingRowCount)-e.floatingTopRowCount-e.floatingBottomRowCount-1)}this.setState({metrics:t,pendingRowCount:s})}handleSelectionChanged(t){A(t);const{onSelectionChanged:e}=this.props,{copyOperation:n}=this.state;this.setState({selectedRanges:t}),n!=null&&this.setState({copyOperation:null}),e(t)}handleMovedColumnsChanged(t,e=()=>null){this.setState({movedColumns:t},e)}handleTooltipRef(t){t!=null&&t.startTimer(),this.tooltip=t}handleConditionalFormatsChange(t){Ce.debug("Updated conditional formats",t),this.setState({conditionalFormats:t})}handleConditionalFormatCreate(){Ce.debug("Create new conditional format");const{openOptions:t,conditionalFormats:e}=this.state;this.setState({openOptions:[...t,{type:Oe.CONDITIONAL_FORMATTING_EDIT,title:"Create Formatting Rule"}],conditionalFormatEditIndex:e.length,conditionalFormatPreview:void 0})}handleConditionalFormatEdit(t){Ce.debug("Edit conditional format",t);const{openOptions:e,conditionalFormats:n}=this.state;this.setState({openOptions:[...e,{type:Oe.CONDITIONAL_FORMATTING_EDIT,title:"Edit Formatting Rule"}],conditionalFormatEditIndex:t,conditionalFormatPreview:{...n[t]}})}handleConditionalFormatEditorSave(t){Ce.debug("Save conditional format changes",t),this.setState(e=>{if(e.conditionalFormatEditIndex===null)return Ce.debug("Invalid format index"),null;const n=[...e.conditionalFormats];return n[e.conditionalFormatEditIndex]=t,{conditionalFormats:n}},()=>{this.handleMenuBack()})}handleConditionalFormatEditorCancel(){this.handleMenuBack(),this.setState({conditionalFormatEditIndex:null})}handleUpdateCustomColumns(t){Ce.info("handleUpdateCustomColumns:",t);const{model:e}=this.props,{movedColumns:n,sorts:s,quickFilters:i,advancedFilters:o,selectDistinctColumns:r}=this.state,{columns:l}=e,a=e.customColumns.map(c=>`${c}`),d=se.getRemovedCustomColumnNames(a,t);if(d.length>0){const c=se.removeSortsInColumns(s,d),u=se.removeFiltersInColumns(l,i,d),m=se.removeFiltersInColumns(l,o,d),p=se.removeColumnFromMovedColumns(l,n,d),g=se.removeColumnsFromSelectDistinctColumns(r,d);c.length!==s.length&&(Ce.debug("removing sorts from removed custom columns..."),this.setState({sorts:c})),(u.size!==i.size||m.size!==o.size)&&(Ce.debug("removing filters from removed custom columns..."),this.setState({quickFilters:u,advancedFilters:m})),ct(n,p)||(Ce.debug("change moved columns for removed custom columns",p),this.setState({movedColumns:p})),ct(r,g)||(Ce.debug("change selectDistinct columns for removed custom columns",p),this.setState({selectDistinctColumns:g}))}this.setState({customColumns:t}),this.startLoading("Applying custom columns...")}handleCustomColumnsChanged(){var e;Ce.debug("custom columns changed");const{isReady:t}=this.state;t?(this.stopLoading(),(e=this.grid)==null||e.forceUpdate()):this.initState()}handlePendingCommitClicked(){return this.commitPending()}handlePendingDiscardClicked(){return this.discardPending()}handlePendingDataUpdated(){var s;Ce.debug("pending data updated");const{model:t}=this.props,{pendingDataMap:e,pendingDataErrors:n}=t;this.setState({pendingDataMap:e,pendingDataErrors:n,pendingSaveError:null}),(s=this.grid)==null||s.forceUpdate()}handleAggregationsChange(t){Ce.debug("handleAggregationsChange",t),this.startLoading(`Aggregating ${t.aggregations.map(e=>e.operation).join(", ")}...`),this.setState({aggregationSettings:t})}handleAggregationChange(t){Ce.debug("handleAggregationChange",t),this.startLoading(`Aggregating ${t.operation}...`),this.setState(({aggregationSettings:e})=>({selectedAggregation:t,aggregationSettings:{...e,aggregations:e.aggregations.map(n=>n.operation===t.operation?t:n)}}))}handleAggregationEdit(t){Ce.debug("handleAggregationEdit",t);const{openOptions:e}=this.state;this.setState({openOptions:[...e,{type:Oe.AGGREGATION_EDIT,title:`Edit Columns to ${t.operation}`}],selectedAggregation:t})}handleRollupChange(t){var e,n;Ce.info("Rollup change",t),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Grouping by columns ${(n=(e=t==null?void 0:t.columns)==null?void 0:e.join(", "))!=null?n:""}...`),this.setState({rollupConfig:t,movedColumns:[],sorts:[],reverseType:P.REVERSE_TYPE.NONE,selectDistinctColumns:[]})}handleSelectDistinctChanged(t){Ce.debug("SelectDistinct change",t),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Selecting distinct values in ${t.length>0?t.join(", "):""}...`),this.setState({selectDistinctColumns:t,movedColumns:[],sorts:[],reverseType:P.REVERSE_TYPE.NONE})}handleDownloadTableStart(){const{canDownloadCsv:t}=this.props;t?this.setState({isTableDownloading:!0,tableDownloadProgress:0,tableDownloadEstimatedTime:null,tableDownloadStatus:on.DOWNLOAD_STATUS.INITIATING}):Ce.error("Attempted to handleDownloadTableStart for user without download CSV permission.")}handleDownloadTable(t,e,n,s){const{canDownloadCsv:i}=this.props;i?(Ce.info("start table downloading",t,e,n,s),this.setState(()=>(this.tableSaver&&this.tableSaver.startDownload(t,e,n,s),{tableDownloadStatus:on.DOWNLOAD_STATUS.DOWNLOADING}))):Ce.error("Attempted to handleDownloadTable for user without download CSV permission.")}handleCancelDownloadTable(){var t;(t=this.tableSaver)==null||t.cancelDownload(),this.setState({isTableDownloading:!1})}handleDownloadCompleted(){this.setState({isTableDownloading:!1,tableDownloadProgress:100,tableDownloadStatus:on.DOWNLOAD_STATUS.FINISHED})}handleDownloadCanceled(){this.setState({isTableDownloading:!1,tableDownloadProgress:0,tableDownloadStatus:on.DOWNLOAD_STATUS.CANCELED})}deleteRanges(t){const{model:e}=this.props;this.pending.add(e.delete(t)).catch(n=>{Ee.isCanceled(n)||Ce.error("Unable to delete ranges",t,n)})}resetColumnSelection(){if(this.grid==null)return;const{isSelectingColumn:t}=this.props;if(t){const{columnAllowedCursor:e}=this.props;this.grid.setState({cursor:e})}else this.grid.setState({cursor:null}),this.setState({hoverSelectColumn:null})}resetGridViewState(t=!0){!this.grid||(this.grid.clearSelectedRanges(),this.grid.setViewState({left:0,top:0,topOffset:0,leftOffset:0},t))}sendStateChange(){if(!this.grid)return;const{state:t}=this,{state:e}=this.grid,{onStateChange:n}=this.props;n(t,e)}handleOverflowClose(){this.setState({showOverflowModal:!1})}getColumnBoundingRect(){var m;const{metrics:t,shownColumnTooltip:e}=this.state;A(t),A(e);const n=(m=this.gridWrapper)==null?void 0:m.getBoundingClientRect(),s=20;A(n);const{columnHeaderHeight:i,visibleColumnXs:o,visibleColumnWidths:r,width:l,columnHeaderMaxDepth:a}=t,d=o.get(e),c=r.get(e);A(d),A(c);const u=n.left+At(d+c/2,s,l-s);return{top:n.top+(a-1)*i,left:n.left+At(d+c/2,s,l-s),bottom:n.top+a*i,right:n.left+At(d+c/2,s,l-s)+1,width:1,height:i,x:u,y:n.top,toJSON:()=>{throw new Error("not implemented")}}}handleGotoRowSelectedRowNumberSubmit(){const{gotoRow:t}=this.state;this.focusRowInGrid(t)}focusRowInGrid(t){var i,o,r;const{model:e}=this.props,{rowCount:n}=e;if(this.setState({gotoRow:t}),t===""){this.setState({gotoRowError:""});return}const s=parseInt(t,10);s>n||s<-n?this.setState({gotoRowError:"Invalid row index"}):s===0?(this.setState({gotoRowError:""}),(i=this.grid)==null||i.setFocusRow(0)):s<0?(this.setState({gotoRowError:""}),(o=this.grid)==null||o.setFocusRow(s+n)):((r=this.grid)==null||r.setFocusRow(s-1),this.setState({gotoRowError:""}))}handleGotoRowSelectedRowNumberChanged(t){const e=t.target.value;this.focusRowInGrid(e)}getColumnTooltip(t,e,n){const{columnHeaderHeight:s,columnHeaderMaxDepth:i,visibleColumnXs:o,visibleColumnWidths:r,width:l}=e,a=o.get(t),d=r.get(t);if(a==null||d==null)return null;const c=Math.max(0,a);let u=d;a+d>l?u=l-a:a<0&&(u=d-Math.abs(a));const m={position:"absolute",top:(i-1)*s,left:c,width:u,height:s,pointerEvents:"none"},p={clientWidth:1,clientHeight:s,getBoundingClientRect:this.getColumnBoundingRect},g={placement:"bottom",modifiers:{flip:{behavior:["bottom","top"]}}},f=this.getModelColumn(t);if(f==null)return null;const b=n.columns[f];return b==null?null:h("div",{style:m,children:h(Ie,{timeout:400,interactive:!0,options:g,ref:this.handleTooltipRef,referenceObject:p,onExited:()=>{this.setState({shownColumnTooltip:null})},children:h(dp,{model:n,column:b,onStatistics:()=>{var C;(C=this.tooltip)==null||C.update()}})},b.name)})}render(){var ut,Si,hc,uc,mc,pc,gc,fc,Cc;const{children:t,customFilters:e,getDownloadWorker:n,isSelectingColumn:s,isStuckToBottom:i,isStuckToRight:o,model:r,name:l,onlyFetchVisibleColumns:a,alwaysFetchColumns:d,advancedSettings:c,onAdvancedSettingsChange:u,canDownloadCsv:m,onCreateChart:p}=this.props,{metricCalculator:g,metrics:f,isFilterBarShown:b,isSelectingPartition:C,isMenuShown:w,isReady:T,copyOperation:y,focusedFilterBarColumn:E,loadingText:I,loadingScrimProgress:R,loadingSpinnerShown:F,keyHandlers:x,mouseHandlers:U,shownColumnTooltip:$,hoverAdvancedFilter:O,shownAdvancedFilter:H,hoverSelectColumn:L,quickFilters:N,advancedFilters:_,partition:k,partitionFilters:V,partitionTable:W,partitionColumn:j,searchFilter:ee,selectDistinctColumns:ve,movedColumns:le,movedRows:Se,formatter:Le,conditionalFormats:J,conditionalFormatPreview:pe,conditionalFormatEditIndex:fe,sorts:xe,reverseType:ke,customColumns:hn,selectedRanges:Xn,isTableDownloading:Sn,tableDownloadStatus:Ct,tableDownloadProgress:Re,tableDownloadEstimatedTime:st,showSearchBar:it,searchValue:Mt,selectedSearchColumns:Yt,invertSearchColumns:Xt,aggregationSettings:Nt,selectedAggregation:On,rollupConfig:Ht,openOptions:wn,pendingSavePromise:Ps,pendingSaveError:zl,pendingRowCount:Wl,pendingDataErrors:Gl,pendingDataMap:Zo,toastMessage:Jo,frozenColumns:er,showOverflowModal:tr,overflowText:nr,overflowButtonTooltipProps:sr,isGotoRowShown:ir,gotoRow:Kl,gotoRowError:ql}=this.state;if(!T)return null;const Hs=this.getTheme(),Yl=this.getCachedFilter(e,N,_,V,ee),bi=g.getUserColumnWidths(),oo=this.getCachedStateOverride(L,b,s,R,N,_,xe,ke,Ht,w),or=f?f.top:0,rr=f?f.bottomViewport:0;let ro=null,lo=null;a&&(ro=f?f.left:0,lo=f?f.right:0);const Xl=f!=null&&f.width>0&&f.height>0,jl=((Si=(ut=Ht==null?void 0:Ht.columns)==null?void 0:ut.length)!=null?Si:0)>0;let lr=null;const Ql=f?Math.min(Math.max(ei.minDebounce,Math.round(f.rowCount/200)),ei.maxDebounce):ei.maxDebounce;if(b&&E!=null&&f!=null){const{gridX:je,gridY:jt,visibleColumnXs:Cs,visibleColumnWidths:ao}=f,Vs=Cs.get(E),Ln=ao.get(E);if(Vs!=null&&Ln!=null){const Qt=je+Vs,Vt=jt-((hc=Hs.filterBarHeight)!=null?hc:0),jn=Ln+1,Us=((uc=Hs.filterBarHeight)!=null?uc:0)-1,Bs={top:Vt,left:Qt,minWidth:jn,height:Us};let wi="",Qn=!0;const $s=this.getModelColumn(E);A($s);const zs=N.get($s),co=_.get($s);zs!=null&&(wi=zs.text,Qn=zs.filter!=null);const Ws=N.size!==0||_.size!==0;lr=h(ip,{ref:this.filterInputRef,style:Bs,className:z({error:!Qn,active:wi!==""||co!=null,"iris-grid-has-filter":Ws}),isAdvancedFilterSet:co!=null,onAdvancedFiltersTriggered:()=>{this.setState({shownAdvancedFilter:E})},onChange:this.handleFilterBarChange,onDone:this.handleFilterBarDone,onTab:this.handleFilterBarTab,onContextMenu:(mc=this.grid)==null?void 0:mc.handleContextMenu,debounceMs:Ql,value:wi},E)}}let ar=null;if(I!=null){const je=v("div",{className:"iris-grid-loading-status",children:[h("div",{className:z("iris-grid-loading-status-bar",{show:F}),children:I}),v("button",{type:"button",onClick:this.handleCancel,className:z("iris-grid-btn-cancel",{show:F}),children:[h(K,{icon:Yi,transform:"down-1"}),"Cancel"]})]}),jt=f?f.gridY:0;ar=h("div",{className:"iris-grid-loading",style:{top:jt},children:je})}let dr=null;$!=null&&f&&(dr=this.getColumnTooltip($,f,r),(pc=this.tooltip)==null||pc.update());const cr=[];if(f&&b){const{gridX:je,gridY:jt,visibleColumns:Cs,visibleColumnXs:ao,visibleColumnWidths:Vs}=f,{filterBarHeight:Ln}=Hs;for(let Qt=0;Qt<Cs.length;Qt+=1){const Vt=Cs[Qt],jn=ao.get(Vt),Us=Vs.get(Vt),Bs=this.getModelColumn(Vt);if(Bs!=null&&r.isFilterable(Bs)&&jn!=null&&Us!=null&&Us>0){const Qn=je+jn+Us-24,$s=jt-(Ln!=null?Ln:0)+2,zs={position:"absolute",top:$s,left:Qn},Ws=_.get(Bs)!=null,mr=Vt===O||Vt===E||Ws,ea=h("div",{className:z("advanced-filter-button-container",{hidden:!mr}),style:zs,children:mr&&h("button",{type:"button",className:z("btn btn-link btn-link-icon advanced-filter-button",{"filter-set":Ws}),onClick:()=>{this.setState({shownAdvancedFilter:Vt})},onContextMenu:Qp=>{var bc;(bc=this.grid)==null||bc.handleContextMenu(Qp)},onMouseEnter:()=>{this.setState({hoverAdvancedFilter:Vt})},onMouseLeave:()=>{this.setState({hoverAdvancedFilter:null})},children:v("div",{className:"fa-layers",children:[h(K,{icon:dd,className:"filter-solid"}),h(K,{icon:Wr,className:"filter-light"})]})})},Vt);cr.push(ea)}}}const hr=[];if(f){const{gridX:je,visibleColumns:jt,visibleColumnXs:Cs,visibleColumnWidths:ao,columnHeaderHeight:Vs}=f;for(let Ln=0;Ln<jt.length;Ln+=1){const Qt=jt[Ln],Vt=Cs.get(Qt),jn=ao.get(Qt);if(Vt!=null&&jn!=null&&jn>0){const Us=je+Vt,Bs=je+Vt+jn-20,wi=b?{position:"absolute",top:Vs,left:Bs,width:20,height:Hs.filterBarHeight}:{position:"absolute",top:0,left:Us,width:jn,height:Vs},Qn=this.getModelColumn(Qt);if(Qn!=null){const $s=r.columns[Qn],zs=_.get(Qn),{options:co}=zs||{},Ws=P.getSortForColumn(r.sort,Qn),mr=Ws?Ws.direction:null,ea=h("div",{className:"advanced-filter-menu-container",style:wi,children:h(xn,{className:"advanced-filter-menu-popper",onEntered:this.getAdvancedMenuOpenedHandler(Qt),onExited:()=>{this.handleAdvancedMenuClosed(Qt)},isShown:H===Qt,interactive:!0,closeOnBlur:!0,children:this.getCachedAdvancedFilterMenuActions(r,$s,co,mr,Le)})},Qt);hr.push(ea)}}}}const ur=this.getCachedOptionItems(p!==void 0&&r.isChartBuilderAvailable,r.isCustomColumnsAvailable,r.isFormatColumnsAvailable,r.isRollupAvailable,r.isTotalsAvailable,r.isSelectDistinctAvailable,r.isExportAvailable,this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,b,it,m,this.isTableSearchAvailable(),ir),Zl=wn.map(je=>{switch(je.type){case Oe.CHART_BUILDER:return h(qm,{model:r,onChange:this.handleChartChange,onSubmit:this.handleChartCreate},Oe.CHART_BUILDER);case Oe.VISIBILITY_ORDERING_BUILDER:return h(pi,{model:r,movedColumns:le,userColumnWidths:bi,onColumnVisibilityChanged:this.handleColumnVisibilityChanged,onMovedColumnsChanged:this.handleMovedColumnsChanged},Oe.VISIBILITY_ORDERING_BUILDER);case Oe.CONDITIONAL_FORMATTING:return h(dT,{rules:J,onChange:this.handleConditionalFormatsChange,onCreate:this.handleConditionalFormatCreate,onSelect:this.handleConditionalFormatEdit});case Oe.CONDITIONAL_FORMATTING_EDIT:return A(r.columns),A(this.handleConditionalFormatEditorUpdate),h(AT,{columns:r.columns,rule:pe,onUpdate:this.handleConditionalFormatEditorUpdate,onSave:this.handleConditionalFormatEditorSave,onCancel:this.handleConditionalFormatEditorCancel});case Oe.CUSTOM_COLUMN_BUILDER:return h(Hd,{model:r,customColumns:hn,onSave:this.handleUpdateCustomColumns,onCancel:this.handleMenuBack},Oe.CUSTOM_COLUMN_BUILDER);case Oe.ROLLUP_ROWS:return h(Vd,{model:r,onChange:this.handleRollupChange,config:Ht},Oe.ROLLUP_ROWS);case Oe.AGGREGATIONS:return h(E0,{settings:Nt,isRollup:jl,onChange:this.handleAggregationsChange,onEdit:this.handleAggregationEdit});case Oe.AGGREGATION_EDIT:return On&&h(I0,{aggregation:On,columns:r.originalColumns,onChange:this.handleAggregationChange});case Oe.TABLE_EXPORTER:return h(on,{model:r,name:l,isDownloading:Sn,tableDownloadStatus:Ct,tableDownloadProgress:Re,tableDownloadEstimatedTime:st!=null?st:void 0,onDownload:this.handleDownloadTable,onDownloadStart:this.handleDownloadTableStart,onCancel:this.handleCancelDownloadTable,selectedRanges:Xn},Oe.TABLE_EXPORTER);case Oe.SELECT_DISTINCT:return h(up,{model:r,selectDistinctColumns:ve,onChange:this.handleSelectDistinctChanged});case Oe.ADVANCED_SETTINGS:return h(zd,{items:c,onChange:u});default:throw Error(`Unexpected option type ${je.type}`)}}),Jl=this.getCachedHiddenColumns(se.getHiddenColumns(bi));return v("div",{className:"iris-grid",role:"presentation",children:[v("div",{className:"iris-grid-column",children:[t!=null&&h("div",{className:"iris-grid-bar",children:t}),h(ht,{in:C,timeout:Tt.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"iris-grid-partition-selector-wrapper iris-grid-bar iris-grid-bar-primary",children:W&&j&&h(hp,{table:W,getFormattedString:(je,jt,Cs)=>r.displayString(je,jt,Cs),columnName:j.name,partition:k,onChange:this.handlePartitionChange,onFetchAll:this.handlePartitionFetchAll,onAppend:this.handlePartitionAppend,onDone:this.handlePartitionDone})})}),h(ht,{in:it,timeout:Tt.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"iris-grid-bar",children:h(Rr,{value:Mt,selectedColumns:Yt,invertSelection:Xt,onChange:this.handleCrossColumnSearch,columns:r.columns,ref:this.crossColumnRef})})}),v("div",{className:"grid-wrapper",ref:je=>{this.gridWrapper=je},children:[h(Ji,{ref:je=>{this.grid=je},isStickyBottom:!Ze(r)||!r.isEditable,isStuckToBottom:i,isStuckToRight:o,metricCalculator:g,model:r,keyHandlers:x,mouseHandlers:U,movedColumns:le,movedRows:Se,onError:this.handleGridError,onViewChanged:this.handleViewChanged,onSelectionChanged:this.handleSelectionChanged,onMovedColumnsChanged:this.handleMovedColumnsChanged,renderer:this.renderer,stateOverride:oo,theme:Hs}),h(PT,{isOpen:tr,text:nr,onClose:this.handleOverflowClose}),Xl&&h(lp,{model:r,modelColumns:r.columns,top:or,bottom:rr,left:ro,right:lo,filter:Yl,formatter:Le,sorts:xe,reverseType:ke,movedColumns:le,customColumns:hn,hiddenColumns:Jl,alwaysFetchColumns:this.getAlwaysFetchColumns(d,r.columns,le,r.floatingLeftColumnCount,r.floatingRightColumnCount,(fc=(gc=this.grid)==null?void 0:gc.state.draggingColumn)==null?void 0:fc.range),formatColumns:this.getCachedPreviewFormatColumns(this.getCachedModelColumns(r,hn),J,pe,((Cc=wn[wn.length-1])==null?void 0:Cc.type)===Oe.CONDITIONAL_FORMATTING_EDIT&&fe!=null?fe:void 0),rollupConfig:this.getModelRollupConfig(r.originalColumns,Ht,Nt),totalsConfig:this.getModelTotalsConfig(r.columns,Ht,Nt),selectDistinctColumns:ve,pendingRowCount:Wl,pendingDataMap:Zo,frozenColumns:er}),!w&&h("div",{className:"grid-settings-button",children:h("button",{type:"button","data-testid":`btn-iris-grid-settings-button-${l}`,className:"btn btn-link btn-link-icon",onClick:this.handleMenu,children:h(K,{icon:Ff,transform:"up-1"})})}),lr,ar,cr,dr,hr,sr&&this.getOverflowButtonTooltip(sr)]}),h(VT,{model:r,isShown:ir,gotoRow:Kl,gotoRowError:ql,onSubmit:this.handleGotoRowSelectedRowNumberSubmit,onGotoRowNumberChanged:this.handleGotoRowSelectedRowNumberChanged,onClose:this.handleGotoRowClosed,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:()=>{this.handleAnimationStart(),this.focus()},onExited:this.handleAnimationEnd}),h(Av,{error:zl,isSaving:Ps!=null,saveTooltip:`Commit (${this.commitAction.shortcut.getDisplayText()})`,discardTooltip:`Discard (${this.discardAction.shortcut.getDisplayText()})`,pendingDataErrors:Gl,pendingDataMap:Zo,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,onSave:this.handlePendingCommitClicked,onDiscard:this.handlePendingDiscardClicked}),h(Qv,{children:Jo}),h(to,{model:r,copyOperation:y!=null?y:void 0,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd}),h(eo,{ref:je=>{this.tableSaver=je},getDownloadWorker:n,onDownloadCompleted:this.handleDownloadCompleted,onDownloadCanceled:this.handleDownloadCanceled,onDownloadProgressUpdate:this.handleDownloadProgressUpdate,isDownloading:Ct===on.DOWNLOAD_STATUS.DOWNLOADING,formatter:Le})]}),h(ht,{in:w,timeout:Tt.transitionMidMs,classNames:"slide-left",onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"table-sidebar",children:v(_C,{children:[h(Uc,{title:"Table Options",onClose:this.handleMenuClose,children:h(Hu,{onSelect:je=>this.handleMenuSelect(ur[je]),items:ur})}),Zl.map((je,jt)=>h(Uc,{title:wn[jt].title,onBack:this.handleMenuBack,onClose:this.handleMenuClose,children:je},wn[jt].type))]})})}),h(oe,{actions:this.contextActions})]})}};let no=ei;no.minDebounce=150;no.maxDebounce=500;no.loadingSpinnerDelay=800;no.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:P.REVERSE_TYPE.NONE,customColumns:[],aggregationSettings:gp,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:us.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:ap,canToggleSearch:!0};class zT extends Error{constructor(e,n){super(`${n} can't be empty (on pending row ${e+1})`),this.isMissingKey=!0,this.rowIndex=e,this.columnName=n}}const WT=X.module("ColumnHeaderGroup");function Nh(t){return t instanceof fp}class fp{constructor({name:e,children:n,color:s,depth:i,childIndexes:o}){this.getVisibleRange=he(r=>{const l=this.childIndexes.flat(),a=G.getVisibleIndexes(l,r),d=Math.min(...a),c=Math.max(...a);return c-d!==l.length-1&&WT.warn(`Column header group ${this.name} is not contiguous`),[d,c]}),this.name=e,this.children=n,this.color=s,this.depth=i,this.childIndexes=o}}const et=X.module("IrisGridTableModel"),GT=150,KT=0;function ri(t){return t.table!==void 0}const Ba=class extends be{constructor(t,e=new cn,n=null){super(),this.pendingNewRowCount=0,this.columnHeaderGroupMap=new Map,this.columnHeaderParentMap=new Map,this._columnHeaderMaxDepth=null,this._columnHeaderGroups=[],this.getMemoizedColumnMap=he(s=>{const i=new Map;return s.forEach(o=>i.set(o.name,o)),i}),this.getColumnIndicesByNameMap=he(s=>{const i=new Map;return s.forEach(({name:o},r)=>i.set(o,r)),i}),this.setViewport=hs((s,i,o)=>{if(i<s){et.error("Invalid viewport",s,i);return}const{viewport:r}=this;if(r!=null&&r.top===s&&r.bottom===i&&r.columns===o){et.debug2("Ignoring duplicate viewport",r);return}this.viewport={top:s,bottom:i,columns:o},et.debug2("setViewport",this.viewport),this.applyViewport()},GT),this.applyViewport=hs(()=>{if(!this.viewport)return;et.debug2("applyViewport",this.viewport);const{top:s,bottom:i,columns:o}=this.viewport,[r,l]=this.getCachedViewportRowRange(s,i);this.applyBufferedViewport(r,l,o)},KT,{leading:!1}),this.getCachedFormattedString=rn((s,i,o,r,l)=>s.getFormattedString(i,o,r,l),{max:1e4}),this.getCachedCustomColumnFormatFlag=rn(cs.isCustomColumnFormatDefined,{max:1e4}),this.getCachedViewportRowRange=he((s,i)=>{const o=i-s,r=Math.max(0,s-o*Ba.ROW_BUFFER_PAGES),l=i+o*Ba.ROW_BUFFER_PAGES;return[r,l]}),this.getCachedPendingErrors=he((s,i,o)=>{const r=new Map;return s.forEach((l,a)=>{var c;const{data:d}=l;for(let u=0;u<o;u+=1)d.has(u)||(r.has(a)||r.set(a,[]),(c=r.get(a))==null||c.push(new zT(a,i[u].name)))}),r}),this.handleTableDisconnect=this.handleTableDisconnect.bind(this),this.handleTableReconnect=this.handleTableReconnect.bind(this),this.handleTableUpdate=this.handleTableUpdate.bind(this),this.handleTotalsUpdate=this.handleTotalsUpdate.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.handleCustomColumnsChanged=this.handleCustomColumnsChanged.bind(this),this.irisFormatter=e,this.inputTable=n,this.subscription=null,this.table=t,this.viewport=null,this.viewportData=null,this.formattedStringData=[],this.pendingStringData=[],this.isSaveInProgress=!1,this.totalsTable=null,this.totalsTablePromise=null,this.totals=null,this.totalsDataMap=null,this.pendingNewDataMap=new Map,this.pendingNewDataErrors=null,this.pendingNewRowCount=0}export(){throw new Error("Method not implemented.")}columnStatistics(t){throw new Error("Method not implemented.")}get customColumns(){return[]}set customColumns(t){throw new Error("Method not implemented.")}get formatColumns(){return[]}set formatColumns(t){throw new Error("Method not implemented.")}updateFrozenColumns(t){throw new Error("Method not implemented.")}get rollupConfig(){throw new Error("Method not implemented.")}set rollupConfig(t){throw new Error("Method not implemented.")}get selectDistinctColumns(){throw new Error("Method not implemented.")}set selectDistinctColumns(t){throw new Error("Method not implemented.")}get columns(){return this.table.columns}close(){this.table.close(),this.totalsTable!==null&&this.totalsTable.close(),this.totalsTablePromise!==null&&this.totalsTablePromise.cancel()}startListening(){super.startListening(),this.table.addEventListener(M.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.addEventListener(M.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.addEventListener(M.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.addEventListener(M.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.addEventListener(M.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable),this.applyViewport()}stopListening(){super.stopListening(),this.table.removeEventListener(M.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.removeEventListener(M.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.removeEventListener(M.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.removeEventListener(M.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.removeEventListener(M.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.removeTotalsListeners(this.totalsTable),this.closeSubscription()}addTotalsListeners(t){t.addEventListener(M.Table.EVENT_UPDATED,this.handleTotalsUpdate),t.setViewport(0,0)}removeTotalsListeners(t){t.removeEventListener(M.Table.EVENT_UPDATED,this.handleTotalsUpdate)}handleTableDisconnect(){this.dispatchEvent(new Ge(be.EVENT.DISCONNECT))}handleTableReconnect(){this.dispatchEvent(new Ge(be.EVENT.RECONNECT))}handleTableUpdate(t){this.copyViewportData(t.detail),this.dispatchEvent(new Ge(be.EVENT.UPDATED))}handleTotalsUpdate(t){this.copyTotalsData(t.detail),this.dispatchEvent(new Ge(be.EVENT.UPDATED))}handleRequestFailed(t){this.dispatchEvent(new Ge(be.EVENT.REQUEST_FAILED,t))}handleCustomColumnsChanged(){this.dispatchEvent(new Ge(be.EVENT.COLUMNS_CHANGED,{detail:this.columns}))}get rowCount(){var t,e,n;return this.table.size+this.pendingNewRowCount+((n=(e=(t=this.totals)==null?void 0:t.operationOrder)==null?void 0:e.length)!=null?n:0)}get pendingDataErrors(){var t,e;return this.getCachedPendingErrors(this.pendingNewDataMap,this.columns,(e=(t=this.inputTable)==null?void 0:t.keyColumns.length)!=null?e:0)}get pendingDataMap(){return this.pendingNewDataMap}set pendingDataMap(t){t!==this.pendingNewDataMap&&(t.forEach((e,n)=>{if(!se.isValidIndex(n))throw new Error(`Invalid rowIndex ${n}`);const{data:s}=e;s.forEach((i,o)=>{if(!se.isValidIndex(o))throw new Error(`Invalid columnIndex ${o}`)})}),this.pendingNewDataMap=t,this.pendingNewRowCount=Math.max(this.pendingNewRowCount,this.maxPendingDataRow),this.formattedStringData=[],this.dispatchEvent(new Ge(be.EVENT.PENDING_DATA_UPDATED)))}get pendingRowCount(){return this.pendingNewRowCount}set pendingRowCount(t){t!==this.pendingNewRowCount&&(this.pendingNewRowCount=Math.max(0,t,this.maxPendingDataRow),this.dispatchEvent(new Ge(be.EVENT.UPDATED)))}get maxPendingDataRow(){return this.pendingNewDataMap.size>0?Math.max(...this.pendingNewDataMap.keys())+1:0}get columnCount(){return this.columns.length}get floatingBottomRowCount(){var t,e,n;return this.totals!=null&&this.totals.showOnTop?0:(n=(e=(t=this.totals)==null?void 0:t.operationOrder)==null?void 0:e.length)!=null?n:0}get floatingTopRowCount(){var t,e,n;return this.totals!=null&&this.totals.showOnTop&&(n=(e=(t=this.totals)==null?void 0:t.operationOrder)==null?void 0:e.length)!=null?n:0}get isChartBuilderAvailable(){return!0}get isTotalsAvailable(){return this.table.getTotalsTable!=null}get isEditable(){return!this.isSaveInProgress&&this.inputTable!=null}cacheFormattedValue(t,e,n){this.formattedStringData[t]==null&&(this.formattedStringData[t]=[]),this.formattedStringData[t][e]=n}cachePendingValue(t,e,n){this.pendingStringData[t]==null&&(this.pendingStringData[t]=[]),this.pendingStringData[t][e]=n}clearPendingValue(t,e){const n=this.pendingStringData[t];n!=null&&delete n[e]}textValueForCell(t,e){var n,s,i;if(((n=this.pendingStringData[t])==null?void 0:n[e])!==void 0)return this.pendingStringData[t][e];if(((s=this.formattedStringData[t])==null?void 0:s[e])===void 0){const o=this.valueForCell(t,e);if(o==null)return null;const r=(i=this.totalsColumn(t,e))!=null?i:this.columns[t],l=this.getCachedCustomColumnFormatFlag(this.formatter,r.name,r.type);let a;if(!l){const c=this.formatForCell(t,e);(c==null?void 0:c.formatString)!=null&&(a=c)}const d=this.displayString(o,r.type,r.name,a);this.cacheFormattedValue(t,e,d)}return this.formattedStringData[t][e]}textForCell(t,e){const n=this.textValueForCell(t,e);if(n==null&&this.isKeyColumn(t)){const s=this.pendingRow(e);if(s!=null&&this.pendingDataMap.has(s))return"*"}return n!=null?n:""}truncationCharForCell(t){const e=this.columns[t],{type:n}=e;if(P.isNumberType(n)&&this.formatter.truncateNumbersWithPound)return"#"}colorForCell(t,e,n){var i;const s=this.dataForCell(t,e);if(s){const{format:o,value:r}=s;if(r==null||r==="")return A(n.nullStringColor),n.nullStringColor;if(o&&o.color)return o.color;if(this.isPendingRow(e))return A(n.pendingTextColor),n.pendingTextColor;if(r!=null){const l=(i=this.totalsColumn(t,e))!=null?i:this.columns[t];if(P.isDateType(l.type)||l.name==="Date")return A(n.dateColor),n.dateColor;if(P.isNumberType(l.type))return r>0?(A(n.positiveNumberColor),n.positiveNumberColor):r<0?(A(n.negativeNumberColor),n.negativeNumberColor):(A(n.zeroNumberColor),n.zeroNumberColor)}}else if(this.isPendingRow(e)&&this.isKeyColumn(t))return A(n.errorTextColor),n.errorTextColor;return n.textColor}backgroundColorForCell(t,e){var n,s;return(s=(n=this.formatForCell(t,e))==null?void 0:n.backgroundColor)!=null?s:null}textAlignForCell(t){const e=this.columns[t],{type:n}=e;return P.isNumberType(n)?"right":P.isDateType(n)||e.name==="Date"?"center":"left"}textForColumnHeader(t,e=0){var n,s;return(s=(n=this.columnAtDepth(t,e))==null?void 0:n.name)!=null?s:void 0}colorForColumnHeader(t,e=0){var s;const n=this.columnAtDepth(t,e);return Nh(n)&&(s=n.color)!=null?s:null}getColumnHeaderGroup(t,e){const n=this.columnAtDepth(t,e);if(Nh(n))return n}getColumnHeaderParentGroup(t,e){var n,s;return this.columnHeaderParentMap.get((s=(n=this.columnAtDepth(t,e))==null?void 0:n.name)!=null?s:"")}columnAtDepth(t,e=0){var o;if(e===0)return this.columns[t];const n=(o=this.columns[t])==null?void 0:o.name;let s=this.columnHeaderParentMap.get(n);if(!s)return;let i=s.depth;for(;i<e;){if(s=this.columnHeaderParentMap.get(s.name),!s)return;i=s.depth}if(s.depth===e)return s}textForRowFooter(t){const e=this.totalsRow(t);return e!=null&&this.totals?this.totals.operationOrder[e]:""}get movedColumns(){var i;let t=[];const e=(o,r)=>{const l=this.getColumnIndexByName(o);if(l==null)throw new Error(`Unknown layout hint column: ${o}`);const a=G.getVisibleIndex(l,t);t=G.moveItem(a,r,t)},n=(o,r)=>{const l=this.columnHeaderGroupMap.get(o);if(!l)throw new Error(`Unknown layout hint group: ${o}`);const a=l.getVisibleRange(t);t=G.moveRange(a,r,t)};if(this.frontColumns.length||this.backColumns.length||this.frozenColumns.length){const o=new Set;let r=0;this.frozenColumns.forEach(a=>{if(o.has(a))throw new Error(`Column specified in multiple layout hints: ${a}`);e(a,r),r+=1}),this.frontColumns.forEach(a=>{if(o.has(a))throw new Error(`Column specified in multiple layout hints: ${a}`);e(a,r),r+=1});let l=this.columnMap.size-1;this.backColumns.forEach(a=>{if(o.has(a))throw new Error(`Column specified in multiple layout hints: ${a}`);e(a,l),l-=1})}const s=(i=this.layoutHints)==null?void 0:i.columnGroups;if(s){this.setColumnHeaderGroups(s);const o=[...this.columnHeaderGroupMap.values()];o.sort((r,l)=>r.depth-l.depth),o.forEach(r=>{const l=r.children[0],a=this.getColumnIndexByName(l);let d;if(a!=null)d=G.getVisibleIndex(a,t);else{const c=this.columnHeaderGroupMap.get(l);if(!c)throw new Error(`Unknown column ${l} in group ${r.name}`);[,d]=c.getVisibleRange(t)}for(let c=1;c<r.children.length;c+=1){const u=r.children[c],m=this.columnHeaderGroupMap.get(u),p=this.getColumnIndexByName(u);if(m){const f=m.getVisibleRange(t)[0]<d?d-m.childIndexes.length+1:d+1;n(u,f),d=f+m.childIndexes.length-1}else if(p!=null){const f=G.getVisibleIndex(p,t)<d?d:d+1;e(u,f),d=f}}})}return t}get columnMap(){return this.getMemoizedColumnMap(this.table.columns)}get columnHeaderMaxDepth(){var t,e;return this._columnHeaderMaxDepth==null&&this.setColumnHeaderGroups((t=this.layoutHints)==null?void 0:t.columnGroups),(e=this._columnHeaderMaxDepth)!=null?e:1}set columnHeaderMaxDepth(t){this._columnHeaderMaxDepth=t}setColumnHeaderGroups(t){if(t===this._columnHeaderGroups||(this._columnHeaderGroups=t!=null?t:[],this.columnHeaderMaxDepth=1,this.columnHeaderParentMap=new Map,this.columnHeaderGroupMap=new Map,!t||t.length===0))return;const e=new Map(t.map(o=>[o.name,o])),n=new Set,s=o=>{const{name:r}=o;if(this.getColumnIndexByName(r)!=null)throw new Error(`Column header group has same name as column: ${r}`);const l=this.columnHeaderGroupMap.get(r);if(l)return l;const a=[];let d=1;o.children.forEach(u=>{if(n.has(u))throw new Error(`Column group child ${u} specified in multiple groups`);n.add(u);const m=e.get(u),p=this.getColumnIndexByName(u);if(m){const g=s(m);a.push(g.childIndexes.flat()),d=Math.max(d,g.depth+1)}else if(p!=null)a.push(p),d=Math.max(d,1);else throw new Error(`Unknown child ${u} in group ${r}`)});const c=new fp({...o,depth:d,childIndexes:a});return this.columnHeaderGroupMap.set(r,c),o.children.forEach(u=>this.columnHeaderParentMap.set(u,c)),this.columnHeaderMaxDepth=Math.max(this.columnHeaderMaxDepth,c.depth+1),c},i=new Set;t.forEach(o=>{const{name:r}=o;if(i.has(r))throw new Error(`Duplicate column group name: ${r}`);i.add(r),s(o)})}get groupedColumns(){return[]}row(t){var l,a,d,c,u,m,p,g,f,b,C,w,T,y;const e=(d=(a=(l=this.totals)==null?void 0:l.operationOrder)==null?void 0:a.length)!=null?d:0,n=(u=(c=this.totals)==null?void 0:c.showOnTop)!=null?u:!1,s=this.totalsRow(t);if(s!=null){const E=(m=this.totals)==null?void 0:m.operationOrder[s];return A(E),(g=(p=this.totalsDataMap)==null?void 0:p.get(E))!=null?g:null}const i=this.pendingRow(t);if(i!=null)return(f=this.pendingNewDataMap.get(i))!=null?f:null;const o=(C=(b=this.viewportData)==null?void 0:b.offset)!=null?C:0,r=(n?t-e:t)-o;return(y=(T=(w=this.viewportData)==null?void 0:w.rows)==null?void 0:T[r])!=null?y:null}totalsColumn(t,e){var r,l,a,d;const n=this.totalsRow(e);if(n==null)return null;const s=(r=this.totals)==null?void 0:r.operationOrder[n],i=(a=(l=this.totals)==null?void 0:l.defaultOperation)!=null?a:Ae.SUM,o=this.columns[t];return(d=this.totalsTable)==null?void 0:d.columns.find(c=>{var u;return c.name===`${o.name}__${s}`||(s===i||((u=this.totals)==null?void 0:u.operationOrder.length)===1)&&c.name===o.name})}totalsRow(t){var i,o,r,l,a;const e=(r=(o=(i=this.totals)==null?void 0:i.operationOrder)==null?void 0:o.length)!=null?r:0,s=((a=(l=this.totals)==null?void 0:l.showOnTop)!=null?a:!1)?t:t-this.table.size;return s>=0&&s<e?s:null}pendingRow(t){const e=t-this.floatingTopRowCount-this.table.size;return e>=0&&e<this.pendingNewRowCount?e:null}isTotalsRow(t){return this.totalsRow(t)!=null}isPendingRow(t){return this.pendingRow(t)!=null}dataForCell(t,e){var n;return(n=this.row(e))==null?void 0:n.data.get(t)}formatForCell(t,e){var n;return(n=this.dataForCell(t,e))==null?void 0:n.format}valueForCell(t,e){var s;const n=this.dataForCell(t,e);if(n)return(s=n.value)!=null?s:null}copyViewportData(t){if(t==null){et.warn("invalid data!");return}this.viewportData=this.extractViewportData(t),this.formattedStringData=[]}copyTotalsData(t){var l,a,d,c,u;if(t==null){et.warn("invalid data!");return}const{columns:e,rows:n}=t;if(n.length!==1){et.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:Ae.SUM,r=(d=this.totals)==null?void 0:d.operationMap;for(let m=0;m<e.length;m+=1){const p=e[m],[g,f=(u=(c=r==null?void 0:r[g])==null?void 0:c[0])!=null?u:o]=p.name.split("__");s.has(f)||s.set(f,{data:new Map});const{data:b}=s.get(f),C=this.columns.findIndex(w=>w.name===g);b.set(C,{value:i.get(p),format:i.getFormat(p)})}et.debug2("copyTotalsData",s),this.totalsDataMap=s,this.formattedStringData=[]}getColumnIndexByName(t){return this.getColumnIndicesByNameMap(this.columns).get(t)}extractViewportData(t){const e={offset:t.offset,rows:[]},{columns:n}=t;for(let s=0;s<t.rows.length;s+=1){const i=t.rows[s],o=this.extractViewportRow(i,n);e.rows.push(o)}return e}extractViewportRow(t,e){const n=new Map;for(let s=0;s<e.length;s+=1){const i=e[s],o=this.getColumnIndexByName(i.name);A(o),n.set(o,{value:t.get(i),format:t.getFormat(i)})}return{data:n}}closeSubscription(){et.debug2("closeSubscription",this.subscription),this.subscription&&(this.subscription.close(),this.subscription=null),this.setViewport.cancel(),this.applyViewport.cancel()}get filter(){return this.table.filter}set filter(t){this.closeSubscription(),this.table.applyFilter(t),this.applyViewport()}get formatter(){return this.irisFormatter}set formatter(t){this.irisFormatter=t,this.formattedStringData=[],this.dispatchEvent(new Ge(be.EVENT.FORMATTER_UPDATED))}displayString(t,e,n="",s){return this.getCachedFormattedString(this.formatter,t,e,n,s)}get sort(){return this.table.sort}set sort(t){this.closeSubscription(),this.table.applySort(t),this.applyViewport()}set totalsConfig(t){if(et.debug("set totalsConfig",t),t!==this.totals){if(this.totals=t,this.formattedStringData=[],this.totalsTablePromise!=null&&this.totalsTablePromise.cancel(),this.setTotalsTable(null),t==null){this.dispatchEvent(new Ge(be.EVENT.UPDATED));return}this.totalsTablePromise=Ee.makeCancelable(this.table.getTotalsTable(t),e=>e.close()),this.totalsTablePromise.then(e=>{this.totalsTablePromise=null,this.setTotalsTable(e)}).catch(e=>{Ee.isCanceled(e)||(et.error("Unable to set next totalsTable",e),this.totalsTablePromise=null,this.dispatchEvent(new Ge(be.EVENT.REQUEST_FAILED,{detail:e})))})}}setTotalsTable(t){et.debug("setTotalsTable",t),this.totalsTable!==null&&(this.listenerCount>0&&this.removeTotalsListeners(this.totalsTable),this.totalsTable.close()),this.totalsTable=t,this.totalsDataMap=null,this.listenerCount>0&&this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable)}applyBufferedViewport(t,e,n){et.debug2("applyBufferedViewport",t,e,n),this.subscription==null?(et.debug2("applyBufferedViewport creating new subscription"),this.subscription=this.table.setViewport(t,e,n)):(et.debug2("applyBufferedViewport using existing subscription"),this.subscription.setViewport(t,e,n))}async snapshot(t,e=!1,n=s=>s){if(this.subscription==null)throw new Error("No subscription available");const s=re.consolidate(t);if(!se.isValidSnapshotRanges(s))throw new Error(`Invalid snapshot ranges ${t}`);const i=new Set,o=[],r=new Set;for(let u=0;u<s.length;u+=1){const m=s[u];A(m.endRow),A(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 re(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=se.columnsFromRanges(s,this.columns),a=[];e&&a.push(l.map(u=>u.name));const d=[...i].sort();for(let u=0;u<d.length;u+=1){const m=d[u],p=l.map(g=>{const f=this.getColumnIndexByName(g.name);return A(f),n(this.valueForCell(f,m),g)});e&&p.push(this.textForRowFooter(m)),a.push(p)}if(o.length>0){const u=se.rangeSetFromRanges(o),m=await this.subscription.snapshot(u,l);a.push(...m.rows.map(p=>l.map(g=>n(p.get(g),g))))}const c=[...r].sort();for(let u=0;u<c.length;u+=1){const m=c[u],p=l.map(g=>{const f=this.getColumnIndexByName(g.name);return A(f),n(this.valueForCell(f,m),g)});e&&p.push(this.textForRowFooter(m)),a.push(p)}return a}async textSnapshot(t,e=!1,n=s=>`${s}`){return et.debug2("textSnapshot",t,e),(await this.snapshot(t,e,n)).map(i=>i.join(" ")).join(`
|
|
34
|
+
${lT(t)}`}const dT=t=>{const{rules:e=[],onChange:n=ua,onCreate:s=ua,onSelect:i=ua}=t,o=S.exports.useCallback((d,c,u)=>{d.stopPropagation(),Rh.debug("Rule clicked",c,u),i(u)},[i]),r=S.exports.useCallback((d,c,u)=>{d.stopPropagation(),Rh.debug("Delete button clicked",c,u);const m=[...e];m.splice(u,1),n(m)},[n,e]),l=S.exports.useCallback(d=>{d.stopPropagation()},[]),a=S.exports.useCallback(d=>{if(Gt.stopDragging(),d.destination==null)return;const c=d.source.index,u=d.destination.index,m=[...e],p=e[c];m.splice(c,1),m.splice(u,0,p),n(m)},[n,e]);return v("div",{className:"conditional-formatting-rules",children:[h(Vo,{onDragStart:Gt.startDragging,onDragEnd:a,children:h(Ho,{droppableId:"droppable-custom-columns",children:(d,c)=>v("div",{ref:d.innerRef,...d.droppableProps,className:z("droppable-container",{dragging:c.draggingFromThisWith}),children:[e.length===0&&h("div",{className:"text-muted pl-2",children:"No formats defined"}),e.map((u,m)=>h(dl,{draggableId:`${m}-${u.type}`,index:m,disableInteractiveElementBlocking:!0,children:(p,g)=>h("div",{role:"menuitem",tabIndex:0,onClick:f=>o(f,u,m),className:z("draggable-container",{dragging:g.isDragging}),ref:p.innerRef,...p.draggableProps,children:h("div",{className:"conditional-formatting-list-item",children:v("div",{className:"formatting-item",children:[h("div",{className:"rule-icon",children:h("span",{className:"rule-icon-bg",style:{backgroundColor:el(u.config.style),color:tl(u.config.style)},children:u.type===Kn.ROWS?"row":"col"})}),h("div",{className:"rule-title",children:aT(u.config)}),v("button",{type:"button",className:"btn btn-link btn-link-icon ml-1 px-2",onClick:f=>r(f,u,m),children:[h(Ie,{children:"Delete rule"}),h(K,{icon:_n})]}),v("button",{type:"button",className:"btn btn-link btn-link-icon px-2 btn-drag-handle",onClick:l,...p.dragHandleProps,children:[h(Ie,{children:"Drag to re-order"}),h(K,{icon:ul})]})]})})})},`${m}-${u.type}`)),d.placeholder]})})}),h("hr",{}),h(Q,{kind:"ghost",onClick:s,icon:Ls,children:"Add New Rule"})]})},yi=X.module("ConditionEditor"),cT=()=>{},hT=[Ye.IS_EQUAL,Ye.IS_NOT_EQUAL,Ye.IS_BETWEEN,Ye.GREATER_THAN,Ye.GREATER_THAN_OR_EQUAL,Ye.LESS_THAN,Ye.LESS_THAN_OR_EQUAL,Ye.IS_NULL,Ye.IS_NOT_NULL].map(t=>h("option",{value:t,children:gv(t)},t)),uT=[sn.IS_EXACTLY,sn.IS_NOT_EXACTLY,sn.CONTAINS,sn.DOES_NOT_CONTAIN,sn.STARTS_WITH,sn.ENDS_WITH,sn.IS_NULL,sn.IS_NOT_NULL].map(t=>h("option",{value:t,children:fv(t)},t)),mT=[Lt.IS_EXACTLY,Lt.IS_NOT_EXACTLY,Lt.IS_BEFORE,Lt.IS_BEFORE_OR_EQUAL,Lt.IS_AFTER,Lt.IS_AFTER_OR_EQUAL,Lt.IS_NULL,Lt.IS_NOT_NULL].map(t=>h("option",{value:t,children:Cv(t)},t)),pT=[Ro.IS_TRUE,Ro.IS_FALSE,Ro.IS_NULL,Ro.IS_NOT_NULL].map(t=>h("option",{value:t,children:bv(t)},t)),gT=[oi.IS_EQUAL,oi.IS_NOT_EQUAL,oi.IS_NULL,oi.IS_NOT_NULL].map(t=>h("option",{value:t,children:Sv(t)},t));function fT(t,e,n,s){return t===Ye.IS_NULL||t===Ye.IS_NOT_NULL||t===Ye.IS_BETWEEN&&n!=null&&n!==""&&!Number.isNaN(Number.parseFloat(n))&&s!=null&&s!==""&&!Number.isNaN(Number.parseFloat(s))||t!==Ye.IS_BETWEEN&&e!==void 0&&e!==""&&!Number.isNaN(Number.parseFloat(e))}function CT(t,e,n,s,i,o,r){switch(t){case Ye.IS_EQUAL:case Ye.IS_NOT_EQUAL:case Ye.GREATER_THAN:case Ye.GREATER_THAN_OR_EQUAL:case Ye.LESS_THAN:case Ye.LESS_THAN_OR_EQUAL:return h("input",{type:"number",className:"form-control",placeholder:"Enter value",value:i!=null?i:"",onChange:e});case Ye.IS_BETWEEN:return v("div",{className:"d-flex flex-row",children:[h("input",{type:"number",className:"form-control d-flex mr-2",placeholder:"Start value",value:o!=null?o:"",onChange:n}),h("input",{type:"number",className:"form-control d-flex",placeholder:"End value",value:r!=null?r:"",onChange:s})]});case Ye.IS_NULL:case Ye.IS_NOT_NULL:return null}}function bT(t,e,n){switch(t){case sn.IS_NULL:case sn.IS_NOT_NULL:return null;default:return h("input",{type:"text",className:"form-control",placeholder:"Enter value",value:n!=null?n:"",onChange:e})}}function ST(t,e,n){switch(t){case Lt.IS_NULL:case Lt.IS_NOT_NULL:return null;default:return h("input",{type:"text",className:"form-control",placeholder:"Enter value",value:n!=null?n:"",onChange:e})}}function wT(){return null}function vT(t,e,n){switch(t){case oi.IS_NULL:case oi.IS_NOT_NULL:return null;default:return h("input",{type:"text",className:"form-control",maxLength:1,placeholder:"Enter value",value:n!=null?n:"",onChange:e})}}const mp=t=>{const{column:e,config:n,onChange:s=cT}=t,i=e.type,[o,r]=S.exports.useState(i),[l,a]=S.exports.useState(n.condition),[d,c]=S.exports.useState(n.value),[u,m]=S.exports.useState(n.start),[p,g]=S.exports.useState(n.end);i!==o&&(a(tp(i)),c(void 0),m(void 0),g(void 0),r(i));const f=S.exports.useMemo(()=>{if(i===void 0)return[];if(P.isNumberType(i))return hT;if(P.isCharType(i))return gT;if(P.isStringType(i))return uT;if(P.isDateType(i))return mT;if(P.isBooleanType(i))return pT},[i]),b=S.exports.useCallback(E=>{const{value:I}=E.target;yi.debug("handleConditionChange",I),a(I)},[]),C=S.exports.useCallback(E=>{const{value:I}=E.target;yi.debug("handleValueChange",I),c(I)},[]),w=S.exports.useCallback(E=>{const{value:I}=E.target;yi.debug("handleStartValueChange",I),m(I)},[]),T=S.exports.useCallback(E=>{const{value:I}=E.target;yi.debug("handleEndValueChange",I),g(I)},[]);S.exports.useEffect(function(){let I=!0;l===void 0&&(yi.debug("Unable to create formatting rule. Condition is not selected."),I=!1),P.isNumberType(e.type)&&!fT(l,d,u,p)&&(yi.debug("Unable to create formatting rule. Invalid value",d),I=!1),s({condition:l,value:d,start:u,end:p},I)},[s,e.type,l,d,u,p]);const y=S.exports.useMemo(()=>{if(i===void 0)return null;if(P.isNumberType(i))return CT(l,C,w,T,d,u,p);if(P.isCharType(i))return vT(l,C,d);if(P.isStringType(i))return bT(l,C,d);if(P.isDateType(i))return ST(l,C,d);if(P.isBooleanType(i))return wT()},[i,l,d,u,p,C,w,T]);return v("div",{className:"condition-editor mb-2",children:[h("select",{value:l,id:"condition-select",className:"custom-select mb-2",onChange:b,children:f}),y]})};const TT=X.module("StyleEditor"),ET="#fcfcfa",yT="#f0f0ee",IT="#1a171a",RT=200,DT=()=>{},pp=t=>{var T,y;const{config:e,onChange:n=DT}=t,[s,i]=S.exports.useState(e.type),[o,r]=S.exports.useState((y=(T=e.customConfig)==null?void 0:T.background)!=null?y:ET),[l,a]=S.exports.useState(!1),[d,c]=S.exports.useState(RT),u=S.exports.useRef(null),m=S.exports.useCallback(E=>{const{value:I}=E.target;TT.debug("handleBackgroundChange",I),r(I)},[]),p=S.exports.useCallback(()=>{l&&a(!1)},[l]),g=S.exports.useCallback(()=>{l||b(),a(!l)},[l]),f=S.exports.useMemo(()=>[Vn.NO_FORMATTING,Vn.POSITIVE,Vn.NEGATIVE,Vn.WARN,Vn.NEUTRAL,Vn.ACCENT_1,Vn.ACCENT_2,Vn.CUSTOM],[]);function b(){u.current&&c(u.current.getBoundingClientRect().width)}S.exports.useEffect(function(){n({type:s,customConfig:{color:pl.isDark(o)?yT:IT,background:o}})},[n,s,o]);const C=S.exports.useCallback(()=>{const E=[];for(let I=0;I<f.length;I+=1){const R=f[I],F=`option-${I}-${R}`;E.push(v(Q,{kind:"inline",className:"style-option-btn",onClick:()=>{i(R),a(!1)},style:{color:tl({type:R}),background:el({type:R})},children:[R===s&&h(K,{icon:ai,className:"mr-2"}),R!==s&&h("span",{className:"mr-4"}),Eh(R)]},F))}return E},[f,s]),w=S.exports.useCallback(()=>h("div",{className:"style-menu-container",role:"presentation",style:{width:d},children:h("div",{className:"style-options",children:C()})}),[d,C]);return v("div",{className:"style-editor",children:[v("div",{className:"mb-2",ref:u,children:[h("label",{className:"mb-0",children:"Style"}),v(Q,{kind:"inline",className:"cs-dropdown",style:{color:tl({type:s}),background:el({type:s})},onClick:g,children:[Eh(s),h("span",{children:h(K,{icon:md,className:"cs-caret"})}),h(Wn,{isShown:l,actions:{menuElement:w()},popperOptions:{placement:"bottom-start"},popperClassName:"style-dropdown-menu",onMenuClosed:p,menuStyle:{maxWidth:"100rem"}})]})]}),s===Vn.CUSTOM&&v("div",{className:"mb-2",children:[h("label",{className:"mb-0",children:"Background"}),h("input",{type:"color",value:o,className:"custom-select color-select",onChange:m})]})]})},go=X.module("ColumnFormatEditor"),MT=()=>{};function NT(t){const{type:e,name:n}=t[0];return{column:{type:e,name:n},style:sp(),...xl(e)}}const FT=t=>{var b;const{columns:e,config:n=NT(e),onChange:s=MT}=t,[i,o]=S.exports.useState((b=e.find(C=>C.name===n.column.name&&C.type===n.column.type))!=null?b:e[0]),[r,l]=S.exports.useState(np(n)),[a,d]=S.exports.useState(!1),[c,u]=S.exports.useState(n.style),m=S.exports.useCallback(C=>{const w=e.find(({name:T})=>T===C);w!==void 0?(o(w),i.type!==w.type&&(l(xl(w.type)),d(!1))):go.error(`Column ${C} not found.`)},[e,i]),p=S.exports.useCallback((C,w)=>{go.debug("handleConditionChange",C,w),l(C),d(w)},[]),g=S.exports.useCallback(C=>{go.debug("handleStyleChange",C),u(C)},[]);S.exports.useEffect(function(){if(i===void 0){go.debug("Column is not selected, skip update.");return}if(c===void 0){go.debug("Style is not selected, skip update.");return}const{type:w,name:T}=i;s({column:{type:w,name:T},style:c,...r},a)},[s,i,c,r,a]);const f=e.map(({name:C})=>({title:C,value:C}));return v("div",{className:"conditional-rule-editor form",children:[v("div",{className:"mb-2",children:[h("label",{className:"mb-0",children:"Format Cell If"}),h(ji,{defaultValue:i==null?void 0:i.name,options:f,inputPlaceholder:"Select a column",spellCheck:!1,onChange:m,searchPlaceholder:"Filter columns"})]}),i!==void 0&&v(ue,{children:[h(mp,{column:i,config:r,onChange:p}),h(pp,{config:c,onChange:g})]})]})},fo=X.module("RowFormatEditor"),xT=()=>{};function _T(t){const{type:e,name:n}=t[0];return{column:{type:e,name:n},style:sp(),...xl(e)}}const kT=t=>{var b;const{columns:e,config:n=_T(e),onChange:s=xT}=t,[i,o]=S.exports.useState((b=e.find(C=>C.name===n.column.name&&C.type===n.column.type))!=null?b:e[0]),[r,l]=S.exports.useState(np(n)),[a,d]=S.exports.useState(!1),[c,u]=S.exports.useState(n.style),m=S.exports.useCallback(C=>{const w=e.find(({name:T})=>T===C);w!==void 0?(o(w),i.type!==w.type&&(l(xl(w.type)),d(!1))):fo.error(`Column ${C} not found.`)},[e,i]),p=S.exports.useCallback((C,w)=>{fo.debug("handleConditionChange",C,w),l(C),d(w)},[]),g=S.exports.useCallback(C=>{fo.debug("handleStyleChange",C),u(C)},[]);S.exports.useEffect(function(){if(i===void 0){fo.debug("Column is not selected, skip update.");return}if(c===void 0){fo.debug("Style is not selected, skip update.");return}const{type:w,name:T}=i;s({column:{type:w,name:T},style:c,...r},a)},[s,i,c,r,a]);const f=e.map(({name:C})=>({title:C,value:C}));return v("div",{className:"conditional-rule-editor form",children:[v("div",{className:"mb-2",children:[h("label",{className:"mb-0",children:"Format Row If"}),h(ji,{defaultValue:i==null?void 0:i.name,options:f,inputPlaceholder:"Select a column",spellCheck:!1,onChange:m,searchPlaceholder:"Filter columns"})]}),i!==void 0&&v(ue,{children:[h(mp,{column:i,config:r,onChange:p}),h(pp,{config:c,onChange:g})]})]})};const ma=X.module("ConditionalFormatEditor"),pa=()=>{};function OT(t){switch(t){case Kn.CONDITIONAL:return h(x0,{});case Kn.ROWS:return h(_0,{})}}function LT(t){switch(t){case Kn.CONDITIONAL:return"Conditional";case Kn.ROWS:return"Rows"}}const Dh=[Kn.CONDITIONAL,Kn.ROWS],AT=t=>{var C;const{columns:e,onSave:n=pa,onUpdate:s=pa,onCancel:i=pa,rule:o}=t,r=e.filter(kv),[l,a]=S.exports.useState((C=o==null?void 0:o.type)!=null?C:Dh[0]),[d,c]=S.exports.useState(o),[u,m]=S.exports.useState(!1),p=S.exports.useCallback(()=>{i()},[i]),g=S.exports.useCallback(()=>{if(d===void 0){ma.error("Rule is not defined.");return}n(d)},[n,d]),f=S.exports.useCallback(w=>{ma.debug("handleFormatterChange",w),a(w)},[]),b=S.exports.useCallback((w,T)=>{ma.debug("handleRuleChange",w,T,l);const y={type:l,config:w};c(y),m(T),s(T?y:void 0)},[s,l]);return v("div",{className:"conditional-format-editor form",children:[v("div",{className:"mb-2",children:[h("label",{className:"mb-0",htmlFor:"formatter-select",children:"Select Formatter"}),h("div",{className:"formatter-list",children:Dh.map((w,T)=>h("div",{className:"formatter-type",children:v("button",{type:"button",className:z("btn","btn-icon","btn-formatter-type",{active:w===l}),"data-index":T,onClick:()=>f(w),children:[OT(w),LT(w)]})},w))})]}),l===Kn.CONDITIONAL&&h(FT,{columns:r,config:d==null?void 0:d.config,onChange:b}),l===Kn.ROWS&&h(kT,{columns:r,config:d==null?void 0:d.config,onChange:b}),h("hr",{}),v("div",{className:"d-flex justify-content-end my-3",children:[h(Q,{kind:"secondary",onClick:p,className:"mr-2",children:"Cancel"}),h(Q,{kind:"primary",onClick:g,disabled:d===void 0||!u,children:"Done"})]})]})};function PT({text:t,isOpen:e,onClose:n}){const[s,i]=S.exports.useState(!1),[o,r]=S.exports.useState(0),[l,a]=S.exports.useState(!1),[d,c]=S.exports.useState(!1),[u,m]=S.exports.useState(!1),p=S.exports.useRef(),g=S.exports.useRef(null),[f,b]=S.exports.useState(!1);S.exports.useEffect(function(){if(!!e){try{JSON.parse(t),m(!0)}catch{m(!1)}c(!1)}},[e,t]),S.exports.useEffect(function(){p.current&&p.current.layout()},[o]),S.exports.useEffect(function(){p.current&&p.current.updateOptions({lineNumbers:l?"on":"off"})},[l]),S.exports.useEffect(()=>(g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{b(!1)},1e3),()=>{g.current&&clearTimeout(g.current)}),[f]);function C(){var R,F;Ne.copyToClipboard((F=(R=p.current)==null?void 0:R.getValue())!=null?F:t).then(()=>{b(!0)})}function w(){a(!l)}function T(){var F;const R=(F=p.current)==null?void 0:F.getModel();!u||!R||(d?(R.setValue(t),c(!1)):(R.setValue(JSON.stringify(JSON.parse(t),void 0,2)),c(!0)),y())}function y(){var F,x;const R=p.current;!R||a(((x=(F=R.getModel())==null?void 0:F.getLineCount())!=null?x:0)>1)}function E(){s&&(p.current=void 0,n())}function I(R){p.current=R,R.onDidContentSizeChange(({contentHeight:F})=>r(F)),y()}return!e&&!s?null:v(Uo,{isOpen:e,centered:!0,keyboard:!0,toggle:E,onOpened:()=>i(!0),onClosed:()=>{i(!1),r(0)},className:"theme-bg-dark cell-overflow-modal",children:[v($o,{toggle:n,children:[h("h5",{className:"overflow-modal-title",children:"Cell Contents"}),h(Q,{kind:"inline",icon:f?ld:od,tooltip:f?"Copied contents":"Copy contents",onClick:C}),h(Q,{kind:"inline",active:l,icon:Df,tooltip:"Toggle line numbers",onClick:w}),u&&h(Q,{kind:"inline",icon:yf,active:d,tooltip:"Format as JSON",onClick:T})]}),h(Bo,{style:{height:o},children:h(Tl,{onEditorInitialized:I,settings:{value:t,readOnly:!0,wordWrap:"on",language:u?"typescript":"plaintext",folding:u,padding:{bottom:16},lineNumbers:l?"on":"off",overviewRulerLanes:0,renderLineHighlight:"none",find:{seedSearchStringFromSelection:"never"}}})})]})}const HT="###,##0",VT=({gotoRow:t,gotoRowError:e,onSubmit:n,isShown:s,onEntering:i,onEntered:o,onExiting:r,onExited:l,model:a,onGotoRowNumberChanged:d,onClose:c})=>{const u=S.exports.useRef(null),m="Row number",{rowCount:p}=a;return S.exports.useEffect(()=>{var g;document.activeElement!==u.current&&((g=u.current)==null||g.select())},[t]),h(_l,{isShown:s,className:z("goto-row"),onEntering:i,onEntered:()=>{var g;o(),(g=u.current)==null||g.select()},onExiting:r,onExited:l,children:v(ue,{children:[v("div",{className:"goto-row-wrapper",children:[h("div",{className:"goto-row-text",children:"Go to row"}),h("div",{className:"goto-row-input",children:h("input",{ref:u,type:"number",onKeyDown:g=>{g.key==="Enter"&&(g.stopPropagation(),g.preventDefault(),n())},className:z("form-control",{"is-invalid":e!==""}),placeholder:m,onChange:g=>{d(g)},value:t})}),v("div",{className:"goto-row-text",children:["of ",dh.i18n.NumberFormat.format(HT,p)]}),e&&h("div",{className:"goto-row-error text-danger",children:e})]}),h("div",{className:"goto-row-close",children:h(Q,{kind:"ghost",onClick:c,children:h(K,{icon:Yi,style:{marginRight:"0"}})})})]})})},Ce=X.module("IrisGrid"),UT=500,BT=250,$T=250,gp=Object.freeze({aggregations:[],showOnTop:!1});function Mh({advancedFilters:t,aggregationSettings:e,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}){return t.size===0&&e.aggregations.length===0&&n.length===0&&s.size===0&&i===P.REVERSE_TYPE.NONE&&o==null&&r==null&&l.length===0&&a.length===0}const ei=class extends S.exports.Component{constructor(t){super(t),this.getAdvancedMenuOpenedHandler=Te(N=>this.handleAdvancedMenuOpened.bind(this,N),{max:100}),this.getCachedAdvancedFilterMenuActions=Te((N,_,k,V,W)=>h($d,{model:N,column:_,onFilterChange:this.handleAdvancedFilterChange,onSortChange:this.handleAdvancedFilterSortChange,onDone:this.handleAdvancedFilterDone,options:k,sortDirection:V,formatter:W}),{max:50}),this.getCachedOptionItems=Te((N,_,k,V,W,j,ee,ve,le,Se,Le,J,pe,fe,xe)=>{const ke=[];return N&&ke.push({type:Oe.CHART_BUILDER,title:"Chart Builder",icon:jf}),ke.push({type:Oe.VISIBILITY_ORDERING_BUILDER,title:"Column Visibility & Ordering",icon:Ra}),k&&ke.push({type:Oe.CONDITIONAL_FORMATTING,title:"Conditional Formatting",icon:hl}),_&&ke.push({type:Oe.CUSTOM_COLUMN_BUILDER,title:"Manage Custom Columns",icon:Lf}),V&&ke.push({type:Oe.ROLLUP_ROWS,title:"Rollup Rows",icon:bu}),W&&ke.push({type:Oe.AGGREGATIONS,title:"Aggregate Columns",icon:Af}),j&&ke.push({type:Oe.SELECT_DISTINCT,title:"Select Distinct Values",icon:Of}),ee&&pe&&ke.push({type:Oe.TABLE_EXPORTER,title:"Download CSV",icon:Cf}),ke.push({type:Oe.ADVANCED_SETTINGS,title:"Advanced Settings",icon:Pf}),ke.push({type:Oe.QUICK_FILTERS,title:"Quick Filters",subtitle:ve.shortcut.getDisplayText(),icon:Wr,isOn:Le,onChange:ve.action}),fe&&ke.push({type:Oe.SEARCH_BAR,title:"Search Bar",subtitle:le.shortcut.getDisplayText(),icon:fu,isOn:J,onChange:le.action}),ke.push({type:Oe.GOTO,title:"Go to",subtitle:Se.shortcut.getDisplayText(),icon:kf,isOn:xe,onChange:Se.action}),ke},{max:1}),this.getCachedHiddenColumns=Te(N=>N,{max:1,normalizer:([N])=>N.join()}),this.getAggregationMap=Te((N,_)=>{const k={};return _.forEach(({operation:V,selected:W,invert:j})=>{k[V]=ks.getOperationColumnNames(N,V,W,j)}),k}),this.getOperationMap=Te((N,_)=>{const k={};return _.filter(V=>!ks.isRollupOperation(V.operation)).forEach(({operation:V,selected:W,invert:j})=>{ks.getOperationColumnNames(N,V,W,j).forEach(ee=>{var le;const ve=[...(le=k[ee])!=null?le:[],V];k[ee]=ve})}),k}),this.getOperationOrder=Te(N=>N.map(_=>_.operation).filter(_=>!ks.isRollupOperation(_))),this.getCachedFormatColumns=Te((N,_)=>_v(N,_)),this.getCachedModelColumns=Te((N,_)=>N.columns),this.getCachedPreviewFormatColumns=Te((N,_,k,V)=>{if(Ce.debug("getCachedPreviewFormatColumns",_,k,V),k!==void 0&&V!==void 0){const W=[..._];return W[V]=k,this.getCachedFormatColumns(N,W)}return this.getCachedFormatColumns(N,_)}),this.getModelRollupConfig=Te((N,_,k)=>se.getModelRollupConfig(N,_,k)),this.getModelTotalsConfig=Te((N,_,k)=>{var ve,le,Se;const{aggregations:V,showOnTop:W}=k;if(((le=(ve=_==null?void 0:_.columns)==null?void 0:ve.length)!=null?le:0)>0||((Se=V==null?void 0:V.length)!=null?Se:0)===0)return null;const j=this.getOperationMap(N,V),ee=this.getOperationOrder(V);return{operationMap:j,operationOrder:ee,showOnTop:W}}),this.getCachedStateOverride=Te((N,_,k,V,W,j,ee,ve,le,Se)=>({hoverSelectColumn:N,isFilterBarShown:_,isSelectingColumn:k,loadingScrimProgress:V,quickFilters:W,advancedFilters:j,sorts:ee,reverseType:ve,rollupConfig:le,isMenuShown:Se}),{max:1}),this.getCachedFilter=Te((N,_,k,V,W)=>[...N!=null?N:[],...V!=null?V:[],...se.getFiltersFromFilterMap(_),...se.getFiltersFromFilterMap(k),...W!=null?W:[]],{max:1}),this.getCachedTheme=Te((N,_)=>({...ap,...N,autoSelectRow:!_}),{max:1}),this.getAlwaysFetchColumns=Te((N,_,k,V,W,j)=>{const ee=[];for(let le=0;le<V;le+=1)ee.push(_[G.getModelIndex(le,k)].name);for(let le=0;le<W;le+=1)ee.push(_[G.getModelIndex(_.length-1-le,k)].name);if(j)for(let le=j[0];le<=j[1];le+=1)ee.push(_[G.getModelIndex(le,k)].name);return[...new Set([...N,...ee])]}),this.updateSearchFilter=Xe((N,_,k,V)=>{const W=Rr.createSearchFilter(N,_,k,V);this.setState({searchFilter:W})},BT),this.handleConditionalFormatEditorUpdate=Xe(N=>{this.setState({conditionalFormatPreview:N})},$T),this.handleDownloadProgressUpdate=hs((N,_)=>{const{tableDownloadStatus:k}=this.state;k===on.DOWNLOAD_STATUS.DOWNLOADING&&this.setState({tableDownloadProgress:N,tableDownloadEstimatedTime:_})},UT),this.getOverflowButtonTooltip=Te(N=>{if(N==null)return null;const _={position:"absolute",...N,pointerEvents:"none"};return h("div",{style:_,children:h(Ie,{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 ps,this.globalColumnFormats=[],this.decimalFormatOptions={},this.integerFormatOptions={},this.truncateNumbersWithPound=!1,this.renderer=new Fo,this.tableSaver=null,this.crossColumnRef=Y.createRef(),this.isAnimating=!1,this.filterInputRef=Y.createRef(),this.toggleFilterBarAction={action:()=>this.toggleFilterBar(),shortcut:ln.TABLE.TOGGLE_QUICK_FILTER},this.toggleSearchBarAction={action:()=>this.toggleSearchBar(),shortcut:ln.TABLE.TOGGLE_SEARCH},this.toggleGotoRowAction={action:()=>this.toggleGotoRow(),shortcut:ln.TABLE.GOTO_ROW},this.discardAction={action:()=>{const{model:N}=this.props;Ze(N)&&N.isEditable&&N.pendingDataMap.size>0&&this.discardPending().catch(Ce.error)},shortcut:ln.INPUT_TABLE.DISCARD},this.commitAction={action:()=>{const{model:N}=this.props;Ze(N)&&N.isEditable&&N.pendingDataMap.size>0&&N.pendingDataErrors.size===0&&this.commitPending().catch(Ce.error)},shortcut:ln.INPUT_TABLE.COMMIT},this.contextActions=[this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,this.discardAction,this.commitAction];const{aggregationSettings:e,conditionalFormats:n,customColumnFormatMap:s,isFilterBarShown:i,isSelectingPartition:o,model:r,movedColumns:l,movedRows:a,partition:d,partitionColumn:c,rollupConfig:u,userColumnWidths:m,userRowHeights:p,showSearchBar:g,searchValue:f,selectedSearchColumns:b,invertSearchColumns:C,advancedFilters:w,quickFilters:T,selectDistinctColumns:y,pendingDataMap:E,canCopy:I,frozenColumns:R}=t,F=[new Uv(this),new Bv(this)];I&&F.push(new Pv(this));const x=[new $v(this),new zv(this),new Wv(this),new Yv(this),new qv(this),new fs(this),new Kv(this),new Xv(this)],U=l.length>0?l:r.movedColumns,$=a.length>0?a:r.movedRows,O=new Zv({userColumnWidths:new Map(m),userRowHeights:new Map(p),movedColumns:U}),H=b!=null?b:[],L=Rr.createSearchFilter(f,H,r.columns,C);this.state={isFilterBarShown:i,isSelectingPartition:o,focusedFilterBarColumn:null,metricCalculator:O,metrics:void 0,keyHandlers:F,mouseHandlers:x,partition:d,partitionColumn:c,partitionTable:null,partitionFilters:[],quickFilters:T?new Map(T):new Map,advancedFilters:new Map(w),shownAdvancedFilter:null,hoverAdvancedFilter:null,sorts:[],reverseType:P.REVERSE_TYPE.NONE,customColumns:[],selectDistinctColumns:y,selectedRanges:[],copyOperation:null,loadingText:null,loadingScrimProgress:null,loadingSpinnerShown:!1,movedColumns:U,movedRows:$,shownColumnTooltip:null,formatter:new cn,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:L,searchValue:f,selectedSearchColumns:H,invertSearchColumns:C,rollupConfig:u,rollupSelectedColumns:[],aggregationSettings:e,selectedAggregation:null,openOptions:[],pendingRowCount:0,pendingDataMap:E!=null?E:new Map,pendingDataErrors:new Map,pendingSavePromise:null,pendingSaveError:null,toastMessage:null,frozenColumns:R,showOverflowModal:!1,overflowText:"",overflowButtonTooltipProps:null,isGotoRowShown:!1,gotoRow:"",gotoRowError:""}}static makeQuickFilter(t,e,n){try{return P.makeQuickFilter(t,e,n)}catch(s){Ce.error("Error creating quick filter",s)}return null}componentDidMount(){const{partitionColumn:t,model:e}=this.props,n=t!=null?t:e.columns.find(s=>s.isPartitionColumn);e.isFilterRequired&&e.isValuesTableAvailable&&n!=null?this.loadPartitionsTable(n):this.initState(),this.startListening(e)}componentDidUpdate(t){var c;const{inputFilters:e,isSelectingColumn:n,settings:s,model:i,customFilters:o,sorts:r}=this.props;i!==t.model&&(this.stopListening(t.model),this.startListening(i));const l=e!==t.inputFilters?e.filter(u=>!t.inputFilters.includes(u)):[];if(l.length>0){const{advancedSettings:u}=this.props,m=(c=u.get(mi.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS))!=null?c:!1;m&&(this.clearGridInputField(),this.clearCrossColumSearch()),this.startLoading("Filtering...",!0),this.applyInputFilters(l,m)}n!==t.isSelectingColumn&&this.resetColumnSelection(),s!==t.settings&&this.updateFormatterSettings(s),o!==t.customFilters&&this.startLoading("Filtering...",!0),r!==t.sorts&&this.updateSorts(r);const{loadingScrimStartTime:a,loadingScrimFinishTime:d}=this;a!=null&&d!=null&&window.requestAnimationFrame(()=>{const u=Date.now(),m=u-a,p=d-a,g=Math.min(m/p,1);d<u&&(this.loadingScrimStartTime=void 0,this.loadingScrimFinishTime=void 0),this.setState(f=>f.loadingScrimProgress==null?(Ce.debug2("Ignoring scrim update because loading cancelled."),null):{loadingScrimProgress:g})}),this.sendStateChange()}componentWillUnmount(){const{model:t}=this.props;this.stopListening(t),this.pending.cancel(),this.updateSearchFilter.cancel(),this.loadingTimer&&clearTimeout(this.loadingTimer),this.handleDownloadProgressUpdate.cancel(),this.animationFrame!==void 0&&cancelAnimationFrame(this.animationFrame)}getValueForCell(t,e,n=!1){const{model:s}=this.props,i=this.getModelColumn(t),o=this.getModelRow(e);return n&&i!=null&&o!=null?s.valueForCell(i,o):n?null:i!=null&&o!=null?s.textForCell(i,o):""}getModelColumn(t){const{metrics:e}=this.state;A(e);const{modelColumns:n}=e;return n==null?null:t!=null?n.get(t):null}getModelRow(t){const{metrics:e}=this.state;A(e);const{modelRows:n}=e;return n==null?null:t!=null?n.get(t):null}getTheme(){var n;const{model:t,theme:e}=this.props;return this.getCachedTheme(e,(n=Ze(t)&&t.isEditable)!=null?n:!1)}getVisibleColumn(t){const{movedColumns:e}=this.state;return G.getVisibleIndex(t,e)}applyInputFilters(t,e=!1){const{model:n}=this.props,{advancedFilters:s,quickFilters:i}=this.state,o=e?new Map:new Map(s),r=e?new Map:new Map(i);let l=e&&s.size>0;t.forEach(({name:a,type:d,value:c})=>{const u=n.columns.findIndex(({name:m,type:p})=>m===a&&p===d);u>=0?(l=o.delete(u)||l,l=this.applyQuickFilter(u,c,r)||l):Ce.error("Unable to find column for inputFilter",a,d,c)}),l&&this.setState({quickFilters:r,advancedFilters:o})}applyQuickFilter(t,e,n){const{model:s}=this.props,{formatter:i}=s,o=s.columns[t];if(e!=null&&`${e}`.trim().length>0){const r=n.get(t);if(r!=null){const{text:l}=r;if(l===e)return Ce.debug2("Ignoring change to existing filter"),!1}return n.set(t,{text:e,filter:ei.makeQuickFilter(o,e,i.timeZone)}),!0}return n.delete(t)}setAdvancedFilterMap(t){this.setState({advancedFilters:t})}setAdvancedFilter(t,e,n){Ce.debug("Setting advanced filter",t,e),this.startLoading("Filtering...",!0),this.setState(({advancedFilters:s})=>{const i=new Map(s);return e==null?i.delete(t):i.set(t,{filter:e,options:n}),{advancedFilters:i}})}setQuickFilter(t,e,n){Ce.debug("Setting quick filter",t,e,n),this.startLoading("Filtering...",!0),this.setState(({quickFilters:s})=>{const i=new Map(s);return i.set(t,{filter:e,text:n}),{quickFilters:i}})}setFilterMap(t){var i;Ce.debug("setFilterMap",t);const{advancedSettings:e}=this.props;((i=e.get(mi.LINK_CHANGE_CLEARS_ALL_FILTERS))!=null?i:!1)&&this.clearAllFilters();const{model:s}=this.props;t.forEach(({columnType:o,text:r,value:l},a)=>{const d=s.columns.find(u=>u.name===a&&u.type===o);if(d==null)return;const c=s.getColumnIndexByName(d.name);if(A(c),l===null)this.setQuickFilter(c,d.filter().isNull(),"=null");else{const u=P.isTextType(o)?M.FilterValue.ofString(l):M.FilterValue.ofNumber(l);this.setQuickFilter(c,d.filter().eq(u),`${r}`)}})}removeColumnFilter(t){this.startLoading("Filtering...",!0),this.setState(({advancedFilters:e,quickFilters:n})=>{const s=e?new Map(e):new Map,i=n?new Map(n):new Map;return i.delete(t),s.delete(t),{quickFilters:i,advancedFilters:s}})}clearAllFilters(){Ce.debug("Clearing all filters");const{advancedFilters:t,quickFilters:e,searchFilter:n}=this.state;e.size===0&&t.size===0&&n===null||(this.clearGridInputField(),this.startLoading("Clearing Filters...",!0),this.setState({quickFilters:new Map,advancedFilters:new Map,searchValue:"",searchFilter:void 0}))}clearCrossColumSearch(){Ce.debug("Clearing cross-column search"),this.setState({searchValue:"",searchFilter:void 0})}clearGridInputField(){this.filterInputRef.current!=null&&this.filterInputRef.current.setValue("")}rebuildFilters(){Ce.debug("Rebuilding filters");const{model:t}=this.props,{advancedFilters:e,quickFilters:n}=this.state,{columns:s,formatter:i}=t,o=new Map,r=new Map;e.forEach((l,a)=>{const{options:d}=l,c=s[a],u=P.makeAdvancedFilter(c,d,i.timeZone);o.set(a,{options:d,filter:u})}),n.forEach((l,a)=>{const{text:d}=l,c=s[a];r.set(a,{text:d,filter:ei.makeQuickFilter(c,d,i.timeZone)})}),this.startLoading("Rebuilding filters...",!0),this.setState({quickFilters:r,advancedFilters:o})}setFilters({quickFilters:t,advancedFilters:e}){this.setState({quickFilters:t,advancedFilters:e})}updateFormatterSettings(t,e=!0){var m,p,g;const n=cs.getColumnFormats(t),s=cs.getDateTimeFormatterOptions(t),i=(m=t==null?void 0:t.defaultDecimalFormatOptions)!=null?m:{},o=(p=t==null?void 0:t.defaultIntegerFormatOptions)!=null?p:{},r=(g=t==null?void 0:t.truncateNumbersWithPound)!=null?g:!1,l=!ct(this.globalColumnFormats,n),a=!ct(this.dateTimeFormatterOptions,s),d=!ct(this.decimalFormatOptions,t==null?void 0:t.defaultDecimalFormatOptions),c=!ct(this.integerFormatOptions,o),u=this.truncateNumbersWithPound!==r;(l||a||d||c||u)&&(this.globalColumnFormats=n,this.dateTimeFormatterOptions=s,this.decimalFormatOptions=i,this.integerFormatOptions=o,this.truncateNumbersWithPound=r,this.updateFormatter({},e),a&&e&&this.rebuildFilters())}updateFormatter(t,e=!0){var r;const{customColumnFormatMap:n}=this.state,s={customColumnFormatMap:n,...t},i=[...(r=this.globalColumnFormats)!=null?r:[],...s.customColumnFormatMap.values()],o=new cn(i,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions,this.truncateNumbersWithPound);Ce.debug("updateFormatter",this.globalColumnFormats,i),this.setState({...s,formatter:o},()=>{e&&this.grid&&this.grid.forceUpdate()})}initFormatter(){const{settings:t}=this.props;this.updateFormatterSettings(t)}initState(){const{applyInputFiltersOnInit:t,inputFilters:e,sorts:n,model:s,reverseType:i,customColumns:o,searchValue:r,selectedSearchColumns:l,invertSearchColumns:a}=this.props,d=l!=null?l:[],c=Rr.createSearchFilter(r,d,s.columns,a);if(t){const u=e.filter(m=>m.value!=null);this.applyInputFilters(u)}this.setState({sorts:n,reverseType:i,customColumns:o,isReady:!0,searchFilter:c}),this.initFormatter()}async loadPartitionsTable(t){const{model:e}=this.props;this.setState({isSelectingPartition:!0});try{const n=await this.pending.add(e.valuesTable(t),r=>r.close()),s=n.columns[0],i=s.sort().desc();n.applySort([i]),n.setViewport(0,0,[s]);const o=await this.pending.add(n.getViewportData());if(o.rows.length>0){const l=o.rows[0].get(s);this.updatePartition(l,t),this.setState({isSelectingPartition:!0})}else Ce.info("Table does not have any data, just fetching all"),this.setState({isSelectingPartition:!1}),this.handlePartitionFetchAll();this.setState({partitionTable:n,partitionColumn:t},()=>{this.initState()})}catch(n){this.handleTableLoadError(n)}}updatePartition(t,e){const s=[e.filter().eq(M.FilterValue.ofString(t))];this.setState({partition:t,partitionFilters:s})}copyCell(t,e,n=!1){const{canCopy:s}=this.props;if(s){const i=String(this.getValueForCell(t,e,n));Ne.copyToClipboard(i).catch(o=>Ce.error("Unable to copy cell",o))}else Ce.error("Attempted to copyCell for user without copy permission.")}copyRanges(t,e=!1,n=!0,s){const{model:i,canCopy:o}=this.props,{metricCalculator:r,movedColumns:l}=this.state,a=r.getUserColumnWidths();if(o){const d={ranges:re.boundedRanges(t,i.columnCount,i.rowCount),includeHeaders:e,formatValues:n,movedColumns:l,userColumnWidths:a,error:s};this.setState({copyOperation:d})}else Ce.error("Attempted copyRanges for user without copy permission.")}startLoading(t,e=!1){var s,i;this.setState({loadingText:t});const n=this.getTheme();if(e&&this.grid&&(this.grid.clearSelectedRanges(),this.grid.setViewState({top:0},!0)),this.loadingScrimStartTime==null){const{minScrimTransitionTime:o,maxScrimTransitionTime:r}=n;A(o),A(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})},ei.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){Ce.debug("loading last loading config",this.lastLoadedConfig);const{advancedFilters:t,aggregationSettings:e,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}=this.lastLoadedConfig;this.lastLoadedConfig=null,this.setState({advancedFilters:t,aggregationSettings:e,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a})}else Ce.debug("remove all sorts, filters, and custom columns"),this.setState({advancedFilters:new Map,aggregationSettings:gp,customColumns:[],quickFilters:new Map,reverseType:P.REVERSE_TYPE.NONE,rollupConfig:void 0,selectDistinctColumns:[],sorts:[]})}canRollback(){return this.lastLoadedConfig!=null||!Mh(this.state)}startListening(t){t.addEventListener(be.EVENT.UPDATED,this.handleUpdate),t.addEventListener(be.EVENT.REQUEST_FAILED,this.handleRequestFailed),t.addEventListener(be.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),t.addEventListener(be.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}stopListening(t){t.removeEventListener(be.EVENT.UPDATED,this.handleUpdate),t.removeEventListener(be.EVENT.REQUEST_FAILED,this.handleRequestFailed),t.removeEventListener(be.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),t.removeEventListener(be.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}focus(){var t;(t=this.grid)==null||t.focus()}focusFilterBar(t){var c,u,m;const{model:e}=this.props,{columnCount:n}=e,s=this.getModelColumn(t);if(t==null||s==null||t<0||n<=t||!e.isFilterable(s)){this.setState({focusedFilterBarColumn:null});return}const{metricCalculator:i,metrics:o}=this.state;A(o);const{gridX:r,left:l,rightVisible:a,lastLeft:d}=o;if(t<l)(c=this.grid)==null||c.setViewState({left:t},!0);else if(a<t){const p=(u=this.grid)==null?void 0:u.getMetricState();A(p);const g=i.getLastLeft(p,t,r);(m=this.grid)==null||m.setViewState({left:Math.min(g,d)},!0)}this.lastFocusedFilterBarColumn=t,this.setState({focusedFilterBarColumn:t,isFilterBarShown:!0})}hideColumnByVisibleIndex(t){var s;const{metricCalculator:e,movedColumns:n}=this.state;e.setColumnWidth(G.getModelIndex(t,n),0),(s=this.grid)==null||s.forceUpdate()}freezeColumnByColumnName(t){const{frozenColumns:e,movedColumns:n}=this.state,{model:s}=this.props;Ce.debug2("freezing column",t);const i=e==null?new Set(s.frozenColumns):new Set(e);i.add(t);const o=s.getColumnIndexByName(t);A(o);const r=G.getVisibleIndex(o,n),l=G.moveItem(r,i.size-1,n);this.setState({frozenColumns:[...i],movedColumns:l})}unFreezeColumnByColumnName(t){const{frozenColumns:e,movedColumns:n}=this.state,{model:s}=this.props;Ce.debug2("unfreezing column",t);const i=e==null?new Set(s.frozenColumns):new Set(e);i.delete(t);const o=s.getColumnIndexByName(t);A(o);const r=G.getVisibleIndex(o,n),l=G.moveItem(r,i.size+s.frontColumns.length,n);this.setState({frozenColumns:[...i],movedColumns:l})}handleColumnVisibilityChanged(t,e){var s;const{metricCalculator:n}=this.state;e===pi.VISIBILITY_OPTIONS.SHOW?t.forEach(i=>{n.resetColumnWidth(i)}):t.forEach(i=>{n.setColumnWidth(i,0)}),(s=this.grid)==null||s.forceUpdate()}handleCrossColumnSearch(t,e,n){const{model:s}=this.props;this.updateSearchFilter(t,e,s.columns,n),this.setState({searchValue:t,selectedSearchColumns:e,invertSearchColumns:n})}handleAnimationLoop(){var t,e;(t=this.grid)==null||t.updateCanvasScale(),(e=this.grid)==null||e.updateCanvas(),this.isAnimating&&(this.animationFrame=requestAnimationFrame(this.handleAnimationLoop))}handleAnimationStart(){Ce.debug2("handleAnimationStart"),this.isAnimating=!0,this.animationFrame=requestAnimationFrame(this.handleAnimationLoop)}handleAnimationEnd(){Ce.debug2("handleAnimationEnd"),this.isAnimating=!1}handlePartitionAppend(t){const{onPartitionAppend:e}=this.props,{partitionColumn:n}=this.state;e(n,t)}handlePartitionChange(t){const{partitionColumn:e}=this.state;this.updatePartition(t,e)}handlePartitionFetchAll(){this.setState({partitionFilters:[],isSelectingPartition:!1})}handlePartitionDone(){this.setState({isSelectingPartition:!1})}handleTableLoadError(t){if(Ee.isCanceled(t))return;Ce.error(t);const{onError:e}=this.props;e(t)}showAllColumns(){var s;const{metricCalculator:t}=this.state,n=[...t.getUserColumnWidths().entries()];for(let i=0;i<n.length;i+=1){const[o,r]=n[i];r===0&&t.resetColumnWidth(o)}(s=this.grid)==null||s.forceUpdate()}toggleSort(t,e){Ce.info("Toggling sort for column",t);const{model:n}=this.props,{sorts:s}=this.state,i=this.getModelColumn(t);A(i);const o=P.toggleSortForColumn(s,n.columns,i,e);this.updateSorts(o)}updateSorts(t){var e;this.startLoading("Sorting..."),this.setState({sorts:t}),(e=this.grid)==null||e.forceUpdate()}sortColumn(t,e=P.sortDirection.none,n=!1,s=!1){var r;A(t);const{model:i}=this.props,o=P.sortColumn(i.sort,i.columns,t,e,n,s);this.startLoading("Sorting..."),this.setState({sorts:o}),(r=this.grid)==null||r.forceUpdate()}reverse(t){var e;this.startLoading("Reversing..."),this.setState({reverseType:t}),(e=this.grid)==null||e.forceUpdate()}isReversible(){const{model:t}=this.props;return t.isReversible}toggleFilterBar(t=this.lastFocusedFilterBarColumn){var n;let{isFilterBarShown:e}=this.state;if(e=!e,this.setState({isFilterBarShown:e}),e)if(t!=null)this.focusFilterBar(t);else{let s=0;const{model:i}=this.props,{columnCount:o}=i;for(let r=0;r<o;r+=1){const l=this.getModelColumn(r);if(l!=null){const a=i.columns[l];if(a!=null&&P.isTextType(a.type)){s=r;break}}}this.focusFilterBar(s)}else(n=this.grid)==null||n.focus()}isTableSearchAvailable(){var s,i,o;const{model:t,canToggleSearch:e}=this.props,n=(s=t==null?void 0:t.layoutHints)==null?void 0:s.searchDisplayMode;return n===((i=M.SearchDisplayMode)==null?void 0:i.SEARCH_DISPLAY_HIDE)?!1:n===((o=M.SearchDisplayMode)==null?void 0:o.SEARCH_DISPLAY_SHOW)?!0:e}toggleSearchBar(){const{showSearchBar:t}=this.state;if(!this.isTableSearchAvailable())return;const e=!t;this.setState({showSearchBar:e},()=>{var n,s,i;e&&((n=this.crossColumnRef)==null?void 0:n.current)?(s=this.crossColumnRef)==null||s.current.focus():(i=this.grid)==null||i.focus()})}toggleGotoRow(t=""){const{isGotoRowShown:e}=this.state;if(t){this.setState({isGotoRowShown:!0,gotoRow:t,gotoRowError:""});return}this.setState({isGotoRowShown:!e,gotoRow:"",gotoRowError:""})}async commitPending(){var i,o;const{model:t}=this.props;if(!Ze(t)||!t.isEditable)throw new Error("Cannot save, table is not editable");const{pendingSavePromise:e}=this.state;if(e!=null)throw new Error("Save already in progress");const n=(i=document==null?void 0:document.activeElement)==null?void 0:i.classList.contains("grid-cell-input-field");if(n!=null&&n){if(document.activeElement!=null&&document.activeElement.classList.contains("error"))throw new Ai("Current input is invalid");(o=this.grid)==null||o.focus()}const s=this.pending.add(t.commitPending()).then(()=>{this.setState({pendingSaveError:null,pendingSavePromise:null})}).catch(r=>{Ee.isCanceled(r)||this.setState({pendingSaveError:r,pendingSavePromise:null})});return this.setState({pendingSavePromise:s}),s}async discardPending(){const{pendingSavePromise:t}=this.state;if(t!=null)throw new Error("Cannot cancel a save in progress");this.setState({pendingSavePromise:null,pendingSaveError:null,pendingDataMap:new Map,pendingDataErrors:new Map})}selectColumn(t){const{onColumnSelected:e}=this.props;e(t)}selectData(t,e){const{model:n}=this.props,{columns:s}=n,i={};for(let r=0;r<s.length;r+=1){const l=s[r],{name:a,type:d}=l,c=n.valueForCell(r,e),u=n.textForCell(r,e);i[a]={value:c,text:u,type:d}}const{onDataSelected:o}=this.props;o(e,i)}handleAdvancedFilterChange(t,e,n){const{model:s}=this.props,i=s.getColumnIndexByName(t.name);A(i),this.setAdvancedFilter(i,e,n)}handleAdvancedFilterSortChange(t,e,n=!1){var a;const{model:s}=this.props,i=s.getColumnIndexByName(t.name);A(i);const o=P.getSortForColumn(s.sort,i);let r=null;(o==null||o.direction!==e)&&(e===P.sortDirection.descending?r=t.sort().desc():r=t.sort().asc());const l=P.setSortForColumn(s.sort,i,r,n);Ce.info("Setting table sorts",l),this.startLoading("Sorting..."),this.setState({sorts:l}),(a=this.grid)==null||a.forceUpdate()}handleAdvancedFilterDone(){var t;(t=this.grid)==null||t.focus()}handleAdvancedMenuOpened(t){this.setState({shownAdvancedFilter:t})}handleGotoRowOpened(){this.setState({isGotoRowShown:!0})}handleGotoRowClosed(){this.setState({isGotoRowShown:!1})}handleAdvancedMenuClosed(t){var s,i;const{focusedFilterBarColumn:e,isFilterBarShown:n}=this.state;n&&e===t&&((s=this.filterInputRef)==null?void 0:s.current)!==null?((i=this.filterInputRef)==null||i.current.focus(),this.setState({shownAdvancedFilter:null})):this.setState({focusedFilterBarColumn:null,shownAdvancedFilter:null})}handleCancel(){this.rollback()}handleChartChange(){}handleChartCreate(t){const{model:e,onCreateChart:n}=this.props;n(t,e)}handleGridError(t){Ce.warn("Grid Error",t),this.setState({toastMessage:h("div",{className:"error-message",children:`${t}`})})}handleFilterBarChange(t){this.startLoading("Filtering...",!0),this.setState(({focusedFilterBarColumn:e,quickFilters:n})=>{const s=new Map(n);if(e!=null){const i=this.getModelColumn(e);A(i),this.applyQuickFilter(i,t,s)}return{quickFilters:s}})}handleFilterBarDone(t=!0,e=!0){var n;t&&((n=this.grid)==null||n.focus()),e&&this.setState({focusedFilterBarColumn:null})}handleFilterBarTab(t){const{focusedFilterBarColumn:e}=this.state;A(e),t?this.focusFilterBar(e-1):this.focusFilterBar(e+1)}handleFormatSelection(t,e){const{model:n}=this.props,s=n.columns[t],{customColumnFormatMap:i}=this.state,o=new Map(i);if(e!=null){const r=P.getNormalizedType(s.type);A(r);const l=cn.makeColumnFormattingRule(r,s.name,e);o.set(s.name,l)}else o.delete(s.name);this.updateFormatter({customColumnFormatMap:o})}handleMenu(t){t.stopPropagation(),this.setState({isMenuShown:!0})}handleMenuClose(){this.setState({isMenuShown:!1,openOptions:[]})}handleMenuBack(){this.setState(({openOptions:t})=>{const e=[...t];return e.pop(),{openOptions:e}})}handleMenuSelect(t){this.setState(({openOptions:e})=>({openOptions:[...e,t]}))}handleRequestFailed(t){const e=t;if(Ce.error("request failed:",e.detail),this.stopLoading(),this.canRollback())this.startLoading("Rolling back changes...",!0),this.rollback();else{Ce.error("Table failed and unable to rollback");const{onError:n}=this.props;n(new Error(`Error displaying table: ${e.detail}`))}}handleUpdate(){var c;this.stopLoading(),Ce.debug2("Received model update");const{advancedFilters:t,aggregationSettings:e,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}=this.state,d={advancedFilters:t,aggregationSettings:e,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a};Mh(d)?this.lastLoadedConfig=null:this.lastLoadedConfig=d,(c=this.grid)==null||c.forceUpdate()}handleViewChanged(t){var i,o;const{model:e}=this.props,{selectionEndRow:n=0}=(o=(i=this.grid)==null?void 0:i.state)!=null?o:{};let s=0;if(Ze(e)&&e.isEditable){A(t);const{bottomViewport:r}=t,l=e.rowCount-e.floatingBottomRowCount;n===l-1?s=e.pendingRowCount+1:n===l-2?s=e.pendingRowCount:s=Math.max(0,r-(e.rowCount-e.pendingRowCount)-e.floatingTopRowCount-e.floatingBottomRowCount-1)}this.setState({metrics:t,pendingRowCount:s})}handleSelectionChanged(t){A(t);const{onSelectionChanged:e}=this.props,{copyOperation:n}=this.state;this.setState({selectedRanges:t}),n!=null&&this.setState({copyOperation:null}),e(t)}handleMovedColumnsChanged(t,e=()=>null){this.setState({movedColumns:t},e)}handleTooltipRef(t){t!=null&&t.startTimer(),this.tooltip=t}handleConditionalFormatsChange(t){Ce.debug("Updated conditional formats",t),this.setState({conditionalFormats:t})}handleConditionalFormatCreate(){Ce.debug("Create new conditional format");const{openOptions:t,conditionalFormats:e}=this.state;this.setState({openOptions:[...t,{type:Oe.CONDITIONAL_FORMATTING_EDIT,title:"Create Formatting Rule"}],conditionalFormatEditIndex:e.length,conditionalFormatPreview:void 0})}handleConditionalFormatEdit(t){Ce.debug("Edit conditional format",t);const{openOptions:e,conditionalFormats:n}=this.state;this.setState({openOptions:[...e,{type:Oe.CONDITIONAL_FORMATTING_EDIT,title:"Edit Formatting Rule"}],conditionalFormatEditIndex:t,conditionalFormatPreview:{...n[t]}})}handleConditionalFormatEditorSave(t){Ce.debug("Save conditional format changes",t),this.setState(e=>{if(e.conditionalFormatEditIndex===null)return Ce.debug("Invalid format index"),null;const n=[...e.conditionalFormats];return n[e.conditionalFormatEditIndex]=t,{conditionalFormats:n}},()=>{this.handleMenuBack()})}handleConditionalFormatEditorCancel(){this.handleMenuBack(),this.setState({conditionalFormatEditIndex:null})}handleUpdateCustomColumns(t){Ce.info("handleUpdateCustomColumns:",t);const{model:e}=this.props,{movedColumns:n,sorts:s,quickFilters:i,advancedFilters:o,selectDistinctColumns:r}=this.state,{columns:l}=e,a=e.customColumns.map(c=>`${c}`),d=se.getRemovedCustomColumnNames(a,t);if(d.length>0){const c=se.removeSortsInColumns(s,d),u=se.removeFiltersInColumns(l,i,d),m=se.removeFiltersInColumns(l,o,d),p=se.removeColumnFromMovedColumns(l,n,d),g=se.removeColumnsFromSelectDistinctColumns(r,d);c.length!==s.length&&(Ce.debug("removing sorts from removed custom columns..."),this.setState({sorts:c})),(u.size!==i.size||m.size!==o.size)&&(Ce.debug("removing filters from removed custom columns..."),this.setState({quickFilters:u,advancedFilters:m})),ct(n,p)||(Ce.debug("change moved columns for removed custom columns",p),this.setState({movedColumns:p})),ct(r,g)||(Ce.debug("change selectDistinct columns for removed custom columns",p),this.setState({selectDistinctColumns:g}))}this.setState({customColumns:t}),this.startLoading("Applying custom columns...")}handleCustomColumnsChanged(){var e;Ce.debug("custom columns changed");const{isReady:t}=this.state;t?(this.stopLoading(),(e=this.grid)==null||e.forceUpdate()):this.initState()}handlePendingCommitClicked(){return this.commitPending()}handlePendingDiscardClicked(){return this.discardPending()}handlePendingDataUpdated(){var s;Ce.debug("pending data updated");const{model:t}=this.props,{pendingDataMap:e,pendingDataErrors:n}=t;this.setState({pendingDataMap:e,pendingDataErrors:n,pendingSaveError:null}),(s=this.grid)==null||s.forceUpdate()}handleAggregationsChange(t){Ce.debug("handleAggregationsChange",t),this.startLoading(`Aggregating ${t.aggregations.map(e=>e.operation).join(", ")}...`),this.setState({aggregationSettings:t})}handleAggregationChange(t){Ce.debug("handleAggregationChange",t),this.startLoading(`Aggregating ${t.operation}...`),this.setState(({aggregationSettings:e})=>({selectedAggregation:t,aggregationSettings:{...e,aggregations:e.aggregations.map(n=>n.operation===t.operation?t:n)}}))}handleAggregationEdit(t){Ce.debug("handleAggregationEdit",t);const{openOptions:e}=this.state;this.setState({openOptions:[...e,{type:Oe.AGGREGATION_EDIT,title:`Edit Columns to ${t.operation}`}],selectedAggregation:t})}handleRollupChange(t){var e,n;Ce.info("Rollup change",t),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Grouping by columns ${(n=(e=t==null?void 0:t.columns)==null?void 0:e.join(", "))!=null?n:""}...`),this.setState({rollupConfig:t,movedColumns:[],sorts:[],reverseType:P.REVERSE_TYPE.NONE,selectDistinctColumns:[]})}handleSelectDistinctChanged(t){Ce.debug("SelectDistinct change",t),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Selecting distinct values in ${t.length>0?t.join(", "):""}...`),this.setState({selectDistinctColumns:t,movedColumns:[],sorts:[],reverseType:P.REVERSE_TYPE.NONE})}handleDownloadTableStart(){const{canDownloadCsv:t}=this.props;t?this.setState({isTableDownloading:!0,tableDownloadProgress:0,tableDownloadEstimatedTime:null,tableDownloadStatus:on.DOWNLOAD_STATUS.INITIATING}):Ce.error("Attempted to handleDownloadTableStart for user without download CSV permission.")}handleDownloadTable(t,e,n,s){const{canDownloadCsv:i}=this.props;i?(Ce.info("start table downloading",t,e,n,s),this.setState(()=>(this.tableSaver&&this.tableSaver.startDownload(t,e,n,s),{tableDownloadStatus:on.DOWNLOAD_STATUS.DOWNLOADING}))):Ce.error("Attempted to handleDownloadTable for user without download CSV permission.")}handleCancelDownloadTable(){var t;(t=this.tableSaver)==null||t.cancelDownload(),this.setState({isTableDownloading:!1})}handleDownloadCompleted(){this.setState({isTableDownloading:!1,tableDownloadProgress:100,tableDownloadStatus:on.DOWNLOAD_STATUS.FINISHED})}handleDownloadCanceled(){this.setState({isTableDownloading:!1,tableDownloadProgress:0,tableDownloadStatus:on.DOWNLOAD_STATUS.CANCELED})}deleteRanges(t){const{model:e}=this.props;this.pending.add(e.delete(t)).catch(n=>{Ee.isCanceled(n)||Ce.error("Unable to delete ranges",t,n)})}resetColumnSelection(){if(this.grid==null)return;const{isSelectingColumn:t}=this.props;if(t){const{columnAllowedCursor:e}=this.props;this.grid.setState({cursor:e})}else this.grid.setState({cursor:null}),this.setState({hoverSelectColumn:null})}resetGridViewState(t=!0){!this.grid||(this.grid.clearSelectedRanges(),this.grid.setViewState({left:0,top:0,topOffset:0,leftOffset:0},t))}sendStateChange(){if(!this.grid)return;const{state:t}=this,{state:e}=this.grid,{onStateChange:n}=this.props;n(t,e)}handleOverflowClose(){this.setState({showOverflowModal:!1})}getColumnBoundingRect(){var m;const{metrics:t,shownColumnTooltip:e}=this.state;A(t),A(e);const n=(m=this.gridWrapper)==null?void 0:m.getBoundingClientRect(),s=20;A(n);const{columnHeaderHeight:i,visibleColumnXs:o,visibleColumnWidths:r,width:l,columnHeaderMaxDepth:a}=t,d=o.get(e),c=r.get(e);A(d),A(c);const u=n.left+At(d+c/2,s,l-s);return{top:n.top+(a-1)*i,left:n.left+At(d+c/2,s,l-s),bottom:n.top+a*i,right:n.left+At(d+c/2,s,l-s)+1,width:1,height:i,x:u,y:n.top,toJSON:()=>{throw new Error("not implemented")}}}handleGotoRowSelectedRowNumberSubmit(){const{gotoRow:t}=this.state;this.focusRowInGrid(t)}focusRowInGrid(t){var i,o,r;const{model:e}=this.props,{rowCount:n}=e;if(this.setState({gotoRow:t}),t===""){this.setState({gotoRowError:""});return}const s=parseInt(t,10);s>n||s<-n?this.setState({gotoRowError:"Invalid row index"}):s===0?(this.setState({gotoRowError:""}),(i=this.grid)==null||i.setFocusRow(0)):s<0?(this.setState({gotoRowError:""}),(o=this.grid)==null||o.setFocusRow(s+n)):((r=this.grid)==null||r.setFocusRow(s-1),this.setState({gotoRowError:""}))}handleGotoRowSelectedRowNumberChanged(t){const e=t.target.value;this.focusRowInGrid(e)}getColumnTooltip(t,e,n){const{columnHeaderHeight:s,columnHeaderMaxDepth:i,visibleColumnXs:o,visibleColumnWidths:r,width:l}=e,a=o.get(t),d=r.get(t);if(a==null||d==null)return null;const c=Math.max(0,a);let u=d;a+d>l?u=l-a:a<0&&(u=d-Math.abs(a));const m={position:"absolute",top:(i-1)*s,left:c,width:u,height:s,pointerEvents:"none"},p={clientWidth:1,clientHeight:s,getBoundingClientRect:this.getColumnBoundingRect},g={placement:"bottom",modifiers:{flip:{behavior:["bottom","top"]}}},f=this.getModelColumn(t);if(f==null)return null;const b=n.columns[f];return b==null?null:h("div",{style:m,children:h(Ie,{timeout:400,interactive:!0,options:g,ref:this.handleTooltipRef,referenceObject:p,onExited:()=>{this.setState({shownColumnTooltip:null})},children:h(dp,{model:n,column:b,onStatistics:()=>{var C;(C=this.tooltip)==null||C.update()}})},b.name)})}render(){var ut,Si,hc,uc,mc,pc,gc,fc,Cc;const{children:t,customFilters:e,getDownloadWorker:n,isSelectingColumn:s,isStuckToBottom:i,isStuckToRight:o,model:r,name:l,onlyFetchVisibleColumns:a,alwaysFetchColumns:d,advancedSettings:c,onAdvancedSettingsChange:u,canDownloadCsv:m,onCreateChart:p}=this.props,{metricCalculator:g,metrics:f,isFilterBarShown:b,isSelectingPartition:C,isMenuShown:w,isReady:T,copyOperation:y,focusedFilterBarColumn:E,loadingText:I,loadingScrimProgress:R,loadingSpinnerShown:F,keyHandlers:x,mouseHandlers:U,shownColumnTooltip:$,hoverAdvancedFilter:O,shownAdvancedFilter:H,hoverSelectColumn:L,quickFilters:N,advancedFilters:_,partition:k,partitionFilters:V,partitionTable:W,partitionColumn:j,searchFilter:ee,selectDistinctColumns:ve,movedColumns:le,movedRows:Se,formatter:Le,conditionalFormats:J,conditionalFormatPreview:pe,conditionalFormatEditIndex:fe,sorts:xe,reverseType:ke,customColumns:hn,selectedRanges:Xn,isTableDownloading:Sn,tableDownloadStatus:Ct,tableDownloadProgress:Re,tableDownloadEstimatedTime:st,showSearchBar:it,searchValue:Mt,selectedSearchColumns:Yt,invertSearchColumns:Xt,aggregationSettings:Nt,selectedAggregation:On,rollupConfig:Ht,openOptions:wn,pendingSavePromise:Ps,pendingSaveError:zl,pendingRowCount:Wl,pendingDataErrors:Gl,pendingDataMap:Zo,toastMessage:Jo,frozenColumns:er,showOverflowModal:tr,overflowText:nr,overflowButtonTooltipProps:sr,isGotoRowShown:ir,gotoRow:Kl,gotoRowError:ql}=this.state;if(!T)return null;const Hs=this.getTheme(),Yl=this.getCachedFilter(e,N,_,V,ee),bi=g.getUserColumnWidths(),oo=this.getCachedStateOverride(L,b,s,R,N,_,xe,ke,Ht,w),or=f?f.top:0,rr=f?f.bottomViewport:0;let ro=null,lo=null;a&&(ro=f?f.left:0,lo=f?f.right:0);const Xl=f!=null&&f.width>0&&f.height>0,jl=((Si=(ut=Ht==null?void 0:Ht.columns)==null?void 0:ut.length)!=null?Si:0)>0;let lr=null;const Ql=f?Math.min(Math.max(ei.minDebounce,Math.round(f.rowCount/200)),ei.maxDebounce):ei.maxDebounce;if(b&&E!=null&&f!=null){const{gridX:je,gridY:jt,visibleColumnXs:Cs,visibleColumnWidths:ao}=f,Vs=Cs.get(E),Ln=ao.get(E);if(Vs!=null&&Ln!=null){const Qt=je+Vs,Vt=jt-((hc=Hs.filterBarHeight)!=null?hc:0),jn=Ln+1,Us=((uc=Hs.filterBarHeight)!=null?uc:0)-1,Bs={top:Vt,left:Qt,minWidth:jn,height:Us};let wi="",Qn=!0;const $s=this.getModelColumn(E);A($s);const zs=N.get($s),co=_.get($s);zs!=null&&(wi=zs.text,Qn=zs.filter!=null);const Ws=N.size!==0||_.size!==0;lr=h(ip,{ref:this.filterInputRef,style:Bs,className:z({error:!Qn,active:wi!==""||co!=null,"iris-grid-has-filter":Ws}),isAdvancedFilterSet:co!=null,onAdvancedFiltersTriggered:()=>{this.setState({shownAdvancedFilter:E})},onChange:this.handleFilterBarChange,onDone:this.handleFilterBarDone,onTab:this.handleFilterBarTab,onContextMenu:(mc=this.grid)==null?void 0:mc.handleContextMenu,debounceMs:Ql,value:wi},E)}}let ar=null;if(I!=null){const je=v("div",{className:"iris-grid-loading-status",children:[h("div",{className:z("iris-grid-loading-status-bar",{show:F}),children:I}),v("button",{type:"button",onClick:this.handleCancel,className:z("iris-grid-btn-cancel",{show:F}),children:[h(K,{icon:Yi,transform:"down-1"}),"Cancel"]})]}),jt=f?f.gridY:0;ar=h("div",{className:"iris-grid-loading",style:{top:jt},children:je})}let dr=null;$!=null&&f&&(dr=this.getColumnTooltip($,f,r),(pc=this.tooltip)==null||pc.update());const cr=[];if(f&&b){const{gridX:je,gridY:jt,visibleColumns:Cs,visibleColumnXs:ao,visibleColumnWidths:Vs}=f,{filterBarHeight:Ln}=Hs;for(let Qt=0;Qt<Cs.length;Qt+=1){const Vt=Cs[Qt],jn=ao.get(Vt),Us=Vs.get(Vt),Bs=this.getModelColumn(Vt);if(Bs!=null&&r.isFilterable(Bs)&&jn!=null&&Us!=null&&Us>0){const Qn=je+jn+Us-24,$s=jt-(Ln!=null?Ln:0)+2,zs={position:"absolute",top:$s,left:Qn},Ws=_.get(Bs)!=null,mr=Vt===O||Vt===E||Ws,ea=h("div",{className:z("advanced-filter-button-container",{hidden:!mr}),style:zs,children:mr&&h("button",{type:"button",className:z("btn btn-link btn-link-icon advanced-filter-button",{"filter-set":Ws}),onClick:()=>{this.setState({shownAdvancedFilter:Vt})},onContextMenu:Qp=>{var bc;(bc=this.grid)==null||bc.handleContextMenu(Qp)},onMouseEnter:()=>{this.setState({hoverAdvancedFilter:Vt})},onMouseLeave:()=>{this.setState({hoverAdvancedFilter:null})},children:v("div",{className:"fa-layers",children:[h(K,{icon:dd,className:"filter-solid"}),h(K,{icon:Wr,className:"filter-light"})]})})},Vt);cr.push(ea)}}}const hr=[];if(f){const{gridX:je,visibleColumns:jt,visibleColumnXs:Cs,visibleColumnWidths:ao,columnHeaderHeight:Vs}=f;for(let Ln=0;Ln<jt.length;Ln+=1){const Qt=jt[Ln],Vt=Cs.get(Qt),jn=ao.get(Qt);if(Vt!=null&&jn!=null&&jn>0){const Us=je+Vt,Bs=je+Vt+jn-20,wi=b?{position:"absolute",top:Vs,left:Bs,width:20,height:Hs.filterBarHeight}:{position:"absolute",top:0,left:Us,width:jn,height:Vs},Qn=this.getModelColumn(Qt);if(Qn!=null){const $s=r.columns[Qn],zs=_.get(Qn),{options:co}=zs||{},Ws=P.getSortForColumn(r.sort,Qn),mr=Ws?Ws.direction:null,ea=h("div",{className:"advanced-filter-menu-container",style:wi,children:h(xn,{className:"advanced-filter-menu-popper",onEntered:this.getAdvancedMenuOpenedHandler(Qt),onExited:()=>{this.handleAdvancedMenuClosed(Qt)},isShown:H===Qt,interactive:!0,closeOnBlur:!0,options:{positionFixed:!0},children:this.getCachedAdvancedFilterMenuActions(r,$s,co,mr,Le)})},Qt);hr.push(ea)}}}}const ur=this.getCachedOptionItems(p!==void 0&&r.isChartBuilderAvailable,r.isCustomColumnsAvailable,r.isFormatColumnsAvailable,r.isRollupAvailable,r.isTotalsAvailable,r.isSelectDistinctAvailable,r.isExportAvailable,this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,b,it,m,this.isTableSearchAvailable(),ir),Zl=wn.map(je=>{switch(je.type){case Oe.CHART_BUILDER:return h(qm,{model:r,onChange:this.handleChartChange,onSubmit:this.handleChartCreate},Oe.CHART_BUILDER);case Oe.VISIBILITY_ORDERING_BUILDER:return h(pi,{model:r,movedColumns:le,userColumnWidths:bi,onColumnVisibilityChanged:this.handleColumnVisibilityChanged,onMovedColumnsChanged:this.handleMovedColumnsChanged},Oe.VISIBILITY_ORDERING_BUILDER);case Oe.CONDITIONAL_FORMATTING:return h(dT,{rules:J,onChange:this.handleConditionalFormatsChange,onCreate:this.handleConditionalFormatCreate,onSelect:this.handleConditionalFormatEdit});case Oe.CONDITIONAL_FORMATTING_EDIT:return A(r.columns),A(this.handleConditionalFormatEditorUpdate),h(AT,{columns:r.columns,rule:pe,onUpdate:this.handleConditionalFormatEditorUpdate,onSave:this.handleConditionalFormatEditorSave,onCancel:this.handleConditionalFormatEditorCancel});case Oe.CUSTOM_COLUMN_BUILDER:return h(Hd,{model:r,customColumns:hn,onSave:this.handleUpdateCustomColumns,onCancel:this.handleMenuBack},Oe.CUSTOM_COLUMN_BUILDER);case Oe.ROLLUP_ROWS:return h(Vd,{model:r,onChange:this.handleRollupChange,config:Ht},Oe.ROLLUP_ROWS);case Oe.AGGREGATIONS:return h(E0,{settings:Nt,isRollup:jl,onChange:this.handleAggregationsChange,onEdit:this.handleAggregationEdit});case Oe.AGGREGATION_EDIT:return On&&h(I0,{aggregation:On,columns:r.originalColumns,onChange:this.handleAggregationChange});case Oe.TABLE_EXPORTER:return h(on,{model:r,name:l,isDownloading:Sn,tableDownloadStatus:Ct,tableDownloadProgress:Re,tableDownloadEstimatedTime:st!=null?st:void 0,onDownload:this.handleDownloadTable,onDownloadStart:this.handleDownloadTableStart,onCancel:this.handleCancelDownloadTable,selectedRanges:Xn},Oe.TABLE_EXPORTER);case Oe.SELECT_DISTINCT:return h(up,{model:r,selectDistinctColumns:ve,onChange:this.handleSelectDistinctChanged});case Oe.ADVANCED_SETTINGS:return h(zd,{items:c,onChange:u});default:throw Error(`Unexpected option type ${je.type}`)}}),Jl=this.getCachedHiddenColumns(se.getHiddenColumns(bi));return v("div",{className:"iris-grid",role:"presentation",children:[v("div",{className:"iris-grid-column",children:[t!=null&&h("div",{className:"iris-grid-bar",children:t}),h(ht,{in:C,timeout:Tt.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"iris-grid-partition-selector-wrapper iris-grid-bar iris-grid-bar-primary",children:W&&j&&h(hp,{table:W,getFormattedString:(je,jt,Cs)=>r.displayString(je,jt,Cs),columnName:j.name,partition:k,onChange:this.handlePartitionChange,onFetchAll:this.handlePartitionFetchAll,onAppend:this.handlePartitionAppend,onDone:this.handlePartitionDone})})}),h(ht,{in:it,timeout:Tt.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"iris-grid-bar",children:h(Rr,{value:Mt,selectedColumns:Yt,invertSelection:Xt,onChange:this.handleCrossColumnSearch,columns:r.columns,ref:this.crossColumnRef})})}),v("div",{className:"grid-wrapper",ref:je=>{this.gridWrapper=je},children:[h(Ji,{ref:je=>{this.grid=je},isStickyBottom:!Ze(r)||!r.isEditable,isStuckToBottom:i,isStuckToRight:o,metricCalculator:g,model:r,keyHandlers:x,mouseHandlers:U,movedColumns:le,movedRows:Se,onError:this.handleGridError,onViewChanged:this.handleViewChanged,onSelectionChanged:this.handleSelectionChanged,onMovedColumnsChanged:this.handleMovedColumnsChanged,renderer:this.renderer,stateOverride:oo,theme:Hs}),h(PT,{isOpen:tr,text:nr,onClose:this.handleOverflowClose}),Xl&&h(lp,{model:r,modelColumns:r.columns,top:or,bottom:rr,left:ro,right:lo,filter:Yl,formatter:Le,sorts:xe,reverseType:ke,movedColumns:le,customColumns:hn,hiddenColumns:Jl,alwaysFetchColumns:this.getAlwaysFetchColumns(d,r.columns,le,r.floatingLeftColumnCount,r.floatingRightColumnCount,(fc=(gc=this.grid)==null?void 0:gc.state.draggingColumn)==null?void 0:fc.range),formatColumns:this.getCachedPreviewFormatColumns(this.getCachedModelColumns(r,hn),J,pe,((Cc=wn[wn.length-1])==null?void 0:Cc.type)===Oe.CONDITIONAL_FORMATTING_EDIT&&fe!=null?fe:void 0),rollupConfig:this.getModelRollupConfig(r.originalColumns,Ht,Nt),totalsConfig:this.getModelTotalsConfig(r.columns,Ht,Nt),selectDistinctColumns:ve,pendingRowCount:Wl,pendingDataMap:Zo,frozenColumns:er}),!w&&h("div",{className:"grid-settings-button",children:h("button",{type:"button","data-testid":`btn-iris-grid-settings-button-${l}`,className:"btn btn-link btn-link-icon",onClick:this.handleMenu,children:h(K,{icon:Ff,transform:"up-1"})})}),lr,ar,cr,dr,hr,sr&&this.getOverflowButtonTooltip(sr)]}),h(VT,{model:r,isShown:ir,gotoRow:Kl,gotoRowError:ql,onSubmit:this.handleGotoRowSelectedRowNumberSubmit,onGotoRowNumberChanged:this.handleGotoRowSelectedRowNumberChanged,onClose:this.handleGotoRowClosed,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:()=>{this.handleAnimationStart(),this.focus()},onExited:this.handleAnimationEnd}),h(Av,{error:zl,isSaving:Ps!=null,saveTooltip:`Commit (${this.commitAction.shortcut.getDisplayText()})`,discardTooltip:`Discard (${this.discardAction.shortcut.getDisplayText()})`,pendingDataErrors:Gl,pendingDataMap:Zo,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,onSave:this.handlePendingCommitClicked,onDiscard:this.handlePendingDiscardClicked}),h(Qv,{children:Jo}),h(to,{model:r,copyOperation:y!=null?y:void 0,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd}),h(eo,{ref:je=>{this.tableSaver=je},getDownloadWorker:n,onDownloadCompleted:this.handleDownloadCompleted,onDownloadCanceled:this.handleDownloadCanceled,onDownloadProgressUpdate:this.handleDownloadProgressUpdate,isDownloading:Ct===on.DOWNLOAD_STATUS.DOWNLOADING,formatter:Le})]}),h(ht,{in:w,timeout:Tt.transitionMidMs,classNames:"slide-left",onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"table-sidebar",children:v(_C,{children:[h(Uc,{title:"Table Options",onClose:this.handleMenuClose,children:h(Hu,{onSelect:je=>this.handleMenuSelect(ur[je]),items:ur})}),Zl.map((je,jt)=>h(Uc,{title:wn[jt].title,onBack:this.handleMenuBack,onClose:this.handleMenuClose,children:je},wn[jt].type))]})})}),h(oe,{actions:this.contextActions})]})}};let no=ei;no.minDebounce=150;no.maxDebounce=500;no.loadingSpinnerDelay=800;no.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:P.REVERSE_TYPE.NONE,customColumns:[],aggregationSettings:gp,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:us.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:ap,canToggleSearch:!0};class zT extends Error{constructor(e,n){super(`${n} can't be empty (on pending row ${e+1})`),this.isMissingKey=!0,this.rowIndex=e,this.columnName=n}}const WT=X.module("ColumnHeaderGroup");function Nh(t){return t instanceof fp}class fp{constructor({name:e,children:n,color:s,depth:i,childIndexes:o}){this.getVisibleRange=he(r=>{const l=this.childIndexes.flat(),a=G.getVisibleIndexes(l,r),d=Math.min(...a),c=Math.max(...a);return c-d!==l.length-1&&WT.warn(`Column header group ${this.name} is not contiguous`),[d,c]}),this.name=e,this.children=n,this.color=s,this.depth=i,this.childIndexes=o}}const et=X.module("IrisGridTableModel"),GT=150,KT=0;function ri(t){return t.table!==void 0}const Ba=class extends be{constructor(t,e=new cn,n=null){super(),this.pendingNewRowCount=0,this.columnHeaderGroupMap=new Map,this.columnHeaderParentMap=new Map,this._columnHeaderMaxDepth=null,this._columnHeaderGroups=[],this.getMemoizedColumnMap=he(s=>{const i=new Map;return s.forEach(o=>i.set(o.name,o)),i}),this.getColumnIndicesByNameMap=he(s=>{const i=new Map;return s.forEach(({name:o},r)=>i.set(o,r)),i}),this.setViewport=hs((s,i,o)=>{if(i<s){et.error("Invalid viewport",s,i);return}const{viewport:r}=this;if(r!=null&&r.top===s&&r.bottom===i&&r.columns===o){et.debug2("Ignoring duplicate viewport",r);return}this.viewport={top:s,bottom:i,columns:o},et.debug2("setViewport",this.viewport),this.applyViewport()},GT),this.applyViewport=hs(()=>{if(!this.viewport)return;et.debug2("applyViewport",this.viewport);const{top:s,bottom:i,columns:o}=this.viewport,[r,l]=this.getCachedViewportRowRange(s,i);this.applyBufferedViewport(r,l,o)},KT,{leading:!1}),this.getCachedFormattedString=rn((s,i,o,r,l)=>s.getFormattedString(i,o,r,l),{max:1e4}),this.getCachedCustomColumnFormatFlag=rn(cs.isCustomColumnFormatDefined,{max:1e4}),this.getCachedViewportRowRange=he((s,i)=>{const o=i-s,r=Math.max(0,s-o*Ba.ROW_BUFFER_PAGES),l=i+o*Ba.ROW_BUFFER_PAGES;return[r,l]}),this.getCachedPendingErrors=he((s,i,o)=>{const r=new Map;return s.forEach((l,a)=>{var c;const{data:d}=l;for(let u=0;u<o;u+=1)d.has(u)||(r.has(a)||r.set(a,[]),(c=r.get(a))==null||c.push(new zT(a,i[u].name)))}),r}),this.handleTableDisconnect=this.handleTableDisconnect.bind(this),this.handleTableReconnect=this.handleTableReconnect.bind(this),this.handleTableUpdate=this.handleTableUpdate.bind(this),this.handleTotalsUpdate=this.handleTotalsUpdate.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.handleCustomColumnsChanged=this.handleCustomColumnsChanged.bind(this),this.irisFormatter=e,this.inputTable=n,this.subscription=null,this.table=t,this.viewport=null,this.viewportData=null,this.formattedStringData=[],this.pendingStringData=[],this.isSaveInProgress=!1,this.totalsTable=null,this.totalsTablePromise=null,this.totals=null,this.totalsDataMap=null,this.pendingNewDataMap=new Map,this.pendingNewDataErrors=null,this.pendingNewRowCount=0}export(){throw new Error("Method not implemented.")}columnStatistics(t){throw new Error("Method not implemented.")}get customColumns(){return[]}set customColumns(t){throw new Error("Method not implemented.")}get formatColumns(){return[]}set formatColumns(t){throw new Error("Method not implemented.")}updateFrozenColumns(t){throw new Error("Method not implemented.")}get rollupConfig(){throw new Error("Method not implemented.")}set rollupConfig(t){throw new Error("Method not implemented.")}get selectDistinctColumns(){throw new Error("Method not implemented.")}set selectDistinctColumns(t){throw new Error("Method not implemented.")}get columns(){return this.table.columns}close(){this.table.close(),this.totalsTable!==null&&this.totalsTable.close(),this.totalsTablePromise!==null&&this.totalsTablePromise.cancel()}startListening(){super.startListening(),this.table.addEventListener(M.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.addEventListener(M.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.addEventListener(M.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.addEventListener(M.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.addEventListener(M.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable),this.applyViewport()}stopListening(){super.stopListening(),this.table.removeEventListener(M.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.removeEventListener(M.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.removeEventListener(M.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.removeEventListener(M.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.removeEventListener(M.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.removeTotalsListeners(this.totalsTable),this.closeSubscription()}addTotalsListeners(t){t.addEventListener(M.Table.EVENT_UPDATED,this.handleTotalsUpdate),t.setViewport(0,0)}removeTotalsListeners(t){t.removeEventListener(M.Table.EVENT_UPDATED,this.handleTotalsUpdate)}handleTableDisconnect(){this.dispatchEvent(new Ge(be.EVENT.DISCONNECT))}handleTableReconnect(){this.dispatchEvent(new Ge(be.EVENT.RECONNECT))}handleTableUpdate(t){this.copyViewportData(t.detail),this.dispatchEvent(new Ge(be.EVENT.UPDATED))}handleTotalsUpdate(t){this.copyTotalsData(t.detail),this.dispatchEvent(new Ge(be.EVENT.UPDATED))}handleRequestFailed(t){this.dispatchEvent(new Ge(be.EVENT.REQUEST_FAILED,t))}handleCustomColumnsChanged(){this.dispatchEvent(new Ge(be.EVENT.COLUMNS_CHANGED,{detail:this.columns}))}get rowCount(){var t,e,n;return this.table.size+this.pendingNewRowCount+((n=(e=(t=this.totals)==null?void 0:t.operationOrder)==null?void 0:e.length)!=null?n:0)}get pendingDataErrors(){var t,e;return this.getCachedPendingErrors(this.pendingNewDataMap,this.columns,(e=(t=this.inputTable)==null?void 0:t.keyColumns.length)!=null?e:0)}get pendingDataMap(){return this.pendingNewDataMap}set pendingDataMap(t){t!==this.pendingNewDataMap&&(t.forEach((e,n)=>{if(!se.isValidIndex(n))throw new Error(`Invalid rowIndex ${n}`);const{data:s}=e;s.forEach((i,o)=>{if(!se.isValidIndex(o))throw new Error(`Invalid columnIndex ${o}`)})}),this.pendingNewDataMap=t,this.pendingNewRowCount=Math.max(this.pendingNewRowCount,this.maxPendingDataRow),this.formattedStringData=[],this.dispatchEvent(new Ge(be.EVENT.PENDING_DATA_UPDATED)))}get pendingRowCount(){return this.pendingNewRowCount}set pendingRowCount(t){t!==this.pendingNewRowCount&&(this.pendingNewRowCount=Math.max(0,t,this.maxPendingDataRow),this.dispatchEvent(new Ge(be.EVENT.UPDATED)))}get maxPendingDataRow(){return this.pendingNewDataMap.size>0?Math.max(...this.pendingNewDataMap.keys())+1:0}get columnCount(){return this.columns.length}get floatingBottomRowCount(){var t,e,n;return this.totals!=null&&this.totals.showOnTop?0:(n=(e=(t=this.totals)==null?void 0:t.operationOrder)==null?void 0:e.length)!=null?n:0}get floatingTopRowCount(){var t,e,n;return this.totals!=null&&this.totals.showOnTop&&(n=(e=(t=this.totals)==null?void 0:t.operationOrder)==null?void 0:e.length)!=null?n:0}get isChartBuilderAvailable(){return!0}get isTotalsAvailable(){return this.table.getTotalsTable!=null}get isEditable(){return!this.isSaveInProgress&&this.inputTable!=null}cacheFormattedValue(t,e,n){this.formattedStringData[t]==null&&(this.formattedStringData[t]=[]),this.formattedStringData[t][e]=n}cachePendingValue(t,e,n){this.pendingStringData[t]==null&&(this.pendingStringData[t]=[]),this.pendingStringData[t][e]=n}clearPendingValue(t,e){const n=this.pendingStringData[t];n!=null&&delete n[e]}textValueForCell(t,e){var n,s,i;if(((n=this.pendingStringData[t])==null?void 0:n[e])!==void 0)return this.pendingStringData[t][e];if(((s=this.formattedStringData[t])==null?void 0:s[e])===void 0){const o=this.valueForCell(t,e);if(o==null)return null;const r=(i=this.totalsColumn(t,e))!=null?i:this.columns[t],l=this.getCachedCustomColumnFormatFlag(this.formatter,r.name,r.type);let a;if(!l){const c=this.formatForCell(t,e);(c==null?void 0:c.formatString)!=null&&(a=c)}const d=this.displayString(o,r.type,r.name,a);this.cacheFormattedValue(t,e,d)}return this.formattedStringData[t][e]}textForCell(t,e){const n=this.textValueForCell(t,e);if(n==null&&this.isKeyColumn(t)){const s=this.pendingRow(e);if(s!=null&&this.pendingDataMap.has(s))return"*"}return n!=null?n:""}truncationCharForCell(t){const e=this.columns[t],{type:n}=e;if(P.isNumberType(n)&&this.formatter.truncateNumbersWithPound)return"#"}colorForCell(t,e,n){var i;const s=this.dataForCell(t,e);if(s){const{format:o,value:r}=s;if(r==null||r==="")return A(n.nullStringColor),n.nullStringColor;if(o&&o.color)return o.color;if(this.isPendingRow(e))return A(n.pendingTextColor),n.pendingTextColor;if(r!=null){const l=(i=this.totalsColumn(t,e))!=null?i:this.columns[t];if(P.isDateType(l.type)||l.name==="Date")return A(n.dateColor),n.dateColor;if(P.isNumberType(l.type))return r>0?(A(n.positiveNumberColor),n.positiveNumberColor):r<0?(A(n.negativeNumberColor),n.negativeNumberColor):(A(n.zeroNumberColor),n.zeroNumberColor)}}else if(this.isPendingRow(e)&&this.isKeyColumn(t))return A(n.errorTextColor),n.errorTextColor;return n.textColor}backgroundColorForCell(t,e){var n,s;return(s=(n=this.formatForCell(t,e))==null?void 0:n.backgroundColor)!=null?s:null}textAlignForCell(t){const e=this.columns[t],{type:n}=e;return P.isNumberType(n)?"right":P.isDateType(n)||e.name==="Date"?"center":"left"}textForColumnHeader(t,e=0){var n,s;return(s=(n=this.columnAtDepth(t,e))==null?void 0:n.name)!=null?s:void 0}colorForColumnHeader(t,e=0){var s;const n=this.columnAtDepth(t,e);return Nh(n)&&(s=n.color)!=null?s:null}getColumnHeaderGroup(t,e){const n=this.columnAtDepth(t,e);if(Nh(n))return n}getColumnHeaderParentGroup(t,e){var n,s;return this.columnHeaderParentMap.get((s=(n=this.columnAtDepth(t,e))==null?void 0:n.name)!=null?s:"")}columnAtDepth(t,e=0){var o;if(e===0)return this.columns[t];const n=(o=this.columns[t])==null?void 0:o.name;let s=this.columnHeaderParentMap.get(n);if(!s)return;let i=s.depth;for(;i<e;){if(s=this.columnHeaderParentMap.get(s.name),!s)return;i=s.depth}if(s.depth===e)return s}textForRowFooter(t){const e=this.totalsRow(t);return e!=null&&this.totals?this.totals.operationOrder[e]:""}get movedColumns(){var i;let t=[];const e=(o,r)=>{const l=this.getColumnIndexByName(o);if(l==null)throw new Error(`Unknown layout hint column: ${o}`);const a=G.getVisibleIndex(l,t);t=G.moveItem(a,r,t)},n=(o,r)=>{const l=this.columnHeaderGroupMap.get(o);if(!l)throw new Error(`Unknown layout hint group: ${o}`);const a=l.getVisibleRange(t);t=G.moveRange(a,r,t)};if(this.frontColumns.length||this.backColumns.length||this.frozenColumns.length){const o=new Set;let r=0;this.frozenColumns.forEach(a=>{if(o.has(a))throw new Error(`Column specified in multiple layout hints: ${a}`);e(a,r),r+=1}),this.frontColumns.forEach(a=>{if(o.has(a))throw new Error(`Column specified in multiple layout hints: ${a}`);e(a,r),r+=1});let l=this.columnMap.size-1;this.backColumns.forEach(a=>{if(o.has(a))throw new Error(`Column specified in multiple layout hints: ${a}`);e(a,l),l-=1})}const s=(i=this.layoutHints)==null?void 0:i.columnGroups;if(s){this.setColumnHeaderGroups(s);const o=[...this.columnHeaderGroupMap.values()];o.sort((r,l)=>r.depth-l.depth),o.forEach(r=>{const l=r.children[0],a=this.getColumnIndexByName(l);let d;if(a!=null)d=G.getVisibleIndex(a,t);else{const c=this.columnHeaderGroupMap.get(l);if(!c)throw new Error(`Unknown column ${l} in group ${r.name}`);[,d]=c.getVisibleRange(t)}for(let c=1;c<r.children.length;c+=1){const u=r.children[c],m=this.columnHeaderGroupMap.get(u),p=this.getColumnIndexByName(u);if(m){const f=m.getVisibleRange(t)[0]<d?d-m.childIndexes.length+1:d+1;n(u,f),d=f+m.childIndexes.length-1}else if(p!=null){const f=G.getVisibleIndex(p,t)<d?d:d+1;e(u,f),d=f}}})}return t}get columnMap(){return this.getMemoizedColumnMap(this.table.columns)}get columnHeaderMaxDepth(){var t,e;return this._columnHeaderMaxDepth==null&&this.setColumnHeaderGroups((t=this.layoutHints)==null?void 0:t.columnGroups),(e=this._columnHeaderMaxDepth)!=null?e:1}set columnHeaderMaxDepth(t){this._columnHeaderMaxDepth=t}setColumnHeaderGroups(t){if(t===this._columnHeaderGroups||(this._columnHeaderGroups=t!=null?t:[],this.columnHeaderMaxDepth=1,this.columnHeaderParentMap=new Map,this.columnHeaderGroupMap=new Map,!t||t.length===0))return;const e=new Map(t.map(o=>[o.name,o])),n=new Set,s=o=>{const{name:r}=o;if(this.getColumnIndexByName(r)!=null)throw new Error(`Column header group has same name as column: ${r}`);const l=this.columnHeaderGroupMap.get(r);if(l)return l;const a=[];let d=1;o.children.forEach(u=>{if(n.has(u))throw new Error(`Column group child ${u} specified in multiple groups`);n.add(u);const m=e.get(u),p=this.getColumnIndexByName(u);if(m){const g=s(m);a.push(g.childIndexes.flat()),d=Math.max(d,g.depth+1)}else if(p!=null)a.push(p),d=Math.max(d,1);else throw new Error(`Unknown child ${u} in group ${r}`)});const c=new fp({...o,depth:d,childIndexes:a});return this.columnHeaderGroupMap.set(r,c),o.children.forEach(u=>this.columnHeaderParentMap.set(u,c)),this.columnHeaderMaxDepth=Math.max(this.columnHeaderMaxDepth,c.depth+1),c},i=new Set;t.forEach(o=>{const{name:r}=o;if(i.has(r))throw new Error(`Duplicate column group name: ${r}`);i.add(r),s(o)})}get groupedColumns(){return[]}row(t){var l,a,d,c,u,m,p,g,f,b,C,w,T,y;const e=(d=(a=(l=this.totals)==null?void 0:l.operationOrder)==null?void 0:a.length)!=null?d:0,n=(u=(c=this.totals)==null?void 0:c.showOnTop)!=null?u:!1,s=this.totalsRow(t);if(s!=null){const E=(m=this.totals)==null?void 0:m.operationOrder[s];return A(E),(g=(p=this.totalsDataMap)==null?void 0:p.get(E))!=null?g:null}const i=this.pendingRow(t);if(i!=null)return(f=this.pendingNewDataMap.get(i))!=null?f:null;const o=(C=(b=this.viewportData)==null?void 0:b.offset)!=null?C:0,r=(n?t-e:t)-o;return(y=(T=(w=this.viewportData)==null?void 0:w.rows)==null?void 0:T[r])!=null?y:null}totalsColumn(t,e){var r,l,a,d;const n=this.totalsRow(e);if(n==null)return null;const s=(r=this.totals)==null?void 0:r.operationOrder[n],i=(a=(l=this.totals)==null?void 0:l.defaultOperation)!=null?a:Ae.SUM,o=this.columns[t];return(d=this.totalsTable)==null?void 0:d.columns.find(c=>{var u;return c.name===`${o.name}__${s}`||(s===i||((u=this.totals)==null?void 0:u.operationOrder.length)===1)&&c.name===o.name})}totalsRow(t){var i,o,r,l,a;const e=(r=(o=(i=this.totals)==null?void 0:i.operationOrder)==null?void 0:o.length)!=null?r:0,s=((a=(l=this.totals)==null?void 0:l.showOnTop)!=null?a:!1)?t:t-this.table.size;return s>=0&&s<e?s:null}pendingRow(t){const e=t-this.floatingTopRowCount-this.table.size;return e>=0&&e<this.pendingNewRowCount?e:null}isTotalsRow(t){return this.totalsRow(t)!=null}isPendingRow(t){return this.pendingRow(t)!=null}dataForCell(t,e){var n;return(n=this.row(e))==null?void 0:n.data.get(t)}formatForCell(t,e){var n;return(n=this.dataForCell(t,e))==null?void 0:n.format}valueForCell(t,e){var s;const n=this.dataForCell(t,e);if(n)return(s=n.value)!=null?s:null}copyViewportData(t){if(t==null){et.warn("invalid data!");return}this.viewportData=this.extractViewportData(t),this.formattedStringData=[]}copyTotalsData(t){var l,a,d,c,u;if(t==null){et.warn("invalid data!");return}const{columns:e,rows:n}=t;if(n.length!==1){et.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:Ae.SUM,r=(d=this.totals)==null?void 0:d.operationMap;for(let m=0;m<e.length;m+=1){const p=e[m],[g,f=(u=(c=r==null?void 0:r[g])==null?void 0:c[0])!=null?u:o]=p.name.split("__");s.has(f)||s.set(f,{data:new Map});const{data:b}=s.get(f),C=this.columns.findIndex(w=>w.name===g);b.set(C,{value:i.get(p),format:i.getFormat(p)})}et.debug2("copyTotalsData",s),this.totalsDataMap=s,this.formattedStringData=[]}getColumnIndexByName(t){return this.getColumnIndicesByNameMap(this.columns).get(t)}extractViewportData(t){const e={offset:t.offset,rows:[]},{columns:n}=t;for(let s=0;s<t.rows.length;s+=1){const i=t.rows[s],o=this.extractViewportRow(i,n);e.rows.push(o)}return e}extractViewportRow(t,e){const n=new Map;for(let s=0;s<e.length;s+=1){const i=e[s],o=this.getColumnIndexByName(i.name);A(o),n.set(o,{value:t.get(i),format:t.getFormat(i)})}return{data:n}}closeSubscription(){et.debug2("closeSubscription",this.subscription),this.subscription&&(this.subscription.close(),this.subscription=null),this.setViewport.cancel(),this.applyViewport.cancel()}get filter(){return this.table.filter}set filter(t){this.closeSubscription(),this.table.applyFilter(t),this.applyViewport()}get formatter(){return this.irisFormatter}set formatter(t){this.irisFormatter=t,this.formattedStringData=[],this.dispatchEvent(new Ge(be.EVENT.FORMATTER_UPDATED))}displayString(t,e,n="",s){return this.getCachedFormattedString(this.formatter,t,e,n,s)}get sort(){return this.table.sort}set sort(t){this.closeSubscription(),this.table.applySort(t),this.applyViewport()}set totalsConfig(t){if(et.debug("set totalsConfig",t),t!==this.totals){if(this.totals=t,this.formattedStringData=[],this.totalsTablePromise!=null&&this.totalsTablePromise.cancel(),this.setTotalsTable(null),t==null){this.dispatchEvent(new Ge(be.EVENT.UPDATED));return}this.totalsTablePromise=Ee.makeCancelable(this.table.getTotalsTable(t),e=>e.close()),this.totalsTablePromise.then(e=>{this.totalsTablePromise=null,this.setTotalsTable(e)}).catch(e=>{Ee.isCanceled(e)||(et.error("Unable to set next totalsTable",e),this.totalsTablePromise=null,this.dispatchEvent(new Ge(be.EVENT.REQUEST_FAILED,{detail:e})))})}}setTotalsTable(t){et.debug("setTotalsTable",t),this.totalsTable!==null&&(this.listenerCount>0&&this.removeTotalsListeners(this.totalsTable),this.totalsTable.close()),this.totalsTable=t,this.totalsDataMap=null,this.listenerCount>0&&this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable)}applyBufferedViewport(t,e,n){et.debug2("applyBufferedViewport",t,e,n),this.subscription==null?(et.debug2("applyBufferedViewport creating new subscription"),this.subscription=this.table.setViewport(t,e,n)):(et.debug2("applyBufferedViewport using existing subscription"),this.subscription.setViewport(t,e,n))}async snapshot(t,e=!1,n=s=>s){if(this.subscription==null)throw new Error("No subscription available");const s=re.consolidate(t);if(!se.isValidSnapshotRanges(s))throw new Error(`Invalid snapshot ranges ${t}`);const i=new Set,o=[],r=new Set;for(let u=0;u<s.length;u+=1){const m=s[u];A(m.endRow),A(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 re(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=se.columnsFromRanges(s,this.columns),a=[];e&&a.push(l.map(u=>u.name));const d=[...i].sort();for(let u=0;u<d.length;u+=1){const m=d[u],p=l.map(g=>{const f=this.getColumnIndexByName(g.name);return A(f),n(this.valueForCell(f,m),g)});e&&p.push(this.textForRowFooter(m)),a.push(p)}if(o.length>0){const u=se.rangeSetFromRanges(o),m=await this.subscription.snapshot(u,l);a.push(...m.rows.map(p=>l.map(g=>n(p.get(g),g))))}const c=[...r].sort();for(let u=0;u<c.length;u+=1){const m=c[u],p=l.map(g=>{const f=this.getColumnIndexByName(g.name);return A(f),n(this.valueForCell(f,m),g)});e&&p.push(this.textForRowFooter(m)),a.push(p)}return a}async textSnapshot(t,e=!1,n=s=>`${s}`){return et.debug2("textSnapshot",t,e),(await this.snapshot(t,e,n)).map(i=>i.join(" ")).join(`
|
|
35
35
|
`)}async valuesTable(t){let e=null;try{return e=await this.table.copy(),e.applyFilter([]),e.applySort([]),e.selectDistinct([t])}finally{e!=null&&e.close()}}isColumnMovable(t,e){if(t<0||t>=this.columnCount)return!1;if(e>0)return!0;const n=this.columns[t].name;return this.frontColumns.includes(n)||this.backColumns.includes(n)||this.frozenColumns.includes(n)||!n?!1:!this.isKeyColumn(t)}isKeyColumn(t){var e,n;return t<((n=(e=this.inputTable)==null?void 0:e.keyColumns.length)!=null?n:0)}isRowMovable(){return!1}isEditableRange(t){return this.inputTable!=null&&re.isBounded(t)&&(this.isPendingRow(t.startRow)&&this.isPendingRow(t.endRow)||t.startColumn>=this.inputTable.keyColumns.length&&t.endColumn>=this.inputTable.keyColumns.length)&&t.startRow>=this.floatingTopRowCount&&t.startRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount&&t.endRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount}isDeletableRange(t){return this.inputTable!=null&&t.startRow!=null&&t.endRow!=null&&t.startRow>=this.floatingTopRowCount&&t.startRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount&&t.endRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount}isEditableRanges(t){return t.every(e=>this.isEditableRange(e))}isDeletableRanges(t){return t.every(e=>this.isDeletableRange(e))}getTableAreaRange(){return new re(null,this.floatingTopRowCount,null,this.floatingTopRowCount+this.table.size-1)}getPendingAreaRange(){return new re(null,this.floatingTopRowCount+this.table.size,null,this.floatingTopRowCount+this.table.size+this.pendingNewRowCount-1)}async setValueForCell(t,e,n){return this.setValueForRanges([new re(t,e,t,e)],n)}async setValueForRanges(t,e){var n;if(!this.isEditableRanges(t))throw new Error(`Uneditable ranges ${t}`);try{const s=new Set,i=[];re.forEachCell(t,(d,c)=>{const u=this.columns[d];if(s.add(u),i[d]===void 0){const m=P.makeValue(u.type,e,this.formatter.timeZone);i[d]=m!=null?this.displayString(m,u.type,u.name):null}this.cachePendingValue(d,c,i[d])});const o=this.getPendingAreaRange(),r=t.map(d=>re.intersection(o,d)).filter(d=>d!=null).map(d=>(A(d),re.offset(d,0,-(this.floatingTopRowCount+this.table.size))));if(r.length>0){const d=new Map(this.pendingNewDataMap);re.forEachCell(r,(c,u)=>{d.has(u)||d.set(u,{data:new Map});const m=this.columns[c],p=d.get(u);A(p);const{data:g}=p,f=new Map(g),b=P.makeValue(m.type,e,this.formatter.timeZone);b!=null?f.set(c,{value:b}):f.delete(c),f.size>0?d.set(u,{...p,data:f}):d.delete(u)}),this.pendingDataMap=d}this.dispatchEvent(new Ge(be.EVENT.UPDATED));const l=this.getTableAreaRange(),a=t.map(d=>re.intersection(l,d)).filter(d=>d!=null);if(a.length>0){const c=(await this.snapshot(a.map(m=>{var p,g;return new re(null,(p=m==null?void 0:m.startRow)!=null?p:null,null,(g=m==null?void 0:m.endRow)!=null?g:null)}))).map(m=>{const p={};for(let g=0;g<this.columns.length;g+=1)p[this.columns[g].name]=m[g];return s.forEach(g=>{p[g.name]=P.makeValue(g.type,e,this.formatter.timeZone)}),p}),u=await((n=this.inputTable)==null?void 0:n.addRows(c));et.debug("setValueForRanges(",t,",",e,") set tableRanges",a,"result",u)}re.forEachCell(t,(d,c)=>{const u=i[d];A(u),this.cacheFormattedValue(d,c,u)})}catch(s){et.error("Unable to set ranges",t,e,s)}finally{re.forEachCell(t,(s,i)=>{this.clearPendingValue(s,i)})}}async setValues(t=[]){var e;if(et.debug("setValues(",t,")"),!t.every(n=>{var s,i;return this.isEditableRange(re.makeCell((s=n.column)!=null?s:n.x,(i=n.row)!=null?i:n.y))}))throw new Error(`Uneditable ranges ${t}`);try{const n=new Map(this.pendingNewDataMap);t.forEach(l=>{var f,b;const{text:a}=l,d=(f=l.column)!=null?f:l.x,c=(b=l.row)!=null?b:l.y,u=this.columns[d],m=P.makeValue(u.type,a,this.formatter.timeZone),p=m!=null?this.displayString(m,u.type,u.name):null;this.cachePendingValue(d,c,p);const g=this.pendingRow(c);if(g!=null){n.has(g)||n.set(g,{data:new Map});const C=n.get(g);A(C);const{data:w}=C,T=new Map(w);m!=null?T.set(d,{value:m}):T.delete(d),T.size>0?n.set(g,{...C,data:T}):n.delete(g)}}),this.pendingDataMap=n,this.dispatchEvent(new Ge(be.EVENT.UPDATED));const s=t.reduce((l,a)=>{var c,u;const d=(c=a.row)!=null?c:a.y;return l.has(d)||l.set(d,[]),(u=l.get(d))==null||u.push(a),l},new Map),i=re.consolidate(t.map(l=>{var a,d;return re.makeCell((a=l.column)!=null?a:l.x,(d=l.row)!=null?d:l.y)})),o=this.getTableAreaRange(),r=i.map(l=>re.intersection(o,l)).filter(l=>l!=null);if(r.length>0){const a=(await this.snapshot(r.map(c=>(A(c),new re(null,c.startRow,null,c.endRow))))).map((c,u)=>{let m=null,p=u;for(let b=0;b<r.length;b+=1){const C=r[b];A(C);const w=re.rowCount([C]);if(p<w){A(C.startRow),m=C.startRow+p;break}p-=w}const g={};for(let b=0;b<this.columns.length;b+=1)g[this.columns[b].name]=c[b];A(m);const f=s.get(m);return f!=null&&f.forEach(b=>{var w;const C=this.columns[(w=b.column)!=null?w:b.x];g[C.name]=P.makeValue(C.type,b.text,this.formatter.timeZone)}),g});et.info("setValues setting tableRanges",r);const d=await((e=this.inputTable)==null?void 0:e.addRows(a));et.info("setValues set tableRanges",r,"SUCCESS",d)}t.forEach(l=>{var g,f;const{text:a}=l,d=(g=l.column)!=null?g:l.x,c=(f=l.row)!=null?f:l.y,u=this.columns[d],m=P.makeValue(u.type,a,this.formatter.timeZone),p=m!=null?this.displayString(m,u.type,u.name):null;this.cacheFormattedValue(d,c,p)})}finally{t.forEach(n=>{this.clearPendingValue(n.column,n.row)})}}async commitPending(){var t,e,n;if(this.pendingNewDataMap.size<=0)throw new Error("No pending changes to commit");try{this.isSaveInProgress=!0;const s=[];this.pendingNewDataMap.forEach(o=>{const r={};o.data.forEach(({value:l},a)=>{const d=this.columns[a];r[d.name]=l}),s.push(r)});const i=await((t=this.inputTable)==null?void 0:t.addRows(s));et.debug("commitPending()",this.pendingNewDataMap,"result",i),this.pendingNewDataMap=new Map,this.pendingNewDataErrors=new Map,this.pendingNewRowCount=Math.max(0,((n=(e=this.viewport)==null?void 0:e.bottom)!=null?n:0)-this.table.size),this.formattedStringData=[],this.dispatchEvent(new Ge(be.EVENT.PENDING_DATA_UPDATED))}finally{this.isSaveInProgress=!1}}editValueForCell(t,e){return this.textValueForCell(t,e)}async delete(t){if(!this.isDeletableRanges(t))throw new Error(`Undeletable ranges ${t}`);A(this.inputTable);const{keyColumns:e}=this.inputTable;if(e.length===0)throw new Error("No key columns to allow deletion");const n=this.getPendingAreaRange(),s=t.map(c=>re.intersection(n,c)).filter(c=>c!=null).map(c=>(A(c),re.offset(c,0,-(this.floatingTopRowCount+this.table.size))));if(s.length>0){const c=new Map(this.pendingNewDataMap);for(let u=0;u<s.length;u+=1){const m=s[u];A(m.startRow),A(m.endRow);for(let p=m.startRow;p<=m.endRow;p+=1)c.delete(p)}this.pendingNewDataMap=c,this.formattedStringData=[],this.dispatchEvent(new Ge(be.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new Ge(be.EVENT.UPDATED))}const i=this.getTableAreaRange(),o=t.map(c=>re.intersection(i,c)).filter(c=>c!=null);if(o.length<=0)return;const[r,l]=await Promise.all([this.snapshot(o.map(c=>(A(c),new re(0,c.startRow,e.length-1,c.endRow)))),this.table.copy()]),d=r.map(c=>{const u=[];for(let m=0;m<e.length;m+=1){const p=e[m],g=c[m],f=P.makeFilterRawValue(p.type,g),b=p.filter().eq(f);u.push(b)}return u.reduce((m,p)=>{var g;return(g=m==null?void 0:m.and(p))!=null?g:p})}).reduce((c,u)=>{var m;return(m=c==null?void 0:c.or(u))!=null?m:u});l.applyFilter([d]),l.close()}isValidForCell(t,e,n){try{const s=this.columns[t];return P.makeValue(s.type,n,this.formatter.timeZone),!0}catch{return!1}}};let Wd=Ba;Wd.ROW_BUFFER_PAGES=1;const Rs=X.module("IrisGridTableModel"),ga=Object.freeze([]);class Cp extends Wd{constructor(e,n=new cn,s=null){super(e,n,s),this.getMemoizedFrontColumns=he(i=>i!=null?i:ga),this.getMemoizedBackColumns=he(i=>i!=null?i:ga),this.getMemoizedFrozenColumns=he((i,o)=>{var r;return(r=o!=null?o:i)!=null?r:ga}),this.getCachedFilterableColumnSet=he(i=>new Set(i.map((o,r)=>r))),this.customColumnList=[],this.formatColumnList=[]}get isExportAvailable(){return this.table.freeze!=null}get isColumnStatisticsAvailable(){return this.table.getColumnStatistics!=null}get isValuesTableAvailable(){return this.table.selectDistinct!=null&&this.table.copy!=null}get isRollupAvailable(){return this.table.rollup!=null}get isSelectDistinctAvailable(){return this.table.selectDistinct!=null}get isCustomColumnsAvailable(){return this.table.applyCustomColumns!=null}get isFormatColumnsAvailable(){return this.table.applyCustomColumns!=null}get frontColumns(){var e;return this.getMemoizedFrontColumns((e=this.layoutHints)==null?void 0:e.frontColumns)}get backColumns(){var e;return this.getMemoizedBackColumns((e=this.layoutHints)==null?void 0:e.backColumns)}get frozenColumns(){var e;return this.getMemoizedFrozenColumns((e=this.layoutHints)==null?void 0:e.frozenColumns,this.userFrozenColumns)}get layoutHints(){return this.table.layoutHints}get floatingLeftColumnCount(){return this.frozenColumns.length}get description(){return this.table.description}get customColumns(){return this.customColumnList}set customColumns(e){if(Rs.debug2("set customColumns",e,this.customColumnList,e===this.customColumnList),this.customColumnList.length===0&&e.length===0){Rs.debug("Ignore empty initial customColumns"),this.customColumnList=e;return}if(this.customColumnList===e){Rs.debug("Ignore same customColumns");return}this.closeSubscription(),this.customColumnList=e,this.table.applyCustomColumns([...e,...this.formatColumns]),this.applyViewport()}get formatColumns(){return this.formatColumnList}set formatColumns(e){if(Rs.debug2("set formatColumns",e,this.formatColumnList,e===this.formatColumnList),this.formatColumnList.length===0&&e.length===0){Rs.debug("Ignore empty initial formatColumns"),this.formatColumnList=e;return}if(this.formatColumnList===e){Rs.debug("Ignore same formatColumns");return}this.closeSubscription(),this.formatColumnList=e,this.table.applyCustomColumns([...this.customColumns,...e]),this.applyViewport()}updateFrozenColumns(e){this.userFrozenColumns=e,this.dispatchEvent(new Ge(be.EVENT.TABLE_CHANGED,{detail:this.table}))}set totalsConfig(e){if(Rs.debug("set totalsConfig",e),e!==this.totals){if(this.totals=e,this.formattedStringData=[],this.totalsTablePromise!=null&&this.totalsTablePromise.cancel(),this.setTotalsTable(null),e==null){this.dispatchEvent(new Ge(be.EVENT.UPDATED));return}this.totalsTablePromise=Ee.makeCancelable(this.table.getTotalsTable(e),n=>n.close()),this.totalsTablePromise.then(n=>{this.totalsTablePromise=null,this.setTotalsTable(n)}).catch(n=>{Ee.isCanceled(n)||(Rs.error("Unable to set next totalsTable",n),this.totalsTablePromise=null,this.dispatchEvent(new Ge(be.EVENT.REQUEST_FAILED,{detail:n})))})}}get isFilterRequired(){return this.table.isUncoalesced}isFilterable(e){return this.getCachedFilterableColumnSet(this.columns).has(e)}async export(){return this.table.freeze()}columnStatistics(e){return this.table.getColumnStatistics(e)}isColumnMovable(e){const n=this.columns[e].name;return this.frontColumns.includes(n)||this.backColumns.includes(n)||this.frozenColumns.includes(n)?!1:!this.isKeyColumn(e)}isColumnFrozen(e){return this.frozenColumns.includes(this.columns[e].name)}async delete(e){var u;if(!this.isDeletableRanges(e))throw new Error(`Undeletable ranges ${e}`);A(this.inputTable);const{keyColumns:n}=this.inputTable;if(n.length===0)throw new Error("No key columns to allow deletion");const s=this.getPendingAreaRange(),i=e.map(m=>re.intersection(s,m)).filter(m=>m!=null).map(m=>(A(m),re.offset(m,0,-(this.floatingTopRowCount+this.table.size))));if(i.length>0){const m=new Map(super.pendingDataMap);for(let p=0;p<i.length;p+=1){const g=i[p];A(g.startRow),A(g.endRow);for(let f=g.startRow;f<=g.endRow;f+=1)m.delete(f)}super.pendingDataMap=m,this.formattedStringData=[],this.dispatchEvent(new Ge(be.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new Ge(be.EVENT.UPDATED))}const o=this.getTableAreaRange(),r=e.map(m=>re.intersection(o,m)).filter(m=>m!=null);if(r.length<=0)return;const[l,a]=await Promise.all([this.snapshot(r.map(m=>(A(m),new re(0,m.startRow,n.length-1,m.endRow)))),this.table.copy()]),c=l.map(m=>{const p=[];for(let g=0;g<n.length;g+=1){const f=n[g],b=m[g],C=P.makeFilterRawValue(f.type,b),w=f.filter().eq(C);p.push(w)}return p.reduce((g,f)=>{var b;return(b=g==null?void 0:g.and(f))!=null?b:f})}).reduce((m,p)=>{var g;return(g=m==null?void 0:m.or(p))!=null?g:p});a.applyFilter([c]),await((u=this.inputTable)==null?void 0:u.deleteTable(a)),a.close()}}class qT extends Wd{constructor(){super(...arguments),this.getCachedFilterableColumnSet=he((e,n)=>new Set(((n==null?void 0:n.length)>0?n:e).map(s=>e.findIndex(i=>s.name===i.name))))}applyBufferedViewport(e,n,s){this.table.setViewport(e,n,s)}textForCell(e,n){const s=this.columns[e],i=this.row(n);if(i!=null&&s!=null&&!i.hasChildren&&s.constituentType!=null){const o=this.valueForCell(e,n);return this.displayString(o,s.constituentType,s.name)}return super.textForCell(e,n)}extractViewportRow(e,n){const{isExpanded:s,hasChildren:i,depth:o}=e;return{...super.extractViewportRow(e,n),isExpanded:s,hasChildren:i,depth:o}}async snapshot(e,n,s){var l,a,d,c;A(this.viewport),A(this.viewportData);const{columns:i}=this.viewport,o=[];n!=null&&n&&o.push(i.map(u=>u.name));const r=new re(0,(l=this.viewportData)==null?void 0:l.offset,i.length,((a=this.viewportData)==null?void 0:a.offset)+((d=this.viewportData)==null?void 0:d.rows.length));for(let u=0;u<e.length;u+=1){const m=re.intersection(r,e[u]);A(m),A(m.startRow),A(m.endRow);for(let p=m.startRow;p<=m.endRow;p+=1){const g=[],f=this.viewportData.rows[p-this.viewportData.offset];A(m.startColumn),A(m.endColumn);for(let b=m.startColumn;b<=m.endColumn;b+=1)A(s),g.push(s((c=f.data.get(b))==null?void 0:c.value,this.columns[b]));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(e){return this.getCachedFilterableColumnSet(this.columns,this.groupedColumns).has(e)}isColumnMovable(e){return e>=this.groupedColumns.length}isRowExpandable(e){var s;const n=this.row(e);return(s=n==null?void 0:n.hasChildren)!=null?s:!1}isRowExpanded(e){var s;const n=this.row(e);return(s=n==null?void 0:n.isExpanded)!=null?s:!1}setRowExpanded(e,n){this.table.setExpanded(e,n)}depthForRow(e){var s;const n=this.row(e);return((s=n==null?void 0:n.depth)!=null?s:1)-1}}const Ds=X.module("IrisGridProxyModel");function fa(t,e,n){return P.isTreeTable(t)?new qT(t,e):new Cp(t,e,n)}class YT extends be{constructor(e,n=new cn,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)=>gt(this.model)?this.model.isRowExpandable(...o):!1,this.isRowExpanded=(...o)=>gt(this.model)?this.model.isRowExpanded(...o):!1,this.setRowExpanded=(...o)=>{if(gt(this.model))return this.model.setRowExpanded(...o);throw Error("Function setRowExpanded does not exist on IrisGridTableModel")},this.depthForRow=(...o)=>gt(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)=>Ze(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)=>(Ze(this.model)&&this.model.editValueForCell(...o),""),this.setValueForCell=(...o)=>Ze(this.model)?this.model.setValueForCell(...o):Promise.reject(new Error("Model is not editable")),this.setValueForRanges=(...o)=>Ze(this.model)?this.model.setValueForRanges(...o):Promise.reject(new Error("Model is not editable")),this.setValues=(...o)=>Ze(this.model)?this.model.setValues(...o):Promise.resolve(),this.isValidForCell=(...o)=>Ze(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=fa(e,n,s);this.originalModel=i,this.model=i,this.modelPromise=null,this.rollup=null,this.selectDistinct=[]}close(){this.originalModel.close(),this.model!==this.originalModel&&this.model.close(),this.modelPromise!=null&&this.modelPromise.cancel()}handleModelEvent(e){Ds.debug2("handleModelEvent",e);const{detail:n,type:s}=e;this.dispatchEvent(new Ge(s,{detail:n}))}setModel(e){Ds.debug("setModel",e);const n=this.model;n!==this.originalModel&&n.close(),this.model=e,this.listenerCount>0&&this.addListeners(e),this.dispatchEvent(new Ge(be.EVENT.COLUMNS_CHANGED,{detail:e.columns})),ri(e)&&this.dispatchEvent(new Ge(be.EVENT.TABLE_CHANGED,{detail:e.table}))}setNextModel(e){Ds.debug2("setNextModel"),this.modelPromise&&this.modelPromise.cancel(),this.listenerCount>0&&this.removeListeners(this.model),this.modelPromise=Ee.makeCancelable(e,n=>n.close()),this.modelPromise.then(n=>{this.modelPromise=null,this.setModel(n)}).catch(n=>{if(Ee.isCanceled(n)){Ds.debug2("setNextModel cancelled");return}Ds.error("Unable to set next model",n),this.modelPromise=null,this.dispatchEvent(new Ge(be.EVENT.REQUEST_FAILED,{detail:n}))})}startListening(){super.startListening(),this.addListeners(this.model)}stopListening(){super.stopListening(),this.removeListeners(this.model)}addListeners(e){const n=Object.keys(be.EVENT);for(let s=0;s<n.length;s+=1)e.addEventListener(n[s],this.handleModelEvent)}removeListeners(e){const n=Object.keys(be.EVENT);for(let s=0;s<n.length;s+=1)e.removeEventListener(n[s],this.handleModelEvent)}get rowCount(){return this.model.rowCount}get columnCount(){return this.model.columnCount}get floatingTopRowCount(){return this.model.floatingTopRowCount}get floatingBottomRowCount(){return this.model.floatingBottomRowCount}get floatingLeftColumnCount(){return this.model.floatingLeftColumnCount}get floatingRightColumnCount(){return this.model.floatingRightColumnCount}isColumnFrozen(e){return this.model.isColumnFrozen(e)}get hasExpandableRows(){return gt(this.model)?this.model.hasExpandableRows:!1}get isExportAvailable(){return this.model.isExportAvailable}get isColumnStatisticsAvailable(){return this.model.isColumnStatisticsAvailable}get isValuesTableAvailable(){return this.model.isValuesTableAvailable}get isCustomColumnsAvailable(){return this.model.isCustomColumnsAvailable&&!(this.isSelectDistinctAvailable&&this.selectDistinctColumns.length>0)}get isFormatColumnsAvailable(){return this.model.isFormatColumnsAvailable}get isChartBuilderAvailable(){return this.model.isChartBuilderAvailable}get isRollupAvailable(){return(this.originalModel.isRollupAvailable||this.rollup!=null)&&this.selectDistinct.length===0}get isSelectDistinctAvailable(){return(this.originalModel.isSelectDistinctAvailable||this.selectDistinct.length>0)&&this.rollup==null}get isTotalsAvailable(){return this.model.isTotalsAvailable}get isReversible(){return this.model.isReversible}get columns(){return this.model.columns}get movedColumns(){return this.model.movedColumns}get movedRows(){return this.model.movedRows}get layoutHints(){return this.model.layoutHints}get frontColumns(){return this.model.frontColumns}get backColumns(){return this.model.backColumns}get frozenColumns(){return this.model.frozenColumns}get columnHeaderMaxDepth(){return this.model.columnHeaderMaxDepth}updateFrozenColumns(e){return this.model.updateFrozenColumns(e)}get originalColumns(){return this.originalModel.columns}get groupedColumns(){return this.model.groupedColumns}get description(){return this.model.description}get filter(){return this.model.filter}set filter(e){this.model.filter=e}get formatter(){return this.model.formatter}set formatter(e){this.model.formatter=e}get sort(){return this.model.sort}set sort(e){this.model.sort=e}get customColumns(){return this.model.customColumns}set customColumns(e){this.model.customColumns=e}get formatColumns(){return this.model.formatColumns}set formatColumns(e){this.model.formatColumns=e}get rollupConfig(){return this.rollup}set rollupConfig(e){if(Ds.debug("set rollupConfig",e),!this.isRollupAvailable)throw new Error("Rollup Rows are not available");if(ct(e,this.rollup))return;this.rollup=e;let n=Promise.resolve(this.originalModel);ri(this.originalModel)&&e!=null&&(n=this.originalModel.table.rollup(e).then(s=>fa(s,this.formatter))),this.setNextModel(n)}get selectDistinctColumns(){return this.selectDistinct}set selectDistinctColumns(e){if(Ds.debug("set selectDistinctColumns",e),!this.isSelectDistinctAvailable)throw new Error("Select distinct is not available");if(e===this.selectDistinctColumns||e.length===0&&this.selectDistinctColumns.length===0){Ds.debug("Ignore same selectDistinctColumns",e);return}this.selectDistinct=e;const n=e.map(i=>this.originalColumns.find(o=>o.name===i)).filter(i=>i!=null);let s=Promise.resolve(this.originalModel);ri(this.originalModel)&&n.length>0&&(s=this.originalModel.table.selectDistinct(n).then(i=>fa(i,this.formatter))),this.setNextModel(s)}get table(){if(ri(this.model))return this.model.table}get totalsConfig(){return this.model.totalsConfig}set totalsConfig(e){this.model.totalsConfig=e}get isFilterRequired(){return this.model.isFilterRequired}get isEditable(){return Ze(this.model)&&this.model.isEditable}export(){if(P.isTreeTable(this.model))throw new Error("TreeTable has no 'export' property");return this.model.export()}columnStatistics(e){if(P.isTreeTable(this.model))throw new Error("TreeTable has no 'columnStatistics' function");return this.model.columnStatistics(e)}get pendingDataMap(){return this.model.pendingDataMap}set pendingDataMap(e){this.model.pendingDataMap=e}get pendingRowCount(){return this.model.pendingRowCount}set pendingRowCount(e){this.model.pendingRowCount=e}get pendingDataErrors(){return this.model.pendingDataErrors}getColumnIndexByName(e){return this.model.getColumnIndexByName(e)}}class Gd{static async makeModel(e,n=new cn){let s=null;return!P.isTreeTable(e)&&e.hasInputTable&&(s=await e.inputTable()),new YT(e,n,s)}}const ts=X.module("TableViewportUpdater"),XT=150,Mo=class extends S.exports.PureComponent{constructor(){super(...arguments),this.getViewportRowRange=he((t,e,n)=>{const s=n-e,i=Math.max(0,e-s*Mo.ROW_BUFFER_PAGES),o=n+s*Mo.ROW_BUFFER_PAGES;return[i,o]}),this.getViewportColumns=he((t,e,n,s)=>{if(e==null||n==null)return null;const i=n-e,o=Math.max(0,e-i*Mo.COLUMN_BUFFER_PAGES),r=Math.min(n+i*Mo.COLUMN_BUFFER_PAGES,t.columns.length-1),l=[];for(let a=o;a<=r;a+=1){const d=G.getModelIndex(a,s);l.push(t.columns[d])}return l}),this.updateViewport=hs((t,e,n,s,i)=>{if(e<t){ts.error("Invalid viewport",t,e);return}if(t===0&&e===0){ts.debug2("Ignoring 0-0 viewport");return}const{movedColumns:o,table:r}=this.props,[l,a]=this.getViewportRowRange(r,t,e),d=i!=null?i:this.getViewportColumns(r,n,s,o);if(ts.debug2("Setting Viewport Top:",l,"Bottom:",a,"Columns:",d),this.subscription==null){ts.debug2("updateViewport creating new subscription"),this.subscription=r.setViewport(l,a,d);const{onSubscription:c}=this.props;c(this.subscription)}else ts.debug2("updateViewport using existing subscription"),this.subscription.setViewport(l,a,d)},XT)}componentDidMount(){const{top:t,bottom:e,left:n,right:s,table:i,filters:o,sorts:r,columns:l,customColumns:a}=this.props;i.applyFilter(o),i.applySort(r),i.applyCustomColumns(a),this.updateViewport(t,e,n,s,l)}componentDidUpdate(t){const{top:e,bottom:n,left:s,right:i,table:o,filters:r,sorts:l,customColumns:a,columns:d}=this.props,c=r!==t.filters,u=l!==t.sorts,m=a!==t.customColumns,p=o!==t.table;(c||u||m||p)&&this.closeSubscription(),(c||p)&&(ts.debug("update table filter",r),o.applyFilter(r)),(u||p)&&(ts.debug("update table sort",l),o.applySort(l)),(m||p)&&(ts.debug("update table custom columns",a),o.applyCustomColumns(a)),this.updateViewport(e,n,s,i,d)}componentWillUnmount(){this.closeSubscription()}closeSubscription(){if(ts.debug2("closeSubscription",this.subscription),this.subscription){this.subscription.close(),this.subscription=void 0;const{onSubscription:t}=this.props;t()}this.updateViewport.cancel()}render(){return null}};let Kd=Mo;Kd.ROW_BUFFER_PAGES=3;Kd.COLUMN_BUFFER_PAGES=1;Kd.defaultProps={top:0,bottom:0,left:null,right:null,columns:null,onSubscription:()=>{},filters:[],sorts:[],customColumns:[],movedColumns:[]};const Ii=X.module("TreeTableViewportUpdater"),jT=150,bp=class extends S.exports.PureComponent{constructor(t){super(t),this.updateViewport=hs((e,n)=>{if(n<e){Ii.error("Invalid viewport",e,n);return}if(e===0&&n===0){Ii.debug2("Ignoring 0-0 viewport");return}const{table:s,updateInterval:i}=this.props,o=n-e,r=Math.max(0,e-o*3),l=n+o*3+1;if(Ii.debug2("Setting Viewport Top:",r,"Bottom:",l,s),!this.listenerCleanup){const{onViewportUpdate:a}=this.props;this.listenerCleanup=s.addEventListener(M.TreeTable.EVENT_UPDATED,a)}s.setViewport(r,l,void 0,i)},jT),this.updateViewport=this.updateViewport.bind(this),this.listenerCleanup=null}componentDidMount(){const{top:t,bottom:e,table:n,filters:s,sorts:i}=this.props;Ii.debug("componentDidMount",this.props),n.applyFilter(s),n.applySort(i),this.updateViewport(t,e)}componentDidUpdate(t){const{top:e,bottom:n,table:s,filters:i,sorts:o}=this.props;i!==t.filters&&(Ii.debug("update table filter",i),s.applyFilter(i)),o!==t.sorts&&(Ii.debug("update table sort",o),s.applySort(o)),this.updateViewport(e,n)}componentWillUnmount(){this.updateViewport.cancel(),this.listenerCleanup&&this.listenerCleanup()}render(){return null}};let Sp=bp;Sp.UPDATE_INTERVAL=1e3;Sp.defaultProps={top:0,bottom:0,onViewportUpdate:()=>{},filters:[],sorts:[],updateInterval:bp.UPDATE_INTERVAL};class Gi{}Gi.OPEN="ChartEvent.OPEN";Gi.CLOSE="ChartEvent.CLOSE";Gi.COLUMN_SELECTED="ChartEvent.COLUMN_SELECTED";class ft{}ft.SESSION_OPENED="ConsoleEvent.SESSION_OPENED";ft.SESSION_CLOSED="ConsoleEvent.SESSION_CLOSED";ft.FOCUS_HISTORY="ConsoleEvent.FOCUS_HISTORY";ft.SEND_COMMAND="ConsoleEvent.SEND_COMMAND";ft.SETTINGS_CHANGED="ConsoleEvent.SETTINGS_CHANGED";class He{}He.TABLE_CHANGED="InputFilterEvent.TABLE_CHANGED";He.COLUMNS_CHANGED="InputFilterEvent.COLUMNS_CHANGED";He.FILTERS_CHANGED="InputFilterEvent.FILTERS_CHANGED";He.CLEAR_ALL_FILTERS="InputFilterEvent.CLEAR_ALL_FILTERS";He.COLUMN_SELECTED="InputFilterEvent.COLUMN_SELECTED";He.OPEN_DROPDOWN="InputFilterEvent.OPEN_DROPDOWN";He.OPEN_INPUT="InputFilterEvent.OPEN_INPUT";He.OPEN_FILTER_SET_MANAGER="InputFilterEvent.OPEN_FILTER_SET_MANAGER";class wt{}wt.OPEN_GRID="IrisGridEvent.OPEN_GRID";wt.CLOSE_GRID="IrisGridEvent.CLOSE_GRID";wt.DATA_SELECTED="IrisGridEvent.DATA_SELECTED";wt.COLUMN_SELECTED="IrisGridEvent.COLUMN_SELECTED";wt.STATE_CHANGED="IrisGridEvent.STATE_CHANGED";wt.CREATE_CHART="IrisGridevent.CREATE_CHART";const wp=Object.freeze({OPEN:"MarkdownEvent.OPEN"});class Ve{}Ve.CREATE_NOTEBOOK="NotebookEvent.createNotebook";Ve.SELECT_NOTEBOOK="NotebookEvent.selectNotebook";Ve.CLOSE_FILE="NotebookEvent.closeFile";Ve.RENAME="NotebookEvent.rename";Ve.RENAME_FILE="NotebookEvent.renameFile";Ve.REGISTER_FILE="NotebookEvent.registerFile";Ve.SEND_TO_NOTEBOOK="NotebookEvent.sendToNotebook";Ve.UNREGISTER_FILE="NotebookEvent.unregisterFile";class zn{}zn.focus="TabEvent.focus";zn.blur="TabEvent.blur";zn.openPQObject="TabEvent.openPQObject";zn.openControl="TabEvent.openControl";zn.reload="TabEvent.reload";zn.clearAllFilters="TabEvent.clearAllFilters";class vp extends S.exports.PureComponent{constructor(e){super(e),this.handleCloseTab=this.handleCloseTab.bind(this),this.handleCloseTabsRight=this.handleCloseTabsRight.bind(this),this.handleCloseTabsAll=this.handleCloseTabsAll.bind(this)}getAllTabs(){var n,s,i;const{glContainer:e}=this.props;return[...(i=(s=(n=e==null?void 0:e.tab)==null?void 0:n.header)==null?void 0:s.tabs)!=null?i:[]]}handleCloseTab(){const{glContainer:e}=this.props;e.close()}handleCloseTabsAll(){this.getAllTabs().forEach(n=>{var s;return(s=(n==null?void 0:n.contentItem).container)==null?void 0:s.close()})}handleCloseTabsRight(){var s,i,o,r,l,a,d;const{glContainer:e}=this.props,n=this.getAllTabs();for(let c=n.length-1;c>0&&((i=(s=n[c].contentItem)==null?void 0:s.config)==null?void 0:i.id)!==((l=(r=(o=e.tab)==null?void 0:o.contentItem)==null?void 0:r.config)==null?void 0:l.id);c-=1)(d=((a=n[c])==null?void 0:a.contentItem).container)==null||d.close()}canCloseTabsRight(){var i,o,r,l,a,d,c,u;const{glContainer:e}=this.props,n=this.getAllTabs();let s=!0;for(let m=n.length-1;m>0&&((o=(i=n[m].contentItem)==null?void 0:i.config)==null?void 0:o.id)!==((a=(l=(r=e.tab)==null?void 0:r.contentItem)==null?void 0:l.config)==null?void 0:a.id);m-=1)if(Boolean((u=(c=(d=n[m])==null?void 0:d.contentItem)==null?void 0:c.config)==null?void 0:u.isClosable)){s=!1;break}return s}canCloseAny(){var s,i,o;const e=this.getAllTabs();let n=!0;for(let r=e.length-1;r>0;r-=1)if(Boolean((o=(i=(s=e[r])==null?void 0:s.contentItem)==null?void 0:i.config)==null?void 0:o.isClosable)){n=!1;break}return n}render(){var o,r,l;const{additionalActions:e,glContainer:n}=this.props,s=[...e],i=(l=(r=(o=n.tab)==null?void 0:o.contentItem)==null?void 0:r.config)==null?void 0:l.isClosable;return s.push({title:"Close",order:10,group:oe.groups.low,action:this.handleCloseTab,disabled:i===void 0||!i}),s.push(()=>({title:"Close Tabs to Right",order:20,group:oe.groups.low,action:this.handleCloseTabsRight,disabled:this.canCloseTabsRight()})),s.push(()=>({title:"Close All",order:30,group:oe.groups.low,action:this.handleCloseTabsAll,disabled:this.canCloseAny()})),h(oe,{actions:s})}}vp.defaultProps={additionalActions:[]};class Tp extends S.exports.PureComponent{constructor(e){super(e),this.handleRenameDialogOpened=this.handleRenameDialogOpened.bind(this),this.handleRenameInputChange=this.handleRenameInputChange.bind(this),this.handleRenameCancel=this.handleRenameCancel.bind(this),this.handleRenameSubmit=this.handleRenameSubmit.bind(this),this.renameInputRef=Y.createRef();const{value:n}=e;this.state={value:n,valueWasValidated:!1}}componentDidUpdate(e){const{isShown:n}=e,{isShown:s}=this.props;s&&!n&&this.resetState()}resetState(){const{value:e}=this.props;this.setState({value:e,valueWasValidated:!1})}handleRenameDialogOpened(){var e,n;(n=(e=this.renameInputRef)==null?void 0:e.current)==null||n.focus()}handleRenameInputChange(e){this.setState({value:e.target.value})}handleRenameCancel(){const{onCancel:e}=this.props;e()}handleRenameSubmit(e){e.stopPropagation(),e.preventDefault();const{value:n}=this.state,s=n==null?void 0:n.trim();if(s!==void 0&&s!==""){const{onSubmit:i}=this.props;i(s)}else this.setState({value:s,valueWasValidated:!0})}renderRenameDialog(){const{isShared:e,isOwner:n,itemType:s}=this.props,{value:i,valueWasValidated:o}=this.state;return v("form",{className:z("p-3",{"was-validated":o}),onSubmit:this.handleRenameSubmit,noValidate:!0,role:"presentation",onMouseDown:r=>{r.stopPropagation()},onMouseUp:r=>{r.stopPropagation()},children:[v("div",{className:"form-group",children:[v("label",{htmlFor:`rename-dialog-${s}-input`,children:["Rename ",s]}),h("input",{type:"text",className:"form-control",id:`rename-dialog-${s}-input`,value:i!=null?i:void 0,ref:this.renameInputRef,onChange:this.handleRenameInputChange,required:!0}),v("div",{className:"invalid-feedback",children:[s," name cannot be empty"]}),(e||!n)&&v("div",{className:"pt-2",children:["Renaming this ",s," will rename for all users."]})]}),v("div",{className:"text-right",children:[h(Q,{kind:"secondary",className:"mr-2",onClick:this.handleRenameCancel,children:"Cancel"}),h(Q,{kind:"primary",type:"submit",children:"Rename"})]})]})}render(){const{isShown:e,onCancel:n}=this.props;return h(xn,{isShown:e,onEntered:this.handleRenameDialogOpened,onExited:n,options:{placement:"bottom",modifiers:{preventOverflow:{boundariesElement:"viewport"}}},interactive:!0,closeOnBlur:!0,children:this.renderRenameDialog()})}}Tp.defaultProps={isShared:!1,isOwner:!0,itemType:"Item",value:""};const QT=X.module("Panel");class Yn extends S.exports.PureComponent{constructor(e){super(e),this.getAdditionActions=he((s,i,o)=>{const r=[];return i&&r.push(this.getCloneAction()),o&&r.push(this.getRenameAction()),[...r,...s]}),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.handleCopyPanel=this.handleCopyPanel.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleHide=this.handleHide.bind(this),this.handleResize=this.handleResize.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleBeforeShow=this.handleBeforeShow.bind(this),this.handleShow=this.handleShow.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleRenameCancel=this.handleRenameCancel.bind(this),this.handleRenameSubmit=this.handleRenameSubmit.bind(this),this.handleShowRenameDialog=this.handleShowRenameDialog.bind(this),this.handleTabClicked=this.handleTabClicked.bind(this),this.handleTab=this.handleTab.bind(this);const{glContainer:n}=this.props;this.state={title:te.getTitleFromContainer(n),showRenameDialog:!1}}componentDidMount(){const{componentPanel:e,glContainer:n,glEventHub:s}=this.props;n.on("resize",this.handleResize),n.on("show",this.handleBeforeShow),n.on("shown",this.handleShow),n.on("hide",this.handleHide),n.on("tab",this.handleTab),n.on("tabClicked",this.handleTabClicked),s.on(ft.SESSION_CLOSED,this.handleSessionClosed),s.on(ft.SESSION_OPENED,this.handleSessionOpened),s.on(zn.focus,this.handleTabFocus),s.on(zn.blur,this.handleTabBlur),s.on(He.CLEAR_ALL_FILTERS,this.handleClearAllFilters),s.emit(Me.MOUNT,e)}componentWillUnmount(){const{componentPanel:e,glContainer:n,glEventHub:s}=this.props;n.off("resize",this.handleResize),n.off("show",this.handleBeforeShow),n.off("shown",this.handleShow),n.off("hide",this.handleHide),n.off("tab",this.handleTab),n.off("tabClicked",this.handleTabClicked),s.off(ft.SESSION_CLOSED,this.handleSessionClosed),s.off(ft.SESSION_OPENED,this.handleSessionOpened),s.off(zn.focus,this.handleTabFocus),s.off(zn.blur,this.handleTabBlur),s.off(He.CLEAR_ALL_FILTERS,this.handleClearAllFilters),s.emit(Me.UNMOUNT,e)}handleTab(e){e!=null&&this.setState({title:te.getTitleFromTab(e)}),this.forceUpdate();const{onTab:n}=this.props;n(e)}handleTabClicked(...e){const{onTabClicked:n}=this.props;n(...e)}handleClearAllFilters(...e){const{onClearAllFilters:n}=this.props;n(...e)}handleFocus(e){const{componentPanel:n,glEventHub:s}=this.props;s.emit(Me.FOCUS,n);const{onFocus:i}=this.props;i(e)}handleBlur(e){const{onBlur:n}=this.props;n(e)}handleHide(...e){const{onHide:n}=this.props;n(...e)}handleResize(...e){const{onResize:n}=this.props;n(...e)}handleSessionClosed(e){const{onSessionClose:n}=this.props;n(e)}handleSessionOpened(e,n){const{onSessionOpen:s}=this.props;s(e,n)}handleBeforeShow(...e){const{onBeforeShow:n}=this.props;n(...e)}handleShow(...e){const{onShow:n}=this.props;n(...e)}handleTabBlur(...e){const{onTabBlur:n}=this.props;n(...e)}handleTabFocus(...e){const{onTabFocus:n}=this.props;n(...e)}handleRenameCancel(){this.setState({showRenameDialog:!1})}handleShowRenameDialog(){this.setState({showRenameDialog:!0})}handleRenameSubmit(e){const{glContainer:n}=this.props;this.setState({showRenameDialog:!1,title:e});const s=te.getRootFromContainer(n),i=te.getComponentConfigFromContainer(n);A(i),te.renameComponent(s,i,e)}handleCopyPanel(){const{glContainer:e,glEventHub:n}=this.props,s=te.getRootFromContainer(e),i=te.getComponentConfigFromContainer(e);if(i==null){QT.error("Could not get component config from container",e);return}const o=te.cloneComponent(s,i);o!==null&&n.emit(Me.CLONED,this,o)}getCloneAction(){return{title:"Copy Panel",order:10,group:oe.groups.high,action:this.handleCopyPanel}}getRenameAction(){return{title:"Rename",order:10,group:oe.groups.medium,action:this.handleShowRenameDialog}}render(){const{children:e,className:n,renderTabTooltip:s,glContainer:i,additionalActions:o,errorMessage:r,isLoaded:l,isLoading:a,isClonable:d,isRenamable:c}=this.props,{tab:u}=i,{showRenameDialog:m,title:p}=this.state;return v("div",{className:z("h-100 w-100 iris-panel",n),onFocusCapture:this.handleFocus,onBlurCapture:this.handleBlur,children:[e,h(Cl,{errorMessage:r,isLoaded:l,isLoading:a}),u!=null&&ui.createPortal(v(ue,{children:[h(vp,{glContainer:i,additionalActions:this.getAdditionActions(o,d,c)}),c&&h(Tp,{isShown:m,value:p,itemType:"Panel",onCancel:this.handleRenameCancel,onSubmit:this.handleRenameSubmit}),s!=null&&h(Ie,{interactive:!0,options:{placement:"bottom"},popperClassName:"panel-tab-popper",children:s()})]}),u.element[0])]})}}Yn.defaultProps={className:"",onTab:()=>{},onTabClicked:()=>{},onClearAllFilters:()=>{},onFocus:()=>{},onBlur:()=>{},onHide:()=>{},onResize:()=>{},onSessionClose:()=>{},onSessionOpen:()=>{},onBeforeShow:()=>{},onShow:()=>{},onTabBlur:()=>{},onTabFocus:()=>{},renderTabTooltip:null,additionalActions:[],errorMessage:null,isLoading:!1,isLoaded:!0,isClonable:!1,isRenamable:!1};const ZT=X.module("WidgetPanelTooltip"),Al=t=>{const{widgetType:e,widgetName:n,glContainer:s,description:i,children:o}=t,r=te.getTitleFromContainer(s),[l,a]=S.exports.useState(!1);return v("div",{className:"tab-tooltip-container",children:[v("div",{className:"row flex-nowrap align-items-start",children:[h("span",{className:"tab-tooltip-title",children:v("b",{children:[e," Name "]})}),h("span",{className:"tab-tooltip-name",children:n}),h(Q,{kind:"ghost",className:"tab-tooltip-copy",icon:l?ld:od,onClick:()=>{Ne.copyToClipboard(n).then(()=>a(!0)).catch(d=>ZT.error("Unable to column name",d))},tooltip:l?"Copied text":"Copy name"})]}),n!==r&&v("div",{className:"row",children:[h("span",{className:"tab-tooltip-title",children:h("b",{children:"Display Name"})}),h("span",{className:"tab-tooltip-name",children:r})]}),i&&h("div",{className:"row",children:h("span",{className:"tab-tooltip-description",children:i})}),o]})};Al.propTypes={glContainer:xd.Container.isRequired,widgetType:D.exports.string,widgetName:D.exports.string,description:D.exports.string,children:D.exports.node};Al.defaultProps={widgetType:"",widgetName:"",description:null,children:null};class Pl extends S.exports.PureComponent{constructor(e){super(e),this.getCachedRenderTabTooltip=he((n,s,i,o,r)=>n?()=>h(Al,{glContainer:s,widgetType:i,widgetName:o,description:r}):null),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleCopyName=this.handleCopyName.bind(this),this.state={isClientDisconnected:!1,isPanelDisconnected:!1,isWidgetDisconnected:!1,isWaitingForReconnect:!1,isPanelInactive:!1}}handleCopyName(){const{widgetName:e}=this.props;Ne.copyToClipboard(e)}getErrorMessage(){const{errorMessage:e}=this.props,{isClientDisconnected:n,isPanelDisconnected:s,isWidgetDisconnected:i,isWaitingForReconnect:o}=this.state;if(e)return`${e}`;if(n&&s&&o)return`Disconnected from server.
|
|
36
36
|
Check your internet connection.`;if(n&&s)return"Disconnected from server.";if(s){const{widgetName:r,widgetType:l}=this.props;return`Variable "${r}" not set.
|
|
37
37
|
${l} does not exist yet.`}if(i){const{widgetName:r}=this.props;return`${r} is unavailable.`}}handleSessionClosed(...e){const{onSessionClose:n}=this.props;this.setState({isPanelDisconnected:!0,isWaitingForReconnect:!1}),n(...e)}handleSessionOpened(...e){const{onSessionOpen:n}=this.props;n(...e)}render(){const{children:e,className:n,componentPanel:s,isLoaded:i,isLoading:o,glContainer:r,glEventHub:l,isDisconnected:a,isClonable:d,isRenamable:c,showTabTooltip:u,renderTabTooltip:m,widgetType:p,widgetName:g,description:f,onClearAllFilters:b,onHide:C,onFocus:w,onBlur:T,onResize:y,onShow:E,onTabBlur:I,onTabFocus:R,onTabClicked:F}=this.props,{isPanelDisconnected:x,isWidgetDisconnected:U,isPanelInactive:$}=this.state,O=this.getErrorMessage(),H=m!=null?m:this.getCachedRenderTabTooltip(u,r,p,g,f),L=[{title:`Copy ${p} Name`,group:oe.groups.medium,order:20,action:this.handleCopyName}];return v(Yn,{className:z(n,{disconnected:x||U||a,inactive:$}),componentPanel:s,glContainer:r,glEventHub:l,onClearAllFilters:b,onHide:C,onFocus:w,onBlur:T,onResize:y,onShow:E,onSessionClose:this.handleSessionClosed,onSessionOpen:this.handleSessionOpened,onTabBlur:I,onTabFocus:R,onTabClicked:F,renderTabTooltip:H,errorMessage:O,isLoaded:i,isLoading:o,isClonable:d,isRenamable:c,additionalActions:L,children:[e,$&&h("div",{className:"fill-parent-absolute"})]})}}Pl.defaultProps={className:"",errorMessage:null,isClonable:!0,isDisconnected:!1,isLoading:!1,isLoaded:!0,isRenamable:!0,showTabTooltip:!0,widgetName:"Widget",widgetType:"Widget",renderTabTooltip:null,description:"",onFocus:()=>{},onBlur:()=>{},onHide:()=>{},onClearAllFilters:()=>{},onResize:()=>{},onSessionClose:()=>{},onSessionOpen:()=>{},onShow:()=>{},onTabBlur:()=>{},onTabFocus:()=>{},onTabClicked:()=>{}};const dn=Object.freeze({DEFAULT:"DEFAULT",LINKER:"LINKER"}),JT="SET_SESSION_WRAPPER",eE=fi(JT,null),tE={sessionWrapper:eE},nE=new Map,Hl=Object.freeze([]),Ep=(t,e)=>{var n;return(n=qt(t,e).columns)!=null?n:Hl},sE=(t,e)=>{var n;return(n=qt(t,e).filterSets)!=null?n:Hl},qd=(t,e)=>{var n;return(n=qt(t,e).filters)!=null?n:Hl},Yd=(t,e)=>{var n;return(n=qt(t,e).tableMap)!=null?n:nE},Xd=(t,e)=>qt(t,e).isolatedLinkerPanelId,so=(t,e)=>{var n;return(n=qt(t,e).links)!=null?n:Hl},jd=(t,e)=>qt(t,e).columnSelectionValidator,iE=(t,e)=>qt(t,e).connection,gi=(t,e)=>qt(t,e).sessionWrapper,oE=(t,e)=>n=>n(qn(t,{connection:e})),rE=(t,e)=>n=>n(qn(t,{sessionWrapper:e})),Qd=(t,e)=>n=>n(qn(t,{links:e})),lE=(t,e)=>(n,s)=>{const i=so(s(),t),o=e.filter(r=>i.findIndex(l=>ct(l.start,r.start)&&ct(l.end,r.end))<0);return n(Qd(t,i.concat(o)))},aE=(t,e)=>(n,s)=>{const o=so(s(),t).filter(r=>!e.includes(r.id));return n(Qd(t,o))},yp=(t,e)=>n=>n(qn(t,{isolatedLinkerPanelId:e})),dE=(t,e)=>n=>n(qn(t,{columnSelectionValidator:e})),cE=(t,e)=>n=>n(qn(t,{consoleSettings:e})),hE=(t,e)=>n=>n(qn(t,{filterSets:e}));Object.entries(tE).map(([t,e])=>Zi.register(t,e));const Ip=({columnMap:t,inputFilterMap:e,linkedColumnMap:n,onAdd:s,onOpenLinker:i,waitingFilterMap:o,waitingInputMap:r})=>{const l=S.exports.useMemo(()=>{const p=Array.from(r.keys()),g=p.find(C=>e.get(C)!=null),f=p.find(C=>n.get(C)!=null),b=tn.join(p.map(C=>`"${C}"`));return g!=null&&g&&f!=null&&f?`Use a filter control or linked table to set a value for ${b}`:g!=null&&g?`Set a filter control value for ${b}`:`Double click a row in a linked table to set a value for ${b}`},[e,n,r]),a=S.exports.useMemo(()=>Array.from(t.values()),[t]),d=S.exports.useCallback(p=>{p.stopPropagation(),p.preventDefault(),s(Array.from(o.values()))},[s,o]),c=S.exports.useCallback(p=>{p.stopPropagation(),p.preventDefault(),i()},[i]),u=o.size>0,m=!u&&r.size>0;return h("div",{className:"chart-panel-overlay chart-filter-overlay",children:v("div",{className:z("chart-panel-overlay-content chart-filter-overlay-content",{"chart-filter-waiting-filter":u},{"chart-filter-waiting-input":m}),children:[u&&v(ue,{children:[h("div",{className:"info-message",children:"This plot requires a filter control to be added to the layout or a table link to be created on the following columns:"}),h("div",{className:"waiting-filter-list",children:a.map(p=>{const g=o.has(p.name),f=g?ds:ad;return v("div",{className:z("waiting-filter-item",{"is-invalid":g}),children:[h(K,{icon:f}),p.name]},p.name)})}),v("div",{children:[h(Bi,{onClick:d,className:"btn-primary",children:"Add Input Filters"}),h(Bi,{onClick:c,className:"btn-primary",children:"Open Linker Tool"})]})]}),m&&v(ue,{children:[h("div",{className:"info-message",children:"Waiting for User Input"}),h("div",{className:"",children:l})]})]})})};Ip.propTypes={columnMap:D.exports.instanceOf(Map).isRequired,inputFilterMap:D.exports.instanceOf(Map).isRequired,linkedColumnMap:D.exports.instanceOf(Map).isRequired,onAdd:D.exports.func.isRequired,onOpenLinker:D.exports.func.isRequired,waitingFilterMap:D.exports.instanceOf(Map).isRequired,waitingInputMap:D.exports.instanceOf(Map).isRequired};const Po=({columns:t,onColumnSelected:e,onMouseEnter:n,onMouseLeave:s})=>h("div",{className:"chart-panel-overlay chart-column-selector-overlay",children:h("div",{className:z("chart-panel-overlay-content"),children:v(ue,{children:[h("div",{className:"info-message",children:"This plot requires a filter control to be added to the layout or a table link to be created on the following columns:"}),h("div",{className:"waiting-column-select-list",children:t.map(i=>h(Sl,{className:z("btn-chart-column-selector",Po.makeButtonClassName(i.name)),onClick:()=>e(i.name),onMouseEnter:()=>{n&&n(i)},onMouseLeave:s,disabled:!i.isValid,isLinked:i.isActive,children:i.name},i.name))})]})})});Po.makeButtonClassName=t=>`btn-chart-column-selector-${t}`;Po.defaultProps={onMouseEnter:()=>{},onMouseLeave:()=>{}};const Jt=X.module("ChartPanel"),uE=150;function Pr(t){return t.settings!==void 0}function mE(t){return t.inputFilters!=null}function pE(t){return t.panelState!=null}class Vl extends S.exports.Component{constructor(e){super(e),this.getWaitingInputMap=he((r,l,a)=>{if(!r)return new Map;const d=new Map(l);return a.forEach((c,u)=>{d.delete(u)}),d}),this.getWaitingFilterMap=he((r,l,a,d,c)=>{if(!r)return new Map;const u=new Map(l);return a.forEach((m,p)=>{u.delete(p)}),c.forEach((m,p)=>{u.delete(p)}),d.forEach((m,p)=>{u.delete(p)}),u}),this.getInputFilterColumnMap=he((r,l)=>{const a=new Map;for(let d=0;d<l.length;d+=1){const c=l[d],{name:u,type:m}=c,p=r.get(u);p!=null&&p.type===m&&a.set(u,c)}return a}),this.getLinkedColumnMap=he((r,l)=>{const a=new Map,d=te.getIdFromPanel(this);for(let c=0;c<l.length;c+=1){const u=l[c];let m=null;if(u.start!=null&&u.start.panelId===d&&r.has(u.start.columnName)?m=u.start.columnName:u.end&&u.end.panelId===d&&r.has(u.end.columnName)&&(m=u.end.columnName),m!=null&&r.has(m)){const p=r.get(m);A(p),a.set(m,p)}}return a}),this.getSelectorColumns=he((r,l,a)=>Array.from(r.values()).map(d=>({name:d.name,type:d.type,isValid:a?a(this,d):!1,isActive:l.has(d.name)}))),this.handleColumnSelected=this.handleColumnSelected.bind(this),this.handleColumnMouseEnter=this.handleColumnMouseEnter.bind(this),this.handleColumnMouseLeave=this.handleColumnMouseLeave.bind(this),this.handleDisconnect=this.handleDisconnect.bind(this),this.handleReconnect=this.handleReconnect.bind(this),this.handleFilterAdd=this.handleFilterAdd.bind(this),this.handleHide=this.handleHide.bind(this),this.handleError=this.handleError.bind(this),this.handleLoadError=this.handleLoadError.bind(this),this.handleLoadSuccess=this.handleLoadSuccess.bind(this),this.handleResize=this.handleResize.bind(this),this.handleSettingsChanged=this.handleSettingsChanged.bind(this),this.handleOpenLinker=this.handleOpenLinker.bind(this),this.handleShow=this.handleShow.bind(this),this.handleSourceColumnChange=this.handleSourceColumnChange.bind(this),this.handleSourceFilterChange=this.handleSourceFilterChange.bind(this),this.handleSourceSortChange=this.handleSourceSortChange.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleUpdate=this.handleUpdate.bind(this),this.updateModelFromSource=Xe(this.updateModelFromSource.bind(this),uE),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.panelContainer=Y.createRef(),this.chart=Y.createRef(),this.pending=new ps;const{metadata:n,panelState:s}=e,{filterValueMap:i=[],settings:o={}}=s!=null?s:{};this.state={settings:o,error:void 0,isActive:!1,isDisconnected:!1,isLoading:!1,isLoaded:!1,isLinked:n!=null&&Pr(n)&&n.settings&&n.settings.isLinked,filterMap:new Map(i),filterValueMap:new Map(i),model:void 0,columnMap:new Map,panelState:s}}componentDidMount(){this.isHidden()||(this.setState({isActive:!0}),this.initModel())}componentDidUpdate(e,n){const{inputFilters:s,source:i}=this.props,{columnMap:o,model:r,filterMap:l,filterValueMap:a,isLinked:d,settings:c}=this.state;!r||(o!==n.columnMap&&this.pruneFilterMaps(),s!==e.inputFilters&&this.updateChangedInputFilters(s,e.inputFilters),l!==n.filterMap?this.updateFilters():a!==n.filterValueMap&&this.updatePanelState(),c!==n.settings&&oh(r)&&(r.updateSettings(c),this.updatePanelState()),d!==n.isLinked?i&&(d?(this.startListeningToSource(i),this.updateModelFromSource()):this.stopListeningToSource(i)):d&&i!==e.source&&(e.source&&this.stopListeningToSource(e.source),i&&(this.startListeningToSource(i),this.updateModelFromSource())))}componentWillUnmount(){this.pending.cancel();const{source:e}=this.props;e&&this.stopListeningToSource(e)}initModel(){this.setState({isLoading:!0,isLoaded:!1,error:void 0});const{makeModel:e}=this.props;this.pending.add(e(),n=>{n.close()}).then(this.handleLoadSuccess,this.handleLoadError)}startListeningToSource(e){Jt.debug("startListeningToSource",e),e.addEventListener(M.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleSourceColumnChange),e.addEventListener(M.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.addEventListener(M.Table.EVENT_SORTCHANGED,this.handleSourceSortChange)}stopListeningToSource(e){Jt.debug("stopListeningToSource",e),e.removeEventListener(M.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleSourceColumnChange),e.removeEventListener(M.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.removeEventListener(M.Table.EVENT_SORTCHANGED,this.handleSourceSortChange)}loadModelIfNecessary(){const{isActive:e,isLoaded:n,isLoading:s}=this.state;e&&!n&&!s&&this.initModel()}isHidden(){const{glContainer:e}=this.props,{isHidden:n}=e;return n}handleColumnSelected(e){const{glEventHub:n}=this.props,{columnMap:s}=this.state;n.emit(Gi.COLUMN_SELECTED,this,s.get(e))}handleColumnMouseEnter({type:e,name:n}){const{columnSelectionValidator:s}=this.props;Jt.debug("handleColumnMouseEnter",s,e,n),s&&s(this,{type:e,name:n})}handleColumnMouseLeave(){const{columnSelectionValidator:e}=this.props;Jt.debug("handleColumnMouseLeave",e),e&&e(this,void 0)}handleDisconnect(){this.setState({error:new Error("Figure disconnected"),isDisconnected:!0})}handleFilterAdd(e){for(let n=0;n<e.length;n+=1)this.openInputFilter(e[n])}handleOpenLinker(){const{localDashboardId:e,setActiveTool:n,setDashboardIsolatedLinkerPanelId:s}=this.props;s(e,void 0),n(dn.LINKER)}handleReconnect(){this.setState({isDisconnected:!1,error:void 0}),this.sendColumnChange(),this.updateColumnFilters()}handleLoadSuccess(e){Jt.debug("handleLoadSuccess");const{model:n}=this.state;this.setState({model:e,isLoaded:!0},()=>{const{inputFilters:s,source:i}=this.props,{filterMap:o,isLinked:r}=this.state;e!==n&&(this.sendColumnChange(),this.updateColumnFilters(),this.updateInputFilters(s,o.size>0||e.isFilterRequired()),i&&r&&(this.startListeningToSource(i),this.updateModelFromSource()))})}handleLoadError(e){Ee.isCanceled(e)||(Jt.error("handleLoadError",e),this.setState({error:e,isLoading:!1}))}handleSourceColumnChange(){this.updateModelFromSource()}handleSourceFilterChange(){this.updateModelFromSource()}handleSourceSortChange(){this.updateModelFromSource()}updateModelFromSource(){const{metadata:e,source:n}=this.props,{isLinked:s,model:i}=this.state;if(!s||!i||!n){Jt.debug2("updateModelFromSource ignoring",s,i,n);return}if(this.pending.cancel(),Pr(e)){const{settings:o}=e;this.pending.add(M.plot.Figure.create(_e.makeFigureSettings(o,n))).then(r=>{oh(i)&&i.setFigure(r)}).catch(this.handleLoadError)}this.updatePanelState()}updatePanelState(){const{sourcePanel:e}=this.props,{panelState:n,filterValueMap:s,settings:i}=this.state;let{tableSettings:o}=n!=null?n:{};if(e&&mE(e.props)&&pE(e.state)){const{inputFilters:r}=e.props,{panelState:l}=e.state;l!=null&&(o=se.extractTableSettings(l,r))}this.setState({panelState:{settings:i,tableSettings:o,filterValueMap:Array.from(s)}})}handleError(){this.setState({isLoading:!1})}handleResize(){this.updateChart()}handleSettingsChanged(e){this.setState(({settings:n})=>{const s={...n,...e};return Jt.debug("Updated settings",s),{settings:s}})}handleHide(){this.setActive(!1)}handleShow(){this.setActive(!0)}handleTabBlur(){this.setActive(!1)}handleTabFocus(){const e=this.isHidden();this.setActive(!e)}handleUpdate(){this.setState({isLoading:!1})}handleClearAllFilters(){this.setState({filterValueMap:new Map,filterMap:new Map}),this.updatePanelState()}openInputFilter(e){const{glEventHub:n}=this.props,{name:s,type:i}=e;n.emit(He.OPEN_INPUT,{title:`${s} Filter`,panelState:{name:s,type:i,isValueShown:!0},createNewStack:!0,focusElement:"input"})}setActive(e){this.setState({isActive:e},()=>{e&&(this.loadModelIfNecessary(),this.updateChart())})}sendColumnChange(){const{model:e}=this.state;if(!e)return;const{glEventHub:n}=this.props;n.emit(He.COLUMNS_CHANGED,this,Array.from(e.getFilterColumnMap().values()))}getCoordinateForColumn(e){var l;const n=Po.makeButtonClassName(e);if(!this.panelContainer.current)return null;const s=this.panelContainer.current.querySelector(`.${n}`),i=(l=s==null?void 0:s.getBoundingClientRect())!=null?l:null;if(i==null||i.width<=0||i.height<=0)return null;const o=i.left+i.width/2,r=i.bottom;return[o,r]}setFilterMap(e){Jt.debug("setFilterMap",e),this.setState(n=>{const{columnMap:s,filterMap:i}=n;let o=null;const r=new Map(n.filterValueMap);return e.forEach(({columnType:l,value:a},d)=>{const c=s.get(d);c==null||c.type!==l||(r.set(d,a),i.get(d)!==a&&(o===null&&(o=new Map(i)),o.set(d,a)))}),{filterValueMap:r,filterMap:o!=null?o:i}})}unsetFilterValue(e){this.setState(n=>{var a;const{inputFilters:s}=this.props,{columnMap:i}=n;let{filterMap:o,filterValueMap:r}=n;if(!r.has(e))return null;r=new Map(n.filterValueMap),r.delete(e);const l=this.getInputFilterColumnMap(i,s);if(l.has(e)){const d=o.get(e),c=(a=l.get(e))==null?void 0:a.value;c!=null&&d!==c&&(o=new Map(n.filterMap),c.length>0?o.set(e,c):o.delete(e))}else o=new Map(n.filterMap),o.delete(e);return{filterMap:o,filterValueMap:r}})}updateChangedInputFilters(e,n){const s=n.filter(o=>e.find(r=>r.name===o.name&&r.type===o.type)===void 0);s.length>0&&this.deleteInputFilters(s);const i=e.filter(o=>!n.includes(o));i.length>0&&this.updateInputFilters(i)}updateInputFilters(e,n=!1){this.setState(s=>{const{columnMap:i}=s,o=new Map(s.filterValueMap),r=new Map(s.filterMap),l=n?{filterMap:r,filterValueMap:o}:{};for(let a=0;a<e.length;a+=1){const{name:d,type:c,value:u}=e[a],m=i.get(d);m!=null&&m.type===c&&(u!=null&&r.get(d)!==u&&(u===""?r.delete(d):r.set(d,u),l.filterMap=r),o.has(d)&&(o.delete(d),l.filterValueMap=o))}return Jt.debug("updateInputFilters",l),l})}deleteInputFilters(e,n=!1){this.setState(s=>{const{columnMap:i,filterValueMap:o}=s,r=new Map(s.filterMap);let l=n;for(let a=0;a<e.length;a+=1){const{name:d,type:c}=e[a],u=i.get(d);if(u!=null&&u.type===c&&r.has(d)){const m=r.get(d);if(o.has(d)){const p=o.get(d);p!==m&&p!=null&&(l=!0,r.set(d,p))}else l=!0,r.delete(d)}}return Jt.debug("deleteInputFilters",l),l?{filterMap:r}:null})}updateColumnFilters(){this.setState(({model:e})=>e?{columnMap:e.getFilterColumnMap()}:null)}updateFilters(){const{columnMap:e,filterMap:n,model:s}=this.state;A(s);const i=this.getWaitingInputMap(s.isFilterRequired(),e,n);if(s.setFilter(n),n.size>0&&i.size===0){const o=s.getDefaultTitle(),r=tn.join(Array.from(n.entries()).map(([l,a])=>`${l}: ${a}`));o?s.setTitle(`${o}<br><span style="font-size: smaller">${r}</span>`):s.setTitle(r),Jt.debug2("updateFilters filters set",n),this.setState({isLoading:!0})}else Jt.debug2("updateFilters waiting on inputs",i),s.setTitle(s.getDefaultTitle()),this.setState({isLoading:!1});this.updatePanelState()}pruneFilterMaps(){this.setState(e=>{const{columnMap:n}=e,s=new Map(e.filterMap),i=new Map(e.filterValueMap),o={};return e.filterValueMap.forEach((r,l)=>{n.has(l)||(i.delete(l),o.filterValueMap=i)}),e.filterMap.forEach((r,l)=>{n.has(l)||(s.delete(l),o.filterMap=s)}),o})}updateChart(){this.chart.current&&this.chart.current.updateDimensions()}render(){const{columnSelectionValidator:e,glContainer:n,glEventHub:s,inputFilters:i,isLinkerActive:o,links:r,metadata:l,settings:a}=this.props,{columnMap:d,filterMap:c,error:u,model:m,isActive:p,isDisconnected:g,isLoaded:f,isLoading:b}=this.state;let C;Pr(l)?C=l.table:C=l.figure;const w=this.getInputFilterColumnMap(d,i),T=this.getLinkedColumnMap(d,r),y=m!=null?this.getWaitingInputMap(m.isFilterRequired(),d,c):new Map,E=m!=null?this.getWaitingFilterMap(m.isFilterRequired(),d,c,T,w):new Map,I=u!=null?`Unable to open chart. ${u}`:void 0,R=y.size>0,F=d.size>0&&o;return h(Pl,{className:z("iris-chart-panel",{"input-required":R}),componentPanel:this,glContainer:n,glEventHub:s,onHide:this.handleHide,onClearAllFilters:this.handleClearAllFilters,onResize:this.handleResize,onShow:this.handleShow,onTabBlur:this.handleTabBlur,onTabFocus:this.handleTabFocus,errorMessage:I,isDisconnected:g,isLoading:b,isLoaded:f,widgetName:C,widgetType:"Chart",children:v("div",{ref:this.panelContainer,className:"chart-panel-container h-100 w-100",children:[h("div",{className:"chart-container h-100 w-100",children:f&&m&&h(lm,{isActive:p,model:m,settings:a,ref:this.chart,onDisconnect:this.handleDisconnect,onReconnect:this.handleReconnect,onUpdate:this.handleUpdate,onError:this.handleError,onSettingsChanged:this.handleSettingsChanged})}),h(ht,{in:R&&!F&&!b,timeout:Tt.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:h(Ip,{inputFilterMap:w,linkedColumnMap:T,onAdd:this.handleFilterAdd,onOpenLinker:this.handleOpenLinker,columnMap:d,waitingFilterMap:E,waitingInputMap:y})}),h(ht,{in:F,timeout:Tt.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:h(Po,{columns:this.getSelectorColumns(d,T,e),onColumnSelected:this.handleColumnSelected,onMouseEnter:this.handleColumnMouseEnter,onMouseLeave:this.handleColumnMouseLeave})})]})})}}Vl.defaultProps={columnSelectionValidator:null,isLinkerActive:!1,source:null,sourcePanel:null,panelState:null,settings:{}};Vl.displayName="ChartPanel";Vl.COMPONENT="ChartPanel";const gE=(t,e)=>{const{localDashboardId:n,metadata:s}=e;let i;s!=null&&(i=s.sourcePanelId);const o=Yd(t,n),r=Wm(t,n),l=Rl(t),a=Xd(t,n),d=l===dn.LINKER&&a===void 0;return{columnSelectionValidator:jd(t,n),isLinkerActive:d,inputFilters:qd(t,n),links:so(t,n),source:i!=null?o.get(i):void 0,sourcePanel:i!=null?r.get(i):void 0,settings:Kt(t)}},Vi=Dt(gE,{setActiveTool:Dl,setDashboardIsolatedLinkerPanelId:yp},null,{forwardRef:!0})(Vl);const Dr=X.module("CommandHistoryPanel"),Rp=class extends S.exports.Component{constructor(t){super(t),this.handleFocusHistory=this.handleFocusHistory.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleSendToConsole=this.handleSendToConsole.bind(this),this.handleSendToNotebook=this.handleSendToNotebook.bind(this),this.container=Y.createRef(),this.pending=new ps;const{session:e,sessionId:n,language:s}=t;this.state={panelState:{},session:e,sessionId:n,language:s,contextActions:[{action:this.handleFocusHistory,shortcut:Nn.COMMAND_HISTORY.FOCUS_HISTORY}]}}static handleError(t){Dr.error(t)}componentDidMount(){const{glEventHub:t,session:e}=this.props;t.on(ft.FOCUS_HISTORY,this.handleFocusHistory),e!=null&&this.loadTable()}componentWillUnmount(){const{glEventHub:t}=this.props;t.off(ft.FOCUS_HISTORY,this.handleFocusHistory),this.pending.cancel()}handleFocusHistory(){this.container.current&&this.container.current.focus()}handleShow(){var t;(t=this.container.current)==null||t.restoreScrollPosition()}handleSessionOpened(t,{language:e,sessionId:n}){this.setState({session:t,sessionId:n,language:e},()=>{this.loadTable()})}handleSessionClosed(){this.pending.cancel(),this.setState({session:void 0,language:void 0,table:void 0})}handleSendToNotebook(t,e=!1){const{session:n,language:s}=this.state;if(Dr.debug("handleSendToNotebook",n,t),!n){Dr.error("Session is not connected.");return}const{glEventHub:i}=this.props;i.emit(e?Ve.CREATE_NOTEBOOK:Ve.SEND_TO_NOTEBOOK,n,s,t)}handleSendToConsole(t,e=!0,n=!1){Dr.debug("handleSendToConsole",t);const{glEventHub:s}=this.props;s.emit(ft.SEND_COMMAND,t,e,n)}loadTable(){const{commandHistoryStorage:t}=this.props,{language:e,sessionId:n}=this.state;A(e),A(n),this.pending.add(t.getTable(e,n,Date.now()),s=>s.close()).then(s=>{this.setState({table:s})}).catch(Rp.handleError)}render(){const{glContainer:t,glEventHub:e,commandHistoryStorage:n}=this.props,{language:s,contextActions:i,table:o}=this.state;return v(Yn,{className:"command-history-pane",componentPanel:this,glContainer:t,glEventHub:e,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onShow:this.handleShow,children:[!o&&h("div",{className:"command-history-disconnected-message",children:"Waiting for console connection"}),o&&s&&v(ue,{children:[h(El,{ref:this.container,language:s,sendToNotebook:this.handleSendToNotebook,sendToConsole:this.handleSendToConsole,table:o,commandHistoryStorage:n}),h(oe,{actions:i})]})]})}};let Zd=Rp;Zd.COMPONENT="CommandHistoryPanel";Zd.TITLE="Command History";const fE=(t,e)=>{const n=hm(t),s=gi(t,e.localDashboardId),{session:i,config:o}=s!=null?s:{},{type:r,id:l}=o!=null?o:{};return{commandHistoryStorage:n,language:r,session:i,sessionId:l}},nl=Dt(fE,null,null,{forwardRef:!0})(Zd);const Mr=X.module("ConsolePanel"),CE=500,bE=Object.freeze({consoleSettings:{},itemIds:[]});class Jd extends S.exports.PureComponent{constructor(e){super(e),this.savePanelState=Xe(()=>{const{consoleSettings:r,itemIds:l}=this.state,a={consoleSettings:r,itemIds:[...l]};Mr.debug("Saving panel state",a),this.setState({panelState:a})},CE),this.handleFocusCommandHistory=this.handleFocusCommandHistory.bind(this),this.handleOpenObject=this.handleOpenObject.bind(this),this.handleCloseObject=this.handleCloseObject.bind(this),this.handleResize=this.handleResize.bind(this),this.handleSettingsChange=this.handleSettingsChange.bind(this),this.handleShow=this.handleShow.bind(this),this.handlePanelMount=this.handlePanelMount.bind(this),this.consoleRef=Y.createRef();const{panelState:n}=e,s={...bE,...n||{}},{consoleSettings:i,itemIds:o}=s;this.state={consoleSettings:i,itemIds:new Map(o),objectMap:new Map,error:void 0,panelState:s}}componentDidMount(){const{glEventHub:e}=this.props;this.closeDisconnectedPanels(),e.on(Me.MOUNT,this.handlePanelMount),this.subscribeToFieldUpdates()}componentDidUpdate(e,n){const{consoleSettings:s,itemIds:i}=this.state;(n.consoleSettings!==s||n.itemIds!==i)&&this.savePanelState()}componentWillUnmount(){var n;const{glEventHub:e}=this.props;this.savePanelState.flush(),e.off(Me.MOUNT,this.handlePanelMount),(n=this.objectSubscriptionCleanup)==null||n.call(this)}subscribeToFieldUpdates(){const{sessionWrapper:e}=this.props,{session:n}=e;this.objectSubscriptionCleanup=n.subscribeToFieldUpdates(s=>{Mr.debug("Got updates",s),this.setState(({objectMap:i})=>{const{updated:o,created:r,removed:l}=s,a=[...o,...l],d=new Map(i);return a.forEach(u=>{const{title:m}=u;m!==void 0&&d.delete(m)}),[...o,...r].forEach(u=>{u.title!==void 0&&d.set(u.title,u)}),{objectMap:d}})})}setItemId(e,n){this.setState(({itemIds:s})=>{const i=new Map(s);return i.set(e,n),{itemIds:i}})}getItemId(e,n=!0){const{itemIds:s}=this.state;let i=s.get(e);return i==null&&n&&(i=We.generate(),this.setItemId(e,i)),i}handleTabFocus(){var e;(e=this.consoleRef.current)==null||e.focus()}handlePanelMount(e){var o,r,l;const{itemIds:n}=this.state,s=(o=e==null?void 0:e.props)==null?void 0:o.id,i=(l=(r=e==null?void 0:e.props)==null?void 0:r.metadata)==null?void 0:l.sourcePanelId;s&&i&&new Set(n.values()).has(i)&&this.setItemId(s,s)}handleFocusCommandHistory(){const{glEventHub:e}=this.props;e.emit(ft.FOCUS_HISTORY)}handleResize(){this.updateDimensions()}handleShow(){this.updateDimensions()}handleOpenObject(e){const{sessionWrapper:n}=this.props,{session:s}=n;this.openWidget(e,s)}handleCloseObject(e){const{title:n}=e;if(n!==void 0){const s=this.getItemId(n,!1),{glEventHub:i}=this.props;i.emit(Me.CLOSE,s)}}handleSettingsChange(e){const{glEventHub:n}=this.props;Mr.debug("handleSettingsChange",e),this.setState({consoleSettings:e}),n.emit(ft.SETTINGS_CHANGED,e)}openWidget(e,n){const{glEventHub:s}=this.props,{title:i}=e;A(i);const o=this.getItemId(i),r={fetch:()=>n.getObject(e),panelId:o,widget:e};Mr.debug("openWidget",r),s.emit(Me.OPEN,r)}addCommand(e,n=!0,s=!1){var i;(i=this.consoleRef.current)==null||i.addCommand(e,n,s)}closeDisconnectedPanels(e=!1){const{consoleSettings:n,itemIds:s}=this.state,{isClosePanelsOnDisconnectEnabled:i=!0}=n;if(!i&&!e)return;const o=[...s.values()],{glEventHub:r}=this.props;o.forEach(l=>{r.emit(Me.CLOSE,l)}),this.setState({itemIds:new Map})}updateDimensions(){var e;(e=this.consoleRef.current)==null||e.updateDimensions()}render(){const{commandHistoryStorage:e,glContainer:n,glEventHub:s,sessionWrapper:i,timeZone:o,unzip:r}=this.props,{consoleSettings:l,error:a,objectMap:d}=this.state,{config:c,session:u,connection:m}=i,{id:p,type:g}=c;return h(Yn,{componentPanel:this,glContainer:n,glEventHub:s,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleTabFocus,errorMessage:a!=null?`${a}`:void 0,children:h(ue,{children:u!=null&&h(Sd,{ref:this.consoleRef,settings:l,session:u,focusCommandHistory:this.handleFocusCommandHistory,openObject:this.handleOpenObject,closeObject:this.handleCloseObject,commandHistoryStorage:e,onSettingsChange:this.handleSettingsChange,language:g,statusBarChildren:v(ue,{children:[h("div",{children:"\xA0"}),h("div",{children:zu.LANGUAGE_MAP.get(g)}),h("div",{children:"\xA0"}),h("div",{children:h(cS,{connection:m,defaultUpdateInterval:10*1e3,hoverUpdateInterval:3*1e3,monitorDuration:10*60*1e3})}),h("div",{children:"\xA0"})]}),scope:p,timeZone:o,objectMap:d,unzip:r})})})}}Jd.COMPONENT="ConsolePanel";Jd.TITLE="Console";const SE=(t,e)=>({commandHistoryStorage:hm(t),sessionWrapper:gi(t,e.localDashboardId),timeZone:Il(t)}),ki=Dt(SE,null,null,{forwardRef:!0})(Jd);const Co=X.module("DropdownFilter"),wE=150,Hr=class extends S.exports.Component{constructor(t){super(t),this.getCompatibleColumns=he((i,o)=>i!=null?o.filter(({type:r})=>r!==void 0&&P.isCompatibleType(r,i.columnType)):[]),this.getColumnOptions=he((i,o)=>{let r=-1;const l=[];return l.push(h("option",{value:"-1",children:"Select a column"},"placeholder")),i.forEach((a,d)=>{l.push(h("option",{value:d,children:this.getItemLabel(i,d)},`${a.name}/${a.type}`)),o!==null&&a.name===o.name&&a.type===o.type&&(r=d)}),[l,r]}),this.getSelectedOptionIndex=he((i,o)=>i.indexOf(o)),this.getValueOptions=he(i=>[h("option",{value:"-1",children:Hr.PLACEHOLDER},"-1"),...i.map((o,r)=>h("option",{value:r,children:o},`${r}/${o}`))]),this.getItemLabel=Te((i,o)=>{const{name:r,type:l}=i[o];if(o>0&&i[o-1].name===r||o<i.length-1&&i[o+1].name===r){const a=l.substring(l.lastIndexOf(".")+1);return`${r} (${a})`}return r}),this.sendUpdate=Xe(()=>{const{onChange:i}=this.props,{column:o,value:r,isValueShown:l}=this.state;i({column:o,isValueShown:l,value:r!=null?r:void 0})},wE),this.handleColumnChange=this.handleColumnChange.bind(this),this.handleSettingsCancel=this.handleSettingsCancel.bind(this),this.handleSettingsClick=this.handleSettingsClick.bind(this),this.handleSettingsSave=this.handleSettingsSave.bind(this),this.handleBackgroundClick=this.handleBackgroundClick.bind(this),this.handleDropdownKeyPress=this.handleDropdownKeyPress.bind(this),this.handleValueChange=this.handleValueChange.bind(this),this.dropdownRef=Y.createRef();const{column:e,isValueShown:n,value:s}=t;this.state={column:e,selectedColumn:e,disableCancel:!n,isValueShown:n,value:s}}componentDidUpdate(t,e){const{source:n,values:s,isLoaded:i}=this.props,{column:o,value:r,isValueShown:l}=this.state;i&&(n!==t.source&&this.sourceUpdated(),s!==t.values&&r!==""&&!s.includes(r)&&this.resetValue(),l!==e.isValueShown&&l&&this.focusInput(),(o!==e.column||r!==e.value||l!==e.isValueShown)&&this.sendUpdate())}componentWillUnmount(){this.sendUpdate.flush()}handleColumnChange(t){const{value:e}=t.target;if(Co.debug2("handleColumnChange",e),e!=null&&parseInt(e,10)<0){this.setState({selectedColumn:null});return}const{columns:n,source:s}=this.props,i=this.getCompatibleColumns(s,n);this.setState({selectedColumn:i[parseInt(e,10)]})}handleDropdownKeyPress(t){t.key==="Enter"&&(t.preventDefault(),t.stopPropagation(),Co.debug2("handleDropdownKeyPress"),this.sendUpdate(),this.sendUpdate.flush())}handleValueChange(t){const{value:e}=t.target,n=parseInt(e,10);let s="";const{values:i}=this.props;if(n===-1)Co.debug2("Selected default item");else if(n>=0&&n<i.length)s=i[n];else{Co.error("Invalid index",n,i);return}Co.debug2("handleValueChange",s),this.setState({value:s})}handleSettingsCancel(){this.setState(({column:t})=>({selectedColumn:t,isValueShown:!0}))}handleSettingsSave(){this.setState(({column:t,selectedColumn:e,value:n})=>({column:e,value:t===e?n:"",isValueShown:!0,disableCancel:!1}))}handleSettingsClick(t){t.stopPropagation(),this.showSettings()}handleBackgroundClick(t){t.target!==this.dropdownRef.current&&this.focusInput()}handleMouseEnter(){const{onSourceMouseEnter:t}=this.props;t()}handleMouseLeave(){const{onSourceMouseLeave:t}=this.props;t()}sourceUpdated(){this.setState({column:null,selectedColumn:null,isValueShown:!1,disableCancel:!0,value:""})}showSettings(){const{column:t}=this.state;this.setState({selectedColumn:t,isValueShown:!1})}focusInput(){this.dropdownRef.current!==null&&this.dropdownRef.current.focus()}resetValue(){this.setState({value:""})}clearFilter(){this.resetValue()}setFilterState({name:t,type:e,value:n,isValueShown:s}){const i=t!=null&&e!=null?{name:t,type:e}:null;this.setState({column:i,value:n,isValueShown:s})}render(){var U;const{columns:t,disableLinking:e,isLinkerActive:n,isLoaded:s,source:i,onColumnSelected:o,onSourceMouseEnter:r,onSourceMouseLeave:l,values:a,settingsError:d}=this.props,{column:c,disableCancel:u,isValueShown:m,selectedColumn:p,value:g}=this.state,f=i===null,b=this.getCompatibleColumns(i,t),C=i!=null,w=(U=i==null?void 0:i.columnName)!=null?U:Hr.SOURCE_BUTTON_PLACEHOLDER,T=c!=null?`${c.name} Filter`:null,[y,E]=this.getColumnOptions(b,p),I=this.getValueOptions(a),R=this.getSelectedOptionIndex(a,g),F=!C||p==null;return v(id,{className:"dropdown-filter fill-parent-absolute",isFlipped:m&&!n,children:[h("div",{className:"dropdown-filter-settings-card",children:v("div",{className:"dropdown-filter-card-content",children:[v("div",{className:"dropdown-filter-settings-grid",children:[h("label",{children:"Source Column"}),h(Sl,{isLinked:C,onClick:o,onMouseEnter:r,onMouseLeave:l,className:Hr.SOURCE_BUTTON_CLASS_NAME,disabled:e,children:w}),h("div",{className:"text-muted small",children:"Select a source column for the list by linking to a table."}),h("label",{children:"Filter Column"}),h("select",{value:E,className:"custom-select",onChange:this.handleColumnChange,disabled:f,children:y}),h("div",{className:"text-muted small",children:"Dropdown filter control will apply its filter to all columns matching this name in this dashboard."})]}),d&&h("div",{className:"error-message text-center",children:d}),C&&v("div",{className:"dropdown-filter-settings-buttons",children:[h(Q,{kind:"secondary",type:"button",onClick:this.handleSettingsCancel,disabled:u||m||n,tooltip:n?"Cancel disabled while linker open":void 0,children:"Cancel"}),h(Q,{kind:"primary",type:"button",className:"ml-2",onClick:this.handleSettingsSave,disabled:F||m||n,tooltip:n?"Save disabled while linker open":void 0,children:"Save"})]})]})}),h("div",{className:"dropdown-filter-value-card",onClick:this.handleBackgroundClick,children:s&&v(ue,{children:[h("div",{className:"dropdown-filter-column",children:h("div",{className:"dropdown-filter-column-title",children:T})}),v("div",{className:"dropdown-filter-card-content",children:[h("div",{className:"dropdown-filter-value-input d-flex flex-column justify-content-center",children:h("select",{className:"custom-select",value:R,ref:this.dropdownRef,onChange:this.handleValueChange,onKeyPress:this.handleDropdownKeyPress,children:I})}),d&&h("div",{className:"error-message mt-3 text-center",children:d})]}),h("div",{className:"dropdown-filter-menu",children:h(Q,{kind:"ghost",className:"m-2 px-2",onClick:this.handleSettingsClick,icon:h(K,{icon:zo,transform:"grow-4"}),tooltip:"Dropdown Filter Settings"})})]})})]})}};let Ki=Hr;Ki.defaultProps={column:null,disableLinking:!1,isLinkerActive:!1,isLoaded:!1,isValueShown:!1,settingsError:null,source:null,value:"",values:[],onColumnSelected:()=>{},onSourceMouseEnter:()=>{},onSourceMouseLeave:()=>{}};Ki.PLACEHOLDER="Select a value...";Ki.SOURCE_BUTTON_CLASS_NAME="btn-dropdown-filter-selector";Ki.SOURCE_BUTTON_PLACEHOLDER="Select a column";const tt=X.module("DropdownFilterPanel"),vE=250,ti=class extends S.exports.Component{constructor(t){super(t),this.getCachedValues=he((d,{type:c,name:u},m)=>c!==void 0&&P.isDateType(c)?d.map(p=>ti.DATETIME_FORMATTER.format(p)):d.map(p=>p!=null&&c!=null?m.getFormattedString(p,c,u):null)),this.getCachedPanelLinks=he((d,c)=>{const u=te.getIdFromPanel(c);return tt.debug("getCachedPanelLinks",d,u),d.filter(m=>{var p;return((p=m.end)==null?void 0:p.panelId)===u})}),this.getCachedSource=he(d=>{tt.debug("getCachedSource",d);let c=null;if(d.length>0){const[u]=d;c=u.start,d.length>1&&tt.error("Filter has more that one link",d)}return c}),this.getCachedSourceTable=he((d,c)=>{var m;if(tt.debug("getCachedSourceTable",d,c),c==null)return null;const{panelId:u}=c;return(m=d.get(u))!=null?m:null}),this.getCachedSourceColumn=he((d,c)=>{var u;return tt.debug("getCachedSourceColumn",d,c),d==null||c==null?null:(u=d.columns.find(({name:m,type:p})=>m===c.columnName&&p===c.columnType))!=null?u:null}),this.handleChange=Xe(this.handleChange.bind(this),vE),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.handleDisconnect=this.handleDisconnect.bind(this),this.handleReconnect=this.handleReconnect.bind(this),this.handleColumnSelected=this.handleColumnSelected.bind(this),this.handleSourceFilterChange=this.handleSourceFilterChange.bind(this),this.handleSourceSortChange=this.handleSourceSortChange.bind(this),this.handleSourceSizeChange=this.handleSourceSizeChange.bind(this),this.handleSourceMouseEnter=this.handleSourceMouseEnter.bind(this),this.handleSourceMouseLeave=this.handleSourceMouseLeave.bind(this),this.handleValuesTableUpdate=this.handleValuesTableUpdate.bind(this),this.dropdownFilterRef=Y.createRef(),this.panelContainer=Y.createRef(),this.pending=new ps;const{panelState:e,settings:n}=t;this.columnFormats=cs.getColumnFormats(n);const{value:s="",isValueShown:i=!1,name:o,type:r,timestamp:l}=e!=null?e:{},a=o!=null&&r!=null?{name:o,type:r}:void 0;this.state={column:a,formatter:new cn(this.columnFormats),valuesTable:void 0,valuesColumn:void 0,sourceSize:0,value:s,timestamp:l,values:[],isValueShown:i,wasFlipped:!1,skipUpdate:!1,panelState:e,isDisconnected:!1,isLoading:!1,isLoaded:!1,error:null}}componentDidMount(){this.updateValuesTable();const{column:t,value:e,timestamp:n}=this.state,s=this.getSourceTable();if(s!==null&&this.startListeningToSource(s),t!=null){const{name:i,type:o}=t;this.sendUpdate(i,o,e,n)}}componentDidUpdate(t,e){const{valuesTable:n}=this.state,{settings:s}=this.props,i=this.getSource(),o=this.getSourceTable(),r=this.getSource(t),l=this.getSourceTable(t);s!==t.settings&&s!==void 0&&this.updateFormatterSettings(s),n!==e.valuesTable&&e.valuesTable!=null&&(tt.debug("Table in state modified, closing the old table."),e.valuesTable.close()),(o!==l||i!==r)&&this.updateValuesTable(),o!==l&&(l!==null&&this.stopListeningToSource(l),o!==null&&this.startListeningToSource(o))}componentWillUnmount(){const{valuesTable:t}=this.state,e=this.getSourceTable();this.pending.cancel(),e!==null&&this.stopListeningToSource(e),this.cleanup&&this.cleanup(),t!=null&&t.close()}getCoordinateForColumn(){var i;if(this.panelContainer.current==null)return null;const t=this.panelContainer.current.querySelector(`.${Ki.SOURCE_BUTTON_CLASS_NAME}`),e=(i=t==null?void 0:t.getBoundingClientRect())!=null?i:null;if(e==null||e.width<=0||e.height<=0)return null;const n=e.left+e.width/2,s=e.bottom;return[n,s]}getSettingsErrorMessage(){const{sourceSize:t}=this.state;if(t>ti.MAX_TABLE_SIZE)return`Table too large, must have fewer than ${ti.MAX_TABLE_SIZE} options.`}getPanelErrorMessage(){const{error:t}=this.state;return t!=null?`${t}`:void 0}getSource(t=this.props){const{dashboardLinks:e}=t,n=this.getCachedPanelLinks(e,this);return this.getCachedSource(n)}getSourceTable(t=this.props){const{panelTableMap:e}=t,n=this.getSource(t);return this.getCachedSourceTable(e,n)}getValuesColumn(t){const e=this.getSource();return this.getCachedSourceColumn(t,e)}startListeningToSource(t){tt.debug("startListeningToSource"),t.addEventListener(M.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),t.addEventListener(M.Table.EVENT_SORTCHANGED,this.handleSourceSortChange),t.addEventListener(M.Table.EVENT_SIZECHANGED,this.handleSourceSizeChange),t.addEventListener(M.Table.EVENT_DISCONNECT,this.handleDisconnect),t.addEventListener(M.Table.EVENT_RECONNECT,this.handleReconnect)}stopListeningToSource(t){tt.debug("stopListeningToSource"),t.removeEventListener(M.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),t.removeEventListener(M.Table.EVENT_SORTCHANGED,this.handleSourceSortChange),t.removeEventListener(M.Table.EVENT_SIZECHANGED,this.handleSourceSizeChange),t.removeEventListener(M.Table.EVENT_DISCONNECT,this.handleDisconnect),t.removeEventListener(M.Table.EVENT_RECONNECT,this.handleReconnect)}handleChange({column:t,isValueShown:e,value:n}){const{name:s=void 0,type:i=void 0}=t!=null?t:{};let o=!0,r=Date.now();this.setState(({panelState:l,timestamp:a,wasFlipped:d,skipUpdate:c})=>{var m;const u=l!=null&&e!==l.isValueShown&&s===l.name&&i===l.type&&n===l.value;return o=(m=!c&&e&&(!u||!d))!=null?m:!1,o||(r=a),{panelState:{isValueShown:e,name:s,type:i,value:n,timestamp:r!=null?r:void 0},timestamp:r,wasFlipped:u,skipUpdate:!1}},()=>{o&&this.sendUpdate(s!=null?s:null,i,n,r)})}handleDisconnect(){this.setState({error:new Error("Table disconnected"),isDisconnected:!0,isLoading:!1})}handleReconnect(){this.setState({isDisconnected:!1,error:null})}handleSourceFilterChange(){this.applySourceFilters()}handleSourceSortChange(){this.applySourceSorts()}handleSourceSizeChange({detail:t}){this.setState({sourceSize:t})}handleColumnSelected(){tt.debug("handleColumnSelected");const{glEventHub:t}=this.props;t.emit(He.COLUMN_SELECTED,this,ti.SOURCE_COLUMN)}handleClearAllFilters(){var t,e;(e=(t=this.dropdownFilterRef)==null?void 0:t.current)==null||e.clearFilter()}setPanelState(t,e=!1){var n,s;if(this.getSource()==null){tt.debug("Ignore state update for unlinked filter",t);return}this.setState({skipUpdate:!e}),(s=(n=this.dropdownFilterRef)==null?void 0:n.current)==null||s.setFilterState(t)}sendUpdate(t,e,n,s){var l;const{glEventHub:i}=this.props,o=(l=this.getSource())==null?void 0:l.panelId,r=o===null?[]:[o];tt.debug("sendUpdate",{name:t,type:e,value:n,timestamp:s,excludePanelIds:r}),i.emit(He.FILTERS_CHANGED,this,{name:t,type:e,value:n!=null?n:"=null",timestamp:s,excludePanelIds:r})}updateValuesTable(){const t=this.getSource(),e=this.getSourceTable();if(tt.debug("updateValuesTable",t,e),this.setState({values:[],valuesTable:void 0,error:null}),t==null){tt.debug("Filter unlinked."),this.setState({isLoading:!1,isLoaded:!0,isValueShown:!1,sourceSize:0});return}this.setState({isLoading:!0}),e!=null&&(this.setState({isLoaded:!1,sourceSize:e.size}),this.pending.add(e.copy(),n=>n.close()).then(n=>{this.updateViewportListener(n),this.setState({valuesTable:n})}).catch(n=>{Ee.isCanceled(n)||(tt.error(n),this.setState({isLoading:!1,error:n}))}))}applySourceSorts(){const{valuesTable:t}=this.state,e=this.getSourceTable();if(tt.debug("applySourceSorts",e.sort),t==null){tt.debug("Table not initialized");return}const n=[...e.sort];t.applySort(n),this.setViewport(t)}applySourceFilters(){const{valuesTable:t}=this.state,e=this.getSourceTable();if(tt.debug("applySourceFilters",e.filter),t==null){tt.debug("Table not initialized");return}const n=[...e.filter];t.applyFilter(n),this.setViewport(t)}updateViewportListener(t){if(tt.debug("updateViewportListener",t==null?void 0:t.size),this.cleanup&&this.cleanup(),t==null){this.cleanup=void 0;return}this.cleanup=t.addEventListener(M.Table.EVENT_UPDATED,this.handleValuesTableUpdate),this.setViewport(t)}setViewport(t){const e=this.getValuesColumn(t);if(!e){tt.error("values column is null");return}t.setViewport(0,ti.MAX_TABLE_SIZE-1,[e])}updateFormatterSettings(t){const e=cs.getColumnFormats(t);ct(this.columnFormats,e)||(this.columnFormats=e,this.setState({formatter:new cn(e)}))}handleValuesTableUpdate({detail:t}){const{rows:e}=t,{valuesTable:n}=this.state;if(!n){tt.error("valuesTable is null");return}const s=this.getValuesColumn(n);if(!s){tt.error("Values column not found");return}const i=e.map(o=>o.get(s));this.setState({values:i,isLoading:!1,isLoaded:!0,valuesColumn:s})}handleSourceMouseEnter(){const{columnSelectionValidator:t}=this.props;!t||t(this,ti.SOURCE_COLUMN)}handleSourceMouseLeave(){const{columnSelectionValidator:t}=this.props;!t||t(this,void 0)}render(){const{columns:t,disableLinking:e,glContainer:n,glEventHub:s,isLinkerActive:i}=this.props,{column:o,formatter:r,isDisconnected:l,isValueShown:a,value:d,values:c,valuesColumn:u,isLoading:m,isLoaded:p}=this.state,g=this.getSource(),f=this.getSettingsErrorMessage(),b=this.getPanelErrorMessage(),C=p&&u!=null?this.getCachedValues(c,u,r):[];return h(Pl,{errorMessage:b,isLoading:m,isLoaded:p,isDisconnected:l,className:"iris-dropdown-filter-panel",componentPanel:this,glContainer:n,glEventHub:s,onClearAllFilters:this.handleClearAllFilters,widgetName:"Dropdown Filter",widgetType:"DropdownFilter",children:h("div",{ref:this.panelContainer,className:"dropdown-filter-container h-100 w-100 container",children:h(Ki,{ref:this.dropdownFilterRef,column:o,columns:t,isValueShown:a,isLinkerActive:i,disableLinking:e,isLoaded:p,settingsError:f,source:g,value:d,values:C,onChange:this.handleChange,onColumnSelected:this.handleColumnSelected,onSourceMouseEnter:this.handleSourceMouseEnter,onSourceMouseLeave:this.handleSourceMouseLeave})})})}};let io=ti;io.displayName="DropdownFilterPanel";io.COMPONENT="DropdownFilterPanel";io.MAX_TABLE_SIZE=256;io.DATETIME_FORMATTER=new at({showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:"yyyy-MM-dd HH:mm:ss.SSSSSSSSS"});io.SOURCE_COLUMN=Object.freeze({name:"FilterSource",type:null});const TE=(t,e)=>{const{localDashboardId:n}=e,s=te.getIdFromPanel({props:e}),i=Yd(t,n),o=so(t,n),r=Rl(t),l=Xd(t,n),a=r===dn.LINKER&&(l===void 0||l===s),d=r===dn.LINKER&&l!==void 0&&l!==s;return{columns:Ep(t,n),columnSelectionValidator:jd(t,n),isLinkerActive:a,disableLinking:d,settings:Kt(t),panelTableMap:i,dashboardLinks:o}},ci=Dt(TE,null,null,{forwardRef:!0})(io);function Gn(t){return t.type==="directory"}var Dp=(t=>(t.GROOVY="text/x-groovy",t.PLAIN_TEXT="text/plain",t.PYTHON="text/x-python",t.PYTHON_COMPILED="application/x-python-code",t.SCALA="text/x-scala",t.UNKNOWN="",t))(Dp||{});class de{static fileExtensionToString(e=""){return e.length===0?"":`.${e}`}static getDepth(e){var s;if(!de.hasPath(e))throw new Error(`Invalid path provided: ${e}`);return((s=e.match(/\//g))!=null?s:[]).length-1}static getExtension(e){var s;const n=this.getBaseName(e).split(".");return n.length>1&&(s=n.pop())!=null?s:""}static getBaseName(e){var n;return(n=e.split("/").pop())!=null?n:""}static getCopyFileName(e){const n=e.lastIndexOf(".");let s=null,i=null;n<0?i=e:(i=e.substring(0,n),s=e.substring(n+1));const o=i?`${i}-copy`:"Copy";return s!==null?`${o}.${s}`:o}static getMimeType(e){switch(this.getExtension(e).toLowerCase()){case"groovy":return"text/x-groovy";case"py":return"text/x-python";case"pyc":return"application/x-python-code";case"scala":return"text/x-scala";case"txt":return"text/plain";default:return""}}static getParent(e){if(!de.hasPath(e))throw new Error(`Invalid name provided: ${e}`);const n=e.split("/");for(;n.pop()==="";);if(n.length===0)throw new Error(`No parent for path provided: ${e}`);return`${n.join("/")}/`}static getPath(e){if(!de.hasPath(e))throw new Error(`Invalid filename provided: ${e}`);const n=e.split("/");return n.pop(),`${n.join("/")}/`}static hasPath(e){return e.startsWith("/")}static isPath(e){return e.startsWith("/")&&e.endsWith("/")}static makePath(e){return e.endsWith("/")?e:`${e}/`}static replaceExtension(e,n=""){const s=e.lastIndexOf("."),i=s>-1?e.substring(0,s):e,o=de.fileExtensionToString(n);return`${i}${o}`}static validateName(e){var o;const n=[".",".."],s=/[\\/\0]/g,i=new Map([["\0","null"]]);if(!e)throw new Ai("Name cannot be empty");if(n.includes(e))throw new Ai(`"${e}" is a reserved name`);if(s.test(e))throw new Ai(`Invalid characters in name: "${((o=e.match(s))!=null?o:[]).reduce((r,l)=>r.includes(l)?r:[...r,l],[]).map(r=>i.has(r)?i.get(r):r).join('", "')}"`)}static reducePaths(e){const n=e.filter(s=>de.isPath(s));return e.filter(s=>!n.some(i=>s!==i&&s.startsWith(i)))}static removeRoot(e,n){if(e.length===0)return n;if(!n.startsWith(e))throw new Error(`Filename ${n} does not start with expected root ${e}`);return n.substring(e.length)}static addRoot(e,n){return`${e}${n}`}}const xt=X.module("FileList"),$a=t=>Gn(t)?de.makePath(t.filename):de.getPath(t.filename),ec=26,EE=500,Fh="item-list-scroll-pane",za=t=>{var I;const{children:e,draggedItems:n,isDragInProgress:s,isDropTargetValid:i,isSelected:o,item:r,itemIndex:l,dropTargetItem:a,onDragStart:d,onDragOver:c,onDragEnd:u,onDrop:m}=t,p=(I=n==null?void 0:n.some(R=>R.id===r.id))!=null?I:!1,g=$a(r),f=s&&a?$a(a):null,b=s&&i&&Gn(r)&&f===g,C=s&&i&&f===g,w=s&&!i&&f===g,T=yE(r),y=de.getDepth(r.filename),E=Array(y).fill(null).map((R,F)=>h("span",{className:"file-list-depth-line"},F));return v("div",{className:z("d-flex w-100 align-items-center","file-list-item",{"is-dragged":p,"is-exact-drop-target":b,"is-in-drop-target":C,"is-invalid-drop-target":w,"is-selected":o}),onDragStart:R=>d(l,R),onDragOver:R=>c(l,R),onDragEnd:R=>u(l,R),onDrop:R=>m(l,R),draggable:!0,role:"presentation","aria-label":r.basename,children:[E," ",h(K,{icon:T,className:"item-icon",fixedWidth:!0})," ",v("span",{className:"truncation-wrapper",children:[e!=null?e:r.basename,h(Ie,{options:{modifiers:{preventOverflow:{boundariesElement:"window"}},placement:"left"},children:e!=null?e:r.basename})]})]})};function yE(t){if(Gn(t))return t.isExpanded?vf:Tf;switch(de.getMimeType(t.basename)){case Dp.PYTHON:return eC;default:return bf}}function xh(t,e){if(t.length===0||e==null)throw new Error("No items to move");const n=$a(e);if(t.some(({filename:s})=>de.getPath(s)===n))throw new Error("File already in the destination folder");if(t.some(s=>Gn(s)&&n.startsWith(de.makePath(s.filename))))throw new Error("Destination folder cannot be a child of a dragged folder");return{files:t,targetPath:n}}const IE=t=>{const{isMultiSelect:e=!1,table:n,onFocusChange:s=()=>{},onMove:i,onSelect:o,onSelectionChange:r=()=>{},renderItem:l=za,rowHeight:a=ec,overscanCount:d=Cn.DEFAULT_OVERSCAN}=t,[c,u]=S.exports.useState(()=>({items:[],offset:0,itemCount:0})),[m,p]=S.exports.useState({top:0,bottom:0}),[g,f]=S.exports.useState(),[b,C]=S.exports.useState(),[w,T]=S.exports.useState(),[y,E]=S.exports.useState([]),I=S.exports.useRef(null),R=S.exports.useRef(null),F=S.exports.useCallback(J=>{if(J.length===0||c==null)return[];const pe=[];for(let fe=0;fe<J.length;fe+=1){const xe=J[fe];for(let ke=xe[0];ke<=xe[1];ke+=1)ke>=c.offset&&ke<c.offset+c.items.length&&pe.push(c.items[ke-c.offset])}return pe},[c]),x=S.exports.useCallback(J=>{const pe=F([[J,J]]);if(pe.length>0)return pe[0]},[F]),U=S.exports.useCallback(()=>{const J=gn.count(y);if(J===0)return null;if(J===1){const pe=y[0][0],fe=x(pe);if(fe!=null)return fe.filename}return`${J} items`},[x,y]),$=S.exports.useCallback(J=>{var pe;if(!(!b||!g)){xt.debug("dropItems",b,"to",J);try{const{files:fe,targetPath:xe}=xh(b,g);i(fe,xe),J!=null&&(E([[J,J]]),(pe=I.current)==null||pe.focusItem(J))}catch(fe){xt.error("Unable to complete move",fe)}}},[b,g,i]),O=S.exports.useCallback((J,pe)=>{const fe=c.items[J-c.offset];fe!==void 0&&(xt.debug("handleItemClick",fe),o(fe,pe),Gn(fe)&&(n==null||n.setExpanded(fe.filename,!fe.isExpanded)))},[c,o,n]),H=S.exports.useCallback((J,pe)=>{var ke;xt.debug2("handleItemDragStart",J,y);let fe=y;gn.isSelected(y,J)||(fe=[[J,J]],E(fe)),C(F(fe)),(ke=I.current)==null||ke.resetMouseState();const xe=document.createElement("div");xe.innerHTML=`<div class="dnd-placeholder-content">${U()}</div>`,xe.className="file-list-dnd-placeholder",document.body.appendChild(xe),pe.dataTransfer.setDragImage(xe,0,0),pe.dataTransfer.effectAllowed="move",T(xe)},[U,F,y]),L=S.exports.useCallback((J,pe)=>{pe.preventDefault(),xt.debug2("handleItemDragOver",pe),f(x(J))},[x]),N=S.exports.useCallback((J,pe)=>{xt.debug("handleItemDragEnd",J),w==null||w.remove(),C(void 0),f(void 0),T(void 0)},[w]),_=S.exports.useCallback((J,pe)=>{$(J)},[$]),k=S.exports.useCallback(()=>{xt.debug2("handleItemDragExit"),f(void 0)},[]),V=S.exports.useCallback(J=>{J.target instanceof Element&&J.target.classList.contains(Fh)&&(J.preventDefault(),xt.debug2("handleListDragOver",J),f({type:"directory",filename:"/",basename:"/",id:"/"}))},[]),W=S.exports.useCallback(J=>{J.target instanceof Element&&J.target.classList.contains(Fh)&&(xt.debug("handleListDrop"),$())},[$]),j=S.exports.useCallback(J=>{if(xt.debug2("handleSelectionChange",J),J!==y){E(J);const pe=F(J);r(pe)}},[F,r,y]),ee=S.exports.useCallback(J=>{if(xt.debug2("handleFocusChange",J),J!=null){const[pe]=F([[J,J]]);s(pe)}else s()},[F,s]),ve=S.exports.useCallback((J,pe)=>{xt.debug("handleViewportChange",J,pe),(J!==m.top||pe!==m.bottom)&&p({top:J,bottom:pe})},[m]),le=S.exports.useMemo(()=>{if(!b||!g)return!1;try{return xh(b,g),xt.debug("handleValidateDropTarget true"),!0}catch{return xt.debug("handleValidateDropTarget false"),!1}},[b,g]),{focusedPath:Se}=t;S.exports.useEffect(()=>{Se!==void 0&&(Se==="/"?n.collapseAll():(n.setExpanded(Se,!1),n.setExpanded(Se,!0)))},[n,Se]),S.exports.useEffect(function(){xt.debug("updating table viewport",m),n==null||n.setViewport({top:Math.max(0,m.top-d),bottom:m.bottom+d})},[d,n,m]),S.exports.useEffect(function(){const pe=n.onUpdate(fe=>{u({items:fe.items.map(xe=>({...xe,itemName:xe.basename})),offset:fe.offset,itemCount:n.size})});return()=>{pe()}},[n]),S.exports.useEffect(function(){if(g!=null&&Gn(g)&&g.filename!=="/"){const pe=setTimeout(()=>{g.isExpanded||n==null||n.setExpanded(g.filename,!0)},EE);return()=>clearTimeout(pe)}},[g,n]);const Le=S.exports.useCallback(J=>l({...J,isDragInProgress:b!=null,dropTargetItem:g,draggedItems:b,isDropTargetValid:le,onDragStart:H,onDragEnd:N,onDragOver:L,onDragExit:k,onDrop:_}),[N,k,L,H,_,b,g,le,l]);return h("div",{ref:R,className:z("file-list",{"is-dragging":b!=null}),onDragOver:V,onDrop:W,children:h(Cn,{ref:I,items:c.items,itemCount:c.itemCount,offset:c.offset,onFocusChange:ee,onSelect:O,onSelectionChange:j,onViewportChange:ve,selectedRanges:y,renderItem:Le,rowHeight:a,isMultiSelect:e,isDragSelect:!1,isDeselectOnClick:!1})})};const RE={name:"File Explorer",DELETE:Be.createAndAdd({id:"FILE_EXPLORER.DELETE",name:"Delete",shortcut:[ge.DELETE],macShortcut:[me.CMD,ge.BACKSPACE]}),RENAME:Be.createAndAdd({id:"FILE_EXPLORER.RENAME",name:"Rename",shortcut:[ge.ENTER],macShortcut:[ge.ENTER]})},_h={FILE_EXPLORER:RE};const kh=X.module("FileListItemEditor"),DE=({item:t,onCancel:e,onSubmit:n,validate:s=()=>Promise.resolve()})=>{const i=S.exports.useRef(null),[o,r]=S.exports.useState(t.basename),[l,a]=S.exports.useState(),[d,c]=S.exports.useState(Promise.resolve()),u=S.exports.useCallback(()=>{var C;(C=i.current)==null||C.focus()},[i]),m=S.exports.useCallback(C=>C.stopPropagation(),[]),p=S.exports.useCallback(()=>{d.then(()=>{n(o)}).catch(C=>kh.info("Unable to validate name",C))},[n,o,d]);S.exports.useEffect(function(){const w=Ee.makeCancelable(s(o));return w.then(()=>a(void 0)).catch(T=>{Ee.isCanceled(T)||a(T)}),c(w),()=>w.cancel()},[s,o]),S.exports.useEffect(function(){u()},[u]);const g=S.exports.useCallback(()=>{kh.debug2("handleBlur"),p()},[p]),f=S.exports.useCallback(C=>{const{value:w}=C.target;r(w)},[]),b=S.exports.useCallback(C=>{C.stopPropagation();const{key:w}=C;switch(w){case"Enter":{p();break}case"Escape":{e();break}}},[e,p]);return v("div",{className:"file-list-item-editor",children:[h("input",{type:"text",className:z("form-control file-list-item-editor-input",{"is-invalid":l}),value:o,ref:i,onBlur:g,onKeyDown:b,onChange:f,onClick:m,onDoubleClick:m,onMouseDown:m}),l&&h("div",{className:"invalid-feedback",children:`${l}`})]})},Mp=t=>{const{isMultiSelect:e=!1,focusedPath:n,showContextMenu:s=!1,onCreateFile:i,onCreateFolder:o,onCopy:r,onDelete:l,onMove:a=()=>{},onRename:d,onSelect:c,onSelectionChange:u,table:m,rowHeight:p=ec,validateRename:g=()=>Promise.resolve()}=t,[f,b]=S.exports.useState(),[C,w]=S.exports.useState([]),[T,y]=S.exports.useState(),E=S.exports.useCallback(k=>{w(k),u==null||u(k)},[u]),I=S.exports.useCallback(k=>{y(k)},[]),R=S.exports.useCallback(()=>{T&&(r==null||r(T))},[T,r]),F=S.exports.useCallback(()=>{C.length>0&&(l==null||l(C))},[l,C]),x=S.exports.useCallback(()=>{i==null||i()},[i]),U=S.exports.useCallback(()=>{T&&(o==null||o(de.getPath(T.filename)))},[T,o]),$=S.exports.useCallback(()=>{T&&b(T)},[T]),O=S.exports.useCallback(()=>{b(void 0)},[]),H=S.exports.useCallback(k=>{f&&(d==null||d(f,k),b(void 0))},[d,f]),L=S.exports.useMemo(()=>{if(f)return[];const k=[];return i&&k.push({title:"New File",description:"Create new file",action:x,group:oe.groups.medium}),o&&k.push({title:"New Folder",description:"Create new folder",action:U,group:oe.groups.medium}),r&&k.push({title:"Copy",description:"Copy",action:R,group:oe.groups.low,disabled:T==null||Gn(T)}),l&&C.length>0&&k.push({title:"Delete",description:"Delete",shortcut:_h.FILE_EXPLORER.DELETE,action:F,group:oe.groups.low}),d&&k.push({title:"Rename",description:"Rename",shortcut:_h.FILE_EXPLORER.RENAME,action:$,group:oe.groups.low,disabled:T==null}),k},[R,F,x,U,$,T,r,i,o,l,d,C,f]),N=S.exports.useCallback(k=>f?g(f,k):Promise.reject(new Error("No rename item")),[f,g]),_=S.exports.useCallback(k=>{const{item:V}=k;return f&&f.filename===V.filename?za({...k,children:h(DE,{item:V,validate:N,onSubmit:H,onCancel:O})}):za(k)},[O,H,f,N]);return v("div",{className:"file-list-container",children:[m!=null&&h(IE,{onMove:a,onSelect:c,onSelectionChange:E,onFocusChange:I,renderItem:_,rowHeight:p,table:m,isMultiSelect:e,focusedPath:n}),s&&h(oe,{actions:L})]})};Mp.displayName="FileListContainer";class Vr extends Ai{constructor(e){super("Name already exists"),this.isExistingFile=!0,this.info=e}}class tc extends Error{constructor(){super("No file exists at the path specified"),this.isFileNotFound=!0}}const Gs=X.module("FileExplorer"),nc=t=>{const{storage:e,isMultiSelect:n=!1,focusedPath:s,onDelete:i=()=>{},onRename:o=()=>{},onSelect:r,onSelectionChange:l,rowHeight:a=ec}=t,[d,c]=S.exports.useState([]),[u,m]=S.exports.useState();S.exports.useEffect(function(){let R;async function F(){Gs.debug("initTable"),R=Ee.makeCancelable(e.getTable(),x=>x.close());try{m(await R)}catch(x){Ee.isCanceled(x)||Gs.error("Unable to initialize table",x)}}return F(),()=>{R.cancel()}},[e]);const p=S.exports.useCallback(I=>{Ee.isCanceled(I)||Gs.error(I)},[]),g=S.exports.useCallback(I=>{Gs.debug("handleDelete, pending confirmation",I),c(I)},[]),f=S.exports.useCallback(()=>{Gs.debug("handleDeleteConfirm",d),d.forEach(I=>e.deleteFile(Gn(I)?de.makePath(I.filename):I.filename)),i(d),c([])},[d,i,e]),b=S.exports.useCallback(()=>{Gs.debug("handleDeleteCancel"),c([])},[]),C=S.exports.useCallback((I,R)=>{de.reducePaths(I.map(x=>Gn(x)?de.makePath(x.filename):x.filename)).forEach(x=>{const U=de.isPath(x)?`${R}${de.getBaseName(x.substring(0,x.length-1))}/`:`${R}${de.getBaseName(x)}`;e.moveFile(x,U).then(()=>{o(x,U)}).catch(p)})},[p,o,e]),w=S.exports.useCallback((I,R)=>{let F=I.filename;const x=Gn(I);x&&!F.endsWith("/")&&(F=`${F}/`);let U=`${de.getParent(F)}${R}`;x&&!U.endsWith("/")&&(U=`${U}/`),Gs.debug2("handleRename",F,U),e.moveFile(F,U).catch(p),o(F,U)},[p,o,e]),T=S.exports.useCallback(async(I,R)=>{if(R===I.basename)return;de.validateName(R);const F=`${de.getPath(I.filename)}${R}`;try{const x=await e.info(F);throw new Vr(x)}catch(x){if(!(x instanceof tc))throw x}},[e]),y=d.length>0,E=S.exports.useMemo(()=>d.length===1?`Are you sure you want to delete "${d[0].filename}"?`:"Are you sure you want to delete the selected files?",[d]);return v("div",{className:"file-explorer",children:[u&&h(Mp,{isMultiSelect:n,focusedPath:s,showContextMenu:!0,onMove:C,onDelete:g,onRename:w,onSelect:r,onSelectionChange:l,rowHeight:a,table:u,validateRename:T}),h(Ui,{isOpen:y,headerText:E,bodyText:"You cannot undo this action.",onCancel:b,onConfirm:f,confirmButtonText:"Delete"})]})};nc.displayName="FileExplorer";const Ks=X.module("NewItemModal"),Ur=class extends S.exports.PureComponent{constructor(t){super(t),this.inputRef=Y.createRef(),this.pending=new ps,this.pathMap=new Map,this.isInitialLoad=!0,this.handleModalSubmit=this.handleModalSubmit.bind(this),this.handleModalOpened=this.handleModalOpened.bind(this),this.handleSelect=this.handleSelect.bind(this),this.handleChange=this.handleChange.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleValidationError=this.handleValidationError.bind(this),this.handleOverwriteCancel=this.handleOverwriteCancel.bind(this),this.handleOverwriteConfirm=this.handleOverwriteConfirm.bind(this),this.handleExtensionChangeCancel=this.handleExtensionChangeCancel.bind(this),this.handleExtensionChangeConfirm=this.handleExtensionChangeConfirm.bind(this),this.handleBreadcrumbSelect=this.handleBreadcrumbSelect.bind(this);const{defaultValue:e}=t,n=de.hasPath(e)?de.getPath(e):"/";this.state={isSubmitting:!1,path:n,prevExtension:de.getExtension(e),showExtensionChangeModal:!1,showOverwriteModal:!1,value:de.getBaseName(e)}}static getValidationMessage(t){return t instanceof Vr&&t.info.type==="directory"?"Error: Cannot overwrite existing directory":`${t}`}static handleError(t){Ee.isCanceled(t)||Ks.error(t)}componentDidUpdate(t,e){const{isOpen:n}=this.props,{isOpen:s}=t,{value:i,path:o}=this.state;!s&&n&&(this.resetValue(),this.isInitialLoad=!0),s&&n&&(!this.isInitialLoad&&(o!==e.path||i!==e.value)&&this.updateValidationStatus(o,i),this.isInitialLoad=!1)}componentWillUnmount(){this.pending.cancel(),this.cancelableValidatePromise&&this.cancelableValidatePromise.cancel(),this.cancelableExistingItemPromise&&this.cancelableExistingItemPromise.cancel()}resetValue(){const{defaultValue:t}=this.props,e=de.hasPath(t)?de.getPath(t):"/";this.setState({path:e,value:de.getBaseName(t),validationError:void 0,prevExtension:de.getExtension(t),isSubmitting:!1})}getValidationPromise(t,e,n=!1){return this.cancelableValidatePromise&&this.cancelableValidatePromise.cancel(),this.cancelableValidatePromise=Ee.makeCancelable(this.validateName(t,e,n)),this.cancelableValidatePromise}async validateName(t,e,n){de.validateName(e);const{defaultValue:s,storage:i}=this.props;if(n){const o=`${t}${e}`;if(o!==s)try{const r=await i.info(o);throw new Vr(r)}catch(r){if(!(r instanceof tc))throw r}}return e}updateValidationStatus(t,e){this.getValidationPromise(t,e).then(()=>{this.setState({validationError:void 0})}).catch(this.handleValidationError).catch(Ur.handleError)}handleModalOpened(){this.focusRenameInput()}handleModalSubmit(){this.submitModal()}handleChange(t){const{value:e}=t.target;this.setState({value:e})}handleSelect(t){if(Ks.debug("handleSelect",t),t.type==="directory")this.setState({path:de.makePath(t.filename)});else{const e=t.basename,n=de.getPath(t.filename);this.setState({value:e,path:n},()=>{this.focusRenameInput()})}}handleKeyDown(t){const{key:e}=t;switch(t.stopPropagation(),e){case"Enter":{t.preventDefault(),this.submitModal();break}case"Escape":{t.preventDefault();const{onCancel:n}=this.props;n();break}}}handleValidationError(t){if(!(t instanceof Ai))throw t;Ks.debug("Validation error",t),this.setState({validationError:t})}handleOverwriteCancel(){this.setState({showOverwriteModal:!1,isSubmitting:!1})}handleOverwriteConfirm(){this.setState({showOverwriteModal:!1});const{onSubmit:t}=this.props,{path:e,value:n}=this.state;Ks.debug("handleOverwriteConfirm",e,n),t(`${e}${n}`)}handleExtensionChangeCancel(){Ks.debug("handleExtensionChangeCancel"),this.setState(({value:t,prevExtension:e})=>{const n=de.replaceExtension(t,e);return{showExtensionChangeModal:!1,value:n}}),this.submitModal(!0)}handleExtensionChangeConfirm(){Ks.debug("handleExtensionChangeConfirm"),this.setState({showExtensionChangeModal:!1}),this.submitModal(!0)}focusRenameInput(){const t=this.inputRef.current;if(t){const{type:e}=this.props,{value:n}=t,s=e==="directory"?n.length:n.lastIndexOf(".");t.focus(),t.setSelectionRange(0,s>0?s:n.length)}}submitModal(t=!1){this.setState(({prevExtension:e,value:n,path:s})=>{const{notifyOnExtensionChange:i,type:o}=this.props;Ks.debug("submitModal",e,n);const r=de.getExtension(n);return i&&!t&&e!==null&&e!==r?{isSubmitting:!1,showExtensionChangeModal:!0,newExtension:r}:(this.getValidationPromise(s,n,!0).then(l=>{const{onSubmit:a}=this.props;a(`${s}${n}`)}).catch(l=>{if(l instanceof Vr&&o!=="directory"&&l.info.type!=="directory"){this.setState({showOverwriteModal:!0});return}throw l}).catch(l=>{throw Ee.isCanceled(l)&&this.setState({isSubmitting:!1}),l}).catch(this.handleValidationError).catch(Ur.handleError),{isSubmitting:!0,showExtensionChangeModal:!1,newExtension:void 0})})}handleBreadcrumbSelect(t){this.setState({path:t})}renderPathButtons(t){const e=t.split("/");return e.pop(),e.map((n,s)=>{let i="";for(let o=0;o<s;o+=1)i+=`${e[o]}/`;return i+=`${n}/`,v(Y.Fragment,{children:[h(Q,{kind:"ghost",className:"directory-breadcrumbs",onClick:()=>this.handleBreadcrumbSelect(i),"aria-label":s===0?"Home":void 0,icon:s===0?h(K,{icon:Ef,transform:"right-1.6"}):void 0,tooltip:s===0?"Home":void 0,children:n}),"/"]},i)})}render(){const{storage:t,isOpen:e,onCancel:n,placeholder:s,title:i,type:o}=this.props,{isSubmitting:r,path:l,showExtensionChangeModal:a,showOverwriteModal:d,validationError:c,value:u,prevExtension:m,newExtension:p}=this.state,g=o==="directory",f=de.fileExtensionToString(m),b=de.fileExtensionToString(p),C=g?"Create":"Save",w=g?"New folder name":"Save file as";return v(ue,{children:[v(Uo,{isOpen:e,toggle:n,onOpened:this.handleModalOpened,className:"modal-dialog-centered new-file-modal theme-bg-dark",children:[h($o,{toggle:n,children:i}),h(Bo,{children:h("form",{children:v("div",{className:"d-flex flex-column new-file-modal-content",children:[v("div",{className:"flex-grow-0 mb-4",children:[h("label",{htmlFor:"file-name-input",children:w}),h("input",{id:"file-name-input",type:"text",autoComplete:"off",autoCapitalize:"none",autoCorrect:"off",spellCheck:"false",className:z("form-control",{"is-invalid":c}),value:u,placeholder:s,ref:this.inputRef,onKeyDown:this.handleKeyDown,onChange:this.handleChange}),c&&h("div",{className:"invalid-feedback",children:Ur.getValidationMessage(c)})]}),v("div",{className:"flex-grow-0",children:[h("label",{children:"Directory: /"}),this.renderPathButtons(l)]}),h("div",{className:"flex-grow-1 file-explorer-container",children:h(nc,{onSelect:this.handleSelect,storage:t,focusedPath:l})})]})})}),v(sd,{children:[h(Q,{kind:"secondary",onClick:n,children:"Cancel"}),h(Q,{kind:"primary",disabled:r,onClick:this.handleModalSubmit,children:C})]})]}),h(Ui,{isOpen:d,headerText:"Confirm overwrite",bodyText:"File with this name already exists, are you sure you want to overwrite it?",onCancel:this.handleOverwriteCancel,onConfirm:this.handleOverwriteConfirm,cancelButtonText:"Cancel",confirmButtonText:"Overwrite"}),h(Ui,{isOpen:a,headerText:"Confirm extension change",bodyText:`Are you sure you want to change extension from "${f}" to "${b}"?`,onCancel:this.handleExtensionChangeCancel,onConfirm:this.handleExtensionChangeConfirm,cancelButtonText:`Keep "${f}"`,confirmButtonText:`Use "${b}"`})]})}};let Ul=Ur;Ul.propTypes={isOpen:D.exports.bool,title:D.exports.string.isRequired,defaultValue:D.exports.string,type:D.exports.oneOf(["file","directory"]).isRequired,onSubmit:D.exports.func,onCancel:D.exports.func,placeholder:D.exports.string,storage:D.exports.shape({}).isRequired,notifyOnExtensionChange:D.exports.bool};Ul.defaultProps={isOpen:!1,defaultValue:"/",notifyOnExtensionChange:!1,placeholder:"",onSubmit:t=>{},onCancel:()=>{}};const ME=({createFile:t,createFolder:e,onSearchChange:n,defaultSearchText:s=""})=>v("div",{className:"file-explorer-toolbar",children:[v("div",{className:"file-explorer-toolbar-buttons",children:[h(Q,{kind:"ghost",icon:pu,tooltip:"New notebook",onClick:t,"aria-label":"New notebook"}),h(Q,{kind:"ghost",icon:xf,tooltip:"New folder",onClick:e,"aria-label":"New folder"})]}),n&&h("div",{className:"file-explorer-toolbar-search",children:h(Ou,{value:s,onChange:n,placeholder:"Search by name"})})]});const Ri=X.module("FileExplorerPanel"),NE=(t,e)=>{const n=um(t),s=gi(t,e.localDashboardId),{session:i,config:o}=s!=null?s:{},r=o==null?void 0:o.type;return{fileStorage:n,language:r,session:i}},FE=Dt(NE,null,null,{forwardRef:!0});function xE(t){const e=t;return e!=null&&typeof e.button=="number"}const Wa=class extends Y.Component{static handleError(t){Ri.error(t)}static isFocusEvent(t){return xE(t)?t.detail>=2:!0}constructor(t){super(t),this.handleFileSelect=this.handleFileSelect.bind(this),this.handleCreateFile=this.handleCreateFile.bind(this),this.handleCreateDirectory=this.handleCreateDirectory.bind(this),this.handleCreateDirectoryCancel=this.handleCreateDirectoryCancel.bind(this),this.handleCreateDirectorySubmit=this.handleCreateDirectorySubmit.bind(this),this.handleDelete=this.handleDelete.bind(this),this.handleRename=this.handleRename.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleSelectionChange=this.handleSelectionChange.bind(this);const{session:e,language:n}=t;this.state={isShown:!1,language:n,session:e,showCreateFolder:!1,focusedFilePath:"/"}}componentDidMount(){this.isHidden()||this.setState({isShown:!0})}handleCreateFile(){const{glEventHub:t}=this.props,{session:e,language:n}=this.state,s={language:n,value:""};Ri.debug("handleCreateFile",e,n,s),t.emit(Ve.CREATE_NOTEBOOK,e,n,s)}handleCreateDirectory(t){this.setState({showCreateFolder:!0})}handleCreateDirectoryCancel(){Ri.debug("handleCreateDirectoryCancel"),this.setState({showCreateFolder:!1})}handleCreateDirectorySubmit(t){Ri.debug("handleCreateDirectorySubmit",t),this.setState({showCreateFolder:!1});const{fileStorage:e}=this.props;e.createDirectory(t).catch(Wa.handleError)}handleDelete(t){const{glEventHub:e}=this.props;t.forEach(n=>{e.emit(Ve.CLOSE_FILE,{id:n.filename,itemName:n.filename})})}handleSelectionChange(t){let e="/";t.length===1&&(t[0].type==="directory"?e=de.makePath(t[0].filename):e=de.getPath(t[0].filename)),this.setState({focusedFilePath:e})}handleFileSelect(t,e){if(Ri.debug("fileSelect",t),t.type==="directory")return;const n=Wa.isFocusEvent(e),s={id:t.filename,itemName:t.filename},{glEventHub:i}=this.props,{session:o,language:r}=this.state,l={value:null,language:r};i.emit(Ve.SELECT_NOTEBOOK,o,r,l,s,n)}handleRename(t,e){const{glEventHub:n}=this.props;Ri.debug("handleRename",t,e),n.emit(Ve.RENAME_FILE,t,e)}handleSessionOpened(t,{language:e}){this.setState({session:t,language:e})}handleSessionClosed(){this.setState({session:void 0,language:void 0})}handleShow(){this.setState({isShown:!0})}isHidden(){const{glContainer:t}=this.props,{isHidden:e}=t;return e}render(){const{fileStorage:t,glContainer:e,glEventHub:n}=this.props,{isShown:s,showCreateFolder:i,focusedFilePath:o}=this.state;return v(Yn,{className:"file-explorer-panel",componentPanel:this,glContainer:e,glEventHub:n,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onShow:this.handleShow,children:[h(ME,{createFile:this.handleCreateFile,createFolder:this.handleCreateDirectory}),s&&h(nc,{isMultiSelect:!0,storage:t,onDelete:this.handleDelete,onRename:this.handleRename,onSelect:this.handleFileSelect,onSelectionChange:this.handleSelectionChange}),h(Ul,{isOpen:i,type:"directory",title:"Create New Folder",storage:t,onSubmit:this.handleCreateDirectorySubmit,onCancel:this.handleCreateDirectoryCancel,defaultValue:o})]})}};let sc=Wa;sc.COMPONENT="FileExplorerPanel";sc.TITLE="File Explorer";const sl=FE(sc);const ot=X.module("FilterSetManager"),_E="Enter name...",Oh="No Available Filter Sets";class il extends S.exports.Component{constructor(e){super(e),this.renameInputRef=Y.createRef(),this.dropdownRef=Y.createRef(),this.editDropdownRef=Y.createRef(),this.isRenamingExistingSet=he((n,s)=>s!==void 0&&n.some(({id:i})=>i===s.id)),this.handleSettingsCancel=this.handleSettingsCancel.bind(this),this.handleSettingsClick=this.handleSettingsClick.bind(this),this.handleSettingsSave=this.handleSettingsSave.bind(this),this.handleBackgroundClick=this.handleBackgroundClick.bind(this),this.handleEditDropdownChange=this.handleEditDropdownChange.bind(this),this.handleFilterChange=this.handleFilterChange.bind(this),this.handleFilterApply=this.handleFilterApply.bind(this),this.handleCaptureNewSet=this.handleCaptureNewSet.bind(this),this.handleNameInputChange=this.handleNameInputChange.bind(this),this.handleNameInputKeyPress=this.handleNameInputKeyPress.bind(this),this.handleRenameConfirm=this.handleRenameConfirm.bind(this),this.handleRenameCancel=this.handleRenameCancel.bind(this),this.handleRestoreFullStateChange=this.handleRestoreFullStateChange.bind(this),this.handleSetDelete=this.handleSetDelete.bind(this),this.handleSetEdit=this.handleSetEdit.bind(this),this.handleSetUpdate=this.handleSetUpdate.bind(this),this.state={editId:void 0,renameSet:void 0,nameInputValue:"",nameInputError:void 0,modifiedFilterSets:[],restoreFullState:!1}}static animateScreenFlash(){var n;const e=document.createElement("div");e.classList.add("screen-flash-overlay"),e.addEventListener("animationend",()=>{e.remove()}),(n=document.querySelector("body"))==null||n.appendChild(e)}componentDidMount(){const{isValueShown:e}=this.props;e?this.updateSelectedId():this.initSettingsScreen()}componentDidUpdate(e,n){const{isValueShown:s,filterSets:i}=this.props,{modifiedFilterSets:o}=this.state;if(e.isValueShown&&!s&&this.initSettingsScreen(),this.isNameInputScreen()&&!this.isNameInputScreen(n)&&this.focusRenameInput(),i!==e.filterSets)if(!s&&i.length>0&&e.filterSets.length===0&&o.length===0){const{onChange:r}=this.props;r({isValueShown:!0,selectedId:i[0].id})}else this.updateSelectedId()}initSettingsScreen(){const{filterSets:e,selectedId:n}=this.props;ot.debug("initSettingsScreen",e,n),this.setState({modifiedFilterSets:[...e],editId:n})}updateSelectedId(){const{isValueShown:e,filterSets:n,selectedId:s,onChange:i}=this.props;if(ot.debug("updateSelectedId",n,s),!!e&&!n.some(({id:o})=>o===s)){const o=n.length===0;i({isValueShown:!o,selectedId:o?void 0:n[0].id})}}handleEditDropdownChange(e){const{value:n}=e.target;this.setState({editId:n})}handleFilterChange(e){const{value:n}=e.target,{isValueShown:s,onChange:i}=this.props;this.applyFilterSet(n),i({isValueShown:s,selectedId:n})}handleFilterApply(){const{selectedId:e}=this.props;this.applyFilterSet(e)}handleSettingsCancel(){const{onChange:e,selectedId:n,filterSets:s}=this.props;this.setState({modifiedFilterSets:[]}),s.length>0&&e({isValueShown:!0,selectedId:n})}handleSettingsSave(){const{onChange:e,onUpdateSets:n}=this.props,{modifiedFilterSets:s,editId:i}=this.state;this.setState({modifiedFilterSets:[]}),ot.debug("Update sets",s,i),n(s),s.length>0&&e({isValueShown:!0,selectedId:i})}handleCaptureNewSet(){const{getFilterState:e}=this.props;il.animateScreenFlash();const n=We(),s=e(),i={id:n,title:"",panels:s};ot.debug("handleSetCreate",i),this.setState({nameInputValue:"",nameInputError:void 0,renameSet:i})}handleRenameCancel(){this.setState({renameSet:void 0})}handleRestoreFullStateChange(e){this.setState({restoreFullState:e.target.value==="true"})}getNameError(e){var o;const{renameSet:n,modifiedFilterSets:s}=this.state,i=(o=e==null?void 0:e.trim())!=null?o:"";if(i.length===0)return ot.debug("Name cannot be empty",i),"Name cannot be empty";if(n!==void 0&&s.some(({title:r,id:l})=>r===i&&l!==n.id))return ot.debug("Set with this name already exists",i),"Set with this name already exists"}handleRenameConfirm(){var c;const{nameInputValue:e,renameSet:n,modifiedFilterSets:s,restoreFullState:i}=this.state;if(n===void 0){ot.error("Renamed set undefined.");return}const o=this.getNameError(e);if(ot.debug("handleRenameConfirm",e,o),o!==void 0){this.setState({nameInputError:o});return}const r=(c=e==null?void 0:e.trim())!=null?c:"",l={...n,title:r,restoreFullState:i},a=s.findIndex(({id:u})=>u===n.id),d=[...s];a>=0?(d[a]=l,ot.debug("Renamed existing set",d)):(d.push(l),ot.debug("Added new set to modified sets",d)),this.setState({editId:l.id,modifiedFilterSets:d,renameSet:void 0})}handleSetDelete(){this.setState(e=>{const{editId:n,modifiedFilterSets:s}=e,i=s.findIndex(({id:a})=>a===n);if(i<0)return ot.error("Unable to find selected filterSet index",s,n),null;const o=s.filter(({id:a})=>a!==n),r=Math.max(0,Math.min(o.length-1,i-1)),l=o.length>0?o[r].id:void 0;return ot.debug("Deleted selected set",n,s,o),ot.debug("New selection",r,l),{modifiedFilterSets:o,editId:l}})}handleSetUpdate(){const{getFilterState:e}=this.props;il.animateScreenFlash();const n=e();this.setState(({modifiedFilterSets:s,editId:i})=>{if(i===void 0)return ot.error("Filter for update not selected."),null;const o=[...s],r=o.findIndex(({id:l})=>l===i);return r<0?(ot.error("Selected set for update not found."),null):(o[r]={...o[r],panels:n},ot.debug("Update set",o,n),{modifiedFilterSets:o})})}handleSetEdit(){this.setState(({editId:e,modifiedFilterSets:n})=>{const s=n.find(({id:r})=>r===e);if(s===void 0)return ot.error("Could not find selected set",e,n),null;const{title:i,restoreFullState:o=!1}=s;return{nameInputValue:i,nameInputError:void 0,renameSet:s,restoreFullState:o}})}handleSettingsClick(e){e.stopPropagation();const{onChange:n,selectedId:s}=this.props;n({isValueShown:!1,selectedId:s})}handleBackgroundClick(e){ot.debug("handleBackgroundClick"),e.target!==this.dropdownRef.current&&this.focusInput()}handleNameInputChange(e){const{value:n}=e.target,s=this.getNameError(n);this.setState({nameInputValue:n,nameInputError:s})}handleNameInputKeyPress(e){const{key:n}=e;n==="Enter"&&(e.preventDefault(),this.handleRenameConfirm())}isNameInputScreen(e=this.state){const{renameSet:n}=e;return n!==void 0}applyFilterSet(e){const{onApply:n,filterSets:s}=this.props;if(e===void 0){ot.debug("No filter selected");return}const i=s.find(({id:o})=>o===e);if(i===void 0){ot.debug("Selected id not found in filterSets",e,s);return}ot.debug("Apply filterSet",i),n(i)}focusInput(){var e;(e=this.dropdownRef.current)==null||e.focus()}focusRenameInput(){var e;(e=this.renameInputRef.current)==null||e.focus()}render(){const{nameInputValue:e,nameInputError:n,editId:s,renameSet:i,modifiedFilterSets:o,restoreFullState:r}=this.state,{isValueShown:l,filterSets:a,selectedId:d}=this.props,c=this.isNameInputScreen(),u=this.isRenamingExistingSet(o,i),m=o.length===0,p=!c&&m&&a.length===0,g=!c&&!p,f=v("div",{className:"fa-layers mr-3",children:[h(K,{icon:Lo,mask:ya,transform:"shrink-1 down-5 right-7"}),h(K,{icon:Ls,className:"text-primary",transform:"shrink-6 down-5 right-7"})]}),b=v("div",{className:"fa-layers",children:[h(K,{icon:Lo,mask:ya,transform:"shrink-1 down-5 right-7"}),h(K,{icon:Ea,transform:"shrink-1 down-5 right-7"})]});return h("div",{className:"filter-set-manager fill-parent-absolute",children:v(id,{className:"w-100 h-100",isFlipped:l,children:[h("div",{className:"filter-set-manager-settings-card fill-parent-absolute",children:v("div",{className:"filter-set-manager-card-content",children:[p&&v("div",{children:[h(Q,{kind:"ghost",className:"btn btn-link no-underline",onClick:this.handleCaptureNewSet,icon:f,children:"Capture filter set"}),h("div",{className:"py-3 text-muted small",children:"Takes a snapshot of the currently applied filters on all panels, allowing you to restore saved filter sets later."})]}),c&&v("div",{className:"d-flex flex-column justify-content-center","data-testid":"edit-filter-set-container",children:[v("div",{className:"form-group",children:[h("label",{children:u?"Edit set":"Name captured set"}),v("div",{className:"name-input-container",children:[h("input",{type:"text",className:"input-set-name form-control",placeholder:_E,value:e,ref:this.renameInputRef,onChange:this.handleNameInputChange,onKeyPress:this.handleNameInputKeyPress,spellCheck:"false"}),h(Q,{"data-testid":"rename-confirm-button",kind:"ghost",className:"btn btn-link no-underline pt-2 pb-2",onClick:this.handleRenameConfirm,tooltip:"Save","test-id":"button-save",icon:gu}),h(Q,{"data-testid":"rename-cancel-button",kind:"ghost",className:"btn btn-link no-underline pt-2 pb-2",onClick:this.handleRenameCancel,tooltip:"Cancel",icon:ff})]}),n!==void 0&&h("div",{className:"error-message",children:n})]}),h("div",{className:"form-group",children:v(bl,{onChange:this.handleRestoreFullStateChange,value:`${r}`,children:[h(Mn,{value:"false",children:"Restore only filters"}),h(Mn,{value:"true",children:"Restore full table state"})]})})]}),g&&v("div",{className:"filter-set-manager-settings-grid-1",children:[v("div",{className:"form-group",children:[h("label",{children:"Edit filter sets"}),v("div",{className:"filter-select-container",children:[v("select",{"data-testid":"settings-card-filter-select",ref:this.editDropdownRef,value:s!=null?s:"-1",className:"custom-select filter-value-select",onChange:this.handleEditDropdownChange,disabled:m,children:[m&&h("option",{value:"-1",disabled:!0,children:Oh}),o.map(({id:C,title:w})=>h("option",{value:C,children:w},C))]}),h(Q,{kind:"ghost",onClick:this.handleSetUpdate,disabled:m,icon:b,tooltip:"Update"}),h(Q,{kind:"ghost",onClick:this.handleSetEdit,disabled:m,icon:hl,tooltip:"Edit"}),h(Q,{kind:"ghost",onClick:this.handleSetDelete,disabled:m,icon:_n,tooltip:"Delete"})]})]}),h("div",{children:h(Q,{kind:"ghost",className:"btn btn-link no-underline",onClick:this.handleCaptureNewSet,icon:f,children:"Capture new filter set"})}),v("div",{className:"py-3 text-right",children:[h(Q,{kind:"secondary",onClick:this.handleSettingsCancel,children:"Cancel"}),"\xA0",h(Q,{kind:"primary",onClick:this.handleSettingsSave,children:"Save"})]})]})]})},"front"),h("div",{className:"filter-set-manager-value-card fill-parent-absolute",onClick:this.handleBackgroundClick,children:v(ue,{children:[h("div",{className:"filter-set-manager-column",children:h("div",{className:"filter-set-manager-column-title",children:"Filter sets"})}),h("div",{className:"filter-set-manager-card-content",children:h("div",{className:"filter-set-manager-value-input",children:v("div",{className:"filter-select-container",children:[v("select",{"data-testid":"value-card-filter-select",ref:this.dropdownRef,value:d,className:"custom-select filter-value-select",onChange:this.handleFilterChange,children:[a.length===0&&h("option",{value:"-1",disabled:!0,children:Oh}),a.map(({id:C,title:w})=>h("option",{value:C,children:w},C))]}),h(Q,{"data-testid":"filter-apply-button",kind:"ghost",onClick:this.handleFilterApply,icon:cd,tooltip:"Apply Filter Set"})]})})}),h("div",{className:"filter-set-manager-menu",children:h(Q,{kind:"ghost",className:"btn btn-link btn-link-icon m-2 px-2",onClick:this.handleSettingsClick,tooltip:"Settings",icon:h(K,{icon:zo,transform:"grow-4"})})})]})},"back")]})})}}const ic=t=>{var r;const{model:e,widgetName:n,glContainer:s,description:i}=t,o=e==null?void 0:e.displayString((r=e==null?void 0:e.rowCount)!=null?r:0,"long");return h(Al,{widgetType:"Table",widgetName:n,glContainer:s,description:i,children:v("div",{className:"column-statistics-grid",children:[h("span",{className:"column-statistic-operation",children:"Number of Rows"}),h("span",{className:"column-statistic-value",children:o})]})})};ic.propTypes={glContainer:xd.Container.isRequired,widgetName:D.exports.string.isRequired,description:D.exports.string};ic.defaultProps={description:null};const Hn=X.module("IrisGridPanel"),kE=500,OE={IrisGrid:no,IrisGridTableModel:Cp,ContextMenuRoot:yu};class qi extends S.exports.PureComponent{constructor(e){super(e),this.getGridInputFilters=he((s,i)=>se.getInputFiltersForColumns(s,i.filter(({value:o,excludePanelIds:r})=>{const l=te.getIdFromPanel(this);return o!=null&&(r==null||l!=null&&!r.includes(l))}))),this.getAlwaysFetchColumns=he((s,i)=>{const o=te.getIdFromPanel(this),r=new Set(i);for(let l=0;l<s.length;l+=1){const{start:a}=s[l];a!=null&&a.panelId===o&&r.add(a.columnName)}return[...r]}),this.getPluginContent=he((s,i,o,r,l)=>!i||!ri(i)||s==null||i.table==null?null:h("div",{className:"iris-grid-plugin",children:h(s,{ref:this.pluginRef,filter:this.handlePluginFilter,onFilter:this.handlePluginFilter,fetchColumns:this.handlePluginFetchColumns,onFetchColumns:this.handlePluginFetchColumns,table:i.table,user:o,panel:this,workspace:r,components:OE,onStateChange:this.handlePluginStateChange,pluginState:l})})),this.getDehydratedIrisGridPanelState=he((s,i,o,r)=>se.dehydrateIrisGridPanelState(s,{isSelectingPartition:i,partition:o,partitionColumn:r})),this.getDehydratedIrisGridState=he((s,i,o,r,l,a,d,c,u,m,p,g,f,b,C,w,T,y,E,I)=>se.dehydrateIrisGridState(s,{advancedFilters:o,aggregationSettings:T,customColumnFormatMap:r,isFilterBarShown:l,metrics:{userColumnWidths:C,userRowHeights:w},quickFilters:a,customColumns:d,reverseType:c,rollupConfig:u,showSearchBar:m,searchValue:p,selectDistinctColumns:g,selectedSearchColumns:f,sorts:i,invertSearchColumns:b,pendingDataMap:y,frozenColumns:E,conditionalFormats:I})),this.getDehydratedGridState=he((s,i,o,r,l)=>se.dehydrateGridState(s,{isStuckToBottom:r,isStuckToRight:l,movedColumns:i,movedRows:o})),this.getCachedPanelState=he((s,i,o,r)=>({irisGridPanelState:s,irisGridState:i,gridState:o,pluginState:r})),this.savePanelState=Xe(()=>{const{irisGridState:s,gridState:i,pluginState:o}=this;A(s);const{onPanelStateUpdate:r}=this.props,{model:l,panelState:a,isSelectingPartition:d,partition:c,partitionColumn:u}=this.state,{advancedFilters:m,aggregationSettings:p,customColumnFormatMap:g,isFilterBarShown:f,quickFilters:b,customColumns:C,reverseType:w,rollupConfig:T,showSearchBar:y,searchValue:E,selectDistinctColumns:I,selectedSearchColumns:R,sorts:F,invertSearchColumns:x,metrics:U,pendingDataMap:$,frozenColumns:O,conditionalFormats:H}=s;A(U);const{userColumnWidths:L,userRowHeights:N}=U;A(i);const{isStuckToBottom:_,isStuckToRight:k,movedColumns:V,movedRows:W}=i,j=this.getCachedPanelState(this.getDehydratedIrisGridPanelState(l,d,c,u),this.getDehydratedIrisGridState(l,F,m,g,f,b,C,w,T,y,E,I,R,x,L,N,p,$,O,H),this.getDehydratedGridState(l,V,W,_,k),o);j!==a&&(Hn.debug("Saving panel state",this,j),this.setState({panelState:j}),r==null||r(j))},kE),this.handleAdvancedSettingsChange=this.handleAdvancedSettingsChange.bind(this),this.handleColumnsChanged=this.handleColumnsChanged.bind(this),this.handleTableChanged=this.handleTableChanged.bind(this),this.handleColumnSelected=this.handleColumnSelected.bind(this),this.handleDataSelected=this.handleDataSelected.bind(this),this.handleError=this.handleError.bind(this),this.handleGridStateChange=this.handleGridStateChange.bind(this),this.handlePluginStateChange=this.handlePluginStateChange.bind(this),this.handlePartitionAppend=this.handlePartitionAppend.bind(this),this.handleCreateChart=this.handleCreateChart.bind(this),this.handleResize=this.handleResize.bind(this),this.handleShow=this.handleShow.bind(this),this.handleTabClicked=this.handleTabClicked.bind(this),this.handleDisconnect=this.handleDisconnect.bind(this),this.handleReconnect=this.handleReconnect.bind(this),this.handleLoadSuccess=this.handleLoadSuccess.bind(this),this.handleLoadError=this.handleLoadError.bind(this),this.isColumnSelectionValid=this.isColumnSelectionValid.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.handlePluginFilter=this.handlePluginFilter.bind(this),this.handlePluginFetchColumns=this.handlePluginFetchColumns.bind(this),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.irisGrid=Y.createRef(),this.pluginRef=Y.createRef();const{panelState:n}=e;this.pluginState=null,this.state={error:null,isDisconnected:!1,isLoaded:!1,isLoading:!0,isModelReady:!1,model:void 0,advancedFilters:new Map,aggregationSettings:{aggregations:[],showOnTop:!1},advancedSettings:new Map(b0.DEFAULTS),customColumns:[],customColumnFormatMap:new Map,isFilterBarShown:!1,quickFilters:new Map,sorts:[],userColumnWidths:new Map,userRowHeights:new Map,reverseType:P.REVERSE_TYPE.NONE,movedColumns:[],movedRows:[],isSelectingPartition:!1,partition:void 0,partitionColumn:void 0,rollupConfig:void 0,showSearchBar:!1,searchValue:"",selectedSearchColumns:void 0,invertSearchColumns:!0,Plugin:void 0,pluginFilters:[],pluginFetchColumns:[],modelQueue:[],pendingDataMap:new Map,frozenColumns:void 0,panelState:n,irisGridStateOverrides:{},gridStateOverrides:{},isStuckToBottom:!1,isStuckToRight:!1,conditionalFormats:[],selectDistinctColumns:[]}}componentDidMount(){this.initModel()}componentDidUpdate(e,n){const{model:s}=this.state;s!==n.model&&(n.model!=null&&(this.stopModelListening(n.model),n.model.close()),s!=null&&this.startModelListening(s))}componentWillUnmount(){this.savePanelState.cancel(),this.modelPromise!=null&&(this.modelPromise.cancel(),this.modelPromise=void 0);const{model:e}=this.state;e&&(this.stopModelListening(e),e.close())}getTableName(){const{metadata:e}=this.props;return e.table}initModel(){this.setState({isModelReady:!1,isLoading:!0,error:null});const{makeModel:e}=this.props;this.modelPromise!=null&&this.modelPromise.cancel(),this.modelPromise=Ee.makeCancelable(e(),n=>n.close()),this.modelPromise.then(this.handleLoadSuccess).catch(this.handleLoadError)}handleLoadSuccess(e){const n=e,{panelState:s,irisGridStateOverrides:i}=this.state,o=[];if(s!=null){const{irisGridState:r}=s,{aggregationSettings:l,customColumns:a,selectDistinctColumns:d=[],rollupConfig:c}={...r,...i};a.length>0&&o.push(u=>{u.customColumns=a}),c!=null&&c.columns.length>0&&o.push(u=>{u.rollupConfig=se.getModelRollupConfig(u.originalColumns,c,l)}),d.length>0&&o.push(u=>{u.selectDistinctColumns=d})}this.setState({model:n,modelQueue:o}),this.initModelQueue(n,o)}initModelQueue(e,n){const s=e;if(n.length===0){this.modelInitialized(s);return}const i=n.shift();Hn.debug("initModelQueue",i),i&&i(s),this.setState({modelQueue:n})}handleAdvancedSettingsChange(e,n){Hn.debug("handleAdvancedSettingsChange",e,n),this.setState(({advancedSettings:s})=>s.get(e)===n?null:{advancedSettings:new Map(s).set(e,n)})}handlePluginFilter(e){const{model:n}=this.state;A(n);const{columns:s,formatter:i}=n,o=se.getFiltersFromInputFilters(s,e,i.timeZone);this.setState({pluginFilters:o})}handlePluginFetchColumns(e){this.setState({pluginFetchColumns:e})}handleContextMenu(e){var n,s,i;return(i=(s=(n=this.pluginRef.current)==null?void 0:n.getMenu)==null?void 0:s.call(n,e))!=null?i:[]}isColumnSelectionValid(e){const{columnSelectionValidator:n}=this.props;return n&&e?n(this,e):!1}handleGridStateChange(e,n){this.irisGridState=e,this.gridState=n,this.setState({isLoaded:!0,isLoading:!1}),this.savePanelState();const{glEventHub:s,onStateChange:i}=this.props;s.emit(wt.STATE_CHANGED,this),i==null||i(e,n)}handlePluginStateChange(e){const{irisGridState:n,gridState:s}=this;this.pluginState=e,n!==null&&s!==null&&this.savePanelState()}handleColumnsChanged(e){const{isModelReady:n,model:s,modelQueue:i}=this.state;n?this.sendColumnsChange(e.detail):(A(s),this.initModelQueue(s,i))}handleTableChanged(e){Hn.debug("handleTableChanged",e);const{glEventHub:n}=this.props,{detail:s}=e;n.emit(He.TABLE_CHANGED,this,s)}handlePartitionAppend(e,n){const{glEventHub:s}=this.props,{name:i}=e,o=this.getTableName(),r=`${o} = ${o}.where("${i}=\`${n}\`")`;s.emit(ft.SEND_COMMAND,r,!1,!0)}handleCreateChart(e,n){this.savePanelState.flush(),this.setState(()=>null,()=>{const{glEventHub:s,inputFilters:i,metadata:o}=this.props,{table:r}=o,{panelState:l}=this.state,a=te.getIdFromPanel(this);let d;l&&(d=se.extractTableSettings(l,i)),s.emit(wt.CREATE_CHART,{metadata:{settings:e,sourcePanelId:a,table:r,tableSettings:d},table:ri(n)?n.table:void 0})})}handleColumnSelected(e){const{glEventHub:n}=this.props;n.emit(wt.COLUMN_SELECTED,this,e)}handleDataSelected(e,n){const{glEventHub:s}=this.props;s.emit(wt.DATA_SELECTED,this,n)}handleResize(){this.updateGrid()}handleShow(){this.updateGrid()}handleTabClicked(){this.irisGrid.current&&this.irisGrid.current.focus()}handleError(e){Hn.error(e),this.setState({error:e,isLoading:!1})}handleDisconnect(){this.setState({error:new Error("Table disconnected"),isDisconnected:!0,isLoading:!1})}handleReconnect(){this.setState({isDisconnected:!1,error:null})}handleLoadError(e){Ee.isCanceled(e)||this.handleError(e)}modelInitialized(e){const{glEventHub:n,loadPlugin:s}=this.props;if(this.modelPromise=void 0,this.loadPanelState(e),this.setState({isModelReady:!0}),ri(e)){const{table:i}=e,{pluginName:o}=i;if(o!==""&&s!=null&&o!=null){const r=s(o);this.setState({Plugin:r})}n.emit(He.TABLE_CHANGED,this,i)}this.sendColumnsChange(e.columns)}handleClearAllFilters(){const e=this.irisGrid.current,{isDisconnected:n}=this.state;e!=null&&!n&&e.clearAllFilters()}sendColumnsChange(e){Hn.debug2("sendColumnsChange",e);const{glEventHub:n}=this.props;n.emit(He.COLUMNS_CHANGED,this,e)}startModelListening(e){e.addEventListener(be.EVENT.DISCONNECT,this.handleDisconnect),e.addEventListener(be.EVENT.RECONNECT,this.handleReconnect),e.addEventListener(be.EVENT.COLUMNS_CHANGED,this.handleColumnsChanged),e.addEventListener(be.EVENT.TABLE_CHANGED,this.handleTableChanged)}stopModelListening(e){e.removeEventListener(be.EVENT.DISCONNECT,this.handleDisconnect),e.removeEventListener(be.EVENT.RECONNECT,this.handleReconnect),e.removeEventListener(be.EVENT.COLUMNS_CHANGED,this.handleColumnsChanged),e.removeEventListener(be.EVENT.TABLE_CHANGED,this.handleTableChanged)}getCoordinateForColumn(e){var w,T,y;const{model:n}=this.state;if(!n)return null;const s=this.irisGrid.current,{gridWrapper:i}=s||{},o=(w=i==null?void 0:i.getBoundingClientRect())!=null?w:null;if(o==null||o.width<=0||o.height<=0)return null;A(s);const{metrics:r}=s.state;A(r);const{columnHeaderHeight:l,visibleColumnXs:a,visibleColumnWidths:d,right:c,columnHeaderMaxDepth:u}=r,m=n.getColumnIndexByName(e);A(m);const p=s.getVisibleColumn(m),g=(T=a.get(p))!=null?T:0,f=(y=d.get(p))!=null?y:0,b=Math.max(o.left,Math.min(p>c?o.right:o.left+g+f*.5,o.right)),C=o.top+l*u;return[b,C]}setFilterMap(e){const n=this.irisGrid.current;n!=null&&n.setFilterMap(e)}setAdvancedFilterMap(e){const n=this.irisGrid.current;n!=null&&n.setAdvancedFilterMap(e)}setFilters({quickFilters:e,advancedFilters:n}){Hn.debug("setFilters",e,n);const{model:s,isDisconnected:i}=this.state,o=this.irisGrid.current;if(o==null||i){Hn.debug("Ignore setFilters, model disconnected");return}A(s);const{columns:r,formatter:l}=s,a=se.changeFilterColumnNamesToIndexes(s.columns,e).filter(([c])=>s.isFilterable(c)),d=se.changeFilterColumnNamesToIndexes(s.columns,n).filter(([c])=>s.isFilterable(c));o.clearAllFilters(),o.setFilters({quickFilters:se.hydrateQuickFilters(r,a,l.timeZone),advancedFilters:se.hydrateAdvancedFilters(r,d,l.timeZone)})}setStateOverrides(e){Hn.debug("setStateOverrides",e);const{irisGridState:n,gridState:s}=e;this.setState({irisGridStateOverrides:n,gridStateOverrides:s},()=>{this.initModel()})}unsetFilterValue(){}loadPanelState(e){const{panelState:n,irisGridStateOverrides:s,gridStateOverrides:i}=this.state;if(n!=null)try{const{gridState:o,irisGridState:r,irisGridPanelState:l}=n,a={...s},{quickFilters:d,advancedFilters:c}=a;d&&(a.quickFilters=se.changeFilterColumnNamesToIndexes(e.columns,d)),c&&(a.advancedFilters=se.changeFilterColumnNamesToIndexes(e.columns,c));const{isSelectingPartition:u,partition:m,partitionColumn:p}=se.hydrateIrisGridPanelState(e,l),{advancedFilters:g,customColumns:f,customColumnFormatMap:b,isFilterBarShown:C,quickFilters:w,reverseType:T,rollupConfig:y,aggregationSettings:E,sorts:I,userColumnWidths:R,userRowHeights:F,showSearchBar:x,searchValue:U,selectDistinctColumns:$,selectedSearchColumns:O,invertSearchColumns:H,pendingDataMap:L,frozenColumns:N,conditionalFormats:_}=se.hydrateIrisGridState(e,{...r,...a}),{isStuckToBottom:k,isStuckToRight:V,movedColumns:W,movedRows:j}=se.hydrateGridState(e,{...o,...i},r.customColumns);this.setState({advancedFilters:g,conditionalFormats:_,customColumns:f,customColumnFormatMap:b,isFilterBarShown:C,isSelectingPartition:u,movedColumns:W,movedRows:j,partition:m,partitionColumn:p,quickFilters:w,reverseType:T,rollupConfig:y,aggregationSettings:E,sorts:I,userColumnWidths:R,userRowHeights:F,showSearchBar:x,searchValue:U,selectDistinctColumns:$,selectedSearchColumns:O,invertSearchColumns:H,pendingDataMap:L,frozenColumns:N,isStuckToBottom:k,isStuckToRight:V})}catch(o){Hn.error("loadPanelState failed to load panelState",n,o)}}updateGrid(){var n,s;const e=(s=(n=this.irisGrid.current)==null?void 0:n.grid)!=null?s:null;!e||e.handleResize()}render(){var On,Ht;const{children:e,glContainer:n,glEventHub:s,columnSelectionValidator:i,getDownloadWorker:o,inputFilters:r,links:l,metadata:a,panelState:d,user:c,workspace:u,settings:m,theme:p}=this.props,{advancedFilters:g,aggregationSettings:f,advancedSettings:b,conditionalFormats:C,customColumns:w,customColumnFormatMap:T,error:y,isDisconnected:E,isFilterBarShown:I,isSelectingPartition:R,isStuckToBottom:F,isStuckToRight:x,isLoaded:U,isLoading:$,isModelReady:O,model:H,movedColumns:L,movedRows:N,partition:_,partitionColumn:k,quickFilters:V,reverseType:W,rollupConfig:j,sorts:ee,userColumnWidths:ve,userRowHeights:le,showSearchBar:Se,searchValue:Le,selectDistinctColumns:J,selectedSearchColumns:pe,invertSearchColumns:fe,Plugin:xe,pluginFilters:ke,pluginFetchColumns:hn,pendingDataMap:Xn,frozenColumns:Sn}=this.state,Ct=y!=null?`Unable to open table. ${y}`:void 0,{table:Re}=a,st=(On=H==null?void 0:H.description)!=null?On:void 0,it=(Ht=d==null?void 0:d.pluginState)!=null?Ht:null,Mt=e!=null?e:this.getPluginContent(xe,H,c,u,it),{permissions:Yt}=c,{canCopy:Xt,canDownloadCsv:Nt}=Yt;return v(Pl,{errorMessage:Ct,isDisconnected:E,isLoading:$,isLoaded:U,className:"iris-grid-panel",glContainer:n,glEventHub:s,onClearAllFilters:this.handleClearAllFilters,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleShow,onTabClicked:this.handleTabClicked,widgetName:Re,widgetType:"Table",description:st,componentPanel:this,renderTabTooltip:()=>h(ic,{model:H,widgetName:Re,glContainer:n,description:st}),children:[O&&H&&h(no,{advancedFilters:g,aggregationSettings:f,advancedSettings:b,alwaysFetchColumns:this.getAlwaysFetchColumns(l,hn),columnAllowedCursor:"linker",columnNotAllowedCursor:"not-allowed",customColumns:w,customColumnFormatMap:T,columnSelectionValidator:this.isColumnSelectionValid,conditionalFormats:C,inputFilters:this.getGridInputFilters(H.columns,r),applyInputFiltersOnInit:d==null,isFilterBarShown:I,isSelectingColumn:i!=null,isSelectingPartition:R,isStuckToBottom:F,isStuckToRight:x,movedColumns:L,movedRows:N,partition:_,partitionColumn:k,quickFilters:V,reverseType:W,rollupConfig:j,settings:m,sorts:ee,userColumnWidths:ve,userRowHeights:le,model:H,showSearchBar:Se,searchValue:Le,selectedSearchColumns:pe,selectDistinctColumns:J,invertSearchColumns:fe,onColumnSelected:this.handleColumnSelected,onCreateChart:this.handleCreateChart,onDataSelected:this.handleDataSelected,onError:this.handleError,onPartitionAppend:this.handlePartitionAppend,onStateChange:this.handleGridStateChange,onContextMenu:this.handleContextMenu,onAdvancedSettingsChange:this.handleAdvancedSettingsChange,customFilters:ke,pendingDataMap:Xn,canCopy:Xt,canDownloadCsv:Nt,ref:this.irisGrid,getDownloadWorker:o,frozenColumns:Sn,theme:p,children:Mt}),!O&&h(ue,{})]})}}qi.defaultProps={onStateChange:()=>{},onPanelStateUpdate:()=>{}};qi.displayName="IrisGridPanel";qi.COMPONENT="IrisGridPanel";const LE=(t,{localDashboardId:e=Rn})=>({inputFilters:qd(t,e),links:so(t,e),columnSelectionValidator:jd(t,e),user:cm(t),workspace:yl(t),settings:Kt(t)}),hi=Dt(LE,null,null,{forwardRef:!0})(qi);const Lh=X.module("InputFilter"),AE=150,Ga=class extends S.exports.Component{constructor(t){super(t),this.getItemLabel=Te((i,o)=>{const{name:r,type:l}=i[o];if(o>0&&i[o-1].name===r||o<i.length-1&&i[o+1].name===r){const a=l.substring(l.lastIndexOf(".")+1);return`${r} (${a})`}return r}),this.sendUpdate=Xe(()=>{const{onChange:i}=this.props,{column:o,value:r,isValueShown:l}=this.state;i({column:o,isValueShown:l,value:r})},AE),this.handleColumnChange=this.handleColumnChange.bind(this),this.handleInputKeyPress=this.handleInputKeyPress.bind(this),this.handleValueChange=this.handleValueChange.bind(this),this.handleSettingsCancel=this.handleSettingsCancel.bind(this),this.handleSettingsClick=this.handleSettingsClick.bind(this),this.handleSettingsSave=this.handleSettingsSave.bind(this),this.handleBackgroundClick=this.handleBackgroundClick.bind(this),this.inputRef=Y.createRef();const{column:e,isValueShown:n,value:s}=t;this.state={column:e,selectedColumn:e,value:s,isValueShown:n}}componentDidUpdate(t,e){const{column:n}=this.props,{column:s,value:i,isValueShown:o}=this.state;n!==t.column&&this.setState({column:n,selectedColumn:n}),o!==void 0&&o&&o!==e.isValueShown&&this.focusInput(),(s!==e.column||i!==e.value||o!==e.isValueShown)&&this.sendUpdate()}componentWillUnmount(){this.sendUpdate.flush()}handleColumnChange(t){const{columns:e}=this.props,{value:n}=t.target,s=e[parseInt(n,10)];Lh.debug2("handleColumnChange",s),this.setState({selectedColumn:s,value:void 0})}handleInputKeyPress(t){t.key==="Enter"&&(t.preventDefault(),t.stopPropagation(),this.setState(({value:e})=>e==null?{value:""}:null,()=>{this.sendUpdate(),this.sendUpdate.flush()}))}handleValueChange(t){const{value:e}=t.target;Lh.debug2("handleValueChange",e),this.setState({value:e})}handleSettingsCancel(){const{column:t}=this.state;this.setState({selectedColumn:t,isValueShown:!0})}handleSettingsSave(){const{selectedColumn:t}=this.state;this.setState({column:t,isValueShown:!0})}handleSettingsClick(t){const{column:e}=this.state;this.setState({selectedColumn:e,isValueShown:!1}),t.stopPropagation()}handleBackgroundClick(t){t.target!==this.inputRef.current&&this.focusInput()}focusInput(){this.inputRef.current!==null&&(this.inputRef.current.select(),this.inputRef.current.focus())}clearFilter(){this.setState({value:""})}setFilterState({name:t,type:e,value:n,isValueShown:s}){const i=t!=null&&e!=null?{name:t,type:e}:void 0,o=s===void 0?{column:i,value:n}:{column:i,value:n,isValueShown:s};this.setState(o)}render(){const{columns:t}=this.props,{column:e,isValueShown:n,selectedColumn:s,value:i}=this.state,o=i==null||i.length===0?Ga.PLACEHOLDER.length:i.length;let r=null;if(e!=null){const l=t.findIndex(a=>a.name===e.name&&a.type===e.type);r=l>=0?this.getItemLabel(t,l):e.name}return v(id,{className:"input-filter fill-parent-absolute",isFlipped:n!=null?n:!1,children:[h("div",{className:"input-filter-settings-card",children:v("div",{className:"input-filter-settings-content",children:[v("div",{className:"input-filter-settings-grid",children:[h("label",{children:"Filter Column"}),v("select",{value:t.findIndex(l=>l.name===(s==null?void 0:s.name)&&l.type===(s==null?void 0:s.type)),className:"custom-select",onChange:this.handleColumnChange,children:[t.map((l,a)=>h("option",{value:a,children:this.getItemLabel(t,a)},`${l.name}/${l.type}`)),t.length===0&&h("option",{value:"-1",disabled:!0,children:"No Available Columns"})]}),h("div",{className:"text-muted small",children:"Input filter control will apply its filter to all columns matching this name in this dashboard."})]}),v("div",{className:"input-filter-settings-buttons",children:[h(Q,{kind:"secondary",onClick:this.handleSettingsCancel,disabled:e==null,children:"Cancel"}),h(Q,{kind:"primary",className:"ml-2",onClick:this.handleSettingsSave,disabled:s==null,children:"Save"})]})]})}),v("div",{className:"input-filter-value-card",onClick:this.handleBackgroundClick,children:[h("div",{className:"input-filter-column",children:v("div",{className:"input-filter-column-title",children:[r," Filter"]})}),h("div",{className:"d-flex justify-content-center align-items-center h-100 w-100",children:h("div",{className:"input-filter-value-input d-flex flex-column justify-content-center",children:h("input",{type:"text",ref:this.inputRef,placeholder:Ga.PLACEHOLDER,value:i!=null?i:"",onChange:this.handleValueChange,onKeyPress:this.handleInputKeyPress,style:{width:`${o+3}ch`},spellCheck:"false"})})}),h("div",{className:"input-filter-menu",children:h(Q,{kind:"ghost",className:"m-2 px-2",onClick:this.handleSettingsClick,icon:h(K,{icon:zo,transform:"grow-4"}),tooltip:"Input Filter Settings"})})]})]})}};let oc=Ga;oc.PLACEHOLDER="Enter value...";oc.defaultProps={column:null,isValueShown:!1,value:null};const PE=250;class Bl extends S.exports.Component{constructor(e){super(e),this.handleChange=Xe(this.handleChange.bind(this),PE),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.inputFilterRef=Y.createRef();const{panelState:n}=e,{value:s,isValueShown:i=!1,name:o,type:r,timestamp:l}=n!=null?n:{};this.state={columns:[],column:o!=null&&r!=null?{name:o,type:r}:void 0,value:s,timestamp:l,isValueShown:i,wasFlipped:!1,skipUpdate:!1,panelState:n}}componentDidMount(){this.updateColumns();const{column:e,value:n,timestamp:s}=this.state;if(e!=null){const{name:i,type:o}=e;this.sendUpdate(i,o,n,s)}}componentDidUpdate(e){const{columns:n}=this.props;n!==e.columns&&this.updateColumns()}handleChange({column:e,isValueShown:n,value:s}){let i,o;e!=null&&({name:i,type:o}=e);let r=!0,l=Date.now();this.setState(({panelState:a,timestamp:d,wasFlipped:c,skipUpdate:u})=>{var p;const m=a!=null&&n!==a.isValueShown&&i===a.name&&o===a.type&&s===a.value;return r=(p=!u&&n&&(!m||!c))!=null?p:!1,r||(l=d),{panelState:{isValueShown:n,name:i,type:o,value:s,timestamp:l},timestamp:l,wasFlipped:m,skipUpdate:!1}},()=>{r&&this.sendUpdate(i,o,s,l)})}handleClearAllFilters(){var e;(e=this.inputFilterRef.current)==null||e.clearFilter()}sendUpdate(e,n,s,i){const{glEventHub:o}=this.props;o.emit(He.FILTERS_CHANGED,this,{name:e,type:n,value:s,timestamp:i})}setPanelState(e,n=!1){var s;this.setState({skipUpdate:!n}),(s=this.inputFilterRef.current)==null||s.setFilterState(e)}updateColumns(){const{columns:e}=this.props;e!=null&&this.setState(n=>{const{column:s}=n;return s==null&&e.length>0?{columns:[...e],column:e[0]}:s!=null&&!e.find(({name:i,type:o})=>s.name===i&&s.type===o)?{columns:[...e,s]}:{columns:[...e]}})}render(){const{glContainer:e,glEventHub:n}=this.props,{column:s,columns:i,isValueShown:o,value:r}=this.state;return h(Yn,{className:"iris-input-filter-panel",componentPanel:this,glContainer:e,glEventHub:n,onClearAllFilters:this.handleClearAllFilters,isClonable:!0,isRenamable:!0,children:h(oc,{ref:this.inputFilterRef,column:s,columns:i,onChange:this.handleChange,isValueShown:o,value:r})})}}Bl.defaultProps={panelState:null};Bl.COMPONENT="InputFilterPanel";Bl.displayName="InputFilterPanel";const HE=(t,e)=>{const{localDashboardId:n}=e;return{columns:Ep(t,n)}},xo=Dt(HE,null,null,{forwardRef:!0})(Bl);const It=X.module("FilterSetManagerPanel");function VE(t){return t.setPanelState!=null}const Ka=class extends S.exports.Component{static changeFilterIndexesToColumnNames(t,e){return e.map(([n,s])=>{if(n>=t.columns.length)return null;const{name:i}=t.columns[n];return{name:i,filter:s}}).filter(n=>n!=null)}constructor(t){super(t),this.handleChange=this.handleChange.bind(this),this.handleFilterApply=this.handleFilterApply.bind(this),this.handleSetsUpdate=this.handleSetsUpdate.bind(this),this.handleGetFilterState=this.handleGetFilterState.bind(this);const{panelState:e,filterSets:n}=t,{selectedId:s=n.length>0?n[0].id:void 0,isValueShown:i=!1}=e!=null?e:{};this.state={selectedId:s,isValueShown:i,panelState:e}}getFilterState(){const{dashboardOpenedPanelMap:t}=this.props,e=[];return[...t.keys()].forEach(n=>{const s=t.get(n);if(s===void 0){It.error("Could not get panel",s);return}const i=te.getComponentNameFromPanel(s),o=te.getIdFromPanel(s);It.debug("Panel:",s,i);const{glContainer:r=null}=s.props;if(r==null){It.error("Could not get panel container",s);return}const l=te.getComponentConfigFromContainer(r);if(l==null){It.error("Could not get component config from container",r);return}const a=te.getPanelComponentState(l);if(a==null){It.debug(`Panel state is null ${o}`);return}switch(i){case te.getComponentName(qi):{let d;o!=null&&(d=this.getIrisGridPanelFilters(o,a)),d!=null&&e.push({panelId:o,type:i,state:d});break}case te.getComponentName(xo):case te.getComponentName(ci):{const{isValueShown:d,name:c,type:u,value:m}=a;e.push({panelId:o,type:i,state:{isValueShown:d,name:c,type:u,value:m}});break}}}),e}getIrisGridPanelFilters(t,e){const{panelTableMap:n}=this.props,s=n.get(t);if(s==null)return It.error(`Unable to get table for panel ${t}.`),null;const{irisGridState:i={advancedFilters:void 0,quickFilters:void 0},gridState:o={}}=e,{advancedFilters:r,quickFilters:l}=i;let a;r&&(a=Ka.changeFilterIndexesToColumnNames(s,r));let d;return l&&(d=Ka.changeFilterIndexesToColumnNames(s,l)),{irisGridState:{...i,advancedFilters:a,quickFilters:d},gridState:{...o}}}handleGetFilterState(){return this.getFilterState()}handleChange({isValueShown:t,selectedId:e}){It.debug("handleChange",t,e),this.setState({isValueShown:t,selectedId:e}),this.updatePanelState()}handleFilterApply(t){const{dashboardOpenedPanelMap:e}=this.props,{panels:n,restoreFullState:s=!1}=t;It.debug("Apply filters from filter set",t),n.forEach(({panelId:i,type:o,state:r})=>{if(i==null){It.debug("panel is null",i);return}if(!e.has(i)){It.debug("Ignore closed panel",i);return}It.debug("Apply panel filters",i,o,r);const l=e.get(i);switch(o){case te.getComponentName(qi):this.restoreIrisGridFilters(l,r,s);break;case te.getComponentName(xo):case te.getComponentName(ci):this.restoreInputFilterState(l,r);break}})}handleSetsUpdate(t){const{setDashboardFilterSets:e,localDashboardId:n}=this.props;It.debug("Saving updated sets",t),e(n,[...t])}updatePanelState(){this.setState(({selectedId:t,isValueShown:e})=>({panelState:{selectedId:t,isValueShown:e}}))}restoreIrisGridFilters(t,e,n){const{irisGridState:s={},advancedFilters:i=[],quickFilters:o=[]}=e,{advancedFilters:r=i,quickFilters:l=o}=s,{panelTableMap:a}=this.props,d=te.getIdFromPanel(t);if(d==null){It.error("Panel Id is null.");return}if(a.get(d)==null){It.error(`Unable to get table for panel ${d}.`);return}It.debug("restoreIrisGridFilters",d,e,n),n?t.setStateOverrides(e):t.setFilters({quickFilters:l,advancedFilters:r})}restoreInputFilterState(t,e){const n={...e};delete n.isValueShown,It.debug("restoreInputFilterState",t,n),t&&VE(t)&&t.setPanelState(n)}render(){const{glContainer:t,glEventHub:e,filterSets:n}=this.props,{isValueShown:s,selectedId:i}=this.state;return h(Yn,{className:"filter-set-manager-panel",componentPanel:this,glContainer:t,glEventHub:e,isClonable:!0,isRenamable:!0,children:h("div",{className:"input-filter-container h-100 w-100 container",children:h(il,{onChange:this.handleChange,onApply:this.handleFilterApply,onUpdateSets:this.handleSetsUpdate,isValueShown:s,filterSets:n,selectedId:i,getFilterState:this.handleGetFilterState})})})}};let rc=Ka;rc.defaultProps={panelState:null};rc.COMPONENT="FilterSetManagerPanel";const UE=(t,e)=>{const{localDashboardId:n}=e;return{filterSets:sE(t,n),dashboardOpenedPanelMap:Wm(t,n),dashboardInputFilters:qd(t,n),panelTableMap:Yd(t,n)}},Ca=Dt(UE,{setDashboardFilterSets:hE},null,{forwardRef:!0})(rc);const Ah=X.module("LogPanel");class $l extends S.exports.PureComponent{constructor(e){super(e),this.handleResize=this.handleResize.bind(this),this.handleShow=this.handleShow.bind(this),this.handleHide=this.handleHide.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.isBottomVisible=!0,this.logView=null;const{session:n}=this.props;this.state={session:n}}handleResize(){this.updateDimensions()}handleShow(){this.updateDimensions(),this.logView&&(this.logView.triggerFindWidget(),this.isBottomVisible&&this.logView.scrollToBottom())}handleHide(){this.logView&&(this.isBottomVisible=this.logView.isBottomVisible())}handleSessionOpened(e){Ah.debug("Session opened",[e]),this.setState({session:e})}handleSessionClosed(e){Ah.debug("Session closed",e)}updateDimensions(){this.logView&&this.logView.updateDimensions()}render(){const{glContainer:e,glEventHub:n}=this.props,{session:s}=this.state;return v(Yn,{componentPanel:this,glContainer:e,glEventHub:n,onResize:this.handleResize,onHide:this.handleHide,onShow:this.handleShow,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,children:[s==null&&h("div",{className:"log-panel-disconnected-message",children:"Waiting for session connection"}),s!=null&&h(Qi,{session:s,ref:i=>{this.logView=i}})]})}}$l.defaultProps={session:null};$l.COMPONENT="LogPanel";$l.TITLE="Log";const BE=(t,e)=>{var n;return{session:(n=gi(t,e.localDashboardId))==null?void 0:n.session}},ol=Dt(BE,null,null,{forwardRef:!0})($l);class Np extends S.exports.PureComponent{render(){const{isEditing:e,children:n,onDoubleClick:s}=this.props;return v("div",{className:"markdown-editor-container h-100 w-100",onDoubleClick:s,children:[h("div",{className:z("text-muted","edit-hint",{viewing:e===void 0||!e}),children:v("span",{children:["double-click to edit ",h(K,{icon:hl})]})}),n]})}}Np.defaultProps={isEditing:!1};const $E=X.module("MarkdownStartPage");class Fp extends S.exports.PureComponent{constructor(e){super(e),this.handleDeleteButtonClick=this.handleDeleteButtonClick.bind(this),this.handleDeleteModalClose=this.handleDeleteModalClose.bind(this),this.state={isDeleteModalShown:!1}}handleDeleteButtonClick(e){this.setState({isDeleteModalShown:!0,toBeDeleted:e})}handleDeleteModalClose(){this.setState({isDeleteModalShown:!1,toBeDeleted:void 0})}handleDeleteMarkdown(e){if($E.debug("delete markdown: ",e),e!==void 0){const{onDelete:n}=this.props;n(e)}this.setState({isDeleteModalShown:!1,toBeDeleted:void 0})}render(){const{closedMarkdowns:e,onOpen:n,onCreate:s}=this.props,{isDeleteModalShown:i,toBeDeleted:o}=this.state;return h("div",{className:"markdown-panel-start-page h-100 w-100",children:v("div",{className:"markdown-panel-start-page-container",children:[v("div",{className:"markdown-panel-start-list",children:[h("h3",{className:"list-title",children:"Start"}),h("div",{className:"list-item",children:h(Q,{kind:"ghost",className:"title",onClick:s,children:"New Markdown Note"})})]}),v("div",{className:"markdown-panel-start-list",children:[h("h3",{className:"list-title",children:"Recently Closed from Dashboard"}),e.map(r=>v("div",{className:"list-item",children:[h(Q,{kind:"ghost",className:"title",onClick:()=>n(r),children:r.title}),h("button",{className:"btn-link icon",type:"button",onClick:()=>{this.handleDeleteButtonClick(r)},children:h(K,{icon:_n})})]},r.id)),v(Uo,{isOpen:i,toggle:this.handleDeleteModalClose,className:"modal-dialog-centered markdown-delete-modal theme-bg-light",children:[h($o,{children:"Are you sure you want to permanently delete this note?"}),h(Bo,{children:"You can't undo this action."}),v(sd,{children:[h(Q,{kind:"secondary",onClick:this.handleDeleteModalClose,children:"Cancel"}),h(Q,{kind:"danger",onClick:()=>{this.handleDeleteMarkdown(o)},children:"Delete"})]})]})]})]})})}}Fp.defaultProps={closedMarkdowns:[],onOpen:()=>{},onCreate:()=>{},onDelete:()=>{}};class xp extends S.exports.PureComponent{constructor(e){super(e),this.renderMarkdown=n=>{const{children:s,className:i}=n,o=i!==void 0&&(i==null?void 0:i.startsWith("language-"))?i.substring(9):"plaintext";return h("pre",{children:h("code",{children:h(vl,{language:o,children:Y.Children.map(s,r=>typeof r=="string"?r.trim():r)})})})},this.container=null}render(){const{isEditing:e,content:n,onEditorInitialized:s}=this.props;return h("div",{className:"markdown-editor-container",ref:i=>{this.container=i},children:e?h(Tl,{settings:{language:"markdown",value:n,lineNumbers:"off"},onEditorInitialized:s}):h(nu,{components:{code:this.renderMarkdown},children:n})})}}xp.defaultProps={isEditing:!1,content:""};const Nr=X.module("MarkdownPanel");class lc extends S.exports.Component{constructor(e){super(e),this.getClosedMarkdowns=he(i=>i.filter(o=>o.component==="MarkdownPanel").reverse()),this.handleContainerDoubleClick=this.handleContainerDoubleClick.bind(this),this.handleCreateMarkdown=this.handleCreateMarkdown.bind(this),this.handleDeleteMarkdown=this.handleDeleteMarkdown.bind(this),this.handleOpenMarkdown=this.handleOpenMarkdown.bind(this),this.handleEditorInitialized=this.handleEditorInitialized.bind(this),this.handleEditorBlur=this.handleEditorBlur.bind(this),this.handleEditorResize=this.handleEditorResize.bind(this);const{panelState:n}=e;let s=null;n!=null&&n.content!=null&&({content:s}=n),this.state={isStartPageShown:s==null,isEditing:!1,content:s,panelState:n},this.markdownEditor=null}setEditorPosition(e){var s,i;A(this.markdownEditor);const{container:n}=this.markdownEditor;if(this.editor&&n){const o=n.getBoundingClientRect().top,r=n.scrollTop,l=n.scrollHeight,a=(i=(s=this.editor.getModel())==null?void 0:s.getLineCount())!=null?i:0;let d=Math.round((r+e-o)/l*a);d>a&&(d=a),this.editor.revealLine(d),this.editor.setPosition({lineNumber:d,column:1}),this.editor.focus()}}handleContainerDoubleClick(e){const{isEditing:n}=this.state,s=e.clientY;n||this.setState({isEditing:!0},()=>{this.setEditorPosition(s)})}handleEditorInitialized(e){Nr.debug("Markdown Editor Initialized..."),this.editor=e}handleCreateMarkdown(){Nr.debug("create markdown..."),this.setState({isStartPageShown:!1,content:"",isEditing:!0,panelState:{content:""}},()=>{this.editor!=null&&this.editor.focus!=null&&this.editor.focus()})}handleOpenMarkdown(e){Nr.debug("open markdown...",e);const{glContainer:n,glEventHub:s}=this.props,i=te.getComponentConfigFromContainer(n);s.emit(Me.REOPEN,e,i)}handleDeleteMarkdown(e){const{glEventHub:n}=this.props;n.emit(Me.DELETE,e)}handleEditorBlur(e){var i;Nr.debug("markdown content changed, saving...");const{isEditing:n}=this.state;if(!n||this.markdownEditor!=null&&this.markdownEditor.container!=null&&this.markdownEditor.container.contains(e.relatedTarget))return;const s=(i=this.editor)==null?void 0:i.getValue();this.setState({content:s,isEditing:!1,panelState:{content:s}})}handleEditorResize(){const{isEditing:e}=this.state;e&&this.editor&&this.editor.layout()}render(){const{glContainer:e,glEventHub:n,closedPanels:s}=this.props,{isEditing:i,isStartPageShown:o,content:r}=this.state,l=this.getClosedMarkdowns(s);return h(Yn,{glContainer:e,glEventHub:n,className:"markdown-panel",componentPanel:this,onResize:this.handleEditorResize,onBlur:this.handleEditorBlur,isClonable:!0,isRenamable:!0,children:o?h(Fp,{closedMarkdowns:l,onCreate:this.handleCreateMarkdown,onOpen:this.handleOpenMarkdown,onDelete:this.handleDeleteMarkdown}):h(Np,{isEditing:i,onDoubleClick:this.handleContainerDoubleClick,children:h(xp,{ref:a=>{this.markdownEditor=a},isEditing:i,content:r!=null?r:void 0,onEditorInitialized:this.handleEditorInitialized})})})}}lc.defaultProps={panelState:null};lc.COMPONENT="MarkdownPanel";const zE=(t,e)=>{const{localDashboardId:n}=e;return{closedPanels:h0(t,n)}},bo=Dt(zE,null,null,{forwardRef:!0})(lc);class _p extends S.exports.PureComponent{constructor(e){super(e),this.handleRunSelected=this.handleRunSelected.bind(this),this.renderCodeBlock=this.renderCodeBlock.bind(this),this.renderLink=this.renderLink.bind(this),this.commands=new Map,this.codeElements=new Map,this.editorScrollView=Y.createRef(),this.state={hasCode:!1,hasRunCode:!1,nextStartLine:null}}componentDidMount(){this.updateHasCode()}componentDidUpdate(){this.updateHasCode()}updateHasCode(){const{hasCode:e}=this.state;this.commands.size===0&&e?this.setState({hasCode:!1}):this.commands.size>0&&!e&&this.setState({hasCode:!0})}getNextStartLine(e){const n=[...this.commands.keys()],s=n.findIndex(i=>i===e)+1;return s>=n.length?null:n[s]}handleRunSelected(e){var c,u,m;e.preventDefault(),e.stopPropagation();const{nextStartLine:n}=this.state,s=[...this.commands.keys()],i=s.findIndex(p=>p===n||n==null);if(i<0)return;const o=s[i],r=this.commands.get(o),l=this.getNextStartLine(o),a=(c=this.codeElements.get(o))==null?void 0:c.current,d=(u=a==null?void 0:a.parentElement)==null?void 0:u.nextElementSibling;if(d!=null){const{offsetTop:p}=d,g=p;(m=this.editorScrollView.current)==null||m.scroll({top:g,left:0})}this.runCode(r),this.setState({nextStartLine:l})}runCode(e){const{onRunCode:n}=this.props;n(e),this.setState({hasRunCode:!0})}renderCodeBlock(e){const{children:n,className:s,inline:i,node:o}=e,{hasRunCode:r,nextStartLine:l}=this.state,{children:a,position:d}=o;A(d);const{start:c}=d,{line:u}=c,m=a[0].value,p=Y.createRef(),g=this.commands.size===0,f=l===u||g&&l==null&&!r,b=s!==void 0&&s.startsWith("language-")?s.substring(9):"plaintext";return i!=null&&i?h("code",{className:s,children:n}):(this.commands.set(u,m),this.codeElements.set(u,p),v("div",{className:z("markdown-notebook-code-block",{"is-selected":f}),ref:p,onClick:()=>{this.setState({nextStartLine:u})},role:"presentation",children:[h(Q,{kind:"ghost",icon:Gr,className:"btn-play-block",onClick:C=>{C.stopPropagation(),C.preventDefault(),this.runCode(m),this.setState({nextStartLine:u})},tooltip:"Run code"}),h("code",{children:h(vl,{language:b,children:Y.Children.map(n,C=>typeof C=="string"?C.trim():C)})})]}))}renderLink(e){const{onLinkClick:n}=this.props,{href:s,children:i,target:o}=e;return h("a",{href:s,onClick:n,target:o,children:i})}render(){const{content:e,transformImageUri:n,transformLinkUri:s}=this.props,{hasCode:i,hasRunCode:o,nextStartLine:r}=this.state;return v("div",{className:"markdown-notebook",children:[h("div",{className:"markdown-notebook-toolbar",children:h(Q,{className:z("btn-play-selected-cell",{flashing:i&&!o}),kind:"ghost",icon:Gr,onClick:this.handleRunSelected,tooltip:"Run code and select next",disabled:o&&r==null||!i,children:"Run Selected Code"})}),h("div",{className:"markdown-notebook-content",ref:this.editorScrollView,children:h(nu,{components:{code:this.renderCodeBlock,a:this.renderLink},linkTarget:"_blank",remarkPlugins:[dg],transformLinkUri:s,transformImageUri:n,includeElementIndex:!0,children:e})})]})}}_p.defaultProps={onRunCode:()=>{}};const $e=X.module("NotebookPanel"),Ph=400,Fi=class extends S.exports.Component{constructor(t){super(t),this.getOverflowActions=he(()=>[{title:"Find",icon:Gf,action:this.handleFind,group:oe.groups.high,shortcut:Nn.NOTEBOOK.FIND,order:10}]),this.handleBlur=this.handleBlur.bind(this),this.handleCloseCancel=this.handleCloseCancel.bind(this),this.handleCloseDiscard=this.handleCloseDiscard.bind(this),this.handleCloseSave=this.handleCloseSave.bind(this),this.handleCopy=this.handleCopy.bind(this),this.handleEditorChange=this.handleEditorChange.bind(this),this.handleFind=this.handleFind.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleLinkClick=this.handleLinkClick.bind(this),this.handleLoadSuccess=this.handleLoadSuccess.bind(this),this.handleLoadError=this.handleLoadError.bind(this),this.handlePanelTabClick=this.handlePanelTabClick.bind(this),this.handleRenameFile=this.handleRenameFile.bind(this),this.handleResize=this.handleResize.bind(this),this.handleRunCommand=this.handleRunCommand.bind(this),this.handleRunAll=this.handleRunAll.bind(this),this.handleRunSelected=this.handleRunSelected.bind(this),this.handleSave=this.handleSave.bind(this),this.handleSaveAsCancel=this.handleSaveAsCancel.bind(this),this.handleSaveAsSubmit=this.handleSaveAsSubmit.bind(this),this.handleSaveError=this.handleSaveError.bind(this),this.handleSaveSuccess=this.handleSaveSuccess.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleShowRename=this.handleShowRename.bind(this),this.handleTab=this.handleTab.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTransformLinkUri=this.handleTransformLinkUri.bind(this),this.pending=new ps,this.debouncedSavePanelState=Xe(this.savePanelState.bind(this),Ph),this.debouncedLoad=Xe(this.load.bind(this),Ph),this.notebook=null,this.tabTitleElement=null,this.tabInitOnce=!1,this.shouldPromptClose=!0;const{isDashboardActive:e,session:n,sessionLanguage:s,panelState:i}=t;let o={value:"",language:""},r=null,{isPreview:l}=t;i!=null&&({fileMetadata:r=r,isPreview:l=l,settings:o=o}=i);const a=r!=null&&de.hasPath(r.itemName),c=a===!0&&o.value!=null||!a&&o.value!=null&&o.value.length>0?1:0;this.state={error:void 0,isDashboardActive:e,isFocused:!1,isLoading:!0,isLoaded:!1,isPreview:l,savedChangeCount:0,changeCount:c,fileMetadata:r,settings:o,session:n,sessionLanguage:s,panelState:{fileMetadata:r,settings:o},showCloseModal:!1,showSaveAsModal:!1,scriptCode:""},$e.debug("constructor",t,this.state)}static handleError(t){Ee.isCanceled(t)||$e.error(t)}static languageFromFileName(t){switch(de.getExtension(t).toLowerCase()){case"py":case"python":return"python";case"groovy":return"groovy";case"scala":return"scala";default:return null}}componentDidMount(){const{glContainer:t,glEventHub:e}=this.props,{tab:n}=t;n!=null&&this.initTab(n),this.initNotebookContent(),e.on(Ve.RENAME_FILE,this.handleRenameFile),t.on("tabClicked",this.handlePanelTabClick)}componentDidUpdate(t,e){const{isPreview:n}=this.state;n!==e.isPreview&&this.setPreviewStatus()}componentWillUnmount(){this.debouncedSavePanelState.flush(),this.pending.cancel();const{glContainer:t,glEventHub:e}=this.props,{fileMetadata:n,isPreview:s}=this.state;e.off(Ve.RENAME_FILE,this.handleRenameFile),t.off("tabClicked",this.handlePanelTabClick),e.emit(Ve.UNREGISTER_FILE,n,s)}initTab(t){this.tabInitOnce||(this.tabInitOnce=!0,this.initTabCloseOverride()),this.initTabClasses(t)}initTabCloseOverride(){const{glContainer:t}=this.props,e=t.close.bind(t);t.close=()=>{const{changeCount:n,savedChangeCount:s}=this.state;return n!==s&&this.shouldPromptClose?this.setState({showCloseModal:!0}):e(),!0}}initTabClasses(t){const e=t.element.get(0);A(e);const n=e.querySelector(".lm_title");this.tabTitleElement=n,n==null||n.classList.add("notebook-title"),this.setPreviewStatus()}getNotebookValue(){const{changeCount:t,savedChangeCount:e,settings:n}=this.state,{value:s}=n;if(t!==e&&this.notebook){const i=this.notebook.getValue();return i!=null?i:s}return s}initNotebookContent(){const{fileMetadata:t,settings:e,isPreview:n}=this.state;if(t&&t.id){$e.debug("Init content from file"),this.registerFileMetadata(t,n),this.load();return}if(e.value!=null){$e.debug("Use content passed in the settings prop"),this.handleLoadSuccess();return}this.handleLoadError(new Error("Missing file metadata"))}closeFileTabById(t){const{glEventHub:e}=this.props;e.emit(Ve.CLOSE_FILE,{id:t})}registerFileMetadata(t,e){const{glEventHub:n,metadata:s}=this.props,{id:i}=s;n.emit(Ve.REGISTER_FILE,i,t,e)}renameTab(t,e){const{glEventHub:n}=this.props;n.emit(Ve.RENAME,t,e)}load(){const{fileMetadata:t,settings:e}=this.state;A(t);const{id:n}=t,{fileStorage:s}=this.props;this.pending.add(s.loadFile(n)).then(i=>{var a;$e.debug("Loaded file",i);const{filename:o}=i,{itemName:r}=this.state;if(o!==r){const{metadata:d}=this.props,{id:c}=d;this.renameTab(c,de.getBaseName(o))}const l={...e,language:(a=Fi.languageFromFileName(o))!=null?a:""};e.value==null&&(l.value=i.content),this.setState({fileMetadata:{id:o,itemName:o},settings:l}),this.debouncedSavePanelState()}).then(this.handleLoadSuccess).catch(this.handleLoadError)}save(){const{fileMetadata:t}=this.state;if(t&&de.hasPath(t.itemName)){const e=this.getNotebookValue();return e!=null?(this.saveContent(t.itemName,e),!0):!1}return this.setState({showSaveAsModal:!0}),!1}saveContent(t,e){$e.debug("saveContent",t,e),this.updateSavedChangeCount();const{fileStorage:n}=this.props;this.pending.add(n.saveFile({filename:t,content:e,basename:t})).then(this.handleSaveSuccess).catch(this.handleSaveError)}updateSavedChangeCount(){this.setState(({changeCount:t})=>({savedChangeCount:t}))}setPreviewStatus(){if(!this.tabTitleElement)return;const{isPreview:t}=this.state;$e.debug("setPreviewStatus",this.tabTitleElement,t),t?this.tabTitleElement.classList.add("is-preview"):this.tabTitleElement.classList.remove("is-preview")}savePanelState(){this.setState(t=>{const{changeCount:e,savedChangeCount:n,fileMetadata:s,isPreview:i,settings:o}=t,r=this.getNotebookValue(),l=e!==n?r:null,a={...o,value:r},c={settings:{...o,value:l},fileMetadata:s,isPreview:i};return $e.debug("Saving panel state",c),{settings:a,panelState:c}})}handleCloseDiscard(){this.shouldPromptClose=!1,this.setState({showCloseModal:!1});const{glContainer:t}=this.props;t.close()}handleCloseSave(){if(this.shouldPromptClose=!1,this.setState({showCloseModal:!1}),this.save()){const{glContainer:t}=this.props;t.close()}}handleCloseCancel(){this.shouldPromptClose=!0,this.setState({showCloseModal:!1})}handleCopy(){const{fileMetadata:t,settings:e}=this.state;A(t);const n=this.getNotebookValue(),{language:s}=e,{itemName:i}=t,o=de.getCopyFileName(i);$e.debug("handleCopy",t,i,o),this.createNotebook(o,s,n!=null?n:void 0)}handleEditorChange(t){$e.debug2("handleEditorChanged",t),this.removePreviewStatus(),this.setState(e=>{const{changeCount:n,savedChangeCount:s}=e,{isUndoing:i,isRedoing:o}=t;return i?{changeCount:n-1,savedChangeCount:s}:!o&&n<s?{changeCount:n+1,savedChangeCount:0}:{changeCount:n+1,savedChangeCount:s}}),this.debouncedSavePanelState()}handleFind(){this.notebook&&this.notebook.toggleFind()}handleBlur(){$e.debug("handleBlur"),this.setState({isFocused:!1})}handleFocus(){$e.debug("handleFocus"),this.setState({isFocused:!0})}handleLinkClick(t){const{notebooksUrl:e,session:n,sessionLanguage:s}=this.props,{href:i}=t.currentTarget;if(!i||!i.startsWith(e))return;t.stopPropagation(),t.preventDefault();const o=`/${i.substring(e.length)}`.replace(/%20/g," ");if(o==="/"){$e.debug("Ignoring invalid notebook link",o);return}$e.debug("Notebook link clicked, opening",o);const{glEventHub:r}=this.props,l={value:null,language:s},a={id:o,itemName:o};r.emit(Ve.SELECT_NOTEBOOK,n,s,l,a)}handleLoadSuccess(){this.setState({error:void 0,isLoaded:!0,isLoading:!1})}handleLoadError(t){let e=t;Ee.isCanceled(e)||(Ee.isTimedOut(e)&&(e=new Error("File not found.")),$e.error(e),this.setState({error:e,isLoading:!1}))}handleSave(){$e.debug("handleSave"),this.save()}handleSaveSuccess(t){var i;const{fileStorage:e}=this.props,n={id:t.filename,itemName:t.filename},s=(i=Fi.languageFromFileName(t.filename))!=null?i:"";this.setState(o=>{const{fileMetadata:r}=o,l={...o.settings,language:s};return $e.debug("handleSaveSuccess",n,r,l),r&&de.hasPath(r.itemName)&&r.itemName!==n.itemName&&($e.debug("handleSaveSuccess deleting old file",r.itemName),e.deleteFile(r.itemName).catch(Fi.handleError)),{fileMetadata:n,settings:l,isPreview:!1}}),this.debouncedSavePanelState(),this.registerFileMetadata(n,!1)}handleSaveError(t){Ee.isCanceled(t)||(this.setState({savedChangeCount:0}),$e.error(t))}handleSaveAsCancel(){this.setState({showSaveAsModal:!1})}handleSaveAsSubmit(t){var i;$e.debug("handleSaveAsSubmit",t);const{fileMetadata:e}=this.state;if(!e)return;const{itemName:n}=e,s=(i=this.getNotebookValue())!=null?i:"";if(this.setState({showSaveAsModal:!1}),de.getBaseName(n)!==de.getBaseName(t)){const{metadata:o}=this.props,{id:r}=o;this.renameTab(r,de.getBaseName(t))}this.saveContent(t,s)}handleRenameFile(t,e){const{fileMetadata:n}=this.state;n&&n.id===t&&(this.setState({fileMetadata:{id:e,itemName:e}}),this.debouncedSavePanelState())}handleResize(){var t;(t=this.notebook)==null||t.updateDimensions()}handleRunCommand(t){this.runCommand(t)}handleRunAll(){var t;if(!this.notebook){$e.error("Editor is not initialized.");return}this.runCommand((t=this.notebook.getValue())!=null?t:void 0)}handleRunSelected(){if(!this.notebook){$e.error("Editor is not initialized.");return}this.runCommand(this.notebook.getSelectedCommand())}handleSessionOpened(t,{language:e}){this.setState({session:t,sessionLanguage:e})}handleSessionClosed(){this.setState({session:void 0,sessionLanguage:void 0})}handleShow(){var t;$e.debug("handleShow"),(t=this.notebook)==null||t.updateDimensions()}handleShowRename(){this.setState({showSaveAsModal:!0})}handleTab(t){$e.debug("NotebookPanel tab event",t),this.initTab(t)}handleTabFocus(...t){$e.debug("handleTabFocus",...t);const{glContainer:e}=this.props;this.setState({isDashboardActive:!0}),this.notebook&&!e.isHidden&&this.notebook.updateDimensions()}handleTabBlur(){$e.debug("handleTabBlur"),this.setState({isDashboardActive:!1})}handlePanelTabClick(){$e.debug("handlePanelTabClick"),this.focus()}handleTransformLinkUri(t){const{notebooksUrl:e}=this.props,{fileMetadata:n}=this.state;if(t.endsWith("/"))return t;if(t.startsWith("/"))return`${e}${t.substring(1)}`;let s=n==null?void 0:n.itemName;if(s===void 0)return t;s.charAt(0)==="/"&&(s=s.substring(1));const i=new URL(s,e);return new URL(t,i).href}focus(){requestAnimationFrame(()=>{this.notebook&&this.notebook.focus()})}createNotebook(t,e,n=""){const{glEventHub:s}=this.props,{session:i,sessionLanguage:o,settings:r}=this.state,l={...r,language:e,value:n},a={id:null,itemName:t};$e.debug("handleCreateNotebook",i,o,l,a),s.emit(Ve.CREATE_NOTEBOOK,i,o,l,a)}runCommand(t){if(t===void 0){$e.debug("Ignoring empty command.");return}this.removePreviewStatus();const{glEventHub:e}=this.props;e.emit(ft.SEND_COMMAND,t,!1,!0)}removePreviewStatus(){this.setState(({isPreview:t})=>{if(t){const{fileMetadata:e}=this.state;return e&&this.registerFileMetadata(e,!1),{isPreview:!1}}return null})}render(){var _,k;const{fileStorage:t,glContainer:e,glContainer:{tab:n},glEventHub:s}=this.props,{changeCount:i,savedChangeCount:o,error:r,isDashboardActive:l,isLoaded:a,isLoading:d,isPreview:c,fileMetadata:u,session:m,sessionLanguage:p,settings:g,showCloseModal:f,showSaveAsModal:b}=this.state,C=l&&!e.isHidden&&!c,w=(_=u==null?void 0:u.itemName)!=null?_:Fi.DEFAULT_NAME,T=w.endsWith(".md"),y=(u==null?void 0:u.id)!=null,E=this.getOverflowActions(),I={...g},R=m!=null,F=p===I.language,x=!a||!R||!F,U=!a,$=[{action:this.handleSave,shortcut:Os.SAVE}],O=Jc.getDisabledRunTooltip(R,F,"Notebook extension","Run"),H=Jc.getDisabledRunTooltip(R,F,"Notebook extension","Run Selected"),L=[{title:y?"Rename":"Save As\u2026",order:10,group:oe.groups.high,action:this.handleShowRename},{title:"Copy File",action:this.handleCopy,group:oe.groups.high,order:20}],N=n==null?void 0:n.element.find(".lm_title_before").get(0);return v(ue,{children:[N&&ui.createPortal(h("span",{className:z("editor-unsaved-indicator",{"is-unsaved":i!==o})}),N),v(Yn,{className:"notebook-container",componentPanel:this,glContainer:e,glEventHub:s,onTab:this.handleTab,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleTabFocus,onTabBlur:this.handleTabBlur,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onFocus:this.handleFocus,onBlur:this.handleBlur,additionalActions:L,renderTabTooltip:()=>w,children:[!T&&v(ue,{children:[v("div",{className:"notebook-toolbar",children:[v("span",{children:[h(Q,{kind:"ghost",className:"btn-play",onClick:this.handleRunAll,disabled:x,icon:h(K,{icon:Gr,transform:"grow-4"}),tooltip:`Run ${Nn.NOTEBOOK.RUN.getDisplayText()}`}),O!=null&&h(Ie,{children:O})]}),v("span",{children:[h(Q,{kind:"ghost",className:"btn-play",onClick:this.handleRunSelected,disabled:x,icon:h(K,{icon:nC,transform:"grow-4"}),tooltip:`Run Selected
|
|
@@ -40,5 +40,5 @@ ${l} does not exist yet.`}if(i){const{widgetName:r}=this.props;return`${r} is un
|
|
|
40
40
|
${qa.makeCirclePath(s,i,Gh)}`,w=`link-select-clip-${o}`,T=Math.atan2(i-f,s-g),y=T-Wh+Math.PI,E=T+Wh+Math.PI,I=s+Math.cos(T)*zh,R=i+Math.sin(T)*zh,F=I+Math.cos(y)*Fr,x=R+Math.sin(y)*Fr,U=I+Math.cos(E)*Fr,$=R+Math.sin(E)*Fr,O=`${I},${R} ${F},${x} ${U},${$}`;return v("svg",{className:t,children:[h("clipPath",{id:w,children:h("path",{d:C,clipRule:"evenodd"})}),h("path",{className:"link-select",d:b,onClick:this.handleClick,clipPath:`url(#${w})`}),h("path",{className:"link-background",d:b}),h("path",{className:"link-foreground",d:b}),h("circle",{className:"link-dot",cx:e,cy:n,r:"5"}),h("polygon",{className:"link-triangle",points:O})]})}};let Pp=qa;Pp.defaultProps={className:"",onClick(){}};const ba=X.module("LinkerOverlayContent");class Hp extends S.exports.Component{constructor(e){super(e),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleEscapePressed=this.handleEscapePressed.bind(this),this.state={mouseX:void 0,mouseY:void 0}}componentDidMount(){window.addEventListener("mousemove",this.handleMouseMove,!0)}componentDidCatch(e,n){ba.error("componentDidCatch",e,n)}componentWillUnmount(){window.removeEventListener("mousemove",this.handleMouseMove,!0)}getPointFromLinkPoint(e){const{panelManager:n}=this.props,{panelId:s,columnName:i}=e,o=n.getOpenedPanelById(s);if(o!=null){if(!kp(o))throw new Error(`Panel does not have getCoordinateForColumn method: ${s}`);try{const l=o.getCoordinateForColumn(i);if(l!=null)return l}catch{ba.error("Could not get coordinate for column",i,o)}}const r=n.getContainerByPanelId(s);if(r==null)throw new Error(`Unable to find panel container for id: ${s}`);return te.getTabPoint(r)}handleMouseMove(e){this.setState({mouseX:e.clientX,mouseY:e.clientY})}handleEscapePressed(){const{onCancel:e}=this.props;e()}render(){const{disabled:e,links:n,messageText:s,onLinkDeleted:i,onAllLinksDeleted:o,onDone:r}=this.props,{mouseX:l,mouseY:a}=this.state,d=n.map(c=>{try{const{id:u,type:m,isReversed:p,start:g,end:f}=c;let[b,C]=this.getPointFromLinkPoint(g),w=l!=null?l:b,T=a!=null?a:C;if(f!=null&&([w,T]=this.getPointFromLinkPoint(f)),p!=null&&p){const[E,I]=[b,C];[b,C]=[w,T],[w,T]=[E,I]}const y=z("linker-link",{disabled:e},{"link-filter-source":m==="filterSource"},{"link-invalid":m==="invalid"},{interactive:c.end==null});return{x1:b,y1:C,x2:w,y2:T,id:u,className:y}}catch(u){return ba.error("Unable to get point for link",c,u),null}}).filter(c=>c!=null);return v("div",{className:"linker-overlay",children:[h("svg",{children:d.map(({x1:c,y1:u,x2:m,y2:p,id:g,className:f})=>h(Pp,{className:f,id:g,x1:c,y1:u,x2:m,y2:p,onClick:i},g))}),v("div",{className:"linker-toast-dialog",children:[h("div",{className:"toast-body",children:s}),v("div",{className:"toast-footer",children:[h(Q,{kind:"secondary",onClick:o,children:"Clear All"}),h(Q,{kind:"primary",onClick:r,children:"Done"})]})]}),h(oe,{actions:[{action:this.handleEscapePressed,shortcut:Os.LINKER_CLOSE,isGlobal:!0}]})]})}}Hp.defaultProps={disabled:"false"};const Ut=X.module("Linker"),ZE=(t,e)=>({activeTool:Rl(t),isolatedLinkerPanelId:Xd(t,e.localDashboardId),links:so(t,e.localDashboardId),timeZone:Il(t)}),JE=Dt(ZE,{setActiveTool:Dl,setDashboardLinks:Qd,addDashboardLinks:lE,deleteDashboardLinks:aE,setDashboardIsolatedLinkerPanelId:yp,setDashboardColumnSelectionValidator:dE});class e1 extends S.exports.Component{constructor(e){super(e),this.getCachedLinks=he((n,s,i)=>{const o=[...n];return s!=null&&s.start!=null&&o.push(s),i!==void 0?o.filter(r=>{var l,a;return((l=r==null?void 0:r.start)==null?void 0:l.panelId)===i||((a=r==null?void 0:r.end)==null?void 0:a.panelId)===i||(r==null?void 0:r.end)==null}):o}),this.handleCancel=this.handleCancel.bind(this),this.handleDone=this.handleDone.bind(this),this.handlePanelCloned=this.handlePanelCloned.bind(this),this.handleFilterColumnSelect=this.handleFilterColumnSelect.bind(this),this.handleColumnsChanged=this.handleColumnsChanged.bind(this),this.handlePanelClosed=this.handlePanelClosed.bind(this),this.handleLayoutStateChanged=this.handleLayoutStateChanged.bind(this),this.handleAllLinksDeleted=this.handleAllLinksDeleted.bind(this),this.handleLinkDeleted=this.handleLinkDeleted.bind(this),this.handleChartColumnSelect=this.handleChartColumnSelect.bind(this),this.handleGridColumnSelect=this.handleGridColumnSelect.bind(this),this.handleUpdateValues=this.handleUpdateValues.bind(this),this.handleStateChange=this.handleStateChange.bind(this),this.handleExited=this.handleExited.bind(this),this.isColumnSelectionValid=this.isColumnSelectionValid.bind(this),this.state={linkInProgress:void 0}}componentDidMount(){const{layout:e}=this.props;this.startListening(e),this.updateSelectionValidators()}componentDidUpdate(e){const{activeTool:n,layout:s}=this.props;s!==e.layout&&(this.stopListening(e.layout),this.startListening(s)),n!==e.activeTool&&this.updateSelectionValidators()}componentDidCatch(e,n){Ut.error("componentDidCatch",e,n)}componentWillUnmount(){const{layout:e}=this.props;this.stopListening(e)}startListening(e){e.on("stateChanged",this.handleLayoutStateChanged);const{eventHub:n}=e;n.on(wt.COLUMN_SELECTED,this.handleGridColumnSelect),n.on(wt.DATA_SELECTED,this.handleUpdateValues),n.on(wt.STATE_CHANGED,this.handleStateChange),n.on(Gi.COLUMN_SELECTED,this.handleChartColumnSelect),n.on(Me.CLONED,this.handlePanelCloned),n.on(He.COLUMN_SELECTED,this.handleFilterColumnSelect),n.on(He.COLUMNS_CHANGED,this.handleColumnsChanged),n.on(Me.CLOSED,this.handlePanelClosed)}stopListening(e){e.off("stateChanged",this.handleLayoutStateChanged);const{eventHub:n}=e;n.off(wt.COLUMN_SELECTED,this.handleGridColumnSelect),n.off(wt.DATA_SELECTED,this.handleUpdateValues),n.off(wt.STATE_CHANGED,this.handleStateChange),n.off(Gi.COLUMN_SELECTED,this.handleChartColumnSelect),n.off(Me.CLONED,this.handlePanelCloned),n.off(He.COLUMN_SELECTED,this.handleFilterColumnSelect),n.off(He.COLUMNS_CHANGED,this.handleColumnsChanged),n.off(Me.CLOSED,this.handlePanelClosed)}handleCancel(){const{linkInProgress:e}=this.state;if(e==null){const{setActiveTool:n}=this.props;n(dn.DEFAULT)}this.setState({linkInProgress:void 0})}handleDone(){const{setActiveTool:e}=this.props;e(dn.DEFAULT),this.setState({linkInProgress:void 0})}handleChartColumnSelect(e,n){this.columnSelected(e,n,!0)}handleFilterColumnSelect(e,n){Ut.debug("handleFilterColumnSelect",this.isOverlayShown());const{links:s,localDashboardId:i,setActiveTool:o,setDashboardIsolatedLinkerPanelId:r}=this.props,l=te.getIdFromPanel(e),a=s.filter(d=>{var c,u;return((c=d.start)==null?void 0:c.panelId)===l||((u=d.end)==null?void 0:u.panelId)===l});if(!this.isOverlayShown()&&l!=null){o(dn.LINKER),r(i,l),a.length===0&&this.columnSelected(e,n,!0,l);return}this.columnSelected(e,n,!0)}handleColumnsChanged(e,n){Ut.debug("handleColumnsChanged",e,n);const{links:s}=this.props,i=te.getIdFromPanel(e);if(i==null){Ut.error("Invalid panelId",e);return}const o=s.filter(({start:r,end:l})=>r.panelId===i&&ni.findColumn(n,r)==null||l!=null&&l.panelId===i&&ni.findColumn(n,l)==null);this.deleteLinks(o)}handleGridColumnSelect(e,n){this.columnSelected(e,n)}columnSelected(e,n,s=!1,i){if(i===void 0&&!this.isOverlayShown())return;const{isolatedLinkerPanelId:o}=this.props,{linkInProgress:r}=this.state,l=te.getIdFromPanel(e);if(l==null)return;const a=te.getComponentNameFromPanel(e),{name:d,type:c}=n;if(r==null||r.start==null){const u={id:We.generate(),start:{panelId:l,panelComponent:a,columnName:d,columnType:c},type:"invalid",isReversed:s};Ut.debug("starting link",u),this.setState({linkInProgress:u})}else{const{start:u,id:m,isReversed:p}=r,g={panelId:l,panelComponent:a,columnName:d,columnType:c},f=ni.getLinkType(p!==void 0&&p?g:u,p!==void 0&&p?u:g,i!=null?i:o);switch(f){case"invalid":Ut.debug("Ignore invalid link connection",r,g);return;case"filterSource":{const{links:C}=this.props,w=p!==void 0&&p?u.panelId:g.panelId,T=C.filter(({end:y})=>(y==null?void 0:y.panelId)===w);this.deleteLinks(T);break}}const b={start:p!==void 0&&p?g:u,end:p!==void 0&&p?u:g,id:m,type:f};Ut.info("creating link",b),this.setState({linkInProgress:void 0},()=>{this.addLinks([b])})}}unsetFilterValueForLink(e){const{panelManager:n}=this.props;if(e.end){const{end:s}=e,{panelId:i,columnName:o,columnType:r}=s,l=n.getOpenedPanelById(i);l?Uh(l)?l.unsetFilterValue(o,r):Ut.debug("endPanel.unsetFilterValue not implemented",l):Ut.debug("endPanel no longer exists, ignoring unsetFilterValue",i)}}setPanelFilterMap(e,n){Ut.debug("Set filter data for panel:",e,n);const{panelManager:s}=this.props,i=s.getOpenedPanelById(e);i?Uh(i)?i.setFilterMap(n):Ut.debug("panel.setFilterMap not implemented",e,i):Ut.debug("panel no longer exists, ignoring setFilterMap",e)}addLinks(e){const{addDashboardLinks:n,localDashboardId:s}=this.props;n(s,e)}deleteLinks(e,n=!1){const{localDashboardId:s}=this.props;if(e.forEach(i=>this.unsetFilterValueForLink(i)),n){const{setDashboardLinks:i}=this.props;i(s,[])}else if(e.length>0){const{deleteDashboardLinks:i}=this.props;i(s,e.map(({id:o})=>o))}}handleAllLinksDeleted(){const{links:e,isolatedLinkerPanelId:n}=this.props;if(n===void 0)this.deleteLinks(e,!0);else{const s=e.filter(i=>{var o,r;return((o=i==null?void 0:i.start)==null?void 0:o.panelId)===n||((r=i==null?void 0:i.end)==null?void 0:r.panelId)===n});this.deleteLinks(s)}this.setState({linkInProgress:void 0})}handleLinkDeleted(e){const{links:n}=this.props,s=n.find(i=>i.id===e);s?this.deleteLinks([s]):Ut.error("Unable to find link to delete",e)}handleUpdateValues(e,n){const s=te.getIdFromPanel(e),{links:i,timeZone:o}=this.props,r=new Map;for(let l=0;l<i.length;l+=1){const{start:a,end:d}=i[l];if(a.panelId===s&&d!=null){const{panelId:c,columnName:u,columnType:m}=d,p=r.has(c)?r.get(c):new Map,{value:g}=n[a.columnName];let f=`${g}`;m!=null&&P.isDateType(m)&&(f=new at({timeZone:o,showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:us.FULL_DATE_FORMAT}).format(g)),p.set(u,{columnType:m,text:f,value:g}),r.set(c,p)}}r.forEach((l,a)=>{this.setPanelFilterMap(a,l)})}handlePanelCloned(e,n){const{links:s}=this.props,i=te.getIdFromPanel(e),o=n.id;if(i!=null){const r=ni.cloneLinksForPanel(s,i,o);this.addLinks(r)}}handlePanelClosed(e){Ut.debug(`Panel ${e} closed, deleting links.`),this.deleteLinksForPanelId(e)}handleLayoutStateChanged(){this.forceUpdate()}handleStateChange(){this.forceUpdate()}handleExited(){const{localDashboardId:e,setDashboardIsolatedLinkerPanelId:n}=this.props;n(e,void 0)}deleteLinksForPanelId(e){const{links:n}=this.props;for(let s=0;s<n.length;s+=1){const i=n[s],{start:o,end:r,id:l}=i;(o.panelId===e||(r==null?void 0:r.panelId)===e)&&this.handleLinkDeleted(l)}}isOverlayShown(){const{activeTool:e}=this.props;return e===dn.LINKER}updateSelectionValidators(){const{activeTool:e,setDashboardColumnSelectionValidator:n,localDashboardId:s}=this.props;switch(e){case dn.LINKER:n(s,this.isColumnSelectionValid);break;default:n(s,void 0);break}}updateLinkInProgressType(e,n="invalid"){this.setState({linkInProgress:{...e,type:n}})}isColumnSelectionValid(e,n){const{linkInProgress:s}=this.state,{isolatedLinkerPanelId:i}=this.props;if((s==null?void 0:s.start)==null)return!0;if(n==null)return this.updateLinkInProgressType(s),!1;const{isReversed:o,start:r}=s,l=te.getIdFromPanel(e);if(l==null)return!1;const a={panelId:l,panelComponent:te.getComponentNameFromPanel(e),columnName:n.name,columnType:n.type},d=o!==void 0&&o?ni.getLinkType(a,r,i):ni.getLinkType(r,a,i);return this.updateLinkInProgressType(s,d),d!=="invalid"}render(){const{links:e,isolatedLinkerPanelId:n,panelManager:s}=this.props,{linkInProgress:i}=this.state,o=this.isOverlayShown(),r=i!=null&&i.start!=null,l=n===void 0?"Click a column source, then click a column target to create a filter link. Remove a filter link by clicking again to erase. Click done when finished.":"Create a link between the source column button and a table column by clicking on one, then the other. Remove the link by clicking it directly. Click done when finished.";return h(ue,{children:h(ht,{in:o,timeout:Tt.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,onExited:this.handleExited,children:h(Hp,{disabled:r,panelManager:s,links:this.getCachedLinks(e,i,n),messageText:l,onLinkDeleted:this.handleLinkDeleted,onAllLinksDeleted:this.handleAllLinksDeleted,onDone:this.handleDone,onCancel:this.handleCancel})})})}}const t1=JE(e1),n1=t=>{As(t);const{id:e,layout:n,panelManager:s}=t;return h(t1,{layout:n,localDashboardId:e,panelManager:s})},Ya=class{static getNewMarkdownTitle(t){let e=`${Ya.DEFAULT_TITLE}`,n=0;for(;t.indexOf(e)>=0;)n+=1,e=`${Ya.DEFAULT_TITLE}-${n}`;return e}};let ko=Ya;ko.DEFAULT_TITLE="Note";ko.DEFAULT_CONTENT=`# Markdown Note
|
|
41
41
|
|
|
42
42
|
This note can be edited using **markdown** for styling.`;const s1=t=>{As(t);const{id:e,layout:n,panelManager:s,registerComponent:i}=t,o=S.exports.useCallback(l=>{const{title:a,componentState:d,props:c}=l;let{panelState:u=null}=c;return d!=null&&({panelState:u=null}=d),a==null||u==null||u.content==null||u.content.length===0||u.content===ko.DEFAULT_CONTENT?null:Nd(l)},[]),r=S.exports.useCallback(({title:l="",metadata:a={},id:d=We.generate(),focusElement:c=te.DEFAULT_FOCUS_SELECTOR,createNewStack:u=!1,dragEvent:m=null}={})=>{const p=s.getOpenedPanelConfigsOfType(bo.COMPONENT),g=s.getClosedPanelConfigsOfType(bo.COMPONENT),f=p.map(y=>{var E;return(E=y.title)!=null?E:""}),b=l!=null&&l!==""?l:ko.getNewMarkdownTitle(f),C=g.length>0?null:ko.DEFAULT_CONTENT,w={type:"react-component",component:bo.COMPONENT,props:{id:d,metadata:a,panelState:{content:C},localDashboardId:e},title:b,id:d},{root:T}=n;te.openComponent({root:T,config:w,focusElement:c,createNewStack:u,dragEvent:m})},[e,n,s]);return S.exports.useEffect(function(){const a=[i(bo.COMPONENT,bo,Fd,o)];return()=>{a.forEach(d=>d())}},[o,i]),Ke(n.eventHub,wp.OPEN,r),h(ue,{})},i1=t=>{As(t);const{hydrate:e,id:n,layout:s,registerComponent:i}=t,o=S.exports.useCallback(({dragEvent:r,fetch:l,panelId:a=We.generate(),widget:d})=>{const{name:c,type:u}=d;if(u!==dh.VariableType.PANDAS)return;const m={name:c,table:c},p=()=>l().then(b=>Gd.makeModel(b)),g={type:"react-component",component:_o.COMPONENT,props:{localDashboardId:n,id:a,metadata:m,makeModel:p},title:c,id:a},{root:f}=s;te.openComponent({root:f,config:g,dragEvent:r})},[n,s]);return S.exports.useEffect(function(){const l=[i(_o.COMPONENT,_o,e)];return()=>{l.forEach(a=>a())}},[e,i]),Ke(s.eventHub,Me.OPEN,o),h(ue,{})};class fn{}fn.DROPDOWN_FILTER="ControlType.DROPDOWN_FILTER";fn.INPUT_FILTER="ControlType.INPUT_FILTER";fn.MARKDOWN="ControlType.MARKDOWN";fn.FILTER_SET_MANAGER="ControlType.FILTER_SET_MANAGER";const o1=D.exports.shape({state:D.exports.shape({panelState:D.exports.shape({})})}),r1=D.exports.shape({panelId:D.exports.string.isRequired,columnName:D.exports.string.isRequired,columnType:D.exports.string.isRequired}),Kh=D.exports.shape({panelId:D.exports.string.isRequired,columnName:D.exports.string.isRequired}),Vp=D.exports.shape({start:Kh,end:Kh,id:D.exports.string,isReversed:D.exports.bool}),l1=D.exports.arrayOf(Vp),a1=D.exports.shape({name:D.exports.string.isRequired,operateAs:D.exports.string.isRequired,groups:D.exports.arrayOf(D.exports.string).isRequired,permissions:D.exports.shape({isSuperUser:D.exports.bool.isRequired,isQueryViewOnly:D.exports.bool.isRequired,isNonInteractive:D.exports.bool.isRequired,canUsePanels:D.exports.bool.isRequired,canCreateDashboard:D.exports.bool.isRequired,canCreateCodeStudio:D.exports.bool.isRequired,canCreateQueryMonitor:D.exports.bool.isRequired,canCopy:D.exports.bool.isRequired,canDownloadCsv:D.exports.bool.isRequired}).isRequired});Object.freeze({LinkPoint:r1,Link:Vp,Links:l1,Panel:o1,User:a1});const d1=(t,e)=>t[e]===null?null:D.exports.bool,c1=(t,e)=>t[e]===null?null:D.exports.string;Object.freeze({nullableBoolean:d1,nullableString:c1});X.module("StorageTableViewportUpdater");class qh{static makeSortConfig(e,n){return{column:e,direction:n}}static makeFilterConfig(e){const n=[],s=[];return e.forEach((i,o)=>{n.push(i),o>0&&s.push(Wt.and)}),{filterItems:n,filterOperators:s}}static combineFilterConfigs(e,n,s=Wt.and){return{filterItems:[...e.filterItems,...n.filterItems],filterOperators:[...e.filterOperators,s,...n.filterOperators]}}static makeFilterItem(e,n,s){return{columnName:e,type:n,value:s}}}const Sa=X.module("PouchStorageTable"),h1="Deephaven.";su.plugin(cg);function u1(t,e){switch(t){case q.in:case q.contains:return{$regex:new RegExp(`${e}`)};case q.inIgnoreCase:return{$regex:new RegExp(`${e}`,"i")};case q.eq:return{$eq:e};case q.notEq:return{$neq:e};case q.greaterThan:return{$gt:e};case q.greaterThanOrEqualTo:return{$gte:e};case q.lessThan:return{$lt:e};case q.lessThanOrEqualTo:return{$lte:e};case q.startsWith:return{$regex:new RegExp(`^(?${e}).*`)};default:throw new Error(`Unsupported type: ${t}`)}}function m1(t){const{filterItems:e,filterOperators:n}=t;let s=null;for(let i=0;i<e.length;i+=1){const o=e[i],{columnName:r,type:l,value:a}=o,d={[r]:u1(l,a)};if(i===0)s=d;else if(s!==null&&i-1<n.length){const c=n[i-1];if(c===Wt.and)s={$and:[s,d]};else if(c===Wt.or)s={$or:[s,d]};else throw new Error(`Unexpected filter operator ${c}, ${d}`)}}if(s==null)throw new Error(`Invalid filter config ${t}`);return s}function wa(t=[]){return{$and:[...t.map(e=>m1(e)),{name:{$gt:null}},{id:{$gt:null}}]}}function p1(t,e=!1){var n;return[{id:e?"desc":"asc"},...(n=t==null?void 0:t.map(s=>({[s.column]:s.direction})))!=null?n:[]]}class g1{constructor(e){this.listeners=[],this.itemListeners=new Map,this.currentSize=0,this.currentReverse=!1,this.currentFilter=null,this.currentSort=null,this.db=new su(`${h1}${e}`),this.db._remote=!1,this.db.changes({live:!0,since:"now",include_docs:!0}).on("change",this.dbUpdate.bind(this)),this.db.createIndex({index:{fields:["id","name"]}}),this.refreshInfo()}onUpdate(e){return this.listeners=[...this.listeners,e],()=>{this.listeners=this.listeners.filter(n=>n!==e)}}onItemUpdate(e,n){return this.itemListeners.has(e)||this.itemListeners.set(e,[]),this.itemListeners.set(e,[...this.itemListeners.get(e),n]),this.refreshItem(e),()=>{this.itemListeners.set(e,this.itemListeners.get(e).filter(s=>s!==n))}}close(){this.listeners=[]}get size(){return this.currentSize}get viewport(){return this.currentViewport}setReversed(e){this.currentReverse=e,this.currentViewportData=void 0,this.refreshData()}setViewport(e){this.currentViewport=e,this.refreshInfo(),this.refreshData()}setSorts(e){this.currentSort=e,this.currentViewportData=void 0,this.refreshData()}setFilters(e){this.currentFilter=e,this.currentViewportData=void 0,this.refreshInfo(),this.refreshData()}get data(){return this.currentViewportData}async getViewportData(){var e;return this.viewportUpdatePromise||this.refreshData(),(e=this.viewportUpdatePromise)!=null?e:Promise.resolve({items:[],offset:0})}async put(e){const n={...e,_id:e.id};return await this.db.put(n),n}sendUpdate(){var s;const{listeners:e}=this,n=(s=this.currentViewportData)!=null?s:{items:[],offset:0};for(let i=0;i<e.length;i+=1)e[i](n)}sendItemUpdate(e){const n=this.itemListeners.get(e.id);if(n!==void 0)for(let s=0;s<n.length;s+=1)n[s](e)}dbUpdate(e){Sa.debug("Update received",e),this.refreshInfo(),e.doc!==void 0&&this.sendItemUpdate(e.doc),this.refreshData()}async refreshInfo(){var e,n;try{(e=this.infoUpdatePromise)==null||e.cancel(),this.infoUpdatePromise=Ee.makeCancelable(this.db.find({selector:wa((n=this.currentFilter)!=null?n:[]),fields:[]}));const s=await this.infoUpdatePromise;this.currentSize=s.docs.length,this.sendUpdate()}catch(s){if(!Ee.isCanceled(s))throw Sa.error("Unable to refreshInfo",s),s}}async refreshData(){var e,n;if(!!this.currentViewport)try{const{currentViewport:s}=this,i=p1(this.currentSort,this.currentReverse);(e=this.viewportUpdatePromise)==null||e.cancel(),this.viewportUpdatePromise=Ee.makeCancelable(this.db.find({selector:wa((n=this.currentFilter)!=null?n:[]),skip:s.top,limit:s.bottom-s.top+1,sort:i,fields:["id","name"]}).then(r=>({items:r.docs,offset:s.top})));const o=await this.viewportUpdatePromise;return this.currentViewportData=o,this.sendUpdate(),o}catch(s){if(!Ee.isCanceled(s))throw Sa.error("Unable to refreshData",s),s}}async refreshItem(e){const s=(await this.db.find({selector:{id:e},limit:1})).docs[0];return s!==void 0&&this.sendItemUpdate(s),s}async getSnapshot(e){const n=new Map,s=[{id:this.currentReverse?"desc":"asc"}];return await Promise.all(e.map(async([i,o])=>{var l;const r=o-i+1;return this.db.find({selector:wa((l=this.currentFilter)!=null?l:[]),skip:i,limit:r,sort:s,fields:["id","name"]}).then(a=>{for(let d=0;d<r;d+=1){const c=i+d;n.set(c,a.docs[d])}})})),n}}class Yh extends g1{constructor(e){super(`CommandHistoryStorage.${e}`)}setSearch(e){this.setFilters(e?[qh.makeFilterConfig([qh.makeFilterItem("name",q.contains,e)])]:[])}}const Xh=X.module("PouchCommandHistoryStorage");class f1{constructor(){this.updateTableMap=new Map}getUpdateTable(e){return this.updateTableMap.has(e)||this.updateTableMap.set(e,new Yh(e)),this.updateTableMap.get(e)}async getTable(e){return new Yh(e)}async addItem(e,n,s,i){return this.updateItem(e,{id:`${new Date().getTime()}`,name:s,data:i})}async updateItem(e,n){const s=this.getUpdateTable(e),i=await s.refreshItem(n.id),o={...i!=null?i:{},...n};return Xh.debug("Updating item",o),await s.put(o),Xh.debug("Update saved"),n}listenItem(e,n,s){return this.getUpdateTable(e).onItemUpdate(n,s)}}const Up="SET_LAYOUT_STORAGE",C1=t=>({type:Up,payload:t}),Bp="/ide/assets/community-wordmark-app.d2c5c1eb.svg";const Ms=X.module("FormattingSectionContent");function b1(t){return t.formatString!=null}const rt=class extends S.exports.PureComponent{constructor(t){super(t),this.getCachedColumnTypeOptions=Te(()=>rt.renderColumnTypeOptions()),this.getCachedDateTimeFormatOptions=Te((c,u,m,p=!1,g=null)=>{const{timestampAtMenuOpen:f}=this.state;return rt.renderDateTimeOptions(f,c,u,m,p,g)}),this.debouncedCommitChanges=Xe(this.commitChanges.bind(this),rt.inputDebounceTime),this.handleDefaultDateTimeFormatChange=this.handleDefaultDateTimeFormatChange.bind(this),this.handleDefaultDecimalFormatChange=this.handleDefaultDecimalFormatChange.bind(this),this.handleDefaultIntegerFormatChange=this.handleDefaultIntegerFormatChange.bind(this),this.handleFormatRuleEntered=this.handleFormatRuleEntered.bind(this),this.handleFormatRuleChange=this.handleFormatRuleChange.bind(this),this.handleFormatRuleCreate=this.handleFormatRuleCreate.bind(this),this.handleFormatRuleDelete=this.handleFormatRuleDelete.bind(this),this.handleShowTimeZoneChange=this.handleShowTimeZoneChange.bind(this),this.handleShowTSeparatorChange=this.handleShowTSeparatorChange.bind(this),this.handleTimeZoneChange=this.handleTimeZoneChange.bind(this),this.handleResetDateTimeFormat=this.handleResetDateTimeFormat.bind(this),this.handleResetDecimalFormat=this.handleResetDecimalFormat.bind(this),this.handleResetIntegerFormat=this.handleResetIntegerFormat.bind(this),this.handleResetTimeZone=this.handleResetTimeZone.bind(this),this.handleTruncateNumbersWithPoundChange=this.handleTruncateNumbersWithPoundChange.bind(this);const{formatter:e,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,showTimeZone:o,showTSeparator:r,timeZone:l,truncateNumbersWithPound:a}=t,d=e.map((c,u)=>({...c,id:u}));this.containerRef=Y.createRef(),this.addFormatRuleButtonRef=Y.createRef(),this.lastFormatRuleIndex=d.length,this.state={formatSettings:d,formatRulesChanged:!1,showTimeZone:o,showTSeparator:r,timeZone:l,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,truncateNumbersWithPound:a,timestampAtMenuOpen:new Date}}static focusFirstInputInContainer(t){const e=t==null?void 0:t.querySelector("input, select, textarea");e&&e.focus()}static isSameOptions(t,e){return t.defaultFormatString===e.defaultFormatString}static isSameDecimalOptions(t,e){return rt.isSameOptions(t,e)}static isSameIntegerOptions(t,e){return rt.isSameOptions(t,e)}static isValidColumnName(t){return t!==""&&ms.isValidColumnName(t)}static isValidFormat(t,e){if(!t||e.formatString==null||!b1(e))return!1;switch(t){case"datetime":return at.isValid(e);case"decimal":return Pe.isValid(e);case"int":return nt.isValid(e);default:return Ms.warn("Trying to validate format of unknown type"),!0}}static removeFormatRuleExtraProps(t){const{id:e,isNewRule:n,...s}=t;return s}static isFormatRuleValidForSave(t){return rt.isValidColumnName(t.columnName)&&rt.isValidFormat(t.columnType,t.format)}static renderTimeZoneOptions(){return In.TIME_ZONES.map(e=>{const{label:n,value:s}=e;return h("option",{value:s,children:n},s)})}static renderColumnTypeOptions(){const e=[{value:P.dataType.DATETIME,label:"DateTime"},{value:P.dataType.DECIMAL,label:"Decimal"},{value:P.dataType.INT,label:"Integer"}].map(n=>h("option",{value:n.value,children:n.label},`key-columnType-${n.value}`));return v(ue,{children:[h("option",{disabled:!0,value:"",children:"Select Type"},"key-columnType-placeholder"),e]})}static renderDateTimeOptions(t,e,n,s,i,o){const r=new cn([],{timeZone:e,showTimeZone:n,showTSeparator:s}),l=i?at.getGlobalFormats(n,s):at.getFormats(n,s);return o&&!l.includes(o)&&l.unshift(o),l.map(a=>{const d=at.makeFormat("",a,at.TYPE_GLOBAL);return h("option",{value:a,children:r.getFormattedString(t,P.dataType.DATETIME,"",d)},a)})}componentDidMount(){rt.focusFirstInputInContainer(this.containerRef.current)}componentWillUnmount(){this.debouncedCommitChanges.flush()}isDuplicateRule(t){var n;const{formatSettings:e}=this.state;return(n=e.some(s=>s.id!==t.id&&s.columnName===t.columnName&&s.columnType===t.columnType))!=null?n:!1}getAutoIncrementFormatRuleIndex(){const{lastFormatRuleIndex:t}=this;return this.lastFormatRuleIndex+=1,t}handleDefaultDateTimeFormatChange(t){Ms.debug("handleDefaultDateTimeFormatChange",t.target.value),this.setState({defaultDateTimeFormat:t.target.value},()=>{this.debouncedCommitChanges()})}handleDefaultDecimalFormatChange(t){Ms.debug("handleDefaultDecimalFormatChange",t.target.value),this.setState({defaultDecimalFormatOptions:{defaultFormatString:t.target.value}},()=>{this.debouncedCommitChanges()})}handleDefaultIntegerFormatChange(t){Ms.debug("handleDefaultIntegerFormatChange",t.target.value),this.setState({defaultIntegerFormatOptions:{defaultFormatString:t.target.value}},()=>{this.debouncedCommitChanges()})}handleFormatRuleChange(t,e,n){this.setState(s=>{const{formatSettings:i}=s;A(i);const o=[...i];let r={};e==="columnType"&&(r={format:""});const l={...o[t],...r,[e]:n};return o[t]=l,{formatSettings:o}},()=>{this.debouncedCommitChanges()})}handleFormatRuleCreate(){this.setState(t=>{const{formatSettings:e}=t,n={columnType:P.dataType.DATETIME,columnName:"",format:{},id:this.getAutoIncrementFormatRuleIndex(),isNewRule:!0};return{formatSettings:e!=null?[...e,n]:[n],formatRulesChanged:!0}})}handleFormatRuleDelete(t){this.setState(e=>{const{formatSettings:n}=e;return{formatSettings:n.filter((i,o)=>o!==t),formatRulesChanged:!0}},()=>{this.debouncedCommitChanges()})}handleShowTimeZoneChange(){this.setState(t=>({showTimeZone:!t.showTimeZone}),()=>{this.debouncedCommitChanges()})}handleShowTSeparatorChange(){this.setState(t=>({showTSeparator:!t.showTSeparator}),()=>{this.debouncedCommitChanges()})}handleTimeZoneChange(t){this.setState({timeZone:t.target.value},()=>{this.debouncedCommitChanges()})}handleResetDateTimeFormat(){const{defaults:t}=this.props,{defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s}=t;Ms.debug("handleResetDateTimeFormat"),this.setState({defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s},()=>{this.debouncedCommitChanges()})}handleResetTimeZone(){const{defaults:t}=this.props,{timeZone:e}=t;Ms.debug("handleResetTimeZone"),this.setState({timeZone:e},()=>{this.debouncedCommitChanges()})}handleResetDecimalFormat(){const{defaults:t}=this.props,{defaultDecimalFormatOptions:e}=t;Ms.debug("handleResetDecimalFormat"),this.setState({defaultDecimalFormatOptions:e},()=>{this.debouncedCommitChanges()})}handleResetIntegerFormat(){const{defaults:t}=this.props,{defaultIntegerFormatOptions:e}=t;Ms.debug("handleResetIntegerFormat"),this.setState({defaultIntegerFormatOptions:e},()=>{this.debouncedCommitChanges()})}handleTruncateNumbersWithPoundChange(){this.setState(t=>({truncateNumbersWithPound:!t.truncateNumbersWithPound}),()=>{this.debouncedCommitChanges()})}handleFormatRuleEntered(t){this.scrollToFormatBlockBottom(),rt.focusFirstInputInContainer(t)}commitChanges(){var m;const{formatSettings:t,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,defaultDecimalFormatOptions:o,defaultIntegerFormatOptions:r,truncateNumbersWithPound:l}=this.state,a=(m=t.filter(rt.isFormatRuleValidForSave).map(rt.removeFormatRuleExtraProps))!=null?m:[],{settings:d,saveSettings:c}=this.props,u={...d,formatter:a,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,truncateNumbersWithPound:l};rt.isValidFormat(P.dataType.DECIMAL,Pe.makeCustomFormat(o.defaultFormatString))&&(u.defaultDecimalFormatOptions=o),rt.isValidFormat(P.dataType.INT,nt.makeCustomFormat(r.defaultFormatString))&&(u.defaultIntegerFormatOptions=r),c(u)}scrollToFormatBlockBottom(){var e,n,s,i;const{scrollTo:t}=this.props;t(0,((n=(e=this.addFormatRuleButtonRef.current)==null?void 0:e.offsetHeight)!=null?n:0)+((i=(s=this.addFormatRuleButtonRef.current)==null?void 0:s.offsetTop)!=null?i:0))}getRuleError(t){const e={hasColumnNameError:!1,hasFormatError:!1,message:""},n=[];return t.isNewRule!==void 0&&t.isNewRule||(this.isDuplicateRule(t)&&(e.hasColumnNameError=!0,n.push("Duplicate column name/type combo.")),rt.isValidColumnName(t.columnName)||(e.hasColumnNameError=!0,n.push("Column names must start with a letter or underscore and contain only alphanumeric characters or underscores.")),t.format.formatString!==void 0&&t.format.formatString.length===0?(e.hasFormatError=!0,n.push("Empty formatting rule.")):rt.isValidFormat(t.columnType,t.format)||(e.hasFormatError=!0,n.push("Invalid formatting rule.")),e.message=n.join(`
|
|
43
|
-
`)),e}renderFormatRule(t,e){const n=`input-${t}-columnName`,s=`input-${t}-columnType`,i=`input-${t}-format`,o=this.getCachedColumnTypeOptions(),r=c=>this.handleFormatRuleChange(t,"columnName",c.target.value),l=()=>this.handleFormatRuleChange(t,"isNewRule",!1),a=c=>this.handleFormatRuleChange(t,"columnType",c.target.value),d=this.getRuleError(e);return v("fieldset",{className:"container-fluid format-rule-container",children:[v("div",{className:"form-row",children:[v("div",{className:"form-group col-7 mb-2",children:[h("label",{htmlFor:n,children:"Column Name"}),h("input",{id:n,className:z("form-control",{"is-invalid":d.hasColumnNameError}),"data-lpignore":!0,type:"text",value:e.columnName,onChange:r,onBlur:l})]}),v("div",{className:"form-group col mb-2",children:[h(Q,{kind:"ghost",className:"btn-delete-format-rule float-right",tabIndex:-1,onClick:()=>this.handleFormatRuleDelete(t),icon:_n,tooltip:"Delete"}),h("label",{htmlFor:s,children:"Column Type"}),h("select",{id:s,className:"custom-select",value:e.columnType,onChange:a,children:o})]})]}),h("div",{className:"form-row",children:v("div",{className:"form-group col-12 d-flex mb-2",children:[h("label",{className:"flex-shrink-0 col-form-label mr-3",htmlFor:i,children:"Formatting Rule"}),this.renderFormatRuleInput(t,e.columnType,i,e.format,d.hasFormatError)]})}),h("div",{className:"form-row",children:h("div",{className:"form-group col-12 d-flex mb-2",children:d.message&&h("p",{className:"text-danger",children:d.message})})})]},t)}renderFormatRuleInput(t,e,n,s,i){switch(P.getNormalizedType(e)){case P.dataType.DATETIME:return this.renderDateTimeFormatRuleInput(t,n,s,i);case P.dataType.DECIMAL:return this.renderDecimalFormatRuleInput(t,n,s,i);case P.dataType.INT:return this.renderIntegerFormatRuleInput(t,n,s,i);default:return null}}renderDateTimeFormatRuleInput(t,e,n,s){const{showTimeZone:i,showTSeparator:o,timeZone:r}=this.state,l=n!=null&&n.formatString||"";return v("select",{className:z("custom-select",{"is-invalid":s}),value:l,id:e,onChange:a=>{const d=at.makeFormat("",a.target.value,at.TYPE_GLOBAL);this.handleFormatRuleChange(t,"format",d)},children:[h("option",{value:"",disabled:!0,children:"Select format"},"default"),this.getCachedDateTimeFormatOptions(r,i,o)]})}renderIntegerFormatRuleInput(t,e,n,s){const i=n!=null&&n.formatString||"";return h("input",{className:z("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:e,placeholder:nt.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const r=nt.makeFormat("",o.target.value,nt.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(t,"format",r)}})}renderDecimalFormatRuleInput(t,e,n,s){const i=n!=null&&n.formatString||"";return h("input",{className:z("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:e,placeholder:Pe.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const r=Pe.makeFormat("",o.target.value,Pe.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(t,"format",r)}})}render(){const{defaults:t}=this.props,{formatRulesChanged:e,formatSettings:n,defaultDateTimeFormat:s,defaultDecimalFormatOptions:i,defaultIntegerFormatOptions:o,timeZone:r,showTimeZone:l,showTSeparator:a,truncateNumbersWithPound:d}=this.state,{defaultFormatString:c=Pe.DEFAULT_FORMAT_STRING}=i!=null?i:{},{defaultFormatString:u=nt.DEFAULT_FORMAT_STRING}=o!=null?o:{},m=n.map((w,T)=>h(ht,{classNames:"fade",timeout:Tt.transitionMs,onEnter:this.handleFormatRuleEntered,children:this.renderFormatRule(T,w)},w.id)),p=h(Q,{kind:"ghost",className:"mb-3",onClick:this.handleFormatRuleCreate,ref:this.addFormatRuleButtonRef,icon:Ls,children:"Add New Rule"}),g=r===t.timeZone,f=a===t.showTSeparator&&l===t.showTimeZone&&s===t.defaultDateTimeFormat,b=rt.isSameDecimalOptions(i,t.defaultDecimalFormatOptions),C=rt.isSameIntegerOptions(o,t.defaultIntegerFormatOptions);return v("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:[v("div",{className:"container-fluid p-0",children:[h("div",{children:"Default formatting for column types"}),h("div",{className:"app-settings-menu-description mb-3",children:"Applies a formatting rule to all columns of a set type."}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"select-reset-timezone",children:"Time zone"}),h("div",{className:"col pr-0",children:h("select",{className:"custom-select",value:r,onChange:this.handleTimeZoneChange,id:"select-reset-timezone",children:rt.renderTimeZoneOptions()})}),h("div",{className:"col-1 btn-col",children:h(Q,{kind:"ghost",icon:xi,onClick:this.handleResetTimeZone,tooltip:"Reset Time Zone",className:z("btn-reset","btn-reset-time-zone",{hidden:g})})})]}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"select-default-time-format",children:"DateTime"}),h("div",{className:"col pr-0",children:h("select",{className:"custom-select",value:s,onChange:this.handleDefaultDateTimeFormatChange,id:"select-default-time-format",children:this.getCachedDateTimeFormatOptions(r,l,a,!0,s)})}),h("div",{className:"col-1 btn-col",children:h(Q,{kind:"ghost",icon:xi,onClick:this.handleResetDateTimeFormat,tooltip:"Reset DateTime Options",className:z("btn-reset","btn-reset-date-time",{hidden:f})})})]}),h("div",{className:"form-row",children:h("div",{className:"offset-3 col-9",children:h(Pt,{checked:l!=null?l:null,onChange:this.handleShowTimeZoneChange,children:"Show time zone in dates"})})}),h("div",{className:"form-row mb-3",children:h("div",{className:"offset-3 col-9",children:h(Pt,{checked:a!=null?a:null,onChange:this.handleShowTSeparatorChange,children:"Show 'T' separator"})})}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"default-decimal-format-input",children:"Decimal"}),h("div",{className:"col pr-0",children:h("input",{className:z("form-control","flex-grow-1","default-decimal-format-input",{"is-invalid":!rt.isValidFormat(P.dataType.DECIMAL,Pe.makeCustomFormat(c))}),"data-lpignore":!0,placeholder:Pe.DEFAULT_FORMAT_STRING,type:"text",id:"default-decimal-format-input",value:c,onChange:this.handleDefaultDecimalFormatChange})}),h("div",{className:"col-1 btn-col",children:h(Q,{kind:"ghost",icon:xi,onClick:this.handleResetDecimalFormat,tooltip:"Reset Decimal Formatting",className:z("btn-reset","btn-reset-decimal",{hidden:b}),"data-testid":"btn-reset-decimal"})})]}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"default-integer-format-input",children:"Integer"}),h("div",{className:"col pr-0",children:h("input",{className:z("form-control","flex-grow-1","default-integer-format-input",{"is-invalid":!rt.isValidFormat(P.dataType.INT,nt.makeCustomFormat(u))}),"data-lpignore":!0,placeholder:nt.DEFAULT_FORMAT_STRING,type:"text",id:"default-integer-format-input",value:u,onChange:this.handleDefaultIntegerFormatChange})}),h("div",{className:"col-1 btn-col",children:h(Q,{kind:"ghost",icon:xi,onClick:this.handleResetIntegerFormat,tooltip:"Reset Integer Formatting",className:z("btn-reset","btn-reset-integer",{hidden:C}),"data-testid":"btn-reset-integer"})})]}),h("div",{className:"form-row mb-3",children:h("div",{className:"offset-3 col-9",children:h(Pt,{checked:d!=null?d:null,onChange:this.handleTruncateNumbersWithPoundChange,children:"Truncate numbers with #"})})})]}),h("div",{children:"Default formatting for matched column names"}),h("div",{className:"app-settings-menu-description mb-3",children:"Applies a formatting rule to all columns that match a specified name and type."}),h(hg,{appear:e,enter:e,exit:e,children:m}),p]})}};let ac=rt;ac.defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:at.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:Pe.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:nt.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:at.DEFAULT_TIME_ZONE_ID}};ac.inputDebounceTime=250;const S1=t=>({formatter:fS(t),defaultDateTimeFormat:mS(t),defaultDecimalFormatOptions:pS(t),defaultIntegerFormatOptions:gS(t),showTimeZone:CS(t),showTSeparator:bS(t),truncateNumbersWithPound:SS(t),timeZone:Il(t),settings:Kt(t)}),w1=Dt(S1,{saveSettings:Tm})(ac),v1=()=>{const[t,e]=S.exports.useState(!1),n=()=>{e(!t)};return v(Q,{kind:"ghost",onClick:n,icon:If,children:["Legal Notices",v(Uo,{isOpen:t,toggle:n,className:"theme-bg-light",children:[h($o,{toggle:n,children:"Legal Notice"}),v(Bo,{children:[h("p",{children:"Deephaven software is protected by U.S. Patent Nos. 9,612,959; 9,613,018; 9,613,109; 9,619,210; 9,633,060; 9,639,570; 9,672,238; 9,679,006; 9,690,821; 9,710,511; 9,760,591; 9,805,084; 9,836,495; 9,836,494; 9,886,469; 9,898,496; 9,934,266; 10,002,153; 10,002,154; 10,002,155; 10,003,673; 10,019,138; 10,069,943; 10,176,211; 10,198,465; 10,198,466; 10,198,469; 10,212,257; 10,241,960; 10,241,965; 10,242,040; 10,242,041; 10,353,893; 10,346,394; 10,452,649; 10,496,639; 10,540,351; 10,552,412; 10,565,194; 10,565,206; 10,572,474; 10,621,168; 10,642,829; 10,657,184; 10,678,787; 10,691,686; and 10,783,191. Other patents pending."}),v("p",{children:["\xA9 2016-",new Date().getFullYear()," Deephaven Data Labs LLC. Patent Pending."]})]})]})]})},rl=t=>{const{children:e,isExpanded:n,sectionKey:s,title:i,onToggle:o}=t;return v(ue,{children:[h("div",{children:v(Q,{kind:"ghost",className:"btn-collapse-trigger",onClick:()=>o(s),children:[h("div",{className:"flex-grow-1",children:i}),h("div",{className:"flex-shrink-0",children:h(K,{transform:n?"flip-v":"",icon:ls})})]})}),h(gd,{in:n,autoFocusOnShow:!0,children:e})]})};rl.propTypes={children:D.exports.node,isExpanded:D.exports.bool.isRequired,sectionKey:D.exports.string.isRequired,title:D.exports.node.isRequired,onToggle:D.exports.func};rl.defaultProps={children:null,onToggle:()=>{}};function T1({shortcut:t,displayText:e,categoryName:n,onChange:s}){const[i,o]=S.exports.useState(e),[r,l]=S.exports.useState(t.getKeyState()),[a,d]=S.exports.useState(!1),[c,u]=S.exports.useState("");S.exports.useEffect(function(){o(e),l(t.getKeyState())},[e,t]),S.exports.useEffect(function(){o($t.getDisplayText(r)),t.matchesKeyState(r)&&d(!1)},[r,t]),S.exports.useEffect(function(){if(a){if(!$t.isValidKeyState(r)){$t.isAllowedKey(r.keyValue)?u("Must contain a modifier key"):u("Must contain an allowed action key");return}const y=Be.getConflictingShortcuts(r).filter(E=>E.id.startsWith(n)&&E!==t).map(E=>E.name);if(y.length){u(`Conflicts with ${y.join(", ")}`);return}u("")}else u("")},[a,r,n,t]);function m(T){if(T.stopPropagation(),T.preventDefault(),t.isEditable&&!T.repeat){const y=$t.getKeyStateFromEvent(T),E=$t.createKeyState([ge.BACKSPACE]);$t.doKeyStatesMatch(y,E)?l($t.NULL_KEY_STATE):l(y)}}function p(T){T.stopPropagation(),T.preventDefault(),t.matchesKeyState(r)||d(!0)}function g(){Ne.disableAllActions()}function f(){Ne.enableAllActions()}function b(){t.setKeyState(r),d(!1),s(t)}function C(){const T=t.getKeyState();l(T),d(!1)}function w(){d(!0),l(t.getDefaultKeyState())}return v(ue,{children:[v("div",{className:"shortcut-item-container",children:[v("label",{className:"shortcut-item-name",children:[t.name,t.tooltip!==void 0&&h(Ie,{children:t.tooltip})]}),v("div",{className:"shortcut-item-input-container",children:[h("input",{className:z("form-control",{"is-invalid":c}),onKeyDown:m,onKeyUp:p,onFocus:g,onBlur:f,disabled:!t.isEditable,value:i,readOnly:!0}),!$t.doKeyStatesMatch(r,t.getDefaultKeyState())&&!c&&h(Q,{className:"reset-to-default-button",kind:"ghost",icon:h(K,{icon:xi,transform:{rotate:90,flipX:!0}}),tooltip:"Reset to default",onClick:w})]})]}),a&&v("div",{className:z("shortcut-item-message-container",{"is-invalid":c}),children:[h("div",{className:"shortcut-item-message",children:c}),v("div",{className:"shortcut-item-message-buttons",children:[$t.isValidKeyState(r)&&h(Q,{kind:"ghost",onClick:b,children:"Confirm"}),h(Q,{kind:"ghost",onClick:C,children:"Undo"})]})]})]})}function E1({shortcutOverrides:t={},settings:e,saveSettings:n}){const s=S.exports.useCallback(l=>{const a=$t.isMacPlatform,d={mac:{...t.mac},windows:{...t.windows}},c=a?d.mac:d.windows;l.forEach(u=>{u.isDefault()?delete c[u.id]:c[u.id]=u.getKeyState()}),n({...e,shortcutOverrides:d})},[e,n,t]);let i=Array.from(Be.shortcutsByCategory.entries()).map(([l,a])=>({name:l,shortcuts:a}));const o=i.findIndex(l=>l.name.toUpperCase()==="GLOBAL"),r=i.splice(o,1);return i=i.concat(r),v(ue,{children:[h("div",{className:"app-settings-menu-description",children:"Customize shortcuts below. Assigning shortcuts that conflict with the browser or IDE shortcuts may cause unintended behavior"}),i.map(l=>h(y1,{name:l.name,shortcuts:l.shortcuts,saveShortcutOverrides:s},l.name))]})}function y1({name:t,shortcuts:e,saveShortcutOverrides:n}){function s(a){return a.split("_").map(d=>`${d[0].toUpperCase()}${d.slice(1).toLowerCase()}`).join(" ")}const[i,o]=S.exports.useState(e);function r(a){const d=i.filter(u=>u!==a&&!u.isNull()&&u.matchesKeyState(a.getKeyState()));d.forEach(u=>u.setToNull());const c=[a,...d];n(c),o(u=>[...u])}const l=S.exports.useMemo(()=>i.map(a=>a.getDisplayText()),[i]);return v("div",{className:"mt-3",children:[h("div",{className:"font-weight-bold",children:s(t)}),i.map((a,d)=>h(T1,{shortcut:a,displayText:l[d],categoryName:t,onChange:r},a.id))]})}const I1=t=>({settings:Kt(t),shortcutOverrides:wS(t)}),R1={saveSettings:Tm},D1=Dt(I1,R1)(E1),Xa=new ef,ja=new zr(Xa);function M1(){X.setLogLevel(parseInt("2",10)),Xa.enable(),ja.enable(),window!=null&&(window.DHLog=X,window.DHLogProxy=Xa,window.DHLogHistory=ja)}const N1="yyyy-MM-dd-HHmmss";function $p(t,e="root",n=new Map([[t,""]])){const s={};return Object.entries(t).forEach(([i,o])=>{try{JSON.stringify(o),s[i]=o}catch{const l=o;if(typeof o=="bigint")s[i]=o.toString();else if(n.has(l))s[i]=`Circular ref to ${n.get(l)}`;else{const a=`${e}.${i}`;n.set(l,a),s[i]=$p(o,a,n)}}}),s}function F1(){const t=Ml.getState();return JSON.stringify($p(t),null,2)}function x1(){const t={uiVersion:"0.21.0",userAgent:navigator.userAgent};return JSON.stringify(t,null,2)}async function _1(t=`${M.i18n.DateTimeFormat.format(N1,new Date)}_support_logs`){const e=new iu,n=e.folder(t);n.file("console.txt",ja.getFormattedHistory()),n.file("redux.json",F1()),n.file("metadata.json",x1());const s=await e.generateAsync({type:"blob"}),i=document.createElement("a");i.href=URL.createObjectURL(s),i.download=`${t}.zip`,i.click()}const xs=class extends S.exports.Component{constructor(t){super(t),this.handleClose=this.handleClose.bind(this),this.handleScrollTo=this.handleScrollTo.bind(this),this.handleSectionToggle=this.handleSectionToggle.bind(this),this.menuContentRef=Y.createRef(),this.state={expandedSectionKey:xs.FORMATTING_SECTION_KEY}}static focusFirstInputInContainer(t){const e=t==null?void 0:t.querySelector("input, select, textarea");e&&e.focus()}static handleExportSupportLogs(){_1()}componentDidMount(){xs.focusFirstInputInContainer(this.menuContentRef.current)}isSectionExpanded(t){const{expandedSectionKey:e}=this.state;return e===t}handleScrollTo(t,e){var n;(n=this.menuContentRef.current)==null||n.scrollTo(t,e)}handleSectionToggle(t){this.setState(e=>({expandedSectionKey:e.expandedSectionKey===t?void 0:t}))}handleClose(){const{onDone:t}=this.props;t()}render(){const t="0.21.0",e="https://github.com/deephaven/web-client-ui/",n="https://deephaven.io/core/docs/";return v("div",{className:"app-settings-menu",children:[v("header",{className:"app-settings-menu-header",children:[h("div",{className:"flex-spacer"}),h(Q,{kind:"ghost",className:"btn-close-settings-menu",onClick:this.handleClose,icon:h(K,{icon:Yi,transform:"grow-4"}),tooltip:"Close"})]}),v("div",{className:"app-settings-menu-content",ref:this.menuContentRef,children:[h("h5",{children:"Settings"}),h("hr",{className:"my-0"}),h(rl,{sectionKey:xs.FORMATTING_SECTION_KEY,isExpanded:this.isSectionExpanded(xs.FORMATTING_SECTION_KEY),title:v(ue,{children:[h(K,{icon:Hf,transform:"grow-4",className:"mr-2"}),"Formatting & Time zone"]}),onToggle:this.handleSectionToggle,children:h(w1,{scrollTo:this.handleScrollTo})}),h(rl,{sectionKey:xs.SHORTCUT_SECTION_KEY,isExpanded:this.isSectionExpanded(xs.SHORTCUT_SECTION_KEY),title:v(ue,{children:[h(K,{icon:_f,transform:"grow-2"})," ","Keyboard Shortcuts"]}),onToggle:this.handleSectionToggle,children:h(D1,{})}),v("div",{className:"app-settings-footer",children:[v("div",{className:"app-settings-footer-section",children:[v("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Support"}),v("div",{children:["GitHub:\xA0",h("a",{href:e,className:"custom-link",target:"_blank",rel:"noopener noreferrer",children:e})]}),h(Q,{kind:"tertiary",className:"mt-2 py-2",onClick:xs.handleExportSupportLogs,children:"Export Logs"})]}),v("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Documentation"}),h("a",{target:"_blank",rel:"noreferrer noopener",href:n,className:"custom-link",children:n})]}),h("div",{className:"app-settings-footer-item",children:v("div",{className:"text-muted",children:["Version ",t]})}),h("div",{className:"app-settings-footer-item",children:h(v1,{})})]}),h("div",{className:"app-settings-footer-section",children:h("div",{className:"logo",children:h("a",{target:"_blank",rel:"noreferrer noopener",href:"https://deephaven.io",className:"d-inline-block custom-link p-1",children:h("img",{src:Bp,alt:"Deephaven Data Labs",width:"230px"})})})})]})]})]})}};let Qo=xs;Qo.defaultProps={onDone:()=>{}};Qo.FORMATTING_SECTION_KEY="SettingsMenu.formatting";Qo.APPLICATION_SECTION_KEY="ApplicationMenu.settings";Qo.SHORTCUT_SECTION_KEY="SettingsMenu.shortcuts";const jh=10,Oi=t=>{const{forwardedProps:{menuItem:{action:e,title:n,disabled:s},iconElement:i,displayShortcut:o,isMouseSelected:r,isKeyboardSelected:l,closeMenu:a}}=t,d=S.exports.useRef(),c=S.exports.useRef(),u=S.exports.useRef(null),[m,p]=S.exports.useState(!1),g=S.exports.useCallback(C=>{d.current!=null&&c.current!=null&&u.current&&(Math.abs(d.current-C.clientX)>=jh||Math.abs(c.current-C.clientY)>=jh)&&(p(!0),window.removeEventListener("mousemove",g),a(),e(C),u.current=null)},[e,a]);function f(C){d.current=C.clientX,c.current=C.clientY,u.current=C.target,window.addEventListener("mousemove",g)}function b(C){u.current===C.target&&(p(!0),a(),e(),window.removeEventListener("mousemove",g)),u.current=null}return S.exports.useEffect(function(){return function(){return window.removeEventListener("mousemove",g)}},[g]),v("button",{type:"button",className:z("btn-context-menu",{disabled:s},{active:r&&!s},{"keyboard-active":l&&!s}),onMouseDown:f,onMouseUp:b,disabled:m,children:[h("span",{className:z("icon"),children:i}),h("span",{className:"title",children:n}),h("span",{className:"shortcut",children:o})]})},dc=t=>{const{handleControlSelect:e,handleToolSelect:n,onClearFilter:s}=t,i=S.exports.useMemo(()=>[{title:"Input Filter",icon:Qf,menuElement:h(Oi,{}),action:o=>{e(fn.INPUT_FILTER,o)},order:10},{title:"Dropdown Filter",icon:bu,menuElement:h(Oi,{}),action:o=>{e(fn.DROPDOWN_FILTER,o)},order:15},{title:"Markdown Widget",icon:Nf,menuElement:h(Oi,{}),action:o=>{e(fn.MARKDOWN,o)},order:20},{title:"Filter Sets",icon:ya,menuElement:h(Oi,{}),action:o=>{e(fn.FILTER_SET_MANAGER,o)},order:25},{disabled:!0,menuElement:h("div",{className:"context-menu-group-header",children:"Tools"}),order:30},{title:"Linker",icon:rd,action:()=>{n(dn.LINKER)},order:40,shortcut:Os.LINKER},{disabled:!0,menuElement:h("div",{className:"context-menu-group-header",children:"Actions"}),order:50},{title:"Clear All Filters",icon:qf,action:()=>{s()},order:60,shortcut:ln.TABLE.CLEAR_ALL_FILTERS}],[e,n,s]);return h(Wn,{popperClassName:"controls-menu-popper",actions:i})};dc.propTypes={handleControlSelect:D.exports.func,handleToolSelect:D.exports.func,onClearFilter:D.exports.func};dc.defaultProps={handleControlSelect:()=>{},handleToolSelect:()=>{},onClearFilter:()=>{}};Oi.propTypes={forwardedProps:D.exports.shape({iconElement:D.exports.node,displayShortcut:D.exports.string,isMouseSelected:D.exports.bool.isRequired,isKeyboardSelected:D.exports.bool.isRequired,closeMenu:D.exports.func.isRequired,menuItem:D.exports.shape({action:D.exports.func,title:D.exports.string,disabled:D.exports.bool}).isRequired})};Oi.defaultProps={forwardedProps:null};const k1=fi(Up,null),O1={layoutStorage:k1},L1=t=>t.layoutStorage;Object.entries(O1).map(([t,e])=>Zi.register(t,e));const Qh=10,A1=t=>{const{onExportLayout:e,onImportLayout:n,onResetLayout:s,onSelect:i,widgets:o=[]}=t,[r,l]=S.exports.useState(!1),[a,d]=S.exports.useState(""),c=S.exports.useRef(null),u=S.exports.useRef(),m=S.exports.useCallback((y,E)=>{y!=null&&i(y,E)},[i]),p=S.exports.useCallback(y=>{d(y.target.value)},[]),g=S.exports.useCallback(y=>{u.current!=null&&(Math.abs(u.current.x-y.clientX)>=Qh||Math.abs(u.current.y-y.clientY)>=Qh)&&(l(!0),window.removeEventListener("mousemove",g),m(u.current.widget,y),u.current=void 0)},[u,m]),f=S.exports.useCallback((y,E)=>{u.current={x:y.clientX,y:y.clientY,widget:E},window.addEventListener("mousemove",g)},[g]),b=S.exports.useCallback((y,E)=>{var I;window.removeEventListener("mousemove",g),((I=u.current)==null?void 0:I.widget)===E&&(l(!0),m(E)),u.current=void 0},[g,u,m]),C=S.exports.useMemo(()=>o.filter(y=>{var E;return a?(E=y.name)==null?void 0:E.toLowerCase().includes(a.toLowerCase()):!0}),[a,o]).sort((y,E)=>{var I,R,F;return(F=(R=y.name)==null?void 0:R.localeCompare((I=E.name)!=null?I:""))!=null?F:0}),w=S.exports.useMemo(()=>C.map(y=>{var E,I;return h("li",{children:v(Q,{kind:"ghost","data-testid":`panel-list-item-${(E=y.name)!=null?E:""}-button`,onMouseDown:R=>{f(R,y)},onMouseUp:R=>{b(R,y)},onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&m(y)},disabled:r,onClick:()=>{},children:[h($u,{type:y.type})," ",(I=y.name)!=null?I:""]})},y.name)}),[C,r,f,b,m]),T=S.exports.useMemo(()=>w.length===0?h("span",{children:"No bound variables found."}):null,[w]);return v("div",{className:"widget-list-container d-flex flex-column",children:[h("div",{className:"widget-list-header",children:h(gs,{value:a,placeholder:"Find Table, Plot or Widget",onChange:p,ref:c})}),v("ul",{className:"widget-list flex-grow-1",children:[T&&h("li",{className:"widget-list-message",children:T}),!T&&w]}),h("div",{children:h("hr",{})}),v("div",{className:"widget-list-footer",children:[v(Q,{kind:"ghost",onClick:e,children:[v("div",{className:"fa-md fa-layers",children:[h(K,{mask:Ia,icon:Ic,transform:"right-5 down-5"}),h(K,{icon:Ic,transform:"right-8 down-6"})]}),"Export Layout"]}),v(Q,{kind:"ghost",onClick:n,children:[v("div",{className:"fa-md fa-layers",children:[h(K,{mask:Ia,icon:Ea,transform:"right-5 down-5"}),h(K,{icon:Ea,transform:"right-8 down-6"})]}),"Import Layout"]}),h(Q,{kind:"ghost",icon:xi,onClick:s,tooltip:"Reset Layout"})]})]})},P1=async(t,e,n)=>{let s,i,o,r;if(Pr(e)?(s=e.settings,i=e.table,o=void 0,r=e.tableSettings):(s={},i="",o=e.figure,r={}),n!==void 0&&(n.tableSettings!=null&&(r=n.tableSettings),n.table!=null&&(i=n.table),n.figure!=null&&(o=n.figure),n.settings!=null&&(s={...s,...n.settings})),o!==void 0){const d={title:o,name:o,type:M.VariableType.FIGURE},c=await t.getObject(d);return zi.makeModel(s,c)}const l={title:o,name:i,type:M.VariableType.TABLE},a=await t.getObject(l);return se.applyTableSettings(a,r,Il(Ml.getState())),zi.makeModelFromSettings(s,a)},H1=async(t,e,n=M.VariableType.TABLE)=>{const{table:s}=e,i={title:s,name:s,type:n},o=await t.getObject(i);return Gd.makeModel(o)};const V1=({onAutoFillClick:t=()=>{}})=>v("div",{className:"empty-dashboard-container",children:[v("div",{className:"hint-container",children:[h(K,{icon:hf})," ",h("br",{}),"Use the panel list to add objects from a query."]}),v("div",{className:"empty-dashboard",children:[h("div",{className:"add-panels-hint",children:"Drag Panels Here"}),h(Q,{kind:"tertiary",onClick:t,children:"Auto fill objects"})]})]});function U1(t){return t.version===2}function B1(t){return Array.isArray(t)}const xr=X.module("UserLayoutUtils"),$1={layoutConfig:[{type:"column",content:[{type:"row",content:[{type:"stack",content:[{type:"react-component",component:ki.COMPONENT,title:ki.TITLE,isClosable:!1},{type:"react-component",component:ol.COMPONENT,title:ol.TITLE,isClosable:!1}]},{type:"stack",width:25,content:[{type:"react-component",component:nl.COMPONENT,title:nl.TITLE,isClosable:!1},{type:"react-component",component:sl.COMPONENT,title:sl.TITLE,isClosable:!1}]}]},{type:"row",content:[{type:"stack",title:"Notebooks",content:[]}]}]}],links:[],filterSets:[],version:2},z1={layoutConfig:[],links:[],filterSets:[],version:2};function zp(t){if(U1(t))return t;if(B1(t))return{layoutConfig:t,links:[],filterSets:[],version:2};throw new Error(`Unexpected layout import format: ${t}`)}async function W1(t,e=!0){try{const n=await t.getLayouts();if(n.length>0)try{const s=await t.getLayout(n[0]);return zp(s)}catch(s){xr.error("Unable to load layout",n[0],":",s),xr.warn("No valid layouts found, falling back to default layout")}}catch(n){xr.error("Unable to fetch layout list",n),xr.warn("Falling back to default layout")}return e?$1:z1}function G1(t){const{filterSets:e,layoutConfig:n,links:s}=t;return{filterSets:e,layoutConfig:n,links:s,version:2}}const Br={exportLayout:G1,getDefaultLayout:W1,normalizeLayout:zp},_r=X.module("DownloadServiceWorkerUtils"),Wp=class{static registerOnLoaded(){new URL("/ide/",window.location.href).origin===window.location.origin&&("serviceWorker"in navigator?window.addEventListener("load",()=>{const e=new URL("/ide/download/serviceWorker.js",window.location.href);navigator.serviceWorker.register(e).then(n=>{n.update(),_r.info("Registering service worker on ",e,n)}).catch(n=>{_r.error("Failed to register service worker",n)})}):_r.info("Service worker is not supported."))}static async getServiceWorker(){if("serviceWorker"in navigator){const e=(await navigator.serviceWorker.getRegistrations()).find(n=>n.scope.endsWith(Wp.DOWNLOAD_PATH));if(e&&e.active)return _r.info("Download service worker is active."),e.active;throw new Error("Can not find download service worker.")}throw new Error("Download service worker is not available.")}static unregisterSW(){}};let ll=Wp;ll.DOWNLOAD_PATH="/download/";const Gp={react:Y},K1=ug(Gp),q1=mg({requires:K1}),Y1=pg.createRequires(Gp),X1=gg({requires:Y1}),j1=X.module("PluginUtils");class Qa{static loadComponentPlugin(e){if("".split(",").includes(e)){const o=Y.lazy(()=>vg(()=>import(`./internal/${e}`),[])),r=Y.forwardRef((l,a)=>h(S.exports.Suspense,{fallback:h("div",{children:"Loading Plugin..."}),children:h(o,{ref:a,...l})}));return r.pluginName=e,r.displayName="Local Plugin",r}const n=new URL("/ide/plugins/",`${window.location}`),s=new URL(`${e}.js`,n),i=Y.forwardRef((o,r)=>h(q1,{url:s,render:({err:l,Component:a})=>{if(l!=null&&l!==""){const d=`Error loading plugin ${e} from ${s} due to ${l}`;return j1.error(d),h("div",{className:"error-message",children:`${d}`})}return h(a,{ref:r,...o})}}));return i.pluginName=e,i.displayName="Plugin",i}static async loadModulePlugin(e){return await X1(e)}static async loadJson(e){return new Promise((n,s)=>{const i=new XMLHttpRequest;i.addEventListener("load",()=>{try{const o=JSON.parse(i.responseText);n(o)}catch(o){s(o)}}),i.addEventListener("error",o=>{s(o)}),i.open("GET",e),i.send()})}}const _t=X.module("AppMainContainer");class Oo extends S.exports.Component{constructor(e){super(e),this.getDashboardPlugins=he(n=>[...n.entries()].filter(([,{DashboardPlugin:s}])=>s).map(([s,{DashboardPlugin:i}])=>h(i,{},s))),this.handleSettingsMenuHide=this.handleSettingsMenuHide.bind(this),this.handleSettingsMenuShow=this.handleSettingsMenuShow.bind(this),this.handleError=this.handleError.bind(this),this.handleControlSelect=this.handleControlSelect.bind(this),this.handleToolSelect=this.handleToolSelect.bind(this),this.handleClearFilter=this.handleClearFilter.bind(this),this.handleDataChange=this.handleDataChange.bind(this),this.handleAutoFillClick=this.handleAutoFillClick.bind(this),this.handleGoldenLayoutChange=this.handleGoldenLayoutChange.bind(this),this.handleLayoutConfigChange=this.handleLayoutConfigChange.bind(this),this.handleExportLayoutClick=this.handleExportLayoutClick.bind(this),this.handleImportLayoutClick=this.handleImportLayoutClick.bind(this),this.handleImportLayoutFiles=this.handleImportLayoutFiles.bind(this),this.handleLoadTablePlugin=this.handleLoadTablePlugin.bind(this),this.handleResetLayoutClick=this.handleResetLayoutClick.bind(this),this.handleWidgetMenuClick=this.handleWidgetMenuClick.bind(this),this.handleWidgetsMenuClose=this.handleWidgetsMenuClose.bind(this),this.handleWidgetSelect=this.handleWidgetSelect.bind(this),this.handlePaste=this.handlePaste.bind(this),this.hydrateChart=this.hydrateChart.bind(this),this.hydrateGrid=this.hydrateGrid.bind(this),this.hydratePandas=this.hydratePandas.bind(this),this.hydrateDefault=this.hydrateDefault.bind(this),this.openNotebookFromURL=this.openNotebookFromURL.bind(this),this.importElement=Y.createRef(),this.state={contextActions:[{action:()=>{this.handleToolSelect(dn.LINKER)},shortcut:Os.LINKER,isGlobal:!0},{action:()=>{this.sendClearFilter()},shortcut:ln.TABLE.CLEAR_ALL_FILTERS,isGlobal:!0},{action:()=>{_t.debug("Consume unhandled save shortcut")},shortcut:Os.SAVE,isGlobal:!0}],isPanelsMenuShown:!1,isSettingsMenuShown:!1,widgets:[]}}static handleWindowBeforeUnload(e){e.preventDefault(),e.returnValue=""}static hydrateConsole(e,n){return Pa.hydrate({...e,unzip:s=>iu.loadAsync(s).then(i=>Object.values(i.files))},n)}componentDidMount(){this.initWidgets(),window.addEventListener("beforeunload",Oo.handleWindowBeforeUnload)}componentDidUpdate(e){const{dashboardData:n}=this.props;e.dashboardData!==n&&this.handleDataChange(n)}componentWillUnmount(){this.deinitWidgets(),window.removeEventListener("beforeunload",Oo.handleWindowBeforeUnload)}initWidgets(){const{connection:e}=this.props;if(e.subscribeToFieldUpdates==null){_t.warn("subscribeToFieldUpdates not supported, not initializing widgets");return}this.widgetListenerRemover=e.subscribeToFieldUpdates(n=>{_t.debug("Got updates",n),this.setState(({widgets:s})=>{const{updated:i,created:o,removed:r}=n,l=[...i,...r],a=s.filter(c=>!l.some(u=>u.name===c.name));return[...i,...o].forEach(c=>{c.name!=null&&c.name!==""&&a.push(c)}),{widgets:a}})})}deinitWidgets(){var e;(e=this.widgetListenerRemover)==null||e.call(this)}openNotebookFromURL(){const{match:e}=this.props,{notebookPath:n}=e.params;if(n){const{session:s,sessionConfig:i}=this.props;if(s==null||i==null){_t.error("No session available to open notebook URL",n);return}const o={id:`/${n}`,itemName:`/${n}`},r=i.type,l={value:null,language:r};this.emitLayoutEvent(Ve.SELECT_NOTEBOOK,s,r,l,o,!0)}}sendClearFilter(){this.emitLayoutEvent(He.CLEAR_ALL_FILTERS)}emitLayoutEvent(e,...n){var s;(s=this.goldenLayout)==null||s.eventHub.emit(e,...n)}handleError(e){Ee.isCanceled(e)||_t.error(e)}handleSettingsMenuHide(){this.setState({isSettingsMenuShown:!1})}handleSettingsMenuShow(){this.setState({isSettingsMenuShown:!0})}handleControlSelect(e,n=null){switch(_t.debug("handleControlSelect",e),e){case fn.DROPDOWN_FILTER:this.emitLayoutEvent(He.OPEN_DROPDOWN,{title:"DropdownFilter",type:e,createNewStack:!0,dragEvent:n});break;case fn.INPUT_FILTER:this.emitLayoutEvent(He.OPEN_INPUT,{title:"InputFilter",type:e,createNewStack:!0,dragEvent:n});break;case fn.MARKDOWN:this.emitLayoutEvent(wp.OPEN,{title:"Markdown",type:e,dragEvent:n});break;case fn.FILTER_SET_MANAGER:this.emitLayoutEvent(He.OPEN_FILTER_SET_MANAGER,{title:"FilterSets",type:e,dragEvent:n});break;default:throw new Error(`Unrecognized control type ${e}`)}}handleToolSelect(e){_t.debug("handleToolSelect",e);const{activeTool:n,setActiveTool:s}=this.props;s(n===e?dn.DEFAULT:e)}handleClearFilter(){this.sendClearFilter()}handleDataChange(e){const{updateWorkspaceData:n}=this.props,{closed:s,filterSets:i,links:o}=e;n({closed:s,filterSets:i,links:o})}handleGoldenLayoutChange(e){this.goldenLayout=e}handleLayoutConfigChange(e){const{updateWorkspaceData:n}=this.props;n({layoutConfig:e})}handleWidgetMenuClick(){this.setState(({isPanelsMenuShown:e})=>({isPanelsMenuShown:!e}))}handleWidgetSelect(e,n){this.setState({isPanelsMenuShown:!1}),_t.debug("handleWidgetSelect",e,n),this.openWidget(e,n)}handleWidgetsMenuClose(){this.setState({isPanelsMenuShown:!1})}handleAutoFillClick(){const{widgets:e}=this.state;_t.debug("handleAutoFillClick",e);const n=e.sort((s,i)=>s.title!=null&&i.title!=null?s.title.localeCompare(i.title):0);for(let s=0;s<n.length;s+=1)this.openWidget(n[s])}handleExportLayoutClick(){_t.info("handleExportLayoutClick"),this.setState({isPanelsMenuShown:!1});try{const{workspace:e}=this.props,{data:n}=e,s=Br.exportLayout(n);_t.info("handleExportLayoutClick exportedConfig",s);const i=new Blob([JSON.stringify(s)],{type:"application/json"}),o=M.i18n.DateTimeFormat.format("yyyy-MM-dd-HHmmss",new Date),r=document.createElement("a");r.href=URL.createObjectURL(i),r.download=`deephaven-app-layout-${o}.json`,r.click()}catch(e){_t.error("Unable to export layout",e)}}handleImportLayoutClick(){_t.info("handleImportLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.importElement.current!=null&&(this.importElement.current.value="",this.importElement.current.click())}handleResetLayoutClick(){_t.info("handleResetLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.resetLayout()}handleImportLayoutFiles(e){var n;e.stopPropagation(),e.preventDefault(),e.target.files!=null&&this.importLayoutFile((n=e.target.files)==null?void 0:n[0])}async importLayoutFile(e){try{const{updateDashboardData:n,updateWorkspaceData:s}=this.props,i=await e.text(),o=JSON.parse(i),{filterSets:r,layoutConfig:l,links:a}=Br.normalizeLayout(o);s({layoutConfig:l}),n(Rn,{filterSets:r,links:a})}catch(n){_t.error("Unable to import layout",n)}}async resetLayout(){const{layoutStorage:e,session:n}=this.props,{filterSets:s,layoutConfig:i,links:o}=await Br.getDefaultLayout(e,n!==void 0),{updateDashboardData:r,updateWorkspaceData:l}=this.props;l({layoutConfig:i}),r(Rn,{filterSets:s,links:o})}handlePaste(e){let n=e.currentTarget.parentElement;for(;n!=null;){if(n.classList.contains("monaco-editor"))return;n=n.parentElement}const{clipboardData:s}=e,i=s.getData("Text"),o=/“|”/g;o.test(i)&&(e.preventDefault(),e.stopPropagation(),document.execCommand("insertText",!1,i.replace(o,'"')))}handleLoadTablePlugin(e){const{plugins:n}=this.props,s=n.get(e);return s!=null&&s.TablePlugin!=null?s.TablePlugin:Qa.loadComponentPlugin(e)}hydrateDefault(e,n){const{connection:s}=this.props,{metadata:i}=e;if((i==null?void 0:i.type)!=null&&((i==null?void 0:i.id)!=null||(i==null?void 0:i.name)!=null)){const o=i.id!=null?{type:i.type,id:i.id}:{type:i.type,name:i.name,title:i.name};return{fetch:()=>s.getObject(o),localDashboardId:n,...e}}return Pa.hydrate(e,n)}hydrateGrid(e,n){return this.hydrateTable(e,n,M.VariableType.TABLE)}hydratePandas(e,n){return this.hydrateTable(e,n,M.VariableType.PANDAS)}hydrateTable(e,n,s=M.VariableType.TABLE){const{connection:i}=this.props;return{...e,getDownloadWorker:ll.getServiceWorker,loadPlugin:this.handleLoadTablePlugin,localDashboardId:n,makeModel:()=>H1(i,e.metadata,s)}}hydrateChart(e,n){const{connection:s}=this.props;return{...e,localDashboardId:n,makeModel:()=>{const{metadata:i,panelState:o}=e;return P1(s,i,o)}}}openWidget(e,n){const{connection:s}=this.props;this.emitLayoutEvent(Me.OPEN,{dragEvent:n,fetch:()=>s.getObject(e),widget:e})}render(){const{activeTool:e,plugins:n,user:s,workspace:i}=this.props,{data:o}=i,{layoutConfig:r}=o,{permissions:l}=s,{canUsePanels:a}=l,{contextActions:d,isPanelsMenuShown:c,isSettingsMenuShown:u,widgets:m}=this.state,p=this.getDashboardPlugins(n);return v("div",{className:z("app-main-tabs","w-100","h-100","d-flex","flex-column",e?`active-tool-${e.toLowerCase()}`:""),onPaste:this.handlePaste,tabIndex:-1,children:[h("nav",{className:"nav-container",children:v("div",{className:"app-main-top-nav-menus",children:[h("img",{src:Bp,alt:"Deephaven Data Labs",width:"115px",className:"ml-1"}),v("div",{children:[v(Q,{kind:"ghost",className:"btn-panels-menu",icon:sC,onClick:()=>{},children:["Controls",h(dc,{handleControlSelect:this.handleControlSelect,handleToolSelect:this.handleToolSelect,onClearFilter:this.handleClearFilter})]}),a&&v(Q,{kind:"ghost",className:"btn-panels-menu btn-show-panels","data-testid":"app-main-panels-button",onClick:this.handleWidgetMenuClick,icon:Jf,children:["Panels",h(xn,{isShown:c,className:"panels-menu-popper",onExited:this.handleWidgetsMenuClose,closeOnBlur:!0,interactive:!0,children:h(A1,{widgets:m,onExportLayout:this.handleExportLayoutClick,onImportLayout:this.handleImportLayoutClick,onResetLayout:this.handleResetLayoutClick,onSelect:this.handleWidgetSelect})})]}),h(Q,{kind:"ghost",className:z("btn-settings-menu",{"text-warning":s.operateAs!==s.name}),onClick:this.handleSettingsMenuShow,icon:h(K,{icon:zo,transform:"grow-3 right-1 down-1"}),tooltip:"User Settings"})]})]})}),v(f0,{emptyDashboard:h(V1,{onAutoFillClick:this.handleAutoFillClick}),id:Rn,layoutConfig:r,onGoldenLayoutChange:this.handleGoldenLayoutChange,onLayoutConfigChange:this.handleLayoutConfigChange,onLayoutInitialized:this.openNotebookFromURL,hydrate:this.hydrateDefault,children:[h(QE,{hydrate:this.hydrateGrid,getDownloadWorker:ll.getServiceWorker,loadPlugin:this.handleLoadTablePlugin}),h(GE,{hydrate:this.hydrateChart}),h(KE,{}),h(YE,{hydrateConsole:Oo.hydrateConsole,notebooksUrl:new URL("/notebooks/",`${window.location}`).href}),h(XE,{}),h(i1,{hydrate:this.hydratePandas}),h(s1,{}),h(n1,{}),p]}),h(ht,{in:u,timeout:Tt.transitionMidMs,classNames:"slide-left",mountOnEnter:!0,unmountOnExit:!0,children:h(Qo,{onDone:this.handleSettingsMenuHide})}),h(oe,{actions:d}),h("input",{ref:this.importElement,type:"file",accept:".json",style:{display:"none"},onChange:this.handleImportLayoutFiles})]})}}const Q1=t=>{var e,n;return{activeTool:Rl(t),dashboardData:qt(t,Rn),layoutStorage:L1(t),plugins:vS(t),connection:iE(t,Rn),session:(e=gi(t,Rn))==null?void 0:e.session,sessionConfig:(n=gi(t,Rn))==null?void 0:n.config,user:cm(t),workspace:yl(t)}},Z1=Dt(Q1,{setActiveTool:Dl,updateDashboardData:qn,updateWorkspaceData:vm})(fg(Oo)),J1=()=>v("div",{className:"app",children:[h(Z1,{}),h(yu,{})]}),e2=X.module("LocalWorkspaceStorage"),No=class{static async makeDefaultWorkspaceData(t,e){const{filterSets:n,links:s,layoutConfig:i}=await Br.getDefaultLayout(t,e==null?void 0:e.isConsoleAvailable);return{settings:{defaultDateTimeFormat:at.DEFAULT_DATETIME_FORMAT_STRING,formatter:[],timeZone:at.DEFAULT_TIME_ZONE_ID,showTimeZone:!1,showTSeparator:!0,disableMoveConfirmation:!1,defaultDecimalFormatOptions:{defaultFormatString:Pe.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:nt.DEFAULT_FORMAT_STRING},truncateNumbersWithPound:!1},layoutConfig:i,closed:[{}],links:s,filterSets:n}}static async makeDefaultWorkspace(t,e){return{data:await No.makeDefaultWorkspaceData(t,e)}}constructor(t){this.layoutStorage=t}async load(t){var e;try{return JSON.parse((e=localStorage.getItem(No.STORAGE_KEY))!=null?e:"")}catch{return e2.info("Unable to load workspace data, initializing to default data"),No.makeDefaultWorkspace(this.layoutStorage,t)}}async save(t){return localStorage.setItem(No.STORAGE_KEY,JSON.stringify(t)),t}};let Kp=No;Kp.STORAGE_KEY="deephaven.WorkspaceStorage";class t2 extends Error{constructor(){super(...arguments),this.isNoConsolesError=!0}}function n2(t){return t.isNoConsolesError}const Li=X.module("SessionUtils");function s2(){return new URL("/jsapi",`${window.location}`)}function qp(){const t=s2();return`${t.protocol}//${t.host}`}function i2(){const t=qp();return Li.info(`Starting connection to '${t}'...`),new M.IdeConnection(t)}async function o2(t){Li.info("Getting console types...");const e=await t.getConsoleTypes();if(Li.info("Available types:",e),e.length===0)throw new t2("No console types available");const n=e[0];Li.info("Starting session with type",n);const s=await t.startSession(n),i={type:n,id:We.generate()};return Li.info("Console session established",i),{session:s,config:i,connection:t}}function r2(){const t=qp();return Li.info("createCoreClient",t),new M.CoreClient(t)}class l2{constructor(e,n=""){this.storageService=e,this.root=n}async getLayouts(){return(await this.storageService.listItems(this.root,"*.json")).map(n=>n.basename)}async getLayout(e){const s=await(await this.storageService.loadFile(`${this.root}/${e}`)).text();return JSON.parse(s)}}const vo=X.module("GrpcFileStorageTable"),Za=class{constructor(t,e="",n=e){this.currentSize=0,this.listeners=[],this.childTables=new Map,this.storageService=t,this.baseRoot=e,this.root=n,n===e&&(this.doRefresh=Xe(this.doRefresh.bind(this),Za.REFRESH_DEBOUNCE))}removeBaseRoot(t){return de.removeRoot(this.baseRoot,t)}getViewportData(){var t;return this.viewportUpdatePromise||this.refreshInternal(),(t=this.viewportUpdatePromise)!=null?t:Promise.resolve({items:[],offset:0})}getSnapshot(t){throw new Error("Method not implemented.")}get size(){return this.currentSize}setExpanded(t,e){const n=t.split("/");let s=n.shift();if((s===void 0||s==="")&&(s=n.shift()),s===void 0||s==="")throw new Error(`Invalid path: ${t}`);const i=n.join("/");if(e){if(!this.childTables.has(s)){const o=new Za(this.storageService,this.baseRoot,`${this.root}/${s}`);this.childTables.set(s,o)}if(i){const o=this.childTables.get(s);o==null||o.setExpanded(i,e)}}else if(this.childTables.has(s))if(i){const o=this.childTables.get(s);o==null||o.setExpanded(i,e)}else this.childTables.delete(s);this.currentViewport&&this.refreshInternal()}collapseAll(){this.childTables.clear(),this.currentViewport&&this.refreshInternal()}setSearch(t){throw new Error("Method not implemented.")}setViewport(t){this.currentViewport=t,this.refreshInternal()}setFilters(){throw new Error("Method not implemented.")}setSorts(){throw new Error("Method not implemented.")}setReversed(){throw new Error("Method not implemented.")}close(){this.listeners=[]}onUpdate(t){return this.listeners=[...this.listeners,t],()=>{this.listeners=this.listeners.filter(e=>e!==t)}}doRefresh(t){vo.debug2("doRefresh",this.root),t(this.fetchData())}refresh(){var n;vo.debug2("refresh",this.root),(n=this.viewportUpdatePromise)==null||n.cancel();const t=new Promise(s=>{this.doRefresh(s)}),e=Ee.makeCancelable(t.then(s=>{if(this.viewportUpdatePromise!==e)throw new di;return this.currentViewportData=s,this.sendUpdate(),s}));e.catch(s=>{Ee.isCanceled(s)||vo.error("Error updating viewport",s)}),this.viewportUpdatePromise=e}refreshInternal(){try{this.refresh()}catch(t){Ee.isCanceled(t)||vo.error("Unable to refresh data",t)}}async fetchData(){const{currentViewport:t}=this;if(!t)throw new Error("No viewport set");let n=(await this.storageService.listItems(this.root)).map(s=>({type:s.type,filename:this.removeBaseRoot(s.filename),basename:s.basename,id:this.removeBaseRoot(s.filename),isExpanded:s.type==="directory"?this.childTables.has(s.basename):void 0})).sort((s,i)=>s.type!==i.type?s.type==="directory"?-1:1:s.basename.localeCompare(i.basename));for(let s=0;s<n.length;s+=1){const i=n[s],{basename:o,filename:r}=i;if(r===this.removeBaseRoot(`${this.root}/${o}`)&&i.type==="directory"){const l=this.childTables.get(o);if(l!=null){l.setViewport({top:0,bottom:t.bottom-s});const a=await l.getViewportData();n.splice(s+1,0,...a.items)}}}return this.currentSize=n.length,vo.debug2(this.root,"items",n,t),n=n.slice(t.top,t.bottom),{items:n,offset:t.top}}sendUpdate(){var n;const{listeners:t}=this,e=(n=this.currentViewportData)!=null?n:{items:[],offset:0};for(let s=0;s<t.length;s+=1)t[s](e)}};let Yp=Za;Yp.REFRESH_DEBOUNCE=50;const a2=X.module("GrpcFileStorage"),Xp=class{constructor(t,e=""){this.tables=[],this.refreshTables=hs(()=>{this.tables.forEach(n=>n.refresh())},Xp.REFRESH_THROTTLE),this.storageService=t,this.root=e}removeRoot(t){return de.removeRoot(this.root,t)}addRoot(t){return de.addRoot(this.root,t)}async createDirectory(t){return await this.storageService.createDirectory(this.addRoot(t)),this.refreshTables(),{type:"directory",id:t,filename:t,basename:de.getBaseName(t)}}async getTable(){const t=new Yp(this.storageService,this.root);return this.tables.push(t),t}async saveFile(t){const e=dh.storage.FileContents.text(t.content);return await this.storageService.saveFile(this.addRoot(t.filename),e,!0),this.refreshTables(),t}async loadFile(t){const n=await(await this.storageService.loadFile(this.addRoot(t))).text();return{filename:t,basename:de.getBaseName(t),content:n}}async deleteFile(t){await this.storageService.deleteItem(this.addRoot(t)),this.refreshTables()}async moveFile(t,e){await this.storageService.moveItem(this.addRoot(t),this.addRoot(e)),this.refreshTables()}async info(t){const e=await this.storageService.listItems(this.addRoot(de.getPath(t)),de.getBaseName(t));if(e.length===0)throw new tc;if(e.length>1)throw a2.error("More than one matching file found, should never happen.",e),new Error("More than one matching file found");const n=e[0];return{filename:this.removeRoot(n.filename),basename:this.removeRoot(n.basename),id:this.removeRoot(n.filename),type:n.type}}};let jp=Xp;jp.REFRESH_THROTTLE=150;const li=X.module("AppInit");async function d2(){li.debug("Loading plugins...");try{const t=await Qa.loadJson("/js-plugins/manifest.json");li.debug("Plugin manifest loaded:",t);const e=[];for(let i=0;i<t.plugins.length;i+=1){const{name:o,main:r}=t.plugins[i],l=`/js-plugins/${o}/${r}`;e.push(Qa.loadModulePlugin(l))}const n=await Promise.all(e),s=new Map;for(let i=0;i<n.length;i+=1){const{name:o}=t.plugins[i];s.set(o,n[i])}return li.info("Plugins loaded:",s),s}catch(t){return li.error("Unable to load plugins:",t),new Map}}async function c2(t){let e;try{e=await o2(t)}catch(n){if(!n2(n))throw n}return e}const cc=t=>{const{workspace:e,setActiveTool:n,setCommandHistoryStorage:s,setDashboardData:i,setFileStorage:o,setLayoutStorage:r,setDashboardConnection:l,setDashboardSessionWrapper:a,setPlugins:d,setUser:c,setWorkspace:u,setWorkspaceStorage:m}=t,[p,g]=S.exports.useState(),[f,b]=S.exports.useState(!0),C=S.exports.useCallback(async()=>{var I,R;try{li.info("Initializing Web UI","0.21.0",navigator.userAgent);const F=await d2(),x=i2(),U=await c2(x);x.addEventListener(M.IdeConnection.HACK_CONNECTION_FAILURE,J=>{var fe;const{detail:pe}=J;li.error("Connection failure",pe),g(`Unable to connect: ${(fe=pe.details)!=null?fe:"Unknown Error"}`)});const $="user",O={name:$,operateAs:$,groups:[],permissions:{isSuperUser:!1,isQueryViewOnly:!1,isNonInteractive:!1,canUsePanels:!0,canCreateDashboard:!0,canCreateCodeStudio:!0,canCreateQueryMonitor:!0,canCopy:!0,canDownloadCsv:!0}},H=r2();await H.login({type:M.CoreClient.LOGIN_TYPE_ANONYMOUS});const L=H.getStorageService(),N=new l2(L,"/layouts"),_=new jp(L,"/notebooks"),k=new Kp(N),V=new f1,W=await k.load({isConsoleAvailable:U!==void 0}),{data:j}=W,{settings:ee}=j;ee.defaultDecimalFormatOptions===void 0&&(ee.defaultDecimalFormatOptions={defaultFormatString:Pe.DEFAULT_FORMAT_STRING}),ee.defaultIntegerFormatOptions===void 0&&(ee.defaultIntegerFormatOptions={defaultFormatString:nt.DEFAULT_FORMAT_STRING}),ee.truncateNumbersWithPound===void 0&&(ee.truncateNumbersWithPound=!1);const{shortcutOverrides:ve={}}=ee,Se=$t.isMacPlatform?(I=ve.mac)!=null?I:{}:(R=ve.windows)!=null?R:{};Object.entries(Se).forEach(([J,pe])=>{var fe;(fe=Be.get(J))==null||fe.setKeyState(pe)});const Le={filterSets:j.filterSets,links:j.links};n(dn.DEFAULT),s(V),i(Rn,Le),o(_),r(N),l(Rn,x),U!==void 0&&a(Rn,U),d(F),c(O),m(k),u(W)}catch(F){li.error(F),g(F)}},[n,s,i,o,r,l,a,d,c,u,m]),w=S.exports.useCallback(()=>{document.fonts!=null?document.fonts.ready.then(()=>{b(!1)}):b(!1)},[]);S.exports.useEffect(function(){C(),w()},[C,w]);const T=e==null&&p==null||f,y=!T&&p==null,E=p!=null?`${p}`:null;return v(ue,{children:[y&&h(J1,{}),h(Cl,{isLoading:T,isLoaded:y,errorMessage:E}),v("div",{id:"preload-fonts",style:{visibility:"hidden",position:"absolute",top:-1e4},children:[h("p",{className:"fira-sans-regular",children:"preload"}),h("p",{className:"fira-sans-semibold",children:"preload"}),h("p",{className:"fira-mono",children:"preload"})]})]})};cc.propTypes={workspace:D.exports.shape({}),workspaceStorage:D.exports.shape({close:D.exports.func}),setActiveTool:D.exports.func.isRequired,setCommandHistoryStorage:D.exports.func.isRequired,setDashboardData:D.exports.func.isRequired,setFileStorage:D.exports.func.isRequired,setLayoutStorage:D.exports.func.isRequired,setDashboardConnection:D.exports.func.isRequired,setDashboardSessionWrapper:D.exports.func.isRequired,setPlugins:D.exports.func.isRequired,setUser:D.exports.func.isRequired,setWorkspace:D.exports.func.isRequired,setWorkspaceStorage:D.exports.func.isRequired};cc.defaultProps={workspace:null,workspaceStorage:null};const h2=t=>({workspace:yl(t),workspaceStorage:uS(t)}),Zh=Dt(h2,{setActiveTool:Dl,setCommandHistoryStorage:yS,setDashboardData:Gm,setFileStorage:IS,setLayoutStorage:C1,setDashboardConnection:oE,setDashboardSessionWrapper:rE,setPlugins:DS,setUser:TS,setWorkspace:wm,setWorkspaceStorage:ES})(cc),u2=()=>h(Cg,{basename:"/ide/",children:v(bg,{children:[h(vc,{exact:!0,path:"/",component:Zh}),h(vc,{path:"/notebook/:notebookPath+",component:Zh}),h(Sg,{from:"*",to:"/"})]})});Boolean(window.location.hostname==="localhost"||window.location.hostname==="[::1]"||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));function m2(){"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(t=>{t.forEach(e=>{e.scope.endsWith("/download/")||e.unregister()})})}M1();ui.render(h(tu,{store:Ml,children:h(u2,{})}),document.getElementById("root"));m2();ll.registerOnLoaded();lt.init();window["__react-beautiful-dnd-disable-dev-warnings"]=!0;
|
|
44
|
-
//# sourceMappingURL=index.
|
|
43
|
+
`)),e}renderFormatRule(t,e){const n=`input-${t}-columnName`,s=`input-${t}-columnType`,i=`input-${t}-format`,o=this.getCachedColumnTypeOptions(),r=c=>this.handleFormatRuleChange(t,"columnName",c.target.value),l=()=>this.handleFormatRuleChange(t,"isNewRule",!1),a=c=>this.handleFormatRuleChange(t,"columnType",c.target.value),d=this.getRuleError(e);return v("fieldset",{className:"container-fluid format-rule-container",children:[v("div",{className:"form-row",children:[v("div",{className:"form-group col-7 mb-2",children:[h("label",{htmlFor:n,children:"Column Name"}),h("input",{id:n,className:z("form-control",{"is-invalid":d.hasColumnNameError}),"data-lpignore":!0,type:"text",value:e.columnName,onChange:r,onBlur:l})]}),v("div",{className:"form-group col mb-2",children:[h(Q,{kind:"ghost",className:"btn-delete-format-rule float-right",tabIndex:-1,onClick:()=>this.handleFormatRuleDelete(t),icon:_n,tooltip:"Delete"}),h("label",{htmlFor:s,children:"Column Type"}),h("select",{id:s,className:"custom-select",value:e.columnType,onChange:a,children:o})]})]}),h("div",{className:"form-row",children:v("div",{className:"form-group col-12 d-flex mb-2",children:[h("label",{className:"flex-shrink-0 col-form-label mr-3",htmlFor:i,children:"Formatting Rule"}),this.renderFormatRuleInput(t,e.columnType,i,e.format,d.hasFormatError)]})}),h("div",{className:"form-row",children:h("div",{className:"form-group col-12 d-flex mb-2",children:d.message&&h("p",{className:"text-danger",children:d.message})})})]},t)}renderFormatRuleInput(t,e,n,s,i){switch(P.getNormalizedType(e)){case P.dataType.DATETIME:return this.renderDateTimeFormatRuleInput(t,n,s,i);case P.dataType.DECIMAL:return this.renderDecimalFormatRuleInput(t,n,s,i);case P.dataType.INT:return this.renderIntegerFormatRuleInput(t,n,s,i);default:return null}}renderDateTimeFormatRuleInput(t,e,n,s){const{showTimeZone:i,showTSeparator:o,timeZone:r}=this.state,l=n!=null&&n.formatString||"";return v("select",{className:z("custom-select",{"is-invalid":s}),value:l,id:e,onChange:a=>{const d=at.makeFormat("",a.target.value,at.TYPE_GLOBAL);this.handleFormatRuleChange(t,"format",d)},children:[h("option",{value:"",disabled:!0,children:"Select format"},"default"),this.getCachedDateTimeFormatOptions(r,i,o)]})}renderIntegerFormatRuleInput(t,e,n,s){const i=n!=null&&n.formatString||"";return h("input",{className:z("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:e,placeholder:nt.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const r=nt.makeFormat("",o.target.value,nt.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(t,"format",r)}})}renderDecimalFormatRuleInput(t,e,n,s){const i=n!=null&&n.formatString||"";return h("input",{className:z("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:e,placeholder:Pe.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const r=Pe.makeFormat("",o.target.value,Pe.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(t,"format",r)}})}render(){const{defaults:t}=this.props,{formatRulesChanged:e,formatSettings:n,defaultDateTimeFormat:s,defaultDecimalFormatOptions:i,defaultIntegerFormatOptions:o,timeZone:r,showTimeZone:l,showTSeparator:a,truncateNumbersWithPound:d}=this.state,{defaultFormatString:c=Pe.DEFAULT_FORMAT_STRING}=i!=null?i:{},{defaultFormatString:u=nt.DEFAULT_FORMAT_STRING}=o!=null?o:{},m=n.map((w,T)=>h(ht,{classNames:"fade",timeout:Tt.transitionMs,onEnter:this.handleFormatRuleEntered,children:this.renderFormatRule(T,w)},w.id)),p=h(Q,{kind:"ghost",className:"mb-3",onClick:this.handleFormatRuleCreate,ref:this.addFormatRuleButtonRef,icon:Ls,children:"Add New Rule"}),g=r===t.timeZone,f=a===t.showTSeparator&&l===t.showTimeZone&&s===t.defaultDateTimeFormat,b=rt.isSameDecimalOptions(i,t.defaultDecimalFormatOptions),C=rt.isSameIntegerOptions(o,t.defaultIntegerFormatOptions);return v("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:[v("div",{className:"container-fluid p-0",children:[h("div",{children:"Default formatting for column types"}),h("div",{className:"app-settings-menu-description mb-3",children:"Applies a formatting rule to all columns of a set type."}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"select-reset-timezone",children:"Time zone"}),h("div",{className:"col pr-0",children:h("select",{className:"custom-select",value:r,onChange:this.handleTimeZoneChange,id:"select-reset-timezone",children:rt.renderTimeZoneOptions()})}),h("div",{className:"col-1 btn-col",children:h(Q,{kind:"ghost",icon:xi,onClick:this.handleResetTimeZone,tooltip:"Reset Time Zone",className:z("btn-reset","btn-reset-time-zone",{hidden:g})})})]}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"select-default-time-format",children:"DateTime"}),h("div",{className:"col pr-0",children:h("select",{className:"custom-select",value:s,onChange:this.handleDefaultDateTimeFormatChange,id:"select-default-time-format",children:this.getCachedDateTimeFormatOptions(r,l,a,!0,s)})}),h("div",{className:"col-1 btn-col",children:h(Q,{kind:"ghost",icon:xi,onClick:this.handleResetDateTimeFormat,tooltip:"Reset DateTime Options",className:z("btn-reset","btn-reset-date-time",{hidden:f})})})]}),h("div",{className:"form-row",children:h("div",{className:"offset-3 col-9",children:h(Pt,{checked:l!=null?l:null,onChange:this.handleShowTimeZoneChange,children:"Show time zone in dates"})})}),h("div",{className:"form-row mb-3",children:h("div",{className:"offset-3 col-9",children:h(Pt,{checked:a!=null?a:null,onChange:this.handleShowTSeparatorChange,children:"Show 'T' separator"})})}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"default-decimal-format-input",children:"Decimal"}),h("div",{className:"col pr-0",children:h("input",{className:z("form-control","flex-grow-1","default-decimal-format-input",{"is-invalid":!rt.isValidFormat(P.dataType.DECIMAL,Pe.makeCustomFormat(c))}),"data-lpignore":!0,placeholder:Pe.DEFAULT_FORMAT_STRING,type:"text",id:"default-decimal-format-input",value:c,onChange:this.handleDefaultDecimalFormatChange})}),h("div",{className:"col-1 btn-col",children:h(Q,{kind:"ghost",icon:xi,onClick:this.handleResetDecimalFormat,tooltip:"Reset Decimal Formatting",className:z("btn-reset","btn-reset-decimal",{hidden:b}),"data-testid":"btn-reset-decimal"})})]}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"default-integer-format-input",children:"Integer"}),h("div",{className:"col pr-0",children:h("input",{className:z("form-control","flex-grow-1","default-integer-format-input",{"is-invalid":!rt.isValidFormat(P.dataType.INT,nt.makeCustomFormat(u))}),"data-lpignore":!0,placeholder:nt.DEFAULT_FORMAT_STRING,type:"text",id:"default-integer-format-input",value:u,onChange:this.handleDefaultIntegerFormatChange})}),h("div",{className:"col-1 btn-col",children:h(Q,{kind:"ghost",icon:xi,onClick:this.handleResetIntegerFormat,tooltip:"Reset Integer Formatting",className:z("btn-reset","btn-reset-integer",{hidden:C}),"data-testid":"btn-reset-integer"})})]}),h("div",{className:"form-row mb-3",children:h("div",{className:"offset-3 col-9",children:h(Pt,{checked:d!=null?d:null,onChange:this.handleTruncateNumbersWithPoundChange,children:"Truncate numbers with #"})})})]}),h("div",{children:"Default formatting for matched column names"}),h("div",{className:"app-settings-menu-description mb-3",children:"Applies a formatting rule to all columns that match a specified name and type."}),h(hg,{appear:e,enter:e,exit:e,children:m}),p]})}};let ac=rt;ac.defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:at.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:Pe.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:nt.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:at.DEFAULT_TIME_ZONE_ID}};ac.inputDebounceTime=250;const S1=t=>({formatter:fS(t),defaultDateTimeFormat:mS(t),defaultDecimalFormatOptions:pS(t),defaultIntegerFormatOptions:gS(t),showTimeZone:CS(t),showTSeparator:bS(t),truncateNumbersWithPound:SS(t),timeZone:Il(t),settings:Kt(t)}),w1=Dt(S1,{saveSettings:Tm})(ac),v1=()=>{const[t,e]=S.exports.useState(!1),n=()=>{e(!t)};return v(Q,{kind:"ghost",onClick:n,icon:If,children:["Legal Notices",v(Uo,{isOpen:t,toggle:n,className:"theme-bg-light",children:[h($o,{toggle:n,children:"Legal Notice"}),v(Bo,{children:[h("p",{children:"Deephaven software is protected by U.S. Patent Nos. 9,612,959; 9,613,018; 9,613,109; 9,619,210; 9,633,060; 9,639,570; 9,672,238; 9,679,006; 9,690,821; 9,710,511; 9,760,591; 9,805,084; 9,836,495; 9,836,494; 9,886,469; 9,898,496; 9,934,266; 10,002,153; 10,002,154; 10,002,155; 10,003,673; 10,019,138; 10,069,943; 10,176,211; 10,198,465; 10,198,466; 10,198,469; 10,212,257; 10,241,960; 10,241,965; 10,242,040; 10,242,041; 10,353,893; 10,346,394; 10,452,649; 10,496,639; 10,540,351; 10,552,412; 10,565,194; 10,565,206; 10,572,474; 10,621,168; 10,642,829; 10,657,184; 10,678,787; 10,691,686; and 10,783,191. Other patents pending."}),v("p",{children:["\xA9 2016-",new Date().getFullYear()," Deephaven Data Labs LLC. Patent Pending."]})]})]})]})},rl=t=>{const{children:e,isExpanded:n,sectionKey:s,title:i,onToggle:o}=t;return v(ue,{children:[h("div",{children:v(Q,{kind:"ghost",className:"btn-collapse-trigger",onClick:()=>o(s),children:[h("div",{className:"flex-grow-1",children:i}),h("div",{className:"flex-shrink-0",children:h(K,{transform:n?"flip-v":"",icon:ls})})]})}),h(gd,{in:n,autoFocusOnShow:!0,children:e})]})};rl.propTypes={children:D.exports.node,isExpanded:D.exports.bool.isRequired,sectionKey:D.exports.string.isRequired,title:D.exports.node.isRequired,onToggle:D.exports.func};rl.defaultProps={children:null,onToggle:()=>{}};function T1({shortcut:t,displayText:e,categoryName:n,onChange:s}){const[i,o]=S.exports.useState(e),[r,l]=S.exports.useState(t.getKeyState()),[a,d]=S.exports.useState(!1),[c,u]=S.exports.useState("");S.exports.useEffect(function(){o(e),l(t.getKeyState())},[e,t]),S.exports.useEffect(function(){o($t.getDisplayText(r)),t.matchesKeyState(r)&&d(!1)},[r,t]),S.exports.useEffect(function(){if(a){if(!$t.isValidKeyState(r)){$t.isAllowedKey(r.keyValue)?u("Must contain a modifier key"):u("Must contain an allowed action key");return}const y=Be.getConflictingShortcuts(r).filter(E=>E.id.startsWith(n)&&E!==t).map(E=>E.name);if(y.length){u(`Conflicts with ${y.join(", ")}`);return}u("")}else u("")},[a,r,n,t]);function m(T){if(T.stopPropagation(),T.preventDefault(),t.isEditable&&!T.repeat){const y=$t.getKeyStateFromEvent(T),E=$t.createKeyState([ge.BACKSPACE]);$t.doKeyStatesMatch(y,E)?l($t.NULL_KEY_STATE):l(y)}}function p(T){T.stopPropagation(),T.preventDefault(),t.matchesKeyState(r)||d(!0)}function g(){Ne.disableAllActions()}function f(){Ne.enableAllActions()}function b(){t.setKeyState(r),d(!1),s(t)}function C(){const T=t.getKeyState();l(T),d(!1)}function w(){d(!0),l(t.getDefaultKeyState())}return v(ue,{children:[v("div",{className:"shortcut-item-container",children:[v("label",{className:"shortcut-item-name",children:[t.name,t.tooltip!==void 0&&h(Ie,{children:t.tooltip})]}),v("div",{className:"shortcut-item-input-container",children:[h("input",{className:z("form-control",{"is-invalid":c}),onKeyDown:m,onKeyUp:p,onFocus:g,onBlur:f,disabled:!t.isEditable,value:i,readOnly:!0}),!$t.doKeyStatesMatch(r,t.getDefaultKeyState())&&!c&&h(Q,{className:"reset-to-default-button",kind:"ghost",icon:h(K,{icon:xi,transform:{rotate:90,flipX:!0}}),tooltip:"Reset to default",onClick:w})]})]}),a&&v("div",{className:z("shortcut-item-message-container",{"is-invalid":c}),children:[h("div",{className:"shortcut-item-message",children:c}),v("div",{className:"shortcut-item-message-buttons",children:[$t.isValidKeyState(r)&&h(Q,{kind:"ghost",onClick:b,children:"Confirm"}),h(Q,{kind:"ghost",onClick:C,children:"Undo"})]})]})]})}function E1({shortcutOverrides:t={},settings:e,saveSettings:n}){const s=S.exports.useCallback(l=>{const a=$t.isMacPlatform,d={mac:{...t.mac},windows:{...t.windows}},c=a?d.mac:d.windows;l.forEach(u=>{u.isDefault()?delete c[u.id]:c[u.id]=u.getKeyState()}),n({...e,shortcutOverrides:d})},[e,n,t]);let i=Array.from(Be.shortcutsByCategory.entries()).map(([l,a])=>({name:l,shortcuts:a}));const o=i.findIndex(l=>l.name.toUpperCase()==="GLOBAL"),r=i.splice(o,1);return i=i.concat(r),v(ue,{children:[h("div",{className:"app-settings-menu-description",children:"Customize shortcuts below. Assigning shortcuts that conflict with the browser or IDE shortcuts may cause unintended behavior"}),i.map(l=>h(y1,{name:l.name,shortcuts:l.shortcuts,saveShortcutOverrides:s},l.name))]})}function y1({name:t,shortcuts:e,saveShortcutOverrides:n}){function s(a){return a.split("_").map(d=>`${d[0].toUpperCase()}${d.slice(1).toLowerCase()}`).join(" ")}const[i,o]=S.exports.useState(e);function r(a){const d=i.filter(u=>u!==a&&!u.isNull()&&u.matchesKeyState(a.getKeyState()));d.forEach(u=>u.setToNull());const c=[a,...d];n(c),o(u=>[...u])}const l=S.exports.useMemo(()=>i.map(a=>a.getDisplayText()),[i]);return v("div",{className:"mt-3",children:[h("div",{className:"font-weight-bold",children:s(t)}),i.map((a,d)=>h(T1,{shortcut:a,displayText:l[d],categoryName:t,onChange:r},a.id))]})}const I1=t=>({settings:Kt(t),shortcutOverrides:wS(t)}),R1={saveSettings:Tm},D1=Dt(I1,R1)(E1),Xa=new ef,ja=new zr(Xa);function M1(){X.setLogLevel(parseInt("2",10)),Xa.enable(),ja.enable(),window!=null&&(window.DHLog=X,window.DHLogProxy=Xa,window.DHLogHistory=ja)}const N1="yyyy-MM-dd-HHmmss";function $p(t,e="root",n=new Map([[t,""]])){const s={};return Object.entries(t).forEach(([i,o])=>{try{JSON.stringify(o),s[i]=o}catch{const l=o;if(typeof o=="bigint")s[i]=o.toString();else if(n.has(l))s[i]=`Circular ref to ${n.get(l)}`;else{const a=`${e}.${i}`;n.set(l,a),s[i]=$p(o,a,n)}}}),s}function F1(){const t=Ml.getState();return JSON.stringify($p(t),null,2)}function x1(){const t={uiVersion:"0.21.1",userAgent:navigator.userAgent};return JSON.stringify(t,null,2)}async function _1(t=`${M.i18n.DateTimeFormat.format(N1,new Date)}_support_logs`){const e=new iu,n=e.folder(t);n.file("console.txt",ja.getFormattedHistory()),n.file("redux.json",F1()),n.file("metadata.json",x1());const s=await e.generateAsync({type:"blob"}),i=document.createElement("a");i.href=URL.createObjectURL(s),i.download=`${t}.zip`,i.click()}const xs=class extends S.exports.Component{constructor(t){super(t),this.handleClose=this.handleClose.bind(this),this.handleScrollTo=this.handleScrollTo.bind(this),this.handleSectionToggle=this.handleSectionToggle.bind(this),this.menuContentRef=Y.createRef(),this.state={expandedSectionKey:xs.FORMATTING_SECTION_KEY}}static focusFirstInputInContainer(t){const e=t==null?void 0:t.querySelector("input, select, textarea");e&&e.focus()}static handleExportSupportLogs(){_1()}componentDidMount(){xs.focusFirstInputInContainer(this.menuContentRef.current)}isSectionExpanded(t){const{expandedSectionKey:e}=this.state;return e===t}handleScrollTo(t,e){var n;(n=this.menuContentRef.current)==null||n.scrollTo(t,e)}handleSectionToggle(t){this.setState(e=>({expandedSectionKey:e.expandedSectionKey===t?void 0:t}))}handleClose(){const{onDone:t}=this.props;t()}render(){const t="0.21.1",e="https://github.com/deephaven/web-client-ui/",n="https://deephaven.io/core/docs/";return v("div",{className:"app-settings-menu",children:[v("header",{className:"app-settings-menu-header",children:[h("div",{className:"flex-spacer"}),h(Q,{kind:"ghost",className:"btn-close-settings-menu",onClick:this.handleClose,icon:h(K,{icon:Yi,transform:"grow-4"}),tooltip:"Close"})]}),v("div",{className:"app-settings-menu-content",ref:this.menuContentRef,children:[h("h5",{children:"Settings"}),h("hr",{className:"my-0"}),h(rl,{sectionKey:xs.FORMATTING_SECTION_KEY,isExpanded:this.isSectionExpanded(xs.FORMATTING_SECTION_KEY),title:v(ue,{children:[h(K,{icon:Hf,transform:"grow-4",className:"mr-2"}),"Formatting & Time zone"]}),onToggle:this.handleSectionToggle,children:h(w1,{scrollTo:this.handleScrollTo})}),h(rl,{sectionKey:xs.SHORTCUT_SECTION_KEY,isExpanded:this.isSectionExpanded(xs.SHORTCUT_SECTION_KEY),title:v(ue,{children:[h(K,{icon:_f,transform:"grow-2"})," ","Keyboard Shortcuts"]}),onToggle:this.handleSectionToggle,children:h(D1,{})}),v("div",{className:"app-settings-footer",children:[v("div",{className:"app-settings-footer-section",children:[v("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Support"}),v("div",{children:["GitHub:\xA0",h("a",{href:e,className:"custom-link",target:"_blank",rel:"noopener noreferrer",children:e})]}),h(Q,{kind:"tertiary",className:"mt-2 py-2",onClick:xs.handleExportSupportLogs,children:"Export Logs"})]}),v("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Documentation"}),h("a",{target:"_blank",rel:"noreferrer noopener",href:n,className:"custom-link",children:n})]}),h("div",{className:"app-settings-footer-item",children:v("div",{className:"text-muted",children:["Version ",t]})}),h("div",{className:"app-settings-footer-item",children:h(v1,{})})]}),h("div",{className:"app-settings-footer-section",children:h("div",{className:"logo",children:h("a",{target:"_blank",rel:"noreferrer noopener",href:"https://deephaven.io",className:"d-inline-block custom-link p-1",children:h("img",{src:Bp,alt:"Deephaven Data Labs",width:"230px"})})})})]})]})]})}};let Qo=xs;Qo.defaultProps={onDone:()=>{}};Qo.FORMATTING_SECTION_KEY="SettingsMenu.formatting";Qo.APPLICATION_SECTION_KEY="ApplicationMenu.settings";Qo.SHORTCUT_SECTION_KEY="SettingsMenu.shortcuts";const jh=10,Oi=t=>{const{forwardedProps:{menuItem:{action:e,title:n,disabled:s},iconElement:i,displayShortcut:o,isMouseSelected:r,isKeyboardSelected:l,closeMenu:a}}=t,d=S.exports.useRef(),c=S.exports.useRef(),u=S.exports.useRef(null),[m,p]=S.exports.useState(!1),g=S.exports.useCallback(C=>{d.current!=null&&c.current!=null&&u.current&&(Math.abs(d.current-C.clientX)>=jh||Math.abs(c.current-C.clientY)>=jh)&&(p(!0),window.removeEventListener("mousemove",g),a(),e(C),u.current=null)},[e,a]);function f(C){d.current=C.clientX,c.current=C.clientY,u.current=C.target,window.addEventListener("mousemove",g)}function b(C){u.current===C.target&&(p(!0),a(),e(),window.removeEventListener("mousemove",g)),u.current=null}return S.exports.useEffect(function(){return function(){return window.removeEventListener("mousemove",g)}},[g]),v("button",{type:"button",className:z("btn-context-menu",{disabled:s},{active:r&&!s},{"keyboard-active":l&&!s}),onMouseDown:f,onMouseUp:b,disabled:m,children:[h("span",{className:z("icon"),children:i}),h("span",{className:"title",children:n}),h("span",{className:"shortcut",children:o})]})},dc=t=>{const{handleControlSelect:e,handleToolSelect:n,onClearFilter:s}=t,i=S.exports.useMemo(()=>[{title:"Input Filter",icon:Qf,menuElement:h(Oi,{}),action:o=>{e(fn.INPUT_FILTER,o)},order:10},{title:"Dropdown Filter",icon:bu,menuElement:h(Oi,{}),action:o=>{e(fn.DROPDOWN_FILTER,o)},order:15},{title:"Markdown Widget",icon:Nf,menuElement:h(Oi,{}),action:o=>{e(fn.MARKDOWN,o)},order:20},{title:"Filter Sets",icon:ya,menuElement:h(Oi,{}),action:o=>{e(fn.FILTER_SET_MANAGER,o)},order:25},{disabled:!0,menuElement:h("div",{className:"context-menu-group-header",children:"Tools"}),order:30},{title:"Linker",icon:rd,action:()=>{n(dn.LINKER)},order:40,shortcut:Os.LINKER},{disabled:!0,menuElement:h("div",{className:"context-menu-group-header",children:"Actions"}),order:50},{title:"Clear All Filters",icon:qf,action:()=>{s()},order:60,shortcut:ln.TABLE.CLEAR_ALL_FILTERS}],[e,n,s]);return h(Wn,{popperClassName:"controls-menu-popper",actions:i})};dc.propTypes={handleControlSelect:D.exports.func,handleToolSelect:D.exports.func,onClearFilter:D.exports.func};dc.defaultProps={handleControlSelect:()=>{},handleToolSelect:()=>{},onClearFilter:()=>{}};Oi.propTypes={forwardedProps:D.exports.shape({iconElement:D.exports.node,displayShortcut:D.exports.string,isMouseSelected:D.exports.bool.isRequired,isKeyboardSelected:D.exports.bool.isRequired,closeMenu:D.exports.func.isRequired,menuItem:D.exports.shape({action:D.exports.func,title:D.exports.string,disabled:D.exports.bool}).isRequired})};Oi.defaultProps={forwardedProps:null};const k1=fi(Up,null),O1={layoutStorage:k1},L1=t=>t.layoutStorage;Object.entries(O1).map(([t,e])=>Zi.register(t,e));const Qh=10,A1=t=>{const{onExportLayout:e,onImportLayout:n,onResetLayout:s,onSelect:i,widgets:o=[]}=t,[r,l]=S.exports.useState(!1),[a,d]=S.exports.useState(""),c=S.exports.useRef(null),u=S.exports.useRef(),m=S.exports.useCallback((y,E)=>{y!=null&&i(y,E)},[i]),p=S.exports.useCallback(y=>{d(y.target.value)},[]),g=S.exports.useCallback(y=>{u.current!=null&&(Math.abs(u.current.x-y.clientX)>=Qh||Math.abs(u.current.y-y.clientY)>=Qh)&&(l(!0),window.removeEventListener("mousemove",g),m(u.current.widget,y),u.current=void 0)},[u,m]),f=S.exports.useCallback((y,E)=>{u.current={x:y.clientX,y:y.clientY,widget:E},window.addEventListener("mousemove",g)},[g]),b=S.exports.useCallback((y,E)=>{var I;window.removeEventListener("mousemove",g),((I=u.current)==null?void 0:I.widget)===E&&(l(!0),m(E)),u.current=void 0},[g,u,m]),C=S.exports.useMemo(()=>o.filter(y=>{var E;return a?(E=y.name)==null?void 0:E.toLowerCase().includes(a.toLowerCase()):!0}),[a,o]).sort((y,E)=>{var I,R,F;return(F=(R=y.name)==null?void 0:R.localeCompare((I=E.name)!=null?I:""))!=null?F:0}),w=S.exports.useMemo(()=>C.map(y=>{var E,I;return h("li",{children:v(Q,{kind:"ghost","data-testid":`panel-list-item-${(E=y.name)!=null?E:""}-button`,onMouseDown:R=>{f(R,y)},onMouseUp:R=>{b(R,y)},onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&m(y)},disabled:r,onClick:()=>{},children:[h($u,{type:y.type})," ",(I=y.name)!=null?I:""]})},y.name)}),[C,r,f,b,m]),T=S.exports.useMemo(()=>w.length===0?h("span",{children:"No bound variables found."}):null,[w]);return v("div",{className:"widget-list-container d-flex flex-column",children:[h("div",{className:"widget-list-header",children:h(gs,{value:a,placeholder:"Find Table, Plot or Widget",onChange:p,ref:c})}),v("ul",{className:"widget-list flex-grow-1",children:[T&&h("li",{className:"widget-list-message",children:T}),!T&&w]}),h("div",{children:h("hr",{})}),v("div",{className:"widget-list-footer",children:[v(Q,{kind:"ghost",onClick:e,children:[v("div",{className:"fa-md fa-layers",children:[h(K,{mask:Ia,icon:Ic,transform:"right-5 down-5"}),h(K,{icon:Ic,transform:"right-8 down-6"})]}),"Export Layout"]}),v(Q,{kind:"ghost",onClick:n,children:[v("div",{className:"fa-md fa-layers",children:[h(K,{mask:Ia,icon:Ea,transform:"right-5 down-5"}),h(K,{icon:Ea,transform:"right-8 down-6"})]}),"Import Layout"]}),h(Q,{kind:"ghost",icon:xi,onClick:s,tooltip:"Reset Layout"})]})]})},P1=async(t,e,n)=>{let s,i,o,r;if(Pr(e)?(s=e.settings,i=e.table,o=void 0,r=e.tableSettings):(s={},i="",o=e.figure,r={}),n!==void 0&&(n.tableSettings!=null&&(r=n.tableSettings),n.table!=null&&(i=n.table),n.figure!=null&&(o=n.figure),n.settings!=null&&(s={...s,...n.settings})),o!==void 0){const d={title:o,name:o,type:M.VariableType.FIGURE},c=await t.getObject(d);return zi.makeModel(s,c)}const l={title:o,name:i,type:M.VariableType.TABLE},a=await t.getObject(l);return se.applyTableSettings(a,r,Il(Ml.getState())),zi.makeModelFromSettings(s,a)},H1=async(t,e,n=M.VariableType.TABLE)=>{const{table:s}=e,i={title:s,name:s,type:n},o=await t.getObject(i);return Gd.makeModel(o)};const V1=({onAutoFillClick:t=()=>{}})=>v("div",{className:"empty-dashboard-container",children:[v("div",{className:"hint-container",children:[h(K,{icon:hf})," ",h("br",{}),"Use the panel list to add objects from a query."]}),v("div",{className:"empty-dashboard",children:[h("div",{className:"add-panels-hint",children:"Drag Panels Here"}),h(Q,{kind:"tertiary",onClick:t,children:"Auto fill objects"})]})]});function U1(t){return t.version===2}function B1(t){return Array.isArray(t)}const xr=X.module("UserLayoutUtils"),$1={layoutConfig:[{type:"column",content:[{type:"row",content:[{type:"stack",content:[{type:"react-component",component:ki.COMPONENT,title:ki.TITLE,isClosable:!1},{type:"react-component",component:ol.COMPONENT,title:ol.TITLE,isClosable:!1}]},{type:"stack",width:25,content:[{type:"react-component",component:nl.COMPONENT,title:nl.TITLE,isClosable:!1},{type:"react-component",component:sl.COMPONENT,title:sl.TITLE,isClosable:!1}]}]},{type:"row",content:[{type:"stack",title:"Notebooks",content:[]}]}]}],links:[],filterSets:[],version:2},z1={layoutConfig:[],links:[],filterSets:[],version:2};function zp(t){if(U1(t))return t;if(B1(t))return{layoutConfig:t,links:[],filterSets:[],version:2};throw new Error(`Unexpected layout import format: ${t}`)}async function W1(t,e=!0){try{const n=await t.getLayouts();if(n.length>0)try{const s=await t.getLayout(n[0]);return zp(s)}catch(s){xr.error("Unable to load layout",n[0],":",s),xr.warn("No valid layouts found, falling back to default layout")}}catch(n){xr.error("Unable to fetch layout list",n),xr.warn("Falling back to default layout")}return e?$1:z1}function G1(t){const{filterSets:e,layoutConfig:n,links:s}=t;return{filterSets:e,layoutConfig:n,links:s,version:2}}const Br={exportLayout:G1,getDefaultLayout:W1,normalizeLayout:zp},_r=X.module("DownloadServiceWorkerUtils"),Wp=class{static registerOnLoaded(){new URL("/ide/",window.location.href).origin===window.location.origin&&("serviceWorker"in navigator?window.addEventListener("load",()=>{const e=new URL("/ide/download/serviceWorker.js",window.location.href);navigator.serviceWorker.register(e).then(n=>{n.update(),_r.info("Registering service worker on ",e,n)}).catch(n=>{_r.error("Failed to register service worker",n)})}):_r.info("Service worker is not supported."))}static async getServiceWorker(){if("serviceWorker"in navigator){const e=(await navigator.serviceWorker.getRegistrations()).find(n=>n.scope.endsWith(Wp.DOWNLOAD_PATH));if(e&&e.active)return _r.info("Download service worker is active."),e.active;throw new Error("Can not find download service worker.")}throw new Error("Download service worker is not available.")}static unregisterSW(){}};let ll=Wp;ll.DOWNLOAD_PATH="/download/";const Gp={react:Y},K1=ug(Gp),q1=mg({requires:K1}),Y1=pg.createRequires(Gp),X1=gg({requires:Y1}),j1=X.module("PluginUtils");class Qa{static loadComponentPlugin(e){if("".split(",").includes(e)){const o=Y.lazy(()=>vg(()=>import(`./internal/${e}`),[])),r=Y.forwardRef((l,a)=>h(S.exports.Suspense,{fallback:h("div",{children:"Loading Plugin..."}),children:h(o,{ref:a,...l})}));return r.pluginName=e,r.displayName="Local Plugin",r}const n=new URL("/ide/plugins/",`${window.location}`),s=new URL(`${e}.js`,n),i=Y.forwardRef((o,r)=>h(q1,{url:s,render:({err:l,Component:a})=>{if(l!=null&&l!==""){const d=`Error loading plugin ${e} from ${s} due to ${l}`;return j1.error(d),h("div",{className:"error-message",children:`${d}`})}return h(a,{ref:r,...o})}}));return i.pluginName=e,i.displayName="Plugin",i}static async loadModulePlugin(e){return await X1(e)}static async loadJson(e){return new Promise((n,s)=>{const i=new XMLHttpRequest;i.addEventListener("load",()=>{try{const o=JSON.parse(i.responseText);n(o)}catch(o){s(o)}}),i.addEventListener("error",o=>{s(o)}),i.open("GET",e),i.send()})}}const _t=X.module("AppMainContainer");class Oo extends S.exports.Component{constructor(e){super(e),this.getDashboardPlugins=he(n=>[...n.entries()].filter(([,{DashboardPlugin:s}])=>s).map(([s,{DashboardPlugin:i}])=>h(i,{},s))),this.handleSettingsMenuHide=this.handleSettingsMenuHide.bind(this),this.handleSettingsMenuShow=this.handleSettingsMenuShow.bind(this),this.handleError=this.handleError.bind(this),this.handleControlSelect=this.handleControlSelect.bind(this),this.handleToolSelect=this.handleToolSelect.bind(this),this.handleClearFilter=this.handleClearFilter.bind(this),this.handleDataChange=this.handleDataChange.bind(this),this.handleAutoFillClick=this.handleAutoFillClick.bind(this),this.handleGoldenLayoutChange=this.handleGoldenLayoutChange.bind(this),this.handleLayoutConfigChange=this.handleLayoutConfigChange.bind(this),this.handleExportLayoutClick=this.handleExportLayoutClick.bind(this),this.handleImportLayoutClick=this.handleImportLayoutClick.bind(this),this.handleImportLayoutFiles=this.handleImportLayoutFiles.bind(this),this.handleLoadTablePlugin=this.handleLoadTablePlugin.bind(this),this.handleResetLayoutClick=this.handleResetLayoutClick.bind(this),this.handleWidgetMenuClick=this.handleWidgetMenuClick.bind(this),this.handleWidgetsMenuClose=this.handleWidgetsMenuClose.bind(this),this.handleWidgetSelect=this.handleWidgetSelect.bind(this),this.handlePaste=this.handlePaste.bind(this),this.hydrateChart=this.hydrateChart.bind(this),this.hydrateGrid=this.hydrateGrid.bind(this),this.hydratePandas=this.hydratePandas.bind(this),this.hydrateDefault=this.hydrateDefault.bind(this),this.openNotebookFromURL=this.openNotebookFromURL.bind(this),this.importElement=Y.createRef(),this.state={contextActions:[{action:()=>{this.handleToolSelect(dn.LINKER)},shortcut:Os.LINKER,isGlobal:!0},{action:()=>{this.sendClearFilter()},shortcut:ln.TABLE.CLEAR_ALL_FILTERS,isGlobal:!0},{action:()=>{_t.debug("Consume unhandled save shortcut")},shortcut:Os.SAVE,isGlobal:!0}],isPanelsMenuShown:!1,isSettingsMenuShown:!1,widgets:[]}}static handleWindowBeforeUnload(e){e.preventDefault(),e.returnValue=""}static hydrateConsole(e,n){return Pa.hydrate({...e,unzip:s=>iu.loadAsync(s).then(i=>Object.values(i.files))},n)}componentDidMount(){this.initWidgets(),window.addEventListener("beforeunload",Oo.handleWindowBeforeUnload)}componentDidUpdate(e){const{dashboardData:n}=this.props;e.dashboardData!==n&&this.handleDataChange(n)}componentWillUnmount(){this.deinitWidgets(),window.removeEventListener("beforeunload",Oo.handleWindowBeforeUnload)}initWidgets(){const{connection:e}=this.props;if(e.subscribeToFieldUpdates==null){_t.warn("subscribeToFieldUpdates not supported, not initializing widgets");return}this.widgetListenerRemover=e.subscribeToFieldUpdates(n=>{_t.debug("Got updates",n),this.setState(({widgets:s})=>{const{updated:i,created:o,removed:r}=n,l=[...i,...r],a=s.filter(c=>!l.some(u=>u.name===c.name));return[...i,...o].forEach(c=>{c.name!=null&&c.name!==""&&a.push(c)}),{widgets:a}})})}deinitWidgets(){var e;(e=this.widgetListenerRemover)==null||e.call(this)}openNotebookFromURL(){const{match:e}=this.props,{notebookPath:n}=e.params;if(n){const{session:s,sessionConfig:i}=this.props;if(s==null||i==null){_t.error("No session available to open notebook URL",n);return}const o={id:`/${n}`,itemName:`/${n}`},r=i.type,l={value:null,language:r};this.emitLayoutEvent(Ve.SELECT_NOTEBOOK,s,r,l,o,!0)}}sendClearFilter(){this.emitLayoutEvent(He.CLEAR_ALL_FILTERS)}emitLayoutEvent(e,...n){var s;(s=this.goldenLayout)==null||s.eventHub.emit(e,...n)}handleError(e){Ee.isCanceled(e)||_t.error(e)}handleSettingsMenuHide(){this.setState({isSettingsMenuShown:!1})}handleSettingsMenuShow(){this.setState({isSettingsMenuShown:!0})}handleControlSelect(e,n=null){switch(_t.debug("handleControlSelect",e),e){case fn.DROPDOWN_FILTER:this.emitLayoutEvent(He.OPEN_DROPDOWN,{title:"DropdownFilter",type:e,createNewStack:!0,dragEvent:n});break;case fn.INPUT_FILTER:this.emitLayoutEvent(He.OPEN_INPUT,{title:"InputFilter",type:e,createNewStack:!0,dragEvent:n});break;case fn.MARKDOWN:this.emitLayoutEvent(wp.OPEN,{title:"Markdown",type:e,dragEvent:n});break;case fn.FILTER_SET_MANAGER:this.emitLayoutEvent(He.OPEN_FILTER_SET_MANAGER,{title:"FilterSets",type:e,dragEvent:n});break;default:throw new Error(`Unrecognized control type ${e}`)}}handleToolSelect(e){_t.debug("handleToolSelect",e);const{activeTool:n,setActiveTool:s}=this.props;s(n===e?dn.DEFAULT:e)}handleClearFilter(){this.sendClearFilter()}handleDataChange(e){const{updateWorkspaceData:n}=this.props,{closed:s,filterSets:i,links:o}=e;n({closed:s,filterSets:i,links:o})}handleGoldenLayoutChange(e){this.goldenLayout=e}handleLayoutConfigChange(e){const{updateWorkspaceData:n}=this.props;n({layoutConfig:e})}handleWidgetMenuClick(){this.setState(({isPanelsMenuShown:e})=>({isPanelsMenuShown:!e}))}handleWidgetSelect(e,n){this.setState({isPanelsMenuShown:!1}),_t.debug("handleWidgetSelect",e,n),this.openWidget(e,n)}handleWidgetsMenuClose(){this.setState({isPanelsMenuShown:!1})}handleAutoFillClick(){const{widgets:e}=this.state;_t.debug("handleAutoFillClick",e);const n=e.sort((s,i)=>s.title!=null&&i.title!=null?s.title.localeCompare(i.title):0);for(let s=0;s<n.length;s+=1)this.openWidget(n[s])}handleExportLayoutClick(){_t.info("handleExportLayoutClick"),this.setState({isPanelsMenuShown:!1});try{const{workspace:e}=this.props,{data:n}=e,s=Br.exportLayout(n);_t.info("handleExportLayoutClick exportedConfig",s);const i=new Blob([JSON.stringify(s)],{type:"application/json"}),o=M.i18n.DateTimeFormat.format("yyyy-MM-dd-HHmmss",new Date),r=document.createElement("a");r.href=URL.createObjectURL(i),r.download=`deephaven-app-layout-${o}.json`,r.click()}catch(e){_t.error("Unable to export layout",e)}}handleImportLayoutClick(){_t.info("handleImportLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.importElement.current!=null&&(this.importElement.current.value="",this.importElement.current.click())}handleResetLayoutClick(){_t.info("handleResetLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.resetLayout()}handleImportLayoutFiles(e){var n;e.stopPropagation(),e.preventDefault(),e.target.files!=null&&this.importLayoutFile((n=e.target.files)==null?void 0:n[0])}async importLayoutFile(e){try{const{updateDashboardData:n,updateWorkspaceData:s}=this.props,i=await e.text(),o=JSON.parse(i),{filterSets:r,layoutConfig:l,links:a}=Br.normalizeLayout(o);s({layoutConfig:l}),n(Rn,{filterSets:r,links:a})}catch(n){_t.error("Unable to import layout",n)}}async resetLayout(){const{layoutStorage:e,session:n}=this.props,{filterSets:s,layoutConfig:i,links:o}=await Br.getDefaultLayout(e,n!==void 0),{updateDashboardData:r,updateWorkspaceData:l}=this.props;l({layoutConfig:i}),r(Rn,{filterSets:s,links:o})}handlePaste(e){let n=e.currentTarget.parentElement;for(;n!=null;){if(n.classList.contains("monaco-editor"))return;n=n.parentElement}const{clipboardData:s}=e,i=s.getData("Text"),o=/“|”/g;o.test(i)&&(e.preventDefault(),e.stopPropagation(),document.execCommand("insertText",!1,i.replace(o,'"')))}handleLoadTablePlugin(e){const{plugins:n}=this.props,s=n.get(e);return s!=null&&s.TablePlugin!=null?s.TablePlugin:Qa.loadComponentPlugin(e)}hydrateDefault(e,n){const{connection:s}=this.props,{metadata:i}=e;if((i==null?void 0:i.type)!=null&&((i==null?void 0:i.id)!=null||(i==null?void 0:i.name)!=null)){const o=i.id!=null?{type:i.type,id:i.id}:{type:i.type,name:i.name,title:i.name};return{fetch:()=>s.getObject(o),localDashboardId:n,...e}}return Pa.hydrate(e,n)}hydrateGrid(e,n){return this.hydrateTable(e,n,M.VariableType.TABLE)}hydratePandas(e,n){return this.hydrateTable(e,n,M.VariableType.PANDAS)}hydrateTable(e,n,s=M.VariableType.TABLE){const{connection:i}=this.props;return{...e,getDownloadWorker:ll.getServiceWorker,loadPlugin:this.handleLoadTablePlugin,localDashboardId:n,makeModel:()=>H1(i,e.metadata,s)}}hydrateChart(e,n){const{connection:s}=this.props;return{...e,localDashboardId:n,makeModel:()=>{const{metadata:i,panelState:o}=e;return P1(s,i,o)}}}openWidget(e,n){const{connection:s}=this.props;this.emitLayoutEvent(Me.OPEN,{dragEvent:n,fetch:()=>s.getObject(e),widget:e})}render(){const{activeTool:e,plugins:n,user:s,workspace:i}=this.props,{data:o}=i,{layoutConfig:r}=o,{permissions:l}=s,{canUsePanels:a}=l,{contextActions:d,isPanelsMenuShown:c,isSettingsMenuShown:u,widgets:m}=this.state,p=this.getDashboardPlugins(n);return v("div",{className:z("app-main-tabs","w-100","h-100","d-flex","flex-column",e?`active-tool-${e.toLowerCase()}`:""),onPaste:this.handlePaste,tabIndex:-1,children:[h("nav",{className:"nav-container",children:v("div",{className:"app-main-top-nav-menus",children:[h("img",{src:Bp,alt:"Deephaven Data Labs",width:"115px",className:"ml-1"}),v("div",{children:[v(Q,{kind:"ghost",className:"btn-panels-menu",icon:sC,onClick:()=>{},children:["Controls",h(dc,{handleControlSelect:this.handleControlSelect,handleToolSelect:this.handleToolSelect,onClearFilter:this.handleClearFilter})]}),a&&v(Q,{kind:"ghost",className:"btn-panels-menu btn-show-panels","data-testid":"app-main-panels-button",onClick:this.handleWidgetMenuClick,icon:Jf,children:["Panels",h(xn,{isShown:c,className:"panels-menu-popper",onExited:this.handleWidgetsMenuClose,closeOnBlur:!0,interactive:!0,children:h(A1,{widgets:m,onExportLayout:this.handleExportLayoutClick,onImportLayout:this.handleImportLayoutClick,onResetLayout:this.handleResetLayoutClick,onSelect:this.handleWidgetSelect})})]}),h(Q,{kind:"ghost",className:z("btn-settings-menu",{"text-warning":s.operateAs!==s.name}),onClick:this.handleSettingsMenuShow,icon:h(K,{icon:zo,transform:"grow-3 right-1 down-1"}),tooltip:"User Settings"})]})]})}),v(f0,{emptyDashboard:h(V1,{onAutoFillClick:this.handleAutoFillClick}),id:Rn,layoutConfig:r,onGoldenLayoutChange:this.handleGoldenLayoutChange,onLayoutConfigChange:this.handleLayoutConfigChange,onLayoutInitialized:this.openNotebookFromURL,hydrate:this.hydrateDefault,children:[h(QE,{hydrate:this.hydrateGrid,getDownloadWorker:ll.getServiceWorker,loadPlugin:this.handleLoadTablePlugin}),h(GE,{hydrate:this.hydrateChart}),h(KE,{}),h(YE,{hydrateConsole:Oo.hydrateConsole,notebooksUrl:new URL("/notebooks/",`${window.location}`).href}),h(XE,{}),h(i1,{hydrate:this.hydratePandas}),h(s1,{}),h(n1,{}),p]}),h(ht,{in:u,timeout:Tt.transitionMidMs,classNames:"slide-left",mountOnEnter:!0,unmountOnExit:!0,children:h(Qo,{onDone:this.handleSettingsMenuHide})}),h(oe,{actions:d}),h("input",{ref:this.importElement,type:"file",accept:".json",style:{display:"none"},onChange:this.handleImportLayoutFiles})]})}}const Q1=t=>{var e,n;return{activeTool:Rl(t),dashboardData:qt(t,Rn),layoutStorage:L1(t),plugins:vS(t),connection:iE(t,Rn),session:(e=gi(t,Rn))==null?void 0:e.session,sessionConfig:(n=gi(t,Rn))==null?void 0:n.config,user:cm(t),workspace:yl(t)}},Z1=Dt(Q1,{setActiveTool:Dl,updateDashboardData:qn,updateWorkspaceData:vm})(fg(Oo)),J1=()=>v("div",{className:"app",children:[h(Z1,{}),h(yu,{})]}),e2=X.module("LocalWorkspaceStorage"),No=class{static async makeDefaultWorkspaceData(t,e){const{filterSets:n,links:s,layoutConfig:i}=await Br.getDefaultLayout(t,e==null?void 0:e.isConsoleAvailable);return{settings:{defaultDateTimeFormat:at.DEFAULT_DATETIME_FORMAT_STRING,formatter:[],timeZone:at.DEFAULT_TIME_ZONE_ID,showTimeZone:!1,showTSeparator:!0,disableMoveConfirmation:!1,defaultDecimalFormatOptions:{defaultFormatString:Pe.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:nt.DEFAULT_FORMAT_STRING},truncateNumbersWithPound:!1},layoutConfig:i,closed:[{}],links:s,filterSets:n}}static async makeDefaultWorkspace(t,e){return{data:await No.makeDefaultWorkspaceData(t,e)}}constructor(t){this.layoutStorage=t}async load(t){var e;try{return JSON.parse((e=localStorage.getItem(No.STORAGE_KEY))!=null?e:"")}catch{return e2.info("Unable to load workspace data, initializing to default data"),No.makeDefaultWorkspace(this.layoutStorage,t)}}async save(t){return localStorage.setItem(No.STORAGE_KEY,JSON.stringify(t)),t}};let Kp=No;Kp.STORAGE_KEY="deephaven.WorkspaceStorage";class t2 extends Error{constructor(){super(...arguments),this.isNoConsolesError=!0}}function n2(t){return t.isNoConsolesError}const Li=X.module("SessionUtils");function s2(){return new URL("/jsapi",`${window.location}`)}function qp(){const t=s2();return`${t.protocol}//${t.host}`}function i2(){const t=qp();return Li.info(`Starting connection to '${t}'...`),new M.IdeConnection(t)}async function o2(t){Li.info("Getting console types...");const e=await t.getConsoleTypes();if(Li.info("Available types:",e),e.length===0)throw new t2("No console types available");const n=e[0];Li.info("Starting session with type",n);const s=await t.startSession(n),i={type:n,id:We.generate()};return Li.info("Console session established",i),{session:s,config:i,connection:t}}function r2(){const t=qp();return Li.info("createCoreClient",t),new M.CoreClient(t)}class l2{constructor(e,n=""){this.storageService=e,this.root=n}async getLayouts(){return(await this.storageService.listItems(this.root,"*.json")).map(n=>n.basename)}async getLayout(e){const s=await(await this.storageService.loadFile(`${this.root}/${e}`)).text();return JSON.parse(s)}}const vo=X.module("GrpcFileStorageTable"),Za=class{constructor(t,e="",n=e){this.currentSize=0,this.listeners=[],this.childTables=new Map,this.storageService=t,this.baseRoot=e,this.root=n,n===e&&(this.doRefresh=Xe(this.doRefresh.bind(this),Za.REFRESH_DEBOUNCE))}removeBaseRoot(t){return de.removeRoot(this.baseRoot,t)}getViewportData(){var t;return this.viewportUpdatePromise||this.refreshInternal(),(t=this.viewportUpdatePromise)!=null?t:Promise.resolve({items:[],offset:0})}getSnapshot(t){throw new Error("Method not implemented.")}get size(){return this.currentSize}setExpanded(t,e){const n=t.split("/");let s=n.shift();if((s===void 0||s==="")&&(s=n.shift()),s===void 0||s==="")throw new Error(`Invalid path: ${t}`);const i=n.join("/");if(e){if(!this.childTables.has(s)){const o=new Za(this.storageService,this.baseRoot,`${this.root}/${s}`);this.childTables.set(s,o)}if(i){const o=this.childTables.get(s);o==null||o.setExpanded(i,e)}}else if(this.childTables.has(s))if(i){const o=this.childTables.get(s);o==null||o.setExpanded(i,e)}else this.childTables.delete(s);this.currentViewport&&this.refreshInternal()}collapseAll(){this.childTables.clear(),this.currentViewport&&this.refreshInternal()}setSearch(t){throw new Error("Method not implemented.")}setViewport(t){this.currentViewport=t,this.refreshInternal()}setFilters(){throw new Error("Method not implemented.")}setSorts(){throw new Error("Method not implemented.")}setReversed(){throw new Error("Method not implemented.")}close(){this.listeners=[]}onUpdate(t){return this.listeners=[...this.listeners,t],()=>{this.listeners=this.listeners.filter(e=>e!==t)}}doRefresh(t){vo.debug2("doRefresh",this.root),t(this.fetchData())}refresh(){var n;vo.debug2("refresh",this.root),(n=this.viewportUpdatePromise)==null||n.cancel();const t=new Promise(s=>{this.doRefresh(s)}),e=Ee.makeCancelable(t.then(s=>{if(this.viewportUpdatePromise!==e)throw new di;return this.currentViewportData=s,this.sendUpdate(),s}));e.catch(s=>{Ee.isCanceled(s)||vo.error("Error updating viewport",s)}),this.viewportUpdatePromise=e}refreshInternal(){try{this.refresh()}catch(t){Ee.isCanceled(t)||vo.error("Unable to refresh data",t)}}async fetchData(){const{currentViewport:t}=this;if(!t)throw new Error("No viewport set");let n=(await this.storageService.listItems(this.root)).map(s=>({type:s.type,filename:this.removeBaseRoot(s.filename),basename:s.basename,id:this.removeBaseRoot(s.filename),isExpanded:s.type==="directory"?this.childTables.has(s.basename):void 0})).sort((s,i)=>s.type!==i.type?s.type==="directory"?-1:1:s.basename.localeCompare(i.basename));for(let s=0;s<n.length;s+=1){const i=n[s],{basename:o,filename:r}=i;if(r===this.removeBaseRoot(`${this.root}/${o}`)&&i.type==="directory"){const l=this.childTables.get(o);if(l!=null){l.setViewport({top:0,bottom:t.bottom-s});const a=await l.getViewportData();n.splice(s+1,0,...a.items)}}}return this.currentSize=n.length,vo.debug2(this.root,"items",n,t),n=n.slice(t.top,t.bottom),{items:n,offset:t.top}}sendUpdate(){var n;const{listeners:t}=this,e=(n=this.currentViewportData)!=null?n:{items:[],offset:0};for(let s=0;s<t.length;s+=1)t[s](e)}};let Yp=Za;Yp.REFRESH_DEBOUNCE=50;const a2=X.module("GrpcFileStorage"),Xp=class{constructor(t,e=""){this.tables=[],this.refreshTables=hs(()=>{this.tables.forEach(n=>n.refresh())},Xp.REFRESH_THROTTLE),this.storageService=t,this.root=e}removeRoot(t){return de.removeRoot(this.root,t)}addRoot(t){return de.addRoot(this.root,t)}async createDirectory(t){return await this.storageService.createDirectory(this.addRoot(t)),this.refreshTables(),{type:"directory",id:t,filename:t,basename:de.getBaseName(t)}}async getTable(){const t=new Yp(this.storageService,this.root);return this.tables.push(t),t}async saveFile(t){const e=dh.storage.FileContents.text(t.content);return await this.storageService.saveFile(this.addRoot(t.filename),e,!0),this.refreshTables(),t}async loadFile(t){const n=await(await this.storageService.loadFile(this.addRoot(t))).text();return{filename:t,basename:de.getBaseName(t),content:n}}async deleteFile(t){await this.storageService.deleteItem(this.addRoot(t)),this.refreshTables()}async moveFile(t,e){await this.storageService.moveItem(this.addRoot(t),this.addRoot(e)),this.refreshTables()}async info(t){const e=await this.storageService.listItems(this.addRoot(de.getPath(t)),de.getBaseName(t));if(e.length===0)throw new tc;if(e.length>1)throw a2.error("More than one matching file found, should never happen.",e),new Error("More than one matching file found");const n=e[0];return{filename:this.removeRoot(n.filename),basename:this.removeRoot(n.basename),id:this.removeRoot(n.filename),type:n.type}}};let jp=Xp;jp.REFRESH_THROTTLE=150;const li=X.module("AppInit");async function d2(){li.debug("Loading plugins...");try{const t=await Qa.loadJson("/js-plugins/manifest.json");li.debug("Plugin manifest loaded:",t);const e=[];for(let i=0;i<t.plugins.length;i+=1){const{name:o,main:r}=t.plugins[i],l=`/js-plugins/${o}/${r}`;e.push(Qa.loadModulePlugin(l))}const n=await Promise.all(e),s=new Map;for(let i=0;i<n.length;i+=1){const{name:o}=t.plugins[i];s.set(o,n[i])}return li.info("Plugins loaded:",s),s}catch(t){return li.error("Unable to load plugins:",t),new Map}}async function c2(t){let e;try{e=await o2(t)}catch(n){if(!n2(n))throw n}return e}const cc=t=>{const{workspace:e,setActiveTool:n,setCommandHistoryStorage:s,setDashboardData:i,setFileStorage:o,setLayoutStorage:r,setDashboardConnection:l,setDashboardSessionWrapper:a,setPlugins:d,setUser:c,setWorkspace:u,setWorkspaceStorage:m}=t,[p,g]=S.exports.useState(),[f,b]=S.exports.useState(!0),C=S.exports.useCallback(async()=>{var I,R;try{li.info("Initializing Web UI","0.21.1",navigator.userAgent);const F=await d2(),x=i2(),U=await c2(x);x.addEventListener(M.IdeConnection.HACK_CONNECTION_FAILURE,J=>{var fe;const{detail:pe}=J;li.error("Connection failure",pe),g(`Unable to connect: ${(fe=pe.details)!=null?fe:"Unknown Error"}`)});const $="user",O={name:$,operateAs:$,groups:[],permissions:{isSuperUser:!1,isQueryViewOnly:!1,isNonInteractive:!1,canUsePanels:!0,canCreateDashboard:!0,canCreateCodeStudio:!0,canCreateQueryMonitor:!0,canCopy:!0,canDownloadCsv:!0}},H=r2();await H.login({type:M.CoreClient.LOGIN_TYPE_ANONYMOUS});const L=H.getStorageService(),N=new l2(L,"/layouts"),_=new jp(L,"/notebooks"),k=new Kp(N),V=new f1,W=await k.load({isConsoleAvailable:U!==void 0}),{data:j}=W,{settings:ee}=j;ee.defaultDecimalFormatOptions===void 0&&(ee.defaultDecimalFormatOptions={defaultFormatString:Pe.DEFAULT_FORMAT_STRING}),ee.defaultIntegerFormatOptions===void 0&&(ee.defaultIntegerFormatOptions={defaultFormatString:nt.DEFAULT_FORMAT_STRING}),ee.truncateNumbersWithPound===void 0&&(ee.truncateNumbersWithPound=!1);const{shortcutOverrides:ve={}}=ee,Se=$t.isMacPlatform?(I=ve.mac)!=null?I:{}:(R=ve.windows)!=null?R:{};Object.entries(Se).forEach(([J,pe])=>{var fe;(fe=Be.get(J))==null||fe.setKeyState(pe)});const Le={filterSets:j.filterSets,links:j.links};n(dn.DEFAULT),s(V),i(Rn,Le),o(_),r(N),l(Rn,x),U!==void 0&&a(Rn,U),d(F),c(O),m(k),u(W)}catch(F){li.error(F),g(F)}},[n,s,i,o,r,l,a,d,c,u,m]),w=S.exports.useCallback(()=>{document.fonts!=null?document.fonts.ready.then(()=>{b(!1)}):b(!1)},[]);S.exports.useEffect(function(){C(),w()},[C,w]);const T=e==null&&p==null||f,y=!T&&p==null,E=p!=null?`${p}`:null;return v(ue,{children:[y&&h(J1,{}),h(Cl,{isLoading:T,isLoaded:y,errorMessage:E}),v("div",{id:"preload-fonts",style:{visibility:"hidden",position:"absolute",top:-1e4},children:[h("p",{className:"fira-sans-regular",children:"preload"}),h("p",{className:"fira-sans-semibold",children:"preload"}),h("p",{className:"fira-mono",children:"preload"})]})]})};cc.propTypes={workspace:D.exports.shape({}),workspaceStorage:D.exports.shape({close:D.exports.func}),setActiveTool:D.exports.func.isRequired,setCommandHistoryStorage:D.exports.func.isRequired,setDashboardData:D.exports.func.isRequired,setFileStorage:D.exports.func.isRequired,setLayoutStorage:D.exports.func.isRequired,setDashboardConnection:D.exports.func.isRequired,setDashboardSessionWrapper:D.exports.func.isRequired,setPlugins:D.exports.func.isRequired,setUser:D.exports.func.isRequired,setWorkspace:D.exports.func.isRequired,setWorkspaceStorage:D.exports.func.isRequired};cc.defaultProps={workspace:null,workspaceStorage:null};const h2=t=>({workspace:yl(t),workspaceStorage:uS(t)}),Zh=Dt(h2,{setActiveTool:Dl,setCommandHistoryStorage:yS,setDashboardData:Gm,setFileStorage:IS,setLayoutStorage:C1,setDashboardConnection:oE,setDashboardSessionWrapper:rE,setPlugins:DS,setUser:TS,setWorkspace:wm,setWorkspaceStorage:ES})(cc),u2=()=>h(Cg,{basename:"/ide/",children:v(bg,{children:[h(vc,{exact:!0,path:"/",component:Zh}),h(vc,{path:"/notebook/:notebookPath+",component:Zh}),h(Sg,{from:"*",to:"/"})]})});Boolean(window.location.hostname==="localhost"||window.location.hostname==="[::1]"||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));function m2(){"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(t=>{t.forEach(e=>{e.scope.endsWith("/download/")||e.unregister()})})}M1();ui.render(h(tu,{store:Ml,children:h(u2,{})}),document.getElementById("root"));m2();ll.registerOnLoaded();lt.init();window["__react-beautiful-dnd-disable-dev-warnings"]=!0;
|
|
44
|
+
//# sourceMappingURL=index.4bbf2b74.js.map
|