@perspective-dev/viewer-datagrid 4.1.0 → 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,6 +1,6 @@
|
|
|
1
|
-
var _e=new WeakMap,It=!0,Yr=navigator.userAgent.toLowerCase().indexOf("firefox")>-1,Xr=Yr?5e6:1e7,Ge=0,ye=0,jt=performance.now();function qr(){let e=performance.now(),t=e-jt,o=Ge,r=ye*1e3/t,n=1e3/o,s=ye;return Ge=0,ye=0,jt=e,{avg:o,real_fps:r,virtual_fps:n,num_frames:s,elapsed:t}}function Kr(e){Ge=(Ge*ye+e)/(ye+1),ye+=1}var ie=new Map;async function Zr(e){return await new Promise(requestAnimationFrame),await ie.get(e)?.promise}async function Gt(e,t){if(ie.has(e)&&(await ie.get(e)?.promise,ie.has(e))){await ie.get(e)?.promise;return}ie.set(e,Promise.withResolvers());try{return await t()}finally{let o=ie.get(e);ie.delete(e),o?.resolve(void 0)}}var Jr=":host{position:absolute;top:0px;left:0px;right:0px;bottom:0px;overflow:scroll;overflow-anchor:none;overscroll-behavior:none;-webkit-overflow-scrolling:touch;}div.rt-virtual-panel{position:absolute;top:0;left:0;right:0;pointer-events:none;}div.rt-scroll-table-clip{position:sticky;contain:strict;overflow-anchor:none;width:100%;height:100%;}div.rt-tree-container{display:flex;align-items:center;height:100%;}slot{position:absolute;overflow:hidden;overflow-anchor:none;}",Qr=":host ::slotted(table){--regular-table--transform-x:0px;--regular-table--transform-y:0px;--regular-table--clip-x:0px;--regular-table--clip-y:0px;}",en="--regular-table--clip-x",tn="--regular-table--clip-y",on="--regular-table--transform-x",rn="--regular-table--transform-y",nn='<div class="rt-virtual-panel"></div><div class="rt-scroll-table-clip"><slot></slot></div>',sn=class extends HTMLElement{u;n;i;a;M;v;T;C;S;K;s;e;t;E;L;table_model;o;async draw(e={}){return typeof e.throttle<"u"&&!e.throttle?await $t.call(this,e):await Gt(this,()=>$t.call(this,e))}async flush(){await Zr(this)}J(){if(this.attachShadow({mode:"open"}),!this.shadowRoot)return;let e=new CSSStyleSheet;e.replaceSync(Jr);let t=new CSSStyleSheet;t.replaceSync(Qr),this.u=t.cssRules[0],this.shadowRoot.adoptedStyleSheets=[e,t],this.shadowRoot.innerHTML=nn;let[o,r]=this.shadowRoot.children;this.s=r,this.n=o,this.P()}P(){this.s&&(this.i==="both"||this.i==="vertical"?this.s.style.top="0px":this.s.style.removeProperty("top"),this.i==="both"||this.i==="horizontal"?this.s.style.left="0px":this.s.style.removeProperty("left"),this.i!=="both"?this.s.style.contain="none":this.s.style.removeProperty("contain"))}Q(e,t){let{start_row:o,end_row:r}=this.Z(e),{start_col:n,end_col:s}=this.H(t);return{start_col:n,end_col:s,start_row:o,end_row:r}}ee({start_col:e,end_col:t,start_row:o,end_row:r}){o=Math.floor(o),r=Math.ceil(r),e=Math.floor(e),t=Math.ceil(t);let n=this.T!==e,s=this.M!==o||this.v!==r||this.C!==t;return this.T=e,this.C=t,this.M=o,this.v=r,{invalid_column:n,invalid_row:s}}D(e,t){if(e)if(this.i==="vertical"||this.i==="none"){let o=0;for(let r of this.e.indices)o+=r||0;this.n.style.width=o.toPrecision(10)+"px"}else{let o=this.te(t);if(o!==0){let r=this.a.width+o+2;this.n.style.width=r.toPrecision(10)+"px"}else this.n.style.width="1px"}}k(e){let{row_height:t=19}=this.e,o=this.t.column_headers_length*t,r;r=Math.min(Xr,e*t+o),this.n.style.height=`${r.toPrecision(10)}px`}O(e){let t=(this.e.row_height||20)*(e.start_row%1)||0,o=(this.e.indices[(this.table_model.d||0)+Math.floor(e.start_col)]||0)*(e.start_col%1)||0;this.u.style.setProperty(en,`${o}px`),this.u.style.setProperty(tn,`${t}px`),this.u.style.setProperty(on,`${-o}px`),this.u.style.setProperty(rn,`${-t}px`)}H(e){if(this.i==="none"||this.i==="vertical")return{start_col:0,end_col:1/0};{let t=this.ie(),o=this.table_model.num_columns()||Math.min(e,Math.ceil(this.a.width/60)),r=t+o+1;return{start_col:t,end_col:r}}}Z(e){let{height:t,containerHeight:o}=this.a,r=this.e.row_height||19,n=this.t.column_headers_length,s=Math.max(1,this.n.offsetHeight-o),i=Math.max(Math.ceil(this.scrollTop),0)/s,l=t/r-n,a=Math.max(0,(e||0)-l)*i,m=Math.max(0,Math.min(a+l,e));return{start_row:a,end_row:m}}ie(){let e=this.t.row_headers_length,t=0,o=0,r=0;for(;o<this.scrollLeft;){let n=this.e.indices[t+e];r=this.scrollLeft-o,t+=1,o+=n!==void 0?n:60}return t+=r/(this.e.indices[t+e-1]||60),Math.max(0,t-1)}se(e){let t=0;if(this.t.row_headers_length>0)for(let n of this.e.indices.slice(0,this.t.row_headers_length))t+=n||0;let o=this.t.row_headers_length,r=e;for(;t<this.a.width&&r>=0;)r--,t+=this.e.indices[r+o]||60;return Math.min(e-1,r+1)}te(e){let t=this.t.row_headers_length,o=this.se(e),r=t,n=0;for(;r<o+t;)n+=this.e.indices[r]||60,r++;if(r<this.e.indices.length){let s=0,i=this.t.row_headers_length;for(let l=0;l<i&&l<this.e.indices.length;l++)s+=this.e.indices[l]||0;n+=Math.max(0,(this.e.indices[r]||0)-(this.a.width-(s||0))||0)}return n}};async function $t(e){let t=It&&performance.now(),{invalid_viewport:o=!0,preserve_width:r=!1}=e,{num_columns:n,num_rows:s,num_row_headers:i,num_column_headers:l,row_height:a}=await this.t.view(0,0,0,0);this.e.row_height=a||this.e.row_height,i!==void 0&&(this.t.row_headers_length=i),l!==void 0&&(this.t.column_headers_length=l);let m=this.i==="none"||this.i==="horizontal",c=this.i==="none"||this.i==="vertical",d=s||0,p=n||0;this.a={width:c?1/0:this.s.clientWidth,height:m?1/0:this.s.clientHeight,containerHeight:m?1/0:this.clientHeight},this.k(d),r||this.D(o,p);let f=this.Q(d,p);this.table_model.updateColumnWidthStyles(f,this.t.row_headers_length);let{invalid_row:g,invalid_column:y}=this.ee(f),_=this.S||y;if(_||g||o){let b=[],E=!0;for await(let D of this.table_model.draw(this.a,this.t,this.K,r,f,p)){D!==void 0&&b.push(...D),E&&(this.O(f),E=!1),this.L=!0;let A=this.o;for(let k of A)await k({detail:this});if(this.L=!1,!this.E&&D!==void 0)break;this.E=!1}let M=this.e.row_height;this.table_model.autosize_cells(b,a),this.table_model.header.reset_header_cache(),M!==this.e.row_height&&this.k(d),r||this.D(_,p),this.S=!1}else this.O(f);It&&Kr(performance.now()-t)}var ln=!1,an=class extends sn{W;$;I;F;p;register_listeners(){this.addEventListener("mousedown",this.oe.bind(this)),this.addEventListener("scroll",this.R.bind(this),{passive:!0}),this.ne()}async R(e){e.stopPropagation(),await this.draw({invalid_viewport:!1}),this.dispatchEvent(new CustomEvent("regular-table-scroll"))}ne(){this.addEventListener("mousewheel",this.re.bind(this),{passive:!0}),ln&&(this.addEventListener("touchmove",this.le.bind(this)),this.addEventListener("touchstart",this.ae.bind(this),{passive:!0}))}re(e){if(!window.hasOwnProperty("safari"))return;let t=e,{clientWidth:o,clientHeight:r,scrollTop:n,scrollLeft:s}=this;t.preventDefault(),t.returnValue=!1;let i=Math.max(1,this.n.offsetHeight-r),l=Math.max(1,this.n.offsetWidth-o);this.scrollTop=Math.max(0,Math.min(i,n+t.deltaY)),this.scrollLeft=Math.max(0,Math.min(l,s+t.deltaX)),this.R(t)}le(e){e.stopPropagation(),e.preventDefault(),e.returnValue=!1;let{clientWidth:t,clientHeight:o}=this,r=Math.max(1,this.n.offsetHeight-o),n=Math.max(1,this.n.offsetWidth-t);this.scrollTop=Math.min(r,(this.W||0)+((this.I||0)-e.touches[0].pageY)),this.scrollLeft=Math.min(n,(this.$||0)+((this.F||0)-e.touches[0].pageX)),this.R(e)}ae(e){this.I=e.touches[0].pageY,this.F=e.touches[0].pageX,this.W=this.scrollTop,this.$=this.scrollLeft}async he(e){let t=e.target,o=t.classList.contains("rt-column-resize");for(;t.tagName!=="TD"&&t.tagName!=="TH";)if(t=t.parentElement,!this.contains(t))return;let r=_e.get(t);if(o){e.stopImmediatePropagation(),e.shiftKey?(this.e.override={},this.e.auto=[],this.e.indices=[]):(delete this.e.override[r.size_key],this.e.auto[r.size_key]=void 0,this.e.indices[r.size_key]=void 0),this.table_model.updateColumnWidthStyles({start_row:0,end_row:0,...this.H(0)},this.t.row_headers_length);for(let n of e.shiftKey?[this.table_model.header.cells[this.table_model.header.cells.length-1],...this.table_model.body.cells]:this.table_model.body.cells)for(let s of e.shiftKey?n:[n[r.B]])s&&s.classList.remove("rt-cell-clip");await this.draw()}}async de(e){if(e.button!==0)return;let t=e.target,o=t.classList.contains("rt-column-resize");for(;t.tagName!=="TD"&&t.tagName!=="TH";)if(t=t.parentElement,!this.contains(t))return;let r=_e.get(t);o&&(this.ce(e,t,r),e.stopImmediatePropagation())}async oe(e){let t=performance.now();this.p&&t-this.p<500?(this.p=t,await this.he(e)):(this.p=t,await this.de(e))}ce(e,t,o){let{virtual_x:r,size_key:n}=o,s=e.pageX,i=(r||0)+t.colSpan-1,l=this.table_model.header.get_column_header(i),a=this.e.indices[n||0]||0,m=d=>Gt(this,async()=>await this.ue(d,l,s,a,n||0,i)),c=()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",c);let d=this.e.override[n||0],p=this.e.indices[n||0]!==d;this.e.indices[n||0]=d,p&&this.draw()};document.addEventListener("mousemove",m),document.addEventListener("mouseup",c)}async ue(e,t,o,r,n,s){await new Promise(requestAnimationFrame);let i=e.pageX-o,l=Math.max(1,r+i);if(this.e.override[n]=l,i<0)await this.draw({preserve_width:!0,throttle:!1});else{this.table_model.updateColumnWidthStyles({start_row:0,end_row:0,...this.H(0)},this.t.row_headers_length);let a=(this.e.auto[n]||0)>l;t.classList.toggle("rt-cell-clip",a);for(let m of this.table_model.body.cells){let c=m[s];c&&c.classList.toggle("rt-cell-clip",a)}}}},cn=class{N;b;c;constructor(e){this.N=e,this.b=[],this.c=0}reset(){this.c=0}get(){this.b[this.c]||(this.b[this.c]=document.createElement(this.N));let e=this.b[this.c];return this.c+=1,e}},Ut=class{e;me;m;table;cells;rows;constructor(e,t,o){this.e=e,this.me=t,this.m=new cn("span"),this.table=o,this.cells=[],this.rows=[]}num_columns(){return this.w(Math.max(0,this.rows.length-1)).row_container.length}num_rows(){return this.cells.length}Te(e,t){_e.set(e,t)}f(e){if(!e)return{value:void 0};let t=_e.get(e);return t||(t={value:void 0},_e.set(e,t)),t}X(e,t){let{tr:o,row_container:r}=this.w(e),n=r[t];return n&&(o.removeChild(n),r.splice(t,1,void 0)),n}_(e,t){if(!(e<0||t<0))return this.cells[e]?.[t]}w(e){let t=this.rows[e];t||(t=this.rows[e]=document.createElement("tr"),this.table.appendChild(t));let o=this.cells[e];return o||(o=this.cells[e]=[]),{tr:t,row_container:o}}A(e="TD",t,o){let{tr:r,row_container:n}=this.w(t),s=n[o];if(!s)if(o<n.length){s=n[o]=document.createElement(e);let i=n.slice(o+1).find(l=>l);r.insertBefore(s,i||null)}else s=n[o]=document.createElement(e),r.appendChild(s);if(s.tagName!==e){let i=document.createElement(e);r.replaceChild(i,s),this.cells[t].splice(o,1,i),s=i}return s}G(e){for(let t=0;t<this.rows.length;t++){let o=this.rows[t],r=this.cells[t];r.length=(Array.isArray(e)?e[t]:e)||0;let n=this.cells[t].filter(i=>i!==void 0).length,s=[];for(let i=n;i<o.children.length;i++)s.push(o.children[i]);for(let i of s)i.remove()}}V(e){let t=[];for(let o=e;o<this.table.children.length;o++)t.push(this.table.children[o]);for(let o of t)o.remove();this.rows.length=e,this.cells.length=e}},dn=class extends Ut{r;l;constructor(e,t,o){super(e,t,o),this.r=[],this.l=[]}Y(e,t,o){let r=this.A("TH",t,e[t]||0);if(e[t]+=1,r.removeAttribute("colspan"),r.textContent="",o instanceof HTMLElement)r.appendChild(o);else{let s=this.m.get();s.textContent=String(o??""),r.appendChild(s)}let n=this.m.get();return n.className="rt-column-resize",r.appendChild(n),r}fe(e,t,o){let r=this.f(o);return r.column_header=e,r.value=t,r}_e(e,t,o,r){let n=this.f(o);if(n.column_header=e,n.value=t,n.size_key=Array.isArray(r)?r[0]:r,!Array.isArray(r)||r.length<=1){let s=this.e.override[n.size_key||0],i=this.e.auto[n.size_key||0]||0;s?o.classList.toggle("rt-cell-clip",i>s):o.classList.remove("rt-cell-clip")}return n}get_column_header(e){return this.A("TH",this.num_rows()-1,e)}draw(e,t,o,r,n,s,i,l,a){let m=t?.length;if(m===0)return;let c,d,p,f;l=typeof l>"u"?m-1:l;for(let g=0;g<m;g++){if(p=t[g]?t[g]:"",this.l[g]=this.l[g]||0,g<l)a&&this.r?.[g]?.[0]?.value===p?(c=this.r[g][1],this.r[g][2]+=1,o===1&&(this.r[g][0].row_header_x=Array.isArray(n)?n[0]:n),c.setAttribute("colspan",String(this.r[g][2]))):(c=this.Y(this.l,g,p),d=this.fe(t,p,c),this.r[g]=[d,c,1]);else{c=this.Y(this.l,g,p),d=this._e(e.length>0?e:t,p,c,n),typeof f>"u"&&(f={th:c,metadata:d});for(let[y]of this.r)y.size_key=d.size_key;c.removeAttribute("colspan")}this.w(g).tr.classList.toggle("rt-autosize",g===l),c.classList.toggle("rt-group-corner",r===void 0),d&&(d.x=typeof r>"u"?r:Math.floor(r),d.column_header_y=g,d.x0=Math.floor(s),d.virtual_x=i,o===1&&(d.row_header_x=Array.isArray(n)?n[0]:n))}return this.V(this.l.length),f=f||{th:c,metadata:d},f}clean(){this.G(this.l)}reset_header_cache(){this.l=[],this.r=[]}},mn=class extends Ut{U(e,t,o,r,{column_name:n},{ridx_offset:s},i){let l=this.A(e,t,r),a=this.f(l);a.y=t+Math.floor(s);let m=a.size_key=i||0;e==="TD"&&(a.column_header=n);let c=this.e.override[m];if(c){let d=(this.e.auto[m]||0)>c;l.classList.contains("rt-cell-clip")!==d&&l.classList.toggle("rt-cell-clip",d)}else l.classList.remove("rt-cell-clip");return a.value!==o&&(o instanceof HTMLElement?(l.textContent="",l.appendChild(o)):l.textContent=String(o??"")),a.value=o,{td:l,metadata:a}}draw(e,t,o,r=!1,n,s,i,l){let{cidx:a,column_data:m,row_headers:c,column_data_listener_metadata:d}=t,{row_height:p}=o,f,g=[],y=[],_=0,b=[],E=r?o.row_headers_length??1:1,M=Math.floor(o.ridx_offset),D=Math.ceil(o.y1),A=Math.ceil(o.x1),k=n===void 0?n:Math.floor(n),h=s===void 0?void 0:Math.floor(s),v=Math.floor((n??0)-(s??0));for(let S=0;S<E;S++){_=0;let x=a+S;for(let T of m){let P;if(r){let L=T,N=L[S],z=g[S]||1,J=this._(_-z,x),te=this.f(J),Pe=b[_]||1,be=this._(_,x-Pe),Wt=this.f(be);if(l&&be&&(Wt.value===N||N===void 0)&&!be.hasAttribute("rowspan")){let oe=b[_]=Pe+1;be.setAttribute("colspan",String(oe)),this.X(_,x)}else if(l&&J&&te.value===N&&!J.hasAttribute("colspan")){let oe=g[S]=z+1;J.setAttribute("rowspan",String(oe)),this.X(_,x)}else{P=this.U("TH",_,N,x,t,o,S);let oe=P.td,se=P.metadata;oe.style.display="",oe.removeAttribute("rowspan"),oe.removeAttribute("colspan"),se.row_header=L,se.row_header_x=S,se.y0=M,se.y1=D,se.virtual_x=S,h!==void 0&&(se.x0=h),g[S]=1,b[_]=1,y[S]=P}}else{P=this.U("TD",_,T,a,t,o,i??0);let L=P.metadata;d&&(L.user=d[_]),L.x=k,L.x1=A,L.row_header=c?.[_]||[],L.y0=M,L.y1=D,L.dx=v,L.dy=(L.y??0)-M,L.virtual_x=a,h!==void 0&&(L.x0=h),y[0]=P}if(_++,f=P?P.metadata:f,p=p||P?.td.offsetHeight,_*(p??0)>e)break}}return this.V(_),{tds:y,ridx:_,row_height:p}}clean({ridx:e,cidx:t}){this.V(e),this.G(t)}},pn=class{e;d=0;header;body;pe(e,t){let{start_row:o=0,start_col:r=0,end_col:n=0,end_row:s=0}=e,i=this.e.indices[(this.d||0)+Math.floor(e.start_col)]||0;return{viewport_width:0,selected_id:t,ridx_offset:o,sub_cell_offset:i,x0:r,x1:n,y1:s,row_height:this.e.row_height,row_headers_length:this.d}}be(e,t,o,r,n,s,i,l,a,m){let c=[`${t}`],d=[],p={column_name:c,cidx:0,column_data:e,row_headers:e,first_col:!0},f=Math.floor(i),g=this.body.draw(r,p,{...n,x0:0},!0,void 0,void 0,f,m),y=[];for(let b=0;b<t;b++){let E=this.header.draw(c,Array(o).fill(""),1,void 0,b,i,b,l,a);E&&y.push(E)}for(let b=0;b<y.length;b++){let{th:E}=y[b];n.viewport_width+=this.e.indices[b]||E.offsetWidth}n.row_height=n.row_height||g.row_height;let _=e[0].length;if(!s)for(let b=0;b<t;b++){let{td:E,metadata:M}=g.tds[b]||{},{th:D,metadata:A}=y[b]||{};(E||D)&&d.push([D||E,A||M])}return{cont_body:g,first_col:!1,B:_,last_cells:d}}we(e,t,o,r,n,s){let i=0,l=0;for(;this.e.indices.length>n+s+i+1&&l+t.viewport_width<o;)i++,l+=this.e.indices[n+s+i]||0;if(l+t.viewport_width<o){let a=Math.min(r,e.start_col+5);e.end_col=Math.max(1,Math.min(r,a))}else e.end_col=Math.max(1,Math.min(r,e.start_col+i))}ge(e,t,o,r,n,s,i,l,a,m){let c=t.column_headers?.[e]||[],d=t.data[e],p=t.metadata?.[e],f={column_name:c,cidx:o,column_data:d,column_data_listener_metadata:p,row_headers:t.row_headers,first_col:i},g=e+r,y=o+Math.floor(r),_=this.header.draw(c,c,void 0,g,y,r,o,l,a),b=this.body.draw(n,f,s,!1,g,r,y,m);return{cont_head:_,cont_body:b}}async ye(e,t,o,r,n,s,i,l,a){let m=Math.max(e.end_col,0);e.start_col=m,this.we(e,n,s,i,l,a);let c=await t(Math.floor(e.start_col),Math.floor(e.start_row),Math.ceil(e.end_col),Math.ceil(e.end_row)),d,p;if(typeof c.column_header_merge_depth<"u"&&(d=c.column_header_merge_depth),typeof c.merge_headers<"u"&&(p=c.merge_headers),c.data.length===0)return{column_header_merge_depth:d,merge_headers:p};e.end_col=e.start_col+c.data.length;for(let f=0;f<c.data.length;f++)o.data[r+f]=c.data[f],c.metadata&&o.metadata&&(o.metadata[r+f]=c.metadata[f]),o.column_headers&&c.column_headers?.[f]&&(o.column_headers[r+f]=c.column_headers[f]);return{column_header_merge_depth:d,merge_headers:p}}g(e,t){this.body.clean({ridx:e?.ridx||0,cidx:t}),this.header.clean(),this.body.m.reset(),this.header.m.reset()}},Ft=class extends pn{table;h;j;constructor(e,t,o){super(),this.e=t,this.clear(o);let[r]=o.children,[n,s]=r.children;this.table=r,this.header=new dn(t,e,n),this.body=new mn(t,e,s)}num_columns(){return this.header.num_columns()}clear(e){e.innerHTML='<table cellspacing="0"><thead></thead><tbody></tbody></table>'}autosize_cells(e,t){let o=[];for(let[r,n]of e){let s=r.getBoundingClientRect();o.push({cell:r,metadata:n,box:s})}for(let{metadata:r,box:n}of o)this.e.row_height=t??Math.max(10,Math.min(this.e.row_height??n.height,n.height)),r?.size_key!==void 0&&(this.e.indices[r.size_key]=n.width,n.width&&this.e.override[r.size_key]===void 0&&(this.e.auto[r.size_key]=n.width))}clearWidthStyles(){this.h?.replaceSync("")}updateColumnWidthStyles(e,t){let o=[],r;for(r=0;r<t;r++){let n=this.e.override[r],s=this.e.auto[r];if(n!==void 0){let i=r+1;o.push(`thead tr.rt-autosize th:nth-child(${i}),`,`tbody td.rt-cell-clip:nth-child(${i})`,`{min-width:${n}px;max-width:${n}px;}`)}else if(s!==void 0){let i=r+1;o.push(`thead tr.rt-autosize th:nth-child(${i}),`,`tbody td.rt-cell-clip:nth-child(${i})`,`{min-width:${s}px;max-width:none;}`)}}for(let n=r;n<r+(Math.ceil(e.end_col)-Math.floor(e.start_col));n++){let s=this.e.override[n+Math.floor(e.start_col)],i=this.e.auto[n+Math.floor(e.start_col)];if(s!==void 0){let l=n+1;o.push(`thead tr.rt-autosize th:nth-child(${l}),`,`tbody td.rt-cell-clip:nth-child(${l})`,`{min-width:${s}px;max-width:${s}px;}`)}else if(i!==void 0){let l=n+1;o.push(`thead tr.rt-autosize th:nth-child(${l}),`,`tbody td.rt-cell-clip:nth-child(${l})`,`{min-width:${i}px;max-width:none;}`)}}o.length>0?this.Me(o.join(`
|
|
2
|
-
`)):this.h&&this.h.replaceSync("")}Me(e){if(e===this.j)return;let t=this.table.getRootNode();!t||!t.adoptedStyleSheets||(this.h||(this.h=new CSSStyleSheet,t.adoptedStyleSheets=[...t.adoptedStyleSheets,this.h]),this.h.replaceSync(e),this.j=e)}async*draw(e,t,o,r,n,s){let{width:i,height:l}=e,a=await t.view(Math.floor(n.start_col),Math.floor(n.start_row),Math.ceil(n.end_col),Math.ceil(n.end_row)),{column_header_merge_depth:m,merge_headers:c="both"}=a,d=c==="both"||c==="row",p=c==="both"||c==="column",f=n.start_col??0;if(a.row_headers){let k=0;for(let h of a.row_headers)h.length>k&&(k=h.length);this.d=k;for(let h=0;h<a.row_headers.length;h++)a.row_headers[h].length=this.d||0}t.row_headers_length=a.num_row_headers??a.row_headers?.[0]?.length??0,t.column_headers_length=a.num_column_headers??a.column_headers?.[0]?.length??0;let{view:g,row_headers_length:y,column_headers_length:_}=t,b=this.pe(n,o),E,M=0,D=[],A=!0;if(a.row_headers?.length){let k=this.be(a.row_headers,y,_,l,b,r,f,m,p,d);E=k.cont_body,A=k.first_col,M=k.B,D=k.last_cells}try{let k=0,h=s-n.start_col;for(;k<h;){if(!a.data[k]){yield void 0;let T=await this.ye(n,g,a,k,b,i,s,M,f);if(T.column_header_merge_depth!==void 0&&(m=T.column_header_merge_depth),T.merge_headers!==void 0&&(c=T.merge_headers),!a.data[k]){this.g(E,M),yield D;return}}let{cont_head:v,cont_body:S}=this.ge(k,a,M,f,l,b,A,m,p,d);if(E=S,A=!1,!r)for(let{td:T,metadata:P}of E.tds)D.push([v?.th||T,v?.metadata||P]);let x=this.e.indices[M+Math.floor(f)]||v?.th?.offsetWidth;if(!x){x=0;for(let{td:T}of E.tds)x+=T?.offsetWidth||0}if(b.viewport_width+=x,b.row_height=b.row_height||E.row_height,M++,k++,this.q(b,i)){this.g(E,M),yield D,b.viewport_width=0;for(let[T]of D)b.viewport_width+=T.offsetWidth;if(this.q(b,i))return}}this.g(E,M),yield D}finally{this.g(E,M)}}q(e,t){return e.viewport_width-e.sub_cell_offset>t}},fn=["both","horizontal","vertical","none"],un=class extends an{z;constructor(){super(),this.e={auto:[],override:{},indices:[]},this.o=[],this.z=!1}connectedCallback(){this.z||(this.J(),this.register_listeners(),this.setAttribute("tabindex","0"),this.z=!0,this.table_model=new Ft(this.s,this.e,this))}ve(){this.M=void 0,this.v=void 0,this.T=void 0,this.C=void 0}Ce(){this.e.indices=[],this.scrollTop=0,this.scrollLeft=0,this.ve()}resetAutoSize(){this.e.auto=[],this.e.override={},this.e.indices=[]}saveColumnSizes(){return structuredClone(this.e.override)}restoreColumnSizes(e){this.e.override=structuredClone(e)}clear(){this.table_model=new Ft(this.s,this.e,this)}addStyleListener(e){this.o.push(e);let t=!0;return()=>{if(!t)return;t=!1,this.o=this.o.slice();let o=this.o.indexOf(e);this.o.splice(o,1)}}removeStyleListener(e){let t=this.o.length;this.o=this.o.filter(o=>o!==e),console.assert(this.o.length===t-1,"No listener found")}invalidate(){if(!this.L)throw new Error("Cannot call `invalidate()` outside of a `StyleListener`");this.E=!0}getMeta(e){if(!(typeof e>"u")){if(e instanceof HTMLElement)return _e.get(e);if(e.row_header_x>=0){if(e.row_header_x<this.t.row_headers_length){let t=this.table_model.body._(e.y,e.row_header_x);return this.getMeta(t)}}else if(e.column_header_y>=0){if(e.column_header_y<this.t.column_headers_length){let t=this.table_model.body._(e.column_header_y,e.y);return this.getMeta(t)}}else return this.getMeta(this.table_model.body._(e.dy,e.dx+(this.table_model.d||0)))}}getDrawFPS(){return qr()}async scrollToCell(e,t){if(!this.t){console.warn("data listener not configured");return}let o=this.e.row_height||19;this.scrollTop=Math.ceil(o*t);let r=0;for(;e>0;)e--,r+=this.e.indices[e+this.t.row_headers_length]||60;this.scrollLeft=Math.ceil(r),await new Promise(requestAnimationFrame),await this.flush()}setDataListener(e,{virtual_mode:t="both",preserve_state:o=!1}={}){console.assert(fn.indexOf(t)>-1,`Unknown virtual_mode ${t}; valid options are "both" (default), "horizontal", "vertical" or "none"`);let r=this.i!==t;o?(console.assert(!r,"preserve_state called with modified virtual_mode"),this.t.view=e):(this.i=t,this.S=!0,this.t={view:e,row_headers_length:0,column_headers_length:0},r&&this.P())}};document.createElement("regular-table").constructor===HTMLElement&&window.customElements.define("regular-table",un);var $=Symbol("Perspective Column Config");var{min:hn,max:gn}=Math,G=(e,t=0,o=1)=>hn(gn(t,e),o);var ue=e=>{e._clipped=!1,e._unclipped=e.slice(0);for(let t=0;t<=3;t++)t<3?((e[t]<0||e[t]>255)&&(e._clipped=!0),e[t]=G(e[t],0,255)):t===3&&(e[t]=G(e[t],0,1));return e};var Bt={};for(let e of["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"])Bt[`[object ${e}]`]=e.toLowerCase();function C(e){return Bt[Object.prototype.toString.call(e)]||"object"}var w=(e,t=null)=>e.length>=3?Array.prototype.slice.call(e):C(e[0])=="object"&&t?t.split("").filter(o=>e[0][o]!==void 0).map(o=>e[0][o]):e[0].slice(0);var F=e=>{if(e.length<2)return null;let t=e.length-1;return C(e[t])=="string"?e[t].toLowerCase():null};var{PI:Ue,min:Be,max:Ye}=Math,I=e=>Math.round(e*100)/100,De=e=>Math.round(e*100)/100,U=Ue*2,Xe=Ue/3,Yt=Ue/180,Xt=180/Ue;function qe(e){return[...e.slice(0,3).reverse(),...e.slice(3)]}var R={format:{},autodetect:[]};var bt=class{constructor(...t){let o=this;if(C(t[0])==="object"&&t[0].constructor&&t[0].constructor===this.constructor)return t[0];let r=F(t),n=!1;if(!r){n=!0,R.sorted||(R.autodetect=R.autodetect.sort((s,i)=>i.p-s.p),R.sorted=!0);for(let s of R.autodetect)if(r=s.test(...t),r)break}if(R.format[r]){let s=R.format[r].apply(null,n?t:t.slice(0,-1));o._rgb=ue(s)}else throw new Error("unknown format: "+t);o._rgb.length===3&&o._rgb.push(1)}toString(){return C(this.hex)=="function"?this.hex():`[${this._rgb.join(",")}]`}},u=bt;var qt="3.1.2";var Kt=(...e)=>new u(...e);Kt.version=qt;var O=Kt;var bn={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},le=bn;var _n=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,yn=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,wn=e=>{if(e.match(_n)){(e.length===4||e.length===7)&&(e=e.substr(1)),e.length===3&&(e=e.split(""),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]);let t=parseInt(e,16),o=t>>16,r=t>>8&255,n=t&255;return[o,r,n,1]}if(e.match(yn)){(e.length===5||e.length===9)&&(e=e.substr(1)),e.length===4&&(e=e.split(""),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]);let t=parseInt(e,16),o=t>>24&255,r=t>>16&255,n=t>>8&255,s=Math.round((t&255)/255*100)/100;return[o,r,n,s]}throw new Error(`unknown hex color: ${e}`)},Ke=wn;var{round:Ze}=Math,vn=(...e)=>{let[t,o,r,n]=w(e,"rgba"),s=F(e)||"auto";n===void 0&&(n=1),s==="auto"&&(s=n<1?"rgba":"rgb"),t=Ze(t),o=Ze(o),r=Ze(r);let l="000000"+(t<<16|o<<8|r).toString(16);l=l.substr(l.length-6);let a="0"+Ze(n*255).toString(16);switch(a=a.substr(a.length-2),s.toLowerCase()){case"rgba":return`#${l}${a}`;case"argb":return`#${a}${l}`;default:return`#${l}`}},Je=vn;u.prototype.name=function(){let e=Je(this._rgb,"rgb");for(let t of Object.keys(le))if(le[t]===e)return t.toLowerCase();return e};R.format.named=e=>{if(e=e.toLowerCase(),le[e])return Ke(le[e]);throw new Error("unknown color name: "+e)};R.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&C(e)==="string"&&le[e.toLowerCase()])return"named"}});u.prototype.alpha=function(e,t=!1){return e!==void 0&&C(e)==="number"?t?(this._rgb[3]=e,this):new u([this._rgb[0],this._rgb[1],this._rgb[2],e],"rgb"):this._rgb[3]};u.prototype.clipped=function(){return this._rgb._clipped||!1};var Oe={Kn:18,labWhitePoint:"d65",Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,kE:.008856451679035631,kKE:8,kK:903.2962962962963,RefWhiteRGB:{X:.95047,Y:1,Z:1.08883},MtxRGB2XYZ:{m00:.4124564390896922,m01:.21267285140562253,m02:.0193338955823293,m10:.357576077643909,m11:.715152155287818,m12:.11919202588130297,m20:.18043748326639894,m21:.07217499330655958,m22:.9503040785363679},MtxXYZ2RGB:{m00:3.2404541621141045,m01:-.9692660305051868,m02:.055643430959114726,m10:-1.5371385127977166,m11:1.8760108454466942,m12:-.2040259135167538,m20:-.498531409556016,m21:.041556017530349834,m22:1.0572251882231791},As:.9414285350000001,Bs:1.040417467,Cs:1.089532651,MtxAdaptMa:{m00:.8951,m01:-.7502,m02:.0389,m10:.2664,m11:1.7135,m12:-.0685,m20:-.1614,m21:.0367,m22:1.0296},MtxAdaptMaI:{m00:.9869929054667123,m01:.43230526972339456,m02:-.008528664575177328,m10:-.14705425642099013,m11:.5183602715367776,m12:.04004282165408487,m20:.15996265166373125,m21:.0492912282128556,m22:.9684866957875502}},Q=Oe,xn=new Map([["a",[1.0985,.35585]],["b",[1.0985,.35585]],["c",[.98074,1.18232]],["d50",[.96422,.82521]],["d55",[.95682,.92149]],["d65",[.95047,1.08883]],["e",[1,1,1]],["f2",[.99186,.67393]],["f7",[.95041,1.08747]],["f11",[1.00962,.6435]],["icc",[.96422,.82521]]]);function B(e){let t=xn.get(String(e).toLowerCase());if(!t)throw new Error("unknown Lab illuminant "+e);Oe.labWhitePoint=e,Oe.Xn=t[0],Oe.Zn=t[1]}function ae(){return Oe.labWhitePoint}var En=(...e)=>{e=w(e,"lab");let[t,o,r]=e,[n,s,i]=kn(t,o,r),[l,a,m]=yt(n,s,i);return[l,a,m,e.length>3?e[3]:1]},kn=(e,t,o)=>{let{kE:r,kK:n,kKE:s,Xn:i,Yn:l,Zn:a}=Q,m=(e+16)/116,c=.002*t+m,d=m-.005*o,p=c*c*c,f=d*d*d,g=p>r?p:(116*c-16)/n,y=e>s?Math.pow((e+16)/116,3):e/n,_=f>r?f:(116*d-16)/n,b=g*i,E=y*l,M=_*a;return[b,E,M]},_t=e=>{let t=Math.sign(e);return e=Math.abs(e),(e<=.0031308?e*12.92:1.055*Math.pow(e,1/2.4)-.055)*t},yt=(e,t,o)=>{let{MtxAdaptMa:r,MtxAdaptMaI:n,MtxXYZ2RGB:s,RefWhiteRGB:i,Xn:l,Yn:a,Zn:m}=Q,c=l*r.m00+a*r.m10+m*r.m20,d=l*r.m01+a*r.m11+m*r.m21,p=l*r.m02+a*r.m12+m*r.m22,f=i.X*r.m00+i.Y*r.m10+i.Z*r.m20,g=i.X*r.m01+i.Y*r.m11+i.Z*r.m21,y=i.X*r.m02+i.Y*r.m12+i.Z*r.m22,_=(e*r.m00+t*r.m10+o*r.m20)*(f/c),b=(e*r.m01+t*r.m11+o*r.m21)*(g/d),E=(e*r.m02+t*r.m12+o*r.m22)*(y/p),M=_*n.m00+b*n.m10+E*n.m20,D=_*n.m01+b*n.m11+E*n.m21,A=_*n.m02+b*n.m12+E*n.m22,k=_t(M*s.m00+D*s.m10+A*s.m20),h=_t(M*s.m01+D*s.m11+A*s.m21),v=_t(M*s.m02+D*s.m12+A*s.m22);return[k*255,h*255,v*255]},we=En;var Cn=(...e)=>{let[t,o,r,...n]=w(e,"rgb"),[s,i,l]=vt(t,o,r),[a,m,c]=Mn(s,i,l);return[a,m,c,...n.length>0&&n[0]<1?[n[0]]:[]]};function Mn(e,t,o){let{Xn:r,Yn:n,Zn:s,kE:i,kK:l}=Q,a=e/r,m=t/n,c=o/s,d=a>i?Math.pow(a,1/3):(l*a+16)/116,p=m>i?Math.pow(m,1/3):(l*m+16)/116,f=c>i?Math.pow(c,1/3):(l*c+16)/116;return[116*p-16,500*(d-p),200*(p-f)]}function wt(e){let t=Math.sign(e);return e=Math.abs(e),(e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4))*t}var vt=(e,t,o)=>{e=wt(e/255),t=wt(t/255),o=wt(o/255);let{MtxRGB2XYZ:r,MtxAdaptMa:n,MtxAdaptMaI:s,Xn:i,Yn:l,Zn:a,As:m,Bs:c,Cs:d}=Q,p=e*r.m00+t*r.m10+o*r.m20,f=e*r.m01+t*r.m11+o*r.m21,g=e*r.m02+t*r.m12+o*r.m22,y=i*n.m00+l*n.m10+a*n.m20,_=i*n.m01+l*n.m11+a*n.m21,b=i*n.m02+l*n.m12+a*n.m22,E=p*n.m00+f*n.m10+g*n.m20,M=p*n.m01+f*n.m11+g*n.m21,D=p*n.m02+f*n.m12+g*n.m22;return E*=y/m,M*=_/c,D*=b/d,p=E*s.m00+M*s.m10+D*s.m20,f=E*s.m01+M*s.m11+D*s.m21,g=E*s.m02+M*s.m12+D*s.m22,[p,f,g]},ve=Cn;u.prototype.lab=function(){return ve(this._rgb)};var Sn=(...e)=>new u(...e,"lab");Object.assign(O,{lab:Sn,getLabWhitePoint:ae,setLabWhitePoint:B});R.format.lab=we;R.autodetect.push({p:2,test:(...e)=>{if(e=w(e,"lab"),C(e)==="array"&&e.length===3)return"lab"}});u.prototype.darken=function(e=1){let t=this,o=t.lab();return o[0]-=Q.Kn*e,new u(o,"lab").alpha(t.alpha(),!0)};u.prototype.brighten=function(e=1){return this.darken(-e)};u.prototype.darker=u.prototype.darken;u.prototype.brighter=u.prototype.brighten;u.prototype.get=function(e){let[t,o]=e.split("."),r=this[t]();if(o){let n=t.indexOf(o)-(t.substr(0,2)==="ok"?2:0);if(n>-1)return r[n];throw new Error(`unknown channel ${o} in mode ${t}`)}else return r};var{pow:Ln}=Math,Rn=1e-7,Tn=20;u.prototype.luminance=function(e,t="rgb"){if(e!==void 0&&C(e)==="number"){if(e===0)return new u([0,0,0,this._rgb[3]],"rgb");if(e===1)return new u([255,255,255,this._rgb[3]],"rgb");let o=this.luminance(),r=Tn,n=(i,l)=>{let a=i.interpolate(l,.5,t),m=a.luminance();return Math.abs(e-m)<Rn||!r--?a:m>e?n(i,a):n(a,l)},s=(o>e?n(new u([0,0,0]),this):n(this,new u([255,255,255]))).rgb();return new u([...s,this._rgb[3]])}return Pn(...this._rgb.slice(0,3))};var Pn=(e,t,o)=>(e=xt(e),t=xt(t),o=xt(o),.2126*e+.7152*t+.0722*o),xt=e=>(e/=255,e<=.03928?e/12.92:Ln((e+.055)/1.055,2.4));var H={};var ee=(e,t,o=.5,...r)=>{let n=r[0]||"lrgb";if(!H[n]&&!r.length&&(n=Object.keys(H)[0]),!H[n])throw new Error(`interpolation mode ${n} is not defined`);return C(e)!=="object"&&(e=new u(e)),C(t)!=="object"&&(t=new u(t)),H[n](e,t,o).alpha(e.alpha()+o*(t.alpha()-e.alpha()))};u.prototype.mix=u.prototype.interpolate=function(e,t=.5,...o){return ee(this,e,t,...o)};u.prototype.premultiply=function(e=!1){let t=this._rgb,o=t[3];return e?(this._rgb=[t[0]*o,t[1]*o,t[2]*o,o],this):new u([t[0]*o,t[1]*o,t[2]*o,o],"rgb")};var{sin:Dn,cos:On}=Math,An=(...e)=>{let[t,o,r]=w(e,"lch");return isNaN(r)&&(r=0),r=r*Yt,[t,On(r)*o,Dn(r)*o]},Qe=An;var Nn=(...e)=>{e=w(e,"lch");let[t,o,r]=e,[n,s,i]=Qe(t,o,r),[l,a,m]=we(n,s,i);return[l,a,m,e.length>3?e[3]:1]},xe=Nn;var Hn=(...e)=>{let t=qe(w(e,"hcl"));return xe(...t)},Zt=Hn;var{sqrt:zn,atan2:Vn,round:Wn}=Math,In=(...e)=>{let[t,o,r]=w(e,"lab"),n=zn(o*o+r*r),s=(Vn(r,o)*Xt+360)%360;return Wn(n*1e4)===0&&(s=Number.NaN),[t,n,s]},et=In;var jn=(...e)=>{let[t,o,r,...n]=w(e,"rgb"),[s,i,l]=ve(t,o,r),[a,m,c]=et(s,i,l);return[a,m,c,...n.length>0&&n[0]<1?[n[0]]:[]]},Ae=jn;u.prototype.lch=function(){return Ae(this._rgb)};u.prototype.hcl=function(){return qe(Ae(this._rgb))};var $n=(...e)=>new u(...e,"lch"),Fn=(...e)=>new u(...e,"hcl");Object.assign(O,{lch:$n,hcl:Fn});R.format.lch=xe;R.format.hcl=Zt;["lch","hcl"].forEach(e=>R.autodetect.push({p:2,test:(...t)=>{if(t=w(t,e),C(t)==="array"&&t.length===3)return e}}));u.prototype.saturate=function(e=1){let t=this,o=t.lch();return o[1]+=Q.Kn*e,o[1]<0&&(o[1]=0),new u(o,"lch").alpha(t.alpha(),!0)};u.prototype.desaturate=function(e=1){return this.saturate(-e)};u.prototype.set=function(e,t,o=!1){let[r,n]=e.split("."),s=this[r]();if(n){let i=r.indexOf(n)-(r.substr(0,2)==="ok"?2:0);if(i>-1){if(C(t)=="string")switch(t.charAt(0)){case"+":s[i]+=+t;break;case"-":s[i]+=+t;break;case"*":s[i]*=+t.substr(1);break;case"/":s[i]/=+t.substr(1);break;default:s[i]=+t}else if(C(t)==="number")s[i]=t;else throw new Error("unsupported value for Color.set");let l=new u(s,r);return o?(this._rgb=l._rgb,this):l}throw new Error(`unknown channel ${n} in mode ${r}`)}else return s};u.prototype.tint=function(e=.5,...t){return ee(this,"white",e,...t)};u.prototype.shade=function(e=.5,...t){return ee(this,"black",e,...t)};var Gn=(e,t,o)=>{let r=e._rgb,n=t._rgb;return new u(r[0]+o*(n[0]-r[0]),r[1]+o*(n[1]-r[1]),r[2]+o*(n[2]-r[2]),"rgb")};H.rgb=Gn;var{sqrt:Et,pow:Ee}=Math,Un=(e,t,o)=>{let[r,n,s]=e._rgb,[i,l,a]=t._rgb;return new u(Et(Ee(r,2)*(1-o)+Ee(i,2)*o),Et(Ee(n,2)*(1-o)+Ee(l,2)*o),Et(Ee(s,2)*(1-o)+Ee(a,2)*o),"rgb")};H.lrgb=Un;var Bn=(e,t,o)=>{let r=e.lab(),n=t.lab();return new u(r[0]+o*(n[0]-r[0]),r[1]+o*(n[1]-r[1]),r[2]+o*(n[2]-r[2]),"lab")};H.lab=Bn;var Y=(e,t,o,r)=>{let n,s;r==="hsl"?(n=e.hsl(),s=t.hsl()):r==="hsv"?(n=e.hsv(),s=t.hsv()):r==="hcg"?(n=e.hcg(),s=t.hcg()):r==="hsi"?(n=e.hsi(),s=t.hsi()):r==="lch"||r==="hcl"?(r="hcl",n=e.hcl(),s=t.hcl()):r==="oklch"&&(n=e.oklch().reverse(),s=t.oklch().reverse());let i,l,a,m,c,d;(r.substr(0,1)==="h"||r==="oklch")&&([i,a,c]=n,[l,m,d]=s);let p,f,g,y;return!isNaN(i)&&!isNaN(l)?(l>i&&l-i>180?y=l-(i+360):l<i&&i-l>180?y=l+360-i:y=l-i,f=i+o*y):isNaN(i)?isNaN(l)?f=Number.NaN:(f=l,(c==1||c==0)&&r!="hsv"&&(p=m)):(f=i,(d==1||d==0)&&r!="hsv"&&(p=a)),p===void 0&&(p=a+o*(m-a)),g=c+o*(d-c),r==="oklch"?new u([g,p,f],r):new u([f,p,g],r)};var Jt=(e,t,o)=>Y(e,t,o,"lch");H.lch=Jt;H.hcl=Jt;var Yn=e=>{if(C(e)=="number"&&e>=0&&e<=16777215){let t=e>>16,o=e>>8&255,r=e&255;return[t,o,r,1]}throw new Error("unknown num color: "+e)},Qt=Yn;var Xn=(...e)=>{let[t,o,r]=w(e,"rgb");return(t<<16)+(o<<8)+r},eo=Xn;u.prototype.num=function(){return eo(this._rgb)};var qn=(...e)=>new u(...e,"num");Object.assign(O,{num:qn});R.format.num=Qt;R.autodetect.push({p:5,test:(...e)=>{if(e.length===1&&C(e[0])==="number"&&e[0]>=0&&e[0]<=16777215)return"num"}});var Kn=(e,t,o)=>{let r=e.num(),n=t.num();return new u(r+o*(n-r),"num")};H.num=Kn;var{floor:Zn}=Math,Jn=(...e)=>{e=w(e,"hcg");let[t,o,r]=e,n,s,i;r=r*255;let l=o*255;if(o===0)n=s=i=r;else{t===360&&(t=0),t>360&&(t-=360),t<0&&(t+=360),t/=60;let a=Zn(t),m=t-a,c=r*(1-o),d=c+l*(1-m),p=c+l*m,f=c+l;switch(a){case 0:[n,s,i]=[f,p,c];break;case 1:[n,s,i]=[d,f,c];break;case 2:[n,s,i]=[c,f,p];break;case 3:[n,s,i]=[c,d,f];break;case 4:[n,s,i]=[p,c,f];break;case 5:[n,s,i]=[f,c,d];break}}return[n,s,i,e.length>3?e[3]:1]},to=Jn;var Qn=(...e)=>{let[t,o,r]=w(e,"rgb"),n=Be(t,o,r),s=Ye(t,o,r),i=s-n,l=i*100/255,a=n/(255-i)*100,m;return i===0?m=Number.NaN:(t===s&&(m=(o-r)/i),o===s&&(m=2+(r-t)/i),r===s&&(m=4+(t-o)/i),m*=60,m<0&&(m+=360)),[m,l,a]},oo=Qn;u.prototype.hcg=function(){return oo(this._rgb)};var es=(...e)=>new u(...e,"hcg");O.hcg=es;R.format.hcg=to;R.autodetect.push({p:1,test:(...e)=>{if(e=w(e,"hcg"),C(e)==="array"&&e.length===3)return"hcg"}});var ts=(e,t,o)=>Y(e,t,o,"hcg");H.hcg=ts;var{cos:ke}=Math,os=(...e)=>{e=w(e,"hsi");let[t,o,r]=e,n,s,i;return isNaN(t)&&(t=0),isNaN(o)&&(o=0),t>360&&(t-=360),t<0&&(t+=360),t/=360,t<1/3?(i=(1-o)/3,n=(1+o*ke(U*t)/ke(Xe-U*t))/3,s=1-(i+n)):t<2/3?(t-=1/3,n=(1-o)/3,s=(1+o*ke(U*t)/ke(Xe-U*t))/3,i=1-(n+s)):(t-=2/3,s=(1-o)/3,i=(1+o*ke(U*t)/ke(Xe-U*t))/3,n=1-(s+i)),n=G(r*n*3),s=G(r*s*3),i=G(r*i*3),[n*255,s*255,i*255,e.length>3?e[3]:1]},ro=os;var{min:rs,sqrt:ns,acos:ss}=Math,is=(...e)=>{let[t,o,r]=w(e,"rgb");t/=255,o/=255,r/=255;let n,s=rs(t,o,r),i=(t+o+r)/3,l=i>0?1-s/i:0;return l===0?n=NaN:(n=(t-o+(t-r))/2,n/=ns((t-o)*(t-o)+(t-r)*(o-r)),n=ss(n),r>o&&(n=U-n),n/=U),[n*360,l,i]},no=is;u.prototype.hsi=function(){return no(this._rgb)};var ls=(...e)=>new u(...e,"hsi");O.hsi=ls;R.format.hsi=ro;R.autodetect.push({p:2,test:(...e)=>{if(e=w(e,"hsi"),C(e)==="array"&&e.length===3)return"hsi"}});var as=(e,t,o)=>Y(e,t,o,"hsi");H.hsi=as;var cs=(...e)=>{e=w(e,"hsl");let[t,o,r]=e,n,s,i;if(o===0)n=s=i=r*255;else{let l=[0,0,0],a=[0,0,0],m=r<.5?r*(1+o):r+o-r*o,c=2*r-m,d=t/360;l[0]=d+1/3,l[1]=d,l[2]=d-1/3;for(let p=0;p<3;p++)l[p]<0&&(l[p]+=1),l[p]>1&&(l[p]-=1),6*l[p]<1?a[p]=c+(m-c)*6*l[p]:2*l[p]<1?a[p]=m:3*l[p]<2?a[p]=c+(m-c)*(2/3-l[p])*6:a[p]=c;[n,s,i]=[a[0]*255,a[1]*255,a[2]*255]}return e.length>3?[n,s,i,e[3]]:[n,s,i,1]},Ne=cs;var ds=(...e)=>{e=w(e,"rgba");let[t,o,r]=e;t/=255,o/=255,r/=255;let n=Be(t,o,r),s=Ye(t,o,r),i=(s+n)/2,l,a;return s===n?(l=0,a=Number.NaN):l=i<.5?(s-n)/(s+n):(s-n)/(2-s-n),t==s?a=(o-r)/(s-n):o==s?a=2+(r-t)/(s-n):r==s&&(a=4+(t-o)/(s-n)),a*=60,a<0&&(a+=360),e.length>3&&e[3]!==void 0?[a,l,i,e[3]]:[a,l,i]},tt=ds;u.prototype.hsl=function(){return tt(this._rgb)};var ms=(...e)=>new u(...e,"hsl");O.hsl=ms;R.format.hsl=Ne;R.autodetect.push({p:2,test:(...e)=>{if(e=w(e,"hsl"),C(e)==="array"&&e.length===3)return"hsl"}});var ps=(e,t,o)=>Y(e,t,o,"hsl");H.hsl=ps;var{floor:fs}=Math,us=(...e)=>{e=w(e,"hsv");let[t,o,r]=e,n,s,i;if(r*=255,o===0)n=s=i=r;else{t===360&&(t=0),t>360&&(t-=360),t<0&&(t+=360),t/=60;let l=fs(t),a=t-l,m=r*(1-o),c=r*(1-o*a),d=r*(1-o*(1-a));switch(l){case 0:[n,s,i]=[r,d,m];break;case 1:[n,s,i]=[c,r,m];break;case 2:[n,s,i]=[m,r,d];break;case 3:[n,s,i]=[m,c,r];break;case 4:[n,s,i]=[d,m,r];break;case 5:[n,s,i]=[r,m,c];break}}return[n,s,i,e.length>3?e[3]:1]},so=us;var{min:hs,max:gs}=Math,bs=(...e)=>{e=w(e,"rgb");let[t,o,r]=e,n=hs(t,o,r),s=gs(t,o,r),i=s-n,l,a,m;return m=s/255,s===0?(l=Number.NaN,a=0):(a=i/s,t===s&&(l=(o-r)/i),o===s&&(l=2+(r-t)/i),r===s&&(l=4+(t-o)/i),l*=60,l<0&&(l+=360)),[l,a,m]},io=bs;u.prototype.hsv=function(){return io(this._rgb)};var _s=(...e)=>new u(...e,"hsv");O.hsv=_s;R.format.hsv=so;R.autodetect.push({p:2,test:(...e)=>{if(e=w(e,"hsv"),C(e)==="array"&&e.length===3)return"hsv"}});var ys=(e,t,o)=>Y(e,t,o,"hsv");H.hsv=ys;function he(e,t){let o=e.length;Array.isArray(e[0])||(e=[e]),Array.isArray(t[0])||(t=t.map(i=>[i]));let r=t[0].length,n=t[0].map((i,l)=>t.map(a=>a[l])),s=e.map(i=>n.map(l=>Array.isArray(i)?i.reduce((a,m,c)=>a+m*(l[c]||0),0):l.reduce((a,m)=>a+m*i,0)));return o===1&&(s=s[0]),r===1?s.map(i=>i[0]):s}var ws=(...e)=>{e=w(e,"lab");let[t,o,r,...n]=e,[s,i,l]=vs([t,o,r]),[a,m,c]=yt(s,i,l);return[a,m,c,...n.length>0&&n[0]<1?[n[0]]:[]]};function vs(e){var t=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],o=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],r=he(o,e);return he(t,r.map(n=>n**3))}var Ce=ws;var xs=(...e)=>{let[t,o,r,...n]=w(e,"rgb"),s=vt(t,o,r);return[...Es(s),...n.length>0&&n[0]<1?[n[0]]:[]]};function Es(e){let t=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],o=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],r=he(t,e);return he(o,r.map(n=>Math.cbrt(n)))}var Me=xs;u.prototype.oklab=function(){return Me(this._rgb)};var ks=(...e)=>new u(...e,"oklab");Object.assign(O,{oklab:ks});R.format.oklab=Ce;R.autodetect.push({p:2,test:(...e)=>{if(e=w(e,"oklab"),C(e)==="array"&&e.length===3)return"oklab"}});var Cs=(e,t,o)=>{let r=e.oklab(),n=t.oklab();return new u(r[0]+o*(n[0]-r[0]),r[1]+o*(n[1]-r[1]),r[2]+o*(n[2]-r[2]),"oklab")};H.oklab=Cs;var Ms=(e,t,o)=>Y(e,t,o,"oklch");H.oklch=Ms;var{pow:kt,sqrt:Ct,PI:Mt,cos:lo,sin:ao,atan2:Ss}=Math,co=(e,t="lrgb",o=null)=>{let r=e.length;o||(o=Array.from(new Array(r)).map(()=>1));let n=r/o.reduce(function(d,p){return d+p});if(o.forEach((d,p)=>{o[p]*=n}),e=e.map(d=>new u(d)),t==="lrgb")return Ls(e,o);let s=e.shift(),i=s.get(t),l=[],a=0,m=0;for(let d=0;d<i.length;d++)if(i[d]=(i[d]||0)*o[0],l.push(isNaN(i[d])?0:o[0]),t.charAt(d)==="h"&&!isNaN(i[d])){let p=i[d]/180*Mt;a+=lo(p)*o[0],m+=ao(p)*o[0]}let c=s.alpha()*o[0];e.forEach((d,p)=>{let f=d.get(t);c+=d.alpha()*o[p+1];for(let g=0;g<i.length;g++)if(!isNaN(f[g]))if(l[g]+=o[p+1],t.charAt(g)==="h"){let y=f[g]/180*Mt;a+=lo(y)*o[p+1],m+=ao(y)*o[p+1]}else i[g]+=f[g]*o[p+1]});for(let d=0;d<i.length;d++)if(t.charAt(d)==="h"){let p=Ss(m/l[d],a/l[d])/Mt*180;for(;p<0;)p+=360;for(;p>=360;)p-=360;i[d]=p}else i[d]=i[d]/l[d];return c/=r,new u(i,t).alpha(c>.99999?1:c,!0)},Ls=(e,t)=>{let o=e.length,r=[0,0,0,0];for(let n=0;n<e.length;n++){let s=e[n],i=t[n]/o,l=s._rgb;r[0]+=kt(l[0],2)*i,r[1]+=kt(l[1],2)*i,r[2]+=kt(l[2],2)*i,r[3]+=l[3]*i}return r[0]=Ct(r[0]),r[1]=Ct(r[1]),r[2]=Ct(r[2]),r[3]>.9999999&&(r[3]=1),new u(ue(r))};var{pow:Rs}=Math;function ge(e){let t="rgb",o=O("#ccc"),r=0,n=[0,1],s=[],i=[0,0],l=!1,a=[],m=!1,c=0,d=1,p=!1,f={},g=!0,y=1,_=function(h){if(h=h||["#fff","#000"],h&&C(h)==="string"&&O.brewer&&O.brewer[h.toLowerCase()]&&(h=O.brewer[h.toLowerCase()]),C(h)==="array"){h.length===1&&(h=[h[0],h[0]]),h=h.slice(0);for(let v=0;v<h.length;v++)h[v]=O(h[v]);s.length=0;for(let v=0;v<h.length;v++)s.push(v/(h.length-1))}return A(),a=h},b=function(h){if(l!=null){let v=l.length-1,S=0;for(;S<v&&h>=l[S];)S++;return S-1}return 0},E=h=>h,M=h=>h,D=function(h,v){let S,x;if(v==null&&(v=!1),isNaN(h)||h===null)return o;v?x=h:l&&l.length>2?x=b(h)/(l.length-2):d!==c?x=(h-c)/(d-c):x=1,x=M(x),v||(x=E(x)),y!==1&&(x=Rs(x,y)),x=i[0]+x*(1-i[0]-i[1]),x=G(x,0,1);let T=Math.floor(x*1e4);if(g&&f[T])S=f[T];else{if(C(a)==="array")for(let P=0;P<s.length;P++){let L=s[P];if(x<=L){S=a[P];break}if(x>=L&&P===s.length-1){S=a[P];break}if(x>L&&x<s[P+1]){x=(x-L)/(s[P+1]-L),S=O.interpolate(a[P],a[P+1],x,t);break}}else C(a)==="function"&&(S=a(x));g&&(f[T]=S)}return S};var A=()=>f={};_(e);let k=function(h){let v=O(D(h));return m&&v[m]?v[m]():v};return k.classes=function(h){if(h!=null){if(C(h)==="array")l=h,n=[h[0],h[h.length-1]];else{let v=O.analyze(n);h===0?l=[v.min,v.max]:l=O.limits(v,"e",h)}return k}return l},k.domain=function(h){if(!arguments.length)return n;c=h[0],d=h[h.length-1],s=[];let v=a.length;if(h.length===v&&c!==d)for(let S of Array.from(h))s.push((S-c)/(d-c));else{for(let S=0;S<v;S++)s.push(S/(v-1));if(h.length>2){let S=h.map((T,P)=>P/(h.length-1)),x=h.map(T=>(T-c)/(d-c));x.every((T,P)=>S[P]===T)||(M=T=>{if(T<=0||T>=1)return T;let P=0;for(;T>=x[P+1];)P++;let L=(T-x[P])/(x[P+1]-x[P]);return S[P]+L*(S[P+1]-S[P])})}}return n=[c,d],k},k.mode=function(h){return arguments.length?(t=h,A(),k):t},k.range=function(h,v){return _(h,v),k},k.out=function(h){return m=h,k},k.spread=function(h){return arguments.length?(r=h,k):r},k.correctLightness=function(h){return h==null&&(h=!0),p=h,A(),p?E=function(v){let S=D(0,!0).lab()[0],x=D(1,!0).lab()[0],T=S>x,P=D(v,!0).lab()[0],L=S+(x-S)*v,N=P-L,z=0,J=1,te=20;for(;Math.abs(N)>.01&&te-- >0;)(function(){return T&&(N*=-1),N<0?(z=v,v+=(J-v)*.5):(J=v,v+=(z-v)*.5),P=D(v,!0).lab()[0],N=P-L})();return v}:E=v=>v,k},k.padding=function(h){return h!=null?(C(h)==="number"&&(h=[h,h]),i=h,k):i},k.colors=function(h,v){arguments.length<2&&(v="hex");let S=[];if(arguments.length===0)S=a.slice(0);else if(h===1)S=[k(.5)];else if(h>1){let x=n[0],T=n[1]-x;S=Ts(0,h,!1).map(P=>k(x+P/(h-1)*T))}else{e=[];let x=[];if(l&&l.length>2)for(let T=1,P=l.length,L=1<=P;L?T<P:T>P;L?T++:T--)x.push((l[T-1]+l[T])*.5);else x=n;S=x.map(T=>k(T))}return O[v]&&(S=S.map(x=>x[v]())),S},k.cache=function(h){return h!=null?(g=h,k):g},k.gamma=function(h){return h!=null?(y=h,k):y},k.nodata=function(h){return h!=null?(o=O(h),k):o},k}function Ts(e,t,o){let r=[],n=e<t,s=o?n?t+1:t-1:t;for(let i=e;n?i<s:i>s;n?i++:i--)r.push(i);return r}var Ps=function(e){let t=[1,1];for(let o=1;o<e;o++){let r=[1];for(let n=1;n<=t.length;n++)r[n]=(t[n]||0)+t[n-1];t=r}return t},Ds=function(e){let t,o,r,n;if(e=e.map(s=>new u(s)),e.length===2)[o,r]=e.map(s=>s.lab()),t=function(s){let i=[0,1,2].map(l=>o[l]+s*(r[l]-o[l]));return new u(i,"lab")};else if(e.length===3)[o,r,n]=e.map(s=>s.lab()),t=function(s){let i=[0,1,2].map(l=>(1-s)*(1-s)*o[l]+2*(1-s)*s*r[l]+s*s*n[l]);return new u(i,"lab")};else if(e.length===4){let s;[o,r,n,s]=e.map(i=>i.lab()),t=function(i){let l=[0,1,2].map(a=>(1-i)*(1-i)*(1-i)*o[a]+3*(1-i)*(1-i)*i*r[a]+3*(1-i)*i*i*n[a]+i*i*i*s[a]);return new u(l,"lab")}}else if(e.length>=5){let s,i,l;s=e.map(a=>a.lab()),l=e.length-1,i=Ps(l),t=function(a){let m=1-a,c=[0,1,2].map(d=>s.reduce((p,f,g)=>p+i[g]*m**(l-g)*a**g*f[d],0));return new u(c,"lab")}}else throw new RangeError("No point in running bezier with only one color.");return t},mo=e=>{let t=Ds(e);return t.scale=()=>ge(t),t};var{round:po}=Math;u.prototype.rgb=function(e=!0){return e===!1?this._rgb.slice(0,3):this._rgb.slice(0,3).map(po)};u.prototype.rgba=function(e=!0){return this._rgb.slice(0,4).map((t,o)=>o<3?e===!1?t:po(t):t)};var Os=(...e)=>new u(...e,"rgb");Object.assign(O,{rgb:Os});R.format.rgb=(...e)=>{let t=w(e,"rgba");return t[3]===void 0&&(t[3]=1),t};R.autodetect.push({p:3,test:(...e)=>{if(e=w(e,"rgba"),C(e)==="array"&&(e.length===3||e.length===4&&C(e[3])=="number"&&e[3]>=0&&e[3]<=1))return"rgb"}});var K=(e,t,o)=>{if(!K[o])throw new Error("unknown blend mode "+o);return K[o](e,t)},ce=e=>(t,o)=>{let r=O(o).rgb(),n=O(t).rgb();return O.rgb(e(r,n))},de=e=>(t,o)=>{let r=[];return r[0]=e(t[0],o[0]),r[1]=e(t[1],o[1]),r[2]=e(t[2],o[2]),r},As=e=>e,Ns=(e,t)=>e*t/255,Hs=(e,t)=>e>t?t:e,zs=(e,t)=>e>t?e:t,Vs=(e,t)=>255*(1-(1-e/255)*(1-t/255)),Ws=(e,t)=>t<128?2*e*t/255:255*(1-2*(1-e/255)*(1-t/255)),Is=(e,t)=>255*(1-(1-t/255)/(e/255)),js=(e,t)=>e===255?255:(e=255*(t/255)/(1-e/255),e>255?255:e);K.normal=ce(de(As));K.multiply=ce(de(Ns));K.screen=ce(de(Vs));K.overlay=ce(de(Ws));K.darken=ce(de(Hs));K.lighten=ce(de(zs));K.dodge=ce(de(js));K.burn=ce(de(Is));var fo=K;var{pow:$s,sin:Fs,cos:Gs}=Math;function uo(e=300,t=-1.5,o=1,r=1,n=[0,1]){let s=0,i;C(n)==="array"?i=n[1]-n[0]:(i=0,n=[n,n]);let l=function(a){let m=U*((e+120)/360+t*a),c=$s(n[0]+i*a,r),p=(s!==0?o[0]+a*s:o)*c*(1-c)/2,f=Gs(m),g=Fs(m),y=c+p*(-.14861*f+1.78277*g),_=c+p*(-.29227*f-.90649*g),b=c+p*(1.97294*f);return O(ue([y*255,_*255,b*255,1]))};return l.start=function(a){return a==null?e:(e=a,l)},l.rotations=function(a){return a==null?t:(t=a,l)},l.gamma=function(a){return a==null?r:(r=a,l)},l.hue=function(a){return a==null?o:(o=a,C(o)==="array"?(s=o[1]-o[0],s===0&&(o=o[1])):s=0,l)},l.lightness=function(a){return a==null?n:(C(a)==="array"?(n=a,i=a[1]-a[0]):(n=[a,a],i=0),l)},l.scale=()=>O.scale(l),l.hue(o),l}var Us="0123456789abcdef",{floor:Bs,random:Ys}=Math,ho=()=>{let e="#";for(let t=0;t<6;t++)e+=Us.charAt(Bs(Ys()*16));return new u(e,"hex")};var{log:go,pow:Xs,floor:qs,abs:Ks}=Math;function St(e,t=null){let o={min:Number.MAX_VALUE,max:Number.MAX_VALUE*-1,sum:0,values:[],count:0};return C(e)==="object"&&(e=Object.values(e)),e.forEach(r=>{t&&C(r)==="object"&&(r=r[t]),r!=null&&!isNaN(r)&&(o.values.push(r),o.sum+=r,r<o.min&&(o.min=r),r>o.max&&(o.max=r),o.count+=1)}),o.domain=[o.min,o.max],o.limits=(r,n)=>Lt(o,r,n),o}function Lt(e,t="equal",o=7){C(e)=="array"&&(e=St(e));let{min:r,max:n}=e,s=e.values.sort((l,a)=>l-a);if(o===1)return[r,n];let i=[];if(t.substr(0,1)==="c"&&(i.push(r),i.push(n)),t.substr(0,1)==="e"){i.push(r);for(let l=1;l<o;l++)i.push(r+l/o*(n-r));i.push(n)}else if(t.substr(0,1)==="l"){if(r<=0)throw new Error("Logarithmic scales are only possible for values > 0");let l=Math.LOG10E*go(r),a=Math.LOG10E*go(n);i.push(r);for(let m=1;m<o;m++)i.push(Xs(10,l+m/o*(a-l)));i.push(n)}else if(t.substr(0,1)==="q"){i.push(r);for(let l=1;l<o;l++){let a=(s.length-1)*l/o,m=qs(a);if(m===a)i.push(s[m]);else{let c=a-m;i.push(s[m]*(1-c)+s[m+1]*c)}}i.push(n)}else if(t.substr(0,1)==="k"){let l,a=s.length,m=new Array(a),c=new Array(o),d=!0,p=0,f=null;f=[],f.push(r);for(let _=1;_<o;_++)f.push(r+_/o*(n-r));for(f.push(n);d;){for(let b=0;b<o;b++)c[b]=0;for(let b=0;b<a;b++){let E=s[b],M=Number.MAX_VALUE,D;for(let A=0;A<o;A++){let k=Ks(f[A]-E);k<M&&(M=k,D=A),c[D]++,m[b]=D}}let _=new Array(o);for(let b=0;b<o;b++)_[b]=null;for(let b=0;b<a;b++)l=m[b],_[l]===null?_[l]=s[b]:_[l]+=s[b];for(let b=0;b<o;b++)_[b]*=1/c[b];d=!1;for(let b=0;b<o;b++)if(_[b]!==f[b]){d=!0;break}f=_,p++,p>200&&(d=!1)}let g={};for(let _=0;_<o;_++)g[_]=[];for(let _=0;_<a;_++)l=m[_],g[l].push(s[_]);let y=[];for(let _=0;_<o;_++)y.push(g[_][0]),y.push(g[_][g[_].length-1]);y=y.sort((_,b)=>_-b),i.push(y[0]);for(let _=1;_<y.length;_+=2){let b=y[_];!isNaN(b)&&i.indexOf(b)===-1&&i.push(b)}}return i}var bo=(e,t)=>{e=new u(e),t=new u(t);let o=e.luminance(),r=t.luminance();return o>r?(o+.05)/(r+.05):(r+.05)/(o+.05)};var _o=.027,Zs=5e-4,Js=.1,yo=1.14,ot=.022,wo=1.414,xo=(e,t)=>{e=new u(e),t=new u(t),e.alpha()<1&&(e=ee(t,e,e.alpha(),"rgb"));let o=vo(...e.rgb()),r=vo(...t.rgb()),n=o>=ot?o:o+Math.pow(ot-o,wo),s=r>=ot?r:r+Math.pow(ot-r,wo),i=Math.pow(s,.56)-Math.pow(n,.57),l=Math.pow(s,.65)-Math.pow(n,.62),a=Math.abs(s-n)<Zs?0:n<s?i*yo:l*yo;return(Math.abs(a)<Js?0:a>0?a-_o:a+_o)*100};function vo(e,t,o){return .2126729*Math.pow(e/255,2.4)+.7151522*Math.pow(t/255,2.4)+.072175*Math.pow(o/255,2.4)}var{sqrt:re,pow:V,min:Qs,max:ei,atan2:Eo,abs:ko,cos:rt,sin:Co,exp:ti,PI:Mo}=Math;function So(e,t,o=1,r=1,n=1){var s=function(gt){return 360*gt/(2*Mo)},i=function(gt){return 2*Mo*gt/360};e=new u(e),t=new u(t);let[l,a,m]=Array.from(e.lab()),[c,d,p]=Array.from(t.lab()),f=(l+c)/2,g=re(V(a,2)+V(m,2)),y=re(V(d,2)+V(p,2)),_=(g+y)/2,b=.5*(1-re(V(_,7)/(V(_,7)+V(25,7)))),E=a*(1+b),M=d*(1+b),D=re(V(E,2)+V(m,2)),A=re(V(M,2)+V(p,2)),k=(D+A)/2,h=s(Eo(m,E)),v=s(Eo(p,M)),S=h>=0?h:h+360,x=v>=0?v:v+360,T=ko(S-x)>180?(S+x+360)/2:(S+x)/2,P=1-.17*rt(i(T-30))+.24*rt(i(2*T))+.32*rt(i(3*T+6))-.2*rt(i(4*T-63)),L=x-S;L=ko(L)<=180?L:x<=S?L+360:L-360,L=2*re(D*A)*Co(i(L)/2);let N=c-l,z=A-D,J=1+.015*V(f-50,2)/re(20+V(f-50,2)),te=1+.045*k,Pe=1+.015*k*P,be=30*ti(-V((T-275)/25,2)),oe=-(2*re(V(k,7)/(V(k,7)+V(25,7))))*Co(2*i(be)),se=re(V(N/(o*J),2)+V(z/(r*te),2)+V(L/(n*Pe),2)+oe*(z/(r*te))*(L/(n*Pe)));return ei(0,Qs(100,se))}function Lo(e,t,o="lab"){e=new u(e),t=new u(t);let r=e.get(o),n=t.get(o),s=0;for(let i in r){let l=(r[i]||0)-(n[i]||0);s+=l*l}return Math.sqrt(s)}var Ro=(...e)=>{try{return new u(...e),!0}catch{return!1}};var To={cool(){return ge([O.hsl(180,1,.9),O.hsl(250,.7,.4)])},hot(){return ge(["#000","#f00","#ff0","#fff"],[0,.25,.75,1]).mode("rgb")}};var Rt={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},Do=Object.keys(Rt),Po=new Map(Do.map(e=>[e.toLowerCase(),e])),oi=typeof Proxy=="function"?new Proxy(Rt,{get(e,t){let o=t.toLowerCase();if(Po.has(o))return e[Po.get(o)]},getOwnPropertyNames(){return Object.getOwnPropertyNames(Do)}}):Rt,Oo=oi;var ri=(...e)=>{e=w(e,"cmyk");let[t,o,r,n]=e,s=e.length>4?e[4]:1;return n===1?[0,0,0,s]:[t>=1?0:255*(1-t)*(1-n),o>=1?0:255*(1-o)*(1-n),r>=1?0:255*(1-r)*(1-n),s]},Ao=ri;var{max:No}=Math,ni=(...e)=>{let[t,o,r]=w(e,"rgb");t=t/255,o=o/255,r=r/255;let n=1-No(t,No(o,r)),s=n<1?1/(1-n):0,i=(1-t-n)*s,l=(1-o-n)*s,a=(1-r-n)*s;return[i,l,a,n]},Ho=ni;u.prototype.cmyk=function(){return Ho(this._rgb)};var si=(...e)=>new u(...e,"cmyk");Object.assign(O,{cmyk:si});R.format.cmyk=Ao;R.autodetect.push({p:2,test:(...e)=>{if(e=w(e,"cmyk"),C(e)==="array"&&e.length===4)return"cmyk"}});var ii=(...e)=>{let t=w(e,"hsla"),o=F(e)||"lsa";return t[0]=I(t[0]||0)+"deg",t[1]=I(t[1]*100)+"%",t[2]=I(t[2]*100)+"%",o==="hsla"||t.length>3&&t[3]<1?(t[3]="/ "+(t.length>3?t[3]:1),o="hsla"):t.length=3,`${o.substr(0,3)}(${t.join(" ")})`},zo=ii;var li=(...e)=>{let t=w(e,"lab"),o=F(e)||"lab";return t[0]=I(t[0])+"%",t[1]=I(t[1]),t[2]=I(t[2]),o==="laba"||t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`lab(${t.join(" ")})`},Vo=li;var ai=(...e)=>{let t=w(e,"lch"),o=F(e)||"lab";return t[0]=I(t[0])+"%",t[1]=I(t[1]),t[2]=isNaN(t[2])?"none":I(t[2])+"deg",o==="lcha"||t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`lch(${t.join(" ")})`},Wo=ai;var ci=(...e)=>{let t=w(e,"lab");return t[0]=I(t[0]*100)+"%",t[1]=De(t[1]),t[2]=De(t[2]),t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`oklab(${t.join(" ")})`},Io=ci;var di=(...e)=>{let[t,o,r,...n]=w(e,"rgb"),[s,i,l]=Me(t,o,r),[a,m,c]=et(s,i,l);return[a,m,c,...n.length>0&&n[0]<1?[n[0]]:[]]},nt=di;var mi=(...e)=>{let t=w(e,"lch");return t[0]=I(t[0]*100)+"%",t[1]=De(t[1]),t[2]=isNaN(t[2])?"none":I(t[2])+"deg",t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`oklch(${t.join(" ")})`},jo=mi;var{round:Tt}=Math,pi=(...e)=>{let t=w(e,"rgba"),o=F(e)||"rgb";if(o.substr(0,3)==="hsl")return zo(tt(t),o);if(o.substr(0,3)==="lab"){let r=ae();B("d50");let n=Vo(ve(t),o);return B(r),n}if(o.substr(0,3)==="lch"){let r=ae();B("d50");let n=Wo(Ae(t),o);return B(r),n}return o.substr(0,5)==="oklab"?Io(Me(t)):o.substr(0,5)==="oklch"?jo(nt(t)):(t[0]=Tt(t[0]),t[1]=Tt(t[1]),t[2]=Tt(t[2]),(o==="rgba"||t.length>3&&t[3]<1)&&(t[3]="/ "+(t.length>3?t[3]:1),o="rgba"),`${o.substr(0,3)}(${t.slice(0,o==="rgb"?3:4).join(" ")})`)},$o=pi;var fi=(...e)=>{e=w(e,"lch");let[t,o,r,...n]=e,[s,i,l]=Qe(t,o,r),[a,m,c]=Ce(s,i,l);return[a,m,c,...n.length>0&&n[0]<1?[n[0]]:[]]},st=fi;var ne=/((?:-?\d+)|(?:-?\d+(?:\.\d+)?)%|none)/.source,Z=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)%?)|none)/.source,it=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)%)|none)/.source,X=/\s*/.source,Le=/\s+/.source,Pt=/\s*,\s*/.source,lt=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)(?:deg)?)|none)/.source,Re=/\s*(?:\/\s*((?:[01]|[01]?\.\d+)|\d+(?:\.\d+)?%))?/.source,Fo=new RegExp("^rgba?\\("+X+[ne,ne,ne].join(Le)+Re+"\\)$"),Go=new RegExp("^rgb\\("+X+[ne,ne,ne].join(Pt)+X+"\\)$"),Uo=new RegExp("^rgba\\("+X+[ne,ne,ne,Z].join(Pt)+X+"\\)$"),Bo=new RegExp("^hsla?\\("+X+[lt,it,it].join(Le)+Re+"\\)$"),Yo=new RegExp("^hsl?\\("+X+[lt,it,it].join(Pt)+X+"\\)$"),Xo=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,qo=new RegExp("^lab\\("+X+[Z,Z,Z].join(Le)+Re+"\\)$"),Ko=new RegExp("^lch\\("+X+[Z,Z,lt].join(Le)+Re+"\\)$"),Zo=new RegExp("^oklab\\("+X+[Z,Z,Z].join(Le)+Re+"\\)$"),Jo=new RegExp("^oklch\\("+X+[Z,Z,lt].join(Le)+Re+"\\)$"),{round:Qo}=Math,Se=e=>e.map((t,o)=>o<=2?G(Qo(t),0,255):t),W=(e,t=0,o=100,r=!1)=>(typeof e=="string"&&e.endsWith("%")&&(e=parseFloat(e.substring(0,e.length-1))/100,r?e=t+(e+1)*.5*(o-t):e=t+e*(o-t)),+e),j=(e,t)=>e==="none"?t:e,er=e=>{if(e=e.toLowerCase().trim(),e==="transparent")return[0,0,0,0];let t;if(R.format.named)try{return R.format.named(e)}catch{}if((t=e.match(Fo))||(t=e.match(Go))){let o=t.slice(1,4);for(let n=0;n<3;n++)o[n]=+W(j(o[n],0),0,255);o=Se(o);let r=t[4]!==void 0?+W(t[4],0,1):1;return o[3]=r,o}if(t=e.match(Uo)){let o=t.slice(1,5);for(let r=0;r<4;r++)o[r]=+W(o[r],0,255);return o}if((t=e.match(Bo))||(t=e.match(Yo))){let o=t.slice(1,4);o[0]=+j(o[0].replace("deg",""),0),o[1]=+W(j(o[1],0),0,100)*.01,o[2]=+W(j(o[2],0),0,100)*.01;let r=Se(Ne(o)),n=t[4]!==void 0?+W(t[4],0,1):1;return r[3]=n,r}if(t=e.match(Xo)){let o=t.slice(1,4);o[1]*=.01,o[2]*=.01;let r=Ne(o);for(let n=0;n<3;n++)r[n]=Qo(r[n]);return r[3]=+t[4],r}if(t=e.match(qo)){let o=t.slice(1,4);o[0]=W(j(o[0],0),0,100),o[1]=W(j(o[1],0),-125,125,!0),o[2]=W(j(o[2],0),-125,125,!0);let r=ae();B("d50");let n=Se(we(o));B(r);let s=t[4]!==void 0?+W(t[4],0,1):1;return n[3]=s,n}if(t=e.match(Ko)){let o=t.slice(1,4);o[0]=W(o[0],0,100),o[1]=W(j(o[1],0),0,150,!1),o[2]=+j(o[2].replace("deg",""),0);let r=ae();B("d50");let n=Se(xe(o));B(r);let s=t[4]!==void 0?+W(t[4],0,1):1;return n[3]=s,n}if(t=e.match(Zo)){let o=t.slice(1,4);o[0]=W(j(o[0],0),0,1),o[1]=W(j(o[1],0),-.4,.4,!0),o[2]=W(j(o[2],0),-.4,.4,!0);let r=Se(Ce(o)),n=t[4]!==void 0?+W(t[4],0,1):1;return r[3]=n,r}if(t=e.match(Jo)){let o=t.slice(1,4);o[0]=W(j(o[0],0),0,1),o[1]=W(j(o[1],0),0,.4,!1),o[2]=+j(o[2].replace("deg",""),0);let r=Se(st(o)),n=t[4]!==void 0?+W(t[4],0,1):1;return r[3]=n,r}};er.test=e=>Fo.test(e)||Bo.test(e)||qo.test(e)||Ko.test(e)||Zo.test(e)||Jo.test(e)||Go.test(e)||Uo.test(e)||Yo.test(e)||Xo.test(e)||e==="transparent";var Dt=er;u.prototype.css=function(e){return $o(this._rgb,e)};var ui=(...e)=>new u(...e,"css");O.css=ui;R.format.css=Dt;R.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&C(e)==="string"&&Dt.test(e))return"css"}});R.format.gl=(...e)=>{let t=w(e,"rgba");return t[0]*=255,t[1]*=255,t[2]*=255,t};var hi=(...e)=>new u(...e,"gl");O.gl=hi;u.prototype.gl=function(){let e=this._rgb;return[e[0]/255,e[1]/255,e[2]/255,e[3]]};u.prototype.hex=function(e){return Je(this._rgb,e)};var gi=(...e)=>new u(...e,"hex");O.hex=gi;R.format.hex=Ke;R.autodetect.push({p:4,test:(e,...t)=>{if(!t.length&&C(e)==="string"&&[3,4,5,6,7,8,9].indexOf(e.length)>=0)return"hex"}});var{log:at}=Math,bi=e=>{let t=e/100,o,r,n;return t<66?(o=255,r=t<6?0:-155.25485562709179-.44596950469579133*(r=t-2)+104.49216199393888*at(r),n=t<20?0:-254.76935184120902+.8274096064007395*(n=t-10)+115.67994401066147*at(n)):(o=351.97690566805693+.114206453784165*(o=t-55)-40.25366309332127*at(o),r=325.4494125711974+.07943456536662342*(r=t-50)-28.0852963507957*at(r),n=255),[o,r,n,1]},ct=bi;var{round:_i}=Math,yi=(...e)=>{let t=w(e,"rgb"),o=t[0],r=t[2],n=1e3,s=4e4,i=.4,l;for(;s-n>i;){l=(s+n)*.5;let a=ct(l);a[2]/a[0]>=r/o?s=l:n=l}return _i(l)},tr=yi;u.prototype.temp=u.prototype.kelvin=u.prototype.temperature=function(){return tr(this._rgb)};var Ot=(...e)=>new u(...e,"temp");Object.assign(O,{temp:Ot,kelvin:Ot,temperature:Ot});R.format.temp=R.format.kelvin=R.format.temperature=ct;u.prototype.oklch=function(){return nt(this._rgb)};var wi=(...e)=>new u(...e,"oklch");Object.assign(O,{oklch:wi});R.format.oklch=st;R.autodetect.push({p:2,test:(...e)=>{if(e=w(e,"oklch"),C(e)==="array"&&e.length===3)return"oklch"}});Object.assign(O,{analyze:St,average:co,bezier:mo,blend:fo,brewer:Oo,Color:u,colors:le,contrast:bo,contrastAPCA:xo,cubehelix:uo,deltaE:So,distance:Lo,input:R,interpolate:ee,limits:Lt,mix:ee,random:ho,scale:ge,scales:To,valid:Ro});var me=O;var At=class{format(t){return t?"true":"false"}},vi={float:{format:{style:"decimal",minimumFractionDigits:2,maximumFractionDigits:2}},datetime:{format:{dateStyle:"short",timeStyle:"medium"}},date:{format:{dateStyle:"short"}}},dt=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??vi[t]?.format;return new Intl.NumberFormat(navigator.languages,r)}create_boolean_formatter(t,o){return new At}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 rr=new dt,or=1;function nr(e,t){return rr.get(e,t)}function He(e,t,o={},r=!1){if(t===null)return null;let n=r&&this._table_schema[e]||this._schema[e]||"string",s=o[e]||{};if((n==="integer"||n==="float")&&s?.number_fg_mode==="bar"){let l=Math.max(0,Math.min(or,Math.abs(t/s.fg_gradient)*or)),a=this._div_factory.get(),m=t>=0?"left":"right",c=(l*100).toFixed(2);return a.setAttribute("style",`width:calc(${c}% - 4px);position:absolute;${m}:2px;height:80%;top:10%;pointer-events:none;`),a}else if(s?.format==="link"&&n==="string"){let l=document.createElement("a");return l.setAttribute("href",t),l.setAttribute("target","_blank"),l.textContent=t,l}else if(s?.format==="bold"&&n==="string"){let l=document.createElement("b");return l.textContent=t,l}else if(s?.format==="italics"&&n==="string"){let l=document.createElement("i");return l.textContent=t,l}else{let l=rr.get(n,s);return l?l.format(t):t}}function*sr(e=[],t,o){let r=o[$]||{};for(let n of e){let s=["TOTAL",...n],i=s[s.length-1],l=s.slice(0,s.length-1).fill(""),a=He.call(this,t[l.length-1],i,r,!0);a instanceof HTMLElement?l=l.concat(a):l=l.concat({toString:()=>a}),l.length=t.length+1,yield l}}function*ir(e=[],t,o){let r=o[$]||{};for(let n of e){let s=[""];for(let i in n)s.push(He.call(this,t[i],n[i],r,!0));yield n}}function lr(e){let t,o,r,n,s;return async function(l,a,m,c,d){let p={},f={start_row:m,start_col:a,end_row:d,end_col:c,id:!0},g=null;if(c-a>0&&d-m>0){this._is_old_viewport=this._last_window?.start_row===m&&this._last_window?.end_row===d&&this._last_window?.start_col===a&&this._last_window?.end_col===c;let[v,S]=await Promise.all([this._view.to_columns_string(f),this._view.num_columns()]);g=S,p=JSON.parse(v);let T=Object.keys(p).filter(L=>L!=="__ROW_PATH__"&&L!=="__ID__"),P=!1;for(let L=0;L<T.length;L++)this._column_paths[f.start_col+L]!==T[L]&&(P=!0,this._column_paths[f.start_col+L]=T[L]);if(P){let[L,N]=await Promise.all([this._view.schema(),this._view.expression_schema()]);this._schema={...L,...N};for(let z=0;z<T.length;z++){let te=T[z].split("|")[this._config.split_by.length];this._is_editable[z+f.start_col]=!!this._table_schema[te],this._column_types[z+f.start_col]=this._schema[te]}}this._last_window=f,this._ids=p.__ID__||Array(d-m).fill(null).map((L,N)=>[N+m]),this._reverse_columns=this._column_paths.slice(a,c).reduce((L,N,z)=>(L.set(N,z),L),new Map),this._reverse_ids=this._ids?.reduce((L,N,z)=>(L.set(N?.join("|"),z),L),new Map)}else this._div_factory.clear(),g=await this._view.num_columns();let y=[],_=[],b=[],E=[],M=e.hasAttribute("settings");for(let v=a;v<Math.min(c,this._column_paths.length);++v){let S=this._column_paths[v],x=S.split("|"),T=p[S]||new Array(d-m).fill(null),P=Math.min(l[$]?.[x[this._config.split_by.length]]?.aggregate_depth||0,this._config.group_by.length);y.push(T.map((L,N)=>(p?.__ROW_PATH__?.[N]?.length??0)<P?"":He.call(this,x[this._config.split_by.length],L,l[$]||{}))),_.push(T),M&&x.push(""),b.push(x),E.push(S)}c-a>0&&d-m>0&&(this.last_column_paths=o,this.last_meta=t,this.last_ids=r,this.last_reverse_ids=n,this.last_reverse_columns=s,o=E,t=_,r=this._ids,n=this._reverse_ids,s=this._reverse_columns);let D=p.__ROW_PATH__!==void 0,A=Array.from((D?sr:ir).call(this,p.__ROW_PATH__,this._config.group_by,l)),k=A[0]?.length;return{num_column_headers:this._config.split_by.length+(M?2:1),num_row_headers:k,num_rows:this._num_rows,num_columns:g,row_headers:A,column_headers:b,data:y,metadata:_,column_header_merge_depth:Math.max(0,this._config.split_by.length)}}}function Nt(e,t){return me.mix(e,`rgb(${t[0]},${t[1]},${t[2]})`,.5).hex()}function pe([e,t,o,r],n=[255,255,255]){function s(i,l){return((1-r)*(n[i]/255)+r*(l/255))*255}return[s(0,e),s(1,t),s(2,o)]}function fe([e,t,o]){return Math.sqrt(e*e*.299+t*t*.587+o*o*.114)>130?"#161616":"#ffffff"}function xi(e){let[t,o,r]=e.rgb(),[n,s,i]=e.set("hsl.h",(e.get("hsl.h")-15)%360).rgb(),[l,a,m]=e.set("hsl.h",(e.get("hsl.h")+15)%360).rgb();return`linear-gradient(to right top,rgb(${n},${s},${i}),rgb(${t},${o},${r}) 50%,rgb(${l},${a},${m}))`}function q(e){let t=me(e),o=xi(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 mt(e,t,o){let r=window.getComputedStyle(e).getPropertyValue(t).trim();return r.length>0?r:o}var Ht=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 Ei(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 pt(e,t,o,r={}){let n=await o.get_config();if(this?.model?._config){let h=this.model._config,v=h.group_by.length!==n.group_by.length,S=(h.group_by.length===0||n.group_by.length===0)&&v;if(!v)for(let N in h.group_by)v||=n.group_by[N]!==h.group_by[N];let x=h.split_by.length!==n.split_by.length;if(x)for(let N in h.split_by)x||=n.split_by[N]!==h.split_by[N];let T=h.columns.length!==n.columns.length;if(T)for(let N in h.columns)T||=n.columns[N]!==h.columns[N];let P=h.filter.length!==n.filter.length;if(P)for(let N in h.filter)for(let z in n.filter[N])P||=n.filter[N][z]!==h.filter[N][z];let L=h.sort.length!==n.sort.length;if(L)for(let N in h.sort)for(let z in n.sort[N])L||=n.sort[N][z]!==h.sort[N][z];this._reset_scroll_top=v,this._reset_scroll_left=x,this._reset_select=v||x||P||L||T,this._reset_column_size=x||v||T||S}let[s,i,l,a,m]=await Promise.all([t.schema(),o.num_rows(),o.schema(),o.expression_schema(),this.parentElement.getEditPort()]),c=me(mt(e,"--plugin--background","#FFFFFF")).rgb(),d=q(mt(e,"--rt-pos-cell--color","#338DCD")),p=q(mt(e,"--rt-neg-cell--color","#FF5942")),f=q(Nt(d[0],c)),g=q(Nt(p[0],c)),y=q(mt(e,"--active--color","#ff0000")),_={...l,...a},b={...s,...a},E=[],M=[],D=[],A=this._edit_mode||"READ_ONLY";this._edit_button.dataset.editMode=A;let k=Object.assign(r,{_edit_port:m,_view:o,_table:t,_table_schema:b,_config:n,_num_rows:i,_schema:_,_ids:[],_plugin_background:c,_color:y,_pos_fg_color:d,_neg_fg_color:p,_pos_bg_color:f,_neg_bg_color:g,_column_paths:E,_column_types:D,_is_editable:M,_edit_mode:A,_selection_state:{selected_areas:[],dirty:!1},_row_header_types:n.group_by.map(h=>b[h]),_series_color_map:new Map,_series_color_seed:new Map,get_psp_type:Ei,_div_factory:r._div_factory||new Ht("div")});return e.setDataListener(lr(this.parentElement).bind(k,e),{virtual_mode:window.getComputedStyle(e).getPropertyValue("--datagrid-virtual-mode")?.trim()||"both"}),k}var ze=["READ_ONLY","EDIT","SELECT_ROW","SELECT_COLUMN","SELECT_REGION"];function Ve(e){typeof e>"u"&&(e=ze[(ze.indexOf(this._edit_mode)+1)%ze.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 We(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 Ie(e,t=!1){if(!this._initialized)return;t&&(this._cached_column_sizes=e);let o={},{group_by:r}=this.model._config,n=r?.length>0?r.length+1:0;for(let s of Object.keys(e))if(s==="__ROW_PATH__")o[n-1]=e[s];else{let i=this.model._column_paths.indexOf(s);o[i+n]=e[s]}this.regular_table.restoreColumnSizes(o)}function je(){if(!this._initialized)return{};if(this._cached_column_sizes){let n=this._cached_column_sizes;return this._cached_column_sizes=void 0,n}let e=this.regular_table.saveColumnSizes(),{group_by:t}=this.model._config,o=t?.length>0?t.length+1:0,r={};for(let n of Object.keys(e)){let s=Number(n);if(e[s]!==void 0){let i=s-o;i>-1?r[this.model._column_paths[i]]=e[s]:i===-1&&(r.__ROW_PATH__=e[s])}}return r}function ar(e,t,o){let r=Array.from(e.children[0].children[0].children),n=r.length,s=t.hasAttribute("settings");if(n<=1?r[0]?.removeAttribute("id"):r.forEach((i,l)=>{let a=s?1:0,m=l===n-(a+1)?"psp-column-titles":l===n-a?"psp-column-edit-buttons":null;m?i.setAttribute("id",m):i.removeAttribute("id")}),t.classList.toggle("psp-menu-open",!!o),s&&n>=2){let i=Array.from(r[n-2].children),l=Array.from(r[n-1].children);if(i&&l){r.slice(0,n-2).forEach(a=>{Array.from(a.children).forEach(m=>{m.classList.toggle("psp-menu-open",!1)})});for(let a=0;a<i.length;a++){let m=i[a],c=l[a],d=m.textContent===o;if(m.classList.toggle("psp-menu-open",d),c.classList.toggle("psp-menu-open",d),this._config.columns.length>1)for(let p of e.querySelectorAll("td")){let f=e.getMeta(p);if(!f?.column_header)continue;let g=f.column_header[f.column_header.length-2]===o;p.classList.toggle("psp-menu-open",g)}}}}}function cr(e,t,o){let r=this._config.group_by.length,n=this._column_settings_selected_column;for(let{element:s,metadata:i}of e.cells){if(!i)continue;let l=i.column_header?.[this._config.split_by.length],a=this._config.sort.find(_=>_[0]===l),m=i.row_header_x===r,c=typeof i.x>"u";m=m||i.x!==void 0&&(i.x+1)%this._config.columns.length===0,s.classList.toggle("psp-header-border",m),s.classList.toggle("psp-header-group",!1),s.classList.toggle("psp-header-leaf",!0),s.classList.toggle("psp-is-top",!1),s.classList.toggle("psp-header-corner",c),s.classList.toggle("psp-header-sort-asc",!o&&!!a&&a[1]==="asc"),s.classList.toggle("psp-header-sort-desc",!o&&!!a&&a[1]==="desc"),s.classList.toggle("psp-header-sort-col-asc",!o&&!!a&&a[1]==="col asc"),s.classList.toggle("psp-header-sort-col-desc",!o&&!!a&&a[1]==="col desc"),s.classList.toggle("psp-header-sort-abs-asc",!o&&!!a&&a[1]==="asc abs"),s.classList.toggle("psp-header-sort-abs-desc",!o&&!!a&&a[1]==="desc abs"),s.classList.toggle("psp-header-sort-abs-col-asc",!o&&!!a&&a[1]==="col asc abs"),s.classList.toggle("psp-header-sort-abs-col-desc",!o&&!!a&&a[1]==="col desc abs");let d=this.get_psp_type(i),p=d==="integer"||d==="float",f=d==="string",g=d==="date",y=d==="datetime";if(s.classList.toggle("psp-align-right",p),s.classList.toggle("psp-align-left",!p),s.classList.toggle("psp-menu-enabled",(f||p||g||y)&&!c&&i.column_header_y===this._config.split_by.length+1),s.classList.toggle("psp-sort-enabled",(f||p||g||y)&&!c&&i.column_header_y===this._config.split_by.length),s.classList.toggle("psp-is-width-override",t.saveColumnSizes()[i.size_key]!==void 0),this._config.columns.length>1&&n){let _=i.column_header?.[i.column_header.length-2]===n;s.classList.toggle("psp-menu-open",_)}}}var ki={desc:"asc",asc:void 0,"desc abs":"asc abs","asc abs":void 0},Ci={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 dr(e,t,o,r){let n=e.getMeta(r);if(!n?.column_header)return;let s=n.column_header[this._config.split_by.length],i=o.ctrlKey||o.metaKet||o.altKey?Mi:Si,l=o.shiftKey,a=i.call(this,s,l);await t.restore({sort:a})}function Mi(e,t){let o=[],r=!1;for(let n of this._config.sort){let[s,i]=n;if(s===e){r=!0;let l=mr.call(this,e,i,t);l&&o.push(l)}else o.push(n)}return r||o.push([e,t?"desc abs":"desc"]),o}function Si(e,t){for(let[o,r]of this._config.sort)if(o===e){let n=mr.call(this,e,r,t);return n?[n]:[]}return[[e,t?"desc abs":"desc"]]}function mr(e,t,o){let n=this._config.split_by.length>0?Ci:ki,s=t?n[t]:"desc";if(s)return[e,s]}async function pr(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(n=>n!==void 0).length-2):t.shiftKey?this._view.set_depth(o.row_header.filter(n=>n!==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 fr(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")){pr.call(this,e,o);return}if(r.classList.contains("psp-menu-enabled")){let s=e.getMeta(r)?.column_header?.[this._config.split_by.length];await t.toggleColumnSettings(s)}else r.classList.contains("psp-sort-enabled")&&dr.call(this,e,t,o,r)}}}function ur(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 zt(e,t,o){let r=e.getMeta(o);if(!r)return!1;let n=t._schema[t._column_paths[r.x]],s=o.textContent||"",i=t._ids[r.y-r.y0][0];if(n==="float"||n==="integer"){let a=parseFloat(s.replace(/,/g,""));if(isNaN(a))return!1;s=a}else if(n==="date"||n==="datetime"){let a=Date.parse(s);if(isNaN(a))return!1;s=a}else n==="boolean"&&(s=s==="true"?!1:s==="false"?!0:null);let l={__INDEX__:i,[t._column_paths[r.x]]:s};return t._table.update([l],{port_id:t._edit_port,format:null}),!0}function hr(e,t,o){let r=e.getMeta(o.target);if(typeof r?.x<"u"){let n=this._is_editable[r.x],s=this.get_psp_type(r)==="boolean",i=o.target.classList.contains("psp-null");n&&s&&!i&&zt(e,this,o.target)}}function gr(e,t,o){let r=o.get(t),n=t.getRootNode();if(r){for(let{element:s,metadata:i}of e)if(i.x===r.x&&i.y===r.y){n.activeElement!==s&&s.focus({preventScroll:!0});return}document.activeElement!==document.body&&t.contains(n.activeElement)&&n.activeElement.blur()}}function br(e,t){let o=t.get(e);if(!o)return!1;let r=e.getRootNode(),n=e.children[0]?.children[1];if(n)for(let s of n.children)for(let i of s.children){let l=e.getMeta(i);if(l&&l.x===o.x&&l.y===o.y)return r.activeElement!==i&&i.focus({preventScroll:!0}),!0}return document.activeElement!==document.body&&e.contains(r.activeElement)&&r.activeElement.blur(),!1}function Ri(e){let t;return async function(...o){if(t){await t;return}let r;t=new Promise(s=>r=s);let n=await e.apply(this,o);return t=void 0,r(),n}}function _r(){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 Te=Ri(async function(e,t,o,r,n){let s=e.getMeta(o);if(!s)return;let i=this._column_paths.length,l=this._num_rows,a=t.get(e);if(!a)return;s.x+r<i&&0<=s.x+r&&(a.x=s.x+r),s.y+n<l&&0<=s.y+n&&(a.y=s.y+n);let m=Math.max(s.x0-10,0),c=Math.min(s.x0+10,i),d=Math.max(s.y0-5,0),p=Math.min(s.y0+10,l),f=s.x0+r,g=s.y0+n;for(;!br(e,t)&&f>=m&&f<c&&g>=d&&g<p;)await e.scrollToCell(f,g),t.set(e,a),f+=r,g+=n});function Ti(e,t,o){let r=t.getMeta(o);return r!==void 0&&r.y===e._num_rows-1}function yr(e,t,o,r){let n=e.getRootNode().activeElement;switch(r.target.classList.remove("psp-error"),r.key){case"Enter":r.preventDefault(),Ti(this,e,n)?(n.blur(),o.delete(e)):r.shiftKey?Te.call(this,e,o,n,0,-1):Te.call(this,e,o,n,0,1);break;case"ArrowLeft":_r.call(n)===0&&(r.preventDefault(),Te.call(this,e,o,n,-1,0));break;case"ArrowUp":r.preventDefault(),Te.call(this,e,o,n,0,-1);break;case"ArrowRight":_r.call(n)===(n.textContent?.length||0)&&(r.preventDefault(),Te.call(this,e,o,n,1,0));break;case"ArrowDown":r.preventDefault(),Te.call(this,e,o,n,0,1);break;default:}}function ft(e,t=!1){let o=this._config.group_by.length===0&&this._config.split_by.length===0,r=e.hasAttribute("selectable"),n=e.children[0],s=t||n?._edit_mode==="EDIT";return o&&!r&&s}function wr(e,t,o,r){if(this._edit_mode==="EDIT"){if(!ft.call(this,t))return;yr.call(this,e,t,o,r)}else console.debug(`Mode ${this._edit_mode} for "keydown" event not yet implemented`)}function vr(e,t,o){if(this._edit_mode==="EDIT"){if(!ft.call(this,t))return;hr.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 xr(e,t,o,r){if(ft.call(this,t)&&o.has(e)){let n=r.target;n.classList.remove("psp-error");let s=o.get(e);o.delete(e),s.content!==n.textContent&&(zt(e,this,n)||(n.textContent=s.content||"",n.classList.add("psp-error"),n.focus()))}}function Er(e,t,o,r){let n=r.target,s=e.getMeta(n);if(s){let i={x:s.x,y:s.y,content:n.textContent||void 0};o.set(e,i)}}async function $e({_view:e,_config:t},o,r){let n=t.group_by,s=t.split_by,i=o>=0?o:0,l=i+1,a=await e.to_json({start_row:i,end_row:l}),c=a.map(b=>b.__ROW_PATH__)[0]||[],d=n.map((b,E)=>{let M=c[E];return M?[b,"==",M]:void 0}).filter(b=>b!==void 0),p=n.length>0?r+1:r,f=Object.keys(a[0])[p],g={row:a[0],column_names:[],config:{filter:[]}},y=[];if(f){let b=f.split("|");g.column_names=[b[s.length]],y=s.map((E,M)=>{let D=b[M];return D?[E,"==",D]:void 0}).filter(E=>E!==void 0).filter(([,,E])=>E!=="__ROW_PATH__")}let _=t.filter.concat(d).concat(y);return g.config={filter:_},g}async function kr(e,t,o,r){let n=e.getMeta(r.target);if(!t.hasAttribute("selectable")||r.handled||r.shiftKey||r.button!==0||(r.stopImmediatePropagation(),!n))return;let s=this._ids?.[n.y-n.y0];if(n&&n.y>=0){let i=o.get(e),l=!!i&&i.reduce((f,g,y)=>f&&g===s[y],!0),a=!!i&&s.length===i.length&&l,m={selected:!a,row:{},config:{filter:[]}},{row:c,column_names:d,config:p}=await $e(this,n.y,n.x);a?(o.delete(e),m={...m,row:c,config:{filter:structuredClone(this._config.filter)}}):(o.set(e,s),m={...m,row:c,column_names:d,config:p}),await e.draw({preserve_width:!0}),r.handled=!0,t.dispatchEvent(new CustomEvent("perspective-select",{bubbles:!0,composed:!0,detail:m}))}}async function Cr(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 Mr(e,t,o){let r=e.getMeta(o.target);if(!r)return;let{x:n,y:s}=r,{row:i,column_names:l,config:a}=await $e(this,s,n);t.dispatchEvent(new CustomEvent("perspective-click",{bubbles:!0,composed:!0,detail:{row:i,column_names:l,config:a}}))}var Di="mouse-selected-area",Sr=(e,t,{className:o=Di,selected:r=[]}={})=>(e.model._selection_state={selected_areas:r,dirty:!0},t.addEventListener("mousedown",Oi(e,t,o)),t.addEventListener("mouseover",Ai(e,t,o)),t.addEventListener("mouseup",Ni(e,t,o)),t.addStyleListener(()=>Fe(e,t,o)),t),Oi=(e,t,o)=>r=>{let n=r;if(n.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 s=t.getMeta(n.target);if(s&&s.x!==void 0&&s.y!==void 0){e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES={x:s.x,y:s.y},e.model._selection_state.old_selected_areas=e.model._selection_state.selected_areas,e.model._selection_state.selected_areas=[];let i={x0:s.x,x1:s.x,y0:s.y,y1:s.y};e.model._selection_state.potential_selection=i,Fe(e,t,o,e.model._selection_state.selected_areas.concat([i]));return}}e.model._selection_state.selected_areas=[]},Ai=(e,t,o)=>r=>{let n=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 s=t.getMeta(n.target);if(s&&s.x!==void 0&&s.y!==void 0){let i={x0:Math.min(s.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),x1:Math.max(s.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),y0:Math.min(s.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y),y1:Math.max(s.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y)};e.model._selection_state.potential_selection=i,Fe(e,t,o,e.model._selection_state.selected_areas.concat([i]))}}},Ni=(e,t,o)=>r=>{let n=r;if(e.model._edit_mode==="SELECT_REGION"||e.model._edit_mode==="SELECT_ROW"||e.model._edit_mode==="SELECT_COLUMN"){let s=t.getMeta(n.target);if(!s)return;if((e.model._selection_state.old_selected_areas?.length??0)>0){let i=e.model._selection_state.old_selected_areas[0];if(i.x0===i.x1&&i.y0===i.y1&&i.x0===s.x&&i.y0===s.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,Fe(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&&s.x!==void 0&&s.y!==void 0){let i={x0:Math.min(s.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),x1:Math.max(s.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),y0:Math.min(s.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y),y1:Math.max(s.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y)};e.model._selection_state.selected_areas.push(i),Fe(e,t,o)}e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES={},e.model._selection_state.potential_selection=void 0}};function Hi(e,t,{x0:o,x1:r,y0:n,y1:s}){let i={},l=t.model._edit_mode;o!==void 0&&["SELECT_COLUMN","SELECT_REGION"].indexOf(l)>-1&&(i.start_col=o),r!==void 0&&["SELECT_COLUMN","SELECT_REGION"].indexOf(l)>-1&&(i.end_col=r+1),n!==void 0&&["SELECT_ROW","SELECT_REGION"].indexOf(l)>-1&&(i.start_row=n),s!==void 0&&["SELECT_ROW","SELECT_REGION"].indexOf(l)>-1&&(i.end_row=s+1),e.setSelection(i)}var Fe=(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 n=t.querySelectorAll("tbody td");if(r.length>0)Hi(e.parentElement,e,r[0]),zi(e,t,r,o);else{e.parentElement.setSelection();for(let s of n)s.classList.remove(o)}}else if(e.model._selection_state.dirty){e.model._selection_state.dirty=!1;let n=t.querySelectorAll("tbody td");for(let s of n)s.classList.remove(o)}},zi=(e,t,o,r)=>{if(e.model._edit_mode==="SELECT_REGION"&&o.length>0){let n=t.querySelectorAll("tbody td");for(let s of n){let i=t.getMeta(s);if(!i)continue;let l=!1;for(let{x0:a,x1:m,y0:c,y1:d}of o)a!==void 0&&c!==void 0&&m!==void 0&&d!==void 0&&a<=i.x&&i.x<=m&&c<=i.y&&i.y<=d&&(l=!0,e.model._selection_state.dirty=!0,s.classList.add(r));l||s.classList.remove(r)}}else if(e.model._edit_mode==="SELECT_ROW"&&o.length>0){let n=t.querySelectorAll("tbody td");for(let s of n){let i=t.getMeta(s);if(!i)continue;let l=!1;for(let{x0:a,x1:m,y0:c,y1:d}of o)a!==void 0&&c!==void 0&&m!==void 0&&d!==void 0&&c<=i.y&&i.y<=d&&(e.model._selection_state.dirty=!0,l=!0,s.classList.add(r));l||s.classList.remove(r)}}else if(e.model._edit_mode==="SELECT_COLUMN"&&o.length>0){let n=t.querySelectorAll("tbody td");for(let s of n){let i=t.getMeta(s);if(!i)continue;let l=!1;for(let{x0:a,x1:m,y0:c,y1:d}of o)a!==void 0&&c!==void 0&&m!==void 0&&d!==void 0&&a<=i.x&&i.x<=m&&(e.model._selection_state.dirty=!0,l=!0,s.classList.add(r));l||s.classList.remove(r)}}};function Lr(e,t,o){if(e.length===0)return;let r=this._column_settings_selected_column,n=e.length,s=o.hasAttribute("settings");if(n<=1?e[0]?.row.removeAttribute("id"):e.forEach(({row:a},m)=>{let c=s?1:0,d=m===n-(c+1)?"psp-column-titles":m===n-c?"psp-column-edit-buttons":null;d?a.setAttribute("id",d):a.removeAttribute("id")}),o.classList.toggle("psp-menu-open",!!r),s&&n>=2){let a=e[n-2],m=e[n-1];if(a&&m){e.slice(0,n-2).forEach(({cells:c})=>{c.forEach(({element:d})=>{d.classList.toggle("psp-menu-open",!1)})});for(let c=0;c<a.cells.length;c++){let d=a.cells[c]?.element,p=m.cells[c]?.element;if(!d||!p)continue;let f=d.textContent===r;d.classList.toggle("psp-menu-open",f),p.classList.toggle("psp-menu-open",f)}}}let i=this._config.split_by.length;if(i<e.length){let a=e[i];a&&this._styleColumnHeaderRow(a,t,!1)}let l=this._config.split_by.length+1;if(l<e.length){let a=e[l];a&&this._styleColumnHeaderRow(a,t,!0)}}function Rr(e,t){let o=this._config.group_by.length,r=[],n=new Set;for(let s=0;s<e.length;s++){let{row:i,cells:l}=e[s],a=new Set;for(let m=0;m<l.length;m++){let{element:c,metadata:d}=l[m];if(!d)continue;c.style.backgroundColor="";let p=o>0&&d.row_header_x===o||(d.x??-1)>=0;c.classList.toggle("psp-align-right",!1),c.classList.toggle("psp-align-left",!1),c.classList.toggle("psp-header-group",!0),c.classList.toggle("psp-header-leaf",!1),c.classList.toggle("psp-header-border",p),c.classList.toggle("psp-header-group-corner",typeof d.x>"u"),c.classList.toggle("psp-color-mode-bar",!1),c.classList.toggle("psp-header-sort-asc",!1),c.classList.toggle("psp-header-sort-desc",!1),c.classList.toggle("psp-header-sort-col-asc",!1),c.classList.toggle("psp-header-sort-col-desc",!1),c.classList.toggle("psp-sort-enabled",!1);let f=m;for(;r[s]&&r[s][f];++f);a.add(f);let g=c;for(let y=f;y<f+g.colSpan;++y)for(let _=s;_<s+g.rowSpan;++_)r[_]||(r[_]=[]),r[_][y]=!0;g.classList.toggle("psp-is-top",s===0||!n.has(f))}n=a}}function Tr(e,t,[,,,,,o,r],[,,,,,n,s],i){let l=this._ids?.[e.dy??0]?.join("|"),a=(i?(e.column_header??[]).slice(0,-1):e.column_header??[]).join("|");if(this.last_reverse_columns?.has(a)&&this.last_reverse_ids?.has(l)){let m=this.last_reverse_ids?.get(l),c=this.last_reverse_columns.get(a);this._is_old_viewport?c!==void 0&&m!==void 0&&this.last_meta?.[c]?.[m]!==void 0&&this.last_meta[c][m]>(e.user??0)?(t.style.setProperty("--pulse--background-color-start",n),t.style.setProperty("--pulse--background-color-end",s),t.style.animationName==="pulse_neg"?t.style.animation="pulse_neg2 0.5s linear":t.style.animation="pulse_neg 0.5s linear"):c!==void 0&&m!==void 0&&this.last_meta?.[c]?.[m]!==void 0&&this.last_meta[c][m]<(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"):m!==e.dy&&(t.style.animation=""):t.style.animation=""}else t.style.animation=""}function Pr(e,t,o,r){let n=(o.user??0)>0,s=(o.user??0)<0,i;e?.pos_bg_color!==void 0?i=e.pos_bg_color:i=this._pos_bg_color;let l;e?.neg_bg_color!==void 0?l=e.neg_bg_color:l=this._neg_bg_color;let a=n?i:s?l:["",this._plugin_background[0],this._plugin_background[1],this._plugin_background[2],"","",""];{let[p,f,g,y]=a;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=p;else if(e?.number_bg_mode==="gradient"){let _=Math.max(0,Math.min(1,Math.abs((o.user??0)/(e.bg_gradient??1)))),b=this._plugin_background,E=fe(pe([f,g,y,_],b));t.style.animation="",t.style.color=E,t.style.backgroundColor=`rgba(${f},${g},${y},${_})`}else e?.number_bg_mode==="pulse"?(Tr.call(this,o,t,i,l,r),t.style.backgroundColor=""):(e?.number_bg_mode==="disabled"||e?.number_bg_mode,t.style.animation="",t.style.backgroundColor="")}let m=e?.pos_fg_color!==void 0?n?e.pos_fg_color:s?e.neg_fg_color:["",this._plugin_background[0],this._plugin_background[1],this._plugin_background[2],"","",""]:n?this._pos_fg_color:s?this._neg_fg_color:["",this._plugin_background[0],this._plugin_background[1],this._plugin_background[2],"","",""],[c,,,,d]=m;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 p=this._plugin_background,f=fe(pe([a[1],a[2],a[3],1],p));t.style.color=f}else e?.number_bg_mode==="gradient"||(t.style.color="");else e?.number_fg_mode==="bar"?(t.style.color="",t.style.position="relative",d!==""&&t.children.length>0&&t.children[0].nodeType===Node.ELEMENT_NODE&&(t.children[0].style.background=d)):(e?.number_fg_mode==="color"||!e?.number_fg_mode)&&(t.style.color=c)}function Dr(e,t,o){let r=o.column_header?.[this._config.split_by.length],n=e?.color!==void 0?e.color:this._color,[s,i,l,a]=n;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=s,t.style.backgroundColor="",e?.format==="link"&&t.children[0]&&(t.children[0].style.color=s);else if(e?.string_color_mode==="background"&&o.user!==null){let m=this._plugin_background,c=fe(pe([i,l,a,1],m));t.style.color=c,t.style.backgroundColor=s}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 m=this._series_color_map.get(r);if(o.user&&!m.has(o.user)){let A=this._series_color_seed.get(r)??0;m.set(o.user,A),this._series_color_seed.set(r,A+1)}let c=m.get(o.user)??0,[d,p,f]=me(s).hsl();d=d+c*150%360;let g=me(d,p,f,"hsl"),[y,_,b]=g.rgb(),E=g.hex(),M=this._plugin_background,D=fe(pe([y,_,b,1],M));t.style.color=D,t.style.backgroundColor=E}else t.style.backgroundColor="",t.style.color=""}function Or(e,t,o){let r=this._color,[n,s,i,l]=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=n,t.style.backgroundColor="";else if(e?.datetime_color_mode==="background"&&o.user!==null){let a=this._plugin_background,m=fe(pe([s,i,l,1],a));t.style.color=m,t.style.backgroundColor=n}else t.style.backgroundColor="",t.style.color=""}function Ar(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 Nr(e,t,o){let r=o.value!==void 0&&o.value!==null&&o.value?.toString()?.trim().length>0,n=(o.row_header_x??0)>=this._config.group_by.length,s=e.getMeta({dx:0,dy:(o.y??0)-(o.y0??0)+1}),i=s&&s.row_header&&typeof s.row_header[(o.row_header_x??0)+1]<"u";t.classList.toggle("psp-tree-label",r&&!n),t.classList.toggle("psp-tree-label-expand",r&&!n&&!i),t.classList.toggle("psp-tree-label-collapse",r&&!n&&i),t.classList.toggle("psp-tree-leaf",r&&n)}function Vi(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 Hr(e,t,o,r,n,s,i,l,a){let m=i.has(s),c=i.get(s);for(let{element:d,metadata:p,isHeader:f}of e){let g=p.column_header?.[this._config.split_by.length],y=Vi(this,p),_=g?t[g.toString()]:void 0,b=y==="integer"||y==="float";p._is_hidden_by_aggregate_depth=(M=>M===0||M===void 0?!1:M-1<Math.min(this._config.group_by.length,_?.aggregate_depth||0))(p.row_header?.filter(M=>M!==void 0)?.length),b?Pr.call(this,_,d,p,o):y==="boolean"?Ar.call(this,_,d,p):y==="string"?Dr.call(this,_,d,p):y==="date"||y==="datetime"?Or.call(this,_,d,p):(d.style.backgroundColor="",d.style.color=""),d.classList.toggle("psp-bool-type",y==="boolean"&&p.user!==null),d.classList.toggle("psp-null",p.value===null),d.classList.toggle("psp-align-right",!f&&b),d.classList.toggle("psp-align-left",f||!b),this._column_settings_selected_column?d.classList.toggle("psp-menu-open",g===this._column_settings_selected_column):d.classList.toggle("psp-menu-open",!1),d.classList.toggle("psp-color-mode-bar",_?.number_fg_mode==="bar"&&b),f&&Nr.call(this,s,d,p);let E=d.parentElement;if(E&&(E.dataset.y=String(p.y)),p.row_header_x===void 0||p.row_header_x===p.row_header.length-1||p.row_header[p.row_header_x+1]===void 0?(d.dataset.y=String(p.y),d.dataset.x=String(p.x)):(delete d.dataset.y,delete d.dataset.x),r)if(!m)d.classList.toggle("psp-row-selected",!1),d.classList.toggle("psp-row-subselected",!1);else{let M=this._ids[(p.y??0)-(p.y0??0)],D=c.reduce((k,h,v)=>k&&h===M[v],!0),A=c;f&&p.row_header_x!==void 0&&M[p.row_header_x]?(d.classList.toggle("psp-row-selected",!1),d.classList.toggle("psp-row-subselected",!1)):(d.classList.toggle("psp-row-selected",M.length===A.length&&D),d.classList.toggle("psp-row-subselected",M.length!==A.length&&D))}if(!f&&p.x!==void 0)if(n&&this._is_editable[p.x]){let D=p.column_header?.[this._config.split_by.length]?.toString();D&&y==="string"&&t[D]?.format==="link"?(d.toggleAttribute("contenteditable",!1),d.classList.toggle("boolean-editable",!1)):y==="boolean"?(d.toggleAttribute("contenteditable",!1),d.classList.toggle("boolean-editable",p.user!==null)):(n!==d.hasAttribute("contenteditable")&&d.toggleAttribute("contenteditable",n),d.classList.toggle("boolean-editable",!1))}else d.toggleAttribute("contenteditable",!1),d.classList.toggle("boolean-editable",!1)}}function zr(e,t,o=!1){let r=e._config.group_by.length===0&&e._config.split_by.length===0,n=t.hasAttribute("selectable"),s=t.children[0],i=o||s?.dataset?.editMode==="EDIT";return r&&!n&&i}function Vr(e,t,o){return function(n,s){let i=n[$]||{},l=s.hasAttribute("settings"),a=s.hasAttribute("selectable"),m=zr(this,s),c=zr(this,s,!0);e.classList.toggle("edit-mode-allowed",c);let d=[],p=[],f=n.children[0]?.children[1];if(f)for(let y of f.children)for(let _ of y.children){let b=n.getMeta(_);if(b){let E=_.tagName==="TH";d.push({element:_,metadata:b,isHeader:E})}}let g=n.children[0]?.children[0];if(g)for(let y of g.children){let _={row:y,cells:[]};for(let b of y.children){let E=n.getMeta(b);_.cells.push({element:b,metadata:E})}p.push(_)}this._applyBodyCellStyles(d,i,l,a,m,n,t,o,s),this._applyGroupHeaderStyles(p,n),this._applyColumnHeaderStyles(p,n,s),this._applyFocusStyle(d,n,o)}}function Wr(e){e._applyBodyCellStyles=Hr,e._applyGroupHeaderStyles=Rr,e._applyColumnHeaderStyles=Lr,e._applyFocusStyle=gr,e._styleColumnHeaderRow=cr}async function Ir(e){let t=this.parentElement,o=await t.getTable();if(this._initialized)await pt.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 pt.call(this,this.regular_table,o,e),!this.model)return;Sr(this,this.regular_table,{className:"psp-select-region"});let r=new WeakMap,n=new WeakMap;Wr(this.model),this.regular_table.addStyleListener(Vr(this,r,n).bind(this.model,this.regular_table,t)),this.regular_table.addEventListener("click",ur.bind(this.model,this.regular_table)),this.regular_table.addEventListener("mousedown",kr.bind(this.model,this.regular_table,t,r)),this.regular_table.addEventListener("psp-deselect-all",Cr.bind(this.model,this.regular_table,t,r)),this.regular_table.addEventListener("click",Mr.bind(this.model,this.regular_table,t)),this.regular_table.addEventListener("mousedown",fr.bind(this.model,this.regular_table,t)),this.regular_table.addEventListener("click",vr.bind(this.model,this.regular_table,t)),this.regular_table.addEventListener("focusin",Er.bind(this.model,this.regular_table,t,n)),this.regular_table.addEventListener("focusout",xr.bind(this.model,this.regular_table,t,n)),this.regular_table.addEventListener("keydown",wr.bind(this.model,this.regular_table,t,n)),t.addEventListener("perspective-toggle-column-settings",s=>{let i=s;if(this.isConnected){if(ar.call(this.model,this.regular_table,t,i.detail.column_name??void 0),!i.detail.open){this.model._column_settings_selected_column=void 0;return}this.model._column_settings_selected_column=i.detail.column_name??void 0}}),this._initialized=!0}}function jr(e,t){e=JSON.parse(JSON.stringify(e)),t=JSON.parse(JSON.stringify(t));let o={};if(e.columns)for(let[s,i]of Object.entries(e.columns))i.column_size_override!==void 0&&(o[s]=i.column_size_override,delete i.column_size_override);let r={};if(t)for(let[s,i]of Object.entries(t))r[s]={...i,pos_fg_color:i.pos_fg_color?q(i.pos_fg_color):void 0,neg_fg_color:i.neg_fg_color?q(i.neg_fg_color):void 0,pos_bg_color:i.pos_bg_color?q(i.pos_bg_color):void 0,neg_bg_color:i.neg_bg_color?q(i.neg_bg_color):void 0,color:i.color?q(i.color):void 0};"edit_mode"in e&&e.edit_mode&&(ze.indexOf(e.edit_mode)!==-1?Ve.call(this,e.edit_mode):console.error("Unknown edit mode "+e.edit_mode)),"scroll_lock"in e&&We.call(this,e.scroll_lock);let n=this.regular_table;Ie.call(this,o,!0),n[$]=r}function $r(){if(this.regular_table){let e={columns:{},scroll_lock:!!this._is_scroll_lock,edit_mode:this._edit_mode},t=je.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 Fr(e){if(this.parentElement&&await this.activate(e),!this.isConnected||this.offsetParent==null||!this.model)return;let t=je.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),Ie.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 Vt(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 Gr='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 ut=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(Gr)),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 Ir.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 Vt.call(this,t,o)}async draw(t){return await Fr.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(),n=await r.to_columns(t),s=await r.column_paths(t),i=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(),l="";for(let a=0;a<i;a++){for(let m of s){let c=n[m],d=this.model._schema[m],p=this.regular_table[$],f=m.split("|").at(-1),g=nr(d,p?.[f]||{});g?l+=g.format(c[a])+" ":l+=c[a]+" "}l+=`
|
|
3
|
-
`}return l.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 $r.call(this)}async restore(t,o){return jr.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
|
|
1
|
+
var Be=0,_e=0,jt=performance.now();function Yr(){let e=performance.now(),t=e-jt,o=Be,r=_e*1e3/t,n=1e3/o,s=_e;return Be=0,_e=0,jt=e,{avg:o,real_fps:r,virtual_fps:n,num_frames:s,elapsed:t}}function Xr(e){Be=(Be*_e+e)/(_e+1),_e+=1}var ie=new Map;async function qr(e){return await new Promise(requestAnimationFrame),await ie.get(e)?.promise}async function Gt(e,t){if(ie.has(e)&&(await ie.get(e)?.promise,ie.has(e))){await ie.get(e)?.promise;return}ie.set(e,Promise.withResolvers());try{return await t()}finally{let o=ie.get(e);ie.delete(e),o?.resolve(void 0)}}var Kr=navigator.userAgent.toLowerCase().indexOf("firefox")>-1,Zr=Kr?5e6:1e7,Jr=":host{position:absolute;top:0px;left:0px;right:0px;bottom:0px;overflow:scroll;overflow-anchor:none;overscroll-behavior:none;-webkit-overflow-scrolling:touch;}div.rt-virtual-panel{position:absolute;top:0;left:0;right:0;pointer-events:none;}div.rt-scroll-table-clip{position:sticky;contain:strict;overflow-anchor:none;width:100%;height:100%;}slot{position:absolute;overflow:hidden;overflow-anchor:none;}",Qr=":host ::slotted(table){--regular-table--transform-x:0px;--regular-table--transform-y:0px;--regular-table--clip-x:0px;--regular-table--clip-y:0px;}",en="--regular-table--clip-x",tn="--regular-table--clip-y",on="--regular-table--transform-x",rn="--regular-table--transform-y",nn='<div class="rt-virtual-panel"></div><div class="rt-scroll-table-clip"><slot></slot></div>',sn=class extends HTMLElement{u;n;i;h;R;A;V;P;v;j;s;e;t;Se;xe;table_model;o;async draw(e={}){return typeof e.throttle<"u"&&!e.throttle?await $t.call(this,e):await Gt(this,()=>$t.call(this,e))}async flush(){await qr(this)}K(){if(this.attachShadow({mode:"open"}),!this.shadowRoot)return;let e=new CSSStyleSheet;e.replaceSync(Jr);let t=new CSSStyleSheet;t.replaceSync(Qr),this.u=t.cssRules[0],this.shadowRoot.adoptedStyleSheets=[e,t],this.shadowRoot.innerHTML=nn;let[o,r]=this.shadowRoot.children;this.s=r,this.n=o,this.z()}z(){this.s&&(this.i==="both"||this.i==="vertical"?this.s.style.top="0px":this.s.style.removeProperty("top"),this.i==="both"||this.i==="horizontal"?this.s.style.left="0px":this.s.style.removeProperty("left"),this.i!=="both"?this.s.style.contain="none":this.s.style.removeProperty("contain"))}J(e,t){let{start_row:o,end_row:r}=this.Q(e),{start_col:n,end_col:s}=this.C(t);return{start_col:n,end_col:s,start_row:o,end_row:r}}Z({start_col:e,end_col:t,start_row:o,end_row:r}){o=Math.floor(o),r=Math.ceil(r),e=Math.floor(e),t=Math.ceil(t);let n=this.V!==e,s=this.R!==o||this.A!==r||this.P!==t;return this.V=e,this.P=t,this.R=o,this.A=r,{invalid_column:n,invalid_row:s}}D(e,t){if(e)if(this.i==="vertical"||this.i==="none"){let o=0;for(let r of this.e.indices)o+=r||0;this.n.style.width=o.toPrecision(10)+"px"}else{let o=this.ee(t);if(o!==0){let r=this.h.width+o+2;this.n.style.width=r.toPrecision(10)+"px"}else this.n.style.width="1px"}}B(e){let{row_height:t=19}=this.e,o=this.t.column_headers_length*t,r;r=Math.min(Zr,e*t+o),this.n.style.height=`${r.toPrecision(10)}px`}W(e,t){let o=(this.e.row_height||20)*(e.start_row%1)||0,r=(this.table_model.r||0)+Math.floor(e.start_col);this.e.indices[r]===void 0&&(this.e.indices[r]=t?.[0]?.offsetWidth||0);let n=this.e.indices[r]*(e.start_col%1)||0;this.u.style.setProperty(en,`${n}px`),this.u.style.setProperty(tn,`${o}px`),this.u.style.setProperty(on,`${-n}px`),this.u.style.setProperty(rn,`${-o}px`)}C(e){if(this.i==="none"||this.i==="vertical")return{start_col:0,end_col:1/0};{let t=this.te(),o=this.table_model.num_columns()||Math.min(e,Math.ceil(this.h.width/60)),r=t+o+1;return{start_col:t,end_col:r}}}Q(e){let{height:t,containerHeight:o}=this.h,r=this.e.row_height||19,n=this.t.column_headers_length,s=Math.max(1,this.n.offsetHeight-o),i=Math.max(Math.ceil(this.scrollTop),0)/s,l=t/r-n,a=Math.max(0,(e||0)-l)*i,d=Math.max(0,Math.min(a+l,e));return{start_row:a,end_row:d}}te(){let e=this.t.row_headers_length,t=0,o=0,r=0;for(;o<this.scrollLeft;){let n=this.e.indices[t+e];r=this.scrollLeft-o,t+=1,o+=n!==void 0?n:60}return t+=r/(this.e.indices[t+e-1]||60),Math.max(0,t-1)}ie(e){let t=0;if(this.t.row_headers_length>0)for(let n of this.e.indices.slice(0,this.t.row_headers_length))t+=n||0;let o=this.t.row_headers_length,r=e;for(;t<this.h.width&&r>=0;)r--,t+=this.e.indices[r+o]||60;return Math.min(e-1,r+1)}ee(e){let t=this.t.row_headers_length,o=this.ie(e),r=t,n=0;for(;r<o+t;)n+=this.e.indices[r]||60,r++;if(r<this.e.indices.length){let s=0,i=this.t.row_headers_length;for(let l=0;l<i&&l<this.e.indices.length;l++)s+=this.e.indices[l]||0;n+=Math.max(0,(this.e.indices[r]||0)-(this.h.width-(s||0))||0)}return n}};async function $t(e){let t=performance.now();e.cache||this.table_model.se();let{invalid_viewport:o=!0,preserve_width:r=!1}=e,{num_columns:n,num_rows:s,num_row_headers:i,num_column_headers:l,row_height:a}=await this.table_model.oe(this.t);this.e.row_height=a||this.e.row_height,i!==void 0&&(this.t.row_headers_length=i),l!==void 0&&(this.t.column_headers_length=l);let d=this.i==="none"||this.i==="horizontal",m=this.i==="none"||this.i==="vertical",c=s||0,p=n||0;this.h={width:m?1/0:this.s.clientWidth,height:d?1/0:this.s.clientHeight,containerHeight:d?1/0:this.clientHeight},this.B(c),r||this.D(o,p);let g=this.J(c,p),{invalid_row:h,invalid_column:y}=this.Z(g),b=this.v||y;if(b||h||o){let _=!0;await this.table_model.draw(this.h,this.t,this.j,r,g,p,async L=>{_&&(this.W(g,L),_=!1);for(let T of this.o)await T({detail:this})});let k=this.e.row_height;this.table_model.header.reset_header_cache(),k!==this.e.row_height&&this.B(c),r||this.D(b,p),this.v=!1}else this.W(g);Xr(performance.now()-t)}var ye=new WeakMap,ln=class{O;p;d;constructor(e){this.O=e,this.p=[],this.d=0}reset(){this.d=0}get(){this.p[this.d]||(this.p[this.d]=document.createElement(this.O));let e=this.p[this.d];return this.d+=1,e}},Bt=class{e;ne;m;table;cells;rows;constructor(e,t,o){this.e=e,this.ne=t,this.m=new ln("span"),this.table=o,this.cells=[],this.rows=[]}num_columns(){return this.w(Math.max(0,this.rows.length-1)).row_container.length}num_rows(){return this.cells.length}Ee(e,t){ye.set(e,t)}f(e){if(!e)return{value:void 0};let t=ye.get(e);return t||(t={value:void 0},ye.set(e,t)),t}$(e,t){let{tr:o,row_container:r}=this.w(e),n=r[t];return n&&(o.removeChild(n),r.splice(t,1,void 0)),n}_(e,t){if(!(e<0||t<0))return this.cells[e]?.[t]}w(e){let t=this.rows[e];t||(t=this.rows[e]=document.createElement("tr"),this.table.appendChild(t));let o=this.cells[e];return o||(o=this.cells[e]=[]),{tr:t,row_container:o}}T(e="TD",t,o){let{tr:r,row_container:n}=this.w(t),s=n[o];if(!s)if(o<n.length){s=n[o]=document.createElement(e);let i=n.slice(o+1).find(l=>l);r.insertBefore(s,i||null)}else s=n[o]=document.createElement(e),r.appendChild(s);if(s.tagName!==e){let i=document.createElement(e);r.replaceChild(i,s),this.cells[t].splice(o,1,i),s=i}return s}k(e){for(let t=0;t<this.rows.length;t++){let o=this.rows[t],r=this.cells[t];r.length=(Array.isArray(e)?e[t]:e)||0;let n=this.cells[t].filter(i=>i!==void 0).length,s=[];for(let i=n;i<o.children.length;i++)s.push(o.children[i]);for(let i of s)i.remove()}}S(e){let t=[];for(let o=e;o<this.table.children.length;o++)t.push(this.table.children[o]);for(let o of t)o.remove();this.rows.length=e,this.cells.length=e}},an=!1,cn=class extends sn{I;F;N;X;b;register_listeners(){this.addEventListener("mousedown",this.re.bind(this)),this.addEventListener("scroll",this.E.bind(this),{passive:!0}),this.le()}async E(e){e.stopPropagation(),await this.draw({invalid_viewport:!1,cache:!0}),this.dispatchEvent(new CustomEvent("regular-table-scroll"))}le(){this.addEventListener("mousewheel",this.ae.bind(this),{passive:!0}),an&&(this.addEventListener("touchmove",this.he.bind(this)),this.addEventListener("touchstart",this.de.bind(this),{passive:!0}))}ae(e){if(!window.hasOwnProperty("safari"))return;let t=e,{clientWidth:o,clientHeight:r,scrollTop:n,scrollLeft:s}=this;t.preventDefault(),t.returnValue=!1;let i=Math.max(1,this.n.offsetHeight-r),l=Math.max(1,this.n.offsetWidth-o);this.scrollTop=Math.max(0,Math.min(i,n+t.deltaY)),this.scrollLeft=Math.max(0,Math.min(l,s+t.deltaX)),this.E(t)}he(e){e.stopPropagation(),e.preventDefault(),e.returnValue=!1;let{clientWidth:t,clientHeight:o}=this,r=Math.max(1,this.n.offsetHeight-o),n=Math.max(1,this.n.offsetWidth-t);this.scrollTop=Math.min(r,(this.I||0)+((this.N||0)-e.touches[0].pageY)),this.scrollLeft=Math.min(n,(this.F||0)+((this.X||0)-e.touches[0].pageX)),this.E(e)}de(e){this.N=e.touches[0].pageY,this.X=e.touches[0].pageX,this.I=this.scrollTop,this.F=this.scrollLeft}async ce(e){let t=e.target,o=t.classList.contains("rt-column-resize");for(;t.tagName!=="TD"&&t.tagName!=="TH";)if(t=t.parentElement,!this.contains(t))return;let r=ye.get(t);if(o&&r){e.stopImmediatePropagation(),e.shiftKey?(this.e.override={},this.e.auto=[],this.e.indices=[]):(delete this.e.override[r.size_key],this.e.auto[r.size_key]=void 0,this.e.indices[r.size_key]=void 0),this.table_model.updateColumnWidthStyles({start_row:0,end_row:0,...this.C(0)},this.t.row_headers_length);for(let n of e.shiftKey?[this.table_model.header.cells[this.table_model.header.cells.length-1],...this.table_model.body.cells]:this.table_model.body.cells)for(let s of e.shiftKey?n:[n[r.virtual_x]])s&&s.classList.remove("rt-cell-clip");await this.draw({cache:!0})}}async ue(e){if(e.button!==0)return;let t=e.target,o=t.classList.contains("rt-column-resize");for(;t.tagName!=="TD"&&t.tagName!=="TH";)if(t=t.parentElement,!this.contains(t))return;let r=ye.get(t);o&&r&&(this.me(e,t,r),e.stopImmediatePropagation())}async re(e){let t=performance.now();this.b&&t-this.b<500?(this.b=t,await this.ce(e)):(this.b=t,await this.ue(e))}me(e,t,o){let{virtual_x:r,size_key:n}=o,s=e.pageX,i=(r||0)+t.colSpan-1,l=this.table_model.header.get_column_header(i),a=this.e.indices[n||0]||0,d=c=>Gt(this,async()=>await this.fe(c,l,s,a,n||0,i)),m=()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",m);let c=this.e.override[n||0],p=this.e.indices[n||0]!==c;this.e.indices[n||0]=c,p&&this.draw({cache:!0})};document.addEventListener("mousemove",d),document.addEventListener("mouseup",m)}async fe(e,t,o,r,n,s){await new Promise(requestAnimationFrame);let i=e.pageX-o,l=Math.max(1,r+i);if(this.e.override[n]=l,i<0)await this.draw({preserve_width:!0,throttle:!1,cache:!0});else{this.table_model.updateColumnWidthStyles({start_row:0,end_row:0,...this.C(0)},this.t.row_headers_length);let a=(this.e.auto[n]||0)>l;t.classList.toggle("rt-cell-clip",a);for(let d of this.table_model.body.cells){let m=d[s];m&&m.classList.toggle("rt-cell-clip",a)}}}},dn=class extends Bt{l;a;constructor(e,t,o){super(e,t,o),this.l=[],this.a=[]}G(e,t,o){let r=this.T("TH",t,e[t]||0);if(e[t]+=1,r.removeAttribute("colspan"),r.textContent="",o instanceof HTMLElement)r.appendChild(o);else{let s=this.m.get();s.textContent=String(o??""),r.appendChild(s)}let n=this.m.get();return n.className="rt-column-resize",r.appendChild(n),r}_e(e,t,o){let r=this.f(o);return r.column_header=e,r.value=t,r}pe(e,t,o,r){let n=this.f(o);if(n.column_header=e,n.value=t,n.size_key=Array.isArray(r)?r[0]:r,!Array.isArray(r)||r.length<=1){let s=this.e.override[n.size_key||0],i=this.e.auto[n.size_key||0]||0;s?o.classList.toggle("rt-cell-clip",i>s):o.classList.remove("rt-cell-clip")}return n}get_column_header(e){return this.T("TH",this.num_rows()-1,e)}draw(e,t,o,r,n,s,i,l,a){let d=t?.length;if(d===0)return;let m,c,p,g;l=typeof l>"u"?d-1:l;for(let h=0;h<d;h++){if(p=t[h]?t[h]:"",this.a[h]=this.a[h]||0,h<l)a&&this.l?.[h]?.[0]?.value===p?(m=this.l[h][1],this.l[h][2]+=1,o===1&&(this.l[h][0].row_header_x=Array.isArray(n)?n[0]:n),m.setAttribute("colspan",String(this.l[h][2]))):(m=this.G(this.a,h,p),c=this._e(t,p,m),this.l[h]=[c,m,1]);else{m=this.G(this.a,h,p),c=this.pe(e.length>0?e:t,p,m,n),typeof g>"u"&&(g={th:m,metadata:c});for(let[y]of this.l)y.size_key=c.size_key;m.removeAttribute("colspan")}this.w(h).tr.classList.toggle("rt-autosize",h===l),m.classList.toggle("rt-group-corner",r===void 0),c&&(c.x=typeof r>"u"?r:Math.floor(r),c.column_header_y=h,c.x0=Math.floor(s),c.virtual_x=i,o===1?(c.type="corner",c.row_header_x=Array.isArray(n)?n[0]:n):(c.type="column_header",delete c.row_header_x))}return this.S(this.a.length),g=g||{th:m,metadata:c},g}clean(){this.k(this.a)}reset_header_cache(){this.a=[],this.l=[]}},mn=class extends Bt{q(e,t,o,r,{column_name:n},{ridx_offset:s},i){let l=this.T(e,t,r),a=this.f(l);a.y=t+Math.floor(s);let d=a.size_key=i||0;e==="TD"&&(a.column_header=n);let m=this.e.override[d];if(m){let c=(this.e.auto[d]||0)>m;l.classList.contains("rt-cell-clip")!==c&&l.classList.toggle("rt-cell-clip",c)}else l.classList.remove("rt-cell-clip");return a.value!==o&&(o instanceof HTMLElement?(l.textContent="",l.appendChild(o)):l.textContent=String(o??"")),a.value=o,{td:l,metadata:a}}draw(e,t,o,r=!1,n,s,i,l){let{cidx:a,column_data:d,row_headers:m,column_data_listener_metadata:c}=t,{row_height:p}=o,g,h=[],y=[],b=0,_=[],k=r?o.row_headers_length??1:1,L=Math.floor(o.ridx_offset),T=Math.ceil(o.y1),A=Math.ceil(o.x1),O=n===void 0?n:Math.floor(n),u=s===void 0?void 0:Math.floor(s),v=Math.floor((n??0)-(s??0));for(let M=0;M<k;M++){b=0;let E=a+M;for(let P of d){let x;if(r){let C=P,N=C[M],z=h[M]||1,J=this._(b-z,E),te=this.f(J),De=_[b]||1,be=this._(b,E-De),It=this.f(be);if(l&&be&&(It.value===N||N===void 0)&&!be.hasAttribute("rowspan")){let oe=_[b]=De+1;be.setAttribute("colspan",String(oe)),this.$(b,E)}else if(l&&J&&te.value===N&&!J.hasAttribute("colspan")){let oe=h[M]=z+1;J.setAttribute("rowspan",String(oe)),this.$(b,E)}else{x=this.q("TH",b,N,E,t,o,M);let oe=x.td,re=x.metadata;oe.style.display="",oe.removeAttribute("rowspan"),oe.removeAttribute("colspan"),re.type="row_header",re.row_header=C,re.row_header_x=M,re.y0=L,re.y1=T,re.virtual_x=M,u!==void 0&&(re.x0=u),h[M]=1,_[b]=1,y[M]=x}}else{x=this.q("TD",b,P,a,t,o,i??0);let C=x.metadata;c&&(C.user=c[b]),C.type="body",C.x=O||0,C.x1=A,C.row_header=m?.[b]||[],C.y0=L,C.y1=T,C.dx=v,C.dy=(C.y??0)-L,C.virtual_x=a,u!==void 0&&(C.x0=u),y[0]=x}if(b++,g=x?x.metadata:g,p=p||x?.td.offsetHeight,b*(p??0)>e)break}}return this.S(b),{tds:y,ridx:b,row_height:p}}clean({ridx:e,cidx:t}){this.S(e),this.k(t)}},pn=class{e;r=0;header;body;we(e,t){let{start_row:o=0,start_col:r=0,end_col:n=0,end_row:s=0}=e,i=this.e.indices[(this.r||0)+Math.floor(e.start_col)]??0;return{viewport_width:0,selected_id:t,ridx_offset:o,sub_cell_offset:i,x0:r,x1:n,y1:s,row_height:this.e.row_height,row_headers_length:this.r}}be(e,t,o,r,n,s,i,l,a,d){let m=[`${t}`],c=[],p={column_name:m,cidx:0,column_data:e,row_headers:e,first_col:!0},g=Math.floor(i),h=this.body.draw(r,p,{...n,x0:0},!0,void 0,void 0,g,d),y=[];for(let _=0;_<t;_++){let k=this.header.draw(m,Array(o).fill(""),1,void 0,_,i,_,l,a);k&&y.push(k)}for(let _=0;_<y.length;_++){let{th:k}=y[_];n.viewport_width+=this.e.indices[_]||k.offsetWidth}n.row_height=n.row_height||h.row_height;let b=e[0].length;if(!s)for(let _=0;_<t;_++){let{td:k,metadata:L}=h.tds[_]||{},{th:T,metadata:A}=y[_]||{};(k||T)&&c.push([T||k,A||L])}return{cont_body:h,first_col:!1,ge:b,last_cells:c}}Me(e,t,o,r,n,s){let i=0,l=0;for(;this.e.indices.length>n+s+i+1&&l+t.viewport_width<o;)i++,l+=this.e.indices[n+s+i]||0;if(l+t.viewport_width<o){let a=Math.min(r,e.start_col+5);e.end_col=Math.max(1,Math.min(r,a))}else e.end_col=Math.max(1,Math.min(r,e.start_col+i))}ye(e,t,o,r,n,s,i,l,a,d){let m=t.column_headers?.[e]||[],c=t.data[e],p=t.metadata?.[e],g={column_name:m,cidx:o,column_data:c,column_data_listener_metadata:p,row_headers:t.row_headers,first_col:i},h=e+r,y=o+Math.floor(r),b=this.header.draw(m,m,void 0,h,y,r,o,l,a),_=this.body.draw(n,g,s,!1,h,r,y,d);return{cont_head:b,cont_body:_}}async ve(e,t,o,r,n,s,i,l,a){let d=Math.max(r+Math.floor(a),0),m=structuredClone(e);m.start_col=d,this.Me(m,n,s,i,l,a);let c=await t(Math.floor(m.start_col),Math.floor(m.start_row),Math.ceil(m.end_col),Math.ceil(m.end_row)),p,g;if(typeof c.column_header_merge_depth<"u"&&(p=c.column_header_merge_depth),typeof c.merge_headers<"u"&&(g=c.merge_headers),c.data.length===0)return{column_header_merge_depth:p,merge_headers:g};e.end_col=m.start_col+c.data.length;for(let h=0;h<c.data.length;h++)o.data[r+h]=c.data[h],c.metadata&&o.metadata&&(o.metadata[r+h]=c.metadata[h]),o.column_headers&&c.column_headers?.[h]&&(o.column_headers[r+h]=c.column_headers[h]);return{column_header_merge_depth:p,merge_headers:g}}g(e,t){this.body.clean({ridx:e?.ridx||0,cidx:t}),this.header.clean()}L(){this.body.m.reset(),this.header.m.reset()}},Ft=class extends pn{table;c;Y;M;Ce;constructor(e,t,o){super(),this.e=t,this.clear(o);let[r]=o.children,[n,s]=r.children;this.table=r,this.header=new dn(t,e,n),this.body=new mn(t,e,s)}num_columns(){return this.header.num_columns()}clear(e){e.innerHTML='<table cellspacing="0"><thead></thead><tbody></tbody></table>'}autosize_cells(e,t){let o=[];for(let[r,n]of e){let s=r.getBoundingClientRect();o.push({cell:r,metadata:n,box:s})}for(let{metadata:r,box:n}of o)this.e.row_height=t??Math.max(10,Math.min(this.e.row_height??n.height,n.height)),r?.size_key!==void 0&&(this.e.indices[r.size_key]=n.width,n.width&&this.e.override[r.size_key]===void 0&&(this.e.auto[r.size_key]=n.width))}updateColumnWidthStyles(e,t){let o=[],r;for(r=0;r<t;r++){let n=this.e.override[r],s=this.e.auto[r];if(n!==void 0){let i=r+1;o.push(`thead tr.rt-autosize th:nth-child(${i}),`,`tbody td.rt-cell-clip:nth-child(${i})`,`{min-width:${n}px;max-width:${n}px;}`)}else if(s!==void 0){let i=r+1;o.push(`thead tr.rt-autosize th:nth-child(${i}),`,`tbody td.rt-cell-clip:nth-child(${i})`,`{min-width:${s}px;max-width:none;}`)}}for(let n=r;n<r+(Math.floor(e.end_col)-Math.floor(e.start_col));n++){let s=this.e.override[n+Math.floor(e.start_col)],i=this.e.auto[n+Math.floor(e.start_col)];if(s!==void 0){let l=n+1;o.push(`thead tr.rt-autosize th:nth-child(${l}),`,`tbody td.rt-cell-clip:nth-child(${l})`,`{min-width:${s}px;max-width:${s}px;}`)}else if(i!==void 0){let l=n+1;o.push(`thead tr.rt-autosize th:nth-child(${l}),`,`tbody td.rt-cell-clip:nth-child(${l})`,`{min-width:${i}px;max-width:none;}`)}}o.length>0?this.Te(o.join(`
|
|
2
|
+
`)):this.c&&this.c.replaceSync("")}Te(e){if(e===this.Y)return;let t=this.table.getRootNode();!t||!t.adoptedStyleSheets||(this.c||(this.c=new CSSStyleSheet,t.adoptedStyleSheets=[...t.adoptedStyleSheets,this.c]),this.c.replaceSync(e),this.Y=e)}async oe(e){return this.M?this.M:await e.view(0,0,0,0)}se(){this.M=void 0,this.Ce=void 0}async draw(e,t,o,r,n,s,i){let{width:l,height:a}=e,d=this.M=await t.view(Math.floor(n.start_col),Math.floor(n.start_row),Math.ceil(n.end_col),Math.ceil(n.end_row)),{column_header_merge_depth:m,merge_headers:c="both"}=d,p=c==="both"||c==="row",g=c==="both"||c==="column",h=n.start_col??0;if(d.row_headers){let u=0;for(let v of d.row_headers)v.length>u&&(u=v.length);this.r=u;for(let v=0;v<d.row_headers.length;v++)d.row_headers[v].length=this.r||0}t.row_headers_length=d.num_row_headers??d.row_headers?.[0]?.length??0,t.column_headers_length=d.num_column_headers??d.column_headers?.[0]?.length??0;let{view:y,row_headers_length:b,column_headers_length:_}=t,k=this.we(n,o),L,T=0,A=[],O=!0;if(d.row_headers?.length){let u=this.be(d.row_headers,b,_,a,k,r,h,m,g,p);L=u.cont_body,O=u.first_col,T=u.ge,A=u.last_cells}try{let u=0,v=s-n.start_col;for(;u<v;){if(!d.data[u]){this.updateColumnWidthStyles(n,t.row_headers_length),await i(A[this.r]);let x=await this.ve(n,y,d,u,k,l,s,T,h);if(x.column_header_merge_depth!==void 0&&(m=x.column_header_merge_depth),x.merge_headers!==void 0&&(c=x.merge_headers),!d.data[u]){this.g(L,T),this.L(),this.updateColumnWidthStyles(n,t.row_headers_length),await i(A[this.r]),this.autosize_cells(A,this.e.row_height);return}}let{cont_head:M,cont_body:E}=this.ye(u,d,T,h,a,k,O,m,g,p);if(L=E,O=!1,!r)for(let{td:x,metadata:C}of L.tds)A.push([M?.th||x,M?.metadata||C]);let P=this.e.indices[T+Math.floor(h)]||M?.th?.offsetWidth;if(!P){P=0;for(let{td:x}of L.tds)P+=x?.offsetWidth||0}if(k.viewport_width+=P,k.row_height=k.row_height||L.row_height,T++,u++,this.U(k,l)){this.g(L,T),this.updateColumnWidthStyles(n,t.row_headers_length),await i(A[this.r]),k.viewport_width=0,this.autosize_cells(A,this.e.row_height);for(let x=0;x<A.length;x++)k.viewport_width+=this.e.indices[Math.floor(h)+x]||0;if(this.U(k,l)){this.L();return}}}this.g(L,T),this.L(),this.updateColumnWidthStyles(n,t.row_headers_length),await i(A[this.r]),this.autosize_cells(A,this.e.row_height)}finally{this.g(L,T)}}U(e,t){return e.viewport_width-e.sub_cell_offset>t}},fn=["both","horizontal","vertical","none"],un=class extends cn{H;constructor(){super(),this.e={auto:[],override:{},indices:[]},this.o=[],this.H=!1}connectedCallback(){this.H||(this.K(),this.register_listeners(),this.setAttribute("tabindex","0"),this.H=!0,this.table_model=new Ft(this.s,this.e,this))}resetAutoSize(){this.e.auto=[],this.e.override={},this.e.indices=[]}saveColumnSizes(){return structuredClone(this.e.override)}restoreColumnSizes(e){this.e.override=structuredClone(e)}clear(){this.table_model=new Ft(this.s,this.e,this)}addStyleListener(e){this.o.push(e);let t=!0;return()=>{if(!t)return;t=!1,this.o=this.o.slice();let o=this.o.indexOf(e);this.o.splice(o,1)}}removeStyleListener(e){let t=this.o.length;this.o=this.o.filter(o=>o!==e),console.assert(this.o.length===t-1,"No listener found")}getMeta(e){if(e!==void 0){if(e instanceof HTMLElement)return ye.get(e);if("row_header_x"in e&&e.row_header_x&&e.row_header_x>=0){if(e.row_header_x<this.t.row_headers_length){let t=this.table_model.body._(e.y,e.row_header_x);return this.getMeta(t)}}else if("column_header_y"in e&&e.column_header_y>=0){if(e.column_header_y<this.t.column_headers_length){let t=this.table_model.header._(e.column_header_y,e.x);return this.getMeta(t)}}else if("dx"in e)return this.getMeta(this.table_model.body._(e.dy,e.dx+(this.table_model.r||0)))}}getDrawFPS(){return Yr()}async scrollToCell(e,t){if(!this.t){console.warn("data listener not configured");return}let o=this.e.row_height||19;this.scrollTop=Math.ceil(o*t);let r=0;for(;e>0;)e--,r+=this.e.indices[e+this.t.row_headers_length]||60;this.scrollLeft=Math.ceil(r),await new Promise(requestAnimationFrame),await this.flush()}setDataListener(e,{virtual_mode:t="both",preserve_state:o=!1}={}){console.assert(fn.indexOf(t)>-1,`Unknown virtual_mode ${t}; valid options are "both" (default), "horizontal", "vertical" or "none"`);let r=this.i!==t;o?(console.assert(!r,"preserve_state called with modified virtual_mode"),this.t.view=e):(this.i=t,this.v=!0,this.t={view:e,row_headers_length:0,column_headers_length:0},r&&this.z())}};document.createElement("regular-table").constructor===HTMLElement&&window.customElements.define("regular-table",un);function we(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 $=Symbol("Perspective Column Config");var{min:hn,max:gn}=Math,G=(e,t=0,o=1)=>hn(gn(t,e),o);var ue=e=>{e._clipped=!1,e._unclipped=e.slice(0);for(let t=0;t<=3;t++)t<3?((e[t]<0||e[t]>255)&&(e._clipped=!0),e[t]=G(e[t],0,255)):t===3&&(e[t]=G(e[t],0,1));return e};var Ut={};for(let e of["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"])Ut[`[object ${e}]`]=e.toLowerCase();function S(e){return Ut[Object.prototype.toString.call(e)]||"object"}var w=(e,t=null)=>e.length>=3?Array.prototype.slice.call(e):S(e[0])=="object"&&t?t.split("").filter(o=>e[0][o]!==void 0).map(o=>e[0][o]):e[0].slice(0);var F=e=>{if(e.length<2)return null;let t=e.length-1;return S(e[t])=="string"?e[t].toLowerCase():null};var{PI:Ue,min:Ye,max:Xe}=Math,I=e=>Math.round(e*100)/100,Oe=e=>Math.round(e*100)/100,B=Ue*2,qe=Ue/3,Yt=Ue/180,Xt=180/Ue;function Ke(e){return[...e.slice(0,3).reverse(),...e.slice(3)]}var R={format:{},autodetect:[]};var _t=class{constructor(...t){let o=this;if(S(t[0])==="object"&&t[0].constructor&&t[0].constructor===this.constructor)return t[0];let r=F(t),n=!1;if(!r){n=!0,R.sorted||(R.autodetect=R.autodetect.sort((s,i)=>i.p-s.p),R.sorted=!0);for(let s of R.autodetect)if(r=s.test(...t),r)break}if(R.format[r]){let s=R.format[r].apply(null,n?t:t.slice(0,-1));o._rgb=ue(s)}else throw new Error("unknown format: "+t);o._rgb.length===3&&o._rgb.push(1)}toString(){return S(this.hex)=="function"?this.hex():`[${this._rgb.join(",")}]`}},f=_t;var qt="3.1.2";var Kt=(...e)=>new f(...e);Kt.version=qt;var D=Kt;var bn={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},le=bn;var _n=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,yn=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,wn=e=>{if(e.match(_n)){(e.length===4||e.length===7)&&(e=e.substr(1)),e.length===3&&(e=e.split(""),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]);let t=parseInt(e,16),o=t>>16,r=t>>8&255,n=t&255;return[o,r,n,1]}if(e.match(yn)){(e.length===5||e.length===9)&&(e=e.substr(1)),e.length===4&&(e=e.split(""),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]);let t=parseInt(e,16),o=t>>24&255,r=t>>16&255,n=t>>8&255,s=Math.round((t&255)/255*100)/100;return[o,r,n,s]}throw new Error(`unknown hex color: ${e}`)},Ze=wn;var{round:Je}=Math,vn=(...e)=>{let[t,o,r,n]=w(e,"rgba"),s=F(e)||"auto";n===void 0&&(n=1),s==="auto"&&(s=n<1?"rgba":"rgb"),t=Je(t),o=Je(o),r=Je(r);let l="000000"+(t<<16|o<<8|r).toString(16);l=l.substr(l.length-6);let a="0"+Je(n*255).toString(16);switch(a=a.substr(a.length-2),s.toLowerCase()){case"rgba":return`#${l}${a}`;case"argb":return`#${a}${l}`;default:return`#${l}`}},Qe=vn;f.prototype.name=function(){let e=Qe(this._rgb,"rgb");for(let t of Object.keys(le))if(le[t]===e)return t.toLowerCase();return e};R.format.named=e=>{if(e=e.toLowerCase(),le[e])return Ze(le[e]);throw new Error("unknown color name: "+e)};R.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&S(e)==="string"&&le[e.toLowerCase()])return"named"}});f.prototype.alpha=function(e,t=!1){return e!==void 0&&S(e)==="number"?t?(this._rgb[3]=e,this):new f([this._rgb[0],this._rgb[1],this._rgb[2],e],"rgb"):this._rgb[3]};f.prototype.clipped=function(){return this._rgb._clipped||!1};var Ae={Kn:18,labWhitePoint:"d65",Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,kE:.008856451679035631,kKE:8,kK:903.2962962962963,RefWhiteRGB:{X:.95047,Y:1,Z:1.08883},MtxRGB2XYZ:{m00:.4124564390896922,m01:.21267285140562253,m02:.0193338955823293,m10:.357576077643909,m11:.715152155287818,m12:.11919202588130297,m20:.18043748326639894,m21:.07217499330655958,m22:.9503040785363679},MtxXYZ2RGB:{m00:3.2404541621141045,m01:-.9692660305051868,m02:.055643430959114726,m10:-1.5371385127977166,m11:1.8760108454466942,m12:-.2040259135167538,m20:-.498531409556016,m21:.041556017530349834,m22:1.0572251882231791},As:.9414285350000001,Bs:1.040417467,Cs:1.089532651,MtxAdaptMa:{m00:.8951,m01:-.7502,m02:.0389,m10:.2664,m11:1.7135,m12:-.0685,m20:-.1614,m21:.0367,m22:1.0296},MtxAdaptMaI:{m00:.9869929054667123,m01:.43230526972339456,m02:-.008528664575177328,m10:-.14705425642099013,m11:.5183602715367776,m12:.04004282165408487,m20:.15996265166373125,m21:.0492912282128556,m22:.9684866957875502}},Q=Ae,xn=new Map([["a",[1.0985,.35585]],["b",[1.0985,.35585]],["c",[.98074,1.18232]],["d50",[.96422,.82521]],["d55",[.95682,.92149]],["d65",[.95047,1.08883]],["e",[1,1,1]],["f2",[.99186,.67393]],["f7",[.95041,1.08747]],["f11",[1.00962,.6435]],["icc",[.96422,.82521]]]);function U(e){let t=xn.get(String(e).toLowerCase());if(!t)throw new Error("unknown Lab illuminant "+e);Ae.labWhitePoint=e,Ae.Xn=t[0],Ae.Zn=t[1]}function ae(){return Ae.labWhitePoint}var En=(...e)=>{e=w(e,"lab");let[t,o,r]=e,[n,s,i]=kn(t,o,r),[l,a,d]=wt(n,s,i);return[l,a,d,e.length>3?e[3]:1]},kn=(e,t,o)=>{let{kE:r,kK:n,kKE:s,Xn:i,Yn:l,Zn:a}=Q,d=(e+16)/116,m=.002*t+d,c=d-.005*o,p=m*m*m,g=c*c*c,h=p>r?p:(116*m-16)/n,y=e>s?Math.pow((e+16)/116,3):e/n,b=g>r?g:(116*c-16)/n,_=h*i,k=y*l,L=b*a;return[_,k,L]},yt=e=>{let t=Math.sign(e);return e=Math.abs(e),(e<=.0031308?e*12.92:1.055*Math.pow(e,1/2.4)-.055)*t},wt=(e,t,o)=>{let{MtxAdaptMa:r,MtxAdaptMaI:n,MtxXYZ2RGB:s,RefWhiteRGB:i,Xn:l,Yn:a,Zn:d}=Q,m=l*r.m00+a*r.m10+d*r.m20,c=l*r.m01+a*r.m11+d*r.m21,p=l*r.m02+a*r.m12+d*r.m22,g=i.X*r.m00+i.Y*r.m10+i.Z*r.m20,h=i.X*r.m01+i.Y*r.m11+i.Z*r.m21,y=i.X*r.m02+i.Y*r.m12+i.Z*r.m22,b=(e*r.m00+t*r.m10+o*r.m20)*(g/m),_=(e*r.m01+t*r.m11+o*r.m21)*(h/c),k=(e*r.m02+t*r.m12+o*r.m22)*(y/p),L=b*n.m00+_*n.m10+k*n.m20,T=b*n.m01+_*n.m11+k*n.m21,A=b*n.m02+_*n.m12+k*n.m22,O=yt(L*s.m00+T*s.m10+A*s.m20),u=yt(L*s.m01+T*s.m11+A*s.m21),v=yt(L*s.m02+T*s.m12+A*s.m22);return[O*255,u*255,v*255]},ve=En;var Cn=(...e)=>{let[t,o,r,...n]=w(e,"rgb"),[s,i,l]=xt(t,o,r),[a,d,m]=Mn(s,i,l);return[a,d,m,...n.length>0&&n[0]<1?[n[0]]:[]]};function Mn(e,t,o){let{Xn:r,Yn:n,Zn:s,kE:i,kK:l}=Q,a=e/r,d=t/n,m=o/s,c=a>i?Math.pow(a,1/3):(l*a+16)/116,p=d>i?Math.pow(d,1/3):(l*d+16)/116,g=m>i?Math.pow(m,1/3):(l*m+16)/116;return[116*p-16,500*(c-p),200*(p-g)]}function vt(e){let t=Math.sign(e);return e=Math.abs(e),(e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4))*t}var xt=(e,t,o)=>{e=vt(e/255),t=vt(t/255),o=vt(o/255);let{MtxRGB2XYZ:r,MtxAdaptMa:n,MtxAdaptMaI:s,Xn:i,Yn:l,Zn:a,As:d,Bs:m,Cs:c}=Q,p=e*r.m00+t*r.m10+o*r.m20,g=e*r.m01+t*r.m11+o*r.m21,h=e*r.m02+t*r.m12+o*r.m22,y=i*n.m00+l*n.m10+a*n.m20,b=i*n.m01+l*n.m11+a*n.m21,_=i*n.m02+l*n.m12+a*n.m22,k=p*n.m00+g*n.m10+h*n.m20,L=p*n.m01+g*n.m11+h*n.m21,T=p*n.m02+g*n.m12+h*n.m22;return k*=y/d,L*=b/m,T*=_/c,p=k*s.m00+L*s.m10+T*s.m20,g=k*s.m01+L*s.m11+T*s.m21,h=k*s.m02+L*s.m12+T*s.m22,[p,g,h]},xe=Cn;f.prototype.lab=function(){return xe(this._rgb)};var Sn=(...e)=>new f(...e,"lab");Object.assign(D,{lab:Sn,getLabWhitePoint:ae,setLabWhitePoint:U});R.format.lab=ve;R.autodetect.push({p:2,test:(...e)=>{if(e=w(e,"lab"),S(e)==="array"&&e.length===3)return"lab"}});f.prototype.darken=function(e=1){let t=this,o=t.lab();return o[0]-=Q.Kn*e,new f(o,"lab").alpha(t.alpha(),!0)};f.prototype.brighten=function(e=1){return this.darken(-e)};f.prototype.darker=f.prototype.darken;f.prototype.brighter=f.prototype.brighten;f.prototype.get=function(e){let[t,o]=e.split("."),r=this[t]();if(o){let n=t.indexOf(o)-(t.substr(0,2)==="ok"?2:0);if(n>-1)return r[n];throw new Error(`unknown channel ${o} in mode ${t}`)}else return r};var{pow:Ln}=Math,Rn=1e-7,Tn=20;f.prototype.luminance=function(e,t="rgb"){if(e!==void 0&&S(e)==="number"){if(e===0)return new f([0,0,0,this._rgb[3]],"rgb");if(e===1)return new f([255,255,255,this._rgb[3]],"rgb");let o=this.luminance(),r=Tn,n=(i,l)=>{let a=i.interpolate(l,.5,t),d=a.luminance();return Math.abs(e-d)<Rn||!r--?a:d>e?n(i,a):n(a,l)},s=(o>e?n(new f([0,0,0]),this):n(this,new f([255,255,255]))).rgb();return new f([...s,this._rgb[3]])}return Pn(...this._rgb.slice(0,3))};var Pn=(e,t,o)=>(e=Et(e),t=Et(t),o=Et(o),.2126*e+.7152*t+.0722*o),Et=e=>(e/=255,e<=.03928?e/12.92:Ln((e+.055)/1.055,2.4));var H={};var ee=(e,t,o=.5,...r)=>{let n=r[0]||"lrgb";if(!H[n]&&!r.length&&(n=Object.keys(H)[0]),!H[n])throw new Error(`interpolation mode ${n} is not defined`);return S(e)!=="object"&&(e=new f(e)),S(t)!=="object"&&(t=new f(t)),H[n](e,t,o).alpha(e.alpha()+o*(t.alpha()-e.alpha()))};f.prototype.mix=f.prototype.interpolate=function(e,t=.5,...o){return ee(this,e,t,...o)};f.prototype.premultiply=function(e=!1){let t=this._rgb,o=t[3];return e?(this._rgb=[t[0]*o,t[1]*o,t[2]*o,o],this):new f([t[0]*o,t[1]*o,t[2]*o,o],"rgb")};var{sin:Dn,cos:On}=Math,An=(...e)=>{let[t,o,r]=w(e,"lch");return isNaN(r)&&(r=0),r=r*Yt,[t,On(r)*o,Dn(r)*o]},et=An;var Nn=(...e)=>{e=w(e,"lch");let[t,o,r]=e,[n,s,i]=et(t,o,r),[l,a,d]=ve(n,s,i);return[l,a,d,e.length>3?e[3]:1]},Ee=Nn;var Hn=(...e)=>{let t=Ke(w(e,"hcl"));return Ee(...t)},Zt=Hn;var{sqrt:zn,atan2:Vn,round:Wn}=Math,In=(...e)=>{let[t,o,r]=w(e,"lab"),n=zn(o*o+r*r),s=(Vn(r,o)*Xt+360)%360;return Wn(n*1e4)===0&&(s=Number.NaN),[t,n,s]},tt=In;var jn=(...e)=>{let[t,o,r,...n]=w(e,"rgb"),[s,i,l]=xe(t,o,r),[a,d,m]=tt(s,i,l);return[a,d,m,...n.length>0&&n[0]<1?[n[0]]:[]]},Ne=jn;f.prototype.lch=function(){return Ne(this._rgb)};f.prototype.hcl=function(){return Ke(Ne(this._rgb))};var $n=(...e)=>new f(...e,"lch"),Fn=(...e)=>new f(...e,"hcl");Object.assign(D,{lch:$n,hcl:Fn});R.format.lch=Ee;R.format.hcl=Zt;["lch","hcl"].forEach(e=>R.autodetect.push({p:2,test:(...t)=>{if(t=w(t,e),S(t)==="array"&&t.length===3)return e}}));f.prototype.saturate=function(e=1){let t=this,o=t.lch();return o[1]+=Q.Kn*e,o[1]<0&&(o[1]=0),new f(o,"lch").alpha(t.alpha(),!0)};f.prototype.desaturate=function(e=1){return this.saturate(-e)};f.prototype.set=function(e,t,o=!1){let[r,n]=e.split("."),s=this[r]();if(n){let i=r.indexOf(n)-(r.substr(0,2)==="ok"?2:0);if(i>-1){if(S(t)=="string")switch(t.charAt(0)){case"+":s[i]+=+t;break;case"-":s[i]+=+t;break;case"*":s[i]*=+t.substr(1);break;case"/":s[i]/=+t.substr(1);break;default:s[i]=+t}else if(S(t)==="number")s[i]=t;else throw new Error("unsupported value for Color.set");let l=new f(s,r);return o?(this._rgb=l._rgb,this):l}throw new Error(`unknown channel ${n} in mode ${r}`)}else return s};f.prototype.tint=function(e=.5,...t){return ee(this,"white",e,...t)};f.prototype.shade=function(e=.5,...t){return ee(this,"black",e,...t)};var Gn=(e,t,o)=>{let r=e._rgb,n=t._rgb;return new f(r[0]+o*(n[0]-r[0]),r[1]+o*(n[1]-r[1]),r[2]+o*(n[2]-r[2]),"rgb")};H.rgb=Gn;var{sqrt:kt,pow:ke}=Math,Bn=(e,t,o)=>{let[r,n,s]=e._rgb,[i,l,a]=t._rgb;return new f(kt(ke(r,2)*(1-o)+ke(i,2)*o),kt(ke(n,2)*(1-o)+ke(l,2)*o),kt(ke(s,2)*(1-o)+ke(a,2)*o),"rgb")};H.lrgb=Bn;var Un=(e,t,o)=>{let r=e.lab(),n=t.lab();return new f(r[0]+o*(n[0]-r[0]),r[1]+o*(n[1]-r[1]),r[2]+o*(n[2]-r[2]),"lab")};H.lab=Un;var Y=(e,t,o,r)=>{let n,s;r==="hsl"?(n=e.hsl(),s=t.hsl()):r==="hsv"?(n=e.hsv(),s=t.hsv()):r==="hcg"?(n=e.hcg(),s=t.hcg()):r==="hsi"?(n=e.hsi(),s=t.hsi()):r==="lch"||r==="hcl"?(r="hcl",n=e.hcl(),s=t.hcl()):r==="oklch"&&(n=e.oklch().reverse(),s=t.oklch().reverse());let i,l,a,d,m,c;(r.substr(0,1)==="h"||r==="oklch")&&([i,a,m]=n,[l,d,c]=s);let p,g,h,y;return!isNaN(i)&&!isNaN(l)?(l>i&&l-i>180?y=l-(i+360):l<i&&i-l>180?y=l+360-i:y=l-i,g=i+o*y):isNaN(i)?isNaN(l)?g=Number.NaN:(g=l,(m==1||m==0)&&r!="hsv"&&(p=d)):(g=i,(c==1||c==0)&&r!="hsv"&&(p=a)),p===void 0&&(p=a+o*(d-a)),h=m+o*(c-m),r==="oklch"?new f([h,p,g],r):new f([g,p,h],r)};var Jt=(e,t,o)=>Y(e,t,o,"lch");H.lch=Jt;H.hcl=Jt;var Yn=e=>{if(S(e)=="number"&&e>=0&&e<=16777215){let t=e>>16,o=e>>8&255,r=e&255;return[t,o,r,1]}throw new Error("unknown num color: "+e)},Qt=Yn;var Xn=(...e)=>{let[t,o,r]=w(e,"rgb");return(t<<16)+(o<<8)+r},eo=Xn;f.prototype.num=function(){return eo(this._rgb)};var qn=(...e)=>new f(...e,"num");Object.assign(D,{num:qn});R.format.num=Qt;R.autodetect.push({p:5,test:(...e)=>{if(e.length===1&&S(e[0])==="number"&&e[0]>=0&&e[0]<=16777215)return"num"}});var Kn=(e,t,o)=>{let r=e.num(),n=t.num();return new f(r+o*(n-r),"num")};H.num=Kn;var{floor:Zn}=Math,Jn=(...e)=>{e=w(e,"hcg");let[t,o,r]=e,n,s,i;r=r*255;let l=o*255;if(o===0)n=s=i=r;else{t===360&&(t=0),t>360&&(t-=360),t<0&&(t+=360),t/=60;let a=Zn(t),d=t-a,m=r*(1-o),c=m+l*(1-d),p=m+l*d,g=m+l;switch(a){case 0:[n,s,i]=[g,p,m];break;case 1:[n,s,i]=[c,g,m];break;case 2:[n,s,i]=[m,g,p];break;case 3:[n,s,i]=[m,c,g];break;case 4:[n,s,i]=[p,m,g];break;case 5:[n,s,i]=[g,m,c];break}}return[n,s,i,e.length>3?e[3]:1]},to=Jn;var Qn=(...e)=>{let[t,o,r]=w(e,"rgb"),n=Ye(t,o,r),s=Xe(t,o,r),i=s-n,l=i*100/255,a=n/(255-i)*100,d;return i===0?d=Number.NaN:(t===s&&(d=(o-r)/i),o===s&&(d=2+(r-t)/i),r===s&&(d=4+(t-o)/i),d*=60,d<0&&(d+=360)),[d,l,a]},oo=Qn;f.prototype.hcg=function(){return oo(this._rgb)};var es=(...e)=>new f(...e,"hcg");D.hcg=es;R.format.hcg=to;R.autodetect.push({p:1,test:(...e)=>{if(e=w(e,"hcg"),S(e)==="array"&&e.length===3)return"hcg"}});var ts=(e,t,o)=>Y(e,t,o,"hcg");H.hcg=ts;var{cos:Ce}=Math,os=(...e)=>{e=w(e,"hsi");let[t,o,r]=e,n,s,i;return isNaN(t)&&(t=0),isNaN(o)&&(o=0),t>360&&(t-=360),t<0&&(t+=360),t/=360,t<1/3?(i=(1-o)/3,n=(1+o*Ce(B*t)/Ce(qe-B*t))/3,s=1-(i+n)):t<2/3?(t-=1/3,n=(1-o)/3,s=(1+o*Ce(B*t)/Ce(qe-B*t))/3,i=1-(n+s)):(t-=2/3,s=(1-o)/3,i=(1+o*Ce(B*t)/Ce(qe-B*t))/3,n=1-(s+i)),n=G(r*n*3),s=G(r*s*3),i=G(r*i*3),[n*255,s*255,i*255,e.length>3?e[3]:1]},ro=os;var{min:rs,sqrt:ns,acos:ss}=Math,is=(...e)=>{let[t,o,r]=w(e,"rgb");t/=255,o/=255,r/=255;let n,s=rs(t,o,r),i=(t+o+r)/3,l=i>0?1-s/i:0;return l===0?n=NaN:(n=(t-o+(t-r))/2,n/=ns((t-o)*(t-o)+(t-r)*(o-r)),n=ss(n),r>o&&(n=B-n),n/=B),[n*360,l,i]},no=is;f.prototype.hsi=function(){return no(this._rgb)};var ls=(...e)=>new f(...e,"hsi");D.hsi=ls;R.format.hsi=ro;R.autodetect.push({p:2,test:(...e)=>{if(e=w(e,"hsi"),S(e)==="array"&&e.length===3)return"hsi"}});var as=(e,t,o)=>Y(e,t,o,"hsi");H.hsi=as;var cs=(...e)=>{e=w(e,"hsl");let[t,o,r]=e,n,s,i;if(o===0)n=s=i=r*255;else{let l=[0,0,0],a=[0,0,0],d=r<.5?r*(1+o):r+o-r*o,m=2*r-d,c=t/360;l[0]=c+1/3,l[1]=c,l[2]=c-1/3;for(let p=0;p<3;p++)l[p]<0&&(l[p]+=1),l[p]>1&&(l[p]-=1),6*l[p]<1?a[p]=m+(d-m)*6*l[p]:2*l[p]<1?a[p]=d:3*l[p]<2?a[p]=m+(d-m)*(2/3-l[p])*6:a[p]=m;[n,s,i]=[a[0]*255,a[1]*255,a[2]*255]}return e.length>3?[n,s,i,e[3]]:[n,s,i,1]},He=cs;var ds=(...e)=>{e=w(e,"rgba");let[t,o,r]=e;t/=255,o/=255,r/=255;let n=Ye(t,o,r),s=Xe(t,o,r),i=(s+n)/2,l,a;return s===n?(l=0,a=Number.NaN):l=i<.5?(s-n)/(s+n):(s-n)/(2-s-n),t==s?a=(o-r)/(s-n):o==s?a=2+(r-t)/(s-n):r==s&&(a=4+(t-o)/(s-n)),a*=60,a<0&&(a+=360),e.length>3&&e[3]!==void 0?[a,l,i,e[3]]:[a,l,i]},ot=ds;f.prototype.hsl=function(){return ot(this._rgb)};var ms=(...e)=>new f(...e,"hsl");D.hsl=ms;R.format.hsl=He;R.autodetect.push({p:2,test:(...e)=>{if(e=w(e,"hsl"),S(e)==="array"&&e.length===3)return"hsl"}});var ps=(e,t,o)=>Y(e,t,o,"hsl");H.hsl=ps;var{floor:fs}=Math,us=(...e)=>{e=w(e,"hsv");let[t,o,r]=e,n,s,i;if(r*=255,o===0)n=s=i=r;else{t===360&&(t=0),t>360&&(t-=360),t<0&&(t+=360),t/=60;let l=fs(t),a=t-l,d=r*(1-o),m=r*(1-o*a),c=r*(1-o*(1-a));switch(l){case 0:[n,s,i]=[r,c,d];break;case 1:[n,s,i]=[m,r,d];break;case 2:[n,s,i]=[d,r,c];break;case 3:[n,s,i]=[d,m,r];break;case 4:[n,s,i]=[c,d,r];break;case 5:[n,s,i]=[r,d,m];break}}return[n,s,i,e.length>3?e[3]:1]},so=us;var{min:hs,max:gs}=Math,bs=(...e)=>{e=w(e,"rgb");let[t,o,r]=e,n=hs(t,o,r),s=gs(t,o,r),i=s-n,l,a,d;return d=s/255,s===0?(l=Number.NaN,a=0):(a=i/s,t===s&&(l=(o-r)/i),o===s&&(l=2+(r-t)/i),r===s&&(l=4+(t-o)/i),l*=60,l<0&&(l+=360)),[l,a,d]},io=bs;f.prototype.hsv=function(){return io(this._rgb)};var _s=(...e)=>new f(...e,"hsv");D.hsv=_s;R.format.hsv=so;R.autodetect.push({p:2,test:(...e)=>{if(e=w(e,"hsv"),S(e)==="array"&&e.length===3)return"hsv"}});var ys=(e,t,o)=>Y(e,t,o,"hsv");H.hsv=ys;function he(e,t){let o=e.length;Array.isArray(e[0])||(e=[e]),Array.isArray(t[0])||(t=t.map(i=>[i]));let r=t[0].length,n=t[0].map((i,l)=>t.map(a=>a[l])),s=e.map(i=>n.map(l=>Array.isArray(i)?i.reduce((a,d,m)=>a+d*(l[m]||0),0):l.reduce((a,d)=>a+d*i,0)));return o===1&&(s=s[0]),r===1?s.map(i=>i[0]):s}var ws=(...e)=>{e=w(e,"lab");let[t,o,r,...n]=e,[s,i,l]=vs([t,o,r]),[a,d,m]=wt(s,i,l);return[a,d,m,...n.length>0&&n[0]<1?[n[0]]:[]]};function vs(e){var t=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],o=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],r=he(o,e);return he(t,r.map(n=>n**3))}var Me=ws;var xs=(...e)=>{let[t,o,r,...n]=w(e,"rgb"),s=xt(t,o,r);return[...Es(s),...n.length>0&&n[0]<1?[n[0]]:[]]};function Es(e){let t=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],o=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],r=he(t,e);return he(o,r.map(n=>Math.cbrt(n)))}var Se=xs;f.prototype.oklab=function(){return Se(this._rgb)};var ks=(...e)=>new f(...e,"oklab");Object.assign(D,{oklab:ks});R.format.oklab=Me;R.autodetect.push({p:2,test:(...e)=>{if(e=w(e,"oklab"),S(e)==="array"&&e.length===3)return"oklab"}});var Cs=(e,t,o)=>{let r=e.oklab(),n=t.oklab();return new f(r[0]+o*(n[0]-r[0]),r[1]+o*(n[1]-r[1]),r[2]+o*(n[2]-r[2]),"oklab")};H.oklab=Cs;var Ms=(e,t,o)=>Y(e,t,o,"oklch");H.oklch=Ms;var{pow:Ct,sqrt:Mt,PI:St,cos:lo,sin:ao,atan2:Ss}=Math,co=(e,t="lrgb",o=null)=>{let r=e.length;o||(o=Array.from(new Array(r)).map(()=>1));let n=r/o.reduce(function(c,p){return c+p});if(o.forEach((c,p)=>{o[p]*=n}),e=e.map(c=>new f(c)),t==="lrgb")return Ls(e,o);let s=e.shift(),i=s.get(t),l=[],a=0,d=0;for(let c=0;c<i.length;c++)if(i[c]=(i[c]||0)*o[0],l.push(isNaN(i[c])?0:o[0]),t.charAt(c)==="h"&&!isNaN(i[c])){let p=i[c]/180*St;a+=lo(p)*o[0],d+=ao(p)*o[0]}let m=s.alpha()*o[0];e.forEach((c,p)=>{let g=c.get(t);m+=c.alpha()*o[p+1];for(let h=0;h<i.length;h++)if(!isNaN(g[h]))if(l[h]+=o[p+1],t.charAt(h)==="h"){let y=g[h]/180*St;a+=lo(y)*o[p+1],d+=ao(y)*o[p+1]}else i[h]+=g[h]*o[p+1]});for(let c=0;c<i.length;c++)if(t.charAt(c)==="h"){let p=Ss(d/l[c],a/l[c])/St*180;for(;p<0;)p+=360;for(;p>=360;)p-=360;i[c]=p}else i[c]=i[c]/l[c];return m/=r,new f(i,t).alpha(m>.99999?1:m,!0)},Ls=(e,t)=>{let o=e.length,r=[0,0,0,0];for(let n=0;n<e.length;n++){let s=e[n],i=t[n]/o,l=s._rgb;r[0]+=Ct(l[0],2)*i,r[1]+=Ct(l[1],2)*i,r[2]+=Ct(l[2],2)*i,r[3]+=l[3]*i}return r[0]=Mt(r[0]),r[1]=Mt(r[1]),r[2]=Mt(r[2]),r[3]>.9999999&&(r[3]=1),new f(ue(r))};var{pow:Rs}=Math;function ge(e){let t="rgb",o=D("#ccc"),r=0,n=[0,1],s=[],i=[0,0],l=!1,a=[],d=!1,m=0,c=1,p=!1,g={},h=!0,y=1,b=function(u){if(u=u||["#fff","#000"],u&&S(u)==="string"&&D.brewer&&D.brewer[u.toLowerCase()]&&(u=D.brewer[u.toLowerCase()]),S(u)==="array"){u.length===1&&(u=[u[0],u[0]]),u=u.slice(0);for(let v=0;v<u.length;v++)u[v]=D(u[v]);s.length=0;for(let v=0;v<u.length;v++)s.push(v/(u.length-1))}return A(),a=u},_=function(u){if(l!=null){let v=l.length-1,M=0;for(;M<v&&u>=l[M];)M++;return M-1}return 0},k=u=>u,L=u=>u,T=function(u,v){let M,E;if(v==null&&(v=!1),isNaN(u)||u===null)return o;v?E=u:l&&l.length>2?E=_(u)/(l.length-2):c!==m?E=(u-m)/(c-m):E=1,E=L(E),v||(E=k(E)),y!==1&&(E=Rs(E,y)),E=i[0]+E*(1-i[0]-i[1]),E=G(E,0,1);let P=Math.floor(E*1e4);if(h&&g[P])M=g[P];else{if(S(a)==="array")for(let x=0;x<s.length;x++){let C=s[x];if(E<=C){M=a[x];break}if(E>=C&&x===s.length-1){M=a[x];break}if(E>C&&E<s[x+1]){E=(E-C)/(s[x+1]-C),M=D.interpolate(a[x],a[x+1],E,t);break}}else S(a)==="function"&&(M=a(E));h&&(g[P]=M)}return M};var A=()=>g={};b(e);let O=function(u){let v=D(T(u));return d&&v[d]?v[d]():v};return O.classes=function(u){if(u!=null){if(S(u)==="array")l=u,n=[u[0],u[u.length-1]];else{let v=D.analyze(n);u===0?l=[v.min,v.max]:l=D.limits(v,"e",u)}return O}return l},O.domain=function(u){if(!arguments.length)return n;m=u[0],c=u[u.length-1],s=[];let v=a.length;if(u.length===v&&m!==c)for(let M of Array.from(u))s.push((M-m)/(c-m));else{for(let M=0;M<v;M++)s.push(M/(v-1));if(u.length>2){let M=u.map((P,x)=>x/(u.length-1)),E=u.map(P=>(P-m)/(c-m));E.every((P,x)=>M[x]===P)||(L=P=>{if(P<=0||P>=1)return P;let x=0;for(;P>=E[x+1];)x++;let C=(P-E[x])/(E[x+1]-E[x]);return M[x]+C*(M[x+1]-M[x])})}}return n=[m,c],O},O.mode=function(u){return arguments.length?(t=u,A(),O):t},O.range=function(u,v){return b(u,v),O},O.out=function(u){return d=u,O},O.spread=function(u){return arguments.length?(r=u,O):r},O.correctLightness=function(u){return u==null&&(u=!0),p=u,A(),p?k=function(v){let M=T(0,!0).lab()[0],E=T(1,!0).lab()[0],P=M>E,x=T(v,!0).lab()[0],C=M+(E-M)*v,N=x-C,z=0,J=1,te=20;for(;Math.abs(N)>.01&&te-- >0;)(function(){return P&&(N*=-1),N<0?(z=v,v+=(J-v)*.5):(J=v,v+=(z-v)*.5),x=T(v,!0).lab()[0],N=x-C})();return v}:k=v=>v,O},O.padding=function(u){return u!=null?(S(u)==="number"&&(u=[u,u]),i=u,O):i},O.colors=function(u,v){arguments.length<2&&(v="hex");let M=[];if(arguments.length===0)M=a.slice(0);else if(u===1)M=[O(.5)];else if(u>1){let E=n[0],P=n[1]-E;M=Ts(0,u,!1).map(x=>O(E+x/(u-1)*P))}else{e=[];let E=[];if(l&&l.length>2)for(let P=1,x=l.length,C=1<=x;C?P<x:P>x;C?P++:P--)E.push((l[P-1]+l[P])*.5);else E=n;M=E.map(P=>O(P))}return D[v]&&(M=M.map(E=>E[v]())),M},O.cache=function(u){return u!=null?(h=u,O):h},O.gamma=function(u){return u!=null?(y=u,O):y},O.nodata=function(u){return u!=null?(o=D(u),O):o},O}function Ts(e,t,o){let r=[],n=e<t,s=o?n?t+1:t-1:t;for(let i=e;n?i<s:i>s;n?i++:i--)r.push(i);return r}var Ps=function(e){let t=[1,1];for(let o=1;o<e;o++){let r=[1];for(let n=1;n<=t.length;n++)r[n]=(t[n]||0)+t[n-1];t=r}return t},Ds=function(e){let t,o,r,n;if(e=e.map(s=>new f(s)),e.length===2)[o,r]=e.map(s=>s.lab()),t=function(s){let i=[0,1,2].map(l=>o[l]+s*(r[l]-o[l]));return new f(i,"lab")};else if(e.length===3)[o,r,n]=e.map(s=>s.lab()),t=function(s){let i=[0,1,2].map(l=>(1-s)*(1-s)*o[l]+2*(1-s)*s*r[l]+s*s*n[l]);return new f(i,"lab")};else if(e.length===4){let s;[o,r,n,s]=e.map(i=>i.lab()),t=function(i){let l=[0,1,2].map(a=>(1-i)*(1-i)*(1-i)*o[a]+3*(1-i)*(1-i)*i*r[a]+3*(1-i)*i*i*n[a]+i*i*i*s[a]);return new f(l,"lab")}}else if(e.length>=5){let s,i,l;s=e.map(a=>a.lab()),l=e.length-1,i=Ps(l),t=function(a){let d=1-a,m=[0,1,2].map(c=>s.reduce((p,g,h)=>p+i[h]*d**(l-h)*a**h*g[c],0));return new f(m,"lab")}}else throw new RangeError("No point in running bezier with only one color.");return t},mo=e=>{let t=Ds(e);return t.scale=()=>ge(t),t};var{round:po}=Math;f.prototype.rgb=function(e=!0){return e===!1?this._rgb.slice(0,3):this._rgb.slice(0,3).map(po)};f.prototype.rgba=function(e=!0){return this._rgb.slice(0,4).map((t,o)=>o<3?e===!1?t:po(t):t)};var Os=(...e)=>new f(...e,"rgb");Object.assign(D,{rgb:Os});R.format.rgb=(...e)=>{let t=w(e,"rgba");return t[3]===void 0&&(t[3]=1),t};R.autodetect.push({p:3,test:(...e)=>{if(e=w(e,"rgba"),S(e)==="array"&&(e.length===3||e.length===4&&S(e[3])=="number"&&e[3]>=0&&e[3]<=1))return"rgb"}});var K=(e,t,o)=>{if(!K[o])throw new Error("unknown blend mode "+o);return K[o](e,t)},ce=e=>(t,o)=>{let r=D(o).rgb(),n=D(t).rgb();return D.rgb(e(r,n))},de=e=>(t,o)=>{let r=[];return r[0]=e(t[0],o[0]),r[1]=e(t[1],o[1]),r[2]=e(t[2],o[2]),r},As=e=>e,Ns=(e,t)=>e*t/255,Hs=(e,t)=>e>t?t:e,zs=(e,t)=>e>t?e:t,Vs=(e,t)=>255*(1-(1-e/255)*(1-t/255)),Ws=(e,t)=>t<128?2*e*t/255:255*(1-2*(1-e/255)*(1-t/255)),Is=(e,t)=>255*(1-(1-t/255)/(e/255)),js=(e,t)=>e===255?255:(e=255*(t/255)/(1-e/255),e>255?255:e);K.normal=ce(de(As));K.multiply=ce(de(Ns));K.screen=ce(de(Vs));K.overlay=ce(de(Ws));K.darken=ce(de(Hs));K.lighten=ce(de(zs));K.dodge=ce(de(js));K.burn=ce(de(Is));var fo=K;var{pow:$s,sin:Fs,cos:Gs}=Math;function uo(e=300,t=-1.5,o=1,r=1,n=[0,1]){let s=0,i;S(n)==="array"?i=n[1]-n[0]:(i=0,n=[n,n]);let l=function(a){let d=B*((e+120)/360+t*a),m=$s(n[0]+i*a,r),p=(s!==0?o[0]+a*s:o)*m*(1-m)/2,g=Gs(d),h=Fs(d),y=m+p*(-.14861*g+1.78277*h),b=m+p*(-.29227*g-.90649*h),_=m+p*(1.97294*g);return D(ue([y*255,b*255,_*255,1]))};return l.start=function(a){return a==null?e:(e=a,l)},l.rotations=function(a){return a==null?t:(t=a,l)},l.gamma=function(a){return a==null?r:(r=a,l)},l.hue=function(a){return a==null?o:(o=a,S(o)==="array"?(s=o[1]-o[0],s===0&&(o=o[1])):s=0,l)},l.lightness=function(a){return a==null?n:(S(a)==="array"?(n=a,i=a[1]-a[0]):(n=[a,a],i=0),l)},l.scale=()=>D.scale(l),l.hue(o),l}var Bs="0123456789abcdef",{floor:Us,random:Ys}=Math,ho=()=>{let e="#";for(let t=0;t<6;t++)e+=Bs.charAt(Us(Ys()*16));return new f(e,"hex")};var{log:go,pow:Xs,floor:qs,abs:Ks}=Math;function Lt(e,t=null){let o={min:Number.MAX_VALUE,max:Number.MAX_VALUE*-1,sum:0,values:[],count:0};return S(e)==="object"&&(e=Object.values(e)),e.forEach(r=>{t&&S(r)==="object"&&(r=r[t]),r!=null&&!isNaN(r)&&(o.values.push(r),o.sum+=r,r<o.min&&(o.min=r),r>o.max&&(o.max=r),o.count+=1)}),o.domain=[o.min,o.max],o.limits=(r,n)=>Rt(o,r,n),o}function Rt(e,t="equal",o=7){S(e)=="array"&&(e=Lt(e));let{min:r,max:n}=e,s=e.values.sort((l,a)=>l-a);if(o===1)return[r,n];let i=[];if(t.substr(0,1)==="c"&&(i.push(r),i.push(n)),t.substr(0,1)==="e"){i.push(r);for(let l=1;l<o;l++)i.push(r+l/o*(n-r));i.push(n)}else if(t.substr(0,1)==="l"){if(r<=0)throw new Error("Logarithmic scales are only possible for values > 0");let l=Math.LOG10E*go(r),a=Math.LOG10E*go(n);i.push(r);for(let d=1;d<o;d++)i.push(Xs(10,l+d/o*(a-l)));i.push(n)}else if(t.substr(0,1)==="q"){i.push(r);for(let l=1;l<o;l++){let a=(s.length-1)*l/o,d=qs(a);if(d===a)i.push(s[d]);else{let m=a-d;i.push(s[d]*(1-m)+s[d+1]*m)}}i.push(n)}else if(t.substr(0,1)==="k"){let l,a=s.length,d=new Array(a),m=new Array(o),c=!0,p=0,g=null;g=[],g.push(r);for(let b=1;b<o;b++)g.push(r+b/o*(n-r));for(g.push(n);c;){for(let _=0;_<o;_++)m[_]=0;for(let _=0;_<a;_++){let k=s[_],L=Number.MAX_VALUE,T;for(let A=0;A<o;A++){let O=Ks(g[A]-k);O<L&&(L=O,T=A),m[T]++,d[_]=T}}let b=new Array(o);for(let _=0;_<o;_++)b[_]=null;for(let _=0;_<a;_++)l=d[_],b[l]===null?b[l]=s[_]:b[l]+=s[_];for(let _=0;_<o;_++)b[_]*=1/m[_];c=!1;for(let _=0;_<o;_++)if(b[_]!==g[_]){c=!0;break}g=b,p++,p>200&&(c=!1)}let h={};for(let b=0;b<o;b++)h[b]=[];for(let b=0;b<a;b++)l=d[b],h[l].push(s[b]);let y=[];for(let b=0;b<o;b++)y.push(h[b][0]),y.push(h[b][h[b].length-1]);y=y.sort((b,_)=>b-_),i.push(y[0]);for(let b=1;b<y.length;b+=2){let _=y[b];!isNaN(_)&&i.indexOf(_)===-1&&i.push(_)}}return i}var bo=(e,t)=>{e=new f(e),t=new f(t);let o=e.luminance(),r=t.luminance();return o>r?(o+.05)/(r+.05):(r+.05)/(o+.05)};var _o=.027,Zs=5e-4,Js=.1,yo=1.14,rt=.022,wo=1.414,xo=(e,t)=>{e=new f(e),t=new f(t),e.alpha()<1&&(e=ee(t,e,e.alpha(),"rgb"));let o=vo(...e.rgb()),r=vo(...t.rgb()),n=o>=rt?o:o+Math.pow(rt-o,wo),s=r>=rt?r:r+Math.pow(rt-r,wo),i=Math.pow(s,.56)-Math.pow(n,.57),l=Math.pow(s,.65)-Math.pow(n,.62),a=Math.abs(s-n)<Zs?0:n<s?i*yo:l*yo;return(Math.abs(a)<Js?0:a>0?a-_o:a+_o)*100};function vo(e,t,o){return .2126729*Math.pow(e/255,2.4)+.7151522*Math.pow(t/255,2.4)+.072175*Math.pow(o/255,2.4)}var{sqrt:ne,pow:V,min:Qs,max:ei,atan2:Eo,abs:ko,cos:nt,sin:Co,exp:ti,PI:Mo}=Math;function So(e,t,o=1,r=1,n=1){var s=function(bt){return 360*bt/(2*Mo)},i=function(bt){return 2*Mo*bt/360};e=new f(e),t=new f(t);let[l,a,d]=Array.from(e.lab()),[m,c,p]=Array.from(t.lab()),g=(l+m)/2,h=ne(V(a,2)+V(d,2)),y=ne(V(c,2)+V(p,2)),b=(h+y)/2,_=.5*(1-ne(V(b,7)/(V(b,7)+V(25,7)))),k=a*(1+_),L=c*(1+_),T=ne(V(k,2)+V(d,2)),A=ne(V(L,2)+V(p,2)),O=(T+A)/2,u=s(Eo(d,k)),v=s(Eo(p,L)),M=u>=0?u:u+360,E=v>=0?v:v+360,P=ko(M-E)>180?(M+E+360)/2:(M+E)/2,x=1-.17*nt(i(P-30))+.24*nt(i(2*P))+.32*nt(i(3*P+6))-.2*nt(i(4*P-63)),C=E-M;C=ko(C)<=180?C:E<=M?C+360:C-360,C=2*ne(T*A)*Co(i(C)/2);let N=m-l,z=A-T,J=1+.015*V(g-50,2)/ne(20+V(g-50,2)),te=1+.045*O,De=1+.015*O*x,be=30*ti(-V((P-275)/25,2)),oe=-(2*ne(V(O,7)/(V(O,7)+V(25,7))))*Co(2*i(be)),re=ne(V(N/(o*J),2)+V(z/(r*te),2)+V(C/(n*De),2)+oe*(z/(r*te))*(C/(n*De)));return ei(0,Qs(100,re))}function Lo(e,t,o="lab"){e=new f(e),t=new f(t);let r=e.get(o),n=t.get(o),s=0;for(let i in r){let l=(r[i]||0)-(n[i]||0);s+=l*l}return Math.sqrt(s)}var Ro=(...e)=>{try{return new f(...e),!0}catch{return!1}};var To={cool(){return ge([D.hsl(180,1,.9),D.hsl(250,.7,.4)])},hot(){return ge(["#000","#f00","#ff0","#fff"],[0,.25,.75,1]).mode("rgb")}};var Tt={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},Do=Object.keys(Tt),Po=new Map(Do.map(e=>[e.toLowerCase(),e])),oi=typeof Proxy=="function"?new Proxy(Tt,{get(e,t){let o=t.toLowerCase();if(Po.has(o))return e[Po.get(o)]},getOwnPropertyNames(){return Object.getOwnPropertyNames(Do)}}):Tt,Oo=oi;var ri=(...e)=>{e=w(e,"cmyk");let[t,o,r,n]=e,s=e.length>4?e[4]:1;return n===1?[0,0,0,s]:[t>=1?0:255*(1-t)*(1-n),o>=1?0:255*(1-o)*(1-n),r>=1?0:255*(1-r)*(1-n),s]},Ao=ri;var{max:No}=Math,ni=(...e)=>{let[t,o,r]=w(e,"rgb");t=t/255,o=o/255,r=r/255;let n=1-No(t,No(o,r)),s=n<1?1/(1-n):0,i=(1-t-n)*s,l=(1-o-n)*s,a=(1-r-n)*s;return[i,l,a,n]},Ho=ni;f.prototype.cmyk=function(){return Ho(this._rgb)};var si=(...e)=>new f(...e,"cmyk");Object.assign(D,{cmyk:si});R.format.cmyk=Ao;R.autodetect.push({p:2,test:(...e)=>{if(e=w(e,"cmyk"),S(e)==="array"&&e.length===4)return"cmyk"}});var ii=(...e)=>{let t=w(e,"hsla"),o=F(e)||"lsa";return t[0]=I(t[0]||0)+"deg",t[1]=I(t[1]*100)+"%",t[2]=I(t[2]*100)+"%",o==="hsla"||t.length>3&&t[3]<1?(t[3]="/ "+(t.length>3?t[3]:1),o="hsla"):t.length=3,`${o.substr(0,3)}(${t.join(" ")})`},zo=ii;var li=(...e)=>{let t=w(e,"lab"),o=F(e)||"lab";return t[0]=I(t[0])+"%",t[1]=I(t[1]),t[2]=I(t[2]),o==="laba"||t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`lab(${t.join(" ")})`},Vo=li;var ai=(...e)=>{let t=w(e,"lch"),o=F(e)||"lab";return t[0]=I(t[0])+"%",t[1]=I(t[1]),t[2]=isNaN(t[2])?"none":I(t[2])+"deg",o==="lcha"||t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`lch(${t.join(" ")})`},Wo=ai;var ci=(...e)=>{let t=w(e,"lab");return t[0]=I(t[0]*100)+"%",t[1]=Oe(t[1]),t[2]=Oe(t[2]),t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`oklab(${t.join(" ")})`},Io=ci;var di=(...e)=>{let[t,o,r,...n]=w(e,"rgb"),[s,i,l]=Se(t,o,r),[a,d,m]=tt(s,i,l);return[a,d,m,...n.length>0&&n[0]<1?[n[0]]:[]]},st=di;var mi=(...e)=>{let t=w(e,"lch");return t[0]=I(t[0]*100)+"%",t[1]=Oe(t[1]),t[2]=isNaN(t[2])?"none":I(t[2])+"deg",t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`oklch(${t.join(" ")})`},jo=mi;var{round:Pt}=Math,pi=(...e)=>{let t=w(e,"rgba"),o=F(e)||"rgb";if(o.substr(0,3)==="hsl")return zo(ot(t),o);if(o.substr(0,3)==="lab"){let r=ae();U("d50");let n=Vo(xe(t),o);return U(r),n}if(o.substr(0,3)==="lch"){let r=ae();U("d50");let n=Wo(Ne(t),o);return U(r),n}return o.substr(0,5)==="oklab"?Io(Se(t)):o.substr(0,5)==="oklch"?jo(st(t)):(t[0]=Pt(t[0]),t[1]=Pt(t[1]),t[2]=Pt(t[2]),(o==="rgba"||t.length>3&&t[3]<1)&&(t[3]="/ "+(t.length>3?t[3]:1),o="rgba"),`${o.substr(0,3)}(${t.slice(0,o==="rgb"?3:4).join(" ")})`)},$o=pi;var fi=(...e)=>{e=w(e,"lch");let[t,o,r,...n]=e,[s,i,l]=et(t,o,r),[a,d,m]=Me(s,i,l);return[a,d,m,...n.length>0&&n[0]<1?[n[0]]:[]]},it=fi;var se=/((?:-?\d+)|(?:-?\d+(?:\.\d+)?)%|none)/.source,Z=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)%?)|none)/.source,lt=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)%)|none)/.source,X=/\s*/.source,Re=/\s+/.source,Dt=/\s*,\s*/.source,at=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)(?:deg)?)|none)/.source,Te=/\s*(?:\/\s*((?:[01]|[01]?\.\d+)|\d+(?:\.\d+)?%))?/.source,Fo=new RegExp("^rgba?\\("+X+[se,se,se].join(Re)+Te+"\\)$"),Go=new RegExp("^rgb\\("+X+[se,se,se].join(Dt)+X+"\\)$"),Bo=new RegExp("^rgba\\("+X+[se,se,se,Z].join(Dt)+X+"\\)$"),Uo=new RegExp("^hsla?\\("+X+[at,lt,lt].join(Re)+Te+"\\)$"),Yo=new RegExp("^hsl?\\("+X+[at,lt,lt].join(Dt)+X+"\\)$"),Xo=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,qo=new RegExp("^lab\\("+X+[Z,Z,Z].join(Re)+Te+"\\)$"),Ko=new RegExp("^lch\\("+X+[Z,Z,at].join(Re)+Te+"\\)$"),Zo=new RegExp("^oklab\\("+X+[Z,Z,Z].join(Re)+Te+"\\)$"),Jo=new RegExp("^oklch\\("+X+[Z,Z,at].join(Re)+Te+"\\)$"),{round:Qo}=Math,Le=e=>e.map((t,o)=>o<=2?G(Qo(t),0,255):t),W=(e,t=0,o=100,r=!1)=>(typeof e=="string"&&e.endsWith("%")&&(e=parseFloat(e.substring(0,e.length-1))/100,r?e=t+(e+1)*.5*(o-t):e=t+e*(o-t)),+e),j=(e,t)=>e==="none"?t:e,er=e=>{if(e=e.toLowerCase().trim(),e==="transparent")return[0,0,0,0];let t;if(R.format.named)try{return R.format.named(e)}catch{}if((t=e.match(Fo))||(t=e.match(Go))){let o=t.slice(1,4);for(let n=0;n<3;n++)o[n]=+W(j(o[n],0),0,255);o=Le(o);let r=t[4]!==void 0?+W(t[4],0,1):1;return o[3]=r,o}if(t=e.match(Bo)){let o=t.slice(1,5);for(let r=0;r<4;r++)o[r]=+W(o[r],0,255);return o}if((t=e.match(Uo))||(t=e.match(Yo))){let o=t.slice(1,4);o[0]=+j(o[0].replace("deg",""),0),o[1]=+W(j(o[1],0),0,100)*.01,o[2]=+W(j(o[2],0),0,100)*.01;let r=Le(He(o)),n=t[4]!==void 0?+W(t[4],0,1):1;return r[3]=n,r}if(t=e.match(Xo)){let o=t.slice(1,4);o[1]*=.01,o[2]*=.01;let r=He(o);for(let n=0;n<3;n++)r[n]=Qo(r[n]);return r[3]=+t[4],r}if(t=e.match(qo)){let o=t.slice(1,4);o[0]=W(j(o[0],0),0,100),o[1]=W(j(o[1],0),-125,125,!0),o[2]=W(j(o[2],0),-125,125,!0);let r=ae();U("d50");let n=Le(ve(o));U(r);let s=t[4]!==void 0?+W(t[4],0,1):1;return n[3]=s,n}if(t=e.match(Ko)){let o=t.slice(1,4);o[0]=W(o[0],0,100),o[1]=W(j(o[1],0),0,150,!1),o[2]=+j(o[2].replace("deg",""),0);let r=ae();U("d50");let n=Le(Ee(o));U(r);let s=t[4]!==void 0?+W(t[4],0,1):1;return n[3]=s,n}if(t=e.match(Zo)){let o=t.slice(1,4);o[0]=W(j(o[0],0),0,1),o[1]=W(j(o[1],0),-.4,.4,!0),o[2]=W(j(o[2],0),-.4,.4,!0);let r=Le(Me(o)),n=t[4]!==void 0?+W(t[4],0,1):1;return r[3]=n,r}if(t=e.match(Jo)){let o=t.slice(1,4);o[0]=W(j(o[0],0),0,1),o[1]=W(j(o[1],0),0,.4,!1),o[2]=+j(o[2].replace("deg",""),0);let r=Le(it(o)),n=t[4]!==void 0?+W(t[4],0,1):1;return r[3]=n,r}};er.test=e=>Fo.test(e)||Uo.test(e)||qo.test(e)||Ko.test(e)||Zo.test(e)||Jo.test(e)||Go.test(e)||Bo.test(e)||Yo.test(e)||Xo.test(e)||e==="transparent";var Ot=er;f.prototype.css=function(e){return $o(this._rgb,e)};var ui=(...e)=>new f(...e,"css");D.css=ui;R.format.css=Ot;R.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&S(e)==="string"&&Ot.test(e))return"css"}});R.format.gl=(...e)=>{let t=w(e,"rgba");return t[0]*=255,t[1]*=255,t[2]*=255,t};var hi=(...e)=>new f(...e,"gl");D.gl=hi;f.prototype.gl=function(){let e=this._rgb;return[e[0]/255,e[1]/255,e[2]/255,e[3]]};f.prototype.hex=function(e){return Qe(this._rgb,e)};var gi=(...e)=>new f(...e,"hex");D.hex=gi;R.format.hex=Ze;R.autodetect.push({p:4,test:(e,...t)=>{if(!t.length&&S(e)==="string"&&[3,4,5,6,7,8,9].indexOf(e.length)>=0)return"hex"}});var{log:ct}=Math,bi=e=>{let t=e/100,o,r,n;return t<66?(o=255,r=t<6?0:-155.25485562709179-.44596950469579133*(r=t-2)+104.49216199393888*ct(r),n=t<20?0:-254.76935184120902+.8274096064007395*(n=t-10)+115.67994401066147*ct(n)):(o=351.97690566805693+.114206453784165*(o=t-55)-40.25366309332127*ct(o),r=325.4494125711974+.07943456536662342*(r=t-50)-28.0852963507957*ct(r),n=255),[o,r,n,1]},dt=bi;var{round:_i}=Math,yi=(...e)=>{let t=w(e,"rgb"),o=t[0],r=t[2],n=1e3,s=4e4,i=.4,l;for(;s-n>i;){l=(s+n)*.5;let a=dt(l);a[2]/a[0]>=r/o?s=l:n=l}return _i(l)},tr=yi;f.prototype.temp=f.prototype.kelvin=f.prototype.temperature=function(){return tr(this._rgb)};var At=(...e)=>new f(...e,"temp");Object.assign(D,{temp:At,kelvin:At,temperature:At});R.format.temp=R.format.kelvin=R.format.temperature=dt;f.prototype.oklch=function(){return st(this._rgb)};var wi=(...e)=>new f(...e,"oklch");Object.assign(D,{oklch:wi});R.format.oklch=it;R.autodetect.push({p:2,test:(...e)=>{if(e=w(e,"oklch"),S(e)==="array"&&e.length===3)return"oklch"}});Object.assign(D,{analyze:Lt,average:co,bezier:mo,blend:fo,brewer:Oo,Color:f,colors:le,contrast:bo,contrastAPCA:xo,cubehelix:uo,deltaE:So,distance:Lo,input:R,interpolate:ee,limits:Rt,mix:ee,random:ho,scale:ge,scales:To,valid:Ro});var me=D;var Nt=class{format(t){return t?"true":"false"}},vi={float:{format:{style:"decimal",minimumFractionDigits:2,maximumFractionDigits:2}},datetime:{format:{dateStyle:"short",timeStyle:"medium"}},date:{format:{dateStyle:"short"}}},mt=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??vi[t]?.format;return new Intl.NumberFormat(navigator.languages,r)}create_boolean_formatter(t,o){return new Nt}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 rr=new mt,or=1;function nr(e,t){return rr.get(e,t)}function ze(e,t,o={},r=!1){if(t===null)return null;let n=r&&this._table_schema[e]||this._schema[e]||"string",s=o[e]||{};if((n==="integer"||n==="float")&&s?.number_fg_mode==="bar"){let l=Math.max(0,Math.min(or,Math.abs(t/s.fg_gradient)*or)),a=this._div_factory.get(),d=t>=0?"left":"right",m=(l*100).toFixed(2);return a.setAttribute("style",`width:calc(${m}% - 4px);position:absolute;${d}:2px;height:80%;top:10%;pointer-events:none;`),a}else if(s?.format==="link"&&n==="string"){let l=document.createElement("a");return l.setAttribute("href",t),l.setAttribute("target","_blank"),l.textContent=t,l}else if(s?.format==="bold"&&n==="string"){let l=document.createElement("b");return l.textContent=t,l}else if(s?.format==="italics"&&n==="string"){let l=document.createElement("i");return l.textContent=t,l}else{let l=rr.get(n,s);return l?l.format(t):t}}function*sr(e=[],t,o){let r=o[$]||{};for(let n of e){let s=["TOTAL",...n],i=s[s.length-1],l=s.slice(0,s.length-1).fill(""),a=ze.call(this,t[l.length-1],i,r,!0);a instanceof HTMLElement?l=l.concat(a):l=l.concat({toString:()=>a}),l.length=t.length+1,yield l}}function*ir(e=[],t,o){let r=o[$]||{};for(let n of e){let s=[""];for(let i in n)s.push(ze.call(this,t[i],n[i],r,!0));yield n}}function lr(e){let t,o,r,n,s;return async function(l,a,d,m,c){let p={},g={start_row:d,start_col:a,end_row:c,end_col:m,id:!0},h=null;if(m-a>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===a&&this._last_window?.end_col===m;let[v,M]=await Promise.all([this._view.to_columns_string(g),this._view.num_columns()]);h=M,p=JSON.parse(v);let P=Object.keys(p).filter(C=>C!=="__ROW_PATH__"&&C!=="__ID__"),x=!1;for(let C=0;C<P.length;C++)this._column_paths[g.start_col+C]!==P[C]&&(x=!0,this._column_paths[g.start_col+C]=P[C]);if(x){let[C,N]=await Promise.all([this._view.schema(),this._view.expression_schema()]);this._schema={...C,...N};for(let z=0;z<P.length;z++){let te=P[z].split("|")[this._config.split_by.length];this._is_editable[z+g.start_col]=!!this._table_schema[te],this._column_types[z+g.start_col]=this._schema[te]}}this._last_window=g,this._ids=p.__ID__||Array(c-d).fill(null).map((C,N)=>[N+d]),this._reverse_columns=this._column_paths.slice(a,m).reduce((C,N,z)=>(C.set(N,z),C),new Map),this._reverse_ids=this._ids?.reduce((C,N,z)=>(C.set(N?.join("|"),z),C),new Map)}else this._div_factory.clear(),h=await this._view.num_columns();let y=[],b=[],_=[],k=[],L=e.hasAttribute("settings");for(let v=a;v<Math.min(m,this._column_paths.length);++v){let M=this._column_paths[v],E=M.split("|"),P=p[M]||new Array(c-d).fill(null),x=Math.min(l[$]?.[E[this._config.split_by.length]]?.aggregate_depth||0,this._config.group_by.length);y.push(P.map((C,N)=>(p?.__ROW_PATH__?.[N]?.length??0)<x?"":ze.call(this,E[this._config.split_by.length],C,l[$]||{}))),b.push(P),L&&E.push(""),_.push(E),k.push(M)}m-a>0&&c-d>0&&(this.last_column_paths=o,this.last_meta=t,this.last_ids=r,this.last_reverse_ids=n,this.last_reverse_columns=s,o=k,t=b,r=this._ids,n=this._reverse_ids,s=this._reverse_columns);let T=p.__ROW_PATH__!==void 0,A=Array.from((T?sr:ir).call(this,p.__ROW_PATH__,this._config.group_by,l)),O=A[0]?.length;return{num_column_headers:this._config.split_by.length+(L?2:1),num_row_headers:O,num_rows:this._num_rows,num_columns:h,row_headers:A,column_headers:_,data:y,metadata:b,column_header_merge_depth:Math.max(0,this._config.split_by.length)}}}function Ht(e,t){return me.mix(e,`rgb(${t[0]},${t[1]},${t[2]})`,.5).hex()}function pe([e,t,o,r],n=[255,255,255]){function s(i,l){return((1-r)*(n[i]/255)+r*(l/255))*255}return[s(0,e),s(1,t),s(2,o)]}function fe([e,t,o]){return Math.sqrt(e*e*.299+t*t*.587+o*o*.114)>130?"#161616":"#ffffff"}function xi(e){let[t,o,r]=e.rgb(),[n,s,i]=e.set("hsl.h",(e.get("hsl.h")-15)%360).rgb(),[l,a,d]=e.set("hsl.h",(e.get("hsl.h")+15)%360).rgb();return`linear-gradient(to right top,rgb(${n},${s},${i}),rgb(${t},${o},${r}) 50%,rgb(${l},${a},${d}))`}function q(e){let t=me(e),o=xi(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 pt(e,t,o){let r=window.getComputedStyle(e).getPropertyValue(t).trim();return r.length>0?r:o}var zt=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 ft(e,t,o,r={}){let n=await o.get_config();if(this?.model?._config){let u=this.model._config,v=u.group_by.length!==n.group_by.length,M=(u.group_by.length===0||n.group_by.length===0)&&v;if(!v)for(let N in u.group_by)v||=n.group_by[N]!==u.group_by[N];let E=u.split_by.length!==n.split_by.length;if(E)for(let N in u.split_by)E||=n.split_by[N]!==u.split_by[N];let P=u.columns.length!==n.columns.length;if(P)for(let N in u.columns)P||=n.columns[N]!==u.columns[N];let x=u.filter.length!==n.filter.length;if(x)for(let N in u.filter)for(let z in n.filter[N])x||=n.filter[N][z]!==u.filter[N][z];let C=u.sort.length!==n.sort.length;if(C)for(let N in u.sort)for(let z in n.sort[N])C||=n.sort[N][z]!==u.sort[N][z];this._reset_scroll_top=v,this._reset_scroll_left=E,this._reset_select=v||E||x||C||P,this._reset_column_size=E||v||P||M}let[s,i,l,a,d]=await Promise.all([t.schema(),o.num_rows(),o.schema(),o.expression_schema(),this.parentElement.getEditPort()]),m=me(pt(e,"--plugin--background","#FFFFFF")).rgb(),c=q(pt(e,"--rt-pos-cell--color","#338DCD")),p=q(pt(e,"--rt-neg-cell--color","#FF5942")),g=q(Ht(c[0],m)),h=q(Ht(p[0],m)),y=q(pt(e,"--active--color","#ff0000")),b={...l,...a},_={...s,...a},k=[],L=[],T=[],A=this._edit_mode||"READ_ONLY";this._edit_button.dataset.editMode=A;let O=Object.assign(r,{_edit_port:d,_view:o,_table:t,_table_schema:_,_config:n,_num_rows:i,_schema:b,_ids:[],_plugin_background:m,_color:y,_pos_fg_color:c,_neg_fg_color:p,_pos_bg_color:g,_neg_bg_color:h,_column_paths:k,_column_types:T,_is_editable:L,_edit_mode:A,_selection_state:{selected_areas:[],dirty:!1},_row_header_types:n.group_by.map(u=>_[u]),_series_color_map:new Map,_series_color_seed:new Map,_div_factory:r._div_factory||new zt("div")});return e.setDataListener(lr(this.parentElement).bind(O,e),{virtual_mode:window.getComputedStyle(e).getPropertyValue("--datagrid-virtual-mode")?.trim()||"both"}),O}var Ve=["READ_ONLY","EDIT","SELECT_ROW","SELECT_COLUMN","SELECT_REGION"];function We(e){typeof e>"u"&&(e=Ve[(Ve.indexOf(this._edit_mode)+1)%Ve.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 Ie(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 je(e,t=!1){if(!this._initialized)return;t&&(this._cached_column_sizes=e);let o={},{group_by:r}=this.model._config,n=r?.length>0?r.length+1:0;for(let s of Object.keys(e))if(s==="__ROW_PATH__")o[n-1]=e[s];else{let i=this.model._column_paths.indexOf(s);o[i+n]=e[s]}this.regular_table.restoreColumnSizes(o)}function $e(){if(!this._initialized)return{};if(this._cached_column_sizes){let n=this._cached_column_sizes;return this._cached_column_sizes=void 0,n}let e=this.regular_table.saveColumnSizes(),{group_by:t}=this.model._config,o=t?.length>0?t.length+1:0,r={};for(let n of Object.keys(e)){let s=Number(n);if(e[s]!==void 0){let i=s-o;i>-1?r[this.model._column_paths[i]]=e[s]:i===-1&&(r.__ROW_PATH__=e[s])}}return r}function ar(e,t,o){let r=Array.from(e.children[0].children[0].children),n=r.length,s=t.hasAttribute("settings");if(n<=1?r[0]?.removeAttribute("id"):r.forEach((i,l)=>{let a=s?1:0,d=l===n-(a+1)?"psp-column-titles":l===n-a?"psp-column-edit-buttons":null;d?i.setAttribute("id",d):i.removeAttribute("id")}),t.classList.toggle("psp-menu-open",!!o),s&&n>=2){let i=Array.from(r[n-2].children),l=Array.from(r[n-1].children);if(i&&l){r.slice(0,n-2).forEach(a=>{Array.from(a.children).forEach(d=>{d.classList.toggle("psp-menu-open",!1)})});for(let a=0;a<i.length;a++){let d=i[a],m=l[a],c=d.textContent===o;if(d.classList.toggle("psp-menu-open",c),m.classList.toggle("psp-menu-open",c),this._config.columns.length>1)for(let p of e.querySelectorAll("td")){let g=e.getMeta(p);if(!g?.column_header)continue;let h=g.column_header[g.column_header.length-2]===o;p.classList.toggle("psp-menu-open",h)}}}}}function cr(e,t,o){let r=this._config.group_by.length,n=this._column_settings_selected_column;for(let{element:s,metadata:i}of e.cells){if(!i||i.type==="body"||i.type==="row_header")continue;let l=i.column_header?.[this._config.split_by.length],a=this._config.sort.find(b=>b[0]===l),d=i.type==="corner"&&i.row_header_x===r,m=typeof i.x>"u";d=d||i.x!==void 0&&(i.x+1)%this._config.columns.length===0,s.classList.toggle("psp-header-border",d),s.classList.toggle("psp-header-group",!1),s.classList.toggle("psp-header-leaf",!0),s.classList.toggle("psp-is-top",!1),s.classList.toggle("psp-header-corner",m),s.classList.toggle("psp-header-sort-asc",!o&&!!a&&a[1]==="asc"),s.classList.toggle("psp-header-sort-desc",!o&&!!a&&a[1]==="desc"),s.classList.toggle("psp-header-sort-col-asc",!o&&!!a&&a[1]==="col asc"),s.classList.toggle("psp-header-sort-col-desc",!o&&!!a&&a[1]==="col desc"),s.classList.toggle("psp-header-sort-abs-asc",!o&&!!a&&a[1]==="asc abs"),s.classList.toggle("psp-header-sort-abs-desc",!o&&!!a&&a[1]==="desc abs"),s.classList.toggle("psp-header-sort-abs-col-asc",!o&&!!a&&a[1]==="col asc abs"),s.classList.toggle("psp-header-sort-abs-col-desc",!o&&!!a&&a[1]==="col desc abs");let c=we(this,i),p=c==="integer"||c==="float",g=c==="string",h=c==="date",y=c==="datetime";if(s.classList.toggle("psp-align-right",p),s.classList.toggle("psp-align-left",!p),s.classList.toggle("psp-menu-enabled",(g||p||h||y)&&!m&&i.column_header_y===this._config.split_by.length+1),s.classList.toggle("psp-sort-enabled",(g||p||h||y)&&!m&&i.column_header_y===this._config.split_by.length),s.classList.toggle("psp-is-width-override",t.saveColumnSizes()[i.size_key]!==void 0),this._config.columns.length>1&&n){let b=i.column_header?.[i.column_header.length-2]===n;s.classList.toggle("psp-menu-open",b)}}}var Ei={desc:"asc",asc:void 0,"desc abs":"asc abs","asc abs":void 0},ki={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 dr(e,t,o,r){let n=e.getMeta(r);if(!n?.column_header)return;let s=n.column_header[this._config.split_by.length],i=o.ctrlKey||o.metaKet||o.altKey?Ci:Mi,l=o.shiftKey,a=i.call(this,`${s}`,l);await t.restore({sort:a})}function Ci(e,t){let o=[],r=!1;for(let n of this._config.sort){let[s,i]=n;if(s===e){r=!0;let l=mr.call(this,e,i,t);l&&o.push(l)}else o.push(n)}return r||o.push([e,t?"desc abs":"desc"]),o}function Mi(e,t){for(let[o,r]of this._config.sort)if(o===e){let n=mr.call(this,e,r,t);return n?[n]:[]}return[[e,t?"desc abs":"desc"]]}function mr(e,t,o){let n=this._config.split_by.length>0?ki:Ei,s=t?n[t]:"desc";if(s)return[e,s]}async function pr(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(n=>n!==void 0).length-2):t.shiftKey?this._view.set_depth(o.row_header.filter(n=>n!==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 fr(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")){pr.call(this,e,o);return}if(r.classList.contains("psp-menu-enabled")){let s=e.getMeta(r)?.column_header?.[this._config.split_by.length];await t.toggleColumnSettings(`${s}`)}else r.classList.contains("psp-sort-enabled")&&dr.call(this,e,t,o,r)}}}function ur(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 Vt(e,t,o){let r=e.getMeta(o);if(!r)return!1;let n=t._schema[t._column_paths[r.x]],s=o.textContent||"",i=t._ids[r.y-r.y0][0];if(n==="float"||n==="integer"){let a=parseFloat(s.replace(/,/g,""));if(isNaN(a))return!1;s=a}else if(n==="date"||n==="datetime"){let a=Date.parse(s);if(isNaN(a))return!1;s=a}else n==="boolean"&&(s=s==="true"?!1:s==="false"?!0:null);let l={__INDEX__:i,[t._column_paths[r.x]]:s};return t._table.update([l],{port_id:t._edit_port,format:null}),!0}function hr(e,t,o){let r=e.getMeta(o.target);if(r?.type==="body"||r?.type==="column_header"){let n=this._is_editable[r.x],s=we(this,r)==="boolean",i=o.target.classList.contains("psp-null");n&&s&&!i&&Vt(e,this,o.target)}}function gr(e,t,o){let r=o.get(t),n=t.getRootNode();if(r){for(let{element:s,metadata:i}of e)if(i.type==="body"&&i.x===r.x&&i.y===r.y){n.activeElement!==s&&s.focus({preventScroll:!0});return}document.activeElement!==document.body&&t.contains(n.activeElement)&&n.activeElement.blur()}}function br(e,t){let o=t.get(e);if(!o)return!1;let r=e.getRootNode(),n=e.children[0]?.children[1];if(n)for(let s of n.children)for(let i of s.children){let l=e.getMeta(i);if(l?.type==="body"&&l.x===o.x&&l.y===o.y)return r.activeElement!==i&&i.focus({preventScroll:!0}),!0}return document.activeElement!==document.body&&e.contains(r.activeElement)&&r.activeElement.blur(),!1}function Li(e){let t;return async function(...o){if(t){await t;return}let r;t=new Promise(s=>r=s);let n=await e.apply(this,o);return t=void 0,r(),n}}function _r(){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 Pe=Li(async function(e,t,o,r,n){let s=e.getMeta(o);if(!s||s.type!=="body")return;let i=this._column_paths.length,l=this._num_rows,a=t.get(e);if(!a)return;s.x+r<i&&0<=s.x+r&&(a.x=s.x+r),s.y+n<l&&0<=s.y+n&&(a.y=s.y+n);let d=Math.max(s.x0-10,0),m=Math.min(s.x0+10,i),c=Math.max(s.y0-5,0),p=Math.min(s.y0+10,l),g=s.x0+r,h=s.y0+n;for(;!br(e,t)&&g>=d&&g<m&&h>=c&&h<p;)await e.scrollToCell(g,h),t.set(e,a),g+=r,h+=n});function Ri(e,t,o){let r=t.getMeta(o);return r?.type==="body"&&r.y===e._num_rows-1}function yr(e,t,o,r){let n=e.getRootNode().activeElement;switch(r.target.classList.remove("psp-error"),r.key){case"Enter":r.preventDefault(),Ri(this,e,n)?(n.blur(),o.delete(e)):r.shiftKey?Pe.call(this,e,o,n,0,-1):Pe.call(this,e,o,n,0,1);break;case"ArrowLeft":_r.call(n)===0&&(r.preventDefault(),Pe.call(this,e,o,n,-1,0));break;case"ArrowUp":r.preventDefault(),Pe.call(this,e,o,n,0,-1);break;case"ArrowRight":_r.call(n)===(n.textContent?.length||0)&&(r.preventDefault(),Pe.call(this,e,o,n,1,0));break;case"ArrowDown":r.preventDefault(),Pe.call(this,e,o,n,0,1);break;default:}}function ut(e,t=!1){let o=this._config.group_by.length===0&&this._config.split_by.length===0,r=e.hasAttribute("selectable"),n=e.children[0],s=t||n?._edit_mode==="EDIT";return o&&!r&&s}function wr(e,t,o,r){if(this._edit_mode==="EDIT"){if(!ut.call(this,t))return;yr.call(this,e,t,o,r)}else console.debug(`Mode ${this._edit_mode} for "keydown" event not yet implemented`)}function vr(e,t,o){if(this._edit_mode==="EDIT"){if(!ut.call(this,t))return;hr.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 xr(e,t,o,r){if(ut.call(this,t)&&o.has(e)){let n=r.target;n.classList.remove("psp-error");let s=o.get(e);o.delete(e),s.content!==n.textContent&&(Vt(e,this,n)||(n.textContent=s.content||"",n.classList.add("psp-error"),n.focus()))}}function Er(e,t,o,r){let n=r.target,s=e.getMeta(n);if(s?.type==="body"){let i={x:s.x,y:s.y,content:n.textContent||void 0};o.set(e,i)}}async function Fe({_view:e,_config:t},o,r){let n=t.group_by,s=t.split_by,i=o>=0?o:0,l=i+1,a=await e.to_json({start_row:i,end_row:l}),m=a.map(_=>_.__ROW_PATH__)[0]||[],c=n.map((_,k)=>{let L=m[k];return L?[_,"==",L]:void 0}).filter(_=>_!==void 0),p=n.length>0?r+1:r,g=Object.keys(a[0])[p],h={row:a[0],column_names:[],config:{filter:[]}},y=[];if(g){let _=g.split("|");h.column_names=[_[s.length]],y=s.map((k,L)=>{let T=_[L];return T?[k,"==",T]:void 0}).filter(k=>k!==void 0).filter(([,,k])=>k!=="__ROW_PATH__")}let b=t.filter.concat(c).concat(y);return h.config={filter:b},h}async function kr(e,t,o,r){let n=e.getMeta(r.target);if(t.hasAttribute("selectable")&&!r.handled&&!r.shiftKey&&r.button===0&&(r.stopImmediatePropagation(),!!n&&(n.type==="body"||n.type==="row_header")&&n.y>=0)){let s=this._ids?.[n.y-n.y0],i=o.get(e),l=!!i&&i.reduce((g,h,y)=>g&&h===s[y],!0),a=!!i&&s.length===i.length&&l,d={selected:!a,row:{},config:{filter:[]}},{row:m,column_names:c,config:p}=await Fe(this,n.y,n.type==="body"?n.x:0);a?(o.delete(e),d={...d,row:m,config:{filter:structuredClone(this._config.filter)}}):(o.set(e,s),d={...d,row:m,column_names:c,config:p}),await e.draw({preserve_width:!0}),r.handled=!0,t.dispatchEvent(new CustomEvent("perspective-select",{bubbles:!0,composed:!0,detail:d}))}}async function Cr(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 Mr(e,t,o){let r=e.getMeta(o.target);if(!r||r.type!=="body")return;let{x:n,y:s}=r,{row:i,column_names:l,config:a}=await Fe(this,s,n);t.dispatchEvent(new CustomEvent("perspective-click",{bubbles:!0,composed:!0,detail:{row:i,column_names:l,config:a}}))}var Pi="mouse-selected-area",Sr=(e,t,{className:o=Pi,selected:r=[]}={})=>(e.model._selection_state={selected_areas:r,dirty:!0},t.addEventListener("mousedown",Di(e,t,o)),t.addEventListener("mouseover",Oi(e,t,o)),t.addEventListener("mouseup",Ai(e,t,o)),t.addStyleListener(()=>Ge(e,t,o)),t),Di=(e,t,o)=>r=>{let n=r;if(n.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 s=t.getMeta(n.target);if(s?.type==="body"&&s.x!==void 0&&s.y!==void 0){e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES={x:s.x,y:s.y},e.model._selection_state.old_selected_areas=e.model._selection_state.selected_areas,e.model._selection_state.selected_areas=[];let i={x0:s.x,x1:s.x,y0:s.y,y1:s.y};e.model._selection_state.potential_selection=i,Ge(e,t,o,e.model._selection_state.selected_areas.concat([i]));return}}e.model._selection_state.selected_areas=[]},Oi=(e,t,o)=>r=>{let n=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 s=t.getMeta(n.target);if(s?.type==="body"&&s.x!==void 0&&s.y!==void 0){let i={x0:Math.min(s.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),x1:Math.max(s.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),y0:Math.min(s.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y),y1:Math.max(s.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y)};e.model._selection_state.potential_selection=i,Ge(e,t,o,e.model._selection_state.selected_areas.concat([i]))}}},Ai=(e,t,o)=>r=>{let n=r;if(e.model._edit_mode==="SELECT_REGION"||e.model._edit_mode==="SELECT_ROW"||e.model._edit_mode==="SELECT_COLUMN"){let s=t.getMeta(n.target);if(!s)return;if((e.model._selection_state.old_selected_areas?.length??0)>0){let i=e.model._selection_state.old_selected_areas[0];if(i.x0===i.x1&&i.y0===i.y1&&s?.type==="body"&&i.x0===s.x&&i.y0===s.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,Ge(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&&s?.type==="body"&&s.x!==void 0&&s.y!==void 0){let i={x0:Math.min(s.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),x1:Math.max(s.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),y0:Math.min(s.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y),y1:Math.max(s.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y)};e.model._selection_state.selected_areas.push(i),Ge(e,t,o)}e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES={},e.model._selection_state.potential_selection=void 0}};function Ni(e,t,{x0:o,x1:r,y0:n,y1:s}){let i={},l=t.model._edit_mode;o!==void 0&&["SELECT_COLUMN","SELECT_REGION"].indexOf(l)>-1&&(i.start_col=o),r!==void 0&&["SELECT_COLUMN","SELECT_REGION"].indexOf(l)>-1&&(i.end_col=r+1),n!==void 0&&["SELECT_ROW","SELECT_REGION"].indexOf(l)>-1&&(i.start_row=n),s!==void 0&&["SELECT_ROW","SELECT_REGION"].indexOf(l)>-1&&(i.end_row=s+1),e.setSelection(i)}var Ge=(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 n=t.querySelectorAll("tbody td");if(r.length>0)Ni(e.parentElement,e,r[0]),Hi(e,t,r,o);else{e.parentElement.setSelection();for(let s of n)s.classList.remove(o)}}else if(e.model._selection_state.dirty){e.model._selection_state.dirty=!1;let n=t.querySelectorAll("tbody td");for(let s of n)s.classList.remove(o)}},Hi=(e,t,o,r)=>{if(e.model._edit_mode==="SELECT_REGION"&&o.length>0){let n=t.querySelectorAll("tbody td");for(let s of n){let i=t.getMeta(s);if(!i||i.type!=="body")continue;let l=!1;for(let{x0:a,x1:d,y0:m,y1:c}of o)a!==void 0&&m!==void 0&&d!==void 0&&c!==void 0&&a<=i.x&&i.x<=d&&m<=i.y&&i.y<=c&&(l=!0,e.model._selection_state.dirty=!0,s.classList.add(r));l||s.classList.remove(r)}}else if(e.model._edit_mode==="SELECT_ROW"&&o.length>0){let n=t.querySelectorAll("tbody td");for(let s of n){let i=t.getMeta(s);if(!i)continue;let l=!1;for(let{x0:a,x1:d,y0:m,y1:c}of o)a!==void 0&&m!==void 0&&d!==void 0&&c!==void 0&&i?.type==="body"&&m<=i.y&&i.y<=c&&(e.model._selection_state.dirty=!0,l=!0,s.classList.add(r));l||s.classList.remove(r)}}else if(e.model._edit_mode==="SELECT_COLUMN"&&o.length>0){let n=t.querySelectorAll("tbody td");for(let s of n){let i=t.getMeta(s);if(!i)continue;let l=!1;for(let{x0:a,x1:d,y0:m,y1:c}of o)a!==void 0&&m!==void 0&&d!==void 0&&c!==void 0&&i?.type==="body"&&a<=i.x&&i.x<=d&&(e.model._selection_state.dirty=!0,l=!0,s.classList.add(r));l||s.classList.remove(r)}}};function Lr(e,t,o){if(e.length===0)return;let r=this._column_settings_selected_column,n=e.length,s=o.hasAttribute("settings");if(n<=1?e[0]?.row.removeAttribute("id"):e.forEach(({row:a},d)=>{let m=s?1:0,c=d===n-(m+1)?"psp-column-titles":d===n-m?"psp-column-edit-buttons":null;c?a.setAttribute("id",c):a.removeAttribute("id")}),o.classList.toggle("psp-menu-open",!!r),s&&n>=2){let a=e[n-2],d=e[n-1];if(a&&d){e.slice(0,n-2).forEach(({cells:m})=>{m.forEach(({element:c})=>{c.classList.toggle("psp-menu-open",!1)})});for(let m=0;m<a.cells.length;m++){let c=a.cells[m]?.element,p=d.cells[m]?.element;if(!c||!p)continue;let g=c.textContent===r;c.classList.toggle("psp-menu-open",g),p.classList.toggle("psp-menu-open",g)}}}let i=this._config.split_by.length;if(i<e.length){let a=e[i];a&&this._styleColumnHeaderRow(a,t,!1)}let l=this._config.split_by.length+1;if(l<e.length){let a=e[l];a&&this._styleColumnHeaderRow(a,t,!0)}}function Rr(e,t){let o=this._config.group_by.length,r=[],n=new Set;for(let s=0;s<e.length;s++){let{row:i,cells:l}=e[s],a=new Set;for(let d=0;d<l.length;d++){let{element:m,metadata:c}=l[d];if(!c)continue;m.style.backgroundColor="";let p=c.type==="corner"&&o>0&&c.row_header_x===o||c.type==="column_header"&&c.x>=0;m.classList.toggle("psp-align-right",!1),m.classList.toggle("psp-align-left",!1),m.classList.toggle("psp-header-group",!0),m.classList.toggle("psp-header-leaf",!1),m.classList.toggle("psp-header-border",p),m.classList.toggle("psp-header-group-corner",c.type==="corner"),m.classList.toggle("psp-color-mode-bar",!1),m.classList.toggle("psp-header-sort-asc",!1),m.classList.toggle("psp-header-sort-desc",!1),m.classList.toggle("psp-header-sort-col-asc",!1),m.classList.toggle("psp-header-sort-col-desc",!1),m.classList.toggle("psp-sort-enabled",!1);let g=d;for(;r[s]&&r[s][g];++g);a.add(g);let h=m;for(let y=g;y<g+h.colSpan;++y)for(let b=s;b<s+h.rowSpan;++b)r[b]||(r[b]=[]),r[b][y]=!0;h.classList.toggle("psp-is-top",s===0||!n.has(g))}n=a}}function Tr(e,t,[,,,,,o,r],[,,,,,n,s],i){let l=this._ids?.[e.dy??0]?.join("|"),a=(i?(e.column_header??[]).slice(0,-1):e.column_header??[]).join("|");if(this.last_reverse_columns?.has(a)&&this.last_reverse_ids?.has(l)){let d=this.last_reverse_ids?.get(l),m=this.last_reverse_columns.get(a);this._is_old_viewport?m!==void 0&&d!==void 0&&this.last_meta?.[m]?.[d]!==void 0&&this.last_meta[m][d]>(e.user??0)?(t.style.setProperty("--pulse--background-color-start",n),t.style.setProperty("--pulse--background-color-end",s),t.style.animationName==="pulse_neg"?t.style.animation="pulse_neg2 0.5s linear":t.style.animation="pulse_neg 0.5s linear"):m!==void 0&&d!==void 0&&this.last_meta?.[m]?.[d]!==void 0&&this.last_meta[m][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 Pr(e,t,o,r){let n=(o.user??0)>0,s=(o.user??0)<0,i;e?.pos_bg_color!==void 0?i=e.pos_bg_color:i=this._pos_bg_color;let l;e?.neg_bg_color!==void 0?l=e.neg_bg_color:l=this._neg_bg_color;let a=n?i:s?l:["",this._plugin_background[0],this._plugin_background[1],this._plugin_background[2],"","",""];{let[p,g,h,y]=a;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=p;else if(e?.number_bg_mode==="gradient"){let b=Math.max(0,Math.min(1,Math.abs((o.user??0)/(e.bg_gradient??1)))),_=this._plugin_background,k=fe(pe([g,h,y,b],_));t.style.animation="",t.style.color=k,t.style.backgroundColor=`rgba(${g},${h},${y},${b})`}else e?.number_bg_mode==="pulse"?(Tr.call(this,o,t,i,l,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?n?e.pos_fg_color:s?e.neg_fg_color:["",this._plugin_background[0],this._plugin_background[1],this._plugin_background[2],"","",""]:n?this._pos_fg_color:s?this._neg_fg_color:["",this._plugin_background[0],this._plugin_background[1],this._plugin_background[2],"","",""],[m,,,,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 p=this._plugin_background,g=fe(pe([a[1],a[2],a[3],1],p));t.style.color=g}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=m)}function Dr(e,t,o){let r=o.column_header?.[this._config.split_by.length],n=e?.color!==void 0?e.color:this._color,[s,i,l,a]=n;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=s,t.style.backgroundColor="",e?.format==="link"&&t.children[0]&&(t.children[0].style.color=s);else if(e?.string_color_mode==="background"&&o.user!==null){let d=this._plugin_background,m=fe(pe([i,l,a,1],d));t.style.color=m,t.style.backgroundColor=s}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 A=this._series_color_seed.get(r)??0;d.set(o.user,A),this._series_color_seed.set(r,A+1)}let m=d.get(o.user)??0,[c,p,g]=me(s).hsl();c=c+m*150%360;let h=me(c,p,g,"hsl"),[y,b,_]=h.rgb(),k=h.hex(),L=this._plugin_background,T=fe(pe([y,b,_,1],L));t.style.color=T,t.style.backgroundColor=k}else t.style.backgroundColor="",t.style.color=""}function Or(e,t,o){let r=this._color,[n,s,i,l]=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=n,t.style.backgroundColor="";else if(e?.datetime_color_mode==="background"&&o.user!==null){let a=this._plugin_background,d=fe(pe([s,i,l,1],a));t.style.color=d,t.style.backgroundColor=n}else t.style.backgroundColor="",t.style.color=""}function Ar(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 Nr(e,t,o){let r=o.value!==void 0&&o.value!==null&&o.value?.toString()?.trim().length>0,n=(o.row_header_x??0)>=this._config.group_by.length,s=e.getMeta({dx:0,dy:(o.y??0)-(o.y0??0)+1}),i=s&&s.row_header&&typeof s.row_header[(o.row_header_x??0)+1]<"u";t.classList.toggle("psp-tree-label",r&&!n),t.classList.toggle("psp-tree-label-expand",r&&!n&&!i),t.classList.toggle("psp-tree-label-collapse",r&&!n&&i),t.classList.toggle("psp-tree-leaf",r&&n)}function Hr(e,t,o,r,n,s,i,l,a){let d=i.has(s),m=i.get(s);for(let{element:c,metadata:p,isHeader:g}of e){let h=p.column_header?.[this._config.split_by.length],y=we(this,p),b=h?t[h.toString()]:void 0,_=y==="integer"||y==="float";p._is_hidden_by_aggregate_depth=(L=>L===0||L===void 0?!1:L-1<Math.min(this._config.group_by.length,b?.aggregate_depth||0))(p.row_header?.filter(L=>L!==void 0)?.length),_?Pr.call(this,b,c,p,o):y==="boolean"?Ar.call(this,b,c,p):y==="string"?Dr.call(this,b,c,p):y==="date"||y==="datetime"?Or.call(this,b,c,p):(c.style.backgroundColor="",c.style.color=""),c.classList.toggle("psp-bool-type",y==="boolean"&&p.user!==null),c.classList.toggle("psp-null",p.value===null),c.classList.toggle("psp-align-right",!g&&_),c.classList.toggle("psp-align-left",g||!_),this._column_settings_selected_column?c.classList.toggle("psp-menu-open",h===this._column_settings_selected_column):c.classList.toggle("psp-menu-open",!1),c.classList.toggle("psp-color-mode-bar",b?.number_fg_mode==="bar"&&_),g&&Nr.call(this,s,c,p);let k=c.parentElement;if(k&&(k.dataset.y=String(p.y)),p.type!=="row_header"||p.row_header_x===p.row_header.length-1||p.row_header[p.row_header_x+1]===void 0?(c.dataset.y=String(p.y),p.type!=="row_header"?c.dataset.x=String(p.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 L=this._ids[(p.y??0)-(p.y0??0)],T=m.reduce((O,u,v)=>O&&u===L[v],!0),A=m;g&&p.type==="row_header"&&p.row_header_x!==void 0&&L[p.row_header_x]?(c.classList.toggle("psp-row-selected",!1),c.classList.toggle("psp-row-subselected",!1)):(c.classList.toggle("psp-row-selected",L.length===A.length&&T),c.classList.toggle("psp-row-subselected",L.length!==A.length&&T))}if(!g&&p.type==="body")if(n&&this._is_editable[p.x]){let T=p.column_header?.[this._config.split_by.length]?.toString();T&&y==="string"&&t[T]?.format==="link"?(c.toggleAttribute("contenteditable",!1),c.classList.toggle("boolean-editable",!1)):y==="boolean"?(c.toggleAttribute("contenteditable",!1),c.classList.toggle("boolean-editable",p.user!==null)):(n!==c.hasAttribute("contenteditable")&&c.toggleAttribute("contenteditable",n),c.classList.toggle("boolean-editable",!1))}else c.toggleAttribute("contenteditable",!1),c.classList.toggle("boolean-editable",!1)}}function zr(e,t,o=!1){let r=e._config.group_by.length===0&&e._config.split_by.length===0,n=t.hasAttribute("selectable"),s=t.children[0],i=o||s?.dataset?.editMode==="EDIT";return r&&!n&&i}function Vr(e,t,o){return function(n,s){let i=n[$]||{},l=s.hasAttribute("settings"),a=s.hasAttribute("selectable"),d=zr(this,s),m=zr(this,s,!0);e.classList.toggle("edit-mode-allowed",m);let c=[],p=[],g=n.children[0]?.children[1];if(g)for(let y of g.children)for(let b of y.children){let _=n.getMeta(b);if(_){let k=b.tagName==="TH";c.push({element:b,metadata:_,isHeader:k})}}let h=n.children[0]?.children[0];if(h)for(let y of h.children){let b={row:y,cells:[]};for(let _ of y.children){let k=n.getMeta(_);b.cells.push({element:_,metadata:k})}p.push(b)}this._applyBodyCellStyles(c,i,l,a,d,n,t,o,s),this._applyGroupHeaderStyles(p,n),this._applyColumnHeaderStyles(p,n,s),this._applyFocusStyle(c,n,o)}}function Wr(e){e._applyBodyCellStyles=Hr,e._applyGroupHeaderStyles=Rr,e._applyColumnHeaderStyles=Lr,e._applyFocusStyle=gr,e._styleColumnHeaderRow=cr}async function Ir(e){let t=this.parentElement,o=await t.getTable();if(this._initialized)await ft.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 ft.call(this,this.regular_table,o,e),!this.model)return;Sr(this,this.regular_table,{className:"psp-select-region"});let r=new WeakMap,n=new WeakMap;Wr(this.model),this.regular_table.addStyleListener(Vr(this,r,n).bind(this.model,this.regular_table,t)),this.regular_table.addEventListener("click",ur.bind(this.model,this.regular_table)),this.regular_table.addEventListener("mousedown",kr.bind(this.model,this.regular_table,t,r)),this.regular_table.addEventListener("psp-deselect-all",Cr.bind(this.model,this.regular_table,t,r)),this.regular_table.addEventListener("click",Mr.bind(this.model,this.regular_table,t)),this.regular_table.addEventListener("mousedown",fr.bind(this.model,this.regular_table,t)),this.regular_table.addEventListener("click",vr.bind(this.model,this.regular_table,t)),this.regular_table.addEventListener("focusin",Er.bind(this.model,this.regular_table,t,n)),this.regular_table.addEventListener("focusout",xr.bind(this.model,this.regular_table,t,n)),this.regular_table.addEventListener("keydown",wr.bind(this.model,this.regular_table,t,n)),t.addEventListener("perspective-toggle-column-settings",s=>{let i=s;if(this.isConnected){if(ar.call(this.model,this.regular_table,t,i.detail.column_name??void 0),!i.detail.open){this.model._column_settings_selected_column=void 0;return}this.model._column_settings_selected_column=i.detail.column_name??void 0}}),this._initialized=!0}}function jr(e,t){e=JSON.parse(JSON.stringify(e)),t=JSON.parse(JSON.stringify(t));let o={};if(e.columns)for(let[s,i]of Object.entries(e.columns))i.column_size_override!==void 0&&(o[s]=i.column_size_override,delete i.column_size_override);let r={};if(t)for(let[s,i]of Object.entries(t))r[s]={...i,pos_fg_color:i.pos_fg_color?q(i.pos_fg_color):void 0,neg_fg_color:i.neg_fg_color?q(i.neg_fg_color):void 0,pos_bg_color:i.pos_bg_color?q(i.pos_bg_color):void 0,neg_bg_color:i.neg_bg_color?q(i.neg_bg_color):void 0,color:i.color?q(i.color):void 0};"edit_mode"in e&&e.edit_mode&&(Ve.indexOf(e.edit_mode)!==-1?We.call(this,e.edit_mode):console.error("Unknown edit mode "+e.edit_mode)),"scroll_lock"in e&&Ie.call(this,e.scroll_lock);let n=this.regular_table;je.call(this,o,!0),n[$]=r}function $r(){if(this.regular_table){let e={columns:{},scroll_lock:!!this._is_scroll_lock,edit_mode:this._edit_mode},t=$e.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 Fr(e){if(this.parentElement&&await this.activate(e),!this.isConnected||this.offsetParent==null||!this.model)return;let t=$e.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),je.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 Wt(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 Gr='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 ht=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(Gr)),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 Ir.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 Wt.call(this,t,o)}async draw(t){return await Fr.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(),n=await r.to_columns(t),s=await r.column_paths(t),i=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(),l="";for(let a=0;a<i;a++){for(let d of s){let m=n[d],c=this.model._schema[d],p=this.regular_table[$],g=d.split("|").at(-1),h=nr(c,p?.[g]||{});h?l+=h.format(m[a])+" ":l+=m[a]+" "}l+=`
|
|
3
|
+
`}return l.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 $r.call(this)}async restore(t,o){return jr.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 Br=':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 Ur=new CSSStyleSheet;Ur.replaceSync(Br);var gt=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(Ur),this.shadowRoot.innerHTML=`
|
|
4
4
|
<div id="toolbar">
|
|
5
5
|
<span class="hover-target">
|
|
6
6
|
<span id="scroll_lock" class="button">
|
|
@@ -13,7 +13,7 @@ var _e=new WeakMap,It=!0,Yr=navigator.userAgent.toLowerCase().indexOf("firefox")
|
|
|
13
13
|
</span>
|
|
14
14
|
</span>
|
|
15
15
|
</div>
|
|
16
|
-
`;let t=this.parentElement,o=this.previousElementSibling;o._scroll_lock=this.shadowRoot.querySelector("#scroll_lock"),o._scroll_lock.addEventListener("click",()=>
|
|
16
|
+
`;let t=this.parentElement,o=this.previousElementSibling;o._scroll_lock=this.shadowRoot.querySelector("#scroll_lock"),o._scroll_lock.addEventListener("click",()=>Ie.call(o)),o._edit_button=this.shadowRoot.querySelector("#edit_mode"),o._edit_button.addEventListener("click",()=>{We.call(o),o.regular_table.draw(),t.dispatchEvent(new Event("perspective-config-update"))})}};async function Wi(){customElements.define("perspective-viewer-datagrid-toolbar",gt),customElements.define("perspective-viewer-datagrid",ht),await customElements.whenDefined("perspective-viewer"),customElements.get("perspective-viewer").registerPlugin("perspective-viewer-datagrid")}Wi();export{ht as HTMLPerspectiveViewerDatagridPluginElement,gt as HTMLPerspectiveViewerDatagridToolbarElement,$ as PRIVATE_PLUGIN_SYMBOL};
|
|
17
17
|
/*! Bundled license information:
|
|
18
18
|
|
|
19
19
|
chroma-js/src/utils/contrastAPCA.js:
|