@nuptechs/nup-xlsx-preview 1.1.1 → 1.1.3

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.
@@ -1,17 +1,17 @@
1
- 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var F=class{rowPositions;colPositions;rowHeightCache;colWidthCache;totalHeight;totalWidth;overscan;rowCount;colCount;frozenRows;frozenCols;frozenRowsHeight;frozenColsWidth;constructor(e){let{rows:t,cols:r,rowHeights:s,colWidths:o,defaultRowHeight:a=24,defaultColWidth:d=100,overscan:h=5,frozenRows:u=0,frozenCols:b=0}=e;this.frozenRows=u,this.frozenCols=b,this.rowCount=t,this.colCount=r,this.overscan=h,this.rowPositions=new Array(t+1),this.rowHeightCache=new Array(t),this.rowPositions[0]=0;for(let p=0;p<t;p++){let w=s[p]??a;this.rowHeightCache[p]=w,this.rowPositions[p+1]=this.rowPositions[p]+w;}this.totalHeight=this.rowPositions[t],this.frozenRowsHeight=u>0?this.rowPositions[u]??0:0,this.colPositions=new Array(r+1),this.colWidthCache=new Array(r),this.colPositions[0]=0;for(let p=0;p<r;p++){let w=o[p]??d;this.colWidthCache[p]=w,this.colPositions[p+1]=this.colPositions[p]+w;}this.totalWidth=this.colPositions[r],this.frozenColsWidth=b>0?this.colPositions[b]??0:0;}getFrozenInfo(){return {rows:this.frozenRows,cols:this.frozenCols,frozenRowsHeight:this.frozenRowsHeight,frozenColsWidth:this.frozenColsWidth}}binarySearch(e,t){let r=0,s=e.length-2;for(;r<=s;){let o=r+s>>>1,a=e[o],d=e[o+1];if(t>=a&&t<d)return o;t<a?s=o-1:r=o+1;}return Math.max(0,Math.min(r,e.length-2))}getVisibleRange(e,t,r,s){let o=e+this.frozenRowsHeight,a=t+this.frozenColsWidth,d=this.binarySearch(this.rowPositions,o),h=this.binarySearch(this.rowPositions,o+Math.max(0,r)),u=this.binarySearch(this.colPositions,a),b=this.binarySearch(this.colPositions,a+Math.max(0,s)),p=Math.max(this.frozenRows,d-this.overscan),w=Math.min(this.rowCount-1,h+this.overscan),re=Math.max(this.frozenCols,u-this.overscan),_=Math.min(this.colCount-1,b+this.overscan);return {startRow:p,endRow:w,startCol:re,endCol:_}}getFrozenRowsRange(){return this.frozenRows===0?null:{startRow:0,endRow:this.frozenRows-1}}getFrozenColsRange(){return this.frozenCols===0?null:{startCol:0,endCol:this.frozenCols-1}}getCellRect(e,t){return {top:this.rowPositions[e]??0,left:this.colPositions[t]??0,width:this.colWidthCache[t]??100,height:this.rowHeightCache[e]??24}}getRowHeight(e){return this.rowHeightCache[e]??24}getColWidth(e){return this.colWidthCache[e]??100}setColWidth(e,t){if(e<0||e>=this.colCount)return;let r=this.colWidthCache[e],s=t-r;this.colWidthCache[e]=t;for(let o=e+1;o<=this.colCount;o++)this.colPositions[o]+=s;this.totalWidth+=s;}getIndexAtPosition(e,t){return {row:this.binarySearch(this.rowPositions,e),col:this.binarySearch(this.colPositions,t)}}getScrollToPosition(e,t,r,s){let o=this.rowPositions[e]??0,a=this.colPositions[t]??0;return {scrollTop:Math.max(0,o-r/2),scrollLeft:Math.max(0,a-s/2)}}};function ee(f){let e="",t=f;for(;t>=0;)e=String.fromCharCode(t%26+65)+e,t=Math.floor(t/26)-1;return e}function Ie(f){let e=0,t=f.toUpperCase();for(let r=0;r<t.length;r++)e=e*26+(t.charCodeAt(r)-64);return e-1}function A(f,e){return `${ee(e)}${f+1}`}function S(f){let e=f.match(/^([A-Z]+)(\d+)$/i);if(!e)return null;let t=Ie(e[1]),r=parseInt(e[2],10)-1;return r<0||t<0?null:{row:r,col:t}}var D=class{state;sheet;onChange;constructor(e,t){this.sheet=e,this.onChange=t??null,this.state={anchor:null,focus:null,ranges:[]};}handleClick(e,t,r){let{shiftKey:s,ctrlKey:o,metaKey:a}=r;s&&this.state.anchor?(this.state.focus={row:e,col:t},this.updateRanges()):o||a?(this.state.anchor={row:e,col:t},this.state.focus={row:e,col:t},this.state.ranges.push(this.createRange(this.state.anchor,this.state.focus))):(this.state.anchor={row:e,col:t},this.state.focus={row:e,col:t},this.state.ranges=[this.createRange(this.state.anchor,this.state.focus)]),this.notifyChange();}handleDrag(e,t){this.state.anchor&&(this.state.focus={row:e,col:t},this.updateRanges(),this.notifyChange());}selectCell(e){let t=S(e);t&&(this.state.anchor=t,this.state.focus=t,this.state.ranges=[this.createRange(t,t)],this.notifyChange());}selectRange(e,t){let r=S(e),s=S(t);!r||!s||(this.state.anchor=r,this.state.focus=s,this.state.ranges=[this.createRange(r,s)],this.notifyChange());}selectAll(){this.state.anchor={row:0,col:0},this.state.focus={row:this.sheet.rowCount-1,col:this.sheet.colCount-1},this.state.ranges=[this.createRange(this.state.anchor,this.state.focus)],this.notifyChange();}clear(){this.state.anchor=null,this.state.focus=null,this.state.ranges=[],this.notifyChange();}getSelection(){return this.state.ranges.length===0?null:this.state.ranges[0]}getAllSelections(){return [...this.state.ranges]}isCellSelected(e,t){return this.state.ranges.some(r=>e>=r.start.row&&e<=r.end.row&&t>=r.start.col&&t<=r.end.col)}isAnchor(e,t){return this.state.anchor?.row===e&&this.state.anchor?.col===t}setSheet(e){this.sheet=e,this.clear();}updateRanges(){if(!this.state.anchor||!this.state.focus)return;let e=this.createRange(this.state.anchor,this.state.focus);this.state.ranges.length>0?this.state.ranges[this.state.ranges.length-1]=e:this.state.ranges.push(e);}createRange(e,t){let r=Math.min(e.row,t.row),s=Math.max(e.row,t.row),o=Math.min(e.col,t.col),a=Math.max(e.col,t.col),d=[],h=[];for(let u=r;u<=s;u++){let b=[];for(let p=o;p<=a;p++){let w=A(u,p);h.push(w),b.push(this.sheet.cells[w]??null);}d.push(b);}return {start:{row:r,col:o},end:{row:s,col:a},cells:d,cellRefs:h}}notifyChange(){this.onChange&&this.onChange(this.getSelection());}};var U=class{selection;virtualScroll;config;onScroll;onCopy;constructor(e,t,r,s){this.selection=e,this.virtualScroll=t,this.config=r,this.onScroll=s?.onScroll??null,this.onCopy=s?.onCopy??null;}handleKeyDown(e){if(!this.config.enabled)return false;let t=this.getAction(e);return t?(e.preventDefault(),this.executeAction(t),true):false}getAction(e){let{key:t,shiftKey:r,ctrlKey:s,metaKey:o}=e,a=s||o;if(a&&t==="c")return "copy";if(a&&t==="a")return "select-all";if(r)switch(t){case "ArrowUp":return "extend-up";case "ArrowDown":return "extend-down";case "ArrowLeft":return "extend-left";case "ArrowRight":return "extend-right"}if(a)switch(t){case "Home":return "move-ctrl-home";case "End":return "move-ctrl-end"}switch(t){case "ArrowUp":return "move-up";case "ArrowDown":return "move-down";case "ArrowLeft":return "move-left";case "ArrowRight":return "move-right";case "PageUp":return "move-page-up";case "PageDown":return "move-page-down";case "Home":return "move-home";case "End":return "move-end";case "Tab":return r?"move-left":"move-right";case "Enter":return r?"move-up":"move-down"}return null}executeAction(e){let t=this.selection.getSelection();if(!t&&!["select-all","move-ctrl-home"].includes(e)){this.selection.selectCell("A1"),this.scrollToSelection();return}let{row:r,col:s}=t?.start??{row:0,col:0},o=r,a=s;switch(e){case "move-up":o=Math.max(0,r-1);break;case "move-down":o=Math.min(this.virtualScroll.rowCount-1,r+1);break;case "move-left":a=Math.max(0,s-1);break;case "move-right":a=Math.min(this.virtualScroll.colCount-1,s+1);break;case "move-page-up":o=Math.max(0,r-20);break;case "move-page-down":o=Math.min(this.virtualScroll.rowCount-1,r+20);break;case "move-home":a=0;break;case "move-end":a=this.virtualScroll.colCount-1;break;case "move-ctrl-home":o=0,a=0;break;case "move-ctrl-end":o=this.virtualScroll.rowCount-1,a=this.virtualScroll.colCount-1;break;case "select-all":this.selection.selectAll();return;case "copy":this.onCopy?.();return;case "extend-up":case "extend-down":case "extend-left":case "extend-right":this.extendSelection(e);return}this.selection.handleClick(o,a,{shiftKey:false,ctrlKey:false,metaKey:false}),this.scrollToSelection();}extendSelection(e){let t=this.selection.getSelection();if(!t)return;let{row:r,col:s}=t.end;switch(e){case "extend-up":r=Math.max(0,r-1);break;case "extend-down":r=Math.min(this.virtualScroll.rowCount-1,r+1);break;case "extend-left":s=Math.max(0,s-1);break;case "extend-right":s=Math.min(this.virtualScroll.colCount-1,s+1);break}this.selection.handleDrag(r,s),this.scrollToSelection();}scrollToSelection(){let e=this.selection.getSelection();!e||!this.onScroll||this.onScroll(e.start.row,e.start.col);}setVirtualScroll(e){this.virtualScroll=e;}setSelection(e){this.selection=e;}};var j=class{merges;mergeMap;constructor(e=[]){this.merges=[],this.mergeMap=new Map,this.parseMerges(e);}parseMerges(e){for(let t of e){let[r,s]=t.split(":");if(!r||!s)continue;let o=S(r),a=S(s);if(!o||!a)continue;let d={startRow:Math.min(o.row,a.row),startCol:Math.min(o.col,a.col),endRow:Math.max(o.row,a.row),endCol:Math.max(o.col,a.col),cellRef:r};this.merges.push(d);for(let h=d.startRow;h<=d.endRow;h++)for(let u=d.startCol;u<=d.endCol;u++){let b=`${h},${u}`;this.mergeMap.set(b,d);}}}getMergeAt(e,t){return this.mergeMap.get(`${e},${t}`)??null}isMergeMaster(e,t){let r=this.getMergeAt(e,t);return r?r.startRow===e&&r.startCol===t:false}isMergeHidden(e,t){let r=this.getMergeAt(e,t);return r?!(r.startRow===e&&r.startCol===t):false}getMergeMaster(e,t){let r=this.getMergeAt(e,t);return r?{row:r.startRow,col:r.startCol}:null}getMergeRect(e,t,r){let s=this.getMergeAt(e,t);if(!s||!this.isMergeMaster(e,t))return null;let o=r(s.startRow,s.startCol),a=r(s.endRow,s.endCol);return {top:o.top,left:o.left,width:a.left+a.width-o.left,height:a.top+a.height-o.top}}getAllMerges(){return [...this.merges]}getVisibleMerges(e,t,r,s){return this.merges.filter(o=>o.endRow>=e&&o.startRow<=t&&o.endCol>=r&&o.startCol<=s)}update(e){this.merges=[],this.mergeMap.clear(),this.parseMerges(e);}};var O=class{async copyToClipboard(e){let t=this.formatSelection(e);try{if(navigator.clipboard&&typeof ClipboardItem<"u"){let r=new Blob([t.html],{type:"text/html"}),s=new Blob([t.text],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/html":r,"text/plain":s})]);}else await this.copyWithExecCommand(t.text);}catch{await this.copyWithExecCommand(t.text);}return t}formatSelection(e){let{cells:t}=e,r=[];for(let d of t){let h=d.map(u=>this.getCellValue(u));r.push(h.join(" "));}let s=r.join(`
2
- `),o=[];for(let d of t){let h=d.map(u=>{let b=this.escapeHtml(this.getCellValue(u));return `<td style="${this.getCellStyle(u)}">${b}</td>`});o.push(`<tr>${h.join("")}</tr>`);}let a=`
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var D=class{rowPositions;colPositions;rowHeightCache;colWidthCache;totalHeight;totalWidth;overscan;rowCount;colCount;frozenRows;frozenCols;frozenRowsHeight;frozenColsWidth;constructor(e){let{rows:t,cols:r,rowHeights:n,colWidths:o,defaultRowHeight:a=24,defaultColWidth:d=100,overscan:h=5,frozenRows:f=0,frozenCols:b=0}=e;this.frozenRows=f,this.frozenCols=b,this.rowCount=t,this.colCount=r,this.overscan=h,this.rowPositions=new Array(t+1),this.rowHeightCache=new Array(t),this.rowPositions[0]=0;for(let p=0;p<t;p++){let w=n[p]??a;this.rowHeightCache[p]=w,this.rowPositions[p+1]=this.rowPositions[p]+w;}this.totalHeight=this.rowPositions[t],this.frozenRowsHeight=f>0?this.rowPositions[f]??0:0,this.colPositions=new Array(r+1),this.colWidthCache=new Array(r),this.colPositions[0]=0;for(let p=0;p<r;p++){let w=o[p]??d;this.colWidthCache[p]=w,this.colPositions[p+1]=this.colPositions[p]+w;}this.totalWidth=this.colPositions[r],this.frozenColsWidth=b>0?this.colPositions[b]??0:0;}getFrozenInfo(){return {rows:this.frozenRows,cols:this.frozenCols,frozenRowsHeight:this.frozenRowsHeight,frozenColsWidth:this.frozenColsWidth}}binarySearch(e,t){let r=0,n=e.length-2;for(;r<=n;){let o=r+n>>>1,a=e[o],d=e[o+1];if(t>=a&&t<d)return o;t<a?n=o-1:r=o+1;}return Math.max(0,Math.min(r,e.length-2))}getVisibleRange(e,t,r,n){let o=e+this.frozenRowsHeight,a=t+this.frozenColsWidth,d=this.binarySearch(this.rowPositions,o),h=this.binarySearch(this.rowPositions,o+Math.max(0,r)),f=this.binarySearch(this.colPositions,a),b=this.binarySearch(this.colPositions,a+Math.max(0,n)),p=Math.max(this.frozenRows,d-this.overscan),w=Math.min(this.rowCount-1,h+this.overscan),oe=Math.max(this.frozenCols,f-this.overscan),Z=Math.min(this.colCount-1,b+this.overscan);return {startRow:p,endRow:w,startCol:oe,endCol:Z}}getFrozenRowsRange(){return this.frozenRows===0?null:{startRow:0,endRow:this.frozenRows-1}}getFrozenColsRange(){return this.frozenCols===0?null:{startCol:0,endCol:this.frozenCols-1}}getCellRect(e,t){return {top:this.rowPositions[e]??0,left:this.colPositions[t]??0,width:this.colWidthCache[t]??100,height:this.rowHeightCache[e]??24}}getRowHeight(e){return this.rowHeightCache[e]??24}getColWidth(e){return this.colWidthCache[e]??100}setColWidth(e,t){if(e<0||e>=this.colCount)return;let r=this.colWidthCache[e],n=t-r;this.colWidthCache[e]=t;for(let o=e+1;o<=this.colCount;o++)this.colPositions[o]+=n;this.totalWidth+=n;}getIndexAtPosition(e,t){return {row:this.binarySearch(this.rowPositions,e),col:this.binarySearch(this.colPositions,t)}}getScrollToPosition(e,t,r,n){let o=this.rowPositions[e]??0,a=this.colPositions[t]??0;return {scrollTop:Math.max(0,o-r/2),scrollLeft:Math.max(0,a-n/2)}}};function te(s){let e="",t=s;for(;t>=0;)e=String.fromCharCode(t%26+65)+e,t=Math.floor(t/26)-1;return e}function De(s){let e=0,t=s.toUpperCase();for(let r=0;r<t.length;r++)e=e*26+(t.charCodeAt(r)-64);return e-1}function A(s,e){return `${te(e)}${s+1}`}function R(s){let e=s.match(/^([A-Z]+)(\d+)$/i);if(!e)return null;let t=De(e[1]),r=parseInt(e[2],10)-1;return r<0||t<0?null:{row:r,col:t}}var j=class{state;sheet;onChange;constructor(e,t){this.sheet=e,this.onChange=t??null,this.state={anchor:null,focus:null,ranges:[]};}handleClick(e,t,r){let{shiftKey:n,ctrlKey:o,metaKey:a}=r;n&&this.state.anchor?(this.state.focus={row:e,col:t},this.updateRanges()):o||a?(this.state.anchor={row:e,col:t},this.state.focus={row:e,col:t},this.state.ranges.push(this.createRange(this.state.anchor,this.state.focus))):(this.state.anchor={row:e,col:t},this.state.focus={row:e,col:t},this.state.ranges=[this.createRange(this.state.anchor,this.state.focus)]),this.notifyChange();}handleDrag(e,t){this.state.anchor&&(this.state.focus={row:e,col:t},this.updateRanges(),this.notifyChange());}selectCell(e){let t=R(e);t&&(this.state.anchor=t,this.state.focus=t,this.state.ranges=[this.createRange(t,t)],this.notifyChange());}selectRange(e,t){let r=R(e),n=R(t);!r||!n||(this.state.anchor=r,this.state.focus=n,this.state.ranges=[this.createRange(r,n)],this.notifyChange());}selectAll(){this.state.anchor={row:0,col:0},this.state.focus={row:this.sheet.rowCount-1,col:this.sheet.colCount-1},this.state.ranges=[this.createRange(this.state.anchor,this.state.focus)],this.notifyChange();}clear(){this.state.anchor=null,this.state.focus=null,this.state.ranges=[],this.notifyChange();}getSelection(){return this.state.ranges.length===0?null:this.state.ranges[0]}getAllSelections(){return [...this.state.ranges]}isCellSelected(e,t){return this.state.ranges.some(r=>e>=r.start.row&&e<=r.end.row&&t>=r.start.col&&t<=r.end.col)}isAnchor(e,t){return this.state.anchor?.row===e&&this.state.anchor?.col===t}setSheet(e){this.sheet=e,this.clear();}updateRanges(){if(!this.state.anchor||!this.state.focus)return;let e=this.createRange(this.state.anchor,this.state.focus);this.state.ranges.length>0?this.state.ranges[this.state.ranges.length-1]=e:this.state.ranges.push(e);}createRange(e,t){let r=Math.min(e.row,t.row),n=Math.max(e.row,t.row),o=Math.min(e.col,t.col),a=Math.max(e.col,t.col),d=[],h=[];for(let f=r;f<=n;f++){let b=[];for(let p=o;p<=a;p++){let w=A(f,p);h.push(w),b.push(this.sheet.cells[w]??null);}d.push(b);}return {start:{row:r,col:o},end:{row:n,col:a},cells:d,cellRefs:h}}notifyChange(){this.onChange&&this.onChange(this.getSelection());}};var U=class{selection;virtualScroll;config;onScroll;onCopy;constructor(e,t,r,n){this.selection=e,this.virtualScroll=t,this.config=r,this.onScroll=n?.onScroll??null,this.onCopy=n?.onCopy??null;}handleKeyDown(e){if(!this.config.enabled)return false;let t=this.getAction(e);return t?(e.preventDefault(),this.executeAction(t),true):false}getAction(e){let{key:t,shiftKey:r,ctrlKey:n,metaKey:o}=e,a=n||o;if(a&&t==="c")return "copy";if(a&&t==="a")return "select-all";if(r)switch(t){case "ArrowUp":return "extend-up";case "ArrowDown":return "extend-down";case "ArrowLeft":return "extend-left";case "ArrowRight":return "extend-right"}if(a)switch(t){case "Home":return "move-ctrl-home";case "End":return "move-ctrl-end"}switch(t){case "ArrowUp":return "move-up";case "ArrowDown":return "move-down";case "ArrowLeft":return "move-left";case "ArrowRight":return "move-right";case "PageUp":return "move-page-up";case "PageDown":return "move-page-down";case "Home":return "move-home";case "End":return "move-end";case "Tab":return r?"move-left":"move-right";case "Enter":return r?"move-up":"move-down"}return null}executeAction(e){let t=this.selection.getSelection();if(!t&&!["select-all","move-ctrl-home"].includes(e)){this.selection.selectCell("A1"),this.scrollToSelection();return}let{row:r,col:n}=t?.start??{row:0,col:0},o=r,a=n;switch(e){case "move-up":o=Math.max(0,r-1);break;case "move-down":o=Math.min(this.virtualScroll.rowCount-1,r+1);break;case "move-left":a=Math.max(0,n-1);break;case "move-right":a=Math.min(this.virtualScroll.colCount-1,n+1);break;case "move-page-up":o=Math.max(0,r-20);break;case "move-page-down":o=Math.min(this.virtualScroll.rowCount-1,r+20);break;case "move-home":a=0;break;case "move-end":a=this.virtualScroll.colCount-1;break;case "move-ctrl-home":o=0,a=0;break;case "move-ctrl-end":o=this.virtualScroll.rowCount-1,a=this.virtualScroll.colCount-1;break;case "select-all":this.selection.selectAll();return;case "copy":this.onCopy?.();return;case "extend-up":case "extend-down":case "extend-left":case "extend-right":this.extendSelection(e);return}this.selection.handleClick(o,a,{shiftKey:false,ctrlKey:false,metaKey:false}),this.scrollToSelection();}extendSelection(e){let t=this.selection.getSelection();if(!t)return;let{row:r,col:n}=t.end;switch(e){case "extend-up":r=Math.max(0,r-1);break;case "extend-down":r=Math.min(this.virtualScroll.rowCount-1,r+1);break;case "extend-left":n=Math.max(0,n-1);break;case "extend-right":n=Math.min(this.virtualScroll.colCount-1,n+1);break}this.selection.handleDrag(r,n),this.scrollToSelection();}scrollToSelection(){let e=this.selection.getSelection();!e||!this.onScroll||this.onScroll(e.start.row,e.start.col);}setVirtualScroll(e){this.virtualScroll=e;}setSelection(e){this.selection=e;}};var O=class{merges;mergeMap;constructor(e=[]){this.merges=[],this.mergeMap=new Map,this.parseMerges(e);}parseMerges(e){for(let t of e){let[r,n]=t.split(":");if(!r||!n)continue;let o=R(r),a=R(n);if(!o||!a)continue;let d={startRow:Math.min(o.row,a.row),startCol:Math.min(o.col,a.col),endRow:Math.max(o.row,a.row),endCol:Math.max(o.col,a.col),cellRef:r};this.merges.push(d);for(let h=d.startRow;h<=d.endRow;h++)for(let f=d.startCol;f<=d.endCol;f++){let b=`${h},${f}`;this.mergeMap.set(b,d);}}}getMergeAt(e,t){return this.mergeMap.get(`${e},${t}`)??null}isMergeMaster(e,t){let r=this.getMergeAt(e,t);return r?r.startRow===e&&r.startCol===t:false}isMergeHidden(e,t){let r=this.getMergeAt(e,t);return r?!(r.startRow===e&&r.startCol===t):false}getMergeMaster(e,t){let r=this.getMergeAt(e,t);return r?{row:r.startRow,col:r.startCol}:null}getMergeRect(e,t,r){let n=this.getMergeAt(e,t);if(!n||!this.isMergeMaster(e,t))return null;let o=r(n.startRow,n.startCol),a=r(n.endRow,n.endCol);return {top:o.top,left:o.left,width:a.left+a.width-o.left,height:a.top+a.height-o.top}}getAllMerges(){return [...this.merges]}getVisibleMerges(e,t,r,n){return this.merges.filter(o=>o.endRow>=e&&o.startRow<=t&&o.endCol>=r&&o.startCol<=n)}update(e){this.merges=[],this.mergeMap.clear(),this.parseMerges(e);}};var q=class{async copyToClipboard(e){let t=this.formatSelection(e);try{if(navigator.clipboard&&typeof ClipboardItem<"u"){let r=new Blob([t.html],{type:"text/html"}),n=new Blob([t.text],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/html":r,"text/plain":n})]);}else await this.copyWithExecCommand(t.text);}catch{await this.copyWithExecCommand(t.text);}return t}formatSelection(e){let{cells:t}=e,r=[];for(let d of t){let h=d.map(f=>this.getCellValue(f));r.push(h.join(" "));}let n=r.join(`
2
+ `),o=[];for(let d of t){let h=d.map(f=>{let b=this.escapeHtml(this.getCellValue(f));return `<td style="${this.getCellStyle(f)}">${b}</td>`});o.push(`<tr>${h.join("")}</tr>`);}let a=`
3
3
  <table style="border-collapse: collapse; font-family: Arial, sans-serif; font-size: 12px;">
4
4
  <tbody>
5
5
  ${o.join(`
6
6
  `)}
7
7
  </tbody>
8
8
  </table>
9
- `.trim();return {text:s,html:a,cells:t}}getCellValue(e){return !e||e.v===void 0||e.v===null?"":String(e.v)}getCellStyle(e){let t=["border: 1px solid #ccc","padding: 4px 8px"];return e?.t==="n"&&t.push("text-align: right"),t.join("; ")}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}async copyWithExecCommand(e){let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-9999px",document.body.appendChild(t),t.select();try{document.execCommand("copy");}finally{document.body.removeChild(t);}}};var q=class{sheet;results;currentIndex;constructor(e){this.sheet=e,this.results=[],this.currentIndex=-1;}search(e,t={}){if(!e)return this.results=[],this.currentIndex=-1,[];let{caseSensitive:r=false,regex:s=false,matchWholeCell:o=false}=t,a;try{if(s)a=new RegExp(e,r?"g":"gi");else {let h=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),u=o?`^${h}$`:h;a=new RegExp(u,r?"g":"gi");}}catch{let h=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");a=new RegExp(h,r?"g":"gi");}let d=[];for(let[h,u]of Object.entries(this.sheet.cells)){if(u.v===void 0||u.v===null)continue;let b=String(u.v);a.lastIndex=0;let p=a.exec(b);if(p){let w=this.parseCellRef(h);w&&d.push({row:w.row,col:w.col,cellRef:h,value:b,matchStart:p.index,matchEnd:p.index+p[0].length});}}return d.sort((h,u)=>h.row!==u.row?h.row-u.row:h.col-u.col),this.results=d,this.currentIndex=d.length>0?0:-1,d}next(){return this.results.length===0?null:(this.currentIndex=(this.currentIndex+1)%this.results.length,this.results[this.currentIndex])}previous(){return this.results.length===0?null:(this.currentIndex=(this.currentIndex-1+this.results.length)%this.results.length,this.results[this.currentIndex])}current(){return this.currentIndex<0||this.currentIndex>=this.results.length?null:this.results[this.currentIndex]}getResults(){return [...this.results]}getCount(){return this.results.length}getCurrentIndex(){return this.currentIndex+1}isResult(e,t){return this.results.some(r=>r.row===e&&r.col===t)}isCurrent(e,t){let r=this.current();return r?.row===e&&r?.col===t}clear(){this.results=[],this.currentIndex=-1;}setSheet(e){this.sheet=e,this.clear();}parseCellRef(e){let t=e.match(/^([A-Z]+)(\d+)$/i);if(!t)return null;let r=t[1].toUpperCase(),s=parseInt(t[2],10)-1,o=0;for(let a=0;a<r.length;a++)o=o*26+(r.charCodeAt(a)-64);return o-=1,{row:s,col:o}}};var X=class{state=null;virtualScroll;onChange;minWidth;maxWidth;constructor(e,t,r=30,s=500){this.virtualScroll=e,this.onChange=t??null,this.minWidth=r,this.maxWidth=s;}startResize(e,t){let r=this.virtualScroll.getColWidth(e);this.state={isResizing:true,colIndex:e,startX:t,startWidth:r},document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),document.body.style.cursor="col-resize",document.body.style.userSelect="none";}handleMouseMove=e=>{if(!this.state)return;let t=e.clientX-this.state.startX,r=Math.min(this.maxWidth,Math.max(this.minWidth,this.state.startWidth+t));this.virtualScroll.setColWidth(this.state.colIndex,r),this.onChange?.(this.state.colIndex,r);};handleMouseUp=()=>{this.cleanup();};isResizing(){return this.state?.isResizing??false}getResizeColumn(){return this.state?.colIndex??null}cancel(){this.state&&(this.virtualScroll.setColWidth(this.state.colIndex,this.state.startWidth),this.onChange?.(this.state.colIndex,this.state.startWidth)),this.cleanup();}cleanup(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.body.style.cursor="",document.body.style.userSelect="",this.state=null;}setVirtualScroll(e){this.virtualScroll=e;}destroy(){this.cleanup();}};var te={default:{name:"default",colors:{background:"#ffffff",foreground:"#202124",grid:"#e0e0e0",headerBackground:"#f8f9fa",headerForeground:"#5f6368",selectionBorder:"#1a73e8",selectionBackground:"rgba(26, 115, 232, 0.08)",frozenBorder:"#dadce0"},fonts:{family:"'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",size:"13px",headerSize:"11px"}},excel:{name:"excel",colors:{background:"#ffffff",foreground:"#000000",grid:"#d4d4d4",headerBackground:"#f0f0f0",headerForeground:"#000000",selectionBorder:"#217346",selectionBackground:"rgba(33, 115, 70, 0.1)",frozenBorder:"#9bc2e6"},fonts:{family:"'Calibri', 'Segoe UI', sans-serif",size:"11px",headerSize:"11px"}},modern:{name:"modern",colors:{background:"#fafafa",foreground:"#18181b",grid:"#e4e4e7",headerBackground:"#f4f4f5",headerForeground:"#71717a",selectionBorder:"#3b82f6",selectionBackground:"rgba(59, 130, 246, 0.08)",frozenBorder:"#a1a1aa"},fonts:{family:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif",size:"13px",headerSize:"11px"}},minimal:{name:"minimal",colors:{background:"#ffffff",foreground:"#27272a",grid:"#f4f4f5",headerBackground:"#ffffff",headerForeground:"#a1a1aa",selectionBorder:"#18181b",selectionBackground:"rgba(24, 24, 27, 0.04)",frozenBorder:"#e4e4e7"},fonts:{family:"'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif",size:"13px",headerSize:"11px"}},dark:{name:"dark",colors:{background:"#1e1e1e",foreground:"#d4d4d4",grid:"#3c3c3c",headerBackground:"#252526",headerForeground:"#858585",selectionBorder:"#0078d4",selectionBackground:"rgba(0, 120, 212, 0.2)",frozenBorder:"#4a4a4a"},fonts:{family:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",size:"13px",headerSize:"11px"}},midnight:{name:"midnight",colors:{background:"#0d1117",foreground:"#c9d1d9",grid:"#21262d",headerBackground:"#161b22",headerForeground:"#8b949e",selectionBorder:"#58a6ff",selectionBackground:"rgba(88, 166, 255, 0.15)",frozenBorder:"#30363d"},fonts:{family:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",size:"13px",headerSize:"11px"}},accessible:{name:"accessible",colors:{background:"#ffffff",foreground:"#000000",grid:"#000000",headerBackground:"#e6e6e6",headerForeground:"#000000",selectionBorder:"#0000ff",selectionBackground:"rgba(0, 0, 255, 0.15)",frozenBorder:"#000000"},fonts:{family:"Arial, Helvetica, sans-serif",size:"14px",headerSize:"12px"}}};function ce(f,e){let t=f.style;t.setProperty("--nup-background",e.colors.background),t.setProperty("--nup-foreground",e.colors.foreground),t.setProperty("--nup-grid",e.colors.grid),t.setProperty("--nup-header-bg",e.colors.headerBackground),t.setProperty("--nup-header-fg",e.colors.headerForeground),t.setProperty("--nup-selection-border",e.colors.selectionBorder),t.setProperty("--nup-selection-bg",e.colors.selectionBackground),t.setProperty("--nup-frozen-border",e.colors.frozenBorder),t.setProperty("--nup-font-family",e.fonts.family),t.setProperty("--nup-font-size",e.fonts.size);}function he(f){return `nup-theme-${f}`}function Pe(f,e){let t=typeof f=="string"?document.querySelector(f):f;if(!t)throw new Error("Container element not found");let{workbook:r,activeSheet:s=0,theme:o="default",width:a="100%",height:d="400px",showHeaders:h=true,showGridLines:u=true,showSheetTabs:b=true,selectable:p=true,resizable:w=true,searchable:re=false,copyable:_=true,keyboardNavigation:de=true,frozenRows:Le=0,frozenCols:Ee=0,overscan:pe=5,defaultRowHeight:me=24,defaultColWidth:fe=100,ariaLabel:ge="Spreadsheet",onCellClick:be,onCellDoubleClick:we,onCellRightClick:ve,onSelectionChange:Ce,onSheetChange:oe,onColumnResize:ye,onScroll:xe,onSearch:Re,onCopy:ne}=e,B=s,k=0,$=0,M=0,H=0,C=null,N=[],T=()=>r.sheets[B]??r.sheets[0],Se=()=>typeof o=="string"?te[o]??te.default:o,g,x,G,se,Z,Y,le,J=()=>{let n=T(),l={},m={};Object.entries(n.rows).forEach(([c,i])=>{i.h&&(l[parseInt(c)]=i.h);}),Object.entries(n.cols).forEach(([c,i])=>{i.w&&(m[parseInt(c)]=i.w);}),g=new F({rows:n.rowCount,cols:n.colCount,rowHeights:l,colWidths:m,defaultRowHeight:me,defaultColWidth:fe,overscan:pe}),x=new D(n,c=>{C=c,Ce?.(c),y();}),G=new j(n.merges??[]),se=new q(n),Z=new O,Y=new X(g,(c,i)=>{ye?.(c,i),y();}),le=new U(x,g,{enabled:de},{onScroll:(c,i)=>{let v=g.getScrollToPosition(c,i,H,M);R?.scrollTo({top:v.scrollTop,left:v.scrollLeft,behavior:"smooth"});},onCopy:async()=>{let c=x.getSelection();if(c&&_){let i=await Z.copyToClipboard(c);ne?.(i);}}});},W=h?24:0,I=h?40:0,Me=typeof o=="string"?he(o):"";t.innerHTML=`
10
- <div class="nup-spreadsheet ${Me} ${u?"":"nup-no-gridlines"}"
9
+ `.trim();return {text:n,html:a,cells:t}}getCellValue(e){return !e||e.v===void 0||e.v===null?"":String(e.v)}getCellStyle(e){let t=["border: 1px solid #ccc","padding: 4px 8px"];return e?.t==="n"&&t.push("text-align: right"),t.join("; ")}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}async copyWithExecCommand(e){let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-9999px",document.body.appendChild(t),t.select();try{document.execCommand("copy");}finally{document.body.removeChild(t);}}};var X=class{sheet;results;currentIndex;constructor(e){this.sheet=e,this.results=[],this.currentIndex=-1;}search(e,t={}){if(!e)return this.results=[],this.currentIndex=-1,[];let{caseSensitive:r=false,regex:n=false,matchWholeCell:o=false}=t,a;try{if(n)a=new RegExp(e,r?"g":"gi");else {let h=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),f=o?`^${h}$`:h;a=new RegExp(f,r?"g":"gi");}}catch{let h=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");a=new RegExp(h,r?"g":"gi");}let d=[];for(let[h,f]of Object.entries(this.sheet.cells)){if(f.v===void 0||f.v===null)continue;let b=String(f.v);a.lastIndex=0;let p=a.exec(b);if(p){let w=this.parseCellRef(h);w&&d.push({row:w.row,col:w.col,cellRef:h,value:b,matchStart:p.index,matchEnd:p.index+p[0].length});}}return d.sort((h,f)=>h.row!==f.row?h.row-f.row:h.col-f.col),this.results=d,this.currentIndex=d.length>0?0:-1,d}next(){return this.results.length===0?null:(this.currentIndex=(this.currentIndex+1)%this.results.length,this.results[this.currentIndex])}previous(){return this.results.length===0?null:(this.currentIndex=(this.currentIndex-1+this.results.length)%this.results.length,this.results[this.currentIndex])}current(){return this.currentIndex<0||this.currentIndex>=this.results.length?null:this.results[this.currentIndex]}getResults(){return [...this.results]}getCount(){return this.results.length}getCurrentIndex(){return this.currentIndex+1}isResult(e,t){return this.results.some(r=>r.row===e&&r.col===t)}isCurrent(e,t){let r=this.current();return r?.row===e&&r?.col===t}clear(){this.results=[],this.currentIndex=-1;}setSheet(e){this.sheet=e,this.clear();}parseCellRef(e){let t=e.match(/^([A-Z]+)(\d+)$/i);if(!t)return null;let r=t[1].toUpperCase(),n=parseInt(t[2],10)-1,o=0;for(let a=0;a<r.length;a++)o=o*26+(r.charCodeAt(a)-64);return o-=1,{row:n,col:o}}};var _=class{state=null;virtualScroll;onChange;minWidth;maxWidth;constructor(e,t,r=30,n=500){this.virtualScroll=e,this.onChange=t??null,this.minWidth=r,this.maxWidth=n;}startResize(e,t){let r=this.virtualScroll.getColWidth(e);this.state={isResizing:true,colIndex:e,startX:t,startWidth:r},document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),document.body.style.cursor="col-resize",document.body.style.userSelect="none";}handleMouseMove=e=>{if(!this.state)return;let t=e.clientX-this.state.startX,r=Math.min(this.maxWidth,Math.max(this.minWidth,this.state.startWidth+t));this.virtualScroll.setColWidth(this.state.colIndex,r),this.onChange?.(this.state.colIndex,r);};handleMouseUp=()=>{this.cleanup();};isResizing(){return this.state?.isResizing??false}getResizeColumn(){return this.state?.colIndex??null}cancel(){this.state&&(this.virtualScroll.setColWidth(this.state.colIndex,this.state.startWidth),this.onChange?.(this.state.colIndex,this.state.startWidth)),this.cleanup();}cleanup(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.body.style.cursor="",document.body.style.userSelect="",this.state=null;}setVirtualScroll(e){this.virtualScroll=e;}destroy(){this.cleanup();}};var re={default:{name:"default",colors:{background:"#ffffff",foreground:"#202124",grid:"#e0e0e0",headerBackground:"#f8f9fa",headerForeground:"#5f6368",selectionBorder:"#1a73e8",selectionBackground:"rgba(26, 115, 232, 0.08)",frozenBorder:"#dadce0"},fonts:{family:"'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",size:"13px",headerSize:"11px"}},excel:{name:"excel",colors:{background:"#ffffff",foreground:"#000000",grid:"#d4d4d4",headerBackground:"#f0f0f0",headerForeground:"#000000",selectionBorder:"#217346",selectionBackground:"rgba(33, 115, 70, 0.1)",frozenBorder:"#9bc2e6"},fonts:{family:"'Calibri', 'Segoe UI', sans-serif",size:"11px",headerSize:"11px"}},modern:{name:"modern",colors:{background:"#fafafa",foreground:"#18181b",grid:"#e4e4e7",headerBackground:"#f4f4f5",headerForeground:"#71717a",selectionBorder:"#3b82f6",selectionBackground:"rgba(59, 130, 246, 0.08)",frozenBorder:"#a1a1aa"},fonts:{family:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif",size:"13px",headerSize:"11px"}},minimal:{name:"minimal",colors:{background:"#ffffff",foreground:"#27272a",grid:"#f4f4f5",headerBackground:"#ffffff",headerForeground:"#a1a1aa",selectionBorder:"#18181b",selectionBackground:"rgba(24, 24, 27, 0.04)",frozenBorder:"#e4e4e7"},fonts:{family:"'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif",size:"13px",headerSize:"11px"}},dark:{name:"dark",colors:{background:"#1e1e1e",foreground:"#d4d4d4",grid:"#3c3c3c",headerBackground:"#252526",headerForeground:"#858585",selectionBorder:"#0078d4",selectionBackground:"rgba(0, 120, 212, 0.2)",frozenBorder:"#4a4a4a"},fonts:{family:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",size:"13px",headerSize:"11px"}},midnight:{name:"midnight",colors:{background:"#0d1117",foreground:"#c9d1d9",grid:"#21262d",headerBackground:"#161b22",headerForeground:"#8b949e",selectionBorder:"#58a6ff",selectionBackground:"rgba(88, 166, 255, 0.15)",frozenBorder:"#30363d"},fonts:{family:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",size:"13px",headerSize:"11px"}},accessible:{name:"accessible",colors:{background:"#ffffff",foreground:"#000000",grid:"#000000",headerBackground:"#e6e6e6",headerForeground:"#000000",selectionBorder:"#0000ff",selectionBackground:"rgba(0, 0, 255, 0.15)",frozenBorder:"#000000"},fonts:{family:"Arial, Helvetica, sans-serif",size:"14px",headerSize:"12px"}}};function he(s,e){let t=s.style;t.setProperty("--nup-background",e.colors.background),t.setProperty("--nup-foreground",e.colors.foreground),t.setProperty("--nup-grid",e.colors.grid),t.setProperty("--nup-header-bg",e.colors.headerBackground),t.setProperty("--nup-header-fg",e.colors.headerForeground),t.setProperty("--nup-selection-border",e.colors.selectionBorder),t.setProperty("--nup-selection-bg",e.colors.selectionBackground),t.setProperty("--nup-frozen-border",e.colors.frozenBorder),t.setProperty("--nup-font-family",e.fonts.family),t.setProperty("--nup-font-size",e.fonts.size);}function de(s){return `nup-theme-${s}`}var je={thin:"1px solid",medium:"2px solid",thick:"3px solid",dashed:"1px dashed",dotted:"1px dotted",double:"3px double"};function G(s){if(!s||!s.style)return;let e=je[s.style]||"1px solid",t=s.color||"#000000";return `${e} ${t}`}function Ue(s,e){let t=s.replace("#",""),r=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),o=parseInt(t.substring(4,6),16),a,d,h;return e<0?(a=Math.round(r*(1+e)),d=Math.round(n*(1+e)),h=Math.round(o*(1+e))):(a=Math.round(r+(255-r)*e),d=Math.round(n+(255-n)*e),h=Math.round(o+(255-o)*e)),`#${a.toString(16).padStart(2,"0")}${d.toString(16).padStart(2,"0")}${h.toString(16).padStart(2,"0")}`}function fe(s){if(!s)return {};let e={};if(s.font){let t=s.font;t.name&&(e.fontFamily=t.name),t.size&&(e.fontSize=`${t.size}pt`),t.bold&&(e.fontWeight="bold"),t.italic&&(e.fontStyle="italic"),t.color&&(e.color=t.color);let r=[];t.underline&&r.push("underline"),t.strike&&r.push("line-through"),r.length>0&&(e.textDecoration=r.join(" "));}if(s.fill){let t=s.fill;if(t.color){let r=t.color;t.tint!==void 0&&t.tint!==0&&(r=Ue(r,t.tint)),e.backgroundColor=r;}}if(s.alignment){let t=s.alignment;t.horizontal&&(e.textAlign=t.horizontal),t.vertical&&(e.verticalAlign=t.vertical==="middle"?"middle":t.vertical),t.wrapText&&(e.whiteSpace="pre-wrap"),t.indent&&(e.paddingLeft=`${t.indent*8}px`),t.rotation&&(e.transform=`rotate(${t.rotation}deg)`);}if(s.border){let t=s.border;(t.top||t.right||t.bottom||t.left)&&(e.borderTop=G(t.top)||"none",e.borderRight=G(t.right)||"none",e.borderBottom=G(t.bottom)||"none",e.borderLeft=G(t.left)||"none");}return e}function pe(s){let e=Object.entries(s).filter(([,t])=>t!==void 0);return e.length===0?"":e.map(([t,r])=>`${t.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${r}`).join("; ")}function Oe(s,e){if(s!==void 0&&e.styles)return e.styles[s]??e.styles[String(s)]}function ge(s){let e=t=>t&&t!=="none";return !!(e(s.borderTop)||e(s.borderRight)||e(s.borderBottom)||e(s.borderLeft))}function me(s,e,t){let r=t?Oe(e,t):void 0;if(!(!s&&!r))return s?r?{...r,...s,font:{...r.font,...s.font},fill:{...r.fill,...s.fill},border:{...r.border,...s.border},alignment:{...r.alignment,...s.alignment}}:s:r}function qe(s,e){let t=typeof s=="string"?document.querySelector(s):s;if(!t)throw new Error("Container element not found");let{workbook:r,activeSheet:n=0,theme:o="default",width:a="100%",height:d="400px",showHeaders:h=true,showGridLines:f=true,showSheetTabs:b=true,selectable:p=true,resizable:w=true,searchable:oe=false,copyable:Z=true,keyboardNavigation:we=true,frozenRows:Xe=0,frozenCols:_e=0,overscan:ve=5,defaultRowHeight:Ce=24,defaultColWidth:xe=100,ariaLabel:ye="Spreadsheet",onCellClick:Se,onCellDoubleClick:Re,onCellRightClick:Me,onSelectionChange:Te,onSheetChange:ne,onColumnResize:ze,onScroll:$e,onSearch:ke,onCopy:se}=e,N=n,k=0,H=0,M=0,T=0,C=null,K=[],$=()=>r.sheets[N]??r.sheets[0],He=()=>typeof o=="string"?re[o]??re.default:o,m,y,V,le,Y,J,ie,Q=()=>{let l=$(),c={},g={};Object.entries(l.rows).forEach(([u,i])=>{i.h&&(c[parseInt(u)]=i.h);}),Object.entries(l.cols).forEach(([u,i])=>{i.w&&(g[parseInt(u)]=i.w);}),m=new D({rows:l.rowCount,cols:l.colCount,rowHeights:c,colWidths:g,defaultRowHeight:Ce,defaultColWidth:xe,overscan:ve}),y=new j(l,u=>{C=u,Te?.(u),x();}),V=new O(l.merges??[]),le=new X(l),Y=new q,J=new _(m,(u,i)=>{ze?.(u,i),x();}),ie=new U(y,m,{enabled:we},{onScroll:(u,i)=>{let v=m.getScrollToPosition(u,i,T,M);S?.scrollTo({top:v.scrollTop,left:v.scrollLeft,behavior:"smooth"});},onCopy:async()=>{let u=y.getSelection();if(u&&Z){let i=await Y.copyToClipboard(u);se?.(i);}}});},W=h?24:0,I=h?40:0,We=typeof o=="string"?de(o):"";t.innerHTML=`
10
+ <div class="nup-spreadsheet ${We} ${f?"":"nup-no-gridlines"}"
11
11
  style="width: ${typeof a=="number"?a+"px":a}; height: ${typeof d=="number"?d+"px":d};"
12
12
  tabindex="0"
13
13
  role="grid"
14
- aria-label="${ge}">
14
+ aria-label="${ye}">
15
15
  ${h?`<div class="nup-corner" style="width: ${I}px; height: ${W}px;"></div>`:""}
16
16
  ${h?`
17
17
  <div class="nup-header-row-container" style="position: absolute; top: 0; left: ${I}px; right: 0; height: ${W}px; overflow: hidden;">
@@ -26,30 +26,30 @@
26
26
  </div>
27
27
  ${b&&r.sheets.length>1?'<div class="nup-sheet-tabs"></div>':""}
28
28
  </div>
29
- `;let ie=t.querySelector(".nup-spreadsheet"),R=t.querySelector(".nup-scroll-container"),P=t.querySelector(".nup-content"),z=t.querySelector(".nup-header-row-inner"),L=t.querySelector(".nup-header-col-inner"),Q=t.querySelector(".nup-sheet-tabs");ce(ie,Se()),J();let ae=new ResizeObserver(n=>{let l=n[0];l&&(M=l.contentRect.width,H=l.contentRect.height,y());});ae.observe(R),M=R.clientWidth,H=R.clientHeight,R.addEventListener("scroll",()=>{k=R.scrollTop,$=R.scrollLeft,z&&(z.style.transform=`translateX(${-$}px)`),L&&(L.style.transform=`translateY(${-k}px)`);let n=g.getVisibleRange(k,$,H,M);xe?.({scrollTop:k,scrollLeft:$,visibleRows:{start:n.startRow,end:n.endRow},visibleCols:{start:n.startCol,end:n.endCol}}),y();}),ie.addEventListener("keydown",n=>{le.handleKeyDown(n);});let y=()=>{let n=T(),l=g.getVisibleRange(k,$,H,M);P.style.width=`${g.totalWidth}px`,P.style.height=`${g.totalHeight}px`,z&&(z.style.width=`${g.totalWidth}px`),L&&(L.style.height=`${g.totalHeight}px`);let m="";for(let c=l.startRow;c<=l.endRow;c++)for(let i=l.startCol;i<=l.endCol;i++){if(G.isMergeHidden(c,i))continue;let v=G.getMergeRect(c,i,(V,We)=>g.getCellRect(V,We))??g.getCellRect(c,i),E=A(c,i),K=n.cells[E],He=x.isCellSelected(c,i),ze=x.isAnchor(c,i),Te=N.some(V=>V.row===c&&V.col===i),ke=["nup-cell",K?.t==="n"?"nup-cell-number":"",He?"nup-cell-selected":"",ze?"nup-cell-anchor":"",Te?"nup-cell-search-result":""].filter(Boolean).join(" "),$e=K?.v!==void 0&&K?.v!==null?String(K.v):"";m+=`
30
- <div class="${ke}"
31
- style="top: ${v.top}px; left: ${v.left}px; width: ${v.width}px; height: ${v.height}px;"
32
- data-row="${c}" data-col="${i}" data-cell-ref="${E}">
33
- ${ue($e)}
29
+ `;let ae=t.querySelector(".nup-spreadsheet"),S=t.querySelector(".nup-scroll-container"),P=t.querySelector(".nup-content"),z=t.querySelector(".nup-header-row-inner"),L=t.querySelector(".nup-header-col-inner"),ee=t.querySelector(".nup-sheet-tabs");he(ae,He()),Q();let ce=new ResizeObserver(l=>{let c=l[0];c&&(M=c.contentRect.width,T=c.contentRect.height,x());});ce.observe(S),M=S.clientWidth,T=S.clientHeight,S.addEventListener("scroll",()=>{k=S.scrollTop,H=S.scrollLeft,z&&(z.style.transform=`translateX(${-H}px)`),L&&(L.style.transform=`translateY(${-k}px)`);let l=m.getVisibleRange(k,H,T,M);$e?.({scrollTop:k,scrollLeft:H,visibleRows:{start:l.startRow,end:l.endRow},visibleCols:{start:l.startCol,end:l.endCol}}),x();}),ae.addEventListener("keydown",l=>{ie.handleKeyDown(l);});let x=()=>{let l=$(),c=m.getVisibleRange(k,H,T,M);P.style.width=`${m.totalWidth}px`,P.style.height=`${m.totalHeight}px`,z&&(z.style.width=`${m.totalWidth}px`),L&&(L.style.height=`${m.totalHeight}px`);let g="";for(let u=c.startRow;u<=c.endRow;u++)for(let i=c.startCol;i<=c.endCol;i++){if(V.isMergeHidden(u,i))continue;let v=V.getMergeRect(u,i,(F,Fe)=>m.getCellRect(F,Fe))??m.getCellRect(u,i),B=A(u,i),E=l.cells[B],Ie=y.isCellSelected(u,i),Pe=y.isAnchor(u,i),Le=K.some(F=>F.row===u&&F.col===i),Be=me(E?.style,E?.s,r),ue=fe(Be),Ee=ge(ue),Ae=V.isMergeMaster(u,i),Ne=["nup-cell",E?.t==="n"?"nup-cell-number":"",Ie?"nup-cell-selected":"",Pe?"nup-cell-anchor":"",Le?"nup-cell-search-result":"",Ee?"nup-has-border":"",Ae?"nup-cell-merge-master":""].filter(Boolean).join(" "),Ke=E?.v!==void 0&&E?.v!==null?String(E.v):"",Ve=pe(ue);g+=`
30
+ <div class="${Ne}"
31
+ style="top: ${v.top}px; left: ${v.left}px; width: ${v.width}px; height: ${v.height}px; ${Ve}"
32
+ data-row="${u}" data-col="${i}" data-cell-ref="${B}">
33
+ ${be(Ke)}
34
34
  </div>
35
- `;}if(C){let c=g.getCellRect(C.start.row,C.start.col),i=g.getCellRect(C.end.row,C.end.col);m+=`
35
+ `;}if(C){let u=m.getCellRect(C.start.row,C.start.col),i=m.getCellRect(C.end.row,C.end.col);g+=`
36
36
  <div class="nup-selection-border"
37
- style="top: ${c.top}px; left: ${c.left}px; width: ${i.left+i.width-c.left}px; height: ${i.top+i.height-c.top}px;">
37
+ style="top: ${u.top}px; left: ${u.left}px; width: ${i.left+i.width-u.left}px; height: ${i.top+i.height-u.top}px;">
38
38
  </div>
39
- `;}if(P.innerHTML=m,h&&z){let c="";for(let i=l.startCol;i<=l.endCol;i++){let v=g.getCellRect(0,i),E=C&&i>=C.start.col&&i<=C.end.col;c+=`
40
- <div class="nup-header nup-header-col ${E?"nup-header-selected":""}"
39
+ `;}if(P.innerHTML=g,h&&z){let u="";for(let i=c.startCol;i<=c.endCol;i++){let v=m.getCellRect(0,i),B=C&&i>=C.start.col&&i<=C.end.col;u+=`
40
+ <div class="nup-header nup-header-col ${B?"nup-header-selected":""}"
41
41
  style="left: ${v.left}px; width: ${v.width}px; height: ${W}px;">
42
- ${ee(i)}
42
+ ${te(i)}
43
43
  ${w?'<div class="nup-resize-handle" data-col="'+i+'"></div>':""}
44
44
  </div>
45
- `;}z.innerHTML=c;}if(h&&L){let c="";for(let i=l.startRow;i<=l.endRow;i++){let v=g.getCellRect(i,0),E=C&&i>=C.start.row&&i<=C.end.row;c+=`
46
- <div class="nup-header nup-header-row ${E?"nup-header-selected":""}"
45
+ `;}z.innerHTML=u;}if(h&&L){let u="";for(let i=c.startRow;i<=c.endRow;i++){let v=m.getCellRect(i,0),B=C&&i>=C.start.row&&i<=C.end.row;u+=`
46
+ <div class="nup-header nup-header-row ${B?"nup-header-selected":""}"
47
47
  style="top: ${v.top}px; width: ${I}px; height: ${v.height}px;">
48
48
  ${i+1}
49
49
  </div>
50
- `;}L.innerHTML=c;}Q&&r.sheets.length>1&&(Q.innerHTML=r.sheets.map((c,i)=>`
51
- <button class="nup-sheet-tab ${i===B?"nup-sheet-tab-active":""}" data-sheet="${i}">
52
- ${ue(c.name)}
50
+ `;}L.innerHTML=u;}ee&&r.sheets.length>1&&(ee.innerHTML=r.sheets.map((u,i)=>`
51
+ <button class="nup-sheet-tab ${i===N?"nup-sheet-tab-active":""}" data-sheet="${i}">
52
+ ${be(u.name)}
53
53
  </button>
54
- `).join(""));};return P.addEventListener("click",n=>{if(!p)return;let l=n.target.closest(".nup-cell");if(!l)return;let m=parseInt(l.dataset.row??"0"),c=parseInt(l.dataset.col??"0"),i=l.dataset.cellRef??"";x.handleClick(m,c,{shiftKey:n.shiftKey,ctrlKey:n.ctrlKey,metaKey:n.metaKey}),be?.({cell:T().cells[i]??null,row:m,col:c,cellRef:i,originalEvent:n});}),P.addEventListener("dblclick",n=>{let l=n.target.closest(".nup-cell");if(!l)return;let m=parseInt(l.dataset.row??"0"),c=parseInt(l.dataset.col??"0"),i=l.dataset.cellRef??"";we?.({cell:T().cells[i]??null,row:m,col:c,cellRef:i,originalEvent:n});}),P.addEventListener("contextmenu",n=>{let l=n.target.closest(".nup-cell");if(!l)return;n.preventDefault();let m=parseInt(l.dataset.row??"0"),c=parseInt(l.dataset.col??"0"),i=l.dataset.cellRef??"";ve?.({cell:T().cells[i]??null,row:m,col:c,cellRef:i,originalEvent:n});}),Q?.addEventListener("click",n=>{let l=n.target.closest(".nup-sheet-tab");if(!l)return;let m=parseInt(l.dataset.sheet??"0");B=m,J(),oe?.(m),y();}),w&&z&&z.addEventListener("mousedown",n=>{let l=n.target.closest(".nup-resize-handle");if(!l)return;let m=parseInt(l.dataset.col??"0");Y.startResize(m,n.clientX);}),y(),{scrollTo:(n,l)=>{let m=g.getScrollToPosition(n,l,H,M);R.scrollTo({top:m.scrollTop,left:m.scrollLeft,behavior:"smooth"});},scrollToCell:n=>{let l=S(n);if(l){let m=g.getScrollToPosition(l.row,l.col,H,M);R.scrollTo({top:m.scrollTop,left:m.scrollLeft,behavior:"smooth"});}},select:n=>{C=n,y();},selectCell:n=>{x.selectCell(n);},selectAll:()=>{x.selectAll();},clearSelection:()=>{x.clear();},getSelection:()=>C,setActiveSheet:n=>{B=n,J(),oe?.(n),y();},getActiveSheet:()=>B,search:n=>{let l=se.search(n);return N=l,Re?.(l),y(),l},highlightResults:n=>{N=n,y();},clearHighlights:()=>{N=[],y();},getWorkbook:()=>r,getVisibleCells:()=>{let n=T(),l=g.getVisibleRange(k,$,H,M),m=[];for(let c=l.startRow;c<=l.endRow;c++){let i=[];for(let v=l.startCol;v<=l.endCol;v++)i.push(n.cells[A(c,v)]??null);m.push(i);}return m},getCellAt:(n,l)=>T().cells[A(n,l)]??null,copySelection:async()=>{let n=x.getSelection();if(n){let l=await Z.copyToClipboard(n);ne?.(l);}},setColumnWidth:(n,l)=>{g.setColWidth(n,l),y();},autoFitColumn:()=>{},autoFitAllColumns:()=>{},refresh:()=>y(),destroy:()=>{ae.disconnect(),Y.destroy(),t.innerHTML="";}}}function ue(f){return f.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}var ot=Pe;exports.createSpreadsheetPreview=Pe;exports.default=ot;//# sourceMappingURL=vanilla.cjs.map
54
+ `).join(""));};return P.addEventListener("click",l=>{if(!p)return;let c=l.target.closest(".nup-cell");if(!c)return;let g=parseInt(c.dataset.row??"0"),u=parseInt(c.dataset.col??"0"),i=c.dataset.cellRef??"";y.handleClick(g,u,{shiftKey:l.shiftKey,ctrlKey:l.ctrlKey,metaKey:l.metaKey}),Se?.({cell:$().cells[i]??null,row:g,col:u,cellRef:i,originalEvent:l});}),P.addEventListener("dblclick",l=>{let c=l.target.closest(".nup-cell");if(!c)return;let g=parseInt(c.dataset.row??"0"),u=parseInt(c.dataset.col??"0"),i=c.dataset.cellRef??"";Re?.({cell:$().cells[i]??null,row:g,col:u,cellRef:i,originalEvent:l});}),P.addEventListener("contextmenu",l=>{let c=l.target.closest(".nup-cell");if(!c)return;l.preventDefault();let g=parseInt(c.dataset.row??"0"),u=parseInt(c.dataset.col??"0"),i=c.dataset.cellRef??"";Me?.({cell:$().cells[i]??null,row:g,col:u,cellRef:i,originalEvent:l});}),ee?.addEventListener("click",l=>{let c=l.target.closest(".nup-sheet-tab");if(!c)return;let g=parseInt(c.dataset.sheet??"0");N=g,Q(),ne?.(g),x();}),w&&z&&z.addEventListener("mousedown",l=>{let c=l.target.closest(".nup-resize-handle");if(!c)return;let g=parseInt(c.dataset.col??"0");J.startResize(g,l.clientX);}),x(),{scrollTo:(l,c)=>{let g=m.getScrollToPosition(l,c,T,M);S.scrollTo({top:g.scrollTop,left:g.scrollLeft,behavior:"smooth"});},scrollToCell:l=>{let c=R(l);if(c){let g=m.getScrollToPosition(c.row,c.col,T,M);S.scrollTo({top:g.scrollTop,left:g.scrollLeft,behavior:"smooth"});}},select:l=>{C=l,x();},selectCell:l=>{y.selectCell(l);},selectAll:()=>{y.selectAll();},clearSelection:()=>{y.clear();},getSelection:()=>C,setActiveSheet:l=>{N=l,Q(),ne?.(l),x();},getActiveSheet:()=>N,search:l=>{let c=le.search(l);return K=c,ke?.(c),x(),c},highlightResults:l=>{K=l,x();},clearHighlights:()=>{K=[],x();},getWorkbook:()=>r,getVisibleCells:()=>{let l=$(),c=m.getVisibleRange(k,H,T,M),g=[];for(let u=c.startRow;u<=c.endRow;u++){let i=[];for(let v=c.startCol;v<=c.endCol;v++)i.push(l.cells[A(u,v)]??null);g.push(i);}return g},getCellAt:(l,c)=>$().cells[A(l,c)]??null,copySelection:async()=>{let l=y.getSelection();if(l){let c=await Y.copyToClipboard(l);se?.(c);}},setColumnWidth:(l,c)=>{m.setColWidth(l,c),x();},autoFitColumn:()=>{},autoFitAllColumns:()=>{},refresh:()=>x(),destroy:()=>{ce.disconnect(),J.destroy(),t.innerHTML="";}}}function be(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}var wt=qe;exports.createSpreadsheetPreview=qe;exports.default=wt;//# sourceMappingURL=vanilla.cjs.map
55
55
  //# sourceMappingURL=vanilla.cjs.map