@deephaven/code-studio 0.22.3-beta.10 → 0.22.3-beta.11
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.
|
@@ -20,7 +20,7 @@ ${e}`):s.setValue(`${e}`);const o=s.getLineCount(),r=s.getLineLength(o)+1;this.e
|
|
|
20
20
|
`&&(n+=`
|
|
21
21
|
`))}}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>Pt.maxLogSize&&(this.messages=this.messages.splice(this.messages.length-Pt.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=Pt.getLogText(n);t+=s,s.charAt(s.length-1)!==`
|
|
22
22
|
`&&(t+=`
|
|
23
|
-
`)}this.bufferedMessages=[],this.appendLogText(t)}queue(t){this.bufferedMessages.push(t),this.bufferedMessages.length===1&&(this.flushTimer=setTimeout(this.handleFlushTimeout,Pt.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(z,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:dC,tooltip:"Clear log"}),h(z,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:zo,tooltip:"Log Settings",onClick:()=>{},children:h(Gn,{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 Zi=Pt;Zi.DefaultLogLevels=[St.STDOUT,St.ERROR,St.FATAL,St.STDERR,St.WARN];Zi.AllLogLevels=[St.INFO,St.STDOUT,St.ERROR,St.FATAL,St.STDERR,St.WARN,St.DEBUG,St.TRACE];Zi.bufferTimeout=16;Zi.maxLogSize=131072;Zi.truncateSize=65536;class et{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""}}et.TYPE_GLOBAL="type-global";et.TYPE_CONTEXT_PRESET="type-context-preset";et.TYPE_CONTEXT_CUSTOM="type-context-custom";class Gb extends et{format(e){switch(e){case 1:case!0:return"true";case 0:case!1:return"false";default:return""}}}class Kb extends et{format(e){return String.fromCharCode(e)}}const oh=X.module("DateTimeColumnFormatter"),Xs=class extends et{constructor({timeZone:t="",showTimeZone:e=!0,showTSeparator:n=!1,defaultDateTimeFormatString:s=Xs.DEFAULT_DATETIME_FORMAT_STRING}={}){super();const i=t||Xs.DEFAULT_TIME_ZONE_ID;try{this.dhTimeZone=M.i18n.TimeZone.getTimeZone(i)}catch{oh.error("Unsupported time zone id",i),this.dhTimeZone=M.i18n.TimeZone.getTimeZone(Xs.DEFAULT_TIME_ZONE_ID)}this.defaultDateTimeFormatString=s,this.showTimeZone=e,this.showTSeparator=n,this.formatStringMap=Xs.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=et.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[...Xs.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[...Xs.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{oh.error("Invalid format arguments")}return""}};let dt=Xs;dt.DEFAULT_DATETIME_FORMAT_STRING="yyyy-MM-dd HH:mm:ss.SSS";dt.DEFAULT_TIME_ZONE_ID="America/New_York";const qb=X.module("DecimalColumnFormatter"),Fn=class extends et{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=et.TYPE_CONTEXT_PRESET,s){return{label:t,type:n,formatString:e,multiplier:s}}static makePresetFormat(t,e="",n){return Fn.makeFormat(t,e,et.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(t="",e){return Fn.makeFormat("Custom Format",t,et.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{qb.error("Invalid format arguments")}return""}};let Le=Fn;Le.DEFAULT_FORMAT_STRING="###,##0.0000";Le.FORMAT_PERCENT=Fn.makePresetFormat("Percent","##0.00%");Le.FORMAT_BASIS_POINTS=Fn.makePresetFormat("Basis Points","###,##0 bp",1e4);Le.FORMAT_MILLIONS=Fn.makePresetFormat("Millions","###,##0.000 mm",1e-6);Le.FORMAT_SCIENTIFIC_NOTATION=Fn.makePresetFormat("Scientific Notation","0.0000E0");Le.FORMAT_ROUND=Fn.makePresetFormat("Round","###,##0");Le.FORMAT_ROUND_TWO_DECIMALS=Fn.makePresetFormat("0.00","###,##0.00");Le.FORMAT_ROUND_FOUR_DECIMALS=Fn.makePresetFormat("0.0000","###,##0.0000");class Yb extends et{format(e){return`${e}`}}const Xb=X.module("IntegerColumnFormatter"),Vi=class extends et{constructor({defaultFormatString:t=Vi.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=et.TYPE_CONTEXT_PRESET,s){return{label:t,type:n,formatString:e,multiplier:s}}static makePresetFormat(t,e="",n){return Vi.makeFormat(t,e,et.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(t="",e){return Vi.makeFormat("Custom Format",t,et.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{Xb.error("Invalid format arguments")}return""}};let it=Vi;it.DEFAULT_FORMAT_STRING="###,##0";it.FORMAT_MILLIONS=Vi.makePresetFormat("Millions","###,##0.000 mm",1e-6);it.FORMAT_SCIENTIFIC_NOTATION=Vi.makePresetFormat("Scientific Notation","0.0000E0");class jb extends et{format(e){return e}}const Gt=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(Gt.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=Gt.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 Gt.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<Gt.months.length;s+=1)if(Gt.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=Gt.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()),d=Gt.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()+1);return[a,d]}if(n==="yesterday"){const l=new Date(Date.now()),a=Gt.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()-1),d=Gt.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=Gt.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=Gt.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=Gt.makeDateWrapper(e,i.year,i.month,i.date,i.hours,i.minutes,i.seconds,i.nanos),r=Gt.getNextDate(s,i,e);return[o,r]}static getJsDate(t){return typeof t=="number"?new Date(t):t.asDate()}};let ps=Gt;ps.FULL_DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSSSSS";ps.months=["january","february","march","april","may","june","july","august","september","october","november","december"];class Yt{}Yt.not="not";Yt.and="and";Yt.or="or";function Qb(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 Zb(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 Jb(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 eS(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 tS(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]=ps.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 yu(`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===Yt.and)l=l.and(p);else if(g===Yt.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]=ps.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 sn.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 un{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 Yb,this.typeFormatterMap=new Map([[P.dataType.BOOLEAN,new Gb],[P.dataType.CHAR,new Kb],[P.dataType.DATETIME,new dt(n)],[P.dataType.DECIMAL,new Le(s)],[P.dataType.INT,new it(i)],[P.dataType.STRING,new jb]]),this.columnFormatMap=un.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 nS(t){if(t&&t.formatter){const{formatter:e}=t;return e}}function sS(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 iS(t,e,n){const s=t.getColumnFormat(n,e);return s!=null&&(s.type===et.TYPE_CONTEXT_PRESET||s.type===et.TYPE_CONTEXT_CUSTOM)}const hs={getColumnFormats:nS,getDateTimeFormatterOptions:sS,isCustomColumnFormatDefined:iS};$r.register([Ig,Rg,Dg,Mg,Ng,Fg]);const dm=typeof na=="function"?na($r):na.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 wt=is;wt.EVENT_UPDATED="ChartModel.EVENT_UPDATED";wt.EVENT_DISCONNECT="ChartModel.EVENT_DISCONNECT";wt.EVENT_RECONNECT="ChartModel.EVENT_RECONNECT";wt.EVENT_DOWNSAMPLESTARTED="ChartModel.EVENT_DOWNSAMPLESTARTED";wt.EVENT_DOWNSAMPLEFINISHED="ChartModel.EVENT_DOWNSAMPLEFINISHED";wt.EVENT_DOWNSAMPLEFAILED="ChartModel.EVENT_DOWNSAMPLEFAILED";wt.EVENT_DOWNSAMPLENEEDED="ChartModel.EVENT_DOWNSAMPLENEEDED";wt.EVENT_LOADFINISHED="ChartModel.EVENT_LOADFINISHED";const oS="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",rS="#403e41",lS="#5b5a5c",aS="#c0bfbf",dS="#4878ea",cS="rgba(91, 90, 92, 0.7)",It={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:oS,gridcolor:rS,linecolor:lS,zerolinecolor:aS,activecolor:dS,rangebgcolor:cS,"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"},qt=Object.freeze({paper_bgcolor:It["paper-bgcolor"],plot_bgcolor:It["plot-bgcolor"],title_color:It["title-color"],colorway:It.colorway,gridcolor:It.gridcolor,linecolor:It.linecolor,zerolinecolor:It.zerolinecolor,activecolor:It.activecolor,rangebgcolor:It.rangebgcolor,area_color:It["area-color"],trend_color:It["trend-color"],line_color:It["line-color"],error_band_line_color:It["error-band-line-color"],error_band_fill_color:It["error-band-fill-color"],ohlc_increasing:It["ohlc-increasing"],ohlc_decreasing:It["ohlc-decreasing"]}),br=X.module("ChartUtils"),Es=Object.freeze(M.calendar.DayOfWeek.values()),rh="io.deephaven.time.DateTime",hS=36e5,uS=1e6;function mS(t){return t.asDate!==void 0}function pS(t){return t.asNumber!==void 0}function lh(t){return t.dhTimeZone!==void 0}function gS(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&&lh(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?",":"",C=c!=null&&c!==""?"e":"f",b=u!==""?u:C,w=a.length+d.length,y=`0${p}${f}.${w}${b}`,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/uS),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=qt){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);su(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=qt,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:C}=f,b=o.get(C);A(b);const w=b.indexOf(f),T=ie.getAxisPropertyName(C);if(T!=null){const y=ie.getAxisLayoutProperty(T,w);if(n.has(y))br.debug(`${y} already added.`);else{br.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 D=[],{businessPeriods:F,businessDays:x,holidays:U,timeZone:$}=I,_=e==null?void 0:e.getColumnTypeFormatter(rh);let H;lh(_)&&(H=_.dhTimeZone);const L=H?($.standardOffset-H.standardOffset)/60:0;U.length>0&&D.push(...ie.createRangeBreakValuesFromHolidays(U,$,H)),F.forEach(N=>D.push({pattern:"hour",bounds:[ie.periodToDecimal(N.close)+L,ie.periodToDecimal(N.open)+L]})),x.length<Es.length&&ie.createBoundsFromDays(x).forEach(N=>D.push({pattern:"day of week",bounds:N})),E.rangebreaks=D}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];gS(o)&&(e[i]=[...o.range])}return e}static updateFigureAxes(t,e,n,s=0,i=0,o=qt){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,C={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?C.right-=(C.right-C.left)*Math.max(0,Math.min(ie.LEGEND_WIDTH_PX/n,ie.MAX_LEGEND_SIZE)):C.right-=(C.right-C.left)*ie.DEFAULT_AXIS_SIZE),C}static updateLayoutAxes(t,e,n,s=0,i=0,o={left:0,top:0,right:1,bottom:1},r,l=qt){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 C=p[f],b=ie.getAxisPropertyName(C);if(b!=null){const w=m.get(C),T=g.get(C),E=C===M.plot.AxisType.Y?i:s;A(w),A(T);for(let I=0;I<w.length;I+=1){const D=w[I],F=T.indexOf(D),x=ie.getAxisLayoutProperty(b,F);c[x]==null&&(c[x]=ie.makeLayoutAxis(C,l));const U=c[x];if(U!=null){ie.updateLayoutAxis(U,D,I,u,a,d,o);const{range:$,autorange:_}=U;if(r!=null&&$!==void 0&&(_===void 0||_===!1)){const H=r(D),[L,N]=H($);br.debug("Setting downsample range",E,L,N),D.range(E,L,N)}else D.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)||[],C=Math.max(r.left,r.left+(g.length-1)*o),b=Math.min(r.right-(f.length-1)*o,r.right);d.domain=[C,b]}else if(e.type===M.plot.AxisType.Y){const g=s.get(M.plot.AxisPosition.BOTTOM)||[],f=s.get(M.plot.AxisPosition.TOP)||[],C=Math.max(r.bottom,r.bottom+(g.length-1)*i),b=Math.min(r.top-(f.length-1)*i,r.top);d.domain=[C,b]}}static periodToDecimal(t){const e=t.split(":");return Number(e[0])+Number(e[1])/60}static createBoundsFromDays(t){const e=t.map(o=>Es.indexOf(o)),n=Es.filter(o=>!t.includes(o)).map(o=>Es.indexOf(o)),s=new Set;n.forEach(o=>{for(let r=o+1;r<o+Es.length;r+=1){const l=r%Es.length;if(e.includes(l)){s.add(l);break}}});const i=[];return s.forEach(o=>{for(let r=o-1;r>o-Es.length;r-=1){const l=r<0?r+Es.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=hS*(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,rh,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(mS(t))return M.i18n.DateTimeFormat.format(ie.DATE_FORMAT,t,e);if(pS(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=qt){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=qt){let e=[];return t.colorway&&(Array.isArray(t.colorway)?e=t.colorway:typeof t.colorway=="string"?e=t.colorway.split(" "):br.warn(`Unable to handle colorway property: ${t.colorway}`)),e}static makeDefaultLayout(t=qt){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 Fe=ie;Fe.DEFAULT_AXIS_SIZE=.15;Fe.MIN_AXIS_SIZE=.025;Fe.MAX_AXIS_SIZE=.2;Fe.AXIS_SIZE_PX=75;Fe.LEGEND_WIDTH_PX=50;Fe.MAX_LEGEND_SIZE=.25;Fe.ORIENTATION=Object.freeze({HORIZONTAL:"h",VERTICAL:"v"});Fe.DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSS";Fe.DEFAULT_MARGIN=Object.freeze({l:60,r:50,t:30,b:60,pad:0});Fe.DEFAULT_TITLE_PADDING=Object.freeze({t:8});Fe.SUBTITLE_LINE_HEIGHT=25;const ys=X.module("Chart"),yo=class extends S.exports.Component{constructor(t){super(t),this.getCachedConfig=me((e,n,s,i)=>{const o=[],r=Boolean(e);if(r&&o.push({name:`Downsampling failed: ${e}`,click:()=>{},icon:yo.convertIcon(Tu),attr:"fill-warning"}),n||s||i||r){const l=yo.downsampleButtonTitle(s,i),a=yo.downsampleButtonAttr(s,i),d=s?fu:Zf;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){ys.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(ys.debug2("Received data update",e,n),e){case wt.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 wt.EVENT_LOADFINISHED:{const{onUpdate:i}=this.props;this.isLoadedFired=!0,i({isLoading:!1});break}case wt.EVENT_DISCONNECT:{const{onDisconnect:i}=this.props;i();break}case wt.EVENT_RECONNECT:{const{onReconnect:i}=this.props;i();break}case wt.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case wt.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case wt.EVENT_DOWNSAMPLENEEDED:case wt.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:ys.debug("Unknown event type",e,t)}}handlePlotUpdate(t){const{layout:e}=t,n=Fe.getLayoutRanges(e);!ht(n,this.ranges)&&(this.ranges=n,this.updateModelDimensions(!0))}handleRelayout(t){if(ys.debug("handleRelayout",t),t.hiddenlabels!=null){const{onSettingsChanged:e}=this.props,n=[...t.hiddenlabels];e({hiddenSeries:n})}this.updateModelDimensions()}handleRestyle([t,e]){if(ys.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){ys.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=hs.getColumnFormats(t),n=hs.getDateTimeFormatterOptions(t),{decimalFormatOptions:s={},integerFormatOptions:i={}}=t;(!ht(this.columnFormats,e)||!ht(this.dateTimeFormatterOptions,n)||!ht(this.decimalFormatOptions,s)||!ht(this.integerFormatOptions,i))&&(this.columnFormats=hs.getColumnFormats(t),this.dateTimeFormatterOptions=n,this.decimalFormatOptions=s,this.integerFormatOptions=i,this.updateFormatter())}updateFormatter(){const t=new un(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=>{ys.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(dm,{ref:this.plot,data:t,layout:o,revision:r,config:l,onAfterPlot:this.handleAfterPlot,onError:ys.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}};let cm=yo;cm.defaultProps={isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:ps.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}};const Ot=X.module("FigureChartModel"),hm=class extends wt{constructor(t,e={},n=qt){super(),this.addPendingSeries=je(()=>{const i=Fe.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=[]},hm.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=>Fe.unwrapValue(l,r)}),this.getValueParser=Te((i,o)=>{const r=this.getTimeZone(i,o);return l=>Fe.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=Fe.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:Fe.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=Fe.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=Fe.groupArray(e,"type"),s=Fe.makeSeriesDataFromSeries(t,n,Fe.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=Fe.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){Ot.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){Ot.debug("Downsample started",t),this.fireDownsampleStart(t.detail)}handleDownsampleFinish(t){Ot.debug("Downsample finished",t),this.fireDownsampleFinish(t.detail)}handleDownsampleFail(t){Ot.error("Downsample failed",t),this.fireDownsampleFail(t.detail)}handleDownsampleNeeded(t){Ot.info("Downsample needed",t),this.fireDownsampleNeeded(t.detail)}handleFigureUpdated(t){const{detail:e}=t,{series:n}=e;Ot.debug2("handleFigureUpdated",n);for(let i=0;i<n.length;i+=1){const o=n[i];Ot.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){Ot.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){Ot.debug("Figure disconnected",t),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(t){Ot.debug("Figure reconnected",t),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(t){const{detail:e}=t;Ot.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=Fe.DEFAULT_MARGIN.t+e*Fe.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=Fe.DEFAULT_TITLE_PADDING.t+e*Fe.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();Fe.updateFigureAxes(this.layout,this.figure,n=>this.getAxisRangeParser(n,this.formatter),t,e,this.theme)}updateLayoutFormats(){if(!this.formatter)return;Fe.getAxisFormats(this.figure,this.formatter).forEach((e,n)=>{Ot.debug(`Assigning ${n}`,this.layout[n],e);const s=this.layout[n];s!=null?Object.assign(s,e):Ot.debug(`Ignoring null layout.${n}`)})}setDataArrayForSeries(t,e,n){const{name:s,plotStyle:i}=t,o=this.seriesDataMap.get(s),r=Fe.getPlotlyProperty(i,e);o&&su(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=Fe.getPlotlyErrorBars(i,o,r)),a&&d&&a!==l&&(s.error_y=Fe.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){Ot.warn("Trying to set a filter, but no one click!");return}Ot.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 _a=hm;_a.ADD_SERIES_DEBOUNCE=50;class Wi{static async makeModelFromSettings(e,n,s=qt){const i=await Wi.makeFigureFromSettings(e,n);return new _a(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(Fe.makeFigureSettings(e,s))}static async makeModel(e,n,s=qt){return new _a(n,e,s)}}function ah(t){return t.setFigure!==void 0}const fS=({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 _=async()=>{const L=await t.getWorkerHeapInfo();if(r(L),s||l){const N=(L.totalHeapSize-L.freeMemory)/L.maximumHeapSize,O=Date.now(),{timestamps:k,usages:V}=d.current;for(;k.length!==0&&O-k[0]>i*1.5;)k.shift(),V.shift();k.push(O),V.push(N)}else d.current={timestamps:[],usages:[]}};_();const H=setInterval(_,l?n:e);return()=>{clearInterval(H)}},[l,n,t,e,i,s]);const c=($,_)=>Math.round($*10**_)/10**_,u=2,m=1024**3,{freeMemory:p,totalHeapSize:g,maximumHeapSize:f}=o,C=c(p/m,u),b=c(g/m,u),w=c(f/m,u),T=b-C,y=($,_,H=!1)=>v("div",{className:W("heap-usage-info-row",{"heading-bottom-border":H}),children:[h("div",{className:"font-weight-bold",children:$}),h("div",{children:_})]}),{timestamps:E,usages:I}=d.current,D=(U=E[E.length-1])!=null?U:0,F=g/f,x=(g-p)/f;return v(pe,{children:[v("div",{className:"max-memory",children:[h("div",{className:"total-memory",style:{width:`calc(${F*100}% - ${F*2}px`}}),h("div",{className:W("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($e,{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:",`${C.toFixed(u)} GB`),y("Total:",`${b.toFixed(u)} GB`),y("Max:",`${w.toFixed(u)} GB`),h("div",{className:"heap-plot",children:h(dm,{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:qt.linecolor,range:[D-i,D],linecolor:qt.linecolor,linewidth:2,mirror:!0},yaxis:{dtick:.2,gridcolor:qt.linecolor,range:[0,1],linecolor:qt.linecolor,linewidth:2,mirror:!0}}})}),v("div",{className:"heap-utilisation-text",children:["% utilization over ",Math.round(i/1e3/60)," min."]})]})})]})},wd=Object.freeze({}),CS=new Map,um=t=>t.user,vd=t=>t.storage,mm=t=>vd(t).commandHistoryStorage,pm=t=>vd(t).fileStorage,bS=t=>vd(t).workspaceStorage,Il=t=>t.workspace,Nt=t=>Il(t).data.settings,SS=t=>Nt(t).defaultDateTimeFormat,wS=t=>{var e;return(e=Nt(t).defaultDecimalFormatOptions)!=null?e:wd},vS=t=>{var e;return(e=Nt(t).defaultIntegerFormatOptions)!=null?e:wd},TS=t=>Nt(t).formatter,Rl=t=>Nt(t).timeZone,ES=t=>Nt(t).showTimeZone,yS=t=>Nt(t).showTSeparator,IS=t=>Nt(t).truncateNumbersWithPound,RS=t=>Nt(t).shortcutOverrides,DS=t=>{var e;return(e=Nt(t).defaultNotebookSettings)!=null?e:wd},Dl=t=>t.activeTool,MS=t=>{var e;return(e=t.plugins)!=null?e:CS},gm="SET_ACTIVE_TOOL",fm="SET_COMMAND_HISTORY_STORAGE",Cm="SET_FILE_STORAGE",bm="SET_PLUGINS",Sm="SET_USER",wm="SET_WORKSPACE",vm="SET_WORKSPACE_STORAGE",Tm="SET_SERVER_CONFIG_VALUES",NS=t=>({type:Sm,payload:t}),Em=t=>({type:wm,payload:t}),FS=t=>({type:vm,payload:t}),xS=t=>({type:fm,payload:t}),_S=t=>({type:Cm,payload:t}),OS=t=>(e,n)=>{e(Em(t));const{storage:s}=n(),{workspaceStorage:i}=s;return i.save(t)},ym=t=>(e,n)=>{const{workspace:s}=n(),{data:i}=s,o={...s,data:{...i,...t}};return e(OS(o))},Td=t=>e=>e(ym({settings:t})),Ml=t=>({type:gm,payload:t}),kS=t=>({type:bm,payload:t}),LS=t=>({type:Tm,payload:t});function Im(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 AS(t,e={},n=!0){return(s=e,i)=>{switch(i.type){case t:{const{id:o,payload:r}=i;return n&&ht({payload:r},{payload:s[o]})?s:{...s,[o]:r}}default:return s}}}function As(t,e){return(n=e,s)=>{switch(s.type){case t:return s.payload;default:return n}}}const PS=As(gm,null),HS=As(bm,null),VS=As(fm,null),US=As(Cm,null),BS=As(vm,null),$S=td({commandHistoryStorage:VS,fileStorage:US,workspaceStorage:BS}),WS=Im(Sm,null),zS=Im(wm,null),GS=As(Tm,null),KS={activeTool:PS,plugins:HS,storage:$S,user:WS,workspace:zS,serverConfigValues:GS};class qS{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 Ji=new qS,ch=X.module("redux-logger"),YS=t=>e=>n=>{ch.debug("dispatching",n);const s=e(n);return ch.debug("next state",t.getState()),s},XS=X.module("redux-crashReporter"),jS=t=>e=>n=>{try{return e(n)}catch(s){throw XS.error("Error executing",n," with state ",t.getState(),":",s),s}},QS=[YS,jS,rg];Object.entries(KS).map(([t,e])=>Ji.register(t,e));var nu;const ZS=(nu=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__)!=null?nu:dg,Nl=lg(td(Ji.reducers),ZS(ag(...QS)));Ji.setListener(t=>{Nl.replaceReducer(td(t))});const Rm=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 Dm(t){return t.componentName!==void 0}function JS(t){return t.component!==void 0}const Mm=Object.freeze({type:"default",isClosable:!0,isFocusOnShow:!0,reorderEnabled:!0,title:""}),e0=Object.freeze(Object.defineProperty({__proto__:null,defaultConfig:Rm,isGLComponentConfig:Dm,isReactComponentConfig:JS,itemDefaultConfig:Mm},Symbol.toStringTag,{value:"Module"})),Oa=class{constructor(){this.off=this.unbind,this.trigger=this.emit,this._mSubscriptions={},this._mSubscriptions[Oa.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[Oa.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 Sn=Oa;Sn.ALL_EVENT="__all";class ka extends Sn{constructor(e,n,s){super(),this.isHidden=!1,this._element=ue(['<div class="lm_item_container">','<div class="lm_content" tabindex="-1"></div>',"</div>"].join("")),this.title=Dm(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(ue.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 t0=Object.freeze(Object.defineProperty({__proto__:null,ItemContainer:ka,Container:ka},Symbol.toStringTag,{value:"Module"}));function Nm(t){var e=location.hash.match(new RegExp(t+"=([^&]*)"));return e?e[1]:null}function Fm(t){if(window.location.hash)return Nm(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 Fl(t){return window.requestAnimationFrame(t)}function n0(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 Ed(){return(Math.random()*1e15).toString(36).replace(".","")}function s0(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 yd(t){return ue.trim(t.replace(/(<([^>]+)>)/gi,""))}class Go extends Sn{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=ue(document),this._eBody=ue(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 xm{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(){hi.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(){hi.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=ue.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"],i0=[!0,!1,"row","column","stack","component","close","maximise","minimise","open in new window"];function Id(t){if(Qr.length>36)throw new Error("Too many keys in config minifier map");const e={};return Rd(t,e,"_min"),e}function La(t){if(Qr.length>36)throw new Error("Too many keys in config minifier map");const e={};return Rd(t,e,"_max"),e}function Rd(t,e,n){const s=n==="_min"?o0:r0;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}Rd(o,r,n)}else{const r=s(o,i0);if(Array.isArray(e))e[Number.parseInt(i,10)]=r;else{const l=s(i,Qr);e[l]=r}}}}function o0(t,e){if(typeof t=="string"&&t.length===1)return"___"+t;var n=e.indexOf(t);return n===-1?t:n.toString(36)}function r0(t,e){return typeof t=="string"&&t.length===1?e[parseInt(t,36)]:typeof t=="string"&&t.substr(0,3)==="___"?t[3]:t}class Aa{constructor(e,n){this.name=e,this.origin=n,this.isPropagationStopped=!1}stopPropagation(){this.isPropagationStopped=!0}}class _m extends Sn{constructor(e){super(),this._layoutManager=e,this._dontPropagateToParent=null,this._childEventSource=null,this.on(Sn.ALL_EVENT,this._onEventFromThis.bind(this)),this._boundOnEventFromChild=this._onEventFromChild.bind(this),ue(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(){ue(window).off("gl_child_event",this._boundOnEventFromChild)}}const l0=Object.freeze(Object.defineProperty({__proto__:null,EventEmitter:Sn,DragListener:Go,ReactComponentHandler:xm,BubblingEvent:Aa,EventHub:_m,getHashValue:Nm,getQueryStringParam:Fm,animFrame:Fl,removeFromArray:n0,getUniqueId:Ed,filterXss:s0,stripTags:yd,minifyConfig:Id,unminifyConfig:La},Symbol.toStringTag,{value:"Module"}));class Om extends Sn{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=ue.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;ue(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-"+Ed();e=Id(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 km=class extends Sn{constructor(t,e,n,s,i,o){var l,a,d,c,u,m,p,g,f,C,b,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=ue(km._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",yd((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(),ue(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=((C=this._layoutManager.container.height())!=null?C:0)+this._minY,this._width=(b=this.element.width())!=null?b: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 Ko=km;Ko._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 Lm{constructor(e,n,s){this._element=e,this._itemConfig=n,this._layoutManager=s,this._dragListener=this._createDragListener()}_createDragListener(){return this._dragListener=new Go(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(ue.extend(!0,{},s)),o=new Ko(e,n,this._dragListener,this._layoutManager,i,null);(r=this._layoutManager.transitionIndicator)==null||r.transitionElements(this._element,o.element)}}class Am{constructor(e,n,s){this._element=ue(window),this._itemConfig=e,this._layoutManager=n,this._createDragListener(s)}_createDragListener(e){this._dragListener&&this._dragListener.destroy(),this._element&&(this._dragListener=new Go(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(ue.extend(!0,{},s));new Ko(e,n,this._dragListener,this._layoutManager,i,null)}}}const Pm=class{constructor(){this.element=ue(Pm._template),ue(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 Dd=Pm;Dd._template='<div class="lm_dropTargetIndicator"><div class="lm_inner"></div></div>';class Io{constructor(e,n,s,i){this._header=e,this.element=ue('<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 a0=Object.freeze(Object.defineProperty({__proto__:null,ConfigurationError:ii},Symbol.toStringTag,{value:"Module"}));function Po(t){return t.isStack}function In(t){return t.isComponent}function Hm(t){return t.isRoot}class Tt extends Sn{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(Sn.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,Po(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&&In(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 Aa(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(Mm)){const i=n;e[i]===void 0&&(e[i]=s)}return e}_propagateEvent(e,n){n instanceof Aa&&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,Fl(this._propagateEventToLayoutManager.bind(this,e,n)))}_propagateEventToLayoutManager(e,n){this._pendingEventPropagations[e]=!1,this.layoutManager.emit(e,n)}}class Vm extends Tt{constructor(e,n,s){super(e,n,s,ue()),this.config=n,this.parent=s;const i=e.getComponent(this.config.componentName)||e.getFallbackComponent(),o=ue.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 ka(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(){Tt.prototype._$init.call(this),this.container.emit("open")}_$hide(){this.container.hide(),Tt.prototype._$hide.call(this)}_$show(){this.container.show(),this.container._config.isFocusOnShow&&this.container._contentElement[0].focus({preventScroll:!0}),Tt.prototype._$show.call(this)}_$destroy(){this.container.emit("destroy",this),Tt.prototype._$destroy.call(this)}_$getArea(){return null}}class Zr extends Tt{constructor(e,n,s,i){super(n,s,i,ue('<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),Tt.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));Tt.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(Tt.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 Bm(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}),Fl(this.callDownwards.bind(this,"setSize",void 0,void 0,void 0))}}class Pa extends Tt{constructor(e,n,s){super(e,{...n,type:"root"},null,ue('<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(In(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 Ha extends Tt{constructor(e,n,s){var o,r,l,a,d,c,u,m,p;super(e,n,s,ue('<div class="lm_item lm_stack"></div>')),this._activeContentItem=null,this.childElementContainer=ue('<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 qo(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(){Tt.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(In(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,C,b,w,T,y,E,I,D,F,x,U,$,_,H,L,N,O,k,V,G,Q;const n=this.header.tabs.length;if(n===0){const J=this.header.element.offset();(w=this.layoutManager.dropTargetIndicator)==null||w.highlightArea({x1:(u=J==null?void 0:J.left)!=null?u:0,x2:((m=J==null?void 0:J.left)!=null?m:0)+100,y1:(g=(p=this.header.element.offset())==null?void 0:p.top)!=null?g:0,y2:((C=(f=this.header.element.offset())==null?void 0:f.top)!=null?C:0)+((b=this.header.element.innerHeight())!=null?b: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=(D=this.layoutManager.tabDropPlaceholder.offset())==null?void 0:D.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=(_=this.header.tabsContainer.offset())==null?void 0:_.left)!=null?H:0)+((L=this.header.tabsContainer.innerWidth())!=null?L:0)),(Q=this.layoutManager.dropTargetIndicator)==null||Q.highlightArea({x1:d,x2:c,y1:(O=(N=this.header.element.offset())==null?void 0:N.top)!=null?O:0,y2:((V=(k=this.header.element.offset())==null?void 0:k.top)!=null?V:0)+((G=this.header.element.innerHeight())!=null?G: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 d0=Object.freeze(Object.defineProperty({__proto__:null,AbstractContentItem:Tt,ContentItem:Tt,Component:Vm,Root:Pa,RowOrColumn:Zr,Stack:Ha,isStack:Po,isComponent:In,isRoot:Hm},Symbol.toStringTag,{value:"Module"})),Um=class{constructor(t,e){var n;this.element=ue(Um._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 Go(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),In(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),In(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 Ko(t,e,this._dragListener,this._layoutManager,this.contentItem,this.header.parent)}_onTabContentFocusIn(){In(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&this.contentItem.container._contentElement[0].focus(),this.element.addClass("lm_focusin")}_onTabContentFocusOut(){In(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&&In(this.contentItem)?(this.header.parent.setActiveContentItem(this.contentItem),this.contentItem.container.emit("tabClicked")):In(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(),In(this.contentItem)?this.contentItem.container.close():this.header.parent.removeChild(this.contentItem)}_onCloseMousedown(t){t.stopPropagation()}};let Md=Um;Md._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 Sn{constructor(t,e){var n,s;super(),this.element=ue(Ar._template),this.tabDropdownList=null,this.tabs=[],this.activeContentItem=null,this.closeButton=null,this.tabDropdownButton=null,this.tabNextButton=ue(Ar._nextButtonTemplate),this.tabPreviousButton=ue(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 Md(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(),ue(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"),ue(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(),ue(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=ue(window).scrollTop())!=null?i:0);e+t>((o=ue(window).height())!=null?o:0)&&this.tabDropdownContainer.css("max-height",((r=ue(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 qo=Ar;qo._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("");qo._previousButtonTemplate=['<ul class="lm_controls">','<li class="lm_tabpreviousbutton"></li>',"</ul>"].join("");qo._nextButtonTemplate=['<li class="lm_tabnextbutton"></li>'].join("");class Bm{constructor(e,n,s){this._isVertical=e,this._size=n,this._grabSize=s<n?n:s,this.element=this._createElement(),this._dragListener=new Go(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=ue('<div class="lm_drag_handle"></div>'),n=ue('<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 $m{constructor(){this._element=ue('<div class="lm_transition_indicator"></div>'),this._toElement=null,this._fromDimensions={},this._totalAnimationDuration=200,this._animationStartTime=null,ue(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),Fl(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 c0=Object.freeze(Object.defineProperty({__proto__:null,BrowserPopout:Om,DragProxy:Ko,DragSource:Lm,DragSourceFromEvent:Am,DropTargetIndicator:Dd,Header:qo,HeaderButton:Io,Splitter:Bm,Tab:Md,TransitionIndicator:$m},Symbol.toStringTag,{value:"Module"})),h0={config:e0,container:t0,controls:c0,errors:a0,items:d0,utils:l0};class Nd extends Sn{constructor(e,n){super(),this.isInitialised=!1,this._isFullPage=!1,this._components={"lm-react-component":xm},this._itemAreas=[],this._maximisedItem=null,this._maximisePlaceholder=ue('<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 _m(this),this.dropTargetIndicator=null,this.transitionIndicator=null,this.tabDropPlaceholder=ue('<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&&ue("body").css("visibility","hidden"),this._typeToItem={column:Zr.bind(this,!0),row:Zr.bind(this,!1),stack:Ha,component:Vm}}static minifyConfig(e){return Id(e)}static unminifyConfig(e){return La(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 Tt))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){ue(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 Dd,this.transitionIndicator=new $m,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(),ue(window).off("resize",this._onResize),ue(window).off("unload beforeunload",this._onUnload),ue(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 Ha)&&!!n&&!(this.isSubWindow===!0&&n instanceof Pa)&&(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 Tt,l=this;if(r){o=this.toConfig(e).content,s=Ed();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 Om(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 Lm(e,n,this);return this._dragSources.push(s),s}createDragSourceFromEvent(e,n){return this.config.settings.constrainDragToContainer=!1,new Am(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(!Po(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 Tt)return e;if(ue.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&&ue(window).resize(this._onResize),ue(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=Fm("gl-window");n&&(this.isSubWindow=!0,e=JSON.parse(localStorage.getItem(n)||"{}"),e=La(e),localStorage.removeItem(n)),e=ue.extend(!0,{},Rm,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=ue('<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=yd((n=this.config.content[0].title)!=null?n:""),ue("head").append(ue("body link, body style, template, .gl_keep")),this.container=ue("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?ue(this._originalContainer):ue("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,ue("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 Pa(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=>{Po(s)?e.push(s):s.isComponent||this._findAllStackContainersRecursive(e,s)})}}Nd.__lm=h0;const u0="_lm_root_15d73_3",m0="_lm_row_15d73_7",p0="_lm_item_15d73_7",g0="_lm_content_15d73_11",f0="_lm_dragging_15d73_17",C0="_lm_maximised_15d73_23",b0="_lm_maximise_placeholder_15d73_30",S0="_lm_splitter_15d73_34",w0="_lm_vertical_15d73_41",v0="_lm_drag_handle_15d73_41",T0="_lm_horizontal_15d73_46",E0="_lm_header_15d73_56",y0="_lm_dropdown_open_15d73_63",I0="_lm_controls_15d73_69",R0="_lm_tabs_15d73_89",D0="_lm_tab_15d73_89",M0="_lm_title_15d73_104",N0="_lm_close_tab_15d73_111",F0="_lm_stack_15d73_120",x0="_lm_left_15d73_120",_0="_lm_right_15d73_121",O0="_lm_dragProxy_15d73_125",k0="_lm_items_15d73_148",L0="_lm_tabdropdown_list_15d73_165",A0="_lm_bottom_15d73_192",P0="_lm_drop_tab_placeholder_15d73_207",H0="_lm_tabdropdown_15d73_165",V0="_lm_dropTargetIndicator_15d73_258",U0="_lm_inner_15d73_264",B0="_lm_transition_indicator_15d73_272",$0="_lm_popin_15d73_282",W0="_lm_bg_15d73_297",z0="_lm_icon_15d73_300",G0="_lm_goldenlayout_15d73_304",K0="_lm_selectable_15d73_340",q0="_lm_active_15d73_370",Y0="_lm_selected_15d73_388",X0="_lm_keyboard_active_15d73_397",j0="_lm_popout_15d73_416",Q0="_lm_maximise_15d73_23",Z0="_lm_close_15d73_111",J0="_lm_tabnextbutton_15d73_425",ew="_lm_tabpreviousbutton_15d73_428",tw="_lm_title_before_15d73_544",nw="_lm_focusin_15d73_568",sw="_lm_window_blur_15d73_573",iw="_lm_tabdropdown_search_15d73_631",ow="_march_15d73_1",rw="_app_15d73_712",lw="_plotly_15d73_721",hh={"tab-height":"28px","drag-border-width":"5px",lm_root:u0,lm_row:m0,lm_item:p0,lm_content:g0,lm_dragging:f0,lm_maximised:C0,lm_maximise_placeholder:b0,lm_splitter:S0,lm_vertical:w0,lm_drag_handle:v0,lm_horizontal:T0,lm_header:E0,lm_dropdown_open:y0,lm_controls:I0,lm_tabs:R0,lm_tab:D0,lm_title:M0,lm_close_tab:N0,lm_stack:F0,lm_left:x0,lm_right:_0,lm_dragProxy:O0,lm_items:k0,lm_tabdropdown_list:L0,lm_bottom:A0,lm_drop_tab_placeholder:P0,lm_tabdropdown:H0,lm_dropTargetIndicator:V0,lm_inner:U0,lm_transition_indicator:B0,lm_popin:$0,lm_bg:W0,lm_icon:z0,lm_goldenlayout:G0,lm_selectable:K0,lm_active:q0,lm_selected:Y0,lm_keyboard_active:X0,lm_popout:j0,lm_maximise:Q0,lm_close:Z0,lm_tabnextbutton:J0,lm_tabpreviousbutton:ew,lm_title_before:tw,"editor-unsaved-indicator":"_editor-unsaved-indicator_15d73_548","is-unsaved":"_is-unsaved_15d73_556",lm_focusin:nw,lm_window_blur:sw,lm_tabdropdown_search:iw,march:ow,app:rw,"js-plotly-plot":"_js-plotly-plot_15d73_721",plotly:lw},uh=Object.freeze({tabHeight:parseInt(hh["tab-height"],10),dragBorderWidth:parseInt(hh["drag-border-width"],10)}),Is=X.module("LayoutUtils");function Wm(t){return t.componentName!==void 0}function Oi(t){const e=t;return(Wm(t)&&t.componentName==="lm-react-component"||t.type==="react-component")&&e.component!==void 0}function Sr(t){return t.focus!==void 0}function mh(t){return t.type==="stack"}const Be=class{static activateTab(t,e){const n=Be.getStackForRoot(t,e,!1);if(!n){Is.error("Could not find stack for config",e);return}const s=Be.getContentItemInStack(n,e);s&&n.setActiveContentItem(s)}static isActiveTab(t,e){const n=Be.getStackForRoot(t,e,!1);if(!n)return Is.error("Could not find stack for config",e),!1;const s=Be.getContentItemInStack(n,e);return n.getActiveContentItem()===s}static addStack(t,e=!0){const n=e?"column":"row";if(Hm(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&&Po(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&&vc(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=Be.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&&vc(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):Is.debug2(`dehydrateLayoutConfig: skipping unmapped component "${o}"`)}else if(r){const l={...i,content:Be.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?(mh(n)&&delete n.activeItemIndex,Be.dropLayoutMinorChange(s)):Oi(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=Be.cloneLayout(t),i=Be.cloneLayout(e);return Be.dropLayoutMinorChange(s),Be.dropLayoutMinorChange(i),ht(s,i)}return ht(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(Oi(o)){const{component:r,props:l={}}=o;n.push({...o,id:(s=o==null?void 0:o.id)!=null?s:ze(),props:e(r,l)})}else if(o.content!==void 0){const r=Be.hydrateLayoutConfig(o.content,e);mh(o)&&o.activeItemIndex!=null&&o.activeItemIndex>=r.length&&(Is.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=ze.generate()),r){t==null||t.layoutManager.createDragSourceFromEvent(a,r);return}const d=s||{id:a.id,component:a.component};A(t);const c=i?Be.addStack(t):Be.getStackForRoot(t,d);A(c);const u=Be.getContentItemInStack(c,d);if(o!=null){const m=p=>{Is.debug("Component created, focusing element",o),c.off("componentCreated",m);const{element:g}=p.origin;requestAnimationFrame(()=>{Be.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&&Sr(l)&&l.focus()}static openComponentInStack(t,e,n=!0){const s=document.activeElement,i={id:e.id},o=Be.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&&Sr(s)&&s.focus()}static closeComponent(t,e){const n=Be.getStackForRoot(t,e,!1,!1,!1);if(!n){Is.warn("Cannot find stack for component, ignoring close",e);return}const s=Be.getContentItemInStack(n,e),i=document.activeElement;s&&(s.isComponent?s.container.close():n.removeChild(s)),i&&document.contains(i)&&Sr(i)&&i.focus()}static renameComponent(t,e,n){const s=Be.getStackForRoot(t,e,!1);if(!s){Is.error("Could not find stack for config",e);return}const i=Be.getContentItemInStack(s,e);i&&i.setTitle(n)}static cloneComponent(t,e){const n=Be.getStackForRoot(t,e,!1);if(!n)return Is.error("Could not find stack for config",e),null;const{props:s={}}=e,i=Be.getPanelComponentState(e),o={type:"react-component",component:e.component,props:{...s,panelState:i},title:`${e.title} Copy`,id:ze.generate()};return Be.openComponentInStack(n,o),o}static getPanelComponentState(t){var e,n;return Wm(t)?(e=t.componentState)==null?void 0:e.panelState:Oi(t)?(n=t.props)==null?void 0:n.panelState:null}static makeDefaultLayout(){return{dimensions:{headerHeight:uh.tabHeight,borderWidth:uh.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=Be.getComponentConfigFromContainer(t);return e?e.id:null}static getIdFromPanel(t){const{glContainer:e}=t.props;return Be.getIdFromContainer(e)}static getComponentNameFromPanel(t){var s;const{glContainer:e}=t.props,n=Be.getComponentConfigFromContainer(e);return n&&Oi(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=Be.DEFAULT_FOCUS_SELECTOR){if(t==null)return null;const n=t.querySelector(e);return n==null?null:(Sr(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=Be;te.DEFAULT_FOCUS_SELECTOR="input, select, textarea, button";const aw=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 ph(t){return(t==null?void 0:t.WrappedComponent)!==void 0}function dw(t){return typeof t.id=="string"&&t.layout instanceof Nd&&t.panelManager instanceof Fd&&typeof t.registerComponent=="function"}function Ps(t){if(!dw(t))throw new Error(`Expected dashboard plugin props, but instead received ${t}`)}const pn=X.module("PanelManager");class Fd{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&&Oi(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=>ph(s)&&n instanceof s.WrappedComponent||!ph(s)&&n instanceof s))}updatePanel(e){const n=te.getIdFromPanel(e);if(n==null){pn.error("updatePanel Panel did not have an ID",e);return}pn.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){pn.error("removePanel Panel did not have an ID",e);return}if(!this.openedMap.has(n)){pn.error(`Missing panel ID ${n} in open panels map`);return}if(this.openedMap.get(n)!==e){pn.debug(`Panel argument doesn't match the open panels map entry for ${n}, removePanel ignored`);return}pn.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){pn.debug2("Focus: ",e),this.updatePanel(e)}handleMount(e){pn.debug2("Mount: ",e),this.updatePanel(e),this.sendUpdate()}handleUnmount(e){pn.debug2("Unmount: ",e),this.removePanel(e),this.sendUpdate()}handleReopen(e,n){pn.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){pn.debug2("Deleted:",e),this.removeClosedPanelConfig(e),this.sendUpdate()}handleClosed(e,n){pn.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&&Oi(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)})}}Fd.MAX_CLOSED_PANEL_COUNT=100;const cw=X.module("PanelErrorBoundary");class hw 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);cw.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(bl,{errorMessage:`${n}`,isLoading:!1,isLoaded:!1})}):e}}function xd(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 _d(t,e=""){return{metadata:{},...t,localDashboardId:e}}const Va={dehydrate:xd,hydrate:_d},uw=R.exports.shape({on:R.exports.func,off:R.exports.func,isHidden:R.exports.bool,tab:R.exports.shape({header:R.exports.shape({tabs:R.exports.arrayOf(R.exports.shape({contentItem:R.exports.shape({})}))})}),title:R.exports.string,setTitle:R.exports.func,close:R.exports.func}),zm=R.exports.shape({on:R.exports.func,off:R.exports.func,emit:R.exports.func}),mw=R.exports.shape({registerComponent:R.exports.func,root:R.exports.shape({addChild:R.exports.func}),on:R.exports.func,off:R.exports.func,eventHub:zm}),Od=Object.freeze({Container:uw,EventHub:zm,Layout:mw}),Ke=(t,e,n)=>S.exports.useEffect(function(){return t.on(e,n),()=>{t.off(e,n)}},[t,e,n]),Gm="SET_DASHBOARD_DATA",pw=AS(Gm,{},!1),gw={dashboardData:pw},fw=new Map,Cw=Object.freeze({}),bw=Object.freeze([]),Sw=t=>t.dashboardData,jt=(t,e)=>{var n;return(n=Sw(t)[e])!=null?n:Cw},ww=(t,e)=>{var n;return(n=jt(t,e).closed)!=null?n:bw},Km=(t,e)=>{var n;return(n=jt(t,e).openedMap)!=null?n:fw},qm=(t,e)=>({type:Gm,id:t,payload:e}),Yn=(t,e)=>(n,s)=>n(qm(t,{...jt(s(),t),...e}));Object.entries(gw).map(([t,e])=>Ji.register(t,e));const wr=X.module("DashboardLayout"),vw=Object.freeze({}),Tw=[],gh=()=>{},fh=t=>t,Ym=({id:t,children:e,emptyDashboard:n=h("div",{children:"Dashboard is empty."}),layout:s,layoutConfig:i=Tw,onLayoutChange:o=gh,onLayoutInitialized:r=gh,hydrate:l=_d,dehydrate:a=xd})=>{var O,k;const d=nd(),c=(O=cg(V=>jt(V,t)))!=null?O:vw,[u,m]=S.exports.useState(!1),[p,g]=S.exports.useState(!1),[f,C]=S.exports.useState(),[b]=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=hg(),D=S.exports.useCallback((V,G,Q=l,J=a)=>{wr.debug2("registerComponent",V,G,Q,J);function ve(_e,ee){const ge=G,{glContainer:Se,glEventHub:Re}=_e;return h(iu,{store:I,children:h(hw,{glContainer:Se,glEventHub:Re,children:h(ge,{..._e,ref:ee})})})}const le=Y.forwardRef(ve),be=s.registerComponent(V,le);return y.set(V,Q),E.set(V,J),be},[l,a,y,E,s,I]),F=S.exports.useCallback((V,G)=>{var Q;return((Q=y.get(V))!=null?Q:fh)(G,t)},[y,t]),x=S.exports.useCallback((V,G)=>{var Q;return((Q=E.get(V))!=null?Q:fh)(G,t)},[E,t]),U=S.exports.useMemo(()=>new Fd(s,F,x,new Map,b,({closed:V,openedMap:G})=>{d(Yn(t,{closed:V,openedMap:G}))}),[x,d,F,t,b,s]),$=S.exports.useCallback(()=>{if(p)return;w||(r(),T(!0));const G=s.toConfig().content,Q=te.dehydrateLayoutConfig(G,x),J=f==null||!te.isEqual(f,Q);wr.debug("handleLayoutStateChanged",J,G,Q),J&&(m(s.root.contentItems.length===0),C(Q),o(Q))},[x,w,p,f,s,o,r]),_=S.exports.useCallback(()=>{g(!0)},[]),H=S.exports.useCallback(()=>{g(!1)},[]),L=S.exports.useCallback(V=>{if(wr.debug2("handleComponentCreated",V),V==null||V.config==null||V.config.component==null||V.element==null)return;const Q=`${V.config.component.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}-component`;V.element.addClass(Q)},[]);Ke(s,"stateChanged",$),Ke(s,"itemPickedUp",_),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){wr.debug("Setting new layout content...");const G=te.hydrateLayoutConfig(i,F);for(;s.root.contentItems.length>0;)s.root.contentItems[0].remove();for(let Q=0;Q<G.length;Q+=1)s.root.addChild(G[Q]);m(s.root.contentItems.length===0)}},[F,s,i,f,U,N]),v(pe,{children:[u&&n,Y.Children.map(e,V=>V!=null?Y.cloneElement(V,{id:t,layout:s,panelManager:U,registerComponent:D}):null)]})};Ym.propTypes={id:R.exports.string.isRequired,children:R.exports.node,data:R.exports.shape({}),emptyDashboard:R.exports.node,layout:Od.Layout.isRequired,layoutConfig:R.exports.arrayOf(R.exports.shape({})),onLayoutChange:R.exports.func,onLayoutInitialized:R.exports.func};const Ew=100,aa=()=>{},yw=Object.freeze({}),Iw=({id:t="default",children:e,emptyDashboard:n,layoutConfig:s,layoutSettings:i=yw,onLayoutConfigChange:o=aa,onGoldenLayoutChange:r=aa,onLayoutInitialized:l=aa,fallbackComponent:a=aw,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 Nd(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 C=S.exports.useMemo(()=>us(()=>{g!=null&&g.isInitialised&&(g==null||g.updateSize())},Ew),[g]);return S.exports.useEffect(function(){return window.addEventListener("resize",C),()=>{window.removeEventListener("resize",C)}},[C]),v("div",{className:"dashboard-container w-100 h-100",children:[h("div",{className:"w-100 h-100",ref:u}),m&&g&&h(Ym,{emptyDashboard:n,id:t,layout:g,layoutConfig:s,onLayoutChange:o,onLayoutInitialized:l,hydrate:d,dehydrate:c,children:e})]})},Dn="default";var ui=(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))(ui||{});const Rw=Object.freeze([[ui.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS,!1],[ui.LINK_CHANGE_CLEARS_ALL_FILTERS,!1]]),Xm={DEFAULTS:Rw};var ke=(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))(ke||{});const Dw=t=>{switch(t){default:return!1}},Mw=(t,e)=>{switch(t){case ke.COUNT:case ke.FIRST:case ke.LAST:case ke.COUNT_DISTINCT:case ke.DISTINCT:case ke.UNIQUE:return!0;case ke.MIN:case ke.MAX:return P.isNumberType(e)||P.isDateType(e)||P.isTextType(e);case ke.SUM:case ke.ABS_SUM:case ke.VAR:case ke.AVG:case ke.STD:return P.isNumberType(e);case ke.SKIP:return!1}},kd=(t,e)=>t.filter(n=>Mw(e,n.type)),Nw=(t,e,n,s)=>kd(t,e).map(({name:i})=>i).filter(i=>n.includes(i)?!s:s),ks={isRollupOperation:Dw,filterValidColumns:kd,getOperationColumnNames:Nw};const Ch=X.module("Aggregations"),Fw=[ke.SUM,ke.ABS_SUM,ke.MIN,ke.MAX,ke.VAR,ke.AVG,ke.STD,ke.FIRST,ke.LAST,ke.COUNT_DISTINCT,ke.DISTINCT,ke.COUNT,ke.UNIQUE],xw=({isRollup:t,settings:e,onChange:n,onEdit:s})=>{const{aggregations:i,showOnTop:o}=e,r=S.exports.useMemo(()=>Fw.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(()=>{Ch.debug("handleDragStart"),Xt.startDragging()},[]),f=S.exports.useCallback(({destination:x,source:U})=>{if(Ch.debug("handleDragEnd",x,U),Xt.stopDragging(),x===null)return;let $=x.index;U.index<x.index&&($+=1);const _=[...i],H=Xt.reorder(_,d,_,$),L=Xt.adjustDestinationIndex($,d),N=[[L,L+H.length-1]];m(_),c(N)},[m,i,d,c]),C=S.exports.useCallback(x=>{a(x)},[a]),b=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:_})=>{const H=x.operation,L=$?`${_}`:void 0,N=$?"item-list-item-clone":void 0,O=ks.isRollupOperation(x.operation),k=!$&&!O;return v(pe,{children:[v("div",{className:W("item-list-item-content","draggable-item-list-item-content",N),children:[v("span",{className:"title",children:[H,!t&&O&&v("span",{className:"small text-warning",children:[h(j,{icon:Tu})," Requires rollup"]})]}),on.renderBadge({text:L}),on.renderHandle()]}),!$&&v(pe,{children:[h(z,{kind:"ghost",className:"btn-edit",icon:hl,tooltip:"Edit Columns",onClick:()=>s(x),disabled:!k}),h(z,{kind:"ghost",className:"btn-delete",icon:_n,tooltip:"Delete Aggregation",onClick:()=>w(U)})]})]})},[w,s,t]),D=r.length>0,F=i.length>0;return v("div",{className:"aggregations",children:[D&&v("div",{className:"form-inline",children:[h(UC,{onChange:C,value:l,children:r.map(x=>h(VC,{value:x,children:x},x))}),v("button",{type:"button",className:"btn btn-link btn-add",onClick:b,children:[h(j,{icon:Ls}),"Add Aggregation"]})]}),D&&F&&h("hr",{}),F&&v(pe,{children:[!t&&v("div",{className:"form-inline",children:[h("label",{children:"Placement:\xA0"}),v(Sl,{onChange:E,value:`${o}`,children:[h(Nn,{value:"true",children:"Top"}),h(Nn,{value:"false",children:"Bottom"})]})]}),h(Uo,{onDragStart:g,onDragEnd:f,children:h(on,{className:"selected-aggregations",itemCount:i.length,items:i,renderItem:I,offset:0,onSelectionChange:T,onSelect:y,selectedRanges:d,isMultiSelect:!0})})]})]})};const _w=30,Ow=({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=kd(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],D=c.indexOf(I);let F=[...c],x=d;D>=0?F.splice(D,1):(F.push(I),F.length===p.length&&(F=[],x=!d)),n({...t,selected:F,invert:x})},[t,d,p,c,n]),C=S.exports.useCallback(()=>{a(0),n({...t,selected:[],invert:!0})},[t,n]),b=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(Bt,{checked:T,onChange:w,children:"Toggle All"}),h("div",{className:"spacer"}),h(ut,{in:y,timeout:Et.transitionSlowMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:h(z,{kind:"ghost",className:"btn-reset",onClick:C,children:"Reset"})}),h(z,{kind:"ghost",className:W({active:l===1}),icon:hd,tooltip:"Sort ascending",onClick:()=>a(1)}),h(z,{kind:"ghost",className:W({active:l===2}),icon:ud,tooltip:"Sort descending",onClick:()=>a(2)})]})}),h("div",{className:"aggregation-edit-item-list",children:h(bn,{itemCount:p.length,items:g,offset:s,renderItem:({item:E})=>h(Bt,{checked:m(E.value),children:E.displayValue}),onSelect:f,onViewportChange:b,rowHeight:_w,focusSelector:"input",ref:u})})]})};function kw(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 Lw(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 Aw(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 Pw(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 Hw(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 Vw(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 Uw(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 bh=X.module("ChartBuilder"),ft=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(Aw,{});case M.plot.SeriesPlotStyle.BAR:return h(kw,{});case M.plot.SeriesPlotStyle.SCATTER:return h(Hw,{});case M.plot.SeriesPlotStyle.PIE:return h(Pw,{});case M.plot.SeriesPlotStyle.HISTOGRAM:return h(Lw,{});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:ze.generate(),value:t}}static makeDefaultSeriesItems(t,e){if(ft.getMaxSeriesCount(t)===0||e==null||e.length===0)return[];const s=e.length>1?e[1].name:e[0].name;return[ft.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=ft.types[0],i=ft.getDefaultXAxis(s,n),o=ft.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:ze.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=ft.types[0],s=ft.getDefaultXAxis(n,e),i=ft.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=ft.types[s];bh.debug2("handleTypeSelect",i),this.setState(o=>{const r=ft.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=ft.makeDefaultSeriesItems(i,d)}return{type:i,seriesItems:l}},this.sendChange)}handleXAxisChange(t){const e=t.target.value;bh.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=ft.getMaxSeriesCount(s),l=ft.getXAxisLabel(s),a=ft.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:ft.types.map((u,m)=>{const p=u;return h("div",{className:"col col-chart-type",children:v("button",{type:"button",className:W("btn","btn-icon","btn-chart-type",{active:u===s}),"data-index":m,onClick:this.handleTypeClick,children:[ft.getTypeIcon(u),ft.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(z,{kind:"ghost",className:"btn-delete-series ml-2 px-2","data-index":m,"data-testid":`delete-series-${m}`,onClick:this.handleSeriesDeleteClick,icon:_n,tooltip:"Delete"})]},u.id)),c&&v("div",{className:"form-row",children:[h("div",{className:"col-2"}),h(z,{kind:"ghost",className:"btn-add-series mt-1",onClick:this.handleAddSeries,icon:Ls,children:"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(j,{mask:pd,icon:Ao,transform:"right-5 down-5"}),h(j,{icon:o?ld:cC,transform:"grow-2 right-8 down-6"})]})}),v(Sl,{onChange:this.handleLinkStateChange,value:`${o}`,children:[h(Nn,{value:"true",children:"Sync State"}),h(Nn,{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:W("form-row","justify-content-end","my-3"),children:[h(z,{kind:"secondary",className:"btn-reset",onClick:this.handleReset,children:"Reset"}),h(z,{kind:"primary",type:"submit",className:"btn-submit",children:"Create"})]})]})})}};let jm=ft;jm.types=[M.plot.SeriesPlotStyle.LINE,M.plot.SeriesPlotStyle.BAR,M.plot.SeriesPlotStyle.SCATTER,M.plot.SeriesPlotStyle.PIE];class Qm 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:W("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"})]})}}Qm.defaultProps={value:"",onContentChanged:()=>{},editorSettings:{},editorIndex:0,onTab:()=>{},invalid:!1};const Ua=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,Ua.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:W("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:W("form-control custom-column-input",{"is-invalid":l}),placeholder:"Column Name",value:e,onChange:c=>{s(t,Ua.INPUT_TYPE.NAME,c.target.value)}}),h(z,{kind:"ghost",className:"ml-1 px-2",onClick:()=>{i(t)},icon:_n,tooltip:"Delete custom column"}),v("button",{type:"button",className:"btn btn-link btn-link-icon px-2 btn-drag-handle",...a.dragHandleProps,children:[h($e,{children:"Drag column to re-order"}),h(j,{icon:ul})]})]}),h(Qm,{editorSettings:{language:"deephavenDb"},editorIndex:o,value:n,onContentChanged:this.handleFormulaEditorContentChanged,onTab:r,invalid:l})]}),h("hr",{})]})})}};let Ld=Ua;Ld.INPUT_TYPE={NAME:"name",FORMULA:"formula"};Ld.defaultProps={name:"",inputIndex:0,formula:"",onChange:()=>{},onDeleteColumn:()=>{},onTabInEditor:()=>{},invalid:!1};class Zm extends Error{constructor(){super(...arguments),this.isAssertionFailed=!0}}function Sh(t){if(t==null)throw new Zm(`Expected 'val' to be defined, but received ${t}`)}class da extends Error{constructor(){super(...arguments),this.isPasteError=!0}}function Je(t){return(t==null?void 0:t.isEditable)!==void 0}function wh(t){if(!Je(t))throw new Zm(`Expected 'model' to be editable, but received ${t}`)}function pt(t){return(t==null?void 0:t.hasExpandableRows)!==void 0}var Mn=(t=>(t.DOWN="DOWN",t.UP="UP",t.LEFT="LEFT",t.RIGHT="RIGHT",t))(Mn||{});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=Mn;function Bw(t){return Array.isArray(t)&&t.length===2&&(t[0]===null||typeof t[0]=="number")&&(t[1]===null||typeof t[1]=="number")}function ca(t){return Bw(t)&&t[0]!=null&&t[1]!=null}const Ne=class{static getGridPointFromXY(t,e,n){const s=Ne.getColumnAtX(t,n),i=Ne.getRowAtY(e,n),o=Ne.getColumnHeaderDepthAtY(e,n);return{x:t,y:e,row:i,column:s,columnHeaderDepth:o}}static getCellInfoFromXY(t,e,n){const{row:s,column:i}=Ne.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,C=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:C!=null?C:null}}static getColumnHeaderDepthAtY(t,e){const n=Ne.getRowAtY(t,e),{columnHeaderHeight:s,columnHeaderMaxDepth:i}=e;if(n===null&&t<=s*i)return Ut(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=Ne.iterateFloatingStart(t,n,s);return i!==void 0?i:Ne.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=Ne.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:Ne.iterateFloating(n,s,e,d=>{if(Ne.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(Ne.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 Ne.getNextShownItem(t,n,s,i)}static getNextShownRow(t,e){const{modelRows:n,visibleRows:s,userRowHeights:i}=e;return Ne.getNextShownItem(t,n,s,i)}static getColumnSeparatorIndex(t,e,n,s){var b,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 C=!1;for(let E=r.length-1;E>=0;E-=1){const I=r[E],D=(b=d.get(I))!=null?b:0,F=(w=c.get(I))!=null?w:0,x=F===0;if(!C||!x){let U=D+F;x?U+=f:C&&(U-=f);const $=U-f,_=U+f;if($<=g&&g<=_)return I;C=x}}C=!1;for(let E=a.length-1;E>=0;E-=1){const I=a[E],D=(T=d.get(I))!=null?T:0,F=(y=c.get(I))!=null?y:0,x=F===0;if(D<l-F)return null;if(!C||!x){let U=D+F;x?U+=f:C&&(U-=f);const $=U-f,_=U+f;if($<=g&&g<=_)return I;C=x}}return null}static isItemHidden(t,e){return e.get(t)===0}static isColumnHidden(t,e){const{visibleColumnWidths:n}=e;return Ne.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(!Ne.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(!Ne.isItemHidden(r,e))break;s.push(r)}return s}static getHiddenColumns(t,e){const{visibleColumns:n,visibleColumnWidths:s}=e;return Ne.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 C=r.length-1;C>=0;C-=1){const b=r[C],w=(g=l.get(b))!=null?g:0,T=(f=a.get(b))!=null?f:0,y=T===0;if(!p||!y){let E=w+T;y?E+=m:p&&(E-=m);const I=E-m,D=E+m;if(I<=u&&u<=D)return b;p=y}}return null}static isRowHidden(t,e){const{visibleRowHeights:n}=e;return Ne.isItemHidden(t,n)}static getHiddenRows(t,e){const{visibleRows:n,visibleRowHeights:s}=e;return Ne.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&&!ca(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&&ca(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;ca(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,C=[];for(let b=0;b<i.length;b+=1){const w=(o=i[b][0])!=null?o:Number.NEGATIVE_INFINITY,T=(r=i[b][1])!=null?r:Number.POSITIVE_INFINITY;let y;const E=[[w,m-1],[m,p],[p+1,T]].map(([I,D])=>[Math.max(I,w),Math.min(D,T)]).filter(([I,D])=>I<=D).map(I=>{const[D,F]=I;return m<=D&&p>=F?(y=[D+f,F+f],y):p<D?[D-c,F-c]:I}).map(I=>{const[D,F]=I;return g>D&&g<=F?[[D,g-1],[g+c,F+c]]:I===y?[I]:g<=D?[[D+c,F+c]]:[I]}).flat();C.push(...E)}i=C.map(([b,w])=>[Number.isFinite(b)?b:null,Number.isFinite(w)?w:null])}return i}static translateRange(t,e,n,s){const i=Ne.applyItemMoves(t.startColumn,t.endColumn,e,s),o=Ne.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 Ne.applyItemMoves(t,t,e,!0)[0][0]}static getModelIndexes(t,e){return t.map(n=>Ne.getModelIndex(n,e))}static getModelRangeIndexes(t,e,n){return Ne.applyItemMoves(t,e,n,!0)}static getModelRange(t,e=[],n=[]){return Ne.translateRange(t,e,n,!0)}static getModelRanges(t,e=[],n=[]){const s=[];for(let i=0;i<t.length;i+=1)s.push(...Ne.getModelRange(t[i],e,n));return s}static getVisibleRangeIndexes(t,e,n){return Ne.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(...Ne.getVisibleRange(t[i],e,n));return s}static getVisibleIndex(t,e){return Ne.applyItemMoves(t,t,e)[0][0]}static getVisibleIndexes(t,e){return t.map(n=>Ne.getVisibleIndex(n,e))}static isMacPlatform(){const{platform:t}=window.navigator;return t.startsWith("Mac")}static getModifierKey(){return Ne.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(t){const e=Ne.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:C}=t;let b=s,w=i,T=o,y=r;return n!=null&&(n>d&&(b+=u),n<f-c&&(T-=m)),e!=null&&(e>l&&(w+=p),e<C-a&&(y-=g)),{x1:b,y1:w,x2:T,y2:y}}static getScrollDelta(t,e=1024,n=768,s=20,i=20){let{deltaX:o,deltaY:r}=t;return!Ne.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&&(Ne.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 K=Ne;K.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 vr(t,e=Yo.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 vh(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:C,minScrollHandleSize:b,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:D,floatingRightColumnCount:F,columnHeaderMaxDepth:x}=a,U=this.getFirstRow(t),$=this.getFirstColumn(t),_=this.getGridX(t),H=this.getGridY(t),L=pt(a)&&a.hasExpandableRows?this.calculateTreePaddingX(t):0,N=0;let O=this.getVisibleRowHeights(t),k=this.getVisibleColumnWidths(t,$,L);const V=Array.from(O.keys()),G=Array.from(k.keys());O=new Map([...O,...this.getFloatingRowHeights(t)]),k=new Map([...k,...this.getFloatingColumnWidths(t)]);let Q=this.getVisibleColumnXs(k,G,s),J=this.getVisibleRowYs(O,V,i);const ve=V.length>0?V[V.length-1]:n,le=G.length>0?G[G.length-1]:e,be=this.getBottomViewport(t,V,J,O),_e=this.getRightViewport(t,G,Q,k),ee=this.getFloatingTopHeight(t,O),ge=this.getFloatingBottomHeight(t,O),Se=this.getFloatingLeftWidth(t,k),Re=this.getFloatingRightWidth(t,k),qe=Array.from(k.values()),Oe=Array.from(O.values()),jn=qe.reduce((mt,fi)=>mt+fi,0)-s,wn=Oe.reduce((mt,fi)=>mt+fi,0)-i,bt=this.getLastLeft(t,null,o-_-w-g),Ie=this.getLastTop(t,null,r-H-w-ge),ot=s+jn+g,rt=i+wn,Ft=o-_,Qt=r-H,Zt=bt>0||ot>Ft,xt=Zt?w:0,kn=Ie>0||rt>Qt-xt,$t=kn?w:0,vn=o-p-$t,Hs=r-C-xt,zl=p,Gl=C,Kl=T===1?vn/ot:(T-bt)/T,Jo=y===1?Hs/rt:(y-Ie)/y,er=Zt?Ut(vn*Kl,b,vn-1):0,tr=kn?Ut(Hs*Jo,b,Hs-1):0,nr=B(k,e,0),sr=B(O,n,0),ir=nr>0?s/nr:0,or=sr>0?i/sr:0,ql=T===1?s/(ot-Ft):(e+ir)/bt,Yl=y===1?i/(rt-Qt):(n+or)/Ie,Vs=Zt?ql*(vn-er):0,Xl=kn?Yl*(Hs-tr):0;let Us=[];(E>0||I>0)&&(Us=[...Array(E).keys(),...[...Array(I).keys()].map(mt=>y-mt-1)],J=new Map([...J,...this.getFloatingRowYs(t,O,Math.floor(r-H-xt))]));let ro=[];(D>0||F>0)&&(ro=[...Array(D).keys(),...[...Array(F).keys()].map(mt=>T-mt-1)],Q=new Map([...Q,...this.getFloatingColumnXs(t,k,Math.floor(o-_-$t))]));const rr=[];if(u)for(let mt=u.range[0];mt<=u.range[1];mt+=1)rr.push(mt),k.has(mt)||k.set(mt,this.getVisibleColumnWidth(mt,t)),Q.has(mt)||Q.set(mt,0);const lr=V.concat(Us),lo=G.concat(ro).concat(rr),ao=this.getModelRows(lr,t),jl=this.getModelColumns(lo,t),Ql=this.getVisibleRowTreeBoxes(O,ao,t),ar=this.getTopVisible(t,J,O,V),Zl=this.getLeftVisible(t,Q,k,G),dr=Ie>0?this.getBottomVisible(t,J,O,V,H):ve,cr=bt>0?this.getRightVisible(t,Q,k,G,_):le,{fontWidths:hr,userColumnWidths:ur,userRowHeights:mr,calculatedRowHeights:Jl,calculatedColumnWidths:ea}=this;return{rowHeight:m,rowHeaderWidth:p,rowFooterWidth:g,rowCount:y,columnWidth:f,columnCount:T,columnHeaderHeight:C,floatingTopRowCount:E,floatingBottomRowCount:I,floatingLeftColumnCount:D,floatingRightColumnCount:F,gridX:_,gridY:H,firstRow:U,firstColumn:$,treePaddingX:L,treePaddingY:N,left:e,top:n,bottom:ve,right:le,topOffset:i,leftOffset:s,topVisible:ar,leftVisible:Zl,bottomVisible:dr,rightVisible:cr,bottomViewport:be,rightViewport:_e,width:o,height:r,maxX:jn,maxY:wn,lastLeft:bt,lastTop:Ie,barHeight:Hs,barTop:Gl,barWidth:vn,barLeft:zl,handleHeight:tr,handleWidth:er,hasHorizontalBar:Zt,hasVerticalBar:kn,verticalBarWidth:$t,horizontalBarHeight:xt,scrollX:Vs,scrollY:Xl,scrollableContentWidth:ot,scrollableContentHeight:rt,scrollableViewportWidth:Ft,scrollableViewportHeight:Qt,visibleRows:V,visibleColumns:G,floatingRows:Us,floatingColumns:ro,allRows:lr,allColumns:lo,visibleRowHeights:O,visibleColumnWidths:k,floatingTopHeight:ee,floatingBottomHeight:ge,floatingLeftWidth:Se,floatingRightWidth:Re,visibleRowYs:J,visibleColumnXs:Q,visibleRowTreeBoxes:Ql,modelRows:ao,modelColumns:jl,movedRows:d,movedColumns:c,fontWidths:hr,userColumnWidths:ur,userRowHeights:mr,calculatedRowHeights:Jl,calculatedColumnWidths:ea,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,n){const{model:s}=t,{columnCount:i,floatingRightColumnCount:o}=s;let r=Math.max(0,i-o-1);e!=null&&(r=e);let l=0;for(;r>=0;){if(l+=this.getVisibleColumnWidth(r,t),l>=n)return Math.min(r+1,e!=null?e:i-1);r-=1}return 0}getLastTop(t,e,n){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 vh(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 vh(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 pt(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=K.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=K.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)),vr(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),vr(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 C=0;const b=this.getWidthForFont(c,e),w=s/m,T=Math.ceil(n+w);return K.iterateAllItems(n,T,l,a,d,y=>{const E=this.getModelRow(y,e),I=o.textForCell(t,E);if(I){const D=u*2;C=Math.max(C,I.length*b+D)}}),C=Math.max(Math.min(C,(i-p-f-g)*Jm.MAX_COLUMN_WIDTH),u*2),C}calculateTreePaddingX(t){const{top:e,height:n,model:s,theme:i}=t,{rowHeight:o,treeDepthIndent:r}=i;if(!pt(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)),vr(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)),vr(n),this.userRowHeights=n}resetRowHeight(t){const e=new Map(this.userRowHeights);e.delete(t),this.userRowHeights=e,this.calculatedRowHeights.delete(t)}};let Yo=Jm;Yo.CACHE_SIZE=1e4;Yo.MAX_COLUMN_WIDTH=.8;const $w=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"}),an=(t,e)=>{let n=!1;const s=Te(t,{...e,dispose:()=>{n||(n=!0,s.clear(),n=!1)}});return s};function Ww(t,e,n=6){const s=ya.hex.lab.raw(t);return s[0]=Math.max(s[0]-s[0]/n*e,0),`#${ya.lab.hex(s)}`}function zw(t,e){const[n,s,i]=ya.hex.rgb(t);return`rgba(${n}, ${s}, ${i}, ${e})`}const Th={colorWithAlpha:zw,darkenForDepth:Ww};class yt{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 ep extends yt{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 C=B(l,g),b=s-a-C-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 D=b;Math.abs(b-I)<=r.headerResizeSnapThreshold?D=null:T!==void 0&&b>T&&(y&&E!==0||E>0)?D=T:b<=r.headerResizeHiddenSnapThreshold&&(D=0),D!==I?p.set(w,D):p.set(w,null),b<-r.headerResizeSnapThreshold&&D===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&&b>T+r.headerResizeSnapThreshold&&D===T?E>0?(this.dragOffset+=D,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((C,b)=>{C!==null?this.setSize(i,b,C):this.resetSize(i,b)}),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 xl extends ep{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=K.getHiddenColumns,this.getNextShownItem=K.getNextShownColumn,this.getSeparator=xl.getColumnSeparator}static getColumnSeparator(e,n,s,i){if(!i.allowColumnResize)return null;const{x:o,y:r,columnHeaderDepth:l}=e,{modelColumns:a}=n,d=K.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=an((t,e,n,s,i)=>os.truncateToWidth(t,e,n,s,i),{max:1e4}),this.getCachedBackgroundColors=an((t,e)=>t.split(" ").map(n=>{const s=[];for(let i=0;i<e;i+=1)s.push(Th.darkenForDepth(n,i,e));return s}),{max:1e3}),this.getCachedColorWithAlpha=an((t,e)=>Th.colorWithAlpha(t,e),{max:1e3}),this.getCachedColorIsDark=an(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 C=a[f];this.drawCellContent(t,e,g,C)}}}}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:C,width:b,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,b-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(C,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(C,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:C,floatingDividerInnerColor:b}=s;if(t.lineWidth=3,t.beginPath(),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)}if(t.stroke(),t.beginPath(),t.lineWidth=1,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)}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:C,height:b}=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:C+10,maxY:r>0&&p.has(u-r-1)?B(p,u-r-1)+B(m,u-r-1)-.5:b+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,C=[],b=[],w=(T,y)=>{const E=pt(a)?a.depthForRow(T):0,I=m[T%m.length],D=I[Math.min(E,I.length-1)];if(f.has(D)||f.set(D,[]),f.get(D).push(T),y!=null){const F=pt(a)?a.depthForRow(y):0;F<E?C.push(T):F>E&&b.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],D=B(p,I),F=B(g,I);t.rect(i,D,o,F)}t.fill()}),C.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<C.length;I+=1){const D=C[I],F=B(p,D);t.translate(0,F),t.fillRect(i,0,o,c),t.translate(0,-F)}t.restore()}if(b.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<b.length;I+=1){const D=b[I],F=B(p,D),x=B(g,D),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=K.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=K.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=K.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),C=B(d,n),b=r.backgroundColorForCell(C,f,l),w=n===a,T=pt(r)&&r.hasExpandableRows;if(b!=null){const y=B(u,n)+1,E=B(p,s)+1,I=B(m,n)-1,D=B(g,s)-1;t.fillStyle=b,t.fillRect(y,E,I,D)}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,C=B(d,n),b=B(u,s),w=B(c,n),T=B(m,s),y=n===a;let E=0;pt(r)&&r.hasExpandableRows&&y&&(E=g*(r.depthForRow(s)+1)+f);const I=w-E;let D=C+p;const F=b+T*.5;return i==="right"?D=C+I-p:i==="center"&&(D=C+I*.5),D+=E,{width:I-p*2,x:D,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),C=B(c,n),b=i!=null?i:r.textForCell(C,f),w=r.truncationCharForCell(C,f),T=n===a;if(b&&g>0){const E=r.textAlignForCell(C,f)||"left";t.textAlign=E;const I=r.colorForCell(C,f,l)||p;t.fillStyle=I;const{width:D,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,b,D,U,w);$&&t.fillText($,F,x)}T&&pt(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:C,treeMarkerHoverColor:b}=l,w=B(u,a),T=B(m,a),y=B(p,n),E=B(g,n);if(!pt(i)||!i.isRowExpandable(n))return;const I=B(f,n),D=o!=null&&r!=null&&o>=d+w&&o<=d+w+T&&r>=c+y&&r<=c+y+E?b:C;this.drawTreeMarker(t,e,w,y,I,D,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(!pt(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),C=B(c,n),b=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,C),t.lineTo(E,C+b)}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,C),t.lineTo(E,C+Math.ceil(b/2)),t.moveTo(E-.5,C+Math.ceil(b/2)+.5),t.lineTo(E+m-.5,C+Math.ceil(b/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:C,floatingLeftWidth:b,floatingRightWidth:w,modelColumns:T,columnHeaderMaxDepth:y}=o;if(d<=0)return;const{headerHiddenSeparatorSize:E,headerHiddenSeparatorHoverColor:I,headerSeparatorColor:D,headerSeparatorHoverColor:F}=i,x=d*.5,U=d*(y-1)+d*.5-x*.5,$=C>0;if(t.save(),this.drawColumnHeadersForRange(t,e,[p[0],p[p.length-1]],{minX:u+b,maxX:m-w}),$&&this.drawColumnHeadersForRange(t,e,[c[0],c[c.length-1]],{minX:u,maxX:u+b}),D){t.strokeStyle=D;const _=[...g.entries()].filter(([H,L])=>L===0).map(([H])=>H);t.beginPath(),t.fillStyle=D;for(let H=0;H<_.length;H+=1){const L=_[H],N=B(f,L),O=B(g,L),k=u+N+O+.5-E*.5;t.rect(k,U,E,x)}t.fill()}if(F){let{index:_,depth:H}=r!=null?r:{};if(_==null&&n!=null&&s!=null){const N=xl.getColumnSeparator(K.getGridPointFromXY(n,s,o),o,a,i);_=N==null?void 0:N.index,H=N==null?void 0:N.depth}let L;if(_==null)L=!1;else{const N=T.get(_),O=T.get(_+1);N==null||O==null?L=!1:L=a.textForColumnHeader(N,H)!==a.textForColumnHeader(O,H)}if(L&&_!=null&&H!=null&&(!l||r!=null)){t.strokeStyle=F;const N=B(f,_),O=B(g,_),k=u+N+O+.5,V=p.indexOf(_),G=V<p.length-1?p[V+1]:null,Q=G!=null?g.get(G):null,J=O===0,ve=Q!=null&&Q===0;J?(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 D,F,x,U,$,_;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:C}=l,{columnHeaderMaxDepth:b}=r,{minX:w,maxX:T}=s,y=T-w;if(b===0)return;const E=n[0],I=n[1];if(t.save(),t.translate(0,(b-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),O=r.textForColumnHeader(N,i),k=r.colorForColumnHeader(N,i);let V=B(d,H)+c,G=V+B(p,H);if(O!=null){let Q=H-1;for(;Q>=0&&(G-V<y||V>w);){const be=(D=a.get(Q))!=null?D:K.getModelIndex(Q,g);if(be==null||r.textForColumnHeader(be,i)!==O)break;V-=(x=(F=m.get(be))!=null?F:u.get(be))!=null?x:C,Q-=1}let J=H+1;for(;J<L&&(G-V<y||G<T);){const be=(U=a.get(J))!=null?U:K.getModelIndex(J,g);if(r.textForColumnHeader(be,i)!==O)break;G+=(_=($=m.get(be))!=null?$:u.get(be))!=null?_:C,J+=1}H=J-1;const ve=G-V>=y;let le=V;ve&&(G<T?le=G-y:V<w&&(le=w)),this.drawColumnHeader(t,e,O,le,Math.min(G-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 J;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:C,width:b}=l,w=(J=C.get(t.font))!=null?J:os.DEFAULT_FONT_WIDTH,y=(i-d*2)/w,{backgroundColor:E=u,separatorColor:I=p}=o!=null?o:{};let{textColor:D=m}=o!=null?o:{};try{const ve=this.getCachedColorIsDark(E),le=this.getCachedColorIsDark(D);ve&&le?D=f:!ve&&!le&&(D=g)}catch{}let{minX:F=0,maxX:x=b}=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=D;let U=n;y<=0?U="":U.length>y&&(U=`${U.substring(0,y-1)}\u2026`);const $=U.length*w;let _=s+i*.5;const H=c*.5;F+=d,x-=d;const L=s+d,N=Ut(L,F,x),O=s+i-d,V=Ut(O,F,x)-N,G=_-$*.5<F,Q=_+$*.5>x;G?$<V?_=F+$*.5:_=O-$*.5:Q&&($<V?_=x-$*.5:_=L+$*.5),t.textAlign="center",t.fillText(U,_,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:C,headerSeparatorColor:b,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),b){t.strokeStyle=b,t.beginPath(),t.moveTo(0,l+.5),t.lineTo(a,l+.5);const E=[];let I=!1;for(let D=0;D<c.length;D+=1){const F=c[D],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=b;for(let D=0;D<E.length;D+=1){const F=E[D],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=K.getRowSeparatorIndex(n,s,i,o)),E!=null){t.strokeStyle=w;const I=B(m,E),D=B(u,E),F=l+I+D+.5,x=c.indexOf(E),U=x<c.length-1?c[x+1]:null,$=U!=null?u.get(U):null,_=D===0,H=$!=null&&$===0;_?(t.strokeStyle=C,t.fillStyle=C,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],D=B(u,I),F=B(m,I)+l;this.drawRowHeader(t,e,I,F,D)}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:C,visibleRowYs:b,width:w}=i;if(m<=0)return;const{cellHorizontalPadding:T,headerBackgroundColor:y,headerColor:E,headerHiddenSeparatorSize:I,headerHiddenSeparatorHoverColor:D,headerSeparatorColor:F,headerSeparatorHoverColor:x}=r,U=m*.5,$=m*.5-U*.5,_=Math.min(d+c,w-m-g);if(t.save(),t.beginPath(),t.fillStyle=y,t.fillRect(_,a,m,p),F){t.strokeStyle=F,t.beginPath(),t.moveTo(_,a+.5),t.lineTo(m,a+.5);const L=[];let N=!1;for(let O=0;O<f.length;O+=1){const k=f[O],V=B(b,k),G=B(C,k);if(G>0){const Q=a+V+G+.5;t.moveTo(_+.5,Q),t.lineTo(_+m-.5,Q),N=!1}else N||(N=!0,L.push(k))}t.moveTo(_+.5,a),t.lineTo(_+.5,p),t.stroke(),t.beginPath(),t.fillStyle=F;for(let O=0;O<L.length;O+=1){const k=L[O],V=B(b,k),G=B(C,k),Q=a+V+G+.5-I*.5;t.rect(_+$,Q,U,I)}t.fill()}if(x){let{index:L=null}=l!=null?l:{};if(L==null&&n!=null&&s!=null&&(L=K.getRowSeparatorIndex(n,s,i,r)),L!=null){t.strokeStyle=x;const N=B(b,L),O=B(C,L),k=a+N+O+.5,V=f.indexOf(L),G=V<f.length-1?f[V+1]:null,Q=G!=null?C.get(G):null,J=O===0,ve=Q!=null&&Q===0;J?(t.strokeStyle=D,t.fillStyle=D,t.fillRect($,k,U,I*.5)):ve&&(t.fillStyle=x,t.fillRect($,k-I*.5,U,I*.5)),t.beginPath(),t.moveTo(_+.5,k),t.lineTo(_+m+.5,k),t.stroke()}}t.beginPath(),t.rect(_,a,m,p),t.clip(),t.fillStyle=E,t.textAlign="left";const H=_+T;for(let L=0;L<f.length;L+=1){const N=f[L],O=B(C,N);if(O>0){const k=B(b,N)+a,V=B(u,N),G=k+O*.5;t.fillText(o.textForRowFooter(V),H,G)}}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:C,height:b}=a,{left:w=a.left,top:T=a.top,right:y=a.right,bottom:E=a.bottom,minY:I=-10,maxY:D=b+10,minX:F=-10,maxX:x=C+10}=n;if(c.length===0)return;const U=Je(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),_=B(f,i),H=B(m,s),L=B(g,i);t.save(),t.beginPath(),t.rect(0,0,C,b),t.rect($,_,H,L),t.clip("evenodd")}t.beginPath();for(let $=0;$<c.length;$+=1){const _=c[$],H=_.startColumn!==null?_.startColumn:w,L=_.startRow!==null?_.startRow:T,N=_.endColumn!==null?_.endColumn:y,O=_.endRow!==null?_.endRow:E;if(O>=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,G=N<=y&&p.has(N)?Math.round(B(p,N)+B(m,N))-.5:x,Q=O<=E&&f.has(O)?Math.round(B(f,O)+B(g,O))-.5:D;t.rect(k,V,G-k,Q-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,C=m-i*.5,b=p+i,w=g+i;f<=0&&(b+=f-1,f=1),C<=0&&(w+=C-1,C=1);const{lineWidth:T}=t;t.beginPath(),t.lineWidth=i,t.strokeStyle=r.selectionOutlineColor,this.drawRoundedRect(t,f,C,b,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 Q;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:C,movedColumns:b,modelColumns:w,floatingLeftWidth:T}=s,y=(Q=w.get(l[0]))!=null?Q:K.getModelIndex(l[0],b),E=r.getColumnHeaderGroup(y,a);if(a>0&&!E)return;const[I,D]=l,F=B(u,I),U=B(u,D)+B(m,D)-F,$=n.left,{backgroundColor:_,font:H,headerFont:L,reorderOffset:N,shadowBlur:O,shadowColor:k}=o,V=(f-a-1)*C;t.save(),t.translate(d,0),t.save(),t.beginPath(),t.rect(T,0,g,p),t.clip(),t.fillStyle=_,t.fillRect(F,V,U,p),t.restore(),t.translate(0,N),t.save(),t.shadowColor=k,t.shadowBlur=O,t.fillStyle=_,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 G=[];for(let J=n.range[0];J<=n.range[1];J+=1)G.push(J);this.drawColumnHeaders(t,e),this.drawColumnHeadersForRange(t,e,[G[0],G[G.length-1]],{minX:F,maxX:g}),t.translate(0,c),t.font=H,this.drawGridBackground(t,e);for(let J=I;J<=D;J+=1)this.drawColumnCellContents(t,e,J);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:C,reorderOffset:b,shadowBlur:w,shadowColor:T}=r;t.save(),t.translate(0,a),t.fillStyle=g,t.fillRect(0,m,u,p),t.translate(l+b,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=C,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:C,hasHorizontalBar:b,hasVerticalBar:w,barWidth:T,barHeight:y}=o,{scrollBarBackgroundColor:E,scrollBarHoverBackgroundColor:I,scrollBarCasingColor:D,scrollBarCornerColor:F,scrollBarColor:x,scrollBarHoverColor:U,scrollBarActiveColor:$,scrollBarSize:_,scrollBarHoverSize:H,scrollBarCasingWidth:L,scrollBarSelectionTick:N,scrollBarSelectionTickColor:O,scrollBarActiveSelectionTickColor:k,autoSelectRow:V,autoSelectColumn:G}=a,Q=r!=null&&l!=null&&r<=u&&l<=m,J=s||w&&!n&&!i&&r!=null&&l!=null&&r>=u-H&&l<=y+c&&Q,ve=n||b&&!s&&!i&&!J&&r!=null&&l!=null&&l>=m-H&&r<=T-d&&Q,le=ve?H:_,be=J?H:_;if(t.translate(d,c),b&&w&&(t.fillStyle=D,t.fillRect(u-d-_,m-c-_,_,_),t.fillStyle=F,t.fillRect(u-d-_+L,m-c-_+L,_-L,_-L)),b){const _e=f,ee=m-c-le;if(t.fillStyle=D,t.fillRect(0,ee,T,le-L),t.fillStyle=ve?I:E,t.fillRect(0,ee+L,T,le-L),n?t.fillStyle=$:ve?t.fillStyle=U:t.fillStyle=x,t.fillRect(_e,ee+L,g,le-L),!V&&N&&O!=null&&k!=null){t.fillStyle=O;const{selectedRanges:ge,cursorColumn:Se}=e,{lastLeft:Re,columnCount:qe}=o,jn=[...ge].filter(Ie=>Ie.startColumn!=null&&Ie.endColumn!=null).map(Ie=>[Ie.startColumn,Ie.endColumn]).sort(K.compareRanges),wn=K.mergeSortedRanges(jn),bt=Ie=>Ie<=Re?Ie/Re*(T-g):T-g+(Ie-Re)/(qe-Re)*g;for(let Ie=0;Ie<wn.length;Ie+=1){const ot=wn[Ie],rt=ot[0],Ft=ot[1];if(rt!=null&&Ft!=null&&(rt!==Se||Ft!==Se)){const Qt=bt(rt),Zt=Math.max(1,Math.round(bt(Ft+1)-Qt)),xt=le-L;t.fillRect(Qt,ee+L+Math.round(xt/3),Zt,Math.round(xt/3))}}if(Se!=null){const Ie=bt(Se),ot=2,rt=le-L;t.fillStyle=k,t.fillRect(Ie,ee+L,ot,rt)}}}if(w){const _e=u-d-be,ee=C;if(t.fillStyle=D,t.fillRect(_e,0,be-L,y),t.fillStyle=J?I:E,t.fillRect(_e+L,0,be-L,y),s?t.fillStyle=$:J?t.fillStyle=U:t.fillStyle=x,t.fillRect(_e+L,ee,be-L,p),!G&&N&&O!=null&&k!=null){const{selectedRanges:ge,cursorRow:Se}=e,{lastTop:Re,rowCount:qe}=o,Oe=Ie=>Ie<=Re?Ie/Re*(y-p):y-p+(Ie-Re)/(qe-Re)*p;t.fillStyle=O;const wn=[...ge].filter(Ie=>Ie.startRow!=null&&Ie.endRow!=null).map(Ie=>[Ie.startRow,Ie.endRow]).sort(K.compareRanges),bt=K.mergeSortedRanges(wn);for(let Ie=0;Ie<bt.length;Ie+=1){const ot=bt[Ie],rt=ot[0],Ft=ot[1];if(rt!=null&&Ft!=null&&(rt!==Se||Ft!==Se)){const Qt=Oe(rt),Zt=be-L,xt=Math.max(1,Math.round(Oe(Ft+1)-Qt));t.fillRect(_e+L+Math.round(Zt/3),Qt,Math.round(Zt/3),xt)}}if(Se!=null){const Ie=Math.round(Oe(Se)),ot=be-L,rt=2;t.fillStyle=k,t.fillRect(_e+L,Ie,ot,rt)}}}t.translate(-d,-c)}};let zi=os;zi.DEFAULT_FONT_WIDTH=10;zi.DEFAULT_EDGE_RADIUS=2;zi.ACTIVE_CELL_BORDER_WIDTH=2;const Eh=100;class Gw extends yt{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=K.isModifierKeyDown(s),C=s.shiftKey;f||(C?n.trimSelectedRanges():n.clearSelectedRanges());const b=n.getTheme(),{autoSelectRow:w,autoSelectColumn:T}=b;return(r!==null||!T)&&(l!==null||!w)&&(n.focus(),n.moveCursorToPosition(r,l,C,!1,C&&f)),this.startPoint=e,this.hasExtendedFloating=!1,this.dragBounds=K.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,C=K.getScrollDragBounds(d,s,i);let b=0,w=0;if(c<u&&(o<C.x1?b=o-C.x1:o>C.x2&&(b=o-C.x2)),m<p&&(r<C.y1?w=r-C.y1:r>C.y2&&(w=r-C.y2)),b!==0||w!==0)this.startTimer(n,e,b>0?Math.ceil(b/g):Math.floor(b/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:D,rowCount:F,bottom:x,right:U,topVisible:$,bottomVisible:_,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>=D-I&&a<D-I&&(a=D-I-1,this.hasExtendedFloating=!0)),s!==null&&!K.isFloatingRow(s,d)&&K.isFloatingRow(l,d)&&(s>l&&l<m?l=$-1:s<l&&l>x&&(l=_+1)),i!==null&&!K.isFloatingColumn(i,d)&&K.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?Eh-Math.min(Eh,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 yh=5,Kw=1e3/60,Tr=10;function Rs(t,e,n,s){var T,y,E,I,D,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:K.getModelIndex(t,o),g=s.getColumnHeaderGroup(p,e),f=g!=null;let C,b,w;if(g!=null){const[U,$]=g.getVisibleRange(o);C=(y=r.get(U))!=null?y:u,b=((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;C=U,b=C+((x=(F=(D=a.get(t))!=null?D:d.get(p))!=null?F:c.get(p))!=null?x:0),w=[t,t]}return{visibleIndex:t,modelIndex:p,left:C,right:b,width:b-C,isColumnGroup:f,range:w,depth:e}}class qw extends yt{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,C;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-=Tr;m<0;){u-=1;const b=K.getModelIndex(i-1,d),w=(f=l.get(b))!=null?f:a.get(b);w===void 0?m=0:m+=w,u<0&&(m=0,u=0)}else{m+=Tr;let b=c.get(i);for(;b!==void 0&&m>b;){u+=1,m-=b;const w=K.getModelIndex(i+1,d);b=(C=l.get(w))!=null?C: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"?-Tr:Tr),e.setState({left:u,leftOffset:m}),(n==="left"&&u===0&&r===0||n==="right"&&u===o)&&this.clearScrollInterval())},Kw))}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=Rs(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)<yh&&Math.abs(this.initialGridPoint.y-o)<yh)return!1;if(a==null){const c=Rs(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=Rs(a.range[0],0,d,l),m=Rs(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 D,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=Rs(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 C=Rs(K.getColumnAtX(Ut(m?g:f,a,d),l,!0),i,l,o),b=o.getColumnHeaderParentGroup(p.modelIndex,p.depth);if(!C)return;if(b!==void 0){const _=b.getVisibleRange(r);if(C.visibleIndex<_[0]){const H=this.moveColumn(p,_[0],r);this.draggingOffset=e-((D=u.get(_[0]))!=null?D:0),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},this.clearScrollInterval(),n.setState({draggingColumn:this.draggingColumn,movedColumns:H});return}if(C.visibleIndex>_[1]){const H=this.moveColumn(p,_[1]-(p.range[1]-p.range[0]),r),{right:L=0}=(F=Rs(_[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(C.modelIndex)){let _=C.visibleIndex;if(m)for(_+=1;_<p.visibleIndex&&!o.isColumnMovable(K.getModelIndex(_,r));)_+=1;else for(_-=1;_>p.visibleIndex&&!o.isColumnMovable(K.getModelIndex(_,r));)_-=1;if(_!==p.visibleIndex){m||(_-=p.range[1]-p.range[0]);const L=this.moveColumn(p,_,r);n.setState({movedColumns:L,draggingColumn:this.draggingColumn})}const H=Rs(_,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(),C.visibleIndex===p.visibleIndex||m&&p.visibleIndex<C.visibleIndex||!m&&p.visibleIndex>C.visibleIndex)return;const w=C.left+C.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(C.modelIndex,E),E-=1;let I;m&&g<w&&(!y||C.visibleIndex===y.getVisibleRange(r)[0])&&(I=this.moveColumn(p,C.range[0],r)),!m&&f>w&&(!y||C.visibleIndex===y.getVisibleRange(r)[1])&&(I=this.moveColumn(p,C.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?K.moveRange(e.range,n,s):K.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 Ad extends yt{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=Ut((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 Ad.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 Yw extends yt{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:C}=l;let b=p;if(a<i){const I=i-1;b=B(f,I)+B(g,I)*.5+p}let w=C;if(i<c){const I=i+1;w=B(f,I)+B(g,I)*.5+p}let{movedRows:T}=n.state;r<b&&i>0&&s.isRowMovable(i-1)?(T=K.moveItem(i,i-1,T),i-=1):w<r&&i<m-1&&s.isRowMovable(i+1)&&(T=K.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 Pd extends ep{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=K.getHiddenRows,this.getNextShownItem=K.getNextShownRow,this.getSeparator=Pd.getRowSeparator}static getRowSeparator(e,n,s,i){if(!i.allowRowResize)return null;const{x:o,y:r}=e,l=K.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 yt{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 C=B(u,s),b=B(m,s),w=B(g,i),T=B(p,i);if(o>=a+C&&o<=a+C+b&&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 Xw extends yt{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 Hd extends yt{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=Ut((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 Hd.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 jw extends yt{onDoubleClick({column:e,row:n},s){const{model:i}=s.props;return Je(i)&&e!=null&&n!=null&&i.isEditableRange(re.makeCell(e,n))?(s.startEditing(e,n),!0):!1}}class gi{constructor(e=5e3){this.order=e}onDown(e,n){return!1}}class Qw extends gi{onDown(e,n){switch(e.key){case"a":if(K.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 K.isModifierKeyDown(e)?!1:this.handlePageUp(e,n);case"j":case"J":return K.isModifierKeyDown(e)?!1:this.handlePageDown(e,n);case"h":case"H":return K.isModifierKeyDown(e)?!1:(e.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(0,n.state.cursorRow,e.shiftKey),!0);case"l":case"L":{if(K.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(K.isModifierKeyDown(e)?n.state.cursorColumn:0,K.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(K.isModifierKeyDown(e)?n.state.cursorColumn:i-1,K.isModifierKeyDown(e)?o-1:n.state.cursorRow,e.shiftKey,!0,!0),!0}case"Escape":return n.clearSelectedRanges(),{preventDefault:!1,stopPropagation:!1};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=K.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,C=r&&o;let b=null,w=null;e<0?(b=0,w=m):e>0?(b=g-1,w=m):n<0?(b=u,w=0):n>0&&(b=u,w=f-1),b!=null&&w!=null&&i.moveCursorToPosition(b,w,o,!0,C)}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:C}=i.metrics;let{left:b}=i.state;b=Ut(b+e,0,C),i.moveCursorToPosition(b,l,o,!1),i.setViewState({left:b})}else if(f&&n!==0){const{lastTop:C}=i.metrics;let{top:b}=i.state;b=Ut(b+n,0,C),i.moveCursorToPosition(b,a,o,!1),i.setViewState({top:b})}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 C=c-u+r;C+=m?0:1,C=Math.min(C,f);const b=Math.min(g,C-(r-u));return n.moveCursorToPosition(l,C,s,!1),n.setViewState({top:b}),!0}}class Zw extends gi{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)&&pt(o)&&o.isRowExpandable(a))return n.toggleRowExpanded(r),!0}}}return!1}}class Jw extends gi{onDown(e,n){if(K.isModifierKeyDown(e))return!1;const{model:s}=n.props,{cursorColumn:i,cursorRow:o}=n.state;if(i==null||o==null||!Je(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 ev(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 tv(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 nv(t){var s,i;const e=t.querySelector("table");if(e!=null)return ev(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
|
+
`)}this.bufferedMessages=[],this.appendLogText(t)}queue(t){this.bufferedMessages.push(t),this.bufferedMessages.length===1&&(this.flushTimer=setTimeout(this.handleFlushTimeout,Pt.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(z,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:dC,tooltip:"Clear log"}),h(z,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:zo,tooltip:"Log Settings",onClick:()=>{},children:h(Gn,{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 Zi=Pt;Zi.DefaultLogLevels=[St.STDOUT,St.ERROR,St.FATAL,St.STDERR,St.WARN];Zi.AllLogLevels=[St.INFO,St.STDOUT,St.ERROR,St.FATAL,St.STDERR,St.WARN,St.DEBUG,St.TRACE];Zi.bufferTimeout=16;Zi.maxLogSize=131072;Zi.truncateSize=65536;class et{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""}}et.TYPE_GLOBAL="type-global";et.TYPE_CONTEXT_PRESET="type-context-preset";et.TYPE_CONTEXT_CUSTOM="type-context-custom";class Gb extends et{format(e){switch(e){case 1:case!0:return"true";case 0:case!1:return"false";default:return""}}}class Kb extends et{format(e){return String.fromCharCode(e)}}const oh=X.module("DateTimeColumnFormatter"),Xs=class extends et{constructor({timeZone:t="",showTimeZone:e=!0,showTSeparator:n=!1,defaultDateTimeFormatString:s=Xs.DEFAULT_DATETIME_FORMAT_STRING}={}){super();const i=t||Xs.DEFAULT_TIME_ZONE_ID;try{this.dhTimeZone=M.i18n.TimeZone.getTimeZone(i)}catch{oh.error("Unsupported time zone id",i),this.dhTimeZone=M.i18n.TimeZone.getTimeZone(Xs.DEFAULT_TIME_ZONE_ID)}this.defaultDateTimeFormatString=s,this.showTimeZone=e,this.showTSeparator=n,this.formatStringMap=Xs.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=et.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[...Xs.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[...Xs.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{oh.error("Invalid format arguments")}return""}};let dt=Xs;dt.DEFAULT_DATETIME_FORMAT_STRING="yyyy-MM-dd HH:mm:ss.SSS";dt.DEFAULT_TIME_ZONE_ID="America/New_York";const qb=X.module("DecimalColumnFormatter"),Fn=class extends et{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=et.TYPE_CONTEXT_PRESET,s){return{label:t,type:n,formatString:e,multiplier:s}}static makePresetFormat(t,e="",n){return Fn.makeFormat(t,e,et.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(t="",e){return Fn.makeFormat("Custom Format",t,et.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{qb.error("Invalid format arguments")}return""}};let Le=Fn;Le.DEFAULT_FORMAT_STRING="###,##0.0000";Le.FORMAT_PERCENT=Fn.makePresetFormat("Percent","##0.00%");Le.FORMAT_BASIS_POINTS=Fn.makePresetFormat("Basis Points","###,##0 bp",1e4);Le.FORMAT_MILLIONS=Fn.makePresetFormat("Millions","###,##0.000 mm",1e-6);Le.FORMAT_SCIENTIFIC_NOTATION=Fn.makePresetFormat("Scientific Notation","0.0000E0");Le.FORMAT_ROUND=Fn.makePresetFormat("Round","###,##0");Le.FORMAT_ROUND_TWO_DECIMALS=Fn.makePresetFormat("0.00","###,##0.00");Le.FORMAT_ROUND_FOUR_DECIMALS=Fn.makePresetFormat("0.0000","###,##0.0000");class Yb extends et{format(e){return`${e}`}}const Xb=X.module("IntegerColumnFormatter"),Vi=class extends et{constructor({defaultFormatString:t=Vi.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=et.TYPE_CONTEXT_PRESET,s){return{label:t,type:n,formatString:e,multiplier:s}}static makePresetFormat(t,e="",n){return Vi.makeFormat(t,e,et.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(t="",e){return Vi.makeFormat("Custom Format",t,et.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{Xb.error("Invalid format arguments")}return""}};let it=Vi;it.DEFAULT_FORMAT_STRING="###,##0";it.FORMAT_MILLIONS=Vi.makePresetFormat("Millions","###,##0.000 mm",1e-6);it.FORMAT_SCIENTIFIC_NOTATION=Vi.makePresetFormat("Scientific Notation","0.0000E0");class jb extends et{format(e){return e}}const Gt=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(Gt.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=Gt.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 Gt.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<Gt.months.length;s+=1)if(Gt.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=Gt.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()),d=Gt.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()+1);return[a,d]}if(n==="yesterday"){const l=new Date(Date.now()),a=Gt.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()-1),d=Gt.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=Gt.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=Gt.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=Gt.makeDateWrapper(e,i.year,i.month,i.date,i.hours,i.minutes,i.seconds,i.nanos),r=Gt.getNextDate(s,i,e);return[o,r]}static getJsDate(t){return typeof t=="number"?new Date(t):t.asDate()}};let ps=Gt;ps.FULL_DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSSSSS";ps.months=["january","february","march","april","may","june","july","august","september","october","november","december"];class Yt{}Yt.not="not";Yt.and="and";Yt.or="or";function Qb(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 Zb(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 Jb(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 eS(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 tS(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]=ps.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 yu(`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===Yt.and)l=l.and(p);else if(g===Yt.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]=ps.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 sn.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 un{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 Yb,this.typeFormatterMap=new Map([[P.dataType.BOOLEAN,new Gb],[P.dataType.CHAR,new Kb],[P.dataType.DATETIME,new dt(n)],[P.dataType.DECIMAL,new Le(s)],[P.dataType.INT,new it(i)],[P.dataType.STRING,new jb]]),this.columnFormatMap=un.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 nS(t){if(t&&t.formatter){const{formatter:e}=t;return e}}function sS(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 iS(t,e,n){const s=t.getColumnFormat(n,e);return s!=null&&(s.type===et.TYPE_CONTEXT_PRESET||s.type===et.TYPE_CONTEXT_CUSTOM)}const hs={getColumnFormats:nS,getDateTimeFormatterOptions:sS,isCustomColumnFormatDefined:iS};$r.register([Ig,Rg,Dg,Mg,Ng,Fg]);const dm=typeof na=="function"?na($r):na.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 wt=is;wt.EVENT_UPDATED="ChartModel.EVENT_UPDATED";wt.EVENT_DISCONNECT="ChartModel.EVENT_DISCONNECT";wt.EVENT_RECONNECT="ChartModel.EVENT_RECONNECT";wt.EVENT_DOWNSAMPLESTARTED="ChartModel.EVENT_DOWNSAMPLESTARTED";wt.EVENT_DOWNSAMPLEFINISHED="ChartModel.EVENT_DOWNSAMPLEFINISHED";wt.EVENT_DOWNSAMPLEFAILED="ChartModel.EVENT_DOWNSAMPLEFAILED";wt.EVENT_DOWNSAMPLENEEDED="ChartModel.EVENT_DOWNSAMPLENEEDED";wt.EVENT_LOADFINISHED="ChartModel.EVENT_LOADFINISHED";const oS="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",rS="#403e41",lS="#5b5a5c",aS="#c0bfbf",dS="#4878ea",cS="rgba(91, 90, 92, 0.7)",It={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:oS,gridcolor:rS,linecolor:lS,zerolinecolor:aS,activecolor:dS,rangebgcolor:cS,"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"},qt=Object.freeze({paper_bgcolor:It["paper-bgcolor"],plot_bgcolor:It["plot-bgcolor"],title_color:It["title-color"],colorway:It.colorway,gridcolor:It.gridcolor,linecolor:It.linecolor,zerolinecolor:It.zerolinecolor,activecolor:It.activecolor,rangebgcolor:It.rangebgcolor,area_color:It["area-color"],trend_color:It["trend-color"],line_color:It["line-color"],error_band_line_color:It["error-band-line-color"],error_band_fill_color:It["error-band-fill-color"],ohlc_increasing:It["ohlc-increasing"],ohlc_decreasing:It["ohlc-decreasing"]}),br=X.module("ChartUtils"),Es=Object.freeze(M.calendar.DayOfWeek.values()),rh="io.deephaven.time.DateTime",hS=36e5,uS=1e6;function mS(t){return t.asDate!==void 0}function pS(t){return t.asNumber!==void 0}function lh(t){return t.dhTimeZone!==void 0}function gS(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&&lh(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?",":"",C=c!=null&&c!==""?"e":"f",b=u!==""?u:C,w=a.length+d.length,y=`0${p}${f}.${w}${b}`,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/uS),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=qt){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);su(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=qt,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:C}=f,b=o.get(C);A(b);const w=b.indexOf(f),T=ie.getAxisPropertyName(C);if(T!=null){const y=ie.getAxisLayoutProperty(T,w);if(n.has(y))br.debug(`${y} already added.`);else{br.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 D=[],{businessPeriods:F,businessDays:x,holidays:U,timeZone:$}=I,_=e==null?void 0:e.getColumnTypeFormatter(rh);let H;lh(_)&&(H=_.dhTimeZone);const L=H?($.standardOffset-H.standardOffset)/60:0;U.length>0&&D.push(...ie.createRangeBreakValuesFromHolidays(U,$,H)),F.forEach(N=>D.push({pattern:"hour",bounds:[ie.periodToDecimal(N.close)+L,ie.periodToDecimal(N.open)+L]})),x.length<Es.length&&ie.createBoundsFromDays(x).forEach(N=>D.push({pattern:"day of week",bounds:N})),E.rangebreaks=D}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];gS(o)&&(e[i]=[...o.range])}return e}static updateFigureAxes(t,e,n,s=0,i=0,o=qt){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,C={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?C.right-=(C.right-C.left)*Math.max(0,Math.min(ie.LEGEND_WIDTH_PX/n,ie.MAX_LEGEND_SIZE)):C.right-=(C.right-C.left)*ie.DEFAULT_AXIS_SIZE),C}static updateLayoutAxes(t,e,n,s=0,i=0,o={left:0,top:0,right:1,bottom:1},r,l=qt){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 C=p[f],b=ie.getAxisPropertyName(C);if(b!=null){const w=m.get(C),T=g.get(C),E=C===M.plot.AxisType.Y?i:s;A(w),A(T);for(let I=0;I<w.length;I+=1){const D=w[I],F=T.indexOf(D),x=ie.getAxisLayoutProperty(b,F);c[x]==null&&(c[x]=ie.makeLayoutAxis(C,l));const U=c[x];if(U!=null){ie.updateLayoutAxis(U,D,I,u,a,d,o);const{range:$,autorange:_}=U;if(r!=null&&$!==void 0&&(_===void 0||_===!1)){const H=r(D),[L,N]=H($);br.debug("Setting downsample range",E,L,N),D.range(E,L,N)}else D.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)||[],C=Math.max(r.left,r.left+(g.length-1)*o),b=Math.min(r.right-(f.length-1)*o,r.right);d.domain=[C,b]}else if(e.type===M.plot.AxisType.Y){const g=s.get(M.plot.AxisPosition.BOTTOM)||[],f=s.get(M.plot.AxisPosition.TOP)||[],C=Math.max(r.bottom,r.bottom+(g.length-1)*i),b=Math.min(r.top-(f.length-1)*i,r.top);d.domain=[C,b]}}static periodToDecimal(t){const e=t.split(":");return Number(e[0])+Number(e[1])/60}static createBoundsFromDays(t){const e=t.map(o=>Es.indexOf(o)),n=Es.filter(o=>!t.includes(o)).map(o=>Es.indexOf(o)),s=new Set;n.forEach(o=>{for(let r=o+1;r<o+Es.length;r+=1){const l=r%Es.length;if(e.includes(l)){s.add(l);break}}});const i=[];return s.forEach(o=>{for(let r=o-1;r>o-Es.length;r-=1){const l=r<0?r+Es.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=hS*(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,rh,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(mS(t))return M.i18n.DateTimeFormat.format(ie.DATE_FORMAT,t,e);if(pS(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=qt){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=qt){let e=[];return t.colorway&&(Array.isArray(t.colorway)?e=t.colorway:typeof t.colorway=="string"?e=t.colorway.split(" "):br.warn(`Unable to handle colorway property: ${t.colorway}`)),e}static makeDefaultLayout(t=qt){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 Fe=ie;Fe.DEFAULT_AXIS_SIZE=.15;Fe.MIN_AXIS_SIZE=.025;Fe.MAX_AXIS_SIZE=.2;Fe.AXIS_SIZE_PX=75;Fe.LEGEND_WIDTH_PX=50;Fe.MAX_LEGEND_SIZE=.25;Fe.ORIENTATION=Object.freeze({HORIZONTAL:"h",VERTICAL:"v"});Fe.DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSS";Fe.DEFAULT_MARGIN=Object.freeze({l:60,r:50,t:30,b:60,pad:0});Fe.DEFAULT_TITLE_PADDING=Object.freeze({t:8});Fe.SUBTITLE_LINE_HEIGHT=25;const ys=X.module("Chart"),yo=class extends S.exports.Component{constructor(t){super(t),this.getCachedConfig=me((e,n,s,i)=>{const o=[],r=Boolean(e);if(r&&o.push({name:`Downsampling failed: ${e}`,click:()=>{},icon:yo.convertIcon(Tu),attr:"fill-warning"}),n||s||i||r){const l=yo.downsampleButtonTitle(s,i),a=yo.downsampleButtonAttr(s,i),d=s?fu:Zf;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){ys.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(ys.debug2("Received data update",e,n),e){case wt.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 wt.EVENT_LOADFINISHED:{const{onUpdate:i}=this.props;this.isLoadedFired=!0,i({isLoading:!1});break}case wt.EVENT_DISCONNECT:{const{onDisconnect:i}=this.props;i();break}case wt.EVENT_RECONNECT:{const{onReconnect:i}=this.props;i();break}case wt.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case wt.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case wt.EVENT_DOWNSAMPLENEEDED:case wt.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:ys.debug("Unknown event type",e,t)}}handlePlotUpdate(t){const{layout:e}=t,n=Fe.getLayoutRanges(e);!ht(n,this.ranges)&&(this.ranges=n,this.updateModelDimensions(!0))}handleRelayout(t){if(ys.debug("handleRelayout",t),t.hiddenlabels!=null){const{onSettingsChanged:e}=this.props,n=[...t.hiddenlabels];e({hiddenSeries:n})}this.updateModelDimensions()}handleRestyle([t,e]){if(ys.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){ys.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=hs.getColumnFormats(t),n=hs.getDateTimeFormatterOptions(t),{decimalFormatOptions:s={},integerFormatOptions:i={}}=t;(!ht(this.columnFormats,e)||!ht(this.dateTimeFormatterOptions,n)||!ht(this.decimalFormatOptions,s)||!ht(this.integerFormatOptions,i))&&(this.columnFormats=hs.getColumnFormats(t),this.dateTimeFormatterOptions=n,this.decimalFormatOptions=s,this.integerFormatOptions=i,this.updateFormatter())}updateFormatter(){const t=new un(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=>{ys.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(dm,{ref:this.plot,data:t,layout:o,revision:r,config:l,onAfterPlot:this.handleAfterPlot,onError:ys.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}};let cm=yo;cm.defaultProps={isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:ps.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}};const Ot=X.module("FigureChartModel"),hm=class extends wt{constructor(t,e={},n=qt){super(),this.addPendingSeries=je(()=>{const i=Fe.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=[]},hm.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=>Fe.unwrapValue(l,r)}),this.getValueParser=Te((i,o)=>{const r=this.getTimeZone(i,o);return l=>Fe.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=Fe.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:Fe.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=Fe.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=Fe.groupArray(e,"type"),s=Fe.makeSeriesDataFromSeries(t,n,Fe.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=Fe.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){Ot.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){Ot.debug("Downsample started",t),this.fireDownsampleStart(t.detail)}handleDownsampleFinish(t){Ot.debug("Downsample finished",t),this.fireDownsampleFinish(t.detail)}handleDownsampleFail(t){Ot.error("Downsample failed",t),this.fireDownsampleFail(t.detail)}handleDownsampleNeeded(t){Ot.info("Downsample needed",t),this.fireDownsampleNeeded(t.detail)}handleFigureUpdated(t){const{detail:e}=t,{series:n}=e;Ot.debug2("handleFigureUpdated",n);for(let i=0;i<n.length;i+=1){const o=n[i];Ot.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){Ot.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){Ot.debug("Figure disconnected",t),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(t){Ot.debug("Figure reconnected",t),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(t){const{detail:e}=t;Ot.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=Fe.DEFAULT_MARGIN.t+e*Fe.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=Fe.DEFAULT_TITLE_PADDING.t+e*Fe.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();Fe.updateFigureAxes(this.layout,this.figure,n=>this.getAxisRangeParser(n,this.formatter),t,e,this.theme)}updateLayoutFormats(){if(!this.formatter)return;Fe.getAxisFormats(this.figure,this.formatter).forEach((e,n)=>{Ot.debug(`Assigning ${n}`,this.layout[n],e);const s=this.layout[n];s!=null?Object.assign(s,e):Ot.debug(`Ignoring null layout.${n}`)})}setDataArrayForSeries(t,e,n){const{name:s,plotStyle:i}=t,o=this.seriesDataMap.get(s),r=Fe.getPlotlyProperty(i,e);o&&su(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=Fe.getPlotlyErrorBars(i,o,r)),a&&d&&a!==l&&(s.error_y=Fe.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){Ot.warn("Trying to set a filter, but no one click!");return}Ot.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 _a=hm;_a.ADD_SERIES_DEBOUNCE=50;class Wi{static async makeModelFromSettings(e,n,s=qt){const i=await Wi.makeFigureFromSettings(e,n);return new _a(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(Fe.makeFigureSettings(e,s))}static async makeModel(e,n,s=qt){return new _a(n,e,s)}}function ah(t){return t.setFigure!==void 0}const fS=({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 _=async()=>{const L=await t.getWorkerHeapInfo();if(r(L),s||l){const N=(L.totalHeapSize-L.freeMemory)/L.maximumHeapSize,O=Date.now(),{timestamps:k,usages:V}=d.current;for(;k.length!==0&&O-k[0]>i*1.5;)k.shift(),V.shift();k.push(O),V.push(N)}else d.current={timestamps:[],usages:[]}};_();const H=setInterval(_,l?n:e);return()=>{clearInterval(H)}},[l,n,t,e,i,s]);const c=($,_)=>Math.round($*10**_)/10**_,u=2,m=1024**3,{freeMemory:p,totalHeapSize:g,maximumHeapSize:f}=o,C=c(p/m,u),b=c(g/m,u),w=c(f/m,u),T=b-C,y=($,_,H=!1)=>v("div",{className:W("heap-usage-info-row",{"heading-bottom-border":H}),children:[h("div",{className:"font-weight-bold",children:$}),h("div",{children:_})]}),{timestamps:E,usages:I}=d.current,D=(U=E[E.length-1])!=null?U:0,F=g/f,x=(g-p)/f;return v(pe,{children:[v("div",{className:"max-memory",children:[h("div",{className:"total-memory",style:{width:`calc(${F*100}% - ${F*2}px`}}),h("div",{className:W("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($e,{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:",`${C.toFixed(u)} GB`),y("Total:",`${b.toFixed(u)} GB`),y("Max:",`${w.toFixed(u)} GB`),h("div",{className:"heap-plot",children:h(dm,{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:qt.linecolor,range:[D-i,D],linecolor:qt.linecolor,linewidth:2,mirror:!0},yaxis:{dtick:.2,gridcolor:qt.linecolor,range:[0,1],linecolor:qt.linecolor,linewidth:2,mirror:!0}}})}),v("div",{className:"heap-utilisation-text",children:["% utilization over ",Math.round(i/1e3/60)," min."]})]})})]})},wd=Object.freeze({}),CS=new Map,um=t=>t.user,vd=t=>t.storage,mm=t=>vd(t).commandHistoryStorage,pm=t=>vd(t).fileStorage,bS=t=>vd(t).workspaceStorage,Il=t=>t.workspace,Nt=t=>Il(t).data.settings,SS=t=>Nt(t).defaultDateTimeFormat,wS=t=>{var e;return(e=Nt(t).defaultDecimalFormatOptions)!=null?e:wd},vS=t=>{var e;return(e=Nt(t).defaultIntegerFormatOptions)!=null?e:wd},TS=t=>Nt(t).formatter,Rl=t=>Nt(t).timeZone,ES=t=>Nt(t).showTimeZone,yS=t=>Nt(t).showTSeparator,IS=t=>Nt(t).truncateNumbersWithPound,RS=t=>Nt(t).shortcutOverrides,DS=t=>{var e;return(e=Nt(t).defaultNotebookSettings)!=null?e:wd},Dl=t=>t.activeTool,MS=t=>{var e;return(e=t.plugins)!=null?e:CS},gm="SET_ACTIVE_TOOL",fm="SET_COMMAND_HISTORY_STORAGE",Cm="SET_FILE_STORAGE",bm="SET_PLUGINS",Sm="SET_USER",wm="SET_WORKSPACE",vm="SET_WORKSPACE_STORAGE",Tm="SET_SERVER_CONFIG_VALUES",NS=t=>({type:Sm,payload:t}),Em=t=>({type:wm,payload:t}),FS=t=>({type:vm,payload:t}),xS=t=>({type:fm,payload:t}),_S=t=>({type:Cm,payload:t}),OS=t=>(e,n)=>{e(Em(t));const{storage:s}=n(),{workspaceStorage:i}=s;return i.save(t)},ym=t=>(e,n)=>{const{workspace:s}=n(),{data:i}=s,o={...s,data:{...i,...t}};return e(OS(o))},Td=t=>e=>e(ym({settings:t})),Ml=t=>({type:gm,payload:t}),kS=t=>({type:bm,payload:t}),LS=t=>({type:Tm,payload:t});function Im(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 AS(t,e={},n=!0){return(s=e,i)=>{switch(i.type){case t:{const{id:o,payload:r}=i;return n&&ht({payload:r},{payload:s[o]})?s:{...s,[o]:r}}default:return s}}}function As(t,e){return(n=e,s)=>{switch(s.type){case t:return s.payload;default:return n}}}const PS=As(gm,null),HS=As(bm,null),VS=As(fm,null),US=As(Cm,null),BS=As(vm,null),$S=td({commandHistoryStorage:VS,fileStorage:US,workspaceStorage:BS}),WS=Im(Sm,null),zS=Im(wm,null),GS=As(Tm,null),KS={activeTool:PS,plugins:HS,storage:$S,user:WS,workspace:zS,serverConfigValues:GS};class qS{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 Ji=new qS,ch=X.module("redux-logger"),YS=t=>e=>n=>{ch.debug("dispatching",n);const s=e(n);return ch.debug("next state",t.getState()),s},XS=X.module("redux-crashReporter"),jS=t=>e=>n=>{try{return e(n)}catch(s){throw XS.error("Error executing",n," with state ",t.getState(),":",s),s}},QS=[YS,jS,rg];Object.entries(KS).map(([t,e])=>Ji.register(t,e));var nu;const ZS=(nu=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__)!=null?nu:dg,Nl=lg(td(Ji.reducers),ZS(ag(...QS)));Ji.setListener(t=>{Nl.replaceReducer(td(t))});const Rm=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 Dm(t){return t.componentName!==void 0}function JS(t){return t.component!==void 0}const Mm=Object.freeze({type:"default",isClosable:!0,isFocusOnShow:!0,reorderEnabled:!0,title:""}),e0=Object.freeze(Object.defineProperty({__proto__:null,defaultConfig:Rm,isGLComponentConfig:Dm,isReactComponentConfig:JS,itemDefaultConfig:Mm},Symbol.toStringTag,{value:"Module"})),Oa=class{constructor(){this.off=this.unbind,this.trigger=this.emit,this._mSubscriptions={},this._mSubscriptions[Oa.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[Oa.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 Sn=Oa;Sn.ALL_EVENT="__all";class ka extends Sn{constructor(e,n,s){super(),this.isHidden=!1,this._element=ue(['<div class="lm_item_container">','<div class="lm_content" tabindex="-1"></div>',"</div>"].join("")),this.title=Dm(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(ue.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 t0=Object.freeze(Object.defineProperty({__proto__:null,ItemContainer:ka,Container:ka},Symbol.toStringTag,{value:"Module"}));function Nm(t){var e=location.hash.match(new RegExp(t+"=([^&]*)"));return e?e[1]:null}function Fm(t){if(window.location.hash)return Nm(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 Fl(t){return window.requestAnimationFrame(t)}function n0(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 Ed(){return(Math.random()*1e15).toString(36).replace(".","")}function s0(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 yd(t){return ue.trim(t.replace(/(<([^>]+)>)/gi,""))}class Go extends Sn{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=ue(document),this._eBody=ue(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 xm{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(){hi.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(){hi.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=ue.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"],i0=[!0,!1,"row","column","stack","component","close","maximise","minimise","open in new window"];function Id(t){if(Qr.length>36)throw new Error("Too many keys in config minifier map");const e={};return Rd(t,e,"_min"),e}function La(t){if(Qr.length>36)throw new Error("Too many keys in config minifier map");const e={};return Rd(t,e,"_max"),e}function Rd(t,e,n){const s=n==="_min"?o0:r0;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}Rd(o,r,n)}else{const r=s(o,i0);if(Array.isArray(e))e[Number.parseInt(i,10)]=r;else{const l=s(i,Qr);e[l]=r}}}}function o0(t,e){if(typeof t=="string"&&t.length===1)return"___"+t;var n=e.indexOf(t);return n===-1?t:n.toString(36)}function r0(t,e){return typeof t=="string"&&t.length===1?e[parseInt(t,36)]:typeof t=="string"&&t.substr(0,3)==="___"?t[3]:t}class Aa{constructor(e,n){this.name=e,this.origin=n,this.isPropagationStopped=!1}stopPropagation(){this.isPropagationStopped=!0}}class _m extends Sn{constructor(e){super(),this._layoutManager=e,this._dontPropagateToParent=null,this._childEventSource=null,this.on(Sn.ALL_EVENT,this._onEventFromThis.bind(this)),this._boundOnEventFromChild=this._onEventFromChild.bind(this),ue(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(){ue(window).off("gl_child_event",this._boundOnEventFromChild)}}const l0=Object.freeze(Object.defineProperty({__proto__:null,EventEmitter:Sn,DragListener:Go,ReactComponentHandler:xm,BubblingEvent:Aa,EventHub:_m,getHashValue:Nm,getQueryStringParam:Fm,animFrame:Fl,removeFromArray:n0,getUniqueId:Ed,filterXss:s0,stripTags:yd,minifyConfig:Id,unminifyConfig:La},Symbol.toStringTag,{value:"Module"}));class Om extends Sn{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=ue.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;ue(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-"+Ed();e=Id(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 km=class extends Sn{constructor(t,e,n,s,i,o){var l,a,d,c,u,m,p,g,f,C,b,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=ue(km._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",yd((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(),ue(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=((C=this._layoutManager.container.height())!=null?C:0)+this._minY,this._width=(b=this.element.width())!=null?b: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 Ko=km;Ko._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 Lm{constructor(e,n,s){this._element=e,this._itemConfig=n,this._layoutManager=s,this._dragListener=this._createDragListener()}_createDragListener(){return this._dragListener=new Go(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(ue.extend(!0,{},s)),o=new Ko(e,n,this._dragListener,this._layoutManager,i,null);(r=this._layoutManager.transitionIndicator)==null||r.transitionElements(this._element,o.element)}}class Am{constructor(e,n,s){this._element=ue(window),this._itemConfig=e,this._layoutManager=n,this._createDragListener(s)}_createDragListener(e){this._dragListener&&this._dragListener.destroy(),this._element&&(this._dragListener=new Go(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(ue.extend(!0,{},s));new Ko(e,n,this._dragListener,this._layoutManager,i,null)}}}const Pm=class{constructor(){this.element=ue(Pm._template),ue(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 Dd=Pm;Dd._template='<div class="lm_dropTargetIndicator"><div class="lm_inner"></div></div>';class Io{constructor(e,n,s,i){this._header=e,this.element=ue('<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 a0=Object.freeze(Object.defineProperty({__proto__:null,ConfigurationError:ii},Symbol.toStringTag,{value:"Module"}));function Po(t){return t.isStack}function In(t){return t.isComponent}function Hm(t){return t.isRoot}class Tt extends Sn{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(Sn.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,Po(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&&In(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 Aa(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(Mm)){const i=n;e[i]===void 0&&(e[i]=s)}return e}_propagateEvent(e,n){n instanceof Aa&&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,Fl(this._propagateEventToLayoutManager.bind(this,e,n)))}_propagateEventToLayoutManager(e,n){this._pendingEventPropagations[e]=!1,this.layoutManager.emit(e,n)}}class Vm extends Tt{constructor(e,n,s){super(e,n,s,ue()),this.config=n,this.parent=s;const i=e.getComponent(this.config.componentName)||e.getFallbackComponent(),o=ue.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 ka(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(){Tt.prototype._$init.call(this),this.container.emit("open")}_$hide(){this.container.hide(),Tt.prototype._$hide.call(this)}_$show(){this.container.show(),this.container._config.isFocusOnShow&&this.container._contentElement[0].focus({preventScroll:!0}),Tt.prototype._$show.call(this)}_$destroy(){this.container.emit("destroy",this),Tt.prototype._$destroy.call(this)}_$getArea(){return null}}class Zr extends Tt{constructor(e,n,s,i){super(n,s,i,ue('<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),Tt.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));Tt.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(Tt.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 Bm(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}),Fl(this.callDownwards.bind(this,"setSize",void 0,void 0,void 0))}}class Pa extends Tt{constructor(e,n,s){super(e,{...n,type:"root"},null,ue('<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(In(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 Ha extends Tt{constructor(e,n,s){var o,r,l,a,d,c,u,m,p;super(e,n,s,ue('<div class="lm_item lm_stack"></div>')),this._activeContentItem=null,this.childElementContainer=ue('<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 qo(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(){Tt.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(In(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,C,b,w,T,y,E,I,D,F,x,U,$,_,H,L,N,O,k,V,G,Q;const n=this.header.tabs.length;if(n===0){const J=this.header.element.offset();(w=this.layoutManager.dropTargetIndicator)==null||w.highlightArea({x1:(u=J==null?void 0:J.left)!=null?u:0,x2:((m=J==null?void 0:J.left)!=null?m:0)+100,y1:(g=(p=this.header.element.offset())==null?void 0:p.top)!=null?g:0,y2:((C=(f=this.header.element.offset())==null?void 0:f.top)!=null?C:0)+((b=this.header.element.innerHeight())!=null?b: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=(D=this.layoutManager.tabDropPlaceholder.offset())==null?void 0:D.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=(_=this.header.tabsContainer.offset())==null?void 0:_.left)!=null?H:0)+((L=this.header.tabsContainer.innerWidth())!=null?L:0)),(Q=this.layoutManager.dropTargetIndicator)==null||Q.highlightArea({x1:d,x2:c,y1:(O=(N=this.header.element.offset())==null?void 0:N.top)!=null?O:0,y2:((V=(k=this.header.element.offset())==null?void 0:k.top)!=null?V:0)+((G=this.header.element.innerHeight())!=null?G: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 d0=Object.freeze(Object.defineProperty({__proto__:null,AbstractContentItem:Tt,ContentItem:Tt,Component:Vm,Root:Pa,RowOrColumn:Zr,Stack:Ha,isStack:Po,isComponent:In,isRoot:Hm},Symbol.toStringTag,{value:"Module"})),Um=class{constructor(t,e){var n;this.element=ue(Um._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 Go(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),In(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),In(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 Ko(t,e,this._dragListener,this._layoutManager,this.contentItem,this.header.parent)}_onTabContentFocusIn(){In(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&this.contentItem.container._contentElement[0].focus(),this.element.addClass("lm_focusin")}_onTabContentFocusOut(){In(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&&In(this.contentItem)?(this.header.parent.setActiveContentItem(this.contentItem),this.contentItem.container.emit("tabClicked")):In(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(),In(this.contentItem)?this.contentItem.container.close():this.header.parent.removeChild(this.contentItem)}_onCloseMousedown(t){t.stopPropagation()}};let Md=Um;Md._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 Sn{constructor(t,e){var n,s;super(),this.element=ue(Ar._template),this.tabDropdownList=null,this.tabs=[],this.activeContentItem=null,this.closeButton=null,this.tabDropdownButton=null,this.tabNextButton=ue(Ar._nextButtonTemplate),this.tabPreviousButton=ue(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 Md(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(),ue(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"),ue(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(),ue(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=ue(window).scrollTop())!=null?i:0);e+t>((o=ue(window).height())!=null?o:0)&&this.tabDropdownContainer.css("max-height",((r=ue(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 qo=Ar;qo._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("");qo._previousButtonTemplate=['<ul class="lm_controls">','<li class="lm_tabpreviousbutton"></li>',"</ul>"].join("");qo._nextButtonTemplate=['<li class="lm_tabnextbutton"></li>'].join("");class Bm{constructor(e,n,s){this._isVertical=e,this._size=n,this._grabSize=s<n?n:s,this.element=this._createElement(),this._dragListener=new Go(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=ue('<div class="lm_drag_handle"></div>'),n=ue('<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 $m{constructor(){this._element=ue('<div class="lm_transition_indicator"></div>'),this._toElement=null,this._fromDimensions={},this._totalAnimationDuration=200,this._animationStartTime=null,ue(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),Fl(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 c0=Object.freeze(Object.defineProperty({__proto__:null,BrowserPopout:Om,DragProxy:Ko,DragSource:Lm,DragSourceFromEvent:Am,DropTargetIndicator:Dd,Header:qo,HeaderButton:Io,Splitter:Bm,Tab:Md,TransitionIndicator:$m},Symbol.toStringTag,{value:"Module"})),h0={config:e0,container:t0,controls:c0,errors:a0,items:d0,utils:l0};class Nd extends Sn{constructor(e,n){super(),this.isInitialised=!1,this._isFullPage=!1,this._components={"lm-react-component":xm},this._itemAreas=[],this._maximisedItem=null,this._maximisePlaceholder=ue('<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 _m(this),this.dropTargetIndicator=null,this.transitionIndicator=null,this.tabDropPlaceholder=ue('<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&&ue("body").css("visibility","hidden"),this._typeToItem={column:Zr.bind(this,!0),row:Zr.bind(this,!1),stack:Ha,component:Vm}}static minifyConfig(e){return Id(e)}static unminifyConfig(e){return La(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 Tt))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){ue(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 Dd,this.transitionIndicator=new $m,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(),ue(window).off("resize",this._onResize),ue(window).off("unload beforeunload",this._onUnload),ue(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 Ha)&&!!n&&!(this.isSubWindow===!0&&n instanceof Pa)&&(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 Tt,l=this;if(r){o=this.toConfig(e).content,s=Ed();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 Om(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 Lm(e,n,this);return this._dragSources.push(s),s}createDragSourceFromEvent(e,n){return this.config.settings.constrainDragToContainer=!1,new Am(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(!Po(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 Tt)return e;if(ue.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&&ue(window).resize(this._onResize),ue(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=Fm("gl-window");n&&(this.isSubWindow=!0,e=JSON.parse(localStorage.getItem(n)||"{}"),e=La(e),localStorage.removeItem(n)),e=ue.extend(!0,{},Rm,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=ue('<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=yd((n=this.config.content[0].title)!=null?n:""),ue("head").append(ue("body link, body style, template, .gl_keep")),this.container=ue("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?ue(this._originalContainer):ue("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,ue("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 Pa(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=>{Po(s)?e.push(s):s.isComponent||this._findAllStackContainersRecursive(e,s)})}}Nd.__lm=h0;const u0="_lm_root_15d73_3",m0="_lm_row_15d73_7",p0="_lm_item_15d73_7",g0="_lm_content_15d73_11",f0="_lm_dragging_15d73_17",C0="_lm_maximised_15d73_23",b0="_lm_maximise_placeholder_15d73_30",S0="_lm_splitter_15d73_34",w0="_lm_vertical_15d73_41",v0="_lm_drag_handle_15d73_41",T0="_lm_horizontal_15d73_46",E0="_lm_header_15d73_56",y0="_lm_dropdown_open_15d73_63",I0="_lm_controls_15d73_69",R0="_lm_tabs_15d73_89",D0="_lm_tab_15d73_89",M0="_lm_title_15d73_104",N0="_lm_close_tab_15d73_111",F0="_lm_stack_15d73_120",x0="_lm_left_15d73_120",_0="_lm_right_15d73_121",O0="_lm_dragProxy_15d73_125",k0="_lm_items_15d73_148",L0="_lm_tabdropdown_list_15d73_165",A0="_lm_bottom_15d73_192",P0="_lm_drop_tab_placeholder_15d73_207",H0="_lm_tabdropdown_15d73_165",V0="_lm_dropTargetIndicator_15d73_258",U0="_lm_inner_15d73_264",B0="_lm_transition_indicator_15d73_272",$0="_lm_popin_15d73_282",W0="_lm_bg_15d73_297",z0="_lm_icon_15d73_300",G0="_lm_goldenlayout_15d73_304",K0="_lm_selectable_15d73_340",q0="_lm_active_15d73_370",Y0="_lm_selected_15d73_388",X0="_lm_keyboard_active_15d73_397",j0="_lm_popout_15d73_416",Q0="_lm_maximise_15d73_23",Z0="_lm_close_15d73_111",J0="_lm_tabnextbutton_15d73_425",ew="_lm_tabpreviousbutton_15d73_428",tw="_lm_title_before_15d73_544",nw="_lm_focusin_15d73_568",sw="_lm_window_blur_15d73_573",iw="_lm_tabdropdown_search_15d73_631",ow="_march_15d73_1",rw="_app_15d73_712",lw="_plotly_15d73_721",hh={"tab-height":"28px","drag-border-width":"5px",lm_root:u0,lm_row:m0,lm_item:p0,lm_content:g0,lm_dragging:f0,lm_maximised:C0,lm_maximise_placeholder:b0,lm_splitter:S0,lm_vertical:w0,lm_drag_handle:v0,lm_horizontal:T0,lm_header:E0,lm_dropdown_open:y0,lm_controls:I0,lm_tabs:R0,lm_tab:D0,lm_title:M0,lm_close_tab:N0,lm_stack:F0,lm_left:x0,lm_right:_0,lm_dragProxy:O0,lm_items:k0,lm_tabdropdown_list:L0,lm_bottom:A0,lm_drop_tab_placeholder:P0,lm_tabdropdown:H0,lm_dropTargetIndicator:V0,lm_inner:U0,lm_transition_indicator:B0,lm_popin:$0,lm_bg:W0,lm_icon:z0,lm_goldenlayout:G0,lm_selectable:K0,lm_active:q0,lm_selected:Y0,lm_keyboard_active:X0,lm_popout:j0,lm_maximise:Q0,lm_close:Z0,lm_tabnextbutton:J0,lm_tabpreviousbutton:ew,lm_title_before:tw,"editor-unsaved-indicator":"_editor-unsaved-indicator_15d73_548","is-unsaved":"_is-unsaved_15d73_556",lm_focusin:nw,lm_window_blur:sw,lm_tabdropdown_search:iw,march:ow,app:rw,"js-plotly-plot":"_js-plotly-plot_15d73_721",plotly:lw},uh=Object.freeze({tabHeight:parseInt(hh["tab-height"],10),dragBorderWidth:parseInt(hh["drag-border-width"],10)}),Is=X.module("LayoutUtils");function Wm(t){return t.componentName!==void 0}function Oi(t){const e=t;return(Wm(t)&&t.componentName==="lm-react-component"||t.type==="react-component")&&e.component!==void 0}function Sr(t){return t.focus!==void 0}function mh(t){return t.type==="stack"}const Be=class{static activateTab(t,e){const n=Be.getStackForRoot(t,e,!1);if(!n){Is.error("Could not find stack for config",e);return}const s=Be.getContentItemInStack(n,e);s&&n.setActiveContentItem(s)}static isActiveTab(t,e){const n=Be.getStackForRoot(t,e,!1);if(!n)return Is.error("Could not find stack for config",e),!1;const s=Be.getContentItemInStack(n,e);return n.getActiveContentItem()===s}static addStack(t,e=!0){const n=e?"column":"row";if(Hm(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&&Po(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&&vc(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=Be.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&&vc(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):Is.debug2(`dehydrateLayoutConfig: skipping unmapped component "${o}"`)}else if(r){const l={...i,content:Be.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?(mh(n)&&delete n.activeItemIndex,Be.dropLayoutMinorChange(s)):Oi(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=Be.cloneLayout(t),i=Be.cloneLayout(e);return Be.dropLayoutMinorChange(s),Be.dropLayoutMinorChange(i),ht(s,i)}return ht(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(Oi(o)){const{component:r,props:l={}}=o;n.push({...o,id:(s=o==null?void 0:o.id)!=null?s:ze(),props:e(r,l)})}else if(o.content!==void 0){const r=Be.hydrateLayoutConfig(o.content,e);mh(o)&&o.activeItemIndex!=null&&o.activeItemIndex>=r.length&&(Is.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=ze.generate()),r){t==null||t.layoutManager.createDragSourceFromEvent(a,r);return}const d=s||{id:a.id,component:a.component};A(t);const c=i?Be.addStack(t):Be.getStackForRoot(t,d);A(c);const u=Be.getContentItemInStack(c,d);if(o!=null){const m=p=>{Is.debug("Component created, focusing element",o),c.off("componentCreated",m);const{element:g}=p.origin;requestAnimationFrame(()=>{Be.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&&Sr(l)&&l.focus()}static openComponentInStack(t,e,n=!0){const s=document.activeElement,i={id:e.id},o=Be.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&&Sr(s)&&s.focus()}static closeComponent(t,e){const n=Be.getStackForRoot(t,e,!1,!1,!1);if(!n){Is.warn("Cannot find stack for component, ignoring close",e);return}const s=Be.getContentItemInStack(n,e),i=document.activeElement;s&&(s.isComponent?s.container.close():n.removeChild(s)),i&&document.contains(i)&&Sr(i)&&i.focus()}static renameComponent(t,e,n){const s=Be.getStackForRoot(t,e,!1);if(!s){Is.error("Could not find stack for config",e);return}const i=Be.getContentItemInStack(s,e);i&&i.setTitle(n)}static cloneComponent(t,e){const n=Be.getStackForRoot(t,e,!1);if(!n)return Is.error("Could not find stack for config",e),null;const{props:s={}}=e,i=Be.getPanelComponentState(e),o={type:"react-component",component:e.component,props:{...s,panelState:i},title:`${e.title} Copy`,id:ze.generate()};return Be.openComponentInStack(n,o),o}static getPanelComponentState(t){var e,n;return Wm(t)?(e=t.componentState)==null?void 0:e.panelState:Oi(t)?(n=t.props)==null?void 0:n.panelState:null}static makeDefaultLayout(){return{dimensions:{headerHeight:uh.tabHeight,borderWidth:uh.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=Be.getComponentConfigFromContainer(t);return e?e.id:null}static getIdFromPanel(t){const{glContainer:e}=t.props;return Be.getIdFromContainer(e)}static getComponentNameFromPanel(t){var s;const{glContainer:e}=t.props,n=Be.getComponentConfigFromContainer(e);return n&&Oi(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=Be.DEFAULT_FOCUS_SELECTOR){if(t==null)return null;const n=t.querySelector(e);return n==null?null:(Sr(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=Be;te.DEFAULT_FOCUS_SELECTOR="input, select, textarea, button";const aw=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 ph(t){return(t==null?void 0:t.WrappedComponent)!==void 0}function dw(t){return typeof t.id=="string"&&t.layout instanceof Nd&&t.panelManager instanceof Fd&&typeof t.registerComponent=="function"}function Ps(t){if(!dw(t))throw new Error(`Expected dashboard plugin props, but instead received ${t}`)}const pn=X.module("PanelManager");class Fd{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&&Oi(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=>ph(s)&&n instanceof s.WrappedComponent||!ph(s)&&n instanceof s))}updatePanel(e){const n=te.getIdFromPanel(e);if(n==null){pn.error("updatePanel Panel did not have an ID",e);return}pn.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){pn.error("removePanel Panel did not have an ID",e);return}if(!this.openedMap.has(n)){pn.error(`Missing panel ID ${n} in open panels map`);return}if(this.openedMap.get(n)!==e){pn.debug(`Panel argument doesn't match the open panels map entry for ${n}, removePanel ignored`);return}pn.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){pn.debug2("Focus: ",e),this.updatePanel(e)}handleMount(e){pn.debug2("Mount: ",e),this.updatePanel(e),this.sendUpdate()}handleUnmount(e){pn.debug2("Unmount: ",e),this.removePanel(e),this.sendUpdate()}handleReopen(e,n){pn.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){pn.debug2("Deleted:",e),this.removeClosedPanelConfig(e),this.sendUpdate()}handleClosed(e,n){pn.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&&Oi(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)})}}Fd.MAX_CLOSED_PANEL_COUNT=100;const cw=X.module("PanelErrorBoundary");class hw 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);cw.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(bl,{errorMessage:`${n}`,isLoading:!1,isLoaded:!1})}):e}}function xd(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 _d(t,e=""){return{metadata:{},...t,localDashboardId:e}}const Va={dehydrate:xd,hydrate:_d},uw=R.exports.shape({on:R.exports.func,off:R.exports.func,isHidden:R.exports.bool,tab:R.exports.shape({header:R.exports.shape({tabs:R.exports.arrayOf(R.exports.shape({contentItem:R.exports.shape({})}))})}),title:R.exports.string,setTitle:R.exports.func,close:R.exports.func}),zm=R.exports.shape({on:R.exports.func,off:R.exports.func,emit:R.exports.func}),mw=R.exports.shape({registerComponent:R.exports.func,root:R.exports.shape({addChild:R.exports.func}),on:R.exports.func,off:R.exports.func,eventHub:zm}),Od=Object.freeze({Container:uw,EventHub:zm,Layout:mw}),Ke=(t,e,n)=>S.exports.useEffect(function(){return t.on(e,n),()=>{t.off(e,n)}},[t,e,n]),Gm="SET_DASHBOARD_DATA",pw=AS(Gm,{},!1),gw={dashboardData:pw},fw=new Map,Cw=Object.freeze({}),bw=Object.freeze([]),Sw=t=>t.dashboardData,jt=(t,e)=>{var n;return(n=Sw(t)[e])!=null?n:Cw},ww=(t,e)=>{var n;return(n=jt(t,e).closed)!=null?n:bw},Km=(t,e)=>{var n;return(n=jt(t,e).openedMap)!=null?n:fw},qm=(t,e)=>({type:Gm,id:t,payload:e}),Yn=(t,e)=>(n,s)=>n(qm(t,{...jt(s(),t),...e}));Object.entries(gw).map(([t,e])=>Ji.register(t,e));const wr=X.module("DashboardLayout"),vw=Object.freeze({}),Tw=[],gh=()=>{},fh=t=>t,Ym=({id:t,children:e,emptyDashboard:n=h("div",{children:"Dashboard is empty."}),layout:s,layoutConfig:i=Tw,onLayoutChange:o=gh,onLayoutInitialized:r=gh,hydrate:l=_d,dehydrate:a=xd})=>{var O,k;const d=nd(),c=(O=cg(V=>jt(V,t)))!=null?O:vw,[u,m]=S.exports.useState(!1),[p,g]=S.exports.useState(!1),[f,C]=S.exports.useState(),[b]=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=hg(),D=S.exports.useCallback((V,G,Q=l,J=a)=>{wr.debug2("registerComponent",V,G,Q,J);function ve(_e,ee){const ge=G,{glContainer:Se,glEventHub:Re}=_e;return h(iu,{store:I,children:h(hw,{glContainer:Se,glEventHub:Re,children:h(ge,{..._e,ref:ee})})})}const le=Y.forwardRef(ve),be=s.registerComponent(V,le);return y.set(V,Q),E.set(V,J),be},[l,a,y,E,s,I]),F=S.exports.useCallback((V,G)=>{var Q;return((Q=y.get(V))!=null?Q:fh)(G,t)},[y,t]),x=S.exports.useCallback((V,G)=>{var Q;return((Q=E.get(V))!=null?Q:fh)(G,t)},[E,t]),U=S.exports.useMemo(()=>new Fd(s,F,x,new Map,b,({closed:V,openedMap:G})=>{d(Yn(t,{closed:V,openedMap:G}))}),[x,d,F,t,b,s]),$=S.exports.useCallback(()=>{if(p)return;w||(r(),T(!0));const G=s.toConfig().content,Q=te.dehydrateLayoutConfig(G,x),J=f==null||!te.isEqual(f,Q);wr.debug("handleLayoutStateChanged",J,G,Q),J&&(m(s.root.contentItems.length===0),C(Q),o(Q))},[x,w,p,f,s,o,r]),_=S.exports.useCallback(()=>{g(!0)},[]),H=S.exports.useCallback(()=>{g(!1)},[]),L=S.exports.useCallback(V=>{if(wr.debug2("handleComponentCreated",V),V==null||V.config==null||V.config.component==null||V.element==null)return;const Q=`${V.config.component.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}-component`;V.element.addClass(Q)},[]);Ke(s,"stateChanged",$),Ke(s,"itemPickedUp",_),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){wr.debug("Setting new layout content...");const G=te.hydrateLayoutConfig(i,F);for(;s.root.contentItems.length>0;)s.root.contentItems[0].remove();for(let Q=0;Q<G.length;Q+=1)s.root.addChild(G[Q]);m(s.root.contentItems.length===0)}},[F,s,i,f,U,N]),v(pe,{children:[u&&n,Y.Children.map(e,V=>V!=null?Y.cloneElement(V,{id:t,layout:s,panelManager:U,registerComponent:D}):null)]})};Ym.propTypes={id:R.exports.string.isRequired,children:R.exports.node,data:R.exports.shape({}),emptyDashboard:R.exports.node,layout:Od.Layout.isRequired,layoutConfig:R.exports.arrayOf(R.exports.shape({})),onLayoutChange:R.exports.func,onLayoutInitialized:R.exports.func};const Ew=100,aa=()=>{},yw=Object.freeze({}),Iw=({id:t="default",children:e,emptyDashboard:n,layoutConfig:s,layoutSettings:i=yw,onLayoutConfigChange:o=aa,onGoldenLayoutChange:r=aa,onLayoutInitialized:l=aa,fallbackComponent:a=aw,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 Nd(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 C=S.exports.useMemo(()=>us(()=>{g!=null&&g.isInitialised&&(g==null||g.updateSize())},Ew),[g]);return S.exports.useEffect(function(){return window.addEventListener("resize",C),()=>{window.removeEventListener("resize",C)}},[C]),v("div",{className:"dashboard-container w-100 h-100",children:[h("div",{className:"w-100 h-100",ref:u}),m&&g&&h(Ym,{emptyDashboard:n,id:t,layout:g,layoutConfig:s,onLayoutChange:o,onLayoutInitialized:l,hydrate:d,dehydrate:c,children:e})]})},Dn="default";var ui=(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))(ui||{});const Rw=Object.freeze([[ui.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS,!1],[ui.LINK_CHANGE_CLEARS_ALL_FILTERS,!1]]),Xm={DEFAULTS:Rw};var ke=(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))(ke||{});const Dw=t=>{switch(t){default:return!1}},Mw=(t,e)=>{switch(t){case ke.COUNT:case ke.FIRST:case ke.LAST:case ke.COUNT_DISTINCT:case ke.DISTINCT:case ke.UNIQUE:return!0;case ke.MIN:case ke.MAX:return P.isNumberType(e)||P.isDateType(e)||P.isTextType(e);case ke.SUM:case ke.ABS_SUM:case ke.VAR:case ke.AVG:case ke.STD:return P.isNumberType(e);case ke.SKIP:return!1}},kd=(t,e)=>t.filter(n=>Mw(e,n.type)),Nw=(t,e,n,s)=>kd(t,e).map(({name:i})=>i).filter(i=>n.includes(i)?!s:s),ks={isRollupOperation:Dw,filterValidColumns:kd,getOperationColumnNames:Nw};const Ch=X.module("Aggregations"),Fw=[ke.SUM,ke.ABS_SUM,ke.MIN,ke.MAX,ke.VAR,ke.AVG,ke.STD,ke.FIRST,ke.LAST,ke.COUNT_DISTINCT,ke.DISTINCT,ke.COUNT,ke.UNIQUE],xw=({isRollup:t,settings:e,onChange:n,onEdit:s})=>{const{aggregations:i,showOnTop:o}=e,r=S.exports.useMemo(()=>Fw.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(()=>{Ch.debug("handleDragStart"),Xt.startDragging()},[]),f=S.exports.useCallback(({destination:x,source:U})=>{if(Ch.debug("handleDragEnd",x,U),Xt.stopDragging(),x===null)return;let $=x.index;U.index<x.index&&($+=1);const _=[...i],H=Xt.reorder(_,d,_,$),L=Xt.adjustDestinationIndex($,d),N=[[L,L+H.length-1]];m(_),c(N)},[m,i,d,c]),C=S.exports.useCallback(x=>{a(x)},[a]),b=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:_})=>{const H=x.operation,L=$?`${_}`:void 0,N=$?"item-list-item-clone":void 0,O=ks.isRollupOperation(x.operation),k=!$&&!O;return v(pe,{children:[v("div",{className:W("item-list-item-content","draggable-item-list-item-content",N),children:[v("span",{className:"title",children:[H,!t&&O&&v("span",{className:"small text-warning",children:[h(j,{icon:Tu})," Requires rollup"]})]}),on.renderBadge({text:L}),on.renderHandle()]}),!$&&v(pe,{children:[h(z,{kind:"ghost",className:"btn-edit",icon:hl,tooltip:"Edit Columns",onClick:()=>s(x),disabled:!k}),h(z,{kind:"ghost",className:"btn-delete",icon:_n,tooltip:"Delete Aggregation",onClick:()=>w(U)})]})]})},[w,s,t]),D=r.length>0,F=i.length>0;return v("div",{className:"aggregations",children:[D&&v("div",{className:"form-inline",children:[h(UC,{onChange:C,value:l,children:r.map(x=>h(VC,{value:x,children:x},x))}),v("button",{type:"button",className:"btn btn-link btn-add",onClick:b,children:[h(j,{icon:Ls}),"Add Aggregation"]})]}),D&&F&&h("hr",{}),F&&v(pe,{children:[!t&&v("div",{className:"form-inline",children:[h("label",{children:"Placement:\xA0"}),v(Sl,{onChange:E,value:`${o}`,children:[h(Nn,{value:"true",children:"Top"}),h(Nn,{value:"false",children:"Bottom"})]})]}),h(Uo,{onDragStart:g,onDragEnd:f,children:h(on,{className:"selected-aggregations",itemCount:i.length,items:i,renderItem:I,offset:0,onSelectionChange:T,onSelect:y,selectedRanges:d,isMultiSelect:!0})})]})]})};const _w=30,Ow=({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=kd(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],D=c.indexOf(I);let F=[...c],x=d;D>=0?F.splice(D,1):(F.push(I),F.length===p.length&&(F=[],x=!d)),n({...t,selected:F,invert:x})},[t,d,p,c,n]),C=S.exports.useCallback(()=>{a(0),n({...t,selected:[],invert:!0})},[t,n]),b=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(Bt,{checked:T,onChange:w,children:"Toggle All"}),h("div",{className:"spacer"}),h(ut,{in:y,timeout:Et.transitionSlowMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:h(z,{kind:"ghost",className:"btn-reset",onClick:C,children:"Reset"})}),h(z,{kind:"ghost",className:W({active:l===1}),icon:hd,tooltip:"Sort ascending",onClick:()=>a(1)}),h(z,{kind:"ghost",className:W({active:l===2}),icon:ud,tooltip:"Sort descending",onClick:()=>a(2)})]})}),h("div",{className:"aggregation-edit-item-list",children:h(bn,{itemCount:p.length,items:g,offset:s,renderItem:({item:E})=>h(Bt,{checked:m(E.value),children:E.displayValue}),onSelect:f,onViewportChange:b,rowHeight:_w,focusSelector:"input",ref:u})})]})};function kw(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 Lw(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 Aw(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 Pw(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 Hw(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 Vw(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 Uw(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 bh=X.module("ChartBuilder"),ft=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(Aw,{});case M.plot.SeriesPlotStyle.BAR:return h(kw,{});case M.plot.SeriesPlotStyle.SCATTER:return h(Hw,{});case M.plot.SeriesPlotStyle.PIE:return h(Pw,{});case M.plot.SeriesPlotStyle.HISTOGRAM:return h(Lw,{});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:ze.generate(),value:t}}static makeDefaultSeriesItems(t,e){if(ft.getMaxSeriesCount(t)===0||e==null||e.length===0)return[];const s=e.length>1?e[1].name:e[0].name;return[ft.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=ft.types[0],i=ft.getDefaultXAxis(s,n),o=ft.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:ze.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=ft.types[0],s=ft.getDefaultXAxis(n,e),i=ft.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=ft.types[s];bh.debug2("handleTypeSelect",i),this.setState(o=>{const r=ft.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=ft.makeDefaultSeriesItems(i,d)}return{type:i,seriesItems:l}},this.sendChange)}handleXAxisChange(t){const e=t.target.value;bh.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=ft.getMaxSeriesCount(s),l=ft.getXAxisLabel(s),a=ft.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:ft.types.map((u,m)=>{const p=u;return h("div",{className:"col col-chart-type",children:v("button",{type:"button",className:W("btn","btn-icon","btn-chart-type",{active:u===s}),"data-index":m,onClick:this.handleTypeClick,children:[ft.getTypeIcon(u),ft.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(z,{kind:"ghost",className:"btn-delete-series ml-2 px-2","data-index":m,"data-testid":`delete-series-${m}`,onClick:this.handleSeriesDeleteClick,icon:_n,tooltip:"Delete"})]},u.id)),c&&v("div",{className:"form-row",children:[h("div",{className:"col-2"}),h(z,{kind:"ghost",className:"btn-add-series mt-1",onClick:this.handleAddSeries,icon:Ls,children:"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(j,{mask:pd,icon:Ao,transform:"right-5 down-5"}),h(j,{icon:o?ld:cC,transform:"grow-2 right-8 down-6"})]})}),v(Sl,{onChange:this.handleLinkStateChange,value:`${o}`,children:[h(Nn,{value:"true",children:"Sync State"}),h(Nn,{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:W("form-row","justify-content-end","my-3"),children:[h(z,{kind:"secondary",className:"btn-reset",onClick:this.handleReset,children:"Reset"}),h(z,{kind:"primary",type:"submit",className:"btn-submit",children:"Create"})]})]})})}};let jm=ft;jm.types=[M.plot.SeriesPlotStyle.LINE,M.plot.SeriesPlotStyle.BAR,M.plot.SeriesPlotStyle.SCATTER,M.plot.SeriesPlotStyle.PIE];class Qm 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:W("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"})]})}}Qm.defaultProps={value:"",onContentChanged:()=>{},editorSettings:{},editorIndex:0,onTab:()=>{},invalid:!1};const Ua=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,Ua.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:W("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:W("form-control custom-column-input",{"is-invalid":l}),placeholder:"Column Name",value:e,onChange:c=>{s(t,Ua.INPUT_TYPE.NAME,c.target.value)}}),h(z,{kind:"ghost",className:"ml-1 px-2",onClick:()=>{i(t)},icon:_n,tooltip:"Delete custom column"}),v("button",{type:"button",className:"btn btn-link btn-link-icon px-2 btn-drag-handle",...a.dragHandleProps,children:[h($e,{children:"Drag column to re-order"}),h(j,{icon:ul})]})]}),h(Qm,{editorSettings:{language:"deephavenDb"},editorIndex:o,value:n,onContentChanged:this.handleFormulaEditorContentChanged,onTab:r,invalid:l})]}),h("hr",{})]})})}};let Ld=Ua;Ld.INPUT_TYPE={NAME:"name",FORMULA:"formula"};Ld.defaultProps={name:"",inputIndex:0,formula:"",onChange:()=>{},onDeleteColumn:()=>{},onTabInEditor:()=>{},invalid:!1};class Zm extends Error{constructor(){super(...arguments),this.isAssertionFailed=!0}}function Sh(t){if(t==null)throw new Zm(`Expected 'val' to be defined, but received ${t}`)}class da extends Error{constructor(){super(...arguments),this.isPasteError=!0}}function Je(t){return(t==null?void 0:t.isEditable)!==void 0}function wh(t){if(!Je(t))throw new Zm(`Expected 'model' to be editable, but received ${t}`)}function pt(t){return(t==null?void 0:t.hasExpandableRows)!==void 0}var Mn=(t=>(t.DOWN="DOWN",t.UP="UP",t.LEFT="LEFT",t.RIGHT="RIGHT",t))(Mn||{});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=Mn;function Bw(t){return Array.isArray(t)&&t.length===2&&(t[0]===null||typeof t[0]=="number")&&(t[1]===null||typeof t[1]=="number")}function ca(t){return Bw(t)&&t[0]!=null&&t[1]!=null}const Ne=class{static getGridPointFromXY(t,e,n){const s=Ne.getColumnAtX(t,n),i=Ne.getRowAtY(e,n),o=Ne.getColumnHeaderDepthAtY(e,n);return{x:t,y:e,row:i,column:s,columnHeaderDepth:o}}static getCellInfoFromXY(t,e,n){const{row:s,column:i}=Ne.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,C=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:C!=null?C:null}}static getColumnHeaderDepthAtY(t,e){const n=Ne.getRowAtY(t,e),{columnHeaderHeight:s,columnHeaderMaxDepth:i}=e;if(n===null&&t<=s*i)return Ut(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=Ne.iterateFloatingStart(t,n,s);return i!==void 0?i:Ne.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=Ne.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:Ne.iterateFloating(n,s,e,d=>{if(Ne.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(Ne.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 Ne.getNextShownItem(t,n,s,i)}static getNextShownRow(t,e){const{modelRows:n,visibleRows:s,userRowHeights:i}=e;return Ne.getNextShownItem(t,n,s,i)}static getColumnSeparatorIndex(t,e,n,s){var b,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 C=!1;for(let E=r.length-1;E>=0;E-=1){const I=r[E],D=(b=d.get(I))!=null?b:0,F=(w=c.get(I))!=null?w:0,x=F===0;if(!C||!x){let U=D+F;x?U+=f:C&&(U-=f);const $=U-f,_=U+f;if($<=g&&g<=_)return I;C=x}}C=!1;for(let E=a.length-1;E>=0;E-=1){const I=a[E],D=(T=d.get(I))!=null?T:0,F=(y=c.get(I))!=null?y:0,x=F===0;if(D<l-F)return null;if(!C||!x){let U=D+F;x?U+=f:C&&(U-=f);const $=U-f,_=U+f;if($<=g&&g<=_)return I;C=x}}return null}static isItemHidden(t,e){return e.get(t)===0}static isColumnHidden(t,e){const{visibleColumnWidths:n}=e;return Ne.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(!Ne.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(!Ne.isItemHidden(r,e))break;s.push(r)}return s}static getHiddenColumns(t,e){const{visibleColumns:n,visibleColumnWidths:s}=e;return Ne.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 C=r.length-1;C>=0;C-=1){const b=r[C],w=(g=l.get(b))!=null?g:0,T=(f=a.get(b))!=null?f:0,y=T===0;if(!p||!y){let E=w+T;y?E+=m:p&&(E-=m);const I=E-m,D=E+m;if(I<=u&&u<=D)return b;p=y}}return null}static isRowHidden(t,e){const{visibleRowHeights:n}=e;return Ne.isItemHidden(t,n)}static getHiddenRows(t,e){const{visibleRows:n,visibleRowHeights:s}=e;return Ne.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&&!ca(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&&ca(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;ca(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,C=[];for(let b=0;b<i.length;b+=1){const w=(o=i[b][0])!=null?o:Number.NEGATIVE_INFINITY,T=(r=i[b][1])!=null?r:Number.POSITIVE_INFINITY;let y;const E=[[w,m-1],[m,p],[p+1,T]].map(([I,D])=>[Math.max(I,w),Math.min(D,T)]).filter(([I,D])=>I<=D).map(I=>{const[D,F]=I;return m<=D&&p>=F?(y=[D+f,F+f],y):p<D?[D-c,F-c]:I}).map(I=>{const[D,F]=I;return g>D&&g<=F?[[D,g-1],[g+c,F+c]]:I===y?[I]:g<=D?[[D+c,F+c]]:[I]}).flat();C.push(...E)}i=C.map(([b,w])=>[Number.isFinite(b)?b:null,Number.isFinite(w)?w:null])}return i}static translateRange(t,e,n,s){const i=Ne.applyItemMoves(t.startColumn,t.endColumn,e,s),o=Ne.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 Ne.applyItemMoves(t,t,e,!0)[0][0]}static getModelIndexes(t,e){return t.map(n=>Ne.getModelIndex(n,e))}static getModelRangeIndexes(t,e,n){return Ne.applyItemMoves(t,e,n,!0)}static getModelRange(t,e=[],n=[]){return Ne.translateRange(t,e,n,!0)}static getModelRanges(t,e=[],n=[]){const s=[];for(let i=0;i<t.length;i+=1)s.push(...Ne.getModelRange(t[i],e,n));return s}static getVisibleRangeIndexes(t,e,n){return Ne.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(...Ne.getVisibleRange(t[i],e,n));return s}static getVisibleIndex(t,e){return Ne.applyItemMoves(t,t,e)[0][0]}static getVisibleIndexes(t,e){return t.map(n=>Ne.getVisibleIndex(n,e))}static isMacPlatform(){const{platform:t}=window.navigator;return t.startsWith("Mac")}static getModifierKey(){return Ne.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(t){const e=Ne.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:C}=t;let b=s,w=i,T=o,y=r;return n!=null&&(n>d&&(b+=u),n<f-c&&(T-=m)),e!=null&&(e>l&&(w+=p),e<C-a&&(y-=g)),{x1:b,y1:w,x2:T,y2:y}}static getScrollDelta(t,e=1024,n=768,s=20,i=20){let{deltaX:o,deltaY:r}=t;return!Ne.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&&(Ne.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 K=Ne;K.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 vr(t,e=Yo.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 vh(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:C,minScrollHandleSize:b,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:D,floatingRightColumnCount:F,columnHeaderMaxDepth:x}=a,U=this.getFirstRow(t),$=this.getFirstColumn(t),_=this.getGridX(t),H=this.getGridY(t),L=pt(a)&&a.hasExpandableRows?this.calculateTreePaddingX(t):0,N=0;let O=this.getVisibleRowHeights(t),k=this.getVisibleColumnWidths(t,$,L);const V=Array.from(O.keys()),G=Array.from(k.keys());O=new Map([...O,...this.getFloatingRowHeights(t)]),k=new Map([...k,...this.getFloatingColumnWidths(t)]);let Q=this.getVisibleColumnXs(k,G,s),J=this.getVisibleRowYs(O,V,i);const ve=V.length>0?V[V.length-1]:n,le=G.length>0?G[G.length-1]:e,be=this.getBottomViewport(t,V,J,O),_e=this.getRightViewport(t,G,Q,k),ee=this.getFloatingTopHeight(t,O),ge=this.getFloatingBottomHeight(t,O),Se=this.getFloatingLeftWidth(t,k),Re=this.getFloatingRightWidth(t,k),qe=Array.from(k.values()),Oe=Array.from(O.values()),jn=qe.reduce((mt,fi)=>mt+fi,0)-s,wn=Oe.reduce((mt,fi)=>mt+fi,0)-i,bt=this.getLastLeft(t,null,o-_-w-g),Ie=this.getLastTop(t,null,r-H-w-ge),ot=s+jn+g,rt=i+wn,Ft=o-_,Qt=r-H,Zt=bt>0||ot>Ft,xt=Zt?w:0,kn=Ie>0||rt>Qt-xt,$t=kn?w:0,vn=o-p-$t,Hs=r-C-xt,zl=p,Gl=C,Kl=T===1?vn/ot:(T-bt)/T,Jo=y===1?Hs/rt:(y-Ie)/y,er=Zt?Ut(vn*Kl,b,vn-1):0,tr=kn?Ut(Hs*Jo,b,Hs-1):0,nr=B(k,e,0),sr=B(O,n,0),ir=nr>0?s/nr:0,or=sr>0?i/sr:0,ql=T===1?s/(ot-Ft):(e+ir)/bt,Yl=y===1?i/(rt-Qt):(n+or)/Ie,Vs=Zt?ql*(vn-er):0,Xl=kn?Yl*(Hs-tr):0;let Us=[];(E>0||I>0)&&(Us=[...Array(E).keys(),...[...Array(I).keys()].map(mt=>y-mt-1)],J=new Map([...J,...this.getFloatingRowYs(t,O,Math.floor(r-H-xt))]));let ro=[];(D>0||F>0)&&(ro=[...Array(D).keys(),...[...Array(F).keys()].map(mt=>T-mt-1)],Q=new Map([...Q,...this.getFloatingColumnXs(t,k,Math.floor(o-_-$t))]));const rr=[];if(u)for(let mt=u.range[0];mt<=u.range[1];mt+=1)rr.push(mt),k.has(mt)||k.set(mt,this.getVisibleColumnWidth(mt,t)),Q.has(mt)||Q.set(mt,0);const lr=V.concat(Us),lo=G.concat(ro).concat(rr),ao=this.getModelRows(lr,t),jl=this.getModelColumns(lo,t),Ql=this.getVisibleRowTreeBoxes(O,ao,t),ar=this.getTopVisible(t,J,O,V),Zl=this.getLeftVisible(t,Q,k,G),dr=Ie>0?this.getBottomVisible(t,J,O,V,H):ve,cr=bt>0?this.getRightVisible(t,Q,k,G,_):le,{fontWidths:hr,userColumnWidths:ur,userRowHeights:mr,calculatedRowHeights:Jl,calculatedColumnWidths:ea}=this;return{rowHeight:m,rowHeaderWidth:p,rowFooterWidth:g,rowCount:y,columnWidth:f,columnCount:T,columnHeaderHeight:C,floatingTopRowCount:E,floatingBottomRowCount:I,floatingLeftColumnCount:D,floatingRightColumnCount:F,gridX:_,gridY:H,firstRow:U,firstColumn:$,treePaddingX:L,treePaddingY:N,left:e,top:n,bottom:ve,right:le,topOffset:i,leftOffset:s,topVisible:ar,leftVisible:Zl,bottomVisible:dr,rightVisible:cr,bottomViewport:be,rightViewport:_e,width:o,height:r,maxX:jn,maxY:wn,lastLeft:bt,lastTop:Ie,barHeight:Hs,barTop:Gl,barWidth:vn,barLeft:zl,handleHeight:tr,handleWidth:er,hasHorizontalBar:Zt,hasVerticalBar:kn,verticalBarWidth:$t,horizontalBarHeight:xt,scrollX:Vs,scrollY:Xl,scrollableContentWidth:ot,scrollableContentHeight:rt,scrollableViewportWidth:Ft,scrollableViewportHeight:Qt,visibleRows:V,visibleColumns:G,floatingRows:Us,floatingColumns:ro,allRows:lr,allColumns:lo,visibleRowHeights:O,visibleColumnWidths:k,floatingTopHeight:ee,floatingBottomHeight:ge,floatingLeftWidth:Se,floatingRightWidth:Re,visibleRowYs:J,visibleColumnXs:Q,visibleRowTreeBoxes:Ql,modelRows:ao,modelColumns:jl,movedRows:d,movedColumns:c,fontWidths:hr,userColumnWidths:ur,userRowHeights:mr,calculatedRowHeights:Jl,calculatedColumnWidths:ea,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,n){const{model:s}=t,{columnCount:i,floatingRightColumnCount:o}=s;let r=Math.max(0,i-o-1);e!=null&&(r=e);let l=0;for(;r>0;){if(l+=this.getVisibleColumnWidth(r,t),l>=n)return Math.min(r+1,e!=null?e:i-1);r-=1}return 0}getLastTop(t,e,n){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 vh(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 vh(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 pt(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=K.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=K.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)),vr(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),vr(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 C=0;const b=this.getWidthForFont(c,e),w=s/m,T=Math.ceil(n+w);return K.iterateAllItems(n,T,l,a,d,y=>{const E=this.getModelRow(y,e),I=o.textForCell(t,E);if(I){const D=u*2;C=Math.max(C,I.length*b+D)}}),C=Math.max(Math.min(C,(i-p-f-g)*Jm.MAX_COLUMN_WIDTH),u*2),C}calculateTreePaddingX(t){const{top:e,height:n,model:s,theme:i}=t,{rowHeight:o,treeDepthIndent:r}=i;if(!pt(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)),vr(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)),vr(n),this.userRowHeights=n}resetRowHeight(t){const e=new Map(this.userRowHeights);e.delete(t),this.userRowHeights=e,this.calculatedRowHeights.delete(t)}};let Yo=Jm;Yo.CACHE_SIZE=1e4;Yo.MAX_COLUMN_WIDTH=.8;const $w=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"}),an=(t,e)=>{let n=!1;const s=Te(t,{...e,dispose:()=>{n||(n=!0,s.clear(),n=!1)}});return s};function Ww(t,e,n=6){const s=ya.hex.lab.raw(t);return s[0]=Math.max(s[0]-s[0]/n*e,0),`#${ya.lab.hex(s)}`}function zw(t,e){const[n,s,i]=ya.hex.rgb(t);return`rgba(${n}, ${s}, ${i}, ${e})`}const Th={colorWithAlpha:zw,darkenForDepth:Ww};class yt{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 ep extends yt{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 C=B(l,g),b=s-a-C-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 D=b;Math.abs(b-I)<=r.headerResizeSnapThreshold?D=null:T!==void 0&&b>T&&(y&&E!==0||E>0)?D=T:b<=r.headerResizeHiddenSnapThreshold&&(D=0),D!==I?p.set(w,D):p.set(w,null),b<-r.headerResizeSnapThreshold&&D===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&&b>T+r.headerResizeSnapThreshold&&D===T?E>0?(this.dragOffset+=D,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((C,b)=>{C!==null?this.setSize(i,b,C):this.resetSize(i,b)}),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 xl extends ep{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=K.getHiddenColumns,this.getNextShownItem=K.getNextShownColumn,this.getSeparator=xl.getColumnSeparator}static getColumnSeparator(e,n,s,i){if(!i.allowColumnResize)return null;const{x:o,y:r,columnHeaderDepth:l}=e,{modelColumns:a}=n,d=K.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=an((t,e,n,s,i)=>os.truncateToWidth(t,e,n,s,i),{max:1e4}),this.getCachedBackgroundColors=an((t,e)=>t.split(" ").map(n=>{const s=[];for(let i=0;i<e;i+=1)s.push(Th.darkenForDepth(n,i,e));return s}),{max:1e3}),this.getCachedColorWithAlpha=an((t,e)=>Th.colorWithAlpha(t,e),{max:1e3}),this.getCachedColorIsDark=an(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 C=a[f];this.drawCellContent(t,e,g,C)}}}}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:C,width:b,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,b-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(C,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(C,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:C,floatingDividerInnerColor:b}=s;if(t.lineWidth=3,t.beginPath(),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)}if(t.stroke(),t.beginPath(),t.lineWidth=1,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)}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:C,height:b}=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:C+10,maxY:r>0&&p.has(u-r-1)?B(p,u-r-1)+B(m,u-r-1)-.5:b+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,C=[],b=[],w=(T,y)=>{const E=pt(a)?a.depthForRow(T):0,I=m[T%m.length],D=I[Math.min(E,I.length-1)];if(f.has(D)||f.set(D,[]),f.get(D).push(T),y!=null){const F=pt(a)?a.depthForRow(y):0;F<E?C.push(T):F>E&&b.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],D=B(p,I),F=B(g,I);t.rect(i,D,o,F)}t.fill()}),C.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<C.length;I+=1){const D=C[I],F=B(p,D);t.translate(0,F),t.fillRect(i,0,o,c),t.translate(0,-F)}t.restore()}if(b.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<b.length;I+=1){const D=b[I],F=B(p,D),x=B(g,D),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=K.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=K.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=K.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),C=B(d,n),b=r.backgroundColorForCell(C,f,l),w=n===a,T=pt(r)&&r.hasExpandableRows;if(b!=null){const y=B(u,n)+1,E=B(p,s)+1,I=B(m,n)-1,D=B(g,s)-1;t.fillStyle=b,t.fillRect(y,E,I,D)}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,C=B(d,n),b=B(u,s),w=B(c,n),T=B(m,s),y=n===a;let E=0;pt(r)&&r.hasExpandableRows&&y&&(E=g*(r.depthForRow(s)+1)+f);const I=w-E;let D=C+p;const F=b+T*.5;return i==="right"?D=C+I-p:i==="center"&&(D=C+I*.5),D+=E,{width:I-p*2,x:D,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),C=B(c,n),b=i!=null?i:r.textForCell(C,f),w=r.truncationCharForCell(C,f),T=n===a;if(b&&g>0){const E=r.textAlignForCell(C,f)||"left";t.textAlign=E;const I=r.colorForCell(C,f,l)||p;t.fillStyle=I;const{width:D,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,b,D,U,w);$&&t.fillText($,F,x)}T&&pt(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:C,treeMarkerHoverColor:b}=l,w=B(u,a),T=B(m,a),y=B(p,n),E=B(g,n);if(!pt(i)||!i.isRowExpandable(n))return;const I=B(f,n),D=o!=null&&r!=null&&o>=d+w&&o<=d+w+T&&r>=c+y&&r<=c+y+E?b:C;this.drawTreeMarker(t,e,w,y,I,D,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(!pt(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),C=B(c,n),b=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,C),t.lineTo(E,C+b)}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,C),t.lineTo(E,C+Math.ceil(b/2)),t.moveTo(E-.5,C+Math.ceil(b/2)+.5),t.lineTo(E+m-.5,C+Math.ceil(b/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:C,floatingLeftWidth:b,floatingRightWidth:w,modelColumns:T,columnHeaderMaxDepth:y}=o;if(d<=0)return;const{headerHiddenSeparatorSize:E,headerHiddenSeparatorHoverColor:I,headerSeparatorColor:D,headerSeparatorHoverColor:F}=i,x=d*.5,U=d*(y-1)+d*.5-x*.5,$=C>0;if(t.save(),this.drawColumnHeadersForRange(t,e,[p[0],p[p.length-1]],{minX:u+b,maxX:m-w}),$&&this.drawColumnHeadersForRange(t,e,[c[0],c[c.length-1]],{minX:u,maxX:u+b}),D){t.strokeStyle=D;const _=[...g.entries()].filter(([H,L])=>L===0).map(([H])=>H);t.beginPath(),t.fillStyle=D;for(let H=0;H<_.length;H+=1){const L=_[H],N=B(f,L),O=B(g,L),k=u+N+O+.5-E*.5;t.rect(k,U,E,x)}t.fill()}if(F){let{index:_,depth:H}=r!=null?r:{};if(_==null&&n!=null&&s!=null){const N=xl.getColumnSeparator(K.getGridPointFromXY(n,s,o),o,a,i);_=N==null?void 0:N.index,H=N==null?void 0:N.depth}let L;if(_==null)L=!1;else{const N=T.get(_),O=T.get(_+1);N==null||O==null?L=!1:L=a.textForColumnHeader(N,H)!==a.textForColumnHeader(O,H)}if(L&&_!=null&&H!=null&&(!l||r!=null)){t.strokeStyle=F;const N=B(f,_),O=B(g,_),k=u+N+O+.5,V=p.indexOf(_),G=V<p.length-1?p[V+1]:null,Q=G!=null?g.get(G):null,J=O===0,ve=Q!=null&&Q===0;J?(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 D,F,x,U,$,_;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:C}=l,{columnHeaderMaxDepth:b}=r,{minX:w,maxX:T}=s,y=T-w;if(b===0)return;const E=n[0],I=n[1];if(t.save(),t.translate(0,(b-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),O=r.textForColumnHeader(N,i),k=r.colorForColumnHeader(N,i);let V=B(d,H)+c,G=V+B(p,H);if(O!=null){let Q=H-1;for(;Q>=0&&(G-V<y||V>w);){const be=(D=a.get(Q))!=null?D:K.getModelIndex(Q,g);if(be==null||r.textForColumnHeader(be,i)!==O)break;V-=(x=(F=m.get(be))!=null?F:u.get(be))!=null?x:C,Q-=1}let J=H+1;for(;J<L&&(G-V<y||G<T);){const be=(U=a.get(J))!=null?U:K.getModelIndex(J,g);if(r.textForColumnHeader(be,i)!==O)break;G+=(_=($=m.get(be))!=null?$:u.get(be))!=null?_:C,J+=1}H=J-1;const ve=G-V>=y;let le=V;ve&&(G<T?le=G-y:V<w&&(le=w)),this.drawColumnHeader(t,e,O,le,Math.min(G-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 J;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:C,width:b}=l,w=(J=C.get(t.font))!=null?J:os.DEFAULT_FONT_WIDTH,y=(i-d*2)/w,{backgroundColor:E=u,separatorColor:I=p}=o!=null?o:{};let{textColor:D=m}=o!=null?o:{};try{const ve=this.getCachedColorIsDark(E),le=this.getCachedColorIsDark(D);ve&&le?D=f:!ve&&!le&&(D=g)}catch{}let{minX:F=0,maxX:x=b}=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=D;let U=n;y<=0?U="":U.length>y&&(U=`${U.substring(0,y-1)}\u2026`);const $=U.length*w;let _=s+i*.5;const H=c*.5;F+=d,x-=d;const L=s+d,N=Ut(L,F,x),O=s+i-d,V=Ut(O,F,x)-N,G=_-$*.5<F,Q=_+$*.5>x;G?$<V?_=F+$*.5:_=O-$*.5:Q&&($<V?_=x-$*.5:_=L+$*.5),t.textAlign="center",t.fillText(U,_,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:C,headerSeparatorColor:b,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),b){t.strokeStyle=b,t.beginPath(),t.moveTo(0,l+.5),t.lineTo(a,l+.5);const E=[];let I=!1;for(let D=0;D<c.length;D+=1){const F=c[D],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=b;for(let D=0;D<E.length;D+=1){const F=E[D],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=K.getRowSeparatorIndex(n,s,i,o)),E!=null){t.strokeStyle=w;const I=B(m,E),D=B(u,E),F=l+I+D+.5,x=c.indexOf(E),U=x<c.length-1?c[x+1]:null,$=U!=null?u.get(U):null,_=D===0,H=$!=null&&$===0;_?(t.strokeStyle=C,t.fillStyle=C,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],D=B(u,I),F=B(m,I)+l;this.drawRowHeader(t,e,I,F,D)}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:C,visibleRowYs:b,width:w}=i;if(m<=0)return;const{cellHorizontalPadding:T,headerBackgroundColor:y,headerColor:E,headerHiddenSeparatorSize:I,headerHiddenSeparatorHoverColor:D,headerSeparatorColor:F,headerSeparatorHoverColor:x}=r,U=m*.5,$=m*.5-U*.5,_=Math.min(d+c,w-m-g);if(t.save(),t.beginPath(),t.fillStyle=y,t.fillRect(_,a,m,p),F){t.strokeStyle=F,t.beginPath(),t.moveTo(_,a+.5),t.lineTo(m,a+.5);const L=[];let N=!1;for(let O=0;O<f.length;O+=1){const k=f[O],V=B(b,k),G=B(C,k);if(G>0){const Q=a+V+G+.5;t.moveTo(_+.5,Q),t.lineTo(_+m-.5,Q),N=!1}else N||(N=!0,L.push(k))}t.moveTo(_+.5,a),t.lineTo(_+.5,p),t.stroke(),t.beginPath(),t.fillStyle=F;for(let O=0;O<L.length;O+=1){const k=L[O],V=B(b,k),G=B(C,k),Q=a+V+G+.5-I*.5;t.rect(_+$,Q,U,I)}t.fill()}if(x){let{index:L=null}=l!=null?l:{};if(L==null&&n!=null&&s!=null&&(L=K.getRowSeparatorIndex(n,s,i,r)),L!=null){t.strokeStyle=x;const N=B(b,L),O=B(C,L),k=a+N+O+.5,V=f.indexOf(L),G=V<f.length-1?f[V+1]:null,Q=G!=null?C.get(G):null,J=O===0,ve=Q!=null&&Q===0;J?(t.strokeStyle=D,t.fillStyle=D,t.fillRect($,k,U,I*.5)):ve&&(t.fillStyle=x,t.fillRect($,k-I*.5,U,I*.5)),t.beginPath(),t.moveTo(_+.5,k),t.lineTo(_+m+.5,k),t.stroke()}}t.beginPath(),t.rect(_,a,m,p),t.clip(),t.fillStyle=E,t.textAlign="left";const H=_+T;for(let L=0;L<f.length;L+=1){const N=f[L],O=B(C,N);if(O>0){const k=B(b,N)+a,V=B(u,N),G=k+O*.5;t.fillText(o.textForRowFooter(V),H,G)}}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:C,height:b}=a,{left:w=a.left,top:T=a.top,right:y=a.right,bottom:E=a.bottom,minY:I=-10,maxY:D=b+10,minX:F=-10,maxX:x=C+10}=n;if(c.length===0)return;const U=Je(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),_=B(f,i),H=B(m,s),L=B(g,i);t.save(),t.beginPath(),t.rect(0,0,C,b),t.rect($,_,H,L),t.clip("evenodd")}t.beginPath();for(let $=0;$<c.length;$+=1){const _=c[$],H=_.startColumn!==null?_.startColumn:w,L=_.startRow!==null?_.startRow:T,N=_.endColumn!==null?_.endColumn:y,O=_.endRow!==null?_.endRow:E;if(O>=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,G=N<=y&&p.has(N)?Math.round(B(p,N)+B(m,N))-.5:x,Q=O<=E&&f.has(O)?Math.round(B(f,O)+B(g,O))-.5:D;t.rect(k,V,G-k,Q-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,C=m-i*.5,b=p+i,w=g+i;f<=0&&(b+=f-1,f=1),C<=0&&(w+=C-1,C=1);const{lineWidth:T}=t;t.beginPath(),t.lineWidth=i,t.strokeStyle=r.selectionOutlineColor,this.drawRoundedRect(t,f,C,b,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 Q;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:C,movedColumns:b,modelColumns:w,floatingLeftWidth:T}=s,y=(Q=w.get(l[0]))!=null?Q:K.getModelIndex(l[0],b),E=r.getColumnHeaderGroup(y,a);if(a>0&&!E)return;const[I,D]=l,F=B(u,I),U=B(u,D)+B(m,D)-F,$=n.left,{backgroundColor:_,font:H,headerFont:L,reorderOffset:N,shadowBlur:O,shadowColor:k}=o,V=(f-a-1)*C;t.save(),t.translate(d,0),t.save(),t.beginPath(),t.rect(T,0,g,p),t.clip(),t.fillStyle=_,t.fillRect(F,V,U,p),t.restore(),t.translate(0,N),t.save(),t.shadowColor=k,t.shadowBlur=O,t.fillStyle=_,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 G=[];for(let J=n.range[0];J<=n.range[1];J+=1)G.push(J);this.drawColumnHeaders(t,e),this.drawColumnHeadersForRange(t,e,[G[0],G[G.length-1]],{minX:F,maxX:g}),t.translate(0,c),t.font=H,this.drawGridBackground(t,e);for(let J=I;J<=D;J+=1)this.drawColumnCellContents(t,e,J);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:C,reorderOffset:b,shadowBlur:w,shadowColor:T}=r;t.save(),t.translate(0,a),t.fillStyle=g,t.fillRect(0,m,u,p),t.translate(l+b,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=C,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:C,hasHorizontalBar:b,hasVerticalBar:w,barWidth:T,barHeight:y}=o,{scrollBarBackgroundColor:E,scrollBarHoverBackgroundColor:I,scrollBarCasingColor:D,scrollBarCornerColor:F,scrollBarColor:x,scrollBarHoverColor:U,scrollBarActiveColor:$,scrollBarSize:_,scrollBarHoverSize:H,scrollBarCasingWidth:L,scrollBarSelectionTick:N,scrollBarSelectionTickColor:O,scrollBarActiveSelectionTickColor:k,autoSelectRow:V,autoSelectColumn:G}=a,Q=r!=null&&l!=null&&r<=u&&l<=m,J=s||w&&!n&&!i&&r!=null&&l!=null&&r>=u-H&&l<=y+c&&Q,ve=n||b&&!s&&!i&&!J&&r!=null&&l!=null&&l>=m-H&&r<=T-d&&Q,le=ve?H:_,be=J?H:_;if(t.translate(d,c),b&&w&&(t.fillStyle=D,t.fillRect(u-d-_,m-c-_,_,_),t.fillStyle=F,t.fillRect(u-d-_+L,m-c-_+L,_-L,_-L)),b){const _e=f,ee=m-c-le;if(t.fillStyle=D,t.fillRect(0,ee,T,le-L),t.fillStyle=ve?I:E,t.fillRect(0,ee+L,T,le-L),n?t.fillStyle=$:ve?t.fillStyle=U:t.fillStyle=x,t.fillRect(_e,ee+L,g,le-L),!V&&N&&O!=null&&k!=null){t.fillStyle=O;const{selectedRanges:ge,cursorColumn:Se}=e,{lastLeft:Re,columnCount:qe}=o,jn=[...ge].filter(Ie=>Ie.startColumn!=null&&Ie.endColumn!=null).map(Ie=>[Ie.startColumn,Ie.endColumn]).sort(K.compareRanges),wn=K.mergeSortedRanges(jn),bt=Ie=>Ie<=Re?Ie/Re*(T-g):T-g+(Ie-Re)/(qe-Re)*g;for(let Ie=0;Ie<wn.length;Ie+=1){const ot=wn[Ie],rt=ot[0],Ft=ot[1];if(rt!=null&&Ft!=null&&(rt!==Se||Ft!==Se)){const Qt=bt(rt),Zt=Math.max(1,Math.round(bt(Ft+1)-Qt)),xt=le-L;t.fillRect(Qt,ee+L+Math.round(xt/3),Zt,Math.round(xt/3))}}if(Se!=null){const Ie=bt(Se),ot=2,rt=le-L;t.fillStyle=k,t.fillRect(Ie,ee+L,ot,rt)}}}if(w){const _e=u-d-be,ee=C;if(t.fillStyle=D,t.fillRect(_e,0,be-L,y),t.fillStyle=J?I:E,t.fillRect(_e+L,0,be-L,y),s?t.fillStyle=$:J?t.fillStyle=U:t.fillStyle=x,t.fillRect(_e+L,ee,be-L,p),!G&&N&&O!=null&&k!=null){const{selectedRanges:ge,cursorRow:Se}=e,{lastTop:Re,rowCount:qe}=o,Oe=Ie=>Ie<=Re?Ie/Re*(y-p):y-p+(Ie-Re)/(qe-Re)*p;t.fillStyle=O;const wn=[...ge].filter(Ie=>Ie.startRow!=null&&Ie.endRow!=null).map(Ie=>[Ie.startRow,Ie.endRow]).sort(K.compareRanges),bt=K.mergeSortedRanges(wn);for(let Ie=0;Ie<bt.length;Ie+=1){const ot=bt[Ie],rt=ot[0],Ft=ot[1];if(rt!=null&&Ft!=null&&(rt!==Se||Ft!==Se)){const Qt=Oe(rt),Zt=be-L,xt=Math.max(1,Math.round(Oe(Ft+1)-Qt));t.fillRect(_e+L+Math.round(Zt/3),Qt,Math.round(Zt/3),xt)}}if(Se!=null){const Ie=Math.round(Oe(Se)),ot=be-L,rt=2;t.fillStyle=k,t.fillRect(_e+L,Ie,ot,rt)}}}t.translate(-d,-c)}};let zi=os;zi.DEFAULT_FONT_WIDTH=10;zi.DEFAULT_EDGE_RADIUS=2;zi.ACTIVE_CELL_BORDER_WIDTH=2;const Eh=100;class Gw extends yt{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=K.isModifierKeyDown(s),C=s.shiftKey;f||(C?n.trimSelectedRanges():n.clearSelectedRanges());const b=n.getTheme(),{autoSelectRow:w,autoSelectColumn:T}=b;return(r!==null||!T)&&(l!==null||!w)&&(n.focus(),n.moveCursorToPosition(r,l,C,!1,C&&f)),this.startPoint=e,this.hasExtendedFloating=!1,this.dragBounds=K.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,C=K.getScrollDragBounds(d,s,i);let b=0,w=0;if(c<u&&(o<C.x1?b=o-C.x1:o>C.x2&&(b=o-C.x2)),m<p&&(r<C.y1?w=r-C.y1:r>C.y2&&(w=r-C.y2)),b!==0||w!==0)this.startTimer(n,e,b>0?Math.ceil(b/g):Math.floor(b/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:D,rowCount:F,bottom:x,right:U,topVisible:$,bottomVisible:_,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>=D-I&&a<D-I&&(a=D-I-1,this.hasExtendedFloating=!0)),s!==null&&!K.isFloatingRow(s,d)&&K.isFloatingRow(l,d)&&(s>l&&l<m?l=$-1:s<l&&l>x&&(l=_+1)),i!==null&&!K.isFloatingColumn(i,d)&&K.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?Eh-Math.min(Eh,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 yh=5,Kw=1e3/60,Tr=10;function Rs(t,e,n,s){var T,y,E,I,D,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:K.getModelIndex(t,o),g=s.getColumnHeaderGroup(p,e),f=g!=null;let C,b,w;if(g!=null){const[U,$]=g.getVisibleRange(o);C=(y=r.get(U))!=null?y:u,b=((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;C=U,b=C+((x=(F=(D=a.get(t))!=null?D:d.get(p))!=null?F:c.get(p))!=null?x:0),w=[t,t]}return{visibleIndex:t,modelIndex:p,left:C,right:b,width:b-C,isColumnGroup:f,range:w,depth:e}}class qw extends yt{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,C;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-=Tr;m<0;){u-=1;const b=K.getModelIndex(i-1,d),w=(f=l.get(b))!=null?f:a.get(b);w===void 0?m=0:m+=w,u<0&&(m=0,u=0)}else{m+=Tr;let b=c.get(i);for(;b!==void 0&&m>b;){u+=1,m-=b;const w=K.getModelIndex(i+1,d);b=(C=l.get(w))!=null?C: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"?-Tr:Tr),e.setState({left:u,leftOffset:m}),(n==="left"&&u===0&&r===0||n==="right"&&u===o)&&this.clearScrollInterval())},Kw))}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=Rs(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)<yh&&Math.abs(this.initialGridPoint.y-o)<yh)return!1;if(a==null){const c=Rs(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=Rs(a.range[0],0,d,l),m=Rs(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 D,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=Rs(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 C=Rs(K.getColumnAtX(Ut(m?g:f,a,d),l,!0),i,l,o),b=o.getColumnHeaderParentGroup(p.modelIndex,p.depth);if(!C)return;if(b!==void 0){const _=b.getVisibleRange(r);if(C.visibleIndex<_[0]){const H=this.moveColumn(p,_[0],r);this.draggingOffset=e-((D=u.get(_[0]))!=null?D:0),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},this.clearScrollInterval(),n.setState({draggingColumn:this.draggingColumn,movedColumns:H});return}if(C.visibleIndex>_[1]){const H=this.moveColumn(p,_[1]-(p.range[1]-p.range[0]),r),{right:L=0}=(F=Rs(_[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(C.modelIndex)){let _=C.visibleIndex;if(m)for(_+=1;_<p.visibleIndex&&!o.isColumnMovable(K.getModelIndex(_,r));)_+=1;else for(_-=1;_>p.visibleIndex&&!o.isColumnMovable(K.getModelIndex(_,r));)_-=1;if(_!==p.visibleIndex){m||(_-=p.range[1]-p.range[0]);const L=this.moveColumn(p,_,r);n.setState({movedColumns:L,draggingColumn:this.draggingColumn})}const H=Rs(_,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(),C.visibleIndex===p.visibleIndex||m&&p.visibleIndex<C.visibleIndex||!m&&p.visibleIndex>C.visibleIndex)return;const w=C.left+C.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(C.modelIndex,E),E-=1;let I;m&&g<w&&(!y||C.visibleIndex===y.getVisibleRange(r)[0])&&(I=this.moveColumn(p,C.range[0],r)),!m&&f>w&&(!y||C.visibleIndex===y.getVisibleRange(r)[1])&&(I=this.moveColumn(p,C.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?K.moveRange(e.range,n,s):K.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 Ad extends yt{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=Ut((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 Ad.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 Yw extends yt{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:C}=l;let b=p;if(a<i){const I=i-1;b=B(f,I)+B(g,I)*.5+p}let w=C;if(i<c){const I=i+1;w=B(f,I)+B(g,I)*.5+p}let{movedRows:T}=n.state;r<b&&i>0&&s.isRowMovable(i-1)?(T=K.moveItem(i,i-1,T),i-=1):w<r&&i<m-1&&s.isRowMovable(i+1)&&(T=K.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 Pd extends ep{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=K.getHiddenRows,this.getNextShownItem=K.getNextShownRow,this.getSeparator=Pd.getRowSeparator}static getRowSeparator(e,n,s,i){if(!i.allowRowResize)return null;const{x:o,y:r}=e,l=K.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 yt{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 C=B(u,s),b=B(m,s),w=B(g,i),T=B(p,i);if(o>=a+C&&o<=a+C+b&&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 Xw extends yt{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 Hd extends yt{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=Ut((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 Hd.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 jw extends yt{onDoubleClick({column:e,row:n},s){const{model:i}=s.props;return Je(i)&&e!=null&&n!=null&&i.isEditableRange(re.makeCell(e,n))?(s.startEditing(e,n),!0):!1}}class gi{constructor(e=5e3){this.order=e}onDown(e,n){return!1}}class Qw extends gi{onDown(e,n){switch(e.key){case"a":if(K.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 K.isModifierKeyDown(e)?!1:this.handlePageUp(e,n);case"j":case"J":return K.isModifierKeyDown(e)?!1:this.handlePageDown(e,n);case"h":case"H":return K.isModifierKeyDown(e)?!1:(e.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(0,n.state.cursorRow,e.shiftKey),!0);case"l":case"L":{if(K.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(K.isModifierKeyDown(e)?n.state.cursorColumn:0,K.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(K.isModifierKeyDown(e)?n.state.cursorColumn:i-1,K.isModifierKeyDown(e)?o-1:n.state.cursorRow,e.shiftKey,!0,!0),!0}case"Escape":return n.clearSelectedRanges(),{preventDefault:!1,stopPropagation:!1};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=K.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,C=r&&o;let b=null,w=null;e<0?(b=0,w=m):e>0?(b=g-1,w=m):n<0?(b=u,w=0):n>0&&(b=u,w=f-1),b!=null&&w!=null&&i.moveCursorToPosition(b,w,o,!0,C)}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:C}=i.metrics;let{left:b}=i.state;b=Ut(b+e,0,C),i.moveCursorToPosition(b,l,o,!1),i.setViewState({left:b})}else if(f&&n!==0){const{lastTop:C}=i.metrics;let{top:b}=i.state;b=Ut(b+n,0,C),i.moveCursorToPosition(b,a,o,!1),i.setViewState({top:b})}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 C=c-u+r;C+=m?0:1,C=Math.min(C,f);const b=Math.min(g,C-(r-u));return n.moveCursorToPosition(l,C,s,!1),n.setViewState({top:b}),!0}}class Zw extends gi{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)&&pt(o)&&o.isRowExpandable(a))return n.toggleRowExpanded(r),!0}}}return!1}}class Jw extends gi{onDown(e,n){if(K.isModifierKeyDown(e))return!1;const{model:s}=n.props,{cursorColumn:i,cursorRow:o}=n.state;if(i==null||o==null||!Je(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 ev(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 tv(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 nv(t){var s,i;const e=t.querySelector("table");if(e!=null)return ev(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(`
|
|
24
24
|
`).map(a=>a.split(" ")):o.length>1||l?tv(t.childNodes):n}return null}class sv extends gi{onDown(e,n){switch(e.key){case"v":if(K.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=nv(s);o!=null&&n.pasteValue(o)};return s.addEventListener("input",i),s.focus(),{preventDefault:!1,stopPropagation:!0}}break}return!1}}const iv=t=>{switch(t){case"ArrowDown":return Mn.DOWN;case"ArrowUp":return Mn.UP;case"ArrowLeft":return Mn.LEFT;case"ArrowRight":return Mn.RIGHT;default:return}},Vd=({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,C]=S.exports.useState(i),[b,w]=S.exports.useState(s);S.exports.useEffect(function(){const{current:_}=c;_!=null&&(_.focus(),t?_.setSelectionRange(t[0],t[1]):_.setSelectionRange(_.value.length,_.value.length))},[t]);const T=S.exports.useCallback($=>{o($)},[o]),y=S.exports.useCallback($=>{const{value:_}=$.target;w(_),g(!0),T(_)},[T,w,g]),E=S.exports.useCallback(()=>{u.current=!0,p&&T(m),g(!1),r()},[m,p,r,T]),I=S.exports.useCallback(()=>{C(!1)},[C]),D=S.exports.useCallback(($,_=!1)=>{l(b,{direction:$,fillRange:_})},[l,b]),F=S.exports.useCallback(()=>{u.current||D(null)},[u,D]),x=S.exports.useCallback($=>{switch($.stopPropagation(),$.key){case"Escape":$.preventDefault(),E();break;case"Enter":if($.preventDefault(),K.isModifierKeyDown($))D(void 0,!0);else if($.altKey){const _=`${b}
|
|
25
25
|
`;w(_),g(!0),T(_)}else D($.shiftKey?Mn.UP:Mn.DOWN);break;case"Tab":$.preventDefault(),D($.shiftKey?Mn.LEFT:Mn.RIGHT);break;case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":f&&($.preventDefault(),D(iv($.key)));break}},[E,D,f,w,g,T,b]),U=S.exports.useCallback($=>{a($)},[a]);return h("textarea",{ref:c,className:W("grid-cell-input-field",e),value:b,onBlur:F,onChange:y,onKeyDown:x,onContextMenu:U,onClick:I,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false",disabled:n,style:d})};Vd.propTypes={selectionRange:R.exports.arrayOf(R.exports.number),className:R.exports.string,disabled:R.exports.bool,isQuickEdit:R.exports.bool,value:R.exports.string,onChange:R.exports.func,onCancel:R.exports.func,onDone:R.exports.func,onContextMenu:R.exports.func,style:R.exports.shape({})};Vd.defaultProps={selectionRange:null,className:"",disabled:!1,value:"",isQuickEdit:!0,onChange:()=>{},onCancel:()=>{},onDone:()=>{},onContextMenu:()=>{},style:{}};const ov=Y.createContext({}),js=class extends S.exports.PureComponent{constructor(t){super(t),this.getCachedKeyHandlers=me(l=>[...l,...this.keyHandlers].sort((a,d)=>a.order-d.order)),this.getCachedMouseHandlers=me(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 zi,this.metricCalculator=s||new Yo,this.canvas=null,this.canvasContext=null,this.animationFrame=null,this.prevMetrics=null,this.metrics=null,this.documentCursor=null,this.dragTimer=null,this.keyHandlers=[new Jw(400),new sv(450),new Qw(500),new Zw(900)],this.mouseHandlers=[new Pd(100),new xl(200),new Yw(300),new qw(400),new jw(450),new Hd(500),new Ad(600),new Xw(700),new Jr(800),new Gw(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 n;this.initContext(),(n=this.canvas)==null||n.addEventListener("wheel",this.handleWheel,{passive:!1}),window.addEventListener("resize",this.handleResize),this.updateCanvasScale(),this.updateCanvas();const{isStuckToBottom:t,isStuckToRight:e}=this.props;t&&this.scrollToBottom(),e&&this.scrollToRight()}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:C,draggingRow:b,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&&C==null&&l(w),f!==T&&a(T),e.draggingRow!=null&&b==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{rowCount:y,columnCount:E,height:I,width:D}=this.metrics,{rowCount:F,columnCount:x,height:U,width:$}=this.prevMetrics;if(F!==y||I!==U){const{isStuckToBottom:_}=this.state;_&&this.scrollToBottom()}if(x!==E||D!==$){const{isStuckToRight:_}=this.state;_&&this.scrollToRight()}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 js.getTheme(this.context,t)}getGridPointFromEvent(t){Sh(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 K.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;pt(n)&&n.isRowExpandable(e)&&n.setRowExpanded(e,!n.isRowExpanded(e)),this.clearSelectedRanges(),this.commitSelection(),this.moveCursorToPosition(0,t),this.commitSelection(),this.setState({isStuckToBottom:!1})}scrollToBottom(){if(!this.metrics)return;const{bottomVisible:t,rowCount:e,top:n,lastTop:s}=this.metrics;(t<e-1&&t>0||n>s)&&this.setState({top:s})}scrollToRight(){if(!this.metrics)return;const{rightVisible:t,columnCount:e,left:n,lastLeft:s}=this.metrics;(t<e-1&&t>0||n>s)&&this.setState({left:s})}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=js.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,C,b;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,(C=w.endColumn)!=null?C:0),I=c!==void 0&&c?null:Math.max(e!=null?e:0,(b=w.endRow)!=null?b: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 D=re.makeNormalized(T,y,E,I);if(w.equals(D))return null;const F=[...o];return F[F.length-1]=D,{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=Ut(l+t,0,c-1),p=Ut(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&&!K.isFloatingRow(e,this.metrics)&&(e<o?(a=n.getTopForTopVisible(l,e),c=0):e>s&&(a=n.getTopForBottomVisible(l,e),c=0)),t!=null&&!K.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(!Je(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 Je(s)&&s.isValidForCell(i,o,n)}async pasteValue(t){const{model:e}=this.props,{movedColumns:n,movedRows:s,selectedRanges:i}=this.state;try{if(wh(e),!e.isEditable||!i.every(u=>e.isEditableRange(u)))throw new da("Can't paste in to read-only area.");if(i.length<=0)throw new da("Select an area to paste to.");if(typeof t=="string"){const u=[],m=K.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 da("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;wh(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=K.getModelRanges(t,s,i);Je(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!==js.getCursorClassName(t)&&(this.documentCursor!=null&&document.documentElement.classList.remove(this.documentCursor),this.documentCursor=js.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)},js.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:C}=this.state,{model:b,stateOverride:w}=this.props,{renderer:T}=this,y=this.canvasContext,E=this.getTheme(),I=this.canvas.clientWidth,D=this.canvas.clientHeight,F={left:e,top:n,width:I,height:D,context:y,theme:E,model:b,metrics:t,mouseX:g,mouseY:f,selectedRanges:C,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,D,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:C,leftOffset:b}=n;const w=this.getTheme();let{deltaX:T,deltaY:y}=K.getScrollDelta(t,n.barWidth,n.barHeight,n.rowHeight,n.rowHeight);for(;m&&T!==0;){if(b+=T,T=0,r>1){if(b>0&&f>=o||b<0&&f<=0){b=0;break}}else{if(b<=0){b=0;break}const x=a-d;if(b>=x){b=x;break}}if(b>0){const x=(E=n.visibleColumnWidths.get(f))!=null?E:e.getVisibleColumnWidth(f,s);b>=x?(T=b-x,b=0,f+=1):w.scrollSnapToColumn&&r>1&&(b=0,f+=1)}else if(b<0){const x=(I=n.visibleColumnWidths.get(f-1))!=null?I:e.getVisibleColumnWidth(f-1,s);Math.abs(b)<=x&&w.scrollSnapToColumn&&r>1?(b=0,f-=1):(T=b+x,b=0,f-=1)}}for(;p&&y!==0;){if(C+=y,y=0,l>1){if(C>0&&g>=i||C<0&&g<=0){C=0;break}}else{if(C<=0){C=0;break}const x=c-u;if(C>=x){C=x;break}}if(C>0){const x=(D=n.visibleRowHeights.get(g))!=null?D:e.getVisibleRowHeight(g,s);C>=x?(y=C-x,C=0,g+=1):w.scrollSnapToRow&&l>1&&(C=0,g+=1)}else if(C<0){const x=(F=n.visibleRowHeights.get(g-1))!=null?F:e.getVisibleRowHeight(g-1,s);Math.abs(C)<=x&&w.scrollSnapToRow&&l>1?(C=0,g-=1):(y=C+x,C=0,g-=1)}}this.setViewState({top:g,left:f,leftOffset:b,topOffset:C}),t.stopPropagation(),t.preventDefault()}handleEditCellCancel(){this.setState({editingCell:null}),this.focus()}handleEditCellChange(t){this.setState(({editingCell:e})=>{try{return Sh(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=Mn.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||!Je(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),C=m.get(r),b=p.get(l),w=g!=null&&f!=null&&C!=null&&b!=null?{position:"absolute",left:a+g,top:d+f,width:C,height:b}:{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(Vd,{selectionRange:s,className:W({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(pe,{children:[h("canvas",{className:W("grid-canvas",js.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 eo=js;eo.contextType=ov;eo.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}};eo.pixelsPerLine=100/3;eo.dragTimeout=1e3;eo.getTheme=me((t,e)=>({...$w,...t,...e}));class tp 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 rv extends tp{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 Qs=class extends rv{constructor({rowCount:t=Qs.DEFAULT_ROW_COUNT,columnCount:e=Qs.DEFAULT_COLUMN_COUNT,children:n=new Map,childRowCount:s=Math.ceil(Math.max(Qs.MIN_CHILD_ROW_COUNT,t*Qs.DEFAULT_CHILD_ROW_COUNT_FACTOR)),maxDepth:i=Qs.MAX_DEPTH}={}){super({rowCount:t,columnCount:e}),this.getCachedModelRowOffset=an((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=an((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=an((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=an((o,r,l)=>this.getCachedDepthForRow(o,r)<l),this.getCachedIsRowExpanded=an((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=an((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 Qs({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 Xo=Qs;Xo.DEFAULT_ROW_COUNT=1e9;Xo.DEFAULT_COLUMN_COUNT=100;Xo.DEFAULT_CHILD_ROW_COUNT_FACTOR=.01;Xo.MIN_CHILD_ROW_COUNT=10;Xo.MAX_DEPTH=10;class Ce extends tp{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}}Ce.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 Fi=class extends S.exports.Component{constructor(t){super(t),this.getInput=me((e,n)=>e.find(s=>s.eventKey===n)),this.getInputIndex=me((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 ze.generate()}static createCustomColumnInput(){return{eventKey:ze.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(Ce.EVENT.COLUMNS_CHANGED,this.handleCustomColumnUpdated),t.addEventListener(Ce.EVENT.UPDATED,this.handleCustomColumnUpdated),t.addEventListener(Ce.EVENT.REQUEST_FAILED,this.handleRequestFailed)}stopListening(){const{model:t}=this.props;t.removeEventListener(Ce.EVENT.COLUMNS_CHANGED,this.handleCustomColumnUpdated),t.removeEventListener(Ce.EVENT.UPDATED,this.handleCustomColumnUpdated),t.removeEventListener(Ce.EVENT.REQUEST_FAILED,this.handleRequestFailed)}parseCustomColumns(t){if(t.length>0){const e=t.map(n=>{const s=n.split(/=(.+)/,2);return{eventKey:Fi.makeCustomColumnInputEventKey(),name:s[0],formula:s[1]}});this.setState({inputs:e})}else this.setState({inputs:[Fi.createCustomColumnInput()]})}handleAddColumnClick(){const{inputs:t}=this.state,e=[...t];e.push(Fi.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(Fi.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}),Fi.SUCCESS_SHOW_DURATION)})}handleRequestFailed(t){const e=t,{isCustomColumnApplying:n}=this.state;!n||this.setState({isCustomColumnApplying:!1,errorMessage:v(pe,{children:[v("p",{children:[h(j,{icon:cs})," 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(Xt.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(Ld,{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(z,{kind:n?"success":"primary",className:W("btn-apply",{"btn-spinner":e}),disabled:n||e,onClick:this.handleSaveClick,children:[e&&v("span",{children:[h(On,{}),h("span",{className:"btn-normal-content",children:"Applying"}),h("span",{className:"btn-hover-content",children:"Applying"})]}),!n&&!e&&s,n&&v(pe,{children:[h(j,{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("hr",{}),h(Uo,{onDragStart:Xt.startDragging,onDragEnd:this.handleDragEnd,children:h(Vo,{droppableId:"droppable-custom-columns",children:(n,s)=>v("div",{ref:n.innerRef,...n.droppableProps,className:W("droppable-container",{dragging:s.draggingFromThisWith}),children:[this.renderInputs(),n.placeholder]})})}),h("div",{className:"pt-1 px-3",children:h(z,{kind:"ghost",className:"btn-add-column",onClick:this.handleAddColumnClick,icon:Ls,children:"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(z,{kind:"secondary",className:"mr-2",onClick:t,children:"Cancel"}),this.renderSaveButton()]})]})]})}};let Ud=Fi;Ud.SUCCESS_SHOW_DURATION=750;Ud.defaultProps={customColumns:[],onSave:()=>{},onCancel:()=>{}};var xe=(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))(xe||{});const uo=X.module("RollupRows"),lv=150,Er="grouped-rollup-rows",yr="ungrouped-rollup-rows",yn=class extends S.exports.Component{constructor(t){super(t),this.search=je(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)},lv),this.getCachedUngroupedColumns=Te((o,r)=>o.filter(l=>yn.isGroupable(l)&&r.find(a=>a===l.name)==null)),this.getCachedSortedColumns=Te((o,r)=>r==null?[...o]:P.sortColumns(o,r===yn.SORT.ASCENDING)),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 on.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===yn.SORT.ASCENDING?null:yn.SORT.ASCENDING}))}handleSortDescending(){this.setState(({sort:t})=>({sort:t===yn.SORT.DESCENDING?null:yn.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===yr){this.setState(({groupedSelectedRanges:o,columns:r})=>{const l=[...r];return Xt.reorder(l,o,[],0),{columns:l,ungroupedSelectedRanges:[],groupedSelectedRanges:[]}});return}const s=n.droppableId===Er;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=Xt.reorder(d,c,a,i),m=s?Xt.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:yn.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(pe,{children:[on.renderTextItem({text:o,badgeText:r,className:l}),(n===void 0||!n)&&h(z,{kind:"ghost",className:"btn btn-link btn-link-icon btn-delete-grouping float-right",onClick:()=>this.handleDeleteClicked(e),children:h(j,{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*on.DEFAULT_ROW_HEIGHT;(e==null?void 0:e.droppableId)===yr&&(d+=on.DEFAULT_ROW_HEIGHT);const c=a.length*on.DEFAULT_ROW_HEIGHT+10,u=Math.min(3*on.DEFAULT_ROW_HEIGHT,c);return h("div",{role:"menu",className:W("rollup-rows",{"is-dragging":e!=null}),tabIndex:0,children:v(Uo,{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(Vo,{droppableId:"placeholder",children:(m,p)=>h("div",{className:W("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(on,{draggingItemClassName:"rollup-rows-dragging-grouped-item",draggablePrefix:Er,droppableId:Er,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(Cs,{className:"w-100",value:n,matchCount:n?i.length:void 0,placeholder:"Find column...",onChange:this.handleSearchChange}),v(z,{kind:"ghost",className:W("btn-link btn-link-icon",{active:l===yn.SORT.ASCENDING}),onClick:this.handleSortAscending,children:[h(j,{icon:hd}),h($e,{children:"Sort ascending"})]}),v(z,{kind:"ghost",className:W("btn-link btn-link-icon",{active:l===yn.SORT.DESCENDING}),onClick:this.handleSortDescending,children:[h(j,{icon:ud}),h($e,{children:"Sort descending"})]})]}),h(on,{className:"rollup-available-grouping-columns",draggablePrefix:yr,droppableId:yr,itemCount:a.length,items:a,renderItem:yn.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)!==Er,isMultiSelect:!0}),v("div",{className:"bottom-menu",children:[h("div",{className:"label",children:"Show:"}),h(Bt,{checked:o,onChange:this.handleShowConstituentsChange,children:"Constituents"}),h(Bt,{checked:r,onChange:this.handleShowNonAggregatedColumnsChange,children:"Non-Aggregated Columns"})]})]})]})})}};let Bd=yn;Bd.SORT=Object.freeze({ASCENDING:"ASC",DESCENDING:"DESC"});Bd.defaultProps={config:null,onChange:()=>{}};const mo=X.module("IrisGridUtils");function Ds(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})=>Ds(a,l)&&(typeof d=="number"&&Ds(d,l)||Array.isArray(d)&&Ds(d[0],l)&&Ds(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})=>Ds(u,c)&&(typeof m=="number"&&Ds(m,c)||Array.isArray(m)&&Ds(m[0],c)&&Ds(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:C,sorts:b,invertSearchColumns:w,pendingDataMap:T=new Map,frozenColumns:y}=n;A(l);const{userColumnWidths:E,userRowHeights:I}=l,{columns:D}=e;return{advancedFilters:se.dehydrateAdvancedFilters(D,i),aggregationSettings:s,customColumnFormatMap:[...o],isFilterBarShown:r,quickFilters:se.dehydrateQuickFilters(a),sorts:se.dehydrateSort(b),userColumnWidths:[...E].filter(([F])=>F!=null&&F>=0&&F<D.length).map(([F,x])=>[D[F].name,x]),userRowHeights:[...I],customColumns:[...d],conditionalFormats:[...c],reverseType:u,rollupConfig:m,showSearchBar:p,searchValue:g,selectDistinctColumns:[...f],selectedSearchColumns:C,invertSearchColumns:w,pendingDataMap:se.dehydratePendingDataMap(D,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:C,selectDistinctColumns:b,selectedSearchColumns:w,invertSearchColumns:T=!0,pendingDataMap:y=[],frozenColumns:E}=n,{columns:I,formatter:D}=e;return{advancedFilters:se.hydrateAdvancedFilters(I,s,D.timeZone),aggregationSettings:i,customColumnFormatMap:new Map(o),isFilterBarShown:r,quickFilters:se.hydrateQuickFilters(I,l,D.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:C,selectDistinctColumns:b,selectedSearchColumns:w,invertSearchColumns:T,pendingDataMap:se.hydratePendingDataMap(I,y),frozenColumns:E}}static dehydrateIrisGridPanelState(e,n){const{isSelectingPartition:s,partition:i,partitionColumn:o,advancedSettings:r}=n;return{isSelectingPartition:s,partition:i,partitionColumn:o!=null?o.name:null,advancedSettings:[...r]}}static hydrateIrisGridPanelState(e,n){const{isSelectingPartition:s,partition:i,partitionColumn:o,advancedSettings:r}=n,{columns:l}=e;return{isSelectingPartition:s,partition:i,partitionColumn:o!=null?se.getColumnByName(l,o):void 0,advancedSettings:new Map([...Xm.DEFAULTS,...r])}}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){mo.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){mo.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(ps.FULL_DATE_FORMAT,e):null}static hydrateDateTime(e){return e!=null?M.i18n.DateTimeFormat.parse(ps.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){mo.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=K.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=K.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=K.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=K.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:C})=>ks.isRollupOperation(g)?[]:ks.getOperationColumnNames(e,g,f,C)),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(C=>g.delete(C))}),g.size>0){const f=(p=c[ke.FIRST])!=null?p:[];c[ke.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]:(mo.error("Unable to retrieve column",n,">=",e.length),null)}static getColumnByName(e,n){const s=e.find(({name:i})=>i===n);return s==null&&mo.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 av=X.module("TableCsvExporter"),Ye=class extends S.exports.Component{static getDateString(){return M.i18n.DateTimeFormat.format(Ye.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}-${Ye.getDateString()}.csv`,downloadOption:Ye.DOWNLOAD_OPTIONS.ALL_ROWS,customizedDownloadOption:Ye.CUSTOMIZED_ROWS_OPTIONS.FIRST,customizedDownloadRows:Ye.DEFAULT_DOWNLOAD_ROWS,errorMessage:null,id:ze.generate()}}getSnapshotRanges(){const{model:t,selectedRanges:e}=this.props,{downloadOption:n,customizedDownloadOption:s,customizedDownloadRows:i}=this.state,{rowCount:o,columnCount:r}=t;let l=[];switch(n){case Ye.DOWNLOAD_OPTIONS.ALL_ROWS:l.push(new re(0,0,r-1,o-1));break;case Ye.DOWNLOAD_OPTIONS.SELECTED_ROWS:l=e.map(a=>({...a,startColumn:0,endColumn:r-1})).sort((a,d)=>a.startRow!=null&&d.startRow!=null?a.startRow-d.startRow:0);break;case Ye.DOWNLOAD_OPTIONS.CUSTOMIZED_ROWS:switch(s){case Ye.CUSTOMIZED_ROWS_OPTIONS.FIRST:l.push(new re(0,0,r-1,Math.min(i-1,o-1)));break;case Ye.CUSTOMIZED_ROWS_OPTIONS.LAST:l.push(new re(0,Math.max(0,o-i),r-1,o-1));break}break}return l}getModelRanges(t){const{userColumnWidths:e,movedColumns:n}=this.props,s=se.getHiddenColumns(e);let i=K.getModelRanges(t,n);if(s.length>0){const o=s.map(re.makeColumn);i=re.subtractRangesFromRanges(i,o)}return i}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(),l=this.getModelRanges(r);if(this.validateOptionInput()){n();try{const a=await t.export(),d=a.setViewport(0,0);await d.getViewportData(),s(o,a,d,r,l)}catch(a){av.error("CSV download failed",a),this.setState({errorMessage:v("p",{children:[h(j,{icon:cs})," ",`${a}`]})}),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===Ye.DOWNLOAD_OPTIONS.SELECTED_ROWS&&t.length===0?(this.setState({errorMessage:v("p",{children:[h(j,{icon:cs})," No rows selected. Please select some rows in the table."]})}),!1):e===Ye.DOWNLOAD_OPTIONS.CUSTOMIZED_ROWS&&n<=0?(this.setState({errorMessage:v("p",{children:[h(j,{icon:cs})," 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(Sl,{onChange:this.handleDownloadOptionChanged,value:l,disabled:e,children:[v(Nn,{value:Ye.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(Nn,{value:Ye.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(Nn,{value:Ye.DOWNLOAD_OPTIONS.CUSTOMIZED_ROWS,"data-testid":"radio-csv-exporter-customized-rows",children:v("div",{className:"radio-input-row",role:"presentation",onClick:()=>{this.setState({downloadOption:Ye.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===Ye.DOWNLOAD_STATUS.DOWNLOADING||o===Ye.DOWNLOAD_STATUS.INITIATING)&&v(pe,{children:[o===Ye.DOWNLOAD_STATUS.INITIATING&&h("div",{className:"text-muted",children:"Starting Download..."}),o===Ye.DOWNLOAD_STATUS.DOWNLOADING&&v("div",{className:"text-muted d-flex justify-content-between",children:[h("span",{children:s||s===0?`Estimated time: ${Rn.formatElapsedTime(s)}`:null}),h("span",{children:`${n}%`})]})]}),o===Ye.DOWNLOAD_STATUS.FINISHED&&h("div",{className:"text-muted text-right",children:"Download Completed"}),o===Ye.DOWNLOAD_STATUS.CANCELED&&h("div",{className:"text-muted",children:"Download Canceled"}),(o===Ye.DOWNLOAD_STATUS.DOWNLOADING||o===Ye.DOWNLOAD_STATUS.INITIATING)&&h("div",{className:"progress",children:h("div",{className:"progress-bar progress-bar-striped progress-bar-animated",style:{width:`${n}%`}})}),o===Ye.DOWNLOAD_STATUS.FINISHED&&h("div",{className:"progress",children:h("div",{className:"progress-bar bg-success",style:{width:`${n}%`}})})]}),v(z,{kind:"primary","data-testid":"btn-csv-exporter-download",className:W("btn-downloading",{"btn-spinner btn-cancelable":e}),onClick:this.handleDownloadClick,children:[e&&v("span",{children:[h(On,{}),h("span",{className:"btn-normal-content",children:"Downloading"}),h("span",{className:"btn-hover-content",children:"Cancel"})]}),!e&&"Download"]})]})]})}};let ln=Ye;ln.FILENAME_DATE_FORMAT="yyyy-MM-dd-HHmmss";ln.DOWNLOAD_STATUS={INITIATING:"INITIATING",DOWNLOADING:"DOWNLOADING",FINISHED:"FINISHED",CANCELED:"CANCELED"};ln.DOWNLOAD_OPTIONS={ALL_ROWS:"ALL_ROWS",SELECTED_ROWS:"SELECTED_ROWS",CUSTOMIZED_ROWS:"CUSTOMIZED_ROWS"};ln.CUSTOMIZED_ROWS_OPTIONS={FIRST:"FIRST",LAST:"LAST"};ln.DEFAULT_DOWNLOAD_ROWS=100;ln.defaultProps={onDownloadStart:()=>{},isDownloading:!1,tableDownloadStatus:"",tableDownloadProgress:0,tableDownloadEstimatedTime:null,selectedRanges:[]};const es=X.module("TableSaver");function dv(t){return t.added!==void 0}function cv(t){if(!dv(t))throw new Error("event is not UpdateEventData")}const _s=class extends S.exports.PureComponent{constructor(t){var e,n;super(t),this.WritableStream=(e=window.WritableStream)!=null?e:Tc,this.getCachedCustomColumnFormatFlag=an(hs.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:Tc,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,i){const{isDownloading:o}=this.props;if(o)return;this.downloadStartTime=Date.now(),es.info(`start downloading ${t}`),this.table=e,this.columns=se.columnsFromRanges(i,e.columns),this.tableSubscription=n,this.gridRanges=s;const r=encodeURIComponent(t.replace(/\//g,":")).replace(/['()]/g,escape).replace(/\*/g,"%2A"),l=new MessageChannel;if(this.port=l.port1,this.fileName=t,this.fileWriter=this.createWriterStream(this.port).getWriter(),this.useBlobFallback){this.writeCsvTable();return}this.sw&&this.sw.postMessage({encodedFileName:r},[l.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?`
|
|
26
26
|
`:",";(e=this.fileWriter)==null||e.write({header:t}).then(()=>null)}startWriteTableBody(){this.columns&&this.gridRanges!=null&&(this.chunkRows=Math.floor(_s.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(_s.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(`
|
|
@@ -44,4 +44,4 @@ This note can be edited using **markdown** for styling.`;const h1=t=>{Ps(t);cons
|
|
|
44
44
|
Web UI Version: ${t}
|
|
45
45
|
Java Version: ${o}
|
|
46
46
|
Barrage Version: ${i}`,children:"Copy Versions"})]})]})]}),h("div",{className:"app-settings-footer-item",children:h(N1,{})})]}),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:zp,alt:"Deephaven Data Labs",width:"230px"})})})})]})]})]})}};let Zo=ni;Zo.defaultProps={onDone:()=>{}};Zo.FORMATTING_SECTION_KEY="SettingsMenu.formatting";Zo.APPLICATION_SECTION_KEY="ApplicationMenu.settings";Zo.SHORTCUT_SECTION_KEY="SettingsMenu.shortcuts";const Jh=10,Li=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(b=>{d.current!=null&&c.current!=null&&u.current&&(Math.abs(d.current-b.clientX)>=Jh||Math.abs(c.current-b.clientY)>=Jh)&&(p(!0),window.removeEventListener("mousemove",g),a(),e(b),u.current=null)},[e,a]);function f(b){d.current=b.clientX,c.current=b.clientY,u.current=b.target,window.addEventListener("mousemove",g)}function C(b){u.current===b.target&&(p(!0),a(),e(),window.removeEventListener("mousemove",g)),u.current=null}return S.exports.useEffect(function(){return function(){return window.removeEventListener("mousemove",g)}},[g]),v("button",{type:"button",className:W("btn-context-menu",{disabled:s},{active:r&&!s},{"keyboard-active":l&&!s}),onMouseDown:f,onMouseUp:C,disabled:m,children:[h("span",{className:W("icon"),children:i}),h("span",{className:"title",children:n}),h("span",{className:"shortcut",children:o})]})},hc=t=>{const{handleControlSelect:e,handleToolSelect:n,onClearFilter:s}=t,i=S.exports.useMemo(()=>[{title:"Input Filter",icon:eC,menuElement:h(Li,{}),action:o=>{e(Cn.INPUT_FILTER,o)},order:10},{title:"Dropdown Filter",icon:vu,menuElement:h(Li,{}),action:o=>{e(Cn.DROPDOWN_FILTER,o)},order:15},{title:"Markdown Widget",icon:xf,menuElement:h(Li,{}),action:o=>{e(Cn.MARKDOWN,o)},order:20},{title:"Filter Sets",icon:Ra,menuElement:h(Li,{}),action:o=>{e(Cn.FILTER_SET_MANAGER,o)},order:25},{disabled:!0,menuElement:h("div",{className:"context-menu-group-header",children:"Tools"}),order:30},{title:"Linker",icon:ld,action:()=>{n(hn.LINKER)},order:40,shortcut:ms.LINKER},{disabled:!0,menuElement:h("div",{className:"context-menu-group-header",children:"Actions"}),order:50},{title:"Clear All Filters",icon:jf,action:()=>{s()},order:60,shortcut:dn.TABLE.CLEAR_ALL_FILTERS}],[e,n,s]);return h(Gn,{popperClassName:"controls-menu-popper",actions:i})};hc.propTypes={handleControlSelect:R.exports.func,handleToolSelect:R.exports.func,onClearFilter:R.exports.func};hc.defaultProps={handleControlSelect:()=>{},handleToolSelect:()=>{},onClearFilter:()=>{}};Li.propTypes={forwardedProps:R.exports.shape({iconElement:R.exports.node,displayShortcut:R.exports.string,isMouseSelected:R.exports.bool.isRequired,isKeyboardSelected:R.exports.bool.isRequired,closeMenu:R.exports.func.isRequired,menuItem:R.exports.shape({action:R.exports.func,title:R.exports.string,disabled:R.exports.bool}).isRequired})};Li.defaultProps={forwardedProps:null};const B1=As(Wp,null),$1={layoutStorage:B1},W1=t=>t.layoutStorage,z1=t=>t.serverConfigValues;Object.entries($1).map(([t,e])=>Ji.register(t,e));const eu=10,G1=t=>{const{onExportLayout:e,onImportLayout:n,onResetLayout:s,onSelect:i,widgets:o=[]}=t,[r,l]=S.exports.useState(!1),[a,d]=S.exports.useState(""),c=S.exports.useRef(null),u=S.exports.useRef(),m=S.exports.useCallback((y,E)=>{y!=null&&i(y,E)},[i]),p=S.exports.useCallback(y=>{d(y.target.value)},[]),g=S.exports.useCallback(y=>{u.current!=null&&(Math.abs(u.current.x-y.clientX)>=eu||Math.abs(u.current.y-y.clientY)>=eu)&&(l(!0),window.removeEventListener("mousemove",g),m(u.current.widget,y),u.current=void 0)},[u,m]),f=S.exports.useCallback((y,E)=>{u.current={x:y.clientX,y:y.clientY,widget:E},window.addEventListener("mousemove",g)},[g]),C=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]),b=S.exports.useMemo(()=>o.filter(y=>{var E;return a?(E=y.name)==null?void 0:E.toLowerCase().includes(a.toLowerCase()):!0}),[a,o]).sort((y,E)=>{var I,D,F;return(F=(D=y.name)==null?void 0:D.localeCompare((I=E.name)!=null?I:""))!=null?F:0}),w=S.exports.useMemo(()=>b.map(y=>{var E,I;return h("li",{children:v(z,{kind:"ghost","data-testid":`panel-list-item-${(E=y.name)!=null?E:""}-button`,onMouseDown:D=>{f(D,y)},onMouseUp:D=>{C(D,y)},onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&m(y)},disabled:r,onClick:()=>{},children:[h(Gu,{type:y.type})," ",(I=y.name)!=null?I:""]})},y.name)}),[b,r,f,C,m]),T=S.exports.useMemo(()=>w.length===0?h("span",{children:"No bound variables found."}):null,[w]);return v("div",{className:"widget-list-container d-flex flex-column",children:[h("div",{className:"widget-list-header",children:h(Cs,{value:a,placeholder:"Find Table, Plot or Widget",onChange:p,ref:c})}),v("ul",{className:"widget-list flex-grow-1",children:[T&&h("li",{className:"widget-list-message",children:T}),!T&&w]}),h("div",{children:h("hr",{})}),v("div",{className:"widget-list-footer",children:[v(z,{kind:"ghost",onClick:e,children:[v("div",{className:"fa-md fa-layers",children:[h(j,{mask:Da,icon:Dc,transform:"right-5 down-5"}),h(j,{icon:Dc,transform:"right-8 down-6"})]}),"Export Layout"]}),v(z,{kind:"ghost",onClick:n,children:[v("div",{className:"fa-md fa-layers",children:[h(j,{mask:Da,icon:Ia,transform:"right-5 down-5"}),h(j,{icon:Ia,transform:"right-8 down-6"})]}),"Import Layout"]}),h(z,{kind:"ghost",icon:_i,onClick:s,tooltip:"Reset Layout"})]})]})},K1=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 Wi.makeModel(s,c)}const l={title:o,name:i,type:M.VariableType.TABLE},a=await t.getObject(l);return se.applyTableSettings(a,r,Rl(Nl.getState())),Wi.makeModelFromSettings(s,a)},q1=async(t,e,n=M.VariableType.TABLE)=>{const{table:s}=e,i={title:s,name:s,type:n},o=await t.getObject(i);return qd.makeModel(o)};const Y1=({onAutoFillClick:t=()=>{}})=>v("div",{className:"empty-dashboard-container",children:[v("div",{className:"hint-container",children:[h(j,{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(z,{kind:"tertiary",onClick:t,children:"Auto fill objects"})]})]});function X1(t){return t.version===2}function j1(t){return Array.isArray(t)}const xr=X.module("UserLayoutUtils"),Q1={layoutConfig:[{type:"column",content:[{type:"row",height:40,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 Kp(t){if(X1(t))return t;if(j1(t))return{layoutConfig:t,links:[],filterSets:[],version:2};throw new Error(`Unexpected layout import format: ${t}`)}async function J1(t,e=!0){try{const n=await t.getLayouts();if(n.length>0)try{const s=await t.getLayout(n[0]);return Kp(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?Q1:Z1}function e2(t){const{filterSets:e,layoutConfig:n,links:s}=t;return{filterSets:e,layoutConfig:n,links:s,version:2}}const Br={exportLayout:e2,getDefaultLayout:J1,normalizeLayout:Kp},_r=X.module("DownloadServiceWorkerUtils"),qp=class{static registerOnLoaded(){new URL("/ide/",window.location.href).origin===window.location.origin&&("serviceWorker"in navigator?window.addEventListener("load",()=>{const e=new URL("/ide/download/serviceWorker.js",window.location.href);navigator.serviceWorker.register(e).then(n=>{n.update(),_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(qp.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=qp;ll.DOWNLOAD_PATH="/download/";const Yp={react:Y},t2=gg(Yp),n2=fg({requires:t2}),s2=Cg.createRequires(Yp),i2=bg({requires:s2}),o2=X.module("PluginUtils");class Ja{static loadComponentPlugin(e){if("".split(",").includes(e)){const o=Y.lazy(()=>Eg(()=>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(n2,{url:s,render:({err:l,Component:a})=>{if(l!=null&&l!==""){const d=`Error loading plugin ${e} from ${s} due to ${l}`;return o2.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 i2(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 Lt=X.module("AppMainContainer");class ko extends S.exports.Component{constructor(e){super(e),this.getDashboardPlugins=me(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(hn.LINKER)},shortcut:ms.LINKER,isGlobal:!0},{action:()=>{this.sendClearFilter()},shortcut:dn.TABLE.CLEAR_ALL_FILTERS,isGlobal:!0},{action:()=>{Lt.debug("Consume unhandled save shortcut")},shortcut:ms.SAVE,isGlobal:!0}],isPanelsMenuShown:!1,isSettingsMenuShown:!1,widgets:[]}}static handleWindowBeforeUnload(e){e.preventDefault(),e.returnValue=""}static hydrateConsole(e,n){return Va.hydrate({...e,unzip:s=>lu.loadAsync(s).then(i=>Object.values(i.files))},n)}componentDidMount(){this.initWidgets(),window.addEventListener("beforeunload",ko.handleWindowBeforeUnload)}componentDidUpdate(e){const{dashboardData:n}=this.props;e.dashboardData!==n&&this.handleDataChange(n)}componentWillUnmount(){this.deinitWidgets(),window.removeEventListener("beforeunload",ko.handleWindowBeforeUnload)}initWidgets(){const{connection:e}=this.props;if(e.subscribeToFieldUpdates==null){Lt.warn("subscribeToFieldUpdates not supported, not initializing widgets");return}this.widgetListenerRemover=e.subscribeToFieldUpdates(n=>{Lt.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){Lt.error("No session available to open notebook URL",n);return}const o={id:`/${n}`,itemName:`/${n}`},r=i.type,l={value:null,language:r};this.emitLayoutEvent(He.SELECT_NOTEBOOK,s,r,l,o,!0)}}sendClearFilter(){this.emitLayoutEvent(Pe.CLEAR_ALL_FILTERS)}emitLayoutEvent(e,...n){var s;(s=this.goldenLayout)==null||s.eventHub.emit(e,...n)}handleError(e){Ee.isCanceled(e)||Lt.error(e)}handleSettingsMenuHide(){this.setState({isSettingsMenuShown:!1})}handleSettingsMenuShow(){this.setState({isSettingsMenuShown:!0})}handleControlSelect(e,n=null){switch(Lt.debug("handleControlSelect",e),e){case Cn.DROPDOWN_FILTER:this.emitLayoutEvent(Pe.OPEN_DROPDOWN,{title:"DropdownFilter",type:e,createNewStack:!0,dragEvent:n});break;case Cn.INPUT_FILTER:this.emitLayoutEvent(Pe.OPEN_INPUT,{title:"InputFilter",type:e,createNewStack:!0,dragEvent:n});break;case Cn.MARKDOWN:this.emitLayoutEvent(Ep.OPEN,{title:"Markdown",type:e,dragEvent:n});break;case Cn.FILTER_SET_MANAGER:this.emitLayoutEvent(Pe.OPEN_FILTER_SET_MANAGER,{title:"FilterSets",type:e,dragEvent:n});break;default:throw new Error(`Unrecognized control type ${e}`)}}handleToolSelect(e){Lt.debug("handleToolSelect",e);const{activeTool:n,setActiveTool:s}=this.props;s(n===e?hn.DEFAULT:e)}handleClearFilter(){this.sendClearFilter()}handleDataChange(e){const{updateWorkspaceData:n}=this.props,{closed:s,filterSets:i,links:o}=e;n({closed:s,filterSets:i,links:o})}handleGoldenLayoutChange(e){this.goldenLayout=e}handleLayoutConfigChange(e){const{updateWorkspaceData:n}=this.props;n({layoutConfig:e})}handleWidgetMenuClick(){this.setState(({isPanelsMenuShown:e})=>({isPanelsMenuShown:!e}))}handleWidgetSelect(e,n){this.setState({isPanelsMenuShown:!1}),Lt.debug("handleWidgetSelect",e,n),this.openWidget(e,n)}handleWidgetsMenuClose(){this.setState({isPanelsMenuShown:!1})}handleAutoFillClick(){const{widgets:e}=this.state;Lt.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(){Lt.info("handleExportLayoutClick"),this.setState({isPanelsMenuShown:!1});try{const{workspace:e}=this.props,{data:n}=e,s=Br.exportLayout(n);Lt.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){Lt.error("Unable to export layout",e)}}handleImportLayoutClick(){Lt.info("handleImportLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.importElement.current!=null&&(this.importElement.current.value="",this.importElement.current.click())}handleResetLayoutClick(){Lt.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(Dn,{filterSets:r,links:a})}catch(n){Lt.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(Dn,{filterSets:s,links:o})}handlePaste(e){let n=e.currentTarget.parentElement;for(;n!=null;){if(n.classList.contains("monaco-editor"))return;n=n.parentElement}const{clipboardData:s}=e,i=s.getData("Text"),o=/“|”/g;o.test(i)&&(e.preventDefault(),e.stopPropagation(),document.execCommand("insertText",!1,i.replace(o,'"')))}handleLoadTablePlugin(e){const{plugins:n}=this.props,s=n.get(e);return s!=null&&s.TablePlugin!=null?s.TablePlugin:Ja.loadComponentPlugin(e)}hydrateDefault(e,n){const{connection:s}=this.props,{metadata:i}=e;if((i==null?void 0:i.type)!=null&&((i==null?void 0:i.id)!=null||(i==null?void 0:i.name)!=null)){const o=i.id!=null?{type:i.type,id:i.id}:{type:i.type,name:i.name,title:i.name};return{fetch:()=>s.getObject(o),localDashboardId:n,...e}}return Va.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:()=>q1(i,e.metadata,s)}}hydrateChart(e,n){const{connection:s}=this.props;return{...e,localDashboardId:n,makeModel:()=>{const{metadata:i,panelState:o}=e;return K1(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,serverConfigValues:o}=this.props,{data:r}=i,{layoutConfig:l}=r,{permissions:a}=s,{canUsePanels:d}=a,{contextActions:c,isPanelsMenuShown:u,isSettingsMenuShown:m,widgets:p}=this.state,g=this.getDashboardPlugins(n);return v("div",{className:W("app-main-tabs","w-100","h-100","d-flex","flex-column",e?`active-tool-${e.toLowerCase()}`:""),onPaste:this.handlePaste,tabIndex:-1,children:[h("nav",{className:"nav-container",children:v("div",{className:"app-main-top-nav-menus",children:[h("img",{src:zp,alt:"Deephaven Data Labs",width:"115px",className:"ml-1"}),v("div",{children:[v(z,{kind:"ghost",className:"btn-panels-menu",icon:rC,onClick:()=>{},children:["Controls",h(hc,{handleControlSelect:this.handleControlSelect,handleToolSelect:this.handleToolSelect,onClearFilter:this.handleClearFilter})]}),d&&v(z,{kind:"ghost",className:"btn-panels-menu btn-show-panels","data-testid":"app-main-panels-button",onClick:this.handleWidgetMenuClick,icon:nC,children:["Panels",h(xn,{isShown:u,className:"panels-menu-popper",onExited:this.handleWidgetsMenuClose,closeOnBlur:!0,interactive:!0,children:h(G1,{widgets:p,onExportLayout:this.handleExportLayoutClick,onImportLayout:this.handleImportLayoutClick,onResetLayout:this.handleResetLayoutClick,onSelect:this.handleWidgetSelect})})]}),h(z,{kind:"ghost",className:W("btn-settings-menu",{"text-warning":s.operateAs!==s.name}),onClick:this.handleSettingsMenuShow,icon:h(j,{icon:zo,transform:"grow-3 right-1 down-1"}),tooltip:"User Settings"})]})]})}),v(Iw,{emptyDashboard:h(Y1,{onAutoFillClick:this.handleAutoFillClick}),id:Dn,layoutConfig:l,onGoldenLayoutChange:this.handleGoldenLayoutChange,onLayoutConfigChange:this.handleLayoutConfigChange,onLayoutInitialized:this.openNotebookFromURL,hydrate:this.hydrateDefault,children:[h(o1,{hydrate:this.hydrateGrid,getDownloadWorker:ll.getServiceWorker,loadPlugin:this.handleLoadTablePlugin}),h(JE,{hydrate:this.hydrateChart}),h(e1,{}),h(n1,{hydrateConsole:ko.hydrateConsole,notebooksUrl:new URL("/notebooks/",`${window.location}`).href}),h(s1,{}),h(u1,{hydrate:this.hydratePandas}),h(h1,{}),h(c1,{}),g]}),h(ut,{in:m,timeout:Et.transitionMidMs,classNames:"slide-left",mountOnEnter:!0,unmountOnExit:!0,children:h(Zo,{serverConfigValues:o,onDone:this.handleSettingsMenuHide})}),h(oe,{actions:c}),h("input",{ref:this.importElement,type:"file",accept:".json",style:{display:"none"},onChange:this.handleImportLayoutFiles})]})}}const r2=t=>{var e,n;return{activeTool:Dl(t),dashboardData:jt(t,Dn),layoutStorage:W1(t),plugins:MS(t),connection:uE(t,Dn),session:(e=pi(t,Dn))==null?void 0:e.session,sessionConfig:(n=pi(t,Dn))==null?void 0:n.config,user:um(t),workspace:Il(t),serverConfigValues:z1(t)}},l2=Mt(r2,{setActiveTool:Ml,updateDashboardData:Yn,updateWorkspaceData:ym})(Sg(ko)),a2=()=>v("div",{className:"app",children:[h(l2,{}),h(Du,{})]}),d2=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:dt.DEFAULT_DATETIME_FORMAT_STRING,formatter:[],timeZone:dt.DEFAULT_TIME_ZONE_ID,showTimeZone:!1,showTSeparator:!0,disableMoveConfirmation:!1,defaultDecimalFormatOptions:{defaultFormatString:Le.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:it.DEFAULT_FORMAT_STRING},truncateNumbersWithPound:!1},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 d2.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 Xp=No;Xp.STORAGE_KEY="deephaven.WorkspaceStorage";class c2 extends Error{constructor(){super(...arguments),this.isNoConsolesError=!0}}function h2(t){return t.isNoConsolesError}const Ai=X.module("SessionUtils");function u2(){return new URL("/jsapi",`${window.location}`)}function jp(){const t=u2();return`${t.protocol}//${t.host}`}function m2(){const t=jp();return Ai.info(`Starting connection to '${t}'...`),new M.IdeConnection(t)}async function p2(t){Ai.info("Getting console types...");const e=await t.getConsoleTypes();if(Ai.info("Available types:",e),e.length===0)throw new c2("No console types available");const n=e[0];Ai.info("Starting session with type",n);const s=await t.startSession(n),i={type:n,id:ze.generate()};return Ai.info("Console session established",i),{session:s,config:i,connection:t}}function g2(){const t=jp();return Ai.info("createCoreClient",t),new M.CoreClient(t)}class f2{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"),ed=class{constructor(t,e="",n=e){this.currentSize=0,this.listeners=[],this.childTables=new Map,this.storageService=t,this.baseRoot=e,this.root=n,n===e&&(this.doRefresh=je(this.doRefresh.bind(this),ed.REFRESH_DEBOUNCE))}removeBaseRoot(t){return ce.removeRoot(this.baseRoot,t)}getViewportData(){var t;return this.viewportUpdatePromise||this.refreshInternal(),(t=this.viewportUpdatePromise)!=null?t:Promise.resolve({items:[],offset:0})}getSnapshot(t){throw new Error("Method not implemented.")}get size(){return this.currentSize}setExpanded(t,e){const n=t.split("/");let s=n.shift();if((s===void 0||s==="")&&(s=n.shift()),s===void 0||s==="")throw new Error(`Invalid path: ${t}`);const i=n.join("/");if(e){if(!this.childTables.has(s)){const o=new ed(this.storageService,this.baseRoot,`${this.root}/${s}`);this.childTables.set(s,o)}if(i){const o=this.childTables.get(s);o==null||o.setExpanded(i,e)}}else if(this.childTables.has(s))if(i){const o=this.childTables.get(s);o==null||o.setExpanded(i,e)}else this.childTables.delete(s);this.currentViewport&&this.refreshInternal()}collapseAll(){this.childTables.clear(),this.currentViewport&&this.refreshInternal()}setSearch(t){throw new Error("Method not implemented.")}setViewport(t){this.currentViewport=t,this.refreshInternal()}setFilters(){throw new Error("Method not implemented.")}setSorts(){throw new Error("Method not implemented.")}setReversed(){throw new Error("Method not implemented.")}close(){this.listeners=[]}onUpdate(t){return this.listeners=[...this.listeners,t],()=>{this.listeners=this.listeners.filter(e=>e!==t)}}doRefresh(t){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 ai;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 Qp=ed;Qp.REFRESH_DEBOUNCE=50;const C2=X.module("GrpcFileStorage"),Zp=class{constructor(t,e=""){this.tables=[],this.refreshTables=us(()=>{this.tables.forEach(n=>n.refresh())},Zp.REFRESH_THROTTLE),this.storageService=t,this.root=e}removeRoot(t){return ce.removeRoot(this.root,t)}addRoot(t){return ce.addRoot(this.root,t)}async createDirectory(t){return await this.storageService.createDirectory(this.addRoot(t)),this.refreshTables(),{type:"directory",id:t,filename:t,basename:ce.getBaseName(t)}}async getTable(){const t=new Qp(this.storageService,this.root);return this.tables.push(t),t}async saveFile(t){const e=dh.storage.FileContents.text(t.content);return await this.storageService.saveFile(this.addRoot(t.filename),e,!0),this.refreshTables(),t}async loadFile(t){const n=await(await this.storageService.loadFile(this.addRoot(t))).text();return{filename:t,basename:ce.getBaseName(t),content:n}}async deleteFile(t){await this.storageService.deleteItem(this.addRoot(t)),this.refreshTables()}async moveFile(t,e){await this.storageService.moveItem(this.addRoot(t),this.addRoot(e)),this.refreshTables()}async info(t){const e=await this.storageService.listItems(this.addRoot(ce.getPath(t)),ce.getBaseName(t));if(e.length===0)throw new sc;if(e.length>1)throw C2.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=Zp;Jp.REFRESH_THROTTLE=150;const li=X.module("AppInit");async function b2(){li.debug("Loading plugins...");try{const t=await Ja.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(Ja.loadModulePlugin(l))}const n=await Promise.all(e),s=new Map;for(let i=0;i<n.length;i+=1){const{name:o}=t.plugins[i];s.set(o,n[i])}return li.info("Plugins loaded:",s),s}catch(t){return li.error("Unable to load plugins:",t),new Map}}async function S2(t){let e;try{e=await p2(t)}catch(n){if(!h2(n))throw n}return e}const uc=t=>{const{workspace:e,setActiveTool:n,setCommandHistoryStorage:s,setDashboardData:i,setFileStorage:o,setLayoutStorage:r,setDashboardConnection:l,setDashboardSessionWrapper:a,setPlugins:d,setUser:c,setWorkspace:u,setWorkspaceStorage:m,setServerConfigValues:p}=t,[g,f]=S.exports.useState(),[C,b]=S.exports.useState(!0),w=S.exports.useCallback(async()=>{var D,F;try{li.info("Initializing Web UI","0.22.2",navigator.userAgent);const x=await b2(),U=m2(),$=await S2(U);U.addEventListener(M.IdeConnection.HACK_CONNECTION_FAILURE,Re=>{var Oe;const{detail:qe}=Re;li.error("Connection failure",`${JSON.stringify(qe)}`),f(`Unable to connect: ${(Oe=qe.details)!=null?Oe:"Unknown Error"}`)});const _="user",H=g2();await H.login({type:M.CoreClient.LOGIN_TYPE_ANONYMOUS});const L=H.getStorageService(),N=new f2(L,"/layouts"),O=new Jp(L,"/notebooks"),k=new Xp(N),V=new y1,G=await k.load({isConsoleAvailable:$!==void 0}),{data:Q}=G,{settings:J}=Q;J.defaultDecimalFormatOptions===void 0&&(J.defaultDecimalFormatOptions={defaultFormatString:Le.DEFAULT_FORMAT_STRING}),J.defaultIntegerFormatOptions===void 0&&(J.defaultIntegerFormatOptions={defaultFormatString:it.DEFAULT_FORMAT_STRING}),J.truncateNumbersWithPound===void 0&&(J.truncateNumbersWithPound=!1);const{shortcutOverrides:ve={}}=J,be=Kt.isMacPlatform?(D=ve.mac)!=null?D:{}:(F=ve.windows)!=null?F:{};Object.entries(be).forEach(([Re,qe])=>{var Oe;(Oe=Ae.get(Re))==null||Oe.setKeyState(qe)});const _e={filterSets:Q.filterSets,links:Q.links},ee=await H.getServerConfigValues(),ge=new Map(ee),Se={name:_,operateAs:_,groups:[],permissions:{isSuperUser:!1,isQueryViewOnly:!1,isNonInteractive:!1,canUsePanels:!0,canCreateDashboard:!0,canCreateCodeStudio:!0,canCreateQueryMonitor:!0,canCopy:ge.get("internal.webClient.appInit.canCopy")!=="false",canDownloadCsv:ge.get("internal.webClient.appInit.canDownloadCsv")!=="false"}};n(hn.DEFAULT),p(ge),s(V),i(Dn,_e),o(O),r(N),l(Dn,U),$!==void 0&&a(Dn,$),d(x),c(Se),m(k),u(G)}catch(x){li.error(x),f(x)}},[n,s,i,o,r,l,a,d,c,u,m,p]),T=S.exports.useCallback(()=>{document.fonts!=null?document.fonts.ready.then(()=>{b(!1)}):b(!1)},[]);S.exports.useEffect(function(){w(),T()},[w,T]);const y=e==null&&g==null||C,E=!y&&g==null,I=g!=null?`${g}`:null;return v(pe,{children:[E&&h(a2,{}),h(bl,{isLoading:y,isLoaded:E,errorMessage:I}),v("div",{id:"preload-fonts",style:{visibility:"hidden",position:"absolute",top:-1e4},children:[h("p",{className:"fira-sans-regular",children:"preload"}),h("p",{className:"fira-sans-semibold",children:"preload"}),h("p",{className:"fira-mono",children:"preload"})]})]})};uc.propTypes={workspace:R.exports.shape({}),workspaceStorage:R.exports.shape({close:R.exports.func}),setActiveTool:R.exports.func.isRequired,setCommandHistoryStorage:R.exports.func.isRequired,setDashboardData:R.exports.func.isRequired,setFileStorage:R.exports.func.isRequired,setLayoutStorage:R.exports.func.isRequired,setDashboardConnection:R.exports.func.isRequired,setDashboardSessionWrapper:R.exports.func.isRequired,setPlugins:R.exports.func.isRequired,setUser:R.exports.func.isRequired,setWorkspace:R.exports.func.isRequired,setWorkspaceStorage:R.exports.func.isRequired};uc.defaultProps={workspace:null,workspaceStorage:null};const w2=t=>({workspace:Il(t),workspaceStorage:bS(t)}),tu=Mt(w2,{setActiveTool:Ml,setCommandHistoryStorage:xS,setDashboardData:qm,setFileStorage:_S,setLayoutStorage:I1,setDashboardConnection:mE,setDashboardSessionWrapper:pE,setPlugins:kS,setUser:NS,setWorkspace:Em,setWorkspaceStorage:FS,setServerConfigValues:LS})(uc),v2=()=>h(wg,{basename:"/ide/",children:v(vg,{children:[h(Ec,{exact:!0,path:"/",component:tu}),h(Ec,{path:"/notebook/:notebookPath+",component:tu}),h(Tg,{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 T2(){"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(t=>{t.forEach(e=>{e.scope.endsWith("/download/")||e.unregister()})})}A1();hi.render(h(iu,{store:Nl,children:h(v2,{})}),document.getElementById("root"));T2();ll.registerOnLoaded();st.init({getWorker:()=>new yg});window["__react-beautiful-dnd-disable-dev-warnings"]=!0;
|
|
47
|
-
//# sourceMappingURL=index.
|
|
47
|
+
//# sourceMappingURL=index.184186f5.js.map
|