import{B as A,a as j}from"./parser-0SxLDwNu.js";import{a as I,r as N,p as $,b as q,c as z,d as H}from"./corruption-BVkvOB4Z.js";import{d as T}from"./renderer-BTxS_YLl.js";const O=(o,c)=>{const{name:a,props:e,children:t}=o,d=A[a];if(!d)throw new Error(`Block "${a}" is not registered in BLOCK_MAP`);if(!d.render)throw new Error(`Block "${a}" has no render method`);let u="";return t&&t.length>0&&t.forEach(i=>{u+=O(i,[e,...c])}),d.render(e,u,c)},K=o=>{var y,P;const c=I(o);c.isCorrupted&&N(o,c);const a=Object.values(A),e=$(o),t={},d={},u=Array.from({length:e.rowCount},()=>Array.from({length:e.colCount})),i={};for(let l=0;l<e.rowCount;l++){const m=o.rows[l],b=q(m,l,e),v=m.cells.length,L=u[l];let r=0;for(let g=0;g<v;g++){for(;(y=i[l])!=null&&y[r];)r++;const s=m.cells[g];let k="";s.style.height&&(b.height=s.style.height),s.style.width&&(t[r]={...t[r],width:s.style.width}),s.classList.contains("wptb-hide-on-mobile")&&(t[r]={...t[r],hideOnMobile:!0});const S=(P=s.className.match(/wptb-col-highlighted-([0-9]+)/))==null?void 0:P[1];S&&(t[r]={...t[r],highlight:!0,highlightScale:parseInt(S)}),Array.from(s.children).forEach(p=>{var n;for(const h of a)if((n=h.isBlock)!=null&&n.call(h,p)&&h.parse){const f=h.parse(p,{isFrontend:!0,tableProps:e}),C=O(f,[e]);k+=C;break}});const B=s.colSpan||1,M=s.rowSpan||1,E=z(s,e.innerBorder);Object.assign(E,{col:r,row:l});for(let p=0;p<M;p++){const n=l+p,h=u[n];i[n]||(i[n]={});for(let w=0;w<B;w++){if(p==0&&w==0)continue;const f=r+w,C={...H,row:n,col:f,isNotACell:!0};i[n][f]=!0,h[f]={...C,el:""}}}L[r]={...E,el:k},r+=B}(b.background||b.height||b.highlightScale!==100)&&(d[l]=b)}return e.columnsProps=t,e.rowsProps=d,{props:e,cells:u}},R=document.querySelectorAll(".wptb-container-legacy");R.forEach(o=>{const c=o.querySelector("table");if(!c)return;const a=o.dataset.tableId,e=K(c);o.className=`wptb-root wptb-table-${a}`,j(e.props.extraStyles,a),T(e,o);let t=0;window.addEventListener("resize",()=>{clearTimeout(t),t=setTimeout(()=>{T(e,o)},500)})});document.dispatchEvent(new CustomEvent("wptb:table-rendered"));
