@deephaven/code-studio 0.52.1-deephaven-ui.3 → 0.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import{r as m,I as vt,C as o,P as yt,J as tn,K as De,H as te,L as Te,F as j,M as ne,N as b,G as E,O as St,D as Tt,T as nn,Q as sn,S as on,U as an,V as rn,W as We,X as ln,Y as cn}from"./vendor-9bc0b4ef.js";import{W as dn}from"./monaco-1410cbed.js";import{L as un,a as hn,D as mn,P as pn,s as xe,g as Ct,b as wt,c as Ft,d as Dt,e as xt,f as Et,h as Rt,i as Nt,j as jt,k as Ee,l as fn,m as Ot,C as V,T as de,r as gn,n as bn,O as vn,o as Ve,p as Ge,q as Be,F as Ze,t as It,u as yn,v as Sn,w as Tn,x as Cn,y as wn,z as Fn,A as He,B as Dn,E as Lt,G as ze,N as xn,I as ae,M as En,H as Rn,J as U,K as Nn,Q as jn,R as H,S as On,U as In,V as Ln,W as Pn,X as kn,Y as An,Z as _n,_ as Mn,$ as Un,a0 as $n,a1 as Kn,a2 as Wn,a3 as Vn,a4 as Gn}from"./ControlType-7a14e9ea.js";import{L as k,v as z,a as Bn,M as Zn,b as Hn,c as zn,d as Yn,l as qn,e as Jn,f as Xn,T as le,g as Qn,h as es,i as ts,j as ns,k as ss,m as os,n as as,o as rs,p as is,q as ls,r as cs,s as ds,t as us,u as hs,w as Ye,x as qe,y as Je,z as ms,A as ps,B as fs,C as gs,D as bs,E as Xe,F as vs,G as ys}from"./index-a05f89d5.js";import{O as ue,P as K,T as A,D as Ss,I as R,a as N,b as L,u as Pt,F as Ts,c as D,d as Cs,B as w,C as fe,S as _,e as Re,f as kt,K as ws,g as Qe,h as Fs,G as Ce,i as At,j as Ds,k as xs,l as Es,m as Rs,n as Ns,o as et,p as js,q as tt,r as Os,s as Is,t as Ls,v as Ps,M as ks}from"./PluginTypes-1b51d53a.js";import{C as As,B as _s,m as Ms,a as Us,D as $s,I as Ks,u as Ws,b as Vs,c as Gs,g as Bs,l as Zs}from"./useUser-3992913e.js";import"./helpers-042e6b4d.js";import"./plotly-26031571.js";function nt(s,e){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(s,a).enumerable})),t.push.apply(t,n)}return t}function Hs(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?nt(Object(t),!0).forEach(function(n){zs(s,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):nt(Object(t)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(t,n))})}return s}function zs(s,e,t){return e=Ys(e),e in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function Ys(s){var e=qs(s,"string");return typeof e=="symbol"?e:String(e)}function qs(s,e){if(typeof s!="object"||s===null)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var n=t.call(s,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(s)}var Js=100,ge=()=>{},Xs=Object.freeze({});function Qs(s){var{id:e="default",children:t,emptyDashboard:n,layoutConfig:a,layoutSettings:r=Xs,onLayoutConfigChange:i=ge,onGoldenLayoutChange:l=ge,onLayoutInitialized:c=ge,fallbackComponent:d=pn,hydrate:h,dehydrate:u,panelWrapper:g}=s,v=m.useRef(null),[y,x]=m.useState(!1),[T,S]=m.useState();m.useEffect(function(){if(!v.current){S(void 0);return}var p=Hs({},un.makeDefaultLayout());p.settings===void 0&&(p.settings={}),Object.assign(p.settings,r),p.content=[];var f=new hn(p,v.current),se=()=>{f.off("initialised",se),x(!0)};return f.on("initialised",se),d!=null&&f.setFallbackComponent(d),f.init(),S(f),l(f),()=>{f.destroy()}},[r,d,l,x,S]);var O=m.useMemo(()=>vt(()=>{T!=null&&T.isInitialised&&T?.updateSize()},Js),[T]);return m.useEffect(function(){return window.addEventListener("resize",O),()=>{window.removeEventListener("resize",O)}},[O]),o.jsxs("div",{className:"dashboard-container w-100 h-100",children:[o.jsx("div",{className:"w-100 h-100",ref:v}),y&&T&&o.jsx(mn,{emptyDashboard:n,id:e,layout:T,layoutConfig:a,onLayoutChange:i,onLayoutInitialized:c,hydrate:h,dehydrate:u,panelWrapper:g,children:t})]})}class st{static makeSortConfig(e,t){return{column:e,direction:t}}static makeFilterConfig(e){var t=[],n=[];return e.forEach((a,r)=>{t.push(a),r>0&&n.push(ue.and)}),{filterItems:t,filterOperators:n}}static combineFilterConfigs(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ue.and;return{filterItems:[...e.filterItems,...t.filterItems],filterOperators:[...e.filterOperators,n,...t.filterOperators]}}static makeFilterItem(e,t,n){return{columnName:e,type:t,value:n}}}function eo(s,e,t){if(s.length>e){var n=s.length-t;return{toKeep:s.slice(n),toPrune:s.slice(0,n)}}return{toKeep:s,toPrune:[]}}function ot(s,e){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(s,a).enumerable})),t.push.apply(t,n)}return t}function at(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ot(Object(t),!0).forEach(function(n){I(s,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):ot(Object(t)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(t,n))})}return s}function rt(s,e,t,n,a,r,i){try{var l=s[r](i),c=l.value}catch(d){t(d);return}l.done?e(c):Promise.resolve(c).then(n,a)}function $(s){return function(){var e=this,t=arguments;return new Promise(function(n,a){var r=s.apply(e,t);function i(c){rt(r,n,a,i,l,"next",c)}function l(c){rt(r,n,a,i,l,"throw",c)}i(void 0)})}}function I(s,e,t){return e=to(e),e in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function to(s){var e=no(s,"string");return typeof e=="symbol"?e:String(e)}function no(s,e){if(typeof s!="object"||s===null)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var n=t.call(s,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(s)}var be=k.module("PouchStorageTable"),so="Deephaven.";yt.plugin(tn);function oo(s,e){switch(s){case A.in:case A.contains:return{$regex:new RegExp("".concat(e))};case A.inIgnoreCase:return{$regex:new RegExp("".concat(e),"i")};case A.eq:return{$eq:e};case A.notEq:return{$neq:e};case A.greaterThan:return{$gt:e};case A.greaterThanOrEqualTo:return{$gte:e};case A.lessThan:return{$lt:e};case A.lessThanOrEqualTo:return{$lte:e};case A.startsWith:return{$regex:new RegExp("^(?".concat(e,").*"))};default:throw new Error("Unsupported type: ".concat(s))}}function ao(s){for(var{filterItems:e,filterOperators:t}=s,n=null,a=0;a<e.length;a+=1){var r=e[a],{columnName:i,type:l,value:c}=r,d={[i]:oo(l,c)};if(a===0)n=d;else if(n!==null&&a-1<t.length){var h=t[a-1];if(h===ue.and)n={$and:[n,d]};else if(h===ue.or)n={$or:[n,d]};else throw new Error("Unexpected filter operator ".concat(h,", ").concat(d))}}if(n==null)throw new Error("Invalid filter config ".concat(s));return n}function ve(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return{$and:[...s.map(e=>ao(e)),{name:{$gt:null}},{id:{$gt:null}}]}}function ro(s){var e,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return[{id:t?"desc":"asc"},...(e=s?.map(n=>({[n.column]:n.direction})))!==null&&e!==void 0?e:[]]}class io{constructor(e,t){I(this,"db",void 0),I(this,"changes",void 0),I(this,"listeners",[]),I(this,"itemListeners",new Map),I(this,"currentSize",0),I(this,"currentViewport",void 0),I(this,"currentReverse",!1),I(this,"currentFilter",null),I(this,"currentSort",null),I(this,"infoUpdatePromise",void 0),I(this,"viewportUpdatePromise",void 0),I(this,"currentViewportData",void 0),this.db=new yt("".concat(so).concat(e),t),this.db._remote=!1,this.listenForChanges(),this.db.createIndex({index:{fields:["id","name"]}}),this.refreshInfo()}listenForChanges(){this.changes=this.db.changes({live:!0,since:"now",include_docs:!0}).on("change",this.dbUpdate.bind(this))}onUpdate(e){return this.listeners=[...this.listeners,e],()=>{this.listeners=this.listeners.filter(t=>t!==e)}}onItemUpdate(e,t){return this.itemListeners.has(e)||this.itemListeners.set(e,[]),this.itemListeners.set(e,[...this.itemListeners.get(e),t]),this.refreshItem(e),()=>{this.itemListeners.set(e,this.itemListeners.get(e).filter(n=>n!==t))}}close(){this.listeners=[]}get size(){return this.currentSize}get viewport(){return this.currentViewport}setReversed(e){this.currentReverse=e,this.currentViewportData=void 0,this.refreshData()}setViewport(e){this.currentViewport=e,this.refreshInfo(),this.refreshData()}setSorts(e){this.currentSort=e,this.currentViewportData=void 0,this.refreshData()}setFilters(e){this.currentFilter=e,this.currentViewportData=void 0,this.refreshInfo(),this.refreshData()}get data(){return this.currentViewportData}getViewportData(){var e=this;return $(function*(){var t;return e.viewportUpdatePromise||e.refreshData(),(t=e.viewportUpdatePromise)!==null&&t!==void 0?t:Promise.resolve({items:[],offset:0})})()}put(e){var t=this;return $(function*(){var n=at(at({},e),{},{_id:e.id});return yield t.db.put(n),n})()}sendUpdate(){for(var e,{listeners:t}=this,n=(e=this.currentViewportData)!==null&&e!==void 0?e:{items:[],offset:0},a=0;a<t.length;a+=1)t[a](n)}sendItemUpdate(e){var t=this.itemListeners.get(e.id);if(t!==void 0)for(var n=0;n<t.length;n+=1)t[n](e)}dbUpdate(e){be.debug("Update received",e),this.refreshInfo(),e.doc!==void 0&&this.sendItemUpdate(e.doc),this.refreshData()}fetchInfo(e){var t=this;return $(function*(){return t.db.find({selector:e,fields:[]})})()}refreshInfo(){var e=this;return $(function*(){try{var t,n;(t=e.infoUpdatePromise)===null||t===void 0||t.cancel(),e.infoUpdatePromise=K.makeCancelable(e.fetchInfo(ve((n=e.currentFilter)!==null&&n!==void 0?n:[])));var a=yield e.infoUpdatePromise;e.currentSize=a.docs.length,e.sendUpdate()}catch(r){if(!K.isCanceled(r))throw be.error("Unable to refreshInfo",r),r}})()}fetchViewportData(e,t,n){var a=this;return $(function*(){return a.db.find({selector:t,skip:e.top,limit:e.bottom-e.top+1,sort:n,fields:["id","name"]}).then(r=>({items:r.docs,offset:e.top}))})()}refreshData(){var e=this;return $(function*(){if(e.currentViewport)try{var t,n,a=ve((t=e.currentFilter)!==null&&t!==void 0?t:[]),r=ro(e.currentSort,e.currentReverse);(n=e.viewportUpdatePromise)===null||n===void 0||n.cancel(),e.viewportUpdatePromise=K.makeCancelable(e.fetchViewportData(e.currentViewport,a,r));var i=yield e.viewportUpdatePromise;return e.currentViewportData=i,e.sendUpdate(),i}catch(l){if(!K.isCanceled(l))throw be.error("Unable to refreshData",l),l}})()}refreshItem(e){var t=this;return $(function*(){var n=yield t.db.find({selector:{id:e},limit:1}),a=n.docs[0];return a!==void 0&&t.sendItemUpdate(a),a})()}getSnapshot(e){var t=this;return $(function*(){var n=new Map,a=[{id:t.currentReverse?"desc":"asc"}];return yield Promise.all(e.map(function(){var r=$(function*(i){var l,[c,d]=i,h=d-c+1;return t.db.find({selector:ve((l=t.currentFilter)!==null&&l!==void 0?l:[]),skip:c,limit:h,sort:a,fields:["id","name"]}).then(u=>{for(var g=0;g<h;g+=1){var v=c+g;n.set(v,u.docs[g])}})});return function(i){return r.apply(this,arguments)}}())),n})()}}const lo=io;function it(s,e){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(s,a).enumerable})),t.push.apply(t,n)}return t}function re(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?it(Object(t),!0).forEach(function(n){_t(s,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):it(Object(t)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(t,n))})}return s}function lt(s,e,t,n,a,r,i){try{var l=s[r](i),c=l.value}catch(d){t(d);return}l.done?e(c):Promise.resolve(c).then(n,a)}function X(s){return function(){var e=this,t=arguments;return new Promise(function(n,a){var r=s.apply(e,t);function i(c){lt(r,n,a,i,l,"next",c)}function l(c){lt(r,n,a,i,l,"throw",c)}i(void 0)})}}function _t(s,e,t){return e=co(e),e in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function co(s){var e=uo(s,"string");return typeof e=="symbol"?e:String(e)}function uo(s,e){if(typeof s!="object"||s===null)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var n=t.call(s,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(s)}var ho=2500,mo=2e3,P=k.module("PouchCommandHistoryTable");class po extends lo{constructor(e,t){var n;super("CommandHistoryStorage.".concat(e),{auto_compaction:!0,revs_limit:1}),_t(this,"searchText",void 0),this.cache=t,this.cache.tableRegistry.has(this.cacheKey)||this.cache.tableRegistry.set(this.cacheKey,new Set),P.debug("Adding table to registry",this.cacheKey),(n=this.cache.tableRegistry.get(this.cacheKey))===null||n===void 0||n.add(this)}get cacheKey(){return this.db.name}setSearch(e){P.debug("Setting search filters",e),this.searchText=e.trim().toLowerCase(),this.setFilters(e?[st.makeFilterConfig([st.makeFilterItem("name",A.contains,e)])]:[])}dbUpdate(e){P.debug("Clearing cache and refreshing data",e),this.cache.response.delete(this.cacheKey),super.dbUpdate(e)}fetchData(e){var t=this;return X(function*(){return K.withTimeout(0,X(function*(){t.cache.response.has(t.cacheKey)?P.debug("Fetching from cache",t.searchText,t.viewport):(P.debug("Fetching from PouchDB",t.searchText,t.viewport),t.cache.response.set(t.cacheKey,t.db.allDocs({include_docs:!0}).then(a=>{var r=a.rows.map(c=>c.doc).filter(c=>{var{name:d}=c;return d});P.debug("Fetched ".concat(r.length," command history items"));var{toKeep:i,toPrune:l}=eo(r,ho,mo);return l.length&&t.pruneItems(l),{docs:i}})));var n=t.cache.response.get(t.cacheKey);return t.searchText==null||t.searchText===""?n:re(re({},n),{},{docs:(yield n).docs.filter(a=>{var{name:r}=a;return r.toLowerCase().includes(t.searchText)})})}))})()}fetchInfo(e){var t=this;return X(function*(){return t.fetchData(e)})()}fetchViewportData(e,t,n){var a=this;return X(function*(){var r=yield a.fetchData(t);P.debug("Fetching viewport data",e.top,e.bottom+1,n,r);var i=typeof n[0]=="object"&&n[0].id==="desc",l=i?r.docs.slice(0).reverse():r.docs,c=l.slice(e.top,e.bottom+1);return{items:c,offset:e.top}})()}pruneItems(e){var t=this;return X(function*(){if(t.cache.isPruning.get(t.cacheKey)===!0){P.debug("Pruning already in progress. Skipping.");return}try{P.debug("Pruning ".concat(e.length," command history items"));var n=t.cache.pauseChangeListeners(t.cacheKey);t.cache.isPruning.set(t.cacheKey,!0),yield t.db.bulkDocs(e.map(a=>re(re({},a),{},{_deleted:!0}))),t.cache.isPruning.set(t.cacheKey,!1),n(),P.debug("Finished pruning command history items")}catch(a){P.error("An error occurred while pruning db",a)}})()}close(){var e,t,n;P.debug("Closing table",this,(e=this.cache.tableRegistry.get(this.cacheKey))===null||e===void 0?void 0:e.size),(t=this.cache.tableRegistry.get(this.cacheKey))===null||t===void 0||t.delete(this),(n=this.changes)===null||n===void 0||n.cancel(),super.close()}}const ct=po;function ye(s,e,t){return e=fo(e),e in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function fo(s){var e=go(s,"string");return typeof e=="symbol"?e:String(e)}function go(s,e){if(typeof s!="object"||s===null)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var n=t.call(s,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(s)}var dt=k.module("PouchCommandHistoryCache");class bo{constructor(){ye(this,"isPruning",void 0),ye(this,"response",void 0),ye(this,"tableRegistry",void 0),this.isPruning=new Map,this.response=new Map,this.tableRegistry=new Map}pauseChangeListeners(e){var t,n=[];return(t=this.tableRegistry.get(e))===null||t===void 0||t.forEach(a=>{a.changes&&(dt.debug("Pausing event listeners on '".concat(e,"' table"),a),a.changes.cancel(),n.push(a))}),()=>{n.forEach(a=>{var r,i;(r=(i=this.tableRegistry.get(e))===null||i===void 0?void 0:i.has(a))!==null&&r!==void 0&&r&&(dt.debug("Resuming event listeners on '".concat(e,"' table"),a),a.listenForChanges())})}}}const vo=bo;function ut(s,e){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(s,a).enumerable})),t.push.apply(t,n)}return t}function ht(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ut(Object(t),!0).forEach(function(n){we(s,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):ut(Object(t)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(t,n))})}return s}function mt(s,e,t,n,a,r,i){try{var l=s[r](i),c=l.value}catch(d){t(d);return}l.done?e(c):Promise.resolve(c).then(n,a)}function Se(s){return function(){var e=this,t=arguments;return new Promise(function(n,a){var r=s.apply(e,t);function i(c){mt(r,n,a,i,l,"next",c)}function l(c){mt(r,n,a,i,l,"throw",c)}i(void 0)})}}function we(s,e,t){return e=yo(e),e in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function yo(s){var e=So(s,"string");return typeof e=="symbol"?e:String(e)}function So(s,e){if(typeof s!="object"||s===null)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var n=t.call(s,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(s)}var pt=k.module("PouchCommandHistoryStorage");class To{constructor(){we(this,"cache",new vo),we(this,"updateTableMap",new Map)}getUpdateTable(e){return this.updateTableMap.has(e)||this.updateTableMap.set(e,new ct(e,this.cache)),this.updateTableMap.get(e)}getTable(e){var t=this;return Se(function*(){return new ct(e,t.cache)})()}addItem(e,t,n,a){var r=this;return Se(function*(){return r.updateItem(e,{id:"".concat(new Date().getTime()),name:n,data:a})})()}updateItem(e,t){var n=this;return Se(function*(){var a=n.getUpdateTable(e),r=yield a.refreshItem(t.id),i=ht(ht({},r??{}),t);return pt.debug("Updating item",i),yield a.put(i),pt.debug("Update saved"),t})()}listenItem(e,t,n){var a=this.getUpdateTable(e);return a.onItemUpdate(t,n)}}const Mt="SET_LAYOUT_STORAGE",Co=s=>({type:Mt,payload:s});var{dh:wo}=globalThis;const W=wo,Ut=""+new URL("community-wordmark-app-d2c5c1eb.svg",import.meta.url).href;const Fo=k.module("SettingsUtils");function Do(s){return s.formatString!=null}function Fe(s){const e=s?.querySelector("input, select, textarea");e&&e.focus()}function $t(s,e){return s.defaultFormatString===e.defaultFormatString}function xo(s,e){return $t(s,e)}function Eo(s,e){return $t(s,e)}function Kt(s){return s!==""&&Ss.isValidColumnName(s)}function G(s,e,t){if(!e||t.formatString==null||!Do(t))return!1;switch(e){case"datetime":return L.isValid(s,t);case"decimal":return N.isValid(s,t);case"int":return R.isValid(s,t);default:return Fo.warn("Trying to validate format of unknown type"),!0}}function Wt(s){const{id:e,isNewRule:t,...n}=s;return n}function Vt(s,e){return Kt(e.columnName)&&G(s,e.columnType,e.format)}function Gt(s){const{timestamp:e,timeZone:t,showTimeZone:n,showTSeparator:a,isGlobalOptions:r,legacyGlobalFormat:i}=s,l=Pt(),c=m.useMemo(()=>new Ts(l,[],{timeZone:t,showTimeZone:n,showTSeparator:a}),[l,n,a,t]),d=r?L.getGlobalFormats(n,a):L.getFormats(n,a);return i!=null&&!d.includes(i)&&d.unshift(i),o.jsx(o.Fragment,{children:d.map(h=>{const u=L.makeFormat("",h,L.TYPE_GLOBAL);return o.jsx("option",{value:h,"data-testid":"time-format",children:c.getFormattedString(e,D.dataType.DATETIME,"",u)},h)})})}function Ro(){return o.jsx(o.Fragment,{children:Cs.TIME_ZONES.map(s=>{const{label:e,value:t}=s;return o.jsx("option",{value:t,children:e},t)})})}const Z=k.module("FormattingSectionContent");class Ne extends m.PureComponent{static defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:L.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:N.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:R.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:L.DEFAULT_TIME_ZONE_ID}};static inputDebounceTime=250;constructor(e){super(e),this.debouncedCommitChanges=De(this.commitChanges.bind(this),Ne.inputDebounceTime),this.handleDefaultDateTimeFormatChange=this.handleDefaultDateTimeFormatChange.bind(this),this.handleDefaultDecimalFormatChange=this.handleDefaultDecimalFormatChange.bind(this),this.handleDefaultIntegerFormatChange=this.handleDefaultIntegerFormatChange.bind(this),this.handleShowTimeZoneChange=this.handleShowTimeZoneChange.bind(this),this.handleShowTSeparatorChange=this.handleShowTSeparatorChange.bind(this),this.handleTimeZoneChange=this.handleTimeZoneChange.bind(this),this.handleResetDateTimeFormat=this.handleResetDateTimeFormat.bind(this),this.handleResetDecimalFormat=this.handleResetDecimalFormat.bind(this),this.handleResetIntegerFormat=this.handleResetIntegerFormat.bind(this),this.handleResetTimeZone=this.handleResetTimeZone.bind(this),this.handleTruncateNumbersWithPoundChange=this.handleTruncateNumbersWithPoundChange.bind(this);const{formatter:t,defaultDateTimeFormat:n,defaultDecimalFormatOptions:a,defaultIntegerFormatOptions:r,showTimeZone:i,showTSeparator:l,timeZone:c,truncateNumbersWithPound:d}=e,h=t.map((u,g)=>({...u,id:g}));this.containerRef=te.createRef(),this.state={formatSettings:h,showTimeZone:i,showTSeparator:l,timeZone:c,defaultDateTimeFormat:n,defaultDecimalFormatOptions:a,defaultIntegerFormatOptions:r,truncateNumbersWithPound:d,timestampAtMenuOpen:new Date}}componentDidMount(){Fe(this.containerRef.current)}componentWillUnmount(){this.debouncedCommitChanges.flush()}debouncedCommitChanges;containerRef;getCachedDateTimeFormatOptions=Te((e,t,n,a=!1,r)=>{const{timestampAtMenuOpen:i}=this.state;return o.jsx(Gt,{timestamp:i,timeZone:e,showTimeZone:t,showTSeparator:n,isGlobalOptions:a,legacyGlobalFormat:r})});handleDefaultDateTimeFormatChange(e){Z.debug("handleDefaultDateTimeFormatChange",e.target.value),this.setState({defaultDateTimeFormat:e.target.value},()=>{this.debouncedCommitChanges()})}handleDefaultDecimalFormatChange(e){Z.debug("handleDefaultDecimalFormatChange",e.target.value),this.setState({defaultDecimalFormatOptions:{defaultFormatString:e.target.value}},()=>{this.debouncedCommitChanges()})}handleDefaultIntegerFormatChange(e){Z.debug("handleDefaultIntegerFormatChange",e.target.value),this.setState({defaultIntegerFormatOptions:{defaultFormatString:e.target.value}},()=>{this.debouncedCommitChanges()})}handleShowTimeZoneChange(){this.setState(e=>({showTimeZone:!e.showTimeZone}),()=>{this.debouncedCommitChanges()})}handleShowTSeparatorChange(){this.setState(e=>({showTSeparator:!e.showTSeparator}),()=>{this.debouncedCommitChanges()})}handleTimeZoneChange(e){this.setState({timeZone:e.target.value},()=>{this.debouncedCommitChanges()})}handleResetDateTimeFormat(){const{defaults:e}=this.props,{defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:a}=e;Z.debug("handleResetDateTimeFormat"),this.setState({defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:a},()=>{this.debouncedCommitChanges()})}handleResetTimeZone(){const{defaults:e}=this.props,{timeZone:t}=e;Z.debug("handleResetTimeZone"),this.setState({timeZone:t},()=>{this.debouncedCommitChanges()})}handleResetDecimalFormat(){const{defaults:e}=this.props,{defaultDecimalFormatOptions:t}=e;Z.debug("handleResetDecimalFormat"),this.setState({defaultDecimalFormatOptions:t},()=>{this.debouncedCommitChanges()})}handleResetIntegerFormat(){const{defaults:e}=this.props,{defaultIntegerFormatOptions:t}=e;Z.debug("handleResetIntegerFormat"),this.setState({defaultIntegerFormatOptions:t},()=>{this.debouncedCommitChanges()})}handleTruncateNumbersWithPoundChange(){this.setState(e=>({truncateNumbersWithPound:!e.truncateNumbersWithPound}),()=>{this.debouncedCommitChanges()})}commitChanges(){const{formatSettings:e,defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:a,timeZone:r,defaultDecimalFormatOptions:i,defaultIntegerFormatOptions:l,truncateNumbersWithPound:c}=this.state,{dh:d}=this.props,h=e.filter(y=>Vt(d,y)).map(Wt)??[],{settings:u,saveSettings:g}=this.props,v={...u,formatter:h,defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:a,timeZone:r,truncateNumbersWithPound:c};G(d,D.dataType.DECIMAL,N.makeCustomFormat(i.defaultFormatString))&&(v.defaultDecimalFormatOptions=i),G(d,D.dataType.INT,R.makeCustomFormat(l.defaultFormatString))&&(v.defaultIntegerFormatOptions=l),g(v)}render(){const{defaults:e,dh:t}=this.props,{defaultDateTimeFormat:n,defaultDecimalFormatOptions:a,defaultIntegerFormatOptions:r,timeZone:i,showTimeZone:l,showTSeparator:c,truncateNumbersWithPound:d}=this.state,{defaultFormatString:h=N.DEFAULT_FORMAT_STRING}=a??{},{defaultFormatString:u=R.DEFAULT_FORMAT_STRING}=r??{},g=i===e.timeZone,v=c===e.showTSeparator&&l===e.showTimeZone&&n===e.defaultDateTimeFormat,y=xo(a,e.defaultDecimalFormatOptions),x=Eo(r,e.defaultIntegerFormatOptions);return o.jsx("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:o.jsxs("div",{className:"container-fluid p-0",children:[o.jsx("div",{className:"app-settings-menu-description mb-3",children:"Choose the default formatting rule to apply to all table columns based on their type."}),o.jsxs("div",{className:"form-row mb-2",children:[o.jsx("label",{className:"col-form-label col-3",htmlFor:"select-reset-timezone",children:"Time zone"}),o.jsx("div",{className:"col pr-0",children:o.jsx("select",{className:"custom-select",value:i,onChange:this.handleTimeZoneChange,id:"select-reset-timezone",children:o.jsx(Ro,{})})}),o.jsx("div",{className:"col-1 btn-col",children:o.jsx(w,{kind:"ghost",icon:z,onClick:this.handleResetTimeZone,tooltip:"Reset Time Zone",className:j("btn-reset","btn-reset-time-zone",{hidden:g})})})]}),o.jsxs("div",{className:"form-row mb-2",children:[o.jsx("label",{className:"col-form-label col-3",htmlFor:"select-default-time-format",children:"DateTime"}),o.jsx("div",{className:"col pr-0",children:o.jsx("select",{className:"custom-select",value:n,onChange:this.handleDefaultDateTimeFormatChange,id:"select-default-time-format",children:this.getCachedDateTimeFormatOptions(i,l,c,!0,n)})}),o.jsx("div",{className:"col-1 btn-col",children:o.jsx(w,{kind:"ghost",icon:z,onClick:this.handleResetDateTimeFormat,tooltip:"Reset DateTime Options",className:j("btn-reset","btn-reset-date-time",{hidden:v})})})]}),o.jsx("div",{className:"form-row",children:o.jsx("div",{className:"offset-3 col-9",children:o.jsx(fe,{checked:l??null,onChange:this.handleShowTimeZoneChange,children:"Show time zone in dates"})})}),o.jsx("div",{className:"form-row mb-3",children:o.jsx("div",{className:"offset-3 col-9",children:o.jsx(fe,{checked:c??null,onChange:this.handleShowTSeparatorChange,children:"Show 'T' separator"})})}),o.jsxs("div",{className:"form-row mb-2",children:[o.jsx("label",{className:"col-form-label col-3",htmlFor:"default-decimal-format-input",children:"Decimal"}),o.jsx("div",{className:"col pr-0",children:o.jsx("input",{className:j("form-control","flex-grow-1","default-decimal-format-input",{"is-invalid":!G(t,D.dataType.DECIMAL,N.makeCustomFormat(h))}),"data-lpignore":!0,placeholder:N.DEFAULT_FORMAT_STRING,type:"text",id:"default-decimal-format-input",value:h,onChange:this.handleDefaultDecimalFormatChange})}),o.jsx("div",{className:"col-1 btn-col",children:o.jsx(w,{kind:"ghost",icon:z,onClick:this.handleResetDecimalFormat,tooltip:"Reset Decimal Formatting",className:j("btn-reset","btn-reset-decimal",{hidden:y}),"data-testid":"btn-reset-decimal"})})]}),o.jsxs("div",{className:"form-row mb-2",children:[o.jsx("label",{className:"col-form-label col-3",htmlFor:"default-integer-format-input",children:"Integer"}),o.jsx("div",{className:"col pr-0",children:o.jsx("input",{className:j("form-control","flex-grow-1","default-integer-format-input",{"is-invalid":!G(t,D.dataType.INT,R.makeCustomFormat(u))}),"data-lpignore":!0,placeholder:R.DEFAULT_FORMAT_STRING,type:"text",id:"default-integer-format-input",value:u,onChange:this.handleDefaultIntegerFormatChange})}),o.jsx("div",{className:"col-1 btn-col",children:o.jsx(w,{kind:"ghost",icon:z,onClick:this.handleResetIntegerFormat,tooltip:"Reset Integer Formatting",className:j("btn-reset","btn-reset-integer",{hidden:x}),"data-testid":"btn-reset-integer"})})]}),o.jsx("div",{className:"form-row mb-3",children:o.jsx("div",{className:"offset-3 col-9",children:o.jsx(fe,{checked:d??null,onChange:this.handleTruncateNumbersWithPoundChange,children:"Show truncated numbers as ###"})})})]})})}}const No=s=>({formatter:Ct(s),defaultDateTimeFormat:wt(s),defaultDecimalFormatOptions:Ft(s),defaultIntegerFormatOptions:Dt(s),dh:xt(s),showTimeZone:Et(s),showTSeparator:Rt(s),truncateNumbersWithPound:Nt(s),timeZone:jt(s),settings:Ee(s)}),jo=ne(No,{saveSettings:xe})(Ne);function Oo(){const[s,e]=m.useState(!1),t=()=>{e(!s)};return o.jsxs(o.Fragment,{children:[o.jsx(w,{kind:"ghost",onClick:t,icon:Bn,children:"Legal Notices"}),o.jsxs(Zn,{isOpen:s,toggle:t,className:"theme-bg-light",children:[o.jsx(Hn,{toggle:t,children:"Legal Notice"}),o.jsxs(zn,{children:[o.jsx("p",{children:"Deephaven software is protected by U.S. Patent Nos. 9,612,959; 9,613,018; 9,613,109; 9,619,210; 9,633,060; 9,639,570; 9,672,238; 9,679,006; 9,690,821; 9,710,511; 9,760,591; 9,805,084; 9,836,494; 9,836,495; 9,886,469; 9,898,496; 9,934,266; 10,002,153; 10,002,154; 10,002,155; 10,003,673; 10,019,138; 10,069,943; 10,176,211; 10,198,465; 10,198,466; 10,198,469; 10,212,257; 10,241,960; 10,241,965; 10,242,040; 10,242,041; 10,346,394; 10,353,893; 10,452,649; 10,496,639; 10,540,351; 10,552,412; 10,565,194; 10,565,206; 10,572,474; 10,621,168; 10,642,829; 10,657,184; 10,678,787; 10,691,686; 10,783,191; 10,866,943; 10,909,183; 10,915,526; 10,922,311; 10,929,394; 11,023,462; 11,126,662; 11,151,133; 11,238,036; 11,249,994; 11,263,211; 11,449,557; 11,514,037; 11,556,528; and 11,574,018. Other patents pending."}),o.jsxs("p",{children:["© 2016-",new Date().getFullYear()," Deephaven Data Labs LLC. Patent Pending."]})]})]})]})}function ee(s){const{children:e,isExpanded:t,sectionKey:n,title:a,onToggle:r}=s;return o.jsxs(o.Fragment,{children:[o.jsx("div",{children:o.jsxs(w,{kind:"ghost",className:"btn-collapse-trigger",onClick:()=>r(n),children:[o.jsx("div",{className:"flex-grow-1",children:a}),o.jsx("div",{className:"flex-shrink-0",children:o.jsx(E,{transform:t?"flip-v":"",icon:Yn})})]})}),o.jsx(As,{in:t,autoFocusOnShow:!0,children:e})]})}ee.propTypes={children:b.node,isExpanded:b.bool.isRequired,sectionKey:b.string.isRequired,title:b.node.isRequired,onToggle:b.func};ee.defaultProps={children:null,onToggle:()=>{}};function Io({shortcut:s,displayText:e,categoryName:t,onChange:n}){const[a,r]=m.useState(e),[i,l]=m.useState(s.getKeyState()),[c,d]=m.useState(!1),[h,u]=m.useState("");m.useEffect(function(){r(e),l(s.getKeyState())},[e,s]),m.useEffect(function(){r(_.getDisplayText(i)),s.matchesKeyState(i)&&d(!1)},[i,s]),m.useEffect(function(){if(c){if(!_.isValidKeyState(i)){_.isAllowedKey(i.keyValue)?u("Must contain a modifier key"):u("Must contain an allowed action key");return}const p=Re.getConflictingShortcuts(i).filter(f=>f.id.startsWith(t)&&f!==s).map(f=>f.name);if(p.length){u(`Conflicts with ${p.join(", ")}`);return}u("")}else u("")},[c,i,t,s]);function g(C){if(C.stopPropagation(),C.preventDefault(),s.isEditable&&!C.repeat){const p=_.getKeyStateFromEvent(C),f=_.createKeyState([ws.BACKSPACE]);_.doKeyStatesMatch(p,f)?l(_.NULL_KEY_STATE):l(p)}}function v(C){C.stopPropagation(),C.preventDefault(),s.matchesKeyState(i)||d(!0)}function y(){Qe.disableAllActions()}function x(){Qe.enableAllActions()}function T(){s.setKeyState(i),d(!1),n(s)}function S(){const C=s.getKeyState();l(C),d(!1)}function O(){d(!0),l(s.getDefaultKeyState())}return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"shortcut-item-container",children:[o.jsxs("label",{className:"shortcut-item-name",children:[s.name,s.tooltip!==void 0&&o.jsx(kt,{children:s.tooltip})]}),o.jsxs("div",{className:"shortcut-item-input-container",children:[o.jsx("input",{className:j("form-control",{"is-invalid":h}),onKeyDown:g,onKeyUp:v,onFocus:y,onBlur:x,disabled:!s.isEditable,value:a,readOnly:!0}),!_.doKeyStatesMatch(i,s.getDefaultKeyState())&&!h&&o.jsx(w,{className:"reset-to-default-button",kind:"ghost",icon:o.jsx(E,{icon:z,transform:{rotate:90,flipX:!0}}),tooltip:"Reset to default",onClick:O})]})]}),c&&o.jsxs("div",{className:j("shortcut-item-message-container",{"is-invalid":h}),children:[o.jsx("div",{className:"shortcut-item-message",children:h}),o.jsxs("div",{className:"shortcut-item-message-buttons",children:[_.isValidKeyState(i)&&o.jsx(w,{kind:"ghost",onClick:T,children:"Confirm"}),o.jsx(w,{kind:"ghost",onClick:S,children:"Undo"})]})]})]})}function Lo({shortcutOverrides:s={},settings:e,saveSettings:t}){const n=m.useCallback(l=>{const c=_.isMacPlatform,d={mac:{...s.mac},windows:{...s.windows}},h=c?d.mac:d.windows;l.forEach(u=>{u.isDefault()?delete h[u.id]:h[u.id]=u.getKeyState()}),t({...e,shortcutOverrides:d})},[e,t,s]);let a=Array.from(Re.shortcutsByCategory.entries()).map(([l,c])=>({name:l,shortcuts:c}));const r=a.findIndex(l=>l.name.toUpperCase()==="GLOBAL"),i=a.splice(r,1);return a=a.concat(i),o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"app-settings-menu-description",children:"Customize shortcuts below. To prevent unexpected results, avoid conflicting shortcuts with the browser or IDE editor."}),a.map(l=>o.jsx(Po,{name:l.name,shortcuts:l.shortcuts,saveShortcutOverrides:n},l.name))]})}function Po({name:s,shortcuts:e,saveShortcutOverrides:t}){function n(c){return c.split("_").map(d=>`${d[0].toUpperCase()}${d.slice(1).toLowerCase()}`).join(" ")}const[a,r]=m.useState(e);function i(c){const d=a.filter(u=>u!==c&&!u.isNull()&&u.matchesKeyState(c.getKeyState()));d.forEach(u=>u.setToNull());const h=[c,...d];t(h),r(u=>[...u])}const l=m.useMemo(()=>a.map(c=>c.getDisplayText()),[a]);return o.jsxs("div",{className:"mt-3",children:[o.jsx("div",{className:"font-weight-bold",children:n(s)}),a.map((c,d)=>o.jsx(Io,{shortcut:c,displayText:l[d],categoryName:s,onChange:i},c.id))]})}const ko=s=>({settings:Ee(s),shortcutOverrides:fn(s)}),Ao={saveSettings:xe},_o=ne(ko,Ao)(Lo),Mo="yyyy-MM-dd-HHmmss";function Bt(s,e="root",t=new Map([[s,""]])){const n={};return Object.entries(s).forEach(([a,r])=>{try{JSON.stringify(r),n[a]=r}catch{const l=r;if(typeof r=="bigint")n[a]=r.toString();else if(t.has(l))n[a]=`Circular ref to ${t.get(l)}`;else{const c=`${e}.${a}`;t.set(l,c),n[a]=Bt(r,c,t)}}}),n}function Uo(){const s=Ot.getState();return JSON.stringify(Bt(s),null,2)}function $o(s){const e={uiVersion:"0.52.0",userAgent:navigator.userAgent,...s};return JSON.stringify(e,null,2)}async function Ko(s=`${W.i18n.DateTimeFormat.format(Mo,new Date)}_support_logs`,e){const t=new St,n=t.folder(s);n.file("console.txt",qn.getFormattedHistory()),n.file("redux.json",Uo()),n.file("metadata.json",$o(e));const a=await t.generateAsync({type:"blob"}),r=document.createElement("a");r.href=URL.createObjectURL(a),r.download=`${s}.zip`,r.click()}const Wo=[{value:D.dataType.DATETIME,label:"DateTime"},{value:D.dataType.DECIMAL,label:"Decimal"},{value:D.dataType.INT,label:"Integer"}];function Vo(){const s=Wo.map(e=>o.jsx("option",{value:e.value,children:e.label},`key-columnType-${e.value}`));return o.jsxs(o.Fragment,{children:[o.jsx("option",{disabled:!0,value:"",children:"Select Type"},"key-columnType-placeholder"),s]})}class je extends m.PureComponent{static defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:L.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:N.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:R.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:L.DEFAULT_TIME_ZONE_ID}};static inputDebounceTime=250;constructor(e){super(e),this.debouncedCommitChanges=De(this.commitChanges.bind(this),je.inputDebounceTime),this.handleFormatRuleEntered=this.handleFormatRuleEntered.bind(this),this.handleFormatRuleChange=this.handleFormatRuleChange.bind(this),this.handleFormatRuleCreate=this.handleFormatRuleCreate.bind(this),this.handleFormatRuleDelete=this.handleFormatRuleDelete.bind(this);const{formatter:t,showTimeZone:n,showTSeparator:a,timeZone:r,truncateNumbersWithPound:i}=e,l=t.map((c,d)=>({...c,id:d}));this.containerRef=te.createRef(),this.addFormatRuleButtonRef=te.createRef(),this.lastFormatRuleIndex=l.length,this.state={formatSettings:l,formatRulesChanged:!1,showTimeZone:n,showTSeparator:a,timeZone:r,truncateNumbersWithPound:i,timestampAtMenuOpen:new Date}}componentDidMount(){Fe(this.containerRef.current)}componentWillUnmount(){this.debouncedCommitChanges.flush()}debouncedCommitChanges;containerRef;addFormatRuleButtonRef;lastFormatRuleIndex;isDuplicateRule(e){const{formatSettings:t}=this.state;return t.some(n=>n.id!==e.id&&n.columnName===e.columnName&&n.columnType===e.columnType)??!1}getAutoIncrementFormatRuleIndex(){const{lastFormatRuleIndex:e}=this;return this.lastFormatRuleIndex+=1,e}getCachedColumnTypeOptions=Te(()=>o.jsx(Vo,{}));getCachedDateTimeFormatOptions=Te((e,t,n,a=!1,r)=>{const{timestampAtMenuOpen:i}=this.state;return o.jsx(Gt,{timestamp:i,timeZone:e,showTimeZone:t,showTSeparator:n,isGlobalOptions:a,legacyGlobalFormat:r})});handleFormatRuleChange(e,t,n){this.setState(a=>{const{formatSettings:r}=a;Jn(r);const i=[...r];let l={};t==="columnType"&&(l={format:this.makeDefaultFormatterItemByType(n)});const c={...i[e],...l,[t]:n};return i[e]=c,{formatSettings:i}},()=>{this.debouncedCommitChanges()})}handleFormatRuleCreate(){this.setState(e=>{const{formatSettings:t}=e,n={columnType:D.dataType.DATETIME,columnName:"",format:{},id:this.getAutoIncrementFormatRuleIndex(),isNewRule:!0};return{formatSettings:[...t,n],formatRulesChanged:!0}})}handleFormatRuleDelete(e){this.setState(t=>{const{formatSettings:n}=t;return{formatSettings:n.filter((r,i)=>i!==e),formatRulesChanged:!0}},()=>{this.debouncedCommitChanges()})}handleFormatRuleEntered(e){this.scrollToFormatBlockBottom(),Fe(e)}commitChanges(){const{formatSettings:e,showTimeZone:t,showTSeparator:n,timeZone:a,truncateNumbersWithPound:r}=this.state,{defaultDateTimeFormat:i,defaultDecimalFormatOptions:l,defaultIntegerFormatOptions:c}=this.props,{dh:d}=this.props,h=e.filter(y=>Vt(d,y)).map(Wt)??[],{settings:u,saveSettings:g}=this.props,v={...u,formatter:h,defaultDateTimeFormat:i,showTimeZone:t,showTSeparator:n,timeZone:a,truncateNumbersWithPound:r};G(d,D.dataType.DECIMAL,N.makeCustomFormat(l.defaultFormatString))&&(v.defaultDecimalFormatOptions=l),G(d,D.dataType.INT,R.makeCustomFormat(c.defaultFormatString))&&(v.defaultIntegerFormatOptions=c),g(v)}scrollToFormatBlockBottom(){const{scrollTo:e}=this.props;e(0,(this.addFormatRuleButtonRef.current?.offsetHeight??0)+(this.addFormatRuleButtonRef.current?.offsetTop??0))}getRuleError(e){const{dh:t}=this.props,n={hasColumnNameError:!1,hasFormatError:!1,message:""},a=[];return e.isNewRule!==void 0&&e.isNewRule||(this.isDuplicateRule(e)&&(n.hasColumnNameError=!0,a.push("Duplicate column name/type combo.")),Kt(e.columnName)||(n.hasColumnNameError=!0,a.push("Column names must start with a letter or underscore and contain only alphanumeric characters or underscores.")),e.format.formatString!==void 0&&e.format.formatString.length===0?(n.hasFormatError=!0,a.push("Empty formatting rule.")):G(t,e.columnType,e.format)||(n.hasFormatError=!0,a.push("Invalid formatting rule.")),n.message=a.join(`
2
- `)),n}makeDefaultFormatterItemByType(e){switch(D.getNormalizedType(e)){case D.dataType.INT:{const{defaultIntegerFormatOptions:t}=this.props,{defaultFormatString:n}=t;return R.makeFormat("",n??R.DEFAULT_FORMAT_STRING,R.TYPE_GLOBAL,void 0)}case D.dataType.DECIMAL:{const{defaultDecimalFormatOptions:t}=this.props,{defaultFormatString:n}=t;return N.makeFormat("",n??N.DEFAULT_FORMAT_STRING,N.TYPE_GLOBAL,void 0)}default:return""}}renderFormatRule(e,t){const n=`input-${e}-columnName`,a=`input-${e}-columnType`,r=`input-${e}-format`,i=this.getCachedColumnTypeOptions(),l=u=>this.handleFormatRuleChange(e,"columnName",u.target.value),c=()=>this.handleFormatRuleChange(e,"isNewRule",!1),d=u=>this.handleFormatRuleChange(e,"columnType",u.target.value),h=this.getRuleError(t);return o.jsxs("fieldset",{className:"container-fluid format-rule-container",children:[o.jsxs("div",{className:"form-row",children:[o.jsxs("div",{className:"form-group col-7 mb-2",children:[o.jsx("label",{htmlFor:n,children:"Column Name"}),o.jsx("input",{id:n,className:j("form-control",{"is-invalid":h.hasColumnNameError}),"data-lpignore":!0,type:"text",value:t.columnName,onChange:l,onBlur:c})]}),o.jsxs("div",{className:"form-group col mb-2",children:[o.jsx(w,{kind:"ghost",className:"btn-delete-format-rule float-right",tabIndex:-1,onClick:()=>this.handleFormatRuleDelete(e),icon:Xn,tooltip:"Delete","aria-label":"Delete Format Rule"}),o.jsx("label",{htmlFor:a,children:"Column Type"}),o.jsx("select",{id:a,className:"custom-select",value:t.columnType,onChange:d,children:i})]})]}),o.jsx("div",{className:"form-row",children:o.jsxs("div",{className:"form-group col-12 d-flex mb-2",children:[o.jsx("label",{className:"flex-shrink-0 col-form-label mr-3",htmlFor:r,children:"Formatting Rule"}),this.renderFormatRuleInput(e,t.columnType,r,t.format,h.hasFormatError)]})}),o.jsx("div",{className:"form-row",children:o.jsx("div",{className:"form-group col-12 d-flex mb-2",children:h.message&&o.jsx("p",{className:"text-danger",children:h.message})})})]},e)}renderFormatRuleInput(e,t,n,a,r){switch(D.getNormalizedType(t)){case D.dataType.DATETIME:return this.renderDateTimeFormatRuleInput(e,n,a,r);case D.dataType.DECIMAL:return this.renderDecimalFormatRuleInput(e,n,a,r);case D.dataType.INT:return this.renderIntegerFormatRuleInput(e,n,a,r);default:throw new Error(`Unrecognized column type: ${t}`)}}renderDateTimeFormatRuleInput(e,t,n,a){const{showTimeZone:r,showTSeparator:i,timeZone:l}=this.state,c=n.formatString??"";return o.jsxs("select",{className:j("custom-select",{"is-invalid":a}),value:c,id:t,onChange:d=>{const h=L.makeFormat("",d.target.value,L.TYPE_GLOBAL);this.handleFormatRuleChange(e,"format",h)},children:[o.jsx("option",{value:"",disabled:!0,children:"Select format"},"default"),this.getCachedDateTimeFormatOptions(l,r,i)]})}renderIntegerFormatRuleInput(e,t,n,a){const{defaultIntegerFormatOptions:r}=this.props,{defaultFormatString:i}=r,l=n.formatString??"";return o.jsx("input",{className:j("form-control","flex-grow-1",{"is-invalid":a}),"data-lpignore":!0,id:t,placeholder:i??R.DEFAULT_FORMAT_STRING,type:"text",value:l,onChange:c=>{const d=R.makeFormat("",c.target.value,R.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(e,"format",d)}})}renderDecimalFormatRuleInput(e,t,n,a){const{defaultDecimalFormatOptions:r}=this.props,{defaultFormatString:i}=r,l=n.formatString??"";return o.jsx("input",{className:j("form-control","flex-grow-1",{"is-invalid":a}),"data-lpignore":!0,id:t,placeholder:i??N.DEFAULT_FORMAT_STRING,type:"text",value:l,onChange:c=>{const d=N.makeFormat("",c.target.value,N.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(e,"format",d)}})}render(){const{formatRulesChanged:e,formatSettings:t}=this.state,n=t.map((r,i)=>o.jsx(Tt,{classNames:"fade",timeout:le.transitionMs,onEnter:this.handleFormatRuleEntered,children:this.renderFormatRule(i,r)},r.id)),a=o.jsx(w,{kind:"ghost",className:"mb-3",onClick:this.handleFormatRuleCreate,ref:this.addFormatRuleButtonRef,icon:Qn,children:"Add New Rule"});return o.jsxs("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:[o.jsx("div",{className:"app-settings-menu-description mb-3",children:"Customize the formatting of table columns by applying rules based on matching both a column name and column type."}),o.jsx(nn,{appear:e,enter:e,exit:e,children:n}),a]})}}const Go=s=>({formatter:Ct(s),defaultDateTimeFormat:wt(s),defaultDecimalFormatOptions:Ft(s),defaultIntegerFormatOptions:Dt(s),dh:xt(s),showTimeZone:Et(s),showTSeparator:Rt(s),truncateNumbersWithPound:Nt(s),timeZone:jt(s),settings:Ee(s)}),Bo=ne(Go,{saveSettings:xe})(je);class M extends m.Component{static defaultProps={onDone:()=>{}};static FORMATTING_SECTION_KEY="SettingsMenu.formatting";static COLUMN_SPECIFIC_SECTION_KEY="SettingsMenu.columnFormatting";static APPLICATION_SECTION_KEY="ApplicationMenu.settings";static SHORTCUT_SECTION_KEY="SettingsMenu.shortcuts";static focusFirstInputInContainer(e){const t=e?.querySelector("input, select, textarea");t&&t.focus()}constructor(e){super(e),this.handleClose=this.handleClose.bind(this),this.handleScrollTo=this.handleScrollTo.bind(this),this.handleSectionToggle=this.handleSectionToggle.bind(this),this.handleExportSupportLogs=this.handleExportSupportLogs.bind(this),this.handleLogout=this.handleLogout.bind(this),this.menuContentRef=te.createRef(),this.broadcastChannel=new BroadcastChannel(_s),this.state={expandedSectionKey:M.FORMATTING_SECTION_KEY}}componentDidMount(){M.focusFirstInputInContainer(this.menuContentRef.current)}componentWillUnmount(){this.broadcastChannel.close()}menuContentRef;broadcastChannel;isSectionExpanded(e){const{expandedSectionKey:t}=this.state;return t===e}handleLogout(){this.broadcastChannel.postMessage(Ms(Us))}handleScrollTo(e,t){this.menuContentRef.current?.scrollTo(e,t)}handleSectionToggle(e){this.setState(t=>({expandedSectionKey:t.expandedSectionKey===e?void 0:e}))}handleClose(){const{onDone:e}=this.props;e()}handleExportSupportLogs(){const{serverConfigValues:e}=this.props;Ko(void 0,Object.fromEntries(e))}render(){const e="0.52.0",t="https://github.com/deephaven/web-client-ui/",n="https://deephaven.io/core/docs/",{serverConfigValues:a,user:r}=this.props,i=a.get("barrage.version"),l=a.get("java.version"),c=a.get("deephaven.version"),d=(v,y)=>o.jsxs(o.Fragment,{children:[o.jsx("div",{children:v}),o.jsx("div",{children:y})]}),h=r.displayName??r.name,u=r.image!=null&&r.image!=="",g=h!=="";return o.jsxs("div",{className:"app-settings-menu",children:[o.jsxs("header",{className:"app-settings-menu-header",children:[o.jsxs("div",{className:"user-info",children:[o.jsxs("div",{className:"user-image",children:[!u&&o.jsx(E,{icon:es,transform:"grow-8"}),u&&o.jsx("img",{src:r.image,alt:h})]}),o.jsxs("div",{className:"user-details",children:[g&&o.jsxs("div",{className:"user-name",children:[h,r.operateAs!=null&&r.name!==r.operateAs&&o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"font-weight-light font-italic",children:[" ","as"," "]}),o.jsxs("span",{className:"operating-as-user",children:[o.jsx(E,{icon:ts,className:"mr-1"}),r.operateAs]})]})]}),r.permissions.canLogout&&o.jsx("button",{type:"button",className:"btn btn-link",onClick:this.handleLogout,children:"logout"})]})]}),o.jsx(w,{kind:"ghost",className:"btn-close-settings-menu",onClick:this.handleClose,icon:o.jsx(E,{icon:ns,transform:"grow-4"}),tooltip:"Close"})]}),o.jsxs("div",{className:"app-settings-menu-content",ref:this.menuContentRef,children:[o.jsx("h5",{children:"Settings"}),o.jsx("hr",{className:"my-0"}),o.jsx(ee,{sectionKey:M.FORMATTING_SECTION_KEY,isExpanded:this.isSectionExpanded(M.FORMATTING_SECTION_KEY),title:o.jsxs(o.Fragment,{children:[o.jsx(E,{icon:ss,transform:"grow-4",className:"mr-2"}),"Default Format & Time zone"]}),onToggle:this.handleSectionToggle,children:o.jsx(jo,{})}),o.jsx(ee,{sectionKey:M.COLUMN_SPECIFIC_SECTION_KEY,isExpanded:this.isSectionExpanded(M.COLUMN_SPECIFIC_SECTION_KEY),title:o.jsxs(o.Fragment,{children:[o.jsx(E,{icon:os,transform:"grow-4",className:"mr-2"}),"Format by Column Name & Type"]}),onToggle:this.handleSectionToggle,children:o.jsx(Bo,{scrollTo:this.handleScrollTo})}),o.jsx(ee,{sectionKey:M.SHORTCUT_SECTION_KEY,isExpanded:this.isSectionExpanded(M.SHORTCUT_SECTION_KEY),title:o.jsxs(o.Fragment,{children:[o.jsx(E,{icon:as,transform:"grow-2"})," ","Keyboard Shortcuts"]}),onToggle:this.handleSectionToggle,children:o.jsx(_o,{})}),o.jsxs("div",{className:"app-settings-footer",children:[o.jsxs("div",{className:"app-settings-footer-section",children:[o.jsxs("div",{className:"app-settings-footer-item",children:[o.jsx("div",{className:"font-weight-bold",children:"Support"}),o.jsxs("div",{children:["GitHub: ",o.jsx("a",{href:t,className:"custom-link",target:"_blank",rel:"noopener noreferrer",children:t})]}),o.jsx(w,{kind:"tertiary",className:"mt-2 py-2",onClick:this.handleExportSupportLogs,children:"Export Logs"})]}),o.jsxs("div",{className:"app-settings-footer-item",children:[o.jsx("div",{className:"font-weight-bold",children:"Documentation"}),o.jsx("a",{target:"_blank",rel:"noreferrer noopener",href:n,className:"custom-link",children:n})]}),o.jsxs("div",{className:"app-settings-footer-item",children:[o.jsx("div",{className:"font-weight-bold",children:"Version"}),o.jsxs("span",{className:"d-inline-block text-muted",children:[c," ",o.jsx(E,{icon:rs}),o.jsxs(kt,{interactive:!0,children:[o.jsxs("div",{className:"detailed-server-config",children:[d("Engine Version",c),d("Web UI Version",e),d("Java Version",l),d("Barrage Version",i)]}),o.jsx(Fs,{tooltip:"Copy version numbers",copy:`Engine Version: ${c}
1
+ import{r as m,I as vt,C as o,P as yt,J as tn,K as De,H as te,L as Te,F as j,M as ne,N as b,G as E,O as St,D as Tt,T as nn,Q as sn,S as on,U as an,V as rn,W as We,X as ln,Y as cn}from"./vendor-9bc0b4ef.js";import{W as dn}from"./monaco-1410cbed.js";import{L as un,a as hn,D as mn,P as pn,s as xe,g as Ct,b as wt,c as Ft,d as Dt,e as xt,f as Et,h as Rt,i as Nt,j as jt,k as Ee,l as fn,m as Ot,C as V,T as de,r as gn,n as bn,O as vn,o as Ve,p as Ge,q as Be,F as Ze,t as It,u as yn,v as Sn,w as Tn,x as Cn,y as wn,z as Fn,A as He,B as Dn,E as Lt,G as ze,N as xn,I as ae,M as En,H as Rn,J as U,K as Nn,Q as jn,R as H,S as On,U as In,V as Ln,W as Pn,X as kn,Y as An,Z as _n,_ as Mn,$ as Un,a0 as $n,a1 as Kn,a2 as Wn,a3 as Vn,a4 as Gn}from"./ControlType-19f7d4f3.js";import{L as k,v as z,a as Bn,M as Zn,b as Hn,c as zn,d as Yn,l as qn,e as Jn,f as Xn,T as le,g as Qn,h as es,i as ts,j as ns,k as ss,m as os,n as as,o as rs,p as is,q as ls,r as cs,s as ds,t as us,u as hs,w as Ye,x as qe,y as Je,z as ms,A as ps,B as fs,C as gs,D as bs,E as Xe,F as vs,G as ys}from"./index-81fc0d6a.js";import{O as ue,P as K,T as A,D as Ss,I as R,a as N,b as L,u as Pt,F as Ts,c as D,d as Cs,B as w,C as fe,S as _,e as Re,f as kt,K as ws,g as Qe,h as Fs,G as Ce,i as At,j as Ds,k as xs,l as Es,m as Rs,n as Ns,o as et,p as js,q as tt,r as Os,s as Is,t as Ls,v as Ps,M as ks}from"./PluginTypes-2b0ef082.js";import{C as As,B as _s,m as Ms,a as Us,D as $s,I as Ks,u as Ws,b as Vs,c as Gs,g as Bs,l as Zs}from"./useUser-da266903.js";import"./helpers-042e6b4d.js";import"./plotly-26031571.js";function nt(s,e){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(s,a).enumerable})),t.push.apply(t,n)}return t}function Hs(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?nt(Object(t),!0).forEach(function(n){zs(s,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):nt(Object(t)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(t,n))})}return s}function zs(s,e,t){return e=Ys(e),e in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function Ys(s){var e=qs(s,"string");return typeof e=="symbol"?e:String(e)}function qs(s,e){if(typeof s!="object"||s===null)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var n=t.call(s,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(s)}var Js=100,ge=()=>{},Xs=Object.freeze({});function Qs(s){var{id:e="default",children:t,emptyDashboard:n,layoutConfig:a,layoutSettings:r=Xs,onLayoutConfigChange:i=ge,onGoldenLayoutChange:l=ge,onLayoutInitialized:c=ge,fallbackComponent:d=pn,hydrate:h,dehydrate:u,panelWrapper:g}=s,v=m.useRef(null),[y,x]=m.useState(!1),[T,S]=m.useState();m.useEffect(function(){if(!v.current){S(void 0);return}var p=Hs({},un.makeDefaultLayout());p.settings===void 0&&(p.settings={}),Object.assign(p.settings,r),p.content=[];var f=new hn(p,v.current),se=()=>{f.off("initialised",se),x(!0)};return f.on("initialised",se),d!=null&&f.setFallbackComponent(d),f.init(),S(f),l(f),()=>{f.destroy()}},[r,d,l,x,S]);var O=m.useMemo(()=>vt(()=>{T!=null&&T.isInitialised&&T?.updateSize()},Js),[T]);return m.useEffect(function(){return window.addEventListener("resize",O),()=>{window.removeEventListener("resize",O)}},[O]),o.jsxs("div",{className:"dashboard-container w-100 h-100",children:[o.jsx("div",{className:"w-100 h-100",ref:v}),y&&T&&o.jsx(mn,{emptyDashboard:n,id:e,layout:T,layoutConfig:a,onLayoutChange:i,onLayoutInitialized:c,hydrate:h,dehydrate:u,panelWrapper:g,children:t})]})}class st{static makeSortConfig(e,t){return{column:e,direction:t}}static makeFilterConfig(e){var t=[],n=[];return e.forEach((a,r)=>{t.push(a),r>0&&n.push(ue.and)}),{filterItems:t,filterOperators:n}}static combineFilterConfigs(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ue.and;return{filterItems:[...e.filterItems,...t.filterItems],filterOperators:[...e.filterOperators,n,...t.filterOperators]}}static makeFilterItem(e,t,n){return{columnName:e,type:t,value:n}}}function eo(s,e,t){if(s.length>e){var n=s.length-t;return{toKeep:s.slice(n),toPrune:s.slice(0,n)}}return{toKeep:s,toPrune:[]}}function ot(s,e){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(s,a).enumerable})),t.push.apply(t,n)}return t}function at(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ot(Object(t),!0).forEach(function(n){I(s,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):ot(Object(t)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(t,n))})}return s}function rt(s,e,t,n,a,r,i){try{var l=s[r](i),c=l.value}catch(d){t(d);return}l.done?e(c):Promise.resolve(c).then(n,a)}function $(s){return function(){var e=this,t=arguments;return new Promise(function(n,a){var r=s.apply(e,t);function i(c){rt(r,n,a,i,l,"next",c)}function l(c){rt(r,n,a,i,l,"throw",c)}i(void 0)})}}function I(s,e,t){return e=to(e),e in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function to(s){var e=no(s,"string");return typeof e=="symbol"?e:String(e)}function no(s,e){if(typeof s!="object"||s===null)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var n=t.call(s,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(s)}var be=k.module("PouchStorageTable"),so="Deephaven.";yt.plugin(tn);function oo(s,e){switch(s){case A.in:case A.contains:return{$regex:new RegExp("".concat(e))};case A.inIgnoreCase:return{$regex:new RegExp("".concat(e),"i")};case A.eq:return{$eq:e};case A.notEq:return{$neq:e};case A.greaterThan:return{$gt:e};case A.greaterThanOrEqualTo:return{$gte:e};case A.lessThan:return{$lt:e};case A.lessThanOrEqualTo:return{$lte:e};case A.startsWith:return{$regex:new RegExp("^(?".concat(e,").*"))};default:throw new Error("Unsupported type: ".concat(s))}}function ao(s){for(var{filterItems:e,filterOperators:t}=s,n=null,a=0;a<e.length;a+=1){var r=e[a],{columnName:i,type:l,value:c}=r,d={[i]:oo(l,c)};if(a===0)n=d;else if(n!==null&&a-1<t.length){var h=t[a-1];if(h===ue.and)n={$and:[n,d]};else if(h===ue.or)n={$or:[n,d]};else throw new Error("Unexpected filter operator ".concat(h,", ").concat(d))}}if(n==null)throw new Error("Invalid filter config ".concat(s));return n}function ve(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return{$and:[...s.map(e=>ao(e)),{name:{$gt:null}},{id:{$gt:null}}]}}function ro(s){var e,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return[{id:t?"desc":"asc"},...(e=s?.map(n=>({[n.column]:n.direction})))!==null&&e!==void 0?e:[]]}class io{constructor(e,t){I(this,"db",void 0),I(this,"changes",void 0),I(this,"listeners",[]),I(this,"itemListeners",new Map),I(this,"currentSize",0),I(this,"currentViewport",void 0),I(this,"currentReverse",!1),I(this,"currentFilter",null),I(this,"currentSort",null),I(this,"infoUpdatePromise",void 0),I(this,"viewportUpdatePromise",void 0),I(this,"currentViewportData",void 0),this.db=new yt("".concat(so).concat(e),t),this.db._remote=!1,this.listenForChanges(),this.db.createIndex({index:{fields:["id","name"]}}),this.refreshInfo()}listenForChanges(){this.changes=this.db.changes({live:!0,since:"now",include_docs:!0}).on("change",this.dbUpdate.bind(this))}onUpdate(e){return this.listeners=[...this.listeners,e],()=>{this.listeners=this.listeners.filter(t=>t!==e)}}onItemUpdate(e,t){return this.itemListeners.has(e)||this.itemListeners.set(e,[]),this.itemListeners.set(e,[...this.itemListeners.get(e),t]),this.refreshItem(e),()=>{this.itemListeners.set(e,this.itemListeners.get(e).filter(n=>n!==t))}}close(){this.listeners=[]}get size(){return this.currentSize}get viewport(){return this.currentViewport}setReversed(e){this.currentReverse=e,this.currentViewportData=void 0,this.refreshData()}setViewport(e){this.currentViewport=e,this.refreshInfo(),this.refreshData()}setSorts(e){this.currentSort=e,this.currentViewportData=void 0,this.refreshData()}setFilters(e){this.currentFilter=e,this.currentViewportData=void 0,this.refreshInfo(),this.refreshData()}get data(){return this.currentViewportData}getViewportData(){var e=this;return $(function*(){var t;return e.viewportUpdatePromise||e.refreshData(),(t=e.viewportUpdatePromise)!==null&&t!==void 0?t:Promise.resolve({items:[],offset:0})})()}put(e){var t=this;return $(function*(){var n=at(at({},e),{},{_id:e.id});return yield t.db.put(n),n})()}sendUpdate(){for(var e,{listeners:t}=this,n=(e=this.currentViewportData)!==null&&e!==void 0?e:{items:[],offset:0},a=0;a<t.length;a+=1)t[a](n)}sendItemUpdate(e){var t=this.itemListeners.get(e.id);if(t!==void 0)for(var n=0;n<t.length;n+=1)t[n](e)}dbUpdate(e){be.debug("Update received",e),this.refreshInfo(),e.doc!==void 0&&this.sendItemUpdate(e.doc),this.refreshData()}fetchInfo(e){var t=this;return $(function*(){return t.db.find({selector:e,fields:[]})})()}refreshInfo(){var e=this;return $(function*(){try{var t,n;(t=e.infoUpdatePromise)===null||t===void 0||t.cancel(),e.infoUpdatePromise=K.makeCancelable(e.fetchInfo(ve((n=e.currentFilter)!==null&&n!==void 0?n:[])));var a=yield e.infoUpdatePromise;e.currentSize=a.docs.length,e.sendUpdate()}catch(r){if(!K.isCanceled(r))throw be.error("Unable to refreshInfo",r),r}})()}fetchViewportData(e,t,n){var a=this;return $(function*(){return a.db.find({selector:t,skip:e.top,limit:e.bottom-e.top+1,sort:n,fields:["id","name"]}).then(r=>({items:r.docs,offset:e.top}))})()}refreshData(){var e=this;return $(function*(){if(e.currentViewport)try{var t,n,a=ve((t=e.currentFilter)!==null&&t!==void 0?t:[]),r=ro(e.currentSort,e.currentReverse);(n=e.viewportUpdatePromise)===null||n===void 0||n.cancel(),e.viewportUpdatePromise=K.makeCancelable(e.fetchViewportData(e.currentViewport,a,r));var i=yield e.viewportUpdatePromise;return e.currentViewportData=i,e.sendUpdate(),i}catch(l){if(!K.isCanceled(l))throw be.error("Unable to refreshData",l),l}})()}refreshItem(e){var t=this;return $(function*(){var n=yield t.db.find({selector:{id:e},limit:1}),a=n.docs[0];return a!==void 0&&t.sendItemUpdate(a),a})()}getSnapshot(e){var t=this;return $(function*(){var n=new Map,a=[{id:t.currentReverse?"desc":"asc"}];return yield Promise.all(e.map(function(){var r=$(function*(i){var l,[c,d]=i,h=d-c+1;return t.db.find({selector:ve((l=t.currentFilter)!==null&&l!==void 0?l:[]),skip:c,limit:h,sort:a,fields:["id","name"]}).then(u=>{for(var g=0;g<h;g+=1){var v=c+g;n.set(v,u.docs[g])}})});return function(i){return r.apply(this,arguments)}}())),n})()}}const lo=io;function it(s,e){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(s,a).enumerable})),t.push.apply(t,n)}return t}function re(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?it(Object(t),!0).forEach(function(n){_t(s,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):it(Object(t)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(t,n))})}return s}function lt(s,e,t,n,a,r,i){try{var l=s[r](i),c=l.value}catch(d){t(d);return}l.done?e(c):Promise.resolve(c).then(n,a)}function X(s){return function(){var e=this,t=arguments;return new Promise(function(n,a){var r=s.apply(e,t);function i(c){lt(r,n,a,i,l,"next",c)}function l(c){lt(r,n,a,i,l,"throw",c)}i(void 0)})}}function _t(s,e,t){return e=co(e),e in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function co(s){var e=uo(s,"string");return typeof e=="symbol"?e:String(e)}function uo(s,e){if(typeof s!="object"||s===null)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var n=t.call(s,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(s)}var ho=2500,mo=2e3,P=k.module("PouchCommandHistoryTable");class po extends lo{constructor(e,t){var n;super("CommandHistoryStorage.".concat(e),{auto_compaction:!0,revs_limit:1}),_t(this,"searchText",void 0),this.cache=t,this.cache.tableRegistry.has(this.cacheKey)||this.cache.tableRegistry.set(this.cacheKey,new Set),P.debug("Adding table to registry",this.cacheKey),(n=this.cache.tableRegistry.get(this.cacheKey))===null||n===void 0||n.add(this)}get cacheKey(){return this.db.name}setSearch(e){P.debug("Setting search filters",e),this.searchText=e.trim().toLowerCase(),this.setFilters(e?[st.makeFilterConfig([st.makeFilterItem("name",A.contains,e)])]:[])}dbUpdate(e){P.debug("Clearing cache and refreshing data",e),this.cache.response.delete(this.cacheKey),super.dbUpdate(e)}fetchData(e){var t=this;return X(function*(){return K.withTimeout(0,X(function*(){t.cache.response.has(t.cacheKey)?P.debug("Fetching from cache",t.searchText,t.viewport):(P.debug("Fetching from PouchDB",t.searchText,t.viewport),t.cache.response.set(t.cacheKey,t.db.allDocs({include_docs:!0}).then(a=>{var r=a.rows.map(c=>c.doc).filter(c=>{var{name:d}=c;return d});P.debug("Fetched ".concat(r.length," command history items"));var{toKeep:i,toPrune:l}=eo(r,ho,mo);return l.length&&t.pruneItems(l),{docs:i}})));var n=t.cache.response.get(t.cacheKey);return t.searchText==null||t.searchText===""?n:re(re({},n),{},{docs:(yield n).docs.filter(a=>{var{name:r}=a;return r.toLowerCase().includes(t.searchText)})})}))})()}fetchInfo(e){var t=this;return X(function*(){return t.fetchData(e)})()}fetchViewportData(e,t,n){var a=this;return X(function*(){var r=yield a.fetchData(t);P.debug("Fetching viewport data",e.top,e.bottom+1,n,r);var i=typeof n[0]=="object"&&n[0].id==="desc",l=i?r.docs.slice(0).reverse():r.docs,c=l.slice(e.top,e.bottom+1);return{items:c,offset:e.top}})()}pruneItems(e){var t=this;return X(function*(){if(t.cache.isPruning.get(t.cacheKey)===!0){P.debug("Pruning already in progress. Skipping.");return}try{P.debug("Pruning ".concat(e.length," command history items"));var n=t.cache.pauseChangeListeners(t.cacheKey);t.cache.isPruning.set(t.cacheKey,!0),yield t.db.bulkDocs(e.map(a=>re(re({},a),{},{_deleted:!0}))),t.cache.isPruning.set(t.cacheKey,!1),n(),P.debug("Finished pruning command history items")}catch(a){P.error("An error occurred while pruning db",a)}})()}close(){var e,t,n;P.debug("Closing table",this,(e=this.cache.tableRegistry.get(this.cacheKey))===null||e===void 0?void 0:e.size),(t=this.cache.tableRegistry.get(this.cacheKey))===null||t===void 0||t.delete(this),(n=this.changes)===null||n===void 0||n.cancel(),super.close()}}const ct=po;function ye(s,e,t){return e=fo(e),e in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function fo(s){var e=go(s,"string");return typeof e=="symbol"?e:String(e)}function go(s,e){if(typeof s!="object"||s===null)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var n=t.call(s,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(s)}var dt=k.module("PouchCommandHistoryCache");class bo{constructor(){ye(this,"isPruning",void 0),ye(this,"response",void 0),ye(this,"tableRegistry",void 0),this.isPruning=new Map,this.response=new Map,this.tableRegistry=new Map}pauseChangeListeners(e){var t,n=[];return(t=this.tableRegistry.get(e))===null||t===void 0||t.forEach(a=>{a.changes&&(dt.debug("Pausing event listeners on '".concat(e,"' table"),a),a.changes.cancel(),n.push(a))}),()=>{n.forEach(a=>{var r,i;(r=(i=this.tableRegistry.get(e))===null||i===void 0?void 0:i.has(a))!==null&&r!==void 0&&r&&(dt.debug("Resuming event listeners on '".concat(e,"' table"),a),a.listenForChanges())})}}}const vo=bo;function ut(s,e){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(s,a).enumerable})),t.push.apply(t,n)}return t}function ht(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ut(Object(t),!0).forEach(function(n){we(s,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):ut(Object(t)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(t,n))})}return s}function mt(s,e,t,n,a,r,i){try{var l=s[r](i),c=l.value}catch(d){t(d);return}l.done?e(c):Promise.resolve(c).then(n,a)}function Se(s){return function(){var e=this,t=arguments;return new Promise(function(n,a){var r=s.apply(e,t);function i(c){mt(r,n,a,i,l,"next",c)}function l(c){mt(r,n,a,i,l,"throw",c)}i(void 0)})}}function we(s,e,t){return e=yo(e),e in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function yo(s){var e=So(s,"string");return typeof e=="symbol"?e:String(e)}function So(s,e){if(typeof s!="object"||s===null)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var n=t.call(s,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(s)}var pt=k.module("PouchCommandHistoryStorage");class To{constructor(){we(this,"cache",new vo),we(this,"updateTableMap",new Map)}getUpdateTable(e){return this.updateTableMap.has(e)||this.updateTableMap.set(e,new ct(e,this.cache)),this.updateTableMap.get(e)}getTable(e){var t=this;return Se(function*(){return new ct(e,t.cache)})()}addItem(e,t,n,a){var r=this;return Se(function*(){return r.updateItem(e,{id:"".concat(new Date().getTime()),name:n,data:a})})()}updateItem(e,t){var n=this;return Se(function*(){var a=n.getUpdateTable(e),r=yield a.refreshItem(t.id),i=ht(ht({},r??{}),t);return pt.debug("Updating item",i),yield a.put(i),pt.debug("Update saved"),t})()}listenItem(e,t,n){var a=this.getUpdateTable(e);return a.onItemUpdate(t,n)}}const Mt="SET_LAYOUT_STORAGE",Co=s=>({type:Mt,payload:s});var{dh:wo}=globalThis;const W=wo,Ut=""+new URL("community-wordmark-app-d2c5c1eb.svg",import.meta.url).href;const Fo=k.module("SettingsUtils");function Do(s){return s.formatString!=null}function Fe(s){const e=s?.querySelector("input, select, textarea");e&&e.focus()}function $t(s,e){return s.defaultFormatString===e.defaultFormatString}function xo(s,e){return $t(s,e)}function Eo(s,e){return $t(s,e)}function Kt(s){return s!==""&&Ss.isValidColumnName(s)}function G(s,e,t){if(!e||t.formatString==null||!Do(t))return!1;switch(e){case"datetime":return L.isValid(s,t);case"decimal":return N.isValid(s,t);case"int":return R.isValid(s,t);default:return Fo.warn("Trying to validate format of unknown type"),!0}}function Wt(s){const{id:e,isNewRule:t,...n}=s;return n}function Vt(s,e){return Kt(e.columnName)&&G(s,e.columnType,e.format)}function Gt(s){const{timestamp:e,timeZone:t,showTimeZone:n,showTSeparator:a,isGlobalOptions:r,legacyGlobalFormat:i}=s,l=Pt(),c=m.useMemo(()=>new Ts(l,[],{timeZone:t,showTimeZone:n,showTSeparator:a}),[l,n,a,t]),d=r?L.getGlobalFormats(n,a):L.getFormats(n,a);return i!=null&&!d.includes(i)&&d.unshift(i),o.jsx(o.Fragment,{children:d.map(h=>{const u=L.makeFormat("",h,L.TYPE_GLOBAL);return o.jsx("option",{value:h,"data-testid":"time-format",children:c.getFormattedString(e,D.dataType.DATETIME,"",u)},h)})})}function Ro(){return o.jsx(o.Fragment,{children:Cs.TIME_ZONES.map(s=>{const{label:e,value:t}=s;return o.jsx("option",{value:t,children:e},t)})})}const Z=k.module("FormattingSectionContent");class Ne extends m.PureComponent{static defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:L.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:N.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:R.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:L.DEFAULT_TIME_ZONE_ID}};static inputDebounceTime=250;constructor(e){super(e),this.debouncedCommitChanges=De(this.commitChanges.bind(this),Ne.inputDebounceTime),this.handleDefaultDateTimeFormatChange=this.handleDefaultDateTimeFormatChange.bind(this),this.handleDefaultDecimalFormatChange=this.handleDefaultDecimalFormatChange.bind(this),this.handleDefaultIntegerFormatChange=this.handleDefaultIntegerFormatChange.bind(this),this.handleShowTimeZoneChange=this.handleShowTimeZoneChange.bind(this),this.handleShowTSeparatorChange=this.handleShowTSeparatorChange.bind(this),this.handleTimeZoneChange=this.handleTimeZoneChange.bind(this),this.handleResetDateTimeFormat=this.handleResetDateTimeFormat.bind(this),this.handleResetDecimalFormat=this.handleResetDecimalFormat.bind(this),this.handleResetIntegerFormat=this.handleResetIntegerFormat.bind(this),this.handleResetTimeZone=this.handleResetTimeZone.bind(this),this.handleTruncateNumbersWithPoundChange=this.handleTruncateNumbersWithPoundChange.bind(this);const{formatter:t,defaultDateTimeFormat:n,defaultDecimalFormatOptions:a,defaultIntegerFormatOptions:r,showTimeZone:i,showTSeparator:l,timeZone:c,truncateNumbersWithPound:d}=e,h=t.map((u,g)=>({...u,id:g}));this.containerRef=te.createRef(),this.state={formatSettings:h,showTimeZone:i,showTSeparator:l,timeZone:c,defaultDateTimeFormat:n,defaultDecimalFormatOptions:a,defaultIntegerFormatOptions:r,truncateNumbersWithPound:d,timestampAtMenuOpen:new Date}}componentDidMount(){Fe(this.containerRef.current)}componentWillUnmount(){this.debouncedCommitChanges.flush()}debouncedCommitChanges;containerRef;getCachedDateTimeFormatOptions=Te((e,t,n,a=!1,r)=>{const{timestampAtMenuOpen:i}=this.state;return o.jsx(Gt,{timestamp:i,timeZone:e,showTimeZone:t,showTSeparator:n,isGlobalOptions:a,legacyGlobalFormat:r})});handleDefaultDateTimeFormatChange(e){Z.debug("handleDefaultDateTimeFormatChange",e.target.value),this.setState({defaultDateTimeFormat:e.target.value},()=>{this.debouncedCommitChanges()})}handleDefaultDecimalFormatChange(e){Z.debug("handleDefaultDecimalFormatChange",e.target.value),this.setState({defaultDecimalFormatOptions:{defaultFormatString:e.target.value}},()=>{this.debouncedCommitChanges()})}handleDefaultIntegerFormatChange(e){Z.debug("handleDefaultIntegerFormatChange",e.target.value),this.setState({defaultIntegerFormatOptions:{defaultFormatString:e.target.value}},()=>{this.debouncedCommitChanges()})}handleShowTimeZoneChange(){this.setState(e=>({showTimeZone:!e.showTimeZone}),()=>{this.debouncedCommitChanges()})}handleShowTSeparatorChange(){this.setState(e=>({showTSeparator:!e.showTSeparator}),()=>{this.debouncedCommitChanges()})}handleTimeZoneChange(e){this.setState({timeZone:e.target.value},()=>{this.debouncedCommitChanges()})}handleResetDateTimeFormat(){const{defaults:e}=this.props,{defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:a}=e;Z.debug("handleResetDateTimeFormat"),this.setState({defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:a},()=>{this.debouncedCommitChanges()})}handleResetTimeZone(){const{defaults:e}=this.props,{timeZone:t}=e;Z.debug("handleResetTimeZone"),this.setState({timeZone:t},()=>{this.debouncedCommitChanges()})}handleResetDecimalFormat(){const{defaults:e}=this.props,{defaultDecimalFormatOptions:t}=e;Z.debug("handleResetDecimalFormat"),this.setState({defaultDecimalFormatOptions:t},()=>{this.debouncedCommitChanges()})}handleResetIntegerFormat(){const{defaults:e}=this.props,{defaultIntegerFormatOptions:t}=e;Z.debug("handleResetIntegerFormat"),this.setState({defaultIntegerFormatOptions:t},()=>{this.debouncedCommitChanges()})}handleTruncateNumbersWithPoundChange(){this.setState(e=>({truncateNumbersWithPound:!e.truncateNumbersWithPound}),()=>{this.debouncedCommitChanges()})}commitChanges(){const{formatSettings:e,defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:a,timeZone:r,defaultDecimalFormatOptions:i,defaultIntegerFormatOptions:l,truncateNumbersWithPound:c}=this.state,{dh:d}=this.props,h=e.filter(y=>Vt(d,y)).map(Wt)??[],{settings:u,saveSettings:g}=this.props,v={...u,formatter:h,defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:a,timeZone:r,truncateNumbersWithPound:c};G(d,D.dataType.DECIMAL,N.makeCustomFormat(i.defaultFormatString))&&(v.defaultDecimalFormatOptions=i),G(d,D.dataType.INT,R.makeCustomFormat(l.defaultFormatString))&&(v.defaultIntegerFormatOptions=l),g(v)}render(){const{defaults:e,dh:t}=this.props,{defaultDateTimeFormat:n,defaultDecimalFormatOptions:a,defaultIntegerFormatOptions:r,timeZone:i,showTimeZone:l,showTSeparator:c,truncateNumbersWithPound:d}=this.state,{defaultFormatString:h=N.DEFAULT_FORMAT_STRING}=a??{},{defaultFormatString:u=R.DEFAULT_FORMAT_STRING}=r??{},g=i===e.timeZone,v=c===e.showTSeparator&&l===e.showTimeZone&&n===e.defaultDateTimeFormat,y=xo(a,e.defaultDecimalFormatOptions),x=Eo(r,e.defaultIntegerFormatOptions);return o.jsx("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:o.jsxs("div",{className:"container-fluid p-0",children:[o.jsx("div",{className:"app-settings-menu-description mb-3",children:"Choose the default formatting rule to apply to all table columns based on their type."}),o.jsxs("div",{className:"form-row mb-2",children:[o.jsx("label",{className:"col-form-label col-3",htmlFor:"select-reset-timezone",children:"Time zone"}),o.jsx("div",{className:"col pr-0",children:o.jsx("select",{className:"custom-select",value:i,onChange:this.handleTimeZoneChange,id:"select-reset-timezone",children:o.jsx(Ro,{})})}),o.jsx("div",{className:"col-1 btn-col",children:o.jsx(w,{kind:"ghost",icon:z,onClick:this.handleResetTimeZone,tooltip:"Reset Time Zone",className:j("btn-reset","btn-reset-time-zone",{hidden:g})})})]}),o.jsxs("div",{className:"form-row mb-2",children:[o.jsx("label",{className:"col-form-label col-3",htmlFor:"select-default-time-format",children:"DateTime"}),o.jsx("div",{className:"col pr-0",children:o.jsx("select",{className:"custom-select",value:n,onChange:this.handleDefaultDateTimeFormatChange,id:"select-default-time-format",children:this.getCachedDateTimeFormatOptions(i,l,c,!0,n)})}),o.jsx("div",{className:"col-1 btn-col",children:o.jsx(w,{kind:"ghost",icon:z,onClick:this.handleResetDateTimeFormat,tooltip:"Reset DateTime Options",className:j("btn-reset","btn-reset-date-time",{hidden:v})})})]}),o.jsx("div",{className:"form-row",children:o.jsx("div",{className:"offset-3 col-9",children:o.jsx(fe,{checked:l??null,onChange:this.handleShowTimeZoneChange,children:"Show time zone in dates"})})}),o.jsx("div",{className:"form-row mb-3",children:o.jsx("div",{className:"offset-3 col-9",children:o.jsx(fe,{checked:c??null,onChange:this.handleShowTSeparatorChange,children:"Show 'T' separator"})})}),o.jsxs("div",{className:"form-row mb-2",children:[o.jsx("label",{className:"col-form-label col-3",htmlFor:"default-decimal-format-input",children:"Decimal"}),o.jsx("div",{className:"col pr-0",children:o.jsx("input",{className:j("form-control","flex-grow-1","default-decimal-format-input",{"is-invalid":!G(t,D.dataType.DECIMAL,N.makeCustomFormat(h))}),"data-lpignore":!0,placeholder:N.DEFAULT_FORMAT_STRING,type:"text",id:"default-decimal-format-input",value:h,onChange:this.handleDefaultDecimalFormatChange})}),o.jsx("div",{className:"col-1 btn-col",children:o.jsx(w,{kind:"ghost",icon:z,onClick:this.handleResetDecimalFormat,tooltip:"Reset Decimal Formatting",className:j("btn-reset","btn-reset-decimal",{hidden:y}),"data-testid":"btn-reset-decimal"})})]}),o.jsxs("div",{className:"form-row mb-2",children:[o.jsx("label",{className:"col-form-label col-3",htmlFor:"default-integer-format-input",children:"Integer"}),o.jsx("div",{className:"col pr-0",children:o.jsx("input",{className:j("form-control","flex-grow-1","default-integer-format-input",{"is-invalid":!G(t,D.dataType.INT,R.makeCustomFormat(u))}),"data-lpignore":!0,placeholder:R.DEFAULT_FORMAT_STRING,type:"text",id:"default-integer-format-input",value:u,onChange:this.handleDefaultIntegerFormatChange})}),o.jsx("div",{className:"col-1 btn-col",children:o.jsx(w,{kind:"ghost",icon:z,onClick:this.handleResetIntegerFormat,tooltip:"Reset Integer Formatting",className:j("btn-reset","btn-reset-integer",{hidden:x}),"data-testid":"btn-reset-integer"})})]}),o.jsx("div",{className:"form-row mb-3",children:o.jsx("div",{className:"offset-3 col-9",children:o.jsx(fe,{checked:d??null,onChange:this.handleTruncateNumbersWithPoundChange,children:"Show truncated numbers as ###"})})})]})})}}const No=s=>({formatter:Ct(s),defaultDateTimeFormat:wt(s),defaultDecimalFormatOptions:Ft(s),defaultIntegerFormatOptions:Dt(s),dh:xt(s),showTimeZone:Et(s),showTSeparator:Rt(s),truncateNumbersWithPound:Nt(s),timeZone:jt(s),settings:Ee(s)}),jo=ne(No,{saveSettings:xe})(Ne);function Oo(){const[s,e]=m.useState(!1),t=()=>{e(!s)};return o.jsxs(o.Fragment,{children:[o.jsx(w,{kind:"ghost",onClick:t,icon:Bn,children:"Legal Notices"}),o.jsxs(Zn,{isOpen:s,toggle:t,className:"theme-bg-light",children:[o.jsx(Hn,{toggle:t,children:"Legal Notice"}),o.jsxs(zn,{children:[o.jsx("p",{children:"Deephaven software is protected by U.S. Patent Nos. 9,612,959; 9,613,018; 9,613,109; 9,619,210; 9,633,060; 9,639,570; 9,672,238; 9,679,006; 9,690,821; 9,710,511; 9,760,591; 9,805,084; 9,836,494; 9,836,495; 9,886,469; 9,898,496; 9,934,266; 10,002,153; 10,002,154; 10,002,155; 10,003,673; 10,019,138; 10,069,943; 10,176,211; 10,198,465; 10,198,466; 10,198,469; 10,212,257; 10,241,960; 10,241,965; 10,242,040; 10,242,041; 10,346,394; 10,353,893; 10,452,649; 10,496,639; 10,540,351; 10,552,412; 10,565,194; 10,565,206; 10,572,474; 10,621,168; 10,642,829; 10,657,184; 10,678,787; 10,691,686; 10,783,191; 10,866,943; 10,909,183; 10,915,526; 10,922,311; 10,929,394; 11,023,462; 11,126,662; 11,151,133; 11,238,036; 11,249,994; 11,263,211; 11,449,557; 11,514,037; 11,556,528; and 11,574,018. Other patents pending."}),o.jsxs("p",{children:["© 2016-",new Date().getFullYear()," Deephaven Data Labs LLC. Patent Pending."]})]})]})]})}function ee(s){const{children:e,isExpanded:t,sectionKey:n,title:a,onToggle:r}=s;return o.jsxs(o.Fragment,{children:[o.jsx("div",{children:o.jsxs(w,{kind:"ghost",className:"btn-collapse-trigger",onClick:()=>r(n),children:[o.jsx("div",{className:"flex-grow-1",children:a}),o.jsx("div",{className:"flex-shrink-0",children:o.jsx(E,{transform:t?"flip-v":"",icon:Yn})})]})}),o.jsx(As,{in:t,autoFocusOnShow:!0,children:e})]})}ee.propTypes={children:b.node,isExpanded:b.bool.isRequired,sectionKey:b.string.isRequired,title:b.node.isRequired,onToggle:b.func};ee.defaultProps={children:null,onToggle:()=>{}};function Io({shortcut:s,displayText:e,categoryName:t,onChange:n}){const[a,r]=m.useState(e),[i,l]=m.useState(s.getKeyState()),[c,d]=m.useState(!1),[h,u]=m.useState("");m.useEffect(function(){r(e),l(s.getKeyState())},[e,s]),m.useEffect(function(){r(_.getDisplayText(i)),s.matchesKeyState(i)&&d(!1)},[i,s]),m.useEffect(function(){if(c){if(!_.isValidKeyState(i)){_.isAllowedKey(i.keyValue)?u("Must contain a modifier key"):u("Must contain an allowed action key");return}const p=Re.getConflictingShortcuts(i).filter(f=>f.id.startsWith(t)&&f!==s).map(f=>f.name);if(p.length){u(`Conflicts with ${p.join(", ")}`);return}u("")}else u("")},[c,i,t,s]);function g(C){if(C.stopPropagation(),C.preventDefault(),s.isEditable&&!C.repeat){const p=_.getKeyStateFromEvent(C),f=_.createKeyState([ws.BACKSPACE]);_.doKeyStatesMatch(p,f)?l(_.NULL_KEY_STATE):l(p)}}function v(C){C.stopPropagation(),C.preventDefault(),s.matchesKeyState(i)||d(!0)}function y(){Qe.disableAllActions()}function x(){Qe.enableAllActions()}function T(){s.setKeyState(i),d(!1),n(s)}function S(){const C=s.getKeyState();l(C),d(!1)}function O(){d(!0),l(s.getDefaultKeyState())}return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"shortcut-item-container",children:[o.jsxs("label",{className:"shortcut-item-name",children:[s.name,s.tooltip!==void 0&&o.jsx(kt,{children:s.tooltip})]}),o.jsxs("div",{className:"shortcut-item-input-container",children:[o.jsx("input",{className:j("form-control",{"is-invalid":h}),onKeyDown:g,onKeyUp:v,onFocus:y,onBlur:x,disabled:!s.isEditable,value:a,readOnly:!0}),!_.doKeyStatesMatch(i,s.getDefaultKeyState())&&!h&&o.jsx(w,{className:"reset-to-default-button",kind:"ghost",icon:o.jsx(E,{icon:z,transform:{rotate:90,flipX:!0}}),tooltip:"Reset to default",onClick:O})]})]}),c&&o.jsxs("div",{className:j("shortcut-item-message-container",{"is-invalid":h}),children:[o.jsx("div",{className:"shortcut-item-message",children:h}),o.jsxs("div",{className:"shortcut-item-message-buttons",children:[_.isValidKeyState(i)&&o.jsx(w,{kind:"ghost",onClick:T,children:"Confirm"}),o.jsx(w,{kind:"ghost",onClick:S,children:"Undo"})]})]})]})}function Lo({shortcutOverrides:s={},settings:e,saveSettings:t}){const n=m.useCallback(l=>{const c=_.isMacPlatform,d={mac:{...s.mac},windows:{...s.windows}},h=c?d.mac:d.windows;l.forEach(u=>{u.isDefault()?delete h[u.id]:h[u.id]=u.getKeyState()}),t({...e,shortcutOverrides:d})},[e,t,s]);let a=Array.from(Re.shortcutsByCategory.entries()).map(([l,c])=>({name:l,shortcuts:c}));const r=a.findIndex(l=>l.name.toUpperCase()==="GLOBAL"),i=a.splice(r,1);return a=a.concat(i),o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"app-settings-menu-description",children:"Customize shortcuts below. To prevent unexpected results, avoid conflicting shortcuts with the browser or IDE editor."}),a.map(l=>o.jsx(Po,{name:l.name,shortcuts:l.shortcuts,saveShortcutOverrides:n},l.name))]})}function Po({name:s,shortcuts:e,saveShortcutOverrides:t}){function n(c){return c.split("_").map(d=>`${d[0].toUpperCase()}${d.slice(1).toLowerCase()}`).join(" ")}const[a,r]=m.useState(e);function i(c){const d=a.filter(u=>u!==c&&!u.isNull()&&u.matchesKeyState(c.getKeyState()));d.forEach(u=>u.setToNull());const h=[c,...d];t(h),r(u=>[...u])}const l=m.useMemo(()=>a.map(c=>c.getDisplayText()),[a]);return o.jsxs("div",{className:"mt-3",children:[o.jsx("div",{className:"font-weight-bold",children:n(s)}),a.map((c,d)=>o.jsx(Io,{shortcut:c,displayText:l[d],categoryName:s,onChange:i},c.id))]})}const ko=s=>({settings:Ee(s),shortcutOverrides:fn(s)}),Ao={saveSettings:xe},_o=ne(ko,Ao)(Lo),Mo="yyyy-MM-dd-HHmmss";function Bt(s,e="root",t=new Map([[s,""]])){const n={};return Object.entries(s).forEach(([a,r])=>{try{JSON.stringify(r),n[a]=r}catch{const l=r;if(typeof r=="bigint")n[a]=r.toString();else if(t.has(l))n[a]=`Circular ref to ${t.get(l)}`;else{const c=`${e}.${a}`;t.set(l,c),n[a]=Bt(r,c,t)}}}),n}function Uo(){const s=Ot.getState();return JSON.stringify(Bt(s),null,2)}function $o(s){const e={uiVersion:"0.53.0",userAgent:navigator.userAgent,...s};return JSON.stringify(e,null,2)}async function Ko(s=`${W.i18n.DateTimeFormat.format(Mo,new Date)}_support_logs`,e){const t=new St,n=t.folder(s);n.file("console.txt",qn.getFormattedHistory()),n.file("redux.json",Uo()),n.file("metadata.json",$o(e));const a=await t.generateAsync({type:"blob"}),r=document.createElement("a");r.href=URL.createObjectURL(a),r.download=`${s}.zip`,r.click()}const Wo=[{value:D.dataType.DATETIME,label:"DateTime"},{value:D.dataType.DECIMAL,label:"Decimal"},{value:D.dataType.INT,label:"Integer"}];function Vo(){const s=Wo.map(e=>o.jsx("option",{value:e.value,children:e.label},`key-columnType-${e.value}`));return o.jsxs(o.Fragment,{children:[o.jsx("option",{disabled:!0,value:"",children:"Select Type"},"key-columnType-placeholder"),s]})}class je extends m.PureComponent{static defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:L.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:N.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:R.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:L.DEFAULT_TIME_ZONE_ID}};static inputDebounceTime=250;constructor(e){super(e),this.debouncedCommitChanges=De(this.commitChanges.bind(this),je.inputDebounceTime),this.handleFormatRuleEntered=this.handleFormatRuleEntered.bind(this),this.handleFormatRuleChange=this.handleFormatRuleChange.bind(this),this.handleFormatRuleCreate=this.handleFormatRuleCreate.bind(this),this.handleFormatRuleDelete=this.handleFormatRuleDelete.bind(this);const{formatter:t,showTimeZone:n,showTSeparator:a,timeZone:r,truncateNumbersWithPound:i}=e,l=t.map((c,d)=>({...c,id:d}));this.containerRef=te.createRef(),this.addFormatRuleButtonRef=te.createRef(),this.lastFormatRuleIndex=l.length,this.state={formatSettings:l,formatRulesChanged:!1,showTimeZone:n,showTSeparator:a,timeZone:r,truncateNumbersWithPound:i,timestampAtMenuOpen:new Date}}componentDidMount(){Fe(this.containerRef.current)}componentWillUnmount(){this.debouncedCommitChanges.flush()}debouncedCommitChanges;containerRef;addFormatRuleButtonRef;lastFormatRuleIndex;isDuplicateRule(e){const{formatSettings:t}=this.state;return t.some(n=>n.id!==e.id&&n.columnName===e.columnName&&n.columnType===e.columnType)??!1}getAutoIncrementFormatRuleIndex(){const{lastFormatRuleIndex:e}=this;return this.lastFormatRuleIndex+=1,e}getCachedColumnTypeOptions=Te(()=>o.jsx(Vo,{}));getCachedDateTimeFormatOptions=Te((e,t,n,a=!1,r)=>{const{timestampAtMenuOpen:i}=this.state;return o.jsx(Gt,{timestamp:i,timeZone:e,showTimeZone:t,showTSeparator:n,isGlobalOptions:a,legacyGlobalFormat:r})});handleFormatRuleChange(e,t,n){this.setState(a=>{const{formatSettings:r}=a;Jn(r);const i=[...r];let l={};t==="columnType"&&(l={format:this.makeDefaultFormatterItemByType(n)});const c={...i[e],...l,[t]:n};return i[e]=c,{formatSettings:i}},()=>{this.debouncedCommitChanges()})}handleFormatRuleCreate(){this.setState(e=>{const{formatSettings:t}=e,n={columnType:D.dataType.DATETIME,columnName:"",format:{},id:this.getAutoIncrementFormatRuleIndex(),isNewRule:!0};return{formatSettings:[...t,n],formatRulesChanged:!0}})}handleFormatRuleDelete(e){this.setState(t=>{const{formatSettings:n}=t;return{formatSettings:n.filter((r,i)=>i!==e),formatRulesChanged:!0}},()=>{this.debouncedCommitChanges()})}handleFormatRuleEntered(e){this.scrollToFormatBlockBottom(),Fe(e)}commitChanges(){const{formatSettings:e,showTimeZone:t,showTSeparator:n,timeZone:a,truncateNumbersWithPound:r}=this.state,{defaultDateTimeFormat:i,defaultDecimalFormatOptions:l,defaultIntegerFormatOptions:c}=this.props,{dh:d}=this.props,h=e.filter(y=>Vt(d,y)).map(Wt)??[],{settings:u,saveSettings:g}=this.props,v={...u,formatter:h,defaultDateTimeFormat:i,showTimeZone:t,showTSeparator:n,timeZone:a,truncateNumbersWithPound:r};G(d,D.dataType.DECIMAL,N.makeCustomFormat(l.defaultFormatString))&&(v.defaultDecimalFormatOptions=l),G(d,D.dataType.INT,R.makeCustomFormat(c.defaultFormatString))&&(v.defaultIntegerFormatOptions=c),g(v)}scrollToFormatBlockBottom(){const{scrollTo:e}=this.props;e(0,(this.addFormatRuleButtonRef.current?.offsetHeight??0)+(this.addFormatRuleButtonRef.current?.offsetTop??0))}getRuleError(e){const{dh:t}=this.props,n={hasColumnNameError:!1,hasFormatError:!1,message:""},a=[];return e.isNewRule!==void 0&&e.isNewRule||(this.isDuplicateRule(e)&&(n.hasColumnNameError=!0,a.push("Duplicate column name/type combo.")),Kt(e.columnName)||(n.hasColumnNameError=!0,a.push("Column names must start with a letter or underscore and contain only alphanumeric characters or underscores.")),e.format.formatString!==void 0&&e.format.formatString.length===0?(n.hasFormatError=!0,a.push("Empty formatting rule.")):G(t,e.columnType,e.format)||(n.hasFormatError=!0,a.push("Invalid formatting rule.")),n.message=a.join(`
2
+ `)),n}makeDefaultFormatterItemByType(e){switch(D.getNormalizedType(e)){case D.dataType.INT:{const{defaultIntegerFormatOptions:t}=this.props,{defaultFormatString:n}=t;return R.makeFormat("",n??R.DEFAULT_FORMAT_STRING,R.TYPE_GLOBAL,void 0)}case D.dataType.DECIMAL:{const{defaultDecimalFormatOptions:t}=this.props,{defaultFormatString:n}=t;return N.makeFormat("",n??N.DEFAULT_FORMAT_STRING,N.TYPE_GLOBAL,void 0)}default:return""}}renderFormatRule(e,t){const n=`input-${e}-columnName`,a=`input-${e}-columnType`,r=`input-${e}-format`,i=this.getCachedColumnTypeOptions(),l=u=>this.handleFormatRuleChange(e,"columnName",u.target.value),c=()=>this.handleFormatRuleChange(e,"isNewRule",!1),d=u=>this.handleFormatRuleChange(e,"columnType",u.target.value),h=this.getRuleError(t);return o.jsxs("fieldset",{className:"container-fluid format-rule-container",children:[o.jsxs("div",{className:"form-row",children:[o.jsxs("div",{className:"form-group col-7 mb-2",children:[o.jsx("label",{htmlFor:n,children:"Column Name"}),o.jsx("input",{id:n,className:j("form-control",{"is-invalid":h.hasColumnNameError}),"data-lpignore":!0,type:"text",value:t.columnName,onChange:l,onBlur:c})]}),o.jsxs("div",{className:"form-group col mb-2",children:[o.jsx(w,{kind:"ghost",className:"btn-delete-format-rule float-right",tabIndex:-1,onClick:()=>this.handleFormatRuleDelete(e),icon:Xn,tooltip:"Delete","aria-label":"Delete Format Rule"}),o.jsx("label",{htmlFor:a,children:"Column Type"}),o.jsx("select",{id:a,className:"custom-select",value:t.columnType,onChange:d,children:i})]})]}),o.jsx("div",{className:"form-row",children:o.jsxs("div",{className:"form-group col-12 d-flex mb-2",children:[o.jsx("label",{className:"flex-shrink-0 col-form-label mr-3",htmlFor:r,children:"Formatting Rule"}),this.renderFormatRuleInput(e,t.columnType,r,t.format,h.hasFormatError)]})}),o.jsx("div",{className:"form-row",children:o.jsx("div",{className:"form-group col-12 d-flex mb-2",children:h.message&&o.jsx("p",{className:"text-danger",children:h.message})})})]},e)}renderFormatRuleInput(e,t,n,a,r){switch(D.getNormalizedType(t)){case D.dataType.DATETIME:return this.renderDateTimeFormatRuleInput(e,n,a,r);case D.dataType.DECIMAL:return this.renderDecimalFormatRuleInput(e,n,a,r);case D.dataType.INT:return this.renderIntegerFormatRuleInput(e,n,a,r);default:throw new Error(`Unrecognized column type: ${t}`)}}renderDateTimeFormatRuleInput(e,t,n,a){const{showTimeZone:r,showTSeparator:i,timeZone:l}=this.state,c=n.formatString??"";return o.jsxs("select",{className:j("custom-select",{"is-invalid":a}),value:c,id:t,onChange:d=>{const h=L.makeFormat("",d.target.value,L.TYPE_GLOBAL);this.handleFormatRuleChange(e,"format",h)},children:[o.jsx("option",{value:"",disabled:!0,children:"Select format"},"default"),this.getCachedDateTimeFormatOptions(l,r,i)]})}renderIntegerFormatRuleInput(e,t,n,a){const{defaultIntegerFormatOptions:r}=this.props,{defaultFormatString:i}=r,l=n.formatString??"";return o.jsx("input",{className:j("form-control","flex-grow-1",{"is-invalid":a}),"data-lpignore":!0,id:t,placeholder:i??R.DEFAULT_FORMAT_STRING,type:"text",value:l,onChange:c=>{const d=R.makeFormat("",c.target.value,R.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(e,"format",d)}})}renderDecimalFormatRuleInput(e,t,n,a){const{defaultDecimalFormatOptions:r}=this.props,{defaultFormatString:i}=r,l=n.formatString??"";return o.jsx("input",{className:j("form-control","flex-grow-1",{"is-invalid":a}),"data-lpignore":!0,id:t,placeholder:i??N.DEFAULT_FORMAT_STRING,type:"text",value:l,onChange:c=>{const d=N.makeFormat("",c.target.value,N.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(e,"format",d)}})}render(){const{formatRulesChanged:e,formatSettings:t}=this.state,n=t.map((r,i)=>o.jsx(Tt,{classNames:"fade",timeout:le.transitionMs,onEnter:this.handleFormatRuleEntered,children:this.renderFormatRule(i,r)},r.id)),a=o.jsx(w,{kind:"ghost",className:"mb-3",onClick:this.handleFormatRuleCreate,ref:this.addFormatRuleButtonRef,icon:Qn,children:"Add New Rule"});return o.jsxs("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:[o.jsx("div",{className:"app-settings-menu-description mb-3",children:"Customize the formatting of table columns by applying rules based on matching both a column name and column type."}),o.jsx(nn,{appear:e,enter:e,exit:e,children:n}),a]})}}const Go=s=>({formatter:Ct(s),defaultDateTimeFormat:wt(s),defaultDecimalFormatOptions:Ft(s),defaultIntegerFormatOptions:Dt(s),dh:xt(s),showTimeZone:Et(s),showTSeparator:Rt(s),truncateNumbersWithPound:Nt(s),timeZone:jt(s),settings:Ee(s)}),Bo=ne(Go,{saveSettings:xe})(je);class M extends m.Component{static defaultProps={onDone:()=>{}};static FORMATTING_SECTION_KEY="SettingsMenu.formatting";static COLUMN_SPECIFIC_SECTION_KEY="SettingsMenu.columnFormatting";static APPLICATION_SECTION_KEY="ApplicationMenu.settings";static SHORTCUT_SECTION_KEY="SettingsMenu.shortcuts";static focusFirstInputInContainer(e){const t=e?.querySelector("input, select, textarea");t&&t.focus()}constructor(e){super(e),this.handleClose=this.handleClose.bind(this),this.handleScrollTo=this.handleScrollTo.bind(this),this.handleSectionToggle=this.handleSectionToggle.bind(this),this.handleExportSupportLogs=this.handleExportSupportLogs.bind(this),this.handleLogout=this.handleLogout.bind(this),this.menuContentRef=te.createRef(),this.broadcastChannel=new BroadcastChannel(_s),this.state={expandedSectionKey:M.FORMATTING_SECTION_KEY}}componentDidMount(){M.focusFirstInputInContainer(this.menuContentRef.current)}componentWillUnmount(){this.broadcastChannel.close()}menuContentRef;broadcastChannel;isSectionExpanded(e){const{expandedSectionKey:t}=this.state;return t===e}handleLogout(){this.broadcastChannel.postMessage(Ms(Us))}handleScrollTo(e,t){this.menuContentRef.current?.scrollTo(e,t)}handleSectionToggle(e){this.setState(t=>({expandedSectionKey:t.expandedSectionKey===e?void 0:e}))}handleClose(){const{onDone:e}=this.props;e()}handleExportSupportLogs(){const{serverConfigValues:e}=this.props;Ko(void 0,Object.fromEntries(e))}render(){const e="0.53.0",t="https://github.com/deephaven/web-client-ui/",n="https://deephaven.io/core/docs/",{serverConfigValues:a,user:r}=this.props,i=a.get("barrage.version"),l=a.get("java.version"),c=a.get("deephaven.version"),d=(v,y)=>o.jsxs(o.Fragment,{children:[o.jsx("div",{children:v}),o.jsx("div",{children:y})]}),h=r.displayName??r.name,u=r.image!=null&&r.image!=="",g=h!=="";return o.jsxs("div",{className:"app-settings-menu",children:[o.jsxs("header",{className:"app-settings-menu-header",children:[o.jsxs("div",{className:"user-info",children:[o.jsxs("div",{className:"user-image",children:[!u&&o.jsx(E,{icon:es,transform:"grow-8"}),u&&o.jsx("img",{src:r.image,alt:h})]}),o.jsxs("div",{className:"user-details",children:[g&&o.jsxs("div",{className:"user-name",children:[h,r.operateAs!=null&&r.name!==r.operateAs&&o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"font-weight-light font-italic",children:[" ","as"," "]}),o.jsxs("span",{className:"operating-as-user",children:[o.jsx(E,{icon:ts,className:"mr-1"}),r.operateAs]})]})]}),r.permissions.canLogout&&o.jsx("button",{type:"button",className:"btn btn-link",onClick:this.handleLogout,children:"logout"})]})]}),o.jsx(w,{kind:"ghost",className:"btn-close-settings-menu",onClick:this.handleClose,icon:o.jsx(E,{icon:ns,transform:"grow-4"}),tooltip:"Close"})]}),o.jsxs("div",{className:"app-settings-menu-content",ref:this.menuContentRef,children:[o.jsx("h5",{children:"Settings"}),o.jsx("hr",{className:"my-0"}),o.jsx(ee,{sectionKey:M.FORMATTING_SECTION_KEY,isExpanded:this.isSectionExpanded(M.FORMATTING_SECTION_KEY),title:o.jsxs(o.Fragment,{children:[o.jsx(E,{icon:ss,transform:"grow-4",className:"mr-2"}),"Default Format & Time zone"]}),onToggle:this.handleSectionToggle,children:o.jsx(jo,{})}),o.jsx(ee,{sectionKey:M.COLUMN_SPECIFIC_SECTION_KEY,isExpanded:this.isSectionExpanded(M.COLUMN_SPECIFIC_SECTION_KEY),title:o.jsxs(o.Fragment,{children:[o.jsx(E,{icon:os,transform:"grow-4",className:"mr-2"}),"Format by Column Name & Type"]}),onToggle:this.handleSectionToggle,children:o.jsx(Bo,{scrollTo:this.handleScrollTo})}),o.jsx(ee,{sectionKey:M.SHORTCUT_SECTION_KEY,isExpanded:this.isSectionExpanded(M.SHORTCUT_SECTION_KEY),title:o.jsxs(o.Fragment,{children:[o.jsx(E,{icon:as,transform:"grow-2"})," ","Keyboard Shortcuts"]}),onToggle:this.handleSectionToggle,children:o.jsx(_o,{})}),o.jsxs("div",{className:"app-settings-footer",children:[o.jsxs("div",{className:"app-settings-footer-section",children:[o.jsxs("div",{className:"app-settings-footer-item",children:[o.jsx("div",{className:"font-weight-bold",children:"Support"}),o.jsxs("div",{children:["GitHub: ",o.jsx("a",{href:t,className:"custom-link",target:"_blank",rel:"noopener noreferrer",children:t})]}),o.jsx(w,{kind:"tertiary",className:"mt-2 py-2",onClick:this.handleExportSupportLogs,children:"Export Logs"})]}),o.jsxs("div",{className:"app-settings-footer-item",children:[o.jsx("div",{className:"font-weight-bold",children:"Documentation"}),o.jsx("a",{target:"_blank",rel:"noreferrer noopener",href:n,className:"custom-link",children:n})]}),o.jsxs("div",{className:"app-settings-footer-item",children:[o.jsx("div",{className:"font-weight-bold",children:"Version"}),o.jsxs("span",{className:"d-inline-block text-muted",children:[c," ",o.jsx(E,{icon:rs}),o.jsxs(kt,{interactive:!0,children:[o.jsxs("div",{className:"detailed-server-config",children:[d("Engine Version",c),d("Web UI Version",e),d("Java Version",l),d("Barrage Version",i)]}),o.jsx(Fs,{tooltip:"Copy version numbers",copy:`Engine Version: ${c}
3
3
  Web UI Version: ${e}
4
4
  Java Version: ${l}
5
5
  Barrage Version: ${i}`,children:"Copy Versions"})]})]})]}),o.jsx("div",{className:"app-settings-footer-item",children:o.jsx(Oo,{})})]}),o.jsx("div",{className:"app-settings-footer-section",children:o.jsx("div",{className:"logo",children:o.jsx("a",{target:"_blank",rel:"noreferrer noopener",href:"https://deephaven.io",className:"d-inline-block custom-link p-1",children:o.jsx("img",{src:Ut,alt:"Deephaven Data Labs",width:"230px"})})})})]})]})]})}}const ft=10;function Y(s){const{forwardedProps:{menuItem:{action:e,title:t,disabled:n},iconElement:a,displayShortcut:r,isMouseSelected:i,isKeyboardSelected:l,closeMenu:c}}=s,d=m.useRef(),h=m.useRef(),u=m.useRef(null),[g,v]=m.useState(!1),y=m.useCallback(S=>{d.current!=null&&h.current!=null&&u.current&&(Math.abs(d.current-S.clientX)>=ft||Math.abs(h.current-S.clientY)>=ft)&&(v(!0),window.removeEventListener("mousemove",y),c(),e(S),u.current=null)},[e,c]);function x(S){d.current=S.clientX,h.current=S.clientY,u.current=S.target,window.addEventListener("mousemove",y)}function T(S){u.current===S.target&&(v(!0),c(),e(),window.removeEventListener("mousemove",y)),u.current=null}return m.useEffect(function(){return function(){return window.removeEventListener("mousemove",y)}},[y]),o.jsxs("button",{type:"button",className:j("btn-context-menu",{disabled:n},{active:i&&!n},{"keyboard-active":l&&!n}),onMouseDown:x,onMouseUp:T,disabled:g,children:[o.jsx("span",{className:j("icon"),children:a}),o.jsx("span",{className:"title",children:t}),o.jsx("span",{className:"shortcut",children:r})]})}function Oe(s){const{handleControlSelect:e,handleToolSelect:t,onClearFilter:n}=s,a=m.useMemo(()=>[{title:"Input Filter",icon:is,menuElement:o.jsx(Y,{}),action:r=>{e(V.INPUT_FILTER,r)},order:10},{title:"Dropdown Filter",icon:ls,menuElement:o.jsx(Y,{}),action:r=>{e(V.DROPDOWN_FILTER,r)},order:15},{title:"Markdown Widget",icon:cs,menuElement:o.jsx(Y,{}),action:r=>{e(V.MARKDOWN,r)},order:20},{title:"Filter Sets",icon:ds,menuElement:o.jsx(Y,{}),action:r=>{e(V.FILTER_SET_MANAGER,r)},order:25},{disabled:!0,menuElement:o.jsx("div",{className:"context-menu-group-header",children:"Tools"}),order:30},{title:"Linker",icon:us,action:()=>{t(de.LINKER)},order:40,shortcut:Ce.LINKER},{disabled:!0,menuElement:o.jsx("div",{className:"context-menu-group-header",children:"Actions"}),order:50},{title:"Clear All Filters",icon:hs,action:()=>{n()},order:60,shortcut:At.TABLE.CLEAR_ALL_FILTERS}],[e,t,n]);return o.jsx(Ds,{popperClassName:"controls-menu-popper",actions:a})}Oe.propTypes={handleControlSelect:b.func,handleToolSelect:b.func,onClearFilter:b.func};Oe.defaultProps={handleControlSelect:()=>{},handleToolSelect:()=>{},onClearFilter:()=>{}};Y.propTypes={forwardedProps:b.shape({iconElement:b.node,displayShortcut:b.string,isMouseSelected:b.bool.isRequired,isKeyboardSelected:b.bool.isRequired,closeMenu:b.func.isRequired,menuItem:b.shape({action:b.func,title:b.string,disabled:b.bool}).isRequired})};Y.defaultProps={forwardedProps:null};const Zo=gn(Mt,null),Ho={layoutStorage:Zo},zo=s=>s.layoutStorage,Yo=s=>s.serverConfigValues;Object.entries(Ho).map(([s,e])=>bn.register(s,e));const gt=10;function qo(s){const{onExportLayout:e,onImportLayout:t,onResetLayout:n,onSelect:a,widgets:r=[]}=s,[i,l]=m.useState(!1),[c,d]=m.useState(""),h=m.useRef(null),u=m.useRef(),g=m.useCallback((p,f)=>{p!=null&&a(p,f)},[a]),v=m.useCallback(p=>{d(p.target.value)},[]),y=m.useCallback(p=>{u.current!=null&&(Math.abs(u.current.x-p.clientX)>=gt||Math.abs(u.current.y-p.clientY)>=gt)&&(l(!0),window.removeEventListener("mousemove",y),g(u.current.widget,p),u.current=void 0)},[u,g]),x=m.useCallback((p,f)=>{u.current={x:p.clientX,y:p.clientY,widget:f},window.addEventListener("mousemove",y)},[y]),T=m.useCallback((p,f)=>{window.removeEventListener("mousemove",y),u.current?.widget===f&&(l(!0),g(f)),u.current=void 0},[y,u,g]),S=m.useMemo(()=>r.filter(p=>c?p.name?.toLowerCase().includes(c.toLowerCase()):!0),[c,r]).sort((p,f)=>p.name?.localeCompare(f.name??"")??0),O=m.useMemo(()=>S.map(p=>o.jsx("li",{children:o.jsxs(w,{kind:"ghost","data-testid":`panel-list-item-${p.name??""}-button`,onMouseDown:f=>{x(f,p)},onMouseUp:f=>{T(f,p)},onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&g(p)},disabled:i,onClick:()=>{},children:[o.jsx(vn,{type:p.type})," ",p.name??""]})},p.name)),[S,i,x,T,g]),C=m.useMemo(()=>O.length===0?o.jsx("span",{children:"No bound variables found."}):null,[O]);return o.jsxs("div",{className:"widget-list-container d-flex flex-column",children:[o.jsx("div",{className:"widget-list-header",children:o.jsx(xs,{value:c,placeholder:"Find Table, Plot or Widget",onChange:v,ref:h})}),o.jsxs("ul",{className:"widget-list flex-grow-1",children:[C&&o.jsx("li",{className:"widget-list-message",children:C}),!C&&O]}),o.jsx("div",{children:o.jsx("hr",{})}),o.jsxs("div",{className:"widget-list-footer",children:[o.jsxs(w,{kind:"ghost",onClick:e,children:[o.jsxs("div",{className:"fa-md fa-layers",children:[o.jsx(E,{mask:Ye,icon:qe,transform:"right-5 down-5"}),o.jsx(E,{icon:qe,transform:"right-8 down-6"})]}),"Export Layout"]}),o.jsxs(w,{kind:"ghost",onClick:t,children:[o.jsxs("div",{className:"fa-md fa-layers",children:[o.jsx(E,{mask:Ye,icon:Je,transform:"right-5 down-5"}),o.jsx(E,{icon:Je,transform:"right-8 down-6"})]}),"Import Layout"]}),o.jsx(w,{kind:"ghost",icon:z,onClick:n,tooltip:"Reset Layout"})]})]})}function Jo({onAutoFillClick:s=()=>{}}){return o.jsxs("div",{className:"empty-dashboard-container",children:[o.jsxs("div",{className:"hint-container",children:[o.jsx(E,{icon:ms})," ",o.jsx("br",{}),"Use the panel list to add objects from a query."]}),o.jsxs("div",{className:"empty-dashboard",children:[o.jsx("div",{className:"add-panels-hint",children:"Drag Panels Here"}),o.jsx(w,{kind:"tertiary",onClick:s,children:"Auto fill objects"})]})]})}function Xo(s){return s.version===2}function Qo(s){return Array.isArray(s)}const ie=k.module("UserLayoutUtils"),ea={layoutConfig:[{type:"column",content:[{type:"row",height:40,content:[{type:"stack",content:[{type:"react-component",component:Ve.COMPONENT,title:Ve.TITLE,isClosable:!1},{type:"react-component",component:Ge.COMPONENT,title:Ge.TITLE,isClosable:!1}]},{type:"stack",width:25,content:[{type:"react-component",component:Be.COMPONENT,title:Be.TITLE,isClosable:!1},{type:"react-component",component:Ze.COMPONENT,title:Ze.TITLE,isClosable:!1}]}]},{type:"row",content:[{type:"stack",title:"Notebooks",content:[]}]}]}],links:[],filterSets:[],version:2},ta={layoutConfig:[],links:[],filterSets:[],version:2};function Zt(s){if(Xo(s))return s;if(Qo(s))return{layoutConfig:s,links:[],filterSets:[],version:2};throw new Error(`Unexpected layout import format: ${s}`)}async function na(s,e=!0){try{const t=await s.getLayouts();if(t.length>0)try{const n=await s.getLayout(t[0]);return Zt(n)}catch(n){ie.error("Unable to load layout",t[0],":",n),ie.warn("No valid layouts found, falling back to default layout")}}catch(t){ie.error("Unable to fetch layout list",t),ie.warn("Falling back to default layout")}return e?ea:ta}function sa(s){const{filterSets:e,layoutConfig:t,links:n}=s;return{filterSets:e,layoutConfig:t,links:n,version:2}}const ce={exportLayout:sa,getDefaultLayout:na,normalizeLayout:Zt},F=k.module("AppMainContainer");class q extends m.Component{static handleWindowBeforeUnload(e){e.preventDefault(),e.returnValue=""}static hydrateConsole(e,t){return ze.hydrate({...e,unzip:n=>St.loadAsync(n).then(a=>Object.values(a.files))},t)}static handleRefresh(){F.info("Refreshing application"),window.location.reload()}constructor(e){super(e),Es(this),this.importElement=te.createRef(),this.state={contextActions:[{action:()=>{this.handleToolSelect(de.LINKER)},shortcut:Ce.LINKER,isGlobal:!0},{action:()=>{this.sendClearFilter()},shortcut:At.TABLE.CLEAR_ALL_FILTERS,isGlobal:!0},{action:()=>{F.debug("Consume unhandled save shortcut")},shortcut:Ce.SAVE,isGlobal:!0}],isAuthFailed:!1,isDisconnected:!1,isPanelsMenuShown:!1,isResetLayoutPromptShown:!1,isSettingsMenuShown:!1,unsavedNotebookCount:0,widgets:[]}}componentDidMount(){this.initWidgets(),this.startListeningForDisconnect(),window.addEventListener("beforeunload",q.handleWindowBeforeUnload)}componentDidUpdate(e){const{dashboardData:t}=this.props;e.dashboardData!==t&&this.handleDataChange(t)}componentWillUnmount(){this.deinitWidgets(),this.stopListeningForDisconnect(),window.removeEventListener("beforeunload",q.handleWindowBeforeUnload)}goldenLayout;importElement;widgetListenerRemover;initWidgets(){const{connection:e}=this.props;if(e.subscribeToFieldUpdates==null){F.warn("subscribeToFieldUpdates not supported, not initializing widgets");return}this.widgetListenerRemover=e.subscribeToFieldUpdates(t=>{F.debug("Got updates",t),this.setState(({widgets:n})=>{const{updated:a,created:r,removed:i}=t,l=[...a,...i],c=n.filter(h=>!l.some(u=>u.name===h.name));return[...a,...r].forEach(h=>{h.name!=null&&h.name!==""&&c.push(h)}),{widgets:c}})})}deinitWidgets(){this.widgetListenerRemover?.()}openNotebookFromURL(){const{match:e}=this.props,{notebookPath:t}=e.params;if(t){const{session:n,sessionConfig:a}=this.props;if(n==null||a==null){F.error("No session available to open notebook URL",t);return}const r={id:`/${t}`,itemName:`/${t}`},i=a.type,l={value:null,language:i};this.emitLayoutEvent(xn.SELECT_NOTEBOOK,n,i,l,r,!0)}}sendClearFilter(){this.emitLayoutEvent(ae.CLEAR_ALL_FILTERS)}emitLayoutEvent(e,...t){this.goldenLayout?.eventHub.emit(e,...t)}handleCancelResetLayoutPrompt(){this.setState({isResetLayoutPromptShown:!1})}handleConfirmResetLayoutPrompt(){this.setState({isResetLayoutPromptShown:!1}),this.resetLayout()}handleError(e){K.isCanceled(e)||F.error(e)}handleSettingsMenuHide(){this.setState({isSettingsMenuShown:!1})}handleSettingsMenuShow(){this.setState({isSettingsMenuShown:!0})}handleControlSelect(e,t){switch(F.debug("handleControlSelect",e),e){case V.DROPDOWN_FILTER:this.emitLayoutEvent(ae.OPEN_DROPDOWN,{title:"DropdownFilter",type:e,createNewStack:!0,dragEvent:t});break;case V.INPUT_FILTER:this.emitLayoutEvent(ae.OPEN_INPUT,{title:"InputFilter",type:e,createNewStack:!0,dragEvent:t});break;case V.MARKDOWN:this.emitLayoutEvent(En.OPEN,{title:"Markdown",type:e,dragEvent:t});break;case V.FILTER_SET_MANAGER:this.emitLayoutEvent(ae.OPEN_FILTER_SET_MANAGER,{title:"FilterSets",type:e,dragEvent:t});break;default:throw new Error(`Unrecognized control type ${e}`)}}handleToolSelect(e){F.debug("handleToolSelect",e);const{activeTool:t,setActiveTool:n}=this.props;n(t===e?de.DEFAULT:e)}handleClearFilter(){this.sendClearFilter()}handleDataChange(e){const{updateWorkspaceData:t}=this.props,{closed:n,filterSets:a,links:r}=e;t({closed:n,filterSets:a,links:r})}handleGoldenLayoutChange(e){this.goldenLayout=e}handleLayoutConfigChange(e){const{updateWorkspaceData:t}=this.props;t({layoutConfig:e})}handleWidgetMenuClick(){this.setState(({isPanelsMenuShown:e})=>({isPanelsMenuShown:!e}))}handleWidgetSelect(e,t){this.setState({isPanelsMenuShown:!1}),F.debug("handleWidgetSelect",e,t),this.openWidget(e,t)}handleWidgetsMenuClose(){this.setState({isPanelsMenuShown:!1})}handleAutoFillClick(){const{widgets:e}=this.state;F.debug("handleAutoFillClick",e);const t=e.sort((n,a)=>n.title!=null&&a.title!=null?n.title.localeCompare(a.title):0);for(let n=0;n<t.length;n+=1)this.openWidget(t[n])}handleExportLayoutClick(){F.info("handleExportLayoutClick"),this.setState({isPanelsMenuShown:!1});try{const{workspace:e}=this.props,{data:t}=e,n=ce.exportLayout(t);F.info("handleExportLayoutClick exportedConfig",n);const a=new Blob([JSON.stringify(n)],{type:"application/json"}),r=W.i18n.DateTimeFormat.format("yyyy-MM-dd-HHmmss",new Date),i=document.createElement("a");i.href=URL.createObjectURL(a),i.download=`deephaven-app-layout-${r}.json`,i.click()}catch(e){F.error("Unable to export layout",e)}}handleImportLayoutClick(){F.info("handleImportLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.importElement.current!=null&&(this.importElement.current.value="",this.importElement.current.click())}handleResetLayoutClick(){F.info("handleResetLayoutClick"),this.setState({isPanelsMenuShown:!1,isResetLayoutPromptShown:!0,unsavedNotebookCount:Rn.unsavedNotebookCount()})}handleImportLayoutFiles(e){e.stopPropagation(),e.preventDefault(),e.target.files!=null&&this.importLayoutFile(e.target.files?.[0])}handleDisconnect(){F.info("Disconnected from server"),this.setState({isDisconnected:!0})}handleReconnect(){F.info("Reconnected to server"),this.setState({isDisconnected:!1})}handleReconnectAuthFailed(){F.warn("Reconnect authentication failed"),this.setState({isAuthFailed:!0})}async importLayoutFile(e){try{const{updateDashboardData:t,updateWorkspaceData:n}=this.props,a=await e.text(),r=JSON.parse(a),{filterSets:i,layoutConfig:l,links:c}=ce.normalizeLayout(r);n({layoutConfig:l}),t(U,{filterSets:i,links:c})}catch(t){F.error("Unable to import layout",t)}}async resetLayout(){const{layoutStorage:e,session:t}=this.props,{filterSets:n,layoutConfig:a,links:r}=await ce.getDefaultLayout(e,t!==void 0),{updateDashboardData:i,updateWorkspaceData:l}=this.props;l({layoutConfig:a}),i(U,{filterSets:n,links:r})}handlePaste(e){if(e.target instanceof HTMLElement&&e.target.closest(".monaco-editor"))return;const{clipboardData:t}=e,n=t.getData("Text"),a=/“|”/g;a.test(n)&&(e.preventDefault(),e.stopPropagation(),document.execCommand("insertText",!1,n.replace(a,'"')))}startListeningForDisconnect(){const{connection:e}=this.props;e.addEventListener(W.IdeConnection.EVENT_DISCONNECT,this.handleDisconnect),e.addEventListener(W.IdeConnection.EVENT_RECONNECT,this.handleReconnect),e.addEventListener(W.CoreClient.EVENT_RECONNECT_AUTH_FAILED,this.handleReconnectAuthFailed)}stopListeningForDisconnect(){const{connection:e}=this.props;e.removeEventListener(W.IdeConnection.EVENT_DISCONNECT,this.handleDisconnect),e.removeEventListener(W.IdeConnection.EVENT_RECONNECT,this.handleReconnect),e.removeEventListener(W.CoreClient.EVENT_RECONNECT_AUTH_FAILED,this.handleReconnectAuthFailed)}hydrateDefault(e,t){const{connection:n}=this.props,{metadata:a}=e;if(a?.type!=null&&(a?.id!=null||a?.name!=null)){const r=a.id!=null?{type:a.type,id:a.id}:{type:a.type,name:a.name,title:a.name};return{fetch:()=>n.getObject(r),...e,localDashboardId:t}}return ze.hydrate(e,t)}openWidget(e,t){const{connection:n}=this.props;this.emitLayoutEvent(Nn.OPEN,{dragEvent:t,fetch:()=>n.getObject(e),widget:e})}getDashboardPlugins=on(e=>[...e.entries()].filter(([,n])=>js(n)||tt(n)).map(([n,a])=>{if(tt(a)){const{DashboardPlugin:i}=a;return o.jsx(i,{},n)}const{component:r}=a;return o.jsx(r,{},n)}));render(){const{activeTool:e,plugins:t,user:n,workspace:a,serverConfigValues:r}=this.props,{data:i}=a,{layoutConfig:l}=i,{permissions:c}=n,{canUsePanels:d}=c,{contextActions:h,isAuthFailed:u,isDisconnected:g,isPanelsMenuShown:v,isResetLayoutPromptShown:y,isSettingsMenuShown:x,unsavedNotebookCount:T,widgets:S}=this.state,O=this.getDashboardPlugins(t);return o.jsxs("div",{className:j("app-main-tabs","w-100","h-100","d-flex","flex-column",e?`active-tool-${e.toLowerCase()}`:""),onPaste:this.handlePaste,tabIndex:-1,children:[o.jsx("nav",{className:"nav-container",children:o.jsxs("div",{className:"app-main-top-nav-menus",children:[o.jsx("img",{src:Ut,alt:"Deephaven Data Labs",width:"115px",className:"ml-1"}),o.jsxs("div",{children:[o.jsxs(w,{kind:"ghost",className:"btn-panels-menu",icon:ps,onClick:()=>{},children:["Controls",o.jsx(Oe,{handleControlSelect:this.handleControlSelect,handleToolSelect:this.handleToolSelect,onClearFilter:this.handleClearFilter})]}),d&&o.jsxs(w,{kind:"ghost",className:"btn-panels-menu btn-show-panels","data-testid":"app-main-panels-button",onClick:this.handleWidgetMenuClick,icon:fs,children:["Panels",o.jsx(Rs,{isShown:v,className:"panels-menu-popper",onExited:this.handleWidgetsMenuClose,options:{placement:"bottom"},closeOnBlur:!0,interactive:!0,children:o.jsx(qo,{widgets:S,onExportLayout:this.handleExportLayoutClick,onImportLayout:this.handleImportLayoutClick,onResetLayout:this.handleResetLayoutClick,onSelect:this.handleWidgetSelect})})]}),o.jsx(w,{kind:"ghost",className:j("btn-settings-menu",{"text-warning":n.operateAs!=null&&n.operateAs!==n.name}),onClick:this.handleSettingsMenuShow,icon:o.jsxs("span",{className:"fa-layers",children:[o.jsx(E,{icon:gs,transform:"grow-3 right-1 down-1"}),g&&!u&&o.jsxs(o.Fragment,{children:[o.jsx(E,{icon:bs,color:le.background,transform:"grow-2 right-8 down-8.5 rotate-45"}),o.jsx(E,{icon:Xe,color:le.danger,transform:"shrink-5 right-6 down-6"})]})]}),tooltip:g&&!u?"Server disconnected":"User Settings"})]})]})}),o.jsxs(Qs,{emptyDashboard:o.jsx(Jo,{onAutoFillClick:this.handleAutoFillClick}),id:U,layoutConfig:l,onGoldenLayoutChange:this.handleGoldenLayoutChange,onLayoutConfigChange:this.handleLayoutConfigChange,onLayoutInitialized:this.openNotebookFromURL,hydrate:this.hydrateDefault,children:[o.jsx(jn,{hydrateConsole:q.hydrateConsole,notebooksUrl:new URL("notebooks/",document.baseURI).href}),O]}),o.jsx(Tt,{in:x,timeout:le.transitionMidMs,classNames:"slide-left",mountOnEnter:!0,unmountOnExit:!0,children:o.jsx(M,{serverConfigValues:r,onDone:this.handleSettingsMenuHide,user:n})}),o.jsx(Ns,{actions:h}),o.jsx("input",{ref:this.importElement,type:"file",accept:".json",style:{display:"none"},onChange:this.handleImportLayoutFiles}),o.jsx($s,{isOpen:g&&!u,debounceMs:1e3,children:o.jsx(Ks,{icon:Xe,title:o.jsxs(o.Fragment,{children:[o.jsx(vs,{})," Attempting to reconnect..."]}),subtitle:"Please check your network connection."})}),o.jsx(et,{confirmButtonText:"Reset",onConfirm:this.handleConfirmResetLayoutPrompt,onCancel:this.handleCancelResetLayoutPrompt,isConfirmDanger:!0,isOpen:y,headerText:T===0?"Reset Layout":"Reset layout and discard unsaved changes",bodyText:T===0?"Do you want to reset your layout? Your existing layout will be lost.":"Do you want to reset your layout? Any unsaved notebooks will be lost."}),o.jsx(et,{confirmButtonText:"Refresh",onConfirm:q.handleRefresh,isOpen:u,headerText:"Authentication failed",bodyText:"Credentials are invalid. Please refresh your browser to try and reconnect."})]})}}const oa=s=>({activeTool:Tn(s),dashboardData:Cn(s,U),layoutStorage:zo(s),plugins:wn(s),connection:Fn(s,U),session:He(s,U)?.session,sessionConfig:He(s,U)?.config,user:Dn(s),workspace:Lt(s),serverConfigValues:Yo(s)}),aa=ne(oa,{setActiveTool:It,updateDashboardData:yn,updateWorkspaceData:Sn})(sn(q));function ra(){return o.jsxs("div",{className:"app",children:[o.jsx(aa,{}),o.jsx(Os,{})]})}const ia=k.module("LocalWorkspaceStorage");class J{static STORAGE_KEY="deephaven.WorkspaceStorage";static async makeDefaultWorkspaceData(e,t){const{filterSets:n,links:a,layoutConfig:r}=await ce.getDefaultLayout(e,t?.isConsoleAvailable);return{settings:{defaultDateTimeFormat:L.DEFAULT_DATETIME_FORMAT_STRING,formatter:[],timeZone:L.DEFAULT_TIME_ZONE_ID,showTimeZone:!1,showTSeparator:!0,disableMoveConfirmation:!1,defaultDecimalFormatOptions:{defaultFormatString:N.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:R.DEFAULT_FORMAT_STRING},truncateNumbersWithPound:!1,defaultNotebookSettings:{isMinimapEnabled:!1}},layoutConfig:r,closed:[{}],links:a,filterSets:n}}static async makeDefaultWorkspace(e,t){return{data:await J.makeDefaultWorkspaceData(e,t)}}layoutStorage;constructor(e){this.layoutStorage=e}async load(e){try{return JSON.parse(localStorage.getItem(J.STORAGE_KEY)??"")}catch{return ia.info("Unable to load workspace data, initializing to default data"),J.makeDefaultWorkspace(this.layoutStorage,e)}}async save(e){return localStorage.setItem(J.STORAGE_KEY,JSON.stringify(e)),e}}class la{storageService;root;constructor(e,t=""){this.storageService=e,this.root=t}async getLayouts(){return(await this.storageService.listItems(this.root,"*.json")).map(t=>t.basename)}async getLayout(e){const n=await(await this.storageService.loadFile(`${this.root}/${e}`)).text();return JSON.parse(n)}}const Q=k.module("GrpcFileStorageTable");class he{static REFRESH_DEBOUNCE=50;storageService;baseRoot;root;currentSize=0;currentViewport;listeners=[];viewportUpdatePromise;currentViewportData;childTables=new Map;constructor(e,t="",n=t){this.storageService=e,this.baseRoot=t,this.root=n,n===t&&(this.doRefresh=De(this.doRefresh.bind(this),he.REFRESH_DEBOUNCE))}removeBaseRoot(e){return H.removeRoot(this.baseRoot,e)}getViewportData(){return this.viewportUpdatePromise||this.refreshInternal(),this.viewportUpdatePromise??Promise.resolve({items:[],offset:0})}getSnapshot(e){throw new Error("Method not implemented.")}get size(){return this.currentSize}setExpanded(e,t){const n=e.split("/");let a=n.shift();if((a===void 0||a==="")&&(a=n.shift()),a===void 0||a==="")throw new Error(`Invalid path: ${e}`);const r=n.join("/");if(t){if(!this.childTables.has(a)){const i=new he(this.storageService,this.baseRoot,`${this.root}/${a}`);this.childTables.set(a,i)}r&&this.childTables.get(a)?.setExpanded(r,t)}else this.childTables.has(a)&&(r?this.childTables.get(a)?.setExpanded(r,t):this.childTables.delete(a));this.currentViewport&&this.refreshInternal()}collapseAll(){this.childTables.clear(),this.currentViewport&&this.refreshInternal()}setSearch(e){throw new Error("Method not implemented.")}setViewport(e){this.currentViewport=e,this.refreshInternal()}setFilters(){throw new Error("Method not implemented.")}setSorts(){throw new Error("Method not implemented.")}setReversed(){throw new Error("Method not implemented.")}close(){this.listeners=[]}onUpdate(e){return this.listeners=[...this.listeners,e],()=>{this.listeners=this.listeners.filter(t=>t!==e)}}doRefresh(e){Q.debug2("doRefresh",this.root),e(this.fetchData())}refresh(){Q.debug2("refresh",this.root),this.viewportUpdatePromise?.cancel();const e=new Promise(n=>{this.doRefresh(n)}),t=K.makeCancelable(e.then(n=>{if(this.viewportUpdatePromise!==t)throw new Is;return this.currentViewportData=n,this.sendUpdate(),n}));t.catch(n=>{K.isCanceled(n)||Q.error("Error updating viewport",n)}),this.viewportUpdatePromise=t}refreshInternal(){try{this.refresh()}catch(e){K.isCanceled(e)||Q.error("Unable to refresh data",e)}}async fetchData(){const{currentViewport:e}=this;if(!e)throw new Error("No viewport set");let n=(await this.storageService.listItems(this.root)).map(a=>({type:a.type,filename:this.removeBaseRoot(a.filename),basename:a.basename,id:this.removeBaseRoot(a.filename),isExpanded:a.type==="directory"?this.childTables.has(a.basename):void 0})).sort((a,r)=>a.type!==r.type?a.type==="directory"?-1:1:a.basename.localeCompare(r.basename));for(let a=0;a<n.length;a+=1){const r=n[a],{basename:i,filename:l}=r;if(l===this.removeBaseRoot(`${this.root}/${i}`)&&r.type==="directory"){const c=this.childTables.get(i);if(c!=null){c.setViewport({top:0,bottom:e.bottom-a});const d=await c.getViewportData();n.splice(a+1,0,...d.items)}}}return this.currentSize=n.length,Q.debug2(this.root,"items",n,e),n=n.slice(e.top,e.bottom),{items:n,offset:e.top}}sendUpdate(){const{listeners:e}=this,t=this.currentViewportData??{items:[],offset:0};for(let n=0;n<e.length;n+=1)e[n](t)}}const ca=k.module("GrpcFileStorage");class Ie{static REFRESH_THROTTLE=150;storageService;tables=[];root;constructor(e,t=""){this.storageService=e,this.root=t}removeRoot(e){return H.removeRoot(this.root,e)}addRoot(e){return H.addRoot(this.root,e)}async createDirectory(e){return await this.storageService.createDirectory(this.addRoot(e)),this.refreshTables(),{type:"directory",id:e,filename:e,basename:H.getBaseName(e)}}async getTable(){const e=new he(this.storageService,this.root);return this.tables.push(e),e}async saveFile(e){const t=dh.storage.FileContents.text(e.content);return await this.storageService.saveFile(this.addRoot(e.filename),t,!0),this.refreshTables(),e}async loadFile(e){const n=await(await this.storageService.loadFile(this.addRoot(e))).text();return{filename:e,basename:H.getBaseName(e),content:n}}async copyFile(e,t){const n=await this.storageService.loadFile(this.addRoot(e));await this.storageService.saveFile(this.addRoot(t),n,!1),this.refreshTables()}async deleteFile(e){await this.storageService.deleteItem(this.addRoot(e)),this.refreshTables()}async moveFile(e,t){await this.storageService.moveItem(this.addRoot(e),this.addRoot(t)),this.refreshTables()}async info(e){const t=await this.storageService.listItems(this.addRoot(H.getPath(e)),H.getBaseName(e));if(t.length===0)throw new On;if(t.length>1)throw ca.error("More than one matching file found, should never happen.",t),new Error("More than one matching file found");const n=t[0];return{filename:this.removeRoot(n.filename),basename:n.basename,id:this.removeRoot(n.filename),type:n.type}}refreshTables=vt(()=>{this.tables.forEach(e=>e.refresh())},Ie.REFRESH_THROTTLE)}const da=k.module("AppInit");function Le(s){const{workspace:e,setActiveTool:t,setApi:n,setCommandHistoryStorage:a,setDashboardData:r,setFileStorage:i,setLayoutStorage:l,setDashboardConnection:c,setDashboardSessionWrapper:d,setPlugins:h,setUser:u,setWorkspace:g,setWorkspaceStorage:v,setServerConfigValues:y}=s,x=Pt(),T=Ws(),S=Ls(),O=Vn(),C=Vs(),p=Gs(),[f,se]=m.useState();m.useEffect(function(){h(O)},[O,h]),m.useEffect(function(){async function zt(){try{const oe=await Bs(),me=await Zs(x,S,oe),_e=T.getStorageService(),Me=new la(_e,"/layouts"),Yt=new Ie(_e,"/notebooks"),Ue=new J(Me),qt=new To,$e=await Ue.load({isConsoleAvailable:me!==void 0}),{data:pe}=$e,{settings:B}=pe;B.defaultDecimalFormatOptions===void 0&&(B.defaultDecimalFormatOptions={defaultFormatString:N.DEFAULT_FORMAT_STRING}),B.defaultIntegerFormatOptions===void 0&&(B.defaultIntegerFormatOptions={defaultFormatString:R.DEFAULT_FORMAT_STRING}),B.truncateNumbersWithPound===void 0&&(B.truncateNumbersWithPound=!1);const{shortcutOverrides:Ke={}}=B,Jt=_.isMacPlatform?Ke.mac??{}:Ke.windows??{};Object.entries(Jt).forEach(([Qt,en])=>{Re.get(Qt)?.setKeyState(en)});const Xt={filterSets:pe.filterSets,links:pe.links};n(x),t(de.DEFAULT),y(C),a(qt),r(U,Xt),i(Yt),l(Me),c(U,S),me!==void 0&&d(U,me),u(p),v(Ue),g($e)}catch(oe){da.error(oe),se(oe)}}zt()},[x,T,S,C,t,n,a,r,i,l,c,d,u,g,v,y,p]);const Pe=e==null&&f==null,ke=!Pe&&f==null,Ae=f!=null?`${f}`:null;return o.jsxs(o.Fragment,{children:[ke&&o.jsx(ra,{}),o.jsx(ys,{isLoading:Pe&&Ae==null,isLoaded:ke,errorMessage:Ae})]})}Le.propTypes={workspace:b.shape({}),workspaceStorage:b.shape({close:b.func}),setActiveTool:b.func.isRequired,setApi:b.func.isRequired,setCommandHistoryStorage:b.func.isRequired,setDashboardData:b.func.isRequired,setFileStorage:b.func.isRequired,setLayoutStorage:b.func.isRequired,setDashboardConnection:b.func.isRequired,setDashboardSessionWrapper:b.func.isRequired,setPlugins:b.func.isRequired,setUser:b.func.isRequired,setWorkspace:b.func.isRequired,setWorkspaceStorage:b.func.isRequired};Le.defaultProps={workspace:null,workspaceStorage:null};const ua=s=>({workspace:Lt(s),workspaceStorage:Gn(s)}),bt=ne(ua,{setActiveTool:It,setApi:In,setCommandHistoryStorage:Ln,setDashboardData:Pn,setFileStorage:kn,setLayoutStorage:Co,setDashboardConnection:An,setDashboardSessionWrapper:_n,setPlugins:Mn,setUser:Un,setWorkspace:$n,setWorkspaceStorage:Kn,setServerConfigValues:Wn})(Le),ha=document.location.pathname;function ma(){return o.jsx(an,{basename:ha,children:o.jsxs(rn,{children:[o.jsx(We,{exact:!0,path:"/",component:bt}),o.jsx(We,{path:"/notebooks/:notebookPath+",component:bt}),o.jsx(ln,{from:"*",to:"/"})]})})}function wa(){return Ps.register(new URL("./download/serviceWorker.js",window.location.href)),ks.init({getWorker:()=>new dn}),window["__react-beautiful-dnd-disable-dev-warnings"]=!0,o.jsx(cn,{store:Ot,children:o.jsx(ma,{})})}export{wa as AppRoot,wa as default};
6
- //# sourceMappingURL=AppRoot-c9153f4a.js.map
6
+ //# sourceMappingURL=AppRoot-e4b51b3e.js.map