@ninebone/table 0.0.695 → 0.0.696

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.
@@ -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,st).querySelector(".ng-container-body .ng-part-body");if(!s){setTimeout(e,10);return}p(this,C,{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,Ft).call(this),this.refresh()},"initWhenReady");e()}};et=new WeakMap,st=new WeakMap,dt=new WeakMap,C=new WeakMap,St=new WeakMap,Et=new WeakMap,Ft=new WeakMap,h(Ce,"NineTableVScrollBar");let wt=Ce;customElements.get("nine-table-vscrollbar")||customElements.define("nine-table-vscrollbar",wt);const Ie=class Ie{constructor(n){d(this,j);d(this,A);d(this,nt);d(this,D,new Map);d(this,N,null);d(this,U,null);d(this,rt,0);d(this,At,40);d(this,Le,!1);d(this,He,!1);d(this,Vt,3);q(this,"refresh",h(()=>{var e;x.log("rowManager.refresh");const n=t(this,A).querySelector(".ng-container-body .ng-part-body");n&&(t(this,Rt).call(this),t(this,qt).call(this),t(this,ft).call(this,n.scrollTop),(e=t(this,A).querySelector("nine-table-vscrollbar"))==null||e.refresh())},"refresh"));q(this,"initialize",h(()=>{x.log("rowManager.initialize"),p(this,nt,{scrollTables:t(this,A).querySelectorAll(".ng-part-body table"),firstTr:t(this,A).querySelector(".ng-container-body .ng-part-body tbody.bindable-tbody tr:not(.nodata)")}),p(this,N,null),t(this,D).clear(),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(o=>{const a=t(this,A).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 g=Array.from(l.querySelectorAll("tr")).map(b=>b.cloneNode(!0));t(this,D).set(o,g)});const n=t(this,A).querySelector(".ng-container-body .ng-part-body"),e=t(this,A).querySelector(".ng-container-left .ng-part-body"),s=t(this,A).querySelector(".ng-container-right .ng-part-body"),r=t(this,A).querySelector(".ng-container-body .ng-part-header"),i=t(this,A).querySelector(".ng-container-body .ng-part-footer");if(n){t(this,Rt).call(this),t(this,kt).call(this),t(this,qt).call(this),t(this,ft).call(this,n.scrollTop);let o=!1;const a=h(c=>{var g;if(o)return;o=!0;const l=c.scrollTop,f=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!==f&&(r.scrollLeft=f),i&&i.scrollLeft!==f&&(i.scrollLeft=f),t(this,ft).call(this,l),(g=t(this,A).querySelector("nine-table-vscrollbar"))==null||g.refresh(),o=!1},"handleContainerScroll");[n,e,s].forEach(c=>{c==null||c.addEventListener("scroll",()=>{a(c)})})}},"initialize"));d(this,Yt,h((n,e)=>{x.log("rowManager.#renderRows");const s=t(this,D).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,At);a++)s.forEach(c=>{o.appendChild(c.cloneNode(!0))});i?i.before(o):r.appendChild(o),e===".ng-container-body"&&(t(this,nt).firstTr=r.querySelector("tr:not(.nodata)"))},"#renderRows"));d(this,Rt,h(()=>{if(t(this,N)!==null&&t(this,N)>0)return t(this,N);const n=t(this,A).querySelector(".ng-container-body .ng-part-body");x.log("rowManager.#measureAndCacheHeight");const e=t(this,D).get(".ng-container-body");if(!e||e.length===0)throw new Error("invalid dom");const s=n.querySelector("tbody.bindable-tbody");if(x.log(s),!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,A),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 f=0;const g=s.querySelectorAll("tr");return g.forEach(b=>{let u=b.offsetHeight||b.getBoundingClientRect().height;if(u===0){const m=window.getComputedStyle(b);u=parseFloat(m.height)||parseFloat(m.minHeight)||0}f+=u}),g.forEach(b=>b.remove()),o.style.display=a,o.style.visibility=c,o.style.position=l,f<=0?-1:(p(this,N,f),t(this,Tt).call(this),t(this,N))},"#measureAndCacheHeight"));d(this,qt,h(()=>{x.log("rowManager.#updateVirtualScrollHeight");const e=(t(this,j).data.get()||[]).length,s=t(this,N),r=e*s;x.log("🔍 [VirtualHeight]",{totalCount:e,rowHeight:s,totalVirtualHeight:r}),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(i=>{const o=t(this,A).querySelector(i);if(!o)return;const a=o.querySelector(".ng-part-body .ng-virtual-spacer");a&&(a.style.height=`${r}px`)})},"#updateVirtualScrollHeight"));d(this,Tt,h(()=>{if(t(this,rt)>0&&t(this,N)>0){const n=Math.ceil(t(this,rt)/t(this,N));p(this,At,n+t(this,Vt))}},"#updateRowCount"));d(this,Ut,h(()=>{var a,c,l,f,g,b;const n=t(this,A).querySelector(".ng-container-left .ng-part-body table"),e=t(this,A).querySelector(".ng-container-body .ng-part-body table"),s=t(this,A).querySelector(".ng-container-right .ng-part-body table");if(e){const u=n?Array.from(n.querySelectorAll("tbody tr")):[],m=Array.from(e.querySelectorAll("tbody tr")),w=s?Array.from(s.querySelectorAll("tbody tr")):[],T=Math.max(u.length,m.length,w.length);for(let v=0;v<T;v++){const _=[((a=u[v])==null?void 0:a.getBoundingClientRect().height)||0,((c=m[v])==null?void 0:c.getBoundingClientRect().height)||0,((l=w[v])==null?void 0:l.getBoundingClientRect().height)||0],k=Math.max(..._);k>0&&(u[v]&&(u[v].style.height=`${k}px`),m[v]&&(m[v].style.height=`${k}px`),w[v]&&(w[v].style.height=`${k}px`))}}const r=t(this,A).querySelector(".ng-container-left .ng-part-footer table"),i=t(this,A).querySelector(".ng-container-body .ng-part-footer table"),o=t(this,A).querySelector(".ng-container-right .ng-part-footer table");if(i){const u=r?Array.from(r.querySelectorAll("tfoot tr")):[],m=Array.from(i.querySelectorAll("tfoot tr")),w=o?Array.from(o.querySelectorAll("tfoot tr")):[],T=Math.max(u.length,m.length,w.length);for(let v=0;v<T;v++){const _=[((f=u[v])==null?void 0:f.getBoundingClientRect().height)||0,((g=m[v])==null?void 0:g.getBoundingClientRect().height)||0,((b=w[v])==null?void 0:b.getBoundingClientRect().height)||0],k=Math.max(..._);k>0&&(u[v]&&(u[v].style.height=`${k}px`),m[v]&&(m[v].style.height=`${k}px`),w[v]&&(w[v].style.height=`${k}px`))}}},"#syncRowHeights"));d(this,Xt,h(()=>{!t(this,A)||!(t(this,A)instanceof HTMLElement)||(p(this,U,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,rt)!==c&&(p(this,rt,c),t(this,Tt).call(this),t(this,N)!==null&&(t(this,kt).call(this),this.refresh()))}}})),t(this,U).observe(t(this,A)))},"#initResizeObserver"));d(this,kt,h(()=>{x.log("rowManager.#renderAllContainers"),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(n=>{const e=t(this,A).querySelector(n);e&&e.querySelector(".ng-part-body tbody.bindable-tbody")&&t(this,Yt).call(this,e,n)}),t(this,Kt).call(this),t(this,Ut).call(this)},"#renderAllContainers"));d(this,Me,h(n=>{[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(e=>{var l;const s=t(this,A).querySelector(e);if(!s)return;const r=s.querySelector(".ng-part-body tbody.bindable-tbody");if(!r)return;const i=Array.from(r.querySelectorAll("tr:not(.nodata)")),o=((l=t(this,D).get(e))==null?void 0:l.length)||1,c=(t(this,j).data.get()||[]).length;i.forEach((f,g)=>{const b=n+Math.floor(g/o);if(b>=c){f.style.visibility="hidden";return}const u=t(this,j).data.get(b);f.style.display="",t(this,Ct).call(this,f,u,b)})})},"#adjustBufferRows"));d(this,ft,h(n=>{var g,b;const e=t(this,N);if(!e||e<=0)return;const s=t(this,j).data.length;if(s===0)return;const r=((g=t(this,D).get(".ng-container-body"))==null?void 0:g.length)||1,i=t(this,A).querySelector(".ng-container-body .ng-part-body");x.log("bodyContainer.clientHeight",i.clientHeight);const 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);x.log(`📜 [Scroll Calc] maxStartIndex: ${o}, startIndex: ${a}, offsetY: ${c}`),a===o&&x.log(`📜 [Scroll Inspect] scrollTop: ${n}, rowHeight: ${e}, maxStartIndex: ${o}, startIndex: ${a}, offsetY: ${c}`);const l=t(this,nt).firstTr,f=l&&l.dataset.row!==void 0?parseInt(l.dataset.row,10):-1;(b=t(this,nt))==null||b.scrollTables.forEach(u=>{u.style.transform=`translate3d(0, ${c}px, 0)`}),f!==a&&(x.log(`🔄 [Row Bind Trigger] currentStartIndex(${f}) !== startIndex(${a})`),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(u=>{const m=t(this,A).querySelector(u);if(!m)return;const w=m.querySelector(".ng-part-body tbody.bindable-tbody");if(!w)return;Array.from(w.querySelectorAll("tr:not(.nodata)")).forEach((v,_)=>{const k=a+Math.floor(_/r);if(k>=s){v.style.display="none";return}const B=t(this,j).data.get(k);v.style.display="",t(this,Ct).call(this,v,B,k)})}))},"#handleScroll"));d(this,Ct,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,Kt,h(()=>{var c,l,f;x.log("rowManager.#syncHeaderHeights");const n=t(this,A).querySelector(".ng-container-left .ng-part-header table"),e=t(this,A).querySelector(".ng-container-body .ng-part-header table"),s=t(this,A).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 g=0;g<a;g++){const b=[((c=r[g])==null?void 0:c.getBoundingClientRect().height)||0,((l=i[g])==null?void 0:l.getBoundingClientRect().height)||0,((f=o[g])==null?void 0:f.getBoundingClientRect().height)||0],u=Math.max(...b);u>0&&(r[g]&&(r[g].style.height=`${u}px`),i[g]&&(i[g].style.height=`${u}px`),o[g]&&(o[g].style.height=`${u}px`))}},"#syncHeaderHeights"));q(this,"destroy",h(()=>{t(this,U)&&(t(this,U).disconnect(),p(this,U,null))},"destroy"));p(this,j,n.getRootNode().host),p(this,A,n),t(this,Xt).call(this)}getRowHeight(){return t(this,N)}templateLength(n=".ng-container-body"){var e;return((e=t(this,D).get(n))==null?void 0:e.length)||1}};j=new WeakMap,A=new WeakMap,nt=new WeakMap,D=new WeakMap,N=new WeakMap,U=new WeakMap,rt=new WeakMap,At=new WeakMap,Le=new WeakMap,He=new WeakMap,Vt=new WeakMap,Yt=new WeakMap,Rt=new WeakMap,qt=new WeakMap,Tt=new WeakMap,Ut=new WeakMap,Xt=new WeakMap,kt=new WeakMap,Me=new WeakMap,ft=new WeakMap,Ct=new WeakMap,Kt=new WeakMap,h(Ie,"RowManager");let ue=Ie;const Zt=class Zt{static compileAll(n){return Array.isArray(n)?n.map(e=>Zt.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 f=l.getAttribute("cell-type")||"renderer";if(l.children.length>0&&l.firstElementChild.tagName.includes("-"))return;let g=`cell-${f}`;const b=l.getAttribute("data-bind"),u=l.getAttribute("data-expr"),m=l.getAttribute("maxbyte"),w=l.getAttribute("type");let T=[];b&&T.push(`data-bind="${b}"`),u&&T.push(`data-expr="${u}"`),m&&T.push(`maxbyte="${m}"`),w&&T.push(`type="${w}"`),l.innerHTML=`<${g} ${T.join(" ")}></${g}>`})},"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,f=document.createElement("colgroup"),g=Math.max(Math.floor(a.clientWidth/l),100);for(let b=0;b<l;b++){const u=document.createElement("col");u.setAttribute("width",g),f.appendChild(u)}a.prepend(f)}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")),f=Array.from(a.querySelectorAll(c+" th,"+c+" td")),g=l.length;if(g===0||f.length===0)return;let b=0;f.forEach(m=>{b+=m.colSpan||1});const u=Array.from(Array(g),()=>Array(b).fill(null));l.forEach(m=>{const w=m.sectionRowIndex;let T=0;Array.from(m.querySelectorAll("th,td")).forEach(v=>{for(let B=0;B<u[w].length;B++)if(u[w][B]===null){T=B;break}const _=v.rowSpan||1,k=v.colSpan||1;for(let B=0;B<_;B++)for(let Z=0;Z<k;Z++)w+B<g&&T+Z<b&&(u[w+B][T+Z]=B===0&&Z===0?"1":"0")})}),l.forEach(m=>{const w=m.sectionRowIndex;Array.from(m.querySelectorAll("th,td")).forEach(T=>{for(let v=0;v<u[w].length;v++)if(u[w][v]==="1"){T.dataset.col=v,u[w][v]="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(f=>{f.setAttribute("fixed",l)})}),i}};h(Zt,"TableCompiler");let ge=Zt;const $e=class $e{constructor(n){d(this,ut);d(this,F);d(this,Lt,{startRow:-1,startCol:-1,endRow:-1,endCol:-1});q(this,"render",h(()=>{const{startRow:n,startCol:e,endRow:s,endCol:r}=t(this,Lt);t(this,F).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body").forEach(o=>{o.querySelectorAll(".selected, .selected-top, .selected-bottom, .selected-left, .selected-right").forEach(a=>{a.classList.remove("selected","selected-top","selected-bottom","selected-left","selected-right")}),!(n<0)&&o.querySelectorAll("tbody tr").forEach(a=>{const c=parseInt(a.dataset.row,10);isNaN(c)||a.querySelectorAll("td, th").forEach(l=>{const f=parseInt(l.dataset.col,10);if(isNaN(f))return;const g=parseInt(l.rowSpan||1,10),b=parseInt(l.colSpan||1,10),u=c+g-1,m=f+b-1;c<=s&&u>=n&&f<=r&&m>=e&&(l.classList.add("selected"),c===n&&l.classList.add("selected-top"),u===s&&l.classList.add("selected-bottom"),f===e&&l.classList.add("selected-left"),m===r&&l.classList.add("selected-right"))})})})},"render"));p(this,F,n),Ge(this,ut,is).call(this)}setRange(n,e,s,r){let i=Math.min(n,s),o=Math.max(n,s),a=Math.min(e,r),c=Math.max(e,r);const l=Ge(this,ut,rs).call(this,i,a,o,c);p(this,Lt,l),this.render()}};F=new WeakMap,Lt=new WeakMap,ut=new WeakSet,rs=h(function(n,e,s,r){let i=n,o=e,a=s,c=r,l=!0;const f=t(this,F).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body");for(;l;)l=!1,f.forEach(g=>{g.querySelectorAll("tbody tr").forEach(b=>{const u=parseInt(b.dataset.row,10);isNaN(u)||b.querySelectorAll("td, th").forEach(m=>{const w=parseInt(m.dataset.col,10);if(isNaN(w))return;const T=parseInt(m.rowSpan||1,10),v=parseInt(m.colSpan||1,10),_=u+T-1,k=w+v-1;if(u<=a&&_>=i&&w<=c&&k>=o){const Z=Math.min(i,u),Je=Math.max(a,_),Qe=Math.min(o,w),ts=Math.max(c,k);(Z!==i||Je!==a||Qe!==o||ts!==c)&&(i=Z,a=Je,o=Qe,c=ts,l=!0)}})})});return{startRow:i,startCol:o,endRow:a,endCol:c}},"#expandRangeByMerge"),is=h(function(){const n=this.selector?t(this,F).querySelector(".ng-container-top"):t(this,F).querySelector(".ng-container-top");n&&n.addEventListener("mousedown",e=>{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;const r=parseInt(s.dataset.row,10),i=parseInt(s.dataset.col,10);this.setRange(r,i,r,i);const o=h(c=>{const l=document.elementFromPoint(c.clientX,c.clientY),f=l==null?void 0:l.closest("td, th");if(!f||!t(this,F).contains(f)||f.dataset.row===void 0||f.dataset.col===void 0||f.closest("tr").classList.contains("nodata"))return;const g=parseInt(f.dataset.row,10),b=parseInt(f.dataset.col,10);this.setRange(r,i,g,b)},"onMouseMove"),a=h(()=>{document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",a)},"onMouseUp");document.addEventListener("mousemove",o),document.addEventListener("mouseup",a)})},"#initEvents"),h($e,"CellSelection");let be=$e;const Mt=class Mt extends HTMLElement{constructor(){super();d(this,Gt);d(this,it,null);d(this,ot);d(this,Ht);q(this,"invalidate",h(()=>{x.log("sheet.invalidate()"),t(this,ot).refresh()},"invalidate"));q(this,"generate",h(e=>{if(x.log("sheet.generate()"),!e)return;p(this,it,ge.compile(e)),t(this,Jt).call(this),t(this,Qt).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,ot).initialize(),setTimeout(()=>{var o;(o=this.querySelector("nine-table-hscrollbar"))==null||o.refresh()},0)},"generate"));d(this,Jt,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,gt).call(this,t(this,it),r,"header")),(o=this.querySelector(`${s} .ng-virtual-spacer`))==null||o.before(t(this,gt).call(this,t(this,it),r,"body")),(a=this.querySelector(`${s} .ng-part-footer`))==null||a.appendChild(t(this,gt).call(this,t(this,it),r,"footer"))})},"#renderSplitContainers"));d(this,Qt,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(i)||(i+=a)}),e==="body"?s.style.flex="1":(s.style.flex=`0 0 ${i}px`,s.style.width=`${i}px`)})},"#updateContainerWidths"));d(this,gt,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 f=document.createElement("tbody");f.className="fixed-tbody",i.appendChild(f)}}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"));q(this,"getRowHeight",h(()=>t(this,ot).getRowHeight(),"getRowHeight"));q(this,"scrollToX",h(e=>{const s=this.querySelector(".ng-container-body .ng-part-body");s&&(s.scrollLeft=e)},"scrollToX"));q(this,"scrollToY",h(e=>{const s=this.querySelector(".ng-container-body .ng-part-body");s&&(s.scrollTop=e)},"scrollToY"));d(this,te,h(()=>{t(this,ee).call(this)},"#init"));d(this,ee,h(()=>{const e=Mt.SCROLLBAR_SIZE;this.innerHTML=`
126
+ `;const e=h(()=>{const s=t(this,st).querySelector(".ng-container-body .ng-part-body");if(!s){setTimeout(e,10);return}p(this,C,{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,Ft).call(this),this.refresh()},"initWhenReady");e()}};et=new WeakMap,st=new WeakMap,dt=new WeakMap,C=new WeakMap,St=new WeakMap,Et=new WeakMap,Ft=new WeakMap,h(Ce,"NineTableVScrollBar");let wt=Ce;customElements.get("nine-table-vscrollbar")||customElements.define("nine-table-vscrollbar",wt);const Ie=class Ie{constructor(n){d(this,j);d(this,A);d(this,nt);d(this,D,new Map);d(this,N,null);d(this,U,null);d(this,rt,0);d(this,At,40);d(this,Le,!1);d(this,He,!1);d(this,Vt,3);q(this,"refresh",h(()=>{var e;x.log("rowManager.refresh");const n=t(this,A).querySelector(".ng-container-body .ng-part-body");n&&(t(this,Rt).call(this),t(this,qt).call(this),t(this,ft).call(this,n.scrollTop),(e=t(this,A).querySelector("nine-table-vscrollbar"))==null||e.refresh())},"refresh"));q(this,"initialize",h(()=>{x.log("rowManager.initialize"),p(this,nt,{scrollTables:t(this,A).querySelectorAll(".ng-part-body table"),firstTr:t(this,A).querySelector(".ng-container-body .ng-part-body tbody.bindable-tbody tr:not(.nodata)")}),p(this,N,null),t(this,D).clear(),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(o=>{const a=t(this,A).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 g=Array.from(l.querySelectorAll("tr")).map(b=>b.cloneNode(!0));t(this,D).set(o,g)});const n=t(this,A).querySelector(".ng-container-body .ng-part-body"),e=t(this,A).querySelector(".ng-container-left .ng-part-body"),s=t(this,A).querySelector(".ng-container-right .ng-part-body"),r=t(this,A).querySelector(".ng-container-body .ng-part-header"),i=t(this,A).querySelector(".ng-container-body .ng-part-footer");if(n){t(this,Rt).call(this),t(this,kt).call(this),t(this,qt).call(this),t(this,ft).call(this,n.scrollTop);let o=!1;const a=h(c=>{var g;if(o)return;o=!0;const l=c.scrollTop,f=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!==f&&(r.scrollLeft=f),i&&i.scrollLeft!==f&&(i.scrollLeft=f),t(this,ft).call(this,l),(g=t(this,A).querySelector("nine-table-vscrollbar"))==null||g.refresh(),o=!1},"handleContainerScroll");[n,e,s].forEach(c=>{c==null||c.addEventListener("scroll",()=>{a(c)})})}},"initialize"));d(this,Yt,h((n,e)=>{x.log("rowManager.#renderRows");const s=t(this,D).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,At);a++)s.forEach(c=>{o.appendChild(c.cloneNode(!0))});i?i.before(o):r.appendChild(o),e===".ng-container-body"&&(t(this,nt).firstTr=r.querySelector("tr:not(.nodata)"))},"#renderRows"));d(this,Rt,h(()=>{if(t(this,N)!==null&&t(this,N)>0)return t(this,N);const n=t(this,A).querySelector(".ng-container-body .ng-part-body");x.log("rowManager.#measureAndCacheHeight");const e=t(this,D).get(".ng-container-body");if(!e||e.length===0)throw new Error("invalid dom");const s=n.querySelector("tbody.bindable-tbody");if(x.log(s),!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,A),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 f=0;const g=s.querySelectorAll("tr");return g.forEach(b=>{let u=b.offsetHeight||b.getBoundingClientRect().height;if(u===0){const m=window.getComputedStyle(b);u=parseFloat(m.height)||parseFloat(m.minHeight)||0}f+=u}),g.forEach(b=>b.remove()),o.style.display=a,o.style.visibility=c,o.style.position=l,f<=0?-1:(p(this,N,f),t(this,Tt).call(this),t(this,N))},"#measureAndCacheHeight"));d(this,qt,h(()=>{x.log("rowManager.#updateVirtualScrollHeight");const e=(t(this,j).data.get()||[]).length,s=t(this,N),r=e*s;x.log("🔍 [VirtualHeight]",{totalCount:e,rowHeight:s,totalVirtualHeight:r}),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(i=>{const o=t(this,A).querySelector(i);if(!o)return;const a=o.querySelector(".ng-part-body .ng-virtual-spacer");a&&(a.style.height=`${r}px`)})},"#updateVirtualScrollHeight"));d(this,Tt,h(()=>{if(t(this,rt)>0&&t(this,N)>0){const n=Math.ceil(t(this,rt)/t(this,N));p(this,At,n+t(this,Vt))}},"#updateRowCount"));d(this,Ut,h(()=>{var a,c,l,f,g,b;const n=t(this,A).querySelector(".ng-container-left .ng-part-body table"),e=t(this,A).querySelector(".ng-container-body .ng-part-body table"),s=t(this,A).querySelector(".ng-container-right .ng-part-body table");if(e){const u=n?Array.from(n.querySelectorAll("tbody tr")):[],m=Array.from(e.querySelectorAll("tbody tr")),w=s?Array.from(s.querySelectorAll("tbody tr")):[],T=Math.max(u.length,m.length,w.length);for(let v=0;v<T;v++){const _=[((a=u[v])==null?void 0:a.getBoundingClientRect().height)||0,((c=m[v])==null?void 0:c.getBoundingClientRect().height)||0,((l=w[v])==null?void 0:l.getBoundingClientRect().height)||0],k=Math.max(..._);k>0&&(u[v]&&(u[v].style.height=`${k}px`),m[v]&&(m[v].style.height=`${k}px`),w[v]&&(w[v].style.height=`${k}px`))}}const r=t(this,A).querySelector(".ng-container-left .ng-part-footer table"),i=t(this,A).querySelector(".ng-container-body .ng-part-footer table"),o=t(this,A).querySelector(".ng-container-right .ng-part-footer table");if(i){const u=r?Array.from(r.querySelectorAll("tfoot tr")):[],m=Array.from(i.querySelectorAll("tfoot tr")),w=o?Array.from(o.querySelectorAll("tfoot tr")):[],T=Math.max(u.length,m.length,w.length);for(let v=0;v<T;v++){const _=[((f=u[v])==null?void 0:f.getBoundingClientRect().height)||0,((g=m[v])==null?void 0:g.getBoundingClientRect().height)||0,((b=w[v])==null?void 0:b.getBoundingClientRect().height)||0],k=Math.max(..._);k>0&&(u[v]&&(u[v].style.height=`${k}px`),m[v]&&(m[v].style.height=`${k}px`),w[v]&&(w[v].style.height=`${k}px`))}}},"#syncRowHeights"));d(this,Xt,h(()=>{!t(this,A)||!(t(this,A)instanceof HTMLElement)||(p(this,U,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,rt)!==c&&(p(this,rt,c),t(this,Tt).call(this),t(this,N)!==null&&(t(this,kt).call(this),this.refresh()))}}})),t(this,U).observe(t(this,A)))},"#initResizeObserver"));d(this,kt,h(()=>{x.log("rowManager.#renderAllContainers"),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(n=>{const e=t(this,A).querySelector(n);e&&e.querySelector(".ng-part-body tbody.bindable-tbody")&&t(this,Yt).call(this,e,n)}),t(this,Kt).call(this),t(this,Ut).call(this)},"#renderAllContainers"));d(this,Me,h(n=>{[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(e=>{var l;const s=t(this,A).querySelector(e);if(!s)return;const r=s.querySelector(".ng-part-body tbody.bindable-tbody");if(!r)return;const i=Array.from(r.querySelectorAll("tr:not(.nodata)")),o=((l=t(this,D).get(e))==null?void 0:l.length)||1,c=(t(this,j).data.get()||[]).length;i.forEach((f,g)=>{const b=n+Math.floor(g/o);if(b>=c){f.style.visibility="hidden";return}const u=t(this,j).data.get(b);f.style.display="",t(this,Ct).call(this,f,u,b)})})},"#adjustBufferRows"));d(this,ft,h(n=>{var g,b;const e=t(this,N);if(!e||e<=0)return;const s=t(this,j).data.length;if(s===0)return;const r=((g=t(this,D).get(".ng-container-body"))==null?void 0:g.length)||1,i=t(this,A).querySelector(".ng-container-body .ng-part-body");x.log("bodyContainer.clientHeight",i.clientHeight);const 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);x.log(`📜 [Scroll Calc] maxStartIndex: ${o}, startIndex: ${a}, offsetY: ${c}`),a===o&&x.log(`📜 [Scroll Inspect] scrollTop: ${n}, rowHeight: ${e}, maxStartIndex: ${o}, startIndex: ${a}, offsetY: ${c}`);const l=t(this,nt).firstTr,f=l&&l.dataset.row!==void 0?parseInt(l.dataset.row,10):-1;(b=t(this,nt))==null||b.scrollTables.forEach(u=>{u.style.transform=`translate3d(0, ${c}px, 0)`}),f!==a&&(x.log(`🔄 [Row Bind Trigger] currentStartIndex(${f}) !== startIndex(${a})`),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(u=>{const m=t(this,A).querySelector(u);if(!m)return;const w=m.querySelector(".ng-part-body tbody.bindable-tbody");if(!w)return;Array.from(w.querySelectorAll("tr:not(.nodata)")).forEach((v,_)=>{const k=a+Math.floor(_/r);if(k>=s){v.style.display="none";return}const B=t(this,j).data.get(k);v.style.display="",t(this,Ct).call(this,v,B,k)})}))},"#handleScroll"));d(this,Ct,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,Kt,h(()=>{var c,l,f;x.log("rowManager.#syncHeaderHeights");const n=t(this,A).querySelector(".ng-container-left .ng-part-header table"),e=t(this,A).querySelector(".ng-container-body .ng-part-header table"),s=t(this,A).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 g=0;g<a;g++){const b=[((c=r[g])==null?void 0:c.getBoundingClientRect().height)||0,((l=i[g])==null?void 0:l.getBoundingClientRect().height)||0,((f=o[g])==null?void 0:f.getBoundingClientRect().height)||0],u=Math.max(...b);u>0&&(r[g]&&(r[g].style.height=`${u}px`),i[g]&&(i[g].style.height=`${u}px`),o[g]&&(o[g].style.height=`${u}px`))}},"#syncHeaderHeights"));q(this,"destroy",h(()=>{t(this,U)&&(t(this,U).disconnect(),p(this,U,null))},"destroy"));p(this,j,n.getRootNode().host),p(this,A,n),t(this,Xt).call(this)}getRowHeight(){return t(this,N)}templateLength(n=".ng-container-body"){var e;return((e=t(this,D).get(n))==null?void 0:e.length)||1}};j=new WeakMap,A=new WeakMap,nt=new WeakMap,D=new WeakMap,N=new WeakMap,U=new WeakMap,rt=new WeakMap,At=new WeakMap,Le=new WeakMap,He=new WeakMap,Vt=new WeakMap,Yt=new WeakMap,Rt=new WeakMap,qt=new WeakMap,Tt=new WeakMap,Ut=new WeakMap,Xt=new WeakMap,kt=new WeakMap,Me=new WeakMap,ft=new WeakMap,Ct=new WeakMap,Kt=new WeakMap,h(Ie,"RowManager");let ue=Ie;const Zt=class Zt{static compileAll(n){return Array.isArray(n)?n.map(e=>Zt.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 f=l.getAttribute("cell-type")||"renderer";if(l.children.length>0&&l.firstElementChild.tagName.includes("-"))return;let g=`cell-${f}`;const b=l.getAttribute("data-bind"),u=l.getAttribute("data-expr"),m=l.getAttribute("maxbyte"),w=l.getAttribute("type");let T=[];b&&T.push(`data-bind="${b}"`),u&&T.push(`data-expr="${u}"`),m&&T.push(`maxbyte="${m}"`),w&&T.push(`type="${w}"`),l.innerHTML=`<${g} ${T.join(" ")}></${g}>`})},"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,f=document.createElement("colgroup"),g=Math.max(Math.floor(a.clientWidth/l),100);for(let b=0;b<l;b++){const u=document.createElement("col");u.setAttribute("width",g),f.appendChild(u)}a.prepend(f)}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")),f=Array.from(a.querySelectorAll(c+" th,"+c+" td")),g=l.length;if(g===0||f.length===0)return;let b=0;f.forEach(m=>{b+=m.colSpan||1});const u=Array.from(Array(g),()=>Array(b).fill(null));l.forEach(m=>{const w=m.sectionRowIndex;let T=0;Array.from(m.querySelectorAll("th,td")).forEach(v=>{for(let B=0;B<u[w].length;B++)if(u[w][B]===null){T=B;break}const _=v.rowSpan||1,k=v.colSpan||1;for(let B=0;B<_;B++)for(let Z=0;Z<k;Z++)w+B<g&&T+Z<b&&(u[w+B][T+Z]=B===0&&Z===0?"1":"0")})}),l.forEach(m=>{const w=m.sectionRowIndex;Array.from(m.querySelectorAll("th,td")).forEach(T=>{for(let v=0;v<u[w].length;v++)if(u[w][v]==="1"){T.dataset.col=v,u[w][v]="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(f=>{f.setAttribute("fixed",l)})}),i}};h(Zt,"TableCompiler");let ge=Zt;const $e=class $e{constructor(n){d(this,ut);d(this,F);d(this,Lt,{startRow:-1,startCol:-1,endRow:-1,endCol:-1});q(this,"render",h(()=>{const{startRow:n,startCol:e,endRow:s,endCol:r}=t(this,Lt);t(this,F).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body").forEach(o=>{o.querySelectorAll(".selected, .selected-top, .selected-bottom, .selected-left, .selected-right").forEach(a=>{a.classList.remove("selected","selected-top","selected-bottom","selected-left","selected-right")}),!(n<0)&&o.querySelectorAll("tbody tr").forEach(a=>{const c=parseInt(a.dataset.row,10);isNaN(c)||a.querySelectorAll("td, th").forEach(l=>{const f=parseInt(l.dataset.col,10);if(isNaN(f))return;const g=parseInt(l.rowSpan||1,10),b=parseInt(l.colSpan||1,10),u=c+g-1,m=f+b-1;c<=s&&u>=n&&f<=r&&m>=e&&(l.classList.add("selected"),c===n&&l.classList.add("selected-top"),u===s&&l.classList.add("selected-bottom"),f===e&&l.classList.add("selected-left"),m===r&&l.classList.add("selected-right"))})})})},"render"));p(this,F,n),Ge(this,ut,is).call(this)}setRange(n,e,s,r){let i=Math.min(n,s),o=Math.max(n,s),a=Math.min(e,r),c=Math.max(e,r);const l=Ge(this,ut,rs).call(this,i,a,o,c);p(this,Lt,l),this.render()}};F=new WeakMap,Lt=new WeakMap,ut=new WeakSet,rs=h(function(n,e,s,r){let i=n,o=e,a=s,c=r,l=!0;const f=t(this,F).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body");for(;l;)l=!1,f.forEach(g=>{g.querySelectorAll("tbody tr").forEach(b=>{const u=parseInt(b.dataset.row,10);isNaN(u)||b.querySelectorAll("td, th").forEach(m=>{const w=parseInt(m.dataset.col,10);if(isNaN(w))return;const T=parseInt(m.rowSpan||1,10),v=parseInt(m.colSpan||1,10),_=u+T-1,k=w+v-1;if(u<=a&&_>=i&&w<=c&&k>=o){const Z=Math.min(i,u),Je=Math.max(a,_),Qe=Math.min(o,w),ts=Math.max(c,k);(Z!==i||Je!==a||Qe!==o||ts!==c)&&(i=Z,a=Je,o=Qe,c=ts,l=!0)}})})});return{startRow:i,startCol:o,endRow:a,endCol:c}},"#expandRangeByMerge"),is=h(function(){const n=this.selector?t(this,F).querySelector(".ng-container-top"):t(this,F).querySelector(".ng-container-top");n&&n.addEventListener("mousedown",e=>{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;const r=parseInt(s.dataset.row,10),i=parseInt(s.dataset.col,10);this.setRange(r,i,r,i);const o=h(c=>{const l=document.elementFromPoint(c.clientX,c.clientY),f=l==null?void 0:l.closest("td, th");if(!f||!t(this,F).contains(f)||f.dataset.row===void 0||f.dataset.col===void 0||f.closest("tr").classList.contains("nodata"))return;const g=parseInt(f.dataset.row,10),b=parseInt(f.dataset.col,10);this.setRange(r,i,g,b)},"onMouseMove"),a=h(()=>{document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",a)},"onMouseUp");document.addEventListener("mousemove",o),document.addEventListener("mouseup",a)})},"#initEvents"),h($e,"CellSelection");let be=$e;const Mt=class Mt extends HTMLElement{constructor(){super();d(this,Gt);d(this,it,null);d(this,ot);d(this,Ht);q(this,"invalidate",h(()=>{x.log("sheet.invalidate()"),t(this,ot).refresh()},"invalidate"));q(this,"generate",h(e=>{if(x.log("sheet.generate()"),!e)return;p(this,it,ge.compile(e)),t(this,Jt).call(this),t(this,Qt).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,ot).initialize(),setTimeout(()=>{var o;(o=this.querySelector("nine-table-hscrollbar"))==null||o.refresh()},0)},"generate"));d(this,Jt,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,gt).call(this,t(this,it),r,"header")),(o=this.querySelector(`${s} .ng-virtual-spacer`))==null||o.before(t(this,gt).call(this,t(this,it),r,"body")),(a=this.querySelector(`${s} .ng-part-footer`))==null||a.appendChild(t(this,gt).call(this,t(this,it),r,"footer"))})},"#renderSplitContainers"));d(this,Qt,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(i)||(i+=a)}),e==="body"?s.style.flex="1":(s.style.flex=`0 0 ${i}px`,s.style.width=`${i}px`)})},"#updateContainerWidths"));d(this,gt,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 f=document.createElement("tbody");f.className="fixed-tbody",i.appendChild(f)}}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"));q(this,"getRowHeight",h(()=>t(this,ot).getRowHeight(),"getRowHeight"));q(this,"scrollToX",h(e=>{const s=this.querySelector(".ng-container-body .ng-part-body");s&&(s.scrollLeft=e)},"scrollToX"));q(this,"scrollToY",h(e=>{const s=this.querySelector(".ng-container-body .ng-part-body");s&&(s.scrollTop=e)},"scrollToY"));d(this,te,h(()=>{t(this,ee).call(this),p(this,Ht,new be(this))},"#init"));d(this,ee,h(()=>{const e=Mt.SCROLLBAR_SIZE;this.innerHTML=`
127
127
  <style>
128
128
  nine-table-sheet {
129
129
  display: none;
@@ -320,7 +320,7 @@
320
320
  <nine-table-hscrollbar></nine-table-hscrollbar>
321
321
  <div class='ng-scroll-edge'></div>
322
322
  </div>
323
- `},"#render"));p(this,ot,new ue(this)),p(this,Ht,new be(this)),p(this,Gt,this.getRootNode().host)}connectedCallback(){t(this,te).call(this)}get selection(){return t(this,Ht)}disconnectedCallback(){this.innerHTML="",x.log("NineTableSheet destroyed.")}};Gt=new WeakMap,it=new WeakMap,ot=new WeakMap,Ht=new WeakMap,Jt=new WeakMap,Qt=new WeakMap,gt=new WeakMap,te=new WeakMap,ee=new WeakMap,h(Mt,"NineTableSheet"),q(Mt,"SCROLLBAR_SIZE",16);let Pt=Mt;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",Pt);const _e=class _e extends HTMLElement{constructor(){super();d(this,se,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,It).call(this,i,r)}),t(this,It).call(this,0,!1)},"#init"));d(this,It,h((e,s=!1)=>{const r=h(()=>{const f=Array.from(this.querySelectorAll("nine-table-sheet"));Array.from(this.querySelectorAll("nine-splitter")).forEach(u=>u.style.setProperty("display","none"));const b=f.filter(u=>u.classList.contains("active"));b.length<2||b.forEach(u=>{const m=parseInt(u.getAttribute("data-index"),10),w=this.querySelector(`nine-splitter[data-split-index="${m}"]`),T=f[m+1];w&&T&&T.classList.contains("active")&&w.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((f,g)=>{f.classList.toggle("active",g===e)}),c.forEach((f,g)=>{const b=g===e;f.classList.toggle("active",b),f.style.flex=b?"1 1 100%":""});else{const f=a[e],g=i.querySelectorAll(".nine-tab-item.active");if(f.classList.contains("active")&&g.length<=1)return;f.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(f=>{f.style.flex=l.length>1?"1 1 0%":"1 1 100%"}),r()},"#switchSheet"))}connectedCallback(){t(this,se).call(this)}};se=new WeakMap,It=new WeakMap,h(_e,"NineTableSheets");let pe=_e;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",pe);const Ne=class Ne{constructor(n){d(this,I);d(this,ne,h(()=>{t(this,re).call(this),new ResizeObserver(n=>{for(let e of n)t(this,I).getAttribute("auto-height")==="true"&&t(this,$t).call(this)}).observe(t(this,I))},"#init"));d(this,$t,h(()=>{var c,l;const n=Array.from(t(this,I).shadowRoot.querySelectorAll("nine-table-sheet.active"));if(n.length===0)return;const e=parseInt(t(this,I).getAttribute("max-display-row"),10)||10,s=Math.max(...n.map(f=>f.getRowHeight())),r=(c=t(this,I).shadowRoot.querySelector("nine-table-header"))==null?void 0:c.getBoundingClientRect().height,i=(l=t(this,I).shadowRoot.querySelector("nine-table-sheets-footer"))==null?void 0:l.getBoundingClientRect().height,o=Pt.SCROLLBAR_SIZE,a=e*s+r+i+o;t(this,I).style.height=`${a}px`},"#applyAutoHeight"));d(this,re,h(()=>{const e=Array.from(t(this,I).children).filter(c=>c.tagName==="TABLE"),s=t(this,I).getAttribute("auto-height")==="true",r=e.length,i=e.map((c,l)=>{const g=`<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 g+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,I).shadowRoot.innerHTML=`
323
+ `},"#render"));p(this,ot,new ue(this)),p(this,Gt,this.getRootNode().host)}connectedCallback(){t(this,te).call(this)}get selection(){return t(this,Ht)}disconnectedCallback(){this.innerHTML="",x.log("NineTableSheet destroyed.")}};Gt=new WeakMap,it=new WeakMap,ot=new WeakMap,Ht=new WeakMap,Jt=new WeakMap,Qt=new WeakMap,gt=new WeakMap,te=new WeakMap,ee=new WeakMap,h(Mt,"NineTableSheet"),q(Mt,"SCROLLBAR_SIZE",16);let Pt=Mt;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",Pt);const _e=class _e extends HTMLElement{constructor(){super();d(this,se,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,It).call(this,i,r)}),t(this,It).call(this,0,!1)},"#init"));d(this,It,h((e,s=!1)=>{const r=h(()=>{const f=Array.from(this.querySelectorAll("nine-table-sheet"));Array.from(this.querySelectorAll("nine-splitter")).forEach(u=>u.style.setProperty("display","none"));const b=f.filter(u=>u.classList.contains("active"));b.length<2||b.forEach(u=>{const m=parseInt(u.getAttribute("data-index"),10),w=this.querySelector(`nine-splitter[data-split-index="${m}"]`),T=f[m+1];w&&T&&T.classList.contains("active")&&w.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((f,g)=>{f.classList.toggle("active",g===e)}),c.forEach((f,g)=>{const b=g===e;f.classList.toggle("active",b),f.style.flex=b?"1 1 100%":""});else{const f=a[e],g=i.querySelectorAll(".nine-tab-item.active");if(f.classList.contains("active")&&g.length<=1)return;f.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(f=>{f.style.flex=l.length>1?"1 1 0%":"1 1 100%"}),r()},"#switchSheet"))}connectedCallback(){t(this,se).call(this)}};se=new WeakMap,It=new WeakMap,h(_e,"NineTableSheets");let pe=_e;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",pe);const Ne=class Ne{constructor(n){d(this,I);d(this,ne,h(()=>{t(this,re).call(this),new ResizeObserver(n=>{for(let e of n)t(this,I).getAttribute("auto-height")==="true"&&t(this,$t).call(this)}).observe(t(this,I))},"#init"));d(this,$t,h(()=>{var c,l;const n=Array.from(t(this,I).shadowRoot.querySelectorAll("nine-table-sheet.active"));if(n.length===0)return;const e=parseInt(t(this,I).getAttribute("max-display-row"),10)||10,s=Math.max(...n.map(f=>f.getRowHeight())),r=(c=t(this,I).shadowRoot.querySelector("nine-table-header"))==null?void 0:c.getBoundingClientRect().height,i=(l=t(this,I).shadowRoot.querySelector("nine-table-sheets-footer"))==null?void 0:l.getBoundingClientRect().height,o=Pt.SCROLLBAR_SIZE,a=e*s+r+i+o;t(this,I).style.height=`${a}px`},"#applyAutoHeight"));d(this,re,h(()=>{const e=Array.from(t(this,I).children).filter(c=>c.tagName==="TABLE"),s=t(this,I).getAttribute("auto-height")==="true",r=e.length,i=e.map((c,l)=>{const g=`<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 g+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,I).shadowRoot.innerHTML=`
324
324
  <style>
325
325
  :host {
326
326
  display: flex;