@univerjs/core 0.10.0 → 0.10.1

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 CHANGED
@@ -5,4 +5,4 @@
5
5
  `,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))(at||{});function RC(e){return`${e}`}const IC=[at.TABLE_START,at.TABLE_ROW_START,at.TABLE_CELL_START,at.TABLE_CELL_END,at.TABLE_ROW_END,at.TABLE_END],Zs=e=>{const t=e.endsWith(`\r
6
6
  `)?e.slice(0,-2):e;return IC.reduce((n,r)=>n.replaceAll(r,""),t)},SC=e=>e?Zs(e).replaceAll("\r","")==="":!0,OC=e=>{const t=e.replace(/\n/g,"\r"),n=[],r=[];let s=0,i="";const o=(l,c=!0)=>{const u=t.slice(s,l);if(q.isLegalUrl(u)){const h=tt(),d=`${u}`,f={startIndex:s,endIndex:s+d.length-1,rangeId:h,rangeType:rn.HYPERLINK,properties:{url:e}};r.push(f),i+=d,s=l+1,c&&(i+="\r",n.push({startIndex:l}))}else i+=t.slice(s,l+1),s=l+1,c&&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}},ra={id:"default_doc",documentStyle:{}};class vC extends Ws{constructor(n){var r;super();p(this,"type",ve.UNIVER_DOC);p(this,"_name$",new ce.BehaviorSubject(""));p(this,"name$",this._name$.asObservable());p(this,"snapshot");this.snapshot={...ra,...n},this._name$.next((r=this.snapshot.title)!=null?r:"No Title")}getUnitId(){throw new Error("Method not implemented.")}getRev(){var n;return(n=this.snapshot.rev)!=null?n:1}incrementRev(){this.snapshot.rev=this.getRev()+1}setRev(n){this.snapshot.rev=n}setName(n){this.snapshot.title=n,this._name$.next(n)}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get zoomRatio(){var n;return((n=this.snapshot.settings)==null?void 0:n.zoomRatio)||1}resetDrawing(n,r){this.snapshot.drawings=n,this.snapshot.drawingsOrder=r}getBody(){return this.snapshot.body}getSnapshot(){return this.snapshot}getBulletPresetList(){var s;const n=(s=this.snapshot.lists)!=null?s:{};return{...Yr,...n}}updateDocumentId(n){this.snapshot.id=n}updateDocumentRenderConfig(n){const{documentStyle:r}=this.snapshot;r.renderConfig==null?r.renderConfig=n:r.renderConfig={...r.renderConfig,...n}}getDocumentStyle(){return this.snapshot.documentStyle}updateDocumentStyle(n){this.snapshot.documentStyle==null?this.snapshot.documentStyle=n:this.snapshot.documentStyle={...this.snapshot.documentStyle,...n}}updateDocumentDataMargin(n){const{t:r,l:s,b:i,r:o}=n,{documentStyle:a}=this.snapshot;r!=null&&(a.marginTop=r),s!=null&&(a.marginLeft=s),i!=null&&(a.marginBottom=i),o!=null&&(a.marginRight=o)}updateDocumentDataPageSize(n,r){const{documentStyle:s}=this.snapshot;if(!s.pageSize){s.pageSize={width:n!=null?n:Number.POSITIVE_INFINITY,height:r!=null?r:Number.POSITIVE_INFINITY};return}n!==void 0&&(s.pageSize.width=n),r!==void 0&&(s.pageSize.height=r)}updateDrawing(n,r){const{drawings:s}=this,{width:i,height:o,left:a,top:l}=r,c=s==null?void 0:s[n];if(!c)return;const u=c.docTransform;u.size.width=i,u.size.height=o,u.positionH.posOffset=a,u.positionV.posOffset=l}setZoomRatio(n=1){this.snapshot.settings?this.snapshot.settings.zoomRatio=n:this.snapshot.settings={zoomRatio:n}}setDisabled(n){this.snapshot.disabled=n}getDisabled(){return this.snapshot.disabled}getTitle(){return this.snapshot.title}}class Nt extends vC{constructor(n){var s,i;super(q.isEmptyObject(n)?b_():n);p(this,"_unitId");p(this,"headerModelMap",new Map);p(this,"footerModelMap",new Map);p(this,"change$",new ce.BehaviorSubject(0));const r=6;this._unitId=(s=this.snapshot.id)!=null?s:tt(r),this._initializeHeaderFooterModel(),this._name$.next((i=this.snapshot.title)!=null?i:"")}dispose(){super.dispose(),this.headerModelMap.forEach(n=>{n.dispose()}),this.footerModelMap.forEach(n=>{n.dispose()}),this._name$.complete()}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getCustomRanges(){var n;return(n=this.snapshot.body)==null?void 0:n.customRanges}getCustomDecorations(){var n;return(n=this.snapshot.body)==null?void 0:n.customDecorations}getSettings(){return this.snapshot.settings}reset(n){if(n.id&&n.id!==this._unitId)throw new Error("Cannot reset a document model with a different unit id!");this.snapshot={...ra,...n},this._initializeHeaderFooterModel(),this.change$.next(this.change$.value+1)}getSelfOrHeaderFooterModel(n){if(n!=null){if(this.headerModelMap.has(n))return this.headerModelMap.get(n);if(this.footerModelMap.has(n))return this.footerModelMap.get(n)}return this}getUnitId(){return this._unitId}apply(n){if(!Gt.isNoop(n))return this.snapshot=Gt.apply(this.snapshot,n),n!=null&&n.some(r=>Array.isArray(r)&&((r==null?void 0:r[0])==="headers"||(r==null?void 0:r[0])==="footers"))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.change$.next(this.change$.value+1),this.snapshot}sliceBody(n,r,s=na.copy){const i=this.getBody();if(i!=null)return yt(i,n,r,!1,s)}_initializeHeaderFooterModel(){const{headers:n,footers:r}=this.getSnapshot();if(n)for(const s in n){const i=n[s];this.headerModelMap.set(s,new Nt(i)),this.headerModelMap.get(s).updateDocumentId(this.getUnitId())}if(r)for(const s in r){const i=r[s];this.footerModelMap.set(s,new Nt(i)),this.footerModelMap.get(s).updateDocumentId(this.getUnitId())}}updateDocumentId(n){super.updateDocumentId(n),this._unitId=n}getPlainText(){var n,r;return Zs((r=(n=this.getBody())==null?void 0:n.dataStream)!=null?r:"")}}function wC(e){const{ranges:t,id:n,type:r}=e,s=new Me;let i=0;for(let o=0;o<t.length;o++){const a=t[o],{startOffset:l,endOffset:c}=a;l>0&&s.push({t:Z.RETAIN,len:l-i}),s.push({t:Z.RETAIN,body:{dataStream:"",customDecorations:[{id:n,type:r,startIndex:0,endIndex:c-l-1}]},len:c-l}),i=c}return s}function bC(e){var u,h,d;const{id:t,segmentId:n,documentDataModel:r}=e,s=r==null?void 0:r.getBody();if(!r||!s)return!1;const i=(d=(h=(u=r.getSelfOrHeaderFooterModel(n))==null?void 0:u.getBody())==null?void 0:h.customDecorations)==null?void 0:d.find(f=>f.id===t);if(!i)return!1;const o=new Me,{startIndex:a,endIndex:l}=i,c=l-a+1;return o.push({t:Z.RETAIN,len:a}),o.push({t:Z.RETAIN,len:c,body:{dataStream:"",customDecorations:[{startIndex:0,endIndex:c-1,id:t,type:pn.DELETED}]}}),o}function Th(e,t,n,r){return e<=n&&t>=n||e>=n&&e<=r}function AC(e,t){const n=[];for(let r=0,s=t.length;r<s;r++){const i=t[r];e.collapsed?i.startIndex<e.startOffset&&e.startOffset<=i.endIndex&&n.push(i):Th(e.startOffset,e.endOffset-1,i.startIndex,i.endIndex)&&n.push(i)}return n}function TC(e){return{...q.deepClone(e),rangeId:tt()}}function yC(e,t){const n=[];let r=e[0];for(const s of t)s<e[0]||s>e[1]||(r<s&&n.push([r,s-1]),r=s+1);return r<=e[1]&&n.push([r,e[1]]),n}function yh(e,t,n,r){const s=[];for(let i=0,o=n.length;i<o;i++){const a=n[i];if((r===void 0||a.rangeType===r)&&Math.max(a.startIndex,e)<=Math.min(a.endIndex,t)&&s.push({...a}),a.startIndex>t)break}return s}function NC(e,t){var i,o,a,l,c;const n=yh(e.startOffset,e.collapsed?e.startOffset:e.endOffset-1,(i=t.customRanges)!=null?i:[]),r=Math.min(e.startOffset,(a=(o=n[0])==null?void 0:o.startIndex)!=null?a:1/0),s=Math.max(e.endOffset,((c=(l=n[n.length-1])==null?void 0:l.endIndex)!=null?c:-1/0)+1);return{startOffset:r,endOffset:s,collapsed:r===s}}var Si,pl;function MC(){if(pl)return Si;pl=1;var e=-1,t=1,n=0;function r(m,x,O,N,A){if(m===x)return m?[[n,m]]:[];if(O!=null){var v=B(m,x,O);if(v)return v}var y=a(m,x),M=m.substring(0,y);m=m.substring(y),x=x.substring(y),y=c(m,x);var L=m.substring(m.length-y);m=m.substring(0,m.length-y),x=x.substring(0,x.length-y);var P=s(m,x);return M&&P.unshift([n,M]),L&&P.push([n,L]),F(P,A),N&&h(P),P}function s(m,x){var O;if(!m)return[[t,x]];if(!x)return[[e,m]];var N=m.length>x.length?m:x,A=m.length>x.length?x:m,v=N.indexOf(A);if(v!==-1)return O=[[t,N.substring(0,v)],[n,A],[t,N.substring(v+A.length)]],m.length>x.length&&(O[0][0]=O[2][0]=e),O;if(A.length===1)return[[e,m],[t,x]];var y=u(m,x);if(y){var M=y[0],L=y[1],P=y[2],J=y[3],V=y[4],oe=r(M,P),le=r(L,J);return oe.concat([[n,V]],le)}return i(m,x)}function i(m,x){for(var O=m.length,N=x.length,A=Math.ceil((O+N)/2),v=A,y=2*A,M=new Array(y),L=new Array(y),P=0;P<y;P++)M[P]=-1,L[P]=-1;M[v+1]=0,L[v+1]=0;for(var J=O-N,V=J%2!==0,oe=0,le=0,I=0,D=0,Y=0;Y<A;Y++){for(var G=-Y+oe;G<=Y-le;G+=2){var H=v+G,j;G===-Y||G!==Y&&M[H-1]<M[H+1]?j=M[H+1]:j=M[H-1]+1;for(var Q=j-G;j<O&&Q<N&&m.charAt(j)===x.charAt(Q);)j++,Q++;if(M[H]=j,j>O)le+=2;else if(Q>N)oe+=2;else if(V){var ee=v+J-G;if(ee>=0&&ee<y&&L[ee]!==-1){var U=O-L[ee];if(j>=U)return o(m,x,j,Q)}}}for(var z=-Y+I;z<=Y-D;z+=2){var ee=v+z,U;z===-Y||z!==Y&&L[ee-1]<L[ee+1]?U=L[ee+1]:U=L[ee-1]+1;for(var X=U-z;U<O&&X<N&&m.charAt(O-U-1)===x.charAt(N-X-1);)U++,X++;if(L[ee]=U,U>O)D+=2;else if(X>N)I+=2;else if(!V){var H=v+J-z;if(H>=0&&H<y&&M[H]!==-1){var j=M[H],Q=v+j-H;if(U=O-U,j>=U)return o(m,x,j,Q)}}}}return[[e,m],[t,x]]}function o(m,x,O,N){var A=m.substring(0,O),v=x.substring(0,N),y=m.substring(O),M=x.substring(N),L=r(A,v),P=r(y,M);return L.concat(P)}function a(m,x){if(!m||!x||m.charAt(0)!==x.charAt(0))return 0;for(var O=0,N=Math.min(m.length,x.length),A=N,v=0;O<A;)m.substring(v,A)==x.substring(v,A)?(O=A,v=O):N=A,A=Math.floor((N-O)/2+O);return k(m.charCodeAt(A-1))&&A--,A}function l(m,x){var O=m.length,N=x.length;if(O==0||N==0)return 0;O>N?m=m.substring(O-N):O<N&&(x=x.substring(0,O));var A=Math.min(O,N);if(m==x)return A;for(var v=0,y=1;;){var M=m.substring(A-y),L=x.indexOf(M);if(L==-1)return v;y+=L,(L==0||m.substring(A-y)==x.substring(0,y))&&(v=y,y++)}}function c(m,x){if(!m||!x||m.slice(-1)!==x.slice(-1))return 0;for(var O=0,N=Math.min(m.length,x.length),A=N,v=0;O<A;)m.substring(m.length-A,m.length-v)==x.substring(x.length-A,x.length-v)?(O=A,v=O):N=A,A=Math.floor((N-O)/2+O);return W(m.charCodeAt(m.length-A))&&A--,A}function u(m,x){var O=m.length>x.length?m:x,N=m.length>x.length?x:m;if(O.length<4||N.length*2<O.length)return null;function A(le,I,D){for(var Y=le.substring(D,D+Math.floor(le.length/4)),G=-1,H="",j,Q,ee,U;(G=I.indexOf(Y,G+1))!==-1;){var z=a(le.substring(D),I.substring(G)),X=c(le.substring(0,D),I.substring(0,G));H.length<X+z&&(H=I.substring(G-X,G)+I.substring(G,G+z),j=le.substring(0,D-X),Q=le.substring(D+z),ee=I.substring(0,G-X),U=I.substring(G+z))}return H.length*2>=le.length?[j,Q,ee,U,H]:null}var v=A(O,N,Math.ceil(O.length/4)),y=A(O,N,Math.ceil(O.length/2)),M;if(!v&&!y)return null;y?v?M=v[4].length>y[4].length?v:y:M=y:M=v;var L,P,J,V;m.length>x.length?(L=M[0],P=M[1],J=M[2],V=M[3]):(J=M[0],V=M[1],L=M[2],P=M[3]);var oe=M[4];return[L,P,J,V,oe]}function h(m){for(var x=!1,O=[],N=0,A=null,v=0,y=0,M=0,L=0,P=0;v<m.length;)m[v][0]==n?(O[N++]=v,y=L,M=P,L=0,P=0,A=m[v][1]):(m[v][0]==t?L+=m[v][1].length:P+=m[v][1].length,A&&A.length<=Math.max(y,M)&&A.length<=Math.max(L,P)&&(m.splice(O[N-1],0,[e,A]),m[O[N-1]+1][0]=t,N--,N--,v=N>0?O[N-1]:-1,y=0,M=0,L=0,P=0,A=null,x=!0)),v++;for(x&&F(m),b(m),v=1;v<m.length;){if(m[v-1][0]==e&&m[v][0]==t){var J=m[v-1][1],V=m[v][1],oe=l(J,V),le=l(V,J);oe>=le?(oe>=J.length/2||oe>=V.length/2)&&(m.splice(v,0,[n,V.substring(0,oe)]),m[v-1][1]=J.substring(0,J.length-oe),m[v+1][1]=V.substring(oe),v++):(le>=J.length/2||le>=V.length/2)&&(m.splice(v,0,[n,J.substring(0,le)]),m[v-1][0]=t,m[v-1][1]=V.substring(0,V.length-le),m[v+1][0]=e,m[v+1][1]=J.substring(le),v++),v++}v++}}var d=/[^a-zA-Z0-9]/,f=/\s/,g=/[\r\n]/,_=/\n\r?\n$/,R=/^\r?\n\r?\n/;function b(m){function x(le,I){if(!le||!I)return 6;var D=le.charAt(le.length-1),Y=I.charAt(0),G=D.match(d),H=Y.match(d),j=G&&D.match(f),Q=H&&Y.match(f),ee=j&&D.match(g),U=Q&&Y.match(g),z=ee&&le.match(_),X=U&&I.match(R);return z||X?5:ee||U?4:G&&!j&&Q?3:j||Q?2:G||H?1:0}for(var O=1;O<m.length-1;){if(m[O-1][0]==n&&m[O+1][0]==n){var N=m[O-1][1],A=m[O][1],v=m[O+1][1],y=c(N,A);if(y){var M=A.substring(A.length-y);N=N.substring(0,N.length-y),A=M+A.substring(0,A.length-y),v=M+v}for(var L=N,P=A,J=v,V=x(N,A)+x(A,v);A.charAt(0)===v.charAt(0);){N+=A.charAt(0),A=A.substring(1)+v.charAt(0),v=v.substring(1);var oe=x(N,A)+x(A,v);oe>=V&&(V=oe,L=N,P=A,J=v)}m[O-1][1]!=L&&(L?m[O-1][1]=L:(m.splice(O-1,1),O--),m[O][1]=P,J?m[O+1][1]=J:(m.splice(O+1,1),O--))}O++}}function F(m,x){m.push([n,""]);for(var O=0,N=0,A=0,v="",y="",M;O<m.length;){if(O<m.length-1&&!m[O][1]){m.splice(O,1);continue}switch(m[O][0]){case t:A++,y+=m[O][1],O++;break;case e:N++,v+=m[O][1],O++;break;case n:var L=O-A-N-1;if(x){if(L>=0&&C(m[L][1])){var P=m[L][1].slice(-1);if(m[L][1]=m[L][1].slice(0,-1),v=P+v,y=P+y,!m[L][1]){m.splice(L,1),O--;var J=L-1;m[J]&&m[J][0]===t&&(A++,y=m[J][1]+y,J--),m[J]&&m[J][0]===e&&(N++,v=m[J][1]+v,J--),L=J}}if(S(m[O][1])){var P=m[O][1].charAt(0);m[O][1]=m[O][1].slice(1),v+=P,y+=P}}if(O<m.length-1&&!m[O][1]){m.splice(O,1);break}if(v.length>0||y.length>0){v.length>0&&y.length>0&&(M=a(y,v),M!==0&&(L>=0?m[L][1]+=y.substring(0,M):(m.splice(0,0,[n,y.substring(0,M)]),O++),y=y.substring(M),v=v.substring(M)),M=c(y,v),M!==0&&(m[O][1]=y.substring(y.length-M)+m[O][1],y=y.substring(0,y.length-M),v=v.substring(0,v.length-M)));var V=A+N;v.length===0&&y.length===0?(m.splice(O-V,V),O=O-V):v.length===0?(m.splice(O-V,V,[t,y]),O=O-V+1):y.length===0?(m.splice(O-V,V,[e,v]),O=O-V+1):(m.splice(O-V,V,[e,v],[t,y]),O=O-V+2)}O!==0&&m[O-1][0]===n?(m[O-1][1]+=m[O][1],m.splice(O,1)):O++,A=0,N=0,v="",y="";break}}m[m.length-1][1]===""&&m.pop();var oe=!1;for(O=1;O<m.length-1;)m[O-1][0]===n&&m[O+1][0]===n&&(m[O][1].substring(m[O][1].length-m[O-1][1].length)===m[O-1][1]?(m[O][1]=m[O-1][1]+m[O][1].substring(0,m[O][1].length-m[O-1][1].length),m[O+1][1]=m[O-1][1]+m[O+1][1],m.splice(O-1,1),oe=!0):m[O][1].substring(0,m[O+1][1].length)==m[O+1][1]&&(m[O-1][1]+=m[O+1][1],m[O][1]=m[O][1].substring(m[O+1][1].length)+m[O+1][1],m.splice(O+1,1),oe=!0)),O++;oe&&F(m,x)}function k(m){return m>=55296&&m<=56319}function W(m){return m>=56320&&m<=57343}function S(m){return W(m.charCodeAt(0))}function C(m){return k(m.charCodeAt(m.length-1))}function w(m){for(var x=[],O=0;O<m.length;O++)m[O][1].length>0&&x.push(m[O]);return x}function T(m,x,O,N){return C(m)||S(N)?null:w([[n,m],[e,x],[t,O],[n,N]])}function B(m,x,O){var N=typeof O=="number"?{index:O,length:0}:O.oldRange,A=typeof O=="number"?null:O.newRange,v=m.length,y=x.length;if(N.length===0&&(A===null||A.length===0)){var M=N.index,L=m.slice(0,M),P=m.slice(M),J=A?A.index:null;e:{var V=M+y-v;if(J!==null&&J!==V||V<0||V>y)break e;var oe=x.slice(0,V),le=x.slice(V);if(le!==P)break e;var I=Math.min(M,V),D=L.slice(0,I),Y=oe.slice(0,I);if(D!==Y)break e;var G=L.slice(I),H=oe.slice(I);return T(D,G,H,P)}e:{if(J!==null&&J!==M)break e;var j=M,oe=x.slice(0,j),le=x.slice(j);if(oe!==L)break e;var Q=Math.min(v-j,y-j),ee=P.slice(P.length-Q),U=le.slice(le.length-Q);if(ee!==U)break e;var G=P.slice(0,P.length-Q),H=le.slice(0,le.length-Q);return T(L,G,H,ee)}}if(N.length>0&&A&&A.length===0)e:{var D=m.slice(0,N.index),ee=m.slice(N.index+N.length),I=D.length,Q=ee.length;if(y<I+Q)break e;var Y=x.slice(0,I),U=x.slice(y-Q);if(D!==Y||ee!==U)break e;var G=m.slice(I,v-Q),H=x.slice(I,y-Q);return T(D,G,H,ee)}return null}function $(m,x,O,N){return r(m,x,O,N,!0)}return $.INSERT=t,$.DELETE=e,$.EQUAL=n,Si=$,Si}var LC=MC();const sa=It(LC);function DC(e){var h,d,f;const{rangeId:t,segmentId:n,documentDataModel:r,insert:s}=e,i=(d=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.customRanges)==null?void 0:d.find(g=>g.rangeId===t);if(!i)return!1;const{startIndex:o,endIndex:a}=i,l=new Me,c=a-o+1;l.push({t:Z.RETAIN,len:o}),l.push({t:Z.RETAIN,len:c,body:{dataStream:"",customRanges:[]}}),s&&l.push({t:Z.INSERT,body:s,len:s.dataStream.length});const u=a+1+((f=s==null?void 0:s.dataStream.length)!=null?f:0);return l.selections=[{startOffset:u,endOffset:u,collapsed:!0}],l}function xC(e){const{ranges:t,rangeId:n,rangeType:r,wholeEntity:s,properties:i,body:o}=e;let a=0;const l=new Me;let c=!1;return t.forEach(u=>{var k,W,S;const h=NC(u,o);if(!h||!o)return!1;const{startOffset:d,endOffset:f}=h,g=(k=o.customRanges)!=null?k:[],_=(C,w,T)=>{var O,N,A,v;const B=yh(C,w,g,r),$=Math.min((N=(O=B[0])==null?void 0:O.startIndex)!=null?N:1/0,C),m=Math.max((v=(A=B[B.length-1])==null?void 0:A.endIndex)!=null?v:-1/0,w),x={rangeId:T?`${n}$${T}`:n,rangeType:r,startIndex:0,endIndex:m-$,wholeEntity:s,properties:{...i}};l.push({t:Z.RETAIN,len:$-a}),l.push({t:Z.RETAIN,len:m-$+1,body:{dataStream:"",customRanges:[x]},coverType:Ee.COVER}),a=m+1},R=((W=o.paragraphs)!=null?W:[]).filter(C=>C.startIndex<f&&C.startIndex>d),b=((S=o.customBlocks)!=null?S:[]).filter(C=>C.startIndex<f&&C.startIndex>d);yC([d,f-1],[...R.map(C=>C.startIndex),...b.map(C=>C.startIndex)]).forEach(([C,w],T)=>_(C,w,T)),c=!0,l.selections=[{startOffset:h.endOffset,endOffset:h.endOffset,collapsed:!0}]}),c?l:!1}function Nh(e,t,n=0,r=null,s=!0){e.sort((c,u)=>c.startOffset-u.startOffset);const i=[],{paragraphs:o=[]}=t,a=o==null?void 0:o.find(c=>c.startIndex>=e[0].startOffset&&c.startIndex<e[0].endOffset);let l=n;if(e.forEach(c=>{const{startOffset:u,endOffset:h}=c;u>l&&(i.push({t:Z.RETAIN,len:u-l}),l=u),l<h&&(i.push({t:Z.DELETE,len:h-l}),l=h)}),r&&i.push({t:Z.INSERT,body:r,len:r.dataStream.length}),a&&s){const c=o.find(u=>u.startIndex-n>=e[e.length-1].endOffset-1);c&&(c.startIndex>l&&(i.push({t:Z.RETAIN,len:c.startIndex-l}),l=c.startIndex),i.push({t:Z.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...c,startIndex:0,bullet:a==null?void 0:a.bullet}]},coverType:Ee.REPLACE}))}return i}function UC(e,t,n=0){const r=[];let s=n;return e.forEach(i=>{const{startOffset:o,endOffset:a}=i;o>s&&(r.push({t:Z.RETAIN,len:o-s}),s=o),a>s&&(r.push({t:Z.RETAIN,len:a-s,body:{...q.deepClone(t),dataStream:""}}),s=a)}),r}const PC=e=>{var h;const{selection:t,body:n,doc:r}=e,s=t.segmentId,i=(h=r.getSelfOrHeaderFooterModel(s))==null?void 0:h.getBody();if(!i)return!1;const o=t.collapsed?null:yt(i,t.startOffset,t.endOffset),a=sa(o?o.dataStream:"",n.dataStream);let l=0;const c=a.map(([d,f])=>{switch(d){case 0:{const g={t:Z.RETAIN,body:{...yt(n,l,l+f.length,!1),dataStream:""},len:f.length};return l+=f.length,g}case 1:{const g={t:Z.INSERT,body:yt(n,l,l+f.length),len:f.length};return l+=f.length,g}default:return{t:Z.DELETE,len:f.length}}}),u=new Me;return u.push({t:Z.RETAIN,len:t.startOffset}),u.push(...c),u};function kC(e,t){return!!((e==null?void 0:e.length)===(t==null?void 0:t.length)&&(e!=null&&e.every((n,r)=>JSON.stringify(n)===JSON.stringify(t==null?void 0:t[r]))))}const FC=e=>{var d;const{selection:t,body:n,doc:r,themeService:s}=e,i=t.segmentId,o=(d=r.getSelfOrHeaderFooterModel(i))==null?void 0:d.getBody();if(!o)return!1;const a=t.collapsed?null:yt(o,t.startOffset,t.endOffset),l=sa(a?a.dataStream:"",n.dataStream);let c=0;const u=l.map(([f,g])=>{switch(f){case 0:{const _=xs(n,c,c+g.length,!1),R=xs(a,c,c+g.length,!1),b={t:Z.RETAIN,body:kC(_,R)?void 0:{textRuns:_==null?void 0:_.map(F=>{var k,W,S,C,w,T,B;return{...F,ts:{...F.ts,cl:(S=(W=(k=F.ts)==null?void 0:k.cl)==null?void 0:W.rgb)!=null&&S.includes(".")?{rgb:s.getColorFromTheme((T=(w=(C=F.ts)==null?void 0:C.cl)==null?void 0:w.rgb)!=null?T:"")}:(B=F.ts)==null?void 0:B.cl}}}),dataStream:""},len:g.length};return c+=g.length,b}case 1:{const _={t:Z.INSERT,body:yt(n,c,c+g.length),len:g.length};return c+=g.length,_}default:return{t:Z.DELETE,len:g.length}}});if(u.every(f=>f.t===Z.RETAIN&&!f.body))return!1;const h=new Me;return h.push({t:Z.RETAIN,len:t.startOffset}),h.push(...u),h};function BC(e,t){const n=[],{customBlocks:r=[]}=e;for(const s of t){const{startOffset:i,endOffset:o}=s;if(!(i==null||o==null))for(const a of r){const{startIndex:l}=a;l>=i&&l<o&&n.push(a.blockId)}}return n}function $C(e,t=""){if(!t)return["body"];const{headers:n,footers:r}=e.getSnapshot();if(n==null&&r==null)throw new Error("Document data model must have headers or footers when update by segment id");if((n==null?void 0:n[t])!=null)return["headers",t,"body"];if((r==null?void 0:r[t])!=null)return["footers",t,"body"];throw new Error("Segment id not found in headers or footers")}const HC=e=>{var _,R,b,F;const{selection:t,documentDataModel:n,drawings:r}=e,{collapsed:s,startOffset:i,segmentId:o}=t,a=new Me,l=Gt.getInstance(),c=[],u=n.getSelfOrHeaderFooterModel(o).getBody();if(!u)return!1;const h=(R=(_=n.getSnapshot().drawingsOrder)==null?void 0:_.length)!=null?R:0;let d=0;if(s)i>0&&a.push({t:Z.RETAIN,len:i});else{const k=Nh([t],u,0,null,!1);a.push(...k);const W=BC(u,[t]),S=(b=n.getDrawings())!=null?b:{},C=(F=n.getDrawingsOrder())!=null?F:[],w=W.sort((T,B)=>C.indexOf(T)>C.indexOf(B)?-1:C.indexOf(T)<C.indexOf(B)?1:0);if(w.length>0)for(const T of w){const B=S[T],$=C.indexOf(T);if(B==null||$<0)continue;const m=l.removeOp(["drawings",T],B),x=l.removeOp(["drawingsOrder",$],T);c.push(m),c.push(x),d++}}a.push({t:Z.INSERT,body:{dataStream:"\b".repeat(r.length),customBlocks:r.map((k,W)=>({startIndex:W,blockId:k.drawingId}))},len:r.length});const f=$C(n,o),g=l.editOp(a.serialize(),f);c.push(g);for(const k of r){const{drawingId:W}=k,S=l.insertOp(["drawings",W],k),C=l.insertOp(["drawingsOrder",h-d],W);c.push(S),c.push(C)}return c.reduce((k,W)=>Gt.compose(k,W),null)};function jC(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 WC(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 YC(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function qi(e,t,n,r){const{startOffset:s,endOffset:i}=e,o=r!=null?r:ia(t,n),a=[];let l=-1;for(let c=0;c<o.length;c++){const u=o[c],{startIndex:h}=u;(s>l&&s<=h||i>l&&i<=h||h>=s&&h<=i)&&a.push(u),l=h}return a}function Zi(e,t,n){const r=[],s=ia(t,n);for(const i of e){const o=qi(i,t,n,s);r.push(...o)}return r}const GC=[at.PARAGRAPH,at.TABLE_START,at.TABLE_END,at.TABLE_ROW_START,at.TABLE_CELL_START,at.TABLE_CELL_END];function ia(e,t){const n=[];for(let r=0;r<e.length;r++){const s=e[r],{startIndex:i}=s;let o=i-1;for(;!GC.includes(t[o])&&o>=0;)o--;n.push({...s,paragraphStart:o+1,paragraphEnd:s.startIndex})}return n}const VC=e=>{var h,d,f;const{paragraphs:t,segmentId:n,document:r}=e;let s=e.listType;const i=(d=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.paragraphs)!=null?d:[],o=t.every(g=>{var _;return((_=g.bullet)==null?void 0:_.listType.indexOf(s))===0});let l=tt(6);if(t.length===1){const g=i.indexOf(t[0]),_=i[g-1],R=i[g+1];_&&_.bullet&&_.bullet.listType.indexOf(s)===0?(l=_.bullet.listId,s!==kt.CHECK_LIST&&(s=_.bullet.listType)):R&&R.bullet&&R.bullet.listType.indexOf(s)===0&&(l=R.bullet.listId,s!==kt.CHECK_LIST&&(s=R.bullet.listType))}const c=new vn;c.reset();const u=new Me;for(const g of t){const{startIndex:_,paragraphStyle:R={},bullet:b}=g;u.push({t:Z.RETAIN,len:_-c.cursor}),u.push({t:Z.RETAIN,len:1,body:{dataStream:"",paragraphs:[o?{paragraphStyle:R,startIndex:0}:{startIndex:0,paragraphStyle:{...R},bullet:{nestingLevel:(f=b==null?void 0:b.nestingLevel)!=null?f:0,textStyle:{fs:20},listType:s,listId:l}}]},coverType:Ee.REPLACE}),c.moveCursorTo(_+1)}return u},zC=e=>{var h;const{paragraphIndex:t,segmentId:n,document:r}=e,s=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.paragraphs;if(s==null)return!1;const i=s.find(d=>d.startIndex===t);if(!(i!=null&&i.bullet)||i.bullet.listType.indexOf(kt.CHECK_LIST)===-1)return!1;const o=new vn;o.reset();const a=new Me,{startIndex:l,paragraphStyle:c={}}=i,u=i.bullet.listType===kt.CHECK_LIST?kt.CHECK_LIST_CHECKED:kt.CHECK_LIST;return a.push({t:Z.RETAIN,len:l-o.cursor}),a.push({t:Z.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...i,paragraphStyle:c,startIndex:0,bullet:{...i.bullet,listType:u}}]},coverType:Ee.REPLACE}),o.moveCursorTo(l+1),a},KC=e=>{var u,h;const{paragraphs:t,listType:n,segmentId:r,document:s}=e;if(((u=s.getSelfOrHeaderFooterModel(r).getBody())==null?void 0:u.paragraphs)==null)return!1;const a=tt(6),l=new vn;l.reset();const c=new Me;for(const d of t){const{startIndex:f,paragraphStyle:g={},bullet:_}=d;c.push({t:Z.RETAIN,len:f-l.cursor}),c.push({t:Z.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:g,bullet:{nestingLevel:(h=_==null?void 0:_.nestingLevel)!=null?h:0,textStyle:(_==null?void 0:_.listType)===n?_.textStyle:{fs:20},listType:n,listId:a}}]},coverType:Ee.REPLACE}),l.moveCursorTo(f+1)}return c};function XC(e,t){return t.some(n=>e.startIndex>n.startIndex&&e.startIndex<n.endIndex)}const qC=e=>{var c,u,h;const{paragraphs:t,document:n,type:r}=e,s=new vn;s.reset();const i=new Me,o=(c=n.getSnapshot().lists)!=null?c:{},a=(h=(u=n.getBody())==null?void 0:u.tables)!=null?h:[],l={...Yr,...o};for(const d of t){const{startIndex:f,paragraphStyle:g={},bullet:_}=d,R=XC(d,a);if(i.push({t:Z.RETAIN,len:f-s.cursor}),_){const b=_.listType;let F=l[b].nestingLevel.length-1;R&&(F=Math.min(F,2)),i.push({t:Z.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:{...g},bullet:{..._,nestingLevel:Math.max(Math.min(_.nestingLevel+r,F),0)}}]},coverType:Ee.REPLACE})}else i.push({t:Z.RETAIN,len:1});s.moveCursorTo(f+1)}return i},ZC=e=>{var R,b,F,k;const{textRanges:t,segmentId:n,document:r,style:s,paragraphTextRun:i,cursor:o,deleteLen:a,textX:l}=e,c=r.getSelfOrHeaderFooterModel(n),u=(b=(R=c.getBody())==null?void 0:R.paragraphs)!=null?b:[],h=(k=(F=c.getBody())==null?void 0:F.dataStream)!=null?k:"",d=Zi(t,u,h),f=new vn;o&&f.moveCursorTo(o);const g=l!=null?l:new Me;d.sort((W,S)=>W.startIndex-S.startIndex);const _=Math.max(0,d[0].paragraphStart-1);_>f.cursor&&(g.push({t:Z.RETAIN,len:_-f.cursor}),f.moveCursorTo(_)),a&&g.push({t:Z.DELETE,len:a});for(const W of d){const{startIndex:S,paragraphStyle:C={}}=W,w=S-f.cursor;g.push({t:Z.RETAIN,len:w,...i?{body:{dataStream:"",textRuns:[{ts:i,st:0,ed:w}]},coverType:Ee.REPLACE}:null}),g.push({t:Z.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:{...C,...s}}]},coverType:Ee.REPLACE}),f.moveCursorTo(S+1)}return g};class Qe{}p(Qe,"customRange",{add:xC,delete:DC,copyCustomRange:TC,getCustomRangesInterestsWithSelection:AC,isIntersecting:Th}),p(Qe,"customDecoration",{add:wC,delete:bC}),p(Qe,"selection",{replace:PC,makeSelection:jC,normalizeSelection:WC,delete:Nh,replaceTextRuns:FC,retain:UC}),p(Qe,"range",{isIntersects:YC,getParagraphsInRange:qi,getParagraphsInRanges:Zi}),p(Qe,"transform",{getPlainText:Zs,fromPlainText:OC,isEmptyDocument:SC}),p(Qe,"paragraph",{bullet:{set:KC,switch:VC,toggleChecklist:zC,changeNestLevel:qC},style:{set:ZC},util:{transform:ia,getParagraphsInRange:qi,getParagraphsInRanges:Zi}}),p(Qe,"drawing",{add:HC});function JC(e,t,n,r){var c;if(t==="")return e;const s={id:"mock-id",body:e,documentStyle:{}},i=new Nt(s),o=t.length;let a;for(;(a=(r?i.getBody().dataStream:i.getBody().dataStream.toLowerCase()).indexOf(t))>=0;){const u=new Me,h=Gt.getInstance();if(a>0&&u.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}]),(c=d==null?void 0:d.customRanges)!=null&&c.length){const g=d.customRanges[0];f.customRanges=[{...g,startIndex:0,endIndex:n.length-1}]}u.insert(n.length,f)}u.delete(o),i.apply(h.editOp(u.serialize()))}const l=i.getBody();return i.dispose(),l}function QC(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 Mh(e){var t;return e.body=QC((t=e.body)!=null?t:{dataStream:""}),e.drawingsOrder||(e.drawingsOrder=[]),e.drawings||(e.drawings={}),e.documentStyle||(e.documentStyle={}),e}class Gr{constructor(t={}){p(this,"_style");this._style=t}static create(t={}){return new Gr(t)}get fontFamily(){return this._style.ff}get fontSize(){return this._style.fs}get italic(){return this._style.it===ie.TRUE}get bold(){return this._style.bl===ie.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 nn.create(q.deepClone(this._style))}getValue(){return{...this._style}}}class nn extends Gr{static create(t={}){return new nn(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 nn.create(q.deepClone(this._style))}build(){return this.getValue()}}class Jt{constructor(t={s:1}){p(this,"_decoration");this._decoration=t}static create(t={s:1}){return new Jt(t)}get show(){return this._decoration.s===ie.TRUE}get followFontColor(){return this._decoration.c===ie.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(q.deepClone(this._decoration))}build(){return{...this._decoration}}}class Vr{constructor(t={}){p(this,"_style");this._style=t}static create(t={}){return new Vr(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===ie.TRUE}get keepNext(){return this._style.keepNext===ie.TRUE}get wordWrap(){return this._style.wordWrap===ie.TRUE}get widowControl(){return this._style.widowControl===ie.TRUE}get shading(){return this._style.shading}get suppressHyphenation(){return this._style.suppressHyphenation===ie.TRUE}copy(){return Lr.create(q.deepClone(this._style))}getValue(){return this._style}}class Lr extends Vr{static create(t={}){return new Lr(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 Lr.create(q.deepClone(this._style))}build(){return this.getValue()}}class Qt{constructor(t){p(this,"_data");if(!t.body)throw new Error("Invalid document data, body is required");this._data=Mh(t)}static create(t){return new Qt(t)}static createByBody(t){return new Qt({body:t,id:"d",documentStyle:{}})}copy(){return En.create(q.deepClone(this._data))}slice(t,n){const{body:r,...s}=this._data;return En.create({...q.deepClone(s),body:yt(r,t,n)})}toPlainText(){var t,n;return Qe.transform.getPlainText((n=(t=this._data.body)==null?void 0:t.dataStream)!=null?n:"").replaceAll("\r",`
7
7
  `)}getParagraphStyle(){var t,n;return Vr.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?Gr.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===rn.HYPERLINK))!=null?r:[]}getData(){return this._data}}class En extends Qt{constructor(n){super(n);p(this,"_doc");this._doc=new Nt(n)}static newEmptyData(){return Mh({id:"d",documentStyle:{},drawings:{},drawingsOrder:[],body:{dataStream:`\r
8
- `,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(n){return new En(n!=null?n:En.newEmptyData())}insertText(n,r,s){var u,h;let i=((h=(u=this._data.body)==null?void 0:u.dataStream.length)!=null?h:2)-2,o,a;if(typeof n=="string"?o=n:(i=Math.min(n,i),o=r),typeof r=="object"?a=r instanceof nn?r.build():r:a=s instanceof nn?s.build():s,!o)return this;const l={dataStream:o,textRuns:a?[{ts:a,st:i,ed:i+o.length}]:[]},c=Qe.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:l});if(!c)throw new Error("Insert text failed, please check.");return Me.apply(this._doc.getBody(),c.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 Qt?n.getData():n:(s=Math.min(n,s),i=r instanceof Qt?r.getData():r);const o=Qe.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 Me.apply(this._doc.getBody(),o.serialize()),this}delete(n,r){if(r!==void 0){if(!r)return this;const s=Qe.selection.delete([{startOffset:n,endOffset:n+r,collapsed:!0}],this._data.body);Me.apply(this._doc.getBody(),s)}return this}setStyle(n,r,s){const i={dataStream:"",textRuns:[{ts:s instanceof nn?s.build():s,st:0,ed:r-n}]},o=Qe.selection.retain([{startOffset:n,endOffset:r,collapsed:!0}],i);return Me.apply(this._doc.getBody(),o),this}setLink(n,r,s){const i=Qe.customRange.add({rangeType:rn.HYPERLINK,rangeId:tt(),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 Me.apply(this._doc.getBody(),i.serialize()),this}cancelLink(n,r){if(typeof n=="string"){const s=Qe.customRange.delete({rangeId:n,documentDataModel:this._doc});if(!s)throw new Error("Insert text failed, please check.");Me.apply(this._doc.getBody(),s.serialize())}else this.slice(n,r).getLinks().forEach(i=>{const o=Qe.customRange.delete({rangeId:i.rangeId,documentDataModel:this._doc});if(!o)throw new Error("Insert text failed, please check.");Me.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,Qt.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=En.createByBody({dataStream:i,customRanges:[{rangeType:rn.HYPERLINK,rangeId:tt(),properties:{url:o},startIndex:0,endIndex:i.length-1}]});return typeof n=="number"?this.insertRichText(n,a):this.insertRichText(a)}}const eR="__default_document_sub_component_id20231101__";class Lh{constructor(){p(this,"skipNextObservers",!1);p(this,"lastReturnValue");p(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class tR extends ce.Subject{constructor(){super(...arguments);p(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 Lh;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 nR(e){return new ce.Observable(t=>{const n=e.subscribeEvent(r=>{t.next(r)});return()=>n.unsubscribe()})}const Js=Ae.createIdentifier("core.resource-manager.service"),Ji={[Ut.Editor]:"Editor",[Ut.Owner]:"Owner",[Ut.Reader]:"Reader",[Ut.UNRECOGNIZED]:"UNRECOGNIZED"},Us=e=>e?{userID:`${Ji[e]}_${tt(8)}`,name:Ji[e],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},rR=(e,t)=>e.startsWith(Ji[t]);class Dr extends Ke{constructor(){super(...arguments);p(this,"_model",new Map);p(this,"_userChange$",new ce.Subject);p(this,"userChange$",this._userChange$.asObservable());p(this,"_currentUser$",new ce.BehaviorSubject(Us()));p(this,"currentUser$",this._currentUser$.asObservable())}dispose(){super.dispose(),this._model.clear(),this._userChange$.complete(),this._currentUser$.complete()}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(n){this.addUser(n),this._currentUser$.next(n)}addUser(n){this._model.set(n.userID,n),this._userChange$.next({type:"add",user:n})}getUser(n,r){const s=this._model.get(n);if(s)return s;r&&r()}delete(n){const r=this.getUser(n);this._model.delete(n),r&&this._userChange$.next({type:"delete",user:r})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}list(){return Array.from(this._model.values())}}var sR=Object.getOwnPropertyDescriptor,iR=(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=o(s)||s);return s},El=(e,t)=>(n,r)=>t(n,r,e);exports.AuthzIoLocalService=class{constructor(t,n){p(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(Us(Ut.Owner))}_getRole(t){const n=this._userManagerService.getCurrentUser();return n?rR(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:[ve.UNIVER_SHEET,ve.UNIVER_DOC,ve.UNIVER_SLIDE],onLoad:(t,n)=>{for(const r in n)this._permissionMap.set(r,n[r])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(t){return tt(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:Ut.Owner,shareScope:-1,scope:{read:Ni.AllCollaborator,edit:Ni.AllCollaborator},creator:Us(Ut.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(Ut.Owner)||this._getRole(Ut.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=iR([El(0,Js),El(1,Ae.Inject(Dr))],exports.AuthzIoLocalService);const Dh=Ae.createIdentifier("IAuthzIoIoService"),oa=Ae.createIdentifier("univer.config-service");class xh{constructor(){p(this,"_configChanged$",new ce.Subject);p(this,"configChanged$",this._configChanged$.asObservable());p(this,"_config",new Map)}dispose(){this._config.clear(),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=Hs(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 ce.Observable(n=>{Object.prototype.hasOwnProperty.call(this._config,t)&&n.next(this._config.get(t));const r=this.configChanged$.pipe(ce.filter(s=>Object.prototype.hasOwnProperty.call(s,t))).subscribe(s=>n.next(s[t]));return()=>r.unsubscribe()})}}const Cr="FOCUSING_UNIT",Hn="FOCUSING_SHEET",Rr="FOCUSING_DOC",Ir="FOCUSING_SLIDE",oR="FOCUSING_EDITOR_BUT_HIDDEN",Uh="EDITOR_ACTIVATED",aR="FOCUSING_EDITOR_INPUT_FORMULA",Ph="FOCUSING_FX_BAR_EDITOR",lR="FOCUSING_UNIVER_EDITOR",cR="FOCUSING_EDITOR_INPUT_FORMULA",uR="FOCUSING_PANEL_EDITOR",hR="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",dR="FOCUSING_COMMON_DRAWINGS",fR="FORMULA_EDITOR_ACTIVATED";class kh extends Ke{constructor(){super(...arguments);p(this,"_error$",new ce.Subject);p(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(n){this._error$.next({errorKey:n})}}var aa=(e=>(e.URL="URL",e.UUID="UUID",e.BASE64="BASE64",e))(aa||{}),Fh=(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))(Fh||{});const Qi=Ae.createIdentifier("core.image-io.service"),mR="0.10.0",gR={version:mR};function _R(e="",t=Fr.ZH_CN,n=""){return{id:e,sheetOrder:[],name:n,appVersion:gR.version,locale:t,styles:{},sheets:{},resources:[]}}class Bh{constructor(t={}){p(this,"_styles");p(this,"_cacheMap",new yr(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=tt(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&&q.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(q.diffValue(n[r],t))return r;return null}}const pR=(e,t)=>t.length===e.length&&!e.some(n=>t.some(r=>!on.equals(r,n))),ER=(e,t)=>t.length===e.length&&e.every((n,r)=>{const s=t[r];return s.unitId===n.unitId&&s.sheetId===n.sheetId&&on.equals(n.range,s.range)}),eo={t:0,b:2,l:2,r:2},CR=e=>({sbr:.6,sbo:e,spr:.6,spo:e}),Cl=90;function Sr(e,t,n={}){const r=e.length,{textRotation:s,paddingData:i,horizontalAlign:o=Tt.UNSPECIFIED,verticalAlign:a=_n.UNSPECIFIED,wrapStrategy:l=In.UNSPECIFIED,cellValueType:c}=n,{t:u,r:h,b:d,l:f}=i||eo,{vertexAngle:g,centerAngle:_}=jh(s),R={id:"d",body:{dataStream:`${e}${Nl}`,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:u,marginBottom:d,marginRight:h,marginLeft:f,renderConfig:{horizontalAlign:o,verticalAlign:a,centerAngle:_,vertexAngle:g,wrapStrategy:l,cellValueType:c,zeroWidthParagraphBreak:1}},drawings:{},drawingsOrder:[]};return new Nt(R)}function RR(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 Rl(e){if(!e)return{};const{ff:t,fs:n,it:r,bl:s,ul:i,st:o,ol:a,cl:l}=e,c={};return t&&(c.ff=t),n&&(c.fs=n),r&&(c.it=r),s&&(c.bl=s),i&&(c.ul=i),o&&(c.st=o),a&&(c.ol=a),l&&(c.cl=l),c}function $h(e,t,n){var i;const r=e.getBody();if((i=r.customRanges)!=null&&i.some(o=>o.rangeType===rn.HYPERLINK))return;const s=Qe.customRange.add({ranges:[{startOffset:0,endOffset:r.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:rn.HYPERLINK,body:r,properties:{url:t,refId:n}});s&&Me.apply(r,s.serialize())}function Hh(e){return e!=null}const IR='"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';function Il(e){const t=st.ff,n=st.fs;if(!e){const h=`${n}pt ${t}`;return{fontCache:h,fontString:h,fontSize:n,originFontSize:n,fontFamily:t}}let r=kn.ITALIC;(e.it===0||e.it===void 0)&&(r=kn.NORMAL);let s=kn.BOLD;(e.bl===0||e.bl===void 0)&&(s=kn.NORMAL);let i=n;e.fs&&(i=Math.ceil(e.fs));let o=t;if(e.ff){let h=e.ff;h=h.replace(/"/g,"").replace(/'/g,""),h.indexOf(" ")>-1&&(h=`"${h}"`),h==null&&(h=t),o=h}const{va:a}=e;let l=i;if(a===Yt.SUBSCRIPT||a===Yt.SUPERSCRIPT){const h=SR(o,l),{sbr:d,spr:f}=h;l*=a===Yt.SUBSCRIPT?d:f}const c=`${r} ${s} ${l}pt ${o}`,u=`${c}, ${IR} `;return{fontCache:c,fontString:u,fontSize:l,originFontSize:i,fontFamily:o}}function SR(e,t){return CR(t)}function jh(e){const{a:t=0,v:n=ie.FALSE}=e||{a:0,v:ie.FALSE};let r=0,s=t;return n===ie.TRUE&&(r=Cl,s=Cl),{centerAngle:r,vertexAngle:s}}class OR{constructor(t,n){p(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!==ie.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:_e.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:_e.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:_e.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:_e.COLUMN}),r}getColumnDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getColumn(i);r[s]=o!=null?o:{w:this._config.defaultColumnWidth,hd:ie.FALSE},s++}return r}getSize(){return tn(this._columnData)}getColumnWidth(t){var n,r;return(r=(n=this._columnData[t])==null?void 0:n.w)!=null?r:this._config.defaultColumnWidth}setColumnWidth(t,n){const r=this._columnData[t];n===this._config.defaultColumnWidth?r&&(delete r.w,Object.keys(r).length===0&&delete this._columnData[t]):this._columnData[t]=r?{...r,w:n}:{w:n}}getColumn(t){return this._columnData[t]}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}}const vR=2e3;class wR{constructor(t,n,r){p(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.getRow(i);r[s]=o!=null?o:{h:this._config.defaultRowHeight,hd:ie.FALSE},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:ie.FALSE,h:s.defaultRowHeight},{ia:l,ah:c,h:u=s.defaultRowHeight}=a;i+=(l==null||l===ie.TRUE)&&typeof c=="number"?c:u}return i}setRowHeight(t,n){const r=this._rowData[t];if(n===this._config.defaultRowHeight)r&&(delete r.h,Object.keys(r).length===0&&delete this._rowData[t]);else{const s=Math.min(n,vR);this._rowData[t]=r?{...r,h:s}:{h:s}}}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:_e.ROW})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:_e.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:_e.ROW})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:_e.ROW}),r}getRowRawVisible(t){const n=this.getRow(t);return n?n.hd!==ie.TRUE:!0}getSize(){return tn(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 bR="DEFAULT_WORKSHEET_ROW_COUNT",Wh=1e3,AR="DEFAULT_WORKSHEET_COLUMN_COUNT",Yh=20,TR="DEFAULT_WORKSHEET_ROW_HEIGHT",Gh=24,yR="DEFAULT_WORKSHEET_COLUMN_WIDTH",Vh=88,NR="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",zh=46,MR="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Kh=20;function Xh(e){const t={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:ie.FALSE,rowCount:Wh,columnCount:Yh,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Vh,defaultRowHeight:Gh,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:ie.TRUE,rowHeader:{width:zh,hidden:ie.FALSE},columnHeader:{height:Kh,hidden:ie.FALSE},rightToLeft:ie.FALSE};return Object.keys(t).forEach(n=>{const r=n;typeof e[r]>"u"&&(e[r]=t[r])}),e}class LR extends Ke{constructor(n){super();p(this,"_cellCache",new Map);p(this,"_rowCache",new Map);p(this,"_columnCache",new Map);p(this,"_hasRow",!1);p(this,"_hasColumn",!1);p(this,"_hasAll",!1);p(this,"_allIndex",-1);p(this,"_mergeData");p(this,"_rangeMap",new yr(5e4));p(this,"_skeletonCache",new yr(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===_e.ROW?this._createRowCache(s,r):i===_e.COLUMN?this._createColumnCache(s,r):i===_e.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||!q.isEmptyObject(this._columnCache)?!0:this._mergeData.some(r=>r.startRow<=n&&n<=r.endRow)}isColumnContainsMergedCell(n){return this._hasAll||!q.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 c=[];for(const u of this._mergeData||[])on.intersects(u,{startRow:n,endRow:s,startColumn:r,endColumn:i})&&(o.push({...u}),c.push(l)),l++;return this._rangeMap.set(a,c),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 c=[];for(let u=0;u<a.length;u++){const{startRow:h,endRow:d,startColumn:f,endColumn:g}=a[u];for(let _=n;_<=s;_++){let R=!1;for(let b=r;b<=i;b++)if(_>=h&&_<=d&&b>=f&&b<=g){o.push({startRow:h,endRow:d,startColumn:f,endColumn:g}),c.push(u),R=!0;break}if(R)break}}return this._skeletonCache.set(l,c),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 qh extends Ke{constructor(n){super();p(this,"_cellContentInterceptor",null);p(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,Pn.Value|Pn.Style,s,i):this.getRawCell(n,r)}getCellValueOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,Pn.Value):this.getRawCell(n,r)}getCellStyleOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,Pn.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,We(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(n){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=n,We(()=>this._rowFilteredInterceptor=null)}}const Sl={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};class xr{constructor(t,n,r){p(this,"_sheetId");p(this,"_snapshot");p(this,"_cellData");p(this,"_rowManager");p(this,"_columnManager");p(this,"_viewModel");p(this,"_spanModel");p(this,"_isRowStylePrecedeColumnStyle",!0);p(this,"_getCellHeight");var a;this.unitId=t,this._styles=r,this._snapshot=Xh(n);const{columnData:s,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:tt(6),this._cellData=new dt(o),this._viewModel=new qh((l,c)=>this.getCellRaw(l,c)),this._rowManager=new wR(this._snapshot,this._viewModel,i),this._columnManager=new OR(this._snapshot,s),this._spanModel=new LR(this._snapshot.mergeData)}__interceptViewModel(t){t(this._viewModel)}__registerGetCellHeight(t){return this._getCellHeight=t,We(()=>{this._getCellHeight=null})}getSnapshot(){return this._snapshot}getCellHeight(t,n){return this._getCellHeight?this._getCellHeight(t,n):this._snapshot.defaultRowHeight}setMergeData(t){this._snapshot.mergeData=t,this.getSpanModel().rebuild(t)}getSpanModel(){return this._spanModel}setIsRowStylePrecedeColumnStyle(t){this._isRowStylePrecedeColumnStyle=t}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)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){const t=this._snapshot.defaultStyle;return this._styles.get(t)}setDefaultCellStyle(t){this._snapshot.defaultStyle=t}getCellStyle(t,n){const r=this.getCell(t,n);if(r){const s=r.s;return typeof s=="string"?this._styles.get(s):s}return null}getComposedCellStyle(t,n,r){const s=this.getDefaultCellStyleInternal(),i=this.getRowStyle(t),o=this.getColumnStyle(n),a=this.getCell(t,n),l=this._styles.getStyleByCell(a);return(r!=null?r:this._isRowStylePrecedeColumnStyle)?ar(s,o,i,a==null?void 0:a.themeStyle,l):ar(s,i,o,a==null?void 0:a.themeStyle,l)}getComposedCellStyleByCellData(t,n,r,s){const i=this.getDefaultCellStyleInternal(),o=this.getRowStyle(t),a=this.getColumnStyle(n),l=this._styles.getStyleByCell(r);return(s!=null?s:this._isRowStylePrecedeColumnStyle)?ar(i,a,o,r==null?void 0:r.themeStyle,l):ar(i,o,a,r==null?void 0:r.themeStyle,l)}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((c,u)=>{Object.keys(u).forEach(h=>{const d=+h,f=t.getValue(c,d),g=f!=null&&f.s?this._styles.get(f.s):null,_=(g==null?void 0:g.bd)&&(g.bd.b||g.bd.l||g.bd.r||g.bd.t||g.bd.bc_tr||g.bd.bl_tr||g.bd.ml_tr||g.bd.tl_bc||g.bd.tl_br||g.bd.tl_mr);(f&&(f.v||f.p)||g!=null&&g.bg||_)&&(a?r=Math.min(r,c):(r=c,a=!0),s=Math.max(s,c),l?i=Math.min(i,d):(l=!0,i=d),o=Math.max(o,d))})}),n.forEach(c=>{a?r=Math.min(r,c.startRow):(r=c.startRow,a=!0),s=Math.max(s,c.endRow),l?i=Math.min(i,c.startColumn):(i=c.startColumn,a=!0),o=Math.max(o,c.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=q.deepClone(t);return new xr(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,c=n;if(r){const{startRow:u,endRow:h,startColumn:d,endColumn:f}=r;t===u&&n===d?(o=h,a=f,l=u,c=d,i=!0):t>=u&&t<=h&&n>=d&&n<=f&&(o=h,a=f,l=u,c=d,s=!0)}return{actualRow:t,actualColumn:n,isMergedMainCell:i,isMerged:s,endRow:o,endColumn:a,startRow:l,startColumn:c}}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)}getRangeFilterRows(t){const n=[];for(let r=t.startRow;r<=t.endRow;r++)this.getRowFiltered(r)&&n.push(r);return n}getMatrixWithMergedCells(t,n,r,s,i=Fn.Raw){const o=this.getCellMatrix(),a=this._spanModel.getMergedCellRange(t,n,r,s),l=new dt;return Vi(t,r,n,s).forEach((c,u)=>{var d;let h;if(i===Fn.Raw)h=this.getCellRaw(c,u);else if(i===Fn.Intercepted)h=this.getCell(c,u);else if(i===Fn.Both){const f=this.getCellRaw(c,u);if(f){h={...f};const g=(d=this.getCell(c,u))==null?void 0:d.v;Hh(g)&&h&&(h.displayV=String(g))}}h&&l.setValue(c,u,h)}),a.forEach(c=>{const{startColumn:u,startRow:h,endColumn:d,endRow:f}=c;Vi(h,f,u,d).forEach((g,_)=>{g===h&&_===u&&l.setValue(g,_,{...o.getValue(g,_),rowSpan:f-h+1,colSpan:d-u+1}),(g!==h||_!==u)&&l.realDeleteValue(g,_)})}),l}getRange(t,n,r,s){return typeof t=="object"?new Kn(this,t,{getStyles:()=>this._styles}):new Kn(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,c=s;return{next(){for(;;){if(c>o&&(l+=1,c=s),l>i)return{done:!0,value:void 0};const u=a.getCell(l,c),h=!u,d=a.getMergedCell(l,c);if(d){if(l!==d.startRow||c!==d.startColumn){c=d.endColumn+1;continue}if(h&&n){c=d.endColumn+1;continue}const g={row:l,col:c,value:u};return g.colSpan=d.endColumn-d.startColumn+1,g.rowSpan=d.endRow-d.startRow+1,c=d.endColumn+1,{done:!1,value:g}}if(h&&n)c+=1;else{const f={row:l,col:c,value:u};return c+=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 c=s,u=i;return{next(){for(;;){if(c>o&&(u+=1,c=s),u>a)return{done:!0,value:void 0};const h=l.getMergedCell(c,u);if(h){const g=c!==h.startRow,_=g||u!==h.startColumn;if(r&&_||!r&&g){c=h.endRow+1;continue}const R=l.getCell(h.startRow,h.startColumn);if(!R&&n){c=h.endRow+1;continue}const F={row:c,col:h.startColumn,value:R};return F.colSpan=h.endColumn-h.startColumn+1,F.rowSpan=h.endRow-h.startRow+1,c=h.endRow+1,{done:!1,value:F}}const d=l.getCell(c,u);if(!d&&n)c+=1;else{const g={row:c,col:u,value:d};return c+=1,{done:!1,value:g}}}}}}}}getCellDocumentModel(t,n,r=Sl){var _;if(!t)return;const{isDeepClone:s,displayRawFormula:i,ignoreTextRotation:o}={...Sl,...r};let a,l="document";const c=RR(n),u=o?st.tr:c.textRotation||st.tr;let h=c.horizontalAlign||st.ht;const d=c.verticalAlign||st.vt,f=c.wrapStrategy||st.tb,g=c.paddingData||eo;if(t.f&&i)a=Sr(t.f.toString(),{},{verticalAlign:d}),h=st.ht;else if(t.p){const{centerAngle:R,vertexAngle:b}=jh(u);a=this._updateConfigAndGetDocumentModel(s?q.deepClone(t.p):t.p,h,g,{horizontalAlign:h,verticalAlign:d,centerAngle:R,vertexAngle:b,wrapStrategy:f,zeroWidthParagraphBreak:1})}else if(t.v!=null){const R=Rl(n);l=Il(R).fontCache;let b=Zh(t);t.t===en.FORCE_STRING&&i&&(b=`'${b}`),a=Sr(b,R,{...c,textRotation:u,cellValueType:t.t})}return a&&t.linkUrl&&t.linkId&&$h(a,t.linkUrl,t.linkId),{documentModel:a,fontString:l,textRotation:u,wrapStrategy:f,verticalAlign:d,horizontalAlign:h,paddingData:g,fill:(_=n==null?void 0:n.bg)==null?void 0:_.rgb}}_updateConfigAndGetDocumentModel(t,n,r,s){var o,a,l,c,u;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=(c=r.l)!=null?c:2,t.documentStyle.marginRight=(u=r.r)!=null?u: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 h of i)h.paragraphStyle||(h.paragraphStyle={}),h.paragraphStyle.horizontalAlign=n;return new Nt(t)}getBlankCellDocumentModel(t,n,r){const s=this.getComposedCellStyleByCellData(n,r,t),i=Rl(s),o=this.getCellDocumentModel(t,s,{ignoreTextRotation:!0});if(o!=null)return o.documentModel==null&&(o.documentModel=Sr("",i)),o;const a="";let l="document";const c=st.tr,u=st.ht,h=st.vt,d=st.tb,f=eo;return l=Il({}).fontCache,{documentModel:Sr(a,i),fontString:l,textRotation:c,wrapStrategy:d,verticalAlign:h,horizontalAlign:u,paddingData:f}}getCellDocumentModelWithFormula(t,n,r){const s=this.getComposedCellStyleByCellData(n,r,t);return this.getCellDocumentModel(t,s,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(t){this._snapshot.custom=t}}function Zh(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 Qe.transform.getPlainText(t);const n=e.v;return typeof n=="string"?e.t===en.BOOLEAN?n.toUpperCase():n.replace(/[\r\n]/g,""):typeof n=="number"?e.t===en.BOOLEAN?n?"TRUE":"FALSE":n.toString():typeof n=="boolean"?n?"TRUE":"FALSE":""}function DR(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 Qe.transform.getPlainText(n)}return e==null?void 0:e.v}var xR=Object.getOwnPropertyDescriptor,UR=(e,t,n,r)=>{for(var s=r>1?void 0:r?xR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},PR=(e,t)=>(n,r)=>t(n,r,e);function kR(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}exports.Workbook=class extends Ws{constructor(n={},r){super();p(this,"type",ve.UNIVER_SHEET);p(this,"_sheetCreated$",new ce.Subject);p(this,"sheetCreated$",this._sheetCreated$.asObservable());p(this,"_sheetDisposed$",new ce.Subject);p(this,"sheetDisposed$",this._sheetDisposed$.asObservable());p(this,"_activeSheet$",new ce.BehaviorSubject(null));p(this,"activeSheet$",this._activeSheet$.asObservable());p(this,"_worksheets");p(this,"_styles");p(this,"_snapshot");p(this,"_unitId");p(this,"_count");p(this,"_name$");p(this,"name$");this._logService=r;const s=_R();q.isEmptyObject(n)?this._snapshot=s:this._snapshot=q.commonExtend(s,n);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=tt(6)),this._unitId=this._snapshot.id,this._styles=new Bh(i),this._count=1,this._worksheets=new Map,this._name$=new ce.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 q.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 xr(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()!==ie.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===ie.TRUE).map(n=>n.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden!==ie.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(q.isEmptyObject(s)){const o=tt();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 c=new xr(this._unitId,a,this._styles);r.set(o,c),i.includes(o)||i.push(o)}this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(n){this._snapshot.custom=n}};exports.Workbook=UR([PR(1,Et)],exports.Workbook);class la extends Ws{constructor(n){var r;super();p(this,"type",ve.UNIVER_SLIDE);p(this,"_activePage$",new ce.BehaviorSubject(null));p(this,"activePage$",this._activePage$.asObservable());p(this,"_name$");p(this,"name$");p(this,"_snapshot");p(this,"_unitId");this._snapshot={...eh,...n},this._unitId=(r=this._snapshot.id)!=null?r:tt(6),this._name$=new ce.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:tt(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=tt(6);return{id:n,pageType:Co.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)}}var FR=Object.getOwnPropertyDescriptor,BR=(e,t,n,r)=>{for(var s=r>1?void 0:r?FR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Ol=(e,t)=>(n,r)=>t(n,r,e);const Xn=Ae.createIdentifier("univer.current");exports.UniverInstanceService=class extends Ke{constructor(n,r){super();p(this,"_unitsByType",new Map);p(this,"_createHandler");p(this,"_ctorByType",new Map);p(this,"_currentUnits",new Map);p(this,"_currentUnits$",new ce.BehaviorSubject(this._currentUnits));p(this,"currentUnits$",this._currentUnits$.asObservable());p(this,"_unitAdded$",new ce.Subject);p(this,"unitAdded$",this._unitAdded$.asObservable());p(this,"_unitDisposed$",new ce.Subject);p(this,"unitDisposed$",this._unitDisposed$.asObservable());p(this,"_focused$",new ce.BehaviorSubject(null));p(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(ce.map(r=>{var s;return(s=r.get(n))!=null?s:null}),ce.distinctUntilChanged())}getCurrentUnitForType(n){return this._currentUnits.get(n)}getCurrentUnitOfType(n){return this.getCurrentUnitForType(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(ce.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(ce.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(ve.UNIVER_DOC)}getUniverDocInstance(n){return this.getUnit(n,ve.UNIVER_DOC)}getUniverSheetInstance(n){return this.getUnit(n,ve.UNIVER_SHEET)}getAllUnitsForType(n){var r;return(r=this._unitsByType.get(n))!=null?r:[]}changeDoc(n,r){const s=this.getAllUnitsForType(ve.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(Cr,!0),this._contextService.setContextValue(Rr,!1),this._contextService.setContextValue(Hn,!0),this._contextService.setContextValue(Ir,!1),this.setCurrentUnitForType(n)):this.focused instanceof Nt?(this._contextService.setContextValue(Cr,!0),this._contextService.setContextValue(Rr,!0),this._contextService.setContextValue(Hn,!1),this._contextService.setContextValue(Ir,!1),this.setCurrentUnitForType(n)):this.focused instanceof la?(this._contextService.setContextValue(Cr,!0),this._contextService.setContextValue(Rr,!1),this._contextService.setContextValue(Hn,!1),this._contextService.setContextValue(Ir,!0),this.setCurrentUnitForType(n)):(this._contextService.setContextValue(Cr,!1),this._contextService.setContextValue(Rr,!1),this._contextService.setContextValue(Hn,!1),this._contextService.setContextValue(Ir,!1))}getFocusedUnit(){return this.focused}getUnitType(n){const r=this._getUnitById(n);return r?r[1]:ve.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._tryResetCurrentOnRemoval(n,i),this._tryResetFocusOnRemoval(n),this._unitDisposed$.next(s),!0}_tryResetCurrentOnRemoval(n,r){const s=this.getCurrentUnitForType(r);(s==null?void 0:s.getUnitId())===n&&(this._currentUnits.set(r,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(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=BR([Ol(0,Ae.Inject(Ae.Injector)),Ol(1,Jn)],exports.UniverInstanceService);var Ue=(e=>(e[e.Starting=0]="Starting",e[e.Ready=1]="Ready",e[e.Rendered=2]="Rendered",e[e.Steady=3]="Steady",e))(Ue||{});const Jh={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"};var $R=Object.getOwnPropertyDescriptor,HR=(e,t,n,r)=>{for(var s=r>1?void 0:r?$R(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},jR=(e,t)=>(n,r)=>t(n,r,e);class Qh extends Error{constructor(t){super(`[LifecycleService]: lifecycle stage "${Jh[t]}" will never be reached!`),this.name="LifecycleUnreachableError"}}exports.LifecycleService=class extends Ke{constructor(n){super();p(this,"_lifecycle$",new ce.BehaviorSubject(Ue.Starting));p(this,"lifecycle$",this._lifecycle$.asObservable());p(this,"_lock",!1);this._logService=n,this._reportProgress(Ue.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()}onStage(n){return ce.firstValueFrom(this.lifecycle$.pipe(ce.filter(r=>r>=n),Li(r=>r===n),ce.map(()=>{}))).catch(r=>r.name==="EmptyError"?Promise.reject(new Qh(n)):Promise.reject(r))}subscribeWithPrevious(){return ce.merge(ed(this.stage),this._lifecycle$.pipe(ce.skip(1))).pipe(Li(n=>n===Ue.Steady))}_reportProgress(n){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${Jh[n]}".`)}};exports.LifecycleService=HR([jR(0,Et)],exports.LifecycleService);function ed(e){switch(e){case Ue.Starting:return ce.of(Ue.Starting);case Ue.Ready:return ce.of(Ue.Starting,Ue.Ready);case Ue.Rendered:return ce.of(Ue.Starting,Ue.Ready,Ue.Rendered);default:return ce.of(Ue.Starting,Ue.Ready,Ue.Rendered,Ue.Steady)}}const WR=Ae.createIdentifier("ILocalStorageService");class Cn extends Ke{constructor(){super();p(this,"_currentLocale$",new ce.BehaviorSubject(Fr.ZH_CN));p(this,"currentLocale$",this._currentLocale$.asObservable());p(this,"_locales",null);p(this,"localeChanged$",new ce.Subject);p(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(We(()=>{this._locales=null,this._currentLocale$.complete(),this.localeChanged$.complete()}))}get _currentLocale(){return this._currentLocale$.value}load(n){var r;this._locales=Hs((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 YR=Object.getOwnPropertyDescriptor,GR=(e,t,n,r)=>{for(var s=r>1?void 0:r?YR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},VR=(e,t)=>(n,r)=>t(n,r,e);exports.MentionIOLocalService=class{constructor(t){this._userManagerService=t}async list(t){return{list:[{type:ws.PERSON,mentions:[{objectType:ws.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=GR([VR(0,Ae.Inject(Dr))],exports.MentionIOLocalService);const td=Ae.createIdentifier("univer.service.mention-io");var ca=(e=>(e.INIT="init",e.FETCHING="fetching",e.DONE="done",e))(ca||{});const nd=Ae.createIdentifier("univer.permission-service");class rd extends Ke{constructor(){super(...arguments);p(this,"_permissionPointMap",new Map);p(this,"_permissionPointUpdate$",new ce.Subject);p(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable());p(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 ce.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 ce.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=ca.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 ce.combineLatest(r).pipe(ls.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 sd(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}var zR=Object.getOwnPropertyDescriptor,KR=(e,t,n,r)=>{for(var s=r>1?void 0:r?zR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Oi=(e,t)=>(n,r)=>t(n,r,e);const XR=4,id=Symbol("DependentOn");class to extends Ke{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}p(to,"pluginName"),p(to,"type",ve.UNIVER_UNKNOWN);class qR{constructor(){p(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)}}function ZR(...e){return function(t){t[id]=e}}exports.PluginService=class{constructor(t,n,r){p(this,"_pluginRegistry",new Map);p(this,"_pluginStore",new qR);p(this,"_seenPlugins",new Set);p(this,"_loadedPlugins",new Set);p(this,"_loadedPluginTypes",new Set([ve.UNIVER_UNKNOWN]));p(this,"_flushTimerByType",new Map);this._injector=t,this._lifecycleService=n,this._logService=r}dispose(){this._pluginStore.removePlugins().forEach(t=>t.dispose()),this._flushTimerByType.forEach(t=>clearTimeout(t))}registerPlugin(t,n){this._assertPluginValid(t);const r={plugin:t,options:n};this._pluginRegistry.set(t.pluginName,r),this._logService.debug("[PluginService]",`Plugin "${t.pluginName}" registered.`);const{type:s}=t;this._loadedPluginTypes.has(s)&&(s===ve.UNIVER_UNKNOWN?this._loadFromPlugins([r]):this._flushType(s))}startPluginsForType(t){this._loadedPluginTypes.has(t)||this._loadPluginsForType(t)}_loadPluginsForType(t){const n=Array.from(this._pluginRegistry.keys()),r=[];n.forEach(s=>{const i=this._pluginRegistry.get(s);i.plugin.type===t&&r.push(i)}),this._loadFromPlugins(r),this._loadedPluginTypes.add(t)}_assertPluginValid(t){const{type:n,pluginName:r}=t;if(n===ve.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)}_flushType(t){this._flushTimerByType.get(t)===void 0&&this._flushTimerByType.set(t,setTimeout(()=>{this._loadPluginsForType(t),this._flushTimerByType.delete(t)},XR))}_loadFromPlugins(t){const n=[],r=new Set,s=o=>{const{plugin:a}=o,{pluginName:l}=a;if(this._loadedPlugins.has(l)||r.has(l))return;r.add(l),this._pluginRegistry.delete(l);const c=a[id];c&&c.forEach(u=>{const h=this._pluginRegistry.get(u.pluginName);if(h)s(h);else if(!this._seenPlugins.has(u.pluginName)&&!r.has(u.pluginName)){if(a.type===ve.UNIVER_UNKNOWN&&u.type!==ve.UNIVER_UNKNOWN)throw new Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${a.pluginName} and the dependency is ${u.pluginName}.`);a.type!==u.type&&u.type!==ve.UNIVER_UNKNOWN&&this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${u.pluginName}" which has different type.`),this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${u.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(u),s({plugin:u,options:void 0})}}),n.push(o)};t.forEach(o=>s(o));const i=n.map(o=>this._initPlugin(o.plugin,o.options));this._pluginsRunLifecycle(i)}_pluginsRunLifecycle(t){const n=this._lifecycleService.stage;if(ed(n).subscribe(r=>this._runStage(t,r)),n!==Ue.Steady){const r=this._lifecycleService.lifecycle$.pipe(ce.skip(1)).subscribe(s=>{this._runStage(t,s),s===Ue.Steady&&r.unsubscribe()})}}_runStage(t,n){t.forEach(r=>{switch(n){case Ue.Starting:r.onStarting();break;case Ue.Ready:r.onReady();break;case Ue.Rendered:r.onRendered();break;case Ue.Steady:r.onSteady();break}})}_initPlugin(t,n){const r=this._injector.createInstance(t,n);return this._pluginStore.addPlugin(r),this._loadedPlugins.add(t.pluginName),this._logService.debug("[PluginService]",`Plugin "${r.getPluginName()}" loaded.`),r}};exports.PluginService=KR([Oi(0,Ae.Inject(Ae.Injector)),Oi(1,Ae.Inject(exports.LifecycleService)),Oi(2,Et)],exports.PluginService);const no=Ae.createIdentifier("resource-loader-service");var JR=Object.getOwnPropertyDescriptor,QR=(e,t,n,r)=>{for(var s=r>1?void 0:r?JR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},eI=(e,t)=>(n,r)=>t(n,r,e);exports.ResourceManagerService=class extends Ke{constructor(n){super();p(this,"_resourceMap",new Map);p(this,"_register$",new ce.Subject);p(this,"register$",this._register$.asObservable());this._logService=n}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),We(()=>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(a){this._logService.error("[ResourceManagerService]","loadResources error",a)}})}unloadResources(n){this.getAllResourceHooks().forEach(r=>{r.onUnLoad(n)})}dispose(){this._register$.complete(),this._resourceMap.clear()}};exports.ResourceManagerService=QR([eI(0,Et)],exports.ResourceManagerService);class Ps extends Ke{constructor(){super();p(this,"_darkMode$",new ce.BehaviorSubject(!1));p(this,"darkMode$",this._darkMode$.asObservable());p(this,"_validColorCache",new Map);p(this,"_currentTheme",Kr.defaultTheme);p(this,"_currentTheme$",new ce.BehaviorSubject(this._currentTheme));p(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(We(()=>{this._currentTheme=Kr.defaultTheme,this._currentTheme$.complete(),this._darkMode$.complete()}))}get darkMode(){return this._darkMode$.getValue()}isValidThemeColor(n){if(this._validColorCache.has(n))return this._validColorCache.get(n);let r=!1;const s=n.split(".");if(s.length===1)r=n in Kr.defaultTheme;else if(s.length===2){const[i,o]=s;r=i in Kr.defaultTheme&&o in this._currentTheme[i]}return this._validColorCache.set(n,r),r}getCurrentTheme(){return this._currentTheme}setTheme(n){this._currentTheme=n,this._currentTheme$.next(n)}setDarkMode(n){this._darkMode$.next(n)}getColorFromTheme(n){return nc(this._currentTheme,n)}}var tI=Object.getOwnPropertyDescriptor,nI=(e,t,n,r)=>{for(var s=r>1?void 0:r?tI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},vi=(e,t)=>(n,r)=>t(n,r,e);const Qs=Ae.createIdentifier("univer.undo-redo.service"),rI=20;class od{dispose(){}async dispatchToHandlers(){return!1}}const ad="univer.command.redo",ld="univer.command.undo",cd=new class extends od{constructor(){super(...arguments);p(this,"type",$r.COMMAND);p(this,"id",ld)}handler(t){const n=t.get(Qs),r=n.pitchTopUndoElement();if(!r)return!1;const s=t.get(Hr);return Gs(r.undoMutations,s)?(n.popUndoToRedo(),!0):!1}},ud=new class extends od{constructor(){super(...arguments);p(this,"type",$r.COMMAND);p(this,"id",ad)}handler(t){const n=t.get(Qs),r=n.pitchTopRedoElement();if(!r)return!1;const s=t.get(Hr);return Gs(r.redoMutations,s)?(n.popRedoToUndo(),!0):!1}};exports.LocalUndoRedoService=class extends Ke{constructor(n,r,s){super();p(this,"undoRedoStatus$");p(this,"_undoRedoStatus$",new ce.BehaviorSubject({undos:0,redos:0}));p(this,"_undoStacks",new Map);p(this,"_redoStacks",new Map);p(this,"_batchingStatus",new Map);this._univerInstanceService=n,this._commandService=r,this._contextService=s,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(cd)),this.disposeWithMe(this._commandService.registerCommand(ud)),this.disposeWithMe(We(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(We(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>rI&&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())}rollback(n,r){const s=r||this._getFocusedUnitId(),i=this._getUndoStack(s),o=i==null?void 0:i[(i==null?void 0:i.length)-1];o&&o.id===n&&(i.pop(),Gs(o.undoMutations,this._commandService))}__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),We(()=>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,c;let n="";const r=this._contextService.getContextValue(Hn),s=this._contextService.getContextValue(Ph),i=this._contextService.getContextValue(Uh);return r?s?n=oo:i?n=io:n=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":n=(c=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?c:"",n}};exports.LocalUndoRedoService=nI([vi(0,Xn),vi(1,Hr),vi(2,Jn)],exports.LocalUndoRedoService);class hd{constructor(t,n=100){p(this,"_imageCacheMap");this._injector=t,this._imageCacheMap=new yr(n)}_getImageCacheKey(t,n){return`${t}-${n}`}getImage(t,n,r,s){const i=this._getImageCacheKey(t,n),o=this._imageCacheMap.get(i);return o||((async()=>{const a=new Image,l=this._injector.has(Qi)?this._injector.get(Qi):null;if(t===aa.UUID)try{a.src=await(l==null?void 0:l.getImage(n))||""}catch(c){console.error(c)}else a.src=n;a.onload=()=>{a.removeAttribute("data-error"),r==null||r()},a.onerror=()=>{a.setAttribute("data-error","true"),s==null||s()},this._imageCacheMap.set(i,a)})(),null)}}function sI(e){return!(e.length===0||e.length>31||e.startsWith("'")||e.endsWith("'")||/[:\\\/\?\*\[\]]/.test(e))}const vl=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],wi=1,ir=8;class ua{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!==wi)throw new Error(`Got v${s} data when expected v${wi}.`);const i=vl[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 ua(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=vl.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,ir,t),this.coords=new this.ArrayType(this.data,ir+a+l,t*2),this._pos=t*2,this._finished=!0):(this.data=new ArrayBuffer(ir+o+a+l),this.ids=new this.IndexArrayType(this.data,ir,t),this.coords=new this.ArrayType(this.data,ir+a+l,t*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(wi<<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 ro(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],c=[];for(;l.length;){const u=l.pop()||0,h=l.pop()||0,d=l.pop()||0;if(h-d<=a){for(let R=d;R<=h;R++){const b=o[2*R],F=o[2*R+1];b>=t&&b<=r&&F>=n&&F<=s&&c.push(i[R])}continue}const f=d+h>>1,g=o[2*f],_=o[2*f+1];g>=t&&g<=r&&_>=n&&_<=s&&c.push(i[f]),(u===0?t<=g:n<=_)&&(l.push(d),l.push(f-1),l.push(1-u)),(u===0?r>=g:s>=_)&&(l.push(f+1),l.push(h),l.push(1-u))}return c}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=[],c=r*r;for(;a.length;){const u=a.pop()||0,h=a.pop()||0,d=a.pop()||0;if(h-d<=o){for(let R=d;R<=h;R++)wl(i[2*R],i[2*R+1],t,n)<=c&&l.push(s[R]);continue}const f=d+h>>1,g=i[2*f],_=i[2*f+1];wl(g,_,t,n)<=c&&l.push(s[f]),(u===0?t-r<=g:n-r<=_)&&(a.push(d),a.push(f-1),a.push(1-u)),(u===0?t+r>=g:n+r>=_)&&(a.push(f+1),a.push(h),a.push(1-u))}return l}}function ro(e,t,n,r,s,i){if(s-r<=n)return;const o=r+s>>1;dd(e,t,o,r,s,i),ro(e,t,n,r,o-1,1-i),ro(e,t,n,o+1,s,1-i)}function dd(e,t,n,r,s,i){for(;s>r;){if(s-r>600){const c=s-r+1,u=n-r+1,h=Math.log(c),d=.5*Math.exp(2*h/3),f=.5*Math.sqrt(h*d*(c-d)/c)*(u-c/2<0?-1:1),g=Math.max(r,Math.floor(n-u*d/c+f)),_=Math.min(s,Math.floor(n+(c-u)*d/c+f));dd(e,t,n,g,_,i)}const o=t[2*n+i];let a=r,l=s;for(or(e,t,r,n),t[2*s+i]>o&&or(e,t,r,s);a<l;){for(or(e,t,a,l),a++,l--;t[2*a+i]<o;)a++;for(;t[2*l+i]>o;)l--}t[2*r+i]===o?or(e,t,r,l):(l++,or(e,t,l,s)),l<=n&&(r=l+1),n<=l&&(s=l-1)}}function or(e,t,n,r){bi(e,n,r),bi(t,2*n,2*r),bi(t,2*n+1,2*r+1)}function bi(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function wl(e,t,n,r){const s=e-n,i=t-r;return s*s+i*i}class iI{constructor(t=!1){p(this,"_tree",new Map);p(this,"_oneCellCache",new Map);p(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 Ls),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 c=l.get(s);c&&c.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:c,endRow:u,endColumn:h}=s;for(let d=l;d<=u;d++){const f=a.get(d);if(f)for(let g=c;g<=h;g++){const _=f.get(g);_&&_.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 g;const{unitId:n,sheetId:r,range:s}=t,{startRow:i,startColumn:o,endRow:a,endColumn:l}=s,c=(g=this._kdTree.get(n))==null?void 0:g.get(r);if(!c)return[];const{tree:u,items:h}=c,d=u.range(o,i,l,a),f=[];for(const _ of d){const R=h[_];f.push(...Array.from(R.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 ua(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:c}=s;if(this._enableOneCellCache&&o===a&&l===c){this._insertOneCellCache(n,r,o,l,i);return}const u=this.getTree(n,r);Number.isNaN(o)&&(o=0),Number.isNaN(l)&&(l=0),Number.isNaN(a)&&(a=Number.POSITIVE_INFINITY),Number.isNaN(c)&&(c=Number.POSITIVE_INFINITY),u.insert({minX:l,minY:o,maxX:c,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 c of l)yield c}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:c}=s;this._enableOneCellCache?o===l&&a===c?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 Ls;s.fromJSON(t[n][r]),this._tree.get(n).set(r,s)}}}}function oI(e){return new Promise(t=>setTimeout(t,e))}function aI(e=1){return new Promise(t=>{let n=0;const r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}var lI=Object.getOwnPropertyDescriptor,cI=(e,t,n,r)=>{for(var s=r>1?void 0:r?lI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},uI=(e,t)=>(n,r)=>t(n,r,e);exports.Skeleton=class extends Ke{constructor(n){super();p(this,"_fontLocale");p(this,"_dirty",!0);this._localeService=n,this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(n){this._dirty=n}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}};exports.Skeleton=cI([uI(0,Ae.Inject(Cn))],exports.Skeleton);var hI=Object.getOwnPropertyDescriptor,dI=(e,t,n,r)=>{for(var s=r>1?void 0:r?hI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},as=(e,t)=>(n,r)=>t(n,r,e);exports.SheetSkeleton=class extends exports.Skeleton{constructor(n,r,s,i,o,a){super(s);p(this,"_worksheetData");p(this,"_renderRawFormula",!1);p(this,"_cellData");p(this,"_imageCacheMap");p(this,"_skipAutoHeightForMergedCells",!0);p(this,"_rowTotalHeight",0);p(this,"_columnTotalWidth",0);p(this,"_rowHeaderWidth",0);p(this,"_columnHeaderHeight",0);p(this,"_rowHeightAccumulation",[]);p(this,"_columnWidthAccumulation",[]);p(this,"_marginTop",0);p(this,"_marginLeft",0);p(this,"_scaleX");p(this,"_scaleY");p(this,"_scrollX");p(this,"_scrollY");this.worksheet=n,this._styles=r,this._contextService=i,this._configService=o,this._injector=a,this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new hd(this._injector),this.initConfig()}initConfig(){var n,r;this._skipAutoHeightForMergedCells=!((n=this._configService.getConfig(Ll))!=null&&n),this.worksheet.setIsRowStylePrecedeColumnStyle((r=this._configService.getConfig(Ml))!=null?r:!1)}resetCache(){}getWorksheetConfig(){return this._worksheetData}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(n){this._columnHeaderHeight=n,this._worksheetData.columnHeader.height=n}set rowHeaderWidth(n){this._rowHeaderWidth=n,this._worksheetData.rowHeader.width=n}get rowHeightAccumulation(){return this._rowHeightAccumulation}get rowTotalHeight(){return this._rowTotalHeight}get columnWidthAccumulation(){return this._columnWidthAccumulation}get columnTotalWidth(){return this._columnTotalWidth}get rowHeaderWidth(){return this._rowHeaderWidth}get columnHeaderHeight(){return this._columnHeaderHeight}setMarginLeft(n){this._marginLeft=n}setMarginTop(n){this._marginTop=n}setScale(n,r){this._updateLayout(),this._scaleX=n,this._scaleY=r||n,this._updateLayout()}setScroll(n,r){q.isDefine(n)&&(this._scrollX=n),q.isDefine(r)&&(this._scrollY=r)}get scrollX(){return this._scrollX}get scrollY(){return this._scrollY}get scaleX(){return this._scaleX}get scaleY(){return this._scaleY}get rowHeaderWidthAndMarginLeft(){return this.rowHeaderWidth+this._marginLeft}get columnHeaderHeightAndMarginTop(){return this.columnHeaderHeight+this._marginTop}get imageCacheMap(){return this._imageCacheMap}_generateRowMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let c=s;if(this.worksheet.getRowFiltered(l))c=0;else if(a[l]!=null){const u=a[l];if(!u)continue;const{h=s,ah:d,ia:f}=u;(f==null||f===ie.TRUE)&&typeof d=="number"?c=d:c=h,u.hd===ie.TRUE&&(c=0)}i+=c,o.push(i)}return{rowTotalHeight:i,rowHeightAccumulation:o}}_generateColumnMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let c=s;if(a[l]!=null){const u=a[l];if(!u)continue;u.w!=null&&(c=u.w),u.hd===ie.TRUE&&(c=0)}i+=c,o.push(i)}return{columnTotalWidth:i,columnWidthAccumulation:o}}intersectMergeRange(n,r){return!!this.worksheet.getMergedCell(n,r)}_getOverflowBound(n,r,s,i,o=Tt.LEFT){let a=0;if(r>s){const l=this._columnWidthAccumulation.length-1;for(let c=r;c>=s;c--){const u=c,h=this.worksheet.getCell(n,u);if(!Fi(h)&&u!==r||this.intersectMergeRange(n,u))return u===r?u:u+1>l?l:u+1;const{startX:d,endX:f}=Un(n,u,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===Tt.CENTER&&u===r?a+=(f-d)/2:a+=f-d,i<a)return u}return r}for(let l=r;l<=s;l++){const c=l,u=this.worksheet.getCell(n,c);if(!Fi(u)&&c!==r||this.intersectMergeRange(n,c))return c===r?c:c-1<0?0:c-1;const{startX:h,endX:d}=Un(n,c,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===Tt.CENTER&&c===r?a+=(d-h)/2:a+=d-h,i<a)return c}return s}_updateLayout(){if(!this.dirty)return;const{rowData:n,columnData:r,defaultRowHeight:s,defaultColumnWidth:i,rowCount:o,columnCount:a,rowHeader:l,columnHeader:c}=this._worksheetData,{rowTotalHeight:u,rowHeightAccumulation:h}=this._generateRowMatrixCache(o,n,s),{columnTotalWidth:d,columnWidthAccumulation:f}=this._generateColumnMatrixCache(a,r,i);this._rowHeaderWidth=l.hidden!==ie.TRUE?this._dynamicallyUpdateRowHeaderWidth(l):0,this._columnHeaderHeight=c.hidden!==ie.TRUE?c.height:0,this._rowTotalHeight=u,this._rowHeightAccumulation=h,this._columnTotalWidth=d,this._columnWidthAccumulation=f,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(n){}_dynamicallyUpdateRowHeaderWidth(n){const s=`${this.worksheet.getRowCount()}`.length*8;return Math.max(n.width,s)}_hasUnMergedCellInRow(n,r,s){if(!this.worksheet.getMergeData())return!1;for(let o=r;o<=s;o++){const{isMerged:a,isMergedMainCell:l}=this.worksheet.getCellInfoInMergeData(n,o);if(!a&&!l)return!0}return!1}expandRangeByMerge(n){let{startRow:r,startColumn:s,endRow:i,endColumn:o}=n;const a=this._worksheetData.mergeData;if(!a)return{startRow:r,startColumn:s,endRow:i,endColumn:o};let l=!0;const c=new dt;for(;l;){l=!1;for(let u=0;u<a.length;u++){const{startRow:h,startColumn:d,endRow:f,endColumn:g}=a[u];if(c.getValue(h,d))continue;rh({startColumn:s,startRow:r,endColumn:o,endRow:i},{startColumn:d,startRow:h,endColumn:g,endRow:f})&&(r=Math.min(r,h),s=Math.min(s,d),i=Math.max(i,f),o=Math.max(o,g),c.setValue(h,d,!0),l=!0)}}return{startRow:r,startColumn:s,endRow:i,endColumn:o}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(n,r){return this.worksheet.getCellInfoInMergeData(n,r)}getNoMergeCellPositionByIndex(n,r,s=!0){return this.getNoMergeCellWithCoordByIndex(n,r,s)}getNoMergeCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this;let{startY:c,endY:u,startX:h,endX:d}=Un(n,r,i,o);return s&&(c+=l,u+=l,h+=a,d+=a),{startY:c,endY:u,startX:h,endX:d}}getNoMergeCellPositionByIndexWithNoHeader(n,r){const{rowHeightAccumulation:s,columnWidthAccumulation:i}=this,{startY:o,endY:a,startX:l,endX:c}=Un(n,r,s,i);return{startY:o,endY:a,startX:l,endX:c}}getRowIndexByOffsetY(n,r,s,i){var l;const{rowHeightAccumulation:o}=this;n=md(n,r,s,this.columnHeaderHeightAndMarginTop);let a=lr(o,n,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(o[a]-n)<Math.abs(n-((l=o[a-1])!=null?l:0))&&(a=a+1),a}getColumnIndexByOffsetX(n,r,s,i){var c;const o=fd(n,r,s,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this;let l=lr(a,o,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(a[l]-o)<Math.abs(o-((c=a[l-1])!=null?c:0))&&(l=l+1),l}getCellIndexByOffset(n,r,s,i,o,a){const l=this.getRowIndexByOffsetY(r,i,o,a),c=this.getColumnIndexByOffsetX(n,s,o,a);return{row:l,column:c}}getCellByOffset(n,r,s,i,o){const a=this==null?void 0:this.getCellIndexByOffset(n,r,s,i,o,{firstMatch:!0});return a?this.worksheet.getCellInfoInMergeData(a.row,a.column):null}getCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this,c=Un(n,r,i,o,this.worksheet.getCellInfoInMergeData(n,r)),{isMerged:u,isMergedMainCell:h}=c;let{startY:d,endY:f,startX:g,endX:_,mergeInfo:R}=c,b=a,F=l;return s===!1&&(b=0,F=0),d+=F,f+=F,g+=b,_+=b,R.startY+=F,R.endY+=F,R.startX+=b,R.endX+=b,{actualRow:n,actualColumn:r,startX:g,startY:d,endX:_,endY:f,isMerged:u,isMergedMainCell:h,mergeInfo:R}}getCellWithCoordByOffset(n,r,s,i,o,a){const{row:l,column:c}=this.getCellIndexByOffset(n,r,s,i,o,a);return this.getCellWithCoordByIndex(l,c)}getOffsetByColumn(n){const{columnWidthAccumulation:r,rowHeaderWidthAndMarginLeft:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetByRow(n){const{rowHeightAccumulation:r,columnHeaderHeightAndMarginTop:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetRelativeToRowCol(n,r){const s=lr(this.columnWidthAccumulation,n);let i=0;s===0?i=n:i=n-this._columnWidthAccumulation[s-1];const o=lr(this.rowHeightAccumulation,r);let a=0;return o===0?a=r:a=r-this._rowHeightAccumulation[o-1],{row:o,column:s,columnOffset:i,rowOffset:a}}_updateConfigAndGetDocumentModel(n,r,s,i){var a,l,c,u,h;if(!i||!((a=n.body)!=null&&a.dataStream))return;n.documentStyle||(n.documentStyle={}),n.documentStyle.marginTop=(l=s.t)!=null?l:0,n.documentStyle.marginBottom=(c=s.b)!=null?c:2,n.documentStyle.marginLeft=(u=s.l)!=null?u:2,n.documentStyle.marginRight=(h=s.r)!=null?h:2,n.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},n.documentStyle.renderConfig={...n.documentStyle.renderConfig,...i};const o=n.body.paragraphs||[];for(const d of o)d.paragraphStyle||(d.paragraphStyle={}),d.paragraphStyle.horizontalAlign=r;return new Nt(n)}dispose(){super.dispose(),this._rowHeightAccumulation=[],this._columnWidthAccumulation=[],this._rowTotalHeight=0,this._columnTotalWidth=0,this._rowHeaderWidth=0,this._columnHeaderHeight=0,this._worksheetData=null,this._cellData=null,this._styles=null}};exports.SheetSkeleton=dI([as(2,Ae.Inject(Cn)),as(3,Jn),as(4,oa),as(5,Ae.Inject(Ae.Injector))],exports.SheetSkeleton);function ha(e,t,n,r){const s=e-1,i=t-1,o=n[s]||0;let a=n[e];a==null&&(a=n[n.length-1]);const l=r[i]||0;let c=r[t];return c==null&&(c=r[r.length-1]),{startY:o,endY:a,startX:l,endX:c}}function fI(e,t,n,r){return ha(e,t,n,r)}function Un(e,t,n,r,s){e=q.clamp(e,0,n.length-1),t=q.clamp(t,0,r.length-1);let{startY:i,endY:o,startX:a,endX:l}=ha(e,t,n,r);if(!s)return{startY:i,endY:o,startX:a,endX:l,isMerged:!1,isMergedMainCell:!1,actualRow:e,actualColumn:t,mergeInfo:{startY:i,endY:o,startX:a,endX:l,startRow:e,startColumn:t,endRow:e,endColumn:t}};const{isMerged:c,isMergedMainCell:u,startRow:h,startColumn:d,endRow:f,endColumn:g}=s;let _={startRow:h,startColumn:d,endRow:f,endColumn:g,startY:i,endY:o,startX:a,endX:l};const R=n.length-1,b=r.length-1;if(c&&h!==-1&&d!==-1){const F=n[h-1]||0,k=n[f]||n[R],W=r[d-1]||0,S=r[g]||r[b];_={..._,startY:F,endY:k,startX:W,endX:S}}else if(!c&&f!==-1&&g!==-1){const F=n[f]||n[R],k=r[g]||r[b];_={..._,startY:i,endY:F,startX:a,endX:k}}return{isMerged:c,isMergedMainCell:u,actualRow:e,actualColumn:t,startY:i,endY:o,startX:a,endX:l,mergeInfo:_}}function fd(e,t,n,r){const{x:s}=n;return e/t+s-r}function md(e,t,n,r){const{y:s}=n;return e=e/t+s-r,e}const mI=["script","style","meta","comment","link"];var gd=(e=>(e[e.INFO=0]="INFO",e[e.STOP=1]="STOP",e[e.WARNING=2]="WARNING",e))(gd||{}),_d=(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))(_d||{}),pd=(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))(pd||{}),Ed=(e=>(e[e.TEXT=0]="TEXT",e[e.ARROW=1]="ARROW",e[e.CUSTOM=2]="CUSTOM",e))(Ed||{}),Cd=(e=>(e.VALID="valid",e.INVALID="invalid",e.VALIDATING="validating",e))(Cd||{}),Rd=(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))(Rd||{}),gI=Object.getOwnPropertyDescriptor,_I=(e,t,n,r)=>{for(var s=r>1?void 0:r?gI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},bl=(e,t)=>(n,r)=>t(n,r,e);let so=class extends Ke{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){const e=n=>{n.businesses.forEach(r=>{switch(r){case ve.UNRECOGNIZED:case ve.UNIVER_UNKNOWN:case ve.UNIVER_SLIDE:case ve.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType(ve.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 ve.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(ve.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$(ve.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(ve.UNIVER_DOC).subscribe(n=>{const r=n.getUnitId();Dl(r)||this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(ve.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(ve.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=q.deepClone(t.getSnapshot());return r.resources=n,r}};so=_I([bl(0,Ae.Inject(Js)),bl(1,Ae.Inject(Xn))],so);class pI{constructor(t={},n){p(this,"_startedTypes",new Set);p(this,"_injector");p(this,"_disposingCallbacks",new js);const r=this._injector=EI(n,t==null?void 0:t.override),{theme:s,darkMode:i,locale:o,locales:a,logLevel:l}=t;s&&this._injector.get(Ps).setTheme(s),i&&this._injector.get(Ps).setDarkMode(i),a&&this._injector.get(Cn).load(a),o&&this._injector.get(Cn).setLocale(o),l&&this._injector.get(Et).setLogLevel(l),this._init(r)}get _univerInstanceService(){return this._injector.get(Xn)}get _pluginService(){return this._injector.get(exports.PluginService)}__getInjector(){return this._injector}onDispose(t){const n=this._disposingCallbacks.add(We(t));return We(()=>n.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(t){this._injector.get(Cn).setLocale(t)}createUnit(t,n){return this._univerInstanceService.createUnit(t,n)}createUniverSheet(t){return this._injector.get(Et).warn("[Univer]","Univer.createUniverSheet is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(ve.UNIVER_SHEET,t)}createUniverDoc(t){return this._injector.get(Et).warn("[Univer]","Univer.createUniverDoc is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(ve.UNIVER_DOC,t)}createUniverSlide(t){return this._injector.get(Et).warn("[Univer]","Univer.createUniverSlide is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(ve.UNIVER_SLIDE,t)}_init(t){this._univerInstanceService.registerCtorForType(ve.UNIVER_SHEET,exports.Workbook),this._univerInstanceService.registerCtorForType(ve.UNIVER_DOC,Nt),this._univerInstanceService.registerCtorForType(ve.UNIVER_SLIDE,la);const n=t.get(Xn);n.__setCreateHandler((r,s,i,o)=>{if(!this._startedTypes.has(r)){this._pluginService.startPluginsForType(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<Ue.Ready&&(this._injector.get(exports.LifecycleService).stage=Ue.Ready)}registerPlugin(t,n){this._pluginService.registerPlugin(t,n)}registerPlugins(t){t.forEach(n=>{const[r,s]=n;this._pluginService.registerPlugin(r,s)})}}function EI(e,t){const n=sd([[kh],[Cn],[Ps],[exports.LifecycleService],[exports.PluginService],[Dr],[Xn,{useClass:exports.UniverInstanceService}],[nd,{useClass:rd}],[Et,{useClass:cu,lazy:!0}],[Hr,{useClass:exports.CommandService}],[Qs,{useClass:exports.LocalUndoRedoService,lazy:!0}],[oa,{useClass:xh}],[Jn,{useClass:au}],[Js,{useClass:exports.ResourceManagerService,lazy:!0}],[no,{useClass:so,lazy:!0}],[Dh,{useClass:exports.AuthzIoLocalService}],[td,{useClass:exports.MentionIOLocalService,lazy:!0}]],t),r=e?e.createChild(n):new Ae.Injector(n);return xl(r,[[Dr],[no]]),r}Ad();exports.ABCToNumber=$0;exports.AUTO_HEIGHT_FOR_MERGED_CELLS=Ll;exports.AbsoluteRefType=Ne;exports.ActionIterator=xn;exports.AlignTypeH=Zc;exports.AlignTypeV=Jc;exports.ArrangeTypeEnum=tu;exports.ArrowsAndMarkersShapes=Oc;exports.AsyncInterceptorManager=Kd;exports.AsyncLock=kd;exports.AutoFillSeries=dc;exports.BaselineOffset=Yt;exports.BasicShapes=Sc;exports.BlockType=Mc;exports.BooleanNumber=ie;exports.BorderStyleTypes=De;exports.BorderType=fc;exports.BuildTextUtils=Qe;exports.BulletAlignment=Br;exports.COLORS=xi;exports.CanceledError=jd;exports.CellModeEnum=Fn;exports.CellValueType=en;exports.Color=Sn;exports.ColorBuilder=Vs;exports.ColorKit=At;exports.ColorType=pt;exports.ColumnSeparatorType=xc;exports.CommandType=$r;exports.CommonHideTypes=mc;exports.ConfigService=xh;exports.ContextService=au;exports.CopyPasteType=gc;exports.CustomCommandExecutionError=Ss;exports.CustomDecorationType=pn;exports.CustomRangeType=rn;exports.DEFAULT_CELL=_0;exports.DEFAULT_DOC=ra;exports.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=eR;exports.DEFAULT_EMPTY_DOCUMENT_VALUE=Nl;exports.DEFAULT_NUMBER_FORMAT=Qu;exports.DEFAULT_RANGE=m0;exports.DEFAULT_RANGE_ARRAY=f0;exports.DEFAULT_SELECTION=g0;exports.DEFAULT_SLIDE=eh;exports.DEFAULT_STYLES=st;exports.DEFAULT_TEXT_FORMAT=Zu;exports.DEFAULT_TEXT_FORMAT_EXCEL=Ju;exports.DEFAULT_WORKSHEET_COLUMN_COUNT=Yh;exports.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=AR;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Kh;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=MR;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH=Vh;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=yR;exports.DEFAULT_WORKSHEET_ROW_COUNT=Wh;exports.DEFAULT_WORKSHEET_ROW_COUNT_KEY=bR;exports.DEFAULT_WORKSHEET_ROW_HEIGHT=Gh;exports.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=TR;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=zh;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=NR;exports.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=oo;exports.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=io;exports.DOCS_ZEN_EDITOR_UNIT_ID_KEY=yl;exports.DOC_DRAWING_PRINTING_COMPONENT_KEY=I0;exports.DOC_RANGE_TYPE=Iu;exports.DashStyleType=$c;exports.DataStreamTreeNodeType=Ah;exports.DataStreamTreeTokenType=at;exports.DataValidationErrorStyle=gd;exports.DataValidationImeMode=_d;exports.DataValidationOperator=pd;exports.DataValidationRenderMode=Ed;exports.DataValidationStatus=Cd;exports.DataValidationType=Rd;exports.DeleteDirection=_c;exports.DependentOn=ZR;exports.DesktopLogService=cu;exports.DeveloperMetadataVisibility=pc;exports.Dimension=Ec;exports.Direction=Cc;exports.Disposable=Ke;exports.DisposableCollection=js;exports.DocStyleType=yc;exports.DocumentDataModel=Nt;exports.DocumentFlavor=Eo;exports.DrawingTypeEnum=nu;exports.EDITOR_ACTIVATED=Uh;exports.EXTENSION_NAMES=th;exports.ErrorService=kh;exports.EventState=Lh;exports.EventSubject=tR;exports.FOCUSING_COMMON_DRAWINGS=dR;exports.FOCUSING_DOC=Rr;exports.FOCUSING_EDITOR_BUT_HIDDEN=oR;exports.FOCUSING_EDITOR_INPUT_FORMULA=aR;exports.FOCUSING_EDITOR_STANDALONE=cR;exports.FOCUSING_FX_BAR_EDITOR=Ph;exports.FOCUSING_PANEL_EDITOR=uR;exports.FOCUSING_SHEET=Hn;exports.FOCUSING_SLIDE=Ir;exports.FOCUSING_UNIT=Cr;exports.FOCUSING_UNIVER_EDITOR=lR;exports.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=hR;exports.FORMULA_EDITOR_ACTIVATED=fR;exports.FollowNumberWithType=Nc;exports.FontItalic=bs;exports.FontStyleType=kn;exports.FontWeight=As;exports.GridType=Lc;exports.HLSColor=_u;exports.HorizontalAlign=Tt;exports.IAuthzIoService=Dh;exports.ICommandService=Hr;exports.IConfigService=oa;exports.IContextService=Jn;exports.IImageIoService=Qi;exports.ILocalStorageService=WR;exports.ILogService=Et;exports.IMentionIOService=td;exports.IPermissionService=nd;exports.IResourceLoaderService=no;exports.IResourceManagerService=Js;exports.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=Ml;exports.IUndoRedoService=Qs;exports.IUniverInstanceService=Xn;exports.ImageCacheMap=hd;exports.ImageSourceType=aa;exports.ImageUploadStatusType=Fh;exports.InterceptorEffectEnum=Pn;exports.InterceptorManager=Gd;exports.InterpolationPointType=Rc;exports.JSON1=x_;exports.JSONX=Gt;exports.LRUHelper=ur;exports.LRUMap=yr;exports.LifecycleStages=Ue;exports.LifecycleUnreachableError=Qh;exports.ListGlyphType=fe;exports.LocaleService=Cn;exports.LocaleType=Fr;exports.LogLevel=lu;exports.MOVE_BUFFER_VALUE=cr;exports.MemoryCursor=vn;exports.MentionType=ws;exports.NAMED_STYLE_MAP=E0;exports.NAMED_STYLE_SPACE_MAP=C0;exports.NamedStyleType=Xe;exports.NilCommand=uu;exports.NumberUnitType=qc;exports.ObjectMatrix=dt;exports.ObjectRelativeFromH=Kc;exports.ObjectRelativeFromV=Xc;exports.OtherShapes=vc;exports.PAGE_SIZE=S0;exports.PAPER_TYPES=w_;exports.PRESET_LIST_TYPE=Yr;exports.PRINT_CHART_COMPONENT_KEY=R0;exports.PageElementType=ru;exports.PageOrientType=eu;exports.PageType=Co;exports.PaperType=ct;exports.ParagraphElementType=Pc;exports.ParagraphStyleBuilder=Lr;exports.ParagraphStyleValue=Vr;exports.PermissionService=rd;exports.PermissionStatus=ca;exports.Plugin=to;exports.PositionedObjectLayoutType=Fc;exports.PresetListType=kt;exports.ProtectionType=Ic;exports.QuickListType=Eh;exports.QuickListTypeMap=Z0;exports.RANGE_DIRECTION=Ru;exports.RANGE_TYPE=_e;exports.RBush=Ls;exports.RCDisposable=u_;exports.RGBA_PAREN=q_;exports.RGB_PAREN=X_;exports.ROTATE_BUFFER_VALUE=mu;exports.RTree=iI;exports.Range=Kn;exports.Rectangle=on;exports.RedoCommand=ud;exports.RedoCommandId=ad;exports.RefAlias=B0;exports.Registry=go;exports.RegistryAsMap=_o;exports.RelativeDate=bc;exports.RelativeSlideLink=su;exports.RgbColor=Ts;exports.RichTextBuilder=En;exports.RichTextValue=Qt;exports.RxDisposable=c_;exports.SHEET_EDITOR_UNITS=p0;exports.SectionType=Dc;exports.SheetTypes=Ac;exports.SheetViewModel=qh;exports.SliceBodyType=na;exports.SlideDataModel=la;exports.SpacingRule=Bc;exports.SpecialShapes=wc;exports.Styles=Bh;exports.THEME_COLORS=gu;exports.TabStopAlignment=Hc;exports.TableAlignmentType=Wc;exports.TableLayoutType=Yc;exports.TableRowHeightRule=Vc;exports.TableSizeType=jc;exports.TableTextWrapType=Gc;exports.TextDecoration=Tc;exports.TextDecorationBuilder=Jt;exports.TextDirection=Tr;exports.TextDirectionType=Uc;exports.TextStyleBuilder=nn;exports.TextStyleValue=Gr;exports.TextX=Me;exports.TextXActionType=Z;exports.ThemeColor=ys;exports.ThemeColorType=it;exports.ThemeColors=Ys;exports.ThemeService=Ps;exports.Tools=q;exports.UndoCommand=cd;exports.UndoCommandId=ld;exports.UnitModel=Ws;exports.Univer=pI;exports.UniverInstanceType=ve;exports.UpdateDocsAttributeType=Ee;exports.UserManagerService=Dr;exports.VerticalAlign=_n;exports.VerticalAlignmentType=zc;exports.Worksheet=xr;exports.WrapStrategy=In;exports.WrapTextType=kc;exports.addLinkToDocumentModel=$h;exports.afterInitApply=Y_;exports.afterTime=j_;exports.awaitTime=oI;exports.binSearchFirstGreaterThanTarget=fu;exports.binarySearchArray=G_;exports.bufferDebounceTime=H_;exports.cellToRange=bp;exports.characterSpacingControlType=Qc;exports.checkForSubstrings=Tp;exports.checkIfMove=z_;exports.checkParagraphHasBullet=uE;exports.checkParagraphHasIndent=hE;exports.checkParagraphHasIndentByStyle=bu;exports.codeToBlob=V_;exports.composeBody=Xi;exports.composeInterceptors=Pl;exports.composeStyles=ar;exports.concatMatrixArray=gp;exports.convertBodyToHtml=K_;exports.convertCellToRange=Su;exports.convertObservableToBehaviorSubject=W_;exports.covertCellValue=Bi;exports.covertCellValues=Ap;exports.covertTextRunToHtml=Di;exports.createAsyncInterceptorKey=Vd;exports.createDefaultUser=Us;exports.createDocumentModelWithStyle=Sr;exports.createInterceptorKey=Yd;exports.createInternalEditorID=$d;exports.createRowColIter=Vi;exports.dayjs=zt;exports.debounce=Xg;exports.dedupe=Td;exports.dedupeBy=yd;exports.deepCompare=Io;exports.delayAnimationFrame=aI;exports.deleteContent=Tu;exports.extractPureTextFromCell=Zh;exports.fromCallback=hu;exports.fromEventSubject=nR;exports.fromObservable=l_;exports.generateRandomId=tt;exports.get=nc;exports.getArrayLength=tn;exports.getBodySlice=yt;exports.getBodySliceHtml=cs;exports.getBorderStyleType=Op;exports.getCellCoordByIndexSimple=ha;exports.getCellInfoInMergeData=fp;exports.getCellPositionByIndexSimple=fI;exports.getCellValueType=up;exports.getCellWithCoordByIndexCore=Un;exports.getColorStyle=Dt;exports.getCustomBlockSlice=Sh;exports.getCustomDecorationSlice=vh;exports.getCustomRangeSlice=Oh;exports.getDocsUpdateBody=vp;exports.getIntersectRange=rh;exports.getOriginCellValue=DR;exports.getParagraphsSlice=Ih;exports.getPlainText=Zs;exports.getReverseDirection=v_;exports.getSectionBreakSlice=oC;exports.getTableSlice=Rh;exports.getTextRunSlice=xs;exports.getTransformOffsetX=fd;exports.getTransformOffsetY=md;exports.getWorksheetUID=kR;exports.groupBy=Ld;exports.handleStyleToString=Sp;exports.hashAlgorithm=fE;exports.horizontalLineSegmentsSubtraction=zs;exports.insertMatrixArray=Ui;exports.insertTextToContent=Au;exports.invertColorByHSL=ef;exports.invertColorByMatrix=nf;exports.isBlackColor=lp;exports.isBooleanString=Bd;exports.isCellCoverable=Fi;exports.isCellV=Cu;exports.isDefaultFormat=h0;exports.isEmptyCell=Ou;exports.isFormulaId=Ip;exports.isFormulaString=vu;exports.isICellData=Eu;exports.isInternalEditorID=Dl;exports.isNodeEnv=O_;exports.isNotNullOrUndefined=Hh;exports.isNullCell=hp;exports.isNumeric=oc;exports.isPatternEqualWithoutDecimal=d0;exports.isRangesEqual=pR;exports.isRealNum=dE;exports.isSafeNumeric=r_;exports.isSameStyleTextRun=wu;exports.isTextFormat=u0;exports.isUnitRangesEqual=ER;exports.isValidRange=wp;exports.isWhiteColor=cp;exports.makeArray=Dd;exports.makeCellRangeToRangeData=Rp;exports.makeCellToSelection=Cp;exports.makeCustomRangeStream=RC;exports.mapObjectMatrix=mp;exports.merge=Hs;exports.mergeLocales=mE;exports.mergeOverrideWithDependencies=sd;exports.mergeSets=o_;exports.mergeWith=Qg;exports.mergeWorksheetSnapshotWithDefault=Xh;exports.mixinClass=n_;exports.moveMatrixArray=ki;exports.moveRangeByOffset=y0;exports.nameCharacterCheck=sI;exports.normalizeBody=aC;exports.normalizeTextRuns=Wr;exports.numberToABC=j0;exports.numberToListABC=W0;exports.numfmt=c0;exports.queryObjectMatrix=F0;exports.registerDependencies=Hd;exports.remove=Ur;exports.repeatStringNumTimes=ih;exports.replaceInDocumentBody=JC;exports.requestImmediateMacroTask=i_;exports.rotate=Md;exports.searchArray=lr;exports.searchInOrderedArray=du;exports.selectionToArray=dp;exports.sequence=lc;exports.sequenceAsync=ac;exports.sequenceExecute=Gs;exports.sequenceExecuteAsync=$_;exports.set=t_;exports.shallowEqual=Ul;exports.skipParseTagNames=mI;exports.sliceMatrixArray=_p;exports.sortRules=Y0;exports.sortRulesByDesc=G0;exports.sortRulesFactory=jr;exports.spliceArray=Pi;exports.splitIntoGrid=ea;exports.takeAfter=Li;exports.textDiff=sa;exports.throttle=Wd;exports.toDisposable=We;exports.touchDependencies=xl;exports.updateAttributeByDelete=wh;exports.updateAttributeByInsert=bh;exports.willLoseNumericPrecision=s_;Object.keys(Ae).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>Ae[e]})});
8
+ `,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(n){return new En(n!=null?n:En.newEmptyData())}insertText(n,r,s){var u,h;let i=((h=(u=this._data.body)==null?void 0:u.dataStream.length)!=null?h:2)-2,o,a;if(typeof n=="string"?o=n:(i=Math.min(n,i),o=r),typeof r=="object"?a=r instanceof nn?r.build():r:a=s instanceof nn?s.build():s,!o)return this;const l={dataStream:o,textRuns:a?[{ts:a,st:i,ed:i+o.length}]:[]},c=Qe.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:l});if(!c)throw new Error("Insert text failed, please check.");return Me.apply(this._doc.getBody(),c.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 Qt?n.getData():n:(s=Math.min(n,s),i=r instanceof Qt?r.getData():r);const o=Qe.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 Me.apply(this._doc.getBody(),o.serialize()),this}delete(n,r){if(r!==void 0){if(!r)return this;const s=Qe.selection.delete([{startOffset:n,endOffset:n+r,collapsed:!0}],this._data.body);Me.apply(this._doc.getBody(),s)}return this}setStyle(n,r,s){const i={dataStream:"",textRuns:[{ts:s instanceof nn?s.build():s,st:0,ed:r-n}]},o=Qe.selection.retain([{startOffset:n,endOffset:r,collapsed:!0}],i);return Me.apply(this._doc.getBody(),o),this}setLink(n,r,s){const i=Qe.customRange.add({rangeType:rn.HYPERLINK,rangeId:tt(),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 Me.apply(this._doc.getBody(),i.serialize()),this}cancelLink(n,r){if(typeof n=="string"){const s=Qe.customRange.delete({rangeId:n,documentDataModel:this._doc});if(!s)throw new Error("Insert text failed, please check.");Me.apply(this._doc.getBody(),s.serialize())}else this.slice(n,r).getLinks().forEach(i=>{const o=Qe.customRange.delete({rangeId:i.rangeId,documentDataModel:this._doc});if(!o)throw new Error("Insert text failed, please check.");Me.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,Qt.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=En.createByBody({dataStream:i,customRanges:[{rangeType:rn.HYPERLINK,rangeId:tt(),properties:{url:o},startIndex:0,endIndex:i.length-1}]});return typeof n=="number"?this.insertRichText(n,a):this.insertRichText(a)}}const eR="__default_document_sub_component_id20231101__";class Lh{constructor(){p(this,"skipNextObservers",!1);p(this,"lastReturnValue");p(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class tR extends ce.Subject{constructor(){super(...arguments);p(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 Lh;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 nR(e){return new ce.Observable(t=>{const n=e.subscribeEvent(r=>{t.next(r)});return()=>n.unsubscribe()})}const Js=Ae.createIdentifier("core.resource-manager.service"),Ji={[Ut.Editor]:"Editor",[Ut.Owner]:"Owner",[Ut.Reader]:"Reader",[Ut.UNRECOGNIZED]:"UNRECOGNIZED"},Us=e=>e?{userID:`${Ji[e]}_${tt(8)}`,name:Ji[e],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},rR=(e,t)=>e.startsWith(Ji[t]);class Dr extends Ke{constructor(){super(...arguments);p(this,"_model",new Map);p(this,"_userChange$",new ce.Subject);p(this,"userChange$",this._userChange$.asObservable());p(this,"_currentUser$",new ce.BehaviorSubject(Us()));p(this,"currentUser$",this._currentUser$.asObservable())}dispose(){super.dispose(),this._model.clear(),this._userChange$.complete(),this._currentUser$.complete()}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(n){this.addUser(n),this._currentUser$.next(n)}addUser(n){this._model.set(n.userID,n),this._userChange$.next({type:"add",user:n})}getUser(n,r){const s=this._model.get(n);if(s)return s;r&&r()}delete(n){const r=this.getUser(n);this._model.delete(n),r&&this._userChange$.next({type:"delete",user:r})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}list(){return Array.from(this._model.values())}}var sR=Object.getOwnPropertyDescriptor,iR=(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=o(s)||s);return s},El=(e,t)=>(n,r)=>t(n,r,e);exports.AuthzIoLocalService=class{constructor(t,n){p(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(Us(Ut.Owner))}_getRole(t){const n=this._userManagerService.getCurrentUser();return n?rR(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:[ve.UNIVER_SHEET,ve.UNIVER_DOC,ve.UNIVER_SLIDE],onLoad:(t,n)=>{for(const r in n)this._permissionMap.set(r,n[r])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(t){return tt(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:Ut.Owner,shareScope:-1,scope:{read:Ni.AllCollaborator,edit:Ni.AllCollaborator},creator:Us(Ut.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(Ut.Owner)||this._getRole(Ut.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=iR([El(0,Js),El(1,Ae.Inject(Dr))],exports.AuthzIoLocalService);const Dh=Ae.createIdentifier("IAuthzIoIoService"),oa=Ae.createIdentifier("univer.config-service");class xh{constructor(){p(this,"_configChanged$",new ce.Subject);p(this,"configChanged$",this._configChanged$.asObservable());p(this,"_config",new Map)}dispose(){this._config.clear(),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=Hs(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 ce.Observable(n=>{Object.prototype.hasOwnProperty.call(this._config,t)&&n.next(this._config.get(t));const r=this.configChanged$.pipe(ce.filter(s=>Object.prototype.hasOwnProperty.call(s,t))).subscribe(s=>n.next(s[t]));return()=>r.unsubscribe()})}}const Cr="FOCUSING_UNIT",Hn="FOCUSING_SHEET",Rr="FOCUSING_DOC",Ir="FOCUSING_SLIDE",oR="FOCUSING_EDITOR_BUT_HIDDEN",Uh="EDITOR_ACTIVATED",aR="FOCUSING_EDITOR_INPUT_FORMULA",Ph="FOCUSING_FX_BAR_EDITOR",lR="FOCUSING_UNIVER_EDITOR",cR="FOCUSING_EDITOR_INPUT_FORMULA",uR="FOCUSING_PANEL_EDITOR",hR="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",dR="FOCUSING_COMMON_DRAWINGS",fR="FORMULA_EDITOR_ACTIVATED";class kh extends Ke{constructor(){super(...arguments);p(this,"_error$",new ce.Subject);p(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(n){this._error$.next({errorKey:n})}}var aa=(e=>(e.URL="URL",e.UUID="UUID",e.BASE64="BASE64",e))(aa||{}),Fh=(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))(Fh||{});const Qi=Ae.createIdentifier("core.image-io.service"),mR="0.10.1",gR={version:mR};function _R(e="",t=Fr.ZH_CN,n=""){return{id:e,sheetOrder:[],name:n,appVersion:gR.version,locale:t,styles:{},sheets:{},resources:[]}}class Bh{constructor(t={}){p(this,"_styles");p(this,"_cacheMap",new yr(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=tt(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&&q.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(q.diffValue(n[r],t))return r;return null}}const pR=(e,t)=>t.length===e.length&&!e.some(n=>t.some(r=>!on.equals(r,n))),ER=(e,t)=>t.length===e.length&&e.every((n,r)=>{const s=t[r];return s.unitId===n.unitId&&s.sheetId===n.sheetId&&on.equals(n.range,s.range)}),eo={t:0,b:2,l:2,r:2},CR=e=>({sbr:.6,sbo:e,spr:.6,spo:e}),Cl=90;function Sr(e,t,n={}){const r=e.length,{textRotation:s,paddingData:i,horizontalAlign:o=Tt.UNSPECIFIED,verticalAlign:a=_n.UNSPECIFIED,wrapStrategy:l=In.UNSPECIFIED,cellValueType:c}=n,{t:u,r:h,b:d,l:f}=i||eo,{vertexAngle:g,centerAngle:_}=jh(s),R={id:"d",body:{dataStream:`${e}${Nl}`,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:u,marginBottom:d,marginRight:h,marginLeft:f,renderConfig:{horizontalAlign:o,verticalAlign:a,centerAngle:_,vertexAngle:g,wrapStrategy:l,cellValueType:c,zeroWidthParagraphBreak:1}},drawings:{},drawingsOrder:[]};return new Nt(R)}function RR(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 Rl(e){if(!e)return{};const{ff:t,fs:n,it:r,bl:s,ul:i,st:o,ol:a,cl:l}=e,c={};return t&&(c.ff=t),n&&(c.fs=n),r&&(c.it=r),s&&(c.bl=s),i&&(c.ul=i),o&&(c.st=o),a&&(c.ol=a),l&&(c.cl=l),c}function $h(e,t,n){var i;const r=e.getBody();if((i=r.customRanges)!=null&&i.some(o=>o.rangeType===rn.HYPERLINK))return;const s=Qe.customRange.add({ranges:[{startOffset:0,endOffset:r.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:rn.HYPERLINK,body:r,properties:{url:t,refId:n}});s&&Me.apply(r,s.serialize())}function Hh(e){return e!=null}const IR='"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';function Il(e){const t=st.ff,n=st.fs;if(!e){const h=`${n}pt ${t}`;return{fontCache:h,fontString:h,fontSize:n,originFontSize:n,fontFamily:t}}let r=kn.ITALIC;(e.it===0||e.it===void 0)&&(r=kn.NORMAL);let s=kn.BOLD;(e.bl===0||e.bl===void 0)&&(s=kn.NORMAL);let i=n;e.fs&&(i=Math.ceil(e.fs));let o=t;if(e.ff){let h=e.ff;h=h.replace(/"/g,"").replace(/'/g,""),h.indexOf(" ")>-1&&(h=`"${h}"`),h==null&&(h=t),o=h}const{va:a}=e;let l=i;if(a===Yt.SUBSCRIPT||a===Yt.SUPERSCRIPT){const h=SR(o,l),{sbr:d,spr:f}=h;l*=a===Yt.SUBSCRIPT?d:f}const c=`${r} ${s} ${l}pt ${o}`,u=`${c}, ${IR} `;return{fontCache:c,fontString:u,fontSize:l,originFontSize:i,fontFamily:o}}function SR(e,t){return CR(t)}function jh(e){const{a:t=0,v:n=ie.FALSE}=e||{a:0,v:ie.FALSE};let r=0,s=t;return n===ie.TRUE&&(r=Cl,s=Cl),{centerAngle:r,vertexAngle:s}}class OR{constructor(t,n){p(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!==ie.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:_e.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:_e.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:_e.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:_e.COLUMN}),r}getColumnDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getColumn(i);r[s]=o!=null?o:{w:this._config.defaultColumnWidth,hd:ie.FALSE},s++}return r}getSize(){return tn(this._columnData)}getColumnWidth(t){var n,r;return(r=(n=this._columnData[t])==null?void 0:n.w)!=null?r:this._config.defaultColumnWidth}setColumnWidth(t,n){const r=this._columnData[t];n===this._config.defaultColumnWidth?r&&(delete r.w,Object.keys(r).length===0&&delete this._columnData[t]):this._columnData[t]=r?{...r,w:n}:{w:n}}getColumn(t){return this._columnData[t]}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}}const vR=2e3;class wR{constructor(t,n,r){p(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.getRow(i);r[s]=o!=null?o:{h:this._config.defaultRowHeight,hd:ie.FALSE},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:ie.FALSE,h:s.defaultRowHeight},{ia:l,ah:c,h:u=s.defaultRowHeight}=a;i+=(l==null||l===ie.TRUE)&&typeof c=="number"?c:u}return i}setRowHeight(t,n){const r=this._rowData[t];if(n===this._config.defaultRowHeight)r&&(delete r.h,Object.keys(r).length===0&&delete this._rowData[t]);else{const s=Math.min(n,vR);this._rowData[t]=r?{...r,h:s}:{h:s}}}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:_e.ROW})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:_e.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:_e.ROW})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:_e.ROW}),r}getRowRawVisible(t){const n=this.getRow(t);return n?n.hd!==ie.TRUE:!0}getSize(){return tn(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 bR="DEFAULT_WORKSHEET_ROW_COUNT",Wh=1e3,AR="DEFAULT_WORKSHEET_COLUMN_COUNT",Yh=20,TR="DEFAULT_WORKSHEET_ROW_HEIGHT",Gh=24,yR="DEFAULT_WORKSHEET_COLUMN_WIDTH",Vh=88,NR="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",zh=46,MR="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Kh=20;function Xh(e){const t={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:ie.FALSE,rowCount:Wh,columnCount:Yh,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Vh,defaultRowHeight:Gh,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:ie.TRUE,rowHeader:{width:zh,hidden:ie.FALSE},columnHeader:{height:Kh,hidden:ie.FALSE},rightToLeft:ie.FALSE};return Object.keys(t).forEach(n=>{const r=n;typeof e[r]>"u"&&(e[r]=t[r])}),e}class LR extends Ke{constructor(n){super();p(this,"_cellCache",new Map);p(this,"_rowCache",new Map);p(this,"_columnCache",new Map);p(this,"_hasRow",!1);p(this,"_hasColumn",!1);p(this,"_hasAll",!1);p(this,"_allIndex",-1);p(this,"_mergeData");p(this,"_rangeMap",new yr(5e4));p(this,"_skeletonCache",new yr(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===_e.ROW?this._createRowCache(s,r):i===_e.COLUMN?this._createColumnCache(s,r):i===_e.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||!q.isEmptyObject(this._columnCache)?!0:this._mergeData.some(r=>r.startRow<=n&&n<=r.endRow)}isColumnContainsMergedCell(n){return this._hasAll||!q.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 c=[];for(const u of this._mergeData||[])on.intersects(u,{startRow:n,endRow:s,startColumn:r,endColumn:i})&&(o.push({...u}),c.push(l)),l++;return this._rangeMap.set(a,c),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 c=[];for(let u=0;u<a.length;u++){const{startRow:h,endRow:d,startColumn:f,endColumn:g}=a[u];for(let _=n;_<=s;_++){let R=!1;for(let b=r;b<=i;b++)if(_>=h&&_<=d&&b>=f&&b<=g){o.push({startRow:h,endRow:d,startColumn:f,endColumn:g}),c.push(u),R=!0;break}if(R)break}}return this._skeletonCache.set(l,c),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 qh extends Ke{constructor(n){super();p(this,"_cellContentInterceptor",null);p(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,Pn.Value|Pn.Style,s,i):this.getRawCell(n,r)}getCellValueOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,Pn.Value):this.getRawCell(n,r)}getCellStyleOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,Pn.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,We(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(n){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=n,We(()=>this._rowFilteredInterceptor=null)}}const Sl={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};class xr{constructor(t,n,r){p(this,"_sheetId");p(this,"_snapshot");p(this,"_cellData");p(this,"_rowManager");p(this,"_columnManager");p(this,"_viewModel");p(this,"_spanModel");p(this,"_isRowStylePrecedeColumnStyle",!0);p(this,"_getCellHeight");var a;this.unitId=t,this._styles=r,this._snapshot=Xh(n);const{columnData:s,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:tt(6),this._cellData=new dt(o),this._viewModel=new qh((l,c)=>this.getCellRaw(l,c)),this._rowManager=new wR(this._snapshot,this._viewModel,i),this._columnManager=new OR(this._snapshot,s),this._spanModel=new LR(this._snapshot.mergeData)}__interceptViewModel(t){t(this._viewModel)}__registerGetCellHeight(t){return this._getCellHeight=t,We(()=>{this._getCellHeight=null})}getSnapshot(){return this._snapshot}getCellHeight(t,n){return this._getCellHeight?this._getCellHeight(t,n):this._snapshot.defaultRowHeight}setMergeData(t){this._snapshot.mergeData=t,this.getSpanModel().rebuild(t)}getSpanModel(){return this._spanModel}setIsRowStylePrecedeColumnStyle(t){this._isRowStylePrecedeColumnStyle=t}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)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){const t=this._snapshot.defaultStyle;return this._styles.get(t)}setDefaultCellStyle(t){this._snapshot.defaultStyle=t}getCellStyle(t,n){const r=this.getCell(t,n);if(r){const s=r.s;return typeof s=="string"?this._styles.get(s):s}return null}getComposedCellStyle(t,n,r){const s=this.getDefaultCellStyleInternal(),i=this.getRowStyle(t),o=this.getColumnStyle(n),a=this.getCell(t,n),l=this._styles.getStyleByCell(a);return(r!=null?r:this._isRowStylePrecedeColumnStyle)?ar(s,o,i,a==null?void 0:a.themeStyle,l):ar(s,i,o,a==null?void 0:a.themeStyle,l)}getComposedCellStyleByCellData(t,n,r,s){const i=this.getDefaultCellStyleInternal(),o=this.getRowStyle(t),a=this.getColumnStyle(n),l=this._styles.getStyleByCell(r);return(s!=null?s:this._isRowStylePrecedeColumnStyle)?ar(i,a,o,r==null?void 0:r.themeStyle,l):ar(i,o,a,r==null?void 0:r.themeStyle,l)}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((c,u)=>{Object.keys(u).forEach(h=>{const d=+h,f=t.getValue(c,d),g=f!=null&&f.s?this._styles.get(f.s):null,_=(g==null?void 0:g.bd)&&(g.bd.b||g.bd.l||g.bd.r||g.bd.t||g.bd.bc_tr||g.bd.bl_tr||g.bd.ml_tr||g.bd.tl_bc||g.bd.tl_br||g.bd.tl_mr);(f&&(f.v||f.p)||g!=null&&g.bg||_)&&(a?r=Math.min(r,c):(r=c,a=!0),s=Math.max(s,c),l?i=Math.min(i,d):(l=!0,i=d),o=Math.max(o,d))})}),n.forEach(c=>{a?r=Math.min(r,c.startRow):(r=c.startRow,a=!0),s=Math.max(s,c.endRow),l?i=Math.min(i,c.startColumn):(i=c.startColumn,a=!0),o=Math.max(o,c.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=q.deepClone(t);return new xr(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,c=n;if(r){const{startRow:u,endRow:h,startColumn:d,endColumn:f}=r;t===u&&n===d?(o=h,a=f,l=u,c=d,i=!0):t>=u&&t<=h&&n>=d&&n<=f&&(o=h,a=f,l=u,c=d,s=!0)}return{actualRow:t,actualColumn:n,isMergedMainCell:i,isMerged:s,endRow:o,endColumn:a,startRow:l,startColumn:c}}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)}getRangeFilterRows(t){const n=[];for(let r=t.startRow;r<=t.endRow;r++)this.getRowFiltered(r)&&n.push(r);return n}getMatrixWithMergedCells(t,n,r,s,i=Fn.Raw){const o=this.getCellMatrix(),a=this._spanModel.getMergedCellRange(t,n,r,s),l=new dt;return Vi(t,r,n,s).forEach((c,u)=>{var d;let h;if(i===Fn.Raw)h=this.getCellRaw(c,u);else if(i===Fn.Intercepted)h=this.getCell(c,u);else if(i===Fn.Both){const f=this.getCellRaw(c,u);if(f){h={...f};const g=(d=this.getCell(c,u))==null?void 0:d.v;Hh(g)&&h&&(h.displayV=String(g))}}h&&l.setValue(c,u,h)}),a.forEach(c=>{const{startColumn:u,startRow:h,endColumn:d,endRow:f}=c;Vi(h,f,u,d).forEach((g,_)=>{g===h&&_===u&&l.setValue(g,_,{...o.getValue(g,_),rowSpan:f-h+1,colSpan:d-u+1}),(g!==h||_!==u)&&l.realDeleteValue(g,_)})}),l}getRange(t,n,r,s){return typeof t=="object"?new Kn(this,t,{getStyles:()=>this._styles}):new Kn(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,c=s;return{next(){for(;;){if(c>o&&(l+=1,c=s),l>i)return{done:!0,value:void 0};const u=a.getCell(l,c),h=!u,d=a.getMergedCell(l,c);if(d){if(l!==d.startRow||c!==d.startColumn){c=d.endColumn+1;continue}if(h&&n){c=d.endColumn+1;continue}const g={row:l,col:c,value:u};return g.colSpan=d.endColumn-d.startColumn+1,g.rowSpan=d.endRow-d.startRow+1,c=d.endColumn+1,{done:!1,value:g}}if(h&&n)c+=1;else{const f={row:l,col:c,value:u};return c+=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 c=s,u=i;return{next(){for(;;){if(c>o&&(u+=1,c=s),u>a)return{done:!0,value:void 0};const h=l.getMergedCell(c,u);if(h){const g=c!==h.startRow,_=g||u!==h.startColumn;if(r&&_||!r&&g){c=h.endRow+1;continue}const R=l.getCell(h.startRow,h.startColumn);if(!R&&n){c=h.endRow+1;continue}const F={row:c,col:h.startColumn,value:R};return F.colSpan=h.endColumn-h.startColumn+1,F.rowSpan=h.endRow-h.startRow+1,c=h.endRow+1,{done:!1,value:F}}const d=l.getCell(c,u);if(!d&&n)c+=1;else{const g={row:c,col:u,value:d};return c+=1,{done:!1,value:g}}}}}}}}getCellDocumentModel(t,n,r=Sl){var _;if(!t)return;const{isDeepClone:s,displayRawFormula:i,ignoreTextRotation:o}={...Sl,...r};let a,l="document";const c=RR(n),u=o?st.tr:c.textRotation||st.tr;let h=c.horizontalAlign||st.ht;const d=c.verticalAlign||st.vt,f=c.wrapStrategy||st.tb,g=c.paddingData||eo;if(t.f&&i)a=Sr(t.f.toString(),{},{verticalAlign:d}),h=st.ht;else if(t.p){const{centerAngle:R,vertexAngle:b}=jh(u);a=this._updateConfigAndGetDocumentModel(s?q.deepClone(t.p):t.p,h,g,{horizontalAlign:h,verticalAlign:d,centerAngle:R,vertexAngle:b,wrapStrategy:f,zeroWidthParagraphBreak:1})}else if(t.v!=null){const R=Rl(n);l=Il(R).fontCache;let b=Zh(t);t.t===en.FORCE_STRING&&i&&(b=`'${b}`),a=Sr(b,R,{...c,textRotation:u,cellValueType:t.t})}return a&&t.linkUrl&&t.linkId&&$h(a,t.linkUrl,t.linkId),{documentModel:a,fontString:l,textRotation:u,wrapStrategy:f,verticalAlign:d,horizontalAlign:h,paddingData:g,fill:(_=n==null?void 0:n.bg)==null?void 0:_.rgb}}_updateConfigAndGetDocumentModel(t,n,r,s){var o,a,l,c,u;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=(c=r.l)!=null?c:2,t.documentStyle.marginRight=(u=r.r)!=null?u: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 h of i)h.paragraphStyle||(h.paragraphStyle={}),h.paragraphStyle.horizontalAlign=n;return new Nt(t)}getBlankCellDocumentModel(t,n,r){const s=this.getComposedCellStyleByCellData(n,r,t),i=Rl(s),o=this.getCellDocumentModel(t,s,{ignoreTextRotation:!0});if(o!=null)return o.documentModel==null&&(o.documentModel=Sr("",i)),o;const a="";let l="document";const c=st.tr,u=st.ht,h=st.vt,d=st.tb,f=eo;return l=Il({}).fontCache,{documentModel:Sr(a,i),fontString:l,textRotation:c,wrapStrategy:d,verticalAlign:h,horizontalAlign:u,paddingData:f}}getCellDocumentModelWithFormula(t,n,r){const s=this.getComposedCellStyleByCellData(n,r,t);return this.getCellDocumentModel(t,s,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(t){this._snapshot.custom=t}}function Zh(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 Qe.transform.getPlainText(t);const n=e.v;return typeof n=="string"?e.t===en.BOOLEAN?n.toUpperCase():n.replace(/[\r\n]/g,""):typeof n=="number"?e.t===en.BOOLEAN?n?"TRUE":"FALSE":n.toString():typeof n=="boolean"?n?"TRUE":"FALSE":""}function DR(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 Qe.transform.getPlainText(n)}return e==null?void 0:e.v}var xR=Object.getOwnPropertyDescriptor,UR=(e,t,n,r)=>{for(var s=r>1?void 0:r?xR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},PR=(e,t)=>(n,r)=>t(n,r,e);function kR(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}exports.Workbook=class extends Ws{constructor(n={},r){super();p(this,"type",ve.UNIVER_SHEET);p(this,"_sheetCreated$",new ce.Subject);p(this,"sheetCreated$",this._sheetCreated$.asObservable());p(this,"_sheetDisposed$",new ce.Subject);p(this,"sheetDisposed$",this._sheetDisposed$.asObservable());p(this,"_activeSheet$",new ce.BehaviorSubject(null));p(this,"activeSheet$",this._activeSheet$.asObservable());p(this,"_worksheets");p(this,"_styles");p(this,"_snapshot");p(this,"_unitId");p(this,"_count");p(this,"_name$");p(this,"name$");this._logService=r;const s=_R();q.isEmptyObject(n)?this._snapshot=s:this._snapshot=q.commonExtend(s,n);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=tt(6)),this._unitId=this._snapshot.id,this._styles=new Bh(i),this._count=1,this._worksheets=new Map,this._name$=new ce.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 q.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 xr(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()!==ie.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===ie.TRUE).map(n=>n.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden!==ie.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(q.isEmptyObject(s)){const o=tt();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 c=new xr(this._unitId,a,this._styles);r.set(o,c),i.includes(o)||i.push(o)}this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(n){this._snapshot.custom=n}};exports.Workbook=UR([PR(1,Et)],exports.Workbook);class la extends Ws{constructor(n){var r;super();p(this,"type",ve.UNIVER_SLIDE);p(this,"_activePage$",new ce.BehaviorSubject(null));p(this,"activePage$",this._activePage$.asObservable());p(this,"_name$");p(this,"name$");p(this,"_snapshot");p(this,"_unitId");this._snapshot={...eh,...n},this._unitId=(r=this._snapshot.id)!=null?r:tt(6),this._name$=new ce.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:tt(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=tt(6);return{id:n,pageType:Co.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)}}var FR=Object.getOwnPropertyDescriptor,BR=(e,t,n,r)=>{for(var s=r>1?void 0:r?FR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Ol=(e,t)=>(n,r)=>t(n,r,e);const Xn=Ae.createIdentifier("univer.current");exports.UniverInstanceService=class extends Ke{constructor(n,r){super();p(this,"_unitsByType",new Map);p(this,"_createHandler");p(this,"_ctorByType",new Map);p(this,"_currentUnits",new Map);p(this,"_currentUnits$",new ce.BehaviorSubject(this._currentUnits));p(this,"currentUnits$",this._currentUnits$.asObservable());p(this,"_unitAdded$",new ce.Subject);p(this,"unitAdded$",this._unitAdded$.asObservable());p(this,"_unitDisposed$",new ce.Subject);p(this,"unitDisposed$",this._unitDisposed$.asObservable());p(this,"_focused$",new ce.BehaviorSubject(null));p(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(ce.map(r=>{var s;return(s=r.get(n))!=null?s:null}),ce.distinctUntilChanged())}getCurrentUnitForType(n){return this._currentUnits.get(n)}getCurrentUnitOfType(n){return this.getCurrentUnitForType(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(ce.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(ce.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(ve.UNIVER_DOC)}getUniverDocInstance(n){return this.getUnit(n,ve.UNIVER_DOC)}getUniverSheetInstance(n){return this.getUnit(n,ve.UNIVER_SHEET)}getAllUnitsForType(n){var r;return(r=this._unitsByType.get(n))!=null?r:[]}changeDoc(n,r){const s=this.getAllUnitsForType(ve.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(Cr,!0),this._contextService.setContextValue(Rr,!1),this._contextService.setContextValue(Hn,!0),this._contextService.setContextValue(Ir,!1),this.setCurrentUnitForType(n)):this.focused instanceof Nt?(this._contextService.setContextValue(Cr,!0),this._contextService.setContextValue(Rr,!0),this._contextService.setContextValue(Hn,!1),this._contextService.setContextValue(Ir,!1),this.setCurrentUnitForType(n)):this.focused instanceof la?(this._contextService.setContextValue(Cr,!0),this._contextService.setContextValue(Rr,!1),this._contextService.setContextValue(Hn,!1),this._contextService.setContextValue(Ir,!0),this.setCurrentUnitForType(n)):(this._contextService.setContextValue(Cr,!1),this._contextService.setContextValue(Rr,!1),this._contextService.setContextValue(Hn,!1),this._contextService.setContextValue(Ir,!1))}getFocusedUnit(){return this.focused}getUnitType(n){const r=this._getUnitById(n);return r?r[1]:ve.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._tryResetCurrentOnRemoval(n,i),this._tryResetFocusOnRemoval(n),this._unitDisposed$.next(s),!0}_tryResetCurrentOnRemoval(n,r){const s=this.getCurrentUnitForType(r);(s==null?void 0:s.getUnitId())===n&&(this._currentUnits.set(r,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(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=BR([Ol(0,Ae.Inject(Ae.Injector)),Ol(1,Jn)],exports.UniverInstanceService);var Ue=(e=>(e[e.Starting=0]="Starting",e[e.Ready=1]="Ready",e[e.Rendered=2]="Rendered",e[e.Steady=3]="Steady",e))(Ue||{});const Jh={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"};var $R=Object.getOwnPropertyDescriptor,HR=(e,t,n,r)=>{for(var s=r>1?void 0:r?$R(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},jR=(e,t)=>(n,r)=>t(n,r,e);class Qh extends Error{constructor(t){super(`[LifecycleService]: lifecycle stage "${Jh[t]}" will never be reached!`),this.name="LifecycleUnreachableError"}}exports.LifecycleService=class extends Ke{constructor(n){super();p(this,"_lifecycle$",new ce.BehaviorSubject(Ue.Starting));p(this,"lifecycle$",this._lifecycle$.asObservable());p(this,"_lock",!1);this._logService=n,this._reportProgress(Ue.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()}onStage(n){return ce.firstValueFrom(this.lifecycle$.pipe(ce.filter(r=>r>=n),Li(r=>r===n),ce.map(()=>{}))).catch(r=>r.name==="EmptyError"?Promise.reject(new Qh(n)):Promise.reject(r))}subscribeWithPrevious(){return ce.merge(ed(this.stage),this._lifecycle$.pipe(ce.skip(1))).pipe(Li(n=>n===Ue.Steady))}_reportProgress(n){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${Jh[n]}".`)}};exports.LifecycleService=HR([jR(0,Et)],exports.LifecycleService);function ed(e){switch(e){case Ue.Starting:return ce.of(Ue.Starting);case Ue.Ready:return ce.of(Ue.Starting,Ue.Ready);case Ue.Rendered:return ce.of(Ue.Starting,Ue.Ready,Ue.Rendered);default:return ce.of(Ue.Starting,Ue.Ready,Ue.Rendered,Ue.Steady)}}const WR=Ae.createIdentifier("ILocalStorageService");class Cn extends Ke{constructor(){super();p(this,"_currentLocale$",new ce.BehaviorSubject(Fr.ZH_CN));p(this,"currentLocale$",this._currentLocale$.asObservable());p(this,"_locales",null);p(this,"localeChanged$",new ce.Subject);p(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(We(()=>{this._locales=null,this._currentLocale$.complete(),this.localeChanged$.complete()}))}get _currentLocale(){return this._currentLocale$.value}load(n){var r;this._locales=Hs((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 YR=Object.getOwnPropertyDescriptor,GR=(e,t,n,r)=>{for(var s=r>1?void 0:r?YR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},VR=(e,t)=>(n,r)=>t(n,r,e);exports.MentionIOLocalService=class{constructor(t){this._userManagerService=t}async list(t){return{list:[{type:ws.PERSON,mentions:[{objectType:ws.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=GR([VR(0,Ae.Inject(Dr))],exports.MentionIOLocalService);const td=Ae.createIdentifier("univer.service.mention-io");var ca=(e=>(e.INIT="init",e.FETCHING="fetching",e.DONE="done",e))(ca||{});const nd=Ae.createIdentifier("univer.permission-service");class rd extends Ke{constructor(){super(...arguments);p(this,"_permissionPointMap",new Map);p(this,"_permissionPointUpdate$",new ce.Subject);p(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable());p(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 ce.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 ce.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=ca.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 ce.combineLatest(r).pipe(ls.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 sd(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}var zR=Object.getOwnPropertyDescriptor,KR=(e,t,n,r)=>{for(var s=r>1?void 0:r?zR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Oi=(e,t)=>(n,r)=>t(n,r,e);const XR=4,id=Symbol("DependentOn");class to extends Ke{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}p(to,"pluginName"),p(to,"type",ve.UNIVER_UNKNOWN);class qR{constructor(){p(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)}}function ZR(...e){return function(t){t[id]=e}}exports.PluginService=class{constructor(t,n,r){p(this,"_pluginRegistry",new Map);p(this,"_pluginStore",new qR);p(this,"_seenPlugins",new Set);p(this,"_loadedPlugins",new Set);p(this,"_loadedPluginTypes",new Set([ve.UNIVER_UNKNOWN]));p(this,"_flushTimerByType",new Map);this._injector=t,this._lifecycleService=n,this._logService=r}dispose(){this._pluginStore.removePlugins().forEach(t=>t.dispose()),this._flushTimerByType.forEach(t=>clearTimeout(t))}registerPlugin(t,n){this._assertPluginValid(t);const r={plugin:t,options:n};this._pluginRegistry.set(t.pluginName,r),this._logService.debug("[PluginService]",`Plugin "${t.pluginName}" registered.`);const{type:s}=t;this._loadedPluginTypes.has(s)&&(s===ve.UNIVER_UNKNOWN?this._loadFromPlugins([r]):this._flushType(s))}startPluginsForType(t){this._loadedPluginTypes.has(t)||this._loadPluginsForType(t)}_loadPluginsForType(t){const n=Array.from(this._pluginRegistry.keys()),r=[];n.forEach(s=>{const i=this._pluginRegistry.get(s);i.plugin.type===t&&r.push(i)}),this._loadFromPlugins(r),this._loadedPluginTypes.add(t)}_assertPluginValid(t){const{type:n,pluginName:r}=t;if(n===ve.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)}_flushType(t){this._flushTimerByType.get(t)===void 0&&this._flushTimerByType.set(t,setTimeout(()=>{this._loadPluginsForType(t),this._flushTimerByType.delete(t)},XR))}_loadFromPlugins(t){const n=[],r=new Set,s=o=>{const{plugin:a}=o,{pluginName:l}=a;if(this._loadedPlugins.has(l)||r.has(l))return;r.add(l),this._pluginRegistry.delete(l);const c=a[id];c&&c.forEach(u=>{const h=this._pluginRegistry.get(u.pluginName);if(h)s(h);else if(!this._seenPlugins.has(u.pluginName)&&!r.has(u.pluginName)){if(a.type===ve.UNIVER_UNKNOWN&&u.type!==ve.UNIVER_UNKNOWN)throw new Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${a.pluginName} and the dependency is ${u.pluginName}.`);a.type!==u.type&&u.type!==ve.UNIVER_UNKNOWN&&this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${u.pluginName}" which has different type.`),this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${u.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(u),s({plugin:u,options:void 0})}}),n.push(o)};t.forEach(o=>s(o));const i=n.map(o=>this._initPlugin(o.plugin,o.options));this._pluginsRunLifecycle(i)}_pluginsRunLifecycle(t){const n=this._lifecycleService.stage;if(ed(n).subscribe(r=>this._runStage(t,r)),n!==Ue.Steady){const r=this._lifecycleService.lifecycle$.pipe(ce.skip(1)).subscribe(s=>{this._runStage(t,s),s===Ue.Steady&&r.unsubscribe()})}}_runStage(t,n){t.forEach(r=>{switch(n){case Ue.Starting:r.onStarting();break;case Ue.Ready:r.onReady();break;case Ue.Rendered:r.onRendered();break;case Ue.Steady:r.onSteady();break}})}_initPlugin(t,n){const r=this._injector.createInstance(t,n);return this._pluginStore.addPlugin(r),this._loadedPlugins.add(t.pluginName),this._logService.debug("[PluginService]",`Plugin "${r.getPluginName()}" loaded.`),r}};exports.PluginService=KR([Oi(0,Ae.Inject(Ae.Injector)),Oi(1,Ae.Inject(exports.LifecycleService)),Oi(2,Et)],exports.PluginService);const no=Ae.createIdentifier("resource-loader-service");var JR=Object.getOwnPropertyDescriptor,QR=(e,t,n,r)=>{for(var s=r>1?void 0:r?JR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},eI=(e,t)=>(n,r)=>t(n,r,e);exports.ResourceManagerService=class extends Ke{constructor(n){super();p(this,"_resourceMap",new Map);p(this,"_register$",new ce.Subject);p(this,"register$",this._register$.asObservable());this._logService=n}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),We(()=>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(a){this._logService.error("[ResourceManagerService]","loadResources error",a)}})}unloadResources(n){this.getAllResourceHooks().forEach(r=>{r.onUnLoad(n)})}dispose(){this._register$.complete(),this._resourceMap.clear()}};exports.ResourceManagerService=QR([eI(0,Et)],exports.ResourceManagerService);class Ps extends Ke{constructor(){super();p(this,"_darkMode$",new ce.BehaviorSubject(!1));p(this,"darkMode$",this._darkMode$.asObservable());p(this,"_validColorCache",new Map);p(this,"_currentTheme",Kr.defaultTheme);p(this,"_currentTheme$",new ce.BehaviorSubject(this._currentTheme));p(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(We(()=>{this._currentTheme=Kr.defaultTheme,this._currentTheme$.complete(),this._darkMode$.complete()}))}get darkMode(){return this._darkMode$.getValue()}isValidThemeColor(n){if(this._validColorCache.has(n))return this._validColorCache.get(n);let r=!1;const s=n.split(".");if(s.length===1)r=n in Kr.defaultTheme;else if(s.length===2){const[i,o]=s;r=i in Kr.defaultTheme&&o in this._currentTheme[i]}return this._validColorCache.set(n,r),r}getCurrentTheme(){return this._currentTheme}setTheme(n){this._currentTheme=n,this._currentTheme$.next(n)}setDarkMode(n){this._darkMode$.next(n)}getColorFromTheme(n){return nc(this._currentTheme,n)}}var tI=Object.getOwnPropertyDescriptor,nI=(e,t,n,r)=>{for(var s=r>1?void 0:r?tI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},vi=(e,t)=>(n,r)=>t(n,r,e);const Qs=Ae.createIdentifier("univer.undo-redo.service"),rI=20;class od{dispose(){}async dispatchToHandlers(){return!1}}const ad="univer.command.redo",ld="univer.command.undo",cd=new class extends od{constructor(){super(...arguments);p(this,"type",$r.COMMAND);p(this,"id",ld)}handler(t){const n=t.get(Qs),r=n.pitchTopUndoElement();if(!r)return!1;const s=t.get(Hr);return Gs(r.undoMutations,s)?(n.popUndoToRedo(),!0):!1}},ud=new class extends od{constructor(){super(...arguments);p(this,"type",$r.COMMAND);p(this,"id",ad)}handler(t){const n=t.get(Qs),r=n.pitchTopRedoElement();if(!r)return!1;const s=t.get(Hr);return Gs(r.redoMutations,s)?(n.popRedoToUndo(),!0):!1}};exports.LocalUndoRedoService=class extends Ke{constructor(n,r,s){super();p(this,"undoRedoStatus$");p(this,"_undoRedoStatus$",new ce.BehaviorSubject({undos:0,redos:0}));p(this,"_undoStacks",new Map);p(this,"_redoStacks",new Map);p(this,"_batchingStatus",new Map);this._univerInstanceService=n,this._commandService=r,this._contextService=s,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(cd)),this.disposeWithMe(this._commandService.registerCommand(ud)),this.disposeWithMe(We(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(We(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>rI&&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())}rollback(n,r){const s=r||this._getFocusedUnitId(),i=this._getUndoStack(s),o=i==null?void 0:i[(i==null?void 0:i.length)-1];o&&o.id===n&&(i.pop(),Gs(o.undoMutations,this._commandService))}__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),We(()=>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,c;let n="";const r=this._contextService.getContextValue(Hn),s=this._contextService.getContextValue(Ph),i=this._contextService.getContextValue(Uh);return r?s?n=oo:i?n=io:n=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":n=(c=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?c:"",n}};exports.LocalUndoRedoService=nI([vi(0,Xn),vi(1,Hr),vi(2,Jn)],exports.LocalUndoRedoService);class hd{constructor(t,n=100){p(this,"_imageCacheMap");this._injector=t,this._imageCacheMap=new yr(n)}_getImageCacheKey(t,n){return`${t}-${n}`}getImage(t,n,r,s){const i=this._getImageCacheKey(t,n),o=this._imageCacheMap.get(i);return o||((async()=>{const a=new Image,l=this._injector.has(Qi)?this._injector.get(Qi):null;if(t===aa.UUID)try{a.src=await(l==null?void 0:l.getImage(n))||""}catch(c){console.error(c)}else a.src=n;a.onload=()=>{a.removeAttribute("data-error"),r==null||r()},a.onerror=()=>{a.setAttribute("data-error","true"),s==null||s()},this._imageCacheMap.set(i,a)})(),null)}}function sI(e){return!(e.length===0||e.length>31||e.startsWith("'")||e.endsWith("'")||/[:\\\/\?\*\[\]]/.test(e))}const vl=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],wi=1,ir=8;class ua{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!==wi)throw new Error(`Got v${s} data when expected v${wi}.`);const i=vl[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 ua(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=vl.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,ir,t),this.coords=new this.ArrayType(this.data,ir+a+l,t*2),this._pos=t*2,this._finished=!0):(this.data=new ArrayBuffer(ir+o+a+l),this.ids=new this.IndexArrayType(this.data,ir,t),this.coords=new this.ArrayType(this.data,ir+a+l,t*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(wi<<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 ro(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],c=[];for(;l.length;){const u=l.pop()||0,h=l.pop()||0,d=l.pop()||0;if(h-d<=a){for(let R=d;R<=h;R++){const b=o[2*R],F=o[2*R+1];b>=t&&b<=r&&F>=n&&F<=s&&c.push(i[R])}continue}const f=d+h>>1,g=o[2*f],_=o[2*f+1];g>=t&&g<=r&&_>=n&&_<=s&&c.push(i[f]),(u===0?t<=g:n<=_)&&(l.push(d),l.push(f-1),l.push(1-u)),(u===0?r>=g:s>=_)&&(l.push(f+1),l.push(h),l.push(1-u))}return c}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=[],c=r*r;for(;a.length;){const u=a.pop()||0,h=a.pop()||0,d=a.pop()||0;if(h-d<=o){for(let R=d;R<=h;R++)wl(i[2*R],i[2*R+1],t,n)<=c&&l.push(s[R]);continue}const f=d+h>>1,g=i[2*f],_=i[2*f+1];wl(g,_,t,n)<=c&&l.push(s[f]),(u===0?t-r<=g:n-r<=_)&&(a.push(d),a.push(f-1),a.push(1-u)),(u===0?t+r>=g:n+r>=_)&&(a.push(f+1),a.push(h),a.push(1-u))}return l}}function ro(e,t,n,r,s,i){if(s-r<=n)return;const o=r+s>>1;dd(e,t,o,r,s,i),ro(e,t,n,r,o-1,1-i),ro(e,t,n,o+1,s,1-i)}function dd(e,t,n,r,s,i){for(;s>r;){if(s-r>600){const c=s-r+1,u=n-r+1,h=Math.log(c),d=.5*Math.exp(2*h/3),f=.5*Math.sqrt(h*d*(c-d)/c)*(u-c/2<0?-1:1),g=Math.max(r,Math.floor(n-u*d/c+f)),_=Math.min(s,Math.floor(n+(c-u)*d/c+f));dd(e,t,n,g,_,i)}const o=t[2*n+i];let a=r,l=s;for(or(e,t,r,n),t[2*s+i]>o&&or(e,t,r,s);a<l;){for(or(e,t,a,l),a++,l--;t[2*a+i]<o;)a++;for(;t[2*l+i]>o;)l--}t[2*r+i]===o?or(e,t,r,l):(l++,or(e,t,l,s)),l<=n&&(r=l+1),n<=l&&(s=l-1)}}function or(e,t,n,r){bi(e,n,r),bi(t,2*n,2*r),bi(t,2*n+1,2*r+1)}function bi(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function wl(e,t,n,r){const s=e-n,i=t-r;return s*s+i*i}class iI{constructor(t=!1){p(this,"_tree",new Map);p(this,"_oneCellCache",new Map);p(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 Ls),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 c=l.get(s);c&&c.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:c,endRow:u,endColumn:h}=s;for(let d=l;d<=u;d++){const f=a.get(d);if(f)for(let g=c;g<=h;g++){const _=f.get(g);_&&_.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 g;const{unitId:n,sheetId:r,range:s}=t,{startRow:i,startColumn:o,endRow:a,endColumn:l}=s,c=(g=this._kdTree.get(n))==null?void 0:g.get(r);if(!c)return[];const{tree:u,items:h}=c,d=u.range(o,i,l,a),f=[];for(const _ of d){const R=h[_];f.push(...Array.from(R.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 ua(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:c}=s;if(this._enableOneCellCache&&o===a&&l===c){this._insertOneCellCache(n,r,o,l,i);return}const u=this.getTree(n,r);Number.isNaN(o)&&(o=0),Number.isNaN(l)&&(l=0),Number.isNaN(a)&&(a=Number.POSITIVE_INFINITY),Number.isNaN(c)&&(c=Number.POSITIVE_INFINITY),u.insert({minX:l,minY:o,maxX:c,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 c of l)yield c}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:c}=s;this._enableOneCellCache?o===l&&a===c?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 Ls;s.fromJSON(t[n][r]),this._tree.get(n).set(r,s)}}}}function oI(e){return new Promise(t=>setTimeout(t,e))}function aI(e=1){return new Promise(t=>{let n=0;const r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}var lI=Object.getOwnPropertyDescriptor,cI=(e,t,n,r)=>{for(var s=r>1?void 0:r?lI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},uI=(e,t)=>(n,r)=>t(n,r,e);exports.Skeleton=class extends Ke{constructor(n){super();p(this,"_fontLocale");p(this,"_dirty",!0);this._localeService=n,this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(n){this._dirty=n}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}};exports.Skeleton=cI([uI(0,Ae.Inject(Cn))],exports.Skeleton);var hI=Object.getOwnPropertyDescriptor,dI=(e,t,n,r)=>{for(var s=r>1?void 0:r?hI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},as=(e,t)=>(n,r)=>t(n,r,e);exports.SheetSkeleton=class extends exports.Skeleton{constructor(n,r,s,i,o,a){super(s);p(this,"_worksheetData");p(this,"_renderRawFormula",!1);p(this,"_cellData");p(this,"_imageCacheMap");p(this,"_skipAutoHeightForMergedCells",!0);p(this,"_rowTotalHeight",0);p(this,"_columnTotalWidth",0);p(this,"_rowHeaderWidth",0);p(this,"_columnHeaderHeight",0);p(this,"_rowHeightAccumulation",[]);p(this,"_columnWidthAccumulation",[]);p(this,"_marginTop",0);p(this,"_marginLeft",0);p(this,"_scaleX");p(this,"_scaleY");p(this,"_scrollX");p(this,"_scrollY");this.worksheet=n,this._styles=r,this._contextService=i,this._configService=o,this._injector=a,this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new hd(this._injector),this.initConfig()}initConfig(){var n,r;this._skipAutoHeightForMergedCells=!((n=this._configService.getConfig(Ll))!=null&&n),this.worksheet.setIsRowStylePrecedeColumnStyle((r=this._configService.getConfig(Ml))!=null?r:!1)}resetCache(){}getWorksheetConfig(){return this._worksheetData}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(n){this._columnHeaderHeight=n,this._worksheetData.columnHeader.height=n}set rowHeaderWidth(n){this._rowHeaderWidth=n,this._worksheetData.rowHeader.width=n}get rowHeightAccumulation(){return this._rowHeightAccumulation}get rowTotalHeight(){return this._rowTotalHeight}get columnWidthAccumulation(){return this._columnWidthAccumulation}get columnTotalWidth(){return this._columnTotalWidth}get rowHeaderWidth(){return this._rowHeaderWidth}get columnHeaderHeight(){return this._columnHeaderHeight}setMarginLeft(n){this._marginLeft=n}setMarginTop(n){this._marginTop=n}setScale(n,r){this._updateLayout(),this._scaleX=n,this._scaleY=r||n,this._updateLayout()}setScroll(n,r){q.isDefine(n)&&(this._scrollX=n),q.isDefine(r)&&(this._scrollY=r)}get scrollX(){return this._scrollX}get scrollY(){return this._scrollY}get scaleX(){return this._scaleX}get scaleY(){return this._scaleY}get rowHeaderWidthAndMarginLeft(){return this.rowHeaderWidth+this._marginLeft}get columnHeaderHeightAndMarginTop(){return this.columnHeaderHeight+this._marginTop}get imageCacheMap(){return this._imageCacheMap}_generateRowMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let c=s;if(this.worksheet.getRowFiltered(l))c=0;else if(a[l]!=null){const u=a[l];if(!u)continue;const{h=s,ah:d,ia:f}=u;(f==null||f===ie.TRUE)&&typeof d=="number"?c=d:c=h,u.hd===ie.TRUE&&(c=0)}i+=c,o.push(i)}return{rowTotalHeight:i,rowHeightAccumulation:o}}_generateColumnMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let c=s;if(a[l]!=null){const u=a[l];if(!u)continue;u.w!=null&&(c=u.w),u.hd===ie.TRUE&&(c=0)}i+=c,o.push(i)}return{columnTotalWidth:i,columnWidthAccumulation:o}}intersectMergeRange(n,r){return!!this.worksheet.getMergedCell(n,r)}_getOverflowBound(n,r,s,i,o=Tt.LEFT){let a=0;if(r>s){const l=this._columnWidthAccumulation.length-1;for(let c=r;c>=s;c--){const u=c,h=this.worksheet.getCell(n,u);if(!Fi(h)&&u!==r||this.intersectMergeRange(n,u))return u===r?u:u+1>l?l:u+1;const{startX:d,endX:f}=Un(n,u,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===Tt.CENTER&&u===r?a+=(f-d)/2:a+=f-d,i<a)return u}return r}for(let l=r;l<=s;l++){const c=l,u=this.worksheet.getCell(n,c);if(!Fi(u)&&c!==r||this.intersectMergeRange(n,c))return c===r?c:c-1<0?0:c-1;const{startX:h,endX:d}=Un(n,c,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===Tt.CENTER&&c===r?a+=(d-h)/2:a+=d-h,i<a)return c}return s}_updateLayout(){if(!this.dirty)return;const{rowData:n,columnData:r,defaultRowHeight:s,defaultColumnWidth:i,rowCount:o,columnCount:a,rowHeader:l,columnHeader:c}=this._worksheetData,{rowTotalHeight:u,rowHeightAccumulation:h}=this._generateRowMatrixCache(o,n,s),{columnTotalWidth:d,columnWidthAccumulation:f}=this._generateColumnMatrixCache(a,r,i);this._rowHeaderWidth=l.hidden!==ie.TRUE?this._dynamicallyUpdateRowHeaderWidth(l):0,this._columnHeaderHeight=c.hidden!==ie.TRUE?c.height:0,this._rowTotalHeight=u,this._rowHeightAccumulation=h,this._columnTotalWidth=d,this._columnWidthAccumulation=f,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(n){}_dynamicallyUpdateRowHeaderWidth(n){const s=`${this.worksheet.getRowCount()}`.length*8;return Math.max(n.width,s)}_hasUnMergedCellInRow(n,r,s){if(!this.worksheet.getMergeData())return!1;for(let o=r;o<=s;o++){const{isMerged:a,isMergedMainCell:l}=this.worksheet.getCellInfoInMergeData(n,o);if(!a&&!l)return!0}return!1}expandRangeByMerge(n){let{startRow:r,startColumn:s,endRow:i,endColumn:o}=n;const a=this._worksheetData.mergeData;if(!a)return{startRow:r,startColumn:s,endRow:i,endColumn:o};let l=!0;const c=new dt;for(;l;){l=!1;for(let u=0;u<a.length;u++){const{startRow:h,startColumn:d,endRow:f,endColumn:g}=a[u];if(c.getValue(h,d))continue;rh({startColumn:s,startRow:r,endColumn:o,endRow:i},{startColumn:d,startRow:h,endColumn:g,endRow:f})&&(r=Math.min(r,h),s=Math.min(s,d),i=Math.max(i,f),o=Math.max(o,g),c.setValue(h,d,!0),l=!0)}}return{startRow:r,startColumn:s,endRow:i,endColumn:o}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(n,r){return this.worksheet.getCellInfoInMergeData(n,r)}getNoMergeCellPositionByIndex(n,r,s=!0){return this.getNoMergeCellWithCoordByIndex(n,r,s)}getNoMergeCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this;let{startY:c,endY:u,startX:h,endX:d}=Un(n,r,i,o);return s&&(c+=l,u+=l,h+=a,d+=a),{startY:c,endY:u,startX:h,endX:d}}getNoMergeCellPositionByIndexWithNoHeader(n,r){const{rowHeightAccumulation:s,columnWidthAccumulation:i}=this,{startY:o,endY:a,startX:l,endX:c}=Un(n,r,s,i);return{startY:o,endY:a,startX:l,endX:c}}getRowIndexByOffsetY(n,r,s,i){var l;const{rowHeightAccumulation:o}=this;n=md(n,r,s,this.columnHeaderHeightAndMarginTop);let a=lr(o,n,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(o[a]-n)<Math.abs(n-((l=o[a-1])!=null?l:0))&&(a=a+1),a}getColumnIndexByOffsetX(n,r,s,i){var c;const o=fd(n,r,s,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this;let l=lr(a,o,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(a[l]-o)<Math.abs(o-((c=a[l-1])!=null?c:0))&&(l=l+1),l}getCellIndexByOffset(n,r,s,i,o,a){const l=this.getRowIndexByOffsetY(r,i,o,a),c=this.getColumnIndexByOffsetX(n,s,o,a);return{row:l,column:c}}getCellByOffset(n,r,s,i,o){const a=this==null?void 0:this.getCellIndexByOffset(n,r,s,i,o,{firstMatch:!0});return a?this.worksheet.getCellInfoInMergeData(a.row,a.column):null}getCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this,c=Un(n,r,i,o,this.worksheet.getCellInfoInMergeData(n,r)),{isMerged:u,isMergedMainCell:h}=c;let{startY:d,endY:f,startX:g,endX:_,mergeInfo:R}=c,b=a,F=l;return s===!1&&(b=0,F=0),d+=F,f+=F,g+=b,_+=b,R.startY+=F,R.endY+=F,R.startX+=b,R.endX+=b,{actualRow:n,actualColumn:r,startX:g,startY:d,endX:_,endY:f,isMerged:u,isMergedMainCell:h,mergeInfo:R}}getCellWithCoordByOffset(n,r,s,i,o,a){const{row:l,column:c}=this.getCellIndexByOffset(n,r,s,i,o,a);return this.getCellWithCoordByIndex(l,c)}getOffsetByColumn(n){const{columnWidthAccumulation:r,rowHeaderWidthAndMarginLeft:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetByRow(n){const{rowHeightAccumulation:r,columnHeaderHeightAndMarginTop:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetRelativeToRowCol(n,r){const s=lr(this.columnWidthAccumulation,n);let i=0;s===0?i=n:i=n-this._columnWidthAccumulation[s-1];const o=lr(this.rowHeightAccumulation,r);let a=0;return o===0?a=r:a=r-this._rowHeightAccumulation[o-1],{row:o,column:s,columnOffset:i,rowOffset:a}}_updateConfigAndGetDocumentModel(n,r,s,i){var a,l,c,u,h;if(!i||!((a=n.body)!=null&&a.dataStream))return;n.documentStyle||(n.documentStyle={}),n.documentStyle.marginTop=(l=s.t)!=null?l:0,n.documentStyle.marginBottom=(c=s.b)!=null?c:2,n.documentStyle.marginLeft=(u=s.l)!=null?u:2,n.documentStyle.marginRight=(h=s.r)!=null?h:2,n.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},n.documentStyle.renderConfig={...n.documentStyle.renderConfig,...i};const o=n.body.paragraphs||[];for(const d of o)d.paragraphStyle||(d.paragraphStyle={}),d.paragraphStyle.horizontalAlign=r;return new Nt(n)}dispose(){super.dispose(),this._rowHeightAccumulation=[],this._columnWidthAccumulation=[],this._rowTotalHeight=0,this._columnTotalWidth=0,this._rowHeaderWidth=0,this._columnHeaderHeight=0,this._worksheetData=null,this._cellData=null,this._styles=null}};exports.SheetSkeleton=dI([as(2,Ae.Inject(Cn)),as(3,Jn),as(4,oa),as(5,Ae.Inject(Ae.Injector))],exports.SheetSkeleton);function ha(e,t,n,r){const s=e-1,i=t-1,o=n[s]||0;let a=n[e];a==null&&(a=n[n.length-1]);const l=r[i]||0;let c=r[t];return c==null&&(c=r[r.length-1]),{startY:o,endY:a,startX:l,endX:c}}function fI(e,t,n,r){return ha(e,t,n,r)}function Un(e,t,n,r,s){e=q.clamp(e,0,n.length-1),t=q.clamp(t,0,r.length-1);let{startY:i,endY:o,startX:a,endX:l}=ha(e,t,n,r);if(!s)return{startY:i,endY:o,startX:a,endX:l,isMerged:!1,isMergedMainCell:!1,actualRow:e,actualColumn:t,mergeInfo:{startY:i,endY:o,startX:a,endX:l,startRow:e,startColumn:t,endRow:e,endColumn:t}};const{isMerged:c,isMergedMainCell:u,startRow:h,startColumn:d,endRow:f,endColumn:g}=s;let _={startRow:h,startColumn:d,endRow:f,endColumn:g,startY:i,endY:o,startX:a,endX:l};const R=n.length-1,b=r.length-1;if(c&&h!==-1&&d!==-1){const F=n[h-1]||0,k=n[f]||n[R],W=r[d-1]||0,S=r[g]||r[b];_={..._,startY:F,endY:k,startX:W,endX:S}}else if(!c&&f!==-1&&g!==-1){const F=n[f]||n[R],k=r[g]||r[b];_={..._,startY:i,endY:F,startX:a,endX:k}}return{isMerged:c,isMergedMainCell:u,actualRow:e,actualColumn:t,startY:i,endY:o,startX:a,endX:l,mergeInfo:_}}function fd(e,t,n,r){const{x:s}=n;return e/t+s-r}function md(e,t,n,r){const{y:s}=n;return e=e/t+s-r,e}const mI=["script","style","meta","comment","link"];var gd=(e=>(e[e.INFO=0]="INFO",e[e.STOP=1]="STOP",e[e.WARNING=2]="WARNING",e))(gd||{}),_d=(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))(_d||{}),pd=(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))(pd||{}),Ed=(e=>(e[e.TEXT=0]="TEXT",e[e.ARROW=1]="ARROW",e[e.CUSTOM=2]="CUSTOM",e))(Ed||{}),Cd=(e=>(e.VALID="valid",e.INVALID="invalid",e.VALIDATING="validating",e))(Cd||{}),Rd=(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))(Rd||{}),gI=Object.getOwnPropertyDescriptor,_I=(e,t,n,r)=>{for(var s=r>1?void 0:r?gI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},bl=(e,t)=>(n,r)=>t(n,r,e);let so=class extends Ke{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){const e=n=>{n.businesses.forEach(r=>{switch(r){case ve.UNRECOGNIZED:case ve.UNIVER_UNKNOWN:case ve.UNIVER_SLIDE:case ve.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType(ve.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 ve.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(ve.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$(ve.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(ve.UNIVER_DOC).subscribe(n=>{const r=n.getUnitId();Dl(r)||this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(ve.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(ve.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=q.deepClone(t.getSnapshot());return r.resources=n,r}};so=_I([bl(0,Ae.Inject(Js)),bl(1,Ae.Inject(Xn))],so);class pI{constructor(t={},n){p(this,"_startedTypes",new Set);p(this,"_injector");p(this,"_disposingCallbacks",new js);const r=this._injector=EI(n,t==null?void 0:t.override),{theme:s,darkMode:i,locale:o,locales:a,logLevel:l}=t;s&&this._injector.get(Ps).setTheme(s),i&&this._injector.get(Ps).setDarkMode(i),a&&this._injector.get(Cn).load(a),o&&this._injector.get(Cn).setLocale(o),l&&this._injector.get(Et).setLogLevel(l),this._init(r)}get _univerInstanceService(){return this._injector.get(Xn)}get _pluginService(){return this._injector.get(exports.PluginService)}__getInjector(){return this._injector}onDispose(t){const n=this._disposingCallbacks.add(We(t));return We(()=>n.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(t){this._injector.get(Cn).setLocale(t)}createUnit(t,n){return this._univerInstanceService.createUnit(t,n)}createUniverSheet(t){return this._injector.get(Et).warn("[Univer]","Univer.createUniverSheet is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(ve.UNIVER_SHEET,t)}createUniverDoc(t){return this._injector.get(Et).warn("[Univer]","Univer.createUniverDoc is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(ve.UNIVER_DOC,t)}createUniverSlide(t){return this._injector.get(Et).warn("[Univer]","Univer.createUniverSlide is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(ve.UNIVER_SLIDE,t)}_init(t){this._univerInstanceService.registerCtorForType(ve.UNIVER_SHEET,exports.Workbook),this._univerInstanceService.registerCtorForType(ve.UNIVER_DOC,Nt),this._univerInstanceService.registerCtorForType(ve.UNIVER_SLIDE,la);const n=t.get(Xn);n.__setCreateHandler((r,s,i,o)=>{if(!this._startedTypes.has(r)){this._pluginService.startPluginsForType(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<Ue.Ready&&(this._injector.get(exports.LifecycleService).stage=Ue.Ready)}registerPlugin(t,n){this._pluginService.registerPlugin(t,n)}registerPlugins(t){t.forEach(n=>{const[r,s]=n;this._pluginService.registerPlugin(r,s)})}}function EI(e,t){const n=sd([[kh],[Cn],[Ps],[exports.LifecycleService],[exports.PluginService],[Dr],[Xn,{useClass:exports.UniverInstanceService}],[nd,{useClass:rd}],[Et,{useClass:cu,lazy:!0}],[Hr,{useClass:exports.CommandService}],[Qs,{useClass:exports.LocalUndoRedoService,lazy:!0}],[oa,{useClass:xh}],[Jn,{useClass:au}],[Js,{useClass:exports.ResourceManagerService,lazy:!0}],[no,{useClass:so,lazy:!0}],[Dh,{useClass:exports.AuthzIoLocalService}],[td,{useClass:exports.MentionIOLocalService,lazy:!0}]],t),r=e?e.createChild(n):new Ae.Injector(n);return xl(r,[[Dr],[no]]),r}Ad();exports.ABCToNumber=$0;exports.AUTO_HEIGHT_FOR_MERGED_CELLS=Ll;exports.AbsoluteRefType=Ne;exports.ActionIterator=xn;exports.AlignTypeH=Zc;exports.AlignTypeV=Jc;exports.ArrangeTypeEnum=tu;exports.ArrowsAndMarkersShapes=Oc;exports.AsyncInterceptorManager=Kd;exports.AsyncLock=kd;exports.AutoFillSeries=dc;exports.BaselineOffset=Yt;exports.BasicShapes=Sc;exports.BlockType=Mc;exports.BooleanNumber=ie;exports.BorderStyleTypes=De;exports.BorderType=fc;exports.BuildTextUtils=Qe;exports.BulletAlignment=Br;exports.COLORS=xi;exports.CanceledError=jd;exports.CellModeEnum=Fn;exports.CellValueType=en;exports.Color=Sn;exports.ColorBuilder=Vs;exports.ColorKit=At;exports.ColorType=pt;exports.ColumnSeparatorType=xc;exports.CommandType=$r;exports.CommonHideTypes=mc;exports.ConfigService=xh;exports.ContextService=au;exports.CopyPasteType=gc;exports.CustomCommandExecutionError=Ss;exports.CustomDecorationType=pn;exports.CustomRangeType=rn;exports.DEFAULT_CELL=_0;exports.DEFAULT_DOC=ra;exports.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=eR;exports.DEFAULT_EMPTY_DOCUMENT_VALUE=Nl;exports.DEFAULT_NUMBER_FORMAT=Qu;exports.DEFAULT_RANGE=m0;exports.DEFAULT_RANGE_ARRAY=f0;exports.DEFAULT_SELECTION=g0;exports.DEFAULT_SLIDE=eh;exports.DEFAULT_STYLES=st;exports.DEFAULT_TEXT_FORMAT=Zu;exports.DEFAULT_TEXT_FORMAT_EXCEL=Ju;exports.DEFAULT_WORKSHEET_COLUMN_COUNT=Yh;exports.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=AR;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Kh;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=MR;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH=Vh;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=yR;exports.DEFAULT_WORKSHEET_ROW_COUNT=Wh;exports.DEFAULT_WORKSHEET_ROW_COUNT_KEY=bR;exports.DEFAULT_WORKSHEET_ROW_HEIGHT=Gh;exports.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=TR;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=zh;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=NR;exports.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=oo;exports.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=io;exports.DOCS_ZEN_EDITOR_UNIT_ID_KEY=yl;exports.DOC_DRAWING_PRINTING_COMPONENT_KEY=I0;exports.DOC_RANGE_TYPE=Iu;exports.DashStyleType=$c;exports.DataStreamTreeNodeType=Ah;exports.DataStreamTreeTokenType=at;exports.DataValidationErrorStyle=gd;exports.DataValidationImeMode=_d;exports.DataValidationOperator=pd;exports.DataValidationRenderMode=Ed;exports.DataValidationStatus=Cd;exports.DataValidationType=Rd;exports.DeleteDirection=_c;exports.DependentOn=ZR;exports.DesktopLogService=cu;exports.DeveloperMetadataVisibility=pc;exports.Dimension=Ec;exports.Direction=Cc;exports.Disposable=Ke;exports.DisposableCollection=js;exports.DocStyleType=yc;exports.DocumentDataModel=Nt;exports.DocumentFlavor=Eo;exports.DrawingTypeEnum=nu;exports.EDITOR_ACTIVATED=Uh;exports.EXTENSION_NAMES=th;exports.ErrorService=kh;exports.EventState=Lh;exports.EventSubject=tR;exports.FOCUSING_COMMON_DRAWINGS=dR;exports.FOCUSING_DOC=Rr;exports.FOCUSING_EDITOR_BUT_HIDDEN=oR;exports.FOCUSING_EDITOR_INPUT_FORMULA=aR;exports.FOCUSING_EDITOR_STANDALONE=cR;exports.FOCUSING_FX_BAR_EDITOR=Ph;exports.FOCUSING_PANEL_EDITOR=uR;exports.FOCUSING_SHEET=Hn;exports.FOCUSING_SLIDE=Ir;exports.FOCUSING_UNIT=Cr;exports.FOCUSING_UNIVER_EDITOR=lR;exports.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=hR;exports.FORMULA_EDITOR_ACTIVATED=fR;exports.FollowNumberWithType=Nc;exports.FontItalic=bs;exports.FontStyleType=kn;exports.FontWeight=As;exports.GridType=Lc;exports.HLSColor=_u;exports.HorizontalAlign=Tt;exports.IAuthzIoService=Dh;exports.ICommandService=Hr;exports.IConfigService=oa;exports.IContextService=Jn;exports.IImageIoService=Qi;exports.ILocalStorageService=WR;exports.ILogService=Et;exports.IMentionIOService=td;exports.IPermissionService=nd;exports.IResourceLoaderService=no;exports.IResourceManagerService=Js;exports.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=Ml;exports.IUndoRedoService=Qs;exports.IUniverInstanceService=Xn;exports.ImageCacheMap=hd;exports.ImageSourceType=aa;exports.ImageUploadStatusType=Fh;exports.InterceptorEffectEnum=Pn;exports.InterceptorManager=Gd;exports.InterpolationPointType=Rc;exports.JSON1=x_;exports.JSONX=Gt;exports.LRUHelper=ur;exports.LRUMap=yr;exports.LifecycleStages=Ue;exports.LifecycleUnreachableError=Qh;exports.ListGlyphType=fe;exports.LocaleService=Cn;exports.LocaleType=Fr;exports.LogLevel=lu;exports.MOVE_BUFFER_VALUE=cr;exports.MemoryCursor=vn;exports.MentionType=ws;exports.NAMED_STYLE_MAP=E0;exports.NAMED_STYLE_SPACE_MAP=C0;exports.NamedStyleType=Xe;exports.NilCommand=uu;exports.NumberUnitType=qc;exports.ObjectMatrix=dt;exports.ObjectRelativeFromH=Kc;exports.ObjectRelativeFromV=Xc;exports.OtherShapes=vc;exports.PAGE_SIZE=S0;exports.PAPER_TYPES=w_;exports.PRESET_LIST_TYPE=Yr;exports.PRINT_CHART_COMPONENT_KEY=R0;exports.PageElementType=ru;exports.PageOrientType=eu;exports.PageType=Co;exports.PaperType=ct;exports.ParagraphElementType=Pc;exports.ParagraphStyleBuilder=Lr;exports.ParagraphStyleValue=Vr;exports.PermissionService=rd;exports.PermissionStatus=ca;exports.Plugin=to;exports.PositionedObjectLayoutType=Fc;exports.PresetListType=kt;exports.ProtectionType=Ic;exports.QuickListType=Eh;exports.QuickListTypeMap=Z0;exports.RANGE_DIRECTION=Ru;exports.RANGE_TYPE=_e;exports.RBush=Ls;exports.RCDisposable=u_;exports.RGBA_PAREN=q_;exports.RGB_PAREN=X_;exports.ROTATE_BUFFER_VALUE=mu;exports.RTree=iI;exports.Range=Kn;exports.Rectangle=on;exports.RedoCommand=ud;exports.RedoCommandId=ad;exports.RefAlias=B0;exports.Registry=go;exports.RegistryAsMap=_o;exports.RelativeDate=bc;exports.RelativeSlideLink=su;exports.RgbColor=Ts;exports.RichTextBuilder=En;exports.RichTextValue=Qt;exports.RxDisposable=c_;exports.SHEET_EDITOR_UNITS=p0;exports.SectionType=Dc;exports.SheetTypes=Ac;exports.SheetViewModel=qh;exports.SliceBodyType=na;exports.SlideDataModel=la;exports.SpacingRule=Bc;exports.SpecialShapes=wc;exports.Styles=Bh;exports.THEME_COLORS=gu;exports.TabStopAlignment=Hc;exports.TableAlignmentType=Wc;exports.TableLayoutType=Yc;exports.TableRowHeightRule=Vc;exports.TableSizeType=jc;exports.TableTextWrapType=Gc;exports.TextDecoration=Tc;exports.TextDecorationBuilder=Jt;exports.TextDirection=Tr;exports.TextDirectionType=Uc;exports.TextStyleBuilder=nn;exports.TextStyleValue=Gr;exports.TextX=Me;exports.TextXActionType=Z;exports.ThemeColor=ys;exports.ThemeColorType=it;exports.ThemeColors=Ys;exports.ThemeService=Ps;exports.Tools=q;exports.UndoCommand=cd;exports.UndoCommandId=ld;exports.UnitModel=Ws;exports.Univer=pI;exports.UniverInstanceType=ve;exports.UpdateDocsAttributeType=Ee;exports.UserManagerService=Dr;exports.VerticalAlign=_n;exports.VerticalAlignmentType=zc;exports.Worksheet=xr;exports.WrapStrategy=In;exports.WrapTextType=kc;exports.addLinkToDocumentModel=$h;exports.afterInitApply=Y_;exports.afterTime=j_;exports.awaitTime=oI;exports.binSearchFirstGreaterThanTarget=fu;exports.binarySearchArray=G_;exports.bufferDebounceTime=H_;exports.cellToRange=bp;exports.characterSpacingControlType=Qc;exports.checkForSubstrings=Tp;exports.checkIfMove=z_;exports.checkParagraphHasBullet=uE;exports.checkParagraphHasIndent=hE;exports.checkParagraphHasIndentByStyle=bu;exports.codeToBlob=V_;exports.composeBody=Xi;exports.composeInterceptors=Pl;exports.composeStyles=ar;exports.concatMatrixArray=gp;exports.convertBodyToHtml=K_;exports.convertCellToRange=Su;exports.convertObservableToBehaviorSubject=W_;exports.covertCellValue=Bi;exports.covertCellValues=Ap;exports.covertTextRunToHtml=Di;exports.createAsyncInterceptorKey=Vd;exports.createDefaultUser=Us;exports.createDocumentModelWithStyle=Sr;exports.createInterceptorKey=Yd;exports.createInternalEditorID=$d;exports.createRowColIter=Vi;exports.dayjs=zt;exports.debounce=Xg;exports.dedupe=Td;exports.dedupeBy=yd;exports.deepCompare=Io;exports.delayAnimationFrame=aI;exports.deleteContent=Tu;exports.extractPureTextFromCell=Zh;exports.fromCallback=hu;exports.fromEventSubject=nR;exports.fromObservable=l_;exports.generateRandomId=tt;exports.get=nc;exports.getArrayLength=tn;exports.getBodySlice=yt;exports.getBodySliceHtml=cs;exports.getBorderStyleType=Op;exports.getCellCoordByIndexSimple=ha;exports.getCellInfoInMergeData=fp;exports.getCellPositionByIndexSimple=fI;exports.getCellValueType=up;exports.getCellWithCoordByIndexCore=Un;exports.getColorStyle=Dt;exports.getCustomBlockSlice=Sh;exports.getCustomDecorationSlice=vh;exports.getCustomRangeSlice=Oh;exports.getDocsUpdateBody=vp;exports.getIntersectRange=rh;exports.getOriginCellValue=DR;exports.getParagraphsSlice=Ih;exports.getPlainText=Zs;exports.getReverseDirection=v_;exports.getSectionBreakSlice=oC;exports.getTableSlice=Rh;exports.getTextRunSlice=xs;exports.getTransformOffsetX=fd;exports.getTransformOffsetY=md;exports.getWorksheetUID=kR;exports.groupBy=Ld;exports.handleStyleToString=Sp;exports.hashAlgorithm=fE;exports.horizontalLineSegmentsSubtraction=zs;exports.insertMatrixArray=Ui;exports.insertTextToContent=Au;exports.invertColorByHSL=ef;exports.invertColorByMatrix=nf;exports.isBlackColor=lp;exports.isBooleanString=Bd;exports.isCellCoverable=Fi;exports.isCellV=Cu;exports.isDefaultFormat=h0;exports.isEmptyCell=Ou;exports.isFormulaId=Ip;exports.isFormulaString=vu;exports.isICellData=Eu;exports.isInternalEditorID=Dl;exports.isNodeEnv=O_;exports.isNotNullOrUndefined=Hh;exports.isNullCell=hp;exports.isNumeric=oc;exports.isPatternEqualWithoutDecimal=d0;exports.isRangesEqual=pR;exports.isRealNum=dE;exports.isSafeNumeric=r_;exports.isSameStyleTextRun=wu;exports.isTextFormat=u0;exports.isUnitRangesEqual=ER;exports.isValidRange=wp;exports.isWhiteColor=cp;exports.makeArray=Dd;exports.makeCellRangeToRangeData=Rp;exports.makeCellToSelection=Cp;exports.makeCustomRangeStream=RC;exports.mapObjectMatrix=mp;exports.merge=Hs;exports.mergeLocales=mE;exports.mergeOverrideWithDependencies=sd;exports.mergeSets=o_;exports.mergeWith=Qg;exports.mergeWorksheetSnapshotWithDefault=Xh;exports.mixinClass=n_;exports.moveMatrixArray=ki;exports.moveRangeByOffset=y0;exports.nameCharacterCheck=sI;exports.normalizeBody=aC;exports.normalizeTextRuns=Wr;exports.numberToABC=j0;exports.numberToListABC=W0;exports.numfmt=c0;exports.queryObjectMatrix=F0;exports.registerDependencies=Hd;exports.remove=Ur;exports.repeatStringNumTimes=ih;exports.replaceInDocumentBody=JC;exports.requestImmediateMacroTask=i_;exports.rotate=Md;exports.searchArray=lr;exports.searchInOrderedArray=du;exports.selectionToArray=dp;exports.sequence=lc;exports.sequenceAsync=ac;exports.sequenceExecute=Gs;exports.sequenceExecuteAsync=$_;exports.set=t_;exports.shallowEqual=Ul;exports.skipParseTagNames=mI;exports.sliceMatrixArray=_p;exports.sortRules=Y0;exports.sortRulesByDesc=G0;exports.sortRulesFactory=jr;exports.spliceArray=Pi;exports.splitIntoGrid=ea;exports.takeAfter=Li;exports.textDiff=sa;exports.throttle=Wd;exports.toDisposable=We;exports.touchDependencies=xl;exports.updateAttributeByDelete=wh;exports.updateAttributeByInsert=bh;exports.willLoseNumericPrecision=s_;Object.keys(Ae).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>Ae[e]})});
package/lib/es/index.js CHANGED
@@ -15683,7 +15683,7 @@ class pE extends Ve {
15683
15683
  }
15684
15684
  }
15685
15685
  var oc = /* @__PURE__ */ ((e) => (e.URL = "URL", e.UUID = "UUID", e.BASE64 = "BASE64", e))(oc || {}), EE = /* @__PURE__ */ ((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))(EE || {});
15686
- const pl = ht("core.image-io.service"), CE = "0.10.0", RE = {
15686
+ const pl = ht("core.image-io.service"), CE = "0.10.1", RE = {
15687
15687
  version: CE
15688
15688
  };
15689
15689
  function IE(e = "", t = Ts.ZH_CN, n = "") {
package/lib/index.js CHANGED
@@ -15683,7 +15683,7 @@ class pE extends Ve {
15683
15683
  }
15684
15684
  }
15685
15685
  var oc = /* @__PURE__ */ ((e) => (e.URL = "URL", e.UUID = "UUID", e.BASE64 = "BASE64", e))(oc || {}), EE = /* @__PURE__ */ ((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))(EE || {});
15686
- const pl = ht("core.image-io.service"), CE = "0.10.0", RE = {
15686
+ const pl = ht("core.image-io.service"), CE = "0.10.1", RE = {
15687
15687
  version: CE
15688
15688
  };
15689
15689
  function IE(e = "", t = Ts.ZH_CN, n = "") {
package/lib/umd/index.js CHANGED
@@ -5,4 +5,4 @@
5
5
  `,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))(lt||{});function EC(e){return`${e}`}const CC=[lt.TABLE_START,lt.TABLE_ROW_START,lt.TABLE_CELL_START,lt.TABLE_CELL_END,lt.TABLE_ROW_END,lt.TABLE_END],Ks=e=>{const t=e.endsWith(`\r
6
6
  `)?e.slice(0,-2):e;return CC.reduce((n,r)=>n.replaceAll(r,""),t)},RC=e=>e?Ks(e).replaceAll("\r","")==="":!0,IC=e=>{const t=e.replace(/\n/g,"\r"),n=[],r=[];let s=0,i="";const o=(l,c=!0)=>{const u=t.slice(s,l);if(Z.isLegalUrl(u)){const h=tt(),d=`${u}`,m={startIndex:s,endIndex:s+d.length-1,rangeId:h,rangeType:Jt.HYPERLINK,properties:{url:e}};r.push(m),i+=d,s=l+1,c&&(i+="\r",n.push({startIndex:l}))}else i+=t.slice(s,l+1),s=l+1,c&&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}},jo={id:"default_doc",documentStyle:{}};class SC extends is{constructor(n){var r;super();C(this,"type",we.UNIVER_DOC);C(this,"_name$",new oe.BehaviorSubject(""));C(this,"name$",this._name$.asObservable());C(this,"snapshot");this.snapshot={...jo,...n},this._name$.next((r=this.snapshot.title)!=null?r:"No Title")}getUnitId(){throw new Error("Method not implemented.")}getRev(){var n;return(n=this.snapshot.rev)!=null?n:1}incrementRev(){this.snapshot.rev=this.getRev()+1}setRev(n){this.snapshot.rev=n}setName(n){this.snapshot.title=n,this._name$.next(n)}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get zoomRatio(){var n;return((n=this.snapshot.settings)==null?void 0:n.zoomRatio)||1}resetDrawing(n,r){this.snapshot.drawings=n,this.snapshot.drawingsOrder=r}getBody(){return this.snapshot.body}getSnapshot(){return this.snapshot}getBulletPresetList(){var s;const n=(s=this.snapshot.lists)!=null?s:{};return{...Ur,...n}}updateDocumentId(n){this.snapshot.id=n}updateDocumentRenderConfig(n){const{documentStyle:r}=this.snapshot;r.renderConfig==null?r.renderConfig=n:r.renderConfig={...r.renderConfig,...n}}getDocumentStyle(){return this.snapshot.documentStyle}updateDocumentStyle(n){this.snapshot.documentStyle==null?this.snapshot.documentStyle=n:this.snapshot.documentStyle={...this.snapshot.documentStyle,...n}}updateDocumentDataMargin(n){const{t:r,l:s,b:i,r:o}=n,{documentStyle:a}=this.snapshot;r!=null&&(a.marginTop=r),s!=null&&(a.marginLeft=s),i!=null&&(a.marginBottom=i),o!=null&&(a.marginRight=o)}updateDocumentDataPageSize(n,r){const{documentStyle:s}=this.snapshot;if(!s.pageSize){s.pageSize={width:n!=null?n:Number.POSITIVE_INFINITY,height:r!=null?r:Number.POSITIVE_INFINITY};return}n!==void 0&&(s.pageSize.width=n),r!==void 0&&(s.pageSize.height=r)}updateDrawing(n,r){const{drawings:s}=this,{width:i,height:o,left:a,top:l}=r,c=s==null?void 0:s[n];if(!c)return;const u=c.docTransform;u.size.width=i,u.size.height=o,u.positionH.posOffset=a,u.positionV.posOffset=l}setZoomRatio(n=1){this.snapshot.settings?this.snapshot.settings.zoomRatio=n:this.snapshot.settings={zoomRatio:n}}setDisabled(n){this.snapshot.disabled=n}getDisabled(){return this.snapshot.disabled}getTitle(){return this.snapshot.title}}class At extends SC{constructor(n){var s,i;super(Z.isEmptyObject(n)?w_():n);C(this,"_unitId");C(this,"headerModelMap",new Map);C(this,"footerModelMap",new Map);C(this,"change$",new oe.BehaviorSubject(0));const r=6;this._unitId=(s=this.snapshot.id)!=null?s:tt(r),this._initializeHeaderFooterModel(),this._name$.next((i=this.snapshot.title)!=null?i:"")}dispose(){super.dispose(),this.headerModelMap.forEach(n=>{n.dispose()}),this.footerModelMap.forEach(n=>{n.dispose()}),this._name$.complete()}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getCustomRanges(){var n;return(n=this.snapshot.body)==null?void 0:n.customRanges}getCustomDecorations(){var n;return(n=this.snapshot.body)==null?void 0:n.customDecorations}getSettings(){return this.snapshot.settings}reset(n){if(n.id&&n.id!==this._unitId)throw new Error("Cannot reset a document model with a different unit id!");this.snapshot={...jo,...n},this._initializeHeaderFooterModel(),this.change$.next(this.change$.value+1)}getSelfOrHeaderFooterModel(n){if(n!=null){if(this.headerModelMap.has(n))return this.headerModelMap.get(n);if(this.footerModelMap.has(n))return this.footerModelMap.get(n)}return this}getUnitId(){return this._unitId}apply(n){if(!jt.isNoop(n))return this.snapshot=jt.apply(this.snapshot,n),n!=null&&n.some(r=>Array.isArray(r)&&((r==null?void 0:r[0])==="headers"||(r==null?void 0:r[0])==="footers"))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.change$.next(this.change$.value+1),this.snapshot}sliceBody(n,r,s=Ho.copy){const i=this.getBody();if(i!=null)return bt(i,n,r,!1,s)}_initializeHeaderFooterModel(){const{headers:n,footers:r}=this.getSnapshot();if(n)for(const s in n){const i=n[s];this.headerModelMap.set(s,new At(i)),this.headerModelMap.get(s).updateDocumentId(this.getUnitId())}if(r)for(const s in r){const i=r[s];this.footerModelMap.set(s,new At(i)),this.footerModelMap.get(s).updateDocumentId(this.getUnitId())}}updateDocumentId(n){super.updateDocumentId(n),this._unitId=n}getPlainText(){var n,r;return Ks((r=(n=this.getBody())==null?void 0:n.dataStream)!=null?r:"")}}function OC(e){const{ranges:t,id:n,type:r}=e,s=new Me;let i=0;for(let o=0;o<t.length;o++){const a=t[o],{startOffset:l,endOffset:c}=a;l>0&&s.push({t:J.RETAIN,len:l-i}),s.push({t:J.RETAIN,body:{dataStream:"",customDecorations:[{id:n,type:r,startIndex:0,endIndex:c-l-1}]},len:c-l}),i=c}return s}function vC(e){var u,h,d;const{id:t,segmentId:n,documentDataModel:r}=e,s=r==null?void 0:r.getBody();if(!r||!s)return!1;const i=(d=(h=(u=r.getSelfOrHeaderFooterModel(n))==null?void 0:u.getBody())==null?void 0:h.customDecorations)==null?void 0:d.find(m=>m.id===t);if(!i)return!1;const o=new Me,{startIndex:a,endIndex:l}=i,c=l-a+1;return o.push({t:J.RETAIN,len:a}),o.push({t:J.RETAIN,len:c,body:{dataStream:"",customDecorations:[{startIndex:0,endIndex:c-1,id:t,type:gn.DELETED}]}}),o}function _h(e,t,n,r){return e<=n&&t>=n||e>=n&&e<=r}function wC(e,t){const n=[];for(let r=0,s=t.length;r<s;r++){const i=t[r];e.collapsed?i.startIndex<e.startOffset&&e.startOffset<=i.endIndex&&n.push(i):_h(e.startOffset,e.endOffset-1,i.startIndex,i.endIndex)&&n.push(i)}return n}function bC(e){return{...Z.deepClone(e),rangeId:tt()}}function AC(e,t){const n=[];let r=e[0];for(const s of t)s<e[0]||s>e[1]||(r<s&&n.push([r,s-1]),r=s+1);return r<=e[1]&&n.push([r,e[1]]),n}function ph(e,t,n,r){const s=[];for(let i=0,o=n.length;i<o;i++){const a=n[i];if((r===void 0||a.rangeType===r)&&Math.max(a.startIndex,e)<=Math.min(a.endIndex,t)&&s.push({...a}),a.startIndex>t)break}return s}function TC(e,t){var i,o,a,l,c;const n=ph(e.startOffset,e.collapsed?e.startOffset:e.endOffset-1,(i=t.customRanges)!=null?i:[]),r=Math.min(e.startOffset,(a=(o=n[0])==null?void 0:o.startIndex)!=null?a:1/0),s=Math.max(e.endOffset,((c=(l=n[n.length-1])==null?void 0:l.endIndex)!=null?c:-1/0)+1);return{startOffset:r,endOffset:s,collapsed:r===s}}var Yo,Eh;function yC(){if(Eh)return Yo;Eh=1;var e=-1,t=1,n=0;function r(g,P,v,M,T){if(g===P)return g?[[n,g]]:[];if(v!=null){var w=$(g,P,v);if(w)return w}var N=a(g,P),L=g.substring(0,N);g=g.substring(N),P=P.substring(N),N=c(g,P);var D=g.substring(g.length-N);g=g.substring(0,g.length-N),P=P.substring(0,P.length-N);var F=s(g,P);return L&&F.unshift([n,L]),D&&F.push([n,D]),B(F,T),M&&h(F),F}function s(g,P){var v;if(!g)return[[t,P]];if(!P)return[[e,g]];var M=g.length>P.length?g:P,T=g.length>P.length?P:g,w=M.indexOf(T);if(w!==-1)return v=[[t,M.substring(0,w)],[n,T],[t,M.substring(w+T.length)]],g.length>P.length&&(v[0][0]=v[2][0]=e),v;if(T.length===1)return[[e,g],[t,P]];var N=u(g,P);if(N){var L=N[0],D=N[1],F=N[2],Q=N[3],z=N[4],le=r(L,F),ue=r(D,Q);return le.concat([[n,z]],ue)}return i(g,P)}function i(g,P){for(var v=g.length,M=P.length,T=Math.ceil((v+M)/2),w=T,N=2*T,L=new Array(N),D=new Array(N),F=0;F<N;F++)L[F]=-1,D[F]=-1;L[w+1]=0,D[w+1]=0;for(var Q=v-M,z=Q%2!==0,le=0,ue=0,S=0,U=0,G=0;G<T;G++){for(var V=-G+le;V<=G-ue;V+=2){var W=w+V,j;V===-G||V!==G&&L[W-1]<L[W+1]?j=L[W+1]:j=L[W-1]+1;for(var ee=j-V;j<v&&ee<M&&g.charAt(j)===P.charAt(ee);)j++,ee++;if(L[W]=j,j>v)ue+=2;else if(ee>M)le+=2;else if(z){var te=w+Q-V;if(te>=0&&te<N&&D[te]!==-1){var k=v-D[te];if(j>=k)return o(g,P,j,ee)}}}for(var K=-G+S;K<=G-U;K+=2){var te=w+K,k;K===-G||K!==G&&D[te-1]<D[te+1]?k=D[te+1]:k=D[te-1]+1;for(var q=k-K;k<v&&q<M&&g.charAt(v-k-1)===P.charAt(M-q-1);)k++,q++;if(D[te]=k,k>v)U+=2;else if(q>M)S+=2;else if(!z){var W=w+Q-K;if(W>=0&&W<N&&L[W]!==-1){var j=L[W],ee=w+j-W;if(k=v-k,j>=k)return o(g,P,j,ee)}}}}return[[e,g],[t,P]]}function o(g,P,v,M){var T=g.substring(0,v),w=P.substring(0,M),N=g.substring(v),L=P.substring(M),D=r(T,w),F=r(N,L);return D.concat(F)}function a(g,P){if(!g||!P||g.charAt(0)!==P.charAt(0))return 0;for(var v=0,M=Math.min(g.length,P.length),T=M,w=0;v<T;)g.substring(w,T)==P.substring(w,T)?(v=T,w=v):M=T,T=Math.floor((M-v)/2+v);return x(g.charCodeAt(T-1))&&T--,T}function l(g,P){var v=g.length,M=P.length;if(v==0||M==0)return 0;v>M?g=g.substring(v-M):v<M&&(P=P.substring(0,v));var T=Math.min(v,M);if(g==P)return T;for(var w=0,N=1;;){var L=g.substring(T-N),D=P.indexOf(L);if(D==-1)return w;N+=D,(D==0||g.substring(T-N)==P.substring(0,N))&&(w=N,N++)}}function c(g,P){if(!g||!P||g.slice(-1)!==P.slice(-1))return 0;for(var v=0,M=Math.min(g.length,P.length),T=M,w=0;v<T;)g.substring(g.length-T,g.length-w)==P.substring(P.length-T,P.length-w)?(v=T,w=v):M=T,T=Math.floor((M-v)/2+v);return Y(g.charCodeAt(g.length-T))&&T--,T}function u(g,P){var v=g.length>P.length?g:P,M=g.length>P.length?P:g;if(v.length<4||M.length*2<v.length)return null;function T(ue,S,U){for(var G=ue.substring(U,U+Math.floor(ue.length/4)),V=-1,W="",j,ee,te,k;(V=S.indexOf(G,V+1))!==-1;){var K=a(ue.substring(U),S.substring(V)),q=c(ue.substring(0,U),S.substring(0,V));W.length<q+K&&(W=S.substring(V-q,V)+S.substring(V,V+K),j=ue.substring(0,U-q),ee=ue.substring(U+K),te=S.substring(0,V-q),k=S.substring(V+K))}return W.length*2>=ue.length?[j,ee,te,k,W]:null}var w=T(v,M,Math.ceil(v.length/4)),N=T(v,M,Math.ceil(v.length/2)),L;if(!w&&!N)return null;N?w?L=w[4].length>N[4].length?w:N:L=N:L=w;var D,F,Q,z;g.length>P.length?(D=L[0],F=L[1],Q=L[2],z=L[3]):(Q=L[0],z=L[1],D=L[2],F=L[3]);var le=L[4];return[D,F,Q,z,le]}function h(g){for(var P=!1,v=[],M=0,T=null,w=0,N=0,L=0,D=0,F=0;w<g.length;)g[w][0]==n?(v[M++]=w,N=D,L=F,D=0,F=0,T=g[w][1]):(g[w][0]==t?D+=g[w][1].length:F+=g[w][1].length,T&&T.length<=Math.max(N,L)&&T.length<=Math.max(D,F)&&(g.splice(v[M-1],0,[e,T]),g[v[M-1]+1][0]=t,M--,M--,w=M>0?v[M-1]:-1,N=0,L=0,D=0,F=0,T=null,P=!0)),w++;for(P&&B(g),A(g),w=1;w<g.length;){if(g[w-1][0]==e&&g[w][0]==t){var Q=g[w-1][1],z=g[w][1],le=l(Q,z),ue=l(z,Q);le>=ue?(le>=Q.length/2||le>=z.length/2)&&(g.splice(w,0,[n,z.substring(0,le)]),g[w-1][1]=Q.substring(0,Q.length-le),g[w+1][1]=z.substring(le),w++):(ue>=Q.length/2||ue>=z.length/2)&&(g.splice(w,0,[n,Q.substring(0,ue)]),g[w-1][0]=t,g[w-1][1]=z.substring(0,z.length-ue),g[w+1][0]=e,g[w+1][1]=Q.substring(ue),w++),w++}w++}}var d=/[^a-zA-Z0-9]/,m=/\s/,_=/[\r\n]/,p=/\n\r?\n$/,I=/^\r?\n\r?\n/;function A(g){function P(ue,S){if(!ue||!S)return 6;var U=ue.charAt(ue.length-1),G=S.charAt(0),V=U.match(d),W=G.match(d),j=V&&U.match(m),ee=W&&G.match(m),te=j&&U.match(_),k=ee&&G.match(_),K=te&&ue.match(p),q=k&&S.match(I);return K||q?5:te||k?4:V&&!j&&ee?3:j||ee?2:V||W?1:0}for(var v=1;v<g.length-1;){if(g[v-1][0]==n&&g[v+1][0]==n){var M=g[v-1][1],T=g[v][1],w=g[v+1][1],N=c(M,T);if(N){var L=T.substring(T.length-N);M=M.substring(0,M.length-N),T=L+T.substring(0,T.length-N),w=L+w}for(var D=M,F=T,Q=w,z=P(M,T)+P(T,w);T.charAt(0)===w.charAt(0);){M+=T.charAt(0),T=T.substring(1)+w.charAt(0),w=w.substring(1);var le=P(M,T)+P(T,w);le>=z&&(z=le,D=M,F=T,Q=w)}g[v-1][1]!=D&&(D?g[v-1][1]=D:(g.splice(v-1,1),v--),g[v][1]=F,Q?g[v+1][1]=Q:(g.splice(v+1,1),v--))}v++}}function B(g,P){g.push([n,""]);for(var v=0,M=0,T=0,w="",N="",L;v<g.length;){if(v<g.length-1&&!g[v][1]){g.splice(v,1);continue}switch(g[v][0]){case t:T++,N+=g[v][1],v++;break;case e:M++,w+=g[v][1],v++;break;case n:var D=v-T-M-1;if(P){if(D>=0&&R(g[D][1])){var F=g[D][1].slice(-1);if(g[D][1]=g[D][1].slice(0,-1),w=F+w,N=F+N,!g[D][1]){g.splice(D,1),v--;var Q=D-1;g[Q]&&g[Q][0]===t&&(T++,N=g[Q][1]+N,Q--),g[Q]&&g[Q][0]===e&&(M++,w=g[Q][1]+w,Q--),D=Q}}if(O(g[v][1])){var F=g[v][1].charAt(0);g[v][1]=g[v][1].slice(1),w+=F,N+=F}}if(v<g.length-1&&!g[v][1]){g.splice(v,1);break}if(w.length>0||N.length>0){w.length>0&&N.length>0&&(L=a(N,w),L!==0&&(D>=0?g[D][1]+=N.substring(0,L):(g.splice(0,0,[n,N.substring(0,L)]),v++),N=N.substring(L),w=w.substring(L)),L=c(N,w),L!==0&&(g[v][1]=N.substring(N.length-L)+g[v][1],N=N.substring(0,N.length-L),w=w.substring(0,w.length-L)));var z=T+M;w.length===0&&N.length===0?(g.splice(v-z,z),v=v-z):w.length===0?(g.splice(v-z,z,[t,N]),v=v-z+1):N.length===0?(g.splice(v-z,z,[e,w]),v=v-z+1):(g.splice(v-z,z,[e,w],[t,N]),v=v-z+2)}v!==0&&g[v-1][0]===n?(g[v-1][1]+=g[v][1],g.splice(v,1)):v++,T=0,M=0,w="",N="";break}}g[g.length-1][1]===""&&g.pop();var le=!1;for(v=1;v<g.length-1;)g[v-1][0]===n&&g[v+1][0]===n&&(g[v][1].substring(g[v][1].length-g[v-1][1].length)===g[v-1][1]?(g[v][1]=g[v-1][1]+g[v][1].substring(0,g[v][1].length-g[v-1][1].length),g[v+1][1]=g[v-1][1]+g[v+1][1],g.splice(v-1,1),le=!0):g[v][1].substring(0,g[v+1][1].length)==g[v+1][1]&&(g[v-1][1]+=g[v+1][1],g[v][1]=g[v][1].substring(g[v+1][1].length)+g[v+1][1],g.splice(v+1,1),le=!0)),v++;le&&B(g,P)}function x(g){return g>=55296&&g<=56319}function Y(g){return g>=56320&&g<=57343}function O(g){return Y(g.charCodeAt(0))}function R(g){return x(g.charCodeAt(g.length-1))}function b(g){for(var P=[],v=0;v<g.length;v++)g[v][1].length>0&&P.push(g[v]);return P}function y(g,P,v,M){return R(g)||O(M)?null:b([[n,g],[e,P],[t,v],[n,M]])}function $(g,P,v){var M=typeof v=="number"?{index:v,length:0}:v.oldRange,T=typeof v=="number"?null:v.newRange,w=g.length,N=P.length;if(M.length===0&&(T===null||T.length===0)){var L=M.index,D=g.slice(0,L),F=g.slice(L),Q=T?T.index:null;e:{var z=L+N-w;if(Q!==null&&Q!==z||z<0||z>N)break e;var le=P.slice(0,z),ue=P.slice(z);if(ue!==F)break e;var S=Math.min(L,z),U=D.slice(0,S),G=le.slice(0,S);if(U!==G)break e;var V=D.slice(S),W=le.slice(S);return y(U,V,W,F)}e:{if(Q!==null&&Q!==L)break e;var j=L,le=P.slice(0,j),ue=P.slice(j);if(le!==D)break e;var ee=Math.min(w-j,N-j),te=F.slice(F.length-ee),k=ue.slice(ue.length-ee);if(te!==k)break e;var V=F.slice(0,F.length-ee),W=ue.slice(0,ue.length-ee);return y(D,V,W,te)}}if(M.length>0&&T&&T.length===0)e:{var U=g.slice(0,M.index),te=g.slice(M.index+M.length),S=U.length,ee=te.length;if(N<S+ee)break e;var G=P.slice(0,S),k=P.slice(N-ee);if(U!==G||te!==k)break e;var V=g.slice(S,w-ee),W=P.slice(S,N-ee);return y(U,V,W,te)}return null}function H(g,P,v,M){return r(g,P,v,M,!0)}return H.INSERT=t,H.DELETE=e,H.EQUAL=n,Yo=H,Yo}var NC=yC();const Go=mt(NC);function MC(e){var h,d,m;const{rangeId:t,segmentId:n,documentDataModel:r,insert:s}=e,i=(d=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.customRanges)==null?void 0:d.find(_=>_.rangeId===t);if(!i)return!1;const{startIndex:o,endIndex:a}=i,l=new Me,c=a-o+1;l.push({t:J.RETAIN,len:o}),l.push({t:J.RETAIN,len:c,body:{dataStream:"",customRanges:[]}}),s&&l.push({t:J.INSERT,body:s,len:s.dataStream.length});const u=a+1+((m=s==null?void 0:s.dataStream.length)!=null?m:0);return l.selections=[{startOffset:u,endOffset:u,collapsed:!0}],l}function LC(e){const{ranges:t,rangeId:n,rangeType:r,wholeEntity:s,properties:i,body:o}=e;let a=0;const l=new Me;let c=!1;return t.forEach(u=>{var x,Y,O;const h=TC(u,o);if(!h||!o)return!1;const{startOffset:d,endOffset:m}=h,_=(x=o.customRanges)!=null?x:[],p=(R,b,y)=>{var v,M,T,w;const $=ph(R,b,_,r),H=Math.min((M=(v=$[0])==null?void 0:v.startIndex)!=null?M:1/0,R),g=Math.max((w=(T=$[$.length-1])==null?void 0:T.endIndex)!=null?w:-1/0,b),P={rangeId:y?`${n}$${y}`:n,rangeType:r,startIndex:0,endIndex:g-H,wholeEntity:s,properties:{...i}};l.push({t:J.RETAIN,len:H-a}),l.push({t:J.RETAIN,len:g-H+1,body:{dataStream:"",customRanges:[P]},coverType:Ce.COVER}),a=g+1},I=((Y=o.paragraphs)!=null?Y:[]).filter(R=>R.startIndex<m&&R.startIndex>d),A=((O=o.customBlocks)!=null?O:[]).filter(R=>R.startIndex<m&&R.startIndex>d);AC([d,m-1],[...I.map(R=>R.startIndex),...A.map(R=>R.startIndex)]).forEach(([R,b],y)=>p(R,b,y)),c=!0,l.selections=[{startOffset:h.endOffset,endOffset:h.endOffset,collapsed:!0}]}),c?l:!1}function Ch(e,t,n=0,r=null,s=!0){e.sort((c,u)=>c.startOffset-u.startOffset);const i=[],{paragraphs:o=[]}=t,a=o==null?void 0:o.find(c=>c.startIndex>=e[0].startOffset&&c.startIndex<e[0].endOffset);let l=n;if(e.forEach(c=>{const{startOffset:u,endOffset:h}=c;u>l&&(i.push({t:J.RETAIN,len:u-l}),l=u),l<h&&(i.push({t:J.DELETE,len:h-l}),l=h)}),r&&i.push({t:J.INSERT,body:r,len:r.dataStream.length}),a&&s){const c=o.find(u=>u.startIndex-n>=e[e.length-1].endOffset-1);c&&(c.startIndex>l&&(i.push({t:J.RETAIN,len:c.startIndex-l}),l=c.startIndex),i.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...c,startIndex:0,bullet:a==null?void 0:a.bullet}]},coverType:Ce.REPLACE}))}return i}function DC(e,t,n=0){const r=[];let s=n;return e.forEach(i=>{const{startOffset:o,endOffset:a}=i;o>s&&(r.push({t:J.RETAIN,len:o-s}),s=o),a>s&&(r.push({t:J.RETAIN,len:a-s,body:{...Z.deepClone(t),dataStream:""}}),s=a)}),r}const UC=e=>{var h;const{selection:t,body:n,doc:r}=e,s=t.segmentId,i=(h=r.getSelfOrHeaderFooterModel(s))==null?void 0:h.getBody();if(!i)return!1;const o=t.collapsed?null:bt(i,t.startOffset,t.endOffset),a=Go(o?o.dataStream:"",n.dataStream);let l=0;const c=a.map(([d,m])=>{switch(d){case 0:{const _={t:J.RETAIN,body:{...bt(n,l,l+m.length,!1),dataStream:""},len:m.length};return l+=m.length,_}case 1:{const _={t:J.INSERT,body:bt(n,l,l+m.length),len:m.length};return l+=m.length,_}default:return{t:J.DELETE,len:m.length}}}),u=new Me;return u.push({t:J.RETAIN,len:t.startOffset}),u.push(...c),u};function PC(e,t){return!!((e==null?void 0:e.length)===(t==null?void 0:t.length)&&(e!=null&&e.every((n,r)=>JSON.stringify(n)===JSON.stringify(t==null?void 0:t[r]))))}const kC=e=>{var d;const{selection:t,body:n,doc:r,themeService:s}=e,i=t.segmentId,o=(d=r.getSelfOrHeaderFooterModel(i))==null?void 0:d.getBody();if(!o)return!1;const a=t.collapsed?null:bt(o,t.startOffset,t.endOffset),l=Go(a?a.dataStream:"",n.dataStream);let c=0;const u=l.map(([m,_])=>{switch(m){case 0:{const p=zs(n,c,c+_.length,!1),I=zs(a,c,c+_.length,!1),A={t:J.RETAIN,body:PC(p,I)?void 0:{textRuns:p==null?void 0:p.map(B=>{var x,Y,O,R,b,y,$;return{...B,ts:{...B.ts,cl:(O=(Y=(x=B.ts)==null?void 0:x.cl)==null?void 0:Y.rgb)!=null&&O.includes(".")?{rgb:s.getColorFromTheme((y=(b=(R=B.ts)==null?void 0:R.cl)==null?void 0:b.rgb)!=null?y:"")}:($=B.ts)==null?void 0:$.cl}}}),dataStream:""},len:_.length};return c+=_.length,A}case 1:{const p={t:J.INSERT,body:bt(n,c,c+_.length),len:_.length};return c+=_.length,p}default:return{t:J.DELETE,len:_.length}}});if(u.every(m=>m.t===J.RETAIN&&!m.body))return!1;const h=new Me;return h.push({t:J.RETAIN,len:t.startOffset}),h.push(...u),h};function FC(e,t){const n=[],{customBlocks:r=[]}=e;for(const s of t){const{startOffset:i,endOffset:o}=s;if(!(i==null||o==null))for(const a of r){const{startIndex:l}=a;l>=i&&l<o&&n.push(a.blockId)}}return n}function xC(e,t=""){if(!t)return["body"];const{headers:n,footers:r}=e.getSnapshot();if(n==null&&r==null)throw new Error("Document data model must have headers or footers when update by segment id");if((n==null?void 0:n[t])!=null)return["headers",t,"body"];if((r==null?void 0:r[t])!=null)return["footers",t,"body"];throw new Error("Segment id not found in headers or footers")}const BC=e=>{var p,I,A,B;const{selection:t,documentDataModel:n,drawings:r}=e,{collapsed:s,startOffset:i,segmentId:o}=t,a=new Me,l=jt.getInstance(),c=[],u=n.getSelfOrHeaderFooterModel(o).getBody();if(!u)return!1;const h=(I=(p=n.getSnapshot().drawingsOrder)==null?void 0:p.length)!=null?I:0;let d=0;if(s)i>0&&a.push({t:J.RETAIN,len:i});else{const x=Ch([t],u,0,null,!1);a.push(...x);const Y=FC(u,[t]),O=(A=n.getDrawings())!=null?A:{},R=(B=n.getDrawingsOrder())!=null?B:[],b=Y.sort((y,$)=>R.indexOf(y)>R.indexOf($)?-1:R.indexOf(y)<R.indexOf($)?1:0);if(b.length>0)for(const y of b){const $=O[y],H=R.indexOf(y);if($==null||H<0)continue;const g=l.removeOp(["drawings",y],$),P=l.removeOp(["drawingsOrder",H],y);c.push(g),c.push(P),d++}}a.push({t:J.INSERT,body:{dataStream:"\b".repeat(r.length),customBlocks:r.map((x,Y)=>({startIndex:Y,blockId:x.drawingId}))},len:r.length});const m=xC(n,o),_=l.editOp(a.serialize(),m);c.push(_);for(const x of r){const{drawingId:Y}=x,O=l.insertOp(["drawings",Y],x),R=l.insertOp(["drawingsOrder",h-d],Y);c.push(O),c.push(R)}return c.reduce((x,Y)=>jt.compose(x,Y),null)};function $C(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 HC(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 WC(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function Vo(e,t,n,r){const{startOffset:s,endOffset:i}=e,o=r!=null?r:Ko(t,n),a=[];let l=-1;for(let c=0;c<o.length;c++){const u=o[c],{startIndex:h}=u;(s>l&&s<=h||i>l&&i<=h||h>=s&&h<=i)&&a.push(u),l=h}return a}function zo(e,t,n){const r=[],s=Ko(t,n);for(const i of e){const o=Vo(i,t,n,s);r.push(...o)}return r}const jC=[lt.PARAGRAPH,lt.TABLE_START,lt.TABLE_END,lt.TABLE_ROW_START,lt.TABLE_CELL_START,lt.TABLE_CELL_END];function Ko(e,t){const n=[];for(let r=0;r<e.length;r++){const s=e[r],{startIndex:i}=s;let o=i-1;for(;!jC.includes(t[o])&&o>=0;)o--;n.push({...s,paragraphStart:o+1,paragraphEnd:s.startIndex})}return n}const YC=e=>{var h,d,m;const{paragraphs:t,segmentId:n,document:r}=e;let s=e.listType;const i=(d=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.paragraphs)!=null?d:[],o=t.every(_=>{var p;return((p=_.bullet)==null?void 0:p.listType.indexOf(s))===0});let l=tt(6);if(t.length===1){const _=i.indexOf(t[0]),p=i[_-1],I=i[_+1];p&&p.bullet&&p.bullet.listType.indexOf(s)===0?(l=p.bullet.listId,s!==Ft.CHECK_LIST&&(s=p.bullet.listType)):I&&I.bullet&&I.bullet.listType.indexOf(s)===0&&(l=I.bullet.listId,s!==Ft.CHECK_LIST&&(s=I.bullet.listType))}const c=new dn;c.reset();const u=new Me;for(const _ of t){const{startIndex:p,paragraphStyle:I={},bullet:A}=_;u.push({t:J.RETAIN,len:p-c.cursor}),u.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[o?{paragraphStyle:I,startIndex:0}:{startIndex:0,paragraphStyle:{...I},bullet:{nestingLevel:(m=A==null?void 0:A.nestingLevel)!=null?m:0,textStyle:{fs:20},listType:s,listId:l}}]},coverType:Ce.REPLACE}),c.moveCursorTo(p+1)}return u},GC=e=>{var h;const{paragraphIndex:t,segmentId:n,document:r}=e,s=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.paragraphs;if(s==null)return!1;const i=s.find(d=>d.startIndex===t);if(!(i!=null&&i.bullet)||i.bullet.listType.indexOf(Ft.CHECK_LIST)===-1)return!1;const o=new dn;o.reset();const a=new Me,{startIndex:l,paragraphStyle:c={}}=i,u=i.bullet.listType===Ft.CHECK_LIST?Ft.CHECK_LIST_CHECKED:Ft.CHECK_LIST;return a.push({t:J.RETAIN,len:l-o.cursor}),a.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...i,paragraphStyle:c,startIndex:0,bullet:{...i.bullet,listType:u}}]},coverType:Ce.REPLACE}),o.moveCursorTo(l+1),a},VC=e=>{var u,h;const{paragraphs:t,listType:n,segmentId:r,document:s}=e;if(((u=s.getSelfOrHeaderFooterModel(r).getBody())==null?void 0:u.paragraphs)==null)return!1;const a=tt(6),l=new dn;l.reset();const c=new Me;for(const d of t){const{startIndex:m,paragraphStyle:_={},bullet:p}=d;c.push({t:J.RETAIN,len:m-l.cursor}),c.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:_,bullet:{nestingLevel:(h=p==null?void 0:p.nestingLevel)!=null?h:0,textStyle:(p==null?void 0:p.listType)===n?p.textStyle:{fs:20},listType:n,listId:a}}]},coverType:Ce.REPLACE}),l.moveCursorTo(m+1)}return c};function zC(e,t){return t.some(n=>e.startIndex>n.startIndex&&e.startIndex<n.endIndex)}const KC=e=>{var c,u,h;const{paragraphs:t,document:n,type:r}=e,s=new dn;s.reset();const i=new Me,o=(c=n.getSnapshot().lists)!=null?c:{},a=(h=(u=n.getBody())==null?void 0:u.tables)!=null?h:[],l={...Ur,...o};for(const d of t){const{startIndex:m,paragraphStyle:_={},bullet:p}=d,I=zC(d,a);if(i.push({t:J.RETAIN,len:m-s.cursor}),p){const A=p.listType;let B=l[A].nestingLevel.length-1;I&&(B=Math.min(B,2)),i.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:{..._},bullet:{...p,nestingLevel:Math.max(Math.min(p.nestingLevel+r,B),0)}}]},coverType:Ce.REPLACE})}else i.push({t:J.RETAIN,len:1});s.moveCursorTo(m+1)}return i},XC=e=>{var I,A,B,x;const{textRanges:t,segmentId:n,document:r,style:s,paragraphTextRun:i,cursor:o,deleteLen:a,textX:l}=e,c=r.getSelfOrHeaderFooterModel(n),u=(A=(I=c.getBody())==null?void 0:I.paragraphs)!=null?A:[],h=(x=(B=c.getBody())==null?void 0:B.dataStream)!=null?x:"",d=zo(t,u,h),m=new dn;o&&m.moveCursorTo(o);const _=l!=null?l:new Me;d.sort((Y,O)=>Y.startIndex-O.startIndex);const p=Math.max(0,d[0].paragraphStart-1);p>m.cursor&&(_.push({t:J.RETAIN,len:p-m.cursor}),m.moveCursorTo(p)),a&&_.push({t:J.DELETE,len:a});for(const Y of d){const{startIndex:O,paragraphStyle:R={}}=Y,b=O-m.cursor;_.push({t:J.RETAIN,len:b,...i?{body:{dataStream:"",textRuns:[{ts:i,st:0,ed:b}]},coverType:Ce.REPLACE}:null}),_.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:{...R,...s}}]},coverType:Ce.REPLACE}),m.moveCursorTo(O+1)}return _};class Je{}C(Je,"customRange",{add:LC,delete:MC,copyCustomRange:bC,getCustomRangesInterestsWithSelection:wC,isIntersecting:_h}),C(Je,"customDecoration",{add:OC,delete:vC}),C(Je,"selection",{replace:UC,makeSelection:$C,normalizeSelection:HC,delete:Ch,replaceTextRuns:kC,retain:DC}),C(Je,"range",{isIntersects:WC,getParagraphsInRange:Vo,getParagraphsInRanges:zo}),C(Je,"transform",{getPlainText:Ks,fromPlainText:IC,isEmptyDocument:RC}),C(Je,"paragraph",{bullet:{set:VC,switch:YC,toggleChecklist:GC,changeNestLevel:KC},style:{set:XC},util:{transform:Ko,getParagraphsInRange:Vo,getParagraphsInRanges:zo}}),C(Je,"drawing",{add:BC});function qC(e,t,n,r){var c;if(t==="")return e;const s={id:"mock-id",body:e,documentStyle:{}},i=new At(s),o=t.length;let a;for(;(a=(r?i.getBody().dataStream:i.getBody().dataStream.toLowerCase()).indexOf(t))>=0;){const u=new Me,h=jt.getInstance();if(a>0&&u.retain(a),n.length>0){const d=i.sliceBody(a,a+o),m={dataStream:n};if(Array.isArray(d==null?void 0:d.textRuns)&&d.textRuns.length&&(m.textRuns=[{...d.textRuns[0],st:0,ed:n.length}]),(c=d==null?void 0:d.customRanges)!=null&&c.length){const _=d.customRanges[0];m.customRanges=[{..._,startIndex:0,endIndex:n.length-1}]}u.insert(n.length,m)}u.delete(o),i.apply(h.editOp(u.serialize()))}const l=i.getBody();return i.dispose(),l}function ZC(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 Rh(e){var t;return e.body=ZC((t=e.body)!=null?t:{dataStream:""}),e.drawingsOrder||(e.drawingsOrder=[]),e.drawings||(e.drawings={}),e.documentStyle||(e.documentStyle={}),e}class Pr{constructor(t={}){C(this,"_style");this._style=t}static create(t={}){return new Pr(t)}get fontFamily(){return this._style.ff}get fontSize(){return this._style.fs}get italic(){return this._style.it===ae.TRUE}get bold(){return this._style.bl===ae.TRUE}get underline(){return this._style.ul&&sn.create(this._style.ul)}get bottomBorderLine(){return this._style.bbl&&sn.create(this._style.bbl)}get strikethrough(){return this._style.st&&sn.create(this._style.st)}get overline(){return this._style.ol&&sn.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 rn.create(Z.deepClone(this._style))}getValue(){return{...this._style}}}class rn extends Pr{static create(t={}){return new rn(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 rn.create(Z.deepClone(this._style))}build(){return this.getValue()}}class sn{constructor(t={s:1}){C(this,"_decoration");this._decoration=t}static create(t={s:1}){return new sn(t)}get show(){return this._decoration.s===ae.TRUE}get followFontColor(){return this._decoration.c===ae.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 sn.create(Z.deepClone(this._decoration))}build(){return{...this._decoration}}}class kr{constructor(t={}){C(this,"_style");this._style=t}static create(t={}){return new kr(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===ae.TRUE}get keepNext(){return this._style.keepNext===ae.TRUE}get wordWrap(){return this._style.wordWrap===ae.TRUE}get widowControl(){return this._style.widowControl===ae.TRUE}get shading(){return this._style.shading}get suppressHyphenation(){return this._style.suppressHyphenation===ae.TRUE}copy(){return Fr.create(Z.deepClone(this._style))}getValue(){return this._style}}class Fr extends kr{static create(t={}){return new Fr(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 Fr.create(Z.deepClone(this._style))}build(){return this.getValue()}}class on{constructor(t){C(this,"_data");if(!t.body)throw new Error("Invalid document data, body is required");this._data=Rh(t)}static create(t){return new on(t)}static createByBody(t){return new on({body:t,id:"d",documentStyle:{}})}copy(){return In.create(Z.deepClone(this._data))}slice(t,n){const{body:r,...s}=this._data;return In.create({...Z.deepClone(s),body:bt(r,t,n)})}toPlainText(){var t,n;return Je.transform.getPlainText((n=(t=this._data.body)==null?void 0:t.dataStream)!=null?n:"").replaceAll("\r",`
7
7
  `)}getParagraphStyle(){var t,n;return kr.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?Pr.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===Jt.HYPERLINK))!=null?r:[]}getData(){return this._data}}class In extends on{constructor(n){super(n);C(this,"_doc");this._doc=new At(n)}static newEmptyData(){return Rh({id:"d",documentStyle:{},drawings:{},drawingsOrder:[],body:{dataStream:`\r
8
- `,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(n){return new In(n!=null?n:In.newEmptyData())}insertText(n,r,s){var u,h;let i=((h=(u=this._data.body)==null?void 0:u.dataStream.length)!=null?h:2)-2,o,a;if(typeof n=="string"?o=n:(i=Math.min(n,i),o=r),typeof r=="object"?a=r instanceof rn?r.build():r:a=s instanceof rn?s.build():s,!o)return this;const l={dataStream:o,textRuns:a?[{ts:a,st:i,ed:i+o.length}]:[]},c=Je.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:l});if(!c)throw new Error("Insert text failed, please check.");return Me.apply(this._doc.getBody(),c.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 on?n.getData():n:(s=Math.min(n,s),i=r instanceof on?r.getData():r);const o=Je.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 Me.apply(this._doc.getBody(),o.serialize()),this}delete(n,r){if(r!==void 0){if(!r)return this;const s=Je.selection.delete([{startOffset:n,endOffset:n+r,collapsed:!0}],this._data.body);Me.apply(this._doc.getBody(),s)}return this}setStyle(n,r,s){const i={dataStream:"",textRuns:[{ts:s instanceof rn?s.build():s,st:0,ed:r-n}]},o=Je.selection.retain([{startOffset:n,endOffset:r,collapsed:!0}],i);return Me.apply(this._doc.getBody(),o),this}setLink(n,r,s){const i=Je.customRange.add({rangeType:Jt.HYPERLINK,rangeId:tt(),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 Me.apply(this._doc.getBody(),i.serialize()),this}cancelLink(n,r){if(typeof n=="string"){const s=Je.customRange.delete({rangeId:n,documentDataModel:this._doc});if(!s)throw new Error("Insert text failed, please check.");Me.apply(this._doc.getBody(),s.serialize())}else this.slice(n,r).getLinks().forEach(i=>{const o=Je.customRange.delete({rangeId:i.rangeId,documentDataModel:this._doc});if(!o)throw new Error("Insert text failed, please check.");Me.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,on.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=In.createByBody({dataStream:i,customRanges:[{rangeType:Jt.HYPERLINK,rangeId:tt(),properties:{url:o},startIndex:0,endIndex:i.length-1}]});return typeof n=="number"?this.insertRichText(n,a):this.insertRichText(a)}}const JC="__default_document_sub_component_id20231101__";class Ih{constructor(){C(this,"skipNextObservers",!1);C(this,"lastReturnValue");C(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class QC 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 Ih;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 eR(e){return new oe.Observable(t=>{const n=e.subscribeEvent(r=>{t.next(r)});return()=>n.unsubscribe()})}const Xs=Re.createIdentifier("core.resource-manager.service"),Xo={[Dt.Editor]:"Editor",[Dt.Owner]:"Owner",[Dt.Reader]:"Reader",[Dt.UNRECOGNIZED]:"UNRECOGNIZED"},qs=e=>e?{userID:`${Xo[e]}_${tt(8)}`,name:Xo[e],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},tR=(e,t)=>e.startsWith(Xo[t]);class xr extends ze{constructor(){super(...arguments);C(this,"_model",new Map);C(this,"_userChange$",new oe.Subject);C(this,"userChange$",this._userChange$.asObservable());C(this,"_currentUser$",new oe.BehaviorSubject(qs()));C(this,"currentUser$",this._currentUser$.asObservable())}dispose(){super.dispose(),this._model.clear(),this._userChange$.complete(),this._currentUser$.complete()}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(n){this.addUser(n),this._currentUser$.next(n)}addUser(n){this._model.set(n.userID,n),this._userChange$.next({type:"add",user:n})}getUser(n,r){const s=this._model.get(n);if(s)return s;r&&r()}delete(n){const r=this.getUser(n);this._model.delete(n),r&&this._userChange$.next({type:"delete",user:r})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}list(){return Array.from(this._model.values())}}var nR=Object.getOwnPropertyDescriptor,rR=(e,t,n,r)=>{for(var s=r>1?void 0:r?nR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Sh=(e,t)=>(n,r)=>t(n,r,e);f.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(qs(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:[we.UNIVER_SHEET,we.UNIVER_DOC,we.UNIVER_SLIDE],onLoad:(t,n)=>{for(const r in n)this._permissionMap.set(r,n[r])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(t){return tt(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:Si.AllCollaborator,edit:Si.AllCollaborator},creator:qs(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){}},f.AuthzIoLocalService=rR([Sh(0,Xs),Sh(1,Re.Inject(xr))],f.AuthzIoLocalService);const Oh=Re.createIdentifier("IAuthzIoIoService"),qo=Re.createIdentifier("univer.config-service");class vh{constructor(){C(this,"_configChanged$",new oe.Subject);C(this,"configChanged$",this._configChanged$.asObservable());C(this,"_config",new Map)}dispose(){this._config.clear(),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=rs(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()})}}const Br="FOCUSING_UNIT",Kn="FOCUSING_SHEET",$r="FOCUSING_DOC",Hr="FOCUSING_SLIDE",sR="FOCUSING_EDITOR_BUT_HIDDEN",wh="EDITOR_ACTIVATED",iR="FOCUSING_EDITOR_INPUT_FORMULA",bh="FOCUSING_FX_BAR_EDITOR",oR="FOCUSING_UNIVER_EDITOR",aR="FOCUSING_EDITOR_INPUT_FORMULA",lR="FOCUSING_PANEL_EDITOR",cR="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",uR="FOCUSING_COMMON_DRAWINGS",hR="FORMULA_EDITOR_ACTIVATED";class Ah extends ze{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})}}var Zo=(e=>(e.URL="URL",e.UUID="UUID",e.BASE64="BASE64",e))(Zo||{}),Th=(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))(Th||{});const Jo=Re.createIdentifier("core.image-io.service"),dR={version:"0.10.0"};function fR(e="",t=lr.ZH_CN,n=""){return{id:e,sheetOrder:[],name:n,appVersion:dR.version,locale:t,styles:{},sheets:{},resources:[]}}class yh{constructor(t={}){C(this,"_styles");C(this,"_cacheMap",new _r(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=tt(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&&Z.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(Z.diffValue(n[r],t))return r;return null}}const mR=(e,t)=>t.length===e.length&&!e.some(n=>t.some(r=>!nn.equals(r,n))),gR=(e,t)=>t.length===e.length&&e.every((n,r)=>{const s=t[r];return s.unitId===n.unitId&&s.sheetId===n.sheetId&&nn.equals(n.range,s.range)}),Qo={t:0,b:2,l:2,r:2},_R=e=>({sbr:.6,sbo:e,spr:.6,spo:e}),Nh=90;function Wr(e,t,n={}){const r=e.length,{textRotation:s,paddingData:i,horizontalAlign:o=Ot.UNSPECIFIED,verticalAlign:a=fn.UNSPECIFIED,wrapStrategy:l=mn.UNSPECIFIED,cellValueType:c}=n,{t:u,r:h,b:d,l:m}=i||Qo,{vertexAngle:_,centerAngle:p}=Ph(s),I={id:"d",body:{dataStream:`${e}${_a}`,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:u,marginBottom:d,marginRight:h,marginLeft:m,renderConfig:{horizontalAlign:o,verticalAlign:a,centerAngle:p,vertexAngle:_,wrapStrategy:l,cellValueType:c,zeroWidthParagraphBreak:1}},drawings:{},drawingsOrder:[]};return new At(I)}function pR(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 Mh(e){if(!e)return{};const{ff:t,fs:n,it:r,bl:s,ul:i,st:o,ol:a,cl:l}=e,c={};return t&&(c.ff=t),n&&(c.fs=n),r&&(c.it=r),s&&(c.bl=s),i&&(c.ul=i),o&&(c.st=o),a&&(c.ol=a),l&&(c.cl=l),c}function Lh(e,t,n){var i;const r=e.getBody();if((i=r.customRanges)!=null&&i.some(o=>o.rangeType===Jt.HYPERLINK))return;const s=Je.customRange.add({ranges:[{startOffset:0,endOffset:r.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:Jt.HYPERLINK,body:r,properties:{url:t,refId:n}});s&&Me.apply(r,s.serialize())}function Dh(e){return e!=null}const ER='"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';function Uh(e){const t=st.ff,n=st.fs;if(!e){const h=`${n}pt ${t}`;return{fontCache:h,fontString:h,fontSize:n,originFontSize:n,fontFamily:t}}let r=Mn.ITALIC;(e.it===0||e.it===void 0)&&(r=Mn.NORMAL);let s=Mn.BOLD;(e.bl===0||e.bl===void 0)&&(s=Mn.NORMAL);let i=n;e.fs&&(i=Math.ceil(e.fs));let o=t;if(e.ff){let h=e.ff;h=h.replace(/"/g,"").replace(/'/g,""),h.indexOf(" ")>-1&&(h=`"${h}"`),h==null&&(h=t),o=h}const{va:a}=e;let l=i;if(a===Ht.SUBSCRIPT||a===Ht.SUPERSCRIPT){const h=CR(o,l),{sbr:d,spr:m}=h;l*=a===Ht.SUBSCRIPT?d:m}const c=`${r} ${s} ${l}pt ${o}`,u=`${c}, ${ER} `;return{fontCache:c,fontString:u,fontSize:l,originFontSize:i,fontFamily:o}}function CR(e,t){return _R(t)}function Ph(e){const{a:t=0,v:n=ae.FALSE}=e||{a:0,v:ae.FALSE};let r=0,s=t;return n===ae.TRUE&&(r=Nh,s=Nh),{centerAngle:r,vertexAngle:s}}class RR{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!==ae.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:pe.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:pe.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:pe.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:pe.COLUMN}),r}getColumnDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getColumn(i);r[s]=o!=null?o:{w:this._config.defaultColumnWidth,hd:ae.FALSE},s++}return r}getSize(){return Qt(this._columnData)}getColumnWidth(t){var n,r;return(r=(n=this._columnData[t])==null?void 0:n.w)!=null?r:this._config.defaultColumnWidth}setColumnWidth(t,n){const r=this._columnData[t];n===this._config.defaultColumnWidth?r&&(delete r.w,Object.keys(r).length===0&&delete this._columnData[t]):this._columnData[t]=r?{...r,w:n}:{w:n}}getColumn(t){return this._columnData[t]}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}}const IR=2e3;class SR{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.getRow(i);r[s]=o!=null?o:{h:this._config.defaultRowHeight,hd:ae.FALSE},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:ae.FALSE,h:s.defaultRowHeight},{ia:l,ah:c,h:u=s.defaultRowHeight}=a;i+=(l==null||l===ae.TRUE)&&typeof c=="number"?c:u}return i}setRowHeight(t,n){const r=this._rowData[t];if(n===this._config.defaultRowHeight)r&&(delete r.h,Object.keys(r).length===0&&delete this._rowData[t]);else{const s=Math.min(n,IR);this._rowData[t]=r?{...r,h:s}:{h:s}}}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:pe.ROW})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:pe.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:pe.ROW})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:pe.ROW}),r}getRowRawVisible(t){const n=this.getRow(t);return n?n.hd!==ae.TRUE:!0}getSize(){return Qt(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 OR="DEFAULT_WORKSHEET_ROW_COUNT",kh=1e3,vR="DEFAULT_WORKSHEET_COLUMN_COUNT",Fh=20,wR="DEFAULT_WORKSHEET_ROW_HEIGHT",xh=24,bR="DEFAULT_WORKSHEET_COLUMN_WIDTH",Bh=88,AR="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",$h=46,TR="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Hh=20;function Wh(e){const t={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:ae.FALSE,rowCount:kh,columnCount:Fh,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Bh,defaultRowHeight:xh,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:ae.TRUE,rowHeader:{width:$h,hidden:ae.FALSE},columnHeader:{height:Hh,hidden:ae.FALSE},rightToLeft:ae.FALSE};return Object.keys(t).forEach(n=>{const r=n;typeof e[r]>"u"&&(e[r]=t[r])}),e}class yR extends ze{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 _r(5e4));C(this,"_skeletonCache",new _r(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===pe.ROW?this._createRowCache(s,r):i===pe.COLUMN?this._createColumnCache(s,r):i===pe.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||!Z.isEmptyObject(this._columnCache)?!0:this._mergeData.some(r=>r.startRow<=n&&n<=r.endRow)}isColumnContainsMergedCell(n){return this._hasAll||!Z.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 c=[];for(const u of this._mergeData||[])nn.intersects(u,{startRow:n,endRow:s,startColumn:r,endColumn:i})&&(o.push({...u}),c.push(l)),l++;return this._rangeMap.set(a,c),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 c=[];for(let u=0;u<a.length;u++){const{startRow:h,endRow:d,startColumn:m,endColumn:_}=a[u];for(let p=n;p<=s;p++){let I=!1;for(let A=r;A<=i;A++)if(p>=h&&p<=d&&A>=m&&A<=_){o.push({startRow:h,endRow:d,startColumn:m,endColumn:_}),c.push(u),I=!0;break}if(I)break}}return this._skeletonCache.set(l,c),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 jh extends ze{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,bn.Value|bn.Style,s,i):this.getRawCell(n,r)}getCellValueOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,bn.Value):this.getRawCell(n,r)}getCellStyleOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,bn.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,je(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(n){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=n,je(()=>this._rowFilteredInterceptor=null)}}const Yh={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};class jr{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");C(this,"_isRowStylePrecedeColumnStyle",!0);C(this,"_getCellHeight");var a;this.unitId=t,this._styles=r,this._snapshot=Wh(n);const{columnData:s,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:tt(6),this._cellData=new ut(o),this._viewModel=new jh((l,c)=>this.getCellRaw(l,c)),this._rowManager=new SR(this._snapshot,this._viewModel,i),this._columnManager=new RR(this._snapshot,s),this._spanModel=new yR(this._snapshot.mergeData)}__interceptViewModel(t){t(this._viewModel)}__registerGetCellHeight(t){return this._getCellHeight=t,je(()=>{this._getCellHeight=null})}getSnapshot(){return this._snapshot}getCellHeight(t,n){return this._getCellHeight?this._getCellHeight(t,n):this._snapshot.defaultRowHeight}setMergeData(t){this._snapshot.mergeData=t,this.getSpanModel().rebuild(t)}getSpanModel(){return this._spanModel}setIsRowStylePrecedeColumnStyle(t){this._isRowStylePrecedeColumnStyle=t}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)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){const t=this._snapshot.defaultStyle;return this._styles.get(t)}setDefaultCellStyle(t){this._snapshot.defaultStyle=t}getCellStyle(t,n){const r=this.getCell(t,n);if(r){const s=r.s;return typeof s=="string"?this._styles.get(s):s}return null}getComposedCellStyle(t,n,r){const s=this.getDefaultCellStyleInternal(),i=this.getRowStyle(t),o=this.getColumnStyle(n),a=this.getCell(t,n),l=this._styles.getStyleByCell(a);return(r!=null?r:this._isRowStylePrecedeColumnStyle)?ar(s,o,i,a==null?void 0:a.themeStyle,l):ar(s,i,o,a==null?void 0:a.themeStyle,l)}getComposedCellStyleByCellData(t,n,r,s){const i=this.getDefaultCellStyleInternal(),o=this.getRowStyle(t),a=this.getColumnStyle(n),l=this._styles.getStyleByCell(r);return(s!=null?s:this._isRowStylePrecedeColumnStyle)?ar(i,a,o,r==null?void 0:r.themeStyle,l):ar(i,o,a,r==null?void 0:r.themeStyle,l)}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((c,u)=>{Object.keys(u).forEach(h=>{const d=+h,m=t.getValue(c,d),_=m!=null&&m.s?this._styles.get(m.s):null,p=(_==null?void 0:_.bd)&&(_.bd.b||_.bd.l||_.bd.r||_.bd.t||_.bd.bc_tr||_.bd.bl_tr||_.bd.ml_tr||_.bd.tl_bc||_.bd.tl_br||_.bd.tl_mr);(m&&(m.v||m.p)||_!=null&&_.bg||p)&&(a?r=Math.min(r,c):(r=c,a=!0),s=Math.max(s,c),l?i=Math.min(i,d):(l=!0,i=d),o=Math.max(o,d))})}),n.forEach(c=>{a?r=Math.min(r,c.startRow):(r=c.startRow,a=!0),s=Math.max(s,c.endRow),l?i=Math.min(i,c.startColumn):(i=c.startColumn,a=!0),o=Math.max(o,c.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=Z.deepClone(t);return new jr(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,c=n;if(r){const{startRow:u,endRow:h,startColumn:d,endColumn:m}=r;t===u&&n===d?(o=h,a=m,l=u,c=d,i=!0):t>=u&&t<=h&&n>=d&&n<=m&&(o=h,a=m,l=u,c=d,s=!0)}return{actualRow:t,actualColumn:n,isMergedMainCell:i,isMerged:s,endRow:o,endColumn:a,startRow:l,startColumn:c}}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)}getRangeFilterRows(t){const n=[];for(let r=t.startRow;r<=t.endRow;r++)this.getRowFiltered(r)&&n.push(r);return n}getMatrixWithMergedCells(t,n,r,s,i=Dn.Raw){const o=this.getCellMatrix(),a=this._spanModel.getMergedCellRange(t,n,r,s),l=new ut;return Fo(t,r,n,s).forEach((c,u)=>{var d;let h;if(i===Dn.Raw)h=this.getCellRaw(c,u);else if(i===Dn.Intercepted)h=this.getCell(c,u);else if(i===Dn.Both){const m=this.getCellRaw(c,u);if(m){h={...m};const _=(d=this.getCell(c,u))==null?void 0:d.v;Dh(_)&&h&&(h.displayV=String(_))}}h&&l.setValue(c,u,h)}),a.forEach(c=>{const{startColumn:u,startRow:h,endColumn:d,endRow:m}=c;Fo(h,m,u,d).forEach((_,p)=>{_===h&&p===u&&l.setValue(_,p,{...o.getValue(_,p),rowSpan:m-h+1,colSpan:d-u+1}),(_!==h||p!==u)&&l.realDeleteValue(_,p)})}),l}getRange(t,n,r,s){return typeof t=="object"?new Wn(this,t,{getStyles:()=>this._styles}):new Wn(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,c=s;return{next(){for(;;){if(c>o&&(l+=1,c=s),l>i)return{done:!0,value:void 0};const u=a.getCell(l,c),h=!u,d=a.getMergedCell(l,c);if(d){if(l!==d.startRow||c!==d.startColumn){c=d.endColumn+1;continue}if(h&&n){c=d.endColumn+1;continue}const _={row:l,col:c,value:u};return _.colSpan=d.endColumn-d.startColumn+1,_.rowSpan=d.endRow-d.startRow+1,c=d.endColumn+1,{done:!1,value:_}}if(h&&n)c+=1;else{const m={row:l,col:c,value:u};return c+=1,{done:!1,value:m}}}}}}}}iterateByColumn(t,n=!0,r=!0){const{startRow:s,startColumn:i,endRow:o,endColumn:a}=t,l=this;return{[Symbol.iterator]:()=>{let c=s,u=i;return{next(){for(;;){if(c>o&&(u+=1,c=s),u>a)return{done:!0,value:void 0};const h=l.getMergedCell(c,u);if(h){const _=c!==h.startRow,p=_||u!==h.startColumn;if(r&&p||!r&&_){c=h.endRow+1;continue}const I=l.getCell(h.startRow,h.startColumn);if(!I&&n){c=h.endRow+1;continue}const B={row:c,col:h.startColumn,value:I};return B.colSpan=h.endColumn-h.startColumn+1,B.rowSpan=h.endRow-h.startRow+1,c=h.endRow+1,{done:!1,value:B}}const d=l.getCell(c,u);if(!d&&n)c+=1;else{const _={row:c,col:u,value:d};return c+=1,{done:!1,value:_}}}}}}}}getCellDocumentModel(t,n,r=Yh){var p;if(!t)return;const{isDeepClone:s,displayRawFormula:i,ignoreTextRotation:o}={...Yh,...r};let a,l="document";const c=pR(n),u=o?st.tr:c.textRotation||st.tr;let h=c.horizontalAlign||st.ht;const d=c.verticalAlign||st.vt,m=c.wrapStrategy||st.tb,_=c.paddingData||Qo;if(t.f&&i)a=Wr(t.f.toString(),{},{verticalAlign:d}),h=st.ht;else if(t.p){const{centerAngle:I,vertexAngle:A}=Ph(u);a=this._updateConfigAndGetDocumentModel(s?Z.deepClone(t.p):t.p,h,_,{horizontalAlign:h,verticalAlign:d,centerAngle:I,vertexAngle:A,wrapStrategy:m,zeroWidthParagraphBreak:1})}else if(t.v!=null){const I=Mh(n);l=Uh(I).fontCache;let A=Gh(t);t.t===Zt.FORCE_STRING&&i&&(A=`'${A}`),a=Wr(A,I,{...c,textRotation:u,cellValueType:t.t})}return a&&t.linkUrl&&t.linkId&&Lh(a,t.linkUrl,t.linkId),{documentModel:a,fontString:l,textRotation:u,wrapStrategy:m,verticalAlign:d,horizontalAlign:h,paddingData:_,fill:(p=n==null?void 0:n.bg)==null?void 0:p.rgb}}_updateConfigAndGetDocumentModel(t,n,r,s){var o,a,l,c,u;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=(c=r.l)!=null?c:2,t.documentStyle.marginRight=(u=r.r)!=null?u: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 h of i)h.paragraphStyle||(h.paragraphStyle={}),h.paragraphStyle.horizontalAlign=n;return new At(t)}getBlankCellDocumentModel(t,n,r){const s=this.getComposedCellStyleByCellData(n,r,t),i=Mh(s),o=this.getCellDocumentModel(t,s,{ignoreTextRotation:!0});if(o!=null)return o.documentModel==null&&(o.documentModel=Wr("",i)),o;const a="";let l="document";const c=st.tr,u=st.ht,h=st.vt,d=st.tb,m=Qo;return l=Uh({}).fontCache,{documentModel:Wr(a,i),fontString:l,textRotation:c,wrapStrategy:d,verticalAlign:h,horizontalAlign:u,paddingData:m}}getCellDocumentModelWithFormula(t,n,r){const s=this.getComposedCellStyleByCellData(n,r,t);return this.getCellDocumentModel(t,s,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(t){this._snapshot.custom=t}}function Gh(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 Je.transform.getPlainText(t);const n=e.v;return typeof n=="string"?e.t===Zt.BOOLEAN?n.toUpperCase():n.replace(/[\r\n]/g,""):typeof n=="number"?e.t===Zt.BOOLEAN?n?"TRUE":"FALSE":n.toString():typeof n=="boolean"?n?"TRUE":"FALSE":""}function NR(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 Je.transform.getPlainText(n)}return e==null?void 0:e.v}var MR=Object.getOwnPropertyDescriptor,LR=(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=o(s)||s);return s},DR=(e,t)=>(n,r)=>t(n,r,e);function UR(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}f.Workbook=class extends is{constructor(n={},r){super();C(this,"type",we.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=fR();Z.isEmptyObject(n)?this._snapshot=s:this._snapshot=Z.commonExtend(s,n);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=tt(6)),this._unitId=this._snapshot.id,this._styles=new yh(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 Z.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 jr(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()!==ae.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===ae.TRUE).map(n=>n.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden!==ae.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(Z.isEmptyObject(s)){const o=tt();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 c=new jr(this._unitId,a,this._styles);r.set(o,c),i.includes(o)||i.push(o)}this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(n){this._snapshot.custom=n}},f.Workbook=LR([DR(1,Et)],f.Workbook);class ea extends is{constructor(n){var r;super();C(this,"type",we.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={...Uu,...n},this._unitId=(r=this._snapshot.id)!=null?r:tt(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:tt(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=tt(6);return{id:n,pageType:wi.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)}}var PR=Object.getOwnPropertyDescriptor,kR=(e,t,n,r)=>{for(var s=r>1?void 0:r?PR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Vh=(e,t)=>(n,r)=>t(n,r,e);const Xn=Re.createIdentifier("univer.current");f.UniverInstanceService=class extends ze{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)}getCurrentUnitOfType(n){return this.getCurrentUnitForType(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(we.UNIVER_DOC)}getUniverDocInstance(n){return this.getUnit(n,we.UNIVER_DOC)}getUniverSheetInstance(n){return this.getUnit(n,we.UNIVER_SHEET)}getAllUnitsForType(n){var r;return(r=this._unitsByType.get(n))!=null?r:[]}changeDoc(n,r){const s=this.getAllUnitsForType(we.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 f.Workbook?(this._contextService.setContextValue(Br,!0),this._contextService.setContextValue($r,!1),this._contextService.setContextValue(Kn,!0),this._contextService.setContextValue(Hr,!1),this.setCurrentUnitForType(n)):this.focused instanceof At?(this._contextService.setContextValue(Br,!0),this._contextService.setContextValue($r,!0),this._contextService.setContextValue(Kn,!1),this._contextService.setContextValue(Hr,!1),this.setCurrentUnitForType(n)):this.focused instanceof ea?(this._contextService.setContextValue(Br,!0),this._contextService.setContextValue($r,!1),this._contextService.setContextValue(Kn,!1),this._contextService.setContextValue(Hr,!0),this.setCurrentUnitForType(n)):(this._contextService.setContextValue(Br,!1),this._contextService.setContextValue($r,!1),this._contextService.setContextValue(Kn,!1),this._contextService.setContextValue(Hr,!1))}getFocusedUnit(){return this.focused}getUnitType(n){const r=this._getUnitById(n);return r?r[1]:we.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._tryResetCurrentOnRemoval(n,i),this._tryResetFocusOnRemoval(n),this._unitDisposed$.next(s),!0}_tryResetCurrentOnRemoval(n,r){const s=this.getCurrentUnitForType(r);(s==null?void 0:s.getUnitId())===n&&(this._currentUnits.set(r,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(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]}}},f.UniverInstanceService=kR([Vh(0,Re.Inject(Re.Injector)),Vh(1,Ln)],f.UniverInstanceService);var ke=(e=>(e[e.Starting=0]="Starting",e[e.Ready=1]="Ready",e[e.Rendered=2]="Rendered",e[e.Steady=3]="Steady",e))(ke||{});const zh={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"};var FR=Object.getOwnPropertyDescriptor,xR=(e,t,n,r)=>{for(var s=r>1?void 0:r?FR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},BR=(e,t)=>(n,r)=>t(n,r,e);class Kh extends Error{constructor(t){super(`[LifecycleService]: lifecycle stage "${zh[t]}" will never be reached!`),this.name="LifecycleUnreachableError"}}f.LifecycleService=class extends ze{constructor(n){super();C(this,"_lifecycle$",new oe.BehaviorSubject(ke.Starting));C(this,"lifecycle$",this._lifecycle$.asObservable());C(this,"_lock",!1);this._logService=n,this._reportProgress(ke.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()}onStage(n){return oe.firstValueFrom(this.lifecycle$.pipe(oe.filter(r=>r>=n),Mi(r=>r===n),oe.map(()=>{}))).catch(r=>r.name==="EmptyError"?Promise.reject(new Kh(n)):Promise.reject(r))}subscribeWithPrevious(){return oe.merge(Xh(this.stage),this._lifecycle$.pipe(oe.skip(1))).pipe(Mi(n=>n===ke.Steady))}_reportProgress(n){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${zh[n]}".`)}},f.LifecycleService=xR([BR(0,Et)],f.LifecycleService);function Xh(e){switch(e){case ke.Starting:return oe.of(ke.Starting);case ke.Ready:return oe.of(ke.Starting,ke.Ready);case ke.Rendered:return oe.of(ke.Starting,ke.Ready,ke.Rendered);default:return oe.of(ke.Starting,ke.Ready,ke.Rendered,ke.Steady)}}const $R=Re.createIdentifier("ILocalStorageService");class Sn extends ze{constructor(){super();C(this,"_currentLocale$",new oe.BehaviorSubject(lr.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(je(()=>{this._locales=null,this._currentLocale$.complete(),this.localeChanged$.complete()}))}get _currentLocale(){return this._currentLocale$.value}load(n){var r;this._locales=rs((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 HR=Object.getOwnPropertyDescriptor,WR=(e,t,n,r)=>{for(var s=r>1?void 0:r?HR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},jR=(e,t)=>(n,r)=>t(n,r,e);f.MentionIOLocalService=class{constructor(t){this._userManagerService=t}async list(t){return{list:[{type:os.PERSON,mentions:[{objectType:os.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}}},f.MentionIOLocalService=WR([jR(0,Re.Inject(xr))],f.MentionIOLocalService);const qh=Re.createIdentifier("univer.service.mention-io");var ta=(e=>(e.INIT="init",e.FETCHING="fetching",e.DONE="done",e))(ta||{});const Zh=Re.createIdentifier("univer.permission-service");class Jh extends ze{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=ta.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(Kr.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 Qh(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}var YR=Object.getOwnPropertyDescriptor,GR=(e,t,n,r)=>{for(var s=r>1?void 0:r?YR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},na=(e,t)=>(n,r)=>t(n,r,e);const VR=4,ed=Symbol("DependentOn");class ra extends ze{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}C(ra,"pluginName"),C(ra,"type",we.UNIVER_UNKNOWN);class zR{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)}}function KR(...e){return function(t){t[ed]=e}}f.PluginService=class{constructor(t,n,r){C(this,"_pluginRegistry",new Map);C(this,"_pluginStore",new zR);C(this,"_seenPlugins",new Set);C(this,"_loadedPlugins",new Set);C(this,"_loadedPluginTypes",new Set([we.UNIVER_UNKNOWN]));C(this,"_flushTimerByType",new Map);this._injector=t,this._lifecycleService=n,this._logService=r}dispose(){this._pluginStore.removePlugins().forEach(t=>t.dispose()),this._flushTimerByType.forEach(t=>clearTimeout(t))}registerPlugin(t,n){this._assertPluginValid(t);const r={plugin:t,options:n};this._pluginRegistry.set(t.pluginName,r),this._logService.debug("[PluginService]",`Plugin "${t.pluginName}" registered.`);const{type:s}=t;this._loadedPluginTypes.has(s)&&(s===we.UNIVER_UNKNOWN?this._loadFromPlugins([r]):this._flushType(s))}startPluginsForType(t){this._loadedPluginTypes.has(t)||this._loadPluginsForType(t)}_loadPluginsForType(t){const n=Array.from(this._pluginRegistry.keys()),r=[];n.forEach(s=>{const i=this._pluginRegistry.get(s);i.plugin.type===t&&r.push(i)}),this._loadFromPlugins(r),this._loadedPluginTypes.add(t)}_assertPluginValid(t){const{type:n,pluginName:r}=t;if(n===we.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)}_flushType(t){this._flushTimerByType.get(t)===void 0&&this._flushTimerByType.set(t,setTimeout(()=>{this._loadPluginsForType(t),this._flushTimerByType.delete(t)},VR))}_loadFromPlugins(t){const n=[],r=new Set,s=o=>{const{plugin:a}=o,{pluginName:l}=a;if(this._loadedPlugins.has(l)||r.has(l))return;r.add(l),this._pluginRegistry.delete(l);const c=a[ed];c&&c.forEach(u=>{const h=this._pluginRegistry.get(u.pluginName);if(h)s(h);else if(!this._seenPlugins.has(u.pluginName)&&!r.has(u.pluginName)){if(a.type===we.UNIVER_UNKNOWN&&u.type!==we.UNIVER_UNKNOWN)throw new Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${a.pluginName} and the dependency is ${u.pluginName}.`);a.type!==u.type&&u.type!==we.UNIVER_UNKNOWN&&this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${u.pluginName}" which has different type.`),this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${u.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(u),s({plugin:u,options:void 0})}}),n.push(o)};t.forEach(o=>s(o));const i=n.map(o=>this._initPlugin(o.plugin,o.options));this._pluginsRunLifecycle(i)}_pluginsRunLifecycle(t){const n=this._lifecycleService.stage;if(Xh(n).subscribe(r=>this._runStage(t,r)),n!==ke.Steady){const r=this._lifecycleService.lifecycle$.pipe(oe.skip(1)).subscribe(s=>{this._runStage(t,s),s===ke.Steady&&r.unsubscribe()})}}_runStage(t,n){t.forEach(r=>{switch(n){case ke.Starting:r.onStarting();break;case ke.Ready:r.onReady();break;case ke.Rendered:r.onRendered();break;case ke.Steady:r.onSteady();break}})}_initPlugin(t,n){const r=this._injector.createInstance(t,n);return this._pluginStore.addPlugin(r),this._loadedPlugins.add(t.pluginName),this._logService.debug("[PluginService]",`Plugin "${r.getPluginName()}" loaded.`),r}},f.PluginService=GR([na(0,Re.Inject(Re.Injector)),na(1,Re.Inject(f.LifecycleService)),na(2,Et)],f.PluginService);const sa=Re.createIdentifier("resource-loader-service");var XR=Object.getOwnPropertyDescriptor,qR=(e,t,n,r)=>{for(var s=r>1?void 0:r?XR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},ZR=(e,t)=>(n,r)=>t(n,r,e);f.ResourceManagerService=class extends ze{constructor(n){super();C(this,"_resourceMap",new Map);C(this,"_register$",new oe.Subject);C(this,"register$",this._register$.asObservable());this._logService=n}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),je(()=>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(a){this._logService.error("[ResourceManagerService]","loadResources error",a)}})}unloadResources(n){this.getAllResourceHooks().forEach(r=>{r.onUnLoad(n)})}dispose(){this._register$.complete(),this._resourceMap.clear()}},f.ResourceManagerService=qR([ZR(0,Et)],f.ResourceManagerService);class Zs extends ze{constructor(){super();C(this,"_darkMode$",new oe.BehaviorSubject(!1));C(this,"darkMode$",this._darkMode$.asObservable());C(this,"_validColorCache",new Map);C(this,"_currentTheme",Xr.defaultTheme);C(this,"_currentTheme$",new oe.BehaviorSubject(this._currentTheme));C(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(je(()=>{this._currentTheme=Xr.defaultTheme,this._currentTheme$.complete(),this._darkMode$.complete()}))}get darkMode(){return this._darkMode$.getValue()}isValidThemeColor(n){if(this._validColorCache.has(n))return this._validColorCache.get(n);let r=!1;const s=n.split(".");if(s.length===1)r=n in Xr.defaultTheme;else if(s.length===2){const[i,o]=s;r=i in Xr.defaultTheme&&o in this._currentTheme[i]}return this._validColorCache.set(n,r),r}getCurrentTheme(){return this._currentTheme}setTheme(n){this._currentTheme=n,this._currentTheme$.next(n)}setDarkMode(n){this._darkMode$.next(n)}getColorFromTheme(n){return nl(this._currentTheme,n)}}var JR=Object.getOwnPropertyDescriptor,QR=(e,t,n,r)=>{for(var s=r>1?void 0:r?JR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},ia=(e,t)=>(n,r)=>t(n,r,e);const Js=Re.createIdentifier("univer.undo-redo.service"),eI=20;class td{dispose(){}async dispatchToHandlers(){return!1}}const nd="univer.command.redo",rd="univer.command.undo",sd=new class extends td{constructor(){super(...arguments);C(this,"type",dr.COMMAND);C(this,"id",rd)}handler(t){const n=t.get(Js),r=n.pitchTopUndoElement();if(!r)return!1;const s=t.get(fr);return fs(r.undoMutations,s)?(n.popUndoToRedo(),!0):!1}},id=new class extends td{constructor(){super(...arguments);C(this,"type",dr.COMMAND);C(this,"id",nd)}handler(t){const n=t.get(Js),r=n.pitchTopRedoElement();if(!r)return!1;const s=t.get(fr);return fs(r.redoMutations,s)?(n.popRedoToUndo(),!0):!1}};f.LocalUndoRedoService=class extends ze{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(sd)),this.disposeWithMe(this._commandService.registerCommand(id)),this.disposeWithMe(je(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(je(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>eI&&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())}rollback(n,r){const s=r||this._getFocusedUnitId(),i=this._getUndoStack(s),o=i==null?void 0:i[(i==null?void 0:i.length)-1];o&&o.id===n&&(i.pop(),fs(o.undoMutations,this._commandService))}__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),je(()=>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,c;let n="";const r=this._contextService.getContextValue(Kn),s=this._contextService.getContextValue(bh),i=this._contextService.getContextValue(wh);return r?s?n=si:i?n=ri:n=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":n=(c=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?c:"",n}},f.LocalUndoRedoService=QR([ia(0,Xn),ia(1,fr),ia(2,Ln)],f.LocalUndoRedoService);class od{constructor(t,n=100){C(this,"_imageCacheMap");this._injector=t,this._imageCacheMap=new _r(n)}_getImageCacheKey(t,n){return`${t}-${n}`}getImage(t,n,r,s){const i=this._getImageCacheKey(t,n),o=this._imageCacheMap.get(i);return o||((async()=>{const a=new Image,l=this._injector.has(Jo)?this._injector.get(Jo):null;if(t===Zo.UUID)try{a.src=await(l==null?void 0:l.getImage(n))||""}catch(c){console.error(c)}else a.src=n;a.onload=()=>{a.removeAttribute("data-error"),r==null||r()},a.onerror=()=>{a.setAttribute("data-error","true"),s==null||s()},this._imageCacheMap.set(i,a)})(),null)}}function tI(e){return!(e.length===0||e.length>31||e.startsWith("'")||e.endsWith("'")||/[:\\\/\?\*\[\]]/.test(e))}const ad=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],oa=1,Yr=8;class aa{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!==oa)throw new Error(`Got v${s} data when expected v${oa}.`);const i=ad[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 aa(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=ad.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,Yr,t),this.coords=new this.ArrayType(this.data,Yr+a+l,t*2),this._pos=t*2,this._finished=!0):(this.data=new ArrayBuffer(Yr+o+a+l),this.ids=new this.IndexArrayType(this.data,Yr,t),this.coords=new this.ArrayType(this.data,Yr+a+l,t*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(oa<<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 la(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],c=[];for(;l.length;){const u=l.pop()||0,h=l.pop()||0,d=l.pop()||0;if(h-d<=a){for(let I=d;I<=h;I++){const A=o[2*I],B=o[2*I+1];A>=t&&A<=r&&B>=n&&B<=s&&c.push(i[I])}continue}const m=d+h>>1,_=o[2*m],p=o[2*m+1];_>=t&&_<=r&&p>=n&&p<=s&&c.push(i[m]),(u===0?t<=_:n<=p)&&(l.push(d),l.push(m-1),l.push(1-u)),(u===0?r>=_:s>=p)&&(l.push(m+1),l.push(h),l.push(1-u))}return c}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=[],c=r*r;for(;a.length;){const u=a.pop()||0,h=a.pop()||0,d=a.pop()||0;if(h-d<=o){for(let I=d;I<=h;I++)cd(i[2*I],i[2*I+1],t,n)<=c&&l.push(s[I]);continue}const m=d+h>>1,_=i[2*m],p=i[2*m+1];cd(_,p,t,n)<=c&&l.push(s[m]),(u===0?t-r<=_:n-r<=p)&&(a.push(d),a.push(m-1),a.push(1-u)),(u===0?t+r>=_:n+r>=p)&&(a.push(m+1),a.push(h),a.push(1-u))}return l}}function la(e,t,n,r,s,i){if(s-r<=n)return;const o=r+s>>1;ld(e,t,o,r,s,i),la(e,t,n,r,o-1,1-i),la(e,t,n,o+1,s,1-i)}function ld(e,t,n,r,s,i){for(;s>r;){if(s-r>600){const c=s-r+1,u=n-r+1,h=Math.log(c),d=.5*Math.exp(2*h/3),m=.5*Math.sqrt(h*d*(c-d)/c)*(u-c/2<0?-1:1),_=Math.max(r,Math.floor(n-u*d/c+m)),p=Math.min(s,Math.floor(n+(c-u)*d/c+m));ld(e,t,n,_,p,i)}const o=t[2*n+i];let a=r,l=s;for(Gr(e,t,r,n),t[2*s+i]>o&&Gr(e,t,r,s);a<l;){for(Gr(e,t,a,l),a++,l--;t[2*a+i]<o;)a++;for(;t[2*l+i]>o;)l--}t[2*r+i]===o?Gr(e,t,r,l):(l++,Gr(e,t,l,s)),l<=n&&(r=l+1),n<=l&&(s=l-1)}}function Gr(e,t,n,r){ca(e,n,r),ca(t,2*n,2*r),ca(t,2*n+1,2*r+1)}function ca(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function cd(e,t,n,r){const s=e-n,i=t-r;return s*s+i*i}class nI{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 Hs),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 c=l.get(s);c&&c.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:c,endRow:u,endColumn:h}=s;for(let d=l;d<=u;d++){const m=a.get(d);if(m)for(let _=c;_<=h;_++){const p=m.get(_);p&&p.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 _;const{unitId:n,sheetId:r,range:s}=t,{startRow:i,startColumn:o,endRow:a,endColumn:l}=s,c=(_=this._kdTree.get(n))==null?void 0:_.get(r);if(!c)return[];const{tree:u,items:h}=c,d=u.range(o,i,l,a),m=[];for(const p of d){const I=h[p];m.push(...Array.from(I.ids))}return m}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 aa(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:c}=s;if(this._enableOneCellCache&&o===a&&l===c){this._insertOneCellCache(n,r,o,l,i);return}const u=this.getTree(n,r);Number.isNaN(o)&&(o=0),Number.isNaN(l)&&(l=0),Number.isNaN(a)&&(a=Number.POSITIVE_INFINITY),Number.isNaN(c)&&(c=Number.POSITIVE_INFINITY),u.insert({minX:l,minY:o,maxX:c,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 c of l)yield c}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:c}=s;this._enableOneCellCache?o===l&&a===c?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 Hs;s.fromJSON(t[n][r]),this._tree.get(n).set(r,s)}}}}function rI(e){return new Promise(t=>setTimeout(t,e))}function sI(e=1){return new Promise(t=>{let n=0;const r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}var iI=Object.getOwnPropertyDescriptor,oI=(e,t,n,r)=>{for(var s=r>1?void 0:r?iI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},aI=(e,t)=>(n,r)=>t(n,r,e);f.Skeleton=class extends ze{constructor(n){super();C(this,"_fontLocale");C(this,"_dirty",!0);this._localeService=n,this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(n){this._dirty=n}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}},f.Skeleton=oI([aI(0,Re.Inject(Sn))],f.Skeleton);var lI=Object.getOwnPropertyDescriptor,cI=(e,t,n,r)=>{for(var s=r>1?void 0:r?lI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Qs=(e,t)=>(n,r)=>t(n,r,e);f.SheetSkeleton=class extends f.Skeleton{constructor(n,r,s,i,o,a){super(s);C(this,"_worksheetData");C(this,"_renderRawFormula",!1);C(this,"_cellData");C(this,"_imageCacheMap");C(this,"_skipAutoHeightForMergedCells",!0);C(this,"_rowTotalHeight",0);C(this,"_columnTotalWidth",0);C(this,"_rowHeaderWidth",0);C(this,"_columnHeaderHeight",0);C(this,"_rowHeightAccumulation",[]);C(this,"_columnWidthAccumulation",[]);C(this,"_marginTop",0);C(this,"_marginLeft",0);C(this,"_scaleX");C(this,"_scaleY");C(this,"_scrollX");C(this,"_scrollY");this.worksheet=n,this._styles=r,this._contextService=i,this._configService=o,this._injector=a,this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new od(this._injector),this.initConfig()}initConfig(){var n,r;this._skipAutoHeightForMergedCells=!((n=this._configService.getConfig(Ea))!=null&&n),this.worksheet.setIsRowStylePrecedeColumnStyle((r=this._configService.getConfig(pa))!=null?r:!1)}resetCache(){}getWorksheetConfig(){return this._worksheetData}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(n){this._columnHeaderHeight=n,this._worksheetData.columnHeader.height=n}set rowHeaderWidth(n){this._rowHeaderWidth=n,this._worksheetData.rowHeader.width=n}get rowHeightAccumulation(){return this._rowHeightAccumulation}get rowTotalHeight(){return this._rowTotalHeight}get columnWidthAccumulation(){return this._columnWidthAccumulation}get columnTotalWidth(){return this._columnTotalWidth}get rowHeaderWidth(){return this._rowHeaderWidth}get columnHeaderHeight(){return this._columnHeaderHeight}setMarginLeft(n){this._marginLeft=n}setMarginTop(n){this._marginTop=n}setScale(n,r){this._updateLayout(),this._scaleX=n,this._scaleY=r||n,this._updateLayout()}setScroll(n,r){Z.isDefine(n)&&(this._scrollX=n),Z.isDefine(r)&&(this._scrollY=r)}get scrollX(){return this._scrollX}get scrollY(){return this._scrollY}get scaleX(){return this._scaleX}get scaleY(){return this._scaleY}get rowHeaderWidthAndMarginLeft(){return this.rowHeaderWidth+this._marginLeft}get columnHeaderHeightAndMarginTop(){return this.columnHeaderHeight+this._marginTop}get imageCacheMap(){return this._imageCacheMap}_generateRowMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let c=s;if(this.worksheet.getRowFiltered(l))c=0;else if(a[l]!=null){const u=a[l];if(!u)continue;const{h=s,ah:d,ia:m}=u;(m==null||m===ae.TRUE)&&typeof d=="number"?c=d:c=h,u.hd===ae.TRUE&&(c=0)}i+=c,o.push(i)}return{rowTotalHeight:i,rowHeightAccumulation:o}}_generateColumnMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let c=s;if(a[l]!=null){const u=a[l];if(!u)continue;u.w!=null&&(c=u.w),u.hd===ae.TRUE&&(c=0)}i+=c,o.push(i)}return{columnTotalWidth:i,columnWidthAccumulation:o}}intersectMergeRange(n,r){return!!this.worksheet.getMergedCell(n,r)}_getOverflowBound(n,r,s,i,o=Ot.LEFT){let a=0;if(r>s){const l=this._columnWidthAccumulation.length-1;for(let c=r;c>=s;c--){const u=c,h=this.worksheet.getCell(n,u);if(!Bi(h)&&u!==r||this.intersectMergeRange(n,u))return u===r?u:u+1>l?l:u+1;const{startX:d,endX:m}=qn(n,u,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===Ot.CENTER&&u===r?a+=(m-d)/2:a+=m-d,i<a)return u}return r}for(let l=r;l<=s;l++){const c=l,u=this.worksheet.getCell(n,c);if(!Bi(u)&&c!==r||this.intersectMergeRange(n,c))return c===r?c:c-1<0?0:c-1;const{startX:h,endX:d}=qn(n,c,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===Ot.CENTER&&c===r?a+=(d-h)/2:a+=d-h,i<a)return c}return s}_updateLayout(){if(!this.dirty)return;const{rowData:n,columnData:r,defaultRowHeight:s,defaultColumnWidth:i,rowCount:o,columnCount:a,rowHeader:l,columnHeader:c}=this._worksheetData,{rowTotalHeight:u,rowHeightAccumulation:h}=this._generateRowMatrixCache(o,n,s),{columnTotalWidth:d,columnWidthAccumulation:m}=this._generateColumnMatrixCache(a,r,i);this._rowHeaderWidth=l.hidden!==ae.TRUE?this._dynamicallyUpdateRowHeaderWidth(l):0,this._columnHeaderHeight=c.hidden!==ae.TRUE?c.height:0,this._rowTotalHeight=u,this._rowHeightAccumulation=h,this._columnTotalWidth=d,this._columnWidthAccumulation=m,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(n){}_dynamicallyUpdateRowHeaderWidth(n){const s=`${this.worksheet.getRowCount()}`.length*8;return Math.max(n.width,s)}_hasUnMergedCellInRow(n,r,s){if(!this.worksheet.getMergeData())return!1;for(let o=r;o<=s;o++){const{isMerged:a,isMergedMainCell:l}=this.worksheet.getCellInfoInMergeData(n,o);if(!a&&!l)return!0}return!1}expandRangeByMerge(n){let{startRow:r,startColumn:s,endRow:i,endColumn:o}=n;const a=this._worksheetData.mergeData;if(!a)return{startRow:r,startColumn:s,endRow:i,endColumn:o};let l=!0;const c=new ut;for(;l;){l=!1;for(let u=0;u<a.length;u++){const{startRow:h,startColumn:d,endRow:m,endColumn:_}=a[u];if(c.getValue(h,d))continue;Bu({startColumn:s,startRow:r,endColumn:o,endRow:i},{startColumn:d,startRow:h,endColumn:_,endRow:m})&&(r=Math.min(r,h),s=Math.min(s,d),i=Math.max(i,m),o=Math.max(o,_),c.setValue(h,d,!0),l=!0)}}return{startRow:r,startColumn:s,endRow:i,endColumn:o}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(n,r){return this.worksheet.getCellInfoInMergeData(n,r)}getNoMergeCellPositionByIndex(n,r,s=!0){return this.getNoMergeCellWithCoordByIndex(n,r,s)}getNoMergeCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this;let{startY:c,endY:u,startX:h,endX:d}=qn(n,r,i,o);return s&&(c+=l,u+=l,h+=a,d+=a),{startY:c,endY:u,startX:h,endX:d}}getNoMergeCellPositionByIndexWithNoHeader(n,r){const{rowHeightAccumulation:s,columnWidthAccumulation:i}=this,{startY:o,endY:a,startX:l,endX:c}=qn(n,r,s,i);return{startY:o,endY:a,startX:l,endX:c}}getRowIndexByOffsetY(n,r,s,i){var l;const{rowHeightAccumulation:o}=this;n=hd(n,r,s,this.columnHeaderHeightAndMarginTop);let a=mr(o,n,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(o[a]-n)<Math.abs(n-((l=o[a-1])!=null?l:0))&&(a=a+1),a}getColumnIndexByOffsetX(n,r,s,i){var c;const o=ud(n,r,s,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this;let l=mr(a,o,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(a[l]-o)<Math.abs(o-((c=a[l-1])!=null?c:0))&&(l=l+1),l}getCellIndexByOffset(n,r,s,i,o,a){const l=this.getRowIndexByOffsetY(r,i,o,a),c=this.getColumnIndexByOffsetX(n,s,o,a);return{row:l,column:c}}getCellByOffset(n,r,s,i,o){const a=this==null?void 0:this.getCellIndexByOffset(n,r,s,i,o,{firstMatch:!0});return a?this.worksheet.getCellInfoInMergeData(a.row,a.column):null}getCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this,c=qn(n,r,i,o,this.worksheet.getCellInfoInMergeData(n,r)),{isMerged:u,isMergedMainCell:h}=c;let{startY:d,endY:m,startX:_,endX:p,mergeInfo:I}=c,A=a,B=l;return s===!1&&(A=0,B=0),d+=B,m+=B,_+=A,p+=A,I.startY+=B,I.endY+=B,I.startX+=A,I.endX+=A,{actualRow:n,actualColumn:r,startX:_,startY:d,endX:p,endY:m,isMerged:u,isMergedMainCell:h,mergeInfo:I}}getCellWithCoordByOffset(n,r,s,i,o,a){const{row:l,column:c}=this.getCellIndexByOffset(n,r,s,i,o,a);return this.getCellWithCoordByIndex(l,c)}getOffsetByColumn(n){const{columnWidthAccumulation:r,rowHeaderWidthAndMarginLeft:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetByRow(n){const{rowHeightAccumulation:r,columnHeaderHeightAndMarginTop:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetRelativeToRowCol(n,r){const s=mr(this.columnWidthAccumulation,n);let i=0;s===0?i=n:i=n-this._columnWidthAccumulation[s-1];const o=mr(this.rowHeightAccumulation,r);let a=0;return o===0?a=r:a=r-this._rowHeightAccumulation[o-1],{row:o,column:s,columnOffset:i,rowOffset:a}}_updateConfigAndGetDocumentModel(n,r,s,i){var a,l,c,u,h;if(!i||!((a=n.body)!=null&&a.dataStream))return;n.documentStyle||(n.documentStyle={}),n.documentStyle.marginTop=(l=s.t)!=null?l:0,n.documentStyle.marginBottom=(c=s.b)!=null?c:2,n.documentStyle.marginLeft=(u=s.l)!=null?u:2,n.documentStyle.marginRight=(h=s.r)!=null?h:2,n.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},n.documentStyle.renderConfig={...n.documentStyle.renderConfig,...i};const o=n.body.paragraphs||[];for(const d of o)d.paragraphStyle||(d.paragraphStyle={}),d.paragraphStyle.horizontalAlign=r;return new At(n)}dispose(){super.dispose(),this._rowHeightAccumulation=[],this._columnWidthAccumulation=[],this._rowTotalHeight=0,this._columnTotalWidth=0,this._rowHeaderWidth=0,this._columnHeaderHeight=0,this._worksheetData=null,this._cellData=null,this._styles=null}},f.SheetSkeleton=cI([Qs(2,Re.Inject(Sn)),Qs(3,Ln),Qs(4,qo),Qs(5,Re.Inject(Re.Injector))],f.SheetSkeleton);function ua(e,t,n,r){const s=e-1,i=t-1,o=n[s]||0;let a=n[e];a==null&&(a=n[n.length-1]);const l=r[i]||0;let c=r[t];return c==null&&(c=r[r.length-1]),{startY:o,endY:a,startX:l,endX:c}}function uI(e,t,n,r){return ua(e,t,n,r)}function qn(e,t,n,r,s){e=Z.clamp(e,0,n.length-1),t=Z.clamp(t,0,r.length-1);let{startY:i,endY:o,startX:a,endX:l}=ua(e,t,n,r);if(!s)return{startY:i,endY:o,startX:a,endX:l,isMerged:!1,isMergedMainCell:!1,actualRow:e,actualColumn:t,mergeInfo:{startY:i,endY:o,startX:a,endX:l,startRow:e,startColumn:t,endRow:e,endColumn:t}};const{isMerged:c,isMergedMainCell:u,startRow:h,startColumn:d,endRow:m,endColumn:_}=s;let p={startRow:h,startColumn:d,endRow:m,endColumn:_,startY:i,endY:o,startX:a,endX:l};const I=n.length-1,A=r.length-1;if(c&&h!==-1&&d!==-1){const B=n[h-1]||0,x=n[m]||n[I],Y=r[d-1]||0,O=r[_]||r[A];p={...p,startY:B,endY:x,startX:Y,endX:O}}else if(!c&&m!==-1&&_!==-1){const B=n[m]||n[I],x=r[_]||r[A];p={...p,startY:i,endY:B,startX:a,endX:x}}return{isMerged:c,isMergedMainCell:u,actualRow:e,actualColumn:t,startY:i,endY:o,startX:a,endX:l,mergeInfo:p}}function ud(e,t,n,r){const{x:s}=n;return e/t+s-r}function hd(e,t,n,r){const{y:s}=n;return e=e/t+s-r,e}const hI=["script","style","meta","comment","link"];var dd=(e=>(e[e.INFO=0]="INFO",e[e.STOP=1]="STOP",e[e.WARNING=2]="WARNING",e))(dd||{}),fd=(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))(fd||{}),md=(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))(md||{}),gd=(e=>(e[e.TEXT=0]="TEXT",e[e.ARROW=1]="ARROW",e[e.CUSTOM=2]="CUSTOM",e))(gd||{}),_d=(e=>(e.VALID="valid",e.INVALID="invalid",e.VALIDATING="validating",e))(_d||{}),pd=(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))(pd||{}),dI=Object.getOwnPropertyDescriptor,fI=(e,t,n,r)=>{for(var s=r>1?void 0:r?dI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Ed=(e,t)=>(n,r)=>t(n,r,e);let ha=class extends ze{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){const e=n=>{n.businesses.forEach(r=>{switch(r){case we.UNRECOGNIZED:case we.UNIVER_UNKNOWN:case we.UNIVER_SLIDE:case we.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType(we.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 we.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(we.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$(we.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(we.UNIVER_DOC).subscribe(n=>{const r=n.getUnitId();Ca(r)||this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(we.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(we.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=Z.deepClone(t.getSnapshot());return r.resources=n,r}};ha=fI([Ed(0,Re.Inject(Xs)),Ed(1,Re.Inject(Xn))],ha);class mI{constructor(t={},n){C(this,"_startedTypes",new Set);C(this,"_injector");C(this,"_disposingCallbacks",new ss);const r=this._injector=gI(n,t==null?void 0:t.override),{theme:s,darkMode:i,locale:o,locales:a,logLevel:l}=t;s&&this._injector.get(Zs).setTheme(s),i&&this._injector.get(Zs).setDarkMode(i),a&&this._injector.get(Sn).load(a),o&&this._injector.get(Sn).setLocale(o),l&&this._injector.get(Et).setLogLevel(l),this._init(r)}get _univerInstanceService(){return this._injector.get(Xn)}get _pluginService(){return this._injector.get(f.PluginService)}__getInjector(){return this._injector}onDispose(t){const n=this._disposingCallbacks.add(je(t));return je(()=>n.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(t){this._injector.get(Sn).setLocale(t)}createUnit(t,n){return this._univerInstanceService.createUnit(t,n)}createUniverSheet(t){return this._injector.get(Et).warn("[Univer]","Univer.createUniverSheet is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(we.UNIVER_SHEET,t)}createUniverDoc(t){return this._injector.get(Et).warn("[Univer]","Univer.createUniverDoc is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(we.UNIVER_DOC,t)}createUniverSlide(t){return this._injector.get(Et).warn("[Univer]","Univer.createUniverSlide is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(we.UNIVER_SLIDE,t)}_init(t){this._univerInstanceService.registerCtorForType(we.UNIVER_SHEET,f.Workbook),this._univerInstanceService.registerCtorForType(we.UNIVER_DOC,At),this._univerInstanceService.registerCtorForType(we.UNIVER_SLIDE,ea);const n=t.get(Xn);n.__setCreateHandler((r,s,i,o)=>{if(!this._startedTypes.has(r)){this._pluginService.startPluginsForType(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(f.LifecycleService).stage<ke.Ready&&(this._injector.get(f.LifecycleService).stage=ke.Ready)}registerPlugin(t,n){this._pluginService.registerPlugin(t,n)}registerPlugins(t){t.forEach(n=>{const[r,s]=n;this._pluginService.registerPlugin(r,s)})}}function gI(e,t){const n=Qh([[Ah],[Sn],[Zs],[f.LifecycleService],[f.PluginService],[xr],[Xn,{useClass:f.UniverInstanceService}],[Zh,{useClass:Jh}],[Et,{useClass:Sc,lazy:!0}],[fr,{useClass:f.CommandService}],[Js,{useClass:f.LocalUndoRedoService,lazy:!0}],[qo,{useClass:vh}],[Ln,{useClass:Rc}],[Xs,{useClass:f.ResourceManagerService,lazy:!0}],[sa,{useClass:ha,lazy:!0}],[Oh,{useClass:f.AuthzIoLocalService}],[qh,{useClass:f.MentionIOLocalService,lazy:!0}]],t),r=e?e.createChild(n):new Re.Injector(n);return Ra(r,[[xr],[sa]]),r}bd(),f.ABCToNumber=x0,f.AUTO_HEIGHT_FOR_MERGED_CELLS=Ea,f.AbsoluteRefType=Ne,f.ActionIterator=zn,f.AlignTypeH=ec,f.AlignTypeV=tc,f.ArrangeTypeEnum=sc,f.ArrowsAndMarkersShapes=bl,f.AsyncInterceptorManager=zd,f.AsyncLock=kd,f.AutoFillSeries=gl,f.BaselineOffset=Ht,f.BasicShapes=wl,f.BlockType=Ul,f.BooleanNumber=ae,f.BorderStyleTypes=Ue,f.BorderType=_l,f.BuildTextUtils=Je,f.BulletAlignment=ur,f.COLORS=Di,f.CanceledError=Hd,f.CellModeEnum=Dn,f.CellValueType=Zt,f.Color=En,f.ColorBuilder=gs,f.ColorKit=wt,f.ColorType=pt,f.ColumnSeparatorType=Fl,f.CommandType=dr,f.CommonHideTypes=pl,f.ConfigService=vh,f.ContextService=Rc,f.CopyPasteType=El,f.CustomCommandExecutionError=qr,f.CustomDecorationType=gn,f.CustomRangeType=Jt,f.DEFAULT_CELL=m0,f.DEFAULT_DOC=jo,f.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=JC,f.DEFAULT_EMPTY_DOCUMENT_VALUE=_a,f.DEFAULT_NUMBER_FORMAT=Du,f.DEFAULT_RANGE=d0,f.DEFAULT_RANGE_ARRAY=h0,f.DEFAULT_SELECTION=f0,f.DEFAULT_SLIDE=Uu,f.DEFAULT_STYLES=st,f.DEFAULT_TEXT_FORMAT=Mu,f.DEFAULT_TEXT_FORMAT_EXCEL=Lu,f.DEFAULT_WORKSHEET_COLUMN_COUNT=Fh,f.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=vR,f.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Hh,f.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=TR,f.DEFAULT_WORKSHEET_COLUMN_WIDTH=Bh,f.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=bR,f.DEFAULT_WORKSHEET_ROW_COUNT=kh,f.DEFAULT_WORKSHEET_ROW_COUNT_KEY=OR,f.DEFAULT_WORKSHEET_ROW_HEIGHT=xh,f.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=wR,f.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=$h,f.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=AR,f.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=si,f.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=ri,f.DOCS_ZEN_EDITOR_UNIT_ID_KEY=ga,f.DOC_DRAWING_PRINTING_COMPONENT_KEY=C0,f.DOC_RANGE_TYPE=Pc,f.DashStyleType=jl,f.DataStreamTreeNodeType=gh,f.DataStreamTreeTokenType=lt,f.DataValidationErrorStyle=dd,f.DataValidationImeMode=fd,f.DataValidationOperator=md,f.DataValidationRenderMode=gd,f.DataValidationStatus=_d,f.DataValidationType=pd,f.DeleteDirection=Cl,f.DependentOn=KR,f.DesktopLogService=Sc,f.DeveloperMetadataVisibility=Rl,f.Dimension=Il,f.Direction=Sl,f.Disposable=ze,f.DisposableCollection=ss,f.DocStyleType=Ll,f.DocumentDataModel=At,f.DocumentFlavor=vi,f.DrawingTypeEnum=ic,f.EDITOR_ACTIVATED=wh,f.EXTENSION_NAMES=Pu,f.ErrorService=Ah,f.EventState=Ih,f.EventSubject=QC,f.FOCUSING_COMMON_DRAWINGS=uR,f.FOCUSING_DOC=$r,f.FOCUSING_EDITOR_BUT_HIDDEN=sR,f.FOCUSING_EDITOR_INPUT_FORMULA=iR,f.FOCUSING_EDITOR_STANDALONE=aR,f.FOCUSING_FX_BAR_EDITOR=bh,f.FOCUSING_PANEL_EDITOR=lR,f.FOCUSING_SHEET=Kn,f.FOCUSING_SLIDE=Hr,f.FOCUSING_UNIT=Br,f.FOCUSING_UNIVER_EDITOR=oR,f.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=cR,f.FORMULA_EDITOR_ACTIVATED=hR,f.FollowNumberWithType=Dl,f.FontItalic=as,f.FontStyleType=Mn,f.FontWeight=ls,f.GridType=Pl,f.HLSColor=Nc,f.HorizontalAlign=Ot,f.IAuthzIoService=Oh,f.ICommandService=fr,f.IConfigService=qo,f.IContextService=Ln,f.IImageIoService=Jo,f.ILocalStorageService=$R,f.ILogService=Et,f.IMentionIOService=qh,f.IPermissionService=Zh,f.IResourceLoaderService=sa,f.IResourceManagerService=Xs,f.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=pa,f.IUndoRedoService=Js,f.IUniverInstanceService=Xn,f.ImageCacheMap=od,f.ImageSourceType=Zo,f.ImageUploadStatusType=Th,f.InterceptorEffectEnum=bn,f.InterceptorManager=Yd,f.InterpolationPointType=Ol,f.JSON1=L_,f.JSONX=jt,f.LRUHelper=pr,f.LRUMap=_r,f.LifecycleStages=ke,f.LifecycleUnreachableError=Kh,f.ListGlyphType=fe,f.LocaleService=Sn,f.LocaleType=lr,f.LogLevel=Ic,f.MOVE_BUFFER_VALUE=gr,f.MemoryCursor=dn,f.MentionType=os,f.NAMED_STYLE_MAP=_0,f.NAMED_STYLE_SPACE_MAP=p0,f.NamedStyleType=qe,f.NilCommand=vc,f.NumberUnitType=Ql,f.ObjectMatrix=ut,f.ObjectRelativeFromH=Zl,f.ObjectRelativeFromV=Jl,f.OtherShapes=Al,f.PAGE_SIZE=R0,f.PAPER_TYPES=v_,f.PRESET_LIST_TYPE=Ur,f.PRINT_CHART_COMPONENT_KEY=E0,f.PageElementType=oc,f.PageOrientType=rc,f.PageType=wi,f.PaperType=ct,f.ParagraphElementType=Bl,f.ParagraphStyleBuilder=Fr,f.ParagraphStyleValue=kr,f.PermissionService=Jh,f.PermissionStatus=ta,f.Plugin=ra,f.PositionedObjectLayoutType=Hl,f.PresetListType=Ft,f.ProtectionType=vl,f.QuickListType=rh,f.QuickListTypeMap=X0,f.RANGE_DIRECTION=Uc,f.RANGE_TYPE=pe,f.RBush=Hs,f.RCDisposable=c_,f.RGBA_PAREN=K_,f.RGB_PAREN=z_,f.ROTATE_BUFFER_VALUE=Tc,f.RTree=nI,f.Range=Wn,f.Rectangle=nn,f.RedoCommand=id,f.RedoCommandId=nd,f.RefAlias=F0,f.Registry=Ri,f.RegistryAsMap=Ii,f.RelativeDate=yl,f.RelativeSlideLink=ac,f.RgbColor=_s,f.RichTextBuilder=In,f.RichTextValue=on,f.RxDisposable=l_,f.SHEET_EDITOR_UNITS=g0,f.SectionType=kl,f.SheetTypes=Nl,f.SheetViewModel=jh,f.SliceBodyType=Ho,f.SlideDataModel=ea,f.SpacingRule=Wl,f.SpecialShapes=Tl,f.Styles=yh,f.THEME_COLORS=yc,f.TabStopAlignment=Yl,f.TableAlignmentType=Vl,f.TableLayoutType=zl,f.TableRowHeightRule=Xl,f.TableSizeType=Gl,f.TableTextWrapType=Kl,f.TextDecoration=Ml,f.TextDecorationBuilder=sn,f.TextDirection=cr,f.TextDirectionType=xl,f.TextStyleBuilder=rn,f.TextStyleValue=Pr,f.TextX=Me,f.TextXActionType=J,f.ThemeColor=ps,f.ThemeColorType=ot,f.ThemeColors=cs,f.ThemeService=Zs,f.Tools=Z,f.UndoCommand=sd,f.UndoCommandId=rd,f.UnitModel=is,f.Univer=mI,f.UniverInstanceType=we,f.UpdateDocsAttributeType=Ce,f.UserManagerService=xr,f.VerticalAlign=fn,f.VerticalAlignmentType=ql,f.Worksheet=jr,f.WrapStrategy=mn,f.WrapTextType=$l,f.addLinkToDocumentModel=Lh,f.afterInitApply=W_,f.afterTime=$_,f.awaitTime=rI,f.binSearchFirstGreaterThanTarget=Ac,f.binarySearchArray=j_,f.bufferDebounceTime=B_,f.cellToRange=vp,f.characterSpacingControlType=nc,f.checkForSubstrings=bp,f.checkIfMove=G_,f.checkParagraphHasBullet=lE,f.checkParagraphHasIndent=cE,f.checkParagraphHasIndentByStyle=Xc,f.codeToBlob=Y_,f.composeBody=Wo,f.composeInterceptors=Sa,f.composeStyles=ar,f.concatMatrixArray=fp,f.convertBodyToHtml=V_,f.convertCellToRange=kc,f.convertObservableToBehaviorSubject=H_,f.covertCellValue=$i,f.covertCellValues=wp,f.covertTextRunToHtml=Li,f.createAsyncInterceptorKey=Gd,f.createDefaultUser=qs,f.createDocumentModelWithStyle=Wr,f.createInterceptorKey=jd,f.createInternalEditorID=Bd,f.createRowColIter=Fo,f.dayjs=Wt,f.debounce=Kg,f.dedupe=Ad,f.dedupeBy=Td,f.deepCompare=Hi,f.delayAnimationFrame=sI,f.deleteContent=Zc,f.extractPureTextFromCell=Gh,f.fromCallback=wc,f.fromEventSubject=eR,f.fromObservable=a_,f.generateRandomId=tt,f.get=nl,f.getArrayLength=Qt,f.getBodySlice=bt,f.getBodySliceHtml=ms,f.getBorderStyleType=Ip,f.getCellCoordByIndexSimple=ua,f.getCellInfoInMergeData=hp,f.getCellPositionByIndexSimple=uI,f.getCellValueType=lp,f.getCellWithCoordByIndexCore=qn,f.getColorStyle=Ut,f.getCustomBlockSlice=lh,f.getCustomDecorationSlice=uh,f.getCustomRangeSlice=ch,f.getDocsUpdateBody=Sp,f.getIntersectRange=Bu,f.getOriginCellValue=NR,f.getParagraphsSlice=ah,f.getPlainText=Ks,f.getReverseDirection=O_,f.getSectionBreakSlice=sC,f.getTableSlice=oh,f.getTextRunSlice=zs,f.getTransformOffsetX=ud,f.getTransformOffsetY=hd,f.getWorksheetUID=UR,f.groupBy=Md,f.handleStyleToString=Rp,f.hashAlgorithm=hE,f.horizontalLineSegmentsSubtraction=ys,f.insertMatrixArray=ki,f.insertTextToContent=qc,f.invertColorByHSL=Qd,f.invertColorByMatrix=tf,f.isBlackColor=op,f.isBooleanString=xd,f.isCellCoverable=Bi,f.isCellV=Dc,f.isDefaultFormat=c0,f.isEmptyCell=Fc,f.isFormulaId=Cp,f.isFormulaString=xc,f.isICellData=Lc,f.isInternalEditorID=Ca,f.isNodeEnv=S_,f.isNotNullOrUndefined=Dh,f.isNullCell=cp,f.isNumeric=cl,f.isPatternEqualWithoutDecimal=u0,f.isRangesEqual=mR,f.isRealNum=uE,f.isSafeNumeric=n_,f.isSameStyleTextRun=Bc,f.isTextFormat=l0,f.isUnitRangesEqual=gR,f.isValidRange=Op,f.isWhiteColor=ap,f.makeArray=Ld,f.makeCellRangeToRangeData=Ep,f.makeCellToSelection=pp,f.makeCustomRangeStream=EC,f.mapObjectMatrix=dp,f.merge=rs,f.mergeLocales=dE,f.mergeOverrideWithDependencies=Qh,f.mergeSets=i_,f.mergeWith=Jg,f.mergeWorksheetSnapshotWithDefault=Wh,f.mixinClass=t_,f.moveMatrixArray=xi,f.moveRangeByOffset=A0,f.nameCharacterCheck=tI,f.normalizeBody=iC,f.normalizeTextRuns=Dr,f.numberToABC=$0,f.numberToListABC=H0,f.numfmt=a0,f.queryObjectMatrix=k0,f.registerDependencies=$d,f.remove=tr,f.repeatStringNumTimes=ju,f.replaceInDocumentBody=qC,f.requestImmediateMacroTask=s_,f.rotate=Nd,f.searchArray=mr,f.searchInOrderedArray=bc,f.selectionToArray=up,f.sequence=hl,f.sequenceAsync=ul,f.sequenceExecute=fs,f.sequenceExecuteAsync=x_,f.set=e_,f.shallowEqual=Ia,f.skipParseTagNames=hI,f.sliceMatrixArray=mp,f.sortRules=W0,f.sortRulesByDesc=j0,f.sortRulesFactory=Lr,f.spliceArray=Fi,f.splitIntoGrid=ko,f.takeAfter=Mi,f.textDiff=Go,f.throttle=Wd,f.toDisposable=je,f.touchDependencies=Ra,f.updateAttributeByDelete=hh,f.updateAttributeByInsert=dh,f.willLoseNumericPrecision=r_,Object.keys(Re).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(f,e)&&Object.defineProperty(f,e,{enumerable:!0,get:()=>Re[e]})}),Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
8
+ `,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(n){return new In(n!=null?n:In.newEmptyData())}insertText(n,r,s){var u,h;let i=((h=(u=this._data.body)==null?void 0:u.dataStream.length)!=null?h:2)-2,o,a;if(typeof n=="string"?o=n:(i=Math.min(n,i),o=r),typeof r=="object"?a=r instanceof rn?r.build():r:a=s instanceof rn?s.build():s,!o)return this;const l={dataStream:o,textRuns:a?[{ts:a,st:i,ed:i+o.length}]:[]},c=Je.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:l});if(!c)throw new Error("Insert text failed, please check.");return Me.apply(this._doc.getBody(),c.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 on?n.getData():n:(s=Math.min(n,s),i=r instanceof on?r.getData():r);const o=Je.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 Me.apply(this._doc.getBody(),o.serialize()),this}delete(n,r){if(r!==void 0){if(!r)return this;const s=Je.selection.delete([{startOffset:n,endOffset:n+r,collapsed:!0}],this._data.body);Me.apply(this._doc.getBody(),s)}return this}setStyle(n,r,s){const i={dataStream:"",textRuns:[{ts:s instanceof rn?s.build():s,st:0,ed:r-n}]},o=Je.selection.retain([{startOffset:n,endOffset:r,collapsed:!0}],i);return Me.apply(this._doc.getBody(),o),this}setLink(n,r,s){const i=Je.customRange.add({rangeType:Jt.HYPERLINK,rangeId:tt(),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 Me.apply(this._doc.getBody(),i.serialize()),this}cancelLink(n,r){if(typeof n=="string"){const s=Je.customRange.delete({rangeId:n,documentDataModel:this._doc});if(!s)throw new Error("Insert text failed, please check.");Me.apply(this._doc.getBody(),s.serialize())}else this.slice(n,r).getLinks().forEach(i=>{const o=Je.customRange.delete({rangeId:i.rangeId,documentDataModel:this._doc});if(!o)throw new Error("Insert text failed, please check.");Me.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,on.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=In.createByBody({dataStream:i,customRanges:[{rangeType:Jt.HYPERLINK,rangeId:tt(),properties:{url:o},startIndex:0,endIndex:i.length-1}]});return typeof n=="number"?this.insertRichText(n,a):this.insertRichText(a)}}const JC="__default_document_sub_component_id20231101__";class Ih{constructor(){C(this,"skipNextObservers",!1);C(this,"lastReturnValue");C(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class QC 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 Ih;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 eR(e){return new oe.Observable(t=>{const n=e.subscribeEvent(r=>{t.next(r)});return()=>n.unsubscribe()})}const Xs=Re.createIdentifier("core.resource-manager.service"),Xo={[Dt.Editor]:"Editor",[Dt.Owner]:"Owner",[Dt.Reader]:"Reader",[Dt.UNRECOGNIZED]:"UNRECOGNIZED"},qs=e=>e?{userID:`${Xo[e]}_${tt(8)}`,name:Xo[e],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},tR=(e,t)=>e.startsWith(Xo[t]);class xr extends ze{constructor(){super(...arguments);C(this,"_model",new Map);C(this,"_userChange$",new oe.Subject);C(this,"userChange$",this._userChange$.asObservable());C(this,"_currentUser$",new oe.BehaviorSubject(qs()));C(this,"currentUser$",this._currentUser$.asObservable())}dispose(){super.dispose(),this._model.clear(),this._userChange$.complete(),this._currentUser$.complete()}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(n){this.addUser(n),this._currentUser$.next(n)}addUser(n){this._model.set(n.userID,n),this._userChange$.next({type:"add",user:n})}getUser(n,r){const s=this._model.get(n);if(s)return s;r&&r()}delete(n){const r=this.getUser(n);this._model.delete(n),r&&this._userChange$.next({type:"delete",user:r})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}list(){return Array.from(this._model.values())}}var nR=Object.getOwnPropertyDescriptor,rR=(e,t,n,r)=>{for(var s=r>1?void 0:r?nR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Sh=(e,t)=>(n,r)=>t(n,r,e);f.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(qs(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:[we.UNIVER_SHEET,we.UNIVER_DOC,we.UNIVER_SLIDE],onLoad:(t,n)=>{for(const r in n)this._permissionMap.set(r,n[r])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(t){return tt(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:Si.AllCollaborator,edit:Si.AllCollaborator},creator:qs(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){}},f.AuthzIoLocalService=rR([Sh(0,Xs),Sh(1,Re.Inject(xr))],f.AuthzIoLocalService);const Oh=Re.createIdentifier("IAuthzIoIoService"),qo=Re.createIdentifier("univer.config-service");class vh{constructor(){C(this,"_configChanged$",new oe.Subject);C(this,"configChanged$",this._configChanged$.asObservable());C(this,"_config",new Map)}dispose(){this._config.clear(),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=rs(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()})}}const Br="FOCUSING_UNIT",Kn="FOCUSING_SHEET",$r="FOCUSING_DOC",Hr="FOCUSING_SLIDE",sR="FOCUSING_EDITOR_BUT_HIDDEN",wh="EDITOR_ACTIVATED",iR="FOCUSING_EDITOR_INPUT_FORMULA",bh="FOCUSING_FX_BAR_EDITOR",oR="FOCUSING_UNIVER_EDITOR",aR="FOCUSING_EDITOR_INPUT_FORMULA",lR="FOCUSING_PANEL_EDITOR",cR="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",uR="FOCUSING_COMMON_DRAWINGS",hR="FORMULA_EDITOR_ACTIVATED";class Ah extends ze{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})}}var Zo=(e=>(e.URL="URL",e.UUID="UUID",e.BASE64="BASE64",e))(Zo||{}),Th=(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))(Th||{});const Jo=Re.createIdentifier("core.image-io.service"),dR={version:"0.10.1"};function fR(e="",t=lr.ZH_CN,n=""){return{id:e,sheetOrder:[],name:n,appVersion:dR.version,locale:t,styles:{},sheets:{},resources:[]}}class yh{constructor(t={}){C(this,"_styles");C(this,"_cacheMap",new _r(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=tt(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&&Z.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(Z.diffValue(n[r],t))return r;return null}}const mR=(e,t)=>t.length===e.length&&!e.some(n=>t.some(r=>!nn.equals(r,n))),gR=(e,t)=>t.length===e.length&&e.every((n,r)=>{const s=t[r];return s.unitId===n.unitId&&s.sheetId===n.sheetId&&nn.equals(n.range,s.range)}),Qo={t:0,b:2,l:2,r:2},_R=e=>({sbr:.6,sbo:e,spr:.6,spo:e}),Nh=90;function Wr(e,t,n={}){const r=e.length,{textRotation:s,paddingData:i,horizontalAlign:o=Ot.UNSPECIFIED,verticalAlign:a=fn.UNSPECIFIED,wrapStrategy:l=mn.UNSPECIFIED,cellValueType:c}=n,{t:u,r:h,b:d,l:m}=i||Qo,{vertexAngle:_,centerAngle:p}=Ph(s),I={id:"d",body:{dataStream:`${e}${_a}`,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:u,marginBottom:d,marginRight:h,marginLeft:m,renderConfig:{horizontalAlign:o,verticalAlign:a,centerAngle:p,vertexAngle:_,wrapStrategy:l,cellValueType:c,zeroWidthParagraphBreak:1}},drawings:{},drawingsOrder:[]};return new At(I)}function pR(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 Mh(e){if(!e)return{};const{ff:t,fs:n,it:r,bl:s,ul:i,st:o,ol:a,cl:l}=e,c={};return t&&(c.ff=t),n&&(c.fs=n),r&&(c.it=r),s&&(c.bl=s),i&&(c.ul=i),o&&(c.st=o),a&&(c.ol=a),l&&(c.cl=l),c}function Lh(e,t,n){var i;const r=e.getBody();if((i=r.customRanges)!=null&&i.some(o=>o.rangeType===Jt.HYPERLINK))return;const s=Je.customRange.add({ranges:[{startOffset:0,endOffset:r.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:Jt.HYPERLINK,body:r,properties:{url:t,refId:n}});s&&Me.apply(r,s.serialize())}function Dh(e){return e!=null}const ER='"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';function Uh(e){const t=st.ff,n=st.fs;if(!e){const h=`${n}pt ${t}`;return{fontCache:h,fontString:h,fontSize:n,originFontSize:n,fontFamily:t}}let r=Mn.ITALIC;(e.it===0||e.it===void 0)&&(r=Mn.NORMAL);let s=Mn.BOLD;(e.bl===0||e.bl===void 0)&&(s=Mn.NORMAL);let i=n;e.fs&&(i=Math.ceil(e.fs));let o=t;if(e.ff){let h=e.ff;h=h.replace(/"/g,"").replace(/'/g,""),h.indexOf(" ")>-1&&(h=`"${h}"`),h==null&&(h=t),o=h}const{va:a}=e;let l=i;if(a===Ht.SUBSCRIPT||a===Ht.SUPERSCRIPT){const h=CR(o,l),{sbr:d,spr:m}=h;l*=a===Ht.SUBSCRIPT?d:m}const c=`${r} ${s} ${l}pt ${o}`,u=`${c}, ${ER} `;return{fontCache:c,fontString:u,fontSize:l,originFontSize:i,fontFamily:o}}function CR(e,t){return _R(t)}function Ph(e){const{a:t=0,v:n=ae.FALSE}=e||{a:0,v:ae.FALSE};let r=0,s=t;return n===ae.TRUE&&(r=Nh,s=Nh),{centerAngle:r,vertexAngle:s}}class RR{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!==ae.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:pe.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:pe.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:pe.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:pe.COLUMN}),r}getColumnDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getColumn(i);r[s]=o!=null?o:{w:this._config.defaultColumnWidth,hd:ae.FALSE},s++}return r}getSize(){return Qt(this._columnData)}getColumnWidth(t){var n,r;return(r=(n=this._columnData[t])==null?void 0:n.w)!=null?r:this._config.defaultColumnWidth}setColumnWidth(t,n){const r=this._columnData[t];n===this._config.defaultColumnWidth?r&&(delete r.w,Object.keys(r).length===0&&delete this._columnData[t]):this._columnData[t]=r?{...r,w:n}:{w:n}}getColumn(t){return this._columnData[t]}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}}const IR=2e3;class SR{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.getRow(i);r[s]=o!=null?o:{h:this._config.defaultRowHeight,hd:ae.FALSE},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:ae.FALSE,h:s.defaultRowHeight},{ia:l,ah:c,h:u=s.defaultRowHeight}=a;i+=(l==null||l===ae.TRUE)&&typeof c=="number"?c:u}return i}setRowHeight(t,n){const r=this._rowData[t];if(n===this._config.defaultRowHeight)r&&(delete r.h,Object.keys(r).length===0&&delete this._rowData[t]);else{const s=Math.min(n,IR);this._rowData[t]=r?{...r,h:s}:{h:s}}}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:pe.ROW})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:pe.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:pe.ROW})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:pe.ROW}),r}getRowRawVisible(t){const n=this.getRow(t);return n?n.hd!==ae.TRUE:!0}getSize(){return Qt(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 OR="DEFAULT_WORKSHEET_ROW_COUNT",kh=1e3,vR="DEFAULT_WORKSHEET_COLUMN_COUNT",Fh=20,wR="DEFAULT_WORKSHEET_ROW_HEIGHT",xh=24,bR="DEFAULT_WORKSHEET_COLUMN_WIDTH",Bh=88,AR="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",$h=46,TR="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Hh=20;function Wh(e){const t={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:ae.FALSE,rowCount:kh,columnCount:Fh,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Bh,defaultRowHeight:xh,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:ae.TRUE,rowHeader:{width:$h,hidden:ae.FALSE},columnHeader:{height:Hh,hidden:ae.FALSE},rightToLeft:ae.FALSE};return Object.keys(t).forEach(n=>{const r=n;typeof e[r]>"u"&&(e[r]=t[r])}),e}class yR extends ze{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 _r(5e4));C(this,"_skeletonCache",new _r(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===pe.ROW?this._createRowCache(s,r):i===pe.COLUMN?this._createColumnCache(s,r):i===pe.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||!Z.isEmptyObject(this._columnCache)?!0:this._mergeData.some(r=>r.startRow<=n&&n<=r.endRow)}isColumnContainsMergedCell(n){return this._hasAll||!Z.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 c=[];for(const u of this._mergeData||[])nn.intersects(u,{startRow:n,endRow:s,startColumn:r,endColumn:i})&&(o.push({...u}),c.push(l)),l++;return this._rangeMap.set(a,c),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 c=[];for(let u=0;u<a.length;u++){const{startRow:h,endRow:d,startColumn:m,endColumn:_}=a[u];for(let p=n;p<=s;p++){let I=!1;for(let A=r;A<=i;A++)if(p>=h&&p<=d&&A>=m&&A<=_){o.push({startRow:h,endRow:d,startColumn:m,endColumn:_}),c.push(u),I=!0;break}if(I)break}}return this._skeletonCache.set(l,c),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 jh extends ze{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,bn.Value|bn.Style,s,i):this.getRawCell(n,r)}getCellValueOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,bn.Value):this.getRawCell(n,r)}getCellStyleOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,bn.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,je(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(n){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=n,je(()=>this._rowFilteredInterceptor=null)}}const Yh={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};class jr{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");C(this,"_isRowStylePrecedeColumnStyle",!0);C(this,"_getCellHeight");var a;this.unitId=t,this._styles=r,this._snapshot=Wh(n);const{columnData:s,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:tt(6),this._cellData=new ut(o),this._viewModel=new jh((l,c)=>this.getCellRaw(l,c)),this._rowManager=new SR(this._snapshot,this._viewModel,i),this._columnManager=new RR(this._snapshot,s),this._spanModel=new yR(this._snapshot.mergeData)}__interceptViewModel(t){t(this._viewModel)}__registerGetCellHeight(t){return this._getCellHeight=t,je(()=>{this._getCellHeight=null})}getSnapshot(){return this._snapshot}getCellHeight(t,n){return this._getCellHeight?this._getCellHeight(t,n):this._snapshot.defaultRowHeight}setMergeData(t){this._snapshot.mergeData=t,this.getSpanModel().rebuild(t)}getSpanModel(){return this._spanModel}setIsRowStylePrecedeColumnStyle(t){this._isRowStylePrecedeColumnStyle=t}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)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){const t=this._snapshot.defaultStyle;return this._styles.get(t)}setDefaultCellStyle(t){this._snapshot.defaultStyle=t}getCellStyle(t,n){const r=this.getCell(t,n);if(r){const s=r.s;return typeof s=="string"?this._styles.get(s):s}return null}getComposedCellStyle(t,n,r){const s=this.getDefaultCellStyleInternal(),i=this.getRowStyle(t),o=this.getColumnStyle(n),a=this.getCell(t,n),l=this._styles.getStyleByCell(a);return(r!=null?r:this._isRowStylePrecedeColumnStyle)?ar(s,o,i,a==null?void 0:a.themeStyle,l):ar(s,i,o,a==null?void 0:a.themeStyle,l)}getComposedCellStyleByCellData(t,n,r,s){const i=this.getDefaultCellStyleInternal(),o=this.getRowStyle(t),a=this.getColumnStyle(n),l=this._styles.getStyleByCell(r);return(s!=null?s:this._isRowStylePrecedeColumnStyle)?ar(i,a,o,r==null?void 0:r.themeStyle,l):ar(i,o,a,r==null?void 0:r.themeStyle,l)}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((c,u)=>{Object.keys(u).forEach(h=>{const d=+h,m=t.getValue(c,d),_=m!=null&&m.s?this._styles.get(m.s):null,p=(_==null?void 0:_.bd)&&(_.bd.b||_.bd.l||_.bd.r||_.bd.t||_.bd.bc_tr||_.bd.bl_tr||_.bd.ml_tr||_.bd.tl_bc||_.bd.tl_br||_.bd.tl_mr);(m&&(m.v||m.p)||_!=null&&_.bg||p)&&(a?r=Math.min(r,c):(r=c,a=!0),s=Math.max(s,c),l?i=Math.min(i,d):(l=!0,i=d),o=Math.max(o,d))})}),n.forEach(c=>{a?r=Math.min(r,c.startRow):(r=c.startRow,a=!0),s=Math.max(s,c.endRow),l?i=Math.min(i,c.startColumn):(i=c.startColumn,a=!0),o=Math.max(o,c.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=Z.deepClone(t);return new jr(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,c=n;if(r){const{startRow:u,endRow:h,startColumn:d,endColumn:m}=r;t===u&&n===d?(o=h,a=m,l=u,c=d,i=!0):t>=u&&t<=h&&n>=d&&n<=m&&(o=h,a=m,l=u,c=d,s=!0)}return{actualRow:t,actualColumn:n,isMergedMainCell:i,isMerged:s,endRow:o,endColumn:a,startRow:l,startColumn:c}}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)}getRangeFilterRows(t){const n=[];for(let r=t.startRow;r<=t.endRow;r++)this.getRowFiltered(r)&&n.push(r);return n}getMatrixWithMergedCells(t,n,r,s,i=Dn.Raw){const o=this.getCellMatrix(),a=this._spanModel.getMergedCellRange(t,n,r,s),l=new ut;return Fo(t,r,n,s).forEach((c,u)=>{var d;let h;if(i===Dn.Raw)h=this.getCellRaw(c,u);else if(i===Dn.Intercepted)h=this.getCell(c,u);else if(i===Dn.Both){const m=this.getCellRaw(c,u);if(m){h={...m};const _=(d=this.getCell(c,u))==null?void 0:d.v;Dh(_)&&h&&(h.displayV=String(_))}}h&&l.setValue(c,u,h)}),a.forEach(c=>{const{startColumn:u,startRow:h,endColumn:d,endRow:m}=c;Fo(h,m,u,d).forEach((_,p)=>{_===h&&p===u&&l.setValue(_,p,{...o.getValue(_,p),rowSpan:m-h+1,colSpan:d-u+1}),(_!==h||p!==u)&&l.realDeleteValue(_,p)})}),l}getRange(t,n,r,s){return typeof t=="object"?new Wn(this,t,{getStyles:()=>this._styles}):new Wn(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,c=s;return{next(){for(;;){if(c>o&&(l+=1,c=s),l>i)return{done:!0,value:void 0};const u=a.getCell(l,c),h=!u,d=a.getMergedCell(l,c);if(d){if(l!==d.startRow||c!==d.startColumn){c=d.endColumn+1;continue}if(h&&n){c=d.endColumn+1;continue}const _={row:l,col:c,value:u};return _.colSpan=d.endColumn-d.startColumn+1,_.rowSpan=d.endRow-d.startRow+1,c=d.endColumn+1,{done:!1,value:_}}if(h&&n)c+=1;else{const m={row:l,col:c,value:u};return c+=1,{done:!1,value:m}}}}}}}}iterateByColumn(t,n=!0,r=!0){const{startRow:s,startColumn:i,endRow:o,endColumn:a}=t,l=this;return{[Symbol.iterator]:()=>{let c=s,u=i;return{next(){for(;;){if(c>o&&(u+=1,c=s),u>a)return{done:!0,value:void 0};const h=l.getMergedCell(c,u);if(h){const _=c!==h.startRow,p=_||u!==h.startColumn;if(r&&p||!r&&_){c=h.endRow+1;continue}const I=l.getCell(h.startRow,h.startColumn);if(!I&&n){c=h.endRow+1;continue}const B={row:c,col:h.startColumn,value:I};return B.colSpan=h.endColumn-h.startColumn+1,B.rowSpan=h.endRow-h.startRow+1,c=h.endRow+1,{done:!1,value:B}}const d=l.getCell(c,u);if(!d&&n)c+=1;else{const _={row:c,col:u,value:d};return c+=1,{done:!1,value:_}}}}}}}}getCellDocumentModel(t,n,r=Yh){var p;if(!t)return;const{isDeepClone:s,displayRawFormula:i,ignoreTextRotation:o}={...Yh,...r};let a,l="document";const c=pR(n),u=o?st.tr:c.textRotation||st.tr;let h=c.horizontalAlign||st.ht;const d=c.verticalAlign||st.vt,m=c.wrapStrategy||st.tb,_=c.paddingData||Qo;if(t.f&&i)a=Wr(t.f.toString(),{},{verticalAlign:d}),h=st.ht;else if(t.p){const{centerAngle:I,vertexAngle:A}=Ph(u);a=this._updateConfigAndGetDocumentModel(s?Z.deepClone(t.p):t.p,h,_,{horizontalAlign:h,verticalAlign:d,centerAngle:I,vertexAngle:A,wrapStrategy:m,zeroWidthParagraphBreak:1})}else if(t.v!=null){const I=Mh(n);l=Uh(I).fontCache;let A=Gh(t);t.t===Zt.FORCE_STRING&&i&&(A=`'${A}`),a=Wr(A,I,{...c,textRotation:u,cellValueType:t.t})}return a&&t.linkUrl&&t.linkId&&Lh(a,t.linkUrl,t.linkId),{documentModel:a,fontString:l,textRotation:u,wrapStrategy:m,verticalAlign:d,horizontalAlign:h,paddingData:_,fill:(p=n==null?void 0:n.bg)==null?void 0:p.rgb}}_updateConfigAndGetDocumentModel(t,n,r,s){var o,a,l,c,u;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=(c=r.l)!=null?c:2,t.documentStyle.marginRight=(u=r.r)!=null?u: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 h of i)h.paragraphStyle||(h.paragraphStyle={}),h.paragraphStyle.horizontalAlign=n;return new At(t)}getBlankCellDocumentModel(t,n,r){const s=this.getComposedCellStyleByCellData(n,r,t),i=Mh(s),o=this.getCellDocumentModel(t,s,{ignoreTextRotation:!0});if(o!=null)return o.documentModel==null&&(o.documentModel=Wr("",i)),o;const a="";let l="document";const c=st.tr,u=st.ht,h=st.vt,d=st.tb,m=Qo;return l=Uh({}).fontCache,{documentModel:Wr(a,i),fontString:l,textRotation:c,wrapStrategy:d,verticalAlign:h,horizontalAlign:u,paddingData:m}}getCellDocumentModelWithFormula(t,n,r){const s=this.getComposedCellStyleByCellData(n,r,t);return this.getCellDocumentModel(t,s,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(t){this._snapshot.custom=t}}function Gh(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 Je.transform.getPlainText(t);const n=e.v;return typeof n=="string"?e.t===Zt.BOOLEAN?n.toUpperCase():n.replace(/[\r\n]/g,""):typeof n=="number"?e.t===Zt.BOOLEAN?n?"TRUE":"FALSE":n.toString():typeof n=="boolean"?n?"TRUE":"FALSE":""}function NR(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 Je.transform.getPlainText(n)}return e==null?void 0:e.v}var MR=Object.getOwnPropertyDescriptor,LR=(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=o(s)||s);return s},DR=(e,t)=>(n,r)=>t(n,r,e);function UR(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}f.Workbook=class extends is{constructor(n={},r){super();C(this,"type",we.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=fR();Z.isEmptyObject(n)?this._snapshot=s:this._snapshot=Z.commonExtend(s,n);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=tt(6)),this._unitId=this._snapshot.id,this._styles=new yh(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 Z.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 jr(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()!==ae.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===ae.TRUE).map(n=>n.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden!==ae.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(Z.isEmptyObject(s)){const o=tt();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 c=new jr(this._unitId,a,this._styles);r.set(o,c),i.includes(o)||i.push(o)}this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(n){this._snapshot.custom=n}},f.Workbook=LR([DR(1,Et)],f.Workbook);class ea extends is{constructor(n){var r;super();C(this,"type",we.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={...Uu,...n},this._unitId=(r=this._snapshot.id)!=null?r:tt(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:tt(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=tt(6);return{id:n,pageType:wi.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)}}var PR=Object.getOwnPropertyDescriptor,kR=(e,t,n,r)=>{for(var s=r>1?void 0:r?PR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Vh=(e,t)=>(n,r)=>t(n,r,e);const Xn=Re.createIdentifier("univer.current");f.UniverInstanceService=class extends ze{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)}getCurrentUnitOfType(n){return this.getCurrentUnitForType(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(we.UNIVER_DOC)}getUniverDocInstance(n){return this.getUnit(n,we.UNIVER_DOC)}getUniverSheetInstance(n){return this.getUnit(n,we.UNIVER_SHEET)}getAllUnitsForType(n){var r;return(r=this._unitsByType.get(n))!=null?r:[]}changeDoc(n,r){const s=this.getAllUnitsForType(we.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 f.Workbook?(this._contextService.setContextValue(Br,!0),this._contextService.setContextValue($r,!1),this._contextService.setContextValue(Kn,!0),this._contextService.setContextValue(Hr,!1),this.setCurrentUnitForType(n)):this.focused instanceof At?(this._contextService.setContextValue(Br,!0),this._contextService.setContextValue($r,!0),this._contextService.setContextValue(Kn,!1),this._contextService.setContextValue(Hr,!1),this.setCurrentUnitForType(n)):this.focused instanceof ea?(this._contextService.setContextValue(Br,!0),this._contextService.setContextValue($r,!1),this._contextService.setContextValue(Kn,!1),this._contextService.setContextValue(Hr,!0),this.setCurrentUnitForType(n)):(this._contextService.setContextValue(Br,!1),this._contextService.setContextValue($r,!1),this._contextService.setContextValue(Kn,!1),this._contextService.setContextValue(Hr,!1))}getFocusedUnit(){return this.focused}getUnitType(n){const r=this._getUnitById(n);return r?r[1]:we.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._tryResetCurrentOnRemoval(n,i),this._tryResetFocusOnRemoval(n),this._unitDisposed$.next(s),!0}_tryResetCurrentOnRemoval(n,r){const s=this.getCurrentUnitForType(r);(s==null?void 0:s.getUnitId())===n&&(this._currentUnits.set(r,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(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]}}},f.UniverInstanceService=kR([Vh(0,Re.Inject(Re.Injector)),Vh(1,Ln)],f.UniverInstanceService);var ke=(e=>(e[e.Starting=0]="Starting",e[e.Ready=1]="Ready",e[e.Rendered=2]="Rendered",e[e.Steady=3]="Steady",e))(ke||{});const zh={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"};var FR=Object.getOwnPropertyDescriptor,xR=(e,t,n,r)=>{for(var s=r>1?void 0:r?FR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},BR=(e,t)=>(n,r)=>t(n,r,e);class Kh extends Error{constructor(t){super(`[LifecycleService]: lifecycle stage "${zh[t]}" will never be reached!`),this.name="LifecycleUnreachableError"}}f.LifecycleService=class extends ze{constructor(n){super();C(this,"_lifecycle$",new oe.BehaviorSubject(ke.Starting));C(this,"lifecycle$",this._lifecycle$.asObservable());C(this,"_lock",!1);this._logService=n,this._reportProgress(ke.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()}onStage(n){return oe.firstValueFrom(this.lifecycle$.pipe(oe.filter(r=>r>=n),Mi(r=>r===n),oe.map(()=>{}))).catch(r=>r.name==="EmptyError"?Promise.reject(new Kh(n)):Promise.reject(r))}subscribeWithPrevious(){return oe.merge(Xh(this.stage),this._lifecycle$.pipe(oe.skip(1))).pipe(Mi(n=>n===ke.Steady))}_reportProgress(n){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${zh[n]}".`)}},f.LifecycleService=xR([BR(0,Et)],f.LifecycleService);function Xh(e){switch(e){case ke.Starting:return oe.of(ke.Starting);case ke.Ready:return oe.of(ke.Starting,ke.Ready);case ke.Rendered:return oe.of(ke.Starting,ke.Ready,ke.Rendered);default:return oe.of(ke.Starting,ke.Ready,ke.Rendered,ke.Steady)}}const $R=Re.createIdentifier("ILocalStorageService");class Sn extends ze{constructor(){super();C(this,"_currentLocale$",new oe.BehaviorSubject(lr.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(je(()=>{this._locales=null,this._currentLocale$.complete(),this.localeChanged$.complete()}))}get _currentLocale(){return this._currentLocale$.value}load(n){var r;this._locales=rs((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 HR=Object.getOwnPropertyDescriptor,WR=(e,t,n,r)=>{for(var s=r>1?void 0:r?HR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},jR=(e,t)=>(n,r)=>t(n,r,e);f.MentionIOLocalService=class{constructor(t){this._userManagerService=t}async list(t){return{list:[{type:os.PERSON,mentions:[{objectType:os.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}}},f.MentionIOLocalService=WR([jR(0,Re.Inject(xr))],f.MentionIOLocalService);const qh=Re.createIdentifier("univer.service.mention-io");var ta=(e=>(e.INIT="init",e.FETCHING="fetching",e.DONE="done",e))(ta||{});const Zh=Re.createIdentifier("univer.permission-service");class Jh extends ze{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=ta.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(Kr.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 Qh(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}var YR=Object.getOwnPropertyDescriptor,GR=(e,t,n,r)=>{for(var s=r>1?void 0:r?YR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},na=(e,t)=>(n,r)=>t(n,r,e);const VR=4,ed=Symbol("DependentOn");class ra extends ze{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}C(ra,"pluginName"),C(ra,"type",we.UNIVER_UNKNOWN);class zR{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)}}function KR(...e){return function(t){t[ed]=e}}f.PluginService=class{constructor(t,n,r){C(this,"_pluginRegistry",new Map);C(this,"_pluginStore",new zR);C(this,"_seenPlugins",new Set);C(this,"_loadedPlugins",new Set);C(this,"_loadedPluginTypes",new Set([we.UNIVER_UNKNOWN]));C(this,"_flushTimerByType",new Map);this._injector=t,this._lifecycleService=n,this._logService=r}dispose(){this._pluginStore.removePlugins().forEach(t=>t.dispose()),this._flushTimerByType.forEach(t=>clearTimeout(t))}registerPlugin(t,n){this._assertPluginValid(t);const r={plugin:t,options:n};this._pluginRegistry.set(t.pluginName,r),this._logService.debug("[PluginService]",`Plugin "${t.pluginName}" registered.`);const{type:s}=t;this._loadedPluginTypes.has(s)&&(s===we.UNIVER_UNKNOWN?this._loadFromPlugins([r]):this._flushType(s))}startPluginsForType(t){this._loadedPluginTypes.has(t)||this._loadPluginsForType(t)}_loadPluginsForType(t){const n=Array.from(this._pluginRegistry.keys()),r=[];n.forEach(s=>{const i=this._pluginRegistry.get(s);i.plugin.type===t&&r.push(i)}),this._loadFromPlugins(r),this._loadedPluginTypes.add(t)}_assertPluginValid(t){const{type:n,pluginName:r}=t;if(n===we.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)}_flushType(t){this._flushTimerByType.get(t)===void 0&&this._flushTimerByType.set(t,setTimeout(()=>{this._loadPluginsForType(t),this._flushTimerByType.delete(t)},VR))}_loadFromPlugins(t){const n=[],r=new Set,s=o=>{const{plugin:a}=o,{pluginName:l}=a;if(this._loadedPlugins.has(l)||r.has(l))return;r.add(l),this._pluginRegistry.delete(l);const c=a[ed];c&&c.forEach(u=>{const h=this._pluginRegistry.get(u.pluginName);if(h)s(h);else if(!this._seenPlugins.has(u.pluginName)&&!r.has(u.pluginName)){if(a.type===we.UNIVER_UNKNOWN&&u.type!==we.UNIVER_UNKNOWN)throw new Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${a.pluginName} and the dependency is ${u.pluginName}.`);a.type!==u.type&&u.type!==we.UNIVER_UNKNOWN&&this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${u.pluginName}" which has different type.`),this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${u.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(u),s({plugin:u,options:void 0})}}),n.push(o)};t.forEach(o=>s(o));const i=n.map(o=>this._initPlugin(o.plugin,o.options));this._pluginsRunLifecycle(i)}_pluginsRunLifecycle(t){const n=this._lifecycleService.stage;if(Xh(n).subscribe(r=>this._runStage(t,r)),n!==ke.Steady){const r=this._lifecycleService.lifecycle$.pipe(oe.skip(1)).subscribe(s=>{this._runStage(t,s),s===ke.Steady&&r.unsubscribe()})}}_runStage(t,n){t.forEach(r=>{switch(n){case ke.Starting:r.onStarting();break;case ke.Ready:r.onReady();break;case ke.Rendered:r.onRendered();break;case ke.Steady:r.onSteady();break}})}_initPlugin(t,n){const r=this._injector.createInstance(t,n);return this._pluginStore.addPlugin(r),this._loadedPlugins.add(t.pluginName),this._logService.debug("[PluginService]",`Plugin "${r.getPluginName()}" loaded.`),r}},f.PluginService=GR([na(0,Re.Inject(Re.Injector)),na(1,Re.Inject(f.LifecycleService)),na(2,Et)],f.PluginService);const sa=Re.createIdentifier("resource-loader-service");var XR=Object.getOwnPropertyDescriptor,qR=(e,t,n,r)=>{for(var s=r>1?void 0:r?XR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},ZR=(e,t)=>(n,r)=>t(n,r,e);f.ResourceManagerService=class extends ze{constructor(n){super();C(this,"_resourceMap",new Map);C(this,"_register$",new oe.Subject);C(this,"register$",this._register$.asObservable());this._logService=n}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),je(()=>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(a){this._logService.error("[ResourceManagerService]","loadResources error",a)}})}unloadResources(n){this.getAllResourceHooks().forEach(r=>{r.onUnLoad(n)})}dispose(){this._register$.complete(),this._resourceMap.clear()}},f.ResourceManagerService=qR([ZR(0,Et)],f.ResourceManagerService);class Zs extends ze{constructor(){super();C(this,"_darkMode$",new oe.BehaviorSubject(!1));C(this,"darkMode$",this._darkMode$.asObservable());C(this,"_validColorCache",new Map);C(this,"_currentTheme",Xr.defaultTheme);C(this,"_currentTheme$",new oe.BehaviorSubject(this._currentTheme));C(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(je(()=>{this._currentTheme=Xr.defaultTheme,this._currentTheme$.complete(),this._darkMode$.complete()}))}get darkMode(){return this._darkMode$.getValue()}isValidThemeColor(n){if(this._validColorCache.has(n))return this._validColorCache.get(n);let r=!1;const s=n.split(".");if(s.length===1)r=n in Xr.defaultTheme;else if(s.length===2){const[i,o]=s;r=i in Xr.defaultTheme&&o in this._currentTheme[i]}return this._validColorCache.set(n,r),r}getCurrentTheme(){return this._currentTheme}setTheme(n){this._currentTheme=n,this._currentTheme$.next(n)}setDarkMode(n){this._darkMode$.next(n)}getColorFromTheme(n){return nl(this._currentTheme,n)}}var JR=Object.getOwnPropertyDescriptor,QR=(e,t,n,r)=>{for(var s=r>1?void 0:r?JR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},ia=(e,t)=>(n,r)=>t(n,r,e);const Js=Re.createIdentifier("univer.undo-redo.service"),eI=20;class td{dispose(){}async dispatchToHandlers(){return!1}}const nd="univer.command.redo",rd="univer.command.undo",sd=new class extends td{constructor(){super(...arguments);C(this,"type",dr.COMMAND);C(this,"id",rd)}handler(t){const n=t.get(Js),r=n.pitchTopUndoElement();if(!r)return!1;const s=t.get(fr);return fs(r.undoMutations,s)?(n.popUndoToRedo(),!0):!1}},id=new class extends td{constructor(){super(...arguments);C(this,"type",dr.COMMAND);C(this,"id",nd)}handler(t){const n=t.get(Js),r=n.pitchTopRedoElement();if(!r)return!1;const s=t.get(fr);return fs(r.redoMutations,s)?(n.popRedoToUndo(),!0):!1}};f.LocalUndoRedoService=class extends ze{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(sd)),this.disposeWithMe(this._commandService.registerCommand(id)),this.disposeWithMe(je(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(je(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>eI&&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())}rollback(n,r){const s=r||this._getFocusedUnitId(),i=this._getUndoStack(s),o=i==null?void 0:i[(i==null?void 0:i.length)-1];o&&o.id===n&&(i.pop(),fs(o.undoMutations,this._commandService))}__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),je(()=>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,c;let n="";const r=this._contextService.getContextValue(Kn),s=this._contextService.getContextValue(bh),i=this._contextService.getContextValue(wh);return r?s?n=si:i?n=ri:n=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":n=(c=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?c:"",n}},f.LocalUndoRedoService=QR([ia(0,Xn),ia(1,fr),ia(2,Ln)],f.LocalUndoRedoService);class od{constructor(t,n=100){C(this,"_imageCacheMap");this._injector=t,this._imageCacheMap=new _r(n)}_getImageCacheKey(t,n){return`${t}-${n}`}getImage(t,n,r,s){const i=this._getImageCacheKey(t,n),o=this._imageCacheMap.get(i);return o||((async()=>{const a=new Image,l=this._injector.has(Jo)?this._injector.get(Jo):null;if(t===Zo.UUID)try{a.src=await(l==null?void 0:l.getImage(n))||""}catch(c){console.error(c)}else a.src=n;a.onload=()=>{a.removeAttribute("data-error"),r==null||r()},a.onerror=()=>{a.setAttribute("data-error","true"),s==null||s()},this._imageCacheMap.set(i,a)})(),null)}}function tI(e){return!(e.length===0||e.length>31||e.startsWith("'")||e.endsWith("'")||/[:\\\/\?\*\[\]]/.test(e))}const ad=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],oa=1,Yr=8;class aa{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!==oa)throw new Error(`Got v${s} data when expected v${oa}.`);const i=ad[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 aa(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=ad.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,Yr,t),this.coords=new this.ArrayType(this.data,Yr+a+l,t*2),this._pos=t*2,this._finished=!0):(this.data=new ArrayBuffer(Yr+o+a+l),this.ids=new this.IndexArrayType(this.data,Yr,t),this.coords=new this.ArrayType(this.data,Yr+a+l,t*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(oa<<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 la(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],c=[];for(;l.length;){const u=l.pop()||0,h=l.pop()||0,d=l.pop()||0;if(h-d<=a){for(let I=d;I<=h;I++){const A=o[2*I],B=o[2*I+1];A>=t&&A<=r&&B>=n&&B<=s&&c.push(i[I])}continue}const m=d+h>>1,_=o[2*m],p=o[2*m+1];_>=t&&_<=r&&p>=n&&p<=s&&c.push(i[m]),(u===0?t<=_:n<=p)&&(l.push(d),l.push(m-1),l.push(1-u)),(u===0?r>=_:s>=p)&&(l.push(m+1),l.push(h),l.push(1-u))}return c}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=[],c=r*r;for(;a.length;){const u=a.pop()||0,h=a.pop()||0,d=a.pop()||0;if(h-d<=o){for(let I=d;I<=h;I++)cd(i[2*I],i[2*I+1],t,n)<=c&&l.push(s[I]);continue}const m=d+h>>1,_=i[2*m],p=i[2*m+1];cd(_,p,t,n)<=c&&l.push(s[m]),(u===0?t-r<=_:n-r<=p)&&(a.push(d),a.push(m-1),a.push(1-u)),(u===0?t+r>=_:n+r>=p)&&(a.push(m+1),a.push(h),a.push(1-u))}return l}}function la(e,t,n,r,s,i){if(s-r<=n)return;const o=r+s>>1;ld(e,t,o,r,s,i),la(e,t,n,r,o-1,1-i),la(e,t,n,o+1,s,1-i)}function ld(e,t,n,r,s,i){for(;s>r;){if(s-r>600){const c=s-r+1,u=n-r+1,h=Math.log(c),d=.5*Math.exp(2*h/3),m=.5*Math.sqrt(h*d*(c-d)/c)*(u-c/2<0?-1:1),_=Math.max(r,Math.floor(n-u*d/c+m)),p=Math.min(s,Math.floor(n+(c-u)*d/c+m));ld(e,t,n,_,p,i)}const o=t[2*n+i];let a=r,l=s;for(Gr(e,t,r,n),t[2*s+i]>o&&Gr(e,t,r,s);a<l;){for(Gr(e,t,a,l),a++,l--;t[2*a+i]<o;)a++;for(;t[2*l+i]>o;)l--}t[2*r+i]===o?Gr(e,t,r,l):(l++,Gr(e,t,l,s)),l<=n&&(r=l+1),n<=l&&(s=l-1)}}function Gr(e,t,n,r){ca(e,n,r),ca(t,2*n,2*r),ca(t,2*n+1,2*r+1)}function ca(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function cd(e,t,n,r){const s=e-n,i=t-r;return s*s+i*i}class nI{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 Hs),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 c=l.get(s);c&&c.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:c,endRow:u,endColumn:h}=s;for(let d=l;d<=u;d++){const m=a.get(d);if(m)for(let _=c;_<=h;_++){const p=m.get(_);p&&p.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 _;const{unitId:n,sheetId:r,range:s}=t,{startRow:i,startColumn:o,endRow:a,endColumn:l}=s,c=(_=this._kdTree.get(n))==null?void 0:_.get(r);if(!c)return[];const{tree:u,items:h}=c,d=u.range(o,i,l,a),m=[];for(const p of d){const I=h[p];m.push(...Array.from(I.ids))}return m}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 aa(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:c}=s;if(this._enableOneCellCache&&o===a&&l===c){this._insertOneCellCache(n,r,o,l,i);return}const u=this.getTree(n,r);Number.isNaN(o)&&(o=0),Number.isNaN(l)&&(l=0),Number.isNaN(a)&&(a=Number.POSITIVE_INFINITY),Number.isNaN(c)&&(c=Number.POSITIVE_INFINITY),u.insert({minX:l,minY:o,maxX:c,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 c of l)yield c}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:c}=s;this._enableOneCellCache?o===l&&a===c?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 Hs;s.fromJSON(t[n][r]),this._tree.get(n).set(r,s)}}}}function rI(e){return new Promise(t=>setTimeout(t,e))}function sI(e=1){return new Promise(t=>{let n=0;const r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}var iI=Object.getOwnPropertyDescriptor,oI=(e,t,n,r)=>{for(var s=r>1?void 0:r?iI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},aI=(e,t)=>(n,r)=>t(n,r,e);f.Skeleton=class extends ze{constructor(n){super();C(this,"_fontLocale");C(this,"_dirty",!0);this._localeService=n,this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(n){this._dirty=n}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}},f.Skeleton=oI([aI(0,Re.Inject(Sn))],f.Skeleton);var lI=Object.getOwnPropertyDescriptor,cI=(e,t,n,r)=>{for(var s=r>1?void 0:r?lI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Qs=(e,t)=>(n,r)=>t(n,r,e);f.SheetSkeleton=class extends f.Skeleton{constructor(n,r,s,i,o,a){super(s);C(this,"_worksheetData");C(this,"_renderRawFormula",!1);C(this,"_cellData");C(this,"_imageCacheMap");C(this,"_skipAutoHeightForMergedCells",!0);C(this,"_rowTotalHeight",0);C(this,"_columnTotalWidth",0);C(this,"_rowHeaderWidth",0);C(this,"_columnHeaderHeight",0);C(this,"_rowHeightAccumulation",[]);C(this,"_columnWidthAccumulation",[]);C(this,"_marginTop",0);C(this,"_marginLeft",0);C(this,"_scaleX");C(this,"_scaleY");C(this,"_scrollX");C(this,"_scrollY");this.worksheet=n,this._styles=r,this._contextService=i,this._configService=o,this._injector=a,this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new od(this._injector),this.initConfig()}initConfig(){var n,r;this._skipAutoHeightForMergedCells=!((n=this._configService.getConfig(Ea))!=null&&n),this.worksheet.setIsRowStylePrecedeColumnStyle((r=this._configService.getConfig(pa))!=null?r:!1)}resetCache(){}getWorksheetConfig(){return this._worksheetData}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(n){this._columnHeaderHeight=n,this._worksheetData.columnHeader.height=n}set rowHeaderWidth(n){this._rowHeaderWidth=n,this._worksheetData.rowHeader.width=n}get rowHeightAccumulation(){return this._rowHeightAccumulation}get rowTotalHeight(){return this._rowTotalHeight}get columnWidthAccumulation(){return this._columnWidthAccumulation}get columnTotalWidth(){return this._columnTotalWidth}get rowHeaderWidth(){return this._rowHeaderWidth}get columnHeaderHeight(){return this._columnHeaderHeight}setMarginLeft(n){this._marginLeft=n}setMarginTop(n){this._marginTop=n}setScale(n,r){this._updateLayout(),this._scaleX=n,this._scaleY=r||n,this._updateLayout()}setScroll(n,r){Z.isDefine(n)&&(this._scrollX=n),Z.isDefine(r)&&(this._scrollY=r)}get scrollX(){return this._scrollX}get scrollY(){return this._scrollY}get scaleX(){return this._scaleX}get scaleY(){return this._scaleY}get rowHeaderWidthAndMarginLeft(){return this.rowHeaderWidth+this._marginLeft}get columnHeaderHeightAndMarginTop(){return this.columnHeaderHeight+this._marginTop}get imageCacheMap(){return this._imageCacheMap}_generateRowMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let c=s;if(this.worksheet.getRowFiltered(l))c=0;else if(a[l]!=null){const u=a[l];if(!u)continue;const{h=s,ah:d,ia:m}=u;(m==null||m===ae.TRUE)&&typeof d=="number"?c=d:c=h,u.hd===ae.TRUE&&(c=0)}i+=c,o.push(i)}return{rowTotalHeight:i,rowHeightAccumulation:o}}_generateColumnMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let c=s;if(a[l]!=null){const u=a[l];if(!u)continue;u.w!=null&&(c=u.w),u.hd===ae.TRUE&&(c=0)}i+=c,o.push(i)}return{columnTotalWidth:i,columnWidthAccumulation:o}}intersectMergeRange(n,r){return!!this.worksheet.getMergedCell(n,r)}_getOverflowBound(n,r,s,i,o=Ot.LEFT){let a=0;if(r>s){const l=this._columnWidthAccumulation.length-1;for(let c=r;c>=s;c--){const u=c,h=this.worksheet.getCell(n,u);if(!Bi(h)&&u!==r||this.intersectMergeRange(n,u))return u===r?u:u+1>l?l:u+1;const{startX:d,endX:m}=qn(n,u,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===Ot.CENTER&&u===r?a+=(m-d)/2:a+=m-d,i<a)return u}return r}for(let l=r;l<=s;l++){const c=l,u=this.worksheet.getCell(n,c);if(!Bi(u)&&c!==r||this.intersectMergeRange(n,c))return c===r?c:c-1<0?0:c-1;const{startX:h,endX:d}=qn(n,c,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===Ot.CENTER&&c===r?a+=(d-h)/2:a+=d-h,i<a)return c}return s}_updateLayout(){if(!this.dirty)return;const{rowData:n,columnData:r,defaultRowHeight:s,defaultColumnWidth:i,rowCount:o,columnCount:a,rowHeader:l,columnHeader:c}=this._worksheetData,{rowTotalHeight:u,rowHeightAccumulation:h}=this._generateRowMatrixCache(o,n,s),{columnTotalWidth:d,columnWidthAccumulation:m}=this._generateColumnMatrixCache(a,r,i);this._rowHeaderWidth=l.hidden!==ae.TRUE?this._dynamicallyUpdateRowHeaderWidth(l):0,this._columnHeaderHeight=c.hidden!==ae.TRUE?c.height:0,this._rowTotalHeight=u,this._rowHeightAccumulation=h,this._columnTotalWidth=d,this._columnWidthAccumulation=m,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(n){}_dynamicallyUpdateRowHeaderWidth(n){const s=`${this.worksheet.getRowCount()}`.length*8;return Math.max(n.width,s)}_hasUnMergedCellInRow(n,r,s){if(!this.worksheet.getMergeData())return!1;for(let o=r;o<=s;o++){const{isMerged:a,isMergedMainCell:l}=this.worksheet.getCellInfoInMergeData(n,o);if(!a&&!l)return!0}return!1}expandRangeByMerge(n){let{startRow:r,startColumn:s,endRow:i,endColumn:o}=n;const a=this._worksheetData.mergeData;if(!a)return{startRow:r,startColumn:s,endRow:i,endColumn:o};let l=!0;const c=new ut;for(;l;){l=!1;for(let u=0;u<a.length;u++){const{startRow:h,startColumn:d,endRow:m,endColumn:_}=a[u];if(c.getValue(h,d))continue;Bu({startColumn:s,startRow:r,endColumn:o,endRow:i},{startColumn:d,startRow:h,endColumn:_,endRow:m})&&(r=Math.min(r,h),s=Math.min(s,d),i=Math.max(i,m),o=Math.max(o,_),c.setValue(h,d,!0),l=!0)}}return{startRow:r,startColumn:s,endRow:i,endColumn:o}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(n,r){return this.worksheet.getCellInfoInMergeData(n,r)}getNoMergeCellPositionByIndex(n,r,s=!0){return this.getNoMergeCellWithCoordByIndex(n,r,s)}getNoMergeCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this;let{startY:c,endY:u,startX:h,endX:d}=qn(n,r,i,o);return s&&(c+=l,u+=l,h+=a,d+=a),{startY:c,endY:u,startX:h,endX:d}}getNoMergeCellPositionByIndexWithNoHeader(n,r){const{rowHeightAccumulation:s,columnWidthAccumulation:i}=this,{startY:o,endY:a,startX:l,endX:c}=qn(n,r,s,i);return{startY:o,endY:a,startX:l,endX:c}}getRowIndexByOffsetY(n,r,s,i){var l;const{rowHeightAccumulation:o}=this;n=hd(n,r,s,this.columnHeaderHeightAndMarginTop);let a=mr(o,n,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(o[a]-n)<Math.abs(n-((l=o[a-1])!=null?l:0))&&(a=a+1),a}getColumnIndexByOffsetX(n,r,s,i){var c;const o=ud(n,r,s,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this;let l=mr(a,o,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(a[l]-o)<Math.abs(o-((c=a[l-1])!=null?c:0))&&(l=l+1),l}getCellIndexByOffset(n,r,s,i,o,a){const l=this.getRowIndexByOffsetY(r,i,o,a),c=this.getColumnIndexByOffsetX(n,s,o,a);return{row:l,column:c}}getCellByOffset(n,r,s,i,o){const a=this==null?void 0:this.getCellIndexByOffset(n,r,s,i,o,{firstMatch:!0});return a?this.worksheet.getCellInfoInMergeData(a.row,a.column):null}getCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this,c=qn(n,r,i,o,this.worksheet.getCellInfoInMergeData(n,r)),{isMerged:u,isMergedMainCell:h}=c;let{startY:d,endY:m,startX:_,endX:p,mergeInfo:I}=c,A=a,B=l;return s===!1&&(A=0,B=0),d+=B,m+=B,_+=A,p+=A,I.startY+=B,I.endY+=B,I.startX+=A,I.endX+=A,{actualRow:n,actualColumn:r,startX:_,startY:d,endX:p,endY:m,isMerged:u,isMergedMainCell:h,mergeInfo:I}}getCellWithCoordByOffset(n,r,s,i,o,a){const{row:l,column:c}=this.getCellIndexByOffset(n,r,s,i,o,a);return this.getCellWithCoordByIndex(l,c)}getOffsetByColumn(n){const{columnWidthAccumulation:r,rowHeaderWidthAndMarginLeft:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetByRow(n){const{rowHeightAccumulation:r,columnHeaderHeightAndMarginTop:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetRelativeToRowCol(n,r){const s=mr(this.columnWidthAccumulation,n);let i=0;s===0?i=n:i=n-this._columnWidthAccumulation[s-1];const o=mr(this.rowHeightAccumulation,r);let a=0;return o===0?a=r:a=r-this._rowHeightAccumulation[o-1],{row:o,column:s,columnOffset:i,rowOffset:a}}_updateConfigAndGetDocumentModel(n,r,s,i){var a,l,c,u,h;if(!i||!((a=n.body)!=null&&a.dataStream))return;n.documentStyle||(n.documentStyle={}),n.documentStyle.marginTop=(l=s.t)!=null?l:0,n.documentStyle.marginBottom=(c=s.b)!=null?c:2,n.documentStyle.marginLeft=(u=s.l)!=null?u:2,n.documentStyle.marginRight=(h=s.r)!=null?h:2,n.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},n.documentStyle.renderConfig={...n.documentStyle.renderConfig,...i};const o=n.body.paragraphs||[];for(const d of o)d.paragraphStyle||(d.paragraphStyle={}),d.paragraphStyle.horizontalAlign=r;return new At(n)}dispose(){super.dispose(),this._rowHeightAccumulation=[],this._columnWidthAccumulation=[],this._rowTotalHeight=0,this._columnTotalWidth=0,this._rowHeaderWidth=0,this._columnHeaderHeight=0,this._worksheetData=null,this._cellData=null,this._styles=null}},f.SheetSkeleton=cI([Qs(2,Re.Inject(Sn)),Qs(3,Ln),Qs(4,qo),Qs(5,Re.Inject(Re.Injector))],f.SheetSkeleton);function ua(e,t,n,r){const s=e-1,i=t-1,o=n[s]||0;let a=n[e];a==null&&(a=n[n.length-1]);const l=r[i]||0;let c=r[t];return c==null&&(c=r[r.length-1]),{startY:o,endY:a,startX:l,endX:c}}function uI(e,t,n,r){return ua(e,t,n,r)}function qn(e,t,n,r,s){e=Z.clamp(e,0,n.length-1),t=Z.clamp(t,0,r.length-1);let{startY:i,endY:o,startX:a,endX:l}=ua(e,t,n,r);if(!s)return{startY:i,endY:o,startX:a,endX:l,isMerged:!1,isMergedMainCell:!1,actualRow:e,actualColumn:t,mergeInfo:{startY:i,endY:o,startX:a,endX:l,startRow:e,startColumn:t,endRow:e,endColumn:t}};const{isMerged:c,isMergedMainCell:u,startRow:h,startColumn:d,endRow:m,endColumn:_}=s;let p={startRow:h,startColumn:d,endRow:m,endColumn:_,startY:i,endY:o,startX:a,endX:l};const I=n.length-1,A=r.length-1;if(c&&h!==-1&&d!==-1){const B=n[h-1]||0,x=n[m]||n[I],Y=r[d-1]||0,O=r[_]||r[A];p={...p,startY:B,endY:x,startX:Y,endX:O}}else if(!c&&m!==-1&&_!==-1){const B=n[m]||n[I],x=r[_]||r[A];p={...p,startY:i,endY:B,startX:a,endX:x}}return{isMerged:c,isMergedMainCell:u,actualRow:e,actualColumn:t,startY:i,endY:o,startX:a,endX:l,mergeInfo:p}}function ud(e,t,n,r){const{x:s}=n;return e/t+s-r}function hd(e,t,n,r){const{y:s}=n;return e=e/t+s-r,e}const hI=["script","style","meta","comment","link"];var dd=(e=>(e[e.INFO=0]="INFO",e[e.STOP=1]="STOP",e[e.WARNING=2]="WARNING",e))(dd||{}),fd=(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))(fd||{}),md=(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))(md||{}),gd=(e=>(e[e.TEXT=0]="TEXT",e[e.ARROW=1]="ARROW",e[e.CUSTOM=2]="CUSTOM",e))(gd||{}),_d=(e=>(e.VALID="valid",e.INVALID="invalid",e.VALIDATING="validating",e))(_d||{}),pd=(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))(pd||{}),dI=Object.getOwnPropertyDescriptor,fI=(e,t,n,r)=>{for(var s=r>1?void 0:r?dI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Ed=(e,t)=>(n,r)=>t(n,r,e);let ha=class extends ze{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){const e=n=>{n.businesses.forEach(r=>{switch(r){case we.UNRECOGNIZED:case we.UNIVER_UNKNOWN:case we.UNIVER_SLIDE:case we.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType(we.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 we.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(we.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$(we.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(we.UNIVER_DOC).subscribe(n=>{const r=n.getUnitId();Ca(r)||this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(we.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(we.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=Z.deepClone(t.getSnapshot());return r.resources=n,r}};ha=fI([Ed(0,Re.Inject(Xs)),Ed(1,Re.Inject(Xn))],ha);class mI{constructor(t={},n){C(this,"_startedTypes",new Set);C(this,"_injector");C(this,"_disposingCallbacks",new ss);const r=this._injector=gI(n,t==null?void 0:t.override),{theme:s,darkMode:i,locale:o,locales:a,logLevel:l}=t;s&&this._injector.get(Zs).setTheme(s),i&&this._injector.get(Zs).setDarkMode(i),a&&this._injector.get(Sn).load(a),o&&this._injector.get(Sn).setLocale(o),l&&this._injector.get(Et).setLogLevel(l),this._init(r)}get _univerInstanceService(){return this._injector.get(Xn)}get _pluginService(){return this._injector.get(f.PluginService)}__getInjector(){return this._injector}onDispose(t){const n=this._disposingCallbacks.add(je(t));return je(()=>n.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(t){this._injector.get(Sn).setLocale(t)}createUnit(t,n){return this._univerInstanceService.createUnit(t,n)}createUniverSheet(t){return this._injector.get(Et).warn("[Univer]","Univer.createUniverSheet is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(we.UNIVER_SHEET,t)}createUniverDoc(t){return this._injector.get(Et).warn("[Univer]","Univer.createUniverDoc is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(we.UNIVER_DOC,t)}createUniverSlide(t){return this._injector.get(Et).warn("[Univer]","Univer.createUniverSlide is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(we.UNIVER_SLIDE,t)}_init(t){this._univerInstanceService.registerCtorForType(we.UNIVER_SHEET,f.Workbook),this._univerInstanceService.registerCtorForType(we.UNIVER_DOC,At),this._univerInstanceService.registerCtorForType(we.UNIVER_SLIDE,ea);const n=t.get(Xn);n.__setCreateHandler((r,s,i,o)=>{if(!this._startedTypes.has(r)){this._pluginService.startPluginsForType(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(f.LifecycleService).stage<ke.Ready&&(this._injector.get(f.LifecycleService).stage=ke.Ready)}registerPlugin(t,n){this._pluginService.registerPlugin(t,n)}registerPlugins(t){t.forEach(n=>{const[r,s]=n;this._pluginService.registerPlugin(r,s)})}}function gI(e,t){const n=Qh([[Ah],[Sn],[Zs],[f.LifecycleService],[f.PluginService],[xr],[Xn,{useClass:f.UniverInstanceService}],[Zh,{useClass:Jh}],[Et,{useClass:Sc,lazy:!0}],[fr,{useClass:f.CommandService}],[Js,{useClass:f.LocalUndoRedoService,lazy:!0}],[qo,{useClass:vh}],[Ln,{useClass:Rc}],[Xs,{useClass:f.ResourceManagerService,lazy:!0}],[sa,{useClass:ha,lazy:!0}],[Oh,{useClass:f.AuthzIoLocalService}],[qh,{useClass:f.MentionIOLocalService,lazy:!0}]],t),r=e?e.createChild(n):new Re.Injector(n);return Ra(r,[[xr],[sa]]),r}bd(),f.ABCToNumber=x0,f.AUTO_HEIGHT_FOR_MERGED_CELLS=Ea,f.AbsoluteRefType=Ne,f.ActionIterator=zn,f.AlignTypeH=ec,f.AlignTypeV=tc,f.ArrangeTypeEnum=sc,f.ArrowsAndMarkersShapes=bl,f.AsyncInterceptorManager=zd,f.AsyncLock=kd,f.AutoFillSeries=gl,f.BaselineOffset=Ht,f.BasicShapes=wl,f.BlockType=Ul,f.BooleanNumber=ae,f.BorderStyleTypes=Ue,f.BorderType=_l,f.BuildTextUtils=Je,f.BulletAlignment=ur,f.COLORS=Di,f.CanceledError=Hd,f.CellModeEnum=Dn,f.CellValueType=Zt,f.Color=En,f.ColorBuilder=gs,f.ColorKit=wt,f.ColorType=pt,f.ColumnSeparatorType=Fl,f.CommandType=dr,f.CommonHideTypes=pl,f.ConfigService=vh,f.ContextService=Rc,f.CopyPasteType=El,f.CustomCommandExecutionError=qr,f.CustomDecorationType=gn,f.CustomRangeType=Jt,f.DEFAULT_CELL=m0,f.DEFAULT_DOC=jo,f.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=JC,f.DEFAULT_EMPTY_DOCUMENT_VALUE=_a,f.DEFAULT_NUMBER_FORMAT=Du,f.DEFAULT_RANGE=d0,f.DEFAULT_RANGE_ARRAY=h0,f.DEFAULT_SELECTION=f0,f.DEFAULT_SLIDE=Uu,f.DEFAULT_STYLES=st,f.DEFAULT_TEXT_FORMAT=Mu,f.DEFAULT_TEXT_FORMAT_EXCEL=Lu,f.DEFAULT_WORKSHEET_COLUMN_COUNT=Fh,f.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=vR,f.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Hh,f.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=TR,f.DEFAULT_WORKSHEET_COLUMN_WIDTH=Bh,f.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=bR,f.DEFAULT_WORKSHEET_ROW_COUNT=kh,f.DEFAULT_WORKSHEET_ROW_COUNT_KEY=OR,f.DEFAULT_WORKSHEET_ROW_HEIGHT=xh,f.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=wR,f.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=$h,f.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=AR,f.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=si,f.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=ri,f.DOCS_ZEN_EDITOR_UNIT_ID_KEY=ga,f.DOC_DRAWING_PRINTING_COMPONENT_KEY=C0,f.DOC_RANGE_TYPE=Pc,f.DashStyleType=jl,f.DataStreamTreeNodeType=gh,f.DataStreamTreeTokenType=lt,f.DataValidationErrorStyle=dd,f.DataValidationImeMode=fd,f.DataValidationOperator=md,f.DataValidationRenderMode=gd,f.DataValidationStatus=_d,f.DataValidationType=pd,f.DeleteDirection=Cl,f.DependentOn=KR,f.DesktopLogService=Sc,f.DeveloperMetadataVisibility=Rl,f.Dimension=Il,f.Direction=Sl,f.Disposable=ze,f.DisposableCollection=ss,f.DocStyleType=Ll,f.DocumentDataModel=At,f.DocumentFlavor=vi,f.DrawingTypeEnum=ic,f.EDITOR_ACTIVATED=wh,f.EXTENSION_NAMES=Pu,f.ErrorService=Ah,f.EventState=Ih,f.EventSubject=QC,f.FOCUSING_COMMON_DRAWINGS=uR,f.FOCUSING_DOC=$r,f.FOCUSING_EDITOR_BUT_HIDDEN=sR,f.FOCUSING_EDITOR_INPUT_FORMULA=iR,f.FOCUSING_EDITOR_STANDALONE=aR,f.FOCUSING_FX_BAR_EDITOR=bh,f.FOCUSING_PANEL_EDITOR=lR,f.FOCUSING_SHEET=Kn,f.FOCUSING_SLIDE=Hr,f.FOCUSING_UNIT=Br,f.FOCUSING_UNIVER_EDITOR=oR,f.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=cR,f.FORMULA_EDITOR_ACTIVATED=hR,f.FollowNumberWithType=Dl,f.FontItalic=as,f.FontStyleType=Mn,f.FontWeight=ls,f.GridType=Pl,f.HLSColor=Nc,f.HorizontalAlign=Ot,f.IAuthzIoService=Oh,f.ICommandService=fr,f.IConfigService=qo,f.IContextService=Ln,f.IImageIoService=Jo,f.ILocalStorageService=$R,f.ILogService=Et,f.IMentionIOService=qh,f.IPermissionService=Zh,f.IResourceLoaderService=sa,f.IResourceManagerService=Xs,f.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=pa,f.IUndoRedoService=Js,f.IUniverInstanceService=Xn,f.ImageCacheMap=od,f.ImageSourceType=Zo,f.ImageUploadStatusType=Th,f.InterceptorEffectEnum=bn,f.InterceptorManager=Yd,f.InterpolationPointType=Ol,f.JSON1=L_,f.JSONX=jt,f.LRUHelper=pr,f.LRUMap=_r,f.LifecycleStages=ke,f.LifecycleUnreachableError=Kh,f.ListGlyphType=fe,f.LocaleService=Sn,f.LocaleType=lr,f.LogLevel=Ic,f.MOVE_BUFFER_VALUE=gr,f.MemoryCursor=dn,f.MentionType=os,f.NAMED_STYLE_MAP=_0,f.NAMED_STYLE_SPACE_MAP=p0,f.NamedStyleType=qe,f.NilCommand=vc,f.NumberUnitType=Ql,f.ObjectMatrix=ut,f.ObjectRelativeFromH=Zl,f.ObjectRelativeFromV=Jl,f.OtherShapes=Al,f.PAGE_SIZE=R0,f.PAPER_TYPES=v_,f.PRESET_LIST_TYPE=Ur,f.PRINT_CHART_COMPONENT_KEY=E0,f.PageElementType=oc,f.PageOrientType=rc,f.PageType=wi,f.PaperType=ct,f.ParagraphElementType=Bl,f.ParagraphStyleBuilder=Fr,f.ParagraphStyleValue=kr,f.PermissionService=Jh,f.PermissionStatus=ta,f.Plugin=ra,f.PositionedObjectLayoutType=Hl,f.PresetListType=Ft,f.ProtectionType=vl,f.QuickListType=rh,f.QuickListTypeMap=X0,f.RANGE_DIRECTION=Uc,f.RANGE_TYPE=pe,f.RBush=Hs,f.RCDisposable=c_,f.RGBA_PAREN=K_,f.RGB_PAREN=z_,f.ROTATE_BUFFER_VALUE=Tc,f.RTree=nI,f.Range=Wn,f.Rectangle=nn,f.RedoCommand=id,f.RedoCommandId=nd,f.RefAlias=F0,f.Registry=Ri,f.RegistryAsMap=Ii,f.RelativeDate=yl,f.RelativeSlideLink=ac,f.RgbColor=_s,f.RichTextBuilder=In,f.RichTextValue=on,f.RxDisposable=l_,f.SHEET_EDITOR_UNITS=g0,f.SectionType=kl,f.SheetTypes=Nl,f.SheetViewModel=jh,f.SliceBodyType=Ho,f.SlideDataModel=ea,f.SpacingRule=Wl,f.SpecialShapes=Tl,f.Styles=yh,f.THEME_COLORS=yc,f.TabStopAlignment=Yl,f.TableAlignmentType=Vl,f.TableLayoutType=zl,f.TableRowHeightRule=Xl,f.TableSizeType=Gl,f.TableTextWrapType=Kl,f.TextDecoration=Ml,f.TextDecorationBuilder=sn,f.TextDirection=cr,f.TextDirectionType=xl,f.TextStyleBuilder=rn,f.TextStyleValue=Pr,f.TextX=Me,f.TextXActionType=J,f.ThemeColor=ps,f.ThemeColorType=ot,f.ThemeColors=cs,f.ThemeService=Zs,f.Tools=Z,f.UndoCommand=sd,f.UndoCommandId=rd,f.UnitModel=is,f.Univer=mI,f.UniverInstanceType=we,f.UpdateDocsAttributeType=Ce,f.UserManagerService=xr,f.VerticalAlign=fn,f.VerticalAlignmentType=ql,f.Worksheet=jr,f.WrapStrategy=mn,f.WrapTextType=$l,f.addLinkToDocumentModel=Lh,f.afterInitApply=W_,f.afterTime=$_,f.awaitTime=rI,f.binSearchFirstGreaterThanTarget=Ac,f.binarySearchArray=j_,f.bufferDebounceTime=B_,f.cellToRange=vp,f.characterSpacingControlType=nc,f.checkForSubstrings=bp,f.checkIfMove=G_,f.checkParagraphHasBullet=lE,f.checkParagraphHasIndent=cE,f.checkParagraphHasIndentByStyle=Xc,f.codeToBlob=Y_,f.composeBody=Wo,f.composeInterceptors=Sa,f.composeStyles=ar,f.concatMatrixArray=fp,f.convertBodyToHtml=V_,f.convertCellToRange=kc,f.convertObservableToBehaviorSubject=H_,f.covertCellValue=$i,f.covertCellValues=wp,f.covertTextRunToHtml=Li,f.createAsyncInterceptorKey=Gd,f.createDefaultUser=qs,f.createDocumentModelWithStyle=Wr,f.createInterceptorKey=jd,f.createInternalEditorID=Bd,f.createRowColIter=Fo,f.dayjs=Wt,f.debounce=Kg,f.dedupe=Ad,f.dedupeBy=Td,f.deepCompare=Hi,f.delayAnimationFrame=sI,f.deleteContent=Zc,f.extractPureTextFromCell=Gh,f.fromCallback=wc,f.fromEventSubject=eR,f.fromObservable=a_,f.generateRandomId=tt,f.get=nl,f.getArrayLength=Qt,f.getBodySlice=bt,f.getBodySliceHtml=ms,f.getBorderStyleType=Ip,f.getCellCoordByIndexSimple=ua,f.getCellInfoInMergeData=hp,f.getCellPositionByIndexSimple=uI,f.getCellValueType=lp,f.getCellWithCoordByIndexCore=qn,f.getColorStyle=Ut,f.getCustomBlockSlice=lh,f.getCustomDecorationSlice=uh,f.getCustomRangeSlice=ch,f.getDocsUpdateBody=Sp,f.getIntersectRange=Bu,f.getOriginCellValue=NR,f.getParagraphsSlice=ah,f.getPlainText=Ks,f.getReverseDirection=O_,f.getSectionBreakSlice=sC,f.getTableSlice=oh,f.getTextRunSlice=zs,f.getTransformOffsetX=ud,f.getTransformOffsetY=hd,f.getWorksheetUID=UR,f.groupBy=Md,f.handleStyleToString=Rp,f.hashAlgorithm=hE,f.horizontalLineSegmentsSubtraction=ys,f.insertMatrixArray=ki,f.insertTextToContent=qc,f.invertColorByHSL=Qd,f.invertColorByMatrix=tf,f.isBlackColor=op,f.isBooleanString=xd,f.isCellCoverable=Bi,f.isCellV=Dc,f.isDefaultFormat=c0,f.isEmptyCell=Fc,f.isFormulaId=Cp,f.isFormulaString=xc,f.isICellData=Lc,f.isInternalEditorID=Ca,f.isNodeEnv=S_,f.isNotNullOrUndefined=Dh,f.isNullCell=cp,f.isNumeric=cl,f.isPatternEqualWithoutDecimal=u0,f.isRangesEqual=mR,f.isRealNum=uE,f.isSafeNumeric=n_,f.isSameStyleTextRun=Bc,f.isTextFormat=l0,f.isUnitRangesEqual=gR,f.isValidRange=Op,f.isWhiteColor=ap,f.makeArray=Ld,f.makeCellRangeToRangeData=Ep,f.makeCellToSelection=pp,f.makeCustomRangeStream=EC,f.mapObjectMatrix=dp,f.merge=rs,f.mergeLocales=dE,f.mergeOverrideWithDependencies=Qh,f.mergeSets=i_,f.mergeWith=Jg,f.mergeWorksheetSnapshotWithDefault=Wh,f.mixinClass=t_,f.moveMatrixArray=xi,f.moveRangeByOffset=A0,f.nameCharacterCheck=tI,f.normalizeBody=iC,f.normalizeTextRuns=Dr,f.numberToABC=$0,f.numberToListABC=H0,f.numfmt=a0,f.queryObjectMatrix=k0,f.registerDependencies=$d,f.remove=tr,f.repeatStringNumTimes=ju,f.replaceInDocumentBody=qC,f.requestImmediateMacroTask=s_,f.rotate=Nd,f.searchArray=mr,f.searchInOrderedArray=bc,f.selectionToArray=up,f.sequence=hl,f.sequenceAsync=ul,f.sequenceExecute=fs,f.sequenceExecuteAsync=x_,f.set=e_,f.shallowEqual=Ia,f.skipParseTagNames=hI,f.sliceMatrixArray=mp,f.sortRules=W0,f.sortRulesByDesc=j0,f.sortRulesFactory=Lr,f.spliceArray=Fi,f.splitIntoGrid=ko,f.takeAfter=Mi,f.textDiff=Go,f.throttle=Wd,f.toDisposable=je,f.touchDependencies=Ra,f.updateAttributeByDelete=hh,f.updateAttributeByInsert=dh,f.willLoseNumericPrecision=r_,Object.keys(Re).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(f,e)&&Object.defineProperty(f,e,{enumerable:!0,get:()=>Re[e]})}),Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/core",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "private": false,
5
5
  "description": "Core library for Univer.",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -70,7 +70,7 @@
70
70
  "numfmt": "^3.2.3",
71
71
  "ot-json1": "^1.0.2",
72
72
  "rbush": "^4.0.1",
73
- "@univerjs/themes": "0.10.0"
73
+ "@univerjs/themes": "0.10.1"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@types/async-lock": "^1.4.2",
@@ -80,7 +80,7 @@
80
80
  "typescript": "^5.8.3",
81
81
  "vite": "^7.0.6",
82
82
  "vitest": "^3.2.4",
83
- "@univerjs-infra/shared": "0.10.0"
83
+ "@univerjs-infra/shared": "0.10.1"
84
84
  },
85
85
  "scripts": {
86
86
  "test": "vitest run",