@univerjs/core 0.6.0-alpha.0 → 0.6.0-nightly.202501251605
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/lib/cjs/index.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +1 -1
- package/LICENSE +0 -176
package/lib/cjs/index.js
CHANGED
|
@@ -9,4 +9,4 @@ For more info please visit our website: https://redi.wendell.fun/en-US/docs/debu
|
|
|
9
9
|
`,e.TABLE_START="",e.TABLE_ROW_START="\x1B",e.TABLE_CELL_START="",e.TABLE_CELL_END="",e.TABLE_ROW_END="",e.TABLE_END="",e.CUSTOM_RANGE_START="",e.CUSTOM_RANGE_END="",e.COLUMN_BREAK="\v",e.PAGE_BREAK="\f",e.DOCS_END="\0",e.TAB=" ",e.CUSTOM_BLOCK="\b",e.LETTER="",e.SPACE=" ",e))(qt||{});function JE(e){return`${e}`}const qE=[qt.TABLE_START,qt.TABLE_ROW_START,qt.TABLE_CELL_START,qt.TABLE_CELL_END,qt.TABLE_ROW_END,qt.TABLE_END],vc=e=>{const t=e.endsWith(`\r
|
|
10
10
|
`)?e.slice(0,-2):e;return qE.reduce((n,r)=>n.replaceAll(r,""),t)},ZE=e=>e?vc(e).replaceAll("\r","")==="":!0,eC=e=>{const t=e.replace(/\n/g,"\r"),n=[],r=[];let s=0,i="";const o=(l,u=!0)=>{const h=t.slice(s,l);if(re.isLegalUrl(h)){const c=zt(),d=`${h}`,f={startIndex:s,endIndex:s+d.length-1,rangeId:c,rangeType:on.HYPERLINK,properties:{url:e}};r.push(f),i+=d,s=l+1,u&&(i+="\r",n.push({startIndex:l}))}else i+=t.slice(s,l+1),s=l+1,u&&n.push({startIndex:l})};let a=0;for(let l=0;l<t.length;l++)t[l]==="\r"&&(o(l),a=l);return(a!==t.length-1||t.length===1)&&o(t.length,!1),{dataStream:i,paragraphs:n,customRanges:r}};function tC(e,t){if(typeof t>"u")return{startOffset:e,endOffset:e,collapsed:!0};if(t<e)throw new Error(`Cannot make a doc selection when endOffset ${t} is less than startOffset ${e}.`);return{startOffset:e,endOffset:t,collapsed:e===t}}function nC(e){const{startOffset:t,endOffset:n,collapsed:r}=e,s=Math.min(t,n),i=Math.max(t,n);return{startOffset:s,endOffset:i,collapsed:r}}function rC(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}class st{}C(st,"customRange",{add:kE,delete:FE,copyCustomRange:LE,getCustomRangesInterestsWithSelection:xE,isIntersecting:Ec}),C(st,"customDecoration",{add:ME,delete:DE}),C(st,"selection",{replace:BE,makeSelection:tC,normalizeSelection:nC,delete:Rc,replaceTextRuns:HE,retain:$E}),C(st,"range",{isIntersects:rC}),C(st,"transform",{getPlainText:vc,fromPlainText:eC,isEmptyDocument:ZE}),C(st,"paragraph",{bullet:{set:KE,switch:VE,toggleChecklist:GE,changeNestLevel:QE}}),C(st,"drawing",{add:YE});function sC(e){if(e.customRanges||(e.customRanges=[]),!e.paragraphs){e.paragraphs=[];for(let t=0;t<e.dataStream.length;t++)e.dataStream[t]==="\r"&&e.paragraphs.push({startIndex:t})}return e.customBlocks||(e.customBlocks=[]),e.textRuns||(e.textRuns=[]),e.customDecorations||(e.customDecorations=[]),e.sectionBreaks||(e.sectionBreaks=[]),e.tables||(e.tables=[]),e}function yc(e){var t;return e.body=sC((t=e.body)!=null?t:{dataStream:""}),e.drawingsOrder||(e.drawingsOrder=[]),e.drawings||(e.drawings={}),e.documentStyle||(e.documentStyle={}),e}class Vn{constructor(t={}){C(this,"_style");this._style=t}static create(t={}){return new Vn(t)}get fontFamily(){return this._style.ff}get fontSize(){return this._style.fs}get italic(){return this._style.it===Se.TRUE}get bold(){return this._style.bl===Se.TRUE}get underline(){return this._style.ul&&jt.create(this._style.ul)}get bottomBorderLine(){return this._style.bbl&&jt.create(this._style.bbl)}get strikethrough(){return this._style.st&&jt.create(this._style.st)}get overline(){return this._style.ol&&jt.create(this._style.ol)}get background(){return this._style.bg}get border(){return this._style.bd}get color(){return this._style.cl}get verticalAlign(){return this._style.va}get numberFormat(){return this._style.n}copy(){return Wt.create(re.deepClone(this._style))}getValue(){return{...this._style}}}class Wt extends Vn{static create(t={}){return new Wt(t)}constructor(t={}){super(t)}setFontFamily(t){return this._style.ff=t,this}setFontSize(t){return this._style.fs=t,this}setItalic(t){return this._style.it=t?1:0,this}setBold(t){return this._style.bl=t?1:0,this}setUnderline(t){return this._style.ul=t.build(),this}setBottomBorderLine(t){return this._style.bbl=t.build(),this}setStrikethrough(t){return this._style.st=t.build(),this}setOverline(t){return this._style.ol=t.build(),this}setBackground(t){return this._style.bg=t,this}setBorder(t){return this._style.bd=t,this}setColor(t){return this._style.cl=t,this}setVerticalAlign(t){return this._style.va=t,this}copy(){return Wt.create(re.deepClone(this._style))}build(){return this.getValue()}}class jt{constructor(t={s:1}){C(this,"_decoration");this._decoration=t}static create(t={s:1}){return new jt(t)}get show(){return this._decoration.s===Se.TRUE}get followFontColor(){return this._decoration.c===Se.TRUE}get color(){return this._decoration.cl}get type(){return this._decoration.t}setShow(t){return this._decoration.s=t?1:0,this}setFollowFontColor(t){return this._decoration.c=t?1:0,this}setColor(t){return this._decoration.cl=t,this}setLineType(t){return this._decoration.t=t,this}copy(){return jt.create(re.deepClone(this._decoration))}build(){return{...this._decoration}}}class Gn{constructor(t={}){C(this,"_style");this._style=t}static create(t={}){return new Gn(t)}get indentFirstLine(){return this._style.indentFirstLine}get hanging(){return this._style.hanging}get indentStart(){return this._style.indentStart}get tabStops(){return this._style.tabStops}get indentEnd(){return this._style.indentEnd}get textStyle(){return this._style.textStyle}get headingId(){return this._style.headingId}get namedStyleType(){return this._style.namedStyleType}get horizontalAlign(){return this._style.horizontalAlign}get lineSpacing(){return this._style.lineSpacing}get direction(){return this._style.direction}get spacingRule(){return this._style.spacingRule}get snapToGrid(){return this._style.snapToGrid}get spaceAbove(){return this._style.spaceAbove}get spaceBelow(){return this._style.spaceBelow}get borderBetween(){return this._style.borderBetween}get borderTop(){return this._style.borderTop}get borderBottom(){return this._style.borderBottom}get borderLeft(){return this._style.borderLeft}get borderRight(){return this._style.borderRight}get keepLines(){return this._style.keepLines===Se.TRUE}get keepNext(){return this._style.keepNext===Se.TRUE}get wordWrap(){return this._style.wordWrap===Se.TRUE}get widowControl(){return this._style.widowControl===Se.TRUE}get shading(){return this._style.shading}get suppressHyphenation(){return this._style.suppressHyphenation===Se.TRUE}copy(){return kn.create(re.deepClone(this._style))}getValue(){return this._style}}class kn extends Gn{static create(t={}){return new kn(t)}constructor(t={}){super(t)}setIndentFirstLine(t){return this._style.indentFirstLine=t,this}setHanging(t){return this._style.hanging=t,this}setIndentStart(t){return this._style.indentStart=t,this}setTabStops(t){return this._style.tabStops=t,this}setIndentEnd(t){return this._style.indentEnd=t,this}setTextStyle(t){return this._style.textStyle=t,this}setHeadingId(t){return this._style.headingId=t,this}setNamedStyleType(t){return this._style.namedStyleType=t,this}setHorizontalAlign(t){return this._style.horizontalAlign=t,this}setLineSpacing(t){return this._style.lineSpacing=t,this}setDirection(t){return this._style.direction=t,this}setSpacingRule(t){return this._style.spacingRule=t,this}setSnapToGrid(t){return this._style.snapToGrid=t?1:0,this}setSpaceAbove(t){return this._style.spaceAbove=t,this}setSpaceBelow(t){return this._style.spaceBelow=t,this}setBorderBetween(t){return this._style.borderBetween=t,this}setBorderTop(t){return this._style.borderTop=t,this}setBorderBottom(t){return this._style.borderBottom=t,this}setBorderLeft(t){return this._style.borderLeft=t,this}setBorderRight(t){return this._style.borderRight=t,this}setKeepLines(t){return this._style.keepLines=t?1:0,this}setKeepNext(t){return this._style.keepNext=t?1:0,this}setWordWrap(t){return this._style.wordWrap=t?1:0,this}setWidowControl(t){return this._style.widowControl=t?1:0,this}setShading(t){return this._style.shading=t,this}setSuppressHyphenation(t){return this._style.suppressHyphenation=t?1:0,this}copy(){return kn.create(re.deepClone(this._style))}build(){return this.getValue()}}class Ht{constructor(t){C(this,"_data");if(!t.body)throw new Error("Invalid document data, body is required");this._data=yc(t)}static create(t){return new Ht(t)}static createByBody(t){return new Ht({body:t,id:"d",documentStyle:{}})}copy(){return sn.create(re.deepClone(this._data))}slice(t,n){const{body:r,...s}=this._data;return sn.create({...re.deepClone(s),body:Tt(r,t,n)})}toPlainText(){var t,n;return st.transform.getPlainText((n=(t=this._data.body)==null?void 0:t.dataStream)!=null?n:"").replaceAll("\r",`
|
|
11
11
|
`)}getParagraphStyle(){var t,n;return Gn.create((n=(t=this._data.body)==null?void 0:t.paragraphs)==null?void 0:n[0].paragraphStyle)}getParagraphBullet(){var t,n;return(n=(t=this._data.body)==null?void 0:t.paragraphs)==null?void 0:n[0].bullet}getParagraphs(){var r,s;const t=(s=(r=this._data.body)==null?void 0:r.paragraphs)!=null?s:[];let n=0;return t.map(i=>{const o=this.slice(n,i.startIndex);return n=i.startIndex,o})}getTextRuns(){var t,n;return((n=(t=this._data.body)==null?void 0:t.textRuns)!=null?n:[]).map(r=>({...r,ts:r.ts?Vn.create(r.ts):null}))}getLinks(){var t,n,r;return(r=(n=(t=this._data.body)==null?void 0:t.customRanges)==null?void 0:n.filter(s=>s.rangeType===on.HYPERLINK))!=null?r:[]}getData(){return this._data}}class sn extends Ht{constructor(n){super(n);C(this,"_doc");this._doc=new Ft(n)}static newEmptyData(){return yc({id:"d",documentStyle:{},drawings:{},drawingsOrder:[],body:{dataStream:`\r
|
|
12
|
-
`,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(n){return new sn(n!=null?n:sn.newEmptyData())}insertText(n,r,s){var h,c;let i=((c=(h=this._data.body)==null?void 0:h.dataStream.length)!=null?c:2)-2,o,a;if(typeof n=="string"?o=n:(i=Math.min(n,i),o=r),typeof r=="object"?a=r instanceof Wt?r.build():r:a=s instanceof Wt?s.build():s,!o)return this;const l={dataStream:o,textRuns:a?[{ts:a,st:i,ed:i+o.length}]:[]},u=st.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:l});if(!u)throw new Error("Insert text failed, please check.");return ze.apply(this._doc.getBody(),u.serialize()),this}insertRichText(n,r){var a,l;let s=((l=(a=this._data.body)==null?void 0:a.dataStream.length)!=null?l:2)-2,i;typeof n=="object"?i=n instanceof Ht?n.getData():n:(s=Math.min(n,s),i=r instanceof Ht?r.getData():r);const o=st.selection.replace({doc:this._doc,selection:{startOffset:s,endOffset:s,collapsed:!0},body:i.body});if(!o)throw new Error("Insert text failed, please check.");return ze.apply(this._doc.getBody(),o.serialize()),this}delete(n,r){if(r!==void 0){if(!r)return this;const s=st.selection.delete([{startOffset:n,endOffset:n+r,collapsed:!0}],this._data.body);ze.apply(this._doc.getBody(),s)}return this}setStyle(n,r,s){const i={dataStream:"",textRuns:[{ts:s instanceof Wt?s.build():s,st:0,ed:r-n}]},o=st.selection.retain([{startOffset:n,endOffset:r,collapsed:!0}],i);return ze.apply(this._doc.getBody(),o),this}setLink(n,r,s){const i=st.customRange.add({rangeType:on.HYPERLINK,rangeId:zt(),properties:{url:s},ranges:[{startOffset:n,endOffset:r,collapsed:!1}],body:this._data.body});if(!i)throw new Error("Insert text failed, please check.");return ze.apply(this._doc.getBody(),i.serialize()),this}cancelLink(n,r){if(typeof n=="string"){const s=st.customRange.delete({rangeId:n,documentDataModel:this._doc});if(!s)throw new Error("Insert text failed, please check.");ze.apply(this._doc.getBody(),s.serialize())}else this.slice(n,r).getLinks().forEach(i=>{const o=st.customRange.delete({rangeId:i.rangeId,documentDataModel:this._doc});if(!o)throw new Error("Insert text failed, please check.");ze.apply(this._doc.getBody(),o.serialize())});return this}updateLink(n,r){var i,o;const s=(o=(i=this._data.body)==null?void 0:i.customRanges)==null?void 0:o.find(a=>a.rangeId===n);if(!s)throw new Error("Link not found");return s.properties.url=r,this}insertParagraph(n,r){var o,a;let s,i;return typeof n=="object"?(s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:n.build()}]},i=((a=(o=this._data.body)==null?void 0:o.dataStream.length)!=null?a:2)-2):(i=n,s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:r==null?void 0:r.build()}]}),this.insertRichText(i,Ht.create({body:s,id:"d",documentStyle:{}})),this}insertLink(n,r,s){let i="",o="";typeof n=="string"?(i=n,o=r):(i=r,o=s);const a=sn.createByBody({dataStream:i,customRanges:[{rangeType:on.HYPERLINK,rangeId:zt(),properties:{url:o},startIndex:0,endIndex:i.length-1}]});return typeof n=="number"?this.insertRichText(n,a):this.insertRichText(a)}}function iC(e,t=16){let n=0,r=null;return function(...i){const o=Date.now();o-n<t?(r&&clearTimeout(r),r=setTimeout(()=>{n=o,e.apply(this,i)},t)):(n=o,e.apply(this,i))}}var An=(e=>(e[e.Style=1]="Style",e[e.Value=2]="Value",e))(An||{});function oC(e){return`sheet_interceptor_${e}`}const Sc=e=>function(t,n){let r=-1,s=t;for(let i=0;i<=e.length;i++){if(i<=r)throw new Error("[SheetInterceptorService]: next() called multiple times!");if(r=i,i===e.length)return s;const o=e[i];let a=!1;if(s=o.handler(s,n,l=>(a=!0,l)),!a)break}return s};class aC{constructor(t){C(this,"_interceptorsByName",new Map);C(this,"_interceptorPoints");this._interceptorPoints=t}fetchThroughInterceptors(t,n){const r=t;let s=this._interceptorsByName.get(r);return n&&(s=s.filter(n)),Sc(s||[])}intercept(t,n){const r=t;this._interceptorsByName.has(r)||this._interceptorsByName.set(r,[]);const s=this._interceptorsByName.get(r);return s.push(n),this._interceptorsByName.set(r,s.sort((i,o)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)})),()=>mr(this._interceptorsByName.get(r),n)}getInterceptPoints(){return this._interceptorPoints}dispose(){this._interceptorsByName.clear()}}function lC(e){return`sheet_async_interceptor_${e}`}const uC=e=>async function(t,n){let r=-1,s=t;for(let i=0;i<=e.length;i++){if(i<=r)throw new Error("[SheetInterceptorService]: next() called multiple times!");if(r=i,i===e.length)return s;const o=e[i];let a=!1;if(s=await o.handler(s,n,async l=>(a=!0,l)),!a)break}return s};class cC{constructor(t){C(this,"_asyncInterceptorsByName",new Map);C(this,"_asyncInterceptorPoints");this._asyncInterceptorPoints=t}fetchThroughAsyncInterceptors(t,n){const r=t;let s=this._asyncInterceptorsByName.get(r);return n&&(s=s.filter(n)),uC(s||[])}async interceptAsync(t,n){const r=t;this._asyncInterceptorsByName.has(r)||this._asyncInterceptorsByName.set(r,[]);const s=this._asyncInterceptorsByName.get(r);return s.push(n),this._asyncInterceptorsByName.set(r,s.sort((i,o)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)})),()=>mr(this._asyncInterceptorsByName.get(r),n)}getInterceptPoints(){return this._asyncInterceptorPoints}dispose(){this._asyncInterceptorsByName.clear()}}function hC(e,t){for(const n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}class Os extends nt{static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(n=>{n!=="constructor"&&(this.prototype[n]=t.prototype[n])}),Object.getOwnPropertyNames(t).forEach(n=>{n!=="prototype"&&n!=="name"&&n!=="length"&&(this[n]=t[n])})}}const $s=Symbol("initializers");class go extends nt{constructor(t){super(),this._injector=t;const n=this,r=Object.getPrototypeOf(this)[$s];r&&r.forEach(function(s){s.apply(n,[t])})}_initialize(t){}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(n=>{if(n==="_initialize"){let r=this.prototype[$s];r||(r=[],this.prototype[$s]=r),r.push(t.prototype._initialize)}else n!=="constructor"&&(this.prototype[n]=t.prototype[n])}),Object.getOwnPropertyNames(t).forEach(n=>{n!=="prototype"&&n!=="name"&&n!=="length"&&(this[n]=t[n])})}}class bs{constructor(){C(this,"_data",[])}static create(){return new bs}add(t){this._data.indexOf(t)>-1||this._data.push(t)}delete(t){const n=this._data.indexOf(t);this._data.splice(n,1)}getData(){return this._data}}class po{constructor(){C(this,"_data",new Map)}static create(){return new po}add(t,n){this._data.has(t)||this._data.set(t,n)}delete(t){this._data.delete(t)}getData(){return this._data}}const dC="0.6.0-alpha.0";function fC(e="",t=zn.ZH_CN,n=""){return{id:e,sheetOrder:[],name:n,appVersion:dC,locale:t,styles:{},sheets:{},resources:[]}}class Oc{constructor(t={}){C(this,"_styles");C(this,"_cacheMap",new fr(1e5));this._styles=t,this._generateCacheMap()}each(t){return Object.entries(this._styles).forEach(t),this}search(t,n){if(this._cacheMap.has(n))return this._cacheMap.get(n);const r=this._getExistingStyleId(t);return r||"-1"}get(t){return typeof t!="string"?t:(t=String(t),this._styles[t])}add(t,n){const r=re.generateRandomId(6);return this._styles[r]=t,this._cacheMap.set(n,r),r}setValue(t){if(t==null)return;const n=JSON.stringify(t),r=this.search(t,n);return r!=="-1"?r:this.add(t,n)}toJSON(){return this._styles}getStyleByCell(t){let n;t&&re.isObject(t.s)?n=t.s:n=(t==null?void 0:t.s)&&this.get(t.s);const r=t==null?void 0:t.interceptorStyle;return r?{...n,...r}:n}_generateCacheMap(){const{_styles:t,_cacheMap:n}=this;for(const r in t){const s=JSON.stringify(t[r]);n.set(s,r)}}_getExistingStyleId(t){const{_styles:n}=this;for(const r in n)if(re.diffValue(n[r],t))return r;return null}}const gC=(e,t)=>t.length===e.length&&!e.some(n=>t.some(r=>!Yt.equals(r,n))),pC=(e,t)=>t.length===e.length&&e.every((n,r)=>{const s=t[r];return s.unitId===n.unitId&&s.sheetId===n.sheetId&&Yt.equals(n.range,s.range)}),mi={t:0,b:2,l:2,r:2},mC=e=>({sbr:.6,sbo:e,spr:.6,spo:e}),Pa=90;function tr(e,t,n={}){const r=e.length,{textRotation:s,paddingData:i,horizontalAlign:o=Bt.UNSPECIFIED,verticalAlign:a=tn.UNSPECIFIED,wrapStrategy:l=_n.UNSPECIFIED,cellValueType:u}=n,{t:h,r:c,b:d,l:f}=i||mi,{vertexAngle:E,centerAngle:R}=Ac(s),O={id:"d",body:{dataStream:`${e}${_l}`,textRuns:[{ts:t,st:0,ed:r}],paragraphs:[{startIndex:r,paragraphStyle:{horizontalAlign:o}}],sectionBreaks:[{startIndex:r+1}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},marginTop:h,marginBottom:d,marginRight:c,marginLeft:f,renderConfig:{horizontalAlign:o,verticalAlign:a,centerAngle:R,vertexAngle:E,wrapStrategy:l,cellValueType:u,zeroWidthParagraphBreak:1}},drawings:{},drawingsOrder:[]};return new Ft(O)}function _C(e){if(!e)return{};const{tr:t,td:n,ht:r,vt:s,tb:i,pd:o}=e;return{textRotation:t,textDirection:n,horizontalAlign:r,verticalAlign:s,wrapStrategy:i,paddingData:o}}function Fa(e){if(!e)return{};const{ff:t,fs:n,it:r,bl:s,ul:i,st:o,ol:a,cl:l}=e,u={};return t&&(u.ff=t),n&&(u.fs=n),r&&(u.it=r),s&&(u.bl=s),i&&(u.ul=i),o&&(u.st=o),a&&(u.ol=a),l&&(u.cl=l),u}function bc(e,t,n){var i;const r=e.getBody();if((i=r.customRanges)!=null&&i.some(o=>o.rangeType===on.HYPERLINK))return;const s=st.customRange.add({ranges:[{startOffset:0,endOffset:r.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:on.HYPERLINK,body:r,properties:{url:t,refId:n}});s&&ze.apply(r,s.serialize())}function wc(e){return e!=null}const EC='"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';function ka(e){const t=ht.ff,n=ht.fs;if(!e){const c=`${n}pt ${t}`;return{fontCache:c,fontString:c,fontSize:n,originFontSize:n,fontFamily:t}}let r=wn.ITALIC;(e.it===0||e.it===void 0)&&(r=wn.NORMAL);let s=wn.BOLD;(e.bl===0||e.bl===void 0)&&(s=wn.NORMAL);let i=n;e.fs&&(i=Math.ceil(e.fs));let o=t;if(e.ff){let c=e.ff;c=c.replace(/"/g,"").replace(/'/g,""),c.indexOf(" ")>-1&&(c=`"${c}"`),c==null&&(c=t),o=c}const{va:a}=e;let l=i;if(a===Pt.SUBSCRIPT||a===Pt.SUPERSCRIPT){const c=CC(o,l),{sbr:d,spr:f}=c;l*=a===Pt.SUBSCRIPT?d:f}const u=`${r} ${s} ${l}pt ${o}`,h=`${u}, ${EC} `;return{fontCache:u,fontString:h,fontSize:l,originFontSize:i,fontFamily:o}}function CC(e,t){return mC(t)}function Ac(e){const{a:t=0,v:n=Se.FALSE}=e||{a:0,v:Se.FALSE};let r=0,s=t;return n===Se.TRUE&&(r=Pa,s=Pa),{centerAngle:r,vertexAngle:s}}class RC{constructor(t,n){C(this,"_columnData",{});this._config=t,this._columnData=n}getColumnData(){return this._columnData}getColVisible(t){const{_columnData:n}=this,r=n[t];return r?r.hd!==Se.TRUE:!0}getColumnStyle(t){var n;return(n=this._columnData[t])==null?void 0:n.s}setColumnStyle(t,n){const r=this.getColumnOrCreate(t);r.s=n}getHiddenCols(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getColVisible(o);s&&a?(s=!1,r.push({rangeType:xe.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:xe.COLUMN}),r}getVisibleCols(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getColVisible(o);s&&!a?(s=!1,r.push({rangeType:xe.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:xe.COLUMN}),r}getColumnDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getColumnOrCreate(i);r[s]=o,s++}return r}getSize(){return rn(this._columnData)}getColumnWidth(t){const{_columnData:n}=this,r=this._config;let s=0;return s=(n[t]||{hd:Se.FALSE,w:r.defaultColumnWidth}).w||r.defaultColumnWidth,s}getColumn(t){const n=this._columnData[t];if(n)return n}removeColumn(t){delete this._columnData[t]}getColumnOrCreate(t){const{_columnData:n}=this,r=n[t];if(r)return r;const s={};return this._columnData[t]=s,s}setCustomMetadata(t,n){const r=this.getColumn(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getColumn(t))==null?void 0:n.custom}}class IC{constructor(t,n,r){C(this,"_rowData");this._config=t,this._viewModel=n,this._rowData=r}getRowData(){return this._rowData}getRowStyle(t){var n;return(n=this._rowData[t])==null?void 0:n.s}setRowStyle(t,n){const r=this.getRowOrCreate(t);r.s=n}getRowDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getRowOrCreate(i);r[s]=o,s++}return r}getRowHeight(t,n=1){const{_rowData:r}=this,s=this._config;let i=0;for(let o=0;o<n;o++){const a=r[o+t]||{hd:Se.FALSE,h:s.defaultRowHeight},{ia:l,ah:u,h=s.defaultRowHeight}=a;i+=(l==null||l===Se.TRUE)&&typeof u=="number"?u:h}return i}getRow(t){return this._rowData[t]}removeRow(t){delete this._rowData[t]}getRowOrCreate(t){const{_rowData:n}=this,r=n[t];if(r)return r;const s={};return n[t]=s,s}getHiddenRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:xe.ROW})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:xe.ROW}),r}getVisibleRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&!a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:xe.ROW})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:xe.ROW}),r}getRowRawVisible(t){const n=this.getRow(t);return n?n.hd!==Se.TRUE:!0}getSize(){return rn(this._rowData)}setCustomMetadata(t,n){const r=this.getRow(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getRow(t))==null?void 0:n.custom}}const vC="DEFAULT_WORKSHEET_ROW_COUNT",Tc=1e3,yC="DEFAULT_WORKSHEET_COLUMN_COUNT",Nc=20,SC="DEFAULT_WORKSHEET_ROW_HEIGHT",Mc=24,OC="DEFAULT_WORKSHEET_COLUMN_WIDTH",Dc=88,bC="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",xc=46,wC="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Lc=20;function Uc(e){const t={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:Se.FALSE,rowCount:Tc,columnCount:Nc,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Dc,defaultRowHeight:Mc,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:Se.TRUE,rowHeader:{width:xc,hidden:Se.FALSE},columnHeader:{height:Lc,hidden:Se.FALSE},rightToLeft:Se.FALSE};return Object.keys(t).forEach(n=>{const r=n;typeof e[r]>"u"&&(e[r]=t[r])}),e}class AC extends nt{constructor(n){super();C(this,"_cellCache",new Map);C(this,"_rowCache",new Map);C(this,"_columnCache",new Map);C(this,"_hasRow",!1);C(this,"_hasColumn",!1);C(this,"_hasAll",!1);C(this,"_allIndex",-1);C(this,"_mergeData");C(this,"_rangeMap",new fr(5e4));C(this,"_skeletonCache",new fr(5e4));this._init(n.concat())}_init(n){this._mergeData=n,this._createCache(n)}_clearCache(){this._cellCache.clear(),this._rowCache.clear(),this._columnCache.clear(),this._hasAll=!1,this._allIndex=-1,this._rangeMap.clear(),this._skeletonCache.clear(),this._hasColumn=!1,this._hasRow=!1}_createCache(n){let r=0;for(const s of n){const{rangeType:i}=s;i===xe.ROW?this._createRowCache(s,r):i===xe.COLUMN?this._createColumnCache(s,r):i===xe.ALL?this._createCellAllCache(r):this._createCellCache(s,r),r++}}rebuild(n){this._clearCache(),this._init(n.concat())}_createRowCache(n,r){const{startRow:s,endRow:i}=n;for(let o=s;o<=i;o++)this._rowCache.set(o,r),this._hasRow=!0}_createColumnCache(n,r){const{startColumn:s,endColumn:i}=n;for(let o=s;o<=i;o++)this._columnCache.set(o,r),this._hasColumn=!0}_createCellAllCache(n){this._hasAll=!0,this._allIndex=n}_createCellCache(n,r){for(let s=n.startRow;s<=n.endRow;s++){let i=this._cellCache.get(s);i==null&&(i=new Map,this._cellCache.set(s,i));for(let o=n.startColumn;o<=n.endColumn;o++)i.set(o,r)}}add(n){this._mergeData.push(n),this._clearCache(),this._createCache(this._mergeData)}remove(n,r){const s=this._getMergeDataIndex(n,r);s!==-1&&(this._mergeData.splice(s,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(n,r){const s=this._getMergeDataIndex(n,r);return s!==-1?this._mergeData[s]:null}getMergeDataIndex(n,r){return this._getMergeDataIndex(n,r)}isRowContainsMergedCell(n){return this._hasAll||!re.isEmptyObject(this._columnCache)?!0:this._mergeData.some(r=>r.startRow<=n&&n<=r.endRow)}isColumnContainsMergedCell(n){return this._hasAll||!re.isEmptyObject(this._rowCache)?!0:this._mergeData.some(r=>r.startColumn<=n&&n<=r.endColumn)}getMergedCellRange(n,r,s,i){const o=[],a=`${n}-${r}-${s}-${i}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let l=0;const u=[];for(const h of this._mergeData||[])Yt.intersects(h,{startRow:n,endRow:s,startColumn:r,endColumn:i})&&(o.push({...h}),u.push(l)),l++;return this._rangeMap.set(a,u),o}getMergedCellRangeForSkeleton(n,r,s,i){const o=[],a=this._mergeData,l=`${n}-${r}-${s}-${i}`;if(this._skeletonCache.has(l))return this._getSkeletonRangeFromCache(l);const u=[];for(let h=0;h<a.length;h++){const{startRow:c,endRow:d,startColumn:f,endColumn:E}=a[h];for(let R=n;R<=s;R++){let O=!1;for(let U=r;U<=i;U++)if(R>=c&&R<=d&&U>=f&&U<=E){o.push({startRow:c,endRow:d,startColumn:f,endColumn:E}),u.push(h),O=!0;break}if(O)break}}return this._skeletonCache.set(l,u),o}_getRangeFromCache(n){const r=this._rangeMap.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getSkeletonRangeFromCache(n){const r=this._skeletonCache.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getMergeDataIndex(n,r){var i;if(this._hasAll)return this._allIndex;if(this._hasRow){const o=this._rowCache.get(n);if(o!==void 0)return o}if(this._hasColumn){const o=this._columnCache.get(r);if(o!==void 0)return o}const s=(i=this._cellCache.get(n))==null?void 0:i.get(r);return s!==void 0?s:-1}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}}class Pc extends nt{constructor(n){super();C(this,"_cellContentInterceptor",null);C(this,"_rowFilteredInterceptor",null);this.getRawCell=n}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(n,r,s,i){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,An.Value|An.Style,s,i):this.getRawCell(n,r)}getCellValueOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,An.Value):this.getRawCell(n,r)}getCellStyleOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,An.Style):this.getRawCell(n,r)}getRowFiltered(n){var r,s;return(s=(r=this._rowFilteredInterceptor)==null?void 0:r.getRowFiltered(n))!=null?s:!1}registerCellContentInterceptor(n){if(this._cellContentInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptor=n,Qe(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(n){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=n,Qe(()=>this._rowFilteredInterceptor=null)}}const $a={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};class gr{constructor(t,n,r){C(this,"_sheetId");C(this,"_snapshot");C(this,"_cellData");C(this,"_rowManager");C(this,"_columnManager");C(this,"_viewModel");C(this,"_spanModel");var a;this.unitId=t,this._styles=r,this._snapshot=Uc(n);const{columnData:s,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:re.generateRandomId(6),this._cellData=new Lt(o),this._viewModel=new Pc((l,u)=>this.getCellRaw(l,u)),this._rowManager=new IC(this._snapshot,this._viewModel,i),this._columnManager=new RC(this._snapshot,s),this._spanModel=new AC(this._snapshot.mergeData)}__interceptViewModel(t){t(this._viewModel)}getSnapshot(){return this._snapshot}setMergeData(t){this._snapshot.mergeData=t,this.getSpanModel().rebuild(t)}getSpanModel(){return this._spanModel}getStyleDataByHash(t){return{...this._styles.get(t)}}setStyleData(t){return this._styles.setValue(t)}getColumnStyle(t,n=!1){return n?this._columnManager.getColumnStyle(t):this._styles.get(this._columnManager.getColumnStyle(t))}setColumnStyle(t,n){this._columnManager.setColumnStyle(t,n)}getRowStyle(t,n=!1){return n?this._rowManager.getRowStyle(t):this._styles.get(this._rowManager.getRowStyle(t))}setRowStyle(t,n){this._rowManager.setRowStyle(t,n)}mixinDefaultStyleToCellRaw(t,n,r,s){const i=this.getColumnStyle(n),o=this.getRowStyle(t),a=this.getDefaultCellStyleInternal();if(a||i||o){let l=r==null?void 0:r.s;typeof l=="string"&&(l=this._styles.get(l));const u=s?si(a,i,o,l):si(a,o,i,l);r||(r={}),r.s=u}}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){const t=this._snapshot.defaultStyle;return this._styles.get(t)}setDefaultCellStyle(t){this._snapshot.defaultStyle=t}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const t=this.getCellMatrix(),n=this.getMergeData();let r=-1,s=-1,i=-1,o=-1,a=!1,l=!1;return t.forEach((u,h)=>{Object.keys(h).forEach(c=>{const d=+c,f=t.getValue(u,d),E=f!=null&&f.s?this._styles.get(f.s):null,R=(E==null?void 0:E.bd)&&(E.bd.b||E.bd.l||E.bd.r||E.bd.t||E.bd.bc_tr||E.bd.bl_tr||E.bd.ml_tr||E.bd.tl_bc||E.bd.tl_br||E.bd.tl_mr);(f&&(f.v||f.p)||E!=null&&E.bg||R)&&(a?r=Math.min(r,u):(r=u,a=!0),s=Math.max(s,u),l?i=Math.min(i,d):(l=!0,i=d),o=Math.max(o,d))})}),n.forEach(u=>{a?r=Math.min(r,u.startRow):(r=u.startRow,a=!0),s=Math.max(s,u.endRow),l?i=Math.min(i,u.startColumn):(i=u.startColumn,a=!0),o=Math.max(o,u.endColumn)}),!a||!l?null:{startColumn:i,startRow:r,endColumn:o,endRow:s}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:t}=this,n=re.deepClone(t);return new gr(this.unitId,n,this._styles)}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(t,n){return this._spanModel.getMergedCell(t,n)}getMergedCellRange(t,n,r,s){return this._spanModel.getMergedCellRange(t,n,r,s)}isRowContainsMergedCell(t){return this._spanModel.isRowContainsMergedCell(t)}isColumnContainsMergedCell(t){return this._spanModel.isColumnContainsMergedCell(t)}getCellInfoInMergeData(t,n){const r=this.getMergedCell(t,n);let s=!1,i=!1,o=t,a=n,l=t,u=n;if(r){const{startRow:h,endRow:c,startColumn:d,endColumn:f}=r;t===h&&n===d?(o=c,a=f,l=h,u=d,i=!0):t>=h&&t<=c&&n>=d&&n<=f&&(o=c,a=f,l=h,u=d,s=!0)}return{actualRow:t,actualColumn:n,isMergedMainCell:i,isMerged:s,endRow:o,endColumn:a,startRow:l,startColumn:u}}getCell(t,n){return t<0||n<0?null:this._viewModel.getCell(t,n)}getCellValueOnly(t,n){return t<0||n<0?null:this._viewModel.getCellValueOnly(t,n)}getCellStyleOnly(t,n){return t<0||n<0?null:this._viewModel.getCellStyleOnly(t,n)}getCellRaw(t,n){return this.getCellMatrix().getValue(t,n)}getCellWithFilteredInterceptors(t,n,r,s){return this._viewModel.getCell(t,n,r,s)}getRowFiltered(t){return this._viewModel.getRowFiltered(t)}getMatrixWithMergedCells(t,n,r,s,i=bn.Raw){const o=this.getCellMatrix(),a=this._spanModel.getMergedCellRange(t,n,r,s),l=new Lt;return ci(t,r,n,s).forEach((u,h)=>{var d;let c;if(i===bn.Raw)c=this.getCellRaw(u,h);else if(i===bn.Intercepted)c=this.getCell(u,h);else if(i===bn.Both){const f=this.getCellRaw(u,h);if(f){c={...f};const E=(d=this.getCell(u,h))==null?void 0:d.v;wc(E)&&c&&(c.displayV=String(E))}}c&&l.setValue(u,h,c)}),a.forEach(u=>{const{startColumn:h,startRow:c,endColumn:d,endRow:f}=u;ci(c,f,h,d).forEach((E,R)=>{E===c&&R===h&&l.setValue(E,R,{...o.getValue(E,R),rowSpan:f-c+1,colSpan:d-h+1}),(E!==c||R!==h)&&l.realDeleteValue(E,R)})}),l}getRange(t,n,r,s){return typeof t=="object"?new Fn(this,t,{getStyles:()=>this._styles}):new Fn(this,{startRow:t,startColumn:n,endColumn:s||n,endRow:r||t},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:t}=this,{columnCount:n}=t;return n}getMaxRows(){const{_snapshot:t}=this,{rowCount:n}=t;return n}getRowCount(){return this._snapshot.rowCount}setRowCount(t){this._snapshot.rowCount=t}getColumnCount(){return this._snapshot.columnCount}setColumnCount(t){this._snapshot.columnCount=t}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:t}=this,{showGridlines:n}=t;return n===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){const{_snapshot:t}=this,{tabColor:n}=t;return n}getColumnWidth(t){return this.getColumnManager().getColumnWidth(t)}getRowHeight(t){return this._viewModel.getRowFiltered(t)?0:this.getRowManager().getRowHeight(t)}isRowFiltered(t){return this._viewModel.getRowFiltered(t)}getRowVisible(t){return!this.isRowFiltered(t)&&this.getRowRawVisible(t)}getRowRawVisible(t){return this.getRowManager().getRowRawVisible(t)}getHiddenRows(t,n){const r=this.getMaxColumns()-1,s=this._rowManager.getHiddenRows(t,n);return s.forEach(i=>i.endColumn=r),s}getColVisible(t){return this._columnManager.getColVisible(t)}getHiddenCols(t,n){const r=this.getMaxRows()-1,s=this._columnManager.getHiddenCols(t,n);return s.forEach(i=>i.endRow=r),s}getVisibleRows(){const t=this.getRowCount();return this._rowManager.getVisibleRows(0,t-1)}getVisibleCols(){const t=this.getColumnCount();return this._columnManager.getVisibleCols(0,t-1)}isRightToLeft(){const{_snapshot:t}=this,{rightToLeft:n}=t;return n}getLastRowWithContent(){return this._cellData.getLength()-1}getLastColumnWithContent(){return this._cellData.getRange().endColumn}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(t){return t&&(t.v!==void 0||t.f!==void 0||t.p!==void 0)}iterateByRow(t,n=!0){const{startRow:r,startColumn:s,endRow:i,endColumn:o}=t,a=this;return{[Symbol.iterator]:()=>{let l=r,u=s;return{next(){for(;;){if(u>o&&(l+=1,u=s),l>i)return{done:!0,value:void 0};const h=a.getCell(l,u),c=!h,d=a.getMergedCell(l,u);if(d){if(l!==d.startRow||u!==d.startColumn){u=d.endColumn+1;continue}if(c&&n){u=d.endColumn+1;continue}const E={row:l,col:u,value:h};return E.colSpan=d.endColumn-d.startColumn+1,E.rowSpan=d.endRow-d.startRow+1,u=d.endColumn+1,{done:!1,value:E}}if(c&&n)u+=1;else{const f={row:l,col:u,value:h};return u+=1,{done:!1,value:f}}}}}}}}iterateByColumn(t,n=!0,r=!0){const{startRow:s,startColumn:i,endRow:o,endColumn:a}=t,l=this;return{[Symbol.iterator]:()=>{let u=s,h=i;return{next(){for(;;){if(u>o&&(h+=1,u=s),h>a)return{done:!0,value:void 0};const c=l.getMergedCell(u,h);if(c){const E=u!==c.startRow,R=E||h!==c.startColumn;if(r&&R||!r&&E){u=c.endRow+1;continue}const O=l.getCell(c.startRow,c.startColumn);if(!O&&n){u=c.endRow+1;continue}const ne={row:u,col:c.startColumn,value:O};return ne.colSpan=c.endColumn-c.startColumn+1,ne.rowSpan=c.endRow-c.startRow+1,u=c.endRow+1,{done:!1,value:ne}}const d=l.getCell(u,h);if(!d&&n)u+=1;else{const E={row:u,col:h,value:d};return u+=1,{done:!1,value:E}}}}}}}}_getCellDocumentModel(t,n=$a){var R;const{isDeepClone:r,displayRawFormula:s,ignoreTextRotation:i}={...$a,...n},o=this._styles.getStyleByCell(t);if(!t)return;let a,l="document";const u=_C(o),h=i?ht.tr:u.textRotation||ht.tr;let c=u.horizontalAlign||ht.ht;const d=u.verticalAlign||ht.vt,f=u.wrapStrategy||ht.tb,E=u.paddingData||mi;if(t.f&&s)a=tr(t.f.toString(),{},{verticalAlign:d}),c=ht.ht;else if(t.p){const{centerAngle:O,vertexAngle:U}=Ac(h);a=this._updateConfigAndGetDocumentModel(r?re.deepClone(t.p):t.p,c,E,{horizontalAlign:c,verticalAlign:d,centerAngle:O,vertexAngle:U,wrapStrategy:f,zeroWidthParagraphBreak:1})}else if(t.v!=null){const O=Fa(o);l=ka(O).fontCache;let U=Fc(t);t.t===nn.FORCE_STRING&&s&&(U=`'${U}`),a=tr(U,O,{...u,textRotation:h,cellValueType:t.t})}return a&&t.linkUrl&&t.linkId&&bc(a,t.linkUrl,t.linkId),{documentModel:a,fontString:l,textRotation:h,wrapStrategy:f,verticalAlign:d,horizontalAlign:c,paddingData:E,fill:(R=o==null?void 0:o.bg)==null?void 0:R.rgb}}_updateConfigAndGetDocumentModel(t,n,r,s){var o,a,l,u,h;if(!s||!((o=t.body)!=null&&o.dataStream))return;t.documentStyle||(t.documentStyle={}),t.documentStyle.marginTop=(a=r.t)!=null?a:0,t.documentStyle.marginBottom=(l=r.b)!=null?l:2,t.documentStyle.marginLeft=(u=r.l)!=null?u:2,t.documentStyle.marginRight=(h=r.r)!=null?h:2,t.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},t.documentStyle.renderConfig={...t.documentStyle.renderConfig,...s};const i=t.body.paragraphs||[];for(const c of i)c.paragraphStyle||(c.paragraphStyle={}),c.paragraphStyle.horizontalAlign=n;return new Ft(t)}getBlankCellDocumentModel(t){const n=this._getCellDocumentModel(t,{ignoreTextRotation:!0}),r=this._styles.getStyleByCell(t),s=Fa(r);if(n!=null)return n.documentModel==null&&(n.documentModel=tr("",s)),n;const i="";let o="document";const a=ht.tr,l=ht.ht,u=ht.vt,h=ht.tb,c=mi;return o=ka({}).fontCache,{documentModel:tr(i,s),fontString:o,textRotation:a,wrapStrategy:h,verticalAlign:u,horizontalAlign:l,paddingData:c}}getCellDocumentModelWithFormula(t){return this._getCellDocumentModel(t,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(t){this._snapshot.custom=t}}function Fc(e){var r,s;if(!e)return"";const t=(s=(r=e.p)==null?void 0:r.body)==null?void 0:s.dataStream;if(t)return st.transform.getPlainText(t);const n=e.v;return typeof n=="string"?e.t===nn.BOOLEAN?n.toUpperCase():n.replace(/[\r\n]/g,""):typeof n=="number"?e.t===nn.BOOLEAN?n?"TRUE":"FALSE":n.toString():typeof n=="boolean"?n?"TRUE":"FALSE":""}function TC(e){if(e===null)return"";if(e!=null&&e.p){const t=e==null?void 0:e.p.body;if(t==null)return"";const n=t.dataStream;return st.transform.getPlainText(n)}return e==null?void 0:e.v}var NC=Object.defineProperty,MC=Object.getOwnPropertyDescriptor,DC=(e,t,n,r)=>{for(var s=r>1?void 0:r?MC(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&NC(t,n,s),s},xC=(e,t)=>(n,r)=>t(n,r,e);function LC(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}exports.Workbook=class extends Ss{constructor(n={},r){super();C(this,"type",$e.UNIVER_SHEET);C(this,"_sheetCreated$",new Oe.Subject);C(this,"sheetCreated$",this._sheetCreated$.asObservable());C(this,"_sheetDisposed$",new Oe.Subject);C(this,"sheetDisposed$",this._sheetDisposed$.asObservable());C(this,"_activeSheet$",new Oe.BehaviorSubject(null));C(this,"activeSheet$",this._activeSheet$.asObservable());C(this,"_worksheets");C(this,"_styles");C(this,"_snapshot");C(this,"_unitId");C(this,"_count");C(this,"_name$");C(this,"name$");this._logService=r;const s=fC();re.isEmptyObject(n)?this._snapshot=s:this._snapshot=re.commonExtend(s,n);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=re.generateRandomId(6)),this._unitId=this._snapshot.id,this._styles=new Oc(i),this._count=1,this._worksheets=new Map,this._name$=new Oe.BehaviorSubject(n.name||""),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(n){return typeof n=="string"||"startRow"in n||"row"in n}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete()}save(){return re.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(n){this._name$.next(n),this._snapshot.name=n}getUnitId(){return this._unitId}getRev(){var n;return(n=this._snapshot.rev)!=null?n:1}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(n){this._snapshot.rev=n}addWorksheet(n,r,s){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[n])return!1;i[n]=s,o.splice(r,0,n);const a=new gr(this._unitId,s,this._styles);return this._worksheets.set(n,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}getConfig(){return this._snapshot}getIndexBySheetId(n){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>s===n)}getActiveSheet(n){if(!this._activeSheet&&typeof n>"u")throw new Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){const n=this._activeSheet;if(n)return n;const r=this._snapshot.sheetOrder;for(let i=0,o=r.length;i<o;i++){const a=this._worksheets.get(r[i]);if(a&&a.isSheetHidden()!==Se.TRUE)return this.setActiveSheet(a),a}const s=this._worksheets.get(r[0]);return this.setActiveSheet(s),s}setActiveSheet(n){this._activeSheet$.next(n)}removeSheet(n){const r=this._worksheets.get(n);return r?(this._worksheets.delete(n),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(n),1),delete this._snapshot.sheets[n],this._sheetDisposed$.next(r),!0):!1}getActiveSheetIndex(){const{sheetOrder:n}=this._snapshot;return n.findIndex(r=>this._worksheets.get(r)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:n}=this._snapshot;return n.map(r=>this._worksheets.get(r))}getSheetsName(){const{sheetOrder:n}=this._snapshot,r=[];return n.forEach(s=>{const i=this._worksheets.get(s);i&&r.push(i.getName())}),r}getSheetIndex(n){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>n.getSheetId()===s)}getSheetBySheetName(n){const{sheetOrder:r}=this._snapshot,s=r.find(i=>this._worksheets.get(i).getName()===n);return this._worksheets.get(s)}getSheetBySheetId(n){return this._worksheets.get(n)}getSheetByIndex(n){const{sheetOrder:r}=this._snapshot;return this._worksheets.get(r[n])}getHiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden===Se.TRUE).map(n=>n.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden!==Se.TRUE).map(n=>n.getConfig().id)}load(n){this._snapshot=n}checkSheetName(n){return this.getSheetsName().includes(n)}uniqueSheetName(n="Sheet1"){let r=n;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}generateNewSheetName(n){let r=n+this._count;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}_parseWorksheetSnapshots(){const{_snapshot:n,_worksheets:r}=this,{sheets:s,sheetOrder:i}=n;if(re.isEmptyObject(s)){const o=re.generateRandomId();s[o]={id:o}}for(const o in s){const a=s[o],{name:l}=a;a.name=this.uniqueSheetName(l),a.name!==l&&this._logService.debug("[Workbook]",`The worksheet name ${l} is duplicated, we changed it to ${a.name}. Please fix the problem in your snapshot.`);const u=new gr(this._unitId,a,this._styles);r.set(o,u),i.includes(o)||i.push(o)}this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(n){this._snapshot.custom=n}};exports.Workbook=DC([xC(1,At)],exports.Workbook);class mo extends Ss{constructor(n){var r;super();C(this,"type",$e.UNIVER_SLIDE);C(this,"_activePage$",new Oe.BehaviorSubject(null));C(this,"activePage$",this._activePage$.asObservable());C(this,"_name$");C(this,"name$");C(this,"_snapshot");C(this,"_unitId");this._snapshot={...gu,...n},this._unitId=(r=this._snapshot.id)!=null?r:re.generateRandomId(6),this._name$=new Oe.BehaviorSubject(this._snapshot.title),this.name$=this._name$.asObservable()}get _activePage(){var r,s;const n=this._activePage$.getValue();if(!n){const i=(r=this.getPageOrder())==null?void 0:r[0];return i?(s=this.getPages())==null?void 0:s[i]:null}return n}setName(n){var r;this._snapshot.title=n,this._name$.next(n),this._unitId=(r=this._snapshot.id)!=null?r:zt(6)}getRev(){return 0}incrementRev(){}setRev(n){}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var n;return(n=this._snapshot.body)==null?void 0:n.pages}getPageOrder(){var n;return(n=this._snapshot.body)==null?void 0:n.pageOrder}getPage(n){const r=this.getPages();return r==null?void 0:r[n]}getElementsByPage(n){var r;return(r=this.getPage(n))==null?void 0:r.pageElements}getElement(n,r){var s;return(s=this.getElementsByPage(n))==null?void 0:s[r]}getPageSize(){return this._snapshot.pageSize}getBlankPage(){const n=zt(6);return{id:n,pageType:lo.SLIDE,zIndex:10,title:n,description:"",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}setActivePage(n){this._activePage$.next(n)}getActivePage(){return this._activePage}updatePage(n,r){this._snapshot.body&&(this._snapshot.body.pages[n]=r)}appendPage(n){var i;if(!this._snapshot.body)return;this._snapshot.body.pages[n.id]=n;const r=this._activePage,s=this._snapshot.body.pageOrder.indexOf((i=r==null?void 0:r.id)!=null?i:"");this._snapshot.body.pageOrder.splice(s+1,0,n.id)}}const nr="FOCUSING_UNIT",Tn="FOCUSING_SHEET",rr="FOCUSING_DOC",sr="FOCUSING_SLIDE",UC="FOCUSING_EDITOR_BUT_HIDDEN",kc="EDITOR_ACTIVATED",PC="FOCUSING_EDITOR_INPUT_FORMULA",$c="FOCUSING_FX_BAR_EDITOR",FC="FOCUSING_UNIVER_EDITOR",kC="FOCUSING_EDITOR_INPUT_FORMULA",$C="FOCUSING_PANEL_EDITOR",BC="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",jC="FOCUSING_COMMON_DRAWINGS",HC="FORMULA_EDITOR_ACTIVATED";var WC=Object.defineProperty,zC=Object.getOwnPropertyDescriptor,YC=(e,t,n,r)=>{for(var s=r>1?void 0:r?zC(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&WC(t,n,s),s},Ba=(e,t)=>(n,r)=>t(n,r,e);const an=_t("univer.current");exports.UniverInstanceService=class extends nt{constructor(n,r){super();C(this,"_unitsByType",new Map);C(this,"_createHandler");C(this,"_ctorByType",new Map);C(this,"_currentUnits",new Map);C(this,"_currentUnits$",new Oe.BehaviorSubject(this._currentUnits));C(this,"currentUnits$",this._currentUnits$.asObservable());C(this,"_unitAdded$",new Oe.Subject);C(this,"unitAdded$",this._unitAdded$.asObservable());C(this,"_unitDisposed$",new Oe.Subject);C(this,"unitDisposed$",this._unitDisposed$.asObservable());C(this,"_focused$",new Oe.BehaviorSubject(null));C(this,"focused$",this._focused$.asObservable());this._injector=n,this._contextService=r}dispose(){super.dispose(),this._focused$.complete()}__setCreateHandler(n){this._createHandler=n}createUnit(n,r,s){return this._createHandler(n,r,this._ctorByType.get(n),s)}registerCtorForType(n,r){return this._ctorByType.set(n,r),{dispose:()=>{this._ctorByType.delete(n)}}}getCurrentTypeOfUnit$(n){return this.currentUnits$.pipe(Oe.map(r=>{var s;return(s=r.get(n))!=null?s:null}),Oe.distinctUntilChanged())}getCurrentUnitForType(n){return this._currentUnits.get(n)}setCurrentUnitForType(n){const r=this._getUnitById(n);if(!r)throw new Error(`[UniverInstanceService]: no document with unitId ${n}!`);this._currentUnits.set(r[1],r[0]),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(n){return this._unitAdded$.pipe(Oe.filter(r=>r.type===n))}__addUnit(n,r){var a;const s=n.type;this._unitsByType.has(s)||this._unitsByType.set(s,[]);const i=this._unitsByType.get(s),o=n.getUnitId();if(i.findIndex(l=>l.getUnitId()===o)!==-1)throw new Error(`[UniverInstanceService]: cannot create a unit with the same unit id: ${o}.`);i.push(n),this._unitAdded$.next(n),((a=r==null?void 0:r.makeCurrent)==null||a)&&this.setCurrentUnitForType(n.getUnitId())}getTypeOfUnitDisposed$(n){return this.unitDisposed$.pipe(Oe.filter(r=>r.type===n))}getUnit(n,r){var i;const s=(i=this._getUnitById(n))==null?void 0:i[0];return r&&(s==null?void 0:s.type)!==r?null:s}getCurrentUniverDocInstance(){return this.getCurrentUnitForType($e.UNIVER_DOC)}getUniverDocInstance(n){return this.getUnit(n,$e.UNIVER_DOC)}getUniverSheetInstance(n){return this.getUnit(n,$e.UNIVER_SHEET)}getAllUnitsForType(n){var r;return(r=this._unitsByType.get(n))!=null?r:[]}changeDoc(n,r){const s=this.getAllUnitsForType($e.UNIVER_DOC),i=s.find(o=>o.getUnitId()===n);if(i!=null){const o=s.indexOf(i);s.splice(o,1)}this.__addUnit(r)}get focused(){var r;const n=this._focused$.getValue();return n?(r=this._getUnitById(n))==null?void 0:r[0]:null}focusUnit(n){this._focused$.next(n),this.focused instanceof exports.Workbook?(this._contextService.setContextValue(nr,!0),this._contextService.setContextValue(rr,!1),this._contextService.setContextValue(Tn,!0),this._contextService.setContextValue(sr,!1),this.setCurrentUnitForType(n)):this.focused instanceof Ft?(this._contextService.setContextValue(nr,!0),this._contextService.setContextValue(rr,!0),this._contextService.setContextValue(Tn,!1),this._contextService.setContextValue(sr,!1),this.setCurrentUnitForType(n)):this.focused instanceof mo?(this._contextService.setContextValue(nr,!0),this._contextService.setContextValue(rr,!1),this._contextService.setContextValue(Tn,!1),this._contextService.setContextValue(sr,!0),this.setCurrentUnitForType(n)):(this._contextService.setContextValue(nr,!1),this._contextService.setContextValue(rr,!1),this._contextService.setContextValue(Tn,!1),this._contextService.setContextValue(sr,!1))}getFocusedUnit(){return this.focused}getUnitType(n){const r=this._getUnitById(n);return r?r[1]:$e.UNRECOGNIZED}disposeUnit(n){const r=this._getUnitById(n);if(!r)return!1;const[s,i]=r,o=this._unitsByType.get(i),a=o.indexOf(s);return o.splice(a,1),this._tryRemoveCurrentUnitForType(n,i),this._tryBlurUnitOnRemoval(n),this._unitDisposed$.next(s),!0}_tryRemoveCurrentUnitForType(n,r){const s=this.getCurrentUnitForType(r);(s==null?void 0:s.getUnitId())===n&&(this._currentUnits.set(r,null),this._currentUnits$.next(this._currentUnits))}_tryBlurUnitOnRemoval(n){var r;((r=this.focused)==null?void 0:r.getUnitId())===n&&this._focused$.next(null)}_getUnitById(n){for(const[r,s]of this._unitsByType){const i=s.find(o=>o.getUnitId()===n);if(i)return[i,r]}}};exports.UniverInstanceService=YC([Ba(0,it(Rt)),Ba(1,Cr)],exports.UniverInstanceService);var We=(e=>(e[e.Starting=0]="Starting",e[e.Ready=1]="Ready",e[e.Rendered=2]="Rendered",e[e.Steady=3]="Steady",e))(We||{});const VC={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"};var GC=Object.defineProperty,KC=Object.getOwnPropertyDescriptor,XC=(e,t,n,r)=>{for(var s=r>1?void 0:r?KC(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&GC(t,n,s),s},QC=(e,t)=>(n,r)=>t(n,r,e);exports.LifecycleService=class extends nt{constructor(n){super();C(this,"_lifecycle$",new Oe.BehaviorSubject(We.Starting));C(this,"lifecycle$",this._lifecycle$.asObservable());C(this,"_lock",!1);this._logService=n,this._reportProgress(We.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(n){if(this._lock)throw new Error("[LifecycleService]: cannot set new stage when related logic is all handled!");if(n<this.stage)throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");n!==this.stage&&(this._lock=!0,this._reportProgress(n),this._lifecycle$.next(n),this._lock=!1)}dispose(){this._lifecycle$.complete(),super.dispose()}subscribeWithPrevious(){return Oe.merge(Bc(this.stage),this._lifecycle$.pipe(Oe.skip(1))).pipe(Yl(n=>n===We.Steady))}_reportProgress(n){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${VC[n]}".`)}};exports.LifecycleService=XC([QC(0,At)],exports.LifecycleService);function Bc(e){switch(e){case We.Starting:return Oe.of(We.Starting);case We.Ready:return Oe.of(We.Starting,We.Ready);case We.Rendered:return Oe.of(We.Starting,We.Ready,We.Rendered);default:return Oe.of(We.Starting,We.Ready,We.Rendered,We.Steady)}}var JC=Object.defineProperty,qC=Object.getOwnPropertyDescriptor,ZC=(e,t,n,r)=>{for(var s=r>1?void 0:r?qC(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&JC(t,n,s),s},Bs=(e,t)=>(n,r)=>t(n,r,e);const en=_t("univer.undo-redo.service"),eR=20;class jc{dispose(){}async dispatchToHandlers(){return!1}}const Hc="univer.command.redo",Wc="univer.command.undo",gn=new class extends jc{constructor(){super(...arguments);C(this,"type",Wn.COMMAND);C(this,"id",Wc)}handler(t){const n=t.get(en),r=n.pitchTopUndoElement();if(!r)return!1;const s=t.get(xt);return zi(r.undoMutations,s)?(n.popUndoToRedo(),!0):!1}},pn=new class extends jc{constructor(){super(...arguments);C(this,"type",Wn.COMMAND);C(this,"id",Hc)}handler(t){const n=t.get(en),r=n.pitchTopRedoElement();if(!r)return!1;const s=t.get(xt);return zi(r.redoMutations,s)?(n.popRedoToUndo(),!0):!1}};exports.LocalUndoRedoService=class extends nt{constructor(n,r,s){super();C(this,"undoRedoStatus$");C(this,"_undoRedoStatus$",new Oe.BehaviorSubject({undos:0,redos:0}));C(this,"_undoStacks",new Map);C(this,"_redoStacks",new Map);C(this,"_batchingStatus",new Map);this._univerInstanceService=n,this._commandService=r,this._contextService=s,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(gn)),this.disposeWithMe(this._commandService.registerCommand(pn)),this.disposeWithMe(Qe(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(Qe(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(n){const{unitID:r}=n,s=this._getRedoStack(r,!0),i=this._getUndoStack(r,!0);if(s.length=0,this._batchingStatus.has(n.unitID)){const a=this._batchingStatus.get(n.unitID),l=this._pitchUndoElement(n.unitID);a===0||!l?(o(n),this._batchingStatus.set(n.unitID,1)):this._tryBatchingElements(l,n)}else o(n);function o(a){i.push(a),i.length>eR&&i.splice(0,1)}this._updateStatus()}clearUndoRedo(n){const r=this._getRedoStack(n);r&&(r.length=0);const s=this._getUndoStack(n);s&&(s.length=0),this._updateStatus()}pitchTopUndoElement(){const n=this._getFocusedUnitId();return this._pitchUndoElement(n)}pitchTopRedoElement(){const n=this._getFocusedUnitId();return this._pitchRedoElement(n)}_pitchUndoElement(n){const r=this._getUndoStack(n);return r!=null&&r.length?r[r.length-1]:null}_pitchRedoElement(n){const r=this._getRedoStack(n);return r!=null&&r.length?r[r.length-1]:null}popUndoToRedo(){const r=this._getUndoStackForFocused().pop();r&&(this._getRedoStackForFocused().push(r),this._updateStatus())}popRedoToUndo(){const r=this._getRedoStackForFocused().pop();r&&(this._getUndoStackForFocused().push(r),this._updateStatus())}__tempBatchingUndoRedo(n){if(this._batchingStatus.has(n))throw new Error("[LocalUndoRedoService]: cannot batching undo redo twice at the same time!");return this._batchingStatus.set(n,0),Qe(()=>this._batchingStatus.delete(n))}_updateStatus(){var i,o;const n=this._getFocusedUnitId(),r=n&&((i=this._undoStacks.get(n))==null?void 0:i.length)||0,s=n&&((o=this._redoStacks.get(n))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:r,redos:s})}_getUndoStack(n,r=!1){let s=this._undoStacks.get(n);return!s&&r&&(s=[],this._undoStacks.set(n,s)),s||null}_getRedoStack(n,r=!1){let s=this._redoStacks.get(n);return!s&&r&&(s=[],this._redoStacks.set(n,s)),s||null}_getUndoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getUndoStack(n,!0)}_getRedoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getRedoStack(n,!0)}_tryBatchingElements(n,r){n.redoMutations.push(...r.redoMutations),n.undoMutations.push(...r.undoMutations)}_getFocusedUnitId(){var o,a,l,u;let n="";const r=this._contextService.getContextValue(Tn),s=this._contextService.getContextValue($c),i=this._contextService.getContextValue(kc);return r?s?n=Pi:i?n=Ui:n=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":n=(u=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?u:"",n}};exports.LocalUndoRedoService=ZC([Bs(0,an),Bs(1,xt),Bs(2,Cr)],exports.LocalUndoRedoService);const ws=_t("core.resource-manager.service"),_i={[Dt.Editor]:"Editor",[Dt.Owner]:"Owner",[Dt.Reader]:"Reader",[Dt.UNRECOGNIZED]:"UNRECOGNIZED"},cs=e=>e?{userID:`${_i[e]}_${re.generateRandomId(8)}`,name:_i[e],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},tR=(e,t)=>e.startsWith(_i[t]);class $n{constructor(){C(this,"_model",new Map);C(this,"_userChange$",new Oe.Subject);C(this,"userChange$",this._userChange$.asObservable());C(this,"_currentUser$",new Oe.BehaviorSubject(cs()));C(this,"currentUser$",this._currentUser$.asObservable())}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(t){this.addUser(t),this._currentUser$.next(t)}addUser(t){this._model.set(t.userID,t),this._userChange$.next({type:"add",user:t})}getUser(t,n){const r=this._model.get(t);if(r)return r;n&&n()}delete(t){const n=this.getUser(t);this._model.delete(t),n&&this._userChange$.next({type:"delete",user:n})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}list(){return Array.from(this._model.values())}}var nR=Object.defineProperty,rR=Object.getOwnPropertyDescriptor,sR=(e,t,n,r)=>{for(var s=r>1?void 0:r?rR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&nR(t,n,s),s},ja=(e,t)=>(n,r)=>t(n,r,e);exports.AuthzIoLocalService=class{constructor(t,n){C(this,"_permissionMap",new Map([]));this._resourceManagerService=t,this._userManagerService=n,this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){const t=this._userManagerService.getCurrentUser();t&&t.userID||this._userManagerService.setCurrentUser(cs(Dt.Owner))}_getRole(t){const n=this._userManagerService.getCurrentUser();return n?tR(n.userID,t):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:t=>{const n=[...this._permissionMap.keys()].reduce((r,s)=>{const i=this._permissionMap.get(s);return r[s]=i,r},{});return JSON.stringify(n)},parseJson:t=>JSON.parse(t),pluginName:"SHEET_AuthzIoMockService_PLUGIN",businesses:[$e.UNIVER_SHEET,$e.UNIVER_DOC,$e.UNIVER_SLIDE],onLoad:(t,n)=>{for(const r in n)this._permissionMap.set(r,n[r])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(t){return zt(8)}async allowed(t){return Promise.resolve([])}async batchAllowed(t){return Promise.resolve([])}async list(t){const n=[];return t.objectIDs.forEach(r=>{const s=this._permissionMap.get(r);if(s){const i={objectID:r,unitID:t.unitID,objectType:s.objectType,name:s.name,shareOn:!1,shareRole:Dt.Owner,shareScope:-1,scope:{read:hi.AllCollaborator,edit:hi.AllCollaborator},creator:cs(Dt.Owner),strategies:[{action:6,role:1},{action:16,role:1},{action:17,role:1},{action:18,role:1},{action:19,role:1},{action:33,role:1},{action:34,role:1},{action:35,role:1},{action:36,role:1},{action:37,role:1},{action:38,role:1},{action:39,role:1},{action:40,role:1}],actions:t.actions.map(o=>({action:o,allowed:this._getRole(Dt.Owner)||this._getRole(Dt.Editor)}))};n.push(i)}}),n}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(t){}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(t){}};exports.AuthzIoLocalService=sR([ja(0,ws),ja(1,it($n))],exports.AuthzIoLocalService);const zc=_t("IAuthzIoIoService"),Yc=_t("univer.config-service");class Vc{constructor(){C(this,"_configChanged$",new Oe.Subject);C(this,"configChanged$",this._configChanged$.asObservable());C(this,"_config",new Map)}dispose(){this._configChanged$.complete()}getConfig(t){return this._config.get(t)}setConfig(t,n,r){var o;const{merge:s=!1}=r||{};let i=(o=this._config.get(t))!=null?o:{};s?i=xi(i,n):i=n,this._config.set(t,i),this._configChanged$.next({[t]:i})}deleteConfig(t){return this._config.delete(t)}subscribeConfigValue$(t){return new Oe.Observable(n=>{Object.prototype.hasOwnProperty.call(this._config,t)&&n.next(this._config.get(t));const r=this.configChanged$.pipe(Oe.filter(s=>Object.prototype.hasOwnProperty.call(s,t))).subscribe(s=>n.next(s[t]));return()=>r.unsubscribe()})}}class Gc extends nt{constructor(){super(...arguments);C(this,"_error$",new Oe.Subject);C(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(n){this._error$.next({errorKey:n})}}class ur extends nt{constructor(){super();C(this,"_currentLocale$",new Oe.BehaviorSubject(zn.ZH_CN));C(this,"currentLocale$",this._currentLocale$.asObservable());C(this,"_locales",null);C(this,"localeChanged$",new Oe.Subject);C(this,"t",(n,...r)=>{if(!this._locales)throw new Error("[LocaleService]: Locale not initialized");const s=n.split("."),i=this.resolveKeyPath(this._locales[this._currentLocale],s);if(typeof i=="string"){let o=i;return r.forEach((a,l)=>{o=o.replace(`{${l}}`,a)}),o}else return n});this.disposeWithMe(Qe(()=>this.localeChanged$.complete()))}get _currentLocale(){return this._currentLocale$.value}load(n){var r;this._locales=xi((r=this._locales)!=null?r:{},n)}setLocale(n){this._currentLocale$.next(n),this.localeChanged$.next()}getLocales(){var n;return(n=this._locales)==null?void 0:n[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(n,r){const s=r.shift();if(s&&n&&s in n){const i=n[s];return r.length>0&&(typeof i=="object"||Array.isArray(i))?this.resolveKeyPath(i,r):i}return null}}var iR=Object.defineProperty,oR=Object.getOwnPropertyDescriptor,aR=(e,t,n,r)=>{for(var s=r>1?void 0:r?oR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&iR(t,n,s),s},lR=(e,t)=>(n,r)=>t(n,r,e);exports.MentionIOLocalService=class{constructor(t){this._userManagerService=t}async list(t){return{list:[{type:dr.PERSON,mentions:[{objectType:dr.PERSON,objectId:this._userManagerService.getCurrentUser().userID,label:this._userManagerService.getCurrentUser().name,metadata:{icon:this._userManagerService.getCurrentUser().avatar}}],metadata:{},title:"PEOPLE"}],page:t.page,size:t.size,total:1}}};exports.MentionIOLocalService=aR([lR(0,it($n))],exports.MentionIOLocalService);const Kc=_t("univer.service.mention-io");var _o=(e=>(e.INIT="init",e.FETCHING="fetching",e.DONE="done",e))(_o||{});const Xc=_t("univer.permission-service");class Qc extends nt{constructor(){super(...arguments);C(this,"_permissionPointMap",new Map);C(this,"_permissionPointUpdate$",new Oe.Subject);C(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable());C(this,"_showComponents",!0)}setShowComponents(n){this._showComponents=n}getShowComponents(){return this._showComponents}deletePermissionPoint(n){const r=this._permissionPointMap.get(n);r&&(r.complete(),this._permissionPointMap.delete(n))}addPermissionPoint(n){const r=n instanceof Oe.BehaviorSubject,s=r?n.getValue():n;if(!s.id)return!1;if(this._permissionPointMap.get(s.id))throw new Error(`${s.id} PermissionPoint already exists`);return this._permissionPointMap.set(s.id,r?n:new Oe.BehaviorSubject(s)),this._permissionPointUpdate$.next(s),!0}updatePermissionPoint(n,r){const s=this._permissionPointMap.get(n);if(!s)return;const i=s.getValue();i.value=r,i.status=_o.DONE,s.next(i),this._permissionPointUpdate$.next(i)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(n){const r=this._permissionPointMap.get(n);if(r)return r.getValue()}getPermissionPoint$(n){const r=this._permissionPointMap.get(n);if(r)return r}composePermission$(n){const r=n.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.asObservable()});return Oe.combineLatest(r).pipe(Br.map(s=>s))}composePermission(n){return n.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.getValue()})}getAllPermissionPoint(){const n=new Map;return this._permissionPointMap.forEach((r,s)=>{n.set(s,r)}),n}}function Jc(e,t){if(!t)return e;const n=[];for(const r of e){const s=t.find(([i])=>i===r[0]);if(s){if(s[1]===null)continue;n.push([r[0],s[1]])}else n.push(r)}return n}const qc=Symbol("DependentOn");class Ei extends nt{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUniverInstanceType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}C(Ei,"pluginName"),C(Ei,"type",$e.UNIVER_UNKNOWN);class uR{constructor(){C(this,"_plugins",[])}addPlugin(t){this._plugins.push(t)}removePlugins(){const t=this._plugins.slice();return this._plugins.length=0,t}forEachPlugin(t){this._plugins.forEach(t)}}class cR{constructor(){C(this,"_pluginsRegistered",[])}registerPlugin(t,n){this._pluginsRegistered.push({plugin:t,options:n})}getRegisterPlugins(){return this._pluginsRegistered.slice()}removePlugins(){this._pluginsRegistered=[]}}var hR=Object.defineProperty,dR=Object.getOwnPropertyDescriptor,Zc=(e,t,n,r)=>{for(var s=r>1?void 0:r?dR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&hR(t,n,s),s},es=(e,t)=>(n,r)=>t(n,r,e);const fR=4;function gR(...e){return function(t){t[qc]=e}}exports.PluginService=class{constructor(t){C(this,"_pluginHolderForUniver");C(this,"_pluginHoldersForTypes",new Map);C(this,"_seenPlugins",new Set);C(this,"_flushTimer");this._injector=t,this._pluginHolderForUniver=this._injector.createInstance(hs,this._checkPluginSeen.bind(this),this._immediateInitPlugin.bind(this)),this._pluginHoldersForTypes.set($e.UNIVER_UNKNOWN,this._pluginHolderForUniver),this._pluginHolderForUniver.start()}dispose(){this._clearFlushTimer();for(const t of this._pluginHoldersForTypes.values())t.dispose();this._pluginHolderForUniver.dispose()}registerPlugin(t,n){this._assertPluginValid(t),this._scheduleInitPlugin();const{type:r}=t;r===$e.UNIVER_UNKNOWN?(this._pluginHolderForUniver.register(t,n),this._pluginHolderForUniver.flush()):this._ensurePluginHolderForType(r).register(t,n)}startPluginForType(t){this._ensurePluginHolderForType(t).start()}_ensurePluginHolderForType(t){if(!this._pluginHoldersForTypes.has(t)){const n=this._injector.createInstance(hs,this._checkPluginSeen.bind(this),this._immediateInitPlugin.bind(this));return this._pluginHoldersForTypes.set(t,n),n}return this._pluginHoldersForTypes.get(t)}_immediateInitPlugin(t){this._seenPlugins.add(t.pluginName),this._ensurePluginHolderForType(t.type).immediateInitPlugin(t)}_checkPluginSeen(t){return this._seenPlugins.has(t.pluginName)}_assertPluginValid(t){const{type:n,pluginName:r}=t;if(n===$e.UNRECOGNIZED)throw new Error(`[PluginService]: invalid plugin type for ${t.name}. Please assign a "type" to your plugin.`);if(!r)throw new Error(`[PluginService]: no plugin name for ${t.name}. Please assign a "pluginName" to your plugin.`);if(this._seenPlugins.has(r))throw new Error(`[PluginService]: duplicated plugin name for "${r}". Maybe a plugin that dependents on "${r} has already registered it. In that case please register "${r}" before the that plugin.`);this._seenPlugins.add(t.pluginName)}_scheduleInitPlugin(){this._flushTimer===void 0&&(this._flushTimer=setTimeout(()=>{this._pluginHolderForUniver.started||this._pluginHolderForUniver.start(),this._flushPlugins(),this._clearFlushTimer()},fR))}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}_flushPlugins(){this._pluginHolderForUniver.flush();for(const[t,n]of this._pluginHoldersForTypes)n.started&&n.flush()}};exports.PluginService=Zc([es(0,it(Rt))],exports.PluginService);let hs=class extends nt{constructor(t,n,r,s,i){super();C(this,"_started",!1);C(this,"_warnedAboutOnStartingDeprecation",!1);C(this,"_pluginRegistry",new cR);C(this,"_pluginStore",new uR);C(this,"_pluginsInBatches",[]);this._checkPluginRegistered=t,this._registerPlugin=n,this._logService=r,this._injector=s,this._lifecycleService=i,this.disposeWithMe(this._lifecycleService.lifecycle$.pipe(Oe.skip(1)).subscribe(o=>{this._pluginsInBatches.forEach(a=>this._runStage(a,o))}))}get started(){return this._started}dispose(){super.dispose(),this._pluginStore.forEachPlugin(t=>t.dispose()),this._pluginStore.removePlugins(),this._pluginRegistry.removePlugins(),this._pluginsInBatches.length=0}register(t,n){this._pluginRegistry.registerPlugin(t,n)}immediateInitPlugin(t){const n=this._initPlugin(t,void 0);this._pluginsRunLifecycle([n])}start(){this._started||(this._started=!0,this.flush())}flush(){if(!this._started)return;const t=this._pluginRegistry.getRegisterPlugins().map(({plugin:n,options:r})=>this._initPlugin(n,r));t.length&&(this._pluginsRunLifecycle(t),this._pluginRegistry.removePlugins())}_initPlugin(t,n){const r=t[qc];if(r){const i=()=>{const o=r.find(a=>!this._checkPluginRegistered(a));return o?(this._logService.debug("[PluginService]",`Plugin "${t.pluginName}" depends on "${o.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._registerPlugin(o,void 0),!0):!1};for(;i(););}const s=this._injector.createInstance(t,n);return this._pluginStore.addPlugin(s),this._logService.debug("[PluginService]",`Plugin "${s.getPluginName()}" registered.`),s}_pluginsRunLifecycle(t){Bc(this._lifecycleService.stage).subscribe(n=>this._runStage(t,n)),this._pluginsInBatches.push(t)}_runStage(t,n){t.forEach(r=>{switch(n){case We.Starting:r.onStarting();break;case We.Ready:r.onReady();break;case We.Rendered:r.onRendered();break;case We.Steady:r.onSteady();break}})}};hs=Zc([es(2,At),es(3,it(Rt)),es(4,it(exports.LifecycleService))],hs);var pR=Object.defineProperty,mR=Object.getOwnPropertyDescriptor,_R=(e,t,n,r)=>{for(var s=r>1?void 0:r?mR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&pR(t,n,s),s},Ha=(e,t)=>(n,r)=>t(n,r,e);let Ci=class extends nt{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){const e=n=>{n.businesses.forEach(r=>{switch(r){case $e.UNRECOGNIZED:case $e.UNIVER_UNKNOWN:case $e.UNIVER_SLIDE:case $e.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType($e.UNIVER_DOC).forEach(s=>{const o=(s.getSnapshot().resources||[]).find(a=>a.name===n.pluginName);if(o)try{const a=n.parseJson(o.data);n.onLoad(s.getUnitId(),a)}catch{console.error(`Load Document{${s.getUnitId()}} Resources{${n.pluginName}} Data Error.`)}});break}case $e.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType($e.UNIVER_SHEET).forEach(s=>{const o=(s.getSnapshot().resources||[]).find(a=>a.name===n.pluginName);if(o)try{const a=n.parseJson(o.data);n.onLoad(s.getUnitId(),a)}catch{console.error(`Load Workbook{${s.getUnitId()}} Resources{${n.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(n=>e(n)),this.disposeWithMe(this._resourceManagerService.register$.subscribe(n=>e(n))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$($e.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$($e.UNIVER_DOC).subscribe(n=>{const r=n.getUnitId();El(r)||this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$($e.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$($e.UNIVER_DOC).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())}))}saveUnit(e){const t=this._univerInstanceService.getUnit(e);if(!t)return null;const n=this._resourceManagerService.getResources(e,t.type),r=re.deepClone(t.getSnapshot());return r.resources=n,r}};Ci=_R([Ha(0,it(ws)),Ha(1,it(an))],Ci);const Ri=_t("resource-loader-service");class eh extends nt{constructor(){super(...arguments);C(this,"_resourceMap",new Map);C(this,"_register$",new Oe.Subject);C(this,"register$",this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(n,r){return r?this.getResourcesByType(n,r):this.getAllResourceHooks().map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}getResourcesByType(n,r){return this.getAllResourceHooks().filter(o=>o.businesses.includes(r)).map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}registerPluginResource(n){const r=n.pluginName;if(this._resourceMap.has(r))throw new Error(`the pluginName is registered {${r}}`);return this._resourceMap.set(r,n),this._register$.next(n),Qe(()=>this._resourceMap.delete(r))}disposePluginResource(n){this._resourceMap.delete(n)}loadResources(n,r){this.getAllResourceHooks().forEach(s=>{var o;const i=(o=r==null?void 0:r.find(a=>a.name===s.pluginName))==null?void 0:o.data;if(i)try{const a=s.parseJson(i);s.onLoad(n,a)}catch{console.error("LoadResources Error!")}})}unloadResources(n){this.getAllResourceHooks().forEach(r=>{r.onUnLoad(n)})}dispose(){this._register$.complete(),this._resourceMap.clear()}}class Eo extends nt{constructor(){super();C(this,"_currentTheme");C(this,"_currentTheme$",new Oe.BehaviorSubject({}));C(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(Qe(()=>this._currentTheme$.complete()))}getCurrentTheme(){if(!this._currentTheme)throw new Error("[ThemeService]: current theme is not set!");return this._currentTheme}setTheme(n){this._currentTheme=n,this._currentTheme$.next(n)}}class th{constructor(t={},n){C(this,"_startedTypes",new Set);C(this,"_injector");C(this,"_disposingCallbacks",new Is);const r=this._injector=ER(n,t==null?void 0:t.override),{theme:s,locale:i,locales:o,logLevel:a}=t;s&&this._injector.get(Eo).setTheme(s),o&&this._injector.get(ur).load(o),i&&this._injector.get(ur).setLocale(i),a&&this._injector.get(At).setLogLevel(a),this._init(r)}get _univerInstanceService(){return this._injector.get(an)}get _pluginService(){return this._injector.get(exports.PluginService)}__getInjector(){return this._injector}onDispose(t){const n=this._disposingCallbacks.add(Qe(t));return Qe(()=>n.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(t){this._injector.get(ur).setLocale(t)}createUnit(t,n){return this._univerInstanceService.createUnit(t,n)}createUniverSheet(t){return this._injector.get(At).warn("[Univer]: Univer.createUniverSheet is deprecated, use createUnit instead"),this._univerInstanceService.createUnit($e.UNIVER_SHEET,t)}createUniverDoc(t){return this._injector.get(At).warn("[Univer]: Univer.createUniverDoc is deprecated, use createUnit instead"),this._univerInstanceService.createUnit($e.UNIVER_DOC,t)}createUniverSlide(t){return this._injector.get(At).warn("[Univer]: Univer.createUniverSlide is deprecated, use createUnit instead"),this._univerInstanceService.createUnit($e.UNIVER_SLIDE,t)}_init(t){this._univerInstanceService.registerCtorForType($e.UNIVER_SHEET,exports.Workbook),this._univerInstanceService.registerCtorForType($e.UNIVER_DOC,Ft),this._univerInstanceService.registerCtorForType($e.UNIVER_SLIDE,mo);const n=t.get(an);n.__setCreateHandler((r,s,i,o)=>{if(!this._startedTypes.has(r)){this._pluginService.startPluginForType(r),this._startedTypes.add(r);const l=t.createInstance(i,s);return n.__addUnit(l,o),this._tryProgressToReady(),l}const a=t.createInstance(i,s);return n.__addUnit(a,o),a})}_tryProgressToReady(){this._injector.get(exports.LifecycleService).stage<We.Ready&&(this._injector.get(exports.LifecycleService).stage=We.Ready)}registerPlugin(t,n){this._pluginService.registerPlugin(t,n)}}function ER(e,t){const n=Jc([[Gc],[ur],[Eo],[exports.LifecycleService],[exports.PluginService],[$n],[an,{useClass:exports.UniverInstanceService}],[Xc,{useClass:Qc}],[At,{useClass:Hl,lazy:!0}],[xt,{useClass:exports.CommandService}],[en,{useClass:exports.LocalUndoRedoService,lazy:!0}],[Yc,{useClass:Vc}],[Cr,{useClass:Bl}],[ws,{useClass:eh,lazy:!0}],[Ri,{useClass:Ci,lazy:!0}],[zc,{useClass:exports.AuthzIoLocalService}],[Kc,{useClass:exports.MentionIOLocalService,lazy:!0}]],t),r=e?e.createChild(n):new Rt(n);return Ll(r,[[$n],[Ri]]),r}var CR=Object.defineProperty,RR=Object.getOwnPropertyDescriptor,IR=(e,t,n,r)=>{for(var s=r>1?void 0:r?RR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&CR(t,n,s),s},vR=(e,t)=>(n,r)=>t(n,r,e);exports.FBlob=class extends Os{constructor(t,n){super(),this._blob=t,this._injector=n}copyBlob(){return this._injector.createInstance(exports.FBlob,this._blob)}getAs(t){const n=this.copyBlob();return n.setContentType(t),n}getDataAsString(t){return this._blob===null?Promise.resolve(""):t===void 0?this._blob.text():new Promise((n,r)=>{this._blob.arrayBuffer().then(s=>{const i=new TextDecoder(t).decode(s);n(i)}).catch(s=>{r(new Error(`Failed to read Blob as ArrayBuffer: ${s.message}`))})})}getBytes(){return this._blob?this._blob.arrayBuffer().then(t=>new Uint8Array(t)):Promise.reject(new Error("Blob is undefined or null."))}setBytes(t){return this._blob=new Blob([t]),this}setDataFromString(t,n){const r=n!=null?n:"text/plain",s=new Blob([t],{type:r});return this._blob=s,this}getContentType(){var t;return(t=this._blob)==null?void 0:t.type}setContentType(t){var n;return this._blob=(n=this._blob)==null?void 0:n.slice(0,this._blob.size,t),this}};exports.FBlob=IR([vR(1,it(Rt))],exports.FBlob);var yR=Object.defineProperty,SR=Object.getOwnPropertyDescriptor,OR=(e,t,n,r)=>{for(var s=r>1?void 0:r?SR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&yR(t,n,s),s},bR=(e,t)=>(n,r)=>t(n,r,e);let Ii=class extends go{constructor(e,t){super(t),this.doc=e}};Ii=OR([bR(1,it(Rt))],Ii);var Co=(e=>(e[e.INFO=0]="INFO",e[e.STOP=1]="STOP",e[e.WARNING=2]="WARNING",e))(Co||{}),Ro=(e=>(e.BETWEEN="between",e.EQUAL="equal",e.GREATER_THAN="greaterThan",e.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",e.LESS_THAN="lessThan",e.LESS_THAN_OR_EQUAL="lessThanOrEqual",e.NOT_BETWEEN="notBetween",e.NOT_EQUAL="notEqual",e))(Ro||{}),Io=(e=>(e[e.TEXT=0]="TEXT",e[e.ARROW=1]="ARROW",e[e.CUSTOM=2]="CUSTOM",e))(Io||{}),vo=(e=>(e.VALID="valid",e.INVALID="invalid",e.VALIDATING="validating",e))(vo||{}),yo=(e=>(e.CUSTOM="custom",e.LIST="list",e.LIST_MULTIPLE="listMultiple",e.NONE="none",e.TEXT_LENGTH="textLength",e.DATE="date",e.TIME="time",e.WHOLE="whole",e.DECIMAL="decimal",e.CHECKBOX="checkbox",e.ANY="any",e))(yo||{});const Dn=class Dn{static get(){if(this._instance)return this._instance;const t=new Dn;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(n=>{n!=="constructor"&&(this.prototype[n]=t.prototype[n])}),Object.getOwnPropertyNames(t).forEach(n=>{n!=="prototype"&&n!=="name"&&n!=="length"&&(this[n]=t[n])})}constructor(){for(const t in Dn.prototype)this[t]=Dn.prototype[t]}get UniverInstanceType(){return $e}get LifecycleStages(){return We}get DataValidationType(){return yo}get DataValidationErrorStyle(){return Co}get DataValidationRenderMode(){return Io}get DataValidationOperator(){return Ro}get DataValidationStatus(){return vo}get CommandType(){return Wn}get BaselineOffset(){return Pt}get BooleanNumber(){return Se}get HorizontalAlign(){return Bt}get TextDecoration(){return ro}get TextDirection(){return Pn}get VerticalAlign(){return tn}get BorderType(){return Vi}get BorderStyleTypes(){return Xe}get AutoFillSeries(){return Yi}get ColorType(){return Et}get CommonHideTypes(){return Gi}get CopyPasteType(){return Ki}get DeleteDirection(){return Xi}get DeveloperMetadataVisibility(){return Qi}get Dimension(){return Ji}get Direction(){return qi}get InterpolationPointType(){return Zi}get LocaleType(){return zn}get MentionType(){return dr}get ProtectionType(){return eo}get RelativeDate(){return to}get SheetTypes(){return no}get ThemeColorType(){return ct}};C(Dn,"_instance");let ds=Dn;const xn=class xn{static get(){if(this._instance)return this._instance;const t=new xn;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(n=>{n!=="constructor"&&(this.prototype[n]=t.prototype[n])}),Object.getOwnPropertyNames(t).forEach(n=>{n!=="prototype"&&n!=="name"&&n!=="length"&&(this[n]=t[n])})}constructor(){for(const t in xn.prototype)this[t]=xn.prototype[t]}get DocCreated(){return"DocCreated"}get DocDisposed(){return"DocDisposed"}get LifeCycleChanged(){return"LifeCycleChanged"}get Redo(){return"Redo"}get Undo(){return"Undo"}get BeforeRedo(){return"BeforeRedo"}get BeforeUndo(){return"BeforeUndo"}get CommandExecuted(){return"CommandExecuted"}get BeforeCommandExecute(){return"BeforeCommandExecute"}};C(xn,"_instance");let fs=xn;var wR=Object.defineProperty,AR=Object.getOwnPropertyDescriptor,TR=(e,t,n,r)=>{for(var s=r>1?void 0:r?AR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&wR(t,n,s),s},Wa=(e,t)=>(n,r)=>t(n,r,e);exports.FHooks=class extends Os{constructor(t,n){super(),this._injector=t,this._lifecycleService=n}onStarting(t){return Qe(this._lifecycleService.lifecycle$.pipe(Oe.filter(n=>n===We.Starting)).subscribe(t))}onReady(t){return Qe(this._lifecycleService.lifecycle$.pipe(Oe.filter(n=>n===We.Ready)).subscribe(t))}onRendered(t){return Qe(this._lifecycleService.lifecycle$.pipe(Oe.filter(n=>n===We.Rendered)).subscribe(t))}onSteady(t){return Qe(this._lifecycleService.lifecycle$.pipe(Oe.filter(n=>n===We.Steady)).subscribe(t))}onBeforeUndo(t){return this._injector.get(xt).beforeCommandExecuted(r=>{if(r.id===gn.id){const i=this._injector.get(en).pitchTopUndoElement();i&&t(i)}})}onUndo(t){return this._injector.get(xt).onCommandExecuted(r=>{if(r.id===gn.id){const i=this._injector.get(en).pitchTopUndoElement();i&&t(i)}})}onBeforeRedo(t){return this._injector.get(xt).beforeCommandExecuted(r=>{if(r.id===pn.id){const i=this._injector.get(en).pitchTopRedoElement();i&&t(i)}})}onRedo(t){return this._injector.get(xt).onCommandExecuted(r=>{if(r.id===pn.id){const i=this._injector.get(en).pitchTopRedoElement();i&&t(i)}})}};exports.FHooks=TR([Wa(0,it(Rt)),Wa(1,it(exports.LifecycleService))],exports.FHooks);var NR=Object.defineProperty,MR=Object.getOwnPropertyDescriptor,DR=(e,t,n,r)=>{for(var s=r>1?void 0:r?MR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&NR(t,n,s),s},za=(e,t)=>(n,r)=>t(n,r,e);let vi=class extends Os{constructor(e,t){super(),this._injector=e,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};vi=DR([za(0,it(Rt)),za(1,it($n))],vi);const ps=class ps{static get(){if(this._instance)return this._instance;const t=new ps;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(n=>{n!=="constructor"&&(this.prototype[n]=t.prototype[n])}),Object.getOwnPropertyNames(t).forEach(n=>{n!=="prototype"&&n!=="name"&&n!=="length"&&(this[n]=t[n])})}get rectangle(){return Yt}get numfmt(){return fu}get tools(){return re}};C(ps,"_instance");let gs=ps;var xR=Object.defineProperty,LR=Object.getOwnPropertyDescriptor,UR=(e,t,n,r)=>{for(var s=r>1?void 0:r?LR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&xR(t,n,s),s},Fr=(e,t)=>(n,r)=>t(n,r,e);exports.FUniver=class extends go{constructor(n,r,s,i){super(n);C(this,"_eventRegistry",new Map);this._injector=n,this._commandService=r,this._univerInstanceService=s,this._lifecycleService=i,this.disposeWithMe(this._lifecycleService.lifecycle$.subscribe(o=>{this.fireEvent(this.Event.LifeCycleChanged,{stage:o})})),this.disposeWithMe(this._commandService.beforeCommandExecuted(o=>{if(!this._eventRegistry.get(this.Event.BeforeRedo)&&!this._eventRegistry.get(this.Event.BeforeUndo)&&!this._eventRegistry.get(this.Event.BeforeCommandExecute))return;const{id:a,type:l,params:u}=o,c={id:a,type:l,params:u};switch(o.id){case pn.id:this.fireEvent(this.Event.BeforeRedo,c);break;case gn.id:this.fireEvent(this.Event.BeforeUndo,c);break;default:this.fireEvent(this.Event.BeforeCommandExecute,c);break}if(c.cancel)throw new Pl})),this.disposeWithMe(this._commandService.onCommandExecuted(o=>{if(!this._eventRegistry.get(this.Event.Redo)&&!this._eventRegistry.get(this.Event.Undo)&&!this._eventRegistry.get(this.Event.CommandExecuted))return;const{id:a,type:l,params:u}=o,c={id:a,type:l,params:u};switch(o.id){case pn.id:this.fireEvent(this.Event.Redo,c);break;case gn.id:this.fireEvent(this.Event.Undo,c);break;default:this.fireEvent(this.Event.CommandExecuted,c);break}})),this._initUnitEvent(this._injector),this._injector.onDispose(()=>{this.dispose()})}static newAPI(n){return(n instanceof th?n.__getInjector():n).createInstance(exports.FUniver)}_ensureEventRegistry(n){return this._eventRegistry.has(n)||this._eventRegistry.set(n,new bs),this._eventRegistry.get(n)}_initUnitEvent(n){const r=n.get(an);this.disposeWithMe(r.unitDisposed$.subscribe(s=>{this._eventRegistry.get(this.Event.DocDisposed)&&s.type===$e.UNIVER_DOC&&this.fireEvent(this.Event.DocDisposed,{unitId:s.getUnitId(),unitType:s.type,snapshot:s.getSnapshot()})})),this.disposeWithMe(r.unitAdded$.subscribe(s=>{if(this._eventRegistry.get(this.Event.DocCreated)&&s.type===$e.UNIVER_DOC){const i=s,o=n.createInstance(Ii,i);this.fireEvent(this.Event.DocCreated,{unitId:s.getUnitId(),type:s.type,doc:o,unit:o})}}))}_eventListend(n){return this._eventRegistry.get(n)}disposeUnit(n){return this._univerInstanceService.disposeUnit(n)}getCurrentLifecycleStage(){return this._injector.get(exports.LifecycleService).stage}undo(){return this._commandService.executeCommand(gn.id)}redo(){return this._commandService.executeCommand(pn.id)}onBeforeCommandExecute(n){return this._commandService.beforeCommandExecuted((r,s)=>{n(r,s)})}onCommandExecuted(n){return this._commandService.onCommandExecuted((r,s)=>{n(r,s)})}executeCommand(n,r,s){return this._commandService.executeCommand(n,r,s)}syncExecuteCommand(n,r,s){return this._commandService.syncExecuteCommand(n,r,s)}getHooks(){return this._injector.createInstance(exports.FHooks)}get Enum(){return ds.get()}get Event(){return fs.get()}get Util(){return gs.get()}addEvent(n,r){return this._ensureEventRegistry(n).add(r),Qe(()=>this._ensureEventRegistry(n).delete(r))}fireEvent(n,r){var s;return(s=this._eventRegistry.get(n))==null||s.getData().forEach(i=>{i(r)}),r.cancel}hasEventCallback(n){var s,i;return((i=(s=this._eventRegistry.get(n))==null?void 0:s.getData().length)!=null?i:0)>0}getUserManager(){return this._injector.createInstance(vi)}newBlob(){return this._injector.createInstance(exports.FBlob)}newColor(){return new Rr}newRichText(n){return sn.create(n)}newRichTextValue(n){return Ht.create(n)}newParagraphStyle(n){return kn.create(n)}newParagraphStyleValue(n){return Gn.create(n)}newTextStyle(n){return Wt.create(n)}newTextStyleValue(n){return Vn.create(n)}newTextDecoration(n){return new jt(n)}};exports.FUniver=UR([Fr(0,it(Rt)),Fr(1,xt),Fr(2,an),Fr(3,it(exports.LifecycleService))],exports.FUniver);function nh(e){return/^-?\d+(\.\d+)?$/.test(e)}function PR(e){return nh(e)?Number(e)<=Number.MAX_SAFE_INTEGER:!1}function FR(e){const t=new MessageChannel;let n=!1;const r=()=>{n||e()};return t.port1.onmessage=r,t.port2.postMessage(null),()=>{n=!0,t.port1.close(),t.port2.close()}}function kR(e,t){return t.forEach(n=>e.add(n)),e}function $R(e,t,n,r){var u;if(t==="")return e;const s={id:"mock-id",body:e,documentStyle:{}},i=new Ft(s),o=t.length;let a;for(;(a=(r?i.getBody().dataStream:i.getBody().dataStream.toLowerCase()).indexOf(t))>=0;){const h=new ze,c=Vt.getInstance();if(a>0&&h.retain(a),n.length>0){const d=i.sliceBody(a,a+o),f={dataStream:n};if(Array.isArray(d==null?void 0:d.textRuns)&&d.textRuns.length&&(f.textRuns=[{...d.textRuns[0],st:0,ed:n.length}]),(u=d==null?void 0:d.customRanges)!=null&&u.length){const E=d.customRanges[0];f.customRanges=[{...E,startIndex:0,endIndex:n.length-1}]}h.insert(n.length,f)}h.delete(o),i.apply(c.editOp(h.serialize()))}const l=i.getBody();return i.dispose(),l}const BR="__default_document_sub_component_id20231101__";class rh{constructor(){C(this,"skipNextObservers",!1);C(this,"lastReturnValue");C(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class jR extends Oe.Subject{constructor(){super(...arguments);C(this,"_sortedObservers",[])}subscribe(){throw new Error("[EventSubject]: please use `subscribeEvent` instead of `subscribe` method for `EventSubject`.")}next(){throw new Error("[EventSubject]: please use `emitEvent` instead of `next` method for `EventSubject`.")}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(n){let r;typeof n=="function"?r={next:([i,o])=>n(i,o)}:r=n;const s=super.subscribe(r);return this._sortedObservers.push(r),this._sortedObservers.sort((i,o)=>{var a,l;return((a=i.priority)!=null?a:0)-((l=o.priority)!=null?l:0)}),s.add(()=>this._sortedObservers=this._sortedObservers.filter(i=>i!==r)),s}clearObservers(){this._sortedObservers.forEach(n=>{var r;return(r=n.complete)==null?void 0:r.call(n)}),this._sortedObservers.length=0}emitEvent(n){var r;if(!this.closed){const s=new rh;s.lastReturnValue=n;for(const i of this._sortedObservers){const o=(r=i.next)==null?void 0:r.call(i,[n,s]);if(s.lastReturnValue=o,s.skipNextObservers)return{handled:!0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}throw new Error("[EventSubject]: cannot emit event on a closed subject.")}}function HR(e){return new Oe.Observable(t=>{const n=e.subscribeEvent(r=>{t.next(r)});return()=>n.unsubscribe()})}const WR=_t("ILocalStorageService");function zR(e){return!(e.length===0||e.length>31||e.startsWith("'")||e.endsWith("'")||/[:\\\/\?\*\[\]]/.test(e))}function YR(e){return new Promise(t=>setTimeout(t,e))}function VR(e=1){return new Promise(t=>{let n=0;const r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}var So=(e=>(e.URL="URL",e.UUID="UUID",e.BASE64="BASE64",e))(So||{}),sh=(e=>(e.SUCCUSS="0",e.ERROR_EXCEED_SIZE="1",e.ERROR_IMAGE_TYPE="2",e.ERROR_UPLOAD_COUNT_LIMIT="3",e.ERROR_IMAGE="4",e))(sh||{});const yi=_t("core.image-io.service");class GR{constructor(t,n=100){C(this,"_imageCacheMap");this._injector=t,this._imageCacheMap=new fr(n)}_getImageCacheKey(t,n){return`${t}-${n}`}getImage(t,n,r,s){const i=this._getImageCacheKey(t,n);let o=this._imageCacheMap.get(i);return o||((async()=>{o=new Image;const a=this._injector.has(yi)?this._injector.get(yi):null;if(t===So.UUID)try{o.src=await(a==null?void 0:a.getImage(n))||""}catch(l){console.error(l)}else o.src=n;o.onload=()=>{r==null||r()},o.onerror=()=>{s==null||s()},this._imageCacheMap.set(i,o)})(),null)}}const KR=["script","style","meta","comment","link"];var ih=(e=>(e[e.DISABLED=0]="DISABLED",e[e.FULL_ALPHA=1]="FULL_ALPHA",e[e.FULL_HANGUL=2]="FULL_HANGUL",e[e.FULL_KATAKANA=3]="FULL_KATAKANA",e[e.HALF_ALPHA=4]="HALF_ALPHA",e[e.HALF_HANGUL=5]="HALF_HANGUL",e[e.HALF_KATAKANA=6]="HALF_KATAKANA",e[e.HIRAGANA=7]="HIRAGANA",e[e.NO_CONTROL=8]="NO_CONTROL",e[e.OFF=9]="OFF",e[e.ON=10]="ON",e))(ih||{});const Ya=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],js=1,Qn=8;class Oo{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[n,r]=new Uint8Array(t,0,2);if(n!==219)throw new Error("Data does not appear to be in a KDBush format.");const s=r>>4;if(s!==js)throw new Error(`Got v${s} data when expected v${js}.`);const i=Ya[r&15];if(!i)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new Oo(a,o,i,t)}constructor(t,n=64,r=Float64Array,s){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+n,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=Ya.indexOf(this.ArrayType),o=t*2*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);s&&s instanceof ArrayBuffer?(this.data=s,this.ids=new this.IndexArrayType(this.data,Qn,t),this.coords=new this.ArrayType(this.data,Qn+a+l,t*2),this._pos=t*2,this._finished=!0):(this.data=new ArrayBuffer(Qn+o+a+l),this.ids=new this.IndexArrayType(this.data,Qn,t),this.coords=new this.ArrayType(this.data,Qn+a+l,t*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(js<<4)+i]),new Uint16Array(this.data,2,1)[0]=n,new Uint32Array(this.data,4,1)[0]=t)}add(t,n){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=n,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Si(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,n,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:o,nodeSize:a}=this,l=[0,i.length-1,0],u=[];for(;l.length;){const h=l.pop()||0,c=l.pop()||0,d=l.pop()||0;if(c-d<=a){for(let O=d;O<=c;O++){const U=o[2*O],ne=o[2*O+1];U>=t&&U<=r&&ne>=n&&ne<=s&&u.push(i[O])}continue}const f=d+c>>1,E=o[2*f],R=o[2*f+1];E>=t&&E<=r&&R>=n&&R<=s&&u.push(i[f]),(h===0?t<=E:n<=R)&&(l.push(d),l.push(f-1),l.push(1-h)),(h===0?r>=E:s>=R)&&(l.push(f+1),l.push(c),l.push(1-h))}return u}within(t,n,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:i,nodeSize:o}=this,a=[0,s.length-1,0],l=[],u=r*r;for(;a.length;){const h=a.pop()||0,c=a.pop()||0,d=a.pop()||0;if(c-d<=o){for(let O=d;O<=c;O++)Va(i[2*O],i[2*O+1],t,n)<=u&&l.push(s[O]);continue}const f=d+c>>1,E=i[2*f],R=i[2*f+1];Va(E,R,t,n)<=u&&l.push(s[f]),(h===0?t-r<=E:n-r<=R)&&(a.push(d),a.push(f-1),a.push(1-h)),(h===0?t+r>=E:n+r>=R)&&(a.push(f+1),a.push(c),a.push(1-h))}return l}}function Si(e,t,n,r,s,i){if(s-r<=n)return;const o=r+s>>1;oh(e,t,o,r,s,i),Si(e,t,n,r,o-1,1-i),Si(e,t,n,o+1,s,1-i)}function oh(e,t,n,r,s,i){for(;s>r;){if(s-r>600){const u=s-r+1,h=n-r+1,c=Math.log(u),d=.5*Math.exp(2*c/3),f=.5*Math.sqrt(c*d*(u-d)/u)*(h-u/2<0?-1:1),E=Math.max(r,Math.floor(n-h*d/u+f)),R=Math.min(s,Math.floor(n+(u-h)*d/u+f));oh(e,t,n,E,R,i)}const o=t[2*n+i];let a=r,l=s;for(Jn(e,t,r,n),t[2*s+i]>o&&Jn(e,t,r,s);a<l;){for(Jn(e,t,a,l),a++,l--;t[2*a+i]<o;)a++;for(;t[2*l+i]>o;)l--}t[2*r+i]===o?Jn(e,t,r,l):(l++,Jn(e,t,l,s)),l<=n&&(r=l+1),n<=l&&(s=l-1)}}function Jn(e,t,n,r){Hs(e,n,r),Hs(t,2*n,2*r),Hs(t,2*n+1,2*r+1)}function Hs(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function Va(e,t,n,r){const s=e-n,i=t-r;return s*s+i*i}function ah(e,t,n=0,r=e.length-1,s=XR){for(;r>n;){if(r-n>600){const l=r-n+1,u=t-n+1,h=Math.log(l),c=.5*Math.exp(2*h/3),d=.5*Math.sqrt(h*c*(l-c)/l)*(u-l/2<0?-1:1),f=Math.max(n,Math.floor(t-u*c/l+d)),E=Math.min(r,Math.floor(t+(l-u)*c/l+d));ah(e,t,f,E,s)}const i=e[t];let o=n,a=r;for(qn(e,n,t),s(e[r],i)>0&&qn(e,n,r);o<a;){for(qn(e,o,a),o++,a--;s(e[o],i)<0;)o++;for(;s(e[a],i)>0;)a--}s(e[n],i)===0?qn(e,n,a):(a++,qn(e,a,r)),a<=t&&(n=a+1),t<=a&&(r=a-1)}}function qn(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function XR(e,t){return e<t?-1:e>t?1:0}class Oi{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let n=this.data;const r=[];if(!$r(t,n))return r;const s=this.toBBox,i=[];for(;n;){for(let o=0;o<n.children.length;o++){const a=n.children[o],l=n.leaf?s(a):a;$r(t,l)&&(n.leaf?r.push(a):zs(t,l)?this._all(a,r):i.push(a))}n=i.pop()}return r}collides(t){let n=this.data;if(!$r(t,n))return!1;const r=[];for(;n;){for(let s=0;s<n.children.length;s++){const i=n.children[s],o=n.leaf?this.toBBox(i):i;if($r(t,o)){if(n.leaf||zs(t,o))return!0;r.push(i)}}n=r.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let r=0;r<t.length;r++)this.insert(t[r]);return this}let n=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=n;else if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){const r=this.data;this.data=n,n=r}this._insert(n,this.data.height-n.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=On([]),this}remove(t,n){if(!t)return this;let r=this.data;const s=this.toBBox(t),i=[],o=[];let a,l,u;for(;r||i.length;){if(r||(r=i.pop(),l=i[i.length-1],a=o.pop(),u=!0),r.leaf){const h=QR(t,r.children,n);if(h!==-1)return r.children.splice(h,1),i.push(r),this._condense(i),this}!u&&!r.leaf&&zs(r,s)?(i.push(r),o.push(a),a=0,l=r,r=r.children[0]):l?(a++,r=l.children[a],u=!1):r=null}return this}toBBox(t){return t}compareMinX(t,n){return t.minX-n.minX}compareMinY(t,n){return t.minY-n.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,n){const r=[];for(;t;)t.leaf?n.push(...t.children):r.push(...t.children),t=r.pop();return n}_build(t,n,r,s){const i=r-n+1;let o=this._maxEntries,a;if(i<=o)return a=On(t.slice(n,r+1)),yn(a,this.toBBox),a;s||(s=Math.ceil(Math.log(i)/Math.log(o)),o=Math.ceil(i/Math.pow(o,s-1))),a=On([]),a.leaf=!1,a.height=s;const l=Math.ceil(i/o),u=l*Math.ceil(Math.sqrt(o));Ga(t,n,r,u,this.compareMinX);for(let h=n;h<=r;h+=u){const c=Math.min(h+u-1,r);Ga(t,h,c,l,this.compareMinY);for(let d=h;d<=c;d+=l){const f=Math.min(d+l-1,c);a.children.push(this._build(t,d,f,s-1))}}return yn(a,this.toBBox),a}_chooseSubtree(t,n,r,s){for(;s.push(n),!(n.leaf||s.length-1===r);){let i=1/0,o=1/0,a;for(let l=0;l<n.children.length;l++){const u=n.children[l],h=Ws(u),c=ZR(t,u)-h;c<o?(o=c,i=h<i?h:i,a=u):c===o&&h<i&&(i=h,a=u)}n=a||n.children[0]}return n}_insert(t,n,r){const s=r?t:this.toBBox(t),i=[],o=this._chooseSubtree(s,this.data,n,i);for(o.children.push(t),or(o,s);n>=0&&i[n].children.length>this._maxEntries;)this._split(i,n),n--;this._adjustParentBBoxes(s,i,n)}_split(t,n){const r=t[n],s=r.children.length,i=this._minEntries;this._chooseSplitAxis(r,i,s);const o=this._chooseSplitIndex(r,i,s),a=On(r.children.splice(o,r.children.length-o));a.height=r.height,a.leaf=r.leaf,yn(r,this.toBBox),yn(a,this.toBBox),n?t[n-1].children.push(a):this._splitRoot(r,a)}_splitRoot(t,n){this.data=On([t,n]),this.data.height=t.height+1,this.data.leaf=!1,yn(this.data,this.toBBox)}_chooseSplitIndex(t,n,r){let s,i=1/0,o=1/0;for(let a=n;a<=r-n;a++){const l=ir(t,0,a,this.toBBox),u=ir(t,a,r,this.toBBox),h=e0(l,u),c=Ws(l)+Ws(u);h<i?(i=h,s=a,o=c<o?c:o):h===i&&c<o&&(o=c,s=a)}return s||r-n}_chooseSplitAxis(t,n,r){const s=t.leaf?this.compareMinX:JR,i=t.leaf?this.compareMinY:qR,o=this._allDistMargin(t,n,r,s),a=this._allDistMargin(t,n,r,i);o<a&&t.children.sort(s)}_allDistMargin(t,n,r,s){t.children.sort(s);const i=this.toBBox,o=ir(t,0,n,i),a=ir(t,r-n,r,i);let l=kr(o)+kr(a);for(let u=n;u<r-n;u++){const h=t.children[u];or(o,t.leaf?i(h):h),l+=kr(o)}for(let u=r-n-1;u>=n;u--){const h=t.children[u];or(a,t.leaf?i(h):h),l+=kr(a)}return l}_adjustParentBBoxes(t,n,r){for(let s=r;s>=0;s--)or(n[s],t)}_condense(t){for(let n=t.length-1,r;n>=0;n--)t[n].children.length===0?n>0?(r=t[n-1].children,r.splice(r.indexOf(t[n]),1)):this.clear():yn(t[n],this.toBBox)}}function QR(e,t,n){if(!n)return t.indexOf(e);for(let r=0;r<t.length;r++)if(n(e,t[r]))return r;return-1}function yn(e,t){ir(e,0,e.children.length,t,e)}function ir(e,t,n,r,s){s||(s=On(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let i=t;i<n;i++){const o=e.children[i];or(s,e.leaf?r(o):o)}return s}function or(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function JR(e,t){return e.minX-t.minX}function qR(e,t){return e.minY-t.minY}function Ws(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function kr(e){return e.maxX-e.minX+(e.maxY-e.minY)}function ZR(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function e0(e,t){const n=Math.max(e.minX,t.minX),r=Math.max(e.minY,t.minY),s=Math.min(e.maxX,t.maxX),i=Math.min(e.maxY,t.maxY);return Math.max(0,s-n)*Math.max(0,i-r)}function zs(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function $r(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function On(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Ga(e,t,n,r,s){const i=[t,n];for(;i.length;){if(n=i.pop(),t=i.pop(),n-t<=r)continue;const o=t+Math.ceil((n-t)/r/2)*r;ah(e,o,t,n,s),i.push(t,o,o,n)}}class t0{constructor(t=!1){C(this,"_tree",new Map);C(this,"_oneCellCache",new Map);C(this,"_kdTree",new Map);this._enableOneCellCache=t}dispose(){this.clear()}getTree(t,n){return this._tree.has(t)||this._tree.set(t,new Map),this._tree.get(t).has(n)||this._tree.get(t).set(n,new Oi),this._tree.get(t).get(n)}_getOneCellCache(t,n,r,s){return this._oneCellCache.has(t)||this._oneCellCache.set(t,new Map),this._oneCellCache.get(t).has(n)||this._oneCellCache.get(t).set(n,new Map),this._oneCellCache.get(t).get(n).has(r)||this._oneCellCache.get(t).get(n).set(r,new Map),this._oneCellCache.get(t).get(n).get(r).has(s)||this._oneCellCache.get(t).get(n).get(r).set(s,new Set),this._oneCellCache.get(t).get(n).get(r).get(s)}_removeOneCellCache(t,n,r,s,i){const o=this._oneCellCache.get(t);if(!o)return;const a=o.get(n);if(!a)return;const l=a.get(r);if(!l)return;const u=l.get(s);u&&u.delete(i)}_removeCellCacheByRange(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this._oneCellCache.get(n);if(!o)return;const a=o.get(r);if(!a)return;const{startRow:l,startColumn:u,endRow:h,endColumn:c}=s;for(let d=l;d<=h;d++){const f=a.get(d);if(f)for(let E=u;E<=c;E++){const R=f.get(E);R&&R.delete(i)}}}_insertOneCellCache(t,n,r,s,i){this._getOneCellCache(t,n,r,s).add(i)}_getRdTreeItems(t){const n=[];for(const[r,s]of t)for(const[i,o]of s)n.push({x:i,y:r,ids:o});return n}_searchByOneCellCache(t){var E;const{unitId:n,sheetId:r,range:s}=t,{startRow:i,startColumn:o,endRow:a,endColumn:l}=s,u=(E=this._kdTree.get(n))==null?void 0:E.get(r);if(!u)return[];const{tree:h,items:c}=u,d=h.range(o,i,l,a),f=[];for(const R of d){const O=c[R];f.push(...Array.from(O.ids))}return f}openKdTree(){var t;for(const[n,r]of this._oneCellCache){this._kdTree.has(n)||this._kdTree.set(n,new Map);for(const[s,i]of r){const o=this._getRdTreeItems(i),a=new Oo(o.length);(t=this._kdTree.get(n))==null||t.set(s,{tree:a,items:o});for(const l of o)a.add(l.x,l.y);a.finish()}}}closeKdTree(){var t;for(const[n,r]of this._oneCellCache)for(const[s,i]of r)(t=this._kdTree.get(n))==null||t.set(s,void 0)}insert(t){const{unitId:n,sheetId:r,range:s,id:i}=t;if(!n||n.length===0)return;let{startRow:o,endRow:a,startColumn:l,endColumn:u}=s;if(this._enableOneCellCache&&o===a&&l===u){this._insertOneCellCache(n,r,o,l,i);return}const h=this.getTree(n,r);Number.isNaN(o)&&(o=0),Number.isNaN(l)&&(l=0),Number.isNaN(a)&&(a=Number.POSITIVE_INFINITY),Number.isNaN(u)&&(u=Number.POSITIVE_INFINITY),h.insert({minX:l,minY:o,maxX:u,maxY:a,id:i})}bulkInsert(t){for(const n of t)this.insert(n)}*searchGenerator(t){var a;const{unitId:n,sheetId:r,range:s}=t;if(this._enableOneCellCache){const l=this._searchByOneCellCache(t);for(const u of l)yield u}const i=(a=this._tree.get(n))==null?void 0:a.get(r);if(!i)return;const o=i.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(const l of o)yield l.id}bulkSearch(t,n){const r=new Set;for(const s of t)for(const i of this.searchGenerator(s))(n==null?void 0:n.has(i))!==!0&&r.add(i);return r}removeById(t,n){var r,s;n?((r=this._tree.get(t))==null||r.delete(n),(s=this._oneCellCache.get(t))==null||s.delete(n)):(this._tree.delete(t),this._oneCellCache.delete(t))}_removeRTreeItem(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this.getTree(n,r),a=o.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(let l=0;l<a.length;l++)a[l].id===i&&o.remove(a[l])}remove(t){const{unitId:n,sheetId:r,range:s,id:i}=t,{startRow:o,startColumn:a,endRow:l,endColumn:u}=s;this._enableOneCellCache?o===l&&a===u?this._removeOneCellCache(n,r,s.startRow,s.startColumn,i):(this._removeCellCacheByRange(t),this._removeRTreeItem(t)):this._removeRTreeItem(t)}bulkRemove(t){for(const n of t)this.remove(n)}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){const t={};return this._tree.forEach((n,r)=>{t[r]={},n.forEach((s,i)=>{t[r][i]=s.toJSON()})}),t}fromJSON(t){this._tree.clear();for(const n in t){this._tree.set(n,new Map);for(const r in t[n]){const s=new Oi;s.fromJSON(t[n][r]),this._tree.get(n).set(r,s)}}}}dh();exports.ABCToNumber=j_;exports.AUTO_HEIGHT_FOR_MERGED_CELLS=yg;exports.AbsoluteRefType=tt;exports.ActionIterator=Sn;exports.AlignTypeH=ju;exports.AlignTypeV=Hu;exports.ArrangeTypeEnum=Yu;exports.ArrowsAndMarkersShapes=Ql;exports.AsyncInterceptorManager=cC;exports.AutoFillSeries=Yi;exports.BaselineOffset=Pt;exports.BasicShapes=Xl;exports.BlockType=Ru;exports.BooleanNumber=Se;exports.BorderStyleTypes=Xe;exports.BorderType=Vi;exports.BuildTextUtils=st;exports.BulletAlignment=vr;exports.COLORS=oi;exports.CanceledError=Pl;exports.CellModeEnum=bn;exports.CellValueType=nn;exports.Color=En;exports.ColorBuilder=Rr;exports.ColorKit=bt;exports.ColorType=Et;exports.ColumnSeparatorType=yu;exports.CommandType=Wn;exports.CommonHideTypes=Gi;exports.ConfigService=Vc;exports.ContextService=Bl;exports.CopyPasteType=Ki;exports.CustomCommandExecutionError=ri;exports.CustomDecorationType=fn;exports.CustomRangeType=on;exports.DEFAULT_CELL=w_;exports.DEFAULT_DOC=fo;exports.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=BR;exports.DEFAULT_EMPTY_DOCUMENT_VALUE=_l;exports.DEFAULT_RANGE=O_;exports.DEFAULT_RANGE_ARRAY=S_;exports.DEFAULT_SELECTION=b_;exports.DEFAULT_SLIDE=gu;exports.DEFAULT_STYLES=ht;exports.DEFAULT_WORKSHEET_COLUMN_COUNT=Nc;exports.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=yC;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Lc;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=wC;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH=Dc;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=OC;exports.DEFAULT_WORKSHEET_ROW_COUNT=Tc;exports.DEFAULT_WORKSHEET_ROW_COUNT_KEY=vC;exports.DEFAULT_WORKSHEET_ROW_HEIGHT=Mc;exports.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=SC;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=xc;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=bC;exports.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=Pi;exports.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=Ui;exports.DOCS_ZEN_EDITOR_UNIT_ID_KEY=ml;exports.DOC_RANGE_TYPE=ou;exports.DashStyleType=Nu;exports.DataStreamTreeNodeType=Ic;exports.DataStreamTreeTokenType=qt;exports.DataValidationErrorStyle=Co;exports.DataValidationImeMode=ih;exports.DataValidationOperator=Ro;exports.DataValidationRenderMode=Io;exports.DataValidationStatus=vo;exports.DataValidationType=yo;exports.DeleteDirection=Xi;exports.DependentOn=gR;exports.DesktopLogService=Hl;exports.DeveloperMetadataVisibility=Qi;exports.Dimension=Ji;exports.Direction=qi;exports.Disposable=nt;exports.DisposableCollection=Is;exports.DocStyleType=Eu;exports.DocumentDataModel=Ft;exports.DocumentFlavor=ao;exports.DrawingTypeEnum=Vu;exports.EDITOR_ACTIVATED=kc;exports.EXTENSION_NAMES=pu;exports.ErrorService=Gc;exports.EventState=rh;exports.EventSubject=jR;exports.FBase=Os;exports.FBaseInitialable=go;exports.FEnum=ds;exports.FEventName=fs;exports.FOCUSING_COMMON_DRAWINGS=jC;exports.FOCUSING_DOC=rr;exports.FOCUSING_EDITOR_BUT_HIDDEN=UC;exports.FOCUSING_EDITOR_INPUT_FORMULA=PC;exports.FOCUSING_EDITOR_STANDALONE=kC;exports.FOCUSING_FX_BAR_EDITOR=$c;exports.FOCUSING_PANEL_EDITOR=$C;exports.FOCUSING_SHEET=Tn;exports.FOCUSING_SLIDE=sr;exports.FOCUSING_UNIT=nr;exports.FOCUSING_UNIVER_EDITOR=FC;exports.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=BC;exports.FORMULA_EDITOR_ACTIVATED=HC;exports.FUtil=gs;exports.FollowNumberWithType=Cu;exports.FontItalic=ss;exports.FontStyleType=wn;exports.FontWeight=is;exports.GridType=Iu;exports.HLSColor=ru;exports.HorizontalAlign=Bt;exports.IAuthzIoService=zc;exports.ICommandService=xt;exports.IConfigService=Yc;exports.IContextService=Cr;exports.IImageIoService=yi;exports.ILocalStorageService=WR;exports.ILogService=At;exports.IMentionIOService=Kc;exports.IPermissionService=Xc;exports.IResourceLoaderService=Ri;exports.IResourceManagerService=ws;exports.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=vg;exports.IUndoRedoService=en;exports.IUniverInstanceService=an;exports.ImageCacheMap=GR;exports.ImageSourceType=So;exports.ImageUploadStatusType=sh;exports.Inject=it;exports.Injector=Rt;exports.InterceptorEffectEnum=An;exports.InterceptorManager=aC;exports.InterpolationPointType=Zi;exports.JSON1=tE;exports.JSONX=Vt;exports.LRUHelper=er;exports.LRUMap=fr;exports.LifecycleStages=We;exports.ListGlyphType=Ne;exports.LocaleService=ur;exports.LocaleType=zn;exports.LogLevel=jl;exports.MOVE_BUFFER_VALUE=Zn;exports.Many=bl;exports.MemoryCursor=Yn;exports.MentionType=dr;exports.NamedStyleType=Au;exports.NilCommand=Wl;exports.NumberUnitType=Bu;exports.ObjectMatrix=Lt;exports.ObjectRelativeFromH=ku;exports.ObjectRelativeFromV=$u;exports.Optional=wl;exports.OtherShapes=Jl;exports.PRESET_LIST_TYPE=Sr;exports.PageElementType=Gu;exports.PageOrientType=zu;exports.PageType=lo;exports.ParagraphElementType=Ou;exports.ParagraphStyleBuilder=kn;exports.ParagraphStyleValue=Gn;exports.PermissionService=Qc;exports.PermissionStatus=_o;exports.Plugin=Ei;exports.PositionedObjectLayoutType=wu;exports.PresetListType=Ut;exports.ProtectionType=eo;exports.QuickListType=uc;exports.QuickListTypeMap=aE;exports.RANGE_DIRECTION=iu;exports.RANGE_TYPE=xe;exports.RBush=Oi;exports.RCDisposable=Ep;exports.RGBA_PAREN=Xp;exports.RGB_PAREN=Kp;exports.ROTATE_BUFFER_VALUE=Kl;exports.RTree=t0;exports.Range=Fn;exports.Rectangle=Yt;exports.RediConsumer=Ml;exports.RediContext=Er;exports.RediError=ot;exports.RediProvider=Wi;exports.RedoCommand=pn;exports.RedoCommandId=Hc;exports.RefAlias=B_;exports.Registry=bs;exports.RegistryAsMap=po;exports.RelativeDate=to;exports.RelativeSlideLink=Ku;exports.ResourceManagerService=eh;exports.RgbColor=os;exports.RichTextBuilder=sn;exports.RichTextValue=Ht;exports.RxDisposable=_p;exports.SHEET_EDITOR_UNITS=A_;exports.SectionType=vu;exports.Self=Ol;exports.SheetTypes=no;exports.SheetViewModel=Pc;exports.SkipSelf=Sl;exports.SliceBodyType=ho;exports.SlideDataModel=mo;exports.SpacingRule=Tu;exports.SpecialShapes=ql;exports.Styles=Oc;exports.THEME_COLORS=nu;exports.TabStopAlignment=Mu;exports.TableAlignmentType=xu;exports.TableLayoutType=Lu;exports.TableRowHeightRule=Pu;exports.TableSizeType=Du;exports.TableTextWrapType=Uu;exports.TextDecoration=ro;exports.TextDecorationBuilder=jt;exports.TextDirection=Pn;exports.TextDirectionType=Su;exports.TextStyleBuilder=Wt;exports.TextStyleValue=Vn;exports.TextX=ze;exports.TextXActionType=ce;exports.ThemeColor=as;exports.ThemeColorType=ct;exports.ThemeColors=vs;exports.ThemeService=Eo;exports.Tools=re;exports.UndoCommand=gn;exports.UndoCommandId=Wc;exports.UnitModel=Ss;exports.Univer=th;exports.UniverInstanceType=$e;exports.UpdateDocsAttributeType=Pe;exports.UserManagerService=$n;exports.VerticalAlign=tn;exports.VerticalAlignmentType=Fu;exports.WithDependency=sp;exports.WithNew=Al;exports.Worksheet=gr;exports.WrapStrategy=_n;exports.WrapTextType=bu;exports.addLinkToDocumentModel=bc;exports.afterInitApply=Ap;exports.afterTime=wp;exports.awaitTime=YR;exports.binSearchFirstGreaterThanTarget=Gl;exports.binarySearchArray=Tp;exports.bufferDebounceTime=bp;exports.cellToRange=Sm;exports.characterSpacingControlType=Wu;exports.checkForSubstrings=Om;exports.checkIfMove=Dp;exports.checkParagraphHasBullet=a_;exports.checkParagraphHasIndent=l_;exports.checkParagraphHasIndentByStyle=cu;exports.codeToBlob=Mp;exports.composeBody=pi;exports.composeInterceptors=Sc;exports.composeStyles=si;exports.concatMatrixArray=R_;exports.connectDependencies=tp;exports.connectInjector=ep;exports.convertBodyToHtml=Gp;exports.convertCellToRange=au;exports.covertTextRunToHtml=ii;exports.createAsyncInterceptorKey=lC;exports.createDefaultUser=cs;exports.createDocumentModelWithStyle=tr;exports.createIdentifier=_t;exports.createInterceptorKey=oC;exports.createInternalEditorID=Sg;exports.createRowColIter=ci;exports.dayjs=Kt;exports.debounce=ag;exports.dedupe=mg;exports.deepCompare=io;exports.delayAnimationFrame=VR;exports.deleteContent=du;exports.extractPureTextFromCell=Fc;exports.forwardRef=Fg;exports.fromCallback=zl;exports.fromEventSubject=HR;exports.fromObservable=mp;exports.generateRandomId=zt;exports.get=kf;exports.getArrayLength=rn;exports.getBodySlice=Tt;exports.getBodySliceHtml=Wr;exports.getBorderStyleType=Im;exports.getCellInfoInMergeData=gm;exports.getCellValueType=cm;exports.getColorStyle=Mt;exports.getCustomBlockSlice=fc;exports.getCustomDecorationSlice=pc;exports.getCustomRangeSlice=gc;exports.getDocsUpdateBody=vm;exports.getIntersectRange=L_;exports.getOriginCellValue=TC;exports.getParagraphsSlice=dc;exports.getReverseDirection=xp;exports.getSectionBreakSlice=mE;exports.getTableSlice=hc;exports.getTextRunSlice=us;exports.getWorksheetUID=LC;exports.groupBy=Cg;exports.handleStyleToString=Rm;exports.hashAlgorithm=h_;exports.horizontalLineSegmentsSubtraction=ys;exports.insertMatrixArray=ai;exports.insertTextToContent=hu;exports.isAsyncDependencyItem=Js;exports.isAsyncHook=jr;exports.isBlackColor=am;exports.isBooleanString=Ig;exports.isCellCoverable=_m;exports.isCellV=dm;exports.isClassDependencyItem=Ks;exports.isCtor=ki;exports.isDisposable=ei;exports.isEmptyCell=lu;exports.isFactoryDependencyItem=Xs;exports.isFormulaId=Cm;exports.isFormulaString=Em;exports.isICellData=um;exports.isInternalEditorID=El;exports.isNodeEnv=Vp;exports.isNotNullOrUndefined=wc;exports.isNullCell=hm;exports.isNumeric=nh;exports.isRangesEqual=gC;exports.isRealNum=c_;exports.isSafeNumeric=PR;exports.isSameStyleTextRun=uu;exports.isUnitRangesEqual=pC;exports.isValidRange=ym;exports.isValueDependencyItem=Qs;exports.isWhiteColor=lm;exports.makeArray=Rg;exports.makeCellRangeToRangeData=mm;exports.makeCellToSelection=pm;exports.makeCustomRangeStream=JE;exports.merge=xi;exports.mergeOverrideWithDependencies=Jc;exports.mergeSets=kR;exports.mergeWith=hg;exports.mergeWorksheetSnapshotWithDefault=Uc;exports.mixinClass=hC;exports.moveMatrixArray=ui;exports.moveRangeByOffset=T_;exports.nameCharacterCheck=zR;exports.normalizeBody=_E;exports.normalizeTextRuns=yr;exports.numberToABC=W_;exports.numberToListABC=z_;exports.numfmt=fu;exports.queryObjectMatrix=$_;exports.registerDependencies=fp;exports.remove=mr;exports.repeatStringNumTimes=_u;exports.replaceInDocumentBody=$R;exports.requestImmediateMacroTask=FR;exports.rotate=Eg;exports.searchArray=Np;exports.searchInOrderedArray=Vl;exports.selectionToArray=fm;exports.sequence=kl;exports.sequenceAsync=Fl;exports.sequenceExecute=zi;exports.sequenceExecuteAsync=Op;exports.set=fg;exports.setDependencies=Pg;exports.shallowEqual=Ul;exports.skipParseTagNames=KR;exports.sliceMatrixArray=I_;exports.sortRules=Y_;exports.sortRulesByDesc=V_;exports.sortRulesFactory=Ir;exports.spliceArray=li;exports.splitIntoGrid=oo;exports.takeAfter=Yl;exports.textDiff=Li;exports.throttle=iC;exports.toDisposable=Qe;exports.touchDependencies=Ll;exports.updateAttributeByDelete=mc;exports.updateAttributeByInsert=_c;exports.useDependency=ap;exports.useDependencyContext=hp;exports.useDependencyContextValue=dp;exports.useDependencyValue=xl;exports.useInjector=Dl;exports.useObservable=up;exports.useUpdateBinder=cp;
|
|
12
|
+
`,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(n){return new sn(n!=null?n:sn.newEmptyData())}insertText(n,r,s){var h,c;let i=((c=(h=this._data.body)==null?void 0:h.dataStream.length)!=null?c:2)-2,o,a;if(typeof n=="string"?o=n:(i=Math.min(n,i),o=r),typeof r=="object"?a=r instanceof Wt?r.build():r:a=s instanceof Wt?s.build():s,!o)return this;const l={dataStream:o,textRuns:a?[{ts:a,st:i,ed:i+o.length}]:[]},u=st.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:l});if(!u)throw new Error("Insert text failed, please check.");return ze.apply(this._doc.getBody(),u.serialize()),this}insertRichText(n,r){var a,l;let s=((l=(a=this._data.body)==null?void 0:a.dataStream.length)!=null?l:2)-2,i;typeof n=="object"?i=n instanceof Ht?n.getData():n:(s=Math.min(n,s),i=r instanceof Ht?r.getData():r);const o=st.selection.replace({doc:this._doc,selection:{startOffset:s,endOffset:s,collapsed:!0},body:i.body});if(!o)throw new Error("Insert text failed, please check.");return ze.apply(this._doc.getBody(),o.serialize()),this}delete(n,r){if(r!==void 0){if(!r)return this;const s=st.selection.delete([{startOffset:n,endOffset:n+r,collapsed:!0}],this._data.body);ze.apply(this._doc.getBody(),s)}return this}setStyle(n,r,s){const i={dataStream:"",textRuns:[{ts:s instanceof Wt?s.build():s,st:0,ed:r-n}]},o=st.selection.retain([{startOffset:n,endOffset:r,collapsed:!0}],i);return ze.apply(this._doc.getBody(),o),this}setLink(n,r,s){const i=st.customRange.add({rangeType:on.HYPERLINK,rangeId:zt(),properties:{url:s},ranges:[{startOffset:n,endOffset:r,collapsed:!1}],body:this._data.body});if(!i)throw new Error("Insert text failed, please check.");return ze.apply(this._doc.getBody(),i.serialize()),this}cancelLink(n,r){if(typeof n=="string"){const s=st.customRange.delete({rangeId:n,documentDataModel:this._doc});if(!s)throw new Error("Insert text failed, please check.");ze.apply(this._doc.getBody(),s.serialize())}else this.slice(n,r).getLinks().forEach(i=>{const o=st.customRange.delete({rangeId:i.rangeId,documentDataModel:this._doc});if(!o)throw new Error("Insert text failed, please check.");ze.apply(this._doc.getBody(),o.serialize())});return this}updateLink(n,r){var i,o;const s=(o=(i=this._data.body)==null?void 0:i.customRanges)==null?void 0:o.find(a=>a.rangeId===n);if(!s)throw new Error("Link not found");return s.properties.url=r,this}insertParagraph(n,r){var o,a;let s,i;return typeof n=="object"?(s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:n.build()}]},i=((a=(o=this._data.body)==null?void 0:o.dataStream.length)!=null?a:2)-2):(i=n,s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:r==null?void 0:r.build()}]}),this.insertRichText(i,Ht.create({body:s,id:"d",documentStyle:{}})),this}insertLink(n,r,s){let i="",o="";typeof n=="string"?(i=n,o=r):(i=r,o=s);const a=sn.createByBody({dataStream:i,customRanges:[{rangeType:on.HYPERLINK,rangeId:zt(),properties:{url:o},startIndex:0,endIndex:i.length-1}]});return typeof n=="number"?this.insertRichText(n,a):this.insertRichText(a)}}function iC(e,t=16){let n=0,r=null;return function(...i){const o=Date.now();o-n<t?(r&&clearTimeout(r),r=setTimeout(()=>{n=o,e.apply(this,i)},t)):(n=o,e.apply(this,i))}}var An=(e=>(e[e.Style=1]="Style",e[e.Value=2]="Value",e))(An||{});function oC(e){return`sheet_interceptor_${e}`}const Sc=e=>function(t,n){let r=-1,s=t;for(let i=0;i<=e.length;i++){if(i<=r)throw new Error("[SheetInterceptorService]: next() called multiple times!");if(r=i,i===e.length)return s;const o=e[i];let a=!1;if(s=o.handler(s,n,l=>(a=!0,l)),!a)break}return s};class aC{constructor(t){C(this,"_interceptorsByName",new Map);C(this,"_interceptorPoints");this._interceptorPoints=t}fetchThroughInterceptors(t,n){const r=t;let s=this._interceptorsByName.get(r);return n&&(s=s.filter(n)),Sc(s||[])}intercept(t,n){const r=t;this._interceptorsByName.has(r)||this._interceptorsByName.set(r,[]);const s=this._interceptorsByName.get(r);return s.push(n),this._interceptorsByName.set(r,s.sort((i,o)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)})),()=>mr(this._interceptorsByName.get(r),n)}getInterceptPoints(){return this._interceptorPoints}dispose(){this._interceptorsByName.clear()}}function lC(e){return`sheet_async_interceptor_${e}`}const uC=e=>async function(t,n){let r=-1,s=t;for(let i=0;i<=e.length;i++){if(i<=r)throw new Error("[SheetInterceptorService]: next() called multiple times!");if(r=i,i===e.length)return s;const o=e[i];let a=!1;if(s=await o.handler(s,n,async l=>(a=!0,l)),!a)break}return s};class cC{constructor(t){C(this,"_asyncInterceptorsByName",new Map);C(this,"_asyncInterceptorPoints");this._asyncInterceptorPoints=t}fetchThroughAsyncInterceptors(t,n){const r=t;let s=this._asyncInterceptorsByName.get(r);return n&&(s=s.filter(n)),uC(s||[])}async interceptAsync(t,n){const r=t;this._asyncInterceptorsByName.has(r)||this._asyncInterceptorsByName.set(r,[]);const s=this._asyncInterceptorsByName.get(r);return s.push(n),this._asyncInterceptorsByName.set(r,s.sort((i,o)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)})),()=>mr(this._asyncInterceptorsByName.get(r),n)}getInterceptPoints(){return this._asyncInterceptorPoints}dispose(){this._asyncInterceptorsByName.clear()}}function hC(e,t){for(const n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}class Os extends nt{static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(n=>{n!=="constructor"&&(this.prototype[n]=t.prototype[n])}),Object.getOwnPropertyNames(t).forEach(n=>{n!=="prototype"&&n!=="name"&&n!=="length"&&(this[n]=t[n])})}}const $s=Symbol("initializers");class go extends nt{constructor(t){super(),this._injector=t;const n=this,r=Object.getPrototypeOf(this)[$s];r&&r.forEach(function(s){s.apply(n,[t])})}_initialize(t){}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(n=>{if(n==="_initialize"){let r=this.prototype[$s];r||(r=[],this.prototype[$s]=r),r.push(t.prototype._initialize)}else n!=="constructor"&&(this.prototype[n]=t.prototype[n])}),Object.getOwnPropertyNames(t).forEach(n=>{n!=="prototype"&&n!=="name"&&n!=="length"&&(this[n]=t[n])})}}class bs{constructor(){C(this,"_data",[])}static create(){return new bs}add(t){this._data.indexOf(t)>-1||this._data.push(t)}delete(t){const n=this._data.indexOf(t);this._data.splice(n,1)}getData(){return this._data}}class po{constructor(){C(this,"_data",new Map)}static create(){return new po}add(t,n){this._data.has(t)||this._data.set(t,n)}delete(t){this._data.delete(t)}getData(){return this._data}}const dC="0.6.0-nightly.202501251605";function fC(e="",t=zn.ZH_CN,n=""){return{id:e,sheetOrder:[],name:n,appVersion:dC,locale:t,styles:{},sheets:{},resources:[]}}class Oc{constructor(t={}){C(this,"_styles");C(this,"_cacheMap",new fr(1e5));this._styles=t,this._generateCacheMap()}each(t){return Object.entries(this._styles).forEach(t),this}search(t,n){if(this._cacheMap.has(n))return this._cacheMap.get(n);const r=this._getExistingStyleId(t);return r||"-1"}get(t){return typeof t!="string"?t:(t=String(t),this._styles[t])}add(t,n){const r=re.generateRandomId(6);return this._styles[r]=t,this._cacheMap.set(n,r),r}setValue(t){if(t==null)return;const n=JSON.stringify(t),r=this.search(t,n);return r!=="-1"?r:this.add(t,n)}toJSON(){return this._styles}getStyleByCell(t){let n;t&&re.isObject(t.s)?n=t.s:n=(t==null?void 0:t.s)&&this.get(t.s);const r=t==null?void 0:t.interceptorStyle;return r?{...n,...r}:n}_generateCacheMap(){const{_styles:t,_cacheMap:n}=this;for(const r in t){const s=JSON.stringify(t[r]);n.set(s,r)}}_getExistingStyleId(t){const{_styles:n}=this;for(const r in n)if(re.diffValue(n[r],t))return r;return null}}const gC=(e,t)=>t.length===e.length&&!e.some(n=>t.some(r=>!Yt.equals(r,n))),pC=(e,t)=>t.length===e.length&&e.every((n,r)=>{const s=t[r];return s.unitId===n.unitId&&s.sheetId===n.sheetId&&Yt.equals(n.range,s.range)}),mi={t:0,b:2,l:2,r:2},mC=e=>({sbr:.6,sbo:e,spr:.6,spo:e}),Pa=90;function tr(e,t,n={}){const r=e.length,{textRotation:s,paddingData:i,horizontalAlign:o=Bt.UNSPECIFIED,verticalAlign:a=tn.UNSPECIFIED,wrapStrategy:l=_n.UNSPECIFIED,cellValueType:u}=n,{t:h,r:c,b:d,l:f}=i||mi,{vertexAngle:E,centerAngle:R}=Ac(s),O={id:"d",body:{dataStream:`${e}${_l}`,textRuns:[{ts:t,st:0,ed:r}],paragraphs:[{startIndex:r,paragraphStyle:{horizontalAlign:o}}],sectionBreaks:[{startIndex:r+1}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},marginTop:h,marginBottom:d,marginRight:c,marginLeft:f,renderConfig:{horizontalAlign:o,verticalAlign:a,centerAngle:R,vertexAngle:E,wrapStrategy:l,cellValueType:u,zeroWidthParagraphBreak:1}},drawings:{},drawingsOrder:[]};return new Ft(O)}function _C(e){if(!e)return{};const{tr:t,td:n,ht:r,vt:s,tb:i,pd:o}=e;return{textRotation:t,textDirection:n,horizontalAlign:r,verticalAlign:s,wrapStrategy:i,paddingData:o}}function Fa(e){if(!e)return{};const{ff:t,fs:n,it:r,bl:s,ul:i,st:o,ol:a,cl:l}=e,u={};return t&&(u.ff=t),n&&(u.fs=n),r&&(u.it=r),s&&(u.bl=s),i&&(u.ul=i),o&&(u.st=o),a&&(u.ol=a),l&&(u.cl=l),u}function bc(e,t,n){var i;const r=e.getBody();if((i=r.customRanges)!=null&&i.some(o=>o.rangeType===on.HYPERLINK))return;const s=st.customRange.add({ranges:[{startOffset:0,endOffset:r.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:on.HYPERLINK,body:r,properties:{url:t,refId:n}});s&&ze.apply(r,s.serialize())}function wc(e){return e!=null}const EC='"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';function ka(e){const t=ht.ff,n=ht.fs;if(!e){const c=`${n}pt ${t}`;return{fontCache:c,fontString:c,fontSize:n,originFontSize:n,fontFamily:t}}let r=wn.ITALIC;(e.it===0||e.it===void 0)&&(r=wn.NORMAL);let s=wn.BOLD;(e.bl===0||e.bl===void 0)&&(s=wn.NORMAL);let i=n;e.fs&&(i=Math.ceil(e.fs));let o=t;if(e.ff){let c=e.ff;c=c.replace(/"/g,"").replace(/'/g,""),c.indexOf(" ")>-1&&(c=`"${c}"`),c==null&&(c=t),o=c}const{va:a}=e;let l=i;if(a===Pt.SUBSCRIPT||a===Pt.SUPERSCRIPT){const c=CC(o,l),{sbr:d,spr:f}=c;l*=a===Pt.SUBSCRIPT?d:f}const u=`${r} ${s} ${l}pt ${o}`,h=`${u}, ${EC} `;return{fontCache:u,fontString:h,fontSize:l,originFontSize:i,fontFamily:o}}function CC(e,t){return mC(t)}function Ac(e){const{a:t=0,v:n=Se.FALSE}=e||{a:0,v:Se.FALSE};let r=0,s=t;return n===Se.TRUE&&(r=Pa,s=Pa),{centerAngle:r,vertexAngle:s}}class RC{constructor(t,n){C(this,"_columnData",{});this._config=t,this._columnData=n}getColumnData(){return this._columnData}getColVisible(t){const{_columnData:n}=this,r=n[t];return r?r.hd!==Se.TRUE:!0}getColumnStyle(t){var n;return(n=this._columnData[t])==null?void 0:n.s}setColumnStyle(t,n){const r=this.getColumnOrCreate(t);r.s=n}getHiddenCols(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getColVisible(o);s&&a?(s=!1,r.push({rangeType:xe.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:xe.COLUMN}),r}getVisibleCols(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getColVisible(o);s&&!a?(s=!1,r.push({rangeType:xe.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:xe.COLUMN}),r}getColumnDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getColumnOrCreate(i);r[s]=o,s++}return r}getSize(){return rn(this._columnData)}getColumnWidth(t){const{_columnData:n}=this,r=this._config;let s=0;return s=(n[t]||{hd:Se.FALSE,w:r.defaultColumnWidth}).w||r.defaultColumnWidth,s}getColumn(t){const n=this._columnData[t];if(n)return n}removeColumn(t){delete this._columnData[t]}getColumnOrCreate(t){const{_columnData:n}=this,r=n[t];if(r)return r;const s={};return this._columnData[t]=s,s}setCustomMetadata(t,n){const r=this.getColumn(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getColumn(t))==null?void 0:n.custom}}class IC{constructor(t,n,r){C(this,"_rowData");this._config=t,this._viewModel=n,this._rowData=r}getRowData(){return this._rowData}getRowStyle(t){var n;return(n=this._rowData[t])==null?void 0:n.s}setRowStyle(t,n){const r=this.getRowOrCreate(t);r.s=n}getRowDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getRowOrCreate(i);r[s]=o,s++}return r}getRowHeight(t,n=1){const{_rowData:r}=this,s=this._config;let i=0;for(let o=0;o<n;o++){const a=r[o+t]||{hd:Se.FALSE,h:s.defaultRowHeight},{ia:l,ah:u,h=s.defaultRowHeight}=a;i+=(l==null||l===Se.TRUE)&&typeof u=="number"?u:h}return i}getRow(t){return this._rowData[t]}removeRow(t){delete this._rowData[t]}getRowOrCreate(t){const{_rowData:n}=this,r=n[t];if(r)return r;const s={};return n[t]=s,s}getHiddenRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:xe.ROW})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:xe.ROW}),r}getVisibleRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&!a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:xe.ROW})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:xe.ROW}),r}getRowRawVisible(t){const n=this.getRow(t);return n?n.hd!==Se.TRUE:!0}getSize(){return rn(this._rowData)}setCustomMetadata(t,n){const r=this.getRow(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getRow(t))==null?void 0:n.custom}}const vC="DEFAULT_WORKSHEET_ROW_COUNT",Tc=1e3,yC="DEFAULT_WORKSHEET_COLUMN_COUNT",Nc=20,SC="DEFAULT_WORKSHEET_ROW_HEIGHT",Mc=24,OC="DEFAULT_WORKSHEET_COLUMN_WIDTH",Dc=88,bC="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",xc=46,wC="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Lc=20;function Uc(e){const t={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:Se.FALSE,rowCount:Tc,columnCount:Nc,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Dc,defaultRowHeight:Mc,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:Se.TRUE,rowHeader:{width:xc,hidden:Se.FALSE},columnHeader:{height:Lc,hidden:Se.FALSE},rightToLeft:Se.FALSE};return Object.keys(t).forEach(n=>{const r=n;typeof e[r]>"u"&&(e[r]=t[r])}),e}class AC extends nt{constructor(n){super();C(this,"_cellCache",new Map);C(this,"_rowCache",new Map);C(this,"_columnCache",new Map);C(this,"_hasRow",!1);C(this,"_hasColumn",!1);C(this,"_hasAll",!1);C(this,"_allIndex",-1);C(this,"_mergeData");C(this,"_rangeMap",new fr(5e4));C(this,"_skeletonCache",new fr(5e4));this._init(n.concat())}_init(n){this._mergeData=n,this._createCache(n)}_clearCache(){this._cellCache.clear(),this._rowCache.clear(),this._columnCache.clear(),this._hasAll=!1,this._allIndex=-1,this._rangeMap.clear(),this._skeletonCache.clear(),this._hasColumn=!1,this._hasRow=!1}_createCache(n){let r=0;for(const s of n){const{rangeType:i}=s;i===xe.ROW?this._createRowCache(s,r):i===xe.COLUMN?this._createColumnCache(s,r):i===xe.ALL?this._createCellAllCache(r):this._createCellCache(s,r),r++}}rebuild(n){this._clearCache(),this._init(n.concat())}_createRowCache(n,r){const{startRow:s,endRow:i}=n;for(let o=s;o<=i;o++)this._rowCache.set(o,r),this._hasRow=!0}_createColumnCache(n,r){const{startColumn:s,endColumn:i}=n;for(let o=s;o<=i;o++)this._columnCache.set(o,r),this._hasColumn=!0}_createCellAllCache(n){this._hasAll=!0,this._allIndex=n}_createCellCache(n,r){for(let s=n.startRow;s<=n.endRow;s++){let i=this._cellCache.get(s);i==null&&(i=new Map,this._cellCache.set(s,i));for(let o=n.startColumn;o<=n.endColumn;o++)i.set(o,r)}}add(n){this._mergeData.push(n),this._clearCache(),this._createCache(this._mergeData)}remove(n,r){const s=this._getMergeDataIndex(n,r);s!==-1&&(this._mergeData.splice(s,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(n,r){const s=this._getMergeDataIndex(n,r);return s!==-1?this._mergeData[s]:null}getMergeDataIndex(n,r){return this._getMergeDataIndex(n,r)}isRowContainsMergedCell(n){return this._hasAll||!re.isEmptyObject(this._columnCache)?!0:this._mergeData.some(r=>r.startRow<=n&&n<=r.endRow)}isColumnContainsMergedCell(n){return this._hasAll||!re.isEmptyObject(this._rowCache)?!0:this._mergeData.some(r=>r.startColumn<=n&&n<=r.endColumn)}getMergedCellRange(n,r,s,i){const o=[],a=`${n}-${r}-${s}-${i}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let l=0;const u=[];for(const h of this._mergeData||[])Yt.intersects(h,{startRow:n,endRow:s,startColumn:r,endColumn:i})&&(o.push({...h}),u.push(l)),l++;return this._rangeMap.set(a,u),o}getMergedCellRangeForSkeleton(n,r,s,i){const o=[],a=this._mergeData,l=`${n}-${r}-${s}-${i}`;if(this._skeletonCache.has(l))return this._getSkeletonRangeFromCache(l);const u=[];for(let h=0;h<a.length;h++){const{startRow:c,endRow:d,startColumn:f,endColumn:E}=a[h];for(let R=n;R<=s;R++){let O=!1;for(let U=r;U<=i;U++)if(R>=c&&R<=d&&U>=f&&U<=E){o.push({startRow:c,endRow:d,startColumn:f,endColumn:E}),u.push(h),O=!0;break}if(O)break}}return this._skeletonCache.set(l,u),o}_getRangeFromCache(n){const r=this._rangeMap.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getSkeletonRangeFromCache(n){const r=this._skeletonCache.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getMergeDataIndex(n,r){var i;if(this._hasAll)return this._allIndex;if(this._hasRow){const o=this._rowCache.get(n);if(o!==void 0)return o}if(this._hasColumn){const o=this._columnCache.get(r);if(o!==void 0)return o}const s=(i=this._cellCache.get(n))==null?void 0:i.get(r);return s!==void 0?s:-1}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}}class Pc extends nt{constructor(n){super();C(this,"_cellContentInterceptor",null);C(this,"_rowFilteredInterceptor",null);this.getRawCell=n}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(n,r,s,i){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,An.Value|An.Style,s,i):this.getRawCell(n,r)}getCellValueOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,An.Value):this.getRawCell(n,r)}getCellStyleOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,An.Style):this.getRawCell(n,r)}getRowFiltered(n){var r,s;return(s=(r=this._rowFilteredInterceptor)==null?void 0:r.getRowFiltered(n))!=null?s:!1}registerCellContentInterceptor(n){if(this._cellContentInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptor=n,Qe(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(n){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=n,Qe(()=>this._rowFilteredInterceptor=null)}}const $a={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};class gr{constructor(t,n,r){C(this,"_sheetId");C(this,"_snapshot");C(this,"_cellData");C(this,"_rowManager");C(this,"_columnManager");C(this,"_viewModel");C(this,"_spanModel");var a;this.unitId=t,this._styles=r,this._snapshot=Uc(n);const{columnData:s,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:re.generateRandomId(6),this._cellData=new Lt(o),this._viewModel=new Pc((l,u)=>this.getCellRaw(l,u)),this._rowManager=new IC(this._snapshot,this._viewModel,i),this._columnManager=new RC(this._snapshot,s),this._spanModel=new AC(this._snapshot.mergeData)}__interceptViewModel(t){t(this._viewModel)}getSnapshot(){return this._snapshot}setMergeData(t){this._snapshot.mergeData=t,this.getSpanModel().rebuild(t)}getSpanModel(){return this._spanModel}getStyleDataByHash(t){return{...this._styles.get(t)}}setStyleData(t){return this._styles.setValue(t)}getColumnStyle(t,n=!1){return n?this._columnManager.getColumnStyle(t):this._styles.get(this._columnManager.getColumnStyle(t))}setColumnStyle(t,n){this._columnManager.setColumnStyle(t,n)}getRowStyle(t,n=!1){return n?this._rowManager.getRowStyle(t):this._styles.get(this._rowManager.getRowStyle(t))}setRowStyle(t,n){this._rowManager.setRowStyle(t,n)}mixinDefaultStyleToCellRaw(t,n,r,s){const i=this.getColumnStyle(n),o=this.getRowStyle(t),a=this.getDefaultCellStyleInternal();if(a||i||o){let l=r==null?void 0:r.s;typeof l=="string"&&(l=this._styles.get(l));const u=s?si(a,i,o,l):si(a,o,i,l);r||(r={}),r.s=u}}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){const t=this._snapshot.defaultStyle;return this._styles.get(t)}setDefaultCellStyle(t){this._snapshot.defaultStyle=t}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const t=this.getCellMatrix(),n=this.getMergeData();let r=-1,s=-1,i=-1,o=-1,a=!1,l=!1;return t.forEach((u,h)=>{Object.keys(h).forEach(c=>{const d=+c,f=t.getValue(u,d),E=f!=null&&f.s?this._styles.get(f.s):null,R=(E==null?void 0:E.bd)&&(E.bd.b||E.bd.l||E.bd.r||E.bd.t||E.bd.bc_tr||E.bd.bl_tr||E.bd.ml_tr||E.bd.tl_bc||E.bd.tl_br||E.bd.tl_mr);(f&&(f.v||f.p)||E!=null&&E.bg||R)&&(a?r=Math.min(r,u):(r=u,a=!0),s=Math.max(s,u),l?i=Math.min(i,d):(l=!0,i=d),o=Math.max(o,d))})}),n.forEach(u=>{a?r=Math.min(r,u.startRow):(r=u.startRow,a=!0),s=Math.max(s,u.endRow),l?i=Math.min(i,u.startColumn):(i=u.startColumn,a=!0),o=Math.max(o,u.endColumn)}),!a||!l?null:{startColumn:i,startRow:r,endColumn:o,endRow:s}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:t}=this,n=re.deepClone(t);return new gr(this.unitId,n,this._styles)}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(t,n){return this._spanModel.getMergedCell(t,n)}getMergedCellRange(t,n,r,s){return this._spanModel.getMergedCellRange(t,n,r,s)}isRowContainsMergedCell(t){return this._spanModel.isRowContainsMergedCell(t)}isColumnContainsMergedCell(t){return this._spanModel.isColumnContainsMergedCell(t)}getCellInfoInMergeData(t,n){const r=this.getMergedCell(t,n);let s=!1,i=!1,o=t,a=n,l=t,u=n;if(r){const{startRow:h,endRow:c,startColumn:d,endColumn:f}=r;t===h&&n===d?(o=c,a=f,l=h,u=d,i=!0):t>=h&&t<=c&&n>=d&&n<=f&&(o=c,a=f,l=h,u=d,s=!0)}return{actualRow:t,actualColumn:n,isMergedMainCell:i,isMerged:s,endRow:o,endColumn:a,startRow:l,startColumn:u}}getCell(t,n){return t<0||n<0?null:this._viewModel.getCell(t,n)}getCellValueOnly(t,n){return t<0||n<0?null:this._viewModel.getCellValueOnly(t,n)}getCellStyleOnly(t,n){return t<0||n<0?null:this._viewModel.getCellStyleOnly(t,n)}getCellRaw(t,n){return this.getCellMatrix().getValue(t,n)}getCellWithFilteredInterceptors(t,n,r,s){return this._viewModel.getCell(t,n,r,s)}getRowFiltered(t){return this._viewModel.getRowFiltered(t)}getMatrixWithMergedCells(t,n,r,s,i=bn.Raw){const o=this.getCellMatrix(),a=this._spanModel.getMergedCellRange(t,n,r,s),l=new Lt;return ci(t,r,n,s).forEach((u,h)=>{var d;let c;if(i===bn.Raw)c=this.getCellRaw(u,h);else if(i===bn.Intercepted)c=this.getCell(u,h);else if(i===bn.Both){const f=this.getCellRaw(u,h);if(f){c={...f};const E=(d=this.getCell(u,h))==null?void 0:d.v;wc(E)&&c&&(c.displayV=String(E))}}c&&l.setValue(u,h,c)}),a.forEach(u=>{const{startColumn:h,startRow:c,endColumn:d,endRow:f}=u;ci(c,f,h,d).forEach((E,R)=>{E===c&&R===h&&l.setValue(E,R,{...o.getValue(E,R),rowSpan:f-c+1,colSpan:d-h+1}),(E!==c||R!==h)&&l.realDeleteValue(E,R)})}),l}getRange(t,n,r,s){return typeof t=="object"?new Fn(this,t,{getStyles:()=>this._styles}):new Fn(this,{startRow:t,startColumn:n,endColumn:s||n,endRow:r||t},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:t}=this,{columnCount:n}=t;return n}getMaxRows(){const{_snapshot:t}=this,{rowCount:n}=t;return n}getRowCount(){return this._snapshot.rowCount}setRowCount(t){this._snapshot.rowCount=t}getColumnCount(){return this._snapshot.columnCount}setColumnCount(t){this._snapshot.columnCount=t}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:t}=this,{showGridlines:n}=t;return n===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){const{_snapshot:t}=this,{tabColor:n}=t;return n}getColumnWidth(t){return this.getColumnManager().getColumnWidth(t)}getRowHeight(t){return this._viewModel.getRowFiltered(t)?0:this.getRowManager().getRowHeight(t)}isRowFiltered(t){return this._viewModel.getRowFiltered(t)}getRowVisible(t){return!this.isRowFiltered(t)&&this.getRowRawVisible(t)}getRowRawVisible(t){return this.getRowManager().getRowRawVisible(t)}getHiddenRows(t,n){const r=this.getMaxColumns()-1,s=this._rowManager.getHiddenRows(t,n);return s.forEach(i=>i.endColumn=r),s}getColVisible(t){return this._columnManager.getColVisible(t)}getHiddenCols(t,n){const r=this.getMaxRows()-1,s=this._columnManager.getHiddenCols(t,n);return s.forEach(i=>i.endRow=r),s}getVisibleRows(){const t=this.getRowCount();return this._rowManager.getVisibleRows(0,t-1)}getVisibleCols(){const t=this.getColumnCount();return this._columnManager.getVisibleCols(0,t-1)}isRightToLeft(){const{_snapshot:t}=this,{rightToLeft:n}=t;return n}getLastRowWithContent(){return this._cellData.getLength()-1}getLastColumnWithContent(){return this._cellData.getRange().endColumn}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(t){return t&&(t.v!==void 0||t.f!==void 0||t.p!==void 0)}iterateByRow(t,n=!0){const{startRow:r,startColumn:s,endRow:i,endColumn:o}=t,a=this;return{[Symbol.iterator]:()=>{let l=r,u=s;return{next(){for(;;){if(u>o&&(l+=1,u=s),l>i)return{done:!0,value:void 0};const h=a.getCell(l,u),c=!h,d=a.getMergedCell(l,u);if(d){if(l!==d.startRow||u!==d.startColumn){u=d.endColumn+1;continue}if(c&&n){u=d.endColumn+1;continue}const E={row:l,col:u,value:h};return E.colSpan=d.endColumn-d.startColumn+1,E.rowSpan=d.endRow-d.startRow+1,u=d.endColumn+1,{done:!1,value:E}}if(c&&n)u+=1;else{const f={row:l,col:u,value:h};return u+=1,{done:!1,value:f}}}}}}}}iterateByColumn(t,n=!0,r=!0){const{startRow:s,startColumn:i,endRow:o,endColumn:a}=t,l=this;return{[Symbol.iterator]:()=>{let u=s,h=i;return{next(){for(;;){if(u>o&&(h+=1,u=s),h>a)return{done:!0,value:void 0};const c=l.getMergedCell(u,h);if(c){const E=u!==c.startRow,R=E||h!==c.startColumn;if(r&&R||!r&&E){u=c.endRow+1;continue}const O=l.getCell(c.startRow,c.startColumn);if(!O&&n){u=c.endRow+1;continue}const ne={row:u,col:c.startColumn,value:O};return ne.colSpan=c.endColumn-c.startColumn+1,ne.rowSpan=c.endRow-c.startRow+1,u=c.endRow+1,{done:!1,value:ne}}const d=l.getCell(u,h);if(!d&&n)u+=1;else{const E={row:u,col:h,value:d};return u+=1,{done:!1,value:E}}}}}}}}_getCellDocumentModel(t,n=$a){var R;const{isDeepClone:r,displayRawFormula:s,ignoreTextRotation:i}={...$a,...n},o=this._styles.getStyleByCell(t);if(!t)return;let a,l="document";const u=_C(o),h=i?ht.tr:u.textRotation||ht.tr;let c=u.horizontalAlign||ht.ht;const d=u.verticalAlign||ht.vt,f=u.wrapStrategy||ht.tb,E=u.paddingData||mi;if(t.f&&s)a=tr(t.f.toString(),{},{verticalAlign:d}),c=ht.ht;else if(t.p){const{centerAngle:O,vertexAngle:U}=Ac(h);a=this._updateConfigAndGetDocumentModel(r?re.deepClone(t.p):t.p,c,E,{horizontalAlign:c,verticalAlign:d,centerAngle:O,vertexAngle:U,wrapStrategy:f,zeroWidthParagraphBreak:1})}else if(t.v!=null){const O=Fa(o);l=ka(O).fontCache;let U=Fc(t);t.t===nn.FORCE_STRING&&s&&(U=`'${U}`),a=tr(U,O,{...u,textRotation:h,cellValueType:t.t})}return a&&t.linkUrl&&t.linkId&&bc(a,t.linkUrl,t.linkId),{documentModel:a,fontString:l,textRotation:h,wrapStrategy:f,verticalAlign:d,horizontalAlign:c,paddingData:E,fill:(R=o==null?void 0:o.bg)==null?void 0:R.rgb}}_updateConfigAndGetDocumentModel(t,n,r,s){var o,a,l,u,h;if(!s||!((o=t.body)!=null&&o.dataStream))return;t.documentStyle||(t.documentStyle={}),t.documentStyle.marginTop=(a=r.t)!=null?a:0,t.documentStyle.marginBottom=(l=r.b)!=null?l:2,t.documentStyle.marginLeft=(u=r.l)!=null?u:2,t.documentStyle.marginRight=(h=r.r)!=null?h:2,t.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},t.documentStyle.renderConfig={...t.documentStyle.renderConfig,...s};const i=t.body.paragraphs||[];for(const c of i)c.paragraphStyle||(c.paragraphStyle={}),c.paragraphStyle.horizontalAlign=n;return new Ft(t)}getBlankCellDocumentModel(t){const n=this._getCellDocumentModel(t,{ignoreTextRotation:!0}),r=this._styles.getStyleByCell(t),s=Fa(r);if(n!=null)return n.documentModel==null&&(n.documentModel=tr("",s)),n;const i="";let o="document";const a=ht.tr,l=ht.ht,u=ht.vt,h=ht.tb,c=mi;return o=ka({}).fontCache,{documentModel:tr(i,s),fontString:o,textRotation:a,wrapStrategy:h,verticalAlign:u,horizontalAlign:l,paddingData:c}}getCellDocumentModelWithFormula(t){return this._getCellDocumentModel(t,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(t){this._snapshot.custom=t}}function Fc(e){var r,s;if(!e)return"";const t=(s=(r=e.p)==null?void 0:r.body)==null?void 0:s.dataStream;if(t)return st.transform.getPlainText(t);const n=e.v;return typeof n=="string"?e.t===nn.BOOLEAN?n.toUpperCase():n.replace(/[\r\n]/g,""):typeof n=="number"?e.t===nn.BOOLEAN?n?"TRUE":"FALSE":n.toString():typeof n=="boolean"?n?"TRUE":"FALSE":""}function TC(e){if(e===null)return"";if(e!=null&&e.p){const t=e==null?void 0:e.p.body;if(t==null)return"";const n=t.dataStream;return st.transform.getPlainText(n)}return e==null?void 0:e.v}var NC=Object.defineProperty,MC=Object.getOwnPropertyDescriptor,DC=(e,t,n,r)=>{for(var s=r>1?void 0:r?MC(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&NC(t,n,s),s},xC=(e,t)=>(n,r)=>t(n,r,e);function LC(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}exports.Workbook=class extends Ss{constructor(n={},r){super();C(this,"type",$e.UNIVER_SHEET);C(this,"_sheetCreated$",new Oe.Subject);C(this,"sheetCreated$",this._sheetCreated$.asObservable());C(this,"_sheetDisposed$",new Oe.Subject);C(this,"sheetDisposed$",this._sheetDisposed$.asObservable());C(this,"_activeSheet$",new Oe.BehaviorSubject(null));C(this,"activeSheet$",this._activeSheet$.asObservable());C(this,"_worksheets");C(this,"_styles");C(this,"_snapshot");C(this,"_unitId");C(this,"_count");C(this,"_name$");C(this,"name$");this._logService=r;const s=fC();re.isEmptyObject(n)?this._snapshot=s:this._snapshot=re.commonExtend(s,n);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=re.generateRandomId(6)),this._unitId=this._snapshot.id,this._styles=new Oc(i),this._count=1,this._worksheets=new Map,this._name$=new Oe.BehaviorSubject(n.name||""),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(n){return typeof n=="string"||"startRow"in n||"row"in n}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete()}save(){return re.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(n){this._name$.next(n),this._snapshot.name=n}getUnitId(){return this._unitId}getRev(){var n;return(n=this._snapshot.rev)!=null?n:1}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(n){this._snapshot.rev=n}addWorksheet(n,r,s){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[n])return!1;i[n]=s,o.splice(r,0,n);const a=new gr(this._unitId,s,this._styles);return this._worksheets.set(n,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}getConfig(){return this._snapshot}getIndexBySheetId(n){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>s===n)}getActiveSheet(n){if(!this._activeSheet&&typeof n>"u")throw new Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){const n=this._activeSheet;if(n)return n;const r=this._snapshot.sheetOrder;for(let i=0,o=r.length;i<o;i++){const a=this._worksheets.get(r[i]);if(a&&a.isSheetHidden()!==Se.TRUE)return this.setActiveSheet(a),a}const s=this._worksheets.get(r[0]);return this.setActiveSheet(s),s}setActiveSheet(n){this._activeSheet$.next(n)}removeSheet(n){const r=this._worksheets.get(n);return r?(this._worksheets.delete(n),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(n),1),delete this._snapshot.sheets[n],this._sheetDisposed$.next(r),!0):!1}getActiveSheetIndex(){const{sheetOrder:n}=this._snapshot;return n.findIndex(r=>this._worksheets.get(r)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:n}=this._snapshot;return n.map(r=>this._worksheets.get(r))}getSheetsName(){const{sheetOrder:n}=this._snapshot,r=[];return n.forEach(s=>{const i=this._worksheets.get(s);i&&r.push(i.getName())}),r}getSheetIndex(n){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>n.getSheetId()===s)}getSheetBySheetName(n){const{sheetOrder:r}=this._snapshot,s=r.find(i=>this._worksheets.get(i).getName()===n);return this._worksheets.get(s)}getSheetBySheetId(n){return this._worksheets.get(n)}getSheetByIndex(n){const{sheetOrder:r}=this._snapshot;return this._worksheets.get(r[n])}getHiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden===Se.TRUE).map(n=>n.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden!==Se.TRUE).map(n=>n.getConfig().id)}load(n){this._snapshot=n}checkSheetName(n){return this.getSheetsName().includes(n)}uniqueSheetName(n="Sheet1"){let r=n;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}generateNewSheetName(n){let r=n+this._count;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}_parseWorksheetSnapshots(){const{_snapshot:n,_worksheets:r}=this,{sheets:s,sheetOrder:i}=n;if(re.isEmptyObject(s)){const o=re.generateRandomId();s[o]={id:o}}for(const o in s){const a=s[o],{name:l}=a;a.name=this.uniqueSheetName(l),a.name!==l&&this._logService.debug("[Workbook]",`The worksheet name ${l} is duplicated, we changed it to ${a.name}. Please fix the problem in your snapshot.`);const u=new gr(this._unitId,a,this._styles);r.set(o,u),i.includes(o)||i.push(o)}this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(n){this._snapshot.custom=n}};exports.Workbook=DC([xC(1,At)],exports.Workbook);class mo extends Ss{constructor(n){var r;super();C(this,"type",$e.UNIVER_SLIDE);C(this,"_activePage$",new Oe.BehaviorSubject(null));C(this,"activePage$",this._activePage$.asObservable());C(this,"_name$");C(this,"name$");C(this,"_snapshot");C(this,"_unitId");this._snapshot={...gu,...n},this._unitId=(r=this._snapshot.id)!=null?r:re.generateRandomId(6),this._name$=new Oe.BehaviorSubject(this._snapshot.title),this.name$=this._name$.asObservable()}get _activePage(){var r,s;const n=this._activePage$.getValue();if(!n){const i=(r=this.getPageOrder())==null?void 0:r[0];return i?(s=this.getPages())==null?void 0:s[i]:null}return n}setName(n){var r;this._snapshot.title=n,this._name$.next(n),this._unitId=(r=this._snapshot.id)!=null?r:zt(6)}getRev(){return 0}incrementRev(){}setRev(n){}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var n;return(n=this._snapshot.body)==null?void 0:n.pages}getPageOrder(){var n;return(n=this._snapshot.body)==null?void 0:n.pageOrder}getPage(n){const r=this.getPages();return r==null?void 0:r[n]}getElementsByPage(n){var r;return(r=this.getPage(n))==null?void 0:r.pageElements}getElement(n,r){var s;return(s=this.getElementsByPage(n))==null?void 0:s[r]}getPageSize(){return this._snapshot.pageSize}getBlankPage(){const n=zt(6);return{id:n,pageType:lo.SLIDE,zIndex:10,title:n,description:"",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}setActivePage(n){this._activePage$.next(n)}getActivePage(){return this._activePage}updatePage(n,r){this._snapshot.body&&(this._snapshot.body.pages[n]=r)}appendPage(n){var i;if(!this._snapshot.body)return;this._snapshot.body.pages[n.id]=n;const r=this._activePage,s=this._snapshot.body.pageOrder.indexOf((i=r==null?void 0:r.id)!=null?i:"");this._snapshot.body.pageOrder.splice(s+1,0,n.id)}}const nr="FOCUSING_UNIT",Tn="FOCUSING_SHEET",rr="FOCUSING_DOC",sr="FOCUSING_SLIDE",UC="FOCUSING_EDITOR_BUT_HIDDEN",kc="EDITOR_ACTIVATED",PC="FOCUSING_EDITOR_INPUT_FORMULA",$c="FOCUSING_FX_BAR_EDITOR",FC="FOCUSING_UNIVER_EDITOR",kC="FOCUSING_EDITOR_INPUT_FORMULA",$C="FOCUSING_PANEL_EDITOR",BC="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",jC="FOCUSING_COMMON_DRAWINGS",HC="FORMULA_EDITOR_ACTIVATED";var WC=Object.defineProperty,zC=Object.getOwnPropertyDescriptor,YC=(e,t,n,r)=>{for(var s=r>1?void 0:r?zC(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&WC(t,n,s),s},Ba=(e,t)=>(n,r)=>t(n,r,e);const an=_t("univer.current");exports.UniverInstanceService=class extends nt{constructor(n,r){super();C(this,"_unitsByType",new Map);C(this,"_createHandler");C(this,"_ctorByType",new Map);C(this,"_currentUnits",new Map);C(this,"_currentUnits$",new Oe.BehaviorSubject(this._currentUnits));C(this,"currentUnits$",this._currentUnits$.asObservable());C(this,"_unitAdded$",new Oe.Subject);C(this,"unitAdded$",this._unitAdded$.asObservable());C(this,"_unitDisposed$",new Oe.Subject);C(this,"unitDisposed$",this._unitDisposed$.asObservable());C(this,"_focused$",new Oe.BehaviorSubject(null));C(this,"focused$",this._focused$.asObservable());this._injector=n,this._contextService=r}dispose(){super.dispose(),this._focused$.complete()}__setCreateHandler(n){this._createHandler=n}createUnit(n,r,s){return this._createHandler(n,r,this._ctorByType.get(n),s)}registerCtorForType(n,r){return this._ctorByType.set(n,r),{dispose:()=>{this._ctorByType.delete(n)}}}getCurrentTypeOfUnit$(n){return this.currentUnits$.pipe(Oe.map(r=>{var s;return(s=r.get(n))!=null?s:null}),Oe.distinctUntilChanged())}getCurrentUnitForType(n){return this._currentUnits.get(n)}setCurrentUnitForType(n){const r=this._getUnitById(n);if(!r)throw new Error(`[UniverInstanceService]: no document with unitId ${n}!`);this._currentUnits.set(r[1],r[0]),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(n){return this._unitAdded$.pipe(Oe.filter(r=>r.type===n))}__addUnit(n,r){var a;const s=n.type;this._unitsByType.has(s)||this._unitsByType.set(s,[]);const i=this._unitsByType.get(s),o=n.getUnitId();if(i.findIndex(l=>l.getUnitId()===o)!==-1)throw new Error(`[UniverInstanceService]: cannot create a unit with the same unit id: ${o}.`);i.push(n),this._unitAdded$.next(n),((a=r==null?void 0:r.makeCurrent)==null||a)&&this.setCurrentUnitForType(n.getUnitId())}getTypeOfUnitDisposed$(n){return this.unitDisposed$.pipe(Oe.filter(r=>r.type===n))}getUnit(n,r){var i;const s=(i=this._getUnitById(n))==null?void 0:i[0];return r&&(s==null?void 0:s.type)!==r?null:s}getCurrentUniverDocInstance(){return this.getCurrentUnitForType($e.UNIVER_DOC)}getUniverDocInstance(n){return this.getUnit(n,$e.UNIVER_DOC)}getUniverSheetInstance(n){return this.getUnit(n,$e.UNIVER_SHEET)}getAllUnitsForType(n){var r;return(r=this._unitsByType.get(n))!=null?r:[]}changeDoc(n,r){const s=this.getAllUnitsForType($e.UNIVER_DOC),i=s.find(o=>o.getUnitId()===n);if(i!=null){const o=s.indexOf(i);s.splice(o,1)}this.__addUnit(r)}get focused(){var r;const n=this._focused$.getValue();return n?(r=this._getUnitById(n))==null?void 0:r[0]:null}focusUnit(n){this._focused$.next(n),this.focused instanceof exports.Workbook?(this._contextService.setContextValue(nr,!0),this._contextService.setContextValue(rr,!1),this._contextService.setContextValue(Tn,!0),this._contextService.setContextValue(sr,!1),this.setCurrentUnitForType(n)):this.focused instanceof Ft?(this._contextService.setContextValue(nr,!0),this._contextService.setContextValue(rr,!0),this._contextService.setContextValue(Tn,!1),this._contextService.setContextValue(sr,!1),this.setCurrentUnitForType(n)):this.focused instanceof mo?(this._contextService.setContextValue(nr,!0),this._contextService.setContextValue(rr,!1),this._contextService.setContextValue(Tn,!1),this._contextService.setContextValue(sr,!0),this.setCurrentUnitForType(n)):(this._contextService.setContextValue(nr,!1),this._contextService.setContextValue(rr,!1),this._contextService.setContextValue(Tn,!1),this._contextService.setContextValue(sr,!1))}getFocusedUnit(){return this.focused}getUnitType(n){const r=this._getUnitById(n);return r?r[1]:$e.UNRECOGNIZED}disposeUnit(n){const r=this._getUnitById(n);if(!r)return!1;const[s,i]=r,o=this._unitsByType.get(i),a=o.indexOf(s);return o.splice(a,1),this._tryRemoveCurrentUnitForType(n,i),this._tryBlurUnitOnRemoval(n),this._unitDisposed$.next(s),!0}_tryRemoveCurrentUnitForType(n,r){const s=this.getCurrentUnitForType(r);(s==null?void 0:s.getUnitId())===n&&(this._currentUnits.set(r,null),this._currentUnits$.next(this._currentUnits))}_tryBlurUnitOnRemoval(n){var r;((r=this.focused)==null?void 0:r.getUnitId())===n&&this._focused$.next(null)}_getUnitById(n){for(const[r,s]of this._unitsByType){const i=s.find(o=>o.getUnitId()===n);if(i)return[i,r]}}};exports.UniverInstanceService=YC([Ba(0,it(Rt)),Ba(1,Cr)],exports.UniverInstanceService);var We=(e=>(e[e.Starting=0]="Starting",e[e.Ready=1]="Ready",e[e.Rendered=2]="Rendered",e[e.Steady=3]="Steady",e))(We||{});const VC={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"};var GC=Object.defineProperty,KC=Object.getOwnPropertyDescriptor,XC=(e,t,n,r)=>{for(var s=r>1?void 0:r?KC(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&GC(t,n,s),s},QC=(e,t)=>(n,r)=>t(n,r,e);exports.LifecycleService=class extends nt{constructor(n){super();C(this,"_lifecycle$",new Oe.BehaviorSubject(We.Starting));C(this,"lifecycle$",this._lifecycle$.asObservable());C(this,"_lock",!1);this._logService=n,this._reportProgress(We.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(n){if(this._lock)throw new Error("[LifecycleService]: cannot set new stage when related logic is all handled!");if(n<this.stage)throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");n!==this.stage&&(this._lock=!0,this._reportProgress(n),this._lifecycle$.next(n),this._lock=!1)}dispose(){this._lifecycle$.complete(),super.dispose()}subscribeWithPrevious(){return Oe.merge(Bc(this.stage),this._lifecycle$.pipe(Oe.skip(1))).pipe(Yl(n=>n===We.Steady))}_reportProgress(n){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${VC[n]}".`)}};exports.LifecycleService=XC([QC(0,At)],exports.LifecycleService);function Bc(e){switch(e){case We.Starting:return Oe.of(We.Starting);case We.Ready:return Oe.of(We.Starting,We.Ready);case We.Rendered:return Oe.of(We.Starting,We.Ready,We.Rendered);default:return Oe.of(We.Starting,We.Ready,We.Rendered,We.Steady)}}var JC=Object.defineProperty,qC=Object.getOwnPropertyDescriptor,ZC=(e,t,n,r)=>{for(var s=r>1?void 0:r?qC(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&JC(t,n,s),s},Bs=(e,t)=>(n,r)=>t(n,r,e);const en=_t("univer.undo-redo.service"),eR=20;class jc{dispose(){}async dispatchToHandlers(){return!1}}const Hc="univer.command.redo",Wc="univer.command.undo",gn=new class extends jc{constructor(){super(...arguments);C(this,"type",Wn.COMMAND);C(this,"id",Wc)}handler(t){const n=t.get(en),r=n.pitchTopUndoElement();if(!r)return!1;const s=t.get(xt);return zi(r.undoMutations,s)?(n.popUndoToRedo(),!0):!1}},pn=new class extends jc{constructor(){super(...arguments);C(this,"type",Wn.COMMAND);C(this,"id",Hc)}handler(t){const n=t.get(en),r=n.pitchTopRedoElement();if(!r)return!1;const s=t.get(xt);return zi(r.redoMutations,s)?(n.popRedoToUndo(),!0):!1}};exports.LocalUndoRedoService=class extends nt{constructor(n,r,s){super();C(this,"undoRedoStatus$");C(this,"_undoRedoStatus$",new Oe.BehaviorSubject({undos:0,redos:0}));C(this,"_undoStacks",new Map);C(this,"_redoStacks",new Map);C(this,"_batchingStatus",new Map);this._univerInstanceService=n,this._commandService=r,this._contextService=s,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(gn)),this.disposeWithMe(this._commandService.registerCommand(pn)),this.disposeWithMe(Qe(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(Qe(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(n){const{unitID:r}=n,s=this._getRedoStack(r,!0),i=this._getUndoStack(r,!0);if(s.length=0,this._batchingStatus.has(n.unitID)){const a=this._batchingStatus.get(n.unitID),l=this._pitchUndoElement(n.unitID);a===0||!l?(o(n),this._batchingStatus.set(n.unitID,1)):this._tryBatchingElements(l,n)}else o(n);function o(a){i.push(a),i.length>eR&&i.splice(0,1)}this._updateStatus()}clearUndoRedo(n){const r=this._getRedoStack(n);r&&(r.length=0);const s=this._getUndoStack(n);s&&(s.length=0),this._updateStatus()}pitchTopUndoElement(){const n=this._getFocusedUnitId();return this._pitchUndoElement(n)}pitchTopRedoElement(){const n=this._getFocusedUnitId();return this._pitchRedoElement(n)}_pitchUndoElement(n){const r=this._getUndoStack(n);return r!=null&&r.length?r[r.length-1]:null}_pitchRedoElement(n){const r=this._getRedoStack(n);return r!=null&&r.length?r[r.length-1]:null}popUndoToRedo(){const r=this._getUndoStackForFocused().pop();r&&(this._getRedoStackForFocused().push(r),this._updateStatus())}popRedoToUndo(){const r=this._getRedoStackForFocused().pop();r&&(this._getUndoStackForFocused().push(r),this._updateStatus())}__tempBatchingUndoRedo(n){if(this._batchingStatus.has(n))throw new Error("[LocalUndoRedoService]: cannot batching undo redo twice at the same time!");return this._batchingStatus.set(n,0),Qe(()=>this._batchingStatus.delete(n))}_updateStatus(){var i,o;const n=this._getFocusedUnitId(),r=n&&((i=this._undoStacks.get(n))==null?void 0:i.length)||0,s=n&&((o=this._redoStacks.get(n))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:r,redos:s})}_getUndoStack(n,r=!1){let s=this._undoStacks.get(n);return!s&&r&&(s=[],this._undoStacks.set(n,s)),s||null}_getRedoStack(n,r=!1){let s=this._redoStacks.get(n);return!s&&r&&(s=[],this._redoStacks.set(n,s)),s||null}_getUndoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getUndoStack(n,!0)}_getRedoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getRedoStack(n,!0)}_tryBatchingElements(n,r){n.redoMutations.push(...r.redoMutations),n.undoMutations.push(...r.undoMutations)}_getFocusedUnitId(){var o,a,l,u;let n="";const r=this._contextService.getContextValue(Tn),s=this._contextService.getContextValue($c),i=this._contextService.getContextValue(kc);return r?s?n=Pi:i?n=Ui:n=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":n=(u=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?u:"",n}};exports.LocalUndoRedoService=ZC([Bs(0,an),Bs(1,xt),Bs(2,Cr)],exports.LocalUndoRedoService);const ws=_t("core.resource-manager.service"),_i={[Dt.Editor]:"Editor",[Dt.Owner]:"Owner",[Dt.Reader]:"Reader",[Dt.UNRECOGNIZED]:"UNRECOGNIZED"},cs=e=>e?{userID:`${_i[e]}_${re.generateRandomId(8)}`,name:_i[e],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},tR=(e,t)=>e.startsWith(_i[t]);class $n{constructor(){C(this,"_model",new Map);C(this,"_userChange$",new Oe.Subject);C(this,"userChange$",this._userChange$.asObservable());C(this,"_currentUser$",new Oe.BehaviorSubject(cs()));C(this,"currentUser$",this._currentUser$.asObservable())}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(t){this.addUser(t),this._currentUser$.next(t)}addUser(t){this._model.set(t.userID,t),this._userChange$.next({type:"add",user:t})}getUser(t,n){const r=this._model.get(t);if(r)return r;n&&n()}delete(t){const n=this.getUser(t);this._model.delete(t),n&&this._userChange$.next({type:"delete",user:n})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}list(){return Array.from(this._model.values())}}var nR=Object.defineProperty,rR=Object.getOwnPropertyDescriptor,sR=(e,t,n,r)=>{for(var s=r>1?void 0:r?rR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&nR(t,n,s),s},ja=(e,t)=>(n,r)=>t(n,r,e);exports.AuthzIoLocalService=class{constructor(t,n){C(this,"_permissionMap",new Map([]));this._resourceManagerService=t,this._userManagerService=n,this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){const t=this._userManagerService.getCurrentUser();t&&t.userID||this._userManagerService.setCurrentUser(cs(Dt.Owner))}_getRole(t){const n=this._userManagerService.getCurrentUser();return n?tR(n.userID,t):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:t=>{const n=[...this._permissionMap.keys()].reduce((r,s)=>{const i=this._permissionMap.get(s);return r[s]=i,r},{});return JSON.stringify(n)},parseJson:t=>JSON.parse(t),pluginName:"SHEET_AuthzIoMockService_PLUGIN",businesses:[$e.UNIVER_SHEET,$e.UNIVER_DOC,$e.UNIVER_SLIDE],onLoad:(t,n)=>{for(const r in n)this._permissionMap.set(r,n[r])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(t){return zt(8)}async allowed(t){return Promise.resolve([])}async batchAllowed(t){return Promise.resolve([])}async list(t){const n=[];return t.objectIDs.forEach(r=>{const s=this._permissionMap.get(r);if(s){const i={objectID:r,unitID:t.unitID,objectType:s.objectType,name:s.name,shareOn:!1,shareRole:Dt.Owner,shareScope:-1,scope:{read:hi.AllCollaborator,edit:hi.AllCollaborator},creator:cs(Dt.Owner),strategies:[{action:6,role:1},{action:16,role:1},{action:17,role:1},{action:18,role:1},{action:19,role:1},{action:33,role:1},{action:34,role:1},{action:35,role:1},{action:36,role:1},{action:37,role:1},{action:38,role:1},{action:39,role:1},{action:40,role:1}],actions:t.actions.map(o=>({action:o,allowed:this._getRole(Dt.Owner)||this._getRole(Dt.Editor)}))};n.push(i)}}),n}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(t){}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(t){}};exports.AuthzIoLocalService=sR([ja(0,ws),ja(1,it($n))],exports.AuthzIoLocalService);const zc=_t("IAuthzIoIoService"),Yc=_t("univer.config-service");class Vc{constructor(){C(this,"_configChanged$",new Oe.Subject);C(this,"configChanged$",this._configChanged$.asObservable());C(this,"_config",new Map)}dispose(){this._configChanged$.complete()}getConfig(t){return this._config.get(t)}setConfig(t,n,r){var o;const{merge:s=!1}=r||{};let i=(o=this._config.get(t))!=null?o:{};s?i=xi(i,n):i=n,this._config.set(t,i),this._configChanged$.next({[t]:i})}deleteConfig(t){return this._config.delete(t)}subscribeConfigValue$(t){return new Oe.Observable(n=>{Object.prototype.hasOwnProperty.call(this._config,t)&&n.next(this._config.get(t));const r=this.configChanged$.pipe(Oe.filter(s=>Object.prototype.hasOwnProperty.call(s,t))).subscribe(s=>n.next(s[t]));return()=>r.unsubscribe()})}}class Gc extends nt{constructor(){super(...arguments);C(this,"_error$",new Oe.Subject);C(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(n){this._error$.next({errorKey:n})}}class ur extends nt{constructor(){super();C(this,"_currentLocale$",new Oe.BehaviorSubject(zn.ZH_CN));C(this,"currentLocale$",this._currentLocale$.asObservable());C(this,"_locales",null);C(this,"localeChanged$",new Oe.Subject);C(this,"t",(n,...r)=>{if(!this._locales)throw new Error("[LocaleService]: Locale not initialized");const s=n.split("."),i=this.resolveKeyPath(this._locales[this._currentLocale],s);if(typeof i=="string"){let o=i;return r.forEach((a,l)=>{o=o.replace(`{${l}}`,a)}),o}else return n});this.disposeWithMe(Qe(()=>this.localeChanged$.complete()))}get _currentLocale(){return this._currentLocale$.value}load(n){var r;this._locales=xi((r=this._locales)!=null?r:{},n)}setLocale(n){this._currentLocale$.next(n),this.localeChanged$.next()}getLocales(){var n;return(n=this._locales)==null?void 0:n[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(n,r){const s=r.shift();if(s&&n&&s in n){const i=n[s];return r.length>0&&(typeof i=="object"||Array.isArray(i))?this.resolveKeyPath(i,r):i}return null}}var iR=Object.defineProperty,oR=Object.getOwnPropertyDescriptor,aR=(e,t,n,r)=>{for(var s=r>1?void 0:r?oR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&iR(t,n,s),s},lR=(e,t)=>(n,r)=>t(n,r,e);exports.MentionIOLocalService=class{constructor(t){this._userManagerService=t}async list(t){return{list:[{type:dr.PERSON,mentions:[{objectType:dr.PERSON,objectId:this._userManagerService.getCurrentUser().userID,label:this._userManagerService.getCurrentUser().name,metadata:{icon:this._userManagerService.getCurrentUser().avatar}}],metadata:{},title:"PEOPLE"}],page:t.page,size:t.size,total:1}}};exports.MentionIOLocalService=aR([lR(0,it($n))],exports.MentionIOLocalService);const Kc=_t("univer.service.mention-io");var _o=(e=>(e.INIT="init",e.FETCHING="fetching",e.DONE="done",e))(_o||{});const Xc=_t("univer.permission-service");class Qc extends nt{constructor(){super(...arguments);C(this,"_permissionPointMap",new Map);C(this,"_permissionPointUpdate$",new Oe.Subject);C(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable());C(this,"_showComponents",!0)}setShowComponents(n){this._showComponents=n}getShowComponents(){return this._showComponents}deletePermissionPoint(n){const r=this._permissionPointMap.get(n);r&&(r.complete(),this._permissionPointMap.delete(n))}addPermissionPoint(n){const r=n instanceof Oe.BehaviorSubject,s=r?n.getValue():n;if(!s.id)return!1;if(this._permissionPointMap.get(s.id))throw new Error(`${s.id} PermissionPoint already exists`);return this._permissionPointMap.set(s.id,r?n:new Oe.BehaviorSubject(s)),this._permissionPointUpdate$.next(s),!0}updatePermissionPoint(n,r){const s=this._permissionPointMap.get(n);if(!s)return;const i=s.getValue();i.value=r,i.status=_o.DONE,s.next(i),this._permissionPointUpdate$.next(i)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(n){const r=this._permissionPointMap.get(n);if(r)return r.getValue()}getPermissionPoint$(n){const r=this._permissionPointMap.get(n);if(r)return r}composePermission$(n){const r=n.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.asObservable()});return Oe.combineLatest(r).pipe(Br.map(s=>s))}composePermission(n){return n.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.getValue()})}getAllPermissionPoint(){const n=new Map;return this._permissionPointMap.forEach((r,s)=>{n.set(s,r)}),n}}function Jc(e,t){if(!t)return e;const n=[];for(const r of e){const s=t.find(([i])=>i===r[0]);if(s){if(s[1]===null)continue;n.push([r[0],s[1]])}else n.push(r)}return n}const qc=Symbol("DependentOn");class Ei extends nt{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUniverInstanceType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}C(Ei,"pluginName"),C(Ei,"type",$e.UNIVER_UNKNOWN);class uR{constructor(){C(this,"_plugins",[])}addPlugin(t){this._plugins.push(t)}removePlugins(){const t=this._plugins.slice();return this._plugins.length=0,t}forEachPlugin(t){this._plugins.forEach(t)}}class cR{constructor(){C(this,"_pluginsRegistered",[])}registerPlugin(t,n){this._pluginsRegistered.push({plugin:t,options:n})}getRegisterPlugins(){return this._pluginsRegistered.slice()}removePlugins(){this._pluginsRegistered=[]}}var hR=Object.defineProperty,dR=Object.getOwnPropertyDescriptor,Zc=(e,t,n,r)=>{for(var s=r>1?void 0:r?dR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&hR(t,n,s),s},es=(e,t)=>(n,r)=>t(n,r,e);const fR=4;function gR(...e){return function(t){t[qc]=e}}exports.PluginService=class{constructor(t){C(this,"_pluginHolderForUniver");C(this,"_pluginHoldersForTypes",new Map);C(this,"_seenPlugins",new Set);C(this,"_flushTimer");this._injector=t,this._pluginHolderForUniver=this._injector.createInstance(hs,this._checkPluginSeen.bind(this),this._immediateInitPlugin.bind(this)),this._pluginHoldersForTypes.set($e.UNIVER_UNKNOWN,this._pluginHolderForUniver),this._pluginHolderForUniver.start()}dispose(){this._clearFlushTimer();for(const t of this._pluginHoldersForTypes.values())t.dispose();this._pluginHolderForUniver.dispose()}registerPlugin(t,n){this._assertPluginValid(t),this._scheduleInitPlugin();const{type:r}=t;r===$e.UNIVER_UNKNOWN?(this._pluginHolderForUniver.register(t,n),this._pluginHolderForUniver.flush()):this._ensurePluginHolderForType(r).register(t,n)}startPluginForType(t){this._ensurePluginHolderForType(t).start()}_ensurePluginHolderForType(t){if(!this._pluginHoldersForTypes.has(t)){const n=this._injector.createInstance(hs,this._checkPluginSeen.bind(this),this._immediateInitPlugin.bind(this));return this._pluginHoldersForTypes.set(t,n),n}return this._pluginHoldersForTypes.get(t)}_immediateInitPlugin(t){this._seenPlugins.add(t.pluginName),this._ensurePluginHolderForType(t.type).immediateInitPlugin(t)}_checkPluginSeen(t){return this._seenPlugins.has(t.pluginName)}_assertPluginValid(t){const{type:n,pluginName:r}=t;if(n===$e.UNRECOGNIZED)throw new Error(`[PluginService]: invalid plugin type for ${t.name}. Please assign a "type" to your plugin.`);if(!r)throw new Error(`[PluginService]: no plugin name for ${t.name}. Please assign a "pluginName" to your plugin.`);if(this._seenPlugins.has(r))throw new Error(`[PluginService]: duplicated plugin name for "${r}". Maybe a plugin that dependents on "${r} has already registered it. In that case please register "${r}" before the that plugin.`);this._seenPlugins.add(t.pluginName)}_scheduleInitPlugin(){this._flushTimer===void 0&&(this._flushTimer=setTimeout(()=>{this._pluginHolderForUniver.started||this._pluginHolderForUniver.start(),this._flushPlugins(),this._clearFlushTimer()},fR))}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}_flushPlugins(){this._pluginHolderForUniver.flush();for(const[t,n]of this._pluginHoldersForTypes)n.started&&n.flush()}};exports.PluginService=Zc([es(0,it(Rt))],exports.PluginService);let hs=class extends nt{constructor(t,n,r,s,i){super();C(this,"_started",!1);C(this,"_warnedAboutOnStartingDeprecation",!1);C(this,"_pluginRegistry",new cR);C(this,"_pluginStore",new uR);C(this,"_pluginsInBatches",[]);this._checkPluginRegistered=t,this._registerPlugin=n,this._logService=r,this._injector=s,this._lifecycleService=i,this.disposeWithMe(this._lifecycleService.lifecycle$.pipe(Oe.skip(1)).subscribe(o=>{this._pluginsInBatches.forEach(a=>this._runStage(a,o))}))}get started(){return this._started}dispose(){super.dispose(),this._pluginStore.forEachPlugin(t=>t.dispose()),this._pluginStore.removePlugins(),this._pluginRegistry.removePlugins(),this._pluginsInBatches.length=0}register(t,n){this._pluginRegistry.registerPlugin(t,n)}immediateInitPlugin(t){const n=this._initPlugin(t,void 0);this._pluginsRunLifecycle([n])}start(){this._started||(this._started=!0,this.flush())}flush(){if(!this._started)return;const t=this._pluginRegistry.getRegisterPlugins().map(({plugin:n,options:r})=>this._initPlugin(n,r));t.length&&(this._pluginsRunLifecycle(t),this._pluginRegistry.removePlugins())}_initPlugin(t,n){const r=t[qc];if(r){const i=()=>{const o=r.find(a=>!this._checkPluginRegistered(a));return o?(this._logService.debug("[PluginService]",`Plugin "${t.pluginName}" depends on "${o.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._registerPlugin(o,void 0),!0):!1};for(;i(););}const s=this._injector.createInstance(t,n);return this._pluginStore.addPlugin(s),this._logService.debug("[PluginService]",`Plugin "${s.getPluginName()}" registered.`),s}_pluginsRunLifecycle(t){Bc(this._lifecycleService.stage).subscribe(n=>this._runStage(t,n)),this._pluginsInBatches.push(t)}_runStage(t,n){t.forEach(r=>{switch(n){case We.Starting:r.onStarting();break;case We.Ready:r.onReady();break;case We.Rendered:r.onRendered();break;case We.Steady:r.onSteady();break}})}};hs=Zc([es(2,At),es(3,it(Rt)),es(4,it(exports.LifecycleService))],hs);var pR=Object.defineProperty,mR=Object.getOwnPropertyDescriptor,_R=(e,t,n,r)=>{for(var s=r>1?void 0:r?mR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&pR(t,n,s),s},Ha=(e,t)=>(n,r)=>t(n,r,e);let Ci=class extends nt{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){const e=n=>{n.businesses.forEach(r=>{switch(r){case $e.UNRECOGNIZED:case $e.UNIVER_UNKNOWN:case $e.UNIVER_SLIDE:case $e.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType($e.UNIVER_DOC).forEach(s=>{const o=(s.getSnapshot().resources||[]).find(a=>a.name===n.pluginName);if(o)try{const a=n.parseJson(o.data);n.onLoad(s.getUnitId(),a)}catch{console.error(`Load Document{${s.getUnitId()}} Resources{${n.pluginName}} Data Error.`)}});break}case $e.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType($e.UNIVER_SHEET).forEach(s=>{const o=(s.getSnapshot().resources||[]).find(a=>a.name===n.pluginName);if(o)try{const a=n.parseJson(o.data);n.onLoad(s.getUnitId(),a)}catch{console.error(`Load Workbook{${s.getUnitId()}} Resources{${n.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(n=>e(n)),this.disposeWithMe(this._resourceManagerService.register$.subscribe(n=>e(n))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$($e.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$($e.UNIVER_DOC).subscribe(n=>{const r=n.getUnitId();El(r)||this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$($e.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$($e.UNIVER_DOC).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())}))}saveUnit(e){const t=this._univerInstanceService.getUnit(e);if(!t)return null;const n=this._resourceManagerService.getResources(e,t.type),r=re.deepClone(t.getSnapshot());return r.resources=n,r}};Ci=_R([Ha(0,it(ws)),Ha(1,it(an))],Ci);const Ri=_t("resource-loader-service");class eh extends nt{constructor(){super(...arguments);C(this,"_resourceMap",new Map);C(this,"_register$",new Oe.Subject);C(this,"register$",this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(n,r){return r?this.getResourcesByType(n,r):this.getAllResourceHooks().map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}getResourcesByType(n,r){return this.getAllResourceHooks().filter(o=>o.businesses.includes(r)).map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}registerPluginResource(n){const r=n.pluginName;if(this._resourceMap.has(r))throw new Error(`the pluginName is registered {${r}}`);return this._resourceMap.set(r,n),this._register$.next(n),Qe(()=>this._resourceMap.delete(r))}disposePluginResource(n){this._resourceMap.delete(n)}loadResources(n,r){this.getAllResourceHooks().forEach(s=>{var o;const i=(o=r==null?void 0:r.find(a=>a.name===s.pluginName))==null?void 0:o.data;if(i)try{const a=s.parseJson(i);s.onLoad(n,a)}catch{console.error("LoadResources Error!")}})}unloadResources(n){this.getAllResourceHooks().forEach(r=>{r.onUnLoad(n)})}dispose(){this._register$.complete(),this._resourceMap.clear()}}class Eo extends nt{constructor(){super();C(this,"_currentTheme");C(this,"_currentTheme$",new Oe.BehaviorSubject({}));C(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(Qe(()=>this._currentTheme$.complete()))}getCurrentTheme(){if(!this._currentTheme)throw new Error("[ThemeService]: current theme is not set!");return this._currentTheme}setTheme(n){this._currentTheme=n,this._currentTheme$.next(n)}}class th{constructor(t={},n){C(this,"_startedTypes",new Set);C(this,"_injector");C(this,"_disposingCallbacks",new Is);const r=this._injector=ER(n,t==null?void 0:t.override),{theme:s,locale:i,locales:o,logLevel:a}=t;s&&this._injector.get(Eo).setTheme(s),o&&this._injector.get(ur).load(o),i&&this._injector.get(ur).setLocale(i),a&&this._injector.get(At).setLogLevel(a),this._init(r)}get _univerInstanceService(){return this._injector.get(an)}get _pluginService(){return this._injector.get(exports.PluginService)}__getInjector(){return this._injector}onDispose(t){const n=this._disposingCallbacks.add(Qe(t));return Qe(()=>n.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(t){this._injector.get(ur).setLocale(t)}createUnit(t,n){return this._univerInstanceService.createUnit(t,n)}createUniverSheet(t){return this._injector.get(At).warn("[Univer]: Univer.createUniverSheet is deprecated, use createUnit instead"),this._univerInstanceService.createUnit($e.UNIVER_SHEET,t)}createUniverDoc(t){return this._injector.get(At).warn("[Univer]: Univer.createUniverDoc is deprecated, use createUnit instead"),this._univerInstanceService.createUnit($e.UNIVER_DOC,t)}createUniverSlide(t){return this._injector.get(At).warn("[Univer]: Univer.createUniverSlide is deprecated, use createUnit instead"),this._univerInstanceService.createUnit($e.UNIVER_SLIDE,t)}_init(t){this._univerInstanceService.registerCtorForType($e.UNIVER_SHEET,exports.Workbook),this._univerInstanceService.registerCtorForType($e.UNIVER_DOC,Ft),this._univerInstanceService.registerCtorForType($e.UNIVER_SLIDE,mo);const n=t.get(an);n.__setCreateHandler((r,s,i,o)=>{if(!this._startedTypes.has(r)){this._pluginService.startPluginForType(r),this._startedTypes.add(r);const l=t.createInstance(i,s);return n.__addUnit(l,o),this._tryProgressToReady(),l}const a=t.createInstance(i,s);return n.__addUnit(a,o),a})}_tryProgressToReady(){this._injector.get(exports.LifecycleService).stage<We.Ready&&(this._injector.get(exports.LifecycleService).stage=We.Ready)}registerPlugin(t,n){this._pluginService.registerPlugin(t,n)}}function ER(e,t){const n=Jc([[Gc],[ur],[Eo],[exports.LifecycleService],[exports.PluginService],[$n],[an,{useClass:exports.UniverInstanceService}],[Xc,{useClass:Qc}],[At,{useClass:Hl,lazy:!0}],[xt,{useClass:exports.CommandService}],[en,{useClass:exports.LocalUndoRedoService,lazy:!0}],[Yc,{useClass:Vc}],[Cr,{useClass:Bl}],[ws,{useClass:eh,lazy:!0}],[Ri,{useClass:Ci,lazy:!0}],[zc,{useClass:exports.AuthzIoLocalService}],[Kc,{useClass:exports.MentionIOLocalService,lazy:!0}]],t),r=e?e.createChild(n):new Rt(n);return Ll(r,[[$n],[Ri]]),r}var CR=Object.defineProperty,RR=Object.getOwnPropertyDescriptor,IR=(e,t,n,r)=>{for(var s=r>1?void 0:r?RR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&CR(t,n,s),s},vR=(e,t)=>(n,r)=>t(n,r,e);exports.FBlob=class extends Os{constructor(t,n){super(),this._blob=t,this._injector=n}copyBlob(){return this._injector.createInstance(exports.FBlob,this._blob)}getAs(t){const n=this.copyBlob();return n.setContentType(t),n}getDataAsString(t){return this._blob===null?Promise.resolve(""):t===void 0?this._blob.text():new Promise((n,r)=>{this._blob.arrayBuffer().then(s=>{const i=new TextDecoder(t).decode(s);n(i)}).catch(s=>{r(new Error(`Failed to read Blob as ArrayBuffer: ${s.message}`))})})}getBytes(){return this._blob?this._blob.arrayBuffer().then(t=>new Uint8Array(t)):Promise.reject(new Error("Blob is undefined or null."))}setBytes(t){return this._blob=new Blob([t]),this}setDataFromString(t,n){const r=n!=null?n:"text/plain",s=new Blob([t],{type:r});return this._blob=s,this}getContentType(){var t;return(t=this._blob)==null?void 0:t.type}setContentType(t){var n;return this._blob=(n=this._blob)==null?void 0:n.slice(0,this._blob.size,t),this}};exports.FBlob=IR([vR(1,it(Rt))],exports.FBlob);var yR=Object.defineProperty,SR=Object.getOwnPropertyDescriptor,OR=(e,t,n,r)=>{for(var s=r>1?void 0:r?SR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&yR(t,n,s),s},bR=(e,t)=>(n,r)=>t(n,r,e);let Ii=class extends go{constructor(e,t){super(t),this.doc=e}};Ii=OR([bR(1,it(Rt))],Ii);var Co=(e=>(e[e.INFO=0]="INFO",e[e.STOP=1]="STOP",e[e.WARNING=2]="WARNING",e))(Co||{}),Ro=(e=>(e.BETWEEN="between",e.EQUAL="equal",e.GREATER_THAN="greaterThan",e.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",e.LESS_THAN="lessThan",e.LESS_THAN_OR_EQUAL="lessThanOrEqual",e.NOT_BETWEEN="notBetween",e.NOT_EQUAL="notEqual",e))(Ro||{}),Io=(e=>(e[e.TEXT=0]="TEXT",e[e.ARROW=1]="ARROW",e[e.CUSTOM=2]="CUSTOM",e))(Io||{}),vo=(e=>(e.VALID="valid",e.INVALID="invalid",e.VALIDATING="validating",e))(vo||{}),yo=(e=>(e.CUSTOM="custom",e.LIST="list",e.LIST_MULTIPLE="listMultiple",e.NONE="none",e.TEXT_LENGTH="textLength",e.DATE="date",e.TIME="time",e.WHOLE="whole",e.DECIMAL="decimal",e.CHECKBOX="checkbox",e.ANY="any",e))(yo||{});const Dn=class Dn{static get(){if(this._instance)return this._instance;const t=new Dn;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(n=>{n!=="constructor"&&(this.prototype[n]=t.prototype[n])}),Object.getOwnPropertyNames(t).forEach(n=>{n!=="prototype"&&n!=="name"&&n!=="length"&&(this[n]=t[n])})}constructor(){for(const t in Dn.prototype)this[t]=Dn.prototype[t]}get UniverInstanceType(){return $e}get LifecycleStages(){return We}get DataValidationType(){return yo}get DataValidationErrorStyle(){return Co}get DataValidationRenderMode(){return Io}get DataValidationOperator(){return Ro}get DataValidationStatus(){return vo}get CommandType(){return Wn}get BaselineOffset(){return Pt}get BooleanNumber(){return Se}get HorizontalAlign(){return Bt}get TextDecoration(){return ro}get TextDirection(){return Pn}get VerticalAlign(){return tn}get BorderType(){return Vi}get BorderStyleTypes(){return Xe}get AutoFillSeries(){return Yi}get ColorType(){return Et}get CommonHideTypes(){return Gi}get CopyPasteType(){return Ki}get DeleteDirection(){return Xi}get DeveloperMetadataVisibility(){return Qi}get Dimension(){return Ji}get Direction(){return qi}get InterpolationPointType(){return Zi}get LocaleType(){return zn}get MentionType(){return dr}get ProtectionType(){return eo}get RelativeDate(){return to}get SheetTypes(){return no}get ThemeColorType(){return ct}};C(Dn,"_instance");let ds=Dn;const xn=class xn{static get(){if(this._instance)return this._instance;const t=new xn;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(n=>{n!=="constructor"&&(this.prototype[n]=t.prototype[n])}),Object.getOwnPropertyNames(t).forEach(n=>{n!=="prototype"&&n!=="name"&&n!=="length"&&(this[n]=t[n])})}constructor(){for(const t in xn.prototype)this[t]=xn.prototype[t]}get DocCreated(){return"DocCreated"}get DocDisposed(){return"DocDisposed"}get LifeCycleChanged(){return"LifeCycleChanged"}get Redo(){return"Redo"}get Undo(){return"Undo"}get BeforeRedo(){return"BeforeRedo"}get BeforeUndo(){return"BeforeUndo"}get CommandExecuted(){return"CommandExecuted"}get BeforeCommandExecute(){return"BeforeCommandExecute"}};C(xn,"_instance");let fs=xn;var wR=Object.defineProperty,AR=Object.getOwnPropertyDescriptor,TR=(e,t,n,r)=>{for(var s=r>1?void 0:r?AR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&wR(t,n,s),s},Wa=(e,t)=>(n,r)=>t(n,r,e);exports.FHooks=class extends Os{constructor(t,n){super(),this._injector=t,this._lifecycleService=n}onStarting(t){return Qe(this._lifecycleService.lifecycle$.pipe(Oe.filter(n=>n===We.Starting)).subscribe(t))}onReady(t){return Qe(this._lifecycleService.lifecycle$.pipe(Oe.filter(n=>n===We.Ready)).subscribe(t))}onRendered(t){return Qe(this._lifecycleService.lifecycle$.pipe(Oe.filter(n=>n===We.Rendered)).subscribe(t))}onSteady(t){return Qe(this._lifecycleService.lifecycle$.pipe(Oe.filter(n=>n===We.Steady)).subscribe(t))}onBeforeUndo(t){return this._injector.get(xt).beforeCommandExecuted(r=>{if(r.id===gn.id){const i=this._injector.get(en).pitchTopUndoElement();i&&t(i)}})}onUndo(t){return this._injector.get(xt).onCommandExecuted(r=>{if(r.id===gn.id){const i=this._injector.get(en).pitchTopUndoElement();i&&t(i)}})}onBeforeRedo(t){return this._injector.get(xt).beforeCommandExecuted(r=>{if(r.id===pn.id){const i=this._injector.get(en).pitchTopRedoElement();i&&t(i)}})}onRedo(t){return this._injector.get(xt).onCommandExecuted(r=>{if(r.id===pn.id){const i=this._injector.get(en).pitchTopRedoElement();i&&t(i)}})}};exports.FHooks=TR([Wa(0,it(Rt)),Wa(1,it(exports.LifecycleService))],exports.FHooks);var NR=Object.defineProperty,MR=Object.getOwnPropertyDescriptor,DR=(e,t,n,r)=>{for(var s=r>1?void 0:r?MR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&NR(t,n,s),s},za=(e,t)=>(n,r)=>t(n,r,e);let vi=class extends Os{constructor(e,t){super(),this._injector=e,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};vi=DR([za(0,it(Rt)),za(1,it($n))],vi);const ps=class ps{static get(){if(this._instance)return this._instance;const t=new ps;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(n=>{n!=="constructor"&&(this.prototype[n]=t.prototype[n])}),Object.getOwnPropertyNames(t).forEach(n=>{n!=="prototype"&&n!=="name"&&n!=="length"&&(this[n]=t[n])})}get rectangle(){return Yt}get numfmt(){return fu}get tools(){return re}};C(ps,"_instance");let gs=ps;var xR=Object.defineProperty,LR=Object.getOwnPropertyDescriptor,UR=(e,t,n,r)=>{for(var s=r>1?void 0:r?LR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&xR(t,n,s),s},Fr=(e,t)=>(n,r)=>t(n,r,e);exports.FUniver=class extends go{constructor(n,r,s,i){super(n);C(this,"_eventRegistry",new Map);this._injector=n,this._commandService=r,this._univerInstanceService=s,this._lifecycleService=i,this.disposeWithMe(this._lifecycleService.lifecycle$.subscribe(o=>{this.fireEvent(this.Event.LifeCycleChanged,{stage:o})})),this.disposeWithMe(this._commandService.beforeCommandExecuted(o=>{if(!this._eventRegistry.get(this.Event.BeforeRedo)&&!this._eventRegistry.get(this.Event.BeforeUndo)&&!this._eventRegistry.get(this.Event.BeforeCommandExecute))return;const{id:a,type:l,params:u}=o,c={id:a,type:l,params:u};switch(o.id){case pn.id:this.fireEvent(this.Event.BeforeRedo,c);break;case gn.id:this.fireEvent(this.Event.BeforeUndo,c);break;default:this.fireEvent(this.Event.BeforeCommandExecute,c);break}if(c.cancel)throw new Pl})),this.disposeWithMe(this._commandService.onCommandExecuted(o=>{if(!this._eventRegistry.get(this.Event.Redo)&&!this._eventRegistry.get(this.Event.Undo)&&!this._eventRegistry.get(this.Event.CommandExecuted))return;const{id:a,type:l,params:u}=o,c={id:a,type:l,params:u};switch(o.id){case pn.id:this.fireEvent(this.Event.Redo,c);break;case gn.id:this.fireEvent(this.Event.Undo,c);break;default:this.fireEvent(this.Event.CommandExecuted,c);break}})),this._initUnitEvent(this._injector),this._injector.onDispose(()=>{this.dispose()})}static newAPI(n){return(n instanceof th?n.__getInjector():n).createInstance(exports.FUniver)}_ensureEventRegistry(n){return this._eventRegistry.has(n)||this._eventRegistry.set(n,new bs),this._eventRegistry.get(n)}_initUnitEvent(n){const r=n.get(an);this.disposeWithMe(r.unitDisposed$.subscribe(s=>{this._eventRegistry.get(this.Event.DocDisposed)&&s.type===$e.UNIVER_DOC&&this.fireEvent(this.Event.DocDisposed,{unitId:s.getUnitId(),unitType:s.type,snapshot:s.getSnapshot()})})),this.disposeWithMe(r.unitAdded$.subscribe(s=>{if(this._eventRegistry.get(this.Event.DocCreated)&&s.type===$e.UNIVER_DOC){const i=s,o=n.createInstance(Ii,i);this.fireEvent(this.Event.DocCreated,{unitId:s.getUnitId(),type:s.type,doc:o,unit:o})}}))}_eventListend(n){return this._eventRegistry.get(n)}disposeUnit(n){return this._univerInstanceService.disposeUnit(n)}getCurrentLifecycleStage(){return this._injector.get(exports.LifecycleService).stage}undo(){return this._commandService.executeCommand(gn.id)}redo(){return this._commandService.executeCommand(pn.id)}onBeforeCommandExecute(n){return this._commandService.beforeCommandExecuted((r,s)=>{n(r,s)})}onCommandExecuted(n){return this._commandService.onCommandExecuted((r,s)=>{n(r,s)})}executeCommand(n,r,s){return this._commandService.executeCommand(n,r,s)}syncExecuteCommand(n,r,s){return this._commandService.syncExecuteCommand(n,r,s)}getHooks(){return this._injector.createInstance(exports.FHooks)}get Enum(){return ds.get()}get Event(){return fs.get()}get Util(){return gs.get()}addEvent(n,r){return this._ensureEventRegistry(n).add(r),Qe(()=>this._ensureEventRegistry(n).delete(r))}fireEvent(n,r){var s;return(s=this._eventRegistry.get(n))==null||s.getData().forEach(i=>{i(r)}),r.cancel}hasEventCallback(n){var s,i;return((i=(s=this._eventRegistry.get(n))==null?void 0:s.getData().length)!=null?i:0)>0}getUserManager(){return this._injector.createInstance(vi)}newBlob(){return this._injector.createInstance(exports.FBlob)}newColor(){return new Rr}newRichText(n){return sn.create(n)}newRichTextValue(n){return Ht.create(n)}newParagraphStyle(n){return kn.create(n)}newParagraphStyleValue(n){return Gn.create(n)}newTextStyle(n){return Wt.create(n)}newTextStyleValue(n){return Vn.create(n)}newTextDecoration(n){return new jt(n)}};exports.FUniver=UR([Fr(0,it(Rt)),Fr(1,xt),Fr(2,an),Fr(3,it(exports.LifecycleService))],exports.FUniver);function nh(e){return/^-?\d+(\.\d+)?$/.test(e)}function PR(e){return nh(e)?Number(e)<=Number.MAX_SAFE_INTEGER:!1}function FR(e){const t=new MessageChannel;let n=!1;const r=()=>{n||e()};return t.port1.onmessage=r,t.port2.postMessage(null),()=>{n=!0,t.port1.close(),t.port2.close()}}function kR(e,t){return t.forEach(n=>e.add(n)),e}function $R(e,t,n,r){var u;if(t==="")return e;const s={id:"mock-id",body:e,documentStyle:{}},i=new Ft(s),o=t.length;let a;for(;(a=(r?i.getBody().dataStream:i.getBody().dataStream.toLowerCase()).indexOf(t))>=0;){const h=new ze,c=Vt.getInstance();if(a>0&&h.retain(a),n.length>0){const d=i.sliceBody(a,a+o),f={dataStream:n};if(Array.isArray(d==null?void 0:d.textRuns)&&d.textRuns.length&&(f.textRuns=[{...d.textRuns[0],st:0,ed:n.length}]),(u=d==null?void 0:d.customRanges)!=null&&u.length){const E=d.customRanges[0];f.customRanges=[{...E,startIndex:0,endIndex:n.length-1}]}h.insert(n.length,f)}h.delete(o),i.apply(c.editOp(h.serialize()))}const l=i.getBody();return i.dispose(),l}const BR="__default_document_sub_component_id20231101__";class rh{constructor(){C(this,"skipNextObservers",!1);C(this,"lastReturnValue");C(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class jR extends Oe.Subject{constructor(){super(...arguments);C(this,"_sortedObservers",[])}subscribe(){throw new Error("[EventSubject]: please use `subscribeEvent` instead of `subscribe` method for `EventSubject`.")}next(){throw new Error("[EventSubject]: please use `emitEvent` instead of `next` method for `EventSubject`.")}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(n){let r;typeof n=="function"?r={next:([i,o])=>n(i,o)}:r=n;const s=super.subscribe(r);return this._sortedObservers.push(r),this._sortedObservers.sort((i,o)=>{var a,l;return((a=i.priority)!=null?a:0)-((l=o.priority)!=null?l:0)}),s.add(()=>this._sortedObservers=this._sortedObservers.filter(i=>i!==r)),s}clearObservers(){this._sortedObservers.forEach(n=>{var r;return(r=n.complete)==null?void 0:r.call(n)}),this._sortedObservers.length=0}emitEvent(n){var r;if(!this.closed){const s=new rh;s.lastReturnValue=n;for(const i of this._sortedObservers){const o=(r=i.next)==null?void 0:r.call(i,[n,s]);if(s.lastReturnValue=o,s.skipNextObservers)return{handled:!0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}throw new Error("[EventSubject]: cannot emit event on a closed subject.")}}function HR(e){return new Oe.Observable(t=>{const n=e.subscribeEvent(r=>{t.next(r)});return()=>n.unsubscribe()})}const WR=_t("ILocalStorageService");function zR(e){return!(e.length===0||e.length>31||e.startsWith("'")||e.endsWith("'")||/[:\\\/\?\*\[\]]/.test(e))}function YR(e){return new Promise(t=>setTimeout(t,e))}function VR(e=1){return new Promise(t=>{let n=0;const r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}var So=(e=>(e.URL="URL",e.UUID="UUID",e.BASE64="BASE64",e))(So||{}),sh=(e=>(e.SUCCUSS="0",e.ERROR_EXCEED_SIZE="1",e.ERROR_IMAGE_TYPE="2",e.ERROR_UPLOAD_COUNT_LIMIT="3",e.ERROR_IMAGE="4",e))(sh||{});const yi=_t("core.image-io.service");class GR{constructor(t,n=100){C(this,"_imageCacheMap");this._injector=t,this._imageCacheMap=new fr(n)}_getImageCacheKey(t,n){return`${t}-${n}`}getImage(t,n,r,s){const i=this._getImageCacheKey(t,n);let o=this._imageCacheMap.get(i);return o||((async()=>{o=new Image;const a=this._injector.has(yi)?this._injector.get(yi):null;if(t===So.UUID)try{o.src=await(a==null?void 0:a.getImage(n))||""}catch(l){console.error(l)}else o.src=n;o.onload=()=>{r==null||r()},o.onerror=()=>{s==null||s()},this._imageCacheMap.set(i,o)})(),null)}}const KR=["script","style","meta","comment","link"];var ih=(e=>(e[e.DISABLED=0]="DISABLED",e[e.FULL_ALPHA=1]="FULL_ALPHA",e[e.FULL_HANGUL=2]="FULL_HANGUL",e[e.FULL_KATAKANA=3]="FULL_KATAKANA",e[e.HALF_ALPHA=4]="HALF_ALPHA",e[e.HALF_HANGUL=5]="HALF_HANGUL",e[e.HALF_KATAKANA=6]="HALF_KATAKANA",e[e.HIRAGANA=7]="HIRAGANA",e[e.NO_CONTROL=8]="NO_CONTROL",e[e.OFF=9]="OFF",e[e.ON=10]="ON",e))(ih||{});const Ya=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],js=1,Qn=8;class Oo{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[n,r]=new Uint8Array(t,0,2);if(n!==219)throw new Error("Data does not appear to be in a KDBush format.");const s=r>>4;if(s!==js)throw new Error(`Got v${s} data when expected v${js}.`);const i=Ya[r&15];if(!i)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new Oo(a,o,i,t)}constructor(t,n=64,r=Float64Array,s){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+n,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=Ya.indexOf(this.ArrayType),o=t*2*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);s&&s instanceof ArrayBuffer?(this.data=s,this.ids=new this.IndexArrayType(this.data,Qn,t),this.coords=new this.ArrayType(this.data,Qn+a+l,t*2),this._pos=t*2,this._finished=!0):(this.data=new ArrayBuffer(Qn+o+a+l),this.ids=new this.IndexArrayType(this.data,Qn,t),this.coords=new this.ArrayType(this.data,Qn+a+l,t*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(js<<4)+i]),new Uint16Array(this.data,2,1)[0]=n,new Uint32Array(this.data,4,1)[0]=t)}add(t,n){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=n,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Si(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,n,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:o,nodeSize:a}=this,l=[0,i.length-1,0],u=[];for(;l.length;){const h=l.pop()||0,c=l.pop()||0,d=l.pop()||0;if(c-d<=a){for(let O=d;O<=c;O++){const U=o[2*O],ne=o[2*O+1];U>=t&&U<=r&&ne>=n&&ne<=s&&u.push(i[O])}continue}const f=d+c>>1,E=o[2*f],R=o[2*f+1];E>=t&&E<=r&&R>=n&&R<=s&&u.push(i[f]),(h===0?t<=E:n<=R)&&(l.push(d),l.push(f-1),l.push(1-h)),(h===0?r>=E:s>=R)&&(l.push(f+1),l.push(c),l.push(1-h))}return u}within(t,n,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:i,nodeSize:o}=this,a=[0,s.length-1,0],l=[],u=r*r;for(;a.length;){const h=a.pop()||0,c=a.pop()||0,d=a.pop()||0;if(c-d<=o){for(let O=d;O<=c;O++)Va(i[2*O],i[2*O+1],t,n)<=u&&l.push(s[O]);continue}const f=d+c>>1,E=i[2*f],R=i[2*f+1];Va(E,R,t,n)<=u&&l.push(s[f]),(h===0?t-r<=E:n-r<=R)&&(a.push(d),a.push(f-1),a.push(1-h)),(h===0?t+r>=E:n+r>=R)&&(a.push(f+1),a.push(c),a.push(1-h))}return l}}function Si(e,t,n,r,s,i){if(s-r<=n)return;const o=r+s>>1;oh(e,t,o,r,s,i),Si(e,t,n,r,o-1,1-i),Si(e,t,n,o+1,s,1-i)}function oh(e,t,n,r,s,i){for(;s>r;){if(s-r>600){const u=s-r+1,h=n-r+1,c=Math.log(u),d=.5*Math.exp(2*c/3),f=.5*Math.sqrt(c*d*(u-d)/u)*(h-u/2<0?-1:1),E=Math.max(r,Math.floor(n-h*d/u+f)),R=Math.min(s,Math.floor(n+(u-h)*d/u+f));oh(e,t,n,E,R,i)}const o=t[2*n+i];let a=r,l=s;for(Jn(e,t,r,n),t[2*s+i]>o&&Jn(e,t,r,s);a<l;){for(Jn(e,t,a,l),a++,l--;t[2*a+i]<o;)a++;for(;t[2*l+i]>o;)l--}t[2*r+i]===o?Jn(e,t,r,l):(l++,Jn(e,t,l,s)),l<=n&&(r=l+1),n<=l&&(s=l-1)}}function Jn(e,t,n,r){Hs(e,n,r),Hs(t,2*n,2*r),Hs(t,2*n+1,2*r+1)}function Hs(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function Va(e,t,n,r){const s=e-n,i=t-r;return s*s+i*i}function ah(e,t,n=0,r=e.length-1,s=XR){for(;r>n;){if(r-n>600){const l=r-n+1,u=t-n+1,h=Math.log(l),c=.5*Math.exp(2*h/3),d=.5*Math.sqrt(h*c*(l-c)/l)*(u-l/2<0?-1:1),f=Math.max(n,Math.floor(t-u*c/l+d)),E=Math.min(r,Math.floor(t+(l-u)*c/l+d));ah(e,t,f,E,s)}const i=e[t];let o=n,a=r;for(qn(e,n,t),s(e[r],i)>0&&qn(e,n,r);o<a;){for(qn(e,o,a),o++,a--;s(e[o],i)<0;)o++;for(;s(e[a],i)>0;)a--}s(e[n],i)===0?qn(e,n,a):(a++,qn(e,a,r)),a<=t&&(n=a+1),t<=a&&(r=a-1)}}function qn(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function XR(e,t){return e<t?-1:e>t?1:0}class Oi{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let n=this.data;const r=[];if(!$r(t,n))return r;const s=this.toBBox,i=[];for(;n;){for(let o=0;o<n.children.length;o++){const a=n.children[o],l=n.leaf?s(a):a;$r(t,l)&&(n.leaf?r.push(a):zs(t,l)?this._all(a,r):i.push(a))}n=i.pop()}return r}collides(t){let n=this.data;if(!$r(t,n))return!1;const r=[];for(;n;){for(let s=0;s<n.children.length;s++){const i=n.children[s],o=n.leaf?this.toBBox(i):i;if($r(t,o)){if(n.leaf||zs(t,o))return!0;r.push(i)}}n=r.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let r=0;r<t.length;r++)this.insert(t[r]);return this}let n=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=n;else if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){const r=this.data;this.data=n,n=r}this._insert(n,this.data.height-n.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=On([]),this}remove(t,n){if(!t)return this;let r=this.data;const s=this.toBBox(t),i=[],o=[];let a,l,u;for(;r||i.length;){if(r||(r=i.pop(),l=i[i.length-1],a=o.pop(),u=!0),r.leaf){const h=QR(t,r.children,n);if(h!==-1)return r.children.splice(h,1),i.push(r),this._condense(i),this}!u&&!r.leaf&&zs(r,s)?(i.push(r),o.push(a),a=0,l=r,r=r.children[0]):l?(a++,r=l.children[a],u=!1):r=null}return this}toBBox(t){return t}compareMinX(t,n){return t.minX-n.minX}compareMinY(t,n){return t.minY-n.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,n){const r=[];for(;t;)t.leaf?n.push(...t.children):r.push(...t.children),t=r.pop();return n}_build(t,n,r,s){const i=r-n+1;let o=this._maxEntries,a;if(i<=o)return a=On(t.slice(n,r+1)),yn(a,this.toBBox),a;s||(s=Math.ceil(Math.log(i)/Math.log(o)),o=Math.ceil(i/Math.pow(o,s-1))),a=On([]),a.leaf=!1,a.height=s;const l=Math.ceil(i/o),u=l*Math.ceil(Math.sqrt(o));Ga(t,n,r,u,this.compareMinX);for(let h=n;h<=r;h+=u){const c=Math.min(h+u-1,r);Ga(t,h,c,l,this.compareMinY);for(let d=h;d<=c;d+=l){const f=Math.min(d+l-1,c);a.children.push(this._build(t,d,f,s-1))}}return yn(a,this.toBBox),a}_chooseSubtree(t,n,r,s){for(;s.push(n),!(n.leaf||s.length-1===r);){let i=1/0,o=1/0,a;for(let l=0;l<n.children.length;l++){const u=n.children[l],h=Ws(u),c=ZR(t,u)-h;c<o?(o=c,i=h<i?h:i,a=u):c===o&&h<i&&(i=h,a=u)}n=a||n.children[0]}return n}_insert(t,n,r){const s=r?t:this.toBBox(t),i=[],o=this._chooseSubtree(s,this.data,n,i);for(o.children.push(t),or(o,s);n>=0&&i[n].children.length>this._maxEntries;)this._split(i,n),n--;this._adjustParentBBoxes(s,i,n)}_split(t,n){const r=t[n],s=r.children.length,i=this._minEntries;this._chooseSplitAxis(r,i,s);const o=this._chooseSplitIndex(r,i,s),a=On(r.children.splice(o,r.children.length-o));a.height=r.height,a.leaf=r.leaf,yn(r,this.toBBox),yn(a,this.toBBox),n?t[n-1].children.push(a):this._splitRoot(r,a)}_splitRoot(t,n){this.data=On([t,n]),this.data.height=t.height+1,this.data.leaf=!1,yn(this.data,this.toBBox)}_chooseSplitIndex(t,n,r){let s,i=1/0,o=1/0;for(let a=n;a<=r-n;a++){const l=ir(t,0,a,this.toBBox),u=ir(t,a,r,this.toBBox),h=e0(l,u),c=Ws(l)+Ws(u);h<i?(i=h,s=a,o=c<o?c:o):h===i&&c<o&&(o=c,s=a)}return s||r-n}_chooseSplitAxis(t,n,r){const s=t.leaf?this.compareMinX:JR,i=t.leaf?this.compareMinY:qR,o=this._allDistMargin(t,n,r,s),a=this._allDistMargin(t,n,r,i);o<a&&t.children.sort(s)}_allDistMargin(t,n,r,s){t.children.sort(s);const i=this.toBBox,o=ir(t,0,n,i),a=ir(t,r-n,r,i);let l=kr(o)+kr(a);for(let u=n;u<r-n;u++){const h=t.children[u];or(o,t.leaf?i(h):h),l+=kr(o)}for(let u=r-n-1;u>=n;u--){const h=t.children[u];or(a,t.leaf?i(h):h),l+=kr(a)}return l}_adjustParentBBoxes(t,n,r){for(let s=r;s>=0;s--)or(n[s],t)}_condense(t){for(let n=t.length-1,r;n>=0;n--)t[n].children.length===0?n>0?(r=t[n-1].children,r.splice(r.indexOf(t[n]),1)):this.clear():yn(t[n],this.toBBox)}}function QR(e,t,n){if(!n)return t.indexOf(e);for(let r=0;r<t.length;r++)if(n(e,t[r]))return r;return-1}function yn(e,t){ir(e,0,e.children.length,t,e)}function ir(e,t,n,r,s){s||(s=On(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let i=t;i<n;i++){const o=e.children[i];or(s,e.leaf?r(o):o)}return s}function or(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function JR(e,t){return e.minX-t.minX}function qR(e,t){return e.minY-t.minY}function Ws(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function kr(e){return e.maxX-e.minX+(e.maxY-e.minY)}function ZR(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function e0(e,t){const n=Math.max(e.minX,t.minX),r=Math.max(e.minY,t.minY),s=Math.min(e.maxX,t.maxX),i=Math.min(e.maxY,t.maxY);return Math.max(0,s-n)*Math.max(0,i-r)}function zs(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function $r(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function On(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Ga(e,t,n,r,s){const i=[t,n];for(;i.length;){if(n=i.pop(),t=i.pop(),n-t<=r)continue;const o=t+Math.ceil((n-t)/r/2)*r;ah(e,o,t,n,s),i.push(t,o,o,n)}}class t0{constructor(t=!1){C(this,"_tree",new Map);C(this,"_oneCellCache",new Map);C(this,"_kdTree",new Map);this._enableOneCellCache=t}dispose(){this.clear()}getTree(t,n){return this._tree.has(t)||this._tree.set(t,new Map),this._tree.get(t).has(n)||this._tree.get(t).set(n,new Oi),this._tree.get(t).get(n)}_getOneCellCache(t,n,r,s){return this._oneCellCache.has(t)||this._oneCellCache.set(t,new Map),this._oneCellCache.get(t).has(n)||this._oneCellCache.get(t).set(n,new Map),this._oneCellCache.get(t).get(n).has(r)||this._oneCellCache.get(t).get(n).set(r,new Map),this._oneCellCache.get(t).get(n).get(r).has(s)||this._oneCellCache.get(t).get(n).get(r).set(s,new Set),this._oneCellCache.get(t).get(n).get(r).get(s)}_removeOneCellCache(t,n,r,s,i){const o=this._oneCellCache.get(t);if(!o)return;const a=o.get(n);if(!a)return;const l=a.get(r);if(!l)return;const u=l.get(s);u&&u.delete(i)}_removeCellCacheByRange(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this._oneCellCache.get(n);if(!o)return;const a=o.get(r);if(!a)return;const{startRow:l,startColumn:u,endRow:h,endColumn:c}=s;for(let d=l;d<=h;d++){const f=a.get(d);if(f)for(let E=u;E<=c;E++){const R=f.get(E);R&&R.delete(i)}}}_insertOneCellCache(t,n,r,s,i){this._getOneCellCache(t,n,r,s).add(i)}_getRdTreeItems(t){const n=[];for(const[r,s]of t)for(const[i,o]of s)n.push({x:i,y:r,ids:o});return n}_searchByOneCellCache(t){var E;const{unitId:n,sheetId:r,range:s}=t,{startRow:i,startColumn:o,endRow:a,endColumn:l}=s,u=(E=this._kdTree.get(n))==null?void 0:E.get(r);if(!u)return[];const{tree:h,items:c}=u,d=h.range(o,i,l,a),f=[];for(const R of d){const O=c[R];f.push(...Array.from(O.ids))}return f}openKdTree(){var t;for(const[n,r]of this._oneCellCache){this._kdTree.has(n)||this._kdTree.set(n,new Map);for(const[s,i]of r){const o=this._getRdTreeItems(i),a=new Oo(o.length);(t=this._kdTree.get(n))==null||t.set(s,{tree:a,items:o});for(const l of o)a.add(l.x,l.y);a.finish()}}}closeKdTree(){var t;for(const[n,r]of this._oneCellCache)for(const[s,i]of r)(t=this._kdTree.get(n))==null||t.set(s,void 0)}insert(t){const{unitId:n,sheetId:r,range:s,id:i}=t;if(!n||n.length===0)return;let{startRow:o,endRow:a,startColumn:l,endColumn:u}=s;if(this._enableOneCellCache&&o===a&&l===u){this._insertOneCellCache(n,r,o,l,i);return}const h=this.getTree(n,r);Number.isNaN(o)&&(o=0),Number.isNaN(l)&&(l=0),Number.isNaN(a)&&(a=Number.POSITIVE_INFINITY),Number.isNaN(u)&&(u=Number.POSITIVE_INFINITY),h.insert({minX:l,minY:o,maxX:u,maxY:a,id:i})}bulkInsert(t){for(const n of t)this.insert(n)}*searchGenerator(t){var a;const{unitId:n,sheetId:r,range:s}=t;if(this._enableOneCellCache){const l=this._searchByOneCellCache(t);for(const u of l)yield u}const i=(a=this._tree.get(n))==null?void 0:a.get(r);if(!i)return;const o=i.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(const l of o)yield l.id}bulkSearch(t,n){const r=new Set;for(const s of t)for(const i of this.searchGenerator(s))(n==null?void 0:n.has(i))!==!0&&r.add(i);return r}removeById(t,n){var r,s;n?((r=this._tree.get(t))==null||r.delete(n),(s=this._oneCellCache.get(t))==null||s.delete(n)):(this._tree.delete(t),this._oneCellCache.delete(t))}_removeRTreeItem(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this.getTree(n,r),a=o.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(let l=0;l<a.length;l++)a[l].id===i&&o.remove(a[l])}remove(t){const{unitId:n,sheetId:r,range:s,id:i}=t,{startRow:o,startColumn:a,endRow:l,endColumn:u}=s;this._enableOneCellCache?o===l&&a===u?this._removeOneCellCache(n,r,s.startRow,s.startColumn,i):(this._removeCellCacheByRange(t),this._removeRTreeItem(t)):this._removeRTreeItem(t)}bulkRemove(t){for(const n of t)this.remove(n)}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){const t={};return this._tree.forEach((n,r)=>{t[r]={},n.forEach((s,i)=>{t[r][i]=s.toJSON()})}),t}fromJSON(t){this._tree.clear();for(const n in t){this._tree.set(n,new Map);for(const r in t[n]){const s=new Oi;s.fromJSON(t[n][r]),this._tree.get(n).set(r,s)}}}}dh();exports.ABCToNumber=j_;exports.AUTO_HEIGHT_FOR_MERGED_CELLS=yg;exports.AbsoluteRefType=tt;exports.ActionIterator=Sn;exports.AlignTypeH=ju;exports.AlignTypeV=Hu;exports.ArrangeTypeEnum=Yu;exports.ArrowsAndMarkersShapes=Ql;exports.AsyncInterceptorManager=cC;exports.AutoFillSeries=Yi;exports.BaselineOffset=Pt;exports.BasicShapes=Xl;exports.BlockType=Ru;exports.BooleanNumber=Se;exports.BorderStyleTypes=Xe;exports.BorderType=Vi;exports.BuildTextUtils=st;exports.BulletAlignment=vr;exports.COLORS=oi;exports.CanceledError=Pl;exports.CellModeEnum=bn;exports.CellValueType=nn;exports.Color=En;exports.ColorBuilder=Rr;exports.ColorKit=bt;exports.ColorType=Et;exports.ColumnSeparatorType=yu;exports.CommandType=Wn;exports.CommonHideTypes=Gi;exports.ConfigService=Vc;exports.ContextService=Bl;exports.CopyPasteType=Ki;exports.CustomCommandExecutionError=ri;exports.CustomDecorationType=fn;exports.CustomRangeType=on;exports.DEFAULT_CELL=w_;exports.DEFAULT_DOC=fo;exports.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=BR;exports.DEFAULT_EMPTY_DOCUMENT_VALUE=_l;exports.DEFAULT_RANGE=O_;exports.DEFAULT_RANGE_ARRAY=S_;exports.DEFAULT_SELECTION=b_;exports.DEFAULT_SLIDE=gu;exports.DEFAULT_STYLES=ht;exports.DEFAULT_WORKSHEET_COLUMN_COUNT=Nc;exports.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=yC;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Lc;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=wC;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH=Dc;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=OC;exports.DEFAULT_WORKSHEET_ROW_COUNT=Tc;exports.DEFAULT_WORKSHEET_ROW_COUNT_KEY=vC;exports.DEFAULT_WORKSHEET_ROW_HEIGHT=Mc;exports.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=SC;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=xc;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=bC;exports.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=Pi;exports.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=Ui;exports.DOCS_ZEN_EDITOR_UNIT_ID_KEY=ml;exports.DOC_RANGE_TYPE=ou;exports.DashStyleType=Nu;exports.DataStreamTreeNodeType=Ic;exports.DataStreamTreeTokenType=qt;exports.DataValidationErrorStyle=Co;exports.DataValidationImeMode=ih;exports.DataValidationOperator=Ro;exports.DataValidationRenderMode=Io;exports.DataValidationStatus=vo;exports.DataValidationType=yo;exports.DeleteDirection=Xi;exports.DependentOn=gR;exports.DesktopLogService=Hl;exports.DeveloperMetadataVisibility=Qi;exports.Dimension=Ji;exports.Direction=qi;exports.Disposable=nt;exports.DisposableCollection=Is;exports.DocStyleType=Eu;exports.DocumentDataModel=Ft;exports.DocumentFlavor=ao;exports.DrawingTypeEnum=Vu;exports.EDITOR_ACTIVATED=kc;exports.EXTENSION_NAMES=pu;exports.ErrorService=Gc;exports.EventState=rh;exports.EventSubject=jR;exports.FBase=Os;exports.FBaseInitialable=go;exports.FEnum=ds;exports.FEventName=fs;exports.FOCUSING_COMMON_DRAWINGS=jC;exports.FOCUSING_DOC=rr;exports.FOCUSING_EDITOR_BUT_HIDDEN=UC;exports.FOCUSING_EDITOR_INPUT_FORMULA=PC;exports.FOCUSING_EDITOR_STANDALONE=kC;exports.FOCUSING_FX_BAR_EDITOR=$c;exports.FOCUSING_PANEL_EDITOR=$C;exports.FOCUSING_SHEET=Tn;exports.FOCUSING_SLIDE=sr;exports.FOCUSING_UNIT=nr;exports.FOCUSING_UNIVER_EDITOR=FC;exports.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=BC;exports.FORMULA_EDITOR_ACTIVATED=HC;exports.FUtil=gs;exports.FollowNumberWithType=Cu;exports.FontItalic=ss;exports.FontStyleType=wn;exports.FontWeight=is;exports.GridType=Iu;exports.HLSColor=ru;exports.HorizontalAlign=Bt;exports.IAuthzIoService=zc;exports.ICommandService=xt;exports.IConfigService=Yc;exports.IContextService=Cr;exports.IImageIoService=yi;exports.ILocalStorageService=WR;exports.ILogService=At;exports.IMentionIOService=Kc;exports.IPermissionService=Xc;exports.IResourceLoaderService=Ri;exports.IResourceManagerService=ws;exports.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=vg;exports.IUndoRedoService=en;exports.IUniverInstanceService=an;exports.ImageCacheMap=GR;exports.ImageSourceType=So;exports.ImageUploadStatusType=sh;exports.Inject=it;exports.Injector=Rt;exports.InterceptorEffectEnum=An;exports.InterceptorManager=aC;exports.InterpolationPointType=Zi;exports.JSON1=tE;exports.JSONX=Vt;exports.LRUHelper=er;exports.LRUMap=fr;exports.LifecycleStages=We;exports.ListGlyphType=Ne;exports.LocaleService=ur;exports.LocaleType=zn;exports.LogLevel=jl;exports.MOVE_BUFFER_VALUE=Zn;exports.Many=bl;exports.MemoryCursor=Yn;exports.MentionType=dr;exports.NamedStyleType=Au;exports.NilCommand=Wl;exports.NumberUnitType=Bu;exports.ObjectMatrix=Lt;exports.ObjectRelativeFromH=ku;exports.ObjectRelativeFromV=$u;exports.Optional=wl;exports.OtherShapes=Jl;exports.PRESET_LIST_TYPE=Sr;exports.PageElementType=Gu;exports.PageOrientType=zu;exports.PageType=lo;exports.ParagraphElementType=Ou;exports.ParagraphStyleBuilder=kn;exports.ParagraphStyleValue=Gn;exports.PermissionService=Qc;exports.PermissionStatus=_o;exports.Plugin=Ei;exports.PositionedObjectLayoutType=wu;exports.PresetListType=Ut;exports.ProtectionType=eo;exports.QuickListType=uc;exports.QuickListTypeMap=aE;exports.RANGE_DIRECTION=iu;exports.RANGE_TYPE=xe;exports.RBush=Oi;exports.RCDisposable=Ep;exports.RGBA_PAREN=Xp;exports.RGB_PAREN=Kp;exports.ROTATE_BUFFER_VALUE=Kl;exports.RTree=t0;exports.Range=Fn;exports.Rectangle=Yt;exports.RediConsumer=Ml;exports.RediContext=Er;exports.RediError=ot;exports.RediProvider=Wi;exports.RedoCommand=pn;exports.RedoCommandId=Hc;exports.RefAlias=B_;exports.Registry=bs;exports.RegistryAsMap=po;exports.RelativeDate=to;exports.RelativeSlideLink=Ku;exports.ResourceManagerService=eh;exports.RgbColor=os;exports.RichTextBuilder=sn;exports.RichTextValue=Ht;exports.RxDisposable=_p;exports.SHEET_EDITOR_UNITS=A_;exports.SectionType=vu;exports.Self=Ol;exports.SheetTypes=no;exports.SheetViewModel=Pc;exports.SkipSelf=Sl;exports.SliceBodyType=ho;exports.SlideDataModel=mo;exports.SpacingRule=Tu;exports.SpecialShapes=ql;exports.Styles=Oc;exports.THEME_COLORS=nu;exports.TabStopAlignment=Mu;exports.TableAlignmentType=xu;exports.TableLayoutType=Lu;exports.TableRowHeightRule=Pu;exports.TableSizeType=Du;exports.TableTextWrapType=Uu;exports.TextDecoration=ro;exports.TextDecorationBuilder=jt;exports.TextDirection=Pn;exports.TextDirectionType=Su;exports.TextStyleBuilder=Wt;exports.TextStyleValue=Vn;exports.TextX=ze;exports.TextXActionType=ce;exports.ThemeColor=as;exports.ThemeColorType=ct;exports.ThemeColors=vs;exports.ThemeService=Eo;exports.Tools=re;exports.UndoCommand=gn;exports.UndoCommandId=Wc;exports.UnitModel=Ss;exports.Univer=th;exports.UniverInstanceType=$e;exports.UpdateDocsAttributeType=Pe;exports.UserManagerService=$n;exports.VerticalAlign=tn;exports.VerticalAlignmentType=Fu;exports.WithDependency=sp;exports.WithNew=Al;exports.Worksheet=gr;exports.WrapStrategy=_n;exports.WrapTextType=bu;exports.addLinkToDocumentModel=bc;exports.afterInitApply=Ap;exports.afterTime=wp;exports.awaitTime=YR;exports.binSearchFirstGreaterThanTarget=Gl;exports.binarySearchArray=Tp;exports.bufferDebounceTime=bp;exports.cellToRange=Sm;exports.characterSpacingControlType=Wu;exports.checkForSubstrings=Om;exports.checkIfMove=Dp;exports.checkParagraphHasBullet=a_;exports.checkParagraphHasIndent=l_;exports.checkParagraphHasIndentByStyle=cu;exports.codeToBlob=Mp;exports.composeBody=pi;exports.composeInterceptors=Sc;exports.composeStyles=si;exports.concatMatrixArray=R_;exports.connectDependencies=tp;exports.connectInjector=ep;exports.convertBodyToHtml=Gp;exports.convertCellToRange=au;exports.covertTextRunToHtml=ii;exports.createAsyncInterceptorKey=lC;exports.createDefaultUser=cs;exports.createDocumentModelWithStyle=tr;exports.createIdentifier=_t;exports.createInterceptorKey=oC;exports.createInternalEditorID=Sg;exports.createRowColIter=ci;exports.dayjs=Kt;exports.debounce=ag;exports.dedupe=mg;exports.deepCompare=io;exports.delayAnimationFrame=VR;exports.deleteContent=du;exports.extractPureTextFromCell=Fc;exports.forwardRef=Fg;exports.fromCallback=zl;exports.fromEventSubject=HR;exports.fromObservable=mp;exports.generateRandomId=zt;exports.get=kf;exports.getArrayLength=rn;exports.getBodySlice=Tt;exports.getBodySliceHtml=Wr;exports.getBorderStyleType=Im;exports.getCellInfoInMergeData=gm;exports.getCellValueType=cm;exports.getColorStyle=Mt;exports.getCustomBlockSlice=fc;exports.getCustomDecorationSlice=pc;exports.getCustomRangeSlice=gc;exports.getDocsUpdateBody=vm;exports.getIntersectRange=L_;exports.getOriginCellValue=TC;exports.getParagraphsSlice=dc;exports.getReverseDirection=xp;exports.getSectionBreakSlice=mE;exports.getTableSlice=hc;exports.getTextRunSlice=us;exports.getWorksheetUID=LC;exports.groupBy=Cg;exports.handleStyleToString=Rm;exports.hashAlgorithm=h_;exports.horizontalLineSegmentsSubtraction=ys;exports.insertMatrixArray=ai;exports.insertTextToContent=hu;exports.isAsyncDependencyItem=Js;exports.isAsyncHook=jr;exports.isBlackColor=am;exports.isBooleanString=Ig;exports.isCellCoverable=_m;exports.isCellV=dm;exports.isClassDependencyItem=Ks;exports.isCtor=ki;exports.isDisposable=ei;exports.isEmptyCell=lu;exports.isFactoryDependencyItem=Xs;exports.isFormulaId=Cm;exports.isFormulaString=Em;exports.isICellData=um;exports.isInternalEditorID=El;exports.isNodeEnv=Vp;exports.isNotNullOrUndefined=wc;exports.isNullCell=hm;exports.isNumeric=nh;exports.isRangesEqual=gC;exports.isRealNum=c_;exports.isSafeNumeric=PR;exports.isSameStyleTextRun=uu;exports.isUnitRangesEqual=pC;exports.isValidRange=ym;exports.isValueDependencyItem=Qs;exports.isWhiteColor=lm;exports.makeArray=Rg;exports.makeCellRangeToRangeData=mm;exports.makeCellToSelection=pm;exports.makeCustomRangeStream=JE;exports.merge=xi;exports.mergeOverrideWithDependencies=Jc;exports.mergeSets=kR;exports.mergeWith=hg;exports.mergeWorksheetSnapshotWithDefault=Uc;exports.mixinClass=hC;exports.moveMatrixArray=ui;exports.moveRangeByOffset=T_;exports.nameCharacterCheck=zR;exports.normalizeBody=_E;exports.normalizeTextRuns=yr;exports.numberToABC=W_;exports.numberToListABC=z_;exports.numfmt=fu;exports.queryObjectMatrix=$_;exports.registerDependencies=fp;exports.remove=mr;exports.repeatStringNumTimes=_u;exports.replaceInDocumentBody=$R;exports.requestImmediateMacroTask=FR;exports.rotate=Eg;exports.searchArray=Np;exports.searchInOrderedArray=Vl;exports.selectionToArray=fm;exports.sequence=kl;exports.sequenceAsync=Fl;exports.sequenceExecute=zi;exports.sequenceExecuteAsync=Op;exports.set=fg;exports.setDependencies=Pg;exports.shallowEqual=Ul;exports.skipParseTagNames=KR;exports.sliceMatrixArray=I_;exports.sortRules=Y_;exports.sortRulesByDesc=V_;exports.sortRulesFactory=Ir;exports.spliceArray=li;exports.splitIntoGrid=oo;exports.takeAfter=Yl;exports.textDiff=Li;exports.throttle=iC;exports.toDisposable=Qe;exports.touchDependencies=Ll;exports.updateAttributeByDelete=mc;exports.updateAttributeByInsert=_c;exports.useDependency=ap;exports.useDependencyContext=hp;exports.useDependencyContextValue=dp;exports.useDependencyValue=xl;exports.useInjector=Dl;exports.useObservable=up;exports.useUpdateBinder=cp;
|
package/lib/es/index.js
CHANGED
|
@@ -13980,7 +13980,7 @@ class ul {
|
|
|
13980
13980
|
return this._data;
|
|
13981
13981
|
}
|
|
13982
13982
|
}
|
|
13983
|
-
const k_ = "0.6.0-
|
|
13983
|
+
const k_ = "0.6.0-nightly.202501251605";
|
|
13984
13984
|
function F_(t = "", e = ur.ZH_CN, n = "") {
|
|
13985
13985
|
return {
|
|
13986
13986
|
id: t,
|