xiaodao-spreader 0.1.2 → 0.1.4
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.
- package/dist/style.css +1 -1
- package/dist/types/components/spreader/borderPicker.vue.d.ts +26 -0
- package/dist/types/components/spreader/colorPicker.vue.d.ts +30 -0
- package/dist/types/components/spreader/constants.d.ts +20 -0
- package/dist/types/components/spreader/dropdown.vue.d.ts +34 -0
- package/dist/types/components/spreader/spreader.vue.d.ts +3 -2
- package/dist/types/components/spreader/tabbar.vue.d.ts +34 -0
- package/dist/types/components/spreader/toolbar.vue.d.ts +44 -0
- package/dist/types/components/spreader/types.d.ts +8 -2
- package/dist/xiaodao-spreader.es.js +3189 -979
- package/dist/xiaodao-spreader.umd.js +9 -4
- package/package.json +1 -1
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
(function(le,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],a):(le=typeof globalThis<"u"?globalThis:le||self,a(le.XiaoDaoSpreader={},le.Vue))})(this,function(le,a){"use strict";const al={"zh-CN":{insert:"插入",delete:"删除",rename:"重命名",moveLeft:"左移",moveRight:"右移",cut:"剪切",copy:"复制",paste:"粘贴",addSheet:"新建工作表",moveSheetLeft:"左移",moveSheetRight:"右移",scrollUp:"向上滚动",scrollDown:"向下滚动",scrollLeft:"向左滚动",scrollRight:"向右滚动",calculate:"计算",sum:"求和"},"en-US":{insert:"Insert",delete:"Delete",rename:"Rename",moveLeft:"Move Left",moveRight:"Move Right",cut:"Cut",copy:"Copy",paste:"Paste",addSheet:"Add new sheet",moveSheetLeft:"Move Left",moveSheetRight:"Move Right",scrollUp:"Scroll up",scrollDown:"Scroll down",scrollLeft:"Scroll left",scrollRight:"Scroll right",calculate:"Calculate",sum:"Sum"}};function B(s,d){var i;return((i=al[s])==null?void 0:i[d])??d}const rl={bg:"#f4f4f4",gridBg:"#ffffff",headerBg:"#e8e8e8",headerBorder:"#c8c8c8",headerText:"#444",headerSep:"#b0b0b0",cornerBg:"#e0e0e0",gridLine:"#e0e0e0",selectionBg:"rgba(0, 120, 215, 0.12)",activeCellBorder:"#0078d7",cellText:"#1a1a1a",scrollTrack:"rgba(0,0,0,0.08)",scrollThumb:"rgba(0,0,0,0.25)",formulaBarBg:"#f0f0f0",formulaBarBorder:"#c8c8c8",formulaBarLabelText:"#333",formulaBarLabelBg:"#fff",formulaBarLabelBorder:"#c0c0c0",formulaBarInputBg:"#fff",formulaBarInputBorder:"#c0c0c0",formulaBarInputText:"#1a1a1a",formulaBarInputFocusBorder:"#0078d7",formulaBarInputFocusShadow:"rgba(0, 120, 215, 0.3)",wrapperBg:"#e8e8e8",cellEditorBorder:"#0078d7",cellEditorText:"#1a1a1a",cellEditorBg:"#fff",cellEditorShadow:"#0078d7",tabBarBg:"#e8e8e8",tabBarBorder:"#c0c0c0",tabActiveBg:"#ffffff",tabActiveText:"#1a1a1a",tabActiveBorder:"#0078d7",tabInactiveBg:"#dfdfdf",tabInactiveText:"#666",tabInactiveBorder:"transparent",tabHoverBg:"#e0e0e0",tabAddBtnColor:"#555",tabAddBtnHoverBg:"#d0d0d0",tabScrollBtnColor:"#888",tabScrollBtnHoverBg:"#d0d0d0",scrollbarThumb:"rgba(0,0,0,0.25)",scrollbarThumbHover:"rgba(0,0,0,0.4)",scrollBtnBg:"#e8e8e8",scrollBtnColor:"#666",scrollBtnHoverBg:"#d0d0d0",scrollBtnActiveBg:"#c0c0c0",scrollTrackBg:"rgba(0,0,0,0.06)"},cl={bg:"#1e1e1e",gridBg:"#252526",headerBg:"#252525",headerBorder:"#3e3e3e",headerText:"#999",headerSep:"#3e3e3e",cornerBg:"#2a2a2a",gridLine:"#3e3e3e",selectionBg:"rgba(0, 120, 215, 0.25)",activeCellBorder:"#0078d7",cellText:"#d4d4d4",scrollTrack:"rgba(255,255,255,0.06)",scrollThumb:"rgba(255,255,255,0.2)",formulaBarBg:"#2d2d2d",formulaBarBorder:"#3e3e3e",formulaBarLabelText:"#ccc",formulaBarLabelBg:"#3c3c3c",formulaBarLabelBorder:"#555",formulaBarInputBg:"#3c3c3c",formulaBarInputBorder:"#555",formulaBarInputText:"#d4d4d4",formulaBarInputFocusBorder:"#0078d7",formulaBarInputFocusShadow:"rgba(0, 120, 215, 0.4)",wrapperBg:"#1e1e1e",cellEditorBorder:"#0078d7",cellEditorText:"#d4d4d4",cellEditorBg:"#3c3c3c",cellEditorShadow:"#0078d7",tabBarBg:"#2a2a2a",tabBarBorder:"#3e3e3e",tabActiveBg:"#1e1e1e",tabActiveText:"#e0e0e0",tabActiveBorder:"#0078d7",tabInactiveBg:"#333333",tabInactiveText:"#888",tabInactiveBorder:"transparent",tabHoverBg:"#3a3a3a",tabAddBtnColor:"#999",tabAddBtnHoverBg:"#3a3a3a",tabScrollBtnColor:"#777",tabScrollBtnHoverBg:"#3a3a3a",scrollbarThumb:"rgba(255,255,255,0.2)",scrollbarThumbHover:"rgba(255,255,255,0.35)",scrollBtnBg:"#2d2d2d",scrollBtnColor:"#999",scrollBtnHoverBg:"#3d3d3d",scrollBtnActiveBg:"#4d4d4d",scrollTrackBg:"rgba(255,255,255,0.05)"};function Y(s){let d="",i=s;do d=String.fromCharCode(65+i%26)+d,i=Math.floor(i/26)-1;while(i>=0);return d}function Qe(s){let d=0;for(let i=0;i<s.length;i++)d=d*26+(s.toUpperCase().charCodeAt(i)-64);return d-1}function ae(s){if(s==null)return null;if(typeof s=="number")return s;if(typeof s=="string"){const d=parseFloat(s);return s.endsWith("%")||isNaN(d)?null:d}return null}function et(s){navigator.clipboard.writeText(s).catch(()=>{const d=document.createElement("textarea");d.value=s,d.style.position="fixed",d.style.opacity="0",document.body.appendChild(d),d.select(),document.execCommand("copy"),document.body.removeChild(d)})}function me(s,d){return`${s},${d}`}function $e(s,d,i){const u=s.match(/^\$?([A-Z]+)\$?(\d+)$/i);if(!u)return null;const c=Qe(u[1]),E=parseInt(u[2],10)-1;return c<0||c>=d||E<0||E>=i?null:{col:c,row:E}}function re(s,d){if(!d)return{x:0,y:0};const i=d.getBoundingClientRect();return{x:s.clientX-i.left,y:s.clientY-i.top}}function sl(s,d,i){const u=s.split(":");if(u.length!==2)return null;const c=$e(u[0],d,i),E=$e(u[1],d,i);return!c||!E?null:{sc:Math.min(c.col,E.col),sr:Math.min(c.row,E.row),ec:Math.max(c.col,E.col),er:Math.max(c.row,E.row)}}function il(s,d,i,u,c){const E=i[me(s,d)];if(!E)return 0;const T=E.value;if(T.startsWith("="))return _t(me(s,d),i,u,c)??0;const b=parseFloat(T);return isNaN(b)?0:b}const be=new Map;function kt(){be.clear()}function _t(s,d,i,u){return ul(s,d,i,u)}function ul(s,d,i,u,c){if(be.has(s))return NaN;be.set(s,NaN);const E=d[s];if(!E)return NaN;const T=E.value;if(!T.startsWith("=")){const g=parseFloat(T),p=isNaN(g)?0:g;return be.set(s,p),p}const b=T.slice(1).trim();if(b.toUpperCase().startsWith("SUM(")&&b.endsWith(")")){const g=b.slice(4,-1).trim(),p=sl(g,i,u);if(p){let D=0;for(let N=p.sc;N<=p.ec;N++)for(let _=p.sr;_<=p.er;_++)D+=il(N,_,d,i,u);return isNaN(D)?NaN:(be.set(s,D),D)}return NaN}return NaN}function St(s,d,i){const u=[],c=/(\$?[A-Z]+\$?\d+)(?::(\$?[A-Z]+\$?\d+))?/gi;let E;for(;(E=c.exec(s))!==null;){const T=$e(E[1],d,i);if(T)if(E[2]){const b=$e(E[2],d,i);if(!b)continue;for(let L=Math.min(T.col,b.col);L<=Math.max(T.col,b.col);L++)for(let g=Math.min(T.row,b.row);g<=Math.max(T.row,b.row);g++)u.push(me(L,g))}else u.push(me(T.col,T.row))}return u}function fl(s,d,i,u,c){const E=i[me(s,d)];if(!E)return"";const T=E.value;if(!T.startsWith("="))return T;const b=_t(me(s,d),i,u,c);return isNaN(b)?"#ERROR":String(b)}function dl(s,d,i,u,c,E){return d===0&&i===0?s:s.replace(/(\$?)([A-Z]+)(\$?)(\d+)/gi,(T,b,L,g,p)=>{const D=b?Qe(L):Qe(L)+d,N=g?parseInt(p,10)-1:parseInt(p,10)-1+i;let _;D<0?_="A":D>=u?_=E(u-1):_=E(D);let C;return N<0?C="1":N>=c?C=String(c):C=String(N+1),(b||"")+_+(g||"")+C})}class vl{constructor(){this.deps=new Map,this.rev=new Map,this.dirty=new Set}clear(d){var u;const i=this.deps.get(d);if(i){for(const c of i)(u=this.rev.get(c))==null||u.delete(d);this.deps.delete(d)}}set(d,i){if(this.clear(d),i.length!==0){this.deps.set(d,i);for(const u of i)this.rev.has(u)||this.rev.set(u,new Set),this.rev.get(u).add(d)}}markDirty(d){const i=[d];for(;i.length>0;){const u=i.pop(),c=this.rev.get(u);if(c)for(const E of c)this.dirty.has(E)||(this.dirty.add(E),i.push(E))}}getDirtyAndClear(){const d=this.dirty;return this.dirty=new Set,d}rebuild(d,i,u){this.deps.clear(),this.rev.clear(),this.dirty.clear(),be.clear();for(const[c,E]of Object.entries(d))if(E.value.startsWith("=")){const T=St(E.value.slice(1),i,u);this.set(c,T)}}}function hl(s,d,i,u){const c={},E=u(d),T=u(i);return E!=null&&(c.width=`${E}px`),T!=null&&(c.height=`${T}px`),c["--sp-formula-bar-bg"]=s.formulaBarBg,c["--sp-formula-bar-border"]=s.formulaBarBorder,c["--sp-formula-bar-label-color"]=s.formulaBarLabelText,c["--sp-formula-bar-label-bg"]=s.formulaBarLabelBg,c["--sp-formula-bar-label-border"]=s.formulaBarLabelBorder,c["--sp-formula-bar-input-bg"]=s.formulaBarInputBg,c["--sp-formula-bar-input-border"]=s.formulaBarInputBorder,c["--sp-formula-bar-input-color"]=s.formulaBarInputText,c["--sp-formula-bar-input-focus-border"]=s.formulaBarInputFocusBorder,c["--sp-formula-bar-input-focus-shadow"]=s.formulaBarInputFocusShadow,c["--sp-wrapper-bg"]=s.wrapperBg,c["--sp-cell-editor-border"]=s.cellEditorBorder,c["--sp-cell-editor-color"]=s.cellEditorText,c["--sp-cell-editor-bg"]=s.cellEditorBg,c["--sp-cell-editor-shadow"]=s.cellEditorShadow,c["--sp-tab-bar-bg"]=s.tabBarBg,c["--sp-tab-bar-border"]=s.tabBarBorder,c["--sp-tab-active-bg"]=s.tabActiveBg,c["--sp-tab-active-color"]=s.tabActiveText,c["--sp-tab-active-border"]=s.tabActiveBorder,c["--sp-tab-inactive-bg"]=s.tabInactiveBg,c["--sp-tab-inactive-color"]=s.tabInactiveText,c["--sp-tab-inactive-border"]=s.tabInactiveBorder,c["--sp-tab-hover-bg"]=s.tabHoverBg,c["--sp-tab-add-btn-color"]=s.tabAddBtnColor,c["--sp-tab-add-btn-hover-bg"]=s.tabAddBtnHoverBg,c["--sp-tab-scroll-btn-color"]=s.tabScrollBtnColor,c["--sp-tab-scroll-btn-hover-bg"]=s.tabScrollBtnHoverBg,c["--sp-scroll-thumb"]=s.scrollbarThumb,c["--sp-scroll-thumb-hover"]=s.scrollbarThumbHover,c["--sp-scroll-btn-bg"]=s.scrollBtnBg,c["--sp-scroll-btn-color"]=s.scrollBtnColor,c["--sp-scroll-btn-hover-bg"]=s.scrollBtnHoverBg,c["--sp-scroll-btn-active-bg"]=s.scrollBtnActiveBg,c["--sp-scroll-track-bg"]=s.scrollTrackBg,c}const pl={class:"tab-list"},ml=["onClick","onDblclick","onContextmenu"],bl=["value"],El={key:1,class:"tab-item__name"},gl=["title"],Hl={class:"formula-bar"},wl={class:"formula-bar__cell-label"},Bl=["value"],yl=["value"],Tl=["title"],Dl=["title"],Rl=["title"],xl=["title"],kl={key:2,class:"sb-corner"},_l=["onClick","onMouseenter"],Sl={class:"context-menu__label"},Cl={key:0,class:"context-menu__arrow"},Il=["onClick"],Ct=((s,d)=>{const i=s.__vccOpts||s;for(const[u,c]of d)i[u]=c;return i})(a.defineComponent({__name:"spreader",props:a.mergeModels({rowCount:{default:200},colCount:{default:26},width:{},height:{},theme:{default:"light"},locale:{default:"zh-CN"}},{data:{default:()=>[]},dataModifiers:{}}),emits:["update:data"],setup(s){const d=s,i=a.computed(()=>d.locale==="zh-CN"?"zh-CN":"en-US"),u=d.colCount,c=d.rowCount,E=a.useModel(s,"data");let T="";const b=a.reactive({}),L=new vl,g=a.ref(null),p=a.ref({col:0,row:0}),D=a.ref(null),N=a.ref(""),_=a.ref(new Array(u).fill(100)),C=a.ref(new Array(c).fill(24)),R=a.ref(0),x=a.ref(0),ce=a.computed(()=>{const e=[0];for(let t=0;t<u;t++)e.push(e[t]+_.value[t]);return e}),se=a.computed(()=>{const e=[0];for(let t=0;t<c;t++)e.push(e[t]+C.value[t]);return e}),tt=a.computed(()=>ce.value[u]),lt=a.computed(()=>se.value[c]);function j(e,t){p.value={col:e,row:t},g.value={startCol:e,startRow:t,endCol:e,endRow:t}}function K(e,t,n,l){p.value={col:e,row:t},g.value={startCol:Math.min(e,n),startRow:Math.min(t,l),endCol:Math.max(e,n),endRow:Math.max(t,l)}}function nt(){K(0,0,u-1,c-1)}function It(e,t){const n=g.value;return n?e>=n.startCol&&e<=n.endCol&&t>=n.startRow&&t<=n.endRow:!1}function M(e,t){return`${e},${t}`}function $(e){Reflect.deleteProperty(b,e)}function Ee(e,t){var n;return((n=b[M(e,t)])==null?void 0:n.value)??""}function Al(e,t){return kt(),fl(e,t,b,u,c)}function ge(e,t,n){var h;const l=M(e,t);if(kt(),n===""||n==null){L.clear(l),$(l),L.markDirty(l);return}const o=String(n),r=((h=b[l])==null?void 0:h.style)??null;b[l]={value:o,style:r},o.startsWith("=")?L.set(l,St(o.slice(1),u,c)):L.clear(l),L.markDirty(l)}function At(e,t,n,l){for(let o=e;o<=t;o++)for(let r=n;r<=l;r++){const h=M(o,r);L.clear(h),$(h),L.markDirty(h)}}function ne(e){D.value||(D.value={...p.value},N.value=e??Ee(p.value.col,p.value.row))}function ie(){D.value&&(ge(D.value.col,D.value.row,N.value),D.value=null,N.value="")}function ue(){D.value=null,N.value=""}function ee(e,t){j(Math.max(0,Math.min(u-1,p.value.col+e)),Math.max(0,Math.min(c-1,p.value.row+t)))}function I(e,t){const n=Math.max(0,G.w-52-11),l=Math.max(0,G.h-24-11),o=ce.value[e],r=se.value[t],h=_.value[e],m=C.value[t];let H=R.value,y=x.value;o<H?H=o:o+h>H+n&&(H=o+h-n),r<y?y=r:r+m>y+l&&(y=r+m-l),V(H,y)}function P(e){const t=ce.value;if(e<0||e>=t[u])return-1;let n=0,l=u-1;for(;n<l;){const o=n+l+1>>1;t[o]<=e?n=o:l=o-1}return n}function Z(e){const t=se.value;if(e<0||e>=t[c])return-1;let n=0,l=c-1;for(;n<l;){const o=n+l+1>>1;t[o]<=e?n=o:l=o-1}return n}const oe=a.ref([]),Le=a.ref([]);function ot(){const e={};for(const[t,n]of Object.entries(b))e[t]={value:n.value,style:n.style};return{cells:e,colWidths:[..._.value],rowHeights:[...C.value]}}function Mt(e){Object.keys(b).forEach(t=>$(t)),Object.assign(b,e.cells),_.value=e.colWidths,C.value=e.rowHeights,L.rebuild(b,u,c)}function F(){const e=ot(),t=oe.value[oe.value.length-1];t&&JSON.stringify(t)===JSON.stringify(e)||(oe.value.push(e),Le.value=[],oe.value.length>50&&oe.value.shift())}function Ml(){oe.value.length&&(Le.value.push(ot()),Mt(oe.value.pop()),g.value=null,v())}function Wl(){Le.value.length&&(oe.value.push(ot()),Mt(Le.value.pop()),g.value=null,v())}let Wt=null;function Ge(){const e=g.value;if(!e)return;Wt={...e};const t=[];for(let n=e.startRow;n<=e.endRow;n++){const l=[];for(let o=e.startCol;o<=e.endCol;o++)l.push(Ee(o,n));t.push(l.join(" "))}et(t.join(`
|
|
2
|
-
`))
|
|
3
|
-
`))
|
|
4
|
-
`))}}}async function Ce(){let e="";try{e=await navigator.clipboard.readText()}catch{return}if(!e&&e!=="")return;const t=e.split(/\r?\n/),n=p.value,l=Wt;for(let o=0;o<t.length;o++){const r=t[o].split(" ");for(let h=0;h<r.length;h++){const m=n.col+h,H=n.row+o;if(m<u&&H<c){let y=r[h];y.startsWith("=")&&l&&(y=dl(y,m-(l.startCol+h),H-(l.startRow+o),u,c,Y)),ge(m,H,y)}}}}function at(){if(Ge(),g.value){const e=g.value;At(e.startCol,e.endCol,e.startRow,e.endRow),v()}}function rt(){if(g.value){const e=g.value;At(e.startCol,e.endCol,e.startRow,e.endRow),v()}}function Nl(){const e=g.value;if(!e)return;F();const t=e.startCol,n=e.startRow,l=e.endCol,o=e.endRow;if(n===o)if(l+1<u){const r=`${Y(t)}${n+1}:${Y(l)}${n+1}`;ge(l+1,n,`=SUM(${r})`)}else{const r=`${Y(t)}${n+1}:${Y(l-1)}${n+1}`;ge(l,n,`=SUM(${r})`)}else for(let r=t;r<=l;r++)if(o+1<c){const h=`${Y(r)}${n+1}:${Y(r)}${o+1}`;ge(r,o+1,`=SUM(${h})`)}else{const h=`${Y(r)}${n+1}:${Y(r)}${o}`;ge(r,o,`=SUM(${h})`)}v(),A()}function $l(e,t){const n=t-e+1;for(let l=e;l<=t;l++)for(let o=0;o<u;o++)$(M(o,l));for(let l=e;l<c-n;l++){for(let o=0;o<u;o++){const r=M(o,l+n),h=M(o,l);b[r]?(b[h]=b[r],$(r)):$(h)}C.value[l]=C.value[l+n]}for(let l=c-n;l<c;l++){for(let o=0;o<u;o++)$(M(o,l));C.value[l]=24}}function Ll(e,t){const n=t-e+1;if(!(t>=c-1)){for(let l=c-1;l>t;l--){for(let o=0;o<u;o++){const r=M(o,l-n),h=M(o,l);b[r]?b[h]=b[r]:$(h)}C.value[l]=C.value[l-n]}for(let l=t+1;l<=t+n;l++){for(let o=0;o<u;o++)$(M(o,l));C.value[l]=24}}}function Gl(e,t){const n=t-e+1;if(!(t>=u-1)){for(let l=u-1;l>t;l--){for(let o=0;o<c;o++){const r=M(l-n,o),h=M(l,o);b[r]?b[h]=b[r]:$(h)}_.value[l]=_.value[l-n]}for(let l=t+1;l<=t+n;l++){for(let o=0;o<c;o++)$(M(l,o));_.value[l]=100}}}function Fl(e,t){const n=t-e+1;for(let l=e;l<=t;l++)for(let o=0;o<c;o++)$(M(l,o));for(let l=e;l<u-n;l++){for(let o=0;o<c;o++){const r=M(l+n,o),h=M(l,o);b[r]?(b[h]=b[r],$(r)):$(h)}_.value[l]=_.value[l+n]}for(let l=u-n;l<u;l++){for(let o=0;o<c;o++)$(M(l,o));_.value[l]=100}}let Nt=0;function $t(){return Nt++,`s_${Nt}`}function Ve(e){return{id:$t(),name:e,cells:{},selection:{startCol:0,startRow:0,endCol:0,endRow:0},activeCell:{col:0,row:0},scrollX:0,scrollY:0,colWidths:new Array(u).fill(100),rowHeights:new Array(c).fill(24)}}const k=a.ref([Ve("Sheet1")]),U=a.ref(0);function Ie(){const e=k.value[U.value];e&&(e.cells={...b},e.selection=g.value?{...g.value}:null,e.activeCell={...p.value},e.scrollX=R.value,e.scrollY=x.value,e.colWidths=[..._.value],e.rowHeights=[...C.value])}function fe(e){const t=k.value[e];t&&(Object.keys(b).forEach(n=>$(n)),Object.assign(b,t.cells),g.value=t.selection?{...t.selection}:null,p.value={...t.activeCell},R.value=t.scrollX,x.value=t.scrollY,_.value=[...t.colWidths],C.value=[...t.rowHeights],U.value=e)}function Vl(e){e===U.value||e<0||e>=k.value.length||(ue(),Ie(),fe(e))}function ct(e){return ue(),Ie(),k.value.push(Ve(`Sheet${k.value.length+1}`)),fe(k.value.length-1),k.value.length-1}function Ol(e){return k.value.length<=1||(ue(),k.value.splice(e,1),fe(Math.min(e,k.value.length-1))),U.value}function Ul(e,t){k.value[e]&&t.trim()&&(k.value[e].name=t.trim())}function Xl(e){ue(),Ie();const t=k.value[e];if(!t)return e;let n=t.name;const l=n.match(/^(.*?)\s*\((\d+)\)$/);let o=l?parseInt(l[2],10)+1:2;l&&(n=l[1]);let r=`${n} (${o})`;const h=new Set(k.value.map(H=>H.name));for(;h.has(r);)o++,r=`${n} (${o})`;const m={id:$t(),name:r,cells:{...t.cells},selection:t.selection?{...t.selection}:null,activeCell:t.activeCell?{...t.activeCell}:{col:0,row:0},scrollX:t.scrollX,scrollY:t.scrollY,colWidths:[...t.colWidths],rowHeights:[...t.rowHeights]};return k.value.splice(e+1,0,m),fe(e+1),e+1}function Lt(e,t){const n=e+t;if(n<0||n>=k.value.length)return;const l=U.value,o=k.value.splice(e,1)[0];k.value.splice(n,0,o),l===e?U.value=n:e<l&&n>=l?U.value=l-1:e>l&&n<=l&&(U.value=l+1),v()}const zl=a.computed(()=>k.value.length);function A(){Ie();const e=k.value.map(n=>{const l={};for(const[m,H]of Object.entries(n.cells))l[m]={value:H.value},H.style&&(l[m].style=H.style);const o={name:n.name,cells:l},r={};for(let m=0;m<n.colWidths.length;m++)n.colWidths[m]!==100&&(r[m]=n.colWidths[m]);Object.keys(r).length&&(o.colWidths=r);const h={};for(let m=0;m<n.rowHeights.length;m++)n.rowHeights[m]!==24&&(h[m]=n.rowHeights[m]);return Object.keys(h).length&&(o.rowHeights=h),o}),t=JSON.stringify(e);t!==T&&(T=t,E.value=e)}let st=!1;function Gt(){st||(st=!0,Promise.resolve().then(()=>{st=!1,A()}))}const Ft=a.computed(()=>d.theme==="dark"?cl:rl),Yl=a.computed(()=>hl(Ft.value,d.width,d.height,ae)),de=a.ref(null),J=a.ref(null),it=a.ref(null),ut=a.ref(null),G=a.reactive({w:800,h:600}),He=a.computed(()=>Math.max(0,tt.value-Math.max(0,G.w-52-11))),we=a.computed(()=>Math.max(0,lt.value-Math.max(0,G.h-24-11)));function V(e,t){const n=Math.max(0,G.w-52-11),l=Math.max(0,G.h-24-11);R.value=Math.max(0,Math.min(e??R.value,Math.max(0,tt.value-n))),x.value=Math.max(0,Math.min(t??x.value,Math.max(0,lt.value-l)))}function jl(){var e;return typeof window>"u"?!1:!((e=window.matchMedia)!=null&&e.call(window,"(hover: none) and (pointer: coarse)").matches)}function O(e=!1){a.nextTick(()=>{const t=it.value;if(t){if(!D.value&&!jl()){document.activeElement===t&&t.blur();return}t.focus(),e&&t.select()}})}function Kl(){O()}let ft=!1,f=null,Ae=1;function v(){ft||(ft=!0,requestAnimationFrame(()=>{ft=!1,Pl()}))}function Pl(){const e=J.value;if(!e)return;const t=de.value;if(!t||(f=e.getContext("2d"),!f))return;Ae=window.devicePixelRatio||1;const n=t.getBoundingClientRect(),l=n.width,o=n.height;G.w=l,G.h=o,e.width=l*Ae,e.height=o*Ae,e.style.width=l+"px",e.style.height=o+"px",f.setTransform(Ae,0,0,Ae,0,0);const r=R.value,h=x.value,m=52,H=24,y=Ft.value,Dt=ce.value,Rt=se.value,qt=_.value,Qt=C.value,Je=Math.max(0,P(r));let el=Je;for(let w=Je;w<u&&!(m+Dt[w]-r>=l);w++)el=w;const tl=el,qe=Math.max(0,Z(h));let ll=qe;for(let w=qe;w<c&&!(H+Rt[w]-h>=o);w++)ll=w;const nl=ll;f.fillStyle=y.bg,f.fillRect(0,0,l,o),f.fillStyle=y.gridBg,f.fillRect(m,H,l-m,o-H),f.save(),f.beginPath(),f.rect(m+.5,H+.5,l-m-1,o-H-1),f.clip();const z=g.value,xt=D.value;for(let w=qe;w<=nl;w++)for(let S=Je;S<=tl;S++){const W=m+Dt[S]-r,pe=H+Rt[w]-h,Ne=qt[S],Se=Qt[w];if(!(W+Ne<m||pe+Se<H||W>l||pe>o)&&(It(S,w)&&(f.fillStyle=y.selectionBg,f.fillRect(W,pe,Ne,Se)),p.value.col===S&&p.value.row===w&&(f.strokeStyle=y.activeCellBorder,f.lineWidth=2,f.strokeRect(W+1,pe+1,Ne-2,Se-2)),f.strokeStyle=y.gridLine,f.lineWidth=.5,f.strokeRect(W+.25,pe+.25,Ne-.5,Se-.5),!(xt&&xt.col===S&&xt.row===w))){const ol=Al(S,w);ol&&(f.fillStyle=y.cellText,f.font='13px -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif',f.textBaseline="middle",f.save(),f.beginPath(),f.rect(W+5,pe+1,Ne-10,Se-2),f.clip(),f.fillText(ol,W+5,pe+Se/2+.5),f.restore())}}f.restore(),f.fillStyle=y.headerBg,f.fillRect(m,0,l-m,H);for(let w=Je;w<=tl;w++){const S=m+Dt[w]-r,W=qt[w];S+W<m||S>l||(z&&w>=z.startCol&&w<=z.endCol&&(f.fillStyle=y.selectionBg,f.fillRect(S,0,W,H)),f.strokeStyle=y.headerBorder,f.lineWidth=.5,f.strokeRect(S+.25,.25,W-.5,H-.5),z&&w>=z.startCol&&w<=z.endCol&&(f.strokeStyle=y.activeCellBorder,f.lineWidth=2,f.beginPath(),f.moveTo(S,H-1),f.lineTo(S+W,H-1),f.stroke()),f.fillStyle=y.headerText,f.font='11px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',f.textAlign="center",f.textBaseline="middle",f.fillText(Y(w),S+W/2,H/2))}f.strokeStyle=y.headerSep,f.lineWidth=1,f.beginPath(),f.moveTo(m,H+.5),f.lineTo(l,H+.5),f.stroke(),f.fillStyle=y.headerBg,f.fillRect(0,H,m,o-H);for(let w=qe;w<=nl;w++){const S=H+Rt[w]-h,W=Qt[w];S+W<H||S>o||(z&&w>=z.startRow&&w<=z.endRow&&(f.fillStyle=y.selectionBg,f.fillRect(0,S,m,W)),f.strokeStyle=y.headerBorder,f.lineWidth=.5,f.strokeRect(.25,S+.25,m-.5,W-.5),z&&w>=z.startRow&&w<=z.endRow&&(f.strokeStyle=y.activeCellBorder,f.lineWidth=2,f.beginPath(),f.moveTo(m-1,S),f.lineTo(m-1,S+W),f.stroke()),f.fillStyle=y.headerText,f.font='11px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',f.textAlign="center",f.textBaseline="middle",f.fillText(String(w+1),m/2,S+W/2+.5))}f.strokeStyle=y.headerSep,f.lineWidth=1,f.beginPath(),f.moveTo(m+.5,H),f.lineTo(m+.5,o),f.stroke(),f.fillStyle=y.headerBg,f.fillRect(0,0,m,H),f.strokeStyle=y.headerSep,f.lineWidth=1,f.strokeRect(.5,.5,m-.5,H-.5)}const Zl=a.computed(()=>Y(p.value.col)+String(p.value.row+1)),Jl=a.computed(()=>D.value?N.value:Ee(p.value.col,p.value.row));function ql(){D.value||(I(p.value.col,p.value.row),N.value=Ee(p.value.col,p.value.row),ne(),v())}function Ql(e){N.value=e.target.value}function en(e){var t,n;e.key==="Enter"?(e.preventDefault(),ie(),ee(0,1),I(p.value.col,p.value.row),(t=ut.value)==null||t.blur(),v(),O()):e.key==="Escape"&&(e.preventDefault(),ue(),(n=ut.value)==null||n.blur(),v(),O())}function tn(){setTimeout(()=>{D.value&&(ie(),v())},0)}const ve=a.ref(null),Be=a.ref("");function ln(e){ve.value===null&&(Vl(e),v())}function Vt(e){e!==U.value&&(Ie(),fe(e),v()),ve.value=e,Be.value=k.value[e].name,a.nextTick(()=>{const t=document.querySelector(".tab-rename-input");t==null||t.focus(),t==null||t.select()})}function Ot(){ve.value!==null&&(Ul(ve.value,Be.value),a.nextTick(A)),ve.value=null,Be.value=""}function nn(){ve.value=null,Be.value=""}function on(e){e.key==="Enter"?(e.preventDefault(),Ot()):e.key==="Escape"&&(e.preventDefault(),nn())}const te=a.ref(null);let Me=null;function Ut(){Me&&(document.removeEventListener("click",Me),Me=null)}function ye(e,t,n){Ut();const l=140,o=n.length*28+8,r=window.innerWidth,h=window.innerHeight;e+l>r&&(e-=l),t+o>h&&(t-=o),te.value={x:e,y:t,items:n},Me=()=>{te.value=null,Ut()},setTimeout(()=>document.addEventListener("click",Me,{once:!0}),0)}const Oe=a.ref(!1);function an(e,t){if(!t.children){Oe.value=!1;return}const l=e.currentTarget.querySelector(".context-submenu");if(!l){Oe.value=!1;return}const o=l.getBoundingClientRect();Oe.value=o.right>window.innerWidth}function rn(e,t){e.preventDefault(),e.stopPropagation(),ye(e.clientX,e.clientY,[{label:B(i.value,"insert"),action:()=>{ct(),v()}},{label:B(i.value,"copy"),action:()=>{Xl(t)}},{label:B(i.value,"rename"),action:()=>{Vt(t)}},{label:B(i.value,"delete"),action:()=>{Ol(t),v()},disabled:zl.value<=1},{label:B(i.value,"moveSheetLeft"),action:()=>{Lt(t,-1)},disabled:t===0},{label:B(i.value,"moveSheetRight"),action:()=>{Lt(t,1)},disabled:t===k.value.length-1}])}function cn(e){e.preventDefault(),!(e.target.closest(".tab-item")||e.target.closest(".tab-bar__add-btn"))&&ye(e.clientX,e.clientY,[{label:B(i.value,"insert"),action:()=>{ct(),v()}}])}function sn(e){e.preventDefault(),nt(),v(),ye(e.clientX,e.clientY,[{label:B(i.value,"cut"),action:()=>{at(),A()}},{label:B(i.value,"copy"),action:()=>Ge()},{label:B(i.value,"paste"),action:()=>{F(),Ce().then(()=>{v(),a.nextTick(A)})}},{label:B(i.value,"delete"),action:()=>{F(),rt();for(let t=0;t<u;t++)_.value[t]=100;for(let t=0;t<c;t++)C.value[t]=24;v(),A()}}])}function un(e,t){e.preventDefault();const n=g.value;n&&n.startCol===0&&n.endCol===u-1&&t>=n.startRow&&t<=n.endRow||(K(0,t,u-1,t),v());const l=g.value;ye(e.clientX,e.clientY,[{label:B(i.value,"insert"),action:()=>{F(),Ll(l.startRow,l.endRow),v(),A()},disabled:l.endRow>=c-1},{label:B(i.value,"cut"),action:()=>{F(),Fe();for(let o=l.startRow;o<=l.endRow;o++)for(let r=0;r<u;r++)$(M(r,o));v(),A()}},{label:B(i.value,"copy"),action:()=>Fe()},{label:B(i.value,"paste"),action:()=>{F(),Ce().then(()=>{v(),a.nextTick(A)})}},{label:B(i.value,"delete"),action:()=>{F(),$l(l.startRow,l.endRow),v(),A()}}])}function fn(e,t){e.preventDefault();const n=g.value;n&&n.startRow===0&&n.endRow===c-1&&t>=n.startCol&&t<=n.endCol||(K(t,0,t,c-1),v());const l=g.value;ye(e.clientX,e.clientY,[{label:B(i.value,"insert"),action:()=>{F(),Gl(l.startCol,l.endCol),v(),A()},disabled:l.endCol>=u-1},{label:B(i.value,"cut"),action:()=>{F(),Fe();for(let o=l.startCol;o<=l.endCol;o++)for(let r=0;r<c;r++)$(M(o,r));v(),A()}},{label:B(i.value,"copy"),action:()=>Fe()},{label:B(i.value,"paste"),action:()=>{F(),Ce().then(()=>{v(),a.nextTick(A)})}},{label:B(i.value,"delete"),action:()=>{F(),Fl(l.startCol,l.endCol),v(),A()}}])}function dn(e,t,n){e.preventDefault(),It(t,n)||(j(t,n),v());const l=g.value,o=!!(l&&l.startCol===l.endCol&&l.startRow===l.endRow);ye(e.clientX,e.clientY,[{label:B(i.value,"cut"),action:()=>{at(),A()}},{label:B(i.value,"copy"),action:()=>Ge()},{label:B(i.value,"paste"),action:()=>{F(),Ce().then(()=>{v(),a.nextTick(A)})}},{label:B(i.value,"delete"),action:()=>{F(),rt(),v(),A()}},{label:B(i.value,"calculate"),children:[{label:B(i.value,"sum"),action:Nl,disabled:o}]}])}const vn=a.computed(()=>{const e=!D.value,t=D.value??p.value,n=t.col,l=t.row;return{left:`${52+ce.value[n]-R.value}px`,top:`${24+se.value[l]-x.value}px`,width:`${_.value[n]}px`,height:`${C.value[l]}px`,opacity:e?0:1,pointerEvents:e?"none":"auto",color:e?"transparent":void 0,caretColor:e?"transparent":void 0,borderColor:e?"transparent":void 0,background:e?"transparent":void 0,boxShadow:e?"none":void 0}}),hn=a.computed(()=>Math.max(0,G.w-52-11)),pn=a.computed(()=>Math.max(0,G.h-24-11)),Ue=a.computed(()=>Math.max(0,hn.value-11*2)),Xe=a.computed(()=>Math.max(0,pn.value-11*2));function dt(){return Math.max(0,G.w-52-11)}function vt(){return Math.max(0,G.h-24-11)}const ze=a.computed(()=>He.value<=0?Ue.value:Math.max(24,dt()/tt.value*Ue.value)),ht=a.computed(()=>He.value<=0?0:R.value/He.value*(Ue.value-ze.value)),Ye=a.computed(()=>we.value<=0?Xe.value:Math.max(24,vt()/lt.value*Xe.value)),pt=a.computed(()=>we.value<=0?0:x.value/we.value*(Xe.value-Ye.value));let he=null,je=0,Ke=0;function mn(e){e.preventDefault(),he="v",je=e.clientY,Ke=x.value,document.addEventListener("mousemove",mt),document.addEventListener("mouseup",bt)}function bn(e){e.preventDefault(),he="h",je=e.clientX,Ke=R.value,document.addEventListener("mousemove",mt),document.addEventListener("mouseup",bt)}function mt(e){if(he==="v"){const n=(e.clientY-je)/(Xe.value-Ye.value);V(null,Ke+n*we.value),v()}else if(he==="h"){const n=(e.clientX-je)/(Ue.value-ze.value);V(Ke+n*He.value,null),v()}}function bt(){he=null,document.removeEventListener("mousemove",mt),document.removeEventListener("mouseup",bt)}function En(e){if(he)return;const t=e.currentTarget.getBoundingClientRect(),n=e.clientY-t.top;n<pt.value?V(null,x.value-vt()):n>pt.value+Ye.value&&V(null,x.value+vt()),v()}function gn(e){if(he)return;const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left;n<ht.value?V(R.value-dt(),null):n>ht.value+ze.value&&V(R.value+dt(),null),v()}let Te=!1,q=0,Q=0,De=!1,Re=!1,Xt=0,zt=0,xe=0,Pe=0,Et=0,gt=0,Yt=0,jt=0,We=!1,Ht=!1,ke=0,_e=0,wt=0,Kt=-1,Pt=-1;function Hn(e){if(e.button!==0)return;e.preventDefault(),te.value=null;const t=re(e,J.value);if(t.y<24&&t.x>=52){const o=t.x-52+R.value,r=P(o);if(r>=0&&Math.abs(t.x-(52+ce.value[r+1]-R.value))<=4){De=!0,Xt=r,xe=_.value[r],Pe=o,v();return}}if(t.x<52&&t.y>=24){const o=t.y-24+x.value,r=Z(o);if(r>=0&&Math.abs(t.y-(24+se.value[r+1]-x.value))<=4){Re=!0,zt=r,xe=C.value[r],Pe=o,v();return}}if(t.x<52||t.y<24){if(t.y<24&&t.x>=52){const o=P(t.x-52+R.value);o>=0&&(K(o,0,o,c-1),Te=!0,q=o,Q=0)}else if(t.x<52&&t.y>=24){const o=Z(t.y-24+x.value);o>=0&&(K(0,o,u-1,o),Te=!0,q=0,Q=o)}else t.x<52&&t.y<24&&nt();v();return}const n=P(t.x-52+R.value),l=Z(t.y-24+x.value);if(!(n<0||l<0)){if(ie(),e.shiftKey&&g.value){const o=g.value;K(o.startCol,o.startRow,n,l)}else j(n,l);Te=!0,q=n,Q=l,O(),v()}}function wn(e){if(De){const r=re(e,J.value).x-52+R.value-Pe;xe+r>=30&&(_.value[Xt]=xe+r),v();return}if(Re){const r=re(e,J.value).y-24+x.value-Pe;xe+r>=24&&(C.value[zt]=xe+r),v();return}if(!Te){const o=J.value;if(!o)return;const r=re(e,o);if(r.y<24&&r.x>=52){const h=P(r.x-52+R.value);if(h>=0&&Math.abs(r.x-(52+ce.value[h+1]-R.value))<=4){o.style.cursor="col-resize";return}}if(r.x<52&&r.y>=24){const h=Z(r.y-24+x.value);if(h>=0&&Math.abs(r.y-(24+se.value[h+1]-x.value))<=4){o.style.cursor="row-resize";return}}o.style.cursor="cell";return}const t=re(e,J.value);if(q<0||Q<0)return;if(t.x<52||t.y<24){if(t.y<24&&t.x>=52){const o=P(t.x-52+R.value);o>=0&&K(Math.min(q,o),0,Math.max(q,o),c-1)}else if(t.x<52&&t.y>=24){const o=Z(t.y-24+x.value);o>=0&&K(0,Math.min(Q,o),u-1,Math.max(Q,o))}v();return}const n=P(t.x-52+R.value),l=Z(t.y-24+x.value);n<0||l<0||(Q===0&&q>=0&&g.value&&g.value.startRow===0&&g.value.endRow===c-1?K(Math.min(q,n),0,Math.max(q,n),c-1):q===0&&Q>=0&&g.value&&g.value.startCol===0&&g.value.endCol===u-1?K(0,Math.min(Q,l),u-1,Math.max(Q,l)):K(q,Q,n,l),v())}function Bn(){const e=De||Re;Te=!1,De=!1,Re=!1,e&&Gt()}function yn(){const e=De||Re;Te=!1,De=!1,Re=!1,e&&Gt()}function Tn(e){e.preventDefault();const t=re(e,J.value);if(t.x<52&&t.y<24){sn(e);return}if(t.y<24&&t.x>=52){const n=P(t.x-52+R.value);n>=0&&fn(e,n);return}if(t.x<52&&t.y>=24){const n=Z(t.y-24+x.value);n>=0&&un(e,n);return}if(t.x>=52&&t.y>=24){const n=P(t.x-52+R.value),l=Z(t.y-24+x.value);n>=0&&l>=0&&dn(e,n,l)}}function Dn(e){const t=re(e,J.value);if(t.x<52||t.y<24)return;const n=P(t.x-52+R.value),l=Z(t.y-24+x.value);n<0||l<0||(j(n,l),I(n,l),ne(),v(),O())}function Rn(e){V(R.value+e.deltaX,x.value+e.deltaY),v()}function xn(e){if(e.touches.length!==1){We=!1;return}const t=e.touches[0],n=J.value;if(!n)return;const l=n.getBoundingClientRect(),o=t.clientX-l.left,r=t.clientY-l.top;o>=52&&r>=24&&(e.preventDefault(),We=!0,Ht=!1,Et=o,gt=r,Yt=R.value,jt=x.value,ke=P(o-52+R.value),_e=Z(r-24+x.value))}function kn(e){if(!We||e.touches.length!==1)return;const t=e.touches[0],n=J.value;if(!n)return;const l=n.getBoundingClientRect(),o=t.clientX-l.left,r=t.clientY-l.top;(Math.abs(o-Et)>8||Math.abs(r-gt)>8)&&(Ht=!0,e.preventDefault(),V(Yt+(Et-o),jt+(gt-r)),v())}function _n(){if(We&&(We=!1,!Ht&&ke>=0&&_e>=0)){const e=Date.now();ke===Kt&&_e===Pt&&e-wt<300?(j(ke,_e),ne(),v(),O(),wt=0):(ie(),j(ke,_e),v(),wt=e),Kt=ke,Pt=_e,O()}}function Bt(e){return e.isComposing||e.key==="Process"||e.keyCode===229}function Zt(e){return e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function Jt(e){if(D.value)return;const t=e.ctrlKey||e.metaKey,n=e.shiftKey;switch(!0){case(t&&(e.key==="c"||e.key==="C")):e.preventDefault(),Ge();return;case(t&&(e.key==="x"||e.key==="X")):e.preventDefault(),at();return;case(t&&(e.key==="z"||e.key==="Z")):e.preventDefault(),Ml();return;case(t&&(e.key==="y"||e.key==="Y")):e.preventDefault(),Wl();return;case(t&&(e.key==="v"||e.key==="V")):e.preventDefault(),F(),Ce().then(()=>{v(),a.nextTick(A)});return;case(t&&(e.key==="a"||e.key==="A")):e.preventDefault(),nt(),v();return;case(t&&e.key==="Home"):e.preventDefault(),j(0,0),I(0,0),v();return;case(t&&e.key==="End"):e.preventDefault(),j(u-1,c-1),I(u-1,c-1),v();return;case e.key==="Home":e.preventDefault(),j(0,p.value.row),I(0,p.value.row),v();return;case e.key==="End":e.preventDefault(),j(u-1,p.value.row),I(u-1,p.value.row),v();return;case e.key==="ArrowUp":e.preventDefault(),ee(0,-1),I(p.value.col,p.value.row),v();return;case e.key==="ArrowDown":e.preventDefault(),ee(0,1),I(p.value.col,p.value.row),v();return;case e.key==="ArrowLeft":e.preventDefault(),ee(-1,0),I(p.value.col,p.value.row),v();return;case e.key==="ArrowRight":e.preventDefault(),ee(1,0),I(p.value.col,p.value.row),v();return;case e.key==="Tab":e.preventDefault(),ee(n?-1:1,0),I(p.value.col,p.value.row),v();return;case e.key==="Enter":e.preventDefault(),ee(0,n?-1:1),I(p.value.col,p.value.row),v();return;case e.key==="F2":e.preventDefault(),I(p.value.col,p.value.row),ne(),v(),O();return;case e.key==="Delete":case e.key==="Backspace":e.preventDefault(),F(),rt(),v();return;case e.key==="Escape":e.preventDefault(),ue(),v();return;case Zt(e):if(Bt(e)){I(p.value.col,p.value.row),ne(""),v(),O();return}e.preventDefault(),I(p.value.col,p.value.row),ne(e.key),v(),a.nextTick(()=>{const l=it.value;l&&(l.focus(),l.setSelectionRange(1,1))});return}}let yt=!1,Tt=!1;function Sn(e){const t=e.target.value;if(!D.value){I(p.value.col,p.value.row),ne(t),v();return}N.value=t}function Cn(){yt=!0,D.value||(I(p.value.col,p.value.row),ne(""),v())}function In(e){yt=!1,Tt=!0,setTimeout(()=>{Tt=!1},0),N.value=e.target.value}function An(e){if(!D.value){if(Zt(e)||Bt(e))return;Jt(e);return}yt||Bt(e)||Tt&&(e.key==="Enter"||e.key==="Escape")||(e.key==="Enter"?(e.preventDefault(),ie(),ee(0,1),I(p.value.col,p.value.row),v(),O()):e.key==="Tab"?(e.preventDefault(),ie(),ee(e.shiftKey?-1:1,0),I(p.value.col,p.value.row),v(),O()):e.key==="Escape"&&(e.preventDefault(),ue(),v(),O()))}function Mn(){setTimeout(()=>{D.value&&(ie(),v())},0)}function Ze(){var t;const e=(t=de.value)==null?void 0:t.getBoundingClientRect();if(e){const n=ae(d.width),l=ae(d.height);n!=null?G.w=n:G.w=e.width,l!=null?G.h=l:G.h=e.height}V(null,null),v()}let X=null;return a.onMounted(()=>{const e=ae(d.width),t=ae(d.height);(e==null||t==null)&&(X=new ResizeObserver(()=>Ze()),de.value&&X.observe(de.value)),a.nextTick(()=>{Ze(),O()}),j(0,0),E.value&&E.value.length>0&&(T=JSON.stringify(E.value),k.value=E.value.map(n=>{const l=Ve(n.name);for(const[o,r]of Object.entries(n.cells))l.cells[o]={value:r.value,style:r.style??null};if(n.colWidths)for(const[o,r]of Object.entries(n.colWidths)){const h=Number(o);h>=0&&h<u&&r>=30&&(l.colWidths[h]=r)}if(n.rowHeights)for(const[o,r]of Object.entries(n.rowHeights)){const h=Number(o);h>=0&&h<c&&r>=24&&(l.rowHeights[h]=r)}return l}),k.value.length>0&&fe(0))}),a.watch(()=>[d.width,d.height],()=>{const e=ae(d.width),t=ae(d.height);e!=null&&t!=null?(X==null||X.disconnect(),X=null):!X&&de.value&&(X=new ResizeObserver(()=>Ze()),X.observe(de.value)),a.nextTick(()=>Ze())}),a.watch(()=>d.theme,()=>v()),a.watch(()=>({...b}),()=>a.nextTick(A),{deep:!1}),a.watch(U,()=>a.nextTick(A)),a.watch(()=>E.value,e=>{if(!e||e.length===0)return;const t=JSON.stringify(e);t!==T&&(T=t,k.value=e.map(n=>{const l=Ve(n.name);for(const[o,r]of Object.entries(n.cells))l.cells[o]={value:r.value,style:r.style??null};if(n.colWidths)for(const[o,r]of Object.entries(n.colWidths)){const h=Number(o);h>=0&&h<u&&r>=30&&(l.colWidths[h]=r)}if(n.rowHeights)for(const[o,r]of Object.entries(n.rowHeights)){const h=Number(o);h>=0&&h<c&&r>=24&&(l.rowHeights[h]=r)}return l}),k.value.length>0&&fe(0),v())},{deep:!0}),a.onBeforeUnmount(()=>{X==null||X.disconnect()}),(e,t)=>(a.openBlock(),a.createElementBlock("div",{class:"spreadsheet-outer",style:a.normalizeStyle(Yl.value)},[a.createElementVNode("div",{class:"tab-bar",onContextmenu:cn},[a.createElementVNode("div",pl,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(k.value,(n,l)=>(a.openBlock(),a.createElementBlock("div",{key:n.id,class:a.normalizeClass(["tab-item",{"tab-item--active":l===U.value}]),onClick:o=>ln(l),onDblclick:a.withModifiers(o=>Vt(l),["prevent"]),onContextmenu:o=>rn(o,l)},[ve.value===l?(a.openBlock(),a.createElementBlock("input",{key:0,class:"tab-rename-input",value:Be.value,onInput:t[0]||(t[0]=o=>Be.value=o.target.value),onKeydown:on,onBlur:Ot,onClick:t[1]||(t[1]=a.withModifiers(()=>{},["stop"]))},null,40,bl)):(a.openBlock(),a.createElementBlock("span",El,a.toDisplayString(n.name),1))],42,ml))),128))]),a.createElementVNode("button",{class:"tab-bar__add-btn",title:a.unref(B)(i.value,"addSheet"),onClick:t[2]||(t[2]=n=>{ct(),v()})}," + ",8,gl)],32),a.createElementVNode("div",Hl,[a.createElementVNode("div",wl,a.toDisplayString(Zl.value),1),a.createElementVNode("input",{ref_key:"formulaBarRef",ref:ut,class:"formula-bar__input",value:Jl.value,onFocus:ql,onInput:Ql,onKeydown:en,onBlur:tn},null,40,Bl)]),a.createElementVNode("div",{ref_key:"wrapperRef",ref:de,class:"spreadsheet-wrapper"},[a.createElementVNode("canvas",{ref_key:"canvasRef",ref:J,class:"grid-canvas",tabindex:"0",onMousedown:Hn,onMousemove:wn,onMouseup:Bn,onMouseleave:yn,onDblclick:Dn,onWheel:a.withModifiers(Rn,["prevent"]),onFocus:Kl,onKeydown:Jt,onContextmenu:Tn,onTouchstart:a.withModifiers(xn,["prevent"]),onTouchmove:a.withModifiers(kn,["prevent"]),onTouchend:_n},null,544),a.createElementVNode("input",{ref_key:"editInputRef",ref:it,class:"cell-editor",value:N.value,style:a.normalizeStyle(vn.value),onInput:Sn,onKeydown:An,onCompositionstart:Cn,onCompositionend:In,onBlur:Mn},null,44,yl),we.value>0?(a.openBlock(),a.createElementBlock("div",{key:0,class:"v-scrollbar",style:a.normalizeStyle({top:a.unref(24)+"px",height:`calc(100% - ${a.unref(24)+a.unref(11)}px)`})},[a.createElementVNode("button",{class:"sb-btn sb-btn--up",title:a.unref(B)(i.value,"scrollUp"),onMousedown:t[3]||(t[3]=a.withModifiers(n=>{V(null,x.value-50),v()},["prevent"]))},[...t[8]||(t[8]=[a.createElementVNode("span",{class:"sb-arrow sb-arrow--up"},null,-1)])],40,Tl),a.createElementVNode("div",{class:"sb-track sb-track--v",onMousedown:En},[a.createElementVNode("div",{class:"sb-thumb sb-thumb--v",style:a.normalizeStyle({top:pt.value+"px",height:Ye.value+"px"}),onMousedown:mn},null,36)],32),a.createElementVNode("button",{class:"sb-btn sb-btn--down",title:a.unref(B)(i.value,"scrollDown"),onMousedown:t[4]||(t[4]=a.withModifiers(n=>{V(null,x.value+50),v()},["prevent"]))},[...t[9]||(t[9]=[a.createElementVNode("span",{class:"sb-arrow sb-arrow--down"},null,-1)])],40,Dl)],4)):a.createCommentVNode("",!0),He.value>0?(a.openBlock(),a.createElementBlock("div",{key:1,class:"h-scrollbar",style:a.normalizeStyle({left:a.unref(52)+"px",width:`calc(100% - ${a.unref(52)+a.unref(11)}px)`})},[a.createElementVNode("button",{class:"sb-btn sb-btn--left",title:a.unref(B)(i.value,"scrollLeft"),onMousedown:t[5]||(t[5]=a.withModifiers(n=>{V(R.value-50,null),v()},["prevent"]))},[...t[10]||(t[10]=[a.createElementVNode("span",{class:"sb-arrow sb-arrow--left"},null,-1)])],40,Rl),a.createElementVNode("div",{class:"sb-track sb-track--h",onMousedown:gn},[a.createElementVNode("div",{class:"sb-thumb sb-thumb--h",style:a.normalizeStyle({left:ht.value+"px",width:ze.value+"px"}),onMousedown:bn},null,36)],32),a.createElementVNode("button",{class:"sb-btn sb-btn--right",title:a.unref(B)(i.value,"scrollRight"),onMousedown:t[6]||(t[6]=a.withModifiers(n=>{V(R.value+50,null),v()},["prevent"]))},[...t[11]||(t[11]=[a.createElementVNode("span",{class:"sb-arrow sb-arrow--right"},null,-1)])],40,xl)],4)):a.createCommentVNode("",!0),He.value>0&&we.value>0?(a.openBlock(),a.createElementBlock("div",kl)):a.createCommentVNode("",!0)],512),(a.openBlock(),a.createBlock(a.Teleport,{to:"body"},[te.value?(a.openBlock(),a.createElementBlock("div",{key:0,class:"context-menu",style:a.normalizeStyle({left:te.value.x+"px",top:te.value.y+"px"}),onClick:t[7]||(t[7]=a.withModifiers(()=>{},["stop"]))},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(te.value.items,(n,l)=>(a.openBlock(),a.createElementBlock("div",{key:l,class:a.normalizeClass(["context-menu__item",{"context-menu__item--disabled":n.disabled}]),onClick:o=>!n.disabled&&n.action&&(n.action(),te.value=null),onMouseenter:o=>an(o,n)},[a.createElementVNode("span",Sl,a.toDisplayString(n.label),1),n.children?(a.openBlock(),a.createElementBlock("span",Cl)):a.createCommentVNode("",!0),n.children?(a.openBlock(),a.createElementBlock("div",{key:1,class:a.normalizeClass(["context-submenu",{"context-submenu--left":Oe.value}])},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.children,(o,r)=>(a.openBlock(),a.createElementBlock("div",{key:r,class:a.normalizeClass(["context-menu__item",{"context-menu__item--disabled":o.disabled}]),onClick:a.withModifiers(h=>!o.disabled&&o.action&&(o.action(),te.value=null),["stop"])},a.toDisplayString(o.label),11,Il))),128))],2)):a.createCommentVNode("",!0)],42,_l))),128))],4)):a.createCommentVNode("",!0)]))],4))}}),[["__scopeId","data-v-5100e6d6"]]);le.Spreader=Ct,le.default=Ct,Object.defineProperties(le,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(Le,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(Le=typeof globalThis<"u"?globalThis:Le||self,e(Le.XiaoDaoSpreader={},Le.Vue))})(this,function(Le,e){"use strict";const Bl={"zh-CN":{insert:"插入",delete:"删除",rename:"重命名",moveLeft:"左移",moveRight:"右移",cut:"剪切",copy:"复制",paste:"粘贴",addSheet:"新建工作表",moveSheetLeft:"左移",moveSheetRight:"右移",scrollUp:"向上滚动",scrollDown:"向下滚动",scrollLeft:"向左滚动",scrollRight:"向右滚动",calculate:"计算",sum:"求和",undo:"撤销",redo:"重做",paintFormat:"格式刷",clearFormat:"清除格式",fontFamily:"字体",fontSize:"字号",fontSizeIncrease:"增大字号",fontSizeDecrease:"减小字号",bold:"加粗",italic:"斜体",underline:"下划线",strikethrough:"删除线",fontColor:"文字颜色",fillColor:"填充颜色",borders:"边框",hAlign:"水平对齐",vAlign:"垂直对齐",alignLeft:"左端对齐",alignCenter:"居中对齐",alignRight:"右端对齐",alignTop:"顶端对齐",alignMiddle:"垂直居中",alignBottom:"底端对齐",wrap:"自动换行",borderBottom:"下框线",borderTop:"上框线",borderLeft:"左框线",borderRight:"右框线",borderNone:"无框线",borderAll:"所有框线",borderOuter:"外框线",borderThickOuter:"粗外框线",fontDefault:"默认",rowHeight:"行高",colWidth:"列宽",autoRowHeight:"自动行高",defaultColWidth:"默认列宽",ok:"确定",cancel:"取消",dimNumberError:"请输入数字",dimRangeError:"请输入 {min}~{max} 之间的数值",colorAutomatic:"自动",colorNoFill:"无填充",colorWhite:"白色",colorBlack:"黑色",colorLightGray:"浅灰",colorLightBlue:"浅蓝",colorLightOrange:"浅橙",colorLightYellow:"浅黄",colorLightGreen:"浅绿",colorPaleBlue:"淡蓝",colorPaleOrange:"淡橙",colorPaleYellow:"淡黄",colorPaleGreen:"淡绿",colorSilver:"银色",colorSkyBlue:"天蓝",colorCoral:"珊瑚",colorGold:"金色",colorMint:"薄荷",colorGray:"灰色",colorMediumBlue:"中蓝",colorOrange:"橙色",colorAmber:"琥珀",colorMediumGreen:"中绿",colorDarkGray:"深灰",colorRoyalBlue:"宝蓝",colorRed:"红色",colorDarkGold:"深金",colorDarkGreen:"深绿",colorCharcoal:"炭灰",colorDeepBlue:"深蓝",colorDarkRed:"深红",colorOlive:"橄榄",colorForest:"森林",colorSlate:"石板灰",colorNavy:"藏青",colorCrimson:"绯红",colorDarkOlive:"深橄榄",colorDeepForest:"深林",colorDarkSlate:"深石板灰",colorMidnight:"午夜蓝",colorMaroon:"栗色",colorCoffee:"咖啡色",colorEvergreen:"常青",colorDarkNavy:"深藏青",colorDarkMaroon:"深栗",colorDarkCoffee:"深咖",colorInkGreen:"墨绿"},"en-US":{insert:"Insert",delete:"Delete",rename:"Rename",moveLeft:"Move Left",moveRight:"Move Right",cut:"Cut",copy:"Copy",paste:"Paste",addSheet:"Add new sheet",moveSheetLeft:"Move Left",moveSheetRight:"Move Right",scrollUp:"Scroll up",scrollDown:"Scroll down",scrollLeft:"Scroll left",scrollRight:"Scroll right",calculate:"Calculate",sum:"Sum",undo:"Undo",redo:"Redo",paintFormat:"Paint Format",clearFormat:"Clear Format",fontFamily:"Font Family",fontSize:"Font Size",fontSizeIncrease:"Increase Font Size",fontSizeDecrease:"Decrease Font Size",bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",fontColor:"Font Color",fillColor:"Fill Color",borders:"Borders",hAlign:"Horizontal Align",vAlign:"Vertical Align",alignLeft:"Align Left",alignCenter:"Align Center",alignRight:"Align Right",alignTop:"Align Top",alignMiddle:"Align Middle",alignBottom:"Align Bottom",wrap:"Wrap Text",borderBottom:"Bottom Border",borderTop:"Top Border",borderLeft:"Left Border",borderRight:"Right Border",borderNone:"No Border",borderAll:"All Borders",borderOuter:"Outside Borders",borderThickOuter:"Thick Box Border",fontDefault:"Default",rowHeight:"Row Height",colWidth:"Column Width",autoRowHeight:"Auto Row Height",defaultColWidth:"Default Column Width",ok:"OK",cancel:"Cancel",dimNumberError:"Please enter a number",dimRangeError:"Please enter a value between {min} and {max}",colorAutomatic:"Automatic",colorNoFill:"No Fill",colorWhite:"White",colorBlack:"Black",colorLightGray:"Light Gray",colorLightBlue:"Light Blue",colorLightOrange:"Light Orange",colorLightYellow:"Light Yellow",colorLightGreen:"Light Green",colorPaleBlue:"Pale Blue",colorPaleOrange:"Pale Orange",colorPaleYellow:"Pale Yellow",colorPaleGreen:"Pale Green",colorSilver:"Silver",colorSkyBlue:"Sky Blue",colorCoral:"Coral",colorGold:"Gold",colorMint:"Mint",colorGray:"Gray",colorMediumBlue:"Medium Blue",colorOrange:"Orange",colorAmber:"Amber",colorMediumGreen:"Medium Green",colorDarkGray:"Dark Gray",colorRoyalBlue:"Royal Blue",colorRed:"Red",colorDarkGold:"Dark Gold",colorDarkGreen:"Dark Green",colorCharcoal:"Charcoal",colorDeepBlue:"Deep Blue",colorDarkRed:"Dark Red",colorOlive:"Olive",colorForest:"Forest",colorSlate:"Slate",colorNavy:"Navy",colorCrimson:"Crimson",colorDarkOlive:"Dark Olive",colorDeepForest:"Deep Forest",colorDarkSlate:"Dark Slate",colorMidnight:"Midnight",colorMaroon:"Maroon",colorCoffee:"Coffee",colorEvergreen:"Evergreen",colorDarkNavy:"Dark Navy",colorDarkMaroon:"Dark Maroon",colorDarkCoffee:"Dark Coffee",colorInkGreen:"Ink Green"}};function w(r,v){var u;return((u=Bl[r])==null?void 0:u[v])??v}const ro='-apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif',_e=10,Cl=[{label:"",value:""},{label:"微软雅黑",value:'"Microsoft YaHei", "微软雅黑", sans-serif'},{label:"宋体",value:'"SimSun", "宋体", serif'},{label:"黑体",value:'"SimHei", "黑体", sans-serif'},{label:"楷体",value:'"KaiTi", "楷体", serif'},{label:"Arial",value:"Arial, sans-serif"},{label:"Arial Black",value:'"Arial Black", sans-serif'},{label:"Times New Roman",value:'"Times New Roman", serif'},{label:"Courier New",value:'"Courier New", monospace'},{label:"Verdana",value:"Verdana, sans-serif"},{label:"Georgia",value:"Georgia, serif"},{label:"Impact",value:"Impact, sans-serif"},{label:"Tahoma",value:"Tahoma, sans-serif"},{label:"Trebuchet MS",value:'"Trebuchet MS", sans-serif'},{label:"Comic Sans MS",value:'"Comic Sans MS", cursive'}],xl=[{label:"9",value:9},{label:"10",value:10},{label:"11",value:11},{label:"12",value:12},{label:"13",value:13},{label:"14",value:14},{label:"16",value:16},{label:"18",value:18},{label:"20",value:20},{label:"24",value:24},{label:"28",value:28},{label:"32",value:32},{label:"36",value:36},{label:"48",value:48},{label:"72",value:72}],Tl='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="3" y1="6" x2="19" y2="6"/><line x1="3" y1="12" x2="15" y2="12"/><line x1="3" y1="18" x2="17" y2="18"/></svg>',Dl='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="3" y1="6" x2="21" y2="6"/><line x1="6" y1="12" x2="18" y2="12"/><line x1="4" y1="18" x2="20" y2="18"/></svg>',Hl='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="5" y1="6" x2="21" y2="6"/><line x1="9" y1="12" x2="21" y2="12"/><line x1="7" y1="18" x2="21" y2="18"/></svg>',Sl='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="6" y1="7" x2="6" y2="20"/><line x1="12" y1="7" x2="12" y2="16"/><line x1="18" y1="7" x2="18" y2="20"/><line x1="4" y1="3" x2="20" y2="3"/></svg>',Rl='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="6" y1="4" x2="6" y2="20"/><line x1="12" y1="8" x2="12" y2="16"/><line x1="18" y1="4" x2="18" y2="20"/></svg>',Ml='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="6" y1="4" x2="6" y2="17"/><line x1="12" y1="8" x2="12" y2="17"/><line x1="18" y1="4" x2="18" y2="17"/><line x1="4" y1="21" x2="20" y2="21"/></svg>',Al=[{value:"left",labelKey:"alignLeft",icon:Tl},{value:"center",labelKey:"alignCenter",icon:Dl},{value:"right",labelKey:"alignRight",icon:Hl}],Nl=[{value:"top",labelKey:"alignTop",icon:Sl},{value:"middle",labelKey:"alignMiddle",icon:Rl},{value:"bottom",labelKey:"alignBottom",icon:Ml}],Il={bg:"#f4f4f4",gridBg:"#ffffff",headerBg:"#e8e8e8",headerBorder:"#c8c8c8",headerText:"#444",headerSep:"#b0b0b0",cornerBg:"#e0e0e0",gridLine:"#e0e0e0",selectionBg:"rgba(0, 120, 215, 0.12)",activeCellBorder:"#0078d7",cellText:"#1a1a1a",scrollTrack:"rgba(0,0,0,0.08)",scrollThumb:"rgba(0,0,0,0.25)",formulaBarBg:"#f0f0f0",formulaBarBorder:"#c8c8c8",formulaBarLabelText:"#333",formulaBarLabelBg:"#fff",formulaBarLabelBorder:"#c0c0c0",formulaBarInputBg:"#fff",formulaBarInputBorder:"#c0c0c0",formulaBarInputText:"#1a1a1a",formulaBarInputFocusBorder:"#0078d7",formulaBarInputFocusShadow:"rgba(0, 120, 215, 0.3)",wrapperBg:"#e8e8e8",cellEditorBorder:"#0078d7",cellEditorText:"#1a1a1a",cellEditorBg:"#fff",cellEditorShadow:"#0078d7",tabBarBg:"#e8e8e8",tabBarBorder:"#c0c0c0",tabActiveBg:"#ffffff",tabActiveText:"#1a1a1a",tabActiveBorder:"#0078d7",tabInactiveBg:"#dfdfdf",tabInactiveText:"#666",tabInactiveBorder:"transparent",tabHoverBg:"#e0e0e0",tabAddBtnColor:"#555",tabAddBtnHoverBg:"#d0d0d0",tabScrollBtnColor:"#888",tabScrollBtnHoverBg:"#d0d0d0",scrollbarThumb:"rgba(0,0,0,0.25)",scrollbarThumbHover:"rgba(0,0,0,0.4)",scrollBtnBg:"#e8e8e8",scrollBtnColor:"#666",scrollBtnHoverBg:"#d0d0d0",scrollBtnActiveBg:"#c0c0c0",scrollTrackBg:"rgba(0,0,0,0.06)",toolbarBg:"#f7f7f7",toolbarBorder:"#d8d8d8",toolbarBtnColor:"#444",toolbarBtnHoverBg:"#e6e6e6",toolbarBtnDisabledColor:"#b0b0b0",toolbarBtnActiveColor:"#0078d7"},Fl={bg:"#1e1e1e",gridBg:"#252526",headerBg:"#252525",headerBorder:"#3e3e3e",headerText:"#999",headerSep:"#3e3e3e",cornerBg:"#2a2a2a",gridLine:"#3e3e3e",selectionBg:"rgba(0, 120, 215, 0.25)",activeCellBorder:"#0078d7",cellText:"#d4d4d4",scrollTrack:"rgba(255,255,255,0.06)",scrollThumb:"rgba(255,255,255,0.2)",formulaBarBg:"#2d2d2d",formulaBarBorder:"#3e3e3e",formulaBarLabelText:"#ccc",formulaBarLabelBg:"#3c3c3c",formulaBarLabelBorder:"#555",formulaBarInputBg:"#3c3c3c",formulaBarInputBorder:"#555",formulaBarInputText:"#d4d4d4",formulaBarInputFocusBorder:"#0078d7",formulaBarInputFocusShadow:"rgba(0, 120, 215, 0.4)",wrapperBg:"#1e1e1e",cellEditorBorder:"#0078d7",cellEditorText:"#d4d4d4",cellEditorBg:"#3c3c3c",cellEditorShadow:"#0078d7",tabBarBg:"#2a2a2a",tabBarBorder:"#3e3e3e",tabActiveBg:"#1e1e1e",tabActiveText:"#e0e0e0",tabActiveBorder:"#0078d7",tabInactiveBg:"#333333",tabInactiveText:"#888",tabInactiveBorder:"transparent",tabHoverBg:"#3a3a3a",tabAddBtnColor:"#999",tabAddBtnHoverBg:"#3a3a3a",tabScrollBtnColor:"#777",tabScrollBtnHoverBg:"#3a3a3a",scrollbarThumb:"rgba(255,255,255,0.2)",scrollbarThumbHover:"rgba(255,255,255,0.35)",scrollBtnBg:"#2d2d2d",scrollBtnColor:"#999",scrollBtnHoverBg:"#3d3d3d",scrollBtnActiveBg:"#4d4d4d",scrollTrackBg:"rgba(255,255,255,0.05)",toolbarBg:"#2a2a2a",toolbarBorder:"#3e3e3e",toolbarBtnColor:"#ccc",toolbarBtnHoverBg:"#3a3a3a",toolbarBtnDisabledColor:"#666",toolbarBtnActiveColor:"#4ea1ff"},Vl=["title"],Ol=["innerHTML"],Ll={key:1,class:"sp-dropdown__value"},_l=["disabled"],Wl=["onClick"],zl=["innerHTML"],$l={class:"sp-dropdown__item-label"},Gl=["disabled"],Pl=e.defineComponent({__name:"dropdown",props:{modelValue:{},options:{},width:{default:"auto"},menuWidth:{default:void 0},visibleCount:{default:8},title:{default:""},modelOpen:{type:Boolean,default:void 0},hideTrigger:{type:Boolean,default:!1},align:{default:"left"}},emits:["update:modelValue","change","update:modelOpen"],setup(r,{emit:v}){const u=r,p=v,s=e.ref(!1),B=e.ref(0),H=e.ref(null),b=e.ref(null),A=e.ref(null),E=e.ref({top:0,up:!1}),y=e.ref(0),S=e.ref(!1),V=e.computed(()=>u.options.find(O=>String(O.value)===String(u.modelValue))),M=e.computed(()=>u.menuWidth),I=e.computed(()=>Math.min(u.visibleCount,u.options.length)),C=e.computed(()=>u.options.slice(B.value,B.value+I.value)),R=e.computed(()=>B.value>0),_=e.computed(()=>B.value+I.value<u.options.length),Y=e.computed(()=>u.options.length>I.value);function X(O){B.value=Math.max(0,Math.min(u.options.length-I.value,B.value+O))}function Re(){s.value=!0,u.modelOpen!==void 0&&p("update:modelOpen",!0);const O=H.value;if(!O)return;const F=O.getBoundingClientRect(),D=I.value*22+(Y.value?2*15:0)+8,Z=window.innerHeight-F.bottom-4<D&&F.top-4>D;u.align==="right"?E.value={right:window.innerWidth-F.right,top:Z?F.top-D-4:F.bottom+4,up:Z}:E.value={left:F.left,top:Z?F.top-D-4:F.bottom+4,up:Z};const rt=u.options.findIndex(We=>String(We.value)===String(u.modelValue));B.value=rt>=0?Math.max(0,Math.min(rt-Math.floor(I.value/2),u.options.length-I.value)):0}function q(){s.value=!1,u.modelOpen!==void 0&&p("update:modelOpen",!1)}function Me(){s.value?q():Re()}function pe(O){p("update:modelValue",O.value),p("change",O.value),q()}function Ae(O){var D,$;if(!s.value)return;const F=O.target;(D=H.value)!=null&&D.contains(F)||($=A.value)!=null&&$.contains(F)||q()}function N(O){s.value&&(O.preventDefault(),X(O.deltaY>0?1:-1))}e.watch(s,O=>{e.nextTick(()=>{var F,D;O?(F=b.value)==null||F.addEventListener("wheel",N,{passive:!1}):(D=b.value)==null||D.removeEventListener("wheel",N)})}),e.watch(()=>u.modelOpen,O=>{O!==void 0&&O!==s.value&&(O?Re():q())});function j(O){s.value&&(y.value=O.touches[0].clientY,S.value=!0)}function d(O){if(!s.value||!S.value)return;const F=O.touches[0].clientY-y.value;Math.abs(F)>5&&(X(F<0?1:-1),y.value=O.touches[0].clientY)}function k(){S.value=!1}function J(O){O.key==="Escape"&&q()}return e.onMounted(()=>{document.addEventListener("mousedown",Ae),window.addEventListener("resize",q),window.addEventListener("scroll",q,!0)}),e.onBeforeUnmount(()=>{document.removeEventListener("mousedown",Ae),window.removeEventListener("resize",q),window.removeEventListener("scroll",q,!0)}),(O,F)=>{var D,$;return e.openBlock(),e.createElementBlock("div",{ref_key:"rootRef",ref:H,class:"sp-dropdown",style:e.normalizeStyle(typeof r.width=="number"?{width:r.width+"px"}:{width:r.width})},[r.hideTrigger?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["sp-dropdown__trigger",{"sp-dropdown__trigger--open":s.value}]),title:r.title,onClick:Me},[(D=V.value)!=null&&D.icon?(e.openBlock(),e.createElementBlock("span",{key:0,class:"sp-dropdown__icon",innerHTML:V.value.icon},null,8,Ol)):(e.openBlock(),e.createElementBlock("span",Ll,e.toDisplayString((($=V.value)==null?void 0:$.label)??""),1)),F[2]||(F[2]=e.createElementVNode("svg",{class:"sp-dropdown__caret",viewBox:"0 0 1024 1024",fill:"currentColor"},[e.createElementVNode("path",{d:"M180.053333 361.386667a32 32 0 0 1 45.226667 0L512 648.106667l286.72-286.72a32 32 0 1 1 45.226667 45.226666l-309.333334 309.333334a32 32 0 0 1-45.226666 0L180.053333 406.613333a32 32 0 0 1 0-45.226666z"})],-1))],10,Vl)),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"menu-pop"},{default:e.withCtx(()=>[s.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"menuRef",ref:A,class:e.normalizeClass(["sp-dropdown__menu",{"sp-dropdown__menu--up":E.value.up}]),style:e.normalizeStyle({left:E.value.left!==void 0?E.value.left+"px":void 0,right:E.value.right!==void 0?E.value.right+"px":void 0,top:E.value.top+"px",minWidth:M.value!==void 0?typeof M.value=="number"?M.value+"px":M.value:void 0}),onKeydown:J},[Y.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["sp-dropdown__nav",{"sp-dropdown__nav--disabled":!R.value}]),disabled:!R.value,onClick:F[0]||(F[0]=Z=>X(-1))},[...F[3]||(F[3]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",fill:"currentColor"},[e.createElementVNode("path",{d:"M180.053333 662.613333a32 32 0 0 0 45.226667 0L512 375.893333l286.72 286.72a32 32 0 1 0 45.226667-45.226666l-309.333334-309.333334a32 32 0 0 0-45.226666 0l-309.333334 309.333334a32 32 0 0 0 0 45.226666z"})],-1)])],10,_l)):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"listRef",ref:b,class:"sp-dropdown__list",onTouchstart:j,onTouchmove:d,onTouchend:k},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(C.value,Z=>(e.openBlock(),e.createElementBlock("button",{key:String(Z.value),type:"button",class:e.normalizeClass(["sp-dropdown__item",{"sp-dropdown__item--active":String(Z.value)===String(r.modelValue)}]),onClick:rt=>pe(Z)},[Z.icon?(e.openBlock(),e.createElementBlock("span",{key:0,class:"sp-dropdown__item-icon",innerHTML:Z.icon},null,8,zl)):e.createCommentVNode("",!0),e.createElementVNode("span",$l,e.toDisplayString(Z.label),1)],10,Wl))),128))],544),Y.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:e.normalizeClass(["sp-dropdown__nav",{"sp-dropdown__nav--disabled":!_.value}]),disabled:!_.value,onClick:F[1]||(F[1]=Z=>X(1))},[...F[4]||(F[4]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",fill:"currentColor"},[e.createElementVNode("path",{d:"M180.053333 361.386667a32 32 0 0 1 45.226667 0L512 648.106667l286.72-286.72a32 32 0 1 1 45.226667 45.226666l-309.333334 309.333334a32 32 0 0 1-45.226666 0L180.053333 406.613333a32 32 0 0 1 0-45.226666z"})],-1)])],10,Gl)):e.createCommentVNode("",!0)],38)):e.createCommentVNode("",!0)]),_:1})]))],4)}}}),lt=(r,v)=>{const u=r.__vccOpts||r;for(const[p,s]of v)u[p]=s;return u},Rt=lt(Pl,[["__scopeId","data-v-0fc61adc"]]),Ul=["title","onClick"],Fo=lt(e.defineComponent({__name:"colorPicker",props:{modelOpen:{type:Boolean,default:void 0},colorKey:{default:"text"},currentColor:{default:""},locale:{default:"zh-CN"}},emits:["update:modelValue","change","update:modelOpen"],setup(r,{expose:v,emit:u}){const p=r,s=u,B=[[{key:"colorAutomatic",value:""},{key:"colorLightBlue",value:"#DEEBF7"},{key:"colorLightOrange",value:"#FCE4D6"},{key:"colorLightYellow",value:"#FFE79A"},{key:"colorLightGreen",value:"#E2EFDA"}],[{key:"colorLightGray",value:"#F2F2F2"},{key:"colorPaleBlue",value:"#BDD7EE"},{key:"colorPaleOrange",value:"#F8CBAD"},{key:"colorPaleYellow",value:"#FFD966"},{key:"colorPaleGreen",value:"#C6EFCE"}],[{key:"colorSilver",value:"#D9D9D9"},{key:"colorSkyBlue",value:"#9BC2E6"},{key:"colorCoral",value:"#F4B183"},{key:"colorGold",value:"#FFC000"},{key:"colorMint",value:"#A9D18E"}],[{key:"colorGray",value:"#BFBFBF"},{key:"colorMediumBlue",value:"#6FA8DC"},{key:"colorOrange",value:"#ED7D31"},{key:"colorAmber",value:"#F1C232"},{key:"colorMediumGreen",value:"#70AD47"}],[{key:"colorDarkGray",value:"#A5A5A5"},{key:"colorRoyalBlue",value:"#4A86E8"},{key:"colorRed",value:"#E06666"},{key:"colorDarkGold",value:"#BF8F00"},{key:"colorDarkGreen",value:"#548235"}],[{key:"colorCharcoal",value:"#808080"},{key:"colorDeepBlue",value:"#2E75B6"},{key:"colorDarkRed",value:"#CC4125"},{key:"colorOlive",value:"#806000"},{key:"colorForest",value:"#375623"}],[{key:"colorSlate",value:"#595959"},{key:"colorNavy",value:"#1F4E79"},{key:"colorCrimson",value:"#993300"},{key:"colorDarkOlive",value:"#5C4500"},{key:"colorDeepForest",value:"#2D6A4F"}],[{key:"colorDarkSlate",value:"#404040"},{key:"colorMidnight",value:"#17375E"},{key:"colorMaroon",value:"#5A1E00"},{key:"colorCoffee",value:"#3D3000"},{key:"colorEvergreen",value:"#1B4332"}],[{key:"colorBlack",value:"#000000"},{key:"colorDarkNavy",value:"#0C2340"},{key:"colorDarkMaroon",value:"#2E0A00"},{key:"colorDarkCoffee",value:"#1F1800"},{key:"colorInkGreen",value:"#081C15"}]],H=[[{key:"colorNoFill",value:""},{key:"colorLightBlue",value:"#DEEBF7"},{key:"colorLightOrange",value:"#FCE4D6"},{key:"colorLightYellow",value:"#FFE79A"},{key:"colorLightGreen",value:"#E2EFDA"}],[{key:"colorWhite",value:"#FFFFFF"},{key:"colorPaleBlue",value:"#BDD7EE"},{key:"colorPaleOrange",value:"#F8CBAD"},{key:"colorPaleYellow",value:"#FFD966"},{key:"colorPaleGreen",value:"#C6EFCE"}],[{key:"colorLightGray",value:"#F2F2F2"},{key:"colorSkyBlue",value:"#9BC2E6"},{key:"colorCoral",value:"#F4B183"},{key:"colorGold",value:"#FFC000"},{key:"colorMint",value:"#A9D18E"}],[{key:"colorSilver",value:"#D9D9D9"},{key:"colorMediumBlue",value:"#6FA8DC"},{key:"colorOrange",value:"#ED7D31"},{key:"colorAmber",value:"#F1C232"},{key:"colorMediumGreen",value:"#70AD47"}],[{key:"colorGray",value:"#BFBFBF"},{key:"colorRoyalBlue",value:"#4A86E8"},{key:"colorRed",value:"#E06666"},{key:"colorDarkGold",value:"#BF8F00"},{key:"colorDarkGreen",value:"#548235"}],[{key:"colorDarkGray",value:"#A5A5A5"},{key:"colorDeepBlue",value:"#2E75B6"},{key:"colorDarkRed",value:"#CC4125"},{key:"colorOlive",value:"#806000"},{key:"colorForest",value:"#375623"}],[{key:"colorCharcoal",value:"#808080"},{key:"colorNavy",value:"#1F4E79"},{key:"colorCrimson",value:"#993300"},{key:"colorDarkOlive",value:"#5C4500"},{key:"colorDeepForest",value:"#2D6A4F"}],[{key:"colorSlate",value:"#595959"},{key:"colorMidnight",value:"#17375E"},{key:"colorMaroon",value:"#5A1E00"},{key:"colorCoffee",value:"#3D3000"},{key:"colorEvergreen",value:"#1B4332"}],[{key:"colorDarkSlate",value:"#404040"},{key:"colorDarkNavy",value:"#0C2340"},{key:"colorDarkMaroon",value:"#2E0A00"},{key:"colorDarkCoffee",value:"#1F1800"},{key:"colorInkGreen",value:"#081C15"}]],b=e.computed(()=>p.colorKey==="fill"?H:B);function A(_){return w(p.locale,_)}function E(_){const Y=p.currentColor;return!Y&&!_?!0:Y?Y.toLowerCase()===_.toLowerCase():!1}const y=e.ref(!1),S=e.ref(null),V=e.ref(null);e.watch(()=>p.modelOpen,_=>{_!==void 0&&_!==y.value&&(_?I():C())});function M(_){const Y=S.value;Y&&!Y.contains(_.target)&&C()}function I(){y.value=!0,p.modelOpen!==void 0&&s("update:modelOpen",!0),e.nextTick(()=>{document.addEventListener("mousedown",M)})}function C(){y.value=!1,p.modelOpen!==void 0&&s("update:modelOpen",!1),document.removeEventListener("mousedown",M)}function R(_){s("update:modelValue",_),s("change",_),C()}return e.onBeforeUnmount(()=>{document.removeEventListener("mousedown",M)}),v({open:y,openMenu:I,close:C}),(_,Y)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootRef",ref:S,class:"color-picker"},[e.createVNode(e.Transition,{name:"menu-pop"},{default:e.withCtx(()=>[y.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"menuRef",ref:V,class:"color-picker__menu",onMousedown:Y[0]||(Y[0]=e.withModifiers(()=>{},["stop"]))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,(X,Re)=>(e.openBlock(),e.createElementBlock("div",{key:Re,class:"color-picker__row"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(X,q=>(e.openBlock(),e.createElementBlock("button",{key:q.value,class:e.normalizeClass(["color-picker__swatch",{"color-picker__swatch--selected":E(q.value)}]),title:A(q.key),style:e.normalizeStyle({background:q.value||"transparent",border:q.value?"1px solid rgba(0,0,0,0.15)":"1px dashed #999"}),onClick:Me=>R(q.value)},null,14,Ul))),128))]))),128))],544)):e.createCommentVNode("",!0)]),_:1})],512))}}),[["__scopeId","data-v-c262a5e5"]]),Kl=["title","onClick"],Yl={viewBox:"0 0 30 30",class:"border-picker__icon"},Xl=["x1","y1","x2","y2","stroke-width","stroke-dasharray","stroke-linecap"],jl={class:"border-picker__label"},Zl=lt(e.defineComponent({__name:"borderPicker",props:{modelOpen:{type:Boolean,default:void 0},locale:{default:"zh-CN"},currentBorder:{default:"none"}},emits:["update:modelOpen","change"],setup(r,{expose:v,emit:u}){const p=r,s=u,B=[{key:"bottom",i18nKey:"borderBottom"},{key:"top",i18nKey:"borderTop"},{key:"left",i18nKey:"borderLeft"},{key:"right",i18nKey:"borderRight"},{key:"none",i18nKey:"borderNone"},{key:"all",i18nKey:"borderAll"},{key:"outer",i18nKey:"borderOuter"},{key:"thickOuter",i18nKey:"borderThickOuter"}],H=[{name:"top",x1:4,y1:4,x2:26,y2:4},{name:"bottom",x1:4,y1:26,x2:26,y2:26},{name:"left",x1:4,y1:4,x2:4,y2:26},{name:"right",x1:26,y1:4,x2:26,y2:26},{name:"vMid",x1:15,y1:4,x2:15,y2:26},{name:"hMid",x1:4,y1:15,x2:26,y2:15}],b={bottom:["bottom"],top:["top"],left:["left"],right:["right"],none:[],all:["top","bottom","left","right","vMid","hMid"],outer:["top","bottom","left","right"],thickOuter:["top","bottom","left","right"]},A={bottom:[],top:[],left:[],right:[],none:[],all:[],outer:[],thickOuter:["top","bottom","left","right"]};function E(R,_){return A[R].includes(_)?"thick":b[R].includes(_)?"solid":"dashed"}const y=e.ref(!1),S=e.ref(null);e.watch(()=>p.modelOpen,R=>{R!==void 0&&R!==y.value&&(R?M():I())});function V(R){const _=S.value;_&&!_.contains(R.target)&&I()}function M(){y.value=!0,p.modelOpen!==void 0&&s("update:modelOpen",!0),e.nextTick(()=>{document.addEventListener("mousedown",V)})}function I(){y.value=!1,p.modelOpen!==void 0&&s("update:modelOpen",!1),document.removeEventListener("mousedown",V)}function C(R){s("change",R),I()}return e.onBeforeUnmount(()=>{document.removeEventListener("mousedown",V)}),v({open:y,openMenu:M,close:I}),(R,_)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootRef",ref:S,class:"border-picker"},[e.createVNode(e.Transition,{name:"menu-pop"},{default:e.withCtx(()=>[y.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"border-picker__menu",onMousedown:_[0]||(_[0]=e.withModifiers(()=>{},["stop"]))},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(B,Y=>e.createElementVNode("button",{key:Y.key,class:"border-picker__item",title:e.unref(w)(r.locale,Y.i18nKey),onClick:X=>C(Y.key)},[(e.openBlock(),e.createElementBlock("svg",Yl,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(H,X=>e.createElementVNode("line",{key:X.name,x1:X.x1,y1:X.y1,x2:X.x2,y2:X.y2,stroke:"currentColor","stroke-width":E(Y.key,X.name)==="thick"?3:1.5,"stroke-dasharray":E(Y.key,X.name)==="dashed"?"0 4":"none","stroke-linecap":E(Y.key,X.name)==="dashed"?"round":"square"},null,8,Xl)),64))])),e.createElementVNode("span",jl,e.toDisplayString(e.unref(w)(r.locale,Y.i18nKey)),1)],8,Kl)),64))],32)):e.createCommentVNode("",!0)]),_:1})],512))}}),[["__scopeId","data-v-c9b0ba80"]]),ql={class:"tb-item","data-key":"undo"},Jl=["title","disabled"],Ql={class:"tb-item","data-key":"redo"},en=["title","disabled"],tn={class:"tb-item","data-key":"paint"},on=["title","disabled"],ln={class:"tb-item","data-key":"clear"},nn=["title","disabled"],an={class:"tb-item","data-key":"font"},rn={class:"tb-item","data-key":"fontSize"},sn={class:"toolbar-font-size"},cn=["value","title"],dn=["title"],un=["title","disabled"],fn=["title","disabled"],mn={class:"tb-item","data-key":"bold"},pn=["title","disabled"],hn={class:"tb-item","data-key":"italic"},bn=["title","disabled"],vn={class:"tb-item","data-key":"underline"},gn=["title","disabled"],yn={class:"tb-item","data-key":"strike"},kn=["title","disabled"],En={class:"tb-item","data-key":"textColor"},wn={class:"toolbar-split"},Bn=["title","disabled"],Cn={viewBox:"0 0 1024 1024",fill:"currentColor"},xn=["fill"],Tn=["title","disabled"],Dn={class:"tb-item","data-key":"fillColor"},Hn={class:"toolbar-split"},Sn=["title","disabled"],Rn={viewBox:"0 0 1024 1024",fill:"currentColor"},Mn=["fill"],An=["title","disabled"],Nn={class:"tb-item","data-key":"border"},In={class:"toolbar-split"},Fn=["title","disabled"],Vn={viewBox:"0 0 30 30",fill:"none",stroke:"currentColor"},On=["x1","y1","x2","y2","stroke-width","stroke-dasharray","stroke-linecap"],Ln=["title","disabled"],_n={class:"tb-item","data-key":"hAlign"},Wn={class:"tb-item","data-key":"vAlign"},zn={class:"tb-item","data-key":"wrap"},$n=["title"],io=2,Gn=6,Pn=34,Un=lt(e.defineComponent({__name:"toolbar",props:{locale:{},canUndo:{type:Boolean},canRedo:{type:Boolean},paintFmtActive:{type:Boolean},hasSelection:{type:Boolean},fontFamilyOptions:{},fontSizeOptions:{},selFontFamily:{},selFontSize:{},fontSizeInput:{},fontSizeMenuOpen:{type:Boolean},selFontWeight:{type:Boolean},selFontStyle:{type:Boolean},selUnderline:{type:Boolean},selStrikethrough:{type:Boolean},selTextColor:{},textColorMenuOpen:{type:Boolean},selFillColor:{},fillColorMenuOpen:{type:Boolean},cachedTextColor:{},cachedFillColor:{},borderMenuOpen:{type:Boolean},cachedBorder:{},selHAlign:{},selVAlign:{},selWrap:{type:Boolean},hAlignOptions:{},vAlignOptions:{}},emits:["undo","redo","paint-format","clear-format","font-family-change","font-size-input","font-size-blur","font-size-keydown","font-size-change","update:font-size-menu-open","font-size-toggle","font-size-step-up","font-size-step-down","bold-toggle","italic-toggle","underline-toggle","strikethrough-toggle","text-color-change","update:text-color-menu-open","fill-color-change","update:fill-color-menu-open","apply-text-color","apply-fill-color","update:border-menu-open","border-change","apply-border","h-align-change","v-align-change","wrap-toggle"],setup(r,{emit:v}){const u=[{name:"top",x1:4,y1:4,x2:26,y2:4},{name:"bottom",x1:4,y1:26,x2:26,y2:26},{name:"left",x1:4,y1:4,x2:4,y2:26},{name:"right",x1:26,y1:4,x2:26,y2:26},{name:"vMid",x1:15,y1:4,x2:15,y2:26},{name:"hMid",x1:4,y1:15,x2:26,y2:15}],p={bottom:["bottom"],top:["top"],left:["left"],right:["right"],none:[],all:["top","bottom","left","right","vMid","hMid"],outer:["top","bottom","left","right"],thickOuter:["top","bottom","left","right"]},s={bottom:[],top:[],left:[],right:[],none:[],all:[],outer:[],thickOuter:["top","bottom","left","right"]};function B(j,d){return s[j].includes(d)?"thick":p[j].includes(d)?"solid":"dashed"}const H=["undo","redo","paint","clear","sep1","font","fontSize","sep2","bold","italic","underline","strike","sep3","textColor","fillColor","border","sep4","hAlign","vAlign","wrap"],b=e.ref(null),A=e.ref(null),E=e.ref(null),y=e.ref(new Set),S=e.ref(!1),V=e.ref(!1),M=new Map,I=e.computed(()=>y.value.size>0);function C(j){return y.value.has(j)}function R(){if(!b.value)return;b.value.querySelectorAll(".tb-item").forEach(d=>{const k=d.dataset.key;k&&M.set(k,d.offsetWidth)})}function _(j,d){if(j.size!==d.size)return!1;for(const k of j)if(!d.has(k))return!1;return!0}function Y(){if(!b.value)return;const j=b.value.clientWidth-Gn*2;if(j<=0)return;M.size===0&&R();let d=0;for(const J of H)d+=(M.get(J)??0)+io;const k=new Set;if(d>j){const J=j-Pn-io;let O=0;for(let F=0;F<H.length;F++){const D=H[F],$=(M.get(D)??0)+io;if(O+$>J){for(let Z=F;Z<H.length;Z++)k.add(H[Z]);break}O+=$}}_(k,y.value)||(y.value=k,k.size===0&&(S.value=!1))}let X=null;const Re=e.ref(0),q=e.computed(()=>{const j=E.value;if(!j)return{position:"fixed",top:"0px",right:"0px"};Re.value;const d=j.getBoundingClientRect();return{position:"fixed",top:`${d.bottom+4}px`,right:`${window.innerWidth-d.right}px`}});function Me(){S.value&&(Re.value++,e.nextTick(()=>Y()))}function pe(j){var k,J;if(!S.value)return;const d=j.target;(k=A.value)!=null&&k.contains(d)||(J=E.value)!=null&&J.contains(d)||(V.value=!0,S.value=!1,e.nextTick(()=>{V.value=!1}))}function Ae(){S.value=!S.value}e.onMounted(()=>{e.nextTick(()=>{R(),Y()}),b.value&&(X=new ResizeObserver(()=>{S.value||Y()}),X.observe(b.value)),document.addEventListener("mousedown",pe,!0),window.addEventListener("resize",Me)}),e.onBeforeUnmount(()=>{X==null||X.disconnect(),document.removeEventListener("mousedown",pe,!0),window.removeEventListener("resize",Me)});const N=v;return(j,d)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{ref_key:"rootEl",ref:b,class:"toolbar"},[(e.openBlock(),e.createBlock(e.Teleport,{disabled:!C("undo"),to:A.value??void 0},[e.createElementVNode("div",ql,[e.createElementVNode("button",{class:e.normalizeClass(["toolbar-btn",{"toolbar-btn--disabled":!r.canUndo}]),title:e.unref(w)(r.locale,"undo"),disabled:!r.canUndo,onClick:d[0]||(d[0]=k=>N("undo"))},[...d[35]||(d[35]=[e.createElementVNode("svg",{class:"toolbar-btn__icon",viewBox:"0 0 1024 1024",fill:"currentColor"},[e.createElementVNode("path",{d:"M596.16 284.064H258.56l101.376-101.44a31.968 31.968 0 1 0-45.248-45.216L178.56 273.504c-11.904 11.872-18.496 27.84-18.56 44.8a63.04 63.04 0 0 0 18.56 45.28l136.128 136.16a31.904 31.904 0 0 0 45.248 0 31.968 31.968 0 0 0 0-45.248l-106.752-106.496H596.16c114.88 0 208.32 93.312 208.32 208s-93.44 208-208.32 208h-223.36a32 32 0 0 0 0 64h223.36c150.144 0 272.32-122.016 272.32-272 0-149.984-122.176-272-272.32-272"})],-1)])],10,Jl)])],8,["disabled","to"])),(e.openBlock(),e.createBlock(e.Teleport,{disabled:!C("redo"),to:A.value??void 0},[e.createElementVNode("div",Ql,[e.createElementVNode("button",{class:e.normalizeClass(["toolbar-btn",{"toolbar-btn--disabled":!r.canRedo}]),title:e.unref(w)(r.locale,"redo"),disabled:!r.canRedo,onClick:d[1]||(d[1]=k=>N("redo"))},[...d[36]||(d[36]=[e.createElementVNode("svg",{class:"toolbar-btn__icon",viewBox:"0 0 1024 1024",fill:"currentColor"},[e.createElementVNode("path",{transform:"translate(1024, 0) scale(-1, 1)",d:"M596.16 284.064H258.56l101.376-101.44a31.968 31.968 0 1 0-45.248-45.216L178.56 273.504c-11.904 11.872-18.496 27.84-18.56 44.8a63.04 63.04 0 0 0 18.56 45.28l136.128 136.16a31.904 31.904 0 0 0 45.248 0 31.968 31.968 0 0 0 0-45.248l-106.752-106.496H596.16c114.88 0 208.32 93.312 208.32 208s-93.44 208-208.32 208h-223.36a32 32 0 0 0 0 64h223.36c150.144 0 272.32-122.016 272.32-272 0-149.984-122.176-272-272.32-272"})],-1)])],10,en)])],8,["disabled","to"])),(e.openBlock(),e.createBlock(e.Teleport,{disabled:!C("paint"),to:A.value??void 0},[e.createElementVNode("div",tn,[e.createElementVNode("button",{class:e.normalizeClass(["toolbar-btn",{"toolbar-btn--active":r.paintFmtActive}]),title:e.unref(w)(r.locale,"paintFormat"),disabled:!r.hasSelection,onClick:d[2]||(d[2]=k=>N("paint-format"))},[...d[37]||(d[37]=[e.createElementVNode("svg",{class:"toolbar-btn__icon",viewBox:"0 0 1024 1024",fill:"currentColor"},[e.createElementVNode("path",{d:"M722.285714 438.857143a36.571429 36.571429 0 0 1-36.571428 36.571428h-512a36.571429 36.571429 0 0 1-36.571429-36.571428V164.571429a36.571429 36.571429 0 0 1 36.571429-36.571429h512a36.571429 36.571429 0 0 1 36.571428 36.571429V256h128a36.571429 36.571429 0 0 1 36.571429 36.571429v294.4a36.571429 36.571429 0 0 1-31.890286 36.278857L448 675.766857V859.428571a36.571429 36.571429 0 0 1-32.292571 36.315429l-4.278858 0.256a36.571429 36.571429 0 0 1-36.571428-36.571429v-215.771428a36.571429 36.571429 0 0 1 31.890286-36.278857l406.966857-52.553143V329.142857h-91.428572v109.714286z m-73.142857-237.714286h-438.857143V402.285714h438.857143V201.142857z"})],-1)])],10,on)])],8,["disabled","to"])),(e.openBlock(),e.createBlock(e.Teleport,{disabled:!C("clear"),to:A.value??void 0},[e.createElementVNode("div",ln,[e.createElementVNode("button",{class:e.normalizeClass(["toolbar-btn",{"toolbar-btn--disabled":!r.hasSelection}]),title:e.unref(w)(r.locale,"clearFormat"),disabled:!r.hasSelection,onClick:d[3]||(d[3]=k=>N("clear-format"))},[...d[38]||(d[38]=[e.createElementVNode("svg",{class:"toolbar-btn__icon",viewBox:"0 0 1024 1024",fill:"currentColor"},[e.createElementVNode("path",{d:"M672.748 105.674c-3.666-3.799-8.778-5.949-14.125-5.949-5.341 0-10.459 2.15-14.119 5.949L10.418 754.633c-7.789 8.163-7.789 20.798 0 28.967l123.353 126.213c7.782 7.979 23.113 14.461 34.111 14.461h395.042c12.774-0.742 24.882-5.854 34.162-14.461l416.525-426.362c7.751-8.163 7.751-20.76 0-28.916l-340.92-348.861h0.057zM557.85 832.801c-9.273 8.582-21.343 13.707-34.111 14.461H217.888c-12.781-0.742-24.882-5.867-34.162-14.461l-58.074-59.482c-7.782-8.163-7.782-20.804 0-28.967l232.333-237.87c3.666-3.799 8.778-5.949 14.125-5.949s10.453 2.15 14.119 5.949l231.102 236.551c7.744 8.157 7.744 20.753 0 28.916l-59.539 60.909 0.058-0.057z m0 0"})],-1)])],10,nn)])],8,["disabled","to"])),(e.openBlock(),e.createBlock(e.Teleport,{disabled:!C("sep1"),to:A.value??void 0},[d[39]||(d[39]=e.createElementVNode("div",{class:"tb-item","data-key":"sep1"},[e.createElementVNode("div",{class:"toolbar-sep"})],-1))],8,["disabled","to"])),(e.openBlock(),e.createBlock(e.Teleport,{disabled:!C("font"),to:A.value??void 0},[e.createElementVNode("div",an,[e.createVNode(Rt,{class:"toolbar-font","model-value":r.selFontFamily,options:r.fontFamilyOptions,width:110,"visible-count":8,title:e.unref(w)(r.locale,"fontFamily"),onChange:d[4]||(d[4]=k=>N("font-family-change",k))},null,8,["model-value","options","title"])])],8,["disabled","to"])),(e.openBlock(),e.createBlock(e.Teleport,{disabled:!C("fontSize"),to:A.value??void 0},[e.createElementVNode("div",rn,[e.createElementVNode("div",sn,[e.createElementVNode("input",{class:"toolbar-font-size__input",type:"number",min:"5",max:"72",step:"1",value:r.fontSizeInput,title:e.unref(w)(r.locale,"fontSize"),onInput:d[5]||(d[5]=k=>N("font-size-input",k.target.value)),onBlur:d[6]||(d[6]=k=>N("font-size-blur")),onKeydown:d[7]||(d[7]=k=>N("font-size-keydown",k))},null,40,cn),e.createVNode(Rt,{class:"toolbar-font-size__dropdown","model-value":r.selFontSize,options:r.fontSizeOptions,width:56,"menu-width":56,"visible-count":9,title:e.unref(w)(r.locale,"fontSize"),"hide-trigger":!0,"model-open":r.fontSizeMenuOpen,"onUpdate:modelOpen":d[8]||(d[8]=k=>N("update:font-size-menu-open",k)),onChange:d[9]||(d[9]=k=>N("font-size-change",k))},null,8,["model-value","options","title","model-open"]),e.createElementVNode("button",{class:"toolbar-font-size__btn",type:"button",title:e.unref(w)(r.locale,"fontSize"),onMousedown:d[10]||(d[10]=e.withModifiers(()=>{},["prevent"])),onClick:d[11]||(d[11]=k=>N("font-size-toggle"))},[...d[40]||(d[40]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",fill:"currentColor"},[e.createElementVNode("path",{d:"M180.053333 361.386667a32 32 0 0 1 45.226667 0L512 648.106667l286.72-286.72a32 32 0 1 1 45.226667 45.226666l-309.333334 309.333334a32 32 0 0 1-45.226666 0L180.053333 406.613333a32 32 0 0 1 0-45.226666z"})],-1)])],40,dn),e.createElementVNode("button",{class:"toolbar-btn toolbar-btn--step",type:"button",title:e.unref(w)(r.locale,"fontSizeDecrease"),disabled:!r.hasSelection,onMousedown:d[12]||(d[12]=e.withModifiers(()=>{},["prevent"])),onClick:d[13]||(d[13]=k=>N("font-size-step-down"))},[...d[41]||(d[41]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",fill:"currentColor"},[e.createElementVNode("path",{d:"M481.28 125.95a29.506 29.506 0 0 0-27.45-18.7h-63.34c-12.13 0-23.02 7.42-27.45 18.7L67.94 876.46c-7.61 19.35 6.66 40.29 27.45 40.29h35.47c12.26 0 23.24-7.58 27.58-19.04l80.89-213.35h364.54l81.94 213.46a29.51 29.51 0 0 0 27.54 18.93h35.56c20.8 0 35.06-20.94 27.45-40.29L481.28 125.95zM273.47 594.06l145.38-384.38h2.2l147.58 384.38H273.47zM928.64 195.74h-177c-16.29 0-29.5 13.21-29.5 29.5s13.21 29.5 29.5 29.5h177c16.29 0 29.5-13.21 29.5-29.5s-13.21-29.5-29.5-29.5z"})],-1)])],40,un),e.createElementVNode("button",{class:"toolbar-btn toolbar-btn--step",type:"button",title:e.unref(w)(r.locale,"fontSizeIncrease"),disabled:!r.hasSelection,onMousedown:d[14]||(d[14]=e.withModifiers(()=>{},["prevent"])),onClick:d[15]||(d[15]=k=>N("font-size-step-up"))},[...d[42]||(d[42]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",fill:"currentColor"},[e.createElementVNode("path",{d:"M481.28 125.95a29.506 29.506 0 0 0-27.45-18.7h-63.34c-12.13 0-23.02 7.42-27.45 18.7L67.94 876.46c-7.61 19.35 6.66 40.29 27.45 40.29h35.47c12.26 0 23.24-7.58 27.58-19.04l80.89-213.35h364.54l81.94 213.46a29.51 29.51 0 0 0 27.54 18.93h35.56c20.8 0 35.06-20.94 27.45-40.29L481.28 125.95zM273.47 594.06l145.38-384.38h2.2l147.58 384.38H273.47zM928.64 195.74h-59v-59c0-16.29-13.21-29.5-29.5-29.5s-29.5 13.21-29.5 29.5v59h-59c-16.29 0-29.5 13.21-29.5 29.5s13.21 29.5 29.5 29.5h59v59c0 16.29 13.21 29.5 29.5 29.5s29.5-13.21 29.5-29.5v-59h59c16.29 0 29.5-13.21 29.5-29.5s-13.21-29.5-29.5-29.5z"})],-1)])],40,fn)])])],8,["disabled","to"])),(e.openBlock(),e.createBlock(e.Teleport,{disabled:!C("sep2"),to:A.value??void 0},[d[43]||(d[43]=e.createElementVNode("div",{class:"tb-item","data-key":"sep2"},[e.createElementVNode("div",{class:"toolbar-sep"})],-1))],8,["disabled","to"])),(e.openBlock(),e.createBlock(e.Teleport,{disabled:!C("bold"),to:A.value??void 0},[e.createElementVNode("div",mn,[e.createElementVNode("button",{class:e.normalizeClass(["toolbar-btn",{"toolbar-btn--active":r.selFontWeight}]),title:e.unref(w)(r.locale,"bold"),disabled:!r.hasSelection,onClick:d[16]||(d[16]=k=>N("bold-toggle"))},[...d[44]||(d[44]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",fill:"currentColor"},[e.createElementVNode("g",{transform:"translate(102.4, 102.4) scale(0.8)"},[e.createElementVNode("path",{d:"M733.610667 467.712A267.562667 267.562667 0 0 0 548.010667 10.581333H183.466667a53.333333 53.333333 0 0 0 0 106.666667h43.221333a10.666667 10.666667 0 0 1 10.666667 10.666667V896a10.666667 10.666667 0 0 1-10.666667 10.666667H183.466667a53.333333 53.333333 0 1 0 0 106.666666h425.088a287.658667 287.658667 0 0 0 125.013333-545.536z m-185.6-350.464a160.512 160.512 0 0 1 0 320.981333H354.688a10.666667 10.666667 0 0 1-10.666667-10.666666V128a10.666667 10.666667 0 0 1 10.666667-10.666667z m60.586666 789.333333H354.688a10.666667 10.666667 0 0 1-10.666667-10.666666v-340.352a10.666667 10.666667 0 0 1 10.666667-10.666667H608.597333a180.864 180.864 0 0 1 0 361.685333z"})])],-1)])],10,pn)])],8,["disabled","to"])),(e.openBlock(),e.createBlock(e.Teleport,{disabled:!C("italic"),to:A.value??void 0},[e.createElementVNode("div",hn,[e.createElementVNode("button",{class:e.normalizeClass(["toolbar-btn",{"toolbar-btn--active":r.selFontStyle}]),title:e.unref(w)(r.locale,"italic"),disabled:!r.hasSelection,onClick:d[17]||(d[17]=k=>N("italic-toggle"))},[...d[45]||(d[45]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",fill:"currentColor"},[e.createElementVNode("g",{transform:"translate(102.4, 102.4) scale(0.8)"},[e.createElementVNode("path",{d:"M960 10.581333h-325.845333a53.333333 53.333333 0 0 0 0 106.666667h46.336a10.666667 10.666667 0 0 1 9.002666 16.384L203.946667 896.725333a21.333333 21.333333 0 0 1-18.005334 9.856H64a53.333333 53.333333 0 0 0 0 106.666667h325.845333a53.333333 53.333333 0 0 0 0-106.666667H343.509333a10.666667 10.666667 0 0 1-9.002666-16.384L820.053333 127.146667a21.333333 21.333333 0 0 1 18.005334-9.898667H960a53.333333 53.333333 0 0 0 0-106.666667z"})])],-1)])],10,bn)])],8,["disabled","to"])),(e.openBlock(),e.createBlock(e.Teleport,{disabled:!C("underline"),to:A.value??void 0},[e.createElementVNode("div",vn,[e.createElementVNode("button",{class:e.normalizeClass(["toolbar-btn",{"toolbar-btn--active":r.selUnderline}]),title:e.unref(w)(r.locale,"underline"),disabled:!r.hasSelection,onClick:d[18]||(d[18]=k=>N("underline-toggle"))},[...d[46]||(d[46]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",fill:"currentColor"},[e.createElementVNode("g",{transform:"translate(102.4, 102.4) scale(0.8)"},[e.createElementVNode("path",{d:"M960 906.581333h-896a53.333333 53.333333 0 0 0 0 106.666667h896a53.333333 53.333333 0 0 0 0-106.666667zM84.394667 117.248h58.154666a10.666667 10.666667 0 0 1 10.666667 10.666667v363.648a358.784 358.784 0 0 0 717.568 0V128a10.666667 10.666667 0 0 1 10.666667-10.666667h58.154666a53.333333 53.333333 0 0 0 0-106.666666H695.466667a53.333333 53.333333 0 0 0 0 106.666666h58.154666a10.666667 10.666667 0 0 1 10.666667 10.666667v363.648a252.117333 252.117333 0 0 1-504.234667 0V128a10.666667 10.666667 0 0 1 10.666667-10.666667H328.533333a53.333333 53.333333 0 1 0 0-106.666666H84.394667a53.333333 53.333333 0 0 0 0 106.666666z"})])],-1)])],10,gn)])],8,["disabled","to"])),(e.openBlock(),e.createBlock(e.Teleport,{disabled:!C("strike"),to:A.value??void 0},[e.createElementVNode("div",yn,[e.createElementVNode("button",{class:e.normalizeClass(["toolbar-btn",{"toolbar-btn--active":r.selStrikethrough}]),title:e.unref(w)(r.locale,"strikethrough"),disabled:!r.hasSelection,onClick:d[19]||(d[19]=k=>N("strikethrough-toggle"))},[...d[47]||(d[47]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",fill:"currentColor"},[e.createElementVNode("g",{transform:"translate(102.4, 102.4) scale(0.8)"},[e.createElementVNode("path",{d:"M1013.333333 552.618667A53.333333 53.333333 0 0 0 960 499.2h-381.269333a20.992 20.992 0 0 1-12.032-3.84c-30.805333-21.888-63.232-41.856-94.634667-61.098667-119.466667-73.173333-192-123.733333-192-207.488 0-95.36 94.165333-109.610667 150.314667-109.610666a193.706667 193.706667 0 0 1 131.456 32.597333 113.578667 113.578667 0 0 1 19.072 84.906667v12.8a53.333333 53.333333 0 1 0 106.666666 0v-11.434667a208.512 208.512 0 0 0-49.706666-161.152C595.157333 31.616 527.317333 10.581333 430.549333 10.581333c-156.074667 0-256.981333 84.864-256.981333 216.277334 0 118.314667 80.725333 192.512 170.666667 252.885333a10.666667 10.666667 0 0 1-5.930667 19.541333H64a53.333333 53.333333 0 0 0 0 106.666667h468.352a10.709333 10.709333 0 0 1 6.784 2.474667 185.130667 185.130667 0 0 1 82.432 147.882666c0 139.434667-146.176 150.272-191.018667 150.272-77.397333 0-133.930667-17.28-163.584-50.048a144.810667 144.810667 0 0 1-27.733333-115.2 53.333333 53.333333 0 0 0-106.154667-10.496A245.76 245.76 0 0 0 187.733333 928.128c51.2 56.490667 132.864 85.333333 242.688 85.333333 178.090667 0 297.685333-103.253333 297.685334-256.938666a258.517333 258.517333 0 0 0-36.224-134.272 10.666667 10.666667 0 0 1 9.216-16.085334H960a53.333333 53.333333 0 0 0 53.333333-53.546666z"})])],-1)])],10,kn)])],8,["disabled","to"])),(e.openBlock(),e.createBlock(e.Teleport,{disabled:!C("sep3"),to:A.value??void 0},[d[48]||(d[48]=e.createElementVNode("div",{class:"tb-item","data-key":"sep3"},[e.createElementVNode("div",{class:"toolbar-sep"})],-1))],8,["disabled","to"])),(e.openBlock(),e.createBlock(e.Teleport,{disabled:!C("textColor"),to:A.value??void 0},[e.createElementVNode("div",En,[e.createElementVNode("div",wn,[e.createElementVNode("button",{class:"toolbar-btn toolbar-split__main",title:e.unref(w)(r.locale,"fontColor"),disabled:!r.hasSelection,onClick:d[20]||(d[20]=k=>N("apply-text-color"))},[(e.openBlock(),e.createElementBlock("svg",Cn,[d[49]||(d[49]=e.createElementVNode("g",{transform:"translate(102.4, 102.4) scale(0.8)"},[e.createElementVNode("path",{d:"M663.120842 529.946947H364.759579l-84.07579 212.884211a53.894737 53.894737 0 0 1-50.122105 34.169263h-14.551579a34.869895 34.869895 0 0 1-32.498526-47.696842L443.715368 70.063158a53.894737 53.894737 0 0 1 50.122106-34.115369h41.768421a53.894737 53.894737 0 0 1 50.176 34.277053l257.670737 659.078737a34.977684 34.977684 0 0 1-32.552421 47.696842h-14.389895a53.894737 53.894737 0 0 1-50.229895-34.277053l-83.159579-212.776421z m-35.139368-89.788631l-113.340632-289.953684-114.472421 289.953684h227.813053z"})],-1)),e.createElementVNode("path",{d:"M62.895 844.369m53.895 0l790.474 0q53.895 0 53.895 53.895l0 26.947q0 53.895-53.895 53.895l-790.474 0q-53.895 0-53.895-53.895l0-26.947q0-53.895 53.895-53.895z",fill:r.cachedTextColor||"#000000"},null,8,xn)]))],8,Bn),e.createElementVNode("button",{class:"toolbar-btn toolbar-split__arrow",title:e.unref(w)(r.locale,"fontColor"),disabled:!r.hasSelection,onClick:d[21]||(d[21]=k=>N("update:text-color-menu-open",!r.textColorMenuOpen))},[...d[50]||(d[50]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",fill:"currentColor"},[e.createElementVNode("path",{d:"M180.053 361.387a32 32 0 0 1 45.227 0L512 648.107l286.72-286.72a32 32 0 1 1 45.227 45.227l-309.334 309.333a32 32 0 0 1-45.226 0L180.053 406.613a32 32 0 0 1 0-45.226z"})],-1)])],8,Tn),e.createVNode(Fo,{"model-open":r.textColorMenuOpen,"color-key":"text","current-color":r.selTextColor,locale:r.locale,"onUpdate:modelOpen":d[22]||(d[22]=k=>N("update:text-color-menu-open",k)),onChange:d[23]||(d[23]=k=>N("text-color-change",k))},null,8,["model-open","current-color","locale"])])])],8,["disabled","to"])),(e.openBlock(),e.createBlock(e.Teleport,{disabled:!C("fillColor"),to:A.value??void 0},[e.createElementVNode("div",Dn,[e.createElementVNode("div",Hn,[e.createElementVNode("button",{class:"toolbar-btn toolbar-split__main",title:e.unref(w)(r.locale,"fillColor"),disabled:!r.hasSelection,onClick:d[24]||(d[24]=k=>N("apply-fill-color"))},[(e.openBlock(),e.createElementBlock("svg",Rn,[d[51]||(d[51]=e.createElementVNode("path",{d:"M447.018667 37.952l352.298666 352.298667c6.613333 6.613333 6.613333 17.344 0 23.957333L446.101333 767.424a16.938667 16.938667 0 0 1-23.957333 0L121.429333 466.688a16.938667 16.938667 0 0 1 0-23.957333L428.608 135.552 388.992 96a8.469333 8.469333 0 0 1 0-11.989333l46.058667-46.037334a8.469333 8.469333 0 0 1 11.968 0z m346.325333 517.461333l57.514667 60.074667c31.744 33.194667 31.744 86.997333 0 120.192a78.869333 78.869333 0 0 1-115.008 0c-31.765333-33.194667-31.765333-86.997333 0-120.192l57.493333-60.074667zM486.101333 193.066667l-261.12 261.12 20.458667 20.458666 380.16-1.728 70.186667-70.186666-209.706667-209.664z"},null,-1)),e.createElementVNode("path",{d:"M85.333333 853.333333m8.896 0l835.541334 0q8.896 0 8.896 8.896l0 110.208q0 8.896-8.896 8.896l-835.541334 0q-8.896 0-8.896-8.896l0-110.208q0-8.896 8.896-8.896Z",fill:r.cachedFillColor||"currentColor"},null,8,Mn)]))],8,Sn),e.createElementVNode("button",{class:"toolbar-btn toolbar-split__arrow",title:e.unref(w)(r.locale,"fillColor"),disabled:!r.hasSelection,onClick:d[25]||(d[25]=k=>N("update:fill-color-menu-open",!r.fillColorMenuOpen))},[...d[52]||(d[52]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",fill:"currentColor"},[e.createElementVNode("path",{d:"M180.053 361.387a32 32 0 0 1 45.227 0L512 648.107l286.72-286.72a32 32 0 1 1 45.227 45.227l-309.334 309.333a32 32 0 0 1-45.226 0L180.053 406.613a32 32 0 0 1 0-45.226z"})],-1)])],8,An),e.createVNode(Fo,{"model-open":r.fillColorMenuOpen,"color-key":"fill","current-color":r.selFillColor,locale:r.locale,"onUpdate:modelOpen":d[26]||(d[26]=k=>N("update:fill-color-menu-open",k)),onChange:d[27]||(d[27]=k=>N("fill-color-change",k))},null,8,["model-open","current-color","locale"])])])],8,["disabled","to"])),(e.openBlock(),e.createBlock(e.Teleport,{disabled:!C("border"),to:A.value??void 0},[e.createElementVNode("div",Nn,[e.createElementVNode("div",In,[e.createElementVNode("button",{class:"toolbar-btn toolbar-split__main",title:e.unref(w)(r.locale,"borders"),disabled:!r.hasSelection,onClick:d[28]||(d[28]=k=>N("apply-border"))},[(e.openBlock(),e.createElementBlock("svg",Vn,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(u,k=>e.createElementVNode("line",{key:k.name,x1:k.x1,y1:k.y1,x2:k.x2,y2:k.y2,"stroke-width":B(r.cachedBorder,k.name)==="thick"?3:1.5,"stroke-dasharray":B(r.cachedBorder,k.name)==="dashed"?"0 4":"none","stroke-linecap":B(r.cachedBorder,k.name)==="dashed"?"round":"square"},null,8,On)),64))]))],8,Fn),e.createElementVNode("button",{class:"toolbar-btn toolbar-split__arrow",title:e.unref(w)(r.locale,"borders"),disabled:!r.hasSelection,onClick:d[29]||(d[29]=k=>N("update:border-menu-open",!r.borderMenuOpen))},[...d[53]||(d[53]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",fill:"currentColor"},[e.createElementVNode("path",{d:"M180.053 361.387a32 32 0 0 1 45.227 0L512 648.107l286.72-286.72a32 32 0 1 1 45.227 45.227l-309.334 309.333a32 32 0 0 1-45.226 0L180.053 406.613a32 32 0 0 1 0-45.226z"})],-1)])],8,Ln),e.createVNode(Zl,{"model-open":r.borderMenuOpen,locale:r.locale,"current-border":r.cachedBorder,"onUpdate:modelOpen":d[30]||(d[30]=k=>N("update:border-menu-open",k)),onChange:d[31]||(d[31]=k=>N("border-change",k))},null,8,["model-open","locale","current-border"])])])],8,["disabled","to"])),(e.openBlock(),e.createBlock(e.Teleport,{disabled:!C("sep4"),to:A.value??void 0},[d[54]||(d[54]=e.createElementVNode("div",{class:"tb-item","data-key":"sep4"},[e.createElementVNode("div",{class:"toolbar-sep"})],-1))],8,["disabled","to"])),(e.openBlock(),e.createBlock(e.Teleport,{disabled:!C("hAlign"),to:A.value??void 0},[e.createElementVNode("div",_n,[e.createVNode(Rt,{class:"toolbar-align","model-value":r.selHAlign,options:r.hAlignOptions,width:44,"visible-count":3,align:"right",title:e.unref(w)(r.locale,"hAlign"),onChange:d[32]||(d[32]=k=>N("h-align-change",k))},null,8,["model-value","options","title"])])],8,["disabled","to"])),(e.openBlock(),e.createBlock(e.Teleport,{disabled:!C("vAlign"),to:A.value??void 0},[e.createElementVNode("div",Wn,[e.createVNode(Rt,{class:"toolbar-align","model-value":r.selVAlign,options:r.vAlignOptions,width:44,"visible-count":3,align:"right",title:e.unref(w)(r.locale,"vAlign"),onChange:d[33]||(d[33]=k=>N("v-align-change",k))},null,8,["model-value","options","title"])]),e.createElementVNode("div",zn,[e.createElementVNode("button",{class:e.normalizeClass(["toolbar-btn",{"toolbar-btn--active":r.selWrap}]),type:"button",title:e.unref(w)(r.locale,"wrap"),onClick:d[34]||(d[34]=k=>N("wrap-toggle"))},[...d[55]||(d[55]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",fill:"currentColor"},[e.createElementVNode("path",{d:"M896 179.2a38.4 38.4 0 0 0-76.8 0v665.6a38.4 38.4 0 0 0 76.8 0v-665.6zM204.8 281.6A38.4 38.4 0 0 0 204.8 358.4h179.2a38.4 38.4 0 0 0 0-76.8H204.8zM550.4 281.6a38.4 38.4 0 0 0 0 76.8h51.2c35.328 0 64 28.672 64 64v179.2c0 35.328-28.672 64-64 64H246.272l36.864-36.864a38.4 38.4 0 1 0-54.272-54.272l-102.4 102.4a38.4 38.4 0 0 0 0 54.272l102.4 102.4a38.4 38.4 0 0 0 54.272-54.272l-36.864-36.864h355.328a140.8 140.8 0 0 0 140.8-140.8v-179.2a140.8 140.8 0 0 0-140.8-140.8h-51.2z"})],-1)])],10,$n)])],8,["disabled","to"])),I.value?(e.openBlock(),e.createElementBlock("button",{key:0,ref_key:"moreBtnEl",ref:E,class:e.normalizeClass(["toolbar-more",{"toolbar-more--active":S.value}]),type:"button",onClick:Ae},[...d[56]||(d[56]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",fill:"currentColor"},[e.createElementVNode("circle",{cx:"512",cy:"160",r:"96"}),e.createElementVNode("circle",{cx:"512",cy:"512",r:"96"}),e.createElementVNode("circle",{cx:"512",cy:"864",r:"96"})],-1)])],2)):e.createCommentVNode("",!0)],512),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"menu-pop"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{ref_key:"overflowMenuEl",ref:A,class:e.normalizeClass(["overflow-menu",{"no-anim":V.value}]),style:e.normalizeStyle(q.value)},null,6),[[e.vShow,S.value]])]),_:1})]))],64))}}),[["__scopeId","data-v-1bf472fc"]]),Kn={class:"tab-list"},Yn=["onClick","onDblclick","onContextmenu"],Xn=["value"],jn={key:1,class:"tab-item__name"},Zn=["title"],qn=lt(e.defineComponent({__name:"tabbar",props:{locale:{},sheets:{},activeSheetIndex:{},renTab:{},renTabVal:{}},emits:["tab-click","tab-dblclick","tab-contextmenu","tab-rename-input","tab-rename-keydown","tab-rename-commit","tabbar-contextmenu","add-sheet"],setup(r,{emit:v}){const u=v;return(p,s)=>(e.openBlock(),e.createElementBlock("div",{class:"tab-bar",onContextmenu:s[5]||(s[5]=B=>u("tabbar-contextmenu",B))},[e.createElementVNode("div",Kn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.sheets,(B,H)=>(e.openBlock(),e.createElementBlock("div",{key:B.id,class:e.normalizeClass(["tab-item",{"tab-item--active":H===r.activeSheetIndex}]),onClick:b=>u("tab-click",H),onDblclick:e.withModifiers(b=>u("tab-dblclick",H),["prevent"]),onContextmenu:b=>u("tab-contextmenu",{ev:b,i:H})},[r.renTab===H?(e.openBlock(),e.createElementBlock("input",{key:0,class:"tab-rename-input",value:r.renTabVal,onInput:s[0]||(s[0]=b=>u("tab-rename-input",b.target.value)),onKeydown:s[1]||(s[1]=b=>u("tab-rename-keydown",b)),onBlur:s[2]||(s[2]=b=>u("tab-rename-commit")),onClick:s[3]||(s[3]=e.withModifiers(()=>{},["stop"]))},null,40,Xn)):(e.openBlock(),e.createElementBlock("span",jn,e.toDisplayString(B.name),1))],42,Yn))),128))]),e.createElementVNode("button",{class:"tab-bar__add-btn",title:e.unref(w)(r.locale,"addSheet"),onClick:s[4]||(s[4]=B=>u("add-sheet"))}," + ",8,Zn)],32))}}),[["__scopeId","data-v-49f54625"]]);function ye(r){let v="",u=r;do v=String.fromCharCode(65+u%26)+v,u=Math.floor(u/26)-1;while(u>=0);return v}function so(r){let v=0;for(let u=0;u<r.length;u++)v=v*26+(r.toUpperCase().charCodeAt(u)-64);return v-1}function Ye(r){if(r==null)return null;if(typeof r=="number")return r;if(typeof r=="string"){const v=parseFloat(r);return r.endsWith("%")||isNaN(v)?null:v}return null}function co(r){navigator.clipboard.writeText(r).catch(()=>{const v=document.createElement("textarea");v.value=r,v.style.position="fixed",v.style.opacity="0",document.body.appendChild(v),v.select(),document.execCommand("copy"),document.body.removeChild(v)})}function nt(r,v){return`${r},${v}`}function Mt(r,v,u){const p=r.match(/^\$?([A-Z]+)\$?(\d+)$/i);if(!p)return null;const s=so(p[1]),B=parseInt(p[2],10)-1;return s<0||s>=v||B<0||B>=u?null:{col:s,row:B}}function Xe(r,v){if(!v)return{x:0,y:0};const u=v.getBoundingClientRect();return{x:r.clientX-u.left,y:r.clientY-u.top}}function Jn(r,v,u){const p=r.split(":");if(p.length!==2)return null;const s=Mt(p[0],v,u),B=Mt(p[1],v,u);return!s||!B?null:{sc:Math.min(s.col,B.col),sr:Math.min(s.row,B.row),ec:Math.max(s.col,B.col),er:Math.max(s.row,B.row)}}function Qn(r,v,u,p,s){const B=u[nt(r,v)];if(!B)return 0;const H=B.value;if(H.startsWith("="))return Oo(nt(r,v),u,p,s)??0;const b=parseFloat(H);return isNaN(b)?0:b}const at=new Map;function Vo(){at.clear()}function Oo(r,v,u,p){return ea(r,v,u,p)}function ea(r,v,u,p,s){if(at.has(r))return NaN;at.set(r,NaN);const B=v[r];if(!B)return NaN;const H=B.value;if(!H.startsWith("=")){const E=parseFloat(H),y=isNaN(E)?0:E;return at.set(r,y),y}const b=H.slice(1).trim();if(b.toUpperCase().startsWith("SUM(")&&b.endsWith(")")){const E=b.slice(4,-1).trim(),y=Jn(E,u,p);if(y){let S=0;for(let V=y.sc;V<=y.ec;V++)for(let M=y.sr;M<=y.er;M++)S+=Qn(V,M,v,u,p);return isNaN(S)?NaN:(at.set(r,S),S)}return NaN}return NaN}function Lo(r,v,u){const p=[],s=/(\$?[A-Z]+\$?\d+)(?::(\$?[A-Z]+\$?\d+))?/gi;let B;for(;(B=s.exec(r))!==null;){const H=Mt(B[1],v,u);if(H)if(B[2]){const b=Mt(B[2],v,u);if(!b)continue;for(let A=Math.min(H.col,b.col);A<=Math.max(H.col,b.col);A++)for(let E=Math.min(H.row,b.row);E<=Math.max(H.row,b.row);E++)p.push(nt(A,E))}else p.push(nt(H.col,H.row))}return p}function ta(r,v,u,p,s){const B=u[nt(r,v)];if(!B)return"";const H=B.value;if(!H.startsWith("="))return H;const b=Oo(nt(r,v),u,p,s);return isNaN(b)?"#ERROR":String(b)}function oa(r,v,u,p,s,B){return v===0&&u===0?r:r.replace(/(\$?)([A-Z]+)(\$?)(\d+)/gi,(H,b,A,E,y)=>{const S=b?so(A):so(A)+v,V=E?parseInt(y,10)-1:parseInt(y,10)-1+u;let M;S<0?M="A":S>=p?M=B(p-1):M=B(S);let I;return V<0?I="1":V>=s?I=String(s):I=String(V+1),(b||"")+M+(E||"")+I})}class la{constructor(){this.deps=new Map,this.rev=new Map,this.dirty=new Set}clear(v){var p;const u=this.deps.get(v);if(u){for(const s of u)(p=this.rev.get(s))==null||p.delete(v);this.deps.delete(v)}}set(v,u){if(this.clear(v),u.length!==0){this.deps.set(v,u);for(const p of u)this.rev.has(p)||this.rev.set(p,new Set),this.rev.get(p).add(v)}}markDirty(v){const u=[v];for(;u.length>0;){const p=u.pop(),s=this.rev.get(p);if(s)for(const B of s)this.dirty.has(B)||(this.dirty.add(B),u.push(B))}}getDirtyAndClear(){const v=this.dirty;return this.dirty=new Set,v}rebuild(v,u,p){this.deps.clear(),this.rev.clear(),this.dirty.clear(),at.clear();for(const[s,B]of Object.entries(v))if(B.value.startsWith("=")){const H=Lo(B.value.slice(1),u,p);this.set(s,H)}}}function na(r,v,u,p){const s={},B=p(v),H=p(u);return B!=null&&(s.width=`${B}px`),H!=null&&(s.height=`${H}px`),s["--sp-formula-bar-bg"]=r.formulaBarBg,s["--sp-formula-bar-border"]=r.formulaBarBorder,s["--sp-formula-bar-label-color"]=r.formulaBarLabelText,s["--sp-formula-bar-label-bg"]=r.formulaBarLabelBg,s["--sp-formula-bar-label-border"]=r.formulaBarLabelBorder,s["--sp-formula-bar-input-bg"]=r.formulaBarInputBg,s["--sp-formula-bar-input-border"]=r.formulaBarInputBorder,s["--sp-formula-bar-input-color"]=r.formulaBarInputText,s["--sp-formula-bar-input-focus-border"]=r.formulaBarInputFocusBorder,s["--sp-formula-bar-input-focus-shadow"]=r.formulaBarInputFocusShadow,s["--sp-wrapper-bg"]=r.wrapperBg,s["--sp-cell-editor-border"]=r.cellEditorBorder,s["--sp-cell-editor-color"]=r.cellEditorText,s["--sp-cell-editor-bg"]=r.cellEditorBg,s["--sp-cell-editor-shadow"]=r.cellEditorShadow,s["--sp-tab-bar-bg"]=r.tabBarBg,s["--sp-tab-bar-border"]=r.tabBarBorder,s["--sp-tab-active-bg"]=r.tabActiveBg,s["--sp-tab-active-color"]=r.tabActiveText,s["--sp-tab-active-border"]=r.tabActiveBorder,s["--sp-tab-inactive-bg"]=r.tabInactiveBg,s["--sp-tab-inactive-color"]=r.tabInactiveText,s["--sp-tab-inactive-border"]=r.tabInactiveBorder,s["--sp-tab-hover-bg"]=r.tabHoverBg,s["--sp-tab-add-btn-color"]=r.tabAddBtnColor,s["--sp-tab-add-btn-hover-bg"]=r.tabAddBtnHoverBg,s["--sp-tab-scroll-btn-color"]=r.tabScrollBtnColor,s["--sp-tab-scroll-btn-hover-bg"]=r.tabScrollBtnHoverBg,s["--sp-scroll-thumb"]=r.scrollbarThumb,s["--sp-scroll-thumb-hover"]=r.scrollbarThumbHover,s["--sp-scroll-btn-bg"]=r.scrollBtnBg,s["--sp-scroll-btn-color"]=r.scrollBtnColor,s["--sp-scroll-btn-hover-bg"]=r.scrollBtnHoverBg,s["--sp-scroll-btn-active-bg"]=r.scrollBtnActiveBg,s["--sp-scroll-track-bg"]=r.scrollTrackBg,s["--sp-toolbar-bg"]=r.toolbarBg,s["--sp-toolbar-border"]=r.toolbarBorder,s["--sp-toolbar-btn-color"]=r.toolbarBtnColor,s["--sp-toolbar-btn-hover-bg"]=r.toolbarBtnHoverBg,s["--sp-toolbar-btn-disabled-color"]=r.toolbarBtnDisabledColor,s["--sp-toolbar-btn-active-color"]=r.toolbarBtnActiveColor,s}const aa={class:"formula-bar"},ra={class:"formula-bar__cell-label"},ia=["value"],sa=["value"],ca=["title"],da=["title"],ua=["title"],fa=["title"],ma={key:2,class:"sb-corner"},pa=["onClick","onMouseenter"],ha={class:"context-menu__label"},ba={key:0,class:"context-menu__arrow"},va=["onClick"],ga={class:"dim-panel__title"},ya={class:"dim-panel__body"},ka=["value"],Ea={key:0,class:"dim-panel__error"},wa={class:"dim-panel__footer"},Ba="\0",_o="#444",Wo=lt(e.defineComponent({__name:"spreader",props:e.mergeModels({rowCount:{default:200},colCount:{default:26},width:{},height:{},theme:{default:"light"},locale:{default:"zh-CN"}},{data:{default:()=>[]},dataModifiers:{}}),emits:["update:data"],setup(r){const v=r,u=e.computed(()=>v.locale==="zh-CN"?"zh-CN":"en-US"),p=v.colCount,s=v.rowCount,B=e.useModel(r,"data");let H="";const b=e.reactive({}),A=new la,E=e.ref(null),y=e.ref({col:0,row:0}),S=e.ref(null),V=e.ref(""),M=e.ref(new Array(p).fill(100)),I=e.ref(new Array(s).fill(void 0)),C=e.ref(0),R=e.ref(0),_=(24-_e)/2,Y=new Map;let X=null;function Re(t,o,l,a){const n=`${a} ${l} ${o}px ${t}`,i=Y.get(n);if(i)return i;X||(X=document.createElement("canvas"));const c=X.getContext("2d");if(!c)return{ascent:o*.8,descent:o*.2};c.font=n;const m=c.measureText("M"),h=m.actualBoundingBoxAscent,T=m.actualBoundingBoxDescent,oe=h||o*.8,ee=T||o*.2,te=Math.max(oe,o*.5),U=Math.max(ee,o*.15),ae={ascent:te,descent:U};return Y.set(n,ae),ae}function q(t,o,l,a){if(!o)return[""];const n=o.split(`
|
|
2
|
+
`),i=[];for(const c of n)if(!a||l<=0)i.push(c);else{let m="";for(let h=0;h<c.length;h++){const T=c[h],oe=m+T;t.measureText(oe).width>l&&m?(i.push(m),m=T):m=oe}i.push(m)}return i}function Me(t,o){var a;const l=(a=b[D(t,o)])==null?void 0:a.style;return typeof(l==null?void 0:l.fontSize)=="number"&&l.fontSize>0?l.fontSize:_e}const pe=e.computed(()=>{const t=[0];for(let o=0;o<p;o++)t.push(t[o]+M.value[o]);return t});function Ae(t){var oe;const o=I.value[t];if(o!=null&&o>0)return o;let l=_e,a=l*.8,n=l*.2,i=1;const c=X?X.getContext("2d"):null;for(let ee=0;ee<p;ee++){const te=Me(ee,t),U=(oe=b[D(ee,t)])==null?void 0:oe.style,ae=typeof(U==null?void 0:U.fontFamily)=="string"&&U.fontFamily?U.fontFamily:ro,xe=(U==null?void 0:U.fontWeight)==="bold"?"bold":"normal",Ue=(U==null?void 0:U.fontStyle)==="italic"?"italic":"normal",ve=rt(ee,t);if(ve&&c){c.font=`${Ue} ${xe} ${te}px ${ae}`;const Te=ve.split(`
|
|
3
|
+
`)[0]||ve,Ke=c.measureText(Te),ie=Ke.actualBoundingBoxAscent,Ne=Ke.actualBoundingBoxDescent,tt=ie||te*.8,De=Ne||te*.2,He=Math.max(tt,te*.5),x=Math.max(De,te*.15);He>a&&(a=He),x>n&&(n=x),te>l&&(l=te);const W=(U==null?void 0:U.wrap)==="wrap";let L;if(W){const le=M.value[ee];L=q(c,ve,Math.max(0,le-10),!0).length,L>i&&(i=L)}else L=ve.split(`
|
|
4
|
+
`).length,L>i&&(i=L)}else if(te>l){l=te;const Te=Re(ae,te,xe,Ue);Te.ascent>a&&(a=Te.ascent),Te.descent>n&&(n=Te.descent)}}const m=l,h=_*2+i*m;return Math.min(500,Math.max(24,Math.round(h)))}const N=e.computed(()=>{const t=[0];for(let o=0;o<s;o++)t.push(t[o]+Ae(o));return t}),j=e.computed(()=>pe.value[p]),d=e.computed(()=>N.value[s]);function k(t,o){y.value={col:t,row:o},E.value={startCol:t,startRow:o,endCol:t,endRow:o}}function J(t,o,l,a){y.value={col:t,row:o},E.value={startCol:Math.min(t,l),startRow:Math.min(o,a),endCol:Math.max(t,l),endRow:Math.max(o,a)}}function O(){J(0,0,p-1,s-1)}function F(t,o){const l=E.value;return l?t>=l.startCol&&t<=l.endCol&&o>=l.startRow&&o<=l.endRow:!1}function D(t,o){return`${t},${o}`}function $(t){Reflect.deleteProperty(b,t)}function Z(t,o){var l;return((l=b[D(t,o)])==null?void 0:l.value)??""}function rt(t,o){return Vo(),ta(t,o,b,p,s)}function We(t,o,l){var c;const a=D(t,o);if(Vo(),l===""||l==null){A.clear(a),$(a),A.markDirty(a);return}const n=String(l),i=((c=b[a])==null?void 0:c.style)??null;b[a]={value:n,style:i},n.startsWith("=")?A.set(a,Lo(n.slice(1),p,s)):A.clear(a),A.markDirty(a)}function zo(t,o,l,a){for(let n=t;n<=o;n++)for(let i=l;i<=a;i++){const c=D(n,i);A.clear(c),$(c),A.markDirty(c)}}function ze(t){S.value||(S.value={...y.value},V.value=t??Z(y.value.col,y.value.row))}function $e(){S.value&&(G(),We(S.value.col,S.value.row,V.value),S.value=null,V.value="")}function je(){S.value=null,V.value=""}function Fe(t,o){k(Math.max(0,Math.min(p-1,y.value.col+t)),Math.max(0,Math.min(s-1,y.value.row+o)))}function Q(t,o){const l=Math.max(0,re.w-52-11),a=Math.max(0,re.h-24-11),n=pe.value[t],i=N.value[o],c=M.value[t],m=Ae(o);let h=C.value,T=R.value;n<h?h=n:n+c>h+l&&(h=n+c-l),i<T?T=i:i+m>T+a&&(T=i+m-a),se(h,T)}function ke(t){const o=pe.value;if(t<0||t>=o[p])return-1;let l=0,a=p-1;for(;l<a;){const n=l+a+1>>1;o[n]<=t?l=n:a=n-1}return l}function Ee(t){const o=N.value;if(t<0||t>=o[s])return-1;let l=0,a=s-1;for(;l<a;){const n=l+a+1>>1;o[n]<=t?l=n:a=n-1}return l}const Ve=e.ref([]),wt=e.ref([]);function $o(t){const o={};for(const[l,a]of Object.entries(t))o[l]={value:a.value,style:a.style};return o}function uo(){return it(),{sheets:P.value.map(t=>({id:t.id,name:t.name,cells:$o(t.cells),selection:t.selection?{...t.selection}:null,activeCell:t.activeCell?{...t.activeCell}:{col:0,row:0},scrollX:t.scrollX,scrollY:t.scrollY,colWidths:[...t.colWidths],rowHeights:[...t.rowHeights]})),activeSheetIndex:ue.value}}function Go(t){P.value=t.sheets.map(o=>({...o,cells:$o(o.cells)})),Pe(Math.max(0,Math.min(t.activeSheetIndex,P.value.length-1))),A.rebuild(b,p,s)}function G(){const t=uo(),o=Ve.value[Ve.value.length-1];o&&JSON.stringify(o)===JSON.stringify(t)||(Ve.value.push(t),wt.value=[],Ve.value.length>50&&Ve.value.shift())}function Po(){Ve.value.length&&(wt.value.push(uo()),Go(Ve.value.pop()),g(),e.nextTick(K))}function Uo(){wt.value.length&&(Ve.value.push(uo()),Go(wt.value.pop()),g(),e.nextTick(K))}const Ca=e.computed(()=>Ve.value.length>0),xa=e.computed(()=>wt.value.length>0),Ta=e.computed(()=>!!E.value),Ze=e.ref(null);function Da(){var l;const t=E.value;if(!t)return;const o={};for(let a=t.startCol;a<=t.endCol;a++)for(let n=t.startRow;n<=t.endRow;n++)o[`${a-t.startCol},${n-t.startRow}`]=((l=b[D(a,n)])==null?void 0:l.style)??null;Ze.value={styles:o}}function Ha(){var l;const t=Ze.value,o=E.value;if(!(!t||!o)){G();for(let a=o.startCol;a<=o.endCol;a++)for(let n=o.startRow;n<=o.endRow;n++){const i=t.styles[`${a-o.startCol},${n-o.startRow}`]??null,c=D(a,n),m=((l=b[c])==null?void 0:l.value)??"";m===""&&i===null?$(c):b[c]={value:m,style:i}}Ze.value=null,g(),K()}}function Sa(){var o;const t=E.value;if(t){G();for(let l=t.startCol;l<=t.endCol;l++)for(let a=t.startRow;a<=t.endRow;a++){const n=D(l,a),i=((o=b[n])==null?void 0:o.value)??"";i===""?$(n):b[n]={value:i,style:null}}g(),K()}}const Ra=e.computed(()=>Cl.map(t=>({...t,label:t.value===""?w(u.value,"fontDefault"):t.label}))),Ma=e.computed(()=>xl.map(t=>({...t,label:String(t.value)}))),Aa=e.computed(()=>{var a;const t=E.value;if(!t)return"";let o,l=!1;for(let n=t.startCol;n<=t.endCol&&!l;n++)for(let i=t.startRow;i<=t.endRow&&!l;i++){const c=(a=b[D(n,i)])==null?void 0:a.style,m=typeof(c==null?void 0:c.fontFamily)=="string"?c.fontFamily:"";o===void 0?o=m:m!==o&&(l=!0)}return l?Ba:o??""}),he=e.computed(()=>{const t=E.value;if(!t)return _e;let o,l=!1;for(let a=t.startCol;a<=t.endCol&&!l;a++)for(let n=t.startRow;n<=t.endRow&&!l;n++){const i=Me(a,n);o===void 0?o=i:i!==o&&(l=!0)}return l?0:o??_e});function ne(t,o){var a,n;const l=E.value;if(l){G();for(let i=l.startCol;i<=l.endCol;i++)for(let c=l.startRow;c<=l.endRow;c++){const m=D(i,c),h=((a=b[m])==null?void 0:a.value)??"",T=(n=b[m])!=null&&n.style?{...b[m].style}:{};o===""||o===null||o===void 0||o===0?delete T[t]:T[t]=o;const oe=Object.keys(T).length?T:null;h===""&&oe===null?$(m):b[m]={value:h,style:oe}}g(),K()}}function Na(t){ne("fontFamily",t===""?"":t)}function Ia(t){ne("fontSize",t),qe.value=!1}const Fa=e.computed(()=>Al.map(t=>({label:w(u.value,t.labelKey),value:t.value,icon:t.icon}))),Va=e.computed(()=>Nl.map(t=>({label:w(u.value,t.labelKey),value:t.value,icon:t.icon}))),Oa=e.computed(()=>{var a;const t=E.value;if(!t)return"left";const o=(a=b[D(t.startCol,t.startRow)])==null?void 0:a.style,l=typeof(o==null?void 0:o.textAlign)=="string"?o.textAlign:"";return l==="center"||l==="right"?l:"left"}),La=e.computed(()=>{var a;const t=E.value;if(!t)return"top";const o=(a=b[D(t.startCol,t.startRow)])==null?void 0:a.style,l=typeof(o==null?void 0:o.verticalAlign)=="string"?o.verticalAlign:"";return l==="middle"||l==="bottom"?l:"top"}),Ko=e.computed(()=>{var l;const t=E.value;if(!t)return!1;const o=(l=b[D(t.startCol,t.startRow)])==null?void 0:l.style;return(o==null?void 0:o.wrap)==="wrap"});function _a(t){ne("textAlign",t)}function Wa(t){ne("verticalAlign",t)}function za(){if(!E.value)return;const o=Ko.value;ne("wrap",o?void 0:"wrap")}const Ge=e.ref(""),qe=e.ref(!1);e.watch(he,t=>{Ge.value=t===0?"":String(t)},{immediate:!0});function $a(t){const o=t.replace(/[^\d]/g,"");Ge.value=o;const l=parseInt(o,10);!isNaN(l)&&l>=5&&l<=72&&l!==he.value&&ne("fontSize",l)}function Ga(){const t=Ge.value.trim();if(!t){Ge.value=he.value===0?"":String(he.value);return}let o=parseInt(t,10);isNaN(o)?o=he.value===0?_e:he.value:o=Math.max(5,Math.min(72,o)),Ge.value=String(o),o!==he.value&&ne("fontSize",o)}function Pa(t){t.key==="Enter"&&t.target.blur()}function Ua(t){qe.value=!qe.value}function Ka(){const t=he.value===0?_e:he.value,o=Math.min(72,t+1);ne("fontSize",o),Ge.value=String(o),qe.value=!1}function Ya(){const t=he.value===0?_e:he.value,o=Math.max(5,t-1);ne("fontSize",o),Ge.value=String(o),qe.value=!1}function At(t){var n;const o=E.value;if(!o)return!1;let l,a=!1;for(let i=o.startCol;i<=o.endCol&&!a;i++)for(let c=o.startRow;c<=o.endRow&&!a;c++){const m=(n=b[D(i,c)])==null?void 0:n.style,h=!!(m!=null&&m[t]);l===void 0?l=h:h!==l&&(a=!0)}return!a&&l===!0}const Yo=e.computed(()=>At("fontWeight")),Xo=e.computed(()=>At("fontStyle")),jo=e.computed(()=>At("underline")),Zo=e.computed(()=>At("strikethrough"));function Xa(){ne("fontWeight",Yo.value?"":"bold")}function ja(){ne("fontStyle",Xo.value?"":"italic")}function Za(){ne("underline",jo.value?"":"underline")}function qa(){ne("strikethrough",Zo.value?"":"line-through")}const Nt=e.ref(""),It=e.ref(""),fo=e.ref(!1),mo=e.ref(!1);function Ja(t){qo.value=t,t&&(fo.value=!1,mo.value=!1)}function Qa(t){Nt.value=t,ne("color",t===""?"":t)}function er(t){It.value=t,ne("backgroundColor",t===""?"":t)}function tr(){ne("color",Nt.value===""?"":Nt.value)}function or(){ne("backgroundColor",It.value===""?"":It.value)}const lr=e.computed(()=>{var a;const t=E.value;if(!t)return"";let o,l=!1;for(let n=t.startCol;n<=t.endCol&&!l;n++)for(let i=t.startRow;i<=t.endRow&&!l;i++){const c=(a=b[D(n,i)])==null?void 0:a.style,m=typeof(c==null?void 0:c.color)=="string"?c.color:"";o===void 0?o=m:m!==o&&(l=!0)}return l?"":o??""}),nr=e.computed(()=>{var a;const t=E.value;if(!t)return"";let o,l=!1;for(let n=t.startCol;n<=t.endCol&&!l;n++)for(let i=t.startRow;i<=t.endRow&&!l;i++){const c=(a=b[D(n,i)])==null?void 0:a.style,m=typeof(c==null?void 0:c.backgroundColor)=="string"?c.backgroundColor:"";o===void 0?o=m:m!==o&&(l=!0)}return l?"":o??""}),po=e.ref("none"),qo=e.ref(!1);function ar(t,o,l,a){const n=l===a.startRow,i=l===a.endRow,c=o===a.startCol,m=o===a.endCol,h={top:0,bottom:0,left:0,right:0};switch(t){case"none":return h;case"bottom":i&&(h.bottom=1);break;case"top":n&&(h.top=1);break;case"left":c&&(h.left=1);break;case"right":m&&(h.right=1);break;case"all":h.top=1,h.bottom=1,h.left=1,h.right=1;break;case"outer":n&&(h.top=1),i&&(h.bottom=1),c&&(h.left=1),m&&(h.right=1);break;case"thickOuter":n&&(h.top=2),i&&(h.bottom=2),c&&(h.left=2),m&&(h.right=2);break}return h}function Jo(t){po.value=t;const o=E.value;if(o){if(G(),t==="none")for(let l=o.startCol;l<=o.endCol;l++)for(let a=o.startRow;a<=o.endRow;a++)Qo(l,a,{top:0,bottom:0,left:0,right:0},!0);else for(let l=o.startCol;l<=o.endCol;l++)for(let a=o.startRow;a<=o.endRow;a++){const n=ar(t,l,a,o);Qo(l,a,n,!1)}g(),K()}}function Qo(t,o,l,a=!0){var ee,te;const n=D(t,o),i=((ee=b[n])==null?void 0:ee.value)??"",c=(te=b[n])!=null&&te.style?{...b[n].style}:{},m=["Top","Bottom","Left","Right"],h=[l.top,l.bottom,l.left,l.right];for(let U=0;U<4;U++){const ae=`border${m[U]}Width`;h[U]===0?a&&delete c[ae]:(c[ae]=h[U],c.borderColor=_o)}m.some(U=>c[`border${U}Width`]!==void 0)||delete c.borderColor;const oe=Object.keys(c).length?c:null;i===""&&oe===null?$(n):b[n]={value:i,style:oe}}function rr(){Jo(po.value)}function el(t,o,l){var n;const a=(n=b[D(t,o)])==null?void 0:n.style;return(a==null?void 0:a[`border${l}Width`])||0}let tl=null;function Ft(){const t=E.value;if(!t)return;tl={...t};const o=[];for(let l=t.startRow;l<=t.endRow;l++){const a=[];for(let n=t.startCol;n<=t.endCol;n++)a.push(Z(n,l));o.push(a.join(" "))}co(o.join(`
|
|
5
|
+
`))}function Vt(){const t=E.value;if(t){if(t.startCol===0&&t.endCol===p-1){const o=[];for(let l=t.startRow;l<=t.endRow;l++){const a=[];for(let n=0;n<p;n++)a.push(Z(n,l));o.push(a.join(" "))}co(o.join(`
|
|
6
|
+
`))}else if(t.startRow===0&&t.endRow===s-1){const o=[];for(let l=0;l<s;l++){const a=[];for(let n=t.startCol;n<=t.endCol;n++)a.push(Z(n,l));o.push(a.join(" "))}co(o.join(`
|
|
7
|
+
`))}}}async function Bt(){let t="";try{t=await navigator.clipboard.readText()}catch{return}if(!t&&t!=="")return;const o=t.split(/\r?\n/),l=y.value,a=tl;for(let n=0;n<o.length;n++){const i=o[n].split(" ");for(let c=0;c<i.length;c++){const m=l.col+c,h=l.row+n;if(m<p&&h<s){let T=i[c];T.startsWith("=")&&a&&(T=oa(T,m-(a.startCol+c),h-(a.startRow+n),p,s,ye)),We(m,h,T)}}}}function ho(){if(Ft(),E.value){const t=E.value;zo(t.startCol,t.endCol,t.startRow,t.endRow),g()}}function bo(){if(E.value){const t=E.value;zo(t.startCol,t.endCol,t.startRow,t.endRow),g()}}function ir(){const t=E.value;if(!t)return;G();const o=t.startCol,l=t.startRow,a=t.endCol,n=t.endRow;if(l===n)if(a+1<p){const i=`${ye(o)}${l+1}:${ye(a)}${l+1}`;We(a+1,l,`=SUM(${i})`)}else{const i=`${ye(o)}${l+1}:${ye(a-1)}${l+1}`;We(a,l,`=SUM(${i})`)}else for(let i=o;i<=a;i++)if(n+1<s){const c=`${ye(i)}${l+1}:${ye(i)}${n+1}`;We(i,n+1,`=SUM(${c})`)}else{const c=`${ye(i)}${l+1}:${ye(i)}${n}`;We(i,n,`=SUM(${c})`)}g(),K()}function sr(t,o){const l=o-t+1;for(let a=t;a<=o;a++)for(let n=0;n<p;n++)$(D(n,a));for(let a=t;a<s-l;a++){for(let n=0;n<p;n++){const i=D(n,a+l),c=D(n,a);b[i]?(b[c]=b[i],$(i)):$(c)}I.value[a]=I.value[a+l]}for(let a=s-l;a<s;a++){for(let n=0;n<p;n++)$(D(n,a));I.value[a]=void 0}}function cr(t,o){const l=o-t+1;if(!(o>=s-1)){for(let a=s-1;a>o;a--){for(let n=0;n<p;n++){const i=D(n,a-l),c=D(n,a);b[i]?b[c]=b[i]:$(c)}I.value[a]=I.value[a-l]}for(let a=o+1;a<=o+l;a++){for(let n=0;n<p;n++)$(D(n,a));I.value[a]=void 0}}}function dr(t,o){const l=o-t+1;if(!(o>=p-1)){for(let a=p-1;a>o;a--){for(let n=0;n<s;n++){const i=D(a-l,n),c=D(a,n);b[i]?b[c]=b[i]:$(c)}M.value[a]=M.value[a-l]}for(let a=o+1;a<=o+l;a++){for(let n=0;n<s;n++)$(D(a,n));M.value[a]=100}}}function ur(t,o){const l=o-t+1;for(let a=t;a<=o;a++)for(let n=0;n<s;n++)$(D(a,n));for(let a=t;a<p-l;a++){for(let n=0;n<s;n++){const i=D(a+l,n),c=D(a,n);b[i]?(b[c]=b[i],$(i)):$(c)}M.value[a]=M.value[a+l]}for(let a=p-l;a<p;a++){for(let n=0;n<s;n++)$(D(a,n));M.value[a]=100}}let ol=0;function ll(){return ol++,`s_${ol}`}function Ot(t){return{id:ll(),name:t,cells:{},selection:{startCol:0,startRow:0,endCol:0,endRow:0},activeCell:{col:0,row:0},scrollX:0,scrollY:0,colWidths:new Array(p).fill(100),rowHeights:new Array(s).fill(void 0)}}const P=e.ref([Ot("Sheet1")]),ue=e.ref(0);function it(){const t=P.value[ue.value];t&&(t.cells={...b},t.selection=E.value?{...E.value}:null,t.activeCell={...y.value},t.scrollX=C.value,t.scrollY=R.value,t.colWidths=[...M.value],t.rowHeights=[...I.value])}function Pe(t){const o=P.value[t];o&&(Object.keys(b).forEach(l=>$(l)),Object.assign(b,o.cells),E.value=o.selection?{...o.selection}:null,y.value={...o.activeCell},C.value=o.scrollX,R.value=o.scrollY,M.value=[...o.colWidths],I.value=[...o.rowHeights],ue.value=t)}function fr(t){t===ue.value||t<0||t>=P.value.length||(je(),it(),Pe(t))}function vo(t){return G(),je(),it(),P.value.push(Ot(`Sheet${P.value.length+1}`)),Pe(P.value.length-1),P.value.length-1}function mr(t){return P.value.length<=1||(G(),je(),P.value.splice(t,1),Pe(Math.min(t,P.value.length-1))),ue.value}function pr(t,o){P.value[t]&&o.trim()&&(G(),P.value[t].name=o.trim())}function hr(t){G(),je(),it();const o=P.value[t];if(!o)return t;let l=o.name;const a=l.match(/^(.*?)\s*\((\d+)\)$/);let n=a?parseInt(a[2],10)+1:2;a&&(l=a[1]);let i=`${l} (${n})`;const c=new Set(P.value.map(h=>h.name));for(;c.has(i);)n++,i=`${l} (${n})`;const m={id:ll(),name:i,cells:{...o.cells},selection:o.selection?{...o.selection}:null,activeCell:o.activeCell?{...o.activeCell}:{col:0,row:0},scrollX:o.scrollX,scrollY:o.scrollY,colWidths:[...o.colWidths],rowHeights:[...o.rowHeights]};return P.value.splice(t+1,0,m),Pe(t+1),t+1}function nl(t,o){const l=t+o;if(l<0||l>=P.value.length)return;G();const a=ue.value,n=P.value.splice(t,1)[0];P.value.splice(l,0,n),a===t?ue.value=l:t<a&&l>=a?ue.value=a-1:t>a&&l<=a&&(ue.value=a+1),g()}const br=e.computed(()=>P.value.length);function K(){it();const t=P.value.map(l=>{const a={};for(const[m,h]of Object.entries(l.cells))a[m]={value:h.value},h.style&&(a[m].style=h.style);const n={name:l.name,cells:a},i={};for(let m=0;m<l.colWidths.length;m++)l.colWidths[m]!==100&&(i[m]=l.colWidths[m]);Object.keys(i).length&&(n.colWidths=i);const c={};for(let m=0;m<l.rowHeights.length;m++){const h=l.rowHeights[m];h!=null&&(c[m]=h)}return Object.keys(c).length&&(n.rowHeights=c),n}),o=JSON.stringify(t);o!==H&&(H=o,B.value=t)}let go=!1;function al(){go||(go=!0,Promise.resolve().then(()=>{go=!1,K()}))}const rl=e.computed(()=>v.theme==="dark"?Fl:Il),vr=e.computed(()=>na(rl.value,v.width,v.height,Ye)),Je=e.ref(null),we=e.ref(null),Lt=e.ref(null),yo=e.ref(null),re=e.reactive({w:800,h:600}),st=e.computed(()=>Math.max(0,j.value-Math.max(0,re.w-52-11))),ct=e.computed(()=>Math.max(0,d.value-Math.max(0,re.h-24-11)));function se(t,o){const l=Math.max(0,re.w-52-11),a=Math.max(0,re.h-24-11);C.value=Math.max(0,Math.min(t??C.value,Math.max(0,j.value-l))),R.value=Math.max(0,Math.min(o??R.value,Math.max(0,d.value-a)))}function gr(){var t;return typeof window>"u"?!1:!((t=window.matchMedia)!=null&&t.call(window,"(hover: none) and (pointer: coarse)").matches)}function fe(t=!1){e.nextTick(()=>{const o=Lt.value;if(o){if(!S.value&&!gr()){document.activeElement===o&&o.blur();return}o.focus({preventScroll:!0}),t&&o.select()}})}function yr(){fe()}let ko=!1,f=null,Ct=1;function g(){ko||(ko=!0,requestAnimationFrame(()=>{ko=!1,kr()}))}function kr(){var tt,De,He;const t=we.value;if(!t)return;const o=Je.value;if(!o||(f=t.getContext("2d"),!f))return;Ct=window.devicePixelRatio||1;const l=o.getBoundingClientRect(),a=l.width,n=l.height;re.w=a,re.h=n,t.width=a*Ct,t.height=n*Ct,t.style.width=a+"px",t.style.height=n+"px",f.setTransform(Ct,0,0,Ct,0,0);const i=C.value,c=R.value,m=52,h=24,T=rl.value,oe=pe.value,ee=N.value,te=M.value,U=[];for(let x=0;x<s;x++)U[x]=ee[x+1]-ee[x];const ae=Math.max(0,ke(i));let xe=ae;for(let x=ae;x<p&&!(m+oe[x]-i>=a);x++)xe=x;const Ue=xe,ve=Math.max(0,Ee(c));let Te=ve;for(let x=ve;x<s&&!(h+ee[x]-c>=n);x++)Te=x;const Ke=Te;f.fillStyle=T.bg,f.fillRect(0,0,a,n),f.fillStyle=T.gridBg,f.fillRect(m,h,a-m,n-h),f.save(),f.beginPath(),f.rect(m+.5,h+.5,a-m-1,n-h-1),f.clip();const ie=E.value,Ne=S.value;for(let x=ve;x<=Ke;x++)for(let W=ae;W<=Ue;W++){const L=m+oe[W]-i,le=h+ee[x]-c,me=te[W],Se=U[x];if(L+me<m||le+Se<h||L>a||le>n)continue;F(W,x)&&(f.fillStyle=T.selectionBg,f.fillRect(L,le,me,Se)),y.value.col===W&&y.value.row===x&&(f.strokeStyle=T.activeCellBorder,f.lineWidth=2,f.strokeRect(L+1,le+1,me-2,Se-2)),f.strokeStyle=T.gridLine,f.lineWidth=.5,f.strokeRect(L+.25,le+.25,me-.5,Se-.5);const Jt=(tt=b[D(W,x)])==null?void 0:tt.style,kl=typeof(Jt==null?void 0:Jt.backgroundColor)=="string"?Jt.backgroundColor:"";if(kl&&(f.fillStyle=kl,f.fillRect(L,le,me,Se)),!(Ne&&Ne.col===W&&Ne.row===x)){const de=rt(W,x);if(de){const z=(De=b[D(W,x)])==null?void 0:De.style,vt=Me(W,x),mi=typeof(z==null?void 0:z.fontFamily)=="string"&&z.fontFamily?z.fontFamily:ro,pi=(z==null?void 0:z.fontWeight)==="bold"?"bold":"normal",hi=(z==null?void 0:z.fontStyle)==="italic"?"italic":"normal",bi=(z==null?void 0:z.underline)==="underline",vi=(z==null?void 0:z.strikethrough)==="line-through",Io=typeof(z==null?void 0:z.color)=="string"?z.color:"",El=typeof(z==null?void 0:z.textAlign)=="string"?z.textAlign:"left",wl=typeof(z==null?void 0:z.verticalAlign)=="string"?z.verticalAlign:"top";f.fillStyle=Io||T.cellText,f.font=`${hi} ${pi} ${vt}px ${mi}`,f.textBaseline="alphabetic",f.save(),f.beginPath(),f.rect(L+5,le+1,me-10,Se-2),f.clip();const gi=(z==null?void 0:z.wrap)==="wrap",Ht=q(f,de,me-10,gi);let gt=0,ot=0;for(const yt of Ht){const St=f.measureText(yt),kt=St.actualBoundingBoxAscent,Et=St.actualBoundingBoxDescent,Ie=kt||vt*.8,ao=Et||vt*.2;gt=Math.max(gt,Ie),ot=Math.max(ot,ao)}gt=Math.max(gt,vt*.5),ot=Math.max(ot,vt*.15);const lo=vt,yi=Ht.length*lo;let no;wl==="middle"?no=le+(Se-yi)/2+gt:wl==="bottom"?no=le+Se-_-ot-(Ht.length-1)*lo:no=le+_+gt;for(let yt=0;yt<Ht.length;yt++){const St=Ht[yt],kt=no+yt*lo,Et=f.measureText(St);let Ie;if(El==="center"?Ie=L+me/2-Et.width/2:El==="right"?Ie=L+me-5-Et.width:Ie=L+5,f.fillText(St,Ie,kt),bi&&(f.strokeStyle=Io||T.cellText,f.lineWidth=1,f.beginPath(),f.moveTo(Ie,kt+ot+1),f.lineTo(Ie+Et.width,kt+ot+1),f.stroke()),vi){f.strokeStyle=Io||T.cellText,f.lineWidth=1;const ao=kt-lo*.25;f.beginPath(),f.moveTo(Ie,ao),f.lineTo(Ie+Et.width,ao),f.stroke()}}f.restore()}}const ge=(He=b[D(W,x)])==null?void 0:He.style,ui=(ge==null?void 0:ge.borderTopWidth)||0,fi=(ge==null?void 0:ge.borderLeftWidth)||0,Qt=(ge==null?void 0:ge.borderBottomWidth)||0,eo=(ge==null?void 0:ge.borderRightWidth)||0,to=Math.max(ui,el(W,x-1,"Bottom")),oo=Math.max(fi,el(W-1,x,"Right"));if(to>0||oo>0||Qt>0||eo>0){if(f.strokeStyle=_o,to>0){f.lineWidth=to,f.beginPath();const de=le+to/2-.5;f.moveTo(L,de),f.lineTo(L+me,de),f.stroke()}if(oo>0){f.lineWidth=oo,f.beginPath();const de=L+oo/2-.5;f.moveTo(de,le),f.lineTo(de,le+Se),f.stroke()}if(x===Ke&&Qt>0){f.lineWidth=Qt,f.beginPath();const de=le+Se-Qt/2+.5;f.moveTo(L,de),f.lineTo(L+me,de),f.stroke()}if(W===Ue&&eo>0){f.lineWidth=eo,f.beginPath();const de=L+me-eo/2+.5;f.moveTo(de,le),f.lineTo(de,le+Se),f.stroke()}}}f.restore(),f.fillStyle=T.headerBg,f.fillRect(m,0,a-m,h);for(let x=ae;x<=Ue;x++){const W=m+oe[x]-i,L=te[x];W+L<m||W>a||(ie&&x>=ie.startCol&&x<=ie.endCol&&(f.fillStyle=T.selectionBg,f.fillRect(W,0,L,h)),f.strokeStyle=T.headerBorder,f.lineWidth=.5,f.strokeRect(W+.25,.25,L-.5,h-.5),ie&&x>=ie.startCol&&x<=ie.endCol&&(f.strokeStyle=T.activeCellBorder,f.lineWidth=2,f.beginPath(),f.moveTo(W,h-1),f.lineTo(W+L,h-1),f.stroke()),f.fillStyle=T.headerText,f.font='11px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',f.textAlign="center",f.textBaseline="middle",f.fillText(ye(x),W+L/2,h/2))}f.strokeStyle=T.headerSep,f.lineWidth=1,f.beginPath(),f.moveTo(m,h+.5),f.lineTo(a,h+.5),f.stroke(),f.fillStyle=T.headerBg,f.fillRect(0,h,m,n-h);for(let x=ve;x<=Ke;x++){const W=h+ee[x]-c,L=U[x];W+L<h||W>n||(ie&&x>=ie.startRow&&x<=ie.endRow&&(f.fillStyle=T.selectionBg,f.fillRect(0,W,m,L)),f.strokeStyle=T.headerBorder,f.lineWidth=.5,f.strokeRect(.25,W+.25,m-.5,L-.5),ie&&x>=ie.startRow&&x<=ie.endRow&&(f.strokeStyle=T.activeCellBorder,f.lineWidth=2,f.beginPath(),f.moveTo(m-1,W),f.lineTo(m-1,W+L),f.stroke()),f.fillStyle=T.headerText,f.font='11px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',f.textAlign="center",f.textBaseline="middle",f.fillText(String(x+1),m/2,W+L/2+.5))}f.strokeStyle=T.headerSep,f.lineWidth=1,f.beginPath(),f.moveTo(m+.5,h),f.lineTo(m+.5,n),f.stroke(),f.fillStyle=T.headerBg,f.fillRect(0,0,m,h),f.strokeStyle=T.headerSep,f.lineWidth=1,f.strokeRect(.5,.5,m-.5,h-.5)}const Er=e.computed(()=>ye(y.value.col)+String(y.value.row+1)),wr=e.computed(()=>S.value?V.value:Z(y.value.col,y.value.row));function Br(){S.value||(Q(y.value.col,y.value.row),V.value=Z(y.value.col,y.value.row),ze(),g())}function Cr(t){V.value=t.target.value}function xr(t){var o,l;t.key==="Enter"?(t.preventDefault(),$e(),Fe(0,1),Q(y.value.col,y.value.row),(o=yo.value)==null||o.blur(),g(),fe()):t.key==="Escape"&&(t.preventDefault(),je(),(l=yo.value)==null||l.blur(),g(),fe())}function Tr(){setTimeout(()=>{S.value&&($e(),g())},0)}const Qe=e.ref(null),dt=e.ref("");function Dr(t){Qe.value===null&&(fr(t),g())}function il(t){t!==ue.value&&(it(),Pe(t),g()),Qe.value=t,dt.value=P.value[t].name,e.nextTick(()=>{const o=document.querySelector(".tab-rename-input");o==null||o.focus(),o==null||o.select()})}function sl(){Qe.value!==null&&(pr(Qe.value,dt.value),e.nextTick(K)),Qe.value=null,dt.value=""}function Hr(){Qe.value=null,dt.value=""}function Sr(t){t.key==="Enter"?(t.preventDefault(),sl()):t.key==="Escape"&&(t.preventDefault(),Hr())}const Oe=e.ref(null);let xt=null;function cl(){xt&&(document.removeEventListener("click",xt),xt=null)}function ut(t,o,l){cl();const a=140,n=l.length*28+8,i=window.innerWidth,c=window.innerHeight;t+a>i&&(t-=a),o+n>c&&(o-=n),Oe.value={x:t,y:o,items:l},xt=()=>{Oe.value=null,cl()},setTimeout(()=>document.addEventListener("click",xt,{once:!0}),0)}const _t=e.ref(!1);function Rr(t,o){if(!o.children){_t.value=!1;return}const a=t.currentTarget.querySelector(".context-submenu");if(!a){_t.value=!1;return}const n=a.getBoundingClientRect();_t.value=n.right>window.innerWidth}function Mr(t,o){t.preventDefault(),t.stopPropagation(),ut(t.clientX,t.clientY,[{label:w(u.value,"insert"),action:()=>{vo(),g()}},{label:w(u.value,"copy"),action:()=>{hr(o)}},{label:w(u.value,"rename"),action:()=>{il(o)}},{label:w(u.value,"delete"),action:()=>{mr(o),g()},disabled:br.value<=1},{label:w(u.value,"moveSheetLeft"),action:()=>{nl(o,-1)},disabled:o===0},{label:w(u.value,"moveSheetRight"),action:()=>{nl(o,1)},disabled:o===P.value.length-1}])}function Ar(t){t.preventDefault(),!(t.target.closest(".tab-item")||t.target.closest(".tab-bar__add-btn"))&&ut(t.clientX,t.clientY,[{label:w(u.value,"insert"),action:()=>{vo(),g()}}])}function Nr(t){t.preventDefault(),O(),g(),ut(t.clientX,t.clientY,[{label:w(u.value,"cut"),action:()=>{ho(),K()}},{label:w(u.value,"copy"),action:()=>Ft()},{label:w(u.value,"paste"),action:()=>{G(),Bt().then(()=>{g(),e.nextTick(K)})}},{label:w(u.value,"delete"),action:()=>{G(),bo();for(let o=0;o<p;o++)M.value[o]=100;for(let o=0;o<s;o++)I.value[o]=void 0;g(),K()}}])}function Ir(t,o){t.preventDefault();const l=t.clientX,a=t.clientY,n=E.value;n&&n.startCol===0&&n.endCol===p-1&&o>=n.startRow&&o<=n.endRow||(J(0,o,p-1,o),g());const i=E.value;ut(t.clientX,t.clientY,[{label:w(u.value,"insert"),action:()=>{G(),cr(i.startRow,i.endRow),g(),K()},disabled:i.endRow>=s-1},{label:w(u.value,"cut"),action:()=>{G(),Vt();for(let c=i.startRow;c<=i.endRow;c++)for(let m=0;m<p;m++)$(D(m,c));g(),K()}},{label:w(u.value,"copy"),action:()=>Vt()},{label:w(u.value,"paste"),action:()=>{G(),Bt().then(()=>{g(),e.nextTick(K)})}},{label:w(u.value,"delete"),action:()=>{G(),sr(i.startRow,i.endRow),g(),K()}},{label:`${w(u.value,"rowHeight")}...`,action:()=>fl("row",l,a)},{label:w(u.value,"autoRowHeight"),action:()=>Wr()}])}function Fr(t,o){t.preventDefault();const l=t.clientX,a=t.clientY,n=E.value;n&&n.startRow===0&&n.endRow===s-1&&o>=n.startCol&&o<=n.endCol||(J(o,0,o,s-1),g());const i=E.value;ut(t.clientX,t.clientY,[{label:w(u.value,"insert"),action:()=>{G(),dr(i.startCol,i.endCol),g(),K()},disabled:i.endCol>=p-1},{label:w(u.value,"cut"),action:()=>{G(),Vt();for(let c=i.startCol;c<=i.endCol;c++)for(let m=0;m<s;m++)$(D(c,m));g(),K()}},{label:w(u.value,"copy"),action:()=>Vt()},{label:w(u.value,"paste"),action:()=>{G(),Bt().then(()=>{g(),e.nextTick(K)})}},{label:w(u.value,"delete"),action:()=>{G(),ur(i.startCol,i.endCol),g(),K()}},{label:`${w(u.value,"colWidth")}...`,action:()=>fl("col",l,a)},{label:w(u.value,"defaultColWidth"),action:()=>zr()}])}function Vr(t,o,l){t.preventDefault(),F(o,l)||(k(o,l),g());const a=E.value,n=!!(a&&a.startCol===a.endCol&&a.startRow===a.endRow);ut(t.clientX,t.clientY,[{label:w(u.value,"cut"),action:()=>{ho(),K()}},{label:w(u.value,"copy"),action:()=>Ft()},{label:w(u.value,"paste"),action:()=>{G(),Bt().then(()=>{g(),e.nextTick(K)})}},{label:w(u.value,"delete"),action:()=>{G(),bo(),g(),K()}},{label:w(u.value,"calculate"),children:[{label:w(u.value,"sum"),action:ir,disabled:n}]}])}const dl=e.ref(null),ce=e.ref(null);let Tt=null;function ul(){Tt&&(document.removeEventListener("mousedown",Tt),Tt=null)}function fl(t,o,l){ul();const a=E.value;let n="";if(a){const T=t==="row"?Ae(a.startRow):M.value[a.startCol];n=T!=null&&T>0?String(Math.round(T)):""}const i=220,c=118;let m=o,h=l;m+i>window.innerWidth&&(m=window.innerWidth-i-8),h+c>window.innerHeight&&(h=window.innerHeight-c-8),m<8&&(m=8),h<8&&(h=8),ce.value={type:t,x:m,y:h,value:n,error:""},Tt=()=>{ce.value=null},setTimeout(()=>document.addEventListener("mousedown",Tt,{once:!0}),0),e.nextTick(()=>{const T=dl.value;T&&(T.focus(),T.select())})}function Or(t){const o=ce.value;if(!o)return;const l=t.target,a=l.value,n=a.replace(/[^\d]/g,"");o.value=n,a!==n&&(l.value=n),o.error=""}function Lr(t){t.key==="Enter"?(t.preventDefault(),ml()):t.key==="Escape"&&Wt()}function _r(){const t=ce.value;if(!t)return;const o=t.value.trim(),l=Number(o),a=t.type==="row",n=a?24:30,i=a?500:1e3;if(o===""||!Number.isFinite(l)){Wt();return}const c=Math.max(n,Math.min(i,Math.round(l)));t.value=String(c),t.error=""}function ml(){const t=ce.value,o=E.value;if(!t||!o)return;const l=t.value.trim(),a=Number(l),n=t.type==="row",i=n?24:30,c=n?500:1e3;if(l===""||!Number.isFinite(a)){t.error=w(u.value,"dimNumberError");return}if(a<i||a>c){t.error=w(u.value,"dimRangeError").replace("{min}",String(i)).replace("{max}",String(c));return}const m=a;if(G(),n)for(let h=o.startRow;h<=o.endRow;h++)I.value[h]=m;else for(let h=o.startCol;h<=o.endCol;h++)M.value[h]=m;g(),K(),Wt()}function Wt(){ul(),ce.value=null}function Wr(){const t=E.value;if(t){G();for(let o=t.startRow;o<=t.endRow;o++)I.value[o]=void 0;g(),K()}}function zr(){const t=E.value;if(t){G();for(let o=t.startCol;o<=t.endCol;o++)M.value[o]=100;g(),K()}}const $r=e.computed(()=>{var x;const t=!S.value,o=S.value??y.value,l=o.col,a=o.row,n=(x=b[D(l,a)])==null?void 0:x.style,i=Me(l,a),c=typeof(n==null?void 0:n.fontFamily)=="string"&&n.fontFamily?n.fontFamily:ro,m=(n==null?void 0:n.fontWeight)==="bold"?"bold":"normal",h=(n==null?void 0:n.fontStyle)==="italic"?"italic":"normal",T=(n==null?void 0:n.underline)==="underline"?"underline":(n==null?void 0:n.strikethrough)==="line-through"?"line-through":"none",oe=(n==null?void 0:n.underline)==="underline"&&(n==null?void 0:n.strikethrough)==="line-through"?"underline line-through":T,ee=typeof(n==null?void 0:n.color)=="string"?n.color:void 0,te=typeof(n==null?void 0:n.backgroundColor)=="string"?n.backgroundColor:void 0,U=typeof(n==null?void 0:n.textAlign)=="string"?n.textAlign:"left",ae=typeof(n==null?void 0:n.verticalAlign)=="string"?n.verticalAlign:"top",xe=Ae(a),Ue=2,{ascent:ve,descent:Te}=Re(c,i,m,h),Ke=ve+Te,Ne=(V.value?V.value.split(`
|
|
8
|
+
`).length:1)*Ke,tt=_-Ue;let De=0,He=0;return ae==="middle"?(De=Math.floor((xe-Ne)/2),He=Math.max(0,xe-Ne-De)):ae==="top"?(De=tt,He=Math.max(0,xe-Ne-De)):ae==="bottom"&&(He=tt,De=Math.max(0,xe-Ne-He)),{left:`${52+pe.value[l]-C.value}px`,top:`${24+N.value[a]-R.value}px`,width:`${M.value[l]}px`,height:`${xe}px`,fontFamily:c,fontSize:`${i}px`,lineHeight:1,fontWeight:m,fontStyle:h,textDecoration:oe,textAlign:U,paddingTop:`${De}px`,paddingRight:"3px",paddingBottom:`${He}px`,paddingLeft:"3px",opacity:t?0:1,pointerEvents:t?"none":"auto",color:t?"transparent":ee,caretColor:t?"transparent":void 0,borderColor:t?"transparent":void 0,background:t?"transparent":te,boxShadow:t?"none":void 0}}),Gr=e.computed(()=>Math.max(0,re.w-52-11)),Pr=e.computed(()=>Math.max(0,re.h-24-11)),zt=e.computed(()=>Math.max(0,Gr.value-11*2)),$t=e.computed(()=>Math.max(0,Pr.value-11*2));function Eo(){return Math.max(0,re.w-52-11)}function wo(){return Math.max(0,re.h-24-11)}const Gt=e.computed(()=>st.value<=0?zt.value:Math.max(24,Eo()/j.value*zt.value)),Bo=e.computed(()=>st.value<=0?0:C.value/st.value*(zt.value-Gt.value)),Pt=e.computed(()=>ct.value<=0?$t.value:Math.max(24,wo()/d.value*$t.value)),Co=e.computed(()=>ct.value<=0?0:R.value/ct.value*($t.value-Pt.value));let et=null,Ut=0,Kt=0;function Ur(t){t.preventDefault(),et="v",Ut=t.clientY,Kt=R.value,document.addEventListener("mousemove",xo),document.addEventListener("mouseup",To)}function Kr(t){t.preventDefault(),et="h",Ut=t.clientX,Kt=C.value,document.addEventListener("mousemove",xo),document.addEventListener("mouseup",To)}function xo(t){if(et==="v"){const l=(t.clientY-Ut)/($t.value-Pt.value);se(null,Kt+l*ct.value),g()}else if(et==="h"){const l=(t.clientX-Ut)/(zt.value-Gt.value);se(Kt+l*st.value,null),g()}}function To(){et=null,document.removeEventListener("mousemove",xo),document.removeEventListener("mouseup",To)}function Yr(t){if(et)return;const o=t.currentTarget.getBoundingClientRect(),l=t.clientY-o.top;l<Co.value?se(null,R.value-wo()):l>Co.value+Pt.value&&se(null,R.value+wo()),g()}function Xr(t){if(et)return;const o=t.currentTarget.getBoundingClientRect(),l=t.clientX-o.left;l<Bo.value?se(C.value-Eo(),null):l>Bo.value+Gt.value&&se(C.value+Eo(),null),g()}let ft=!1,Be=0,Ce=0,mt=!1,pt=!1,Yt=0,Xt=0,jt=0,Zt=0,Do=0,Ho=0,pl=0,hl=0,Dt=!1,So=!1,ht=0,bt=0,Ro=0,bl=-1,vl=-1;function jr(t){if(t.button!==0)return;t.preventDefault(),Oe.value=null;const o=Xe(t,we.value);if(o.y<24&&o.x>=52){const n=o.x-52+C.value,i=ke(n);if(i>=0&&Math.abs(o.x-(52+pe.value[i+1]-C.value))<=4){G(),mt=!0,Yt=i,jt=M.value[i],Zt=n,g();return}}if(o.x<52&&o.y>=24){const n=o.y-24+R.value,i=Ee(n);if(i>=0&&Math.abs(o.y-(24+N.value[i+1]-R.value))<=4){G(),pt=!0,Xt=i,jt=Ae(i),Zt=n,g();return}}if(o.x<52||o.y<24){if($e(),o.y<24&&o.x>=52){const n=ke(o.x-52+C.value);n>=0&&(J(n,0,n,s-1),ft=!0,Be=n,Ce=0)}else if(o.x<52&&o.y>=24){const n=Ee(o.y-24+R.value);n>=0&&(J(0,n,p-1,n),ft=!0,Be=0,Ce=n)}else o.x<52&&o.y<24&&O();g();return}const l=ke(o.x-52+C.value),a=Ee(o.y-24+R.value);if(!(l<0||a<0)){if($e(),t.shiftKey&&E.value){const n=E.value;J(n.startCol,n.startRow,l,a)}else k(l,a);ft=!0,Be=l,Ce=a,fe(),g()}}function Zr(t){if(mt){const i=Xe(t,we.value).x-52+C.value-Zt,c=jt+i;c>=30&&c<=1e3?M.value[Yt]=c:c<30?M.value[Yt]=30:M.value[Yt]=1e3,g();return}if(pt){const i=Xe(t,we.value).y-24+R.value-Zt,c=jt+i;c>=24&&c<=500?I.value[Xt]=c:c<24?I.value[Xt]=24:I.value[Xt]=500,g();return}if(!ft){const n=we.value;if(!n)return;if(Ze.value){n.style.cursor="copy";return}const i=Xe(t,n);if(i.y<24&&i.x>=52){const c=ke(i.x-52+C.value);if(c>=0&&Math.abs(i.x-(52+pe.value[c+1]-C.value))<=4){n.style.cursor="col-resize";return}}if(i.x<52&&i.y>=24){const c=Ee(i.y-24+R.value);if(c>=0&&Math.abs(i.y-(24+N.value[c+1]-R.value))<=4){n.style.cursor="row-resize";return}}n.style.cursor="cell";return}const o=Xe(t,we.value);if(Be<0||Ce<0)return;if(o.x<52||o.y<24){if(o.y<24&&o.x>=52){const n=ke(o.x-52+C.value);n>=0&&J(Math.min(Be,n),0,Math.max(Be,n),s-1)}else if(o.x<52&&o.y>=24){const n=Ee(o.y-24+R.value);n>=0&&J(0,Math.min(Ce,n),p-1,Math.max(Ce,n))}g();return}const l=ke(o.x-52+C.value),a=Ee(o.y-24+R.value);l<0||a<0||(Ce===0&&Be>=0&&E.value&&E.value.startRow===0&&E.value.endRow===s-1?J(Math.min(Be,l),0,Math.max(Be,l),s-1):Be===0&&Ce>=0&&E.value&&E.value.startCol===0&&E.value.endCol===p-1?J(0,Math.min(Ce,a),p-1,Math.max(Ce,a)):J(Be,Ce,l,a),g())}function qr(t){const o=mt||pt;ft=!1,mt=!1,pt=!1,o&&al(),Ze.value&&Ha()}function Jr(){const t=mt||pt;ft=!1,mt=!1,pt=!1,t&&al()}function Qr(t){t.preventDefault();const o=Xe(t,we.value);if(o.x<52&&o.y<24){Nr(t);return}if(o.y<24&&o.x>=52){const l=ke(o.x-52+C.value);l>=0&&Fr(t,l);return}if(o.x<52&&o.y>=24){const l=Ee(o.y-24+R.value);l>=0&&Ir(t,l);return}if(o.x>=52&&o.y>=24){const l=ke(o.x-52+C.value),a=Ee(o.y-24+R.value);l>=0&&a>=0&&Vr(t,l,a)}}function ei(t){const o=Xe(t,we.value);if(o.x<52||o.y<24)return;const l=ke(o.x-52+C.value),a=Ee(o.y-24+R.value);l<0||a<0||(k(l,a),Q(l,a),ze(),g(),fe())}function ti(t){se(C.value+t.deltaX,R.value+t.deltaY),g()}function oi(t){if(t.touches.length!==1){Dt=!1;return}const o=t.touches[0],l=we.value;if(!l)return;const a=l.getBoundingClientRect(),n=o.clientX-a.left,i=o.clientY-a.top;n>=52&&i>=24&&(t.preventDefault(),Dt=!0,So=!1,Do=n,Ho=i,pl=C.value,hl=R.value,ht=ke(n-52+C.value),bt=Ee(i-24+R.value))}function li(t){if(!Dt||t.touches.length!==1)return;const o=t.touches[0],l=we.value;if(!l)return;const a=l.getBoundingClientRect(),n=o.clientX-a.left,i=o.clientY-a.top;(Math.abs(n-Do)>8||Math.abs(i-Ho)>8)&&(So=!0,t.preventDefault(),se(pl+(Do-n),hl+(Ho-i)),g())}function ni(){if(Dt&&(Dt=!1,!So&&ht>=0&&bt>=0)){const t=Date.now();ht===bl&&bt===vl&&t-Ro<300?(k(ht,bt),ze(),g(),fe(),Ro=0):($e(),k(ht,bt),g(),Ro=t),bl=ht,vl=bt,fe()}}function Mo(t){return t.isComposing||t.key==="Process"||t.keyCode===229}function gl(t){return t.key.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey}function yl(t){if(S.value)return;const o=t.ctrlKey||t.metaKey,l=t.shiftKey;switch(!0){case(o&&(t.key==="c"||t.key==="C")):t.preventDefault(),Ft();return;case(o&&(t.key==="x"||t.key==="X")):t.preventDefault(),ho();return;case(o&&(t.key==="z"||t.key==="Z")):t.preventDefault(),Po();return;case(o&&(t.key==="y"||t.key==="Y")):t.preventDefault(),Uo();return;case(o&&(t.key==="v"||t.key==="V")):t.preventDefault(),G(),Bt().then(()=>{g(),e.nextTick(K)});return;case(o&&(t.key==="a"||t.key==="A")):t.preventDefault(),O(),g();return;case(o&&t.key==="Home"):t.preventDefault(),k(0,0),Q(0,0),g();return;case(o&&t.key==="End"):t.preventDefault(),k(p-1,s-1),Q(p-1,s-1),g();return;case t.key==="Home":t.preventDefault(),k(0,y.value.row),Q(0,y.value.row),g();return;case t.key==="End":t.preventDefault(),k(p-1,y.value.row),Q(p-1,y.value.row),g();return;case t.key==="ArrowUp":t.preventDefault(),Fe(0,-1),Q(y.value.col,y.value.row),g();return;case t.key==="ArrowDown":t.preventDefault(),Fe(0,1),Q(y.value.col,y.value.row),g();return;case t.key==="ArrowLeft":t.preventDefault(),Fe(-1,0),Q(y.value.col,y.value.row),g();return;case t.key==="ArrowRight":t.preventDefault(),Fe(1,0),Q(y.value.col,y.value.row),g();return;case t.key==="Tab":t.preventDefault(),Fe(l?-1:1,0),Q(y.value.col,y.value.row),g();return;case t.key==="Enter":t.preventDefault(),Fe(0,l?-1:1),Q(y.value.col,y.value.row),g();return;case t.key==="F2":t.preventDefault(),Q(y.value.col,y.value.row),ze(),g(),fe();return;case t.key==="Delete":case t.key==="Backspace":t.preventDefault(),G(),bo(),g();return;case t.key==="Escape":t.preventDefault(),je(),Ze.value=null,g();return;case gl(t):if(Mo(t)){Q(y.value.col,y.value.row),ze(""),g(),fe();return}t.preventDefault(),Q(y.value.col,y.value.row),ze(t.key),g(),e.nextTick(()=>{const a=Lt.value;a&&(a.focus(),a.setSelectionRange(1,1))});return}}let Ao=!1,No=!1;function ai(t){const o=t.target.value;if(!S.value){Q(y.value.col,y.value.row),ze(o),g();return}V.value=o}function ri(){Ao=!0,S.value||(Q(y.value.col,y.value.row),ze(""),g())}function ii(t){Ao=!1,No=!0,setTimeout(()=>{No=!1},0),V.value=t.target.value}function si(t){if(!S.value){if(gl(t)||Mo(t))return;yl(t);return}if(!(Ao||Mo(t))&&!(No&&(t.key==="Enter"||t.key==="Escape")))if(t.key==="Enter"&&(t.altKey||t.metaKey)){t.preventDefault();const o=Lt.value;if(!o)return;const l=o.selectionStart??o.value.length,a=o.selectionEnd??o.value.length,n=o.value,i=n.slice(0,l)+`
|
|
9
|
+
`+n.slice(a);V.value=i,o.value=i,o.selectionStart=o.selectionEnd=l+1,g()}else t.key==="Enter"?(t.preventDefault(),$e(),Fe(0,1),Q(y.value.col,y.value.row),g(),fe()):t.key==="Tab"?(t.preventDefault(),$e(),Fe(t.shiftKey?-1:1,0),Q(y.value.col,y.value.row),g(),fe()):t.key==="Escape"&&(t.preventDefault(),je(),g(),fe())}function ci(t){S.value}function di(){setTimeout(()=>{S.value&&($e(),g())},0)}function qt(){var o;const t=(o=Je.value)==null?void 0:o.getBoundingClientRect();if(t){const l=Ye(v.width),a=Ye(v.height);l!=null?re.w=l:re.w=t.width,a!=null?re.h=a:re.h=t.height}se(null,null),g()}let be=null;return e.onMounted(()=>{const t=Ye(v.width),o=Ye(v.height);(t==null||o==null)&&(be=new ResizeObserver(()=>qt()),Je.value&&be.observe(Je.value)),e.nextTick(()=>{qt(),fe()}),k(0,0),B.value&&B.value.length>0&&(H=JSON.stringify(B.value),P.value=B.value.map(l=>{const a=Ot(l.name);for(const[n,i]of Object.entries(l.cells))a.cells[n]={value:i.value,style:i.style??null};if(l.colWidths)for(const[n,i]of Object.entries(l.colWidths)){const c=Number(n);c>=0&&c<p&&i>=30&&(a.colWidths[c]=i)}if(l.rowHeights)for(const[n,i]of Object.entries(l.rowHeights)){const c=Number(n);c>=0&&c<s&&i>=24&&(a.rowHeights[c]=i)}return a}),P.value.length>0&&Pe(0))}),e.watch(()=>[v.width,v.height],()=>{const t=Ye(v.width),o=Ye(v.height);t!=null&&o!=null?(be==null||be.disconnect(),be=null):!be&&Je.value&&(be=new ResizeObserver(()=>qt()),be.observe(Je.value)),e.nextTick(()=>qt())}),e.watch(()=>v.theme,()=>g()),e.watch(()=>({...b}),()=>e.nextTick(K),{deep:!1}),e.watch(ue,()=>e.nextTick(K)),e.watch(()=>B.value,t=>{if(!t||t.length===0)return;const o=JSON.stringify(t);o!==H&&(H=o,P.value=t.map(l=>{const a=Ot(l.name);for(const[n,i]of Object.entries(l.cells))a.cells[n]={value:i.value,style:i.style??null};if(l.colWidths)for(const[n,i]of Object.entries(l.colWidths)){const c=Number(n);c>=0&&c<p&&i>=30&&(a.colWidths[c]=i)}if(l.rowHeights)for(const[n,i]of Object.entries(l.rowHeights)){const c=Number(n);c>=0&&c<s&&i>=24&&(a.rowHeights[c]=i)}return a}),P.value.length>0&&Pe(0),g())},{deep:!0}),e.onBeforeUnmount(()=>{be==null||be.disconnect()}),(t,o)=>(e.openBlock(),e.createElementBlock("div",{class:"spreadsheet-outer",style:e.normalizeStyle(vr.value)},[e.createVNode(Un,{locale:u.value,"can-undo":Ca.value,"can-redo":xa.value,"paint-fmt-active":Ze.value!==null,"has-selection":Ta.value,"font-family-options":Ra.value,"font-size-options":Ma.value,"sel-font-family":Aa.value,"sel-font-size":he.value,"font-size-input":Ge.value,"font-size-menu-open":qe.value,"sel-font-weight":Yo.value,"sel-font-style":Xo.value,"sel-underline":jo.value,"sel-strikethrough":Zo.value,"sel-text-color":lr.value,"text-color-menu-open":fo.value,"sel-fill-color":nr.value,"fill-color-menu-open":mo.value,"cached-text-color":Nt.value,"cached-fill-color":It.value,"border-menu-open":qo.value,"cached-border":po.value,"h-align-options":Fa.value,"v-align-options":Va.value,"sel-h-align":Oa.value,"sel-v-align":La.value,"sel-wrap":Ko.value,onUndo:o[0]||(o[0]=l=>Po()),onRedo:o[1]||(o[1]=l=>Uo()),onPaintFormat:Da,onClearFormat:o[2]||(o[2]=l=>Sa()),onFontFamilyChange:o[3]||(o[3]=l=>Na(l)),onFontSizeInput:o[4]||(o[4]=l=>$a(l)),onFontSizeBlur:Ga,onFontSizeKeydown:o[5]||(o[5]=l=>Pa(l)),onFontSizeChange:o[6]||(o[6]=l=>Ia(l)),"onUpdate:fontSizeMenuOpen":o[7]||(o[7]=l=>qe.value=l),onFontSizeToggle:o[8]||(o[8]=l=>Ua()),onFontSizeStepUp:Ka,onFontSizeStepDown:Ya,onBoldToggle:Xa,onItalicToggle:ja,onUnderlineToggle:Za,onStrikethroughToggle:qa,onTextColorChange:o[9]||(o[9]=l=>Qa(l)),"onUpdate:textColorMenuOpen":o[10]||(o[10]=l=>fo.value=l),onFillColorChange:o[11]||(o[11]=l=>er(l)),"onUpdate:fillColorMenuOpen":o[12]||(o[12]=l=>mo.value=l),onApplyTextColor:tr,onApplyFillColor:or,"onUpdate:borderMenuOpen":o[13]||(o[13]=l=>Ja(l)),onBorderChange:o[14]||(o[14]=l=>Jo(l)),onApplyBorder:rr,onHAlignChange:o[15]||(o[15]=l=>_a(l)),onVAlignChange:o[16]||(o[16]=l=>Wa(l)),onWrapToggle:za},null,8,["locale","can-undo","can-redo","paint-fmt-active","has-selection","font-family-options","font-size-options","sel-font-family","sel-font-size","font-size-input","font-size-menu-open","sel-font-weight","sel-font-style","sel-underline","sel-strikethrough","sel-text-color","text-color-menu-open","sel-fill-color","fill-color-menu-open","cached-text-color","cached-fill-color","border-menu-open","cached-border","h-align-options","v-align-options","sel-h-align","sel-v-align","sel-wrap"]),e.createElementVNode("div",aa,[e.createElementVNode("div",ra,e.toDisplayString(Er.value),1),e.createElementVNode("input",{ref_key:"formulaBarRef",ref:yo,class:"formula-bar__input",value:wr.value,onFocus:Br,onInput:Cr,onKeydown:xr,onBlur:Tr},null,40,ia)]),e.createElementVNode("div",{ref_key:"wrapperRef",ref:Je,class:"spreadsheet-wrapper"},[e.createElementVNode("canvas",{ref_key:"canvasRef",ref:we,class:"grid-canvas",tabindex:"0",onMousedown:jr,onMousemove:Zr,onMouseup:qr,onMouseleave:Jr,onDblclick:ei,onWheel:e.withModifiers(ti,["prevent"]),onFocus:yr,onKeydown:yl,onContextmenu:Qr,onTouchstart:e.withModifiers(oi,["prevent"]),onTouchmove:e.withModifiers(li,["prevent"]),onTouchend:ni},null,544),e.createElementVNode("textarea",{ref_key:"editInputRef",ref:Lt,class:"cell-editor",value:V.value,style:e.normalizeStyle($r.value),onInput:ai,onKeydown:si,onCompositionstart:ri,onCompositionend:ii,onBlur:di,onPaste:ci},null,44,sa),ct.value>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"v-scrollbar",style:e.normalizeStyle({top:e.unref(24)+"px",height:`calc(100% - ${e.unref(24)+e.unref(11)}px)`})},[e.createElementVNode("button",{class:"sb-btn sb-btn--up",title:e.unref(w)(u.value,"scrollUp"),onMousedown:o[17]||(o[17]=e.withModifiers(l=>{se(null,R.value-50),g()},["prevent"]))},[...o[31]||(o[31]=[e.createElementVNode("span",{class:"sb-arrow sb-arrow--up"},null,-1)])],40,ca),e.createElementVNode("div",{class:"sb-track sb-track--v",onMousedown:Yr},[e.createElementVNode("div",{class:"sb-thumb sb-thumb--v",style:e.normalizeStyle({top:Co.value+"px",height:Pt.value+"px"}),onMousedown:Ur},null,36)],32),e.createElementVNode("button",{class:"sb-btn sb-btn--down",title:e.unref(w)(u.value,"scrollDown"),onMousedown:o[18]||(o[18]=e.withModifiers(l=>{se(null,R.value+50),g()},["prevent"]))},[...o[32]||(o[32]=[e.createElementVNode("span",{class:"sb-arrow sb-arrow--down"},null,-1)])],40,da)],4)):e.createCommentVNode("",!0),st.value>0?(e.openBlock(),e.createElementBlock("div",{key:1,class:"h-scrollbar",style:e.normalizeStyle({left:e.unref(52)+"px",width:`calc(100% - ${e.unref(52)+e.unref(11)}px)`})},[e.createElementVNode("button",{class:"sb-btn sb-btn--left",title:e.unref(w)(u.value,"scrollLeft"),onMousedown:o[19]||(o[19]=e.withModifiers(l=>{se(C.value-50,null),g()},["prevent"]))},[...o[33]||(o[33]=[e.createElementVNode("span",{class:"sb-arrow sb-arrow--left"},null,-1)])],40,ua),e.createElementVNode("div",{class:"sb-track sb-track--h",onMousedown:Xr},[e.createElementVNode("div",{class:"sb-thumb sb-thumb--h",style:e.normalizeStyle({left:Bo.value+"px",width:Gt.value+"px"}),onMousedown:Kr},null,36)],32),e.createElementVNode("button",{class:"sb-btn sb-btn--right",title:e.unref(w)(u.value,"scrollRight"),onMousedown:o[20]||(o[20]=e.withModifiers(l=>{se(C.value+50,null),g()},["prevent"]))},[...o[34]||(o[34]=[e.createElementVNode("span",{class:"sb-arrow sb-arrow--right"},null,-1)])],40,fa)],4)):e.createCommentVNode("",!0),st.value>0&&ct.value>0?(e.openBlock(),e.createElementBlock("div",ma)):e.createCommentVNode("",!0)],512),e.createVNode(qn,{locale:u.value,sheets:P.value,"active-sheet-index":ue.value,"ren-tab":Qe.value,"ren-tab-val":dt.value,onTabClick:o[21]||(o[21]=l=>Dr(l)),onTabDblclick:o[22]||(o[22]=l=>il(l)),onTabContextmenu:o[23]||(o[23]=l=>Mr(l.ev,l.i)),onTabRenameInput:o[24]||(o[24]=l=>dt.value=l),onTabRenameKeydown:o[25]||(o[25]=l=>Sr(l)),onTabRenameCommit:sl,onTabbarContextmenu:o[26]||(o[26]=l=>Ar(l)),onAddSheet:o[27]||(o[27]=l=>{vo(),g()})},null,8,["locale","sheets","active-sheet-index","ren-tab","ren-tab-val"]),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"menu-pop"},{default:e.withCtx(()=>[Oe.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"context-menu",style:e.normalizeStyle({left:Oe.value.x+"px",top:Oe.value.y+"px"}),onClick:o[28]||(o[28]=e.withModifiers(()=>{},["stop"]))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Oe.value.items,(l,a)=>(e.openBlock(),e.createElementBlock("div",{key:a,class:e.normalizeClass(["context-menu__item",{"context-menu__item--disabled":l.disabled}]),onClick:n=>!l.disabled&&l.action&&(l.action(),Oe.value=null),onMouseenter:n=>Rr(n,l)},[e.createElementVNode("span",ha,e.toDisplayString(l.label),1),l.children?(e.openBlock(),e.createElementBlock("span",ba)):e.createCommentVNode("",!0),l.children?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["context-submenu",{"context-submenu--left":_t.value}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.children,(n,i)=>(e.openBlock(),e.createElementBlock("div",{key:i,class:e.normalizeClass(["context-menu__item",{"context-menu__item--disabled":n.disabled}]),onClick:e.withModifiers(c=>!n.disabled&&n.action&&(n.action(),Oe.value=null),["stop"])},e.toDisplayString(n.label),11,va))),128))],2)):e.createCommentVNode("",!0)],42,pa))),128))],4)):e.createCommentVNode("",!0)]),_:1})])),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"menu-pop"},{default:e.withCtx(()=>[ce.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"dim-panel",style:e.normalizeStyle({left:ce.value.x+"px",top:ce.value.y+"px"}),onMousedown:o[29]||(o[29]=e.withModifiers(()=>{},["stop"])),onClick:o[30]||(o[30]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",ga,e.toDisplayString(ce.value.type==="row"?e.unref(w)(u.value,"rowHeight"):e.unref(w)(u.value,"colWidth")),1),e.createElementVNode("div",ya,[e.createElementVNode("input",{ref_key:"dimInputRef",ref:dl,class:e.normalizeClass(["dim-panel__input",{"dim-panel__input--error":ce.value.error}]),type:"number",step:"1",min:"1",inputmode:"numeric",value:ce.value.value,onInput:Or,onKeydown:Lr,onBlur:_r},null,42,ka),o[35]||(o[35]=e.createElementVNode("span",{class:"dim-panel__unit"},"px",-1))]),ce.value.error?(e.openBlock(),e.createElementBlock("div",Ea,e.toDisplayString(ce.value.error),1)):e.createCommentVNode("",!0),e.createElementVNode("div",wa,[e.createElementVNode("button",{class:"dim-panel__btn dim-panel__btn--primary",onClick:ml},e.toDisplayString(e.unref(w)(u.value,"ok")),1),e.createElementVNode("button",{class:"dim-panel__btn",onClick:Wt},e.toDisplayString(e.unref(w)(u.value,"cancel")),1)])],36)):e.createCommentVNode("",!0)]),_:1})]))],4))}}),[["__scopeId","data-v-c6748ebf"]]);Le.Spreader=Wo,Le.default=Wo,Object.defineProperties(Le,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|