@ninebone/table 0.0.810 → 0.0.812

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(E,R){typeof exports=="object"&&typeof module<"u"?R(require("@ninebone/util")):typeof define=="function"&&define.amd?define(["@ninebone/util"],R):(E=typeof globalThis<"u"?globalThis:E||self,R(E.NineboneUtil))})(this,function(E){"use strict";var ms=Object.defineProperty;var xs=E=>{throw TypeError(E)};var Rs=(E,R,S)=>R in E?ms(E,R,{enumerable:!0,configurable:!0,writable:!0,value:S}):E[R]=S;var h=(E,R)=>ms(E,"name",{value:R,configurable:!0});var C=(E,R,S)=>Rs(E,typeof R!="symbol"?R+"":R,S),gs=(E,R,S)=>R.has(E)||xs("Cannot "+S);var t=(E,R,S)=>(gs(E,R,"read from private field"),S?S.call(E):R.get(E)),d=(E,R,S)=>R.has(E)?xs("Cannot add the same private member more than once"):R instanceof WeakSet?R.add(E):R.set(E,S),p=(E,R,S,Z)=>(gs(E,R,"write to private field"),Z?Z.call(E,S):R.set(E,S),S),G=(E,R,S)=>(gs(E,R,"access private method"),S);var ws=(E,R,S,Z)=>({set _(kt){p(E,R,kt,S)},get _(){return t(E,R,Z)}});var U,J,T,st,nt,rt,te,ot,ee,it,at,wt,L,Lt,It,se,lt,q,ct,V,D,Q,ht,Mt,Xe,Ke,ne,re,Y,oe,Ht,$t,Nt,ie,ae,_t,vt,le,ce,_,X,K,Jt,vs,j,dt,de,fe,ft,bs,Ot,Dt,Wt,ut,zt,Ss,ue,gt,bt,Bt,Pt,ge,be,St,pe,ye,me,jt,O,xe,Ut,we,Vt,Rt,W,I,z,At,ve,tt,Se,pt,Yt,Re,Ae,Et,yt,qt,H,Xt,Ee,mt,qe,Te,M,Gt,v,os,is,as,ls,cs,Zt,xt,Tt,Ct,Ce,et,fs;const Ue=class Ue extends E.trace.constructor{constructor(){super(),this.init("nine-table","green")}};h(Ue,"Trace");let R=Ue;const S=new R,Ve=class Ve extends HTMLElement{constructor(){super();d(this,U);d(this,J,!1);d(this,T);d(this,st);d(this,nt);d(this,rt);d(this,te,h(()=>{if(!t(this,U))return;const e=t(this,U).querySelector(".ng-container-body .ng-part-body");e&&(p(this,rt,new ResizeObserver(()=>{this.refresh()})),t(this,rt).observe(e))},"#observeResize"));C(this,"refresh",h(()=>{if(!t(this,U)||!t(this,T)||t(this,J))return;const e=t(this,T).container,s=e.querySelector("table");if(!s)return;const r=t(this,T).track,i=t(this,T).thumb,o=t(this,U).querySelector(".ng-container-bottom"),a=e.clientWidth,c=s.scrollWidth;if(a!==0&&c>a)o&&(o.style.display="flex");else{o&&(o.style.display="none");return}const l=r.clientWidth;if(l<=0)return;const u=Math.max(Math.min(l*(a/c),l),20);i.style.width=`${u}px`;const f=e.scrollLeft,b=c-a;let g=0;b>0&&(g=parseInt(f/b*(l-u),10)),g<0&&(g=0);const y=l-u;g>y&&(g=y),i.style.left=`${g}px`,t(this,T).left.disabled=g===0,t(this,T).right.disabled=g>=y-1},"refresh"));d(this,ot,h(e=>{if(!t(this,T))return!1;const s=t(this,T).container,r=s.querySelector("table");if(!r)return!1;const i=t(this,T).track.getBoundingClientRect(),o=t(this,T).thumb.clientWidth;let a=e;a<0&&(a=0);const c=i.width-o;a>c&&(a=c),a=parseInt(a,10),t(this,T).thumb.style.left=`${a}px`,S.log("1111=========="),t(this,T).left.disabled=a===0,t(this,T).right.disabled=a>=c-1;const l=s.clientWidth,f=r.scrollWidth-l;return c>0&&f>0&&(s.scrollLeft=a/c*f),a>0&&a<c-1},"#thumbMoveTo"));d(this,ee,h(()=>{const e=h(r=>{clearInterval(t(this,st)),clearInterval(t(this,nt));const i=parseInt(t(this,T).thumb.style.left||0,10);t(this,ot).call(this,i+r),p(this,st,setInterval(()=>{clearInterval(t(this,st)),p(this,nt,setInterval(()=>{const o=parseInt(t(this,T).thumb.style.left||0,10);t(this,ot).call(this,o+r)||clearInterval(t(this,nt))},50))},500))},"delayScroll"),s=h(()=>{clearInterval(t(this,st)),clearInterval(t(this,nt))},"clearTimer");["mouseup","mouseleave","touchend"].forEach(r=>{t(this,T).left.addEventListener(r,s),t(this,T).right.addEventListener(r,s),t(this,T).track.addEventListener(r,s)}),t(this,T).left.addEventListener("mousedown",r=>{r.button===0&&e(-20)}),t(this,T).right.addEventListener("mousedown",r=>{r.button===0&&e(20)}),t(this,T).left.addEventListener("touchstart",()=>e(-20)),t(this,T).right.addEventListener("touchstart",()=>e(20)),t(this,T).track.addEventListener("mousedown",r=>{if(r.button!==0)return;r.preventDefault();const i=t(this,T).track.getBoundingClientRect(),o=t(this,T).thumb.clientWidth;t(this,ot).call(this,r.clientX-i.left-o/2)}),t(this,T).thumb.addEventListener("mousedown",r=>{if(r.button!==0)return;r.stopPropagation(),r.preventDefault(),p(this,J,!0),this.shiftX=r.clientX-t(this,T).thumb.getBoundingClientRect().left;const i=h(a=>{if(!t(this,J))return;const c=t(this,T).track.getBoundingClientRect();t(this,ot).call(this,a.clientX-c.left-this.shiftX)},"onMouseMove"),o=h(()=>{p(this,J,!1),s(),document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",o),this.refresh()},"onMouseUp");document.addEventListener("mousemove",i),document.addEventListener("mouseup",o)})},"#init"))}connectedCallback(){if(p(this,U,this.closest("nine-table-sheet")||this.getRootNode().host),!t(this,U))return;this.innerHTML=`
1
+ (function(E,R){typeof exports=="object"&&typeof module<"u"?R(require("@ninebone/util")):typeof define=="function"&&define.amd?define(["@ninebone/util"],R):(E=typeof globalThis<"u"?globalThis:E||self,R(E.NineboneUtil))})(this,function(E){"use strict";var ms=Object.defineProperty;var xs=E=>{throw TypeError(E)};var Rs=(E,R,v)=>R in E?ms(E,R,{enumerable:!0,configurable:!0,writable:!0,value:v}):E[R]=v;var h=(E,R)=>ms(E,"name",{value:R,configurable:!0});var C=(E,R,v)=>Rs(E,typeof R!="symbol"?R+"":R,v),gs=(E,R,v)=>R.has(E)||xs("Cannot "+v);var t=(E,R,v)=>(gs(E,R,"read from private field"),v?v.call(E):R.get(E)),d=(E,R,v)=>R.has(E)?xs("Cannot add the same private member more than once"):R instanceof WeakSet?R.add(E):R.set(E,v),y=(E,R,v,G)=>(gs(E,R,"write to private field"),G?G.call(E,v):R.set(E,v),v),K=(E,R,v)=>(gs(E,R,"access private method"),v);var ws=(E,R,v,G)=>({set _(Ct){y(E,R,Ct,v)},get _(){return t(E,R,G)}});var U,Z,T,et,st,nt,Qt,rt,te,ot,it,xt,L,kt,Lt,ee,at,q,lt,V,D,J,ct,It,Ye,Xe,se,Ke,ne,re,Mt,Ht,$t,oe,ie,Nt,wt,ae,le,_,Y,X,Zt,vs,j,ht,he,de,dt,bs,_t,Ot,Dt,ft,Wt,Ss,fe,ut,gt,zt,Bt,ue,ge,vt,be,pe,ye,Ft,O,me,jt,xe,Ut,St,W,I,z,Rt,we,Q,ve,bt,Vt,Se,Re,At,pt,Et,H,Yt,Ae,yt,Ee,qe,M,Kt,S,os,is,as,ls,cs,Gt,mt,qt,Tt,Te,tt,fs;const je=class je extends E.trace.constructor{constructor(){super(),this.init("nine-table","green")}};h(je,"Trace");let R=je;const v=new R,Ue=class Ue extends HTMLElement{constructor(){super();d(this,U);d(this,Z,!1);d(this,T);d(this,et);d(this,st);d(this,nt);d(this,Qt,h(()=>{if(!t(this,U))return;const e=t(this,U).querySelector(".ng-container-body .ng-part-body");e&&(y(this,nt,new ResizeObserver(()=>{this.refresh()})),t(this,nt).observe(e))},"#observeResize"));C(this,"refresh",h(()=>{if(!t(this,U)||!t(this,T)||t(this,Z))return;const e=t(this,T).container,s=e.querySelector("table");if(!s)return;const r=t(this,T).track,i=t(this,T).thumb,o=t(this,U).querySelector(".ng-container-bottom"),a=e.clientWidth,c=s.scrollWidth;if(a!==0&&c>a)o&&(o.style.display="flex");else{o&&(o.style.display="none");return}const l=r.clientWidth;if(l<=0)return;const g=Math.max(Math.min(l*(a/c),l),20);i.style.width=`${g}px`;const f=e.scrollLeft,b=c-a;let u=0;b>0&&(u=parseInt(f/b*(l-g),10)),u<0&&(u=0);const p=l-g;u>p&&(u=p),i.style.left=`${u}px`,t(this,T).left.disabled=u===0,t(this,T).right.disabled=u>=p-1},"refresh"));d(this,rt,h(e=>{if(!t(this,T))return!1;const s=t(this,T).container,r=s.querySelector("table");if(!r)return!1;const i=t(this,T).track.getBoundingClientRect(),o=t(this,T).thumb.clientWidth;let a=e;a<0&&(a=0);const c=i.width-o;a>c&&(a=c),a=parseInt(a,10),t(this,T).thumb.style.left=`${a}px`,v.log("1111=========="),t(this,T).left.disabled=a===0,t(this,T).right.disabled=a>=c-1;const l=s.clientWidth,f=r.scrollWidth-l;return c>0&&f>0&&(s.scrollLeft=a/c*f),a>0&&a<c-1},"#thumbMoveTo"));d(this,te,h(()=>{const e=h(r=>{clearInterval(t(this,et)),clearInterval(t(this,st));const i=parseInt(t(this,T).thumb.style.left||0,10);t(this,rt).call(this,i+r),y(this,et,setInterval(()=>{clearInterval(t(this,et)),y(this,st,setInterval(()=>{const o=parseInt(t(this,T).thumb.style.left||0,10);t(this,rt).call(this,o+r)||clearInterval(t(this,st))},50))},500))},"delayScroll"),s=h(()=>{clearInterval(t(this,et)),clearInterval(t(this,st))},"clearTimer");["mouseup","mouseleave","touchend"].forEach(r=>{t(this,T).left.addEventListener(r,s),t(this,T).right.addEventListener(r,s),t(this,T).track.addEventListener(r,s)}),t(this,T).left.addEventListener("mousedown",r=>{r.button===0&&e(-20)}),t(this,T).right.addEventListener("mousedown",r=>{r.button===0&&e(20)}),t(this,T).left.addEventListener("touchstart",()=>e(-20)),t(this,T).right.addEventListener("touchstart",()=>e(20)),t(this,T).track.addEventListener("mousedown",r=>{if(r.button!==0)return;r.preventDefault();const i=t(this,T).track.getBoundingClientRect(),o=t(this,T).thumb.clientWidth;t(this,rt).call(this,r.clientX-i.left-o/2)}),t(this,T).thumb.addEventListener("mousedown",r=>{if(r.button!==0)return;r.stopPropagation(),r.preventDefault(),y(this,Z,!0),this.shiftX=r.clientX-t(this,T).thumb.getBoundingClientRect().left;const i=h(a=>{if(!t(this,Z))return;const c=t(this,T).track.getBoundingClientRect();t(this,rt).call(this,a.clientX-c.left-this.shiftX)},"onMouseMove"),o=h(()=>{y(this,Z,!1),s(),document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",o),this.refresh()},"onMouseUp");document.addEventListener("mousemove",i),document.addEventListener("mouseup",o)})},"#init"))}connectedCallback(){if(y(this,U,this.closest("nine-table-sheet")||this.getRootNode().host),!t(this,U))return;this.innerHTML=`
2
2
  <style>
3
3
  nine-table-hscrollbar {
4
4
  display: flex;
@@ -60,7 +60,7 @@
60
60
  <button class='ng-scroll-left' disabled><div class='ng-scroll-icon'></div></button>
61
61
  <div class='ng-scroll-track'><div class='ng-scroll-thumb'></div></div>
62
62
  <button class='ng-scroll-right' disabled><div class='ng-scroll-icon'></div></button>
63
- `;const e=h(()=>{const s=t(this,U).querySelector(".ng-container-body .ng-part-body");if(!s){setTimeout(e,10);return}p(this,T,{container:s,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),left:this.querySelector(".ng-scroll-left"),right:this.querySelector(".ng-scroll-right")}),s.addEventListener("scroll",()=>{t(this,J)||this.refresh()}),t(this,ee).call(this),t(this,te).call(this),this.refresh()},"initWhenReady");e()}disconnectedCallback(){t(this,rt)&&t(this,rt).disconnect()}};U=new WeakMap,J=new WeakMap,T=new WeakMap,st=new WeakMap,nt=new WeakMap,rt=new WeakMap,te=new WeakMap,ot=new WeakMap,ee=new WeakMap,h(Ve,"NineTableHScrollBar");let Z=Ve;customElements.get("nine-table-hscrollbar")||customElements.define("nine-table-hscrollbar",Z);const Ye=class Ye extends HTMLElement{constructor(){super();d(this,it);d(this,at);d(this,wt,!1);d(this,L);d(this,Lt,0);d(this,It,0);C(this,"refresh",h(()=>{if(!t(this,it)||!t(this,L))return;const e=t(this,L).container,s=t(this,L).track,r=t(this,L).thumb,i=e.clientHeight,o=t(this,it).data.length,a=t(this,at).getRowHeight(),c=o*a;if(c<=i||o===0){this.style.display="none";return}else this.style.display="flex";const l=s.clientHeight;if(l<=0)return;const u=Math.max(Math.min(l*(i/c),l),20);r.style.height=`${u}px`;const f=e.scrollTop,b=Math.max(c-i,1);let g=0;b>0&&(g=f/b*(l-u));const y=l-u;g<0&&(g=0),g>y&&(g=y),r.style.top=`${g}px`,t(this,L).top.disabled=f<=0,t(this,L).bottom.disabled=f>=b-1},"refresh"));d(this,se,h(()=>{S.log("nine-table-vscrollbar.#init");const e=t(this,L).container,s=h(()=>{const i=(t(this,it).data.get()||[]).length,o=t(this,at).getRowHeight();return i*o},"getContentHeight");t(this,L).thumb.addEventListener("mousedown",r=>{if(r.button!==0)return;r.stopPropagation(),r.preventDefault(),p(this,wt,!0),p(this,Lt,r.clientY),p(this,It,e.scrollTop);const i=h(a=>{if(!t(this,wt))return;const c=t(this,L).track.getBoundingClientRect(),l=t(this,L).thumb.clientHeight,f=c.height-l,b=a.clientY-t(this,Lt),g=e.clientHeight,y=s(),x=Math.max(y-g,1);if(f>0&&x>0){const w=b/f*x;let m=t(this,It)+w;const k=Math.max(0,y-g);m<0&&(m=0),m>k&&(m=k),e.scrollTop=m}this.refresh()},"onMouseMove"),o=h(()=>{p(this,wt,!1),document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",o),this.refresh()},"onMouseUp");document.addEventListener("mousemove",i),document.addEventListener("mouseup",o)}),t(this,L).track.addEventListener("mousedown",r=>{if(r.button!==0||r.target===t(this,L).thumb)return;const i=t(this,L).track.getBoundingClientRect(),o=t(this,L).thumb.clientHeight,a=r.clientY-i.top-o/2,l=i.height-o,u=e.clientHeight,f=s(),b=Math.max(f-u,1);if(l>0&&b>0){const g=Math.max(0,Math.min(1,a/l));e.scrollTop=g*b}this.refresh()}),t(this,L).top.addEventListener("click",()=>{e.scrollTop-=40}),t(this,L).bottom.addEventListener("click",()=>{e.scrollTop+=40})},"#init"))}connectedCallback(){p(this,it,this.getRootNode().host),p(this,at,this.closest("nine-table-sheet")),this.innerHTML=`
63
+ `;const e=h(()=>{const s=t(this,U).querySelector(".ng-container-body .ng-part-body");if(!s){setTimeout(e,10);return}y(this,T,{container:s,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),left:this.querySelector(".ng-scroll-left"),right:this.querySelector(".ng-scroll-right")}),s.addEventListener("scroll",()=>{t(this,Z)||this.refresh()}),t(this,te).call(this),t(this,Qt).call(this),this.refresh()},"initWhenReady");e()}disconnectedCallback(){t(this,nt)&&t(this,nt).disconnect()}};U=new WeakMap,Z=new WeakMap,T=new WeakMap,et=new WeakMap,st=new WeakMap,nt=new WeakMap,Qt=new WeakMap,rt=new WeakMap,te=new WeakMap,h(Ue,"NineTableHScrollBar");let G=Ue;customElements.get("nine-table-hscrollbar")||customElements.define("nine-table-hscrollbar",G);const Ve=class Ve extends HTMLElement{constructor(){super();d(this,ot);d(this,it);d(this,xt,!1);d(this,L);d(this,kt,0);d(this,Lt,0);C(this,"refresh",h(()=>{if(!t(this,ot)||!t(this,L))return;const e=t(this,L).container,s=t(this,L).track,r=t(this,L).thumb,i=e.clientHeight,o=t(this,ot).data.length,a=t(this,it).getRowHeight(),c=o*a;if(c<=i||o===0){this.style.display="none";return}else this.style.display="flex";const l=s.clientHeight;if(l<=0)return;const g=Math.max(Math.min(l*(i/c),l),20);r.style.height=`${g}px`;const f=e.scrollTop,b=Math.max(c-i,1);let u=0;b>0&&(u=f/b*(l-g));const p=l-g;u<0&&(u=0),u>p&&(u=p),r.style.top=`${u}px`,t(this,L).top.disabled=f<=0,t(this,L).bottom.disabled=f>=b-1},"refresh"));d(this,ee,h(()=>{v.log("nine-table-vscrollbar.#init");const e=t(this,L).container,s=h(()=>{const i=(t(this,ot).data.get()||[]).length,o=t(this,it).getRowHeight();return i*o},"getContentHeight");t(this,L).thumb.addEventListener("mousedown",r=>{if(r.button!==0)return;r.stopPropagation(),r.preventDefault(),y(this,xt,!0),y(this,kt,r.clientY),y(this,Lt,e.scrollTop);const i=h(a=>{if(!t(this,xt))return;const c=t(this,L).track.getBoundingClientRect(),l=t(this,L).thumb.clientHeight,f=c.height-l,b=a.clientY-t(this,kt),u=e.clientHeight,p=s(),x=Math.max(p-u,1);if(f>0&&x>0){const w=b/f*x;let m=t(this,Lt)+w;const k=Math.max(0,p-u);m<0&&(m=0),m>k&&(m=k),e.scrollTop=m}this.refresh()},"onMouseMove"),o=h(()=>{y(this,xt,!1),document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",o),this.refresh()},"onMouseUp");document.addEventListener("mousemove",i),document.addEventListener("mouseup",o)}),t(this,L).track.addEventListener("mousedown",r=>{if(r.button!==0||r.target===t(this,L).thumb)return;const i=t(this,L).track.getBoundingClientRect(),o=t(this,L).thumb.clientHeight,a=r.clientY-i.top-o/2,l=i.height-o,g=e.clientHeight,f=s(),b=Math.max(f-g,1);if(l>0&&b>0){const u=Math.max(0,Math.min(1,a/l));e.scrollTop=u*b}this.refresh()}),t(this,L).top.addEventListener("click",()=>{e.scrollTop-=40}),t(this,L).bottom.addEventListener("click",()=>{e.scrollTop+=40})},"#init"))}connectedCallback(){y(this,ot,this.getRootNode().host),y(this,it,this.closest("nine-table-sheet")),this.innerHTML=`
64
64
  <style>
65
65
  nine-table-vscrollbar {
66
66
  display: flex;
@@ -123,7 +123,7 @@
123
123
  <button class='ng-scroll-top' disabled><div class='ng-scroll-icon'></div></button>
124
124
  <div class='ng-scroll-track'><div class='ng-scroll-thumb'></div></div>
125
125
  <button class='ng-scroll-bottom' disabled><div class='ng-scroll-icon'></div></button>
126
- `;const e=h(()=>{const s=t(this,at).querySelector(".ng-container-body .ng-part-body");if(!s){setTimeout(e,10);return}p(this,L,{container:s,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),top:this.querySelector(".ng-scroll-top"),bottom:this.querySelector(".ng-scroll-bottom")}),t(this,se).call(this),this.refresh()},"initWhenReady");e()}};it=new WeakMap,at=new WeakMap,wt=new WeakMap,L=new WeakMap,Lt=new WeakMap,It=new WeakMap,se=new WeakMap,h(Ye,"NineTableVScrollBar");let kt=Ye;customElements.get("nine-table-vscrollbar")||customElements.define("nine-table-vscrollbar",kt);const Ge=class Ge{constructor(n){d(this,lt);d(this,q);d(this,ct);d(this,V,new Map);d(this,D,null);d(this,Q,null);d(this,ht,0);d(this,Mt,40);d(this,Xe,!1);d(this,Ke,!1);d(this,ne,3);d(this,re,10);d(this,Y,0);C(this,"refresh",h(()=>{var e;S.log("rowManager.refresh");const n=t(this,q).querySelector(".ng-container-body .ng-part-body");n&&(t(this,Ht).call(this),t(this,$t).call(this),t(this,vt).call(this,n.scrollTop),(e=t(this,q).querySelector("nine-table-vscrollbar"))==null||e.refresh())},"refresh"));C(this,"initialize",h(()=>{S.log("rowManager.initialize"),p(this,ct,{scrollTables:t(this,q).querySelectorAll(".ng-part-body table"),firstTr:t(this,q).querySelector(".ng-container-body .ng-part-body tbody.bindable-tbody tr:not(.nodata)")}),p(this,D,null),t(this,V).clear(),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(o=>{const a=t(this,q).querySelector(o);if(!a)return;const c=a.querySelector(".ng-part-body table");if(!c)return;const l=c.querySelector("tbody.bindable-tbody");if(!l)return;const f=Array.from(l.querySelectorAll("tr")).map(b=>b.cloneNode(!0));t(this,V).set(o,f)});const n=t(this,q).querySelector(".ng-container-body .ng-part-body"),e=t(this,q).querySelector(".ng-container-left .ng-part-body"),s=t(this,q).querySelector(".ng-container-right .ng-part-body"),r=t(this,q).querySelector(".ng-container-body .ng-part-header"),i=t(this,q).querySelector(".ng-container-body .ng-part-footer");if(n){t(this,Ht).call(this),t(this,_t).call(this),t(this,$t).call(this),t(this,vt).call(this,n.scrollTop);let o=!1;p(this,Y,n.scrollLeft);const a=h(c=>{var b;if(o)return;o=!0;const l=c.scrollTop,u=c.scrollLeft;n&&n.scrollTop!==l&&(n.scrollTop=l),e&&e.scrollTop!==l&&(e.scrollTop=l),s&&s.scrollTop!==l&&(s.scrollTop=l),Math.abs(u-t(this,Y))>=t(this,re)?(r&&r.scrollLeft!==u&&(r.scrollLeft=u),i&&i.scrollLeft!==u&&(i.scrollLeft=u),p(this,Y,u)):r&&r.scrollLeft!==t(this,Y)&&(r.scrollLeft=t(this,Y),i&&(i.scrollLeft=t(this,Y))),t(this,vt).call(this,l),(b=t(this,q).querySelector("nine-table-vscrollbar"))==null||b.refresh(),o=!1},"handleContainerScroll");n==null||n.addEventListener("scroll",c=>{a(n)}),[e,s].forEach(c=>{c==null||c.addEventListener("scroll",l=>{if(o)return;o=!0;const u=c.scrollTop;n&&n.scrollTop!==u&&(n.scrollTop=u),o=!1})})}},"initialize"));d(this,oe,h((n,e)=>{S.log("rowManager.#renderRows");const s=t(this,V).get(e);if(!s||s.length===0)return;const r=n.querySelector(".ng-part-body tbody.bindable-tbody");if(!r)return;r.querySelectorAll("tr:not(.nodata)").forEach(a=>a.remove());const i=r.querySelector("tr.nodata"),o=document.createDocumentFragment();for(let a=0;a<t(this,Mt);a++)s.forEach(c=>{o.appendChild(c.cloneNode(!0))});i?i.before(o):r.appendChild(o),e===".ng-container-body"&&(t(this,ct).firstTr=r.querySelector("tr:not(.nodata)"))},"#renderRows"));d(this,Ht,h(()=>{if(t(this,D)!==null&&t(this,D)>0)return t(this,D);const n=t(this,q).querySelector(".ng-container-body .ng-part-body");S.log("rowManager.#measureAndCacheHeight");const e=t(this,V).get(".ng-container-body");if(!e||e.length===0)throw new Error("invalid dom");const s=n.querySelector("tbody.bindable-tbody");if(!s)throw new Error("invalid dom");s.querySelectorAll("tr:not(.nodata)").forEach(b=>b.remove());const r=s.querySelector("tr.nodata"),i=document.createDocumentFragment();e.forEach(b=>{i.appendChild(b.cloneNode(!0))}),r?r.before(i):s.appendChild(i);const o=t(this,q),a=o.style.display,c=o.style.visibility,l=o.style.position;(a==="none"||window.getComputedStyle(o).display==="none")&&(o.style.display="block",o.style.visibility="hidden",o.style.position="absolute");let u=0;const f=s.querySelectorAll("tr");return f.forEach(b=>{let g=b.offsetHeight||b.getBoundingClientRect().height;if(g===0){const y=window.getComputedStyle(b);g=parseFloat(y.height)||parseFloat(y.minHeight)||0}u+=g}),f.forEach(b=>b.remove()),o.style.display=a,o.style.visibility=c,o.style.position=l,u<=0?-1:(p(this,D,u),t(this,Nt).call(this),t(this,D))},"#measureAndCacheHeight"));d(this,$t,h(()=>{S.log("rowManager.#updateVirtualScrollHeight");const e=(t(this,lt).data.get()||[]).length,s=t(this,D),r=e*s;[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(i=>{const o=t(this,q).querySelector(i);if(!o)return;const a=o.querySelector(".ng-part-body .ng-virtual-spacer");a&&(a.style.height=`${r}px`)})},"#updateVirtualScrollHeight"));d(this,Nt,h(()=>{if(t(this,ht)>0&&t(this,D)>0){const n=Math.ceil(t(this,ht)/t(this,D));p(this,Mt,n+t(this,ne))}},"#updateRowCount"));d(this,ie,h(()=>{var a,c,l,u,f,b;const n=t(this,q).querySelector(".ng-container-left .ng-part-body table"),e=t(this,q).querySelector(".ng-container-body .ng-part-body table"),s=t(this,q).querySelector(".ng-container-right .ng-part-body table");if(e){const g=n?Array.from(n.querySelectorAll("tbody tr")):[],y=Array.from(e.querySelectorAll("tbody tr")),x=s?Array.from(s.querySelectorAll("tbody tr")):[],w=Math.max(g.length,y.length,x.length);for(let m=0;m<w;m++){const k=[((a=g[m])==null?void 0:a.getBoundingClientRect().height)||0,((c=y[m])==null?void 0:c.getBoundingClientRect().height)||0,((l=x[m])==null?void 0:l.getBoundingClientRect().height)||0],A=Math.max(...k);A>0&&(g[m]&&(g[m].style.height=`${A}px`),y[m]&&(y[m].style.height=`${A}px`),x[m]&&(x[m].style.height=`${A}px`))}}const r=t(this,q).querySelector(".ng-container-left .ng-part-footer table"),i=t(this,q).querySelector(".ng-container-body .ng-part-footer table"),o=t(this,q).querySelector(".ng-container-right .ng-part-footer table");if(i){const g=r?Array.from(r.querySelectorAll("tfoot tr")):[],y=Array.from(i.querySelectorAll("tfoot tr")),x=o?Array.from(o.querySelectorAll("tfoot tr")):[],w=Math.max(g.length,y.length,x.length);for(let m=0;m<w;m++){const k=[((u=g[m])==null?void 0:u.getBoundingClientRect().height)||0,((f=y[m])==null?void 0:f.getBoundingClientRect().height)||0,((b=x[m])==null?void 0:b.getBoundingClientRect().height)||0],A=Math.max(...k);A>0&&(g[m]&&(g[m].style.height=`${A}px`),y[m]&&(y[m].style.height=`${A}px`),x[m]&&(x[m].style.height=`${A}px`))}}},"#syncRowHeights"));d(this,ae,h(()=>{!t(this,q)||!(t(this,q)instanceof HTMLElement)||(p(this,Q,new ResizeObserver(n=>{for(const e of n){const s=e.target;if(!s.classList.contains("active"))continue;const r=e.contentRect.height;if(r>0){let i=0;const o=s.querySelector(".ng-part-header"),a=s.querySelector(".ng-part-footer");o&&(i+=o.offsetHeight),a&&(i+=a.offsetHeight);const c=Math.max(r-i,100);t(this,ht)!==c&&(p(this,ht,c),t(this,Nt).call(this),t(this,D)!==null&&(t(this,_t).call(this),this.refresh()))}}})),t(this,Q).observe(t(this,q)))},"#initResizeObserver"));d(this,_t,h(()=>{S.log("rowManager.#renderAllContainers"),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(n=>{const e=t(this,q).querySelector(n);e&&e.querySelector(".ng-part-body tbody.bindable-tbody")&&t(this,oe).call(this,e,n)}),t(this,ce).call(this),t(this,ie).call(this)},"#renderAllContainers"));d(this,vt,h(n=>{var f,b;const e=t(this,D);if(!e||e<=0)return;const s=t(this,lt).data.length;if(s===0)return;const r=((f=t(this,V).get(".ng-container-body"))==null?void 0:f.length)||1,i=t(this,q).querySelector(".ng-container-body .ng-part-body"),o=Math.max(0,s-Math.floor(i.clientHeight/e)),a=Math.min(o,Math.max(0,Math.floor(n/e)));let c=Math.floor(a*e);const l=t(this,ct).firstTr,u=l&&l.dataset.row!==void 0?parseInt(l.dataset.row,10):-1;(b=t(this,ct))==null||b.scrollTables.forEach(g=>{g.style.transform=`translate3d(0, ${c}px, 0)`}),u!==a&&[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(g=>{const y=t(this,q).querySelector(g);if(!y)return;const x=y.querySelector(".ng-part-body tbody.bindable-tbody");if(!x)return;Array.from(x.querySelectorAll("tr:not(.nodata)")).forEach((m,k)=>{const A=a+Math.floor(k/r);if(A>=s){m.style.display="none";return}const N=t(this,lt).data.get(A);m.style.display="",t(this,le).call(this,m,N,A)})})},"#handleScroll"));d(this,le,h((n,e,s)=>{n.dataset.row=s,n.data=e,Array.from(n.cells).forEach((r,i)=>{r.dataset.row=s;const o=Array.from(r.children).find(a=>a.tagName.toLowerCase().startsWith("cell-")||typeof a.refresh=="function");o&&typeof o.refresh=="function"&&o.refresh()})},"#bindRowData"));d(this,ce,h(()=>{var c,l,u;S.log("rowManager.#syncHeaderHeights");const n=t(this,q).querySelector(".ng-container-left .ng-part-header table"),e=t(this,q).querySelector(".ng-container-body .ng-part-header table"),s=t(this,q).querySelector(".ng-container-right .ng-part-header table");if(!e)return;const r=n?Array.from(n.querySelectorAll("tr")):[],i=Array.from(e.querySelectorAll("tr")),o=s?Array.from(s.querySelectorAll("tr")):[],a=Math.max(r.length,i.length,o.length);for(let f=0;f<a;f++){const b=[((c=r[f])==null?void 0:c.getBoundingClientRect().height)||0,((l=i[f])==null?void 0:l.getBoundingClientRect().height)||0,((u=o[f])==null?void 0:u.getBoundingClientRect().height)||0],g=Math.max(...b);g>0&&(r[f]&&(r[f].style.height=`${g}px`),i[f]&&(i[f].style.height=`${g}px`),o[f]&&(o[f].style.height=`${g}px`))}},"#syncHeaderHeights"));C(this,"destroy",h(()=>{t(this,Q)&&(t(this,Q).disconnect(),p(this,Q,null))},"destroy"));p(this,lt,n.getRootNode().host),p(this,q,n),t(this,ae).call(this)}getRowHeight(){return t(this,D)}templateLength(n=".ng-container-body"){var e;return((e=t(this,V).get(n))==null?void 0:e.length)||1}};lt=new WeakMap,q=new WeakMap,ct=new WeakMap,V=new WeakMap,D=new WeakMap,Q=new WeakMap,ht=new WeakMap,Mt=new WeakMap,Xe=new WeakMap,Ke=new WeakMap,ne=new WeakMap,re=new WeakMap,Y=new WeakMap,oe=new WeakMap,Ht=new WeakMap,$t=new WeakMap,Nt=new WeakMap,ie=new WeakMap,ae=new WeakMap,_t=new WeakMap,vt=new WeakMap,le=new WeakMap,ce=new WeakMap,h(Ge,"RowManager");let Le=Ge;const he=class he{static compileAll(n){return Array.isArray(n)?n.map(e=>he.compile(e)):[]}static compile(n){if(!n)return null;const e=h(a=>{a.querySelectorAll("tbody td, tbody th, tfoot td, tfoot th").forEach(l=>{const u=l.getAttribute("cell-type")||"renderer";if(l.children.length>0&&l.firstElementChild.tagName.includes("-"))return;let f=`cell-${u}`;const b=l.getAttribute("data-bind"),g=l.getAttribute("data-expr"),y=l.getAttribute("maxbyte"),x=l.getAttribute("type");let w=[];b&&w.push(`data-bind="${b}"`),g&&w.push(`data-expr="${g}"`),y&&w.push(`maxbyte="${y}"`),x&&w.push(`type="${x}"`),l.innerHTML=`<${f} ${w.join(" ")}></${f}>`}),a.querySelectorAll("tbody td, tfoot td").forEach(l=>{l.setAttribute("tabindex","0")})},"processCellTypes"),s=h(a=>{if(!a.querySelector("colgroup")){const c=a.querySelector("tbody tr")||a.querySelector("tr"),l=c?c.querySelectorAll("th, td").length:1,u=document.createElement("colgroup"),f=Math.max(Math.floor(a.clientWidth/l),100);for(let b=0;b<l;b++){const g=document.createElement("col");g.setAttribute("width",f),u.appendChild(g)}a.prepend(u)}if(!a.querySelector("thead")){const c=document.createElement("thead"),l=a.querySelector("colgroup");l?l.after(c):a.prepend(c)}a.classList.add("nine-table-element")},"ensureTableStructure"),r=h((a,c)=>{const l=Array.from(a.querySelectorAll(c+" tr")),u=Array.from(a.querySelectorAll(c+" th,"+c+" td")),f=l.length;if(f===0||u.length===0)return;let b=0;u.forEach(y=>{b+=y.colSpan||1});const g=Array.from(Array(f),()=>Array(b).fill(null));l.forEach(y=>{const x=y.sectionRowIndex;let w=0;Array.from(y.querySelectorAll("th,td")).forEach(m=>{for(let N=0;N<g[x].length;N++)if(g[x][N]===null){w=N;break}const k=m.rowSpan||1,A=m.colSpan||1;for(let N=0;N<k;N++)for(let B=0;B<A;B++)x+N<f&&w+B<b&&(g[x+N][w+B]=N===0&&B===0?"1":"0")})}),l.forEach(y=>{const x=y.sectionRowIndex;Array.from(y.querySelectorAll("th,td")).forEach(w=>{for(let m=0;m<g[x].length;m++)if(g[x][m]==="1"){w.dataset.col=m,g[x][m]="0";break}})})},"resetColIndex"),i=n.cloneNode(!0);return s(i),e(i),r(i,"thead"),r(i,"tbody"),r(i,"tfoot"),Array.from(i.querySelectorAll("colgroup col")).forEach((a,c)=>{const l=a.getAttribute("fixed");l&&i.querySelectorAll(`thead [data-col="${c}"], tbody [data-col="${c}"], tfoot [data-col="${c}"]`).forEach(u=>{u.setAttribute("fixed",l)})}),i}};h(he,"TableCompiler");let Ie=he;const Ze=class Ze{constructor(n){d(this,K);d(this,_);d(this,X,{startRow:-1,startCol:-1,endRow:-1,endCol:-1});C(this,"render",h(()=>{const{startRow:n,startCol:e,endRow:s,endCol:r}=t(this,X);S.log("🎨 [CellSelection.render] Rendering range ->",t(this,X));const i=t(this,_).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body");if(i.forEach(a=>{a.querySelectorAll(".selected, .selected-top, .selected-bottom, .selected-left, .selected-right").forEach(c=>{c.classList.remove("selected","selected-top","selected-bottom","selected-left","selected-right")})}),n<0||e<0){S.log("⚠️ [CellSelection.render] Range is invalid (< 0), skipping render.");return}let o=0;i.forEach(a=>{a.querySelectorAll("tbody tr").forEach(c=>{const{matrixRow:l}=G(this,K,Jt).call(this,c);l<0||c.querySelectorAll("td, th").forEach(u=>{const f=parseInt(u.dataset.col,10);if(isNaN(f))return;const b=parseInt(u.rowSpan||1,10),g=parseInt(u.colSpan||1,10),y=l+b-1,x=f+g-1;y>=n&&l<=s&&x>=e&&f<=r&&(o++,u.classList.add("selected"),S.log(u,n,e,s,r),l<=n&&u.classList.add("selected-top"),y>=s&&u.classList.add("selected-bottom"),f<=e&&u.classList.add("selected-left"),x>=r&&u.classList.add("selected-right"))})})}),S.log(`✨ [CellSelection.render] Total rendered cells marked: ${o}`)},"render"));p(this,_,n),G(this,K,vs).call(this),t(this,_).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body").forEach(s=>{s.addEventListener("scroll",()=>{t(this,X).startRow>=0&&t(this,X).startCol>=0&&this.render()})}),S.log("🎯 [CellSelection] Initialized")}setRange(n,e,s,r){S.log(`🔍 [CellSelection.setRange] Input -> startRow: ${n}, startCol: ${e}, endRow: ${s}, endCol: ${r}`);let i=Math.min(n,s),o=Math.max(n,s),a=Math.min(e,r),c=Math.max(e,r);const l=t(this,_).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body");let u=!0,f=0;for(;u&&f<5;)u=!1,f++,l.forEach(b=>{b.querySelectorAll("tbody tr").forEach(g=>{if(g.classList.contains("nodata"))return;const{matrixRow:y}=G(this,K,Jt).call(this,g);y<0||g.querySelectorAll("td, th").forEach(x=>{const w=parseInt(x.dataset.col,10);if(isNaN(w))return;const m=parseInt(x.rowSpan||1,10),k=parseInt(x.colSpan||1,10),A=y+m-1,N=w+k-1;if(A>=i&&y<=o&&N>=a&&w<=c){const P=Math.min(i,y),ke=Math.max(o,A),ps=Math.min(a,w),ys=Math.max(c,N);(P!==i||ke!==o||ps!==a||ys!==c)&&(i=P,o=ke,a=ps,c=ys,u=!0)}})})});p(this,X,{startRow:i,startCol:a,endRow:o,endCol:c}),S.log("📦 [CellSelection.setRange] Final Range ->",t(this,X)),this.render()}};_=new WeakMap,X=new WeakMap,K=new WeakSet,Jt=h(function(n){if(!n||n.classList.contains("nodata"))return{dataRow:-1,subRowIndex:-1,matrixRow:-1};const e=parseInt(n.dataset.row,10);if(isNaN(e))return{dataRow:-1,subRowIndex:-1,matrixRow:-1};const s=n.closest("tbody"),i=Array.from(s.querySelectorAll("tr:not(.nodata)")).filter(l=>parseInt(l.dataset.row,10)===e),o=i.indexOf(n),a=i.length>0?i.length:1,c=e*a+(o>=0?o:n.sectionRowIndex%a);return{dataRow:e,subRowIndex:o,matrixRow:c}},"#getMatrixRow"),vs=h(function(){const n=t(this,_).querySelector(".ng-container-top");if(!n){S.log("❌ [CellSelection] .ng-container-top not found!");return}n.addEventListener("mousedown",e=>{if(e.button!==0)return;const s=e.target.closest("td, th");if(!s||s.dataset.row===void 0||s.dataset.col===void 0||s.closest("tr").classList.contains("nodata"))return;t(this,_).style.userSelect="none",t(this,_).style.webkitUserSelect="none";const r=s.closest("tr"),{matrixRow:i}=G(this,K,Jt).call(this,r),o=parseInt(s.dataset.col,10);if(i<0){t(this,_).style.userSelect="",t(this,_).style.webkitUserSelect="";return}S.log(`🖱️ [MouseDown Success] startRow: ${i}, startCol: ${o}`),t(this,_).navigation.currentCell=s;let a=i,c=o;const l=h(f=>{const b=document.elementFromPoint(f.clientX,f.clientY);let g=b==null?void 0:b.closest("td, th");if(!g||!t(this,_).contains(g)){const m=t(this,_).querySelectorAll(".ng-part-body tbody tr:not(.nodata) td, .ng-part-body tbody tr:not(.nodata) th");for(const k of m){const A=k.getBoundingClientRect();if(f.clientX>=A.left&&f.clientX<=A.right&&f.clientY>=A.top&&f.clientY<=A.bottom){g=k;break}}}if(!g||g.dataset.row===void 0||g.dataset.col===void 0||g.closest("tr").classList.contains("nodata"))return;const y=g.closest("tr"),{matrixRow:x}=G(this,K,Jt).call(this,y),w=parseInt(g.dataset.col,10);x<0||a===x&&c===w||(a=x,c=w,this.setRange(i,o,x,w))},"onMouseMove"),u=h(()=>{S.log("🖱️ [MouseUp] Drag ended."),t(this,_).style.userSelect="",t(this,_).style.webkitUserSelect="",document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",u)},"onMouseUp");document.addEventListener("mousemove",l),document.addEventListener("mouseup",u)})},"#initEvents"),h(Ze,"CellSelection");let Me=Ze;const Je=class Je{constructor(n){d(this,ft);d(this,j);d(this,dt,null);d(this,de,-1);d(this,fe,-1);d(this,Ot,h(n=>{const e=[];return n.forEach(s=>e.push(...Array.from(s.querySelectorAll("td")))),e.length===0?null:(e.sort((s,r)=>parseInt(s.dataset.col,10)-parseInt(r.dataset.col,10)),e[e.length-1])},"#getMaxColCell"));d(this,Dt,h((n,e)=>{const s=t(this,ut).call(this,n);if(s.length===0)return e+1;let r=e+1;const i=[];s.forEach(o=>i.push(...Array.from(o.querySelectorAll("td")))),i.sort((o,a)=>parseInt(o.dataset.col,10)-parseInt(a.dataset.col,10));for(const o of i){const a=parseInt(o.dataset.col,10),c=parseInt(o.colSpan||1,10);if(e>=a&&e<a+c){r=a+c;break}}return r},"#getNextCol"));d(this,Wt,h((n,e)=>{const s=t(this,ut).call(this,n);if(s.length===0)return Math.max(0,e-1);let r=-1;const i=[];s.forEach(o=>i.push(...Array.from(o.querySelectorAll("td")))),i.sort((o,a)=>parseInt(o.dataset.col,10)-parseInt(a.dataset.col,10));for(const o of i){const a=parseInt(o.dataset.col,10);if(a<e)r=a;else break}return r},"#getPreviousCol"));d(this,ut,h(n=>{const e=t(this,j).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body"),s=[];return e.forEach(r=>{const i=Array.from(r.querySelectorAll("tbody tr:not(.nodata)"));for(const o of i){const a=parseInt(o.dataset.row,10),c=i.filter(y=>parseInt(y.dataset.row,10)===a),l=c.length>0?c.length:1,u=c.indexOf(o),f=a*l+(u>=0?u:0);if(f===n){s.push(o);break}const b=Array.from(o.querySelectorAll("td"));let g=!1;for(const y of b){const x=parseInt(y.rowSpan||1,10);if(x>1&&n>=f&&n<f+x){s.push(o),g=!0;break}}if(g)break}}),s},"#findTargetTrsByMatrix"));d(this,zt,h((n,e,s,r)=>{const i=t(this,j).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body"),o=r!==void 0?r:n*1+e;for(const a of i){const c=Array.from(a.querySelectorAll("tbody tr:not(.nodata)"));for(const l of c){const u=parseInt(l.dataset.row,10),f=c.filter(w=>parseInt(w.dataset.row,10)===u),b=f.length>0?f.length:1,g=f.indexOf(l),y=u*b+(g>=0?g:0),x=Array.from(l.querySelectorAll("td"));for(const w of x){const m=parseInt(w.dataset.col,10),k=parseInt(w.colSpan||1,10),A=parseInt(w.rowSpan||1,10);if(!isNaN(m)&&s>=m&&s<m+k&&o>=y&&o<y+A&&window.getComputedStyle(w).display!=="none")return w}}}return null},"#getNearElement"));p(this,j,n),G(this,ft,Ss).call(this),S.log("🎯 [CellNavigation] Initialized")}get currentCell(){return t(this,dt)}set currentCell(n){if(!n)return;p(this,dt,n),n.focus({preventScroll:!0});const e=parseInt(n.dataset.row,10),s=parseInt(n.dataset.col,10);if(!isNaN(e)&&!isNaN(s)){p(this,de,e),p(this,fe,s);const r=n.closest("tr"),i=r==null?void 0:r.closest("tbody");if(i){const a=Array.from(i.querySelectorAll("tr:not(.nodata)")).filter(f=>parseInt(f.dataset.row,10)===e),c=a.length>0?a.length:1,l=a.indexOf(r),u=e*c+(l>=0?l:0);t(this,j).selection.setRange(u,s,u,s)}}}moveCell(n){var m,k,A,N;if(!t(this,dt))return;const e=t(this,dt),s=e.closest("tr"),r=parseInt(e.dataset.row,10),i=parseInt(e.dataset.col,10),o=s==null?void 0:s.closest("tbody");if(!o)return;const c=Array.from(o.querySelectorAll("tr:not(.nodata)")).filter(B=>parseInt(B.dataset.row,10)===r),l=c.length>0?c.length:1,u=c.indexOf(s),f=r*l+(u>=0?u:0);let b=f,g=i;switch(n.code){case"Tab":if(n.preventDefault(),n.shiftKey){if(g=t(this,Wt).call(this,f,i),g<0&&f>0){b=f-1;const B=t(this,ut).call(this,b),P=t(this,Ot).call(this,B);g=P?parseInt(P.dataset.col,10):0}}else{g=t(this,Dt).call(this,f,i);const B=t(this,ut).call(this,f),P=t(this,Ot).call(this,B),ke=P?parseInt(P.dataset.col,10)+parseInt(P.colSpan||1,10):0;g>=ke&&(b=f+1,g=0)}break;case"ArrowRight":g=t(this,Dt).call(this,f,i);break;case"ArrowLeft":g=t(this,Wt).call(this,f,i);break;case"ArrowDown":n.preventDefault(),b=f+(e.rowSpan||1);break;case"ArrowUp":n.preventDefault(),b=Math.max(0,f-(e.rowSpan||1));break}const y=Math.floor(b/l),x=b%l;let w=t(this,zt).call(this,y,x,g,b);if(w)this.currentCell=w,G(this,ft,bs).call(this,w);else if(y!==r&&y>=0){const B=((k=(m=t(this,j)).getRowHeight)==null?void 0:k.call(m))||40;(N=(A=t(this,j)).scrollToY)==null||N.call(A,y*B),setTimeout(()=>{const P=t(this,zt).call(this,y,x,g,b);P&&(this.currentCell=P,G(this,ft,bs).call(this,P))},0)}}};j=new WeakMap,dt=new WeakMap,de=new WeakMap,fe=new WeakMap,ft=new WeakSet,bs=h(function(n){const e=t(this,j).querySelector(".ng-container-body .ng-part-body");if(!e)return;const s=n.getBoundingClientRect(),r=e.getBoundingClientRect();s.top<r.top?e.scrollTop-=r.top-s.top:s.bottom>r.bottom&&(e.scrollTop+=s.bottom-r.bottom),s.left<r.left?e.scrollLeft-=r.left-s.left:s.right>r.right&&(e.scrollLeft+=s.right-r.right)},"#ensureCellVisible"),Ot=new WeakMap,Dt=new WeakMap,Wt=new WeakMap,ut=new WeakMap,zt=new WeakMap,Ss=h(function(){t(this,j).addEventListener("keydown",n=>{["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(n.code)&&this.moveCell(n)})},"#initEvents"),h(Je,"CellNavigation");let He=Je;const Ft=class Ft extends HTMLElement{constructor(){super();d(this,ue);d(this,gt,null);d(this,bt);d(this,Bt);d(this,Pt);C(this,"invalidate",h(()=>{S.log("sheet.invalidate()"),t(this,bt).refresh()},"invalidate"));C(this,"generate",h(e=>{if(S.log("sheet.generate()"),!e)return;p(this,gt,Ie.compile(e)),t(this,ge).call(this),t(this,be).call(this);const s=this.querySelector(".ng-container-body .ng-part-header"),r=this.querySelector(".ng-container-body .ng-part-footer"),i=this.querySelector(".ng-nodata-overlay");s&&i&&(i.style.top=`${s.offsetHeight}px`),r&&i&&(i.style.bottom=`${r.offsetHeight}px`),t(this,bt).initialize(),setTimeout(()=>{var o;(o=this.querySelector("nine-table-hscrollbar"))==null||o.refresh()},0)},"generate"));d(this,ge,h(()=>{[{selector:".ng-container-body",type:null},{selector:".ng-container-left",type:"left"},{selector:".ng-container-right",type:"right"}].forEach(({selector:s,type:r})=>{var i,o,a;(i=this.querySelector(`${s} .ng-part-header`))==null||i.appendChild(t(this,St).call(this,t(this,gt),r,"header")),(o=this.querySelector(`${s} .ng-virtual-spacer`))==null||o.before(t(this,St).call(this,t(this,gt),r,"body")),(a=this.querySelector(`${s} .ng-part-footer`))==null||a.appendChild(t(this,St).call(this,t(this,gt),r,"footer"))})},"#renderSplitContainers"));d(this,be,h(()=>{["left","right","body"].forEach(e=>{const s=this.querySelector(`.ng-container-${e}`),r=s==null?void 0:s.querySelectorAll("table");if(!s||!r||r.length===0)return;let i=0;r[0].querySelectorAll("col").forEach(o=>{const a=parseInt(o.getAttribute("width"),10);isNaN(a)||(i+=a)}),e==="body"?(s.style.flex="1",r.forEach(o=>{o.style.width=`${i}px`,o.style.minWidth=`${i}px`})):(s.style.flex=`0 0 ${i}px`,s.style.width=`${i}px`,r.forEach(o=>{o.style.width=`${i}px`,o.style.minWidth=`${i}px`}))})},"#updateContainerWidths"));d(this,St,h((e,s,r)=>{const i=e.cloneNode(!0),o=i.querySelector("thead"),a=i.querySelector("tbody"),c=i.querySelector("tfoot");if(r==="header"){if(a&&a.remove(),c&&c.remove(),e.querySelector("tbody")){const u=document.createElement("tbody");u.className="fixed-tbody",i.appendChild(u)}}else r==="body"?(o&&o.remove(),c&&c.remove(),a&&(a.className="bindable-tbody")):r==="footer"&&(o&&o.remove(),a&&a.remove());return s==="left"?i.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(l=>{l.getAttribute("fixed")!=="left"&&l.remove()}):s==="right"?i.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(l=>{l.getAttribute("fixed")!=="right"&&l.remove()}):i.querySelectorAll("[fixed=left], [fixed=right]").forEach(l=>{l.remove()}),i},"#createSplitTable"));C(this,"getRowHeight",h(()=>t(this,bt).getRowHeight(),"getRowHeight"));C(this,"scrollToX",h(e=>{const s=this.querySelector(".ng-container-body .ng-part-body");s&&(s.scrollLeft=e)},"scrollToX"));C(this,"scrollToY",h(e=>{const s=this.querySelector(".ng-container-body .ng-part-body");s&&(s.scrollTop=e)},"scrollToY"));d(this,pe,h(()=>{t(this,ye).call(this),p(this,Bt,new Me(this)),p(this,Pt,new He(this))},"#init"));d(this,ye,h(()=>{const e=Ft.SCROLLBAR_SIZE;this.innerHTML=`
126
+ `;const e=h(()=>{const s=t(this,it).querySelector(".ng-container-body .ng-part-body");if(!s){setTimeout(e,10);return}y(this,L,{container:s,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),top:this.querySelector(".ng-scroll-top"),bottom:this.querySelector(".ng-scroll-bottom")}),t(this,ee).call(this),this.refresh()},"initWhenReady");e()}};ot=new WeakMap,it=new WeakMap,xt=new WeakMap,L=new WeakMap,kt=new WeakMap,Lt=new WeakMap,ee=new WeakMap,h(Ve,"NineTableVScrollBar");let Ct=Ve;customElements.get("nine-table-vscrollbar")||customElements.define("nine-table-vscrollbar",Ct);const Ge=class Ge{constructor(n){d(this,at);d(this,q);d(this,lt);d(this,V,new Map);d(this,D,null);d(this,J,null);d(this,ct,0);d(this,It,40);d(this,Ye,!1);d(this,Xe,!1);d(this,se,3);d(this,Ke,3);d(this,ne,0);C(this,"refresh",h(()=>{var e;v.log("rowManager.refresh");const n=t(this,q).querySelector(".ng-container-body .ng-part-body");n&&(t(this,Mt).call(this),t(this,Ht).call(this),t(this,wt).call(this,n.scrollTop),(e=t(this,q).querySelector("nine-table-vscrollbar"))==null||e.refresh())},"refresh"));C(this,"initialize",h(()=>{v.log("rowManager.initialize"),y(this,lt,{scrollTables:t(this,q).querySelectorAll(".ng-part-body table"),firstTr:t(this,q).querySelector(".ng-container-body .ng-part-body tbody.bindable-tbody tr:not(.nodata)")}),y(this,D,null),t(this,V).clear(),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(o=>{const a=t(this,q).querySelector(o);if(!a)return;const c=a.querySelector(".ng-part-body table");if(!c)return;const l=c.querySelector("tbody.bindable-tbody");if(!l)return;const f=Array.from(l.querySelectorAll("tr")).map(b=>b.cloneNode(!0));t(this,V).set(o,f)});const n=t(this,q).querySelector(".ng-container-body .ng-part-body"),e=t(this,q).querySelector(".ng-container-left .ng-part-body"),s=t(this,q).querySelector(".ng-container-right .ng-part-body"),r=t(this,q).querySelector(".ng-container-body .ng-part-header"),i=t(this,q).querySelector(".ng-container-body .ng-part-footer");if(n){t(this,Mt).call(this),t(this,Nt).call(this),t(this,Ht).call(this),t(this,wt).call(this,n.scrollTop);let o=!1;y(this,ne,n.scrollLeft);const a=h(c=>{var f;if(o)return;o=!0;const l=c.scrollTop,g=c.scrollLeft;n&&n.scrollTop!==l&&(n.scrollTop=l),e&&e.scrollTop!==l&&(e.scrollTop=l),s&&s.scrollTop!==l&&(s.scrollTop=l),r&&r.scrollLeft!==g&&(r.scrollLeft=g),i&&i.scrollLeft!==g&&(i.scrollLeft=g),t(this,wt).call(this,l),(f=t(this,q).querySelector("nine-table-vscrollbar"))==null||f.refresh(),o=!1},"handleContainerScroll");n==null||n.addEventListener("scroll",c=>{a(n)}),[e,s].forEach(c=>{c==null||c.addEventListener("scroll",l=>{if(o)return;o=!0;const g=c.scrollTop;n&&n.scrollTop!==g&&(n.scrollTop=g),o=!1})})}},"initialize"));d(this,re,h((n,e)=>{v.log("rowManager.#renderRows");const s=t(this,V).get(e);if(!s||s.length===0)return;const r=n.querySelector(".ng-part-body tbody.bindable-tbody");if(!r)return;r.querySelectorAll("tr:not(.nodata)").forEach(a=>a.remove());const i=r.querySelector("tr.nodata"),o=document.createDocumentFragment();for(let a=0;a<t(this,It);a++)s.forEach(c=>{o.appendChild(c.cloneNode(!0))});i?i.before(o):r.appendChild(o),e===".ng-container-body"&&(t(this,lt).firstTr=r.querySelector("tr:not(.nodata)"))},"#renderRows"));d(this,Mt,h(()=>{if(t(this,D)!==null&&t(this,D)>0)return t(this,D);const n=t(this,q).querySelector(".ng-container-body .ng-part-body");v.log("rowManager.#measureAndCacheHeight");const e=t(this,V).get(".ng-container-body");if(!e||e.length===0)throw new Error("invalid dom");const s=n.querySelector("tbody.bindable-tbody");if(!s)throw new Error("invalid dom");s.querySelectorAll("tr:not(.nodata)").forEach(b=>b.remove());const r=s.querySelector("tr.nodata"),i=document.createDocumentFragment();e.forEach(b=>{i.appendChild(b.cloneNode(!0))}),r?r.before(i):s.appendChild(i);const o=t(this,q),a=o.style.display,c=o.style.visibility,l=o.style.position;(a==="none"||window.getComputedStyle(o).display==="none")&&(o.style.display="block",o.style.visibility="hidden",o.style.position="absolute");let g=0;const f=s.querySelectorAll("tr");return f.forEach(b=>{let u=b.offsetHeight||b.getBoundingClientRect().height;if(u===0){const p=window.getComputedStyle(b);u=parseFloat(p.height)||parseFloat(p.minHeight)||0}g+=u}),f.forEach(b=>b.remove()),o.style.display=a,o.style.visibility=c,o.style.position=l,g<=0?-1:(y(this,D,g),t(this,$t).call(this),t(this,D))},"#measureAndCacheHeight"));d(this,Ht,h(()=>{v.log("rowManager.#updateVirtualScrollHeight");const e=(t(this,at).data.get()||[]).length,s=t(this,D),r=e*s;[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(i=>{const o=t(this,q).querySelector(i);if(!o)return;const a=o.querySelector(".ng-part-body .ng-virtual-spacer");a&&(a.style.height=`${r}px`)})},"#updateVirtualScrollHeight"));d(this,$t,h(()=>{if(t(this,ct)>0&&t(this,D)>0){const n=Math.ceil(t(this,ct)/t(this,D));y(this,It,n+t(this,se))}},"#updateRowCount"));d(this,oe,h(()=>{var a,c,l,g,f,b;const n=t(this,q).querySelector(".ng-container-left .ng-part-body table"),e=t(this,q).querySelector(".ng-container-body .ng-part-body table"),s=t(this,q).querySelector(".ng-container-right .ng-part-body table");if(e){const u=n?Array.from(n.querySelectorAll("tbody tr")):[],p=Array.from(e.querySelectorAll("tbody tr")),x=s?Array.from(s.querySelectorAll("tbody tr")):[],w=Math.max(u.length,p.length,x.length);for(let m=0;m<w;m++){const k=[((a=u[m])==null?void 0:a.getBoundingClientRect().height)||0,((c=p[m])==null?void 0:c.getBoundingClientRect().height)||0,((l=x[m])==null?void 0:l.getBoundingClientRect().height)||0],A=Math.max(...k);A>0&&(u[m]&&(u[m].style.height=`${A}px`),p[m]&&(p[m].style.height=`${A}px`),x[m]&&(x[m].style.height=`${A}px`))}}const r=t(this,q).querySelector(".ng-container-left .ng-part-footer table"),i=t(this,q).querySelector(".ng-container-body .ng-part-footer table"),o=t(this,q).querySelector(".ng-container-right .ng-part-footer table");if(i){const u=r?Array.from(r.querySelectorAll("tfoot tr")):[],p=Array.from(i.querySelectorAll("tfoot tr")),x=o?Array.from(o.querySelectorAll("tfoot tr")):[],w=Math.max(u.length,p.length,x.length);for(let m=0;m<w;m++){const k=[((g=u[m])==null?void 0:g.getBoundingClientRect().height)||0,((f=p[m])==null?void 0:f.getBoundingClientRect().height)||0,((b=x[m])==null?void 0:b.getBoundingClientRect().height)||0],A=Math.max(...k);A>0&&(u[m]&&(u[m].style.height=`${A}px`),p[m]&&(p[m].style.height=`${A}px`),x[m]&&(x[m].style.height=`${A}px`))}}},"#syncRowHeights"));d(this,ie,h(()=>{!t(this,q)||!(t(this,q)instanceof HTMLElement)||(y(this,J,new ResizeObserver(n=>{for(const e of n){const s=e.target;if(!s.classList.contains("active"))continue;const r=e.contentRect.height;if(r>0){let i=0;const o=s.querySelector(".ng-part-header"),a=s.querySelector(".ng-part-footer");o&&(i+=o.offsetHeight),a&&(i+=a.offsetHeight);const c=Math.max(r-i,100);t(this,ct)!==c&&(y(this,ct,c),t(this,$t).call(this),t(this,D)!==null&&(t(this,Nt).call(this),this.refresh()))}}})),t(this,J).observe(t(this,q)))},"#initResizeObserver"));d(this,Nt,h(()=>{v.log("rowManager.#renderAllContainers"),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(n=>{const e=t(this,q).querySelector(n);e&&e.querySelector(".ng-part-body tbody.bindable-tbody")&&t(this,re).call(this,e,n)}),t(this,le).call(this),t(this,oe).call(this)},"#renderAllContainers"));d(this,wt,h(n=>{var f,b;const e=t(this,D);if(!e||e<=0)return;const s=t(this,at).data.length;if(s===0)return;const r=((f=t(this,V).get(".ng-container-body"))==null?void 0:f.length)||1,i=t(this,q).querySelector(".ng-container-body .ng-part-body"),o=Math.max(0,s-Math.floor(i.clientHeight/e)),a=Math.min(o,Math.max(0,Math.floor(n/e)));let c=Math.floor(a*e);const l=t(this,lt).firstTr,g=l&&l.dataset.row!==void 0?parseInt(l.dataset.row,10):-1;(b=t(this,lt))==null||b.scrollTables.forEach(u=>{u.style.transform=`translate3d(0, ${c}px, 0)`}),g!==a&&[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(u=>{const p=t(this,q).querySelector(u);if(!p)return;const x=p.querySelector(".ng-part-body tbody.bindable-tbody");if(!x)return;Array.from(x.querySelectorAll("tr:not(.nodata)")).forEach((m,k)=>{const A=a+Math.floor(k/r);if(A>=s){m.style.display="none";return}const N=t(this,at).data.get(A);m.style.display="",t(this,ae).call(this,m,N,A)})})},"#handleScroll"));d(this,ae,h((n,e,s)=>{n.dataset.row=s,n.data=e,Array.from(n.cells).forEach((r,i)=>{r.dataset.row=s;const o=Array.from(r.children).find(a=>a.tagName.toLowerCase().startsWith("cell-")||typeof a.refresh=="function");o&&typeof o.refresh=="function"&&o.refresh()})},"#bindRowData"));d(this,le,h(()=>{var c,l,g;v.log("rowManager.#syncHeaderHeights");const n=t(this,q).querySelector(".ng-container-left .ng-part-header table"),e=t(this,q).querySelector(".ng-container-body .ng-part-header table"),s=t(this,q).querySelector(".ng-container-right .ng-part-header table");if(!e)return;const r=n?Array.from(n.querySelectorAll("tr")):[],i=Array.from(e.querySelectorAll("tr")),o=s?Array.from(s.querySelectorAll("tr")):[],a=Math.max(r.length,i.length,o.length);for(let f=0;f<a;f++){const b=[((c=r[f])==null?void 0:c.getBoundingClientRect().height)||0,((l=i[f])==null?void 0:l.getBoundingClientRect().height)||0,((g=o[f])==null?void 0:g.getBoundingClientRect().height)||0],u=Math.max(...b);u>0&&(r[f]&&(r[f].style.height=`${u}px`),i[f]&&(i[f].style.height=`${u}px`),o[f]&&(o[f].style.height=`${u}px`))}},"#syncHeaderHeights"));C(this,"destroy",h(()=>{t(this,J)&&(t(this,J).disconnect(),y(this,J,null))},"destroy"));y(this,at,n.getRootNode().host),y(this,q,n),t(this,ie).call(this)}getRowHeight(){return t(this,D)}templateLength(n=".ng-container-body"){var e;return((e=t(this,V).get(n))==null?void 0:e.length)||1}};at=new WeakMap,q=new WeakMap,lt=new WeakMap,V=new WeakMap,D=new WeakMap,J=new WeakMap,ct=new WeakMap,It=new WeakMap,Ye=new WeakMap,Xe=new WeakMap,se=new WeakMap,Ke=new WeakMap,ne=new WeakMap,re=new WeakMap,Mt=new WeakMap,Ht=new WeakMap,$t=new WeakMap,oe=new WeakMap,ie=new WeakMap,Nt=new WeakMap,wt=new WeakMap,ae=new WeakMap,le=new WeakMap,h(Ge,"RowManager");let ke=Ge;const ce=class ce{static compileAll(n){return Array.isArray(n)?n.map(e=>ce.compile(e)):[]}static compile(n){if(!n)return null;const e=h(a=>{a.querySelectorAll("tbody td, tbody th, tfoot td, tfoot th").forEach(l=>{const g=l.getAttribute("cell-type")||"renderer";if(l.children.length>0&&l.firstElementChild.tagName.includes("-"))return;let f=`cell-${g}`;const b=l.getAttribute("data-bind"),u=l.getAttribute("data-expr"),p=l.getAttribute("maxbyte"),x=l.getAttribute("type");let w=[];b&&w.push(`data-bind="${b}"`),u&&w.push(`data-expr="${u}"`),p&&w.push(`maxbyte="${p}"`),x&&w.push(`type="${x}"`),l.innerHTML=`<${f} ${w.join(" ")}></${f}>`}),a.querySelectorAll("tbody td, tfoot td").forEach(l=>{l.setAttribute("tabindex","0")})},"processCellTypes"),s=h(a=>{if(!a.querySelector("colgroup")){const c=a.querySelector("tbody tr")||a.querySelector("tr"),l=c?c.querySelectorAll("th, td").length:1,g=document.createElement("colgroup"),f=Math.max(Math.floor(a.clientWidth/l),100);for(let b=0;b<l;b++){const u=document.createElement("col");u.setAttribute("width",f),g.appendChild(u)}a.prepend(g)}if(!a.querySelector("thead")){const c=document.createElement("thead"),l=a.querySelector("colgroup");l?l.after(c):a.prepend(c)}a.classList.add("nine-table-element")},"ensureTableStructure"),r=h((a,c)=>{const l=Array.from(a.querySelectorAll(c+" tr")),g=Array.from(a.querySelectorAll(c+" th,"+c+" td")),f=l.length;if(f===0||g.length===0)return;let b=0;g.forEach(p=>{b+=p.colSpan||1});const u=Array.from(Array(f),()=>Array(b).fill(null));l.forEach(p=>{const x=p.sectionRowIndex;let w=0;Array.from(p.querySelectorAll("th,td")).forEach(m=>{for(let N=0;N<u[x].length;N++)if(u[x][N]===null){w=N;break}const k=m.rowSpan||1,A=m.colSpan||1;for(let N=0;N<k;N++)for(let B=0;B<A;B++)x+N<f&&w+B<b&&(u[x+N][w+B]=N===0&&B===0?"1":"0")})}),l.forEach(p=>{const x=p.sectionRowIndex;Array.from(p.querySelectorAll("th,td")).forEach(w=>{for(let m=0;m<u[x].length;m++)if(u[x][m]==="1"){w.dataset.col=m,u[x][m]="0";break}})})},"resetColIndex"),i=n.cloneNode(!0);return s(i),e(i),r(i,"thead"),r(i,"tbody"),r(i,"tfoot"),Array.from(i.querySelectorAll("colgroup col")).forEach((a,c)=>{const l=a.getAttribute("fixed");l&&i.querySelectorAll(`thead [data-col="${c}"], tbody [data-col="${c}"], tfoot [data-col="${c}"]`).forEach(g=>{g.setAttribute("fixed",l)})}),i}};h(ce,"TableCompiler");let Le=ce;const Ze=class Ze{constructor(n){d(this,X);d(this,_);d(this,Y,{startRow:-1,startCol:-1,endRow:-1,endCol:-1});C(this,"render",h(()=>{const{startRow:n,startCol:e,endRow:s,endCol:r}=t(this,Y);v.log("🎨 [CellSelection.render] Rendering range ->",t(this,Y));const i=t(this,_).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body");if(i.forEach(a=>{a.querySelectorAll(".selected, .selected-top, .selected-bottom, .selected-left, .selected-right").forEach(c=>{c.classList.remove("selected","selected-top","selected-bottom","selected-left","selected-right")})}),n<0||e<0){v.log("⚠️ [CellSelection.render] Range is invalid (< 0), skipping render.");return}let o=0;i.forEach(a=>{a.querySelectorAll("tbody tr").forEach(c=>{const{matrixRow:l}=K(this,X,Zt).call(this,c);l<0||c.querySelectorAll("td, th").forEach(g=>{const f=parseInt(g.dataset.col,10);if(isNaN(f))return;const b=parseInt(g.rowSpan||1,10),u=parseInt(g.colSpan||1,10),p=l+b-1,x=f+u-1;p>=n&&l<=s&&x>=e&&f<=r&&(o++,g.classList.add("selected"),v.log(g,n,e,s,r),l<=n&&g.classList.add("selected-top"),p>=s&&g.classList.add("selected-bottom"),f<=e&&g.classList.add("selected-left"),x>=r&&g.classList.add("selected-right"))})})}),v.log(`✨ [CellSelection.render] Total rendered cells marked: ${o}`)},"render"));y(this,_,n),K(this,X,vs).call(this),t(this,_).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body").forEach(s=>{s.addEventListener("scroll",()=>{t(this,Y).startRow>=0&&t(this,Y).startCol>=0&&this.render()})}),v.log("🎯 [CellSelection] Initialized")}setRange(n,e,s,r){v.log(`🔍 [CellSelection.setRange] Input -> startRow: ${n}, startCol: ${e}, endRow: ${s}, endCol: ${r}`);let i=Math.min(n,s),o=Math.max(n,s),a=Math.min(e,r),c=Math.max(e,r);const l=t(this,_).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body");let g=!0,f=0;for(;g&&f<5;)g=!1,f++,l.forEach(b=>{b.querySelectorAll("tbody tr").forEach(u=>{if(u.classList.contains("nodata"))return;const{matrixRow:p}=K(this,X,Zt).call(this,u);p<0||u.querySelectorAll("td, th").forEach(x=>{const w=parseInt(x.dataset.col,10);if(isNaN(w))return;const m=parseInt(x.rowSpan||1,10),k=parseInt(x.colSpan||1,10),A=p+m-1,N=w+k-1;if(A>=i&&p<=o&&N>=a&&w<=c){const P=Math.min(i,p),Ce=Math.max(o,A),ps=Math.min(a,w),ys=Math.max(c,N);(P!==i||Ce!==o||ps!==a||ys!==c)&&(i=P,o=Ce,a=ps,c=ys,g=!0)}})})});y(this,Y,{startRow:i,startCol:a,endRow:o,endCol:c}),v.log("📦 [CellSelection.setRange] Final Range ->",t(this,Y)),this.render()}};_=new WeakMap,Y=new WeakMap,X=new WeakSet,Zt=h(function(n){if(!n||n.classList.contains("nodata"))return{dataRow:-1,subRowIndex:-1,matrixRow:-1};const e=parseInt(n.dataset.row,10);if(isNaN(e))return{dataRow:-1,subRowIndex:-1,matrixRow:-1};const s=n.closest("tbody"),i=Array.from(s.querySelectorAll("tr:not(.nodata)")).filter(l=>parseInt(l.dataset.row,10)===e),o=i.indexOf(n),a=i.length>0?i.length:1,c=e*a+(o>=0?o:n.sectionRowIndex%a);return{dataRow:e,subRowIndex:o,matrixRow:c}},"#getMatrixRow"),vs=h(function(){const n=t(this,_).querySelector(".ng-container-top");if(!n){v.log("❌ [CellSelection] .ng-container-top not found!");return}n.addEventListener("mousedown",e=>{if(e.button!==0)return;const s=e.target.closest("td, th");if(!s||s.dataset.row===void 0||s.dataset.col===void 0||s.closest("tr").classList.contains("nodata"))return;t(this,_).style.userSelect="none",t(this,_).style.webkitUserSelect="none";const r=s.closest("tr"),{matrixRow:i}=K(this,X,Zt).call(this,r),o=parseInt(s.dataset.col,10);if(i<0){t(this,_).style.userSelect="",t(this,_).style.webkitUserSelect="";return}v.log(`🖱️ [MouseDown Success] startRow: ${i}, startCol: ${o}`),t(this,_).navigation.currentCell=s;let a=i,c=o;const l=h(f=>{const b=document.elementFromPoint(f.clientX,f.clientY);let u=b==null?void 0:b.closest("td, th");if(!u||!t(this,_).contains(u)){const m=t(this,_).querySelectorAll(".ng-part-body tbody tr:not(.nodata) td, .ng-part-body tbody tr:not(.nodata) th");for(const k of m){const A=k.getBoundingClientRect();if(f.clientX>=A.left&&f.clientX<=A.right&&f.clientY>=A.top&&f.clientY<=A.bottom){u=k;break}}}if(!u||u.dataset.row===void 0||u.dataset.col===void 0||u.closest("tr").classList.contains("nodata"))return;const p=u.closest("tr"),{matrixRow:x}=K(this,X,Zt).call(this,p),w=parseInt(u.dataset.col,10);x<0||a===x&&c===w||(a=x,c=w,this.setRange(i,o,x,w))},"onMouseMove"),g=h(()=>{v.log("🖱️ [MouseUp] Drag ended."),t(this,_).style.userSelect="",t(this,_).style.webkitUserSelect="",document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",g)},"onMouseUp");document.addEventListener("mousemove",l),document.addEventListener("mouseup",g)})},"#initEvents"),h(Ze,"CellSelection");let Ie=Ze;const Je=class Je{constructor(n){d(this,dt);d(this,j);d(this,ht,null);d(this,he,-1);d(this,de,-1);d(this,_t,h(n=>{const e=[];return n.forEach(s=>e.push(...Array.from(s.querySelectorAll("td")))),e.length===0?null:(e.sort((s,r)=>parseInt(s.dataset.col,10)-parseInt(r.dataset.col,10)),e[e.length-1])},"#getMaxColCell"));d(this,Ot,h((n,e)=>{const s=t(this,ft).call(this,n);if(s.length===0)return e+1;let r=e+1;const i=[];s.forEach(o=>i.push(...Array.from(o.querySelectorAll("td")))),i.sort((o,a)=>parseInt(o.dataset.col,10)-parseInt(a.dataset.col,10));for(const o of i){const a=parseInt(o.dataset.col,10),c=parseInt(o.colSpan||1,10);if(e>=a&&e<a+c){r=a+c;break}}return r},"#getNextCol"));d(this,Dt,h((n,e)=>{const s=t(this,ft).call(this,n);if(s.length===0)return Math.max(0,e-1);let r=-1;const i=[];s.forEach(o=>i.push(...Array.from(o.querySelectorAll("td")))),i.sort((o,a)=>parseInt(o.dataset.col,10)-parseInt(a.dataset.col,10));for(const o of i){const a=parseInt(o.dataset.col,10);if(a<e)r=a;else break}return r},"#getPreviousCol"));d(this,ft,h(n=>{const e=t(this,j).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body"),s=[];return e.forEach(r=>{const i=Array.from(r.querySelectorAll("tbody tr:not(.nodata)"));for(const o of i){const a=parseInt(o.dataset.row,10),c=i.filter(p=>parseInt(p.dataset.row,10)===a),l=c.length>0?c.length:1,g=c.indexOf(o),f=a*l+(g>=0?g:0);if(f===n){s.push(o);break}const b=Array.from(o.querySelectorAll("td"));let u=!1;for(const p of b){const x=parseInt(p.rowSpan||1,10);if(x>1&&n>=f&&n<f+x){s.push(o),u=!0;break}}if(u)break}}),s},"#findTargetTrsByMatrix"));d(this,Wt,h((n,e,s,r)=>{const i=t(this,j).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body"),o=r!==void 0?r:n*1+e;for(const a of i){const c=Array.from(a.querySelectorAll("tbody tr:not(.nodata)"));for(const l of c){const g=parseInt(l.dataset.row,10),f=c.filter(w=>parseInt(w.dataset.row,10)===g),b=f.length>0?f.length:1,u=f.indexOf(l),p=g*b+(u>=0?u:0),x=Array.from(l.querySelectorAll("td"));for(const w of x){const m=parseInt(w.dataset.col,10),k=parseInt(w.colSpan||1,10),A=parseInt(w.rowSpan||1,10);if(!isNaN(m)&&s>=m&&s<m+k&&o>=p&&o<p+A&&window.getComputedStyle(w).display!=="none")return w}}}return null},"#getNearElement"));y(this,j,n),K(this,dt,Ss).call(this),v.log("🎯 [CellNavigation] Initialized")}get currentCell(){return t(this,ht)}set currentCell(n){if(!n)return;y(this,ht,n),n.focus({preventScroll:!0});const e=parseInt(n.dataset.row,10),s=parseInt(n.dataset.col,10);if(!isNaN(e)&&!isNaN(s)){y(this,he,e),y(this,de,s);const r=n.closest("tr"),i=r==null?void 0:r.closest("tbody");if(i){const a=Array.from(i.querySelectorAll("tr:not(.nodata)")).filter(f=>parseInt(f.dataset.row,10)===e),c=a.length>0?a.length:1,l=a.indexOf(r),g=e*c+(l>=0?l:0);t(this,j).selection.setRange(g,s,g,s)}}}moveCell(n){var m,k,A,N;if(!t(this,ht))return;const e=t(this,ht),s=e.closest("tr"),r=parseInt(e.dataset.row,10),i=parseInt(e.dataset.col,10),o=s==null?void 0:s.closest("tbody");if(!o)return;const c=Array.from(o.querySelectorAll("tr:not(.nodata)")).filter(B=>parseInt(B.dataset.row,10)===r),l=c.length>0?c.length:1,g=c.indexOf(s),f=r*l+(g>=0?g:0);let b=f,u=i;switch(n.code){case"Tab":if(n.preventDefault(),n.shiftKey){if(u=t(this,Dt).call(this,f,i),u<0&&f>0){b=f-1;const B=t(this,ft).call(this,b),P=t(this,_t).call(this,B);u=P?parseInt(P.dataset.col,10):0}}else{u=t(this,Ot).call(this,f,i);const B=t(this,ft).call(this,f),P=t(this,_t).call(this,B),Ce=P?parseInt(P.dataset.col,10)+parseInt(P.colSpan||1,10):0;u>=Ce&&(b=f+1,u=0)}break;case"ArrowRight":u=t(this,Ot).call(this,f,i);break;case"ArrowLeft":u=t(this,Dt).call(this,f,i);break;case"ArrowDown":n.preventDefault(),b=f+(e.rowSpan||1);break;case"ArrowUp":n.preventDefault(),b=Math.max(0,f-(e.rowSpan||1));break}const p=Math.floor(b/l),x=b%l;let w=t(this,Wt).call(this,p,x,u,b);if(v.log(w,p,x,u,b),w)this.currentCell=w,K(this,dt,bs).call(this,w);else if(p!==r&&p>=0){const B=((k=(m=t(this,j)).getRowHeight)==null?void 0:k.call(m))||40;(N=(A=t(this,j)).scrollToY)==null||N.call(A,p*B),setTimeout(()=>{const P=t(this,Wt).call(this,p,x,u,b);P&&(this.currentCell=P,K(this,dt,bs).call(this,P))},0)}}};j=new WeakMap,ht=new WeakMap,he=new WeakMap,de=new WeakMap,dt=new WeakSet,bs=h(function(n){const e=t(this,j).querySelector(".ng-container-body .ng-part-body");if(!e)return;const s=n.getBoundingClientRect(),r=e.getBoundingClientRect();s.top<r.top?e.scrollTop-=r.top-s.top:s.bottom>r.bottom&&(e.scrollTop+=s.bottom-r.bottom),s.left<r.left?e.scrollLeft-=r.left-s.left:s.right>r.right&&(e.scrollLeft+=s.right-r.right)},"#ensureCellVisible"),_t=new WeakMap,Ot=new WeakMap,Dt=new WeakMap,ft=new WeakMap,Wt=new WeakMap,Ss=h(function(){t(this,j).addEventListener("keydown",n=>{["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(n.code)&&this.moveCell(n)})},"#initEvents"),h(Je,"CellNavigation");let Me=Je;const Pt=class Pt extends HTMLElement{constructor(){super();d(this,fe);d(this,ut,null);d(this,gt);d(this,zt);d(this,Bt);C(this,"invalidate",h(()=>{v.log("sheet.invalidate()"),t(this,gt).refresh()},"invalidate"));C(this,"generate",h(e=>{if(v.log("sheet.generate()"),!e)return;y(this,ut,Le.compile(e)),t(this,ue).call(this),t(this,ge).call(this);const s=this.querySelector(".ng-container-body .ng-part-header"),r=this.querySelector(".ng-container-body .ng-part-footer"),i=this.querySelector(".ng-nodata-overlay");s&&i&&(i.style.top=`${s.offsetHeight}px`),r&&i&&(i.style.bottom=`${r.offsetHeight}px`),t(this,gt).initialize(),setTimeout(()=>{var o;(o=this.querySelector("nine-table-hscrollbar"))==null||o.refresh()},0)},"generate"));d(this,ue,h(()=>{[{selector:".ng-container-body",type:null},{selector:".ng-container-left",type:"left"},{selector:".ng-container-right",type:"right"}].forEach(({selector:s,type:r})=>{var i,o,a;(i=this.querySelector(`${s} .ng-part-header`))==null||i.appendChild(t(this,vt).call(this,t(this,ut),r,"header")),(o=this.querySelector(`${s} .ng-virtual-spacer`))==null||o.before(t(this,vt).call(this,t(this,ut),r,"body")),(a=this.querySelector(`${s} .ng-part-footer`))==null||a.appendChild(t(this,vt).call(this,t(this,ut),r,"footer"))})},"#renderSplitContainers"));d(this,ge,h(()=>{["left","right","body"].forEach(e=>{const s=this.querySelector(`.ng-container-${e}`),r=s==null?void 0:s.querySelectorAll("table");if(!s||!r||r.length===0)return;let i=0;r[0].querySelectorAll("col").forEach(o=>{const a=parseInt(o.getAttribute("width"),10);isNaN(a)||(i+=a)}),e==="body"?(s.style.flex="1",r.forEach(o=>{o.style.width=`${i}px`,o.style.minWidth=`${i}px`})):(s.style.flex=`0 0 ${i}px`,s.style.width=`${i}px`,r.forEach(o=>{o.style.width=`${i}px`,o.style.minWidth=`${i}px`}))})},"#updateContainerWidths"));d(this,vt,h((e,s,r)=>{const i=e.cloneNode(!0),o=i.querySelector("thead"),a=i.querySelector("tbody"),c=i.querySelector("tfoot");if(r==="header"){if(a&&a.remove(),c&&c.remove(),e.querySelector("tbody")){const g=document.createElement("tbody");g.className="fixed-tbody",i.appendChild(g)}}else r==="body"?(o&&o.remove(),c&&c.remove(),a&&(a.className="bindable-tbody")):r==="footer"&&(o&&o.remove(),a&&a.remove());return s==="left"?i.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(l=>{l.getAttribute("fixed")!=="left"&&l.remove()}):s==="right"?i.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(l=>{l.getAttribute("fixed")!=="right"&&l.remove()}):i.querySelectorAll("[fixed=left], [fixed=right]").forEach(l=>{l.remove()}),i},"#createSplitTable"));C(this,"getRowHeight",h(()=>t(this,gt).getRowHeight(),"getRowHeight"));C(this,"scrollToX",h(e=>{const s=this.querySelector(".ng-container-body .ng-part-body");s&&(s.scrollLeft=e)},"scrollToX"));C(this,"scrollToY",h(e=>{const s=this.querySelector(".ng-container-body .ng-part-body");s&&(s.scrollTop=e)},"scrollToY"));d(this,be,h(()=>{t(this,pe).call(this),y(this,zt,new Ie(this)),y(this,Bt,new Me(this))},"#init"));d(this,pe,h(()=>{const e=Pt.SCROLLBAR_SIZE;this.innerHTML=`
127
127
  <style>
128
128
  nine-table-sheet {
129
129
  display: none;
@@ -321,7 +321,7 @@
321
321
  <nine-table-hscrollbar></nine-table-hscrollbar>
322
322
  <div class='ng-scroll-edge'></div>
323
323
  </div>
324
- `},"#render"));p(this,bt,new Le(this)),p(this,ue,this.getRootNode().host)}connectedCallback(){t(this,pe).call(this)}get selection(){return t(this,Bt)}get navigation(){return t(this,Pt)}disconnectedCallback(){this.innerHTML="",S.log("NineTableSheet destroyed.")}};ue=new WeakMap,gt=new WeakMap,bt=new WeakMap,Bt=new WeakMap,Pt=new WeakMap,ge=new WeakMap,be=new WeakMap,St=new WeakMap,pe=new WeakMap,ye=new WeakMap,h(Ft,"NineTableSheet"),C(Ft,"SCROLLBAR_SIZE",16);let Qt=Ft;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",Qt);const Qe=class Qe extends HTMLElement{constructor(){super();d(this,me,h(()=>{var e;(e=this.querySelector(".nine-tab-bar"))==null||e.addEventListener("click",s=>{var o;const r=s.ctrlKey||s.metaKey||s.shiftKey,i=parseInt((o=s.target.closest(".nine-tab-item"))==null?void 0:o.dataset.index,10);t(this,jt).call(this,i,r)}),t(this,jt).call(this,0,!1)},"#init"));d(this,jt,h((e,s=!1)=>{const r=h(()=>{const u=Array.from(this.querySelectorAll("nine-table-sheet"));Array.from(this.querySelectorAll("nine-splitter")).forEach(g=>g.style.setProperty("display","none"));const b=u.filter(g=>g.classList.contains("active"));b.length<2||b.forEach(g=>{const y=parseInt(g.getAttribute("data-index"),10),x=this.querySelector(`nine-splitter[data-split-index="${y}"]`),w=u[y+1];x&&w&&w.classList.contains("active")&&x.style.setProperty("display","flex")})},"updateSplitters"),i=this.querySelector(".nine-tab-bar"),o=this.querySelector("nine-table-sheets-body"),a=i.querySelectorAll(".nine-tab-item"),c=o.querySelectorAll("nine-table-sheet");if(!a[e])return;if(!s)a.forEach((u,f)=>{u.classList.toggle("active",f===e)}),c.forEach((u,f)=>{const b=f===e;u.classList.toggle("active",b),u.style.flex=b?"1 1 100%":""});else{const u=a[e],f=i.querySelectorAll(".nine-tab-item.active");if(u.classList.contains("active")&&f.length<=1)return;u.classList.toggle("active");const b=o.querySelector(`nine-table-sheet[data-index="${e}"]`);b&&(b.classList.toggle("active"),b.classList.contains("active")||(b.style.flex=""))}const l=o.querySelectorAll("nine-table-sheet.active");l==null||l.forEach(u=>{u.style.flex=l.length>1?"1 1 0%":"1 1 100%"}),r()},"#switchSheet"))}connectedCallback(){t(this,me).call(this)}};me=new WeakMap,jt=new WeakMap,h(Qe,"NineTableSheets");let $e=Qe;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",$e);const ts=class ts{constructor(n){d(this,O);d(this,xe,h(()=>{t(this,we).call(this),new ResizeObserver(n=>{for(let e of n)t(this,O).getAttribute("auto-height")==="true"&&t(this,Ut).call(this)}).observe(t(this,O))},"#init"));d(this,Ut,h(()=>{var c,l;const n=Array.from(t(this,O).shadowRoot.querySelectorAll("nine-table-sheet.active"));if(n.length===0)return;const e=parseInt(t(this,O).getAttribute("max-display-row"),10)||10,s=Math.max(...n.map(u=>u.getRowHeight())),r=(c=t(this,O).shadowRoot.querySelector("nine-table-header"))==null?void 0:c.getBoundingClientRect().height,i=(l=t(this,O).shadowRoot.querySelector("nine-table-sheets-footer"))==null?void 0:l.getBoundingClientRect().height,o=Qt.SCROLLBAR_SIZE,a=e*s+r+i+o;t(this,O).style.height=`${a}px`},"#applyAutoHeight"));d(this,we,h(()=>{const e=Array.from(t(this,O).children).filter(c=>c.tagName==="TABLE"),s=t(this,O).getAttribute("auto-height")==="true",r=e.length,i=e.map((c,l)=>{const f=`<nine-table-sheet class="${l===0?"active":""}" data-index="${l}"></nine-table-sheet>`,b=l<r-1?`<nine-splitter class="h" data-split-index="${l}"></nine-splitter>`:"";return f+b}).join(""),o=e.map((c,l)=>`<div class="nine-tab-item ${l===0?"active":""}" data-index="${l}">Sheet ${l+1}</div>`).join("");t(this,O).shadowRoot.innerHTML=`
324
+ `},"#render"));y(this,gt,new ke(this)),y(this,fe,this.getRootNode().host)}connectedCallback(){t(this,be).call(this)}get selection(){return t(this,zt)}get navigation(){return t(this,Bt)}disconnectedCallback(){this.innerHTML="",v.log("NineTableSheet destroyed.")}};fe=new WeakMap,ut=new WeakMap,gt=new WeakMap,zt=new WeakMap,Bt=new WeakMap,ue=new WeakMap,ge=new WeakMap,vt=new WeakMap,be=new WeakMap,pe=new WeakMap,h(Pt,"NineTableSheet"),C(Pt,"SCROLLBAR_SIZE",16);let Jt=Pt;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",Jt);const Qe=class Qe extends HTMLElement{constructor(){super();d(this,ye,h(()=>{var e;(e=this.querySelector(".nine-tab-bar"))==null||e.addEventListener("click",s=>{var o;const r=s.ctrlKey||s.metaKey||s.shiftKey,i=parseInt((o=s.target.closest(".nine-tab-item"))==null?void 0:o.dataset.index,10);t(this,Ft).call(this,i,r)}),t(this,Ft).call(this,0,!1)},"#init"));d(this,Ft,h((e,s=!1)=>{const r=h(()=>{const g=Array.from(this.querySelectorAll("nine-table-sheet"));Array.from(this.querySelectorAll("nine-splitter")).forEach(u=>u.style.setProperty("display","none"));const b=g.filter(u=>u.classList.contains("active"));b.length<2||b.forEach(u=>{const p=parseInt(u.getAttribute("data-index"),10),x=this.querySelector(`nine-splitter[data-split-index="${p}"]`),w=g[p+1];x&&w&&w.classList.contains("active")&&x.style.setProperty("display","flex")})},"updateSplitters"),i=this.querySelector(".nine-tab-bar"),o=this.querySelector("nine-table-sheets-body"),a=i.querySelectorAll(".nine-tab-item"),c=o.querySelectorAll("nine-table-sheet");if(!a[e])return;if(!s)a.forEach((g,f)=>{g.classList.toggle("active",f===e)}),c.forEach((g,f)=>{const b=f===e;g.classList.toggle("active",b),g.style.flex=b?"1 1 100%":""});else{const g=a[e],f=i.querySelectorAll(".nine-tab-item.active");if(g.classList.contains("active")&&f.length<=1)return;g.classList.toggle("active");const b=o.querySelector(`nine-table-sheet[data-index="${e}"]`);b&&(b.classList.toggle("active"),b.classList.contains("active")||(b.style.flex=""))}const l=o.querySelectorAll("nine-table-sheet.active");l==null||l.forEach(g=>{g.style.flex=l.length>1?"1 1 0%":"1 1 100%"}),r()},"#switchSheet"))}connectedCallback(){t(this,ye).call(this)}};ye=new WeakMap,Ft=new WeakMap,h(Qe,"NineTableSheets");let He=Qe;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",He);const ts=class ts{constructor(n){d(this,O);d(this,me,h(()=>{t(this,xe).call(this),new ResizeObserver(n=>{for(let e of n)t(this,O).getAttribute("auto-height")==="true"&&t(this,jt).call(this)}).observe(t(this,O))},"#init"));d(this,jt,h(()=>{var c,l;const n=Array.from(t(this,O).shadowRoot.querySelectorAll("nine-table-sheet.active"));if(n.length===0)return;const e=parseInt(t(this,O).getAttribute("max-display-row"),10)||10,s=Math.max(...n.map(g=>g.getRowHeight())),r=(c=t(this,O).shadowRoot.querySelector("nine-table-header"))==null?void 0:c.getBoundingClientRect().height,i=(l=t(this,O).shadowRoot.querySelector("nine-table-sheets-footer"))==null?void 0:l.getBoundingClientRect().height,o=Jt.SCROLLBAR_SIZE,a=e*s+r+i+o;t(this,O).style.height=`${a}px`},"#applyAutoHeight"));d(this,xe,h(()=>{const e=Array.from(t(this,O).children).filter(c=>c.tagName==="TABLE"),s=t(this,O).getAttribute("auto-height")==="true",r=e.length,i=e.map((c,l)=>{const f=`<nine-table-sheet class="${l===0?"active":""}" data-index="${l}"></nine-table-sheet>`,b=l<r-1?`<nine-splitter class="h" data-split-index="${l}"></nine-splitter>`:"";return f+b}).join(""),o=e.map((c,l)=>`<div class="nine-tab-item ${l===0?"active":""}" data-index="${l}">Sheet ${l+1}</div>`).join("");t(this,O).shadowRoot.innerHTML=`
325
325
  <style>
326
326
  :host {
327
327
  display: flex;
@@ -441,10 +441,10 @@
441
441
  <nine-table-analysis></nine-table-analysis>
442
442
  </nine-table-body>
443
443
  <nine-table-footer></nine-table-footer>
444
- `,t(this,O).shadowRoot.querySelector("nine-table-sheets").classList.add("nodata");const a=t(this,O).shadowRoot.querySelectorAll("nine-table-sheet");a==null||a.forEach((c,l)=>{e[l]&&setTimeout(()=>{c.generate(e[l]),s&&t(this,Ut).call(this)})})},"#render"));p(this,O,n),t(this,xe).call(this)}};O=new WeakMap,xe=new WeakMap,Ut=new WeakMap,we=new WeakMap,h(ts,"LayoutManager");let Ne=ts;const es=class es{constructor(n){d(this,Vt);d(this,Rt,-1);C(this,"count",h(()=>t(this,Vt).rawRecords.length,"count"));p(this,Vt,n)}get at(){return t(this,Rt)}set at(n){p(this,Rt,parseInt(n,10)),body&&!body.querySelector(`tbody.bindable tr[data-row="${t(this,Rt)}"]`)&&setTimeout(()=>{})}};Vt=new WeakMap,Rt=new WeakMap,h(es,"ngRow");let _e=es;const F=class F{constructor(n,e){d(this,W);d(this,I);d(this,z,[]);d(this,At,[]);d(this,ve,0);d(this,tt,[]);d(this,Se,h(()=>{p(this,tt,[]);const n=t(this,W).template||[];Array.from(n).forEach(e=>{var s;t(this,tt).push(((s=e.getBoundingClientRect)==null?void 0:s.call(e).height)||24)}),(t(this,I).rawRecords||[]).forEach(e=>{e.__ng||(e.__ng=t(this,Yt).call(this)),e.__ng.height=t(this,tt).slice()})},"#initialize"));d(this,pt,h(()=>{const n=t(this,W).shadowRoot.querySelector("nine-table-sheets");n==null||n.classList.toggle("nodata",this.length===0),t(this,W).shadowRoot.querySelectorAll("nine-table-sheet").forEach(e=>{e.invalidate()})},"#invalidate"));C(this,"get",h((n,e)=>{var i;const s=this.getValidData();if(!s||s.length<=0)return;if(n==null)return t(this,Et).call(this,s);if(n<0||n>=s.length)return null;const r=typeof((i=t(this,W).fields)==null?void 0:i.get)=="function"?t(this,W).fields.get():[];if(e!=null){const o=r.indexOf(e);return o>=0?s[n].v[o]:null}return t(this,Et).call(this,s[n])},"get"));C(this,"set",h(n=>{this.clear(),this.add(n,!1),t(this,pt).call(this)},"set"));d(this,Yt,h(()=>({rowState:F.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:t(this,tt).slice(),o:{},c:{},_:[0,0,0,0,F.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,t(this,tt).slice(),-1,{},{}]}),"#getDefaultMeta"));C(this,"reset",h(()=>{p(this,z,[]),p(this,At,[]),t(this,pt).call(this)},"reset"));C(this,"clear",h(()=>{var n;t(this,I).rawRecords=[],p(this,z,[]),p(this,At,[]),(n=t(this,I).viewRecords)!=null&&n.reset&&t(this,I).viewRecords.reset()},"clear"));d(this,Re,h(n=>{var r;Array.isArray(n)||(n=[n]);const e=typeof((r=t(this,W).fields)==null?void 0:r.get)=="function"?t(this,W).fields.get():Object.keys(n[0]||{}),s=[];return n.forEach(i=>{const o={v:[]};e.forEach(a=>{o.v.push(i[a]!==void 0&&i[a]!==null?i[a]:"")}),s.push(o)}),s},"#json2Array"));d(this,Ae,h(n=>(Array.isArray(n)||(n=[n]),n.forEach(e=>{e.__ng=t(this,Yt).call(this),e.__ng.rowid=this.nextId,e.__ng.rowState=F.ROW_STATE.INSERT,e.__ng._[0]=e.__ng.rowid}),n),"#defaultInsert"));C(this,"add",h((n,e=!0)=>{n===void 0&&(n={});const s=t(this,Re).call(this,n);t(this,I).rawRecords=t(this,I).rawRecords.concat(t(this,Ae).call(this,s)),this.resetRecords();const r=this.count()-1;return e||s.forEach((i,o)=>{const a=t(this,I).rawRecords[r-o];a&&(a.__ng.rowState=F.ROW_STATE.EMPTY)}),t(this,pt).call(this),r},"add"));C(this,"delete",h(n=>{let e=[];Array.isArray(n)?e=n:typeof n>"u"?e=[t(this,I).host.row.at]:e=[parseInt(n,10)],e.sort((s,r)=>r-s).forEach(s=>{if(t(this,z)[s]){const r=t(this,z)[s].__ng.rowid;t(this,z)[s].__ng.rowState===F.ROW_STATE.INSERT?t(this,I).rawRecords=t(this,I).rawRecords.filter(i=>i.__ng.rowid!==r):t(this,I).rawRecords.forEach(i=>{i.__ng.rowid===r&&(i.__ng.deleted=!0,i.__ng.rowState=F.ROW_STATE.DELETE)})}}),this.resetRecords(),t(this,pt).call(this)},"delete"));C(this,"setValue",h((n,e,s)=>{var c;n=parseInt(n,10);const i=(typeof((c=t(this,W).fields)==null?void 0:c.get)=="function"?t(this,W).fields.get():[]).indexOf(e);if(i<0)return;const o=this.getValidData()[n];if(!o)return;const a=o.v[i];a!==s&&o.__ng.rowState!==F.ROW_STATE.INSERT&&(o.__ng.o.hasOwnProperty(e)||(o.__ng.o[e]=a),o.__ng.rowState=F.ROW_STATE.UPDATE),o.v[i]=s},"setValue"));C(this,"resetRecords",h(()=>{p(this,At,t(this,I).rawRecords.filter(n=>!n.__ng.deleted)),p(this,z,t(this,I).rawRecords.filter(n=>!n.__ng.deleted&&!n.__ng.filtered)),t(this,I).rawRecords.forEach((n,e)=>{n.__ng.rowidx=e}),t(this,z).forEach((n,e)=>{n.__ng.i=e})},"resetRecords"));C(this,"getValidData",h(()=>(t(this,z).length===0&&t(this,I).rawRecords.length>0&&this.resetRecords(),t(this,z)),"getValidData"));d(this,Et,h(n=>{var o;if(!n)return n;const e=!Array.isArray(n),s=e?[n]:n,r=typeof((o=t(this,W).fields)==null?void 0:o.get)=="function"?t(this,W).fields.get():[],i=s.filter(a=>!a.__ng.deleted).map(a=>{const c={};return r.forEach((l,u)=>{c[l]=a.v?a.v[u]:a[l]}),c.__ng=a.__ng,c});return e?i[0]:i},"#conv"));C(this,"count",h(()=>this.getValidData().length,"count"));p(this,W,n),p(this,I,e),t(this,Se).call(this)}get source(){return t(this,Et).call(this,t(this,I).rawRecords)}set source(n){this.clear(),this.add(n,!1)}get nextId(){return++ws(this,ve)._}get count(){return t(this,z).length}get length(){return t(this,z).length}getRowCount(){return this.length}};W=new WeakMap,I=new WeakMap,z=new WeakMap,At=new WeakMap,ve=new WeakMap,tt=new WeakMap,Se=new WeakMap,pt=new WeakMap,Yt=new WeakMap,Re=new WeakMap,Ae=new WeakMap,Et=new WeakMap,h(F,"ngData"),C(F,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let Oe=F;const ss=class ss{constructor(n){d(this,yt);p(this,yt,n),this.row=new _e(this),this.data=new Oe(t(this,yt),this),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.pageCnt=25,this.viewRecords.reset=()=>{var e;(e=t(this,yt).view)!=null&&e.redraw&&t(this,yt).view.redraw()},this.setDataSource=e=>{this.data&&this.data.reset(),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.data.set(e||[])},this.getRowState=e=>{var r,i;const s=parseInt(e,10);if(!(s>=this.data.count()))return(i=(r=this.data.getValidData()[s])==null?void 0:r.__ng)==null?void 0:i.rowState},this.getRowPosition=()=>this.row.at,this.setRowPosition=e=>{this.row.at=e},this.scrollTo_V1=e=>(e<0&&(e=0),e>=this.rawRecords.length&&(e=this.rawRecords.length-1),this.viewRecords.rawIndex=e,this.viewRecords.reset&&this.viewRecords.reset(),!(e<=0||e>=this.rawRecords.length-1)),this.getColumn=(e,s)=>this.data.get(e,s),this.setColumn=(e,s,r)=>{e=parseInt(e,10),this.data.setValue(e,s,r)},this.setDataSource([])}};yt=new WeakMap,h(ss,"ngDataManager");let De=ss;const ns=class ns{constructor(n){d(this,qt);d(this,H,[]);C(this,"add",h((n,e="string")=>{n.forEach(s=>{t(this,H).some(r=>r.name===s)||t(this,H).push({name:s,type:e})}),t(this,Xt).call(this)},"add"));d(this,Xt,h(()=>{const n=new Map;t(this,H).forEach(e=>{n.set(e.name,e.type)}),p(this,H,Array.from(n,([e,s])=>({name:e,type:s}))),p(this,H,t(this,H).filter(e=>e.name!==""&&e.name!=="__ng")),t(this,H).sort((e,s)=>e.name.length<s.name.length?1:-1)},"#adjust"));d(this,Ee,h(()=>{p(this,H,[]),S.log(t(this,qt).querySelectorAll("table"));const n=Array.from(t(this,qt).querySelectorAll("table"));if(!(!n||n.length===0)){for(const e of n)S.log(e),$("[data-bind]",e).each((s,r)=>{const i=r.dataset.bind,o=r.getAttribute("data-type")||"string";i&&t(this,H).push({name:i,type:o})}),["data-expr","background-color","color","tooltip","visible","readonly","enable-button","enable-check","class-expr","icon-color","icon-src"].forEach(s=>{$(`[${s}]`,e).each((r,i)=>{var o=i.getAttribute(s);if(o.indexOf("data.")<0){const a=o.search(/[(]/g);if(a>0)try{o=String(window[o.substring(0,a).trim()])}catch{o=""}}o.split("data.").forEach(a=>{if(a.trim()!=""){const c=a.search(/[^_A-Za-z0-9]/g);let l="";c>=0?l=a.substring(0,c):o.startsWith("data.")&&(l=a.replace("data.","")),l&&t(this,H).push({name:l,type:"string"})}})})});t(this,Xt).call(this)}},"#init"));p(this,qt,n),t(this,Ee).call(this)}get(){return t(this,H).map(n=>n.name)}getFields(){return t(this,H)}getType(n){const e=t(this,H).find(s=>s.name===n);return e?e.type:"string"}indexOf(n){return t(this,H).findIndex(e=>e.name===n)}includes(n){return t(this,H).some(e=>e.name===n)}};qt=new WeakMap,H=new WeakMap,Xt=new WeakMap,Ee=new WeakMap,h(ns,"ngFields");let We=ns;const rs=class rs extends HTMLElement{constructor(){super();d(this,mt);d(this,qe);d(this,Te,h(()=>{this.fields=new We(this),p(this,qe,new Ne(this)),S.log("NineTable connected."),this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{target:this}}))},"#init"));this.attachShadow({mode:"open"}),p(this,mt,new De(this))}connectedCallback(){t(this,Te).call(this)}disconnectedCallback(){S.log("NineTable disconnected.")}get data(){return t(this,mt).data}get row(){return t(this,mt).row}get dataManager(){return t(this,mt)}};mt=new WeakMap,qe=new WeakMap,Te=new WeakMap,h(rs,"NineTable");let ze=rs;customElements.get("nine-table")||customElements.define("nine-table",ze);const Kt=class Kt extends HTMLElement{constructor(){super()}applyBaseStyle(){this.constructor.name}connectedCallback(){}};h(Kt,"BasicCellElement"),C(Kt,"_styleCache",new Map),C(Kt,"_customStyleCache",new Map);let Be=Kt;const hs=class hs extends Be{constructor(){super();d(this,M);d(this,Gt);d(this,v);d(this,os);d(this,is);d(this,as);d(this,ls);C(this,"getDisplayText",h(e=>{if(t(this,v))if(t(this,v).closest("tbody")){const s=t(this,v).closest("tr").data,r=parseInt(t(this,v).dataset.row);if(!s)return"";if(ninegrid.isNull(t(this,v).dataset.expr)){if(!ninegrid.isNull(t(this,v).dataset.bind))return s[t(this,v).dataset.bind]||ninegrid.nvl(e,"")}else try{return this.getExprValue(t(this,v).dataset.expr,s,r,t(this,v))}catch{console.error(t(this,v).dataset.expr,s,t(this,v).dataset.row)}return ninegrid.nvl(e,"")}else try{return t(this,M).exprFunction(t(this,v).dataset.expr).call(this,null,-1,t(this,M).data)}catch{}},"getDisplayText"));d(this,cs,h(()=>{if(!(!t(this,M)||!t(this,M).template||!t(this,v).closest("tbody.bindable"))){var e=ninegrid.j.querySelectorAll(t(this,v)).attr("suppress");if(e&&(e=parseInt(e)),e&&!isNaN(e)){var s=t(this,v).closest("tr"),r=[];$("th,td",s).each((m,k)=>{var A=ninegrid.j.querySelectorAll(k).attr("suppress");A&&k.dataset.row&&(A=parseInt(A),!isNaN(A)&&A<=e&&r.push(A))}),r.sort();var i=!1;if(parseInt(s.sectionRowIndex/t(this,M).template.length)>0)for(var o of r){if(o>e)break;var a=parseInt(t(this,v).dataset.row),c=a-1,l=t(this,v).closest("tr").data,u=t(this,M).data.get(c);t(this,v).dataset.matrixRow;var f=t(this,M).body.querySelector(`tbody.bindable [suppress="${o}"][data-matrix-row="${t(this,v).dataset.matrixRow}"]`),b=f.dataset.expr?this.getExprValue(f.dataset.expr,l,a):l[f.dataset.bind],g=f.dataset.expr?this.getExprValue(f.dataset.expr,u,c):u[f.dataset.bind];if(b!=g){i=!0;break}}else i=!0;i?ninegrid.j.querySelectorAll(t(this,v)).removeClass("suppress"):ninegrid.j.querySelectorAll(t(this,v)).addClass("suppress"),ninegrid.j.querySelectorAll(t(this,v)).hasClass("hidden")||(i?ninegrid.j.querySelectorAll(t(this,v)).removeClass("hidden"):ninegrid.j.querySelectorAll(t(this,v)).addClass("hidden"));var y=parseInt(t(this,v).dataset.matrixRow),x=y-1,w=t(this,M).body.querySelector(`tbody.bindable [data-col="${t(this,v).dataset.col}"][data-matrix-row="${x}"]`);$(w).hasClass("suppress")&&!ninegrid.j.querySelectorAll(t(this,v)).hasClass("suppress")?ninegrid.j.querySelectorAll(w).removeClass("last-none-suppress").addClass("last-suppress"):!$(w).hasClass("suppress")&&ninegrid.j.querySelectorAll(t(this,v)).hasClass("suppress")?ninegrid.j.querySelectorAll(w).removeClass("last-suppress").addClass("last-none-suppress"):ninegrid.j.querySelectorAll(w).removeClass("last-none-suppress").removeClass("last-suppress")}}},"#resetSuppress"));C(this,"getExprValue",h((e,s,r,i)=>{if(typeof e<"u")try{r=parseInt(r);const o=e.replace("()","");return t(this,M)[o]?t(this,M)[o].call(this,s,r,t(this,v)):t(this,M).exprFunction(e).call(this,s,r,t(this,M).data)}catch{return["NG-COMBO"].includes(this.tagName)?"":e}else return e},"getExprValue"))}connectedCallback(){super.connectedCallback(),p(this,M,this.getRootNode().host),p(this,v,this.closest("th,td")),p(this,Gt,t(this,v).closest("tr"))}get value(){var e=!t(this,M)||!t(this,M).dataManager||!t(this,v)||!t(this,v).dataset||!t(this,v).dataset.row||!t(this,v).dataset.bind?"":t(this,v).closest("tr").data[t(this,v).dataset.bind];return e??""}set value(e){var s=parseInt(t(this,v).dataset.row);const r=this.getAttribute("update-row-state")!="false";s<0?t(this,M).data.setValueNF(parseInt(t(this,v).dataset.index),t(this,v).dataset.bind,e,r):t(this,M).data.setValue(s,t(this,v).dataset.bind,e,r)}get row(){return parseInt(t(this,v).dataset.row)}get data(){return t(this,v).closest("tr").data}refresh(){const e=t(this,v).dataset.bind;return parseInt(t(this,v).dataset.row),t(this,Gt).data[e]}};M=new WeakMap,Gt=new WeakMap,v=new WeakMap,os=new WeakMap,is=new WeakMap,as=new WeakMap,ls=new WeakMap,cs=new WeakMap,h(hs,"CellElement");let Pe=hs;const ds=class ds extends Pe{constructor(){super()}connectedCallback(){super.connectedCallback()}refresh(){return super.refresh()}};h(ds,"EditableCellElement");let Fe=ds;const us=class us extends Fe{constructor(){super();d(this,Zt);d(this,xt);d(this,Tt);d(this,Ct);d(this,Ce);d(this,et);C(this,"refresh",h(()=>{const e=super.refresh();t(this,Zt).value=e},"refresh"));d(this,fs,h(e=>{if(!["Escape","Enter","Tab","Home","End","ArrowLeft","ArrowRight","PageUp","PageDown","Backspace","Delete"].includes(e.code)){if(t(this,xt)=="number"){let i=[];if(t(this,et)&&Number(t(this,et))>0&&i.push("."),t(this,Ct)&&Number(t(this,Ct))>=0&&i.push("-"),!(e.keyCode>=48&&e.keyCode<=57||e.keyCode>=96&&e.keyCode<=105)&&!i.includes(e.key)&&e.preventDefault(),t(this,et)&&(e.keyCode>=48&&e.keyCode<=57||e.keyCode>=96&&e.keyCode<=105)&&e.target.selectionStart==e.target.selectionEnd){var s=e.target.value,r=s.indexOf(".");if(r>=0){var s=s.substr(r+1,s.length);s.length>=Number(t(this,et))&&e.preventDefault()}}}t(this,Tt)&&ninegrid.getByteLength(e.target.value)>=Number(t(this,Tt))&&e.target.selectionStart==e.target.selectionEnd&&e.preventDefault()}},"#onKeyDown"));if(this.applyBaseStyle(),p(this,xt,this.getAttribute("type")||"text"),p(this,Tt,this.getAttribute("maxbyte")),p(this,Ct,this.getAttribute("min")),p(this,Ce,this.getAttribute("max")),p(this,et,this.getAttribute("scale")),!["text","number"].includes(t(this,xt)))throw`invalid type : ${t(this,xt)}`}connectedCallback(){for(var e=[],s=0;s<this.attributes.length;s++)["type","maxlength","maxbyte","min","max","step","scale","text-align"].includes(this.attributes[s].name)&&e.push(`${this.attributes[s].name}="${this.attributes[s].value}"`);this.innerHTML=`
444
+ `,t(this,O).shadowRoot.querySelector("nine-table-sheets").classList.add("nodata");const a=t(this,O).shadowRoot.querySelectorAll("nine-table-sheet");a==null||a.forEach((c,l)=>{e[l]&&setTimeout(()=>{c.generate(e[l]),s&&t(this,jt).call(this)})})},"#render"));y(this,O,n),t(this,me).call(this)}};O=new WeakMap,me=new WeakMap,jt=new WeakMap,xe=new WeakMap,h(ts,"LayoutManager");let $e=ts;const es=class es{constructor(n){d(this,Ut);d(this,St,-1);C(this,"count",h(()=>t(this,Ut).rawRecords.length,"count"));y(this,Ut,n)}get at(){return t(this,St)}set at(n){y(this,St,parseInt(n,10)),body&&!body.querySelector(`tbody.bindable tr[data-row="${t(this,St)}"]`)&&setTimeout(()=>{})}};Ut=new WeakMap,St=new WeakMap,h(es,"ngRow");let Ne=es;const F=class F{constructor(n,e){d(this,W);d(this,I);d(this,z,[]);d(this,Rt,[]);d(this,we,0);d(this,Q,[]);d(this,ve,h(()=>{y(this,Q,[]);const n=t(this,W).template||[];Array.from(n).forEach(e=>{var s;t(this,Q).push(((s=e.getBoundingClientRect)==null?void 0:s.call(e).height)||24)}),(t(this,I).rawRecords||[]).forEach(e=>{e.__ng||(e.__ng=t(this,Vt).call(this)),e.__ng.height=t(this,Q).slice()})},"#initialize"));d(this,bt,h(()=>{const n=t(this,W).shadowRoot.querySelector("nine-table-sheets");n==null||n.classList.toggle("nodata",this.length===0),t(this,W).shadowRoot.querySelectorAll("nine-table-sheet").forEach(e=>{e.invalidate()})},"#invalidate"));C(this,"get",h((n,e)=>{var i;const s=this.getValidData();if(!s||s.length<=0)return;if(n==null)return t(this,At).call(this,s);if(n<0||n>=s.length)return null;const r=typeof((i=t(this,W).fields)==null?void 0:i.get)=="function"?t(this,W).fields.get():[];if(e!=null){const o=r.indexOf(e);return o>=0?s[n].v[o]:null}return t(this,At).call(this,s[n])},"get"));C(this,"set",h(n=>{this.clear(),this.add(n,!1),t(this,bt).call(this)},"set"));d(this,Vt,h(()=>({rowState:F.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:t(this,Q).slice(),o:{},c:{},_:[0,0,0,0,F.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,t(this,Q).slice(),-1,{},{}]}),"#getDefaultMeta"));C(this,"reset",h(()=>{y(this,z,[]),y(this,Rt,[]),t(this,bt).call(this)},"reset"));C(this,"clear",h(()=>{var n;t(this,I).rawRecords=[],y(this,z,[]),y(this,Rt,[]),(n=t(this,I).viewRecords)!=null&&n.reset&&t(this,I).viewRecords.reset()},"clear"));d(this,Se,h(n=>{var r;Array.isArray(n)||(n=[n]);const e=typeof((r=t(this,W).fields)==null?void 0:r.get)=="function"?t(this,W).fields.get():Object.keys(n[0]||{}),s=[];return n.forEach(i=>{const o={v:[]};e.forEach(a=>{o.v.push(i[a]!==void 0&&i[a]!==null?i[a]:"")}),s.push(o)}),s},"#json2Array"));d(this,Re,h(n=>(Array.isArray(n)||(n=[n]),n.forEach(e=>{e.__ng=t(this,Vt).call(this),e.__ng.rowid=this.nextId,e.__ng.rowState=F.ROW_STATE.INSERT,e.__ng._[0]=e.__ng.rowid}),n),"#defaultInsert"));C(this,"add",h((n,e=!0)=>{n===void 0&&(n={});const s=t(this,Se).call(this,n);t(this,I).rawRecords=t(this,I).rawRecords.concat(t(this,Re).call(this,s)),this.resetRecords();const r=this.count()-1;return e||s.forEach((i,o)=>{const a=t(this,I).rawRecords[r-o];a&&(a.__ng.rowState=F.ROW_STATE.EMPTY)}),t(this,bt).call(this),r},"add"));C(this,"delete",h(n=>{let e=[];Array.isArray(n)?e=n:typeof n>"u"?e=[t(this,I).host.row.at]:e=[parseInt(n,10)],e.sort((s,r)=>r-s).forEach(s=>{if(t(this,z)[s]){const r=t(this,z)[s].__ng.rowid;t(this,z)[s].__ng.rowState===F.ROW_STATE.INSERT?t(this,I).rawRecords=t(this,I).rawRecords.filter(i=>i.__ng.rowid!==r):t(this,I).rawRecords.forEach(i=>{i.__ng.rowid===r&&(i.__ng.deleted=!0,i.__ng.rowState=F.ROW_STATE.DELETE)})}}),this.resetRecords(),t(this,bt).call(this)},"delete"));C(this,"setValue",h((n,e,s)=>{var c;n=parseInt(n,10);const i=(typeof((c=t(this,W).fields)==null?void 0:c.get)=="function"?t(this,W).fields.get():[]).indexOf(e);if(i<0)return;const o=this.getValidData()[n];if(!o)return;const a=o.v[i];a!==s&&o.__ng.rowState!==F.ROW_STATE.INSERT&&(o.__ng.o.hasOwnProperty(e)||(o.__ng.o[e]=a),o.__ng.rowState=F.ROW_STATE.UPDATE),o.v[i]=s},"setValue"));C(this,"resetRecords",h(()=>{y(this,Rt,t(this,I).rawRecords.filter(n=>!n.__ng.deleted)),y(this,z,t(this,I).rawRecords.filter(n=>!n.__ng.deleted&&!n.__ng.filtered)),t(this,I).rawRecords.forEach((n,e)=>{n.__ng.rowidx=e}),t(this,z).forEach((n,e)=>{n.__ng.i=e})},"resetRecords"));C(this,"getValidData",h(()=>(t(this,z).length===0&&t(this,I).rawRecords.length>0&&this.resetRecords(),t(this,z)),"getValidData"));d(this,At,h(n=>{var o;if(!n)return n;const e=!Array.isArray(n),s=e?[n]:n,r=typeof((o=t(this,W).fields)==null?void 0:o.get)=="function"?t(this,W).fields.get():[],i=s.filter(a=>!a.__ng.deleted).map(a=>{const c={};return r.forEach((l,g)=>{c[l]=a.v?a.v[g]:a[l]}),c.__ng=a.__ng,c});return e?i[0]:i},"#conv"));C(this,"count",h(()=>this.getValidData().length,"count"));y(this,W,n),y(this,I,e),t(this,ve).call(this)}get source(){return t(this,At).call(this,t(this,I).rawRecords)}set source(n){this.clear(),this.add(n,!1)}get nextId(){return++ws(this,we)._}get count(){return t(this,z).length}get length(){return t(this,z).length}getRowCount(){return this.length}};W=new WeakMap,I=new WeakMap,z=new WeakMap,Rt=new WeakMap,we=new WeakMap,Q=new WeakMap,ve=new WeakMap,bt=new WeakMap,Vt=new WeakMap,Se=new WeakMap,Re=new WeakMap,At=new WeakMap,h(F,"ngData"),C(F,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let _e=F;const ss=class ss{constructor(n){d(this,pt);y(this,pt,n),this.row=new Ne(this),this.data=new _e(t(this,pt),this),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.pageCnt=25,this.viewRecords.reset=()=>{var e;(e=t(this,pt).view)!=null&&e.redraw&&t(this,pt).view.redraw()},this.setDataSource=e=>{this.data&&this.data.reset(),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.data.set(e||[])},this.getRowState=e=>{var r,i;const s=parseInt(e,10);if(!(s>=this.data.count()))return(i=(r=this.data.getValidData()[s])==null?void 0:r.__ng)==null?void 0:i.rowState},this.getRowPosition=()=>this.row.at,this.setRowPosition=e=>{this.row.at=e},this.scrollTo_V1=e=>(e<0&&(e=0),e>=this.rawRecords.length&&(e=this.rawRecords.length-1),this.viewRecords.rawIndex=e,this.viewRecords.reset&&this.viewRecords.reset(),!(e<=0||e>=this.rawRecords.length-1)),this.getColumn=(e,s)=>this.data.get(e,s),this.setColumn=(e,s,r)=>{e=parseInt(e,10),this.data.setValue(e,s,r)},this.setDataSource([])}};pt=new WeakMap,h(ss,"ngDataManager");let Oe=ss;const ns=class ns{constructor(n){d(this,Et);d(this,H,[]);C(this,"add",h((n,e="string")=>{n.forEach(s=>{t(this,H).some(r=>r.name===s)||t(this,H).push({name:s,type:e})}),t(this,Yt).call(this)},"add"));d(this,Yt,h(()=>{const n=new Map;t(this,H).forEach(e=>{n.set(e.name,e.type)}),y(this,H,Array.from(n,([e,s])=>({name:e,type:s}))),y(this,H,t(this,H).filter(e=>e.name!==""&&e.name!=="__ng")),t(this,H).sort((e,s)=>e.name.length<s.name.length?1:-1)},"#adjust"));d(this,Ae,h(()=>{y(this,H,[]),v.log(t(this,Et).querySelectorAll("table"));const n=Array.from(t(this,Et).querySelectorAll("table"));if(!(!n||n.length===0)){for(const e of n)v.log(e),$("[data-bind]",e).each((s,r)=>{const i=r.dataset.bind,o=r.getAttribute("data-type")||"string";i&&t(this,H).push({name:i,type:o})}),["data-expr","background-color","color","tooltip","visible","readonly","enable-button","enable-check","class-expr","icon-color","icon-src"].forEach(s=>{$(`[${s}]`,e).each((r,i)=>{var o=i.getAttribute(s);if(o.indexOf("data.")<0){const a=o.search(/[(]/g);if(a>0)try{o=String(window[o.substring(0,a).trim()])}catch{o=""}}o.split("data.").forEach(a=>{if(a.trim()!=""){const c=a.search(/[^_A-Za-z0-9]/g);let l="";c>=0?l=a.substring(0,c):o.startsWith("data.")&&(l=a.replace("data.","")),l&&t(this,H).push({name:l,type:"string"})}})})});t(this,Yt).call(this)}},"#init"));y(this,Et,n),t(this,Ae).call(this)}get(){return t(this,H).map(n=>n.name)}getFields(){return t(this,H)}getType(n){const e=t(this,H).find(s=>s.name===n);return e?e.type:"string"}indexOf(n){return t(this,H).findIndex(e=>e.name===n)}includes(n){return t(this,H).some(e=>e.name===n)}};Et=new WeakMap,H=new WeakMap,Yt=new WeakMap,Ae=new WeakMap,h(ns,"ngFields");let De=ns;const rs=class rs extends HTMLElement{constructor(){super();d(this,yt);d(this,Ee);d(this,qe,h(()=>{this.fields=new De(this),y(this,Ee,new $e(this)),v.log("NineTable connected."),this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{target:this}}))},"#init"));this.attachShadow({mode:"open"}),y(this,yt,new Oe(this))}connectedCallback(){t(this,qe).call(this)}disconnectedCallback(){v.log("NineTable disconnected.")}get data(){return t(this,yt).data}get row(){return t(this,yt).row}get dataManager(){return t(this,yt)}};yt=new WeakMap,Ee=new WeakMap,qe=new WeakMap,h(rs,"NineTable");let We=rs;customElements.get("nine-table")||customElements.define("nine-table",We);const Xt=class Xt extends HTMLElement{constructor(){super()}applyBaseStyle(){this.constructor.name}connectedCallback(){}};h(Xt,"BasicCellElement"),C(Xt,"_styleCache",new Map),C(Xt,"_customStyleCache",new Map);let ze=Xt;const hs=class hs extends ze{constructor(){super();d(this,M);d(this,Kt);d(this,S);d(this,os);d(this,is);d(this,as);d(this,ls);C(this,"getDisplayText",h(e=>{if(t(this,S))if(t(this,S).closest("tbody")){const s=t(this,S).closest("tr").data,r=parseInt(t(this,S).dataset.row);if(!s)return"";if(ninegrid.isNull(t(this,S).dataset.expr)){if(!ninegrid.isNull(t(this,S).dataset.bind))return s[t(this,S).dataset.bind]||ninegrid.nvl(e,"")}else try{return this.getExprValue(t(this,S).dataset.expr,s,r,t(this,S))}catch{console.error(t(this,S).dataset.expr,s,t(this,S).dataset.row)}return ninegrid.nvl(e,"")}else try{return t(this,M).exprFunction(t(this,S).dataset.expr).call(this,null,-1,t(this,M).data)}catch{}},"getDisplayText"));d(this,cs,h(()=>{if(!(!t(this,M)||!t(this,M).template||!t(this,S).closest("tbody.bindable"))){var e=ninegrid.j.querySelectorAll(t(this,S)).attr("suppress");if(e&&(e=parseInt(e)),e&&!isNaN(e)){var s=t(this,S).closest("tr"),r=[];$("th,td",s).each((m,k)=>{var A=ninegrid.j.querySelectorAll(k).attr("suppress");A&&k.dataset.row&&(A=parseInt(A),!isNaN(A)&&A<=e&&r.push(A))}),r.sort();var i=!1;if(parseInt(s.sectionRowIndex/t(this,M).template.length)>0)for(var o of r){if(o>e)break;var a=parseInt(t(this,S).dataset.row),c=a-1,l=t(this,S).closest("tr").data,g=t(this,M).data.get(c);t(this,S).dataset.matrixRow;var f=t(this,M).body.querySelector(`tbody.bindable [suppress="${o}"][data-matrix-row="${t(this,S).dataset.matrixRow}"]`),b=f.dataset.expr?this.getExprValue(f.dataset.expr,l,a):l[f.dataset.bind],u=f.dataset.expr?this.getExprValue(f.dataset.expr,g,c):g[f.dataset.bind];if(b!=u){i=!0;break}}else i=!0;i?ninegrid.j.querySelectorAll(t(this,S)).removeClass("suppress"):ninegrid.j.querySelectorAll(t(this,S)).addClass("suppress"),ninegrid.j.querySelectorAll(t(this,S)).hasClass("hidden")||(i?ninegrid.j.querySelectorAll(t(this,S)).removeClass("hidden"):ninegrid.j.querySelectorAll(t(this,S)).addClass("hidden"));var p=parseInt(t(this,S).dataset.matrixRow),x=p-1,w=t(this,M).body.querySelector(`tbody.bindable [data-col="${t(this,S).dataset.col}"][data-matrix-row="${x}"]`);$(w).hasClass("suppress")&&!ninegrid.j.querySelectorAll(t(this,S)).hasClass("suppress")?ninegrid.j.querySelectorAll(w).removeClass("last-none-suppress").addClass("last-suppress"):!$(w).hasClass("suppress")&&ninegrid.j.querySelectorAll(t(this,S)).hasClass("suppress")?ninegrid.j.querySelectorAll(w).removeClass("last-suppress").addClass("last-none-suppress"):ninegrid.j.querySelectorAll(w).removeClass("last-none-suppress").removeClass("last-suppress")}}},"#resetSuppress"));C(this,"getExprValue",h((e,s,r,i)=>{if(typeof e<"u")try{r=parseInt(r);const o=e.replace("()","");return t(this,M)[o]?t(this,M)[o].call(this,s,r,t(this,S)):t(this,M).exprFunction(e).call(this,s,r,t(this,M).data)}catch{return["NG-COMBO"].includes(this.tagName)?"":e}else return e},"getExprValue"))}connectedCallback(){super.connectedCallback(),y(this,M,this.getRootNode().host),y(this,S,this.closest("th,td")),y(this,Kt,t(this,S).closest("tr"))}get value(){var e=!t(this,M)||!t(this,M).dataManager||!t(this,S)||!t(this,S).dataset||!t(this,S).dataset.row||!t(this,S).dataset.bind?"":t(this,S).closest("tr").data[t(this,S).dataset.bind];return e??""}set value(e){var s=parseInt(t(this,S).dataset.row);const r=this.getAttribute("update-row-state")!="false";s<0?t(this,M).data.setValueNF(parseInt(t(this,S).dataset.index),t(this,S).dataset.bind,e,r):t(this,M).data.setValue(s,t(this,S).dataset.bind,e,r)}get row(){return parseInt(t(this,S).dataset.row)}get data(){return t(this,S).closest("tr").data}refresh(){const e=t(this,S).dataset.bind;return parseInt(t(this,S).dataset.row),t(this,Kt).data[e]}};M=new WeakMap,Kt=new WeakMap,S=new WeakMap,os=new WeakMap,is=new WeakMap,as=new WeakMap,ls=new WeakMap,cs=new WeakMap,h(hs,"CellElement");let Be=hs;const ds=class ds extends Be{constructor(){super()}connectedCallback(){super.connectedCallback()}refresh(){return super.refresh()}};h(ds,"EditableCellElement");let Pe=ds;const us=class us extends Pe{constructor(){super();d(this,Gt);d(this,mt);d(this,qt);d(this,Tt);d(this,Te);d(this,tt);C(this,"refresh",h(()=>{const e=super.refresh();t(this,Gt).value=e},"refresh"));d(this,fs,h(e=>{if(!["Escape","Enter","Tab","Home","End","ArrowLeft","ArrowRight","PageUp","PageDown","Backspace","Delete"].includes(e.code)){if(t(this,mt)=="number"){let i=[];if(t(this,tt)&&Number(t(this,tt))>0&&i.push("."),t(this,Tt)&&Number(t(this,Tt))>=0&&i.push("-"),!(e.keyCode>=48&&e.keyCode<=57||e.keyCode>=96&&e.keyCode<=105)&&!i.includes(e.key)&&e.preventDefault(),t(this,tt)&&(e.keyCode>=48&&e.keyCode<=57||e.keyCode>=96&&e.keyCode<=105)&&e.target.selectionStart==e.target.selectionEnd){var s=e.target.value,r=s.indexOf(".");if(r>=0){var s=s.substr(r+1,s.length);s.length>=Number(t(this,tt))&&e.preventDefault()}}}t(this,qt)&&ninegrid.getByteLength(e.target.value)>=Number(t(this,qt))&&e.target.selectionStart==e.target.selectionEnd&&e.preventDefault()}},"#onKeyDown"));if(this.applyBaseStyle(),y(this,mt,this.getAttribute("type")||"text"),y(this,qt,this.getAttribute("maxbyte")),y(this,Tt,this.getAttribute("min")),y(this,Te,this.getAttribute("max")),y(this,tt,this.getAttribute("scale")),!["text","number"].includes(t(this,mt)))throw`invalid type : ${t(this,mt)}`}connectedCallback(){for(var e=[],s=0;s<this.attributes.length;s++)["type","maxlength","maxbyte","min","max","step","scale","text-align"].includes(this.attributes[s].name)&&e.push(`${this.attributes[s].name}="${this.attributes[s].value}"`);this.innerHTML=`
445
445
  <input type="text"
446
446
  ${e.join(" ")}
447
447
  ondragstart="return false;"
448
448
  >
449
- `,super.connectedCallback(),p(this,Zt,this.querySelector("input"))}};Zt=new WeakMap,xt=new WeakMap,Tt=new WeakMap,Ct=new WeakMap,Ce=new WeakMap,et=new WeakMap,fs=new WeakMap,h(us,"CellInputText");let je=us;customElements.get("cell-input-text"),customElements.get("cell-input")||customElements.define("cell-input",je)});
449
+ `,super.connectedCallback(),y(this,Gt,this.querySelector("input"))}};Gt=new WeakMap,mt=new WeakMap,qt=new WeakMap,Tt=new WeakMap,Te=new WeakMap,tt=new WeakMap,fs=new WeakMap,h(us,"CellInputText");let Fe=us;customElements.get("cell-input-text"),customElements.get("cell-input")||customElements.define("cell-input",Fe)});
450
450
  //# sourceMappingURL=nine-table.umd.js.map