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