import {a}from'./chunk-D6GO7UGD.mjs';var o={TABLE_INDEX:"data-table-index",ROW_INDEX:"data-row",COLUMN_INDEX:"data-col",TABLE_CELL:"data-table-cell"};function i(e,l){if(!(e instanceof Element))return null;let t=e;for(;t&&t!==l;){if(t.tagName==="TD"||t.tagName==="TH"){let n=t.getAttribute(o.ROW_INDEX),r=t.getAttribute(o.COLUMN_INDEX);if(n!==null&&r!==null){let a=t;for(;a&&a!==l;){if(a.tagName==="TABLE"){let u=a.getAttribute(o.TABLE_INDEX);if(u!==null)return {tableIndex:parseInt(u,10),rowIndex:parseInt(n,10),columnIndex:parseInt(r,10)};break}a=a.parentElement;}}break}t=t.parentElement;}return null}function p(e,l){if(!e.package?.document?.content)return null;let t=0;for(let n of e.package.document.content)if(n.type==="table"){if(t===l)return n;t++;}return null}function b(e,l,t){if(!e.package?.document?.content)return e;let n=0,r=e.package.document.content.map(a=>{if(a.type==="table"){if(n===l)return n++,t;n++;}return a});return {...e,package:{...e.package,document:{...e.package.document,content:r}}}}function d(e,l){if(!e.package?.document?.content)return e;let t=0,n=e.package.document.content.filter(r=>{if(r.type==="table"){let a=t===l;return t++,!a}return  true});return {...e,package:{...e.package,document:{...e.package.document,content:n}}}}var m=class extends a{constructor(){super({selectedCell:null});}selectCell(l){this.setSnapshot({selectedCell:l});}clearSelection(){this.setSnapshot({selectedCell:null});}isCellSelected(l,t,n){let{selectedCell:r}=this.getSnapshot();return r?r.tableIndex===l&&r.rowIndex===t&&r.columnIndex===n:false}getSelectedCell(){return this.getSnapshot().selectedCell}};export{o as a,i as b,p as c,b as d,d as e,m as f};