@perspective-dev/viewer-datagrid 4.1.1 → 4.2.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.
- package/dist/cdn/perspective-viewer-datagrid.js +4 -4
- package/dist/cdn/perspective-viewer-datagrid.js.map +4 -4
- package/dist/esm/event_handlers/click/edit_click.d.ts +1 -1
- package/dist/esm/model/create.d.ts +1 -1
- package/dist/esm/perspective-viewer-datagrid.js +3 -3
- package/dist/esm/perspective-viewer-datagrid.js.map +3 -3
- package/dist/esm/style_handlers/body.d.ts +1 -1
- package/dist/esm/style_handlers/column_header.d.ts +1 -1
- package/dist/esm/style_handlers/consolidated.d.ts +2 -5
- package/dist/esm/style_handlers/table_cell/boolean.d.ts +1 -5
- package/dist/esm/style_handlers/table_cell/cell_flash.d.ts +2 -2
- package/dist/esm/style_handlers/table_cell/datetime.d.ts +1 -5
- package/dist/esm/style_handlers/table_cell/row_header.d.ts +2 -2
- package/dist/esm/style_handlers/types.d.ts +2 -5
- package/dist/esm/types.d.ts +1 -1
- package/package.json +3 -3
- package/src/ts/color_utils.ts +0 -1
- package/src/ts/event_handlers/click/edit_click.ts +13 -10
- package/src/ts/event_handlers/dispatch_click.ts +2 -4
- package/src/ts/event_handlers/expand_collapse.ts +4 -3
- package/src/ts/event_handlers/focus.ts +1 -1
- package/src/ts/event_handlers/header_click.ts +1 -1
- package/src/ts/event_handlers/keydown/edit_keydown.ts +2 -2
- package/src/ts/event_handlers/row_select_click.ts +6 -4
- package/src/ts/event_handlers/select_region.ts +23 -11
- package/src/ts/event_handlers/sort.ts +1 -1
- package/src/ts/get_cell_config.ts +1 -0
- package/src/ts/model/create.ts +11 -18
- package/src/ts/style_handlers/body.ts +16 -21
- package/src/ts/style_handlers/column_header.ts +15 -4
- package/src/ts/style_handlers/consolidated.ts +8 -13
- package/src/ts/style_handlers/focus.ts +4 -10
- package/src/ts/style_handlers/group_header.ts +6 -3
- package/src/ts/style_handlers/table_cell/boolean.ts +2 -5
- package/src/ts/style_handlers/table_cell/cell_flash.ts +2 -2
- package/src/ts/style_handlers/table_cell/datetime.ts +2 -5
- package/src/ts/style_handlers/table_cell/row_header.ts +8 -7
- package/src/ts/style_handlers/types.ts +6 -6
- package/src/ts/types.ts +15 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type RegularTable, type DatagridModel, type PerspectiveViewerElement } from "../../types.js";
|
|
2
2
|
export declare function write_cell(table: RegularTable, model: DatagridModel, active_cell: HTMLElement): boolean;
|
|
3
3
|
export declare function clickListener(this: DatagridModel, table: RegularTable, _viewer: PerspectiveViewerElement, event: MouseEvent): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Table, View } from "@perspective-dev/client";
|
|
2
|
-
import type
|
|
2
|
+
import { type DatagridModel, type DatagridPluginElement, type RegularTable } from "../types.js";
|
|
3
3
|
export declare function createModel(this: DatagridPluginElement, regular: RegularTable, table: Table, view: View, extend?: Partial<DatagridModel>): Promise<DatagridModel>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import"regular-table";var M=Symbol("Perspective Column Config");import Xe from"chroma-js";var Z=class{format(t){return t?"true":"false"}},Je={float:{format:{style:"decimal",minimumFractionDigits:2,maximumFractionDigits:2}},datetime:{format:{dateStyle:"short",timeStyle:"medium"}},date:{format:{dateStyle:"short"}}},$=class{_formatters;constructor(){this._formatters=new Map}create_datetime_formatter(t,o){if(o.date_format?.format!=="custom"){let r={timeZone:o.date_format?.timeZone,dateStyle:o.date_format?.dateStyle==="disabled"?void 0:o.date_format?.dateStyle??"short",timeStyle:o.date_format?.timeStyle==="disabled"?void 0:o.date_format?.timeStyle??"medium"};return new Intl.DateTimeFormat(navigator.languages,r)}else{let r={timeZone:o.date_format?.timeZone,hour12:o.date_format?.hour12??!0,fractionalSecondDigits:o.date_format?.fractionalSecondDigits};return o.date_format?.year!=="disabled"&&(r.year=o.date_format?.year??"2-digit"),o.date_format?.month!=="disabled"&&(r.month=o.date_format?.month??"numeric"),o.date_format?.day!=="disabled"&&(r.day=o.date_format?.day??"numeric"),o.date_format?.weekday&&o.date_format?.weekday!=="disabled"&&(r.weekday=o.date_format.weekday),o.date_format?.hour!=="disabled"&&(r.hour=o.date_format?.hour??"numeric"),o.date_format?.minute!=="disabled"&&(r.minute=o.date_format?.minute??"numeric"),o.date_format?.second!=="disabled"&&(r.second=o.date_format?.second??"numeric"),new Intl.DateTimeFormat(navigator.languages,r)}}create_date_formatter(t,o){let r={timeZone:"utc",dateStyle:o.date_format?.dateStyle==="disabled"?void 0:o.date_format?.dateStyle??"short"};return new Intl.DateTimeFormat(navigator.languages,r)}create_number_formatter(t,o){let r=o.number_format??Je[t]?.format;return new Intl.NumberFormat(navigator.languages,r)}create_boolean_formatter(t,o){return new Z}get(t,o){let r=[t,...Object.values(o.date_format??{}),...Object.values(o.number_format??{})].join("-");return this._formatters.has(r)||(t==="date"?this._formatters.set(r,this.create_date_formatter(t,o)):t==="datetime"?this._formatters.set(r,this.create_datetime_formatter(t,o)):t==="integer"||t==="float"?this._formatters.set(r,this.create_number_formatter(t,o)):t==="boolean"?this._formatters.set(r,this.create_boolean_formatter(t,o)):this._formatters.set(r,!1)),this._formatters.get(r)}};var le=new $,re=1;function se(e,t){return le.get(e,t)}function V(e,t,o={},r=!1){if(t===null)return null;let s=r&&this._table_schema[e]||this._schema[e]||"string",l=o[e]||{};if((s==="integer"||s==="float")&&l?.number_fg_mode==="bar"){let a=Math.max(0,Math.min(re,Math.abs(t/l.fg_gradient)*re)),i=this._div_factory.get(),d=t>=0?"left":"right",p=(a*100).toFixed(2);return i.setAttribute("style",`width:calc(${p}% - 4px);position:absolute;${d}:2px;height:80%;top:10%;pointer-events:none;`),i}else if(l?.format==="link"&&s==="string"){let a=document.createElement("a");return a.setAttribute("href",t),a.setAttribute("target","_blank"),a.textContent=t,a}else if(l?.format==="bold"&&s==="string"){let a=document.createElement("b");return a.textContent=t,a}else if(l?.format==="italics"&&s==="string"){let a=document.createElement("i");return a.textContent=t,a}else{let a=le.get(s,l);return a?a.format(t):t}}function*ne(e=[],t,o){let r=o[M]||{};for(let s of e){let l=["TOTAL",...s],n=l[l.length-1],a=l.slice(0,l.length-1).fill(""),i=V.call(this,t[a.length-1],n,r,!0);i instanceof HTMLElement?a=a.concat(i):a=a.concat({toString:()=>i}),a.length=t.length+1,yield a}}function*ie(e=[],t,o){let r=o[M]||{};for(let s of e){let l=[""];for(let n in s)l.push(V.call(this,t[n],s[n],r,!0));yield s}}function ae(e){let t,o,r,s,l;return async function(a,i,d,p,c){let m={},u={start_row:d,start_col:i,end_row:c,end_col:p,id:!0},g=null;if(p-i>0&&c-d>0){this._is_old_viewport=this._last_window?.start_row===d&&this._last_window?.end_row===c&&this._last_window?.start_col===i&&this._last_window?.end_col===p;let[k,A]=await Promise.all([this._view.to_columns_string(u),this._view.num_columns()]);g=A,m=JSON.parse(k);let R=Object.keys(m).filter(v=>v!=="__ROW_PATH__"&&v!=="__ID__"),D=!1;for(let v=0;v<R.length;v++)this._column_paths[u.start_col+v]!==R[v]&&(D=!0,this._column_paths[u.start_col+v]=R[v]);if(D){let[v,h]=await Promise.all([this._view.schema(),this._view.expression_schema()]);this._schema={...v,...h};for(let C=0;C<R.length;C++){let oe=R[C].split("|")[this._config.split_by.length];this._is_editable[C+u.start_col]=!!this._table_schema[oe],this._column_types[C+u.start_col]=this._schema[oe]}}this._last_window=u,this._ids=m.__ID__||Array(c-d).fill(null).map((v,h)=>[h+d]),this._reverse_columns=this._column_paths.slice(i,p).reduce((v,h,C)=>(v.set(h,C),v),new Map),this._reverse_ids=this._ids?.reduce((v,h,C)=>(v.set(h?.join("|"),C),v),new Map)}else this._div_factory.clear(),g=await this._view.num_columns();let _=[],b=[],f=[],w=[],y=e.hasAttribute("settings");for(let k=i;k<Math.min(p,this._column_paths.length);++k){let A=this._column_paths[k],L=A.split("|"),R=m[A]||new Array(c-d).fill(null),D=Math.min(a[M]?.[L[this._config.split_by.length]]?.aggregate_depth||0,this._config.group_by.length);_.push(R.map((v,h)=>(m?.__ROW_PATH__?.[h]?.length??0)<D?"":V.call(this,L[this._config.split_by.length],v,a[M]||{}))),b.push(R),y&&L.push(""),f.push(L),w.push(A)}p-i>0&&c-d>0&&(this.last_column_paths=o,this.last_meta=t,this.last_ids=r,this.last_reverse_ids=s,this.last_reverse_columns=l,o=w,t=b,r=this._ids,s=this._reverse_ids,l=this._reverse_columns);let E=m.__ROW_PATH__!==void 0,S=Array.from((E?ne:ie).call(this,m.__ROW_PATH__,this._config.group_by,a)),N=S[0]?.length;return{num_column_headers:this._config.split_by.length+(y?2:1),num_row_headers:N,num_rows:this._num_rows,num_columns:g,row_headers:S,column_headers:f,data:_,metadata:b,column_header_merge_depth:Math.max(0,this._config.split_by.length)}}}import ce from"chroma-js";function X(e,t){return ce.mix(e,`rgb(${t[0]},${t[1]},${t[2]})`,.5).hex()}function P([e,t,o,r],s=[255,255,255]){function l(n,a){return((1-r)*(s[n]/255)+r*(a/255))*255}return[l(0,e),l(1,t),l(2,o)]}function O([e,t,o]){return Math.sqrt(e*e*.299+t*t*.587+o*o*.114)>130?"#161616":"#ffffff"}function Ze(e){let[t,o,r]=e.rgb(),[s,l,n]=e.set("hsl.h",(e.get("hsl.h")-15)%360).rgb(),[a,i,d]=e.set("hsl.h",(e.get("hsl.h")+15)%360).rgb();return`linear-gradient(to right top,rgb(${s},${l},${n}),rgb(${t},${o},${r}) 50%,rgb(${a},${i},${d}))`}function T(e){let t=ce(e),o=Ze(t),r=t.rgb();return[e,r[0],r[1],r[2],o,`rgba(${r[0]},${r[1]},${r[2]},1)`,`rgba(${r[0]},${r[1]},${r[2]},0)`]}function B(e,t,o){let r=window.getComputedStyle(e).getPropertyValue(t).trim();return r.length>0?r:o}var Q=class{_name;_elements;_index;constructor(t){this._name=t,this._elements=[],this._index=0}clear(){this._index=0}get(){this._elements[this._index]||(this._elements[this._index]=document.createElement(this._name));let t=this._elements[this._index];return this._index+=1,t}};function Qe(e){return e.x!==void 0&&e.x>=0?this._column_types[e.x]:this._row_header_types[e.row_header_x-1]}async function Y(e,t,o,r={}){let s=await o.get_config();if(this?.model?._config){let x=this.model._config,k=x.group_by.length!==s.group_by.length,A=(x.group_by.length===0||s.group_by.length===0)&&k;if(!k)for(let h in x.group_by)k||=s.group_by[h]!==x.group_by[h];let L=x.split_by.length!==s.split_by.length;if(L)for(let h in x.split_by)L||=s.split_by[h]!==x.split_by[h];let R=x.columns.length!==s.columns.length;if(R)for(let h in x.columns)R||=s.columns[h]!==x.columns[h];let D=x.filter.length!==s.filter.length;if(D)for(let h in x.filter)for(let C in s.filter[h])D||=s.filter[h][C]!==x.filter[h][C];let v=x.sort.length!==s.sort.length;if(v)for(let h in x.sort)for(let C in s.sort[h])v||=s.sort[h][C]!==x.sort[h][C];this._reset_scroll_top=k,this._reset_scroll_left=L,this._reset_select=k||L||D||v||R,this._reset_column_size=L||k||R||A}let[l,n,a,i,d]=await Promise.all([t.schema(),o.num_rows(),o.schema(),o.expression_schema(),this.parentElement.getEditPort()]),p=Xe(B(e,"--plugin--background","#FFFFFF")).rgb(),c=T(B(e,"--rt-pos-cell--color","#338DCD")),m=T(B(e,"--rt-neg-cell--color","#FF5942")),u=T(X(c[0],p)),g=T(X(m[0],p)),_=T(B(e,"--active--color","#ff0000")),b={...a,...i},f={...l,...i},w=[],y=[],E=[],S=this._edit_mode||"READ_ONLY";this._edit_button.dataset.editMode=S;let N=Object.assign(r,{_edit_port:d,_view:o,_table:t,_table_schema:f,_config:s,_num_rows:n,_schema:b,_ids:[],_plugin_background:p,_color:_,_pos_fg_color:c,_neg_fg_color:m,_pos_bg_color:u,_neg_bg_color:g,_column_paths:w,_column_types:E,_is_editable:y,_edit_mode:S,_selection_state:{selected_areas:[],dirty:!1},_row_header_types:s.group_by.map(x=>f[x]),_series_color_map:new Map,_series_color_seed:new Map,get_psp_type:Qe,_div_factory:r._div_factory||new Q("div")});return e.setDataListener(ae(this.parentElement).bind(N,e),{virtual_mode:window.getComputedStyle(e).getPropertyValue("--datagrid-virtual-mode")?.trim()||"both"}),N}var z=["READ_ONLY","EDIT","SELECT_ROW","SELECT_COLUMN","SELECT_REGION"];function I(e){typeof e>"u"&&(e=z[(z.indexOf(this._edit_mode)+1)%z.length]),this.parentElement?.setSelection?.(),this._edit_mode=e,this.model&&(this.model._edit_mode=e,this.model._selection_state={selected_areas:[],dirty:!0}),this._edit_button!==void 0&&(this._edit_button.dataset.editMode=e),this.dataset.editMode=e}function W(e){typeof e>"u"&&(e=!this._is_scroll_lock),this._is_scroll_lock=e,this.classList.toggle("sub-cell-scroll-disabled",e),this._scroll_lock!==void 0&&this._scroll_lock.classList.toggle("lock-scroll",e)}function F(e,t=!1){if(!this._initialized)return;t&&(this._cached_column_sizes=e);let o={},{group_by:r}=this.model._config,s=r?.length>0?r.length+1:0;for(let l of Object.keys(e))if(l==="__ROW_PATH__")o[s-1]=e[l];else{let n=this.model._column_paths.indexOf(l);o[n+s]=e[l]}this.regular_table.restoreColumnSizes(o)}function j(){if(!this._initialized)return{};if(this._cached_column_sizes){let s=this._cached_column_sizes;return this._cached_column_sizes=void 0,s}let e=this.regular_table.saveColumnSizes(),{group_by:t}=this.model._config,o=t?.length>0?t.length+1:0,r={};for(let s of Object.keys(e)){let l=Number(s);if(e[l]!==void 0){let n=l-o;n>-1?r[this.model._column_paths[n]]=e[l]:n===-1&&(r.__ROW_PATH__=e[l])}}return r}function de(e,t,o){let r=Array.from(e.children[0].children[0].children),s=r.length,l=t.hasAttribute("settings");if(s<=1?r[0]?.removeAttribute("id"):r.forEach((n,a)=>{let i=l?1:0,d=a===s-(i+1)?"psp-column-titles":a===s-i?"psp-column-edit-buttons":null;d?n.setAttribute("id",d):n.removeAttribute("id")}),t.classList.toggle("psp-menu-open",!!o),l&&s>=2){let n=Array.from(r[s-2].children),a=Array.from(r[s-1].children);if(n&&a){r.slice(0,s-2).forEach(i=>{Array.from(i.children).forEach(d=>{d.classList.toggle("psp-menu-open",!1)})});for(let i=0;i<n.length;i++){let d=n[i],p=a[i],c=d.textContent===o;if(d.classList.toggle("psp-menu-open",c),p.classList.toggle("psp-menu-open",c),this._config.columns.length>1)for(let m of e.querySelectorAll("td")){let u=e.getMeta(m);if(!u?.column_header)continue;let g=u.column_header[u.column_header.length-2]===o;m.classList.toggle("psp-menu-open",g)}}}}}function pe(e,t,o){let r=this._config.group_by.length,s=this._column_settings_selected_column;for(let{element:l,metadata:n}of e.cells){if(!n)continue;let a=n.column_header?.[this._config.split_by.length],i=this._config.sort.find(b=>b[0]===a),d=n.row_header_x===r,p=typeof n.x>"u";d=d||n.x!==void 0&&(n.x+1)%this._config.columns.length===0,l.classList.toggle("psp-header-border",d),l.classList.toggle("psp-header-group",!1),l.classList.toggle("psp-header-leaf",!0),l.classList.toggle("psp-is-top",!1),l.classList.toggle("psp-header-corner",p),l.classList.toggle("psp-header-sort-asc",!o&&!!i&&i[1]==="asc"),l.classList.toggle("psp-header-sort-desc",!o&&!!i&&i[1]==="desc"),l.classList.toggle("psp-header-sort-col-asc",!o&&!!i&&i[1]==="col asc"),l.classList.toggle("psp-header-sort-col-desc",!o&&!!i&&i[1]==="col desc"),l.classList.toggle("psp-header-sort-abs-asc",!o&&!!i&&i[1]==="asc abs"),l.classList.toggle("psp-header-sort-abs-desc",!o&&!!i&&i[1]==="desc abs"),l.classList.toggle("psp-header-sort-abs-col-asc",!o&&!!i&&i[1]==="col asc abs"),l.classList.toggle("psp-header-sort-abs-col-desc",!o&&!!i&&i[1]==="col desc abs");let c=this.get_psp_type(n),m=c==="integer"||c==="float",u=c==="string",g=c==="date",_=c==="datetime";if(l.classList.toggle("psp-align-right",m),l.classList.toggle("psp-align-left",!m),l.classList.toggle("psp-menu-enabled",(u||m||g||_)&&!p&&n.column_header_y===this._config.split_by.length+1),l.classList.toggle("psp-sort-enabled",(u||m||g||_)&&!p&&n.column_header_y===this._config.split_by.length),l.classList.toggle("psp-is-width-override",t.saveColumnSizes()[n.size_key]!==void 0),this._config.columns.length>1&&s){let b=n.column_header?.[n.column_header.length-2]===s;l.classList.toggle("psp-menu-open",b)}}}var et={desc:"asc",asc:void 0,"desc abs":"asc abs","asc abs":void 0},tt={desc:"asc",asc:"col desc","desc abs":"asc abs","asc abs":"col desc abs","col desc":"col asc","col asc":void 0,"col desc abs":"col asc abs","col asc abs":void 0};async function me(e,t,o,r){let s=e.getMeta(r);if(!s?.column_header)return;let l=s.column_header[this._config.split_by.length],n=o.ctrlKey||o.metaKet||o.altKey?ot:rt,a=o.shiftKey,i=n.call(this,l,a);await t.restore({sort:i})}function ot(e,t){let o=[],r=!1;for(let s of this._config.sort){let[l,n]=s;if(l===e){r=!0;let a=ue.call(this,e,n,t);a&&o.push(a)}else o.push(s)}return r||o.push([e,t?"desc abs":"desc"]),o}function rt(e,t){for(let[o,r]of this._config.sort)if(o===e){let s=ue.call(this,e,r,t);return s?[s]:[]}return[[e,t?"desc abs":"desc"]]}function ue(e,t,o){let s=this._config.split_by.length>0?tt:et,l=t?s[t]:"desc";if(l)return[e,l]}async function ge(e,t){let o=e.getMeta(t.target);if(!o?.row_header)return;let r=t.target.classList.contains("psp-tree-label-collapse");t.shiftKey&&r?this._view.set_depth(o.row_header.filter(s=>s!==void 0).length-2):t.shiftKey?this._view.set_depth(o.row_header.filter(s=>s!==void 0).length-1):r?this._view.collapse(o.y):this._view.expand(o.y),this._num_rows=await this._view.num_rows(),this._num_columns=await this._view.num_columns(),e.draw()}async function _e(e,t,o){if(o.which!==1)return;let r=o.target;if(r?.tagName!=="A"){for(;r&&r.tagName!=="TD"&&r.tagName!=="TH";)if(r=r.parentElement,!r||!e.contains(r))return;if(r){if(r.classList.contains("psp-tree-label")){ge.call(this,e,o);return}if(r.classList.contains("psp-menu-enabled")){let l=e.getMeta(r)?.column_header?.[this._config.split_by.length];await t.toggleColumnSettings(l)}else r.classList.contains("psp-sort-enabled")&&me.call(this,e,t,o,r)}}}function be(e,t){if(t.which!==1)return;let o=t.target;for(;o&&o.tagName!=="TD"&&o.tagName!=="TH";)if(o=o.parentElement,!o||!e.contains(o))return;o&&(o.classList.contains("psp-tree-label")&&t.offsetX<26||o.classList.contains("psp-header-leaf")&&!o.classList.contains("psp-header-corner"))&&t.stopImmediatePropagation()}function ee(e,t,o){let r=e.getMeta(o);if(!r)return!1;let s=t._schema[t._column_paths[r.x]],l=o.textContent||"",n=t._ids[r.y-r.y0][0];if(s==="float"||s==="integer"){let i=parseFloat(l.replace(/,/g,""));if(isNaN(i))return!1;l=i}else if(s==="date"||s==="datetime"){let i=Date.parse(l);if(isNaN(i))return!1;l=i}else s==="boolean"&&(l=l==="true"?!1:l==="false"?!0:null);let a={__INDEX__:n,[t._column_paths[r.x]]:l};return t._table.update([a],{port_id:t._edit_port,format:null}),!0}function fe(e,t,o){let r=e.getMeta(o.target);if(typeof r?.x<"u"){let s=this._is_editable[r.x],l=this.get_psp_type(r)==="boolean",n=o.target.classList.contains("psp-null");s&&l&&!n&&ee(e,this,o.target)}}function he(e,t,o){let r=o.get(t),s=t.getRootNode();if(r){for(let{element:l,metadata:n}of e)if(n.x===r.x&&n.y===r.y){s.activeElement!==l&&l.focus({preventScroll:!0});return}document.activeElement!==document.body&&t.contains(s.activeElement)&&s.activeElement.blur()}}function ye(e,t){let o=t.get(e);if(!o)return!1;let r=e.getRootNode(),s=e.children[0]?.children[1];if(s)for(let l of s.children)for(let n of l.children){let a=e.getMeta(n);if(a&&a.x===o.x&&a.y===o.y)return r.activeElement!==n&&n.focus({preventScroll:!0}),!0}return document.activeElement!==document.body&&e.contains(r.activeElement)&&r.activeElement.blur(),!1}function st(e){let t;return async function(...o){if(t){await t;return}let r;t=new Promise(l=>r=l);let s=await e.apply(this,o);return t=void 0,r(),s}}function ve(){if(this.isContentEditable){let e=this.getRootNode().getSelection()?.getRangeAt(0);if(!e)return 0;let t=e.cloneRange();return t.selectNodeContents(this),t.setEnd(e.endContainer,e.endOffset),t.toString().length}else return this.selectionStart||0}var H=st(async function(e,t,o,r,s){let l=e.getMeta(o);if(!l)return;let n=this._column_paths.length,a=this._num_rows,i=t.get(e);if(!i)return;l.x+r<n&&0<=l.x+r&&(i.x=l.x+r),l.y+s<a&&0<=l.y+s&&(i.y=l.y+s);let d=Math.max(l.x0-10,0),p=Math.min(l.x0+10,n),c=Math.max(l.y0-5,0),m=Math.min(l.y0+10,a),u=l.x0+r,g=l.y0+s;for(;!ye(e,t)&&u>=d&&u<p&&g>=c&&g<m;)await e.scrollToCell(u,g),t.set(e,i),u+=r,g+=s});function nt(e,t,o){let r=t.getMeta(o);return r!==void 0&&r.y===e._num_rows-1}function we(e,t,o,r){let s=e.getRootNode().activeElement;switch(r.target.classList.remove("psp-error"),r.key){case"Enter":r.preventDefault(),nt(this,e,s)?(s.blur(),o.delete(e)):r.shiftKey?H.call(this,e,o,s,0,-1):H.call(this,e,o,s,0,1);break;case"ArrowLeft":ve.call(s)===0&&(r.preventDefault(),H.call(this,e,o,s,-1,0));break;case"ArrowUp":r.preventDefault(),H.call(this,e,o,s,0,-1);break;case"ArrowRight":ve.call(s)===(s.textContent?.length||0)&&(r.preventDefault(),H.call(this,e,o,s,1,0));break;case"ArrowDown":r.preventDefault(),H.call(this,e,o,s,0,1);break;default:}}function K(e,t=!1){let o=this._config.group_by.length===0&&this._config.split_by.length===0,r=e.hasAttribute("selectable"),s=e.children[0],l=t||s?._edit_mode==="EDIT";return o&&!r&&l}function xe(e,t,o,r){if(this._edit_mode==="EDIT"){if(!K.call(this,t))return;we.call(this,e,t,o,r)}else console.debug(`Mode ${this._edit_mode} for "keydown" event not yet implemented`)}function Ee(e,t,o){if(this._edit_mode==="EDIT"){if(!K.call(this,t))return;fe.call(this,e,t,o)}else this._edit_mode==="READ_ONLY"||this._edit_mode==="SELECT_COLUMN"||this._edit_mode==="SELECT_ROW"||this._edit_mode==="SELECT_REGION"||console.debug(`Mode ${this._edit_mode} for "click" event not yet implemented`)}function Ce(e,t,o,r){if(K.call(this,t)&&o.has(e)){let s=r.target;s.classList.remove("psp-error");let l=o.get(e);o.delete(e),l.content!==s.textContent&&(ee(e,this,s)||(s.textContent=l.content||"",s.classList.add("psp-error"),s.focus()))}}function ke(e,t,o,r){let s=r.target,l=e.getMeta(s);if(l){let n={x:l.x,y:l.y,content:s.textContent||void 0};o.set(e,n)}}async function U({_view:e,_config:t},o,r){let s=t.group_by,l=t.split_by,n=o>=0?o:0,a=n+1,i=await e.to_json({start_row:n,end_row:a}),p=i.map(f=>f.__ROW_PATH__)[0]||[],c=s.map((f,w)=>{let y=p[w];return y?[f,"==",y]:void 0}).filter(f=>f!==void 0),m=s.length>0?r+1:r,u=Object.keys(i[0])[m],g={row:i[0],column_names:[],config:{filter:[]}},_=[];if(u){let f=u.split("|");g.column_names=[f[l.length]],_=l.map((w,y)=>{let E=f[y];return E?[w,"==",E]:void 0}).filter(w=>w!==void 0).filter(([,,w])=>w!=="__ROW_PATH__")}let b=t.filter.concat(c).concat(_);return g.config={filter:b},g}async function Me(e,t,o,r){let s=e.getMeta(r.target);if(!t.hasAttribute("selectable")||r.handled||r.shiftKey||r.button!==0||(r.stopImmediatePropagation(),!s))return;let l=this._ids?.[s.y-s.y0];if(s&&s.y>=0){let n=o.get(e),a=!!n&&n.reduce((u,g,_)=>u&&g===l[_],!0),i=!!n&&l.length===n.length&&a,d={selected:!i,row:{},config:{filter:[]}},{row:p,column_names:c,config:m}=await U(this,s.y,s.x);i?(o.delete(e),d={...d,row:p,config:{filter:structuredClone(this._config.filter)}}):(o.set(e,l),d={...d,row:p,column_names:c,config:m}),await e.draw({preserve_width:!0}),r.handled=!0,t.dispatchEvent(new CustomEvent("perspective-select",{bubbles:!0,composed:!0,detail:d}))}}async function Se(e,t,o){o.delete(e);for(let r of e.querySelectorAll("td,th"))r.classList.toggle("psp-row-selected",!1),r.classList.toggle("psp-row-subselected",!1)}async function Re(e,t,o){let r=e.getMeta(o.target);if(!r)return;let{x:s,y:l}=r,{row:n,column_names:a,config:i}=await U(this,l,s);t.dispatchEvent(new CustomEvent("perspective-click",{bubbles:!0,composed:!0,detail:{row:n,column_names:a,config:i}}))}var at="mouse-selected-area",Te=(e,t,{className:o=at,selected:r=[]}={})=>(e.model._selection_state={selected_areas:r,dirty:!0},t.addEventListener("mousedown",ct(e,t,o)),t.addEventListener("mouseover",dt(e,t,o)),t.addEventListener("mouseup",pt(e,t,o)),t.addStyleListener(()=>G(e,t,o)),t),ct=(e,t,o)=>r=>{let s=r;if(s.button===0&&(e.model._edit_mode==="SELECT_REGION"||e.model._edit_mode==="SELECT_ROW"||e.model._edit_mode==="SELECT_COLUMN")){e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES={};let l=t.getMeta(s.target);if(l&&l.x!==void 0&&l.y!==void 0){e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES={x:l.x,y:l.y},e.model._selection_state.old_selected_areas=e.model._selection_state.selected_areas,e.model._selection_state.selected_areas=[];let n={x0:l.x,x1:l.x,y0:l.y,y1:l.y};e.model._selection_state.potential_selection=n,G(e,t,o,e.model._selection_state.selected_areas.concat([n]));return}}e.model._selection_state.selected_areas=[]},dt=(e,t,o)=>r=>{let s=r;if((e.model._edit_mode==="SELECT_REGION"||e.model._edit_mode==="SELECT_ROW"||e.model._edit_mode==="SELECT_COLUMN")&&e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES&&e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x!==void 0){let l=t.getMeta(s.target);if(l&&l.x!==void 0&&l.y!==void 0){let n={x0:Math.min(l.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),x1:Math.max(l.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),y0:Math.min(l.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y),y1:Math.max(l.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y)};e.model._selection_state.potential_selection=n,G(e,t,o,e.model._selection_state.selected_areas.concat([n]))}}},pt=(e,t,o)=>r=>{let s=r;if(e.model._edit_mode==="SELECT_REGION"||e.model._edit_mode==="SELECT_ROW"||e.model._edit_mode==="SELECT_COLUMN"){let l=t.getMeta(s.target);if(!l)return;if((e.model._selection_state.old_selected_areas?.length??0)>0){let n=e.model._selection_state.old_selected_areas[0];if(n.x0===n.x1&&n.y0===n.y1&&n.x0===l.x&&n.y0===l.y){e.model._selection_state.selected_areas=[],e.model._selection_state.old_selected_areas=[],e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES={},e.model._selection_state.potential_selection=void 0,G(e,t,o,[]);return}}if(e.model._selection_state.old_selected_areas=[],e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES&&e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x!==void 0&&l.x!==void 0&&l.y!==void 0){let n={x0:Math.min(l.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),x1:Math.max(l.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),y0:Math.min(l.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y),y1:Math.max(l.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y)};e.model._selection_state.selected_areas.push(n),G(e,t,o)}e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES={},e.model._selection_state.potential_selection=void 0}};function mt(e,t,{x0:o,x1:r,y0:s,y1:l}){let n={},a=t.model._edit_mode;o!==void 0&&["SELECT_COLUMN","SELECT_REGION"].indexOf(a)>-1&&(n.start_col=o),r!==void 0&&["SELECT_COLUMN","SELECT_REGION"].indexOf(a)>-1&&(n.end_col=r+1),s!==void 0&&["SELECT_ROW","SELECT_REGION"].indexOf(a)>-1&&(n.start_row=s),l!==void 0&&["SELECT_ROW","SELECT_REGION"].indexOf(a)>-1&&(n.end_row=l+1),e.setSelection(n)}var G=(e,t,o,r)=>{if(e.model._edit_mode==="SELECT_REGION"||e.model._edit_mode==="SELECT_ROW"||e.model._edit_mode==="SELECT_COLUMN"){r=e.model._selection_state.selected_areas.slice(0),e.model._selection_state.potential_selection&&r.push(e.model._selection_state.potential_selection);let s=t.querySelectorAll("tbody td");if(r.length>0)mt(e.parentElement,e,r[0]),ut(e,t,r,o);else{e.parentElement.setSelection();for(let l of s)l.classList.remove(o)}}else if(e.model._selection_state.dirty){e.model._selection_state.dirty=!1;let s=t.querySelectorAll("tbody td");for(let l of s)l.classList.remove(o)}},ut=(e,t,o,r)=>{if(e.model._edit_mode==="SELECT_REGION"&&o.length>0){let s=t.querySelectorAll("tbody td");for(let l of s){let n=t.getMeta(l);if(!n)continue;let a=!1;for(let{x0:i,x1:d,y0:p,y1:c}of o)i!==void 0&&p!==void 0&&d!==void 0&&c!==void 0&&i<=n.x&&n.x<=d&&p<=n.y&&n.y<=c&&(a=!0,e.model._selection_state.dirty=!0,l.classList.add(r));a||l.classList.remove(r)}}else if(e.model._edit_mode==="SELECT_ROW"&&o.length>0){let s=t.querySelectorAll("tbody td");for(let l of s){let n=t.getMeta(l);if(!n)continue;let a=!1;for(let{x0:i,x1:d,y0:p,y1:c}of o)i!==void 0&&p!==void 0&&d!==void 0&&c!==void 0&&p<=n.y&&n.y<=c&&(e.model._selection_state.dirty=!0,a=!0,l.classList.add(r));a||l.classList.remove(r)}}else if(e.model._edit_mode==="SELECT_COLUMN"&&o.length>0){let s=t.querySelectorAll("tbody td");for(let l of s){let n=t.getMeta(l);if(!n)continue;let a=!1;for(let{x0:i,x1:d,y0:p,y1:c}of o)i!==void 0&&p!==void 0&&d!==void 0&&c!==void 0&&i<=n.x&&n.x<=d&&(e.model._selection_state.dirty=!0,a=!0,l.classList.add(r));a||l.classList.remove(r)}}};function Le(e,t,o){if(e.length===0)return;let r=this._column_settings_selected_column,s=e.length,l=o.hasAttribute("settings");if(s<=1?e[0]?.row.removeAttribute("id"):e.forEach(({row:i},d)=>{let p=l?1:0,c=d===s-(p+1)?"psp-column-titles":d===s-p?"psp-column-edit-buttons":null;c?i.setAttribute("id",c):i.removeAttribute("id")}),o.classList.toggle("psp-menu-open",!!r),l&&s>=2){let i=e[s-2],d=e[s-1];if(i&&d){e.slice(0,s-2).forEach(({cells:p})=>{p.forEach(({element:c})=>{c.classList.toggle("psp-menu-open",!1)})});for(let p=0;p<i.cells.length;p++){let c=i.cells[p]?.element,m=d.cells[p]?.element;if(!c||!m)continue;let u=c.textContent===r;c.classList.toggle("psp-menu-open",u),m.classList.toggle("psp-menu-open",u)}}}let n=this._config.split_by.length;if(n<e.length){let i=e[n];i&&this._styleColumnHeaderRow(i,t,!1)}let a=this._config.split_by.length+1;if(a<e.length){let i=e[a];i&&this._styleColumnHeaderRow(i,t,!0)}}function De(e,t){let o=this._config.group_by.length,r=[],s=new Set;for(let l=0;l<e.length;l++){let{row:n,cells:a}=e[l],i=new Set;for(let d=0;d<a.length;d++){let{element:p,metadata:c}=a[d];if(!c)continue;p.style.backgroundColor="";let m=o>0&&c.row_header_x===o||(c.x??-1)>=0;p.classList.toggle("psp-align-right",!1),p.classList.toggle("psp-align-left",!1),p.classList.toggle("psp-header-group",!0),p.classList.toggle("psp-header-leaf",!1),p.classList.toggle("psp-header-border",m),p.classList.toggle("psp-header-group-corner",typeof c.x>"u"),p.classList.toggle("psp-color-mode-bar",!1),p.classList.toggle("psp-header-sort-asc",!1),p.classList.toggle("psp-header-sort-desc",!1),p.classList.toggle("psp-header-sort-col-asc",!1),p.classList.toggle("psp-header-sort-col-desc",!1),p.classList.toggle("psp-sort-enabled",!1);let u=d;for(;r[l]&&r[l][u];++u);i.add(u);let g=p;for(let _=u;_<u+g.colSpan;++_)for(let b=l;b<l+g.rowSpan;++b)r[b]||(r[b]=[]),r[b][_]=!0;g.classList.toggle("psp-is-top",l===0||!s.has(u))}s=i}}function Pe(e,t,[,,,,,o,r],[,,,,,s,l],n){let a=this._ids?.[e.dy??0]?.join("|"),i=(n?(e.column_header??[]).slice(0,-1):e.column_header??[]).join("|");if(this.last_reverse_columns?.has(i)&&this.last_reverse_ids?.has(a)){let d=this.last_reverse_ids?.get(a),p=this.last_reverse_columns.get(i);this._is_old_viewport?p!==void 0&&d!==void 0&&this.last_meta?.[p]?.[d]!==void 0&&this.last_meta[p][d]>(e.user??0)?(t.style.setProperty("--pulse--background-color-start",s),t.style.setProperty("--pulse--background-color-end",l),t.style.animationName==="pulse_neg"?t.style.animation="pulse_neg2 0.5s linear":t.style.animation="pulse_neg 0.5s linear"):p!==void 0&&d!==void 0&&this.last_meta?.[p]?.[d]!==void 0&&this.last_meta[p][d]<(e.user??0)?(t.style.setProperty("--pulse--background-color-start",o),t.style.setProperty("--pulse--background-color-end",r),t.style.animationName==="pulse_pos"?t.style.animation="pulse_pos2 0.5s linear":t.style.animation="pulse_pos 0.5s linear"):d!==e.dy&&(t.style.animation=""):t.style.animation=""}else t.style.animation=""}function Oe(e,t,o,r){let s=(o.user??0)>0,l=(o.user??0)<0,n;e?.pos_bg_color!==void 0?n=e.pos_bg_color:n=this._pos_bg_color;let a;e?.neg_bg_color!==void 0?a=e.neg_bg_color:a=this._neg_bg_color;let i=s?n:l?a:["",this._plugin_background[0],this._plugin_background[1],this._plugin_background[2],"","",""];{let[m,u,g,_]=i;if(t.style.position="",o._is_hidden_by_aggregate_depth)t.style.animation="",t.style.backgroundColor="";else if(e?.number_bg_mode==="color")t.style.animation="",t.style.backgroundColor=m;else if(e?.number_bg_mode==="gradient"){let b=Math.max(0,Math.min(1,Math.abs((o.user??0)/(e.bg_gradient??1)))),f=this._plugin_background,w=O(P([u,g,_,b],f));t.style.animation="",t.style.color=w,t.style.backgroundColor=`rgba(${u},${g},${_},${b})`}else e?.number_bg_mode==="pulse"?(Pe.call(this,o,t,n,a,r),t.style.backgroundColor=""):(e?.number_bg_mode==="disabled"||e?.number_bg_mode,t.style.animation="",t.style.backgroundColor="")}let d=e?.pos_fg_color!==void 0?s?e.pos_fg_color:l?e.neg_fg_color:["",this._plugin_background[0],this._plugin_background[1],this._plugin_background[2],"","",""]:s?this._pos_fg_color:l?this._neg_fg_color:["",this._plugin_background[0],this._plugin_background[1],this._plugin_background[2],"","",""],[p,,,,c]=d;if(o._is_hidden_by_aggregate_depth)t.style.backgroundColor="",t.style.color="";else if(e?.number_fg_mode==="disabled")if(e?.number_bg_mode==="color"){let m=this._plugin_background,u=O(P([i[1],i[2],i[3],1],m));t.style.color=u}else e?.number_bg_mode==="gradient"||(t.style.color="");else e?.number_fg_mode==="bar"?(t.style.color="",t.style.position="relative",c!==""&&t.children.length>0&&t.children[0].nodeType===Node.ELEMENT_NODE&&(t.children[0].style.background=c)):(e?.number_fg_mode==="color"||!e?.number_fg_mode)&&(t.style.color=p)}import Ae from"chroma-js";function Ne(e,t,o){let r=o.column_header?.[this._config.split_by.length],s=e?.color!==void 0?e.color:this._color,[l,n,a,i]=s;if(o._is_hidden_by_aggregate_depth)t.style.backgroundColor="",t.style.color="";else if(e?.string_color_mode==="foreground"&&o.user!==null)t.style.color=l,t.style.backgroundColor="",e?.format==="link"&&t.children[0]&&(t.children[0].style.color=l);else if(e?.string_color_mode==="background"&&o.user!==null){let d=this._plugin_background,p=O(P([n,a,i,1],d));t.style.color=p,t.style.backgroundColor=l}else if(e?.string_color_mode==="series"&&o.user!==null&&r){this._series_color_map.has(r)||(this._series_color_map.set(r,new Map),this._series_color_seed.set(r,0));let d=this._series_color_map.get(r);if(o.user&&!d.has(o.user)){let S=this._series_color_seed.get(r)??0;d.set(o.user,S),this._series_color_seed.set(r,S+1)}let p=d.get(o.user)??0,[c,m,u]=Ae(l).hsl();c=c+p*150%360;let g=Ae(c,m,u,"hsl"),[_,b,f]=g.rgb(),w=g.hex(),y=this._plugin_background,E=O(P([_,b,f,1],y));t.style.color=E,t.style.backgroundColor=w}else t.style.backgroundColor="",t.style.color=""}function He(e,t,o){let r=this._color,[s,l,n,a]=r;if(o._is_hidden_by_aggregate_depth)t.style.backgroundColor="",t.style.color="";else if(e?.datetime_color_mode==="foreground"&&o.user!==null)t.style.color=s,t.style.backgroundColor="";else if(e?.datetime_color_mode==="background"&&o.user!==null){let i=this._plugin_background,d=O(P([l,n,a,1],i));t.style.color=d,t.style.backgroundColor=s}else t.style.backgroundColor="",t.style.color=""}function Ve(e,t,o){if(o._is_hidden_by_aggregate_depth)t.style.backgroundColor="",t.style.color="";else{let[r]=o.user===!0?this._pos_fg_color:o.user===!1?this._neg_fg_color:["",0,0,0,""];t.style.backgroundColor="",t.style.color=r}}function ze(e,t,o){let r=o.value!==void 0&&o.value!==null&&o.value?.toString()?.trim().length>0,s=(o.row_header_x??0)>=this._config.group_by.length,l=e.getMeta({dx:0,dy:(o.y??0)-(o.y0??0)+1}),n=l&&l.row_header&&typeof l.row_header[(o.row_header_x??0)+1]<"u";t.classList.toggle("psp-tree-label",r&&!s),t.classList.toggle("psp-tree-label-expand",r&&!s&&!n),t.classList.toggle("psp-tree-label-collapse",r&&!s&&n),t.classList.toggle("psp-tree-leaf",r&&s)}function gt(e,t){return t.x!==void 0&&t.x>=0?e._column_types[t.x]:e._row_header_types[(t.row_header_x??0)-1]}function Ie(e,t,o,r,s,l,n,a,i){let d=n.has(l),p=n.get(l);for(let{element:c,metadata:m,isHeader:u}of e){let g=m.column_header?.[this._config.split_by.length],_=gt(this,m),b=g?t[g.toString()]:void 0,f=_==="integer"||_==="float";m._is_hidden_by_aggregate_depth=(y=>y===0||y===void 0?!1:y-1<Math.min(this._config.group_by.length,b?.aggregate_depth||0))(m.row_header?.filter(y=>y!==void 0)?.length),f?Oe.call(this,b,c,m,o):_==="boolean"?Ve.call(this,b,c,m):_==="string"?Ne.call(this,b,c,m):_==="date"||_==="datetime"?He.call(this,b,c,m):(c.style.backgroundColor="",c.style.color=""),c.classList.toggle("psp-bool-type",_==="boolean"&&m.user!==null),c.classList.toggle("psp-null",m.value===null),c.classList.toggle("psp-align-right",!u&&f),c.classList.toggle("psp-align-left",u||!f),this._column_settings_selected_column?c.classList.toggle("psp-menu-open",g===this._column_settings_selected_column):c.classList.toggle("psp-menu-open",!1),c.classList.toggle("psp-color-mode-bar",b?.number_fg_mode==="bar"&&f),u&&ze.call(this,l,c,m);let w=c.parentElement;if(w&&(w.dataset.y=String(m.y)),m.row_header_x===void 0||m.row_header_x===m.row_header.length-1||m.row_header[m.row_header_x+1]===void 0?(c.dataset.y=String(m.y),c.dataset.x=String(m.x)):(delete c.dataset.y,delete c.dataset.x),r)if(!d)c.classList.toggle("psp-row-selected",!1),c.classList.toggle("psp-row-subselected",!1);else{let y=this._ids[(m.y??0)-(m.y0??0)],E=p.reduce((N,x,k)=>N&&x===y[k],!0),S=p;u&&m.row_header_x!==void 0&&y[m.row_header_x]?(c.classList.toggle("psp-row-selected",!1),c.classList.toggle("psp-row-subselected",!1)):(c.classList.toggle("psp-row-selected",y.length===S.length&&E),c.classList.toggle("psp-row-subselected",y.length!==S.length&&E))}if(!u&&m.x!==void 0)if(s&&this._is_editable[m.x]){let E=m.column_header?.[this._config.split_by.length]?.toString();E&&_==="string"&&t[E]?.format==="link"?(c.toggleAttribute("contenteditable",!1),c.classList.toggle("boolean-editable",!1)):_==="boolean"?(c.toggleAttribute("contenteditable",!1),c.classList.toggle("boolean-editable",m.user!==null)):(s!==c.hasAttribute("contenteditable")&&c.toggleAttribute("contenteditable",s),c.classList.toggle("boolean-editable",!1))}else c.toggleAttribute("contenteditable",!1),c.classList.toggle("boolean-editable",!1)}}function We(e,t,o=!1){let r=e._config.group_by.length===0&&e._config.split_by.length===0,s=t.hasAttribute("selectable"),l=t.children[0],n=o||l?.dataset?.editMode==="EDIT";return r&&!s&&n}function Fe(e,t,o){return function(s,l){let n=s[M]||{},a=l.hasAttribute("settings"),i=l.hasAttribute("selectable"),d=We(this,l),p=We(this,l,!0);e.classList.toggle("edit-mode-allowed",p);let c=[],m=[],u=s.children[0]?.children[1];if(u)for(let _ of u.children)for(let b of _.children){let f=s.getMeta(b);if(f){let w=b.tagName==="TH";c.push({element:b,metadata:f,isHeader:w})}}let g=s.children[0]?.children[0];if(g)for(let _ of g.children){let b={row:_,cells:[]};for(let f of _.children){let w=s.getMeta(f);b.cells.push({element:f,metadata:w})}m.push(b)}this._applyBodyCellStyles(c,n,a,i,d,s,t,o,l),this._applyGroupHeaderStyles(m,s),this._applyColumnHeaderStyles(m,s,l),this._applyFocusStyle(c,s,o)}}function je(e){e._applyBodyCellStyles=Ie,e._applyGroupHeaderStyles=De,e._applyColumnHeaderStyles=Le,e._applyFocusStyle=he,e._styleColumnHeaderRow=pe}async function Ue(e){let t=this.parentElement,o=await t.getTable();if(this._initialized)await Y.call(this,this.regular_table,o,e,this.model);else{if(this.innerHTML="",this.shadowRoot?this.shadowRoot.appendChild(this.regular_table):this.appendChild(this.regular_table),this.model=await Y.call(this,this.regular_table,o,e),!this.model)return;Te(this,this.regular_table,{className:"psp-select-region"});let r=new WeakMap,s=new WeakMap;je(this.model),this.regular_table.addStyleListener(Fe(this,r,s).bind(this.model,this.regular_table,t)),this.regular_table.addEventListener("click",be.bind(this.model,this.regular_table)),this.regular_table.addEventListener("mousedown",Me.bind(this.model,this.regular_table,t,r)),this.regular_table.addEventListener("psp-deselect-all",Se.bind(this.model,this.regular_table,t,r)),this.regular_table.addEventListener("click",Re.bind(this.model,this.regular_table,t)),this.regular_table.addEventListener("mousedown",_e.bind(this.model,this.regular_table,t)),this.regular_table.addEventListener("click",Ee.bind(this.model,this.regular_table,t)),this.regular_table.addEventListener("focusin",ke.bind(this.model,this.regular_table,t,s)),this.regular_table.addEventListener("focusout",Ce.bind(this.model,this.regular_table,t,s)),this.regular_table.addEventListener("keydown",xe.bind(this.model,this.regular_table,t,s)),t.addEventListener("perspective-toggle-column-settings",l=>{let n=l;if(this.isConnected){if(de.call(this.model,this.regular_table,t,n.detail.column_name??void 0),!n.detail.open){this.model._column_settings_selected_column=void 0;return}this.model._column_settings_selected_column=n.detail.column_name??void 0}}),this._initialized=!0}}function Ge(e,t){e=JSON.parse(JSON.stringify(e)),t=JSON.parse(JSON.stringify(t));let o={};if(e.columns)for(let[l,n]of Object.entries(e.columns))n.column_size_override!==void 0&&(o[l]=n.column_size_override,delete n.column_size_override);let r={};if(t)for(let[l,n]of Object.entries(t))r[l]={...n,pos_fg_color:n.pos_fg_color?T(n.pos_fg_color):void 0,neg_fg_color:n.neg_fg_color?T(n.neg_fg_color):void 0,pos_bg_color:n.pos_bg_color?T(n.pos_bg_color):void 0,neg_bg_color:n.neg_bg_color?T(n.neg_bg_color):void 0,color:n.color?T(n.color):void 0};"edit_mode"in e&&e.edit_mode&&(z.indexOf(e.edit_mode)!==-1?I.call(this,e.edit_mode):console.error("Unknown edit mode "+e.edit_mode)),"scroll_lock"in e&&W.call(this,e.scroll_lock);let s=this.regular_table;F.call(this,o,!0),s[M]=r}function $e(){if(this.regular_table){let e={columns:{},scroll_lock:!!this._is_scroll_lock,edit_mode:this._edit_mode},t=j.call(this);for(let o of Object.keys(t||{}))e.columns?.[o]||(e.columns=e.columns||{},e.columns[o]={}),e.columns[o].column_size_override=t[o];return JSON.parse(JSON.stringify(e))}return{}}async function Be(e){if(this.parentElement&&await this.activate(e),!this.isConnected||this.offsetParent==null||!this.model)return;let t=j.call(this),o=this.regular_table.draw({invalid_columns:!0});this._reset_scroll_top&&(this.regular_table.scrollTop=0,this._reset_scroll_top=!1),this._reset_scroll_left&&(this.regular_table.scrollLeft=0,this._reset_scroll_left=!1),this._reset_select&&(this.regular_table.dispatchEvent(new CustomEvent("psp-deselect-all",{bubbles:!1})),this._reset_select=!1),this._reset_column_size&&(this.regular_table.resetAutoSize(),this._reset_column_size=!1),F.call(this,t),await o,this._toolbar?.classList.toggle("aggregated",this.model._config.group_by.length>0||this.model._config.split_by.length>0)}function te(e,t){return e==="integer"||e==="float"?{datagrid_number_style:{fg_gradient:0,pos_fg_color:this.model._pos_fg_color[0],neg_fg_color:this.model._neg_fg_color[0],number_fg_mode:"color",bg_gradient:0,pos_bg_color:this.model._pos_bg_color[0],neg_bg_color:this.model._neg_bg_color[0],number_bg_mode:"disabled"},number_string_format:!0}:e==="date"||e==="datetime"||e==="string"?{[e==="date"||e==="datetime"?"datagrid_datetime_style":"datagrid_string_style"]:{color:this.model._color[0],bg_color:this.model._color[0]}}:null}var Ye='regular-table{padding:0;margin:12px 0 0 12px;font-family:inherit;--rt-hover--border-color:var(--inactive--color,#c5c9d080);}regular-table div[tabindex]{outline:none;}regular-table>div{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;}regular-table th{text-align:center;}regular-table thead tr:not(.rt-autosize) th{overflow:hidden;max-width:0px;}regular-table thead tr:last-child .rt-float,regular-table tbody .rt-float{text-align:right;}regular-table thead .rt-integer,regular-table tbody .rt-integer{text-align:right;}regular-table tbody th{text-align:left;}regular-table span.rt-tree-container{display:flex;align-items:center;height:100%;}regular-table thead .rt-string,regular-table tbody .rt-string,regular-table thead .rt-date,regular-table tbody .rt-date,regular-table thead .rt-datetime,regular-table tbody .rt-datetime{text-align:left;}regular-table thead tr:last-child th{border-bottom:1px solid#8b868045;}regular-table tbody tr:first-child td,regular-table tbody tr:first-child th{border-top:1px solid transparent!important;}regular-table th{position:relative;}regular-table tr th span.rt-tree-group{margin-left:5px;margin-right:15px;border-left:1px solid#eee;height:100%;}regular-table td,regular-table th{white-space:nowrap;font-size:12px;padding-right:5px;padding-left:5px;padding-top:0px;padding-bottom:0px;height:19px;}regular-table table *{box-sizing:border-box;}regular-table table{position:absolute;color:#666;outline:none;}regular-table span.rt-row-header-icon{color:#aaa;padding-right:4px;font-family:var(--button--font-family);}regular-table span.rt-column-header-icon{font-size:10px;padding-left:3px;display:inline-block;width:10px;font-family:var(--button--font-family);}regular-table span.rt-row-header-icon:hover{color:#1a7da1;text-shadow:0px 0px 3px#1a7da1;}regular-table .rt-selected td{background-color:#eee;}regular-table .rt-cell-clip{overflow:hidden;text-overflow:ellipsis;}regular-table td span.rt-group-name,regular-table th span.rt-group-name{margin-right:-5px;padding-right:5px;padding-left:8px;flex:1;height:100%;}regular-table th span.rt-group-name{text-align:left;}regular-table td th span.rt-group-leaf,regular-table th span.rt-group-leaf{margin-left:16px;height:100%;}regular-table .rt-column-resize{height:100%;width:10px;position:absolute;top:0;right:0;cursor:col-resize;}regular-table a{color:var(--rt-pos-cell--color);}regular-table a:visited{color:var(--active--color);}regular-table td.psp-null:after,regular-table th.psp-null:after{content:var(--null--content,"-");}.psp-header-border:not(.psp-is-top):not(.psp-header-leaf){box-shadow:1px 0px var(--inactive--border-color,#8b868045);}.psp-header-group{box-shadow:0px 10px 0 -9px var(--inactive--border-color,#8b868045);}.psp-is-top{box-shadow:5px 4px 0px -4px var(--inactive--border-color,#8b868045);}.psp-is-top.psp-header-group:not(.psp-header-group-corner){box-shadow:5px 4px 0px -4px var(--inactive--border-color,#8b868045),0px 10px 0 -9px var(--inactive--border-color,#8b868045);}.psp-header-border.psp-header-group:not(.psp-is-top):not(.psp-header-group-corner){box-shadow:1px 0px var(--inactive--border-color,#8b868045),0px 10px 0 -9px var(--inactive--border-color,#8b868045);}perspective-viewer[settings] tr.rt-autosize .psp-header-leaf.psp-header-border:not(.psp-menu-enabled){box-shadow:1px 0px var(--inactive--border-color,#8b868045);}:host-context(perspective-viewer[settings]) tr.rt-autosize .psp-header-leaf.psp-header-border:not(.psp-menu-enabled){box-shadow:1px 0px var(--inactive--border-color,#8b868045);}.psp-header-leaf.psp-header-border{box-shadow:5px -4px 0px -4px var(--inactive--border-color,#8b868045);}tr:only-child th{box-shadow:none!important;}regular-table tbody tr:hover th.psp-tree-leaf:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover th.psp-tree-label:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover td:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover:after{border-color:var(--rt-hover--border-color,#c5c9d080)!important;box-shadow:0px 1px 0px var(--rt-hover--border-color,#c5c9d080);}regular-table tbody tr:hover th.psp-tree-leaf.psp-menu-open:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover th.psp-tree-label.psp-menu-open:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover td.psp-menu-open:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr.psp-menu-open:hover:after{box-shadow:inset -2px 0px 0px var(--icon--color),inset 2px 0px 0px var(--icon--color),0px 1px 0px var(--rt-hover--border-color,#c5c9d080);}regular-table tbody tr:last-child:hover td.psp-menu-open:not(.psp-row-selected):not(.psp-row-subselected){box-shadow:inset -2px 0px 0px var(--icon--color),inset 2px 0px 0px var(--icon--color),inset 0px -2px 0px var(--icon--color),0px 1px 0px var(--rt-hover--border-color,#c5c9d080);}regular-table tbody tr:hover+tr th.psp-tree-leaf:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover+tr th.psp-tree-label:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover+tr td:not(.psp-row-selected):not(.psp-row-subselected){border-top-color:transparent;}regular-table tbody tr th:first-child:not(:empty),regular-table tbody tr th:first-child:empty+th:not(:empty),regular-table tbody tr th:first-child:empty~th:empty+th:not(:empty),regular-table tbody tr td:first-child{border-left-width:1px;border-left-color:transparent;}regular-table tbody tr th:last-child,regular-table tbody tr td:last-child{border-right-width:0px;border-right-color:transparent;}regular-table tbody tr:hover{color:inherit;}regular-table tbody tr:hover th:first-child:not(:empty),regular-table tbody tr:hover th:first-child:empty+th:not(:empty),regular-table tbody tr:hover th:first-child:empty~th:empty+th:not(:empty),regular-table tbody tr:hover td:first-child{border-left-color:var(--rt-hover--border-color,#c5c9d080)!important;}regular-table tbody tr:hover th:last-child,regular-table tbody tr:hover td:last-child{border-right-color:var(--rt-hover--border-color,#c5c9d080)!important;}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody td,perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table thead th:not(.rt-group-corner),:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody td,:host(:not(.sub-cell-scroll-disabled)) regular-table table thead th:not(.rt-group-corner){transform:translate(var(--regular-table--transform-x,0px));}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody,:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody{transform:translate(0,var(--regular-table--transform-y,0px));}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody tr:first-child td,perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody tr:first-child th,perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody tr:first-child:after,:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody tr:first-child td,:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody tr:first-child th,:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody tr:first-child:after{clip-path:polygon(0 var(--regular-table--clip-y,0),0 200%,200% 200%,200% var(--regular-table--clip-y,0));}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody tr td:first-of-type,:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody tr td:first-of-type{clip-path:polygon(var(--regular-table--clip-x,0) 0,var(--regular-table--clip-x,0) 200%,200% 200%,200% 0);}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody tr:first-child td:first-of-type,:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody tr:first-child td:first-of-type{clip-path:polygon(var(--regular-table--clip-x,0) var(--regular-table--clip-y,0),var(--regular-table--clip-x,0) 200%,200% 200%,200% var(--regular-table--clip-y,0));}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table thead tr:last-child:after,:host(:not(.sub-cell-scroll-disabled)) regular-table table thead tr:last-child:after{transform:translate(var(--regular-table--transform-x,0px));}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody tr:not(:first-child):after,:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody tr:not(:first-child):after{transform:translate(var(--regular-table--transform-x,0px));}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody tr:hover:first-child:after,:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody tr:hover:first-child:after{clip-path:polygon(0 var(--regular-table--clip-y,0),0 200%,200% 200%,200% var(--regular-table--clip-y,0));}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table thead tr th.rt-group-corner+th:not(.rt-group-corner),:host(:not(.sub-cell-scroll-disabled)) regular-table table thead tr th.rt-group-corner+th:not(.rt-group-corner){clip-path:polygon(var(--regular-table--clip-x,0) 0,var(--regular-table--clip-x,0) 200%,200% 200%,200% 0);}regular-table{outline:none;}regular-table::-webkit-scrollbar,regular-table::-webkit-scrollbar-corner{background-color:transparent;height:12px;width:12px;}regular-table::-webkit-scrollbar-thumb{background-clip:content-box;background:var(--icon--color);border:5.5px solid var(--plugin--background);max-height:50%;max-width:50%;min-width:10%;min-height:10%;}perspective-viewer .psp-menu-enabled{padding:0 6px;font-size:8px;border-radius:3px 3px 0 0;}perspective-viewer .psp-menu-enabled:hover,perspective-viewer tr:not(.rt-autosize) th.psp-menu-open{color:var(--plugin--background);background-color:var(--icon--color);border-bottom-color:var(--icon--color);cursor:pointer;}perspective-viewer tr:not(.rt-autosize) th.psp-menu-open:before{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;height:8px;width:10px;-webkit-mask-image:var(--column-settings-icon--mask-image);mask-image:var(--column-settings-icon--mask-image);margin-right:4px;background-color:var(--plugin--background);}perspective-viewer td.psp-menu-open{box-shadow:inset -2px 0px 0px var(--icon--color),inset 2px 0px 0px var(--icon--color);}perspective-viewer tr:first-child td.psp-menu-open{border-top-color:var(--icon--color)!important;}perspective-viewer tr:last-child td.psp-menu-open{box-shadow:inset -2px 0px 0px var(--icon--color),inset 2px 0px 0px var(--icon--color),inset 0px -2px 0px var(--icon--color);}:host .psp-menu-enabled{padding:0 6px;font-size:8px;border-radius:3px 3px 0 0;}:host .psp-menu-enabled:hover,:host tr:not(.rt-autosize) th.psp-menu-open{color:var(--plugin--background);background-color:var(--icon--color);border-bottom-color:var(--icon--color);cursor:pointer;}:host tr:not(.rt-autosize) th.psp-menu-open:before{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;height:8px;width:10px;-webkit-mask-image:var(--column-settings-icon--mask-image);mask-image:var(--column-settings-icon--mask-image);margin-right:4px;background-color:var(--plugin--background);}:host td.psp-menu-open{box-shadow:inset -2px 0px 0px var(--icon--color),inset 2px 0px 0px var(--icon--color);}:host tr:first-child td.psp-menu-open{border-top-color:var(--icon--color)!important;}:host tr:last-child td.psp-menu-open{box-shadow:inset -2px 0px 0px var(--icon--color),inset 2px 0px 0px var(--icon--color),inset 0px -2px 0px var(--icon--color);}perspective-viewer regular-table table thead tr:last-child th{border-bottom-width:1px;border-bottom-color:var(--inactive--border-color,#8b868045);}:host-context(perspective-viewer) regular-table table thead tr:last-child th{border-bottom-width:1px;border-bottom-color:var(--inactive--border-color,#8b868045);}.psp-sort-enabled:hover{cursor:pointer;}.psp-row-selected,:hover .psp-row-selected,:hover th.psp-tree-leaf.psp-row-selected,:hover th.psp-tree-label.psp-row-selected{color:white!important;background-color:var(--selected-row--background-color,#ea7319)!important;border-color:var(--selected-row--background-color,#ea7319)!important;}.psp-row-selected.psp-tree-label:not(:hover):before{color:white;}.psp-row-subselected,:hover .psp-row-subselected,:hover th.psp-tree-leaf.psp-row-subselected,:hover th.psp-tree-label.psp-row-subselected{background:rgba(234,115,25,0.2)!important;}.psp-error{color:red;}td:focus{outline:#666;outline-style:dotted;outline-width:1px;}perspective-viewer.dragging regular-table{pointer-events:none;}:host-context(perspective-viewer.dragging) regular-table{pointer-events:none;}.psp-header-border:last-child{border-right-width:0px;}.psp-header-sort-desc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-desc-icon--mask-image);mask-image:var(--sort-desc-icon--mask-image);}.psp-header-sort-asc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-asc-icon--mask-image);mask-image:var(--sort-asc-icon--mask-image);}.psp-header-sort-col-desc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-col-desc-icon--mask-image);mask-image:var(--sort-col-desc-icon--mask-image);}.psp-header-sort-col-asc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-col-asc-icon--mask-image);mask-image:var(--sort-col-asc-icon--mask-image);}.psp-header-sort-abs-desc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-abs-desc-icon--mask-image);mask-image:var(--sort-abs-desc-icon--mask-image);}.psp-header-sort-abs-asc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-abs-asc-icon--mask-image);mask-image:var(--sort-abs-asc-icon--mask-image);}.psp-header-sort-abs-col-desc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-abs-col-desc-icon--mask-image);mask-image:var(--sort-abs-col-desc-icon--mask-image);}.psp-header-sort-abs-col-asc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-abs-col-asc-icon--mask-image);mask-image:var(--sort-abs-col-asc-icon--mask-image);}tbody th:last-of-type{border-right:1px solid var(--inactive--border-color,#8b868045);overflow:hidden;text-overflow:ellipsis;}tbody th:empty{background-image:linear-gradient(to right,transparent 9px,var(--inactive--border-color,#eee) 10px,transparent 11px);background-repeat:no-repeat;min-width:20px;max-width:20px;pointer-events:none;}.psp-tree-label{max-width:0px;min-width:0px;}.psp-tree-label:before{color:var(--icon--color);font-family:var(--button--font-family,inherit);padding-right:11px;}.psp-tree-label-expand:before{content:var(--tree-label-expand--content,"+");}.psp-tree-label-collapse:before{content:var(--tree-label-collapse--content,"-");}.psp-tree-label-expand,.psp-tree-label-collapse{cursor:pointer;}.psp-tree-label:hover:before{color:var(--active--color);text-shadow:0px 0px 5px var(--active--color);}.psp-tree-leaf{padding-left:24px;}.psp-align-right{text-align:right;}.psp-align-left{text-align:left;}.psp-positive:not(:focus){color:var(--rt-pos-cell--color);}.psp-negative:not(:focus){color:var(--rt-neg-cell--color);}regular-table table tbody td{min-width:52px!important;}.psp-is-width-override .rt-column-resize,.rt-column-resize:hover{border:1px dashed#999;border-bottom-width:0px;border-left-width:0px;}.boolean-editable{cursor:pointer;}regular-table table{user-select:none;color:inherit;border-collapse:separate;}regular-table table th{font-weight:400;}regular-table table td,regular-table table th{border-color:var(--inactive--border-color,#8b868045);height:23px;}regular-table table .psp-header-group{text-overflow:ellipsis;}regular-table table th.psp-header-leaf{border-bottom-width:0px;}regular-table table th.psp-header-leaf span{height:23px;min-height:23px;}regular-table table td,regular-table table th.psp-tree-label,regular-table table th.psp-tree-label,regular-table table th.psp-tree-leaf,regular-table table tbody tr:first-child th{border-style:solid;border-width:0px;border-top-width:1px;}regular-table table tbody th:empty{background-position:0px -10px;}regular-table table td.psp-select-region,regular-table table th.psp-select-region{background-color:var(--icon--color)!important;color:var(--plugin--background)!important;border-color:var(--plugin--background)!important;}regular-table tbody tr:hover td.psp-select-region:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover+tr td.psp-select-region:not(.psp-row-selected):not(.psp-row-subselected){border-color:var(--plugin--background)!important;}regular-table tbody tr:hover td.psp-select-region.psp-menu-open:not(.psp-row-selected):not(.psp-row-subselected){box-shadow:inset -2px 0px 0px var(--plugin--background),inset 2px 0px 0px var(--plugin--background);}:host-context(perspective-viewer[settings]) td.psp-select-region.psp-menu-open{box-shadow:inset -2px 0px 0px var(--plugin--background),inset 2px 0px 0px var(--plugin--background);}regular-table #psp-column-edit-buttons th:not(.rt-group-corner) span:not(.rt-column-resize):before{content:var(--datagrid-column-edit-button--content,"Edit");}perspective-viewer:not([settings]) regular-table #psp-column-edit-buttons:after{content:none;}:host-context(perspective-viewer:not([settings])) regular-table #psp-column-edit-buttons:after{content:none;}regular-table table thead tr:last-child:after{width:10000px;box-sizing:border-box;display:block;height:23px;content:" ";border-bottom:1px solid var(--inactive--border-color);}regular-table table tbody tr:after{width:10000px;box-sizing:border-box;display:block;height:23px;content:" ";border-top:1px solid transparent;}regular-table table tbody tr:not(:first-child):after{border-top:1px solid var(--inactive--border-color);}regular-table table tbody tr:hover:not(:first-child):after{border-top:1px solid var(--rt-hover--border-color);}regular-table table tbody tr:hover+tr:after{border-top:1px solid var(--rt-hover--border-color);}@keyframes pulse_pos{0%{background-color:var(--pulse--background-color-start,rgba(0,128,255,0.5));}100%{background-color:var(--pulse--background-color-end,rgba(0,128,255,0));}}@keyframes pulse_pos2{0%{background-color:var(--pulse--background-color-start,rgba(0,128,255,0.5));}100%{background-color:var(--pulse--background-color-end,rgba(0,128,255,0));}}@keyframes pulse_neg{0%{background-color:var(--pulse--background-color-start,rgba(255,25,0,0.5));}100%{background-color:var(--pulse--background-color-end,rgba(255,25,0,0));}}@keyframes pulse_neg2{0%{background-color:var(--pulse--background-color-start,rgba(255,25,0,0.5));}100%{background-color:var(--pulse--background-color-end,rgba(255,25,0,0));}}';var q=class e extends HTMLElement{static _global_stylesheet_installed=!1;static _sheet;static renderTarget=window.CSS?.supports&&window.CSS?.supports("selector(:host-context(foo))")?"shadow":"light";regular_table;model;_toolbar;_edit_button;_scroll_lock;_is_scroll_lock;_edit_mode;_initialized;_reset_scroll_top;_reset_scroll_left;_reset_select;_reset_column_size;constructor(){super(),this.regular_table=document.createElement("regular-table"),this.regular_table.part="regular-table",this._is_scroll_lock=!1,this._edit_mode="READ_ONLY";let t=e;t._sheet||(t._sheet=new CSSStyleSheet,t._sheet.replaceSync(Ye)),t.renderTarget==="shadow"?this.attachShadow({mode:"open"}).adoptedStyleSheets.push(t._sheet):t.renderTarget==="light"&&!t._global_stylesheet_installed&&(t._global_stylesheet_installed=!0,document.adoptedStyleSheets.push(t._sheet))}connectedCallback(){this._toolbar||(this._toolbar=document.createElement("perspective-viewer-datagrid-toolbar"));let t=this.parentElement;t&&t.appendChild(this._toolbar)}disconnectedCallback(){this._toolbar?.parentElement?.removeChild?.(this._toolbar)}async activate(t){return await Ue.call(this,t)}get name(){return"Datagrid"}get category(){return"Basic"}get select_mode(){return"toggle"}get min_config_columns(){}get config_column_names(){return["Columns"]}get priority(){return 1}can_render_column_styles(t,o){return t!=="boolean"}column_style_controls(t,o){return te.call(this,t,o)}async draw(t){return await Be.call(this,t)}async update(t){if(this.model===void 0)await this.draw(t);else if(this.model._config.split_by?.length>0){let o=await t.dimensions();this.model._num_rows=o.num_view_rows,await this.regular_table.draw()}else this.model._num_rows=await t.num_rows(),await this.regular_table.draw()}async render(t){let r=await this.parentElement.getView(),s=await r.to_columns(t),l=await r.column_paths(t),n=t?.end_row!==void 0&&t?.end_row!==null&&t?.start_row!==void 0&&t?.start_row!==null?t.end_row-t.start_row:await r.num_rows(),a="";for(let i=0;i<n;i++){for(let d of l){let p=s[d],c=this.model._schema[d],m=this.regular_table[M],u=d.split("|").at(-1),g=se(c,m?.[u]||{});g?a+=g.format(p[i])+" ":a+=p[i]+" "}a+=`
|
|
2
|
-
`}return a.trim()}async resize(){!this.isConnected||this.offsetParent==null||this._initialized&&await this.regular_table.draw()}async clear(){this.regular_table.resetAutoSize(),this.regular_table.clear()}async save(){return
|
|
1
|
+
import"regular-table";function N(e,t){return t.type==="body"||t.type==="column_header"||t.type==="corner"?e._column_types[t.x]:e._row_header_types[(t.row_header_x??0)-1]}var M=Symbol("Perspective Column Config");import Qe from"chroma-js";var X=class{format(t){return t?"true":"false"}},Ze={float:{format:{style:"decimal",minimumFractionDigits:2,maximumFractionDigits:2}},datetime:{format:{dateStyle:"short",timeStyle:"medium"}},date:{format:{dateStyle:"short"}}},B=class{_formatters;constructor(){this._formatters=new Map}create_datetime_formatter(t,o){if(o.date_format?.format!=="custom"){let r={timeZone:o.date_format?.timeZone,dateStyle:o.date_format?.dateStyle==="disabled"?void 0:o.date_format?.dateStyle??"short",timeStyle:o.date_format?.timeStyle==="disabled"?void 0:o.date_format?.timeStyle??"medium"};return new Intl.DateTimeFormat(navigator.languages,r)}else{let r={timeZone:o.date_format?.timeZone,hour12:o.date_format?.hour12??!0,fractionalSecondDigits:o.date_format?.fractionalSecondDigits};return o.date_format?.year!=="disabled"&&(r.year=o.date_format?.year??"2-digit"),o.date_format?.month!=="disabled"&&(r.month=o.date_format?.month??"numeric"),o.date_format?.day!=="disabled"&&(r.day=o.date_format?.day??"numeric"),o.date_format?.weekday&&o.date_format?.weekday!=="disabled"&&(r.weekday=o.date_format.weekday),o.date_format?.hour!=="disabled"&&(r.hour=o.date_format?.hour??"numeric"),o.date_format?.minute!=="disabled"&&(r.minute=o.date_format?.minute??"numeric"),o.date_format?.second!=="disabled"&&(r.second=o.date_format?.second??"numeric"),new Intl.DateTimeFormat(navigator.languages,r)}}create_date_formatter(t,o){let r={timeZone:"utc",dateStyle:o.date_format?.dateStyle==="disabled"?void 0:o.date_format?.dateStyle??"short"};return new Intl.DateTimeFormat(navigator.languages,r)}create_number_formatter(t,o){let r=o.number_format??Ze[t]?.format;return new Intl.NumberFormat(navigator.languages,r)}create_boolean_formatter(t,o){return new X}get(t,o){let r=[t,...Object.values(o.date_format??{}),...Object.values(o.number_format??{})].join("-");return this._formatters.has(r)||(t==="date"?this._formatters.set(r,this.create_date_formatter(t,o)):t==="datetime"?this._formatters.set(r,this.create_datetime_formatter(t,o)):t==="integer"||t==="float"?this._formatters.set(r,this.create_number_formatter(t,o)):t==="boolean"?this._formatters.set(r,this.create_boolean_formatter(t,o)):this._formatters.set(r,!1)),this._formatters.get(r)}};var se=new B,le=1;function ne(e,t){return se.get(e,t)}function z(e,t,o={},r=!1){if(t===null)return null;let s=r&&this._table_schema[e]||this._schema[e]||"string",l=o[e]||{};if((s==="integer"||s==="float")&&l?.number_fg_mode==="bar"){let a=Math.max(0,Math.min(le,Math.abs(t/l.fg_gradient)*le)),i=this._div_factory.get(),d=t>=0?"left":"right",p=(a*100).toFixed(2);return i.setAttribute("style",`width:calc(${p}% - 4px);position:absolute;${d}:2px;height:80%;top:10%;pointer-events:none;`),i}else if(l?.format==="link"&&s==="string"){let a=document.createElement("a");return a.setAttribute("href",t),a.setAttribute("target","_blank"),a.textContent=t,a}else if(l?.format==="bold"&&s==="string"){let a=document.createElement("b");return a.textContent=t,a}else if(l?.format==="italics"&&s==="string"){let a=document.createElement("i");return a.textContent=t,a}else{let a=se.get(s,l);return a?a.format(t):t}}function*ie(e=[],t,o){let r=o[M]||{};for(let s of e){let l=["TOTAL",...s],n=l[l.length-1],a=l.slice(0,l.length-1).fill(""),i=z.call(this,t[a.length-1],n,r,!0);i instanceof HTMLElement?a=a.concat(i):a=a.concat({toString:()=>i}),a.length=t.length+1,yield a}}function*ae(e=[],t,o){let r=o[M]||{};for(let s of e){let l=[""];for(let n in s)l.push(z.call(this,t[n],s[n],r,!0));yield s}}function ce(e){let t,o,r,s,l;return async function(a,i,d,p,c){let m={},u={start_row:d,start_col:i,end_row:c,end_col:p,id:!0},g=null;if(p-i>0&&c-d>0){this._is_old_viewport=this._last_window?.start_row===d&&this._last_window?.end_row===c&&this._last_window?.start_col===i&&this._last_window?.end_col===p;let[k,H]=await Promise.all([this._view.to_columns_string(u),this._view.num_columns()]);g=H,m=JSON.parse(k);let T=Object.keys(m).filter(v=>v!=="__ROW_PATH__"&&v!=="__ID__"),D=!1;for(let v=0;v<T.length;v++)this._column_paths[u.start_col+v]!==T[v]&&(D=!0,this._column_paths[u.start_col+v]=T[v]);if(D){let[v,h]=await Promise.all([this._view.schema(),this._view.expression_schema()]);this._schema={...v,...h};for(let C=0;C<T.length;C++){let re=T[C].split("|")[this._config.split_by.length];this._is_editable[C+u.start_col]=!!this._table_schema[re],this._column_types[C+u.start_col]=this._schema[re]}}this._last_window=u,this._ids=m.__ID__||Array(c-d).fill(null).map((v,h)=>[h+d]),this._reverse_columns=this._column_paths.slice(i,p).reduce((v,h,C)=>(v.set(h,C),v),new Map),this._reverse_ids=this._ids?.reduce((v,h,C)=>(v.set(h?.join("|"),C),v),new Map)}else this._div_factory.clear(),g=await this._view.num_columns();let _=[],b=[],f=[],w=[],y=e.hasAttribute("settings");for(let k=i;k<Math.min(p,this._column_paths.length);++k){let H=this._column_paths[k],L=H.split("|"),T=m[H]||new Array(c-d).fill(null),D=Math.min(a[M]?.[L[this._config.split_by.length]]?.aggregate_depth||0,this._config.group_by.length);_.push(T.map((v,h)=>(m?.__ROW_PATH__?.[h]?.length??0)<D?"":z.call(this,L[this._config.split_by.length],v,a[M]||{}))),b.push(T),y&&L.push(""),f.push(L),w.push(H)}p-i>0&&c-d>0&&(this.last_column_paths=o,this.last_meta=t,this.last_ids=r,this.last_reverse_ids=s,this.last_reverse_columns=l,o=w,t=b,r=this._ids,s=this._reverse_ids,l=this._reverse_columns);let E=m.__ROW_PATH__!==void 0,S=Array.from((E?ie:ae).call(this,m.__ROW_PATH__,this._config.group_by,a)),A=S[0]?.length;return{num_column_headers:this._config.split_by.length+(y?2:1),num_row_headers:A,num_rows:this._num_rows,num_columns:g,row_headers:S,column_headers:f,data:_,metadata:b,column_header_merge_depth:Math.max(0,this._config.split_by.length)}}}import de from"chroma-js";function Q(e,t){return de.mix(e,`rgb(${t[0]},${t[1]},${t[2]})`,.5).hex()}function P([e,t,o,r],s=[255,255,255]){function l(n,a){return((1-r)*(s[n]/255)+r*(a/255))*255}return[l(0,e),l(1,t),l(2,o)]}function O([e,t,o]){return Math.sqrt(e*e*.299+t*t*.587+o*o*.114)>130?"#161616":"#ffffff"}function Xe(e){let[t,o,r]=e.rgb(),[s,l,n]=e.set("hsl.h",(e.get("hsl.h")-15)%360).rgb(),[a,i,d]=e.set("hsl.h",(e.get("hsl.h")+15)%360).rgb();return`linear-gradient(to right top,rgb(${s},${l},${n}),rgb(${t},${o},${r}) 50%,rgb(${a},${i},${d}))`}function R(e){let t=de(e),o=Xe(t),r=t.rgb();return[e,r[0],r[1],r[2],o,`rgba(${r[0]},${r[1]},${r[2]},1)`,`rgba(${r[0]},${r[1]},${r[2]},0)`]}function Y(e,t,o){let r=window.getComputedStyle(e).getPropertyValue(t).trim();return r.length>0?r:o}var ee=class{_name;_elements;_index;constructor(t){this._name=t,this._elements=[],this._index=0}clear(){this._index=0}get(){this._elements[this._index]||(this._elements[this._index]=document.createElement(this._name));let t=this._elements[this._index];return this._index+=1,t}};async function K(e,t,o,r={}){let s=await o.get_config();if(this?.model?._config){let x=this.model._config,k=x.group_by.length!==s.group_by.length,H=(x.group_by.length===0||s.group_by.length===0)&&k;if(!k)for(let h in x.group_by)k||=s.group_by[h]!==x.group_by[h];let L=x.split_by.length!==s.split_by.length;if(L)for(let h in x.split_by)L||=s.split_by[h]!==x.split_by[h];let T=x.columns.length!==s.columns.length;if(T)for(let h in x.columns)T||=s.columns[h]!==x.columns[h];let D=x.filter.length!==s.filter.length;if(D)for(let h in x.filter)for(let C in s.filter[h])D||=s.filter[h][C]!==x.filter[h][C];let v=x.sort.length!==s.sort.length;if(v)for(let h in x.sort)for(let C in s.sort[h])v||=s.sort[h][C]!==x.sort[h][C];this._reset_scroll_top=k,this._reset_scroll_left=L,this._reset_select=k||L||D||v||T,this._reset_column_size=L||k||T||H}let[l,n,a,i,d]=await Promise.all([t.schema(),o.num_rows(),o.schema(),o.expression_schema(),this.parentElement.getEditPort()]),p=Qe(Y(e,"--plugin--background","#FFFFFF")).rgb(),c=R(Y(e,"--rt-pos-cell--color","#338DCD")),m=R(Y(e,"--rt-neg-cell--color","#FF5942")),u=R(Q(c[0],p)),g=R(Q(m[0],p)),_=R(Y(e,"--active--color","#ff0000")),b={...a,...i},f={...l,...i},w=[],y=[],E=[],S=this._edit_mode||"READ_ONLY";this._edit_button.dataset.editMode=S;let A=Object.assign(r,{_edit_port:d,_view:o,_table:t,_table_schema:f,_config:s,_num_rows:n,_schema:b,_ids:[],_plugin_background:p,_color:_,_pos_fg_color:c,_neg_fg_color:m,_pos_bg_color:u,_neg_bg_color:g,_column_paths:w,_column_types:E,_is_editable:y,_edit_mode:S,_selection_state:{selected_areas:[],dirty:!1},_row_header_types:s.group_by.map(x=>f[x]),_series_color_map:new Map,_series_color_seed:new Map,_div_factory:r._div_factory||new ee("div")});return e.setDataListener(ce(this.parentElement).bind(A,e),{virtual_mode:window.getComputedStyle(e).getPropertyValue("--datagrid-virtual-mode")?.trim()||"both"}),A}var I=["READ_ONLY","EDIT","SELECT_ROW","SELECT_COLUMN","SELECT_REGION"];function W(e){typeof e>"u"&&(e=I[(I.indexOf(this._edit_mode)+1)%I.length]),this.parentElement?.setSelection?.(),this._edit_mode=e,this.model&&(this.model._edit_mode=e,this.model._selection_state={selected_areas:[],dirty:!0}),this._edit_button!==void 0&&(this._edit_button.dataset.editMode=e),this.dataset.editMode=e}function F(e){typeof e>"u"&&(e=!this._is_scroll_lock),this._is_scroll_lock=e,this.classList.toggle("sub-cell-scroll-disabled",e),this._scroll_lock!==void 0&&this._scroll_lock.classList.toggle("lock-scroll",e)}function U(e,t=!1){if(!this._initialized)return;t&&(this._cached_column_sizes=e);let o={},{group_by:r}=this.model._config,s=r?.length>0?r.length+1:0;for(let l of Object.keys(e))if(l==="__ROW_PATH__")o[s-1]=e[l];else{let n=this.model._column_paths.indexOf(l);o[n+s]=e[l]}this.regular_table.restoreColumnSizes(o)}function j(){if(!this._initialized)return{};if(this._cached_column_sizes){let s=this._cached_column_sizes;return this._cached_column_sizes=void 0,s}let e=this.regular_table.saveColumnSizes(),{group_by:t}=this.model._config,o=t?.length>0?t.length+1:0,r={};for(let s of Object.keys(e)){let l=Number(s);if(e[l]!==void 0){let n=l-o;n>-1?r[this.model._column_paths[n]]=e[l]:n===-1&&(r.__ROW_PATH__=e[l])}}return r}function pe(e,t,o){let r=Array.from(e.children[0].children[0].children),s=r.length,l=t.hasAttribute("settings");if(s<=1?r[0]?.removeAttribute("id"):r.forEach((n,a)=>{let i=l?1:0,d=a===s-(i+1)?"psp-column-titles":a===s-i?"psp-column-edit-buttons":null;d?n.setAttribute("id",d):n.removeAttribute("id")}),t.classList.toggle("psp-menu-open",!!o),l&&s>=2){let n=Array.from(r[s-2].children),a=Array.from(r[s-1].children);if(n&&a){r.slice(0,s-2).forEach(i=>{Array.from(i.children).forEach(d=>{d.classList.toggle("psp-menu-open",!1)})});for(let i=0;i<n.length;i++){let d=n[i],p=a[i],c=d.textContent===o;if(d.classList.toggle("psp-menu-open",c),p.classList.toggle("psp-menu-open",c),this._config.columns.length>1)for(let m of e.querySelectorAll("td")){let u=e.getMeta(m);if(!u?.column_header)continue;let g=u.column_header[u.column_header.length-2]===o;m.classList.toggle("psp-menu-open",g)}}}}}function me(e,t,o){let r=this._config.group_by.length,s=this._column_settings_selected_column;for(let{element:l,metadata:n}of e.cells){if(!n||n.type==="body"||n.type==="row_header")continue;let a=n.column_header?.[this._config.split_by.length],i=this._config.sort.find(b=>b[0]===a),d=n.type==="corner"&&n.row_header_x===r,p=typeof n.x>"u";d=d||n.x!==void 0&&(n.x+1)%this._config.columns.length===0,l.classList.toggle("psp-header-border",d),l.classList.toggle("psp-header-group",!1),l.classList.toggle("psp-header-leaf",!0),l.classList.toggle("psp-is-top",!1),l.classList.toggle("psp-header-corner",p),l.classList.toggle("psp-header-sort-asc",!o&&!!i&&i[1]==="asc"),l.classList.toggle("psp-header-sort-desc",!o&&!!i&&i[1]==="desc"),l.classList.toggle("psp-header-sort-col-asc",!o&&!!i&&i[1]==="col asc"),l.classList.toggle("psp-header-sort-col-desc",!o&&!!i&&i[1]==="col desc"),l.classList.toggle("psp-header-sort-abs-asc",!o&&!!i&&i[1]==="asc abs"),l.classList.toggle("psp-header-sort-abs-desc",!o&&!!i&&i[1]==="desc abs"),l.classList.toggle("psp-header-sort-abs-col-asc",!o&&!!i&&i[1]==="col asc abs"),l.classList.toggle("psp-header-sort-abs-col-desc",!o&&!!i&&i[1]==="col desc abs");let c=N(this,n),m=c==="integer"||c==="float",u=c==="string",g=c==="date",_=c==="datetime";if(l.classList.toggle("psp-align-right",m),l.classList.toggle("psp-align-left",!m),l.classList.toggle("psp-menu-enabled",(u||m||g||_)&&!p&&n.column_header_y===this._config.split_by.length+1),l.classList.toggle("psp-sort-enabled",(u||m||g||_)&&!p&&n.column_header_y===this._config.split_by.length),l.classList.toggle("psp-is-width-override",t.saveColumnSizes()[n.size_key]!==void 0),this._config.columns.length>1&&s){let b=n.column_header?.[n.column_header.length-2]===s;l.classList.toggle("psp-menu-open",b)}}}var et={desc:"asc",asc:void 0,"desc abs":"asc abs","asc abs":void 0},tt={desc:"asc",asc:"col desc","desc abs":"asc abs","asc abs":"col desc abs","col desc":"col asc","col asc":void 0,"col desc abs":"col asc abs","col asc abs":void 0};async function ue(e,t,o,r){let s=e.getMeta(r);if(!s?.column_header)return;let l=s.column_header[this._config.split_by.length],n=o.ctrlKey||o.metaKet||o.altKey?ot:rt,a=o.shiftKey,i=n.call(this,`${l}`,a);await t.restore({sort:i})}function ot(e,t){let o=[],r=!1;for(let s of this._config.sort){let[l,n]=s;if(l===e){r=!0;let a=ge.call(this,e,n,t);a&&o.push(a)}else o.push(s)}return r||o.push([e,t?"desc abs":"desc"]),o}function rt(e,t){for(let[o,r]of this._config.sort)if(o===e){let s=ge.call(this,e,r,t);return s?[s]:[]}return[[e,t?"desc abs":"desc"]]}function ge(e,t,o){let s=this._config.split_by.length>0?tt:et,l=t?s[t]:"desc";if(l)return[e,l]}async function _e(e,t){let o=e.getMeta(t.target);if(!o||o.type!=="row_header")return;let r=t.target.classList.contains("psp-tree-label-collapse");t.shiftKey&&r?this._view.set_depth(o.row_header.filter(s=>s!==void 0).length-2):t.shiftKey?this._view.set_depth(o.row_header.filter(s=>s!==void 0).length-1):r?this._view.collapse(o.y):this._view.expand(o.y),this._num_rows=await this._view.num_rows(),this._num_columns=await this._view.num_columns(),e.draw()}async function be(e,t,o){if(o.which!==1)return;let r=o.target;if(r?.tagName!=="A"){for(;r&&r.tagName!=="TD"&&r.tagName!=="TH";)if(r=r.parentElement,!r||!e.contains(r))return;if(r){if(r.classList.contains("psp-tree-label")){_e.call(this,e,o);return}if(r.classList.contains("psp-menu-enabled")){let l=e.getMeta(r)?.column_header?.[this._config.split_by.length];await t.toggleColumnSettings(`${l}`)}else r.classList.contains("psp-sort-enabled")&&ue.call(this,e,t,o,r)}}}function fe(e,t){if(t.which!==1)return;let o=t.target;for(;o&&o.tagName!=="TD"&&o.tagName!=="TH";)if(o=o.parentElement,!o||!e.contains(o))return;o&&(o.classList.contains("psp-tree-label")&&t.offsetX<26||o.classList.contains("psp-header-leaf")&&!o.classList.contains("psp-header-corner"))&&t.stopImmediatePropagation()}function te(e,t,o){let r=e.getMeta(o);if(!r)return!1;let s=t._schema[t._column_paths[r.x]],l=o.textContent||"",n=t._ids[r.y-r.y0][0];if(s==="float"||s==="integer"){let i=parseFloat(l.replace(/,/g,""));if(isNaN(i))return!1;l=i}else if(s==="date"||s==="datetime"){let i=Date.parse(l);if(isNaN(i))return!1;l=i}else s==="boolean"&&(l=l==="true"?!1:l==="false"?!0:null);let a={__INDEX__:n,[t._column_paths[r.x]]:l};return t._table.update([a],{port_id:t._edit_port,format:null}),!0}function he(e,t,o){let r=e.getMeta(o.target);if(r?.type==="body"||r?.type==="column_header"){let s=this._is_editable[r.x],l=N(this,r)==="boolean",n=o.target.classList.contains("psp-null");s&&l&&!n&&te(e,this,o.target)}}function ye(e,t,o){let r=o.get(t),s=t.getRootNode();if(r){for(let{element:l,metadata:n}of e)if(n.type==="body"&&n.x===r.x&&n.y===r.y){s.activeElement!==l&&l.focus({preventScroll:!0});return}document.activeElement!==document.body&&t.contains(s.activeElement)&&s.activeElement.blur()}}function ve(e,t){let o=t.get(e);if(!o)return!1;let r=e.getRootNode(),s=e.children[0]?.children[1];if(s)for(let l of s.children)for(let n of l.children){let a=e.getMeta(n);if(a?.type==="body"&&a.x===o.x&&a.y===o.y)return r.activeElement!==n&&n.focus({preventScroll:!0}),!0}return document.activeElement!==document.body&&e.contains(r.activeElement)&&r.activeElement.blur(),!1}function st(e){let t;return async function(...o){if(t){await t;return}let r;t=new Promise(l=>r=l);let s=await e.apply(this,o);return t=void 0,r(),s}}function we(){if(this.isContentEditable){let e=this.getRootNode().getSelection()?.getRangeAt(0);if(!e)return 0;let t=e.cloneRange();return t.selectNodeContents(this),t.setEnd(e.endContainer,e.endOffset),t.toString().length}else return this.selectionStart||0}var V=st(async function(e,t,o,r,s){let l=e.getMeta(o);if(!l||l.type!=="body")return;let n=this._column_paths.length,a=this._num_rows,i=t.get(e);if(!i)return;l.x+r<n&&0<=l.x+r&&(i.x=l.x+r),l.y+s<a&&0<=l.y+s&&(i.y=l.y+s);let d=Math.max(l.x0-10,0),p=Math.min(l.x0+10,n),c=Math.max(l.y0-5,0),m=Math.min(l.y0+10,a),u=l.x0+r,g=l.y0+s;for(;!ve(e,t)&&u>=d&&u<p&&g>=c&&g<m;)await e.scrollToCell(u,g),t.set(e,i),u+=r,g+=s});function nt(e,t,o){let r=t.getMeta(o);return r?.type==="body"&&r.y===e._num_rows-1}function xe(e,t,o,r){let s=e.getRootNode().activeElement;switch(r.target.classList.remove("psp-error"),r.key){case"Enter":r.preventDefault(),nt(this,e,s)?(s.blur(),o.delete(e)):r.shiftKey?V.call(this,e,o,s,0,-1):V.call(this,e,o,s,0,1);break;case"ArrowLeft":we.call(s)===0&&(r.preventDefault(),V.call(this,e,o,s,-1,0));break;case"ArrowUp":r.preventDefault(),V.call(this,e,o,s,0,-1);break;case"ArrowRight":we.call(s)===(s.textContent?.length||0)&&(r.preventDefault(),V.call(this,e,o,s,1,0));break;case"ArrowDown":r.preventDefault(),V.call(this,e,o,s,0,1);break;default:}}function q(e,t=!1){let o=this._config.group_by.length===0&&this._config.split_by.length===0,r=e.hasAttribute("selectable"),s=e.children[0],l=t||s?._edit_mode==="EDIT";return o&&!r&&l}function Ee(e,t,o,r){if(this._edit_mode==="EDIT"){if(!q.call(this,t))return;xe.call(this,e,t,o,r)}else console.debug(`Mode ${this._edit_mode} for "keydown" event not yet implemented`)}function Ce(e,t,o){if(this._edit_mode==="EDIT"){if(!q.call(this,t))return;he.call(this,e,t,o)}else this._edit_mode==="READ_ONLY"||this._edit_mode==="SELECT_COLUMN"||this._edit_mode==="SELECT_ROW"||this._edit_mode==="SELECT_REGION"||console.debug(`Mode ${this._edit_mode} for "click" event not yet implemented`)}function ke(e,t,o,r){if(q.call(this,t)&&o.has(e)){let s=r.target;s.classList.remove("psp-error");let l=o.get(e);o.delete(e),l.content!==s.textContent&&(te(e,this,s)||(s.textContent=l.content||"",s.classList.add("psp-error"),s.focus()))}}function Me(e,t,o,r){let s=r.target,l=e.getMeta(s);if(l?.type==="body"){let n={x:l.x,y:l.y,content:s.textContent||void 0};o.set(e,n)}}async function G({_view:e,_config:t},o,r){let s=t.group_by,l=t.split_by,n=o>=0?o:0,a=n+1,i=await e.to_json({start_row:n,end_row:a}),p=i.map(f=>f.__ROW_PATH__)[0]||[],c=s.map((f,w)=>{let y=p[w];return y?[f,"==",y]:void 0}).filter(f=>f!==void 0),m=s.length>0?r+1:r,u=Object.keys(i[0])[m],g={row:i[0],column_names:[],config:{filter:[]}},_=[];if(u){let f=u.split("|");g.column_names=[f[l.length]],_=l.map((w,y)=>{let E=f[y];return E?[w,"==",E]:void 0}).filter(w=>w!==void 0).filter(([,,w])=>w!=="__ROW_PATH__")}let b=t.filter.concat(c).concat(_);return g.config={filter:b},g}async function Se(e,t,o,r){let s=e.getMeta(r.target);if(t.hasAttribute("selectable")&&!r.handled&&!r.shiftKey&&r.button===0&&(r.stopImmediatePropagation(),!!s&&(s.type==="body"||s.type==="row_header")&&s.y>=0)){let l=this._ids?.[s.y-s.y0],n=o.get(e),a=!!n&&n.reduce((u,g,_)=>u&&g===l[_],!0),i=!!n&&l.length===n.length&&a,d={selected:!i,row:{},config:{filter:[]}},{row:p,column_names:c,config:m}=await G(this,s.y,s.type==="body"?s.x:0);i?(o.delete(e),d={...d,row:p,config:{filter:structuredClone(this._config.filter)}}):(o.set(e,l),d={...d,row:p,column_names:c,config:m}),await e.draw({preserve_width:!0}),r.handled=!0,t.dispatchEvent(new CustomEvent("perspective-select",{bubbles:!0,composed:!0,detail:d}))}}async function Te(e,t,o){o.delete(e);for(let r of e.querySelectorAll("td,th"))r.classList.toggle("psp-row-selected",!1),r.classList.toggle("psp-row-subselected",!1)}async function Re(e,t,o){let r=e.getMeta(o.target);if(!r||r.type!=="body")return;let{x:s,y:l}=r,{row:n,column_names:a,config:i}=await G(this,l,s);t.dispatchEvent(new CustomEvent("perspective-click",{bubbles:!0,composed:!0,detail:{row:n,column_names:a,config:i}}))}var at="mouse-selected-area",Le=(e,t,{className:o=at,selected:r=[]}={})=>(e.model._selection_state={selected_areas:r,dirty:!0},t.addEventListener("mousedown",ct(e,t,o)),t.addEventListener("mouseover",dt(e,t,o)),t.addEventListener("mouseup",pt(e,t,o)),t.addStyleListener(()=>$(e,t,o)),t),ct=(e,t,o)=>r=>{let s=r;if(s.button===0&&(e.model._edit_mode==="SELECT_REGION"||e.model._edit_mode==="SELECT_ROW"||e.model._edit_mode==="SELECT_COLUMN")){e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES={};let l=t.getMeta(s.target);if(l?.type==="body"&&l.x!==void 0&&l.y!==void 0){e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES={x:l.x,y:l.y},e.model._selection_state.old_selected_areas=e.model._selection_state.selected_areas,e.model._selection_state.selected_areas=[];let n={x0:l.x,x1:l.x,y0:l.y,y1:l.y};e.model._selection_state.potential_selection=n,$(e,t,o,e.model._selection_state.selected_areas.concat([n]));return}}e.model._selection_state.selected_areas=[]},dt=(e,t,o)=>r=>{let s=r;if((e.model._edit_mode==="SELECT_REGION"||e.model._edit_mode==="SELECT_ROW"||e.model._edit_mode==="SELECT_COLUMN")&&e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES&&e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x!==void 0){let l=t.getMeta(s.target);if(l?.type==="body"&&l.x!==void 0&&l.y!==void 0){let n={x0:Math.min(l.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),x1:Math.max(l.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),y0:Math.min(l.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y),y1:Math.max(l.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y)};e.model._selection_state.potential_selection=n,$(e,t,o,e.model._selection_state.selected_areas.concat([n]))}}},pt=(e,t,o)=>r=>{let s=r;if(e.model._edit_mode==="SELECT_REGION"||e.model._edit_mode==="SELECT_ROW"||e.model._edit_mode==="SELECT_COLUMN"){let l=t.getMeta(s.target);if(!l)return;if((e.model._selection_state.old_selected_areas?.length??0)>0){let n=e.model._selection_state.old_selected_areas[0];if(n.x0===n.x1&&n.y0===n.y1&&l?.type==="body"&&n.x0===l.x&&n.y0===l.y){e.model._selection_state.selected_areas=[],e.model._selection_state.old_selected_areas=[],e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES={},e.model._selection_state.potential_selection=void 0,$(e,t,o,[]);return}}if(e.model._selection_state.old_selected_areas=[],e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES&&e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x!==void 0&&l?.type==="body"&&l.x!==void 0&&l.y!==void 0){let n={x0:Math.min(l.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),x1:Math.max(l.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),y0:Math.min(l.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y),y1:Math.max(l.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y)};e.model._selection_state.selected_areas.push(n),$(e,t,o)}e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES={},e.model._selection_state.potential_selection=void 0}};function mt(e,t,{x0:o,x1:r,y0:s,y1:l}){let n={},a=t.model._edit_mode;o!==void 0&&["SELECT_COLUMN","SELECT_REGION"].indexOf(a)>-1&&(n.start_col=o),r!==void 0&&["SELECT_COLUMN","SELECT_REGION"].indexOf(a)>-1&&(n.end_col=r+1),s!==void 0&&["SELECT_ROW","SELECT_REGION"].indexOf(a)>-1&&(n.start_row=s),l!==void 0&&["SELECT_ROW","SELECT_REGION"].indexOf(a)>-1&&(n.end_row=l+1),e.setSelection(n)}var $=(e,t,o,r)=>{if(e.model._edit_mode==="SELECT_REGION"||e.model._edit_mode==="SELECT_ROW"||e.model._edit_mode==="SELECT_COLUMN"){r=e.model._selection_state.selected_areas.slice(0),e.model._selection_state.potential_selection&&r.push(e.model._selection_state.potential_selection);let s=t.querySelectorAll("tbody td");if(r.length>0)mt(e.parentElement,e,r[0]),ut(e,t,r,o);else{e.parentElement.setSelection();for(let l of s)l.classList.remove(o)}}else if(e.model._selection_state.dirty){e.model._selection_state.dirty=!1;let s=t.querySelectorAll("tbody td");for(let l of s)l.classList.remove(o)}},ut=(e,t,o,r)=>{if(e.model._edit_mode==="SELECT_REGION"&&o.length>0){let s=t.querySelectorAll("tbody td");for(let l of s){let n=t.getMeta(l);if(!n||n.type!=="body")continue;let a=!1;for(let{x0:i,x1:d,y0:p,y1:c}of o)i!==void 0&&p!==void 0&&d!==void 0&&c!==void 0&&i<=n.x&&n.x<=d&&p<=n.y&&n.y<=c&&(a=!0,e.model._selection_state.dirty=!0,l.classList.add(r));a||l.classList.remove(r)}}else if(e.model._edit_mode==="SELECT_ROW"&&o.length>0){let s=t.querySelectorAll("tbody td");for(let l of s){let n=t.getMeta(l);if(!n)continue;let a=!1;for(let{x0:i,x1:d,y0:p,y1:c}of o)i!==void 0&&p!==void 0&&d!==void 0&&c!==void 0&&n?.type==="body"&&p<=n.y&&n.y<=c&&(e.model._selection_state.dirty=!0,a=!0,l.classList.add(r));a||l.classList.remove(r)}}else if(e.model._edit_mode==="SELECT_COLUMN"&&o.length>0){let s=t.querySelectorAll("tbody td");for(let l of s){let n=t.getMeta(l);if(!n)continue;let a=!1;for(let{x0:i,x1:d,y0:p,y1:c}of o)i!==void 0&&p!==void 0&&d!==void 0&&c!==void 0&&n?.type==="body"&&i<=n.x&&n.x<=d&&(e.model._selection_state.dirty=!0,a=!0,l.classList.add(r));a||l.classList.remove(r)}}};function De(e,t,o){if(e.length===0)return;let r=this._column_settings_selected_column,s=e.length,l=o.hasAttribute("settings");if(s<=1?e[0]?.row.removeAttribute("id"):e.forEach(({row:i},d)=>{let p=l?1:0,c=d===s-(p+1)?"psp-column-titles":d===s-p?"psp-column-edit-buttons":null;c?i.setAttribute("id",c):i.removeAttribute("id")}),o.classList.toggle("psp-menu-open",!!r),l&&s>=2){let i=e[s-2],d=e[s-1];if(i&&d){e.slice(0,s-2).forEach(({cells:p})=>{p.forEach(({element:c})=>{c.classList.toggle("psp-menu-open",!1)})});for(let p=0;p<i.cells.length;p++){let c=i.cells[p]?.element,m=d.cells[p]?.element;if(!c||!m)continue;let u=c.textContent===r;c.classList.toggle("psp-menu-open",u),m.classList.toggle("psp-menu-open",u)}}}let n=this._config.split_by.length;if(n<e.length){let i=e[n];i&&this._styleColumnHeaderRow(i,t,!1)}let a=this._config.split_by.length+1;if(a<e.length){let i=e[a];i&&this._styleColumnHeaderRow(i,t,!0)}}function Pe(e,t){let o=this._config.group_by.length,r=[],s=new Set;for(let l=0;l<e.length;l++){let{row:n,cells:a}=e[l],i=new Set;for(let d=0;d<a.length;d++){let{element:p,metadata:c}=a[d];if(!c)continue;p.style.backgroundColor="";let m=c.type==="corner"&&o>0&&c.row_header_x===o||c.type==="column_header"&&c.x>=0;p.classList.toggle("psp-align-right",!1),p.classList.toggle("psp-align-left",!1),p.classList.toggle("psp-header-group",!0),p.classList.toggle("psp-header-leaf",!1),p.classList.toggle("psp-header-border",m),p.classList.toggle("psp-header-group-corner",c.type==="corner"),p.classList.toggle("psp-color-mode-bar",!1),p.classList.toggle("psp-header-sort-asc",!1),p.classList.toggle("psp-header-sort-desc",!1),p.classList.toggle("psp-header-sort-col-asc",!1),p.classList.toggle("psp-header-sort-col-desc",!1),p.classList.toggle("psp-sort-enabled",!1);let u=d;for(;r[l]&&r[l][u];++u);i.add(u);let g=p;for(let _=u;_<u+g.colSpan;++_)for(let b=l;b<l+g.rowSpan;++b)r[b]||(r[b]=[]),r[b][_]=!0;g.classList.toggle("psp-is-top",l===0||!s.has(u))}s=i}}function Oe(e,t,[,,,,,o,r],[,,,,,s,l],n){let a=this._ids?.[e.dy??0]?.join("|"),i=(n?(e.column_header??[]).slice(0,-1):e.column_header??[]).join("|");if(this.last_reverse_columns?.has(i)&&this.last_reverse_ids?.has(a)){let d=this.last_reverse_ids?.get(a),p=this.last_reverse_columns.get(i);this._is_old_viewport?p!==void 0&&d!==void 0&&this.last_meta?.[p]?.[d]!==void 0&&this.last_meta[p][d]>(e.user??0)?(t.style.setProperty("--pulse--background-color-start",s),t.style.setProperty("--pulse--background-color-end",l),t.style.animationName==="pulse_neg"?t.style.animation="pulse_neg2 0.5s linear":t.style.animation="pulse_neg 0.5s linear"):p!==void 0&&d!==void 0&&this.last_meta?.[p]?.[d]!==void 0&&this.last_meta[p][d]<(e.user??0)?(t.style.setProperty("--pulse--background-color-start",o),t.style.setProperty("--pulse--background-color-end",r),t.style.animationName==="pulse_pos"?t.style.animation="pulse_pos2 0.5s linear":t.style.animation="pulse_pos 0.5s linear"):d!==e.dy&&(t.style.animation=""):t.style.animation=""}else t.style.animation=""}function He(e,t,o,r){let s=(o.user??0)>0,l=(o.user??0)<0,n;e?.pos_bg_color!==void 0?n=e.pos_bg_color:n=this._pos_bg_color;let a;e?.neg_bg_color!==void 0?a=e.neg_bg_color:a=this._neg_bg_color;let i=s?n:l?a:["",this._plugin_background[0],this._plugin_background[1],this._plugin_background[2],"","",""];{let[m,u,g,_]=i;if(t.style.position="",o._is_hidden_by_aggregate_depth)t.style.animation="",t.style.backgroundColor="";else if(e?.number_bg_mode==="color")t.style.animation="",t.style.backgroundColor=m;else if(e?.number_bg_mode==="gradient"){let b=Math.max(0,Math.min(1,Math.abs((o.user??0)/(e.bg_gradient??1)))),f=this._plugin_background,w=O(P([u,g,_,b],f));t.style.animation="",t.style.color=w,t.style.backgroundColor=`rgba(${u},${g},${_},${b})`}else e?.number_bg_mode==="pulse"?(Oe.call(this,o,t,n,a,r),t.style.backgroundColor=""):(e?.number_bg_mode==="disabled"||e?.number_bg_mode,t.style.animation="",t.style.backgroundColor="")}let d=e?.pos_fg_color!==void 0?s?e.pos_fg_color:l?e.neg_fg_color:["",this._plugin_background[0],this._plugin_background[1],this._plugin_background[2],"","",""]:s?this._pos_fg_color:l?this._neg_fg_color:["",this._plugin_background[0],this._plugin_background[1],this._plugin_background[2],"","",""],[p,,,,c]=d;if(o._is_hidden_by_aggregate_depth)t.style.backgroundColor="",t.style.color="";else if(e?.number_fg_mode==="disabled")if(e?.number_bg_mode==="color"){let m=this._plugin_background,u=O(P([i[1],i[2],i[3],1],m));t.style.color=u}else e?.number_bg_mode==="gradient"||(t.style.color="");else e?.number_fg_mode==="bar"?(t.style.color="",t.style.position="relative",c!==""&&t.children.length>0&&t.children[0].nodeType===Node.ELEMENT_NODE&&(t.children[0].style.background=c)):(e?.number_fg_mode==="color"||!e?.number_fg_mode)&&(t.style.color=p)}import Ae from"chroma-js";function Ne(e,t,o){let r=o.column_header?.[this._config.split_by.length],s=e?.color!==void 0?e.color:this._color,[l,n,a,i]=s;if(o._is_hidden_by_aggregate_depth)t.style.backgroundColor="",t.style.color="";else if(e?.string_color_mode==="foreground"&&o.user!==null)t.style.color=l,t.style.backgroundColor="",e?.format==="link"&&t.children[0]&&(t.children[0].style.color=l);else if(e?.string_color_mode==="background"&&o.user!==null){let d=this._plugin_background,p=O(P([n,a,i,1],d));t.style.color=p,t.style.backgroundColor=l}else if(e?.string_color_mode==="series"&&o.user!==null&&r){this._series_color_map.has(r)||(this._series_color_map.set(r,new Map),this._series_color_seed.set(r,0));let d=this._series_color_map.get(r);if(o.user&&!d.has(o.user)){let S=this._series_color_seed.get(r)??0;d.set(o.user,S),this._series_color_seed.set(r,S+1)}let p=d.get(o.user)??0,[c,m,u]=Ae(l).hsl();c=c+p*150%360;let g=Ae(c,m,u,"hsl"),[_,b,f]=g.rgb(),w=g.hex(),y=this._plugin_background,E=O(P([_,b,f,1],y));t.style.color=E,t.style.backgroundColor=w}else t.style.backgroundColor="",t.style.color=""}function Ve(e,t,o){let r=this._color,[s,l,n,a]=r;if(o._is_hidden_by_aggregate_depth)t.style.backgroundColor="",t.style.color="";else if(e?.datetime_color_mode==="foreground"&&o.user!==null)t.style.color=s,t.style.backgroundColor="";else if(e?.datetime_color_mode==="background"&&o.user!==null){let i=this._plugin_background,d=O(P([l,n,a,1],i));t.style.color=d,t.style.backgroundColor=s}else t.style.backgroundColor="",t.style.color=""}function ze(e,t,o){if(o._is_hidden_by_aggregate_depth)t.style.backgroundColor="",t.style.color="";else{let[r]=o.user===!0?this._pos_fg_color:o.user===!1?this._neg_fg_color:["",0,0,0,""];t.style.backgroundColor="",t.style.color=r}}function Ie(e,t,o){let r=o.value!==void 0&&o.value!==null&&o.value?.toString()?.trim().length>0,s=(o.row_header_x??0)>=this._config.group_by.length,l=e.getMeta({dx:0,dy:(o.y??0)-(o.y0??0)+1}),n=l&&l.row_header&&typeof l.row_header[(o.row_header_x??0)+1]<"u";t.classList.toggle("psp-tree-label",r&&!s),t.classList.toggle("psp-tree-label-expand",r&&!s&&!n),t.classList.toggle("psp-tree-label-collapse",r&&!s&&n),t.classList.toggle("psp-tree-leaf",r&&s)}function We(e,t,o,r,s,l,n,a,i){let d=n.has(l),p=n.get(l);for(let{element:c,metadata:m,isHeader:u}of e){let g=m.column_header?.[this._config.split_by.length],_=N(this,m),b=g?t[g.toString()]:void 0,f=_==="integer"||_==="float";m._is_hidden_by_aggregate_depth=(y=>y===0||y===void 0?!1:y-1<Math.min(this._config.group_by.length,b?.aggregate_depth||0))(m.row_header?.filter(y=>y!==void 0)?.length),f?He.call(this,b,c,m,o):_==="boolean"?ze.call(this,b,c,m):_==="string"?Ne.call(this,b,c,m):_==="date"||_==="datetime"?Ve.call(this,b,c,m):(c.style.backgroundColor="",c.style.color=""),c.classList.toggle("psp-bool-type",_==="boolean"&&m.user!==null),c.classList.toggle("psp-null",m.value===null),c.classList.toggle("psp-align-right",!u&&f),c.classList.toggle("psp-align-left",u||!f),this._column_settings_selected_column?c.classList.toggle("psp-menu-open",g===this._column_settings_selected_column):c.classList.toggle("psp-menu-open",!1),c.classList.toggle("psp-color-mode-bar",b?.number_fg_mode==="bar"&&f),u&&Ie.call(this,l,c,m);let w=c.parentElement;if(w&&(w.dataset.y=String(m.y)),m.type!=="row_header"||m.row_header_x===m.row_header.length-1||m.row_header[m.row_header_x+1]===void 0?(c.dataset.y=String(m.y),m.type!=="row_header"?c.dataset.x=String(m.x):delete c.dataset.x):(delete c.dataset.y,delete c.dataset.x),r)if(!d)c.classList.toggle("psp-row-selected",!1),c.classList.toggle("psp-row-subselected",!1);else{let y=this._ids[(m.y??0)-(m.y0??0)],E=p.reduce((A,x,k)=>A&&x===y[k],!0),S=p;u&&m.type==="row_header"&&m.row_header_x!==void 0&&y[m.row_header_x]?(c.classList.toggle("psp-row-selected",!1),c.classList.toggle("psp-row-subselected",!1)):(c.classList.toggle("psp-row-selected",y.length===S.length&&E),c.classList.toggle("psp-row-subselected",y.length!==S.length&&E))}if(!u&&m.type==="body")if(s&&this._is_editable[m.x]){let E=m.column_header?.[this._config.split_by.length]?.toString();E&&_==="string"&&t[E]?.format==="link"?(c.toggleAttribute("contenteditable",!1),c.classList.toggle("boolean-editable",!1)):_==="boolean"?(c.toggleAttribute("contenteditable",!1),c.classList.toggle("boolean-editable",m.user!==null)):(s!==c.hasAttribute("contenteditable")&&c.toggleAttribute("contenteditable",s),c.classList.toggle("boolean-editable",!1))}else c.toggleAttribute("contenteditable",!1),c.classList.toggle("boolean-editable",!1)}}function Fe(e,t,o=!1){let r=e._config.group_by.length===0&&e._config.split_by.length===0,s=t.hasAttribute("selectable"),l=t.children[0],n=o||l?.dataset?.editMode==="EDIT";return r&&!s&&n}function Ue(e,t,o){return function(s,l){let n=s[M]||{},a=l.hasAttribute("settings"),i=l.hasAttribute("selectable"),d=Fe(this,l),p=Fe(this,l,!0);e.classList.toggle("edit-mode-allowed",p);let c=[],m=[],u=s.children[0]?.children[1];if(u)for(let _ of u.children)for(let b of _.children){let f=s.getMeta(b);if(f){let w=b.tagName==="TH";c.push({element:b,metadata:f,isHeader:w})}}let g=s.children[0]?.children[0];if(g)for(let _ of g.children){let b={row:_,cells:[]};for(let f of _.children){let w=s.getMeta(f);b.cells.push({element:f,metadata:w})}m.push(b)}this._applyBodyCellStyles(c,n,a,i,d,s,t,o,l),this._applyGroupHeaderStyles(m,s),this._applyColumnHeaderStyles(m,s,l),this._applyFocusStyle(c,s,o)}}function je(e){e._applyBodyCellStyles=We,e._applyGroupHeaderStyles=Pe,e._applyColumnHeaderStyles=De,e._applyFocusStyle=ye,e._styleColumnHeaderRow=me}async function Ge(e){let t=this.parentElement,o=await t.getTable();if(this._initialized)await K.call(this,this.regular_table,o,e,this.model);else{if(this.innerHTML="",this.shadowRoot?this.shadowRoot.appendChild(this.regular_table):this.appendChild(this.regular_table),this.model=await K.call(this,this.regular_table,o,e),!this.model)return;Le(this,this.regular_table,{className:"psp-select-region"});let r=new WeakMap,s=new WeakMap;je(this.model),this.regular_table.addStyleListener(Ue(this,r,s).bind(this.model,this.regular_table,t)),this.regular_table.addEventListener("click",fe.bind(this.model,this.regular_table)),this.regular_table.addEventListener("mousedown",Se.bind(this.model,this.regular_table,t,r)),this.regular_table.addEventListener("psp-deselect-all",Te.bind(this.model,this.regular_table,t,r)),this.regular_table.addEventListener("click",Re.bind(this.model,this.regular_table,t)),this.regular_table.addEventListener("mousedown",be.bind(this.model,this.regular_table,t)),this.regular_table.addEventListener("click",Ce.bind(this.model,this.regular_table,t)),this.regular_table.addEventListener("focusin",Me.bind(this.model,this.regular_table,t,s)),this.regular_table.addEventListener("focusout",ke.bind(this.model,this.regular_table,t,s)),this.regular_table.addEventListener("keydown",Ee.bind(this.model,this.regular_table,t,s)),t.addEventListener("perspective-toggle-column-settings",l=>{let n=l;if(this.isConnected){if(pe.call(this.model,this.regular_table,t,n.detail.column_name??void 0),!n.detail.open){this.model._column_settings_selected_column=void 0;return}this.model._column_settings_selected_column=n.detail.column_name??void 0}}),this._initialized=!0}}function $e(e,t){e=JSON.parse(JSON.stringify(e)),t=JSON.parse(JSON.stringify(t));let o={};if(e.columns)for(let[l,n]of Object.entries(e.columns))n.column_size_override!==void 0&&(o[l]=n.column_size_override,delete n.column_size_override);let r={};if(t)for(let[l,n]of Object.entries(t))r[l]={...n,pos_fg_color:n.pos_fg_color?R(n.pos_fg_color):void 0,neg_fg_color:n.neg_fg_color?R(n.neg_fg_color):void 0,pos_bg_color:n.pos_bg_color?R(n.pos_bg_color):void 0,neg_bg_color:n.neg_bg_color?R(n.neg_bg_color):void 0,color:n.color?R(n.color):void 0};"edit_mode"in e&&e.edit_mode&&(I.indexOf(e.edit_mode)!==-1?W.call(this,e.edit_mode):console.error("Unknown edit mode "+e.edit_mode)),"scroll_lock"in e&&F.call(this,e.scroll_lock);let s=this.regular_table;U.call(this,o,!0),s[M]=r}function Be(){if(this.regular_table){let e={columns:{},scroll_lock:!!this._is_scroll_lock,edit_mode:this._edit_mode},t=j.call(this);for(let o of Object.keys(t||{}))e.columns?.[o]||(e.columns=e.columns||{},e.columns[o]={}),e.columns[o].column_size_override=t[o];return JSON.parse(JSON.stringify(e))}return{}}async function Ye(e){if(this.parentElement&&await this.activate(e),!this.isConnected||this.offsetParent==null||!this.model)return;let t=j.call(this),o=this.regular_table.draw({invalid_columns:!0});this._reset_scroll_top&&(this.regular_table.scrollTop=0,this._reset_scroll_top=!1),this._reset_scroll_left&&(this.regular_table.scrollLeft=0,this._reset_scroll_left=!1),this._reset_select&&(this.regular_table.dispatchEvent(new CustomEvent("psp-deselect-all",{bubbles:!1})),this._reset_select=!1),this._reset_column_size&&(this.regular_table.resetAutoSize(),this._reset_column_size=!1),U.call(this,t),await o,this._toolbar?.classList.toggle("aggregated",this.model._config.group_by.length>0||this.model._config.split_by.length>0)}function oe(e,t){return e==="integer"||e==="float"?{datagrid_number_style:{fg_gradient:0,pos_fg_color:this.model._pos_fg_color[0],neg_fg_color:this.model._neg_fg_color[0],number_fg_mode:"color",bg_gradient:0,pos_bg_color:this.model._pos_bg_color[0],neg_bg_color:this.model._neg_bg_color[0],number_bg_mode:"disabled"},number_string_format:!0}:e==="date"||e==="datetime"||e==="string"?{[e==="date"||e==="datetime"?"datagrid_datetime_style":"datagrid_string_style"]:{color:this.model._color[0],bg_color:this.model._color[0]}}:null}var Ke='regular-table{padding:0;margin:12px 0 0 12px;font-family:inherit;--rt-hover--border-color:var(--inactive--color,#c5c9d080);}regular-table div[tabindex]{outline:none;}regular-table>div{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;}regular-table th{text-align:center;}regular-table thead tr:not(.rt-autosize) th{overflow:hidden;max-width:0px;}regular-table thead tr:last-child .rt-float,regular-table tbody .rt-float{text-align:right;}regular-table thead .rt-integer,regular-table tbody .rt-integer{text-align:right;}regular-table tbody th{text-align:left;}regular-table span.rt-tree-container{display:flex;align-items:center;height:100%;}regular-table thead .rt-string,regular-table tbody .rt-string,regular-table thead .rt-date,regular-table tbody .rt-date,regular-table thead .rt-datetime,regular-table tbody .rt-datetime{text-align:left;}regular-table thead tr:last-child th{border-bottom:1px solid#8b868045;}regular-table tbody tr:first-child td,regular-table tbody tr:first-child th{border-top:1px solid transparent!important;}regular-table th{position:relative;}regular-table tr th span.rt-tree-group{margin-left:5px;margin-right:15px;border-left:1px solid#eee;height:100%;}regular-table td,regular-table th{white-space:nowrap;font-size:12px;padding-right:5px;padding-left:5px;padding-top:0px;padding-bottom:0px;height:19px;}regular-table table *{box-sizing:border-box;}regular-table table{position:absolute;color:#666;outline:none;}regular-table span.rt-row-header-icon{color:#aaa;padding-right:4px;font-family:var(--button--font-family);}regular-table span.rt-column-header-icon{font-size:10px;padding-left:3px;display:inline-block;width:10px;font-family:var(--button--font-family);}regular-table span.rt-row-header-icon:hover{color:#1a7da1;text-shadow:0px 0px 3px#1a7da1;}regular-table .rt-selected td{background-color:#eee;}regular-table .rt-cell-clip{overflow:hidden;text-overflow:ellipsis;}regular-table td span.rt-group-name,regular-table th span.rt-group-name{margin-right:-5px;padding-right:5px;padding-left:8px;flex:1;height:100%;}regular-table th span.rt-group-name{text-align:left;}regular-table td th span.rt-group-leaf,regular-table th span.rt-group-leaf{margin-left:16px;height:100%;}regular-table .rt-column-resize{height:100%;width:10px;position:absolute;top:0;right:0;cursor:col-resize;}regular-table a{color:var(--rt-pos-cell--color);}regular-table a:visited{color:var(--active--color);}regular-table td.psp-null:after,regular-table th.psp-null:after{content:var(--null--content,"-");}.psp-header-border:not(.psp-is-top):not(.psp-header-leaf){box-shadow:1px 0px var(--inactive--border-color,#8b868045);}.psp-header-group{box-shadow:0px 10px 0 -9px var(--inactive--border-color,#8b868045);}.psp-is-top{box-shadow:5px 4px 0px -4px var(--inactive--border-color,#8b868045);}.psp-is-top.psp-header-group:not(.psp-header-group-corner){box-shadow:5px 4px 0px -4px var(--inactive--border-color,#8b868045),0px 10px 0 -9px var(--inactive--border-color,#8b868045);}.psp-header-border.psp-header-group:not(.psp-is-top):not(.psp-header-group-corner){box-shadow:1px 0px var(--inactive--border-color,#8b868045),0px 10px 0 -9px var(--inactive--border-color,#8b868045);}perspective-viewer[settings] tr.rt-autosize .psp-header-leaf.psp-header-border:not(.psp-menu-enabled){box-shadow:1px 0px var(--inactive--border-color,#8b868045);}:host-context(perspective-viewer[settings]) tr.rt-autosize .psp-header-leaf.psp-header-border:not(.psp-menu-enabled){box-shadow:1px 0px var(--inactive--border-color,#8b868045);}.psp-header-leaf.psp-header-border{box-shadow:5px -4px 0px -4px var(--inactive--border-color,#8b868045);}tr:only-child th{box-shadow:none!important;}regular-table tbody tr:hover th.psp-tree-leaf:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover th.psp-tree-label:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover td:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover:after{border-color:var(--rt-hover--border-color,#c5c9d080)!important;box-shadow:0px 1px 0px var(--rt-hover--border-color,#c5c9d080);}regular-table tbody tr:hover th.psp-tree-leaf.psp-menu-open:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover th.psp-tree-label.psp-menu-open:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover td.psp-menu-open:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr.psp-menu-open:hover:after{box-shadow:inset -2px 0px 0px var(--icon--color),inset 2px 0px 0px var(--icon--color),0px 1px 0px var(--rt-hover--border-color,#c5c9d080);}regular-table tbody tr:last-child:hover td.psp-menu-open:not(.psp-row-selected):not(.psp-row-subselected){box-shadow:inset -2px 0px 0px var(--icon--color),inset 2px 0px 0px var(--icon--color),inset 0px -2px 0px var(--icon--color),0px 1px 0px var(--rt-hover--border-color,#c5c9d080);}regular-table tbody tr:hover+tr th.psp-tree-leaf:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover+tr th.psp-tree-label:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover+tr td:not(.psp-row-selected):not(.psp-row-subselected){border-top-color:transparent;}regular-table tbody tr th:first-child:not(:empty),regular-table tbody tr th:first-child:empty+th:not(:empty),regular-table tbody tr th:first-child:empty~th:empty+th:not(:empty),regular-table tbody tr td:first-child{border-left-width:1px;border-left-color:transparent;}regular-table tbody tr th:last-child,regular-table tbody tr td:last-child{border-right-width:0px;border-right-color:transparent;}regular-table tbody tr:hover{color:inherit;}regular-table tbody tr:hover th:first-child:not(:empty),regular-table tbody tr:hover th:first-child:empty+th:not(:empty),regular-table tbody tr:hover th:first-child:empty~th:empty+th:not(:empty),regular-table tbody tr:hover td:first-child{border-left-color:var(--rt-hover--border-color,#c5c9d080)!important;}regular-table tbody tr:hover th:last-child,regular-table tbody tr:hover td:last-child{border-right-color:var(--rt-hover--border-color,#c5c9d080)!important;}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody td,perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table thead th:not(.rt-group-corner),:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody td,:host(:not(.sub-cell-scroll-disabled)) regular-table table thead th:not(.rt-group-corner){transform:translate(var(--regular-table--transform-x,0px));}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody,:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody{transform:translate(0,var(--regular-table--transform-y,0px));}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody tr:first-child td,perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody tr:first-child th,perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody tr:first-child:after,:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody tr:first-child td,:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody tr:first-child th,:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody tr:first-child:after{clip-path:polygon(0 var(--regular-table--clip-y,0),0 200%,200% 200%,200% var(--regular-table--clip-y,0));}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody tr td:first-of-type,:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody tr td:first-of-type{clip-path:polygon(var(--regular-table--clip-x,0) 0,var(--regular-table--clip-x,0) 200%,200% 200%,200% 0);}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody tr:first-child td:first-of-type,:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody tr:first-child td:first-of-type{clip-path:polygon(var(--regular-table--clip-x,0) var(--regular-table--clip-y,0),var(--regular-table--clip-x,0) 200%,200% 200%,200% var(--regular-table--clip-y,0));}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table thead tr:last-child:after,:host(:not(.sub-cell-scroll-disabled)) regular-table table thead tr:last-child:after{transform:translate(var(--regular-table--transform-x,0px));}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody tr:not(:first-child):after,:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody tr:not(:first-child):after{transform:translate(var(--regular-table--transform-x,0px));}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody tr:hover:first-child:after,:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody tr:hover:first-child:after{clip-path:polygon(0 var(--regular-table--clip-y,0),0 200%,200% 200%,200% var(--regular-table--clip-y,0));}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table thead tr th.rt-group-corner+th:not(.rt-group-corner),:host(:not(.sub-cell-scroll-disabled)) regular-table table thead tr th.rt-group-corner+th:not(.rt-group-corner){clip-path:polygon(var(--regular-table--clip-x,0) 0,var(--regular-table--clip-x,0) 200%,200% 200%,200% 0);}regular-table{outline:none;}regular-table::-webkit-scrollbar,regular-table::-webkit-scrollbar-corner{background-color:transparent;height:12px;width:12px;}regular-table::-webkit-scrollbar-thumb{background-clip:content-box;background:var(--icon--color);border:5.5px solid var(--plugin--background);max-height:50%;max-width:50%;min-width:10%;min-height:10%;}perspective-viewer .psp-menu-enabled{padding:0 6px;font-size:8px;border-radius:3px 3px 0 0;}perspective-viewer .psp-menu-enabled:hover,perspective-viewer tr:not(.rt-autosize) th.psp-menu-open{color:var(--plugin--background);background-color:var(--icon--color);border-bottom-color:var(--icon--color);cursor:pointer;}perspective-viewer tr:not(.rt-autosize) th.psp-menu-open:before{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;height:8px;width:10px;-webkit-mask-image:var(--column-settings-icon--mask-image);mask-image:var(--column-settings-icon--mask-image);margin-right:4px;background-color:var(--plugin--background);}perspective-viewer td.psp-menu-open{box-shadow:inset -2px 0px 0px var(--icon--color),inset 2px 0px 0px var(--icon--color);}perspective-viewer tr:first-child td.psp-menu-open{border-top-color:var(--icon--color)!important;}perspective-viewer tr:last-child td.psp-menu-open{box-shadow:inset -2px 0px 0px var(--icon--color),inset 2px 0px 0px var(--icon--color),inset 0px -2px 0px var(--icon--color);}:host .psp-menu-enabled{padding:0 6px;font-size:8px;border-radius:3px 3px 0 0;}:host .psp-menu-enabled:hover,:host tr:not(.rt-autosize) th.psp-menu-open{color:var(--plugin--background);background-color:var(--icon--color);border-bottom-color:var(--icon--color);cursor:pointer;}:host tr:not(.rt-autosize) th.psp-menu-open:before{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;height:8px;width:10px;-webkit-mask-image:var(--column-settings-icon--mask-image);mask-image:var(--column-settings-icon--mask-image);margin-right:4px;background-color:var(--plugin--background);}:host td.psp-menu-open{box-shadow:inset -2px 0px 0px var(--icon--color),inset 2px 0px 0px var(--icon--color);}:host tr:first-child td.psp-menu-open{border-top-color:var(--icon--color)!important;}:host tr:last-child td.psp-menu-open{box-shadow:inset -2px 0px 0px var(--icon--color),inset 2px 0px 0px var(--icon--color),inset 0px -2px 0px var(--icon--color);}perspective-viewer regular-table table thead tr:last-child th{border-bottom-width:1px;border-bottom-color:var(--inactive--border-color,#8b868045);}:host-context(perspective-viewer) regular-table table thead tr:last-child th{border-bottom-width:1px;border-bottom-color:var(--inactive--border-color,#8b868045);}.psp-sort-enabled:hover{cursor:pointer;}.psp-row-selected,:hover .psp-row-selected,:hover th.psp-tree-leaf.psp-row-selected,:hover th.psp-tree-label.psp-row-selected{color:white!important;background-color:var(--selected-row--background-color,#ea7319)!important;border-color:var(--selected-row--background-color,#ea7319)!important;}.psp-row-selected.psp-tree-label:not(:hover):before{color:white;}.psp-row-subselected,:hover .psp-row-subselected,:hover th.psp-tree-leaf.psp-row-subselected,:hover th.psp-tree-label.psp-row-subselected{background:rgba(234,115,25,0.2)!important;}.psp-error{color:red;}td:focus{outline:#666;outline-style:dotted;outline-width:1px;}perspective-viewer.dragging regular-table{pointer-events:none;}:host-context(perspective-viewer.dragging) regular-table{pointer-events:none;}.psp-header-border:last-child{border-right-width:0px;}.psp-header-sort-desc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-desc-icon--mask-image);mask-image:var(--sort-desc-icon--mask-image);}.psp-header-sort-asc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-asc-icon--mask-image);mask-image:var(--sort-asc-icon--mask-image);}.psp-header-sort-col-desc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-col-desc-icon--mask-image);mask-image:var(--sort-col-desc-icon--mask-image);}.psp-header-sort-col-asc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-col-asc-icon--mask-image);mask-image:var(--sort-col-asc-icon--mask-image);}.psp-header-sort-abs-desc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-abs-desc-icon--mask-image);mask-image:var(--sort-abs-desc-icon--mask-image);}.psp-header-sort-abs-asc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-abs-asc-icon--mask-image);mask-image:var(--sort-abs-asc-icon--mask-image);}.psp-header-sort-abs-col-desc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-abs-col-desc-icon--mask-image);mask-image:var(--sort-abs-col-desc-icon--mask-image);}.psp-header-sort-abs-col-asc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-abs-col-asc-icon--mask-image);mask-image:var(--sort-abs-col-asc-icon--mask-image);}tbody th:last-of-type{border-right:1px solid var(--inactive--border-color,#8b868045);overflow:hidden;text-overflow:ellipsis;}tbody th:empty{background-image:linear-gradient(to right,transparent 9px,var(--inactive--border-color,#eee) 10px,transparent 11px);background-repeat:no-repeat;min-width:20px;max-width:20px;pointer-events:none;}.psp-tree-label{max-width:0px;min-width:0px;}.psp-tree-label:before{color:var(--icon--color);font-family:var(--button--font-family,inherit);padding-right:11px;}.psp-tree-label-expand:before{content:var(--tree-label-expand--content,"+");}.psp-tree-label-collapse:before{content:var(--tree-label-collapse--content,"-");}.psp-tree-label-expand,.psp-tree-label-collapse{cursor:pointer;}.psp-tree-label:hover:before{color:var(--active--color);text-shadow:0px 0px 5px var(--active--color);}.psp-tree-leaf{padding-left:24px;}.psp-align-right{text-align:right;}.psp-align-left{text-align:left;}.psp-positive:not(:focus){color:var(--rt-pos-cell--color);}.psp-negative:not(:focus){color:var(--rt-neg-cell--color);}regular-table table tbody td{min-width:52px!important;}.psp-is-width-override .rt-column-resize,.rt-column-resize:hover{border:1px dashed#999;border-bottom-width:0px;border-left-width:0px;}.boolean-editable{cursor:pointer;}regular-table table{user-select:none;color:inherit;border-collapse:separate;}regular-table table th{font-weight:400;}regular-table table td,regular-table table th{border-color:var(--inactive--border-color,#8b868045);height:23px;}regular-table table .psp-header-group{text-overflow:ellipsis;}regular-table table th.psp-header-leaf{border-bottom-width:0px;}regular-table table th.psp-header-leaf span{height:23px;min-height:23px;}regular-table table td,regular-table table th.psp-tree-label,regular-table table th.psp-tree-label,regular-table table th.psp-tree-leaf,regular-table table tbody tr:first-child th{border-style:solid;border-width:0px;border-top-width:1px;}regular-table table tbody th:empty{background-position:0px -10px;}regular-table table td.psp-select-region,regular-table table th.psp-select-region{background-color:var(--icon--color)!important;color:var(--plugin--background)!important;border-color:var(--plugin--background)!important;}regular-table tbody tr:hover td.psp-select-region:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover+tr td.psp-select-region:not(.psp-row-selected):not(.psp-row-subselected){border-color:var(--plugin--background)!important;}regular-table tbody tr:hover td.psp-select-region.psp-menu-open:not(.psp-row-selected):not(.psp-row-subselected){box-shadow:inset -2px 0px 0px var(--plugin--background),inset 2px 0px 0px var(--plugin--background);}:host-context(perspective-viewer[settings]) td.psp-select-region.psp-menu-open{box-shadow:inset -2px 0px 0px var(--plugin--background),inset 2px 0px 0px var(--plugin--background);}regular-table #psp-column-edit-buttons th:not(.rt-group-corner) span:not(.rt-column-resize):before{content:var(--datagrid-column-edit-button--content,"Edit");}perspective-viewer:not([settings]) regular-table #psp-column-edit-buttons:after{content:none;}:host-context(perspective-viewer:not([settings])) regular-table #psp-column-edit-buttons:after{content:none;}regular-table table thead tr:last-child:after{width:10000px;box-sizing:border-box;display:block;height:23px;content:" ";border-bottom:1px solid var(--inactive--border-color);}regular-table table tbody tr:after{width:10000px;box-sizing:border-box;display:block;height:23px;content:" ";border-top:1px solid transparent;}regular-table table tbody tr:not(:first-child):after{border-top:1px solid var(--inactive--border-color);}regular-table table tbody tr:hover:not(:first-child):after{border-top:1px solid var(--rt-hover--border-color);}regular-table table tbody tr:hover+tr:after{border-top:1px solid var(--rt-hover--border-color);}@keyframes pulse_pos{0%{background-color:var(--pulse--background-color-start,rgba(0,128,255,0.5));}100%{background-color:var(--pulse--background-color-end,rgba(0,128,255,0));}}@keyframes pulse_pos2{0%{background-color:var(--pulse--background-color-start,rgba(0,128,255,0.5));}100%{background-color:var(--pulse--background-color-end,rgba(0,128,255,0));}}@keyframes pulse_neg{0%{background-color:var(--pulse--background-color-start,rgba(255,25,0,0.5));}100%{background-color:var(--pulse--background-color-end,rgba(255,25,0,0));}}@keyframes pulse_neg2{0%{background-color:var(--pulse--background-color-start,rgba(255,25,0,0.5));}100%{background-color:var(--pulse--background-color-end,rgba(255,25,0,0));}}';var J=class e extends HTMLElement{static _global_stylesheet_installed=!1;static _sheet;static renderTarget=window.CSS?.supports&&window.CSS?.supports("selector(:host-context(foo))")?"shadow":"light";regular_table;model;_toolbar;_edit_button;_scroll_lock;_is_scroll_lock;_edit_mode;_initialized;_reset_scroll_top;_reset_scroll_left;_reset_select;_reset_column_size;constructor(){super(),this.regular_table=document.createElement("regular-table"),this.regular_table.part="regular-table",this._is_scroll_lock=!1,this._edit_mode="READ_ONLY";let t=e;t._sheet||(t._sheet=new CSSStyleSheet,t._sheet.replaceSync(Ke)),t.renderTarget==="shadow"?this.attachShadow({mode:"open"}).adoptedStyleSheets.push(t._sheet):t.renderTarget==="light"&&!t._global_stylesheet_installed&&(t._global_stylesheet_installed=!0,document.adoptedStyleSheets.push(t._sheet))}connectedCallback(){this._toolbar||(this._toolbar=document.createElement("perspective-viewer-datagrid-toolbar"));let t=this.parentElement;t&&t.appendChild(this._toolbar)}disconnectedCallback(){this._toolbar?.parentElement?.removeChild?.(this._toolbar)}async activate(t){return await Ge.call(this,t)}get name(){return"Datagrid"}get category(){return"Basic"}get select_mode(){return"toggle"}get min_config_columns(){}get config_column_names(){return["Columns"]}get priority(){return 1}can_render_column_styles(t,o){return t!=="boolean"}column_style_controls(t,o){return oe.call(this,t,o)}async draw(t){return await Ye.call(this,t)}async update(t){if(this.model===void 0)await this.draw(t);else if(this.model._config.split_by?.length>0){let o=await t.dimensions();this.model._num_rows=o.num_view_rows,await this.regular_table.draw()}else this.model._num_rows=await t.num_rows(),await this.regular_table.draw()}async render(t){let r=await this.parentElement.getView(),s=await r.to_columns(t),l=await r.column_paths(t),n=t?.end_row!==void 0&&t?.end_row!==null&&t?.start_row!==void 0&&t?.start_row!==null?t.end_row-t.start_row:await r.num_rows(),a="";for(let i=0;i<n;i++){for(let d of l){let p=s[d],c=this.model._schema[d],m=this.regular_table[M],u=d.split("|").at(-1),g=ne(c,m?.[u]||{});g?a+=g.format(p[i])+" ":a+=p[i]+" "}a+=`
|
|
2
|
+
`}return a.trim()}async resize(){!this.isConnected||this.offsetParent==null||this._initialized&&await this.regular_table.draw()}async clear(){this.regular_table.resetAutoSize(),this.regular_table.clear()}async save(){return Be.call(this)}async restore(t,o){return $e.call(this,t,o??{})}async restyle(){this.model?._view&&await this.draw(this.model._view)}async delete(){this.disconnectedCallback(),this._toolbar=void 0,this.regular_table.table_model&&this.regular_table.resetAutoSize(),this.regular_table.clear()}};var qe=':host{position:relative;display:block;height:100%;}:host #container{position:absolute;display:flex;flex-direction:column;justify-content:stretch;align-items:stretch;top:0;left:0;right:0;bottom:0;}:host #toolbar{display:flex;align-items:stretch;height:100%;}:host #toolbar .hover-target{margin:0;display:inline-flex;align-items:center;cursor:pointer;}:host #toolbar .hover-target:hover{box-shadow:-4px 0 0 var(--icon--color),4px 0 0 var(--icon--color);background-color:var(--icon--color);}:host #slot-container{flex:1;position:relative;}#scroll_lock.lock-scroll:before{-webkit-mask-image:var(--toolbar-scroll-lock-active--content);}#scroll_lock:before{-webkit-mask-image:var(--toolbar-scroll-lock--content);}#select_mode:before{content:"highlight_alt";}#edit_mode:before{-webkit-mask-image:"";}#edit_mode[data-edit-mode="READ_ONLY"]:before{-webkit-mask-image:var(--toolbar-edit-mode--read-only--content);}#edit_mode[data-edit-mode="EDIT"]:before{-webkit-mask-image:var(--toolbar-edit-mode--edit--content);}:host(.aggregated) #toolbar #edit_mode[data-edit-mode="EDIT"]:before{-webkit-mask-image:var(--toolbar-edit-mode--read-only--content);}#edit_mode[data-edit-mode="SELECT_ROW"]:before{-webkit-mask-image:var(--toolbar-edit-mode--select-row--content);}#edit_mode[data-edit-mode="SELECT_COLUMN"]:before{-webkit-mask-image:var(--toolbar-edit-mode--select-column--content);}#edit_mode[data-edit-mode="SELECT_REGION"]:before{-webkit-mask-image:var(--toolbar-edit-mode--select-region--content);}#edit_mode[data-edit-mode="READ_ONLY"] span:before{content:var(--edit-mode--read-only--content,"Read Only");}#edit_mode[data-edit-mode="EDIT"] span:before{content:var(--edit-mode--edit--content,"Editable");}#edit_mode[data-edit-mode="SELECT_ROW"] span:before{content:var(--edit-mode--select-row--content,"Row Select");}#edit_mode[data-edit-mode="SELECT_COLUMN"] span:before{content:var(--edit-mode--select-column--content,"Column Select");}#edit_mode[data-edit-mode="SELECT_REGION"] span:before{content:var(--edit-mode--select-region--content,"Region Select");}#scroll_lock span:before{content:var(--scroll-lock-toggle--content,"Free Scroll");}#scroll_lock.lock-scroll span:before{content:var(--scroll-lock-alt-toggle--content,"Align Scroll");}.button:before{width:21px;height:21px;content:"";-webkit-mask-size:cover;mask-size:cover;background-color:var(--icon--color);}.button.editable:before,.button.lock-scroll:before{color:inherit;}.button{display:inline-flex;justify-content:center;align-items:center;user-select:none;padding:0 5px;border:1px solid transparent;border-radius:3px;border:1px solid transparent;box-sizing:border-box;display:inline-flex;font-size:var(--label--font-size,0.75em);height:22px;user-select:none;white-space:nowrap;width:37px;}.button>span{display:none;margin:0;padding:0;}.hover-target:focus-within .button,.hover-target:hover .button{position:relative;background-color:var(--icon--color);color:var(--plugin--background);opacity:1;display:flex;align-items:center;cursor:pointer;}.hover-target:focus-within .button:before,.hover-target:hover .button:before{background-color:var(--plugin--background);}.hover-target:focus-within .button>span,.hover-target:hover .button>span{display:block;position:absolute;top:calc(100% + 3px);left:50%;translate:-50%;margin:0;padding:5px;height:auto;white-space:pre-wrap;line-height:1;font-size:9px;background-color:var(--icon--color);width:35px;text-align:center;border-radius:0 0 3px 3px;}';var Je=new CSSStyleSheet;Je.replaceSync(qe);var Z=class extends HTMLElement{_initialized=!1;connectedCallback(){if(this._initialized)return;this._initialized=!0,this.setAttribute("slot","statusbar-extra"),this.attachShadow({mode:"open"}),this.shadowRoot.adoptedStyleSheets.push(Je),this.shadowRoot.innerHTML=`
|
|
3
3
|
<div id="toolbar">
|
|
4
4
|
<span class="hover-target">
|
|
5
5
|
<span id="scroll_lock" class="button">
|
|
@@ -12,5 +12,5 @@ import"regular-table";var M=Symbol("Perspective Column Config");import Xe from"c
|
|
|
12
12
|
</span>
|
|
13
13
|
</span>
|
|
14
14
|
</div>
|
|
15
|
-
`;let t=this.parentElement,o=this.previousElementSibling;o._scroll_lock=this.shadowRoot.querySelector("#scroll_lock"),o._scroll_lock.addEventListener("click",()=>
|
|
15
|
+
`;let t=this.parentElement,o=this.previousElementSibling;o._scroll_lock=this.shadowRoot.querySelector("#scroll_lock"),o._scroll_lock.addEventListener("click",()=>F.call(o)),o._edit_button=this.shadowRoot.querySelector("#edit_mode"),o._edit_button.addEventListener("click",()=>{W.call(o),o.regular_table.draw(),t.dispatchEvent(new Event("perspective-config-update"))})}};async function bt(){customElements.define("perspective-viewer-datagrid-toolbar",Z),customElements.define("perspective-viewer-datagrid",J),await customElements.whenDefined("perspective-viewer"),customElements.get("perspective-viewer").registerPlugin("perspective-viewer-datagrid")}bt();export{J as HTMLPerspectiveViewerDatagridPluginElement,Z as HTMLPerspectiveViewerDatagridToolbarElement,M as PRIVATE_PLUGIN_SYMBOL};
|
|
16
16
|
//# sourceMappingURL=perspective-viewer-datagrid.js.map
|