@ninebone/table 0.0.813 → 0.0.814

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,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;w.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(()=>{w.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(w.log(t(this,V)),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)=>{w.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");w.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(()=>{w.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")):[],v=Math.max(u.length,p.length,x.length);for(let m=0;m<v;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")):[],v=Math.max(u.length,p.length,x.length);for(let m=0;m<v;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(()=>{w.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;w.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 v=[];b&&v.push(`data-bind="${b}"`),u&&v.push(`data-expr="${u}"`),p&&v.push(`maxbyte="${p}"`),x&&v.push(`type="${x}"`),l.innerHTML=`<${f} ${v.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 v=0;Array.from(p.querySelectorAll("th,td")).forEach(m=>{for(let N=0;N<u[x].length;N++)if(u[x][N]===null){v=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&&v+B<b&&(u[x+N][v+B]=N===0&&B===0?"1":"0")})}),l.forEach(p=>{const x=p.sectionRowIndex;Array.from(p.querySelectorAll("th,td")).forEach(v=>{for(let m=0;m<u[x].length;m++)if(u[x][m]==="1"){v.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);w.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){w.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"),w.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"))})})}),w.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()})}),w.log("🎯 [CellSelection] Initialized")}setRange(n,e,s,r){w.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 v=parseInt(x.dataset.col,10);if(isNaN(v))return;const m=parseInt(x.rowSpan||1,10),k=parseInt(x.colSpan||1,10),A=p+m-1,N=v+k-1;if(A>=i&&p<=o&&N>=a&&v<=c){const P=Math.min(i,p),Ce=Math.max(o,A),ps=Math.min(a,v),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}),w.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){w.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}w.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),v=parseInt(u.dataset.col,10);x<0||a===x&&c===v||(a=x,c=v,this.setRange(i,o,x,v))},"onMouseMove"),g=h(()=>{w.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(v=>parseInt(v.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 v of x){const m=parseInt(v.dataset.col,10),k=parseInt(v.colSpan||1,10),A=parseInt(v.rowSpan||1,10);if(!isNaN(m)&&s>=m&&s<m+k&&o>=p&&o<p+A&&window.getComputedStyle(v).display!=="none")return v}}}return null},"#getNearElement"));y(this,j,n),K(this,dt,Ss).call(this),w.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")).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),w.log("matrixRow:",f,"nextMatrixRow",b);break;case"ArrowUp":n.preventDefault(),b=Math.max(0,f-(e.rowSpan||1));break}const p=Math.floor(b/l),x=b%l;let v=t(this,Wt).call(this,p,x,u,b);if(w.log(v,p,x,u,b),v)this.currentCell=v,K(this,dt,bs).call(this,v);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(()=>{w.log("sheet.invalidate()"),t(this,gt).refresh()},"invalidate"));C(this,"generate",h(e=>{if(w.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=`
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;w.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(()=>{w.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(w.log("********************"),w.log(t(this,V)),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)=>{w.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");w.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(()=>{w.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")):[],v=Math.max(u.length,p.length,x.length);for(let m=0;m<v;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")):[],v=Math.max(u.length,p.length,x.length);for(let m=0;m<v;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(()=>{w.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;w.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 v=[];b&&v.push(`data-bind="${b}"`),u&&v.push(`data-expr="${u}"`),p&&v.push(`maxbyte="${p}"`),x&&v.push(`type="${x}"`),l.innerHTML=`<${f} ${v.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 v=0;Array.from(p.querySelectorAll("th,td")).forEach(m=>{for(let N=0;N<u[x].length;N++)if(u[x][N]===null){v=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&&v+B<b&&(u[x+N][v+B]=N===0&&B===0?"1":"0")})}),l.forEach(p=>{const x=p.sectionRowIndex;Array.from(p.querySelectorAll("th,td")).forEach(v=>{for(let m=0;m<u[x].length;m++)if(u[x][m]==="1"){v.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);w.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){w.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"),w.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"))})})}),w.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()})}),w.log("🎯 [CellSelection] Initialized")}setRange(n,e,s,r){w.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 v=parseInt(x.dataset.col,10);if(isNaN(v))return;const m=parseInt(x.rowSpan||1,10),k=parseInt(x.colSpan||1,10),A=p+m-1,N=v+k-1;if(A>=i&&p<=o&&N>=a&&v<=c){const P=Math.min(i,p),Ce=Math.max(o,A),ps=Math.min(a,v),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}),w.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){w.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}w.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),v=parseInt(u.dataset.col,10);x<0||a===x&&c===v||(a=x,c=v,this.setRange(i,o,x,v))},"onMouseMove"),g=h(()=>{w.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(v=>parseInt(v.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 v of x){const m=parseInt(v.dataset.col,10),k=parseInt(v.colSpan||1,10),A=parseInt(v.rowSpan||1,10);if(!isNaN(m)&&s>=m&&s<m+k&&o>=p&&o<p+A&&window.getComputedStyle(v).display!=="none")return v}}}return null},"#getNearElement"));y(this,j,n),K(this,dt,Ss).call(this),w.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")).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),w.log("matrixRow:",f,"nextMatrixRow",b);break;case"ArrowUp":n.preventDefault(),b=Math.max(0,f-(e.rowSpan||1));break}const p=Math.floor(b/l),x=b%l;let v=t(this,Wt).call(this,p,x,u,b);if(w.log(v,p,x,u,b),v)this.currentCell=v,K(this,dt,bs).call(this,v);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(()=>{w.log("sheet.invalidate()"),t(this,gt).refresh()},"invalidate"));C(this,"generate",h(e=>{if(w.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;