@univerjs/core 0.19.0 → 0.20.0
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 +3 -3
- package/lib/es/index.js +2 -2
- package/lib/index.js +2 -2
- package/lib/types/index.d.ts +1 -1
- package/lib/types/sheets/sheet-skeleton.d.ts +11 -54
- package/lib/umd/index.js +3 -3
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -5,5 +5,5 @@ import e from"async-lock";import{Inject as t,Inject as n,InjectSelf as r,Injecto
|
|
|
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}({});function uc(e){return`${e}`}const dc=[X.TABLE_START,X.TABLE_ROW_START,X.TABLE_CELL_START,X.TABLE_CELL_END,X.TABLE_ROW_END,X.TABLE_END],fc=e=>{let t=e.endsWith(`\r
|
|
6
6
|
`)?e.slice(0,-2):e;return dc.reduce((e,t)=>e.replaceAll(t,``),t)},pc=e=>e?fc(e).replaceAll(`\r`,``)===``:!0,mc=e=>{let t=e.replace(/\n/g,`\r`),n=[],r=[],i=0,a=``,o=(o,s=!0)=>{let c=t.slice(i,o);if(D.isLegalUrl(c)){let t=O(),l=`${c}`,u={startIndex:i,endIndex:i+l.length-1,rangeId:t,rangeType:or.HYPERLINK,properties:{url:e}};r.push(u),a+=l,i=o+1,s&&(a+=`\r`,n.push({startIndex:o}))}else a+=t.slice(i,o+1),i=o+1,s&&n.push({startIndex:o})},s=0;for(let e=0;e<t.length;e++)t[e]===`\r`&&(o(e),s=e);return(s!==t.length-1||t.length===1)&&o(t.length,!1),{dataStream:a,paragraphs:n,customRanges:r}},hc={id:`default_doc`,documentStyle:{}};var gc=class extends pn{getUnitId(){throw Error(`Method not implemented.`)}constructor(e){var t;super(),C(this,`type`,x.UNIVER_DOC),C(this,`_name$`,new v(``)),C(this,`name$`,this._name$.asObservable()),C(this,`snapshot`,void 0),this.snapshot={...hc,...e},this._name$.next((t=this.snapshot.title)==null?`No Title`:t)}getRev(){var e;return(e=this.snapshot.rev)==null?1:e}incrementRev(){this.snapshot.rev=this.getRev()+1}setRev(e){this.snapshot.rev=e}setName(e){this.snapshot.title=e,this._name$.next(e)}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get zoomRatio(){var e;return((e=this.snapshot.settings)==null?void 0:e.zoomRatio)||1}resetDrawing(e,t){this.snapshot.drawings=e,this.snapshot.drawingsOrder=t}getBody(){return this.snapshot.body}getSnapshot(){return this.snapshot}getBulletPresetList(){var e;let t=(e=this.snapshot.lists)==null?{}:e;return{...xs,...t}}updateDocumentId(e){this.snapshot.id=e}updateDocumentRenderConfig(e){let{documentStyle:t}=this.snapshot;t.renderConfig==null?t.renderConfig=e:t.renderConfig={...t.renderConfig,...e}}getDocumentStyle(){return this.snapshot.documentStyle}updateDocumentStyle(e){this.snapshot.documentStyle==null?this.snapshot.documentStyle=e:this.snapshot.documentStyle={...this.snapshot.documentStyle,...e}}updateDocumentDataMargin(e){let{t,l:n,b:r,r:i}=e,{documentStyle:a}=this.snapshot;t!=null&&(a.marginTop=t),n!=null&&(a.marginLeft=n),r!=null&&(a.marginBottom=r),i!=null&&(a.marginRight=i)}updateDocumentDataPageSize(e,t){let{documentStyle:n}=this.snapshot;if(!n.pageSize){n.pageSize={width:e==null?1/0:e,height:t==null?1/0:t};return}e!==void 0&&(n.pageSize.width=e),t!==void 0&&(n.pageSize.height=t)}updateDrawing(e,t){let{drawings:n}=this,{width:r,height:i,left:a,top:o}=t,s=n==null?void 0:n[e];if(!s)return;let c=s.docTransform;c.size.width=r,c.size.height=i,c.positionH.posOffset=a,c.positionV.posOffset=o}setZoomRatio(e=1){this.snapshot.settings?this.snapshot.settings.zoomRatio=e:this.snapshot.settings={zoomRatio:e}}setDisabled(e){this.snapshot.disabled=e}getDisabled(){return this.snapshot.disabled}getTitle(){return this.snapshot.title}},_c=class e extends gc{constructor(e){var t,n;super(D.isEmptyObject(e)?Jr():e),C(this,`_unitId`,void 0),C(this,`headerModelMap`,new Map),C(this,`footerModelMap`,new Map),C(this,`change$`,new v(0)),this._unitId=(t=this.snapshot.id)==null?O(6):t,this._initializeHeaderFooterModel(),this._name$.next((n=this.snapshot.title)==null?``:n)}dispose(){super.dispose(),this.headerModelMap.forEach(e=>{e.dispose()}),this.footerModelMap.forEach(e=>{e.dispose()}),this._name$.complete()}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getCustomRanges(){var e;return(e=this.snapshot.body)==null?void 0:e.customRanges}getCustomDecorations(){var e;return(e=this.snapshot.body)==null?void 0:e.customDecorations}getSettings(){return this.snapshot.settings}reset(e){if(e.id&&e.id!==this._unitId)throw Error(`Cannot reset a document model with a different unit id!`);this.snapshot={...hc,...e},this._initializeHeaderFooterModel(),this.change$.next(this.change$.value+1)}getSelfOrHeaderFooterModel(e){if(e!=null){if(this.headerModelMap.has(e))return this.headerModelMap.get(e);if(this.footerModelMap.has(e))return this.footerModelMap.get(e)}return this}getUnitId(){return this._unitId}apply(e){if(!cc.isNoop(e))return this.snapshot=cc.apply(this.snapshot,e),e!=null&&e.some(e=>Array.isArray(e)&&((e==null?void 0:e[0])===`headers`||(e==null?void 0:e[0])===`footers`))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.change$.next(this.change$.value+1),this.snapshot}sliceBody(e,t,n=Ps.copy){let r=this.getBody();if(r!=null)return Bs(r,e,t,!1,n)}_initializeHeaderFooterModel(){let{headers:t,footers:n}=this.getSnapshot();if(t)for(let n in t){let r=t[n];this.headerModelMap.set(n,new e(r)),this.headerModelMap.get(n).updateDocumentId(this.getUnitId())}if(n)for(let t in n){let r=n[t];this.footerModelMap.set(t,new e(r)),this.footerModelMap.get(t).updateDocumentId(this.getUnitId())}}updateDocumentId(e){super.updateDocumentId(e),this._unitId=e}getPlainText(){var e,t;return fc((e=(t=this.getBody())==null?void 0:t.dataStream)==null?``:e)}};function vc(e){let{ranges:t,id:n,type:r}=e,i=new Y,a=0;for(let e=0;e<t.length;e++){let{startOffset:o,endOffset:s}=t[e];o>0&&i.push({t:I.RETAIN,len:o-a}),i.push({t:I.RETAIN,body:{dataStream:``,customDecorations:[{id:n,type:r,startIndex:0,endIndex:s-o-1}]},len:s-o}),a=s}return i}function yc(e){var t;let{id:n,segmentId:r,documentDataModel:i}=e,a=i==null?void 0:i.getBody();if(!i||!a)return!1;let o=(t=i.getSelfOrHeaderFooterModel(r))==null||(t=t.getBody())==null||(t=t.customDecorations)==null?void 0:t.find(e=>e.id===n);if(!o)return!1;let s=new Y,{startIndex:c,endIndex:l}=o,u=l-c+1;return s.push({t:I.RETAIN,len:c}),s.push({t:I.RETAIN,len:u,body:{dataStream:``,customDecorations:[{startIndex:0,endIndex:u-1,id:n,type:sr.DELETED}]}}),s}function bc(e,t,n,r){return e<=n&&t>=n||e>=n&&e<=r}function xc(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];e.collapsed?i.startIndex<e.startOffset&&e.startOffset<=i.endIndex&&n.push(i):bc(e.startOffset,e.endOffset-1,i.startIndex,i.endIndex)&&n.push(i)}return n}function Sc(e){return{...D.deepClone(e),rangeId:O()}}function Cc(e,t){let n=[],r=e[0];for(let i of t)i<e[0]||i>e[1]||(r<i&&n.push([r,i-1]),r=i+1);return r<=e[1]&&n.push([r,e[1]]),n}function wc(e,t,n,r){let i=[];for(let a=0,o=n.length;a<o;a++){let o=n[a];if((r===void 0||o.rangeType===r)&&Math.max(o.startIndex,e)<=Math.min(o.endIndex,t)&&i.push({...o}),o.startIndex>t)break}return i}function Tc(e,t){var n,r,i,a,o;let s=wc(e.startOffset,e.collapsed?e.startOffset:e.endOffset-1,(n=t.customRanges)==null?[]:n),c=Math.min(e.startOffset,(r=(i=s[0])==null?void 0:i.startIndex)==null?1/0:r),l=Math.max(e.endOffset,((a=(o=s[s.length-1])==null?void 0:o.endIndex)==null?-1/0:a)+1);return{startOffset:c,endOffset:l,collapsed:c===l}}function Ec(e){var t,n;let{rangeId:r,segmentId:i,documentDataModel:a,insert:o}=e,s=(t=a.getSelfOrHeaderFooterModel(i).getBody())==null||(t=t.customRanges)==null?void 0:t.find(e=>e.rangeId===r);if(!s)return!1;let{startIndex:c,endIndex:l}=s,u=new Y,d=l-c+1;u.push({t:I.RETAIN,len:c}),u.push({t:I.RETAIN,len:d,body:{dataStream:``,customRanges:[]}}),o&&u.push({t:I.INSERT,body:o,len:o.dataStream.length});let f=l+1+((n=o==null?void 0:o.dataStream.length)==null?0:n);return u.selections=[{startOffset:f,endOffset:f,collapsed:!0}],u}function Dc(e){let{ranges:t,rangeId:n,rangeType:r,wholeEntity:i,properties:a,body:o}=e,s=0,c=new Y,l=!1;return t.forEach(e=>{var t,u,d;let f=Tc(e,o);if(!f||!o)return!1;let{startOffset:p,endOffset:m}=f,h=(t=o.customRanges)==null?[]:t,g=(e,t,o)=>{var l,u,d,f;let p=wc(e,t,h,r),m=Math.min((l=(u=p[0])==null?void 0:u.startIndex)==null?1/0:l,e),g=Math.max((d=(f=p[p.length-1])==null?void 0:f.endIndex)==null?-1/0:d,t),_={rangeId:o?`${n}$${o}`:n,rangeType:r,startIndex:0,endIndex:g-m,wholeEntity:i,properties:{...a}};c.push({t:I.RETAIN,len:m-s}),c.push({t:I.RETAIN,len:g-m+1,body:{dataStream:``,customRanges:[_]},coverType:F.COVER}),s=g+1},_=((u=o.paragraphs)==null?[]:u).filter(e=>e.startIndex<m&&e.startIndex>p),ee=((d=o.customBlocks)==null?[]:d).filter(e=>e.startIndex<m&&e.startIndex>p);Cc([p,m-1],[..._.map(e=>e.startIndex),...ee.map(e=>e.startIndex)]).forEach(([e,t],n)=>g(e,t,n)),l=!0,c.selections=[{startOffset:f.endOffset,endOffset:f.endOffset,collapsed:!0}]}),l?c:!1}function Oc(e,t,n=0,r=null,i=!0){e.sort((e,t)=>e.startOffset-t.startOffset);let a=[],{paragraphs:o=[]}=t,s=o==null?void 0:o.find(t=>t.startIndex>=e[0].startOffset&&t.startIndex<e[0].endOffset),c=n;if(e.forEach(e=>{let{startOffset:t,endOffset:n}=e;t>c&&(a.push({t:I.RETAIN,len:t-c}),c=t),c<n&&(a.push({t:I.DELETE,len:n-c}),c=n)}),r&&a.push({t:I.INSERT,body:r,len:r.dataStream.length}),s&&i){let t=o.find(t=>t.startIndex-n>=e[e.length-1].endOffset-1);t&&(t.startIndex>c&&(a.push({t:I.RETAIN,len:t.startIndex-c}),c=t.startIndex),a.push({t:I.RETAIN,len:1,body:{dataStream:``,paragraphs:[{...t,startIndex:0,bullet:s==null?void 0:s.bullet}]},coverType:F.REPLACE}))}return a}function kc(e,t,n=0){let r=[],i=n;return e.forEach(e=>{let{startOffset:n,endOffset:a}=e;n>i&&(r.push({t:I.RETAIN,len:n-i}),i=n),a>i&&(r.push({t:I.RETAIN,len:a-i,body:{...D.deepClone(t),dataStream:``}}),i=a)}),r}const Ac=e=>{var t;let{selection:n,body:r,doc:i}=e,a=n.segmentId,o=(t=i.getSelfOrHeaderFooterModel(a))==null?void 0:t.getBody();if(!o)return!1;let s=n.collapsed?null:Bs(o,n.startOffset,n.endOffset),c=qe(s?s.dataStream:``,r.dataStream),l=0,u=c.map(([e,t])=>{switch(e){case 0:{let e={t:I.RETAIN,body:{...Bs(r,l,l+t.length,!1),dataStream:``},len:t.length};return l+=t.length,e}case 1:{let e={t:I.INSERT,body:Bs(r,l,l+t.length),len:t.length};return l+=t.length,e}default:return{t:I.DELETE,len:t.length}}}),d=new Y;return d.push({t:I.RETAIN,len:n.startOffset}),d.push(...u),d};function jc(e,t){return!!((e==null?void 0:e.length)===(t==null?void 0:t.length)&&e!=null&&e.every((e,n)=>JSON.stringify(e)===JSON.stringify(t==null?void 0:t[n])))}const Mc=e=>{var t;let{selection:n,body:r,doc:i,themeService:a}=e,o=n.segmentId,s=(t=i.getSelfOrHeaderFooterModel(o))==null?void 0:t.getBody();if(!s)return!1;let c=n.collapsed?null:Bs(s,n.startOffset,n.endOffset),l=qe(c?c.dataStream:``,r.dataStream),u=0,d=l.map(([e,t])=>{switch(e){case 0:{let e=Fs(r,u,u+t.length,!1),n=Fs(c,u,u+t.length,!1),i={t:I.RETAIN,body:jc(e,n)?void 0:{textRuns:e==null?void 0:e.map(e=>{var t,n,r,i;return{...e,ts:{...e.ts,cl:!((t=e.ts)==null||(t=t.cl)==null||(t=t.rgb)==null)&&t.includes(`.`)?{rgb:a.getColorFromTheme((n=(r=e.ts)==null||(r=r.cl)==null?void 0:r.rgb)==null?``:n)}:(i=e.ts)==null?void 0:i.cl}}}),dataStream:``},len:t.length};return u+=t.length,i}case 1:{let e={t:I.INSERT,body:Bs(r,u,u+t.length),len:t.length};return u+=t.length,e}default:return{t:I.DELETE,len:t.length}}});if(d.every(e=>e.t===I.RETAIN&&!e.body))return!1;let f=new Y;return f.push({t:I.RETAIN,len:n.startOffset}),f.push(...d),f};function Nc(e,t){let n=[],{customBlocks:r=[]}=e;for(let e of t){let{startOffset:t,endOffset:i}=e;if(!(t==null||i==null))for(let e of r){let{startIndex:r}=e;r>=t&&r<i&&n.push(e.blockId)}}return n}function Pc(e,t=``){if(!t)return[`body`];let{headers:n,footers:r}=e.getSnapshot();if(n==null&&r==null)throw 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 Error(`Segment id not found in headers or footers`)}const Fc=e=>{var t,n;let{selection:r,documentDataModel:i,drawings:a}=e,{collapsed:o,startOffset:s,segmentId:c}=r,l=new Y,u=cc.getInstance(),d=[],f=i.getSelfOrHeaderFooterModel(c).getBody();if(!f)return!1;let p=(t=(n=i.getSnapshot().drawingsOrder)==null?void 0:n.length)==null?0:t,m=0;if(o)s>0&&l.push({t:I.RETAIN,len:s});else{var h,g;let e=Oc([r],f,0,null,!1);l.push(...e);let t=Nc(f,[r]),n=(h=i.getDrawings())==null?{}:h,a=(g=i.getDrawingsOrder())==null?[]:g,o=t.sort((e,t)=>a.indexOf(e)>a.indexOf(t)?-1:a.indexOf(e)<a.indexOf(t)?1:0);if(o.length>0)for(let e of o){let t=n[e],r=a.indexOf(e);if(t==null||r<0)continue;let i=u.removeOp([`drawings`,e],t),o=u.removeOp([`drawingsOrder`,r],e);d.push(i),d.push(o),m++}}l.push({t:I.INSERT,body:{dataStream:`\b`.repeat(a.length),customBlocks:a.map((e,t)=>({startIndex:t,blockId:e.drawingId}))},len:a.length});let _=Pc(i,c),ee=u.editOp(l.serialize(),_);d.push(ee);for(let e of a){let{drawingId:t}=e,n=u.insertOp([`drawings`,t],e),r=u.insertOp([`drawingsOrder`,p-m],t);d.push(n),d.push(r)}return d.reduce((e,t)=>cc.compose(e,t),null)};function Ic(e,t){if(t===void 0)return{startOffset:e,endOffset:e,collapsed:!0};if(t<e)throw Error(`Cannot make a doc selection when endOffset ${t} is less than startOffset ${e}.`);return{startOffset:e,endOffset:t,collapsed:e===t}}function Lc(e){let{startOffset:t,endOffset:n,collapsed:r}=e;return{startOffset:Math.min(t,n),endOffset:Math.max(t,n),collapsed:r}}function Rc(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function zc(e,t,n,r){let{startOffset:i,endOffset:a}=e,o=r==null?Hc(t,n):r,s=[],c=-1;for(let e=0;e<o.length;e++){let t=o[e],{startIndex:n}=t;(i>c&&i<=n||a>c&&a<=n||n>=i&&n<=a)&&s.push(t),c=n}return s}function Bc(e,t,n){let r=[],i=Hc(t,n);for(let a of e){let e=zc(a,t,n,i);r.push(...e)}return r}const Vc=[X.PARAGRAPH,X.TABLE_START,X.TABLE_END,X.TABLE_ROW_START,X.TABLE_CELL_START,X.TABLE_CELL_END];function Hc(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r],{startIndex:a}=i,o=a-1;for(;!Vc.includes(t[o])&&o>=0;)o--;n.push({...i,paragraphStart:o+1,paragraphEnd:i.startIndex})}return n}const Uc=e=>{var t,n;let{paragraphs:r,segmentId:i,document:a}=e,o=e.listType,s=(t=(n=a.getSelfOrHeaderFooterModel(i).getBody())==null?void 0:n.paragraphs)==null?[]:t,c=r.every(e=>{var t;return((t=e.bullet)==null?void 0:t.listType.indexOf(o))===0}),l=O(6);if(r.length===1){let e=s.indexOf(r[0]),t=s[e-1],n=s[e+1];t&&t.bullet&&t.bullet.listType.indexOf(o)===0?(l=t.bullet.listId,o!==q.CHECK_LIST&&(o=t.bullet.listType)):n&&n.bullet&&n.bullet.listType.indexOf(o)===0&&(l=n.bullet.listId,o!==q.CHECK_LIST&&(o=n.bullet.listType))}let u=new Zt;u.reset();let d=new Y;for(let e of r){var f;let{startIndex:t,paragraphStyle:n={},bullet:r}=e;d.push({t:I.RETAIN,len:t-u.cursor}),d.push({t:I.RETAIN,len:1,body:{dataStream:``,paragraphs:[c?{paragraphStyle:n,startIndex:0}:{startIndex:0,paragraphStyle:{...n},bullet:{nestingLevel:(f=r==null?void 0:r.nestingLevel)==null?0:f,textStyle:{fs:20},listType:o,listId:l}}]},coverType:F.REPLACE}),u.moveCursorTo(t+1)}return d},Wc=e=>{var t;let{paragraphIndex:n,segmentId:r,document:i}=e,a=(t=i.getSelfOrHeaderFooterModel(r).getBody())==null?void 0:t.paragraphs;if(a==null)return!1;let o=a.find(e=>e.startIndex===n);if(!(o!=null&&o.bullet)||o.bullet.listType.indexOf(q.CHECK_LIST)===-1)return!1;let s=new Zt;s.reset();let c=new Y,{startIndex:l,paragraphStyle:u={}}=o,d=o.bullet.listType===q.CHECK_LIST?q.CHECK_LIST_CHECKED:q.CHECK_LIST;return c.push({t:I.RETAIN,len:l-s.cursor}),c.push({t:I.RETAIN,len:1,body:{dataStream:``,paragraphs:[{...o,paragraphStyle:u,startIndex:0,bullet:{...o.bullet,listType:d}}]},coverType:F.REPLACE}),s.moveCursorTo(l+1),c},Gc=e=>{var t;let{paragraphs:n,listType:r,segmentId:i,document:a}=e;if(((t=a.getSelfOrHeaderFooterModel(i).getBody())==null?void 0:t.paragraphs)==null)return!1;let o=O(6),s=new Zt;s.reset();let c=new Y;for(let e of n){var l;let{startIndex:t,paragraphStyle:n={},bullet:i}=e;c.push({t:I.RETAIN,len:t-s.cursor}),c.push({t:I.RETAIN,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphStyle:n,bullet:{nestingLevel:(l=i==null?void 0:i.nestingLevel)==null?0:l,textStyle:(i==null?void 0:i.listType)===r?i.textStyle:{fs:20},listType:r,listId:o}}]},coverType:F.REPLACE}),s.moveCursorTo(t+1)}return c};function Kc(e,t){return t.some(t=>e.startIndex>t.startIndex&&e.startIndex<t.endIndex)}const qc=e=>{var t,n,r;let{paragraphs:i,document:a,type:o}=e,s=new Zt;s.reset();let c=new Y,l=(t=a.getSnapshot().lists)==null?{}:t,u=(n=(r=a.getBody())==null?void 0:r.tables)==null?[]:n,d={...xs,...l};for(let e of i){let{startIndex:t,paragraphStyle:n={},bullet:r}=e,i=Kc(e,u);if(c.push({t:I.RETAIN,len:t-s.cursor}),r){let e=d[r.listType].nestingLevel.length-1;i&&(e=Math.min(e,2)),c.push({t:I.RETAIN,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphStyle:{...n},bullet:{...r,nestingLevel:Math.max(Math.min(r.nestingLevel+o,e),0)}}]},coverType:F.REPLACE})}else c.push({t:I.RETAIN,len:1});s.moveCursorTo(t+1)}return c},Jc=e=>{var t,n,r,i;let{textRanges:a,segmentId:o,document:s,style:c,paragraphTextRun:l,cursor:u,deleteLen:d,textX:f}=e,p=s.getSelfOrHeaderFooterModel(o),m=Bc(a,(t=(n=p.getBody())==null?void 0:n.paragraphs)==null?[]:t,(r=(i=p.getBody())==null?void 0:i.dataStream)==null?``:r),h=new Zt;u&&h.moveCursorTo(u);let g=f==null?new Y:f;m.sort((e,t)=>e.startIndex-t.startIndex);let _=Math.max(0,m[0].paragraphStart-1);_>h.cursor&&(g.push({t:I.RETAIN,len:_-h.cursor}),h.moveCursorTo(_)),d&&g.push({t:I.DELETE,len:d});for(let e of m){let{startIndex:t,paragraphStyle:n={}}=e,r=t-h.cursor;g.push({t:I.RETAIN,len:r,...l?{body:{dataStream:``,textRuns:[{ts:l,st:0,ed:r}]},coverType:F.REPLACE}:null}),g.push({t:I.RETAIN,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphStyle:{...n,...c}}]},coverType:F.REPLACE}),h.moveCursorTo(t+1)}return g};var Z=class{};C(Z,`customRange`,{add:Dc,delete:Ec,copyCustomRange:Sc,getCustomRangesInterestsWithSelection:xc,isIntersecting:bc}),C(Z,`customDecoration`,{add:vc,delete:yc}),C(Z,`selection`,{replace:Ac,makeSelection:Ic,normalizeSelection:Lc,delete:Oc,replaceTextRuns:Mc,retain:kc}),C(Z,`range`,{isIntersects:Rc,getParagraphsInRange:zc,getParagraphsInRanges:Bc}),C(Z,`transform`,{getPlainText:fc,fromPlainText:mc,isEmptyDocument:pc}),C(Z,`paragraph`,{bullet:{set:Gc,switch:Uc,toggleChecklist:Wc,changeNestLevel:qc},style:{set:Jc},util:{transform:Hc,getParagraphsInRange:zc,getParagraphsInRanges:Bc}}),C(Z,`drawing`,{add:Fc});function Yc(e,t,n,r){if(t===``)return e;let i=new _c({id:`mock-id`,body:e,documentStyle:{}}),a=t.length,o;for(;(o=(r?i.getBody().dataStream:i.getBody().dataStream.toLowerCase()).indexOf(t))>=0;){let e=new Y,t=cc.getInstance();if(o>0&&e.retain(o),n.length>0){var s;let t=i.sliceBody(o,o+a),r={dataStream:n};Array.isArray(t==null?void 0:t.textRuns)&&t.textRuns.length&&(r.textRuns=[{...t.textRuns[0],st:0,ed:n.length}]),!(t==null||(s=t.customRanges)==null)&&s.length&&(r.customRanges=[{...t.customRanges[0],startIndex:0,endIndex:n.length-1}]),e.insert(n.length,r)}e.delete(a),i.apply(t.editOp(e.serialize()))}let c=i.getBody();return i.dispose(),c}function Xc(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 Zc(e){var t;return e.body=Xc((t=e.body)==null?{dataStream:``}:t),e.drawingsOrder||(e.drawingsOrder=[]),e.drawings||(e.drawings={}),e.documentStyle||(e.documentStyle={}),e}var Qc=class e{static create(t={}){return new e(t)}constructor(e={}){C(this,`_style`,void 0),this._style=e}get fontFamily(){return this._style.ff}get fontSize(){return this._style.fs}get italic(){return this._style.it===A.TRUE}get bold(){return this._style.bl===A.TRUE}get underline(){return this._style.ul&&el.create(this._style.ul)}get bottomBorderLine(){return this._style.bbl&&el.create(this._style.bbl)}get strikethrough(){return this._style.st&&el.create(this._style.st)}get overline(){return this._style.ol&&el.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 $c.create(D.deepClone(this._style))}getValue(){return{...this._style}}},$c=class e extends Qc{static create(t={}){return new e(t)}constructor(e={}){super(e)}setFontFamily(e){return this._style.ff=e,this}setFontSize(e){return this._style.fs=e,this}setItalic(e){return this._style.it=e?1:0,this}setBold(e){return this._style.bl=e?1:0,this}setUnderline(e){return this._style.ul=e.build(),this}setBottomBorderLine(e){return this._style.bbl=e.build(),this}setStrikethrough(e){return this._style.st=e.build(),this}setOverline(e){return this._style.ol=e.build(),this}setBackground(e){return this._style.bg=e,this}setBorder(e){return this._style.bd=e,this}setColor(e){return this._style.cl=e,this}setVerticalAlign(e){return this._style.va=e,this}copy(){return e.create(D.deepClone(this._style))}build(){return this.getValue()}},el=class e{static create(t={s:1}){return new e(t)}constructor(e={s:1}){C(this,`_decoration`,void 0),this._decoration=e}get show(){return this._decoration.s===A.TRUE}get followFontColor(){return this._decoration.c===A.TRUE}get color(){return this._decoration.cl}get type(){return this._decoration.t}setShow(e){return this._decoration.s=e?1:0,this}setFollowFontColor(e){return this._decoration.c=e?1:0,this}setColor(e){return this._decoration.cl=e,this}setLineType(e){return this._decoration.t=e,this}copy(){return e.create(D.deepClone(this._decoration))}build(){return{...this._decoration}}},tl=class e{static create(t={}){return new e(t)}constructor(e={}){C(this,`_style`,void 0),this._style=e}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===A.TRUE}get keepNext(){return this._style.keepNext===A.TRUE}get wordWrap(){return this._style.wordWrap===A.TRUE}get widowControl(){return this._style.widowControl===A.TRUE}get shading(){return this._style.shading}get suppressHyphenation(){return this._style.suppressHyphenation===A.TRUE}copy(){return nl.create(D.deepClone(this._style))}getValue(){return this._style}},nl=class e extends tl{static create(t={}){return new e(t)}constructor(e={}){super(e)}setIndentFirstLine(e){return this._style.indentFirstLine=e,this}setHanging(e){return this._style.hanging=e,this}setIndentStart(e){return this._style.indentStart=e,this}setTabStops(e){return this._style.tabStops=e,this}setIndentEnd(e){return this._style.indentEnd=e,this}setTextStyle(e){return this._style.textStyle=e,this}setHeadingId(e){return this._style.headingId=e,this}setNamedStyleType(e){return this._style.namedStyleType=e,this}setHorizontalAlign(e){return this._style.horizontalAlign=e,this}setLineSpacing(e){return this._style.lineSpacing=e,this}setDirection(e){return this._style.direction=e,this}setSpacingRule(e){return this._style.spacingRule=e,this}setSnapToGrid(e){return this._style.snapToGrid=e?1:0,this}setSpaceAbove(e){return this._style.spaceAbove=e,this}setSpaceBelow(e){return this._style.spaceBelow=e,this}setBorderBetween(e){return this._style.borderBetween=e,this}setBorderTop(e){return this._style.borderTop=e,this}setBorderBottom(e){return this._style.borderBottom=e,this}setBorderLeft(e){return this._style.borderLeft=e,this}setBorderRight(e){return this._style.borderRight=e,this}setKeepLines(e){return this._style.keepLines=e?1:0,this}setKeepNext(e){return this._style.keepNext=e?1:0,this}setWordWrap(e){return this._style.wordWrap=e?1:0,this}setWidowControl(e){return this._style.widowControl=e?1:0,this}setShading(e){return this._style.shading=e,this}setSuppressHyphenation(e){return this._style.suppressHyphenation=e?1:0,this}copy(){return e.create(D.deepClone(this._style))}build(){return this.getValue()}},rl=class e{static create(t){return new e(t)}static createByBody(t){return new e({body:t,id:`d`,documentStyle:{}})}constructor(e){if(C(this,`_data`,void 0),!e.body)throw Error(`Invalid document data, body is required`);this._data=Zc(e)}copy(){return il.create(D.deepClone(this._data))}slice(e,t){let{body:n,...r}=this._data;return il.create({...D.deepClone(r),body:Bs(n,e,t)})}toPlainText(){var e,t;return Z.transform.getPlainText((e=(t=this._data.body)==null?void 0:t.dataStream)==null?``:e).replaceAll(`\r`,`
|
|
7
7
|
`)}getParagraphStyle(){var e;return tl.create((e=this._data.body)==null||(e=e.paragraphs)==null?void 0:e[0].paragraphStyle)}getParagraphBullet(){var e;return(e=this._data.body)==null||(e=e.paragraphs)==null?void 0:e[0].bullet}getParagraphs(){var e,t;let n=(e=(t=this._data.body)==null?void 0:t.paragraphs)==null?[]:e,r=0;return n.map(e=>{let t=this.slice(r,e.startIndex);return r=e.startIndex,t})}getTextRuns(){var e,t;return((e=(t=this._data.body)==null?void 0:t.textRuns)==null?[]:e).map(e=>({...e,ts:e.ts?Qc.create(e.ts):null}))}getLinks(){var e,t;return(e=(t=this._data.body)==null||(t=t.customRanges)==null?void 0:t.filter(e=>e.rangeType===or.HYPERLINK))==null?[]:e}getData(){return this._data}},il=class e extends rl{static newEmptyData(){return Zc({id:`d`,documentStyle:{},drawings:{},drawingsOrder:[],body:{dataStream:`\r
|
|
8
|
-
`,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(t){return new e(t==null?e.newEmptyData():t)}constructor(e){super(e),C(this,`_doc`,void 0),this._doc=new _c(e)}insertText(e,t,n){var r,i;let a=((r=(i=this._data.body)==null?void 0:i.dataStream.length)==null?2:r)-2,o,s;if(typeof e==`string`?o=e:(a=Math.min(e,a),o=t),s=typeof t==`object`?t instanceof $c?t.build():t:n instanceof $c?n.build():n,!o)return this;let c={dataStream:o,textRuns:s?[{ts:s,st:a,ed:a+o.length}]:[]},l=Z.selection.replace({doc:this._doc,selection:{startOffset:a,endOffset:a,collapsed:!0},body:c});if(!l)throw Error(`Insert text failed, please check.`);return Y.apply(this._doc.getBody(),l.serialize()),this}insertRichText(e,t){var n,r;let i=((n=(r=this._data.body)==null?void 0:r.dataStream.length)==null?2:n)-2,a;typeof e==`object`?a=e instanceof rl?e.getData():e:(i=Math.min(e,i),a=t instanceof rl?t.getData():t);let o=Z.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:a.body});if(!o)throw Error(`Insert text failed, please check.`);return Y.apply(this._doc.getBody(),o.serialize()),this}delete(e,t){if(t!==void 0){if(!t)return this;let n=Z.selection.delete([{startOffset:e,endOffset:e+t,collapsed:!0}],this._data.body);Y.apply(this._doc.getBody(),n)}return this}setStyle(e,t,n){let r={dataStream:``,textRuns:[{ts:n instanceof $c?n.build():n,st:0,ed:t-e}]},i=Z.selection.retain([{startOffset:e,endOffset:t,collapsed:!0}],r);return Y.apply(this._doc.getBody(),i),this}setLink(e,t,n){let r=Z.customRange.add({rangeType:or.HYPERLINK,rangeId:O(),properties:{url:n},ranges:[{startOffset:e,endOffset:t,collapsed:!1}],body:this._data.body});if(!r)throw Error(`Insert text failed, please check.`);return Y.apply(this._doc.getBody(),r.serialize()),this}cancelLink(e,t){if(typeof e==`string`){let t=Z.customRange.delete({rangeId:e,documentDataModel:this._doc});if(!t)throw Error(`Insert text failed, please check.`);Y.apply(this._doc.getBody(),t.serialize())}else this.slice(e,t).getLinks().forEach(e=>{let t=Z.customRange.delete({rangeId:e.rangeId,documentDataModel:this._doc});if(!t)throw Error(`Insert text failed, please check.`);Y.apply(this._doc.getBody(),t.serialize())});return this}updateLink(e,t){var n;let r=(n=this._data.body)==null||(n=n.customRanges)==null?void 0:n.find(t=>t.rangeId===e);if(!r)throw Error(`Link not found`);return r.properties.url=t,this}insertParagraph(e,t){let n,r;if(typeof e==`object`){var i,a;n={dataStream:`\r`,paragraphs:[{startIndex:0,paragraphStyle:e.build()}]},r=((i=(a=this._data.body)==null?void 0:a.dataStream.length)==null?2:i)-2}else r=e,n={dataStream:`\r`,paragraphs:[{startIndex:0,paragraphStyle:t==null?void 0:t.build()}]};return this.insertRichText(r,rl.create({body:n,id:`d`,documentStyle:{}})),this}insertLink(t,n,r){let i=``,a=``;typeof t==`string`?(i=t,a=n):(i=n,a=r);let o=e.createByBody({dataStream:i,customRanges:[{rangeType:or.HYPERLINK,rangeId:O(),properties:{url:a},startIndex:0,endIndex:i.length-1}]});return typeof t==`number`?this.insertRichText(t,o):this.insertRichText(o)}};const al=`__default_document_sub_component_id20231101__`;var ol=class{constructor(){C(this,`skipNextObservers`,!1),C(this,`lastReturnValue`,void 0),C(this,`isStopPropagation`,!1)}stopPropagation(){this.isStopPropagation=!0}},sl=class extends y{constructor(...e){super(...e),C(this,`_sortedObservers`,[])}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(e){let t;t=typeof e==`function`?{next:([t,n])=>e(t,n)}:e;let n=super.subscribe(t);return this._sortedObservers.push(t),this._sortedObservers.sort((e,t)=>{var n,r;return((n=e.priority)==null?0:n)-((r=t.priority)==null?0:r)}),n.add(()=>this._sortedObservers=this._sortedObservers.filter(e=>e!==t)),n}clearObservers(){this._sortedObservers.forEach(e=>{var t;return(t=e.complete)==null?void 0:t.call(e)}),this._sortedObservers.length=0}emitEvent(e){if(!this.closed){let n=new ol;n.lastReturnValue=e;for(let r of this._sortedObservers){var t;if(n.lastReturnValue=(t=r.next)==null?void 0:t.call(r,[e,n]),n.skipNextObservers)return{handled:!0,lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}throw Error(`[EventSubject]: cannot emit event on a closed subject.`)}};function cl(e){return new fe(t=>{let n=e.subscribeEvent(e=>{t.next(e)});return()=>n.unsubscribe()})}const ll=m(`core.resource-manager.service`),ul={[b.Editor]:`Editor`,[b.Owner]:`Owner`,[b.Reader]:`Reader`,[b.UNRECOGNIZED]:`UNRECOGNIZED`},dl=e=>e?{userID:`${ul[e]}_${O(8)}`,name:ul[e],avatar:``}:{userID:``,name:``,avatar:``,anonymous:!0,canBindAnonymous:!1},fl=(e,t)=>e.startsWith(ul[t]);var pl=class extends E{constructor(...e){super(...e),C(this,`_model`,new Map),C(this,`_userChange$`,new y),C(this,`userChange$`,this._userChange$.asObservable()),C(this,`_currentUser$`,new v(dl())),C(this,`currentUser$`,this._currentUser$.asObservable())}dispose(){super.dispose(),this._model.clear(),this._userChange$.complete(),this._currentUser$.complete()}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(e){this.addUser(e),this._currentUser$.next(e)}addUser(e){this._model.set(e.userID,e),this._userChange$.next({type:`add`,user:e})}getUser(e,t){let n=this._model.get(e);if(n)return n;t&&t()}delete(e){let t=this.getUser(e);this._model.delete(e),t&&this._userChange$.next({type:`delete`,user:t})}clear(){this._model.clear(),this._userChange$.next({type:`clear`})}list(){return Array.from(this._model.values())}};let ml=class{constructor(e,t){this._resourceManagerService=e,this._userManagerService=t,C(this,`_permissionMap`,new Map([])),C(this,`_permissionOverrides`,new Map),this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){let e=this._userManagerService.getCurrentUser();e&&e.userID||this._userManagerService.setCurrentUser(dl(b.Owner))}_getRole(e){let t=this._userManagerService.getCurrentUser();return t?fl(t.userID,e):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:e=>{let t=[...this._permissionMap.keys()].reduce((e,t)=>(e[t]=this._permissionMap.get(t),e),{});return JSON.stringify(t)},parseJson:e=>JSON.parse(e),pluginName:`SHEET_AuthzIoMockService_PLUGIN`,businesses:[Oe.UNIVER_SHEET,Oe.UNIVER_DOC,Oe.UNIVER_SLIDE],onLoad:(e,t)=>{for(let e in t)this._permissionMap.set(e,t[e])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(e){let t=O(8),{objectType:n,selectRangeObject:r,worksheetObject:i}=e,a=r||i,o={objectType:n,unitID:(a==null?void 0:a.unitID)||``,name:(a==null?void 0:a.name)||``,strategies:[{action:6,role:b.Owner},{action:16,role:b.Owner},{action:17,role:b.Owner},{action:18,role:b.Owner},{action:19,role:b.Owner},{action:33,role:b.Owner},{action:34,role:b.Owner},{action:35,role:b.Owner},{action:36,role:b.Owner},{action:37,role:b.Owner},{action:38,role:b.Owner},{action:39,role:b.Owner},{action:40,role:b.Owner}],selectRangeObject:r};return this._permissionMap.set(t,o),t}async allowed(e){let{objectID:t,actions:n}=e,r=this._permissionMap.get(t);return r?n.map(e=>{let n=`${t}:${e}`;if(this._permissionOverrides.has(n))return{action:e,allowed:this._permissionOverrides.get(n)};let i=r.strategies.find(t=>t.action===e);return i?{action:e,allowed:this._getRole(i.role)}:{action:e,allowed:this._getRole(b.Owner)||this._getRole(b.Editor)}}):n.map(e=>({action:e,allowed:this._getRole(b.Owner)||this._getRole(b.Editor)}))}async batchAllowed(e){let t=await Promise.all(e.map(e=>this.allowed(e)));return e.map((e,n)=>({unitID:e.unitID,objectID:e.objectID,actions:t[n]}))}async list(e){let t=[],n=[{action:6,role:b.Owner},{action:16,role:b.Owner},{action:17,role:b.Owner},{action:18,role:b.Owner},{action:19,role:b.Owner},{action:33,role:b.Owner},{action:34,role:b.Owner},{action:35,role:b.Owner},{action:36,role:b.Owner},{action:37,role:b.Owner},{action:38,role:b.Owner},{action:39,role:b.Owner},{action:40,role:b.Owner}];return e.objectIDs.forEach(r=>{let i=this._permissionMap.get(r),a=(i==null?void 0:i.strategies)||n,o={objectID:r,unitID:e.unitID,objectType:(i==null?void 0:i.objectType)||3,name:(i==null?void 0:i.name)||``,shareOn:!1,shareRole:b.Owner,shareScope:-1,scope:{read:De.AllCollaborator,edit:De.AllCollaborator},creator:dl(b.Owner),strategies:a.map(e=>({action:e.action,role:e.role})),actions:e.actions.map(e=>{let t=`${r}:${e}`;if(this._permissionOverrides.has(t))return{action:e,allowed:this._permissionOverrides.get(t)};let n=a.find(t=>t.action===e);return n?{action:e,allowed:this._getRole(n.role)}:{action:e,allowed:this._getRole(b.Owner)||this._getRole(b.Editor)}})};t.push(o)}),t}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(e){let{objectID:t,strategies:n}=e,r=this._permissionMap.get(t);r&&n&&(r.strategies=n.map(e=>({action:e.action,role:e.role})),this._permissionMap.set(t,r),n.forEach(e=>{e.role===b.Reader?this.setPermissionOverride(t,e.action,!1):(e.role===b.Owner||e.role===b.Editor)&&this.clearPermissionOverride(t,e.action)}))}setPermissionOverride(e,t,n){let r=`${e}:${t}`;this._permissionOverrides.set(r,n)}clearPermissionOverride(e,t){let n=`${e}:${t}`;this._permissionOverrides.delete(n)}clearAllOverrides(e){let t=[];this._permissionOverrides.forEach((n,r)=>{r.startsWith(`${e}:`)&&t.push(r)}),t.forEach(e=>this._permissionOverrides.delete(e))}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(e){}};ml=z([R(0,ll),R(1,t(pl))],ml);const hl=m(`IAuthzIoIoService`),gl=m(`univer.confirm-service`);var _l=class{constructor(){C(this,`confirmOptions$`,new y)}dispose(){this.confirmOptions$.complete()}open(e){throw Error(`This is not implemented in the test service!`)}confirm(e){return Promise.resolve(!0)}close(e){throw Error(`This is not implemented in the test service!`)}};const vl=`FOCUSING_UNIT`,yl=`FOCUSING_SHEET`,bl=`FOCUSING_DOC`,xl=`FOCUSING_SLIDE`,Sl=`FOCUSING_EDITOR_BUT_HIDDEN`,Cl=`EDITOR_ACTIVATED`,wl=`FOCUSING_EDITOR_INPUT_FORMULA`,Tl=`FOCUSING_FX_BAR_EDITOR`,El=`FOCUSING_UNIVER_EDITOR`,Dl=`FOCUSING_EDITOR_INPUT_FORMULA`,Ol=`FOCUSING_COMMENT_EDITOR`,kl=`FOCUSING_PANEL_EDITOR`,Al=`FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE`,jl=`FOCUSING_COMMON_DRAWINGS`,Ml=`FOCUSING_SHAPE_TEXT_EDITOR`,Nl=`FORMULA_EDITOR_ACTIVATED`;var Pl=class extends E{constructor(...e){super(...e),C(this,`_error$`,new y),C(this,`error$`,this._error$.asObservable())}dispose(){this._error$.complete()}emit(e){this._error$.next({errorKey:e})}};let Fl=function(e){return e.URL=`URL`,e.UUID=`UUID`,e.BASE64=`BASE64`,e}({}),Il=function(e){return e.SUCCUSS=`0`,e.ERROR_EXCEED_SIZE=`1`,e.ERROR_IMAGE_TYPE=`2`,e.ERROR_UPLOAD_COUNT_LIMIT=`3`,e.ERROR_IMAGE=`4`,e}({});const Ll=m(`core.image-io.service`),Rl=m(`core.url-image.service`);var zl=`@univerjs/core`,Bl=`0.19.0`;function Vl(e=``,t=Rn.ZH_CN,n=``){return{id:e,sheetOrder:[],name:n,appVersion:Bl,locale:t,styles:{},sheets:{},resources:[]}}var Hl=class{constructor(e={}){C(this,`_styles`,void 0),C(this,`_cacheMap`,new so(1e5)),this._styles=e,this._generateCacheMap()}each(e){return Object.entries(this._styles).forEach(e),this}search(e,t){return this._cacheMap.has(t)?this._cacheMap.get(t):this._getExistingStyleId(e)||`-1`}get(e){return typeof e==`string`?(e=String(e),this._styles[e]):e}add(e,t){let n=O(6);return this._styles[n]=e,this._cacheMap.set(t,n),n}setValue(e){if(e==null)return;let t=JSON.stringify(e),n=this.search(e,t);return n===`-1`?this.add(e,t):n}addCustomStyle(e,t){t!=null&&(this._styles[e]=t,this._cacheMap.set(JSON.stringify(t),e))}remove(e){let t=this._styles[e];t&&(delete this._styles[e],this._cacheMap.delete(JSON.stringify(t)))}toJSON(){return this._styles}getStyleByCell(e){let t;t=e&&D.isObject(e.s)?e.s:(e==null?void 0:e.s)&&this.get(e.s);let n=e==null?void 0:e.interceptorStyle;return n?{...t,...n}:t}_generateCacheMap(){let{_styles:e,_cacheMap:t}=this;for(let n in e){let r=JSON.stringify(e[n]);t.set(r,n)}}_getExistingStyleId(e){let{_styles:t}=this;for(let n in t)if(D.diffValue(t[n],e))return n;return null}};const Ul=(e,t)=>t.length===e.length&&!e.some(e=>t.some(t=>!G.equals(t,e))),Wl=(e,t)=>t.length===e.length&&e.every((e,n)=>{let r=t[n];return r.unitId===e.unitId&&r.sheetId===e.sheetId&&G.equals(e.range,r.range)}),Gl={t:0,b:2,l:2,r:2},Kl=e=>({sbr:.6,sbo:e,spr:.6,spo:e});function ql(e,t,n={}){let r=e.length,{textRotation:i,paddingData:a,horizontalAlign:o=Yn.UNSPECIFIED,verticalAlign:s=Xn.UNSPECIFIED,wrapStrategy:c=Zn.UNSPECIFIED,cellValueType:l}=n,{t:u,r:d,b:f,l:p}=a||Gl,{vertexAngle:m,centerAngle:h}=tu(i);return new _c({id:`d`,body:{dataStream:`${e}\r
|
|
9
|
-
`,textRuns:[{ts:t,st:0,ed:r}],paragraphs:[{startIndex:r,paragraphStyle:{horizontalAlign:o}}],sectionBreaks:[{startIndex:r+1}]},documentStyle:{pageSize:{width:1/0,height:1/0},marginTop:u,marginBottom:f,marginRight:d,marginLeft:p,renderConfig:{horizontalAlign:o,verticalAlign:s,centerAngle:h,vertexAngle:m,wrapStrategy:c,cellValueType:l}},drawings:{},drawingsOrder:[]})}function Jl(e){if(!e)return{};let{tr:t,td:n,ht:r,vt:i,tb:a,pd:o}=e;return{textRotation:t,textDirection:n,horizontalAlign:r,verticalAlign:i,wrapStrategy:a,paddingData:o}}function Yl(e){if(!e)return{};let{ff:t,fs:n,it:r,bl:i,ul:a,st:o,ol:s,cl:c}=e,l={};return t&&(l.ff=t),n&&(l.fs=n),r&&(l.it=r),i&&(l.bl=i),a&&(l.ul=a),o&&(l.st=o),s&&(l.ol=s),c&&(l.cl=c),l}function Xl(e,t,n){var r;let i=e.getBody();if((r=i.customRanges)!=null&&r.some(e=>e.rangeType===or.HYPERLINK))return;let a=Z.customRange.add({ranges:[{startOffset:0,endOffset:i.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:or.HYPERLINK,body:i,properties:{url:t,refId:n}});a&&Y.apply(i,a.serialize())}function Zl(e){return e!=null}function Ql(){return{p:null,s:null,v:null,t:null,f:null,si:null,ref:null,xf:null}}function $l(e){let t=W.ff,n=W.fs;if(!e){let e=`${n}pt ${t}`;return{fontCache:e,fontString:e,fontSize:n,originFontSize:n,fontFamily:t}}let r=Er.ITALIC;(e.it===0||e.it===void 0)&&(r=Er.NORMAL);let i=Er.BOLD;(e.bl===0||e.bl===void 0)&&(i=Er.NORMAL);let a=n;e.fs&&(a=Math.ceil(e.fs));let o=t;if(e.ff){let n=e.ff;n=n.replace(/"/g,``).replace(/'/g,``),n.indexOf(` `)>-1&&(n=`"${n}"`),n==null&&(n=t),o=n}let{va:s}=e,c=a;if(s===er.SUBSCRIPT||s===er.SUPERSCRIPT){let{sbr:e,spr:t}=eu(o,c);c*=s===er.SUBSCRIPT?e:t}let l=`${r} ${i} ${c}pt ${o}`;return{fontCache:l,fontString:`${l}, "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif `,fontSize:c,originFontSize:a,fontFamily:o}}function eu(e,t){return Kl(t)}function tu(e){let{a:t=0,v:n=A.FALSE}=e||{a:0,v:A.FALSE},r=0,i=t;return n===A.TRUE&&(r=90,i=90),{centerAngle:r,vertexAngle:i}}function Q(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e)){let t=e.length,n=Array(t);for(let r=0;r<t;r++)n[r]=Q(e[r]);return n}let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r];t[i]=Q(e[i])}return t}function nu(e){if(e==null)return e;let t={};return e.p!==void 0&&(t.p=e.p===null?null:Q(e.p)),e.s!==void 0&&(e.s===null||typeof e.s==`string`?t.s=e.s:t.s=Q(e.s)),e.v!==void 0&&(t.v=e.v),e.t!==void 0&&(t.t=e.t),e.f!==void 0&&(t.f=e.f),e.ref!==void 0&&(t.ref=e.ref),e.xf!==void 0&&(t.xf=e.xf),e.si!==void 0&&(t.si=e.si),e.custom!==void 0&&(t.custom=e.custom===null?null:Q(e.custom)),t}function ru(e){if(e==null)return e;let t={};return e.p!==void 0&&(t.p=e.p===null?null:Q(e.p)),e.s!==void 0&&(e.s===null||typeof e.s==`string`?t.s=e.s:t.s=Q(e.s)),e.v!==void 0&&(t.v=e.v),e.t!==void 0&&(t.t=e.t),e.f!==void 0&&(t.f=e.f),e.ref!==void 0&&(t.ref=e.ref),e.xf!==void 0&&(t.xf=e.xf),e.si!==void 0&&(t.si=e.si),e.custom!==void 0&&(t.custom=e.custom===null?null:Q(e.custom)),e.rowSpan!==void 0&&(t.rowSpan=e.rowSpan),e.colSpan!==void 0&&(t.colSpan=e.colSpan),e.displayV!==void 0&&(t.displayV=e.displayV),t}function iu(e){let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r],a=Number(i),o=e[a];if(o===void 0)continue;let s={},c=Object.keys(o);for(let e=0,t=c.length;e<t;e++){let t=c[e],n=Number(t),r=o[n];r!=null&&(s[n]=nu(r))}t[a]=s}return t}function au(e){let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r],a=Number(i),o=e[a];if(o===void 0)continue;let s={};`h`in o&&o.h!==void 0&&(s.h=o.h),`ia`in o&&o.ia!==void 0&&(s.ia=o.ia),`ah`in o&&o.ah!==void 0&&(s.ah=o.ah),`hd`in o&&o.hd!==void 0&&(s.hd=o.hd),`w`in o&&o.w!==void 0&&(s.w=o.w),`s`in o&&o.s!==void 0&&(o.s===null||typeof o.s==`string`?s.s=o.s:s.s=Q(o.s)),`custom`in o&&o.custom!==void 0&&(s.custom=o.custom===null?null:Q(o.custom)),t[a]=s}return t}function ou(e){let t=e.length,n=Array(t);for(let r=0;r<t;r++){let t=e[r];n[r]={startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn,rangeType:t.rangeType,startAbsoluteRefType:t.startAbsoluteRefType,endAbsoluteRefType:t.endAbsoluteRefType}}return n}function su(e){let t={id:e.id,name:e.name,tabColor:e.tabColor,hidden:e.hidden,rowCount:e.rowCount,columnCount:e.columnCount,zoomRatio:e.zoomRatio,scrollTop:e.scrollTop,scrollLeft:e.scrollLeft,defaultColumnWidth:e.defaultColumnWidth,defaultRowHeight:e.defaultRowHeight,showGridlines:e.showGridlines,rightToLeft:e.rightToLeft,freeze:{xSplit:e.freeze.xSplit,ySplit:e.freeze.ySplit,startRow:e.freeze.startRow,startColumn:e.freeze.startColumn},rowHeader:{width:e.rowHeader.width,hidden:e.rowHeader.hidden},columnHeader:{height:e.columnHeader.height,hidden:e.columnHeader.hidden},mergeData:ou(e.mergeData),cellData:iu(e.cellData),rowData:au(e.rowData),columnData:au(e.columnData)};return e.gridlinesColor!==void 0&&(t.gridlinesColor=e.gridlinesColor),e.defaultStyle!==void 0&&(e.defaultStyle===null||typeof e.defaultStyle==`string`?t.defaultStyle=e.defaultStyle:t.defaultStyle=Q(e.defaultStyle)),e.custom!==void 0&&(t.custom=e.custom===null?null:Q(e.custom)),t}var cu=class{constructor(e,t){this._config=e,C(this,`_columnData`,{}),this._columnData=t}getColumnData(){return this._columnData}getColVisible(e){let{_columnData:t}=this,n=t[e];return n?n.hd!==A.TRUE:!0}getColumnStyle(e){var t;return(t=this._columnData[e])==null?void 0:t.s}setColumnStyle(e,t){let n=this.getColumnOrCreate(e);n.s=t}getHiddenCols(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getColVisible(a);r&&e?(r=!1,n.push({rangeType:B.COLUMN,startColumn:i,endColumn:a-1,startRow:0,endRow:0})):!r&&!e&&(r=!0,i=a)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:t,rangeType:B.COLUMN}),n}getVisibleCols(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getColVisible(a);r&&!e?(r=!1,n.push({rangeType:B.COLUMN,startColumn:i,endColumn:a-1,startRow:0,endRow:0})):!r&&e&&(r=!0,i=a)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:t,rangeType:B.COLUMN}),n}getColumnDatas(e,t){let n={},r=0;for(let i=e;i<e+t;i++){let e=this.getColumn(i);n[r]=e==null?{w:this._config.defaultColumnWidth,hd:A.FALSE}:e,r++}return n}getSize(){return pa(this._columnData)}getColumnWidth(e){var t,n;return(t=(n=this._columnData[e])==null?void 0:n.w)==null?this._config.defaultColumnWidth:t}setColumnWidth(e,t){let n=this._columnData[e];t===this._config.defaultColumnWidth?n&&(delete n.w,Object.keys(n).length===0&&delete this._columnData[e]):this._columnData[e]=n?{...n,w:t}:{w:t}}getColumn(e){return this._columnData[e]}insertColumnsWithData(e,t,n){let r=t-e+1,i=Object.keys(this._columnData);for(let t=i.length-1;t>=0;t--){let n=Number(i[t]);n>=e&&(this._columnData[n+r]=this._columnData[n],delete this._columnData[n])}for(let r=e;r<=t;r++){let t=n==null?void 0:n[r-e];t!=null&&Object.keys(t).length>0&&(this._columnData[r]={...t})}}removeColumn(e){delete this._columnData[e]}getColumnOrCreate(e){let{_columnData:t}=this,n=t[e];if(n)return n;let r={};return this._columnData[e]=r,r}setCustomMetadata(e,t){let n=this.getColumn(e);n&&(n.custom=t)}getCustomMetadata(e){var t;return(t=this.getColumn(e))==null?void 0:t.custom}},lu=class{constructor(e,t,n){this._config=e,this._viewModel=t,C(this,`_rowData`,void 0),this._rowData=n}getRowData(){return this._rowData}getRowStyle(e){var t;return(t=this._rowData[e])==null?void 0:t.s}setRowStyle(e,t){let n=this.getRowOrCreate(e);n.s=t}getRowDatas(e,t){let n={},r=0;for(let i=e;i<e+t;i++){let e=this.getRow(i);n[r]=e==null?{h:this._config.defaultRowHeight,hd:A.FALSE}:e,r++}return n}getRowHeight(e,t=1){let{_rowData:n}=this,r=this._config,i=0;for(let a=0;a<t;a++){let{ia:t,ah:o,h:s=r.defaultRowHeight}=n[a+e]||{hd:A.FALSE,h:r.defaultRowHeight};i+=(t==null||t===A.TRUE)&&typeof o==`number`?o:s}return i}setRowHeight(e,t){let n=this._rowData[e];if(t===this._config.defaultRowHeight)n&&(delete n.h,Object.keys(n).length===0&&delete this._rowData[e]);else{let r=Math.min(t,2e3);this._rowData[e]=n?{...n,h:r}:{h:r}}}getRow(e){return this._rowData[e]}insertRowsWithData(e,t,n){let r=t-e+1,i=Object.keys(this._rowData);for(let t=i.length-1;t>=0;t--){let n=Number(i[t]);n>=e&&(this._rowData[n+r]=this._rowData[n],delete this._rowData[n])}for(let r=e;r<=t;r++){let t=n==null?void 0:n[r-e];t!=null&&Object.keys(t).length>0&&(this._rowData[r]={...t})}}removeRow(e){delete this._rowData[e]}getRowOrCreate(e){let{_rowData:t}=this,n=t[e];if(n)return n;let r={};return t[e]=r,r}getHiddenRows(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getRowRawVisible(a);r&&e?(r=!1,n.push({startRow:i,endRow:a-1,startColumn:0,endColumn:0,rangeType:B.ROW})):!r&&!e&&(r=!0,i=a)}return r&&n.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:B.ROW}),n}getVisibleRows(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getRowRawVisible(a);r&&!e?(r=!1,n.push({startRow:i,endRow:a-1,startColumn:0,endColumn:0,rangeType:B.ROW})):!r&&e&&(r=!0,i=a)}return r&&n.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:B.ROW}),n}getRowRawVisible(e){let t=this.getRow(e);return t?t.hd!==A.TRUE:!0}getSize(){return pa(this._rowData)}setCustomMetadata(e,t){let n=this.getRow(e);n&&(n.custom=t)}getCustomMetadata(e){var t;return(t=this.getRow(e))==null?void 0:t.custom}};const uu=`DEFAULT_WORKSHEET_ROW_COUNT`,du=1e3,fu=`DEFAULT_WORKSHEET_COLUMN_COUNT`,pu=20,mu=`DEFAULT_WORKSHEET_ROW_HEIGHT`,hu=24,gu=`DEFAULT_WORKSHEET_COLUMN_WIDTH`,_u=88,vu=`DEFAULT_WORKSHEET_ROW_TITLE_WIDTH`,yu=46,bu=`DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT`,xu=20;function Su(e){let t={name:`Sheet1`,id:`sheet-01`,tabColor:``,hidden:A.FALSE,rowCount:du,columnCount:20,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:88,defaultRowHeight:24,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:A.TRUE,rowHeader:{width:46,hidden:A.FALSE},columnHeader:{height:20,hidden:A.FALSE},rightToLeft:A.FALSE};return Object.keys(t).forEach(n=>{let r=n;e[r]===void 0&&(e[r]=t[r])}),e}var Cu=class extends E{constructor(e){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`,void 0),C(this,`_rangeMap`,new so(5e4)),this._init(e.concat())}_init(e){this._mergeData=e,this._createCache(e)}_clearCache(){this._cellCache.clear(),this._rowCache.clear(),this._columnCache.clear(),this._hasAll=!1,this._allIndex=-1,this._rangeMap.clear(),this._hasColumn=!1,this._hasRow=!1}_createCache(e){let t=0;for(let n of e){let{rangeType:e}=n;e===B.ROW?this._createRowCache(n,t):e===B.COLUMN?this._createColumnCache(n,t):e===B.ALL?this._createCellAllCache(t):this._createCellCache(n,t),t++}}rebuild(e){this._clearCache(),this._init(e.concat())}_createRowCache(e,t){let{startRow:n,endRow:r}=e;for(let e=n;e<=r;e++)this._rowCache.set(e,t),this._hasRow=!0}_createColumnCache(e,t){let{startColumn:n,endColumn:r}=e;for(let e=n;e<=r;e++)this._columnCache.set(e,t),this._hasColumn=!0}_createCellAllCache(e){this._hasAll=!0,this._allIndex=e}_createCellCache(e,t){for(let n=e.startRow;n<=e.endRow;n++){let r=this._cellCache.get(n);r==null&&(r=new Map,this._cellCache.set(n,r));for(let n=e.startColumn;n<=e.endColumn;n++)r.set(n,t)}}add(e){this._mergeData.push(e),this._clearCache(),this._createCache(this._mergeData)}remove(e,t){let n=this._getMergeDataIndex(e,t);n!==-1&&(this._mergeData.splice(n,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(e,t){let n=this._getMergeDataIndex(e,t);return n===-1?null:this._mergeData[n]}getMergeDataIndex(e,t){return this._getMergeDataIndex(e,t)}isRowContainsMergedCell(e){return this._hasAll||!D.isEmptyObject(this._columnCache)?!0:this._mergeData.some(t=>t.startRow<=e&&e<=t.endRow)}isColumnContainsMergedCell(e){return this._hasAll||!D.isEmptyObject(this._rowCache)?!0:this._mergeData.some(t=>t.startColumn<=e&&e<=t.endColumn)}getMergedCellRange(e,t,n,r){let i=[],a=`${e}-${t}-${n}-${r}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let o=0,s=[];for(let a of this._mergeData||[])G.intersects(a,{startRow:e,endRow:n,startColumn:t,endColumn:r})&&(i.push({...a}),s.push(o)),o++;return this._rangeMap.set(a,s),i}_getRangeFromCache(e){let t=this._rangeMap.get(e)||[],n=[];for(let e of t)n.push({...this._mergeData[e]});return n}_getMergeDataIndex(e,t){var n;if(this._hasAll)return this._allIndex;if(this._hasRow){let t=this._rowCache.get(e);if(t!==void 0)return t}if(this._hasColumn){let e=this._columnCache.get(t);if(e!==void 0)return e}let r=(n=this._cellCache.get(e))==null?void 0:n.get(t);return r===void 0?-1:r}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}},wu=class extends E{constructor(e){super(),this.getRawCell=e,C(this,`_cellContentInterceptor`,null),C(this,`_rowFilteredInterceptor`,null)}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(e,t,n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,At.Value|At.Style,n,r):this.getRawCell(e,t)}getCellValueOnly(e,t){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,At.Value):this.getRawCell(e,t)}getCellStyleOnly(e,t){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,At.Style):this.getRawCell(e,t)}getRowFiltered(e){var t,n;return(t=(n=this._rowFilteredInterceptor)==null?void 0:n.getRowFiltered(e))==null?!1:t}registerCellContentInterceptor(e){if(this._cellContentInterceptor)throw Error(`[SheetViewModel]: Interceptor already registered.`);return this._cellContentInterceptor=e,T(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(e){if(this._rowFilteredInterceptor)throw Error(`[SheetViewModel]: Interceptor already registered.`);return this._rowFilteredInterceptor=e,T(()=>this._rowFilteredInterceptor=null)}};const Tu={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};var Eu=class e{constructor(e,t,n){var r;this.unitId=e,this._styles=n,C(this,`_sheetId`,void 0),C(this,`_snapshot`,void 0),C(this,`_cellData`,void 0),C(this,`_rowManager`,void 0),C(this,`_columnManager`,void 0),C(this,`_viewModel`,void 0),C(this,`_spanModel`,void 0),C(this,`_isRowStylePrecedeColumnStyle`,!0),C(this,`_getCellHeight`,void 0),this._snapshot=Su(t);let{columnData:i,rowData:a,cellData:o}=this._snapshot;this._sheetId=(r=this._snapshot.id)==null?O(6):r,this._cellData=new Sa(o),this._viewModel=new wu((e,t)=>this.getCellRaw(e,t)),this._rowManager=new lu(this._snapshot,this._viewModel,a),this._columnManager=new cu(this._snapshot,i),this._spanModel=new Cu(this._snapshot.mergeData)}__interceptViewModel(e){e(this._viewModel)}__registerGetCellHeight(e){return this._getCellHeight=e,T(()=>{this._getCellHeight=null})}getSnapshot(){return this._snapshot}getCellHeight(e,t){return this._getCellHeight?this._getCellHeight(e,t):this._snapshot.defaultRowHeight}setMergeData(e){this._snapshot.mergeData=e,this.getSpanModel().rebuild(e)}getSpanModel(){return this._spanModel}setIsRowStylePrecedeColumnStyle(e){this._isRowStylePrecedeColumnStyle=e}getStyleDataByHash(e){return{...this._styles.get(e)}}setStyleData(e){return this._styles.setValue(e)}getColumnStyle(e,t=!1){return t?this._columnManager.getColumnStyle(e):this._styles.get(this._columnManager.getColumnStyle(e))}setColumnStyle(e,t){this._columnManager.setColumnStyle(e,t)}getRowStyle(e,t=!1){return t?this._rowManager.getRowStyle(e):this._styles.get(this._rowManager.getRowStyle(e))}setRowStyle(e,t){this._rowManager.setRowStyle(e,t)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){let e=this._snapshot.defaultStyle;return this._styles.get(e)}setDefaultCellStyle(e){this._snapshot.defaultStyle=e}getCellStyle(e,t){let n=this.getCell(e,t);if(n){let e=n.s;return typeof e==`string`?this._styles.get(e):e}return null}getComposedCellStyle(e,t,n){let r=this.getDefaultCellStyleInternal(),i=this.getRowStyle(e),a=this.getColumnStyle(t),o=this.getCell(e,t),s=this._styles.getStyleByCell(o);return(n==null?this._isRowStylePrecedeColumnStyle:n)?wn(r,a,i,o==null?void 0:o.themeStyle,s):wn(r,i,a,o==null?void 0:o.themeStyle,s)}getComposedCellStyleByCellData(e,t,n,r){let i=this.getDefaultCellStyleInternal(),a=this.getRowStyle(e),o=this.getColumnStyle(t),s=this._styles.getStyleByCell(n);return(r==null?this._isRowStylePrecedeColumnStyle:r)?wn(i,o,a,n==null?void 0:n.themeStyle,s):wn(i,a,o,n==null?void 0:n.themeStyle,s)}getComposedCellStyleWithoutSelf(e,t,n,r){let i=n===void 0?this.getComposedCellStyle(e,t,r):this.getComposedCellStyleByCellData(e,t,n,r),a=this.getCellRaw(e,t);if(!a||!a.s)return i;let o=typeof a.s==`string`?this._styles.get(a.s):a.s;if(!o)return i;for(let e in o)e in i&&delete i[e];return i}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){let e=this.getCellMatrix(),t=this.getMergeData(),n=-1,r=-1,i=-1,a=-1,o=!1,s=!1;return e.forEach((t,c)=>{Object.keys(c).forEach(c=>{let l=+c,u=e.getValue(t,l),d=u!=null&&u.s?this._styles.get(u.s):null,f=(d==null?void 0:d.bd)&&(d.bd.b||d.bd.l||d.bd.r||d.bd.t||d.bd.bc_tr||d.bd.bl_tr||d.bd.ml_tr||d.bd.tl_bc||d.bd.tl_br||d.bd.tl_mr);(u&&(u.v!==null&&u.v!==void 0&&u.v!==``||u.p)||d!=null&&d.bg||f)&&(o?n=Math.min(n,t):(n=t,o=!0),r=Math.max(r,t),s?i=Math.min(i,l):(s=!0,i=l),a=Math.max(a,l))})}),t.forEach(e=>{o?n=Math.min(n,e.startRow):(n=e.startRow,o=!0),r=Math.max(r,e.endRow),s?i=Math.min(i,e.startColumn):(i=e.startColumn,o=!0),a=Math.max(a,e.endColumn)}),!o||!s?null:{startColumn:i,startRow:n,endColumn:a,endRow:r}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){let{_snapshot:t}=this,n=su(t);return new e(this.unitId,n,this._styles)}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(e,t){return this._spanModel.getMergedCell(e,t)}getMergedCellRange(e,t,n,r){return this._spanModel.getMergedCellRange(e,t,n,r)}isRowContainsMergedCell(e){return this._spanModel.isRowContainsMergedCell(e)}isColumnContainsMergedCell(e){return this._spanModel.isColumnContainsMergedCell(e)}getCellInfoInMergeData(e,t){let n=this.getMergedCell(e,t),r=!1,i=!1,a=e,o=t,s=e,c=t;if(n){let{startRow:l,endRow:u,startColumn:d,endColumn:f}=n;e===l&&t===d?(a=u,o=f,s=l,c=d,i=!0):e>=l&&e<=u&&t>=d&&t<=f&&(a=u,o=f,s=l,c=d,r=!0)}return{actualRow:e,actualColumn:t,isMergedMainCell:i,isMerged:r,endRow:a,endColumn:o,startRow:s,startColumn:c}}getCell(e,t){return e<0||t<0?null:this._viewModel.getCell(e,t)}getCellValueOnly(e,t){return e<0||t<0?null:this._viewModel.getCellValueOnly(e,t)}getCellStyleOnly(e,t){return e<0||t<0?null:this._viewModel.getCellStyleOnly(e,t)}getCellRaw(e,t){return this.getCellMatrix().getValue(e,t)}getCellWithFilteredInterceptors(e,t,n,r){return this._viewModel.getCell(e,t,n,r)}getRowFiltered(e){return this._viewModel.getRowFiltered(e)}getRangeFilterRows(e){let t=[];for(let n=e.startRow;n<=e.endRow;n++)this.getRowFiltered(n)&&t.push(n);return t}getMatrixWithMergedCells(e,t,n,r,i=ea.Raw){let a=this.getCellMatrix(),o=this._spanModel.getMergedCellRange(e,t,n,r),s=new Sa;return Uo(e,n,t,r).forEach((e,t)=>{let n;if(i===ea.Raw)n=this.getCellRaw(e,t);else if(i===ea.Intercepted)n=this.getCell(e,t);else if(i===ea.Both){let i=this.getCellRaw(e,t);if(i){var r;n={...i};let a=(r=this.getCell(e,t))==null?void 0:r.v;Zl(a)&&n&&(n.displayV=String(a))}}n&&s.setValue(e,t,n)}),o.forEach(e=>{let{startColumn:t,startRow:n,endColumn:r,endRow:i}=e;Uo(n,i,t,r).forEach((e,o)=>{e===n&&o===t&&s.setValue(e,o,{...a.getValue(e,o),rowSpan:i-n+1,colSpan:r-t+1}),(e!==n||o!==t)&&s.realDeleteValue(e,o)})}),s}getRange(e,t,n,r){return typeof e==`object`?new Eo(this,e,{getStyles:()=>this._styles}):new Eo(this,{startRow:e,startColumn:t,endColumn:r||t,endRow:n||e},{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(){let{_snapshot:e}=this,{columnCount:t}=e;return t}getMaxRows(){let{_snapshot:e}=this,{rowCount:t}=e;return t}getRowCount(){return this._snapshot.rowCount}setRowCount(e){this._snapshot.rowCount=e}getColumnCount(){return this._snapshot.columnCount}setColumnCount(e){this._snapshot.columnCount=e}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){let{_snapshot:e}=this,{showGridlines:t}=e;return t===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){let{_snapshot:e}=this,{tabColor:t}=e;return t}getColumnWidth(e){return this.getColumnManager().getColumnWidth(e)}getRowHeight(e){return this._viewModel.getRowFiltered(e)?0:this.getRowManager().getRowHeight(e)}isRowFiltered(e){return this._viewModel.getRowFiltered(e)}getRowVisible(e){return!this.isRowFiltered(e)&&this.getRowRawVisible(e)}getRowRawVisible(e){return this.getRowManager().getRowRawVisible(e)}getHiddenRows(e,t){let n=this.getMaxColumns()-1,r=this._rowManager.getHiddenRows(e,t);return r.forEach(e=>e.endColumn=n),r}getColVisible(e){return this._columnManager.getColVisible(e)}getHiddenCols(e,t){let n=this.getMaxRows()-1,r=this._columnManager.getHiddenCols(e,t);return r.forEach(e=>e.endRow=n),r}getVisibleRows(){let e=this.getRowCount();return this._rowManager.getVisibleRows(0,e-1)}getVisibleCols(){let e=this.getColumnCount();return this._columnManager.getVisibleCols(0,e-1)}isRightToLeft(){let{_snapshot:e}=this,{rightToLeft:t}=e;return t}getLastRowWithContent(){return this._cellData.getRealRowRange().endRow}getLastColumnWithContent(){return this.getDataRealRange().endColumn}getDataRealRange(){return this._cellData.getRealRange()}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(e){return e&&(e.v!==void 0||e.f!==void 0||e.p!==void 0)}iterateByRow(e,t=!0){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e,o=this;return{[Symbol.iterator]:()=>{let e=n,s=r;return{next(){for(;;){if(s>a&&(e+=1,s=r),e>i)return{done:!0,value:void 0};let n=o.getCell(e,s),c=!n,l=o.getMergedCell(e,s);if(l){if(e!==l.startRow||s!==l.startColumn){s=l.endColumn+1;continue}if(c&&t){s=l.endColumn+1;continue}let r={row:e,col:s,value:n};return r.colSpan=l.endColumn-l.startColumn+1,r.rowSpan=l.endRow-l.startRow+1,s=l.endColumn+1,{done:!1,value:r}}if(c&&t)s+=1;else{let t={row:e,col:s,value:n};return s+=1,{done:!1,value:t}}}}}}}}iterateByColumn(e,t=!0,n=!0){let{startRow:r,startColumn:i,endRow:a,endColumn:o}=e,s=this;return{[Symbol.iterator]:()=>{let e=r,c=i;return{next(){for(;;){if(e>a&&(c+=1,e=r),c>o)return{done:!0,value:void 0};let i=s.getMergedCell(e,c);if(i){let r=e!==i.startRow,a=r||c!==i.startColumn;if(n&&a||!n&&r){e=i.endRow+1;continue}let o=s.getCell(i.startRow,i.startColumn);if(!o&&t){e=i.endRow+1;continue}let l={row:e,col:i.startColumn,value:o};return l.colSpan=i.endColumn-i.startColumn+1,l.rowSpan=i.endRow-i.startRow+1,e=i.endRow+1,{done:!1,value:l}}let l=s.getCell(e,c);if(!l&&t)e+=1;else{let t={row:e,col:c,value:l};return e+=1,{done:!1,value:t}}}}}}}}getCellDocumentModel(e,t,n=Tu){var r;if(!e)return;let{isDeepClone:i,displayRawFormula:a,ignoreTextRotation:o}={...Tu,...n},s,c=`document`,l=Jl(t),u=o?W.tr:l.textRotation||W.tr,d=l.horizontalAlign||W.ht,f=l.verticalAlign||W.vt,p=l.wrapStrategy||W.tb,m=l.paddingData||Gl;if(e.f&&a)s=ql(e.f.toString(),{},{verticalAlign:f}),d=W.ht;else if(e.p){let{centerAngle:t,vertexAngle:n}=tu(u);s=this._updateConfigAndGetDocumentModel(i?D.deepClone(e.p):e.p,d,m,{horizontalAlign:d,verticalAlign:f,centerAngle:t,vertexAngle:n,wrapStrategy:p,zeroWidthParagraphBreak:1})}else if(e.v!=null){let n=Yl(t);c=$l(n).fontCache;let r=Du(e);e.t===tr.FORCE_STRING&&a&&(r=`'${r}`),s=ql(r,n,{...l,textRotation:u,cellValueType:e.t})}return s&&e.linkUrl&&e.linkId&&Xl(s,e.linkUrl,e.linkId),{documentModel:s,fontString:c,textRotation:u,wrapStrategy:p,verticalAlign:f,horizontalAlign:d,paddingData:m,fill:t==null||(r=t.bg)==null?void 0:r.rgb}}_updateConfigAndGetDocumentModel(e,t,n,r){var i,a,o,s,c;if(!r||!((i=e.body)!=null&&i.dataStream))return;e.documentStyle||(e.documentStyle={}),e.documentStyle.marginTop=(a=n.t)==null?0:a,e.documentStyle.marginBottom=(o=n.b)==null?2:o,e.documentStyle.marginLeft=(s=n.l)==null?2:s,e.documentStyle.marginRight=(c=n.r)==null?2:c,e.documentStyle.pageSize={width:1/0,height:1/0},e.documentStyle.renderConfig={...e.documentStyle.renderConfig,...r};let l=e.body.paragraphs||[];for(let e of l)e.paragraphStyle||(e.paragraphStyle={}),e.paragraphStyle.horizontalAlign=t;return new _c(e)}getBlankCellDocumentModel(e,t,n){let r=this.getComposedCellStyleByCellData(t,n,e),i=Yl(r),a=this.getCellDocumentModel(e,r,{ignoreTextRotation:!0});if(a!=null)return a.documentModel==null&&(a.documentModel=ql(``,i)),a;let o=`document`,s=W.tr,c=W.ht,l=W.vt,u=W.tb,d=Gl;return o=$l({}).fontCache,{documentModel:ql(``,i),fontString:o,textRotation:s,wrapStrategy:u,verticalAlign:l,horizontalAlign:c,paddingData:d}}getCellDocumentModelWithFormula(e,t,n){let r=this.getComposedCellStyleByCellData(t,n,e);return this.getCellDocumentModel(e,r,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(e){this._snapshot.custom=e}};function Du(e){var t;if(!e)return``;let n=(t=e.p)==null||(t=t.body)==null?void 0:t.dataStream;if(n)return Z.transform.getPlainText(n);let r=e.v;return typeof r==`string`?e.t===tr.BOOLEAN?r.toUpperCase():r.replace(/[\r\n]/g,``):typeof r==`number`?e.t===tr.BOOLEAN?r?`TRUE`:`FALSE`:r.toString():typeof r==`boolean`?r?`TRUE`:`FALSE`:``}function Ou(e){if(e===null)return``;if(e!=null&&e.p){let t=e==null?void 0:e.p.body;if(t==null)return``;let n=t.dataStream;return Z.transform.getPlainText(n)}return e==null?void 0:e.v}function ku(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}let Au=class extends pn{get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(e){return typeof e==`string`||`startRow`in e||`row`in e}constructor(e={},t){super(),this._logService=t,C(this,`type`,x.UNIVER_SHEET),C(this,`_sheetCreated$`,new y),C(this,`sheetCreated$`,this._sheetCreated$.asObservable()),C(this,`_sheetDisposed$`,new y),C(this,`sheetDisposed$`,this._sheetDisposed$.asObservable()),C(this,`_activeSheet$`,new v(null)),C(this,`activeSheet$`,this._activeSheet$.asObservable()),C(this,`_worksheets`,void 0),C(this,`_styles`,void 0),C(this,`_snapshot`,void 0),C(this,`_unitId`,void 0),C(this,`_count`,void 0),C(this,`_name$`,void 0),C(this,`name$`,void 0);let n=Vl();D.isEmptyObject(e)?this._snapshot=n:this._snapshot=D.commonExtend(n,e);let{styles:r}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=O(6)),this._unitId=this._snapshot.id,this._styles=new Hl(r),this._count=1,this._worksheets=new Map,this._name$=new v(e.name||``),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete(),Array.from(this._worksheets.keys()).forEach(e=>{this._removeSheet(e)})}save(){return D.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(e){this._name$.next(e),this._snapshot.name=e}getUnitId(){return this._unitId}getRev(){var e;return(e=this._snapshot.rev)==null?1:e}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(e){this._snapshot.rev=e}addWorksheet(e,t,n){let{sheets:r,sheetOrder:i}=this._snapshot;if(r[e])return!1;r[e]=n,i.splice(t,0,e),this.ensureSheetOrderUnique();let a=new Eu(this._unitId,n,this._styles);return this._worksheets.set(e,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}ensureSheetOrderUnique(){let e=new Set,t=[];for(let n of this._snapshot.sheetOrder)e.has(n)||(e.add(n),t.push(n));this._snapshot.sheetOrder=t,e.clear()}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}addStyles(e){Object.entries(e).forEach(([e,t])=>{this._styles.addCustomStyle(e,t)})}removeStyles(e){e.forEach(e=>{this._styles.remove(e)})}getConfig(){return this._snapshot}getIndexBySheetId(e){let{sheetOrder:t}=this._snapshot;return t.findIndex(t=>t===e)}getActiveSheet(e){if(!this._activeSheet&&e===void 0)throw Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){let e=this._activeSheet;if(e)return e;let t=this._snapshot.sheetOrder;for(let e=0,n=t.length;e<n;e++){let n=this._worksheets.get(t[e]);if(n&&n.isSheetHidden()!==A.TRUE)return this.setActiveSheet(n),n}let n=this._worksheets.get(t[0]);return this.setActiveSheet(n),n}setActiveSheet(e){this._activeSheet$.next(e)}_removeSheet(e){let t=this._worksheets.get(e);return t?(this._worksheets.delete(e),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(e),1),this.ensureSheetOrderUnique(),this._sheetDisposed$.next(t),!0):!1}removeSheet(e){let t=this._removeSheet(e);return t&&delete this._snapshot.sheets[e],t}getActiveSheetIndex(){let{sheetOrder:e}=this._snapshot;return e.findIndex(e=>this._worksheets.get(e)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){let{sheetOrder:e}=this._snapshot;return e.map(e=>this._worksheets.get(e))}getSheetsName(){let{sheetOrder:e}=this._snapshot,t=[];return e.forEach(e=>{let n=this._worksheets.get(e);n&&t.push(n.getName())}),t}getSheetIndex(e){let{sheetOrder:t}=this._snapshot;return t.findIndex(t=>e.getSheetId()===t)}getSheetBySheetName(e){let{sheetOrder:t}=this._snapshot,n=t.find(t=>this._worksheets.get(t).getName()===e);return this._worksheets.get(n)}getSheetBySheetId(e){return this._worksheets.get(e)}getSheetByIndex(e){let{sheetOrder:t}=this._snapshot;return this._worksheets.get(t[e])}getHiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden===A.TRUE).map(e=>e.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden!==A.TRUE).map(e=>e.getConfig().id)}load(e){this._snapshot=e}checkSheetName(e){return this.getSheetsName().some(t=>t.toLowerCase()===e.toLowerCase())}uniqueSheetName(e=`Sheet1`){let t=e;for(;this.checkSheetName(t);)t=e+this._count,this._count++;return t}generateNewSheetName(e){let t=e+this._count;for(;this.checkSheetName(t);)t=e+this._count,this._count++;return t}_parseWorksheetSnapshots(){let{_snapshot:e,_worksheets:t}=this,{sheets:n,sheetOrder:r}=e;if(D.isEmptyObject(n)){let e=O();n[e]={id:e}}for(let e in n){let i=n[e],{name:a}=i;i.name=this.uniqueSheetName(a),i.name!==a&&this._logService.debug(`[Workbook]`,`The worksheet name ${a} is duplicated, we changed it to ${i.name}. Please fix the problem in your snapshot.`);let o=new Eu(this._unitId,i,this._styles);t.set(e,o),r.includes(e)||r.push(e)}this.ensureSheetOrderUnique(),this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(e){this._snapshot.custom=e}};Au=z([R(1,L)],Au);var ju=class extends pn{get _activePage(){let e=this._activePage$.getValue();if(!e){var t,n;let e=(t=this.getPageOrder())==null?void 0:t[0];return e?(n=this.getPages())==null?void 0:n[e]:null}return e}constructor(e){var t;super(),C(this,`type`,x.UNIVER_SLIDE),C(this,`_activePage$`,new v(null)),C(this,`activePage$`,this._activePage$.asObservable()),C(this,`_name$`,void 0),C(this,`name$`,void 0),C(this,`_snapshot`,void 0),C(this,`_unitId`,void 0),this._snapshot={..._o,...e},this._unitId=(t=this._snapshot.id)==null?O(6):t,this._name$=new v(this._snapshot.title),this.name$=this._name$.asObservable()}setName(e){var t;this._snapshot.title=e,this._name$.next(e),this._unitId=(t=this._snapshot.id)==null?O(6):t}getRev(){return 0}incrementRev(){}setRev(e){}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var e;return(e=this._snapshot.body)==null?void 0:e.pages}getPageOrder(){var e;return(e=this._snapshot.body)==null?void 0:e.pageOrder}getPage(e){let t=this.getPages();return t==null?void 0:t[e]}getElementsByPage(e){var t;return(t=this.getPage(e))==null?void 0:t.pageElements}getElement(e,t){var n;return(n=this.getElementsByPage(e))==null?void 0:n[t]}getPageSize(){return this._snapshot.pageSize}getBlankPage(){let e=O(6);return{id:e,pageType:Lr.SLIDE,zIndex:10,title:e,description:``,pageBackgroundFill:{rgb:`rgb(255,255,255)`},pageElements:{}}}setActivePage(e){this._activePage$.next(e)}getActivePage(){return this._activePage}updatePage(e,t){this._snapshot.body&&(this._snapshot.body.pages[e]=t)}appendPage(e){var t;if(!this._snapshot.body)return;this._snapshot.body.pages[e.id]=e;let n=this._activePage,r=this._snapshot.body.pageOrder.indexOf((t=n==null?void 0:n.id)==null?``:t);this._snapshot.body.pageOrder.splice(r+1,0,e.id)}};const Mu=m(`univer.current`);let Nu=class extends E{constructor(e,t,n){super(),this._injector=e,this._contextService=t,this._logService=n,C(this,`_unitsByType`,new Map),C(this,`_createHandler`,void 0),C(this,`_ctorByType`,new Map),C(this,`_currentUnits`,new Map),C(this,`_currentUnits$`,new v(this._currentUnits)),C(this,`currentUnits$`,this._currentUnits$.asObservable()),C(this,`_unitAdded$`,new y),C(this,`unitAdded$`,this._unitAdded$.asObservable()),C(this,`_unitDisposed$`,new y),C(this,`unitDisposed$`,this._unitDisposed$.asObservable()),C(this,`_focused$`,new v(null)),C(this,`focused$`,this._focused$.asObservable())}dispose(){super.dispose(),this._focused$.complete(),this._currentUnits$.complete(),this._unitAdded$.complete(),this._currentUnits.forEach(e=>e==null?void 0:e.dispose()),this._currentUnits.clear(),this._unitsByType.clear()}__setCreateHandler(e){this._createHandler=e}createUnit(e,t,n){return this._createHandler(e,t,this._ctorByType.get(e),n)}registerCtorForType(e,t){return this._ctorByType.set(e,t),{dispose:()=>{this._ctorByType.delete(e)}}}getCurrentTypeOfUnit$(e){return this.currentUnits$.pipe(be(t=>{var n;return(n=t.get(e))==null?null:n}),_e())}getCurrentUnitForType(e){return this._currentUnits.get(e)}getCurrentUnitOfType(e){return this.getCurrentUnitForType(e)}setCurrentUnitForType(e){let t=this._getUnitById(e);if(!t)throw Error(`[UniverInstanceService]: no document with unitId ${e}!`);this._currentUnits.set(t[1],t[0]),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(e){return this._unitAdded$.pipe(ve(t=>t.type===e))}__addUnit(e,t){var n;this._logService.debug(`[UniverInstanceService]: Adding unit with id ${e.getUnitId()}`);let r=e.type;this._unitsByType.has(r)||this._unitsByType.set(r,[]);let i=this._unitsByType.get(r),a=e.getUnitId();if(i.findIndex(e=>e.getUnitId()===a)!==-1)throw Error(`[UniverInstanceService]: cannot create a unit with the same unit id: ${a}.`);i.push(e),this._unitAdded$.next(e),((n=t==null?void 0:t.makeCurrent)==null||n)&&this.setCurrentUnitForType(e.getUnitId())}getTypeOfUnitDisposed$(e){return this.unitDisposed$.pipe(ve(t=>t.type===e))}getUnit(e,t){var n;let r=(n=this._getUnitById(e))==null?void 0:n[0];return t&&(r==null?void 0:r.type)!==t?null:r}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(x.UNIVER_DOC)}getUniverDocInstance(e){return this.getUnit(e,x.UNIVER_DOC)}getUniverSheetInstance(e){return this.getUnit(e,x.UNIVER_SHEET)}getAllUnitsForType(e){var t;return(t=this._unitsByType.get(e))==null?[]:t}changeDoc(e,t){let n=this.getAllUnitsForType(x.UNIVER_DOC),r=n.find(t=>t.getUnitId()===e);if(r!=null){let e=n.indexOf(r);n.splice(e,1)}this.__addUnit(t)}get focused(){var e;let t=this._focused$.getValue();return t?(e=this._getUnitById(t))==null?void 0:e[0]:null}focusUnit(e){this._focused$.next(e),this.focused instanceof Au?(this._contextService.setContextValue(vl,!0),this._contextService.setContextValue(bl,!1),this._contextService.setContextValue(yl,!0),this._contextService.setContextValue(xl,!1),this.setCurrentUnitForType(e)):this.focused instanceof _c?(this._contextService.setContextValue(vl,!0),this._contextService.setContextValue(bl,!0),this._contextService.setContextValue(yl,!1),this._contextService.setContextValue(xl,!1),this.setCurrentUnitForType(e)):this.focused instanceof ju?(this._contextService.setContextValue(vl,!0),this._contextService.setContextValue(bl,!1),this._contextService.setContextValue(yl,!1),this._contextService.setContextValue(xl,!0),this.setCurrentUnitForType(e)):(this._contextService.setContextValue(vl,!1),this._contextService.setContextValue(bl,!1),this._contextService.setContextValue(yl,!1),this._contextService.setContextValue(xl,!1))}getFocusedUnit(){return this.focused}getUnitType(e){let t=this._getUnitById(e);return t?t[1]:x.UNRECOGNIZED}disposeUnit(e){this._logService.debug(`[UniverInstanceService]: Disposing unit with id ${e}`);let t=this._getUnitById(e);if(!t)return this._logService.debug(`[UniverInstanceService]: No unit found with id ${e}`),!1;let[n,r]=t,i=this._unitsByType.get(r),a=i.indexOf(n);return i.splice(a,1),this._tryResetCurrentOnRemoval(e,r),this._tryResetFocusOnRemoval(e),this._unitDisposed$.next(n),n.dispose(),!0}_tryResetCurrentOnRemoval(e,t){let n=this.getCurrentUnitForType(t);(n==null?void 0:n.getUnitId())===e&&(this._currentUnits.set(t,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(e){var t;((t=this.focused)==null?void 0:t.getUnitId())===e&&this._focused$.next(null)}_getUnitById(e){for(let[t,n]of this._unitsByType){let r=n.find(t=>t.getUnitId()===e);if(r)return[r,t]}}};Nu=z([R(0,t(i)),R(1,Zr),R(2,t(L))],Nu);let $=function(e){return e[e.Starting=0]=`Starting`,e[e.Ready=1]=`Ready`,e[e.Rendered=2]=`Rendered`,e[e.Steady=3]=`Steady`,e}({});const Pu={[$.Starting]:`Starting`,[$.Ready]:`Ready`,[$.Rendered]:`Rendered`,[$.Steady]:`Steady`};var Fu=class extends Error{constructor(e){super(`[LifecycleService]: lifecycle stage "${Pu[e]}" will never be reached!`),this.name=`LifecycleUnreachableError`}};let Iu=class extends E{constructor(e){super(),this._logService=e,C(this,`_lifecycle$`,new v($.Starting)),C(this,`lifecycle$`,this._lifecycle$.asObservable()),C(this,`_lock`,!1),this._reportProgress($.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(e){if(this._lock)throw Error(`[LifecycleService]: cannot set new stage when related logic is all handled!`);if(e<this.stage)throw Error(`[LifecycleService]: lifecycle stage cannot go backward!`);e!==this.stage&&(this._lock=!0,this._reportProgress(e),this._lifecycle$.next(e),this._lock=!1)}dispose(){this._lifecycle$.complete(),super.dispose()}onStage(e){return ye(this.lifecycle$.pipe(ve(t=>t>=e),fi(t=>t===e),be(()=>void 0))).catch(t=>t.name===`EmptyError`?Promise.reject(new Fu(e)):Promise.reject(t))}subscribeWithPrevious(){return xe(Lu(this.stage),this._lifecycle$.pipe(Ce(1))).pipe(fi(e=>e===$.Steady))}_reportProgress(e){this._logService.debug(`[LifecycleService]`,`lifecycle progressed to "${Pu[e]}".`)}};Iu=z([R(0,L)],Iu);function Lu(e){switch(e){case $.Starting:return Se($.Starting);case $.Ready:return Se($.Starting,$.Ready);case $.Rendered:return Se($.Starting,$.Ready,$.Rendered);default:return Se($.Starting,$.Ready,$.Rendered,$.Steady)}}const Ru=m(`ILocalStorageService`);var zu=class extends E{get _currentLocale(){return this._currentLocale$.value}constructor(){super(),C(this,`_currentLocale$`,new v(Rn.ZH_CN)),C(this,`currentLocale$`,this._currentLocale$.asObservable()),C(this,`_locales`,null),C(this,`localeChanged$`,new y),C(this,`t`,(e,...t)=>{if(!this._locales)throw Error(`[LocaleService]: Locale not initialized`);let n=e.split(`.`),r=this.resolveKeyPath(this._locales[this._currentLocale],n);if(typeof r==`string`){let e=r;return t.forEach((t,n)=>{e=e.replace(`{${n}}`,t)}),e}else return e}),this.disposeWithMe(T(()=>{this._locales=null,this._currentLocale$.complete(),this.localeChanged$.complete()}))}load(e){var t;this._locales=le((t=this._locales)==null?{}:t,e)}setLocale(e){this._currentLocale$.next(e),this.localeChanged$.next()}getLocales(){var e;return(e=this._locales)==null?void 0:e[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(e,t){let n=t.shift();if(n&&e&&n in e){let r=e[n];return t.length>0&&(typeof r==`object`||Array.isArray(r))?this.resolveKeyPath(r,t):r}return null}};let Bu=class{constructor(e){this._userManagerService=e}async list(e){return{list:[{type:zn.PERSON,mentions:[{objectType:zn.PERSON,objectId:this._userManagerService.getCurrentUser().userID,label:this._userManagerService.getCurrentUser().name,metadata:{icon:this._userManagerService.getCurrentUser().avatar}}],metadata:{},title:`PEOPLE`}],page:e.page,size:e.size,total:1}}};Bu=z([R(0,n(pl))],Bu);const Vu=h(`univer.service.mention-io`);let Hu=function(e){return e.INIT=`init`,e.FETCHING=`fetching`,e.DONE=`done`,e}({});const Uu=m(`univer.permission-service`);var Wu=class extends E{constructor(...e){super(...e),C(this,`_permissionPointMap`,new Map),C(this,`_permissionPointUpdate$`,new y),C(this,`permissionPointUpdate$`,this._permissionPointUpdate$.asObservable()),C(this,`_showComponents`,!0)}setShowComponents(e){this._showComponents=e}getShowComponents(){return this._showComponents}deletePermissionPoint(e){let t=this._permissionPointMap.get(e);t&&(t.complete(),this._permissionPointMap.delete(e))}addPermissionPoint(e){let t=e instanceof v,n=t?e.getValue():e;return n.id?this._permissionPointMap.get(n.id)?(console.warn(`${n.id} PermissionPoint already exists`),!1):(this._permissionPointMap.set(n.id,t?e:new v(n)),this._permissionPointUpdate$.next(n),!0):!1}updatePermissionPoint(e,t){let n=this._permissionPointMap.get(e);if(!n)return;let r=n.getValue();r.value=t,r.status=Hu.DONE,n.next(r),this._permissionPointUpdate$.next(r)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(e){let t=this._permissionPointMap.get(e);if(t)return t.getValue()}getPermissionPoint$(e){let t=this._permissionPointMap.get(e);if(t)return t}composePermission$(e){return he(e.map(e=>{var t;let n=(t=this._permissionPointMap)==null?void 0:t.get(e);if(!n)throw Error(`[PermissionService]: ${e} permissionPoint does not exist!`);return n.asObservable()})).pipe(Pe(e=>e))}composePermission(e){return e.map(e=>{var t;let n=(t=this._permissionPointMap)==null?void 0:t.get(e);if(!n)throw Error(`[PermissionService]: ${e} permissionPoint does not exist!`);return n.getValue()})}getAllPermissionPoint(){let e=new Map;return this._permissionPointMap.forEach((t,n)=>{e.set(n,t)}),e}};function Gu(e,t){if(!t)return e;let n=[];for(let r of e){let e=t.find(([e])=>e===r[0]);if(e){if(e[1]===null)continue;n.push([r[0],e[1]])}else n.push(r)}return n}const Ku=Symbol(`DependentOn`);var qu=class extends E{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}};C(qu,`pluginName`,void 0),C(qu,`packageName`,zl),C(qu,`version`,Bl),C(qu,`type`,x.UNIVER_UNKNOWN);var Ju=class{constructor(){C(this,`_plugins`,[])}addPlugin(e){this._plugins.push(e)}removePlugins(){let e=this._plugins.slice();return this._plugins.length=0,e}forEachPlugin(e){this._plugins.forEach(e)}};function Yu(...e){return function(t){t[Ku]=e}}let Xu=class{constructor(e,t,n){this._injector=e,this._lifecycleService=t,this._logService=n,C(this,`_pluginRegistry`,new Map),C(this,`_pluginStore`,new Ju),C(this,`_seenPlugins`,new Set),C(this,`_loadedPlugins`,new Set),C(this,`_loadedPluginTypes`,new Set([x.UNIVER_UNKNOWN])),C(this,`_flushTimerByType`,new Map)}dispose(){this._pluginStore.removePlugins().forEach(e=>e.dispose()),this._flushTimerByType.forEach(e=>clearTimeout(e))}registerPlugin(e,t){this._assertPluginValid(e);let n={plugin:e,options:t};this._pluginRegistry.set(e.pluginName,n),this._logService.debug(`[PluginService]`,`Plugin "${e.pluginName}" registered.`);let{type:r}=e;this._loadedPluginTypes.has(r)&&(r===x.UNIVER_UNKNOWN?this._loadFromPlugins([n]):this._flushType(r))}startPluginsForType(e){this._loadedPluginTypes.has(e)||this._loadPluginsForType(e)}_loadPluginsForType(e){let t=Array.from(this._pluginRegistry.keys()),n=[];t.forEach(t=>{let r=this._pluginRegistry.get(t);r.plugin.type===e&&n.push(r)}),this._loadFromPlugins(n),this._loadedPluginTypes.add(e)}_assertPluginValid(e){let{type:t,pluginName:n,packageName:r,version:i}=e;if(t===x.UNRECOGNIZED)throw Error(`[PluginService]: invalid plugin type for ${e.name}. Please assign a "type" to your plugin.`);if(!n)throw Error(`[PluginService]: no plugin name for ${e.name}. Please assign a "pluginName" to your plugin.`);if(i&&i!==qu.version)throw Error(`[PluginService]: package "${r==null?`UNKNOWN`:r}" version mismatch. Plugin version is "${i}" but @univerjs/core version is "${qu.version}". Please make sure all @univerjs packages use the same version.`);if(this._seenPlugins.has(n))throw Error(`[PluginService]: duplicated plugin name for "${n}". Maybe a plugin that dependents on "${n} has already registered it. In that case please register "${n}" before the that plugin.`);this._seenPlugins.add(e.pluginName)}_flushType(e){this._flushTimerByType.get(e)===void 0&&this._flushTimerByType.set(e,setTimeout(()=>{this._loadPluginsForType(e),this._flushTimerByType.delete(e)},4))}_loadFromPlugins(e){let t=[],n=new Set,r=e=>{let{plugin:i}=e,{pluginName:a}=i;if(this._loadedPlugins.has(a)||n.has(a))return;n.add(a),this._pluginRegistry.delete(a);let o=i[Ku];o&&o.forEach(e=>{let t=this._pluginRegistry.get(e.pluginName);if(t)r(t);else if(!this._seenPlugins.has(e.pluginName)&&!n.has(e.pluginName)){if(i.type===x.UNIVER_UNKNOWN&&e.type!==x.UNIVER_UNKNOWN)throw Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${i.pluginName} and the dependency is ${e.pluginName}.`);i.type!==e.type&&e.type!==x.UNIVER_UNKNOWN&&this._logService.debug(`[PluginService]`,`Plugin "${a}" depends on "${e.pluginName}" which has different type.`),this._logService.debug(`[PluginService]`,`Plugin "${a}" depends on "${e.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(e),r({plugin:e,options:void 0})}}),t.push(e)};e.forEach(e=>r(e));let i=t.map(e=>this._initPlugin(e.plugin,e.options));this._pluginsRunLifecycle(i)}_pluginsRunLifecycle(e){let t=this._lifecycleService.stage;if(Lu(t).subscribe(t=>this._runStage(e,t)),t!==$.Steady){let t=this._lifecycleService.lifecycle$.pipe(Ce(1)).subscribe(n=>{this._runStage(e,n),n===$.Steady&&t.unsubscribe()})}}_runStage(e,t){e.forEach(e=>{switch(t){case $.Starting:e.onStarting();break;case $.Ready:e.onReady();break;case $.Rendered:e.onRendered();break;case $.Steady:e.onSteady();break}})}_initPlugin(e,t){let n=this._injector.createInstance(e,t);return this._pluginStore.addPlugin(n),this._loadedPlugins.add(e.pluginName),this._logService.debug(`[PluginService]`,`Plugin "${n.getPluginName()}" loaded.`),n}};Xu=z([R(0,t(i)),R(1,t(Iu)),R(2,L)],Xu);const Zu=m(`resource-loader-service`);let Qu=class extends E{constructor(e){super(),this._logService=e,C(this,`_resourceMap`,new Map),C(this,`_register$`,new y),C(this,`register$`,this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(e,t){return t?this.getResourcesByType(e,t):this.getAllResourceHooks().map(t=>{let n=t.toJson(e);return{name:t.pluginName,data:n}})}getResourcesByType(e,t){return this.getAllResourceHooks().filter(e=>e.businesses.includes(t)).map(t=>{let n=t.toJson(e);return{name:t.pluginName,data:n}})}registerPluginResource(e){let t=e.pluginName;if(this._resourceMap.has(t))throw Error(`the pluginName is registered {${t}}`);return this._resourceMap.set(t,e),this._register$.next(e),T(()=>this._resourceMap.delete(t))}disposePluginResource(e){this._resourceMap.delete(e)}loadResources(e,t){this.getAllResourceHooks().forEach(n=>{var r;let i=t==null||(r=t.find(e=>e.name===n.pluginName))==null?void 0:r.data;if(i)try{let t=n.parseJson(i);n.onLoad(e,t)}catch(e){this._logService.error(`[ResourceManagerService]`,`loadResources error`,e)}})}unloadResources(e,t){this.getAllResourceHooks().filter(e=>e.businesses.includes(t)).forEach(t=>{t.onUnLoad(e)})}dispose(){this._register$.complete(),this._resourceMap.clear()}};Qu=z([R(0,L)],Qu);var $u=class extends E{get darkMode(){return this._darkMode$.getValue()}constructor(){super(),C(this,`_darkMode$`,new v(!1)),C(this,`darkMode$`,this._darkMode$.asObservable()),C(this,`_validColorCache`,new Map),C(this,`_currentTheme`,Je),C(this,`_currentTheme$`,new v(this._currentTheme)),C(this,`currentTheme$`,this._currentTheme$.asObservable()),this.disposeWithMe(T(()=>{this._currentTheme=Je,this._currentTheme$.complete(),this._darkMode$.complete()}))}isValidThemeColor(e){if(this._validColorCache.has(e))return this._validColorCache.get(e);let t=!1,n=e.split(`.`);if(n.length===1)t=e in Je;else if(n.length===2){let[e,r]=n;t=e in Je&&r in this._currentTheme[e]}return this._validColorCache.set(e,t),t}getCurrentTheme(){return this._currentTheme}setTheme(e){this._currentTheme=e,this._currentTheme$.next(e)}setDarkMode(e){this._darkMode$.next(e)}getColorFromTheme(e){return ce(this._currentTheme,e)}},ed=function(e){return e[e.WAITING=0]=`WAITING`,e[e.CREATED=1]=`CREATED`,e}(ed||{});const td=m(`univer.undo-redo.service`);var nd=class{dispose(){}async dispatchToHandlers(){return!1}};const rd=`univer.command.redo`,id=`univer.command.undo`,ad=new class extends nd{constructor(...e){super(...e),C(this,`type`,ri.COMMAND),C(this,`id`,id)}handler(e){let t=e.get(td),n=t.pitchTopUndoElement();if(!n)return!1;let r=e.get(ii);return li(n.undoMutations,r)?(t.popUndoToRedo(),!0):!1}},od=new class extends nd{constructor(...e){super(...e),C(this,`type`,ri.COMMAND),C(this,`id`,rd)}handler(e){let t=e.get(td),n=t.pitchTopRedoElement();if(!n)return!1;let r=e.get(ii);return li(n.redoMutations,r)?(t.popRedoToUndo(),!0):!1}};let sd=class extends E{constructor(e,t,n){super(),this._univerInstanceService=e,this._commandService=t,this._contextService=n,C(this,`undoRedoStatus$`,void 0),C(this,`_undoRedoStatus$`,new v({undos:0,redos:0})),C(this,`_undoStacks`,new Map),C(this,`_redoStacks`,new Map),C(this,`_batchingStatus`,new Map),this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(ad)),this.disposeWithMe(this._commandService.registerCommand(od)),this.disposeWithMe(T(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(T(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(e){let{unitID:t}=e,n=this._getRedoStack(t,!0),r=this._getUndoStack(t,!0);if(n.length=0,this._batchingStatus.has(e.unitID)){let t=this._batchingStatus.get(e.unitID),n=this._pitchUndoElement(e.unitID);t===ed.WAITING||!n?(i(e),this._batchingStatus.set(e.unitID,ed.CREATED)):this._tryBatchingElements(n,e)}else i(e);function i(e){r.push(e),r.length>20&&r.splice(0,1)}this._updateStatus()}clearUndoRedo(e){let t=this._getRedoStack(e);t&&(t.length=0);let n=this._getUndoStack(e);n&&(n.length=0),this._updateStatus()}pitchTopUndoElement(){let e=this._getFocusedUnitId();return this._pitchUndoElement(e)}pitchTopRedoElement(){let e=this._getFocusedUnitId();return this._pitchRedoElement(e)}_pitchUndoElement(e){let t=this._getUndoStack(e);return t!=null&&t.length?t[t.length-1]:null}_pitchRedoElement(e){let t=this._getRedoStack(e);return t!=null&&t.length?t[t.length-1]:null}popUndoToRedo(){let e=this._getUndoStackForFocused().pop();e&&(e.redoMutations.length>0&&this._getRedoStackForFocused().push(e),this._updateStatus())}popRedoToUndo(){let e=this._getRedoStackForFocused().pop();e&&(this._getUndoStackForFocused().push(e),this._updateStatus())}rollback(e,t){let n=t||this._getFocusedUnitId(),r=this._getUndoStack(n),i=r==null?void 0:r[(r==null?void 0:r.length)-1];i&&i.id===e&&(r.pop(),li(i.undoMutations,this._commandService))}__tempBatchingUndoRedo(e){if(this._batchingStatus.has(e))throw Error(`[LocalUndoRedoService]: cannot batching undo redo twice at the same time!`);return this._batchingStatus.set(e,ed.WAITING),T(()=>this._batchingStatus.delete(e))}_updateStatus(){var e,t;let n=this._getFocusedUnitId(),r=n&&((e=this._undoStacks.get(n))==null?void 0:e.length)||0,i=n&&((t=this._redoStacks.get(n))==null?void 0:t.length)||0;this._undoRedoStatus$.next({undos:r,redos:i})}_getUndoStack(e,t=!1){let n=this._undoStacks.get(e);return!n&&t&&(n=[],this._undoStacks.set(e,n)),n||null}_getRedoStack(e,t=!1){let n=this._redoStacks.get(e);return!n&&t&&(n=[],this._redoStacks.set(e,n)),n||null}_getUndoStackForFocused(){let e=this._getFocusedUnitId();if(!e)throw Error(`No focused univer instance!`);return this._getUndoStack(e,!0)}_getRedoStackForFocused(){let e=this._getFocusedUnitId();if(!e)throw Error(`No focused univer instance!`);return this._getRedoStack(e,!0)}_tryBatchingElements(e,t){e.redoMutations.push(...t.redoMutations),e.undoMutations.push(...t.undoMutations)}_getFocusedUnitId(){let e=``,t=this._contextService.getContextValue(yl),n=this._contextService.getContextValue(Tl),r=this._contextService.getContextValue(Cl);if(t)if(n)e=ft;else if(r)e=dt;else{var i,a;e=(i=(a=this._univerInstanceService.getFocusedUnit())==null?void 0:a.getUnitId())==null?``:i}else{var o,s;e=(o=(s=this._univerInstanceService.getFocusedUnit())==null?void 0:s.getUnitId())==null?``:o}return e}};sd=z([R(0,Mu),R(1,ii),R(2,Zr)],sd);var cd=class{constructor(e,t=1e3){this._injector=e,C(this,`_imageCacheMap`,void 0),this._imageCacheMap=new so(t)}_getImageCacheKey(e,t){return`${e}-${t}`}getImage(e,t,n,r){let i=this._getImageCacheKey(e,t);return this._imageCacheMap.get(i)||((async()=>{let a=new Image,o=this._injector.has(Ll)?this._injector.get(Ll):null,s=this._injector.has(Rl)?this._injector.get(Rl):null;if(e===Fl.UUID)try{a.src=await(o==null?void 0:o.getImage(t))||``}catch(e){console.error(e)}else if(e===Fl.URL)try{a.src=await(s==null?void 0:s.getImage(t))||t}catch{a.src=t}else a.src=t;a.onload=()=>{a.removeAttribute(`data-error`),n==null||n()},a.onerror=()=>{a.setAttribute(`data-error`,`true`),r==null||r()},this._imageCacheMap.set(i,a)})(),null)}};function ld(e){return!(e.length===0||e.length>31||e.startsWith(`'`)||e.endsWith(`'`)||/[:\\\/\?\*\[\]]/.test(e))}function ud(e,t){return!(!e||e.length===0||e.length>255||t.has(e)||/[ :\\\/\?\*\[\]]/.test(e)||!/^[\p{L}_]/u.test(e)||/^\$?[A-Za-z]{1,3}\$?[0-9]+$/.test(e)||/^[rR]\d+[cC]\d+$/.test(e)||/^\d+$/.test(e))}var dd=class{constructor(e=!1){this._enableOneCellCache=e,C(this,`_tree`,new Map),C(this,`_oneCellCache`,new Map),C(this,`_kdTree`,new Map)}dispose(){this.clear()}getTree(e,t){return this._tree.has(e)||this._tree.set(e,new Map),this._tree.get(e).has(t)||this._tree.get(e).set(t,new Ge),this._tree.get(e).get(t)}_getOneCellCache(e,t,n,r){return this._oneCellCache.has(e)||this._oneCellCache.set(e,new Map),this._oneCellCache.get(e).has(t)||this._oneCellCache.get(e).set(t,new Map),this._oneCellCache.get(e).get(t).has(n)||this._oneCellCache.get(e).get(t).set(n,new Map),this._oneCellCache.get(e).get(t).get(n).has(r)||this._oneCellCache.get(e).get(t).get(n).set(r,new Set),this._oneCellCache.get(e).get(t).get(n).get(r)}_removeOneCellCache(e,t,n,r,i){let a=this._oneCellCache.get(e);if(!a)return;let o=a.get(t);if(!o)return;let s=o.get(n);if(!s)return;let c=s.get(r);c&&c.delete(i)}_removeCellCacheByRange(e){let{unitId:t,sheetId:n,range:r,id:i}=e,a=this._oneCellCache.get(t);if(!a)return;let o=a.get(n);if(!o)return;let{startRow:s,startColumn:c,endRow:l,endColumn:u}=r;for(let e=s;e<=l;e++){let t=o.get(e);if(t)for(let e=c;e<=u;e++){let n=t.get(e);n&&n.delete(i)}}}_insertOneCellCache(e,t,n,r,i){this._getOneCellCache(e,t,n,r).add(i)}_getRdTreeItems(e){let t=[];for(let[n,r]of e)for(let[e,i]of r)t.push({x:e,y:n,ids:i});return t}_searchByOneCellCache(e){var t;let{unitId:n,sheetId:r,range:i}=e,{startRow:a,startColumn:o,endRow:s,endColumn:c}=i,l=(t=this._kdTree.get(n))==null?void 0:t.get(r);if(!l)return[];let{tree:u,items:d}=l,f=u.range(o,a,c,s),p=[];for(let e of f){let t=d[e];p.push(...Array.from(t.ids))}return p}openKdTree(){for(let[t,n]of this._oneCellCache){this._kdTree.has(t)||this._kdTree.set(t,new Map);for(let[r,i]of n){var e;let n=this._getRdTreeItems(i),a=new Ye(n.length);(e=this._kdTree.get(t))==null||e.set(r,{tree:a,items:n});for(let e of n)a.add(e.x,e.y);a.finish()}}}closeKdTree(){for(let[t,n]of this._oneCellCache)for(let[r,i]of n){var e;(e=this._kdTree.get(t))==null||e.set(r,void 0)}}insert(e){let{unitId:t,sheetId:n,range:r,id:i}=e;if(!t||t.length===0)return;let{startRow:a,endRow:o,startColumn:s,endColumn:c}=r;if(this._enableOneCellCache&&a===o&&s===c){this._insertOneCellCache(t,n,a,s,i);return}let l=this.getTree(t,n);Number.isNaN(a)&&(a=0),Number.isNaN(s)&&(s=0),Number.isNaN(o)&&(o=1/0),Number.isNaN(c)&&(c=1/0),l.insert({minX:s,minY:a,maxX:c,maxY:o,id:i})}bulkInsert(e){for(let t of e)this.insert(t)}*searchGenerator(e){var t;let{unitId:n,sheetId:r,range:i}=e;if(this._enableOneCellCache){let t=this._searchByOneCellCache(e);for(let e of t)yield e}let a=(t=this._tree.get(n))==null?void 0:t.get(r);if(!a)return;let o=a.search({minX:i.startColumn,minY:i.startRow,maxX:i.endColumn,maxY:i.endRow});for(let e of o)yield e.id}bulkSearch(e,t){let n=new Set;for(let r of e)for(let e of this.searchGenerator(r))(t==null?void 0:t.has(e))!==!0&&n.add(e);return n}removeById(e,t){if(t){var n,r;(n=this._tree.get(e))==null||n.delete(t),(r=this._oneCellCache.get(e))==null||r.delete(t)}else this._tree.delete(e),this._oneCellCache.delete(e)}_removeRTreeItem(e){let{unitId:t,sheetId:n,range:r,id:i}=e,a=this.getTree(t,n),o=a.search({minX:r.startColumn,minY:r.startRow,maxX:r.endColumn,maxY:r.endRow});for(let e=0;e<o.length;e++)o[e].id===i&&a.remove(o[e])}remove(e){let{unitId:t,sheetId:n,range:r,id:i}=e,{startRow:a,startColumn:o,endRow:s,endColumn:c}=r;this._enableOneCellCache?a===s&&o===c?this._removeOneCellCache(t,n,r.startRow,r.startColumn,i):(this._removeCellCacheByRange(e),this._removeRTreeItem(e)):this._removeRTreeItem(e)}bulkRemove(e){for(let t of e)this.remove(t)}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){let e={};return this._tree.forEach((t,n)=>{e[n]={},t.forEach((t,r)=>{e[n][r]=t.toJSON()})}),e}fromJSON(e){this._tree.clear();for(let t in e){this._tree.set(t,new Map);for(let n in e[t]){let r=new Ge;r.fromJSON(e[t][n]),this._tree.get(t).set(n,r)}}}};function fd(e){return new Promise(t=>setTimeout(t,e))}function pd(e=1){return new Promise(t=>{let n=0,r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}let md=class extends E{constructor(e){super(),this._localeService=e,C(this,`_fontLocale`,void 0),C(this,`_dirty`,!0),this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(e){this._dirty=e}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}};md=z([R(0,n(zu))],md);let hd=class extends md{constructor(e,t,n,r,i,a){super(n),this.worksheet=e,this._styles=t,this._contextService=r,this._configService=i,this._injector=a,C(this,`_worksheetData`,void 0),C(this,`_renderRawFormula`,!1),C(this,`_cellData`,void 0),C(this,`_imageCacheMap`,void 0),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`,void 0),C(this,`_scaleY`,void 0),C(this,`_scrollX`,void 0),C(this,`_scrollY`,void 0),this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new cd(this._injector),this.initConfig()}initConfig(){var e,t;this._skipAutoHeightForMergedCells=!((e=this._configService.getConfig(_t))!=null&&e),this.worksheet.setIsRowStylePrecedeColumnStyle((t=this._configService.getConfig(`isRowStylePrecedeColumnStyle`))==null?!1:t)}resetCache(){}getWorksheetConfig(){return this._worksheetData}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(e){this._columnHeaderHeight=e,this._worksheetData.columnHeader.height=e}set rowHeaderWidth(e){this._rowHeaderWidth=e,this._worksheetData.rowHeader.width=e}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(e){this._marginLeft=e}setMarginTop(e){this._marginTop=e}setScale(e,t){this._updateLayout(),this._scaleX=e,this._scaleY=t||e,this._updateLayout()}setScroll(e,t){D.isDefine(e)&&(this._scrollX=e),D.isDefine(t)&&(this._scrollY=t)}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(e,t,n){let r=0,i=[],a=t;for(let t=0;t<e;t++){let e=n;if(this.worksheet.getRowFiltered(t))e=0;else if(a[t]!=null){let r=a[t];if(!r)continue;let{h:i=n,ah:o,ia:s}=r;e=(s==null||s===A.TRUE)&&typeof o==`number`&&o>0?o:i,r.hd===A.TRUE&&(e=0)}r+=e,i.push(r)}return{rowTotalHeight:r,rowHeightAccumulation:i}}_generateColumnMatrixCache(e,t,n){let r=0,i=[],a=t;for(let t=0;t<e;t++){let e=n;if(a[t]!=null){let n=a[t];if(!n)continue;n.w!=null&&(e=n.w),n.hd===A.TRUE&&(e=0)}r+=e,i.push(r)}return{columnTotalWidth:r,columnWidthAccumulation:i}}intersectMergeRange(e,t){return!!this.worksheet.getMergedCell(e,t)}_getOverflowBound(e,t,n,r,i=Yn.LEFT){let a=0;if(t>n){let o=this._columnWidthAccumulation.length-1;for(let s=t;s>=n;s--){let n=s;if(!Da(this.worksheet.getCell(e,n))&&n!==t||this.intersectMergeRange(e,n))return n===t?n:n+1>o?o:n+1;let{startX:c,endX:l}=vd(e,n,this.rowHeightAccumulation,this.columnWidthAccumulation);if(i===Yn.CENTER&&n===t?a+=(l-c)/2:a+=l-c,r<a)return n}return t}for(let o=t;o<=n;o++){let n=o;if(!Da(this.worksheet.getCell(e,n))&&n!==t||this.intersectMergeRange(e,n))return n===t?n:n-1<0?0:n-1;let{startX:s,endX:c}=vd(e,n,this.rowHeightAccumulation,this.columnWidthAccumulation);if(i===Yn.CENTER&&n===t?a+=(c-s)/2:a+=c-s,r<a)return n}return n}_updateLayout(){if(!this.dirty)return;let{rowData:e,columnData:t,defaultRowHeight:n,defaultColumnWidth:r,rowCount:i,columnCount:a,rowHeader:o,columnHeader:s}=this._worksheetData,{rowTotalHeight:c,rowHeightAccumulation:l}=this._generateRowMatrixCache(i,e,n),{columnTotalWidth:u,columnWidthAccumulation:d}=this._generateColumnMatrixCache(a,t,r);this._rowHeaderWidth=o.hidden===A.TRUE?0:this._dynamicallyUpdateRowHeaderWidth(o),this._columnHeaderHeight=s.hidden===A.TRUE?0:s.height,this._rowTotalHeight=c,this._rowHeightAccumulation=l,this._columnTotalWidth=u,this._columnWidthAccumulation=d,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(e){}_dynamicallyUpdateRowHeaderWidth(e){let t=`${this.worksheet.getRowCount()}`.length*8;return Math.max(e.width,t)}_hasUnMergedCellInRow(e,t,n){if(!this.worksheet.getMergeData())return!1;for(let r=t;r<=n;r++){let{isMerged:t,isMergedMainCell:n}=this.worksheet.getCellInfoInMergeData(e,r);if(!t&&!n)return!0}return!1}expandRangeByMerge(e,t){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e,o=this._worksheetData.mergeData;if(!o)return{startRow:n,startColumn:r,endRow:i,endColumn:a};let s=!0,c=new Sa,l=0,u=null;for(;s;){s=!1;for(let e=0;e<o.length;e++){let{startRow:t,startColumn:d,endRow:f,endColumn:p}=o[e];if(c.getValue(t,d))continue;let m={startColumn:r,startRow:n,endColumn:a,endRow:i},h={startColumn:d,startRow:t,endColumn:p,endRow:f};Po(m,h)&&(n=Math.min(n,t),r=Math.min(r,d),i=Math.max(i,f),a=Math.max(a,p),c.setValue(t,d,!0),s=!0,l++,u=h)}}return t&&l===1&&G.contains(u,e)?{startRow:u.startRow,startColumn:u.startColumn,endRow:u.startRow,endColumn:u.startColumn}:{startRow:n,startColumn:r,endRow:i,endColumn:a}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(e,t){return this.worksheet.getCellInfoInMergeData(e,t)}getNoMergeCellPositionByIndex(e,t,n=!0){return this.getNoMergeCellWithCoordByIndex(e,t,n)}getNoMergeCellWithCoordByIndex(e,t,n=!0){let{rowHeightAccumulation:r,columnWidthAccumulation:i,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:o}=this,{startY:s,endY:c,startX:l,endX:u}=vd(e,t,r,i);return n&&(s+=o,c+=o,l+=a,u+=a),{startY:s,endY:c,startX:l,endX:u}}getNoMergeCellPositionByIndexWithNoHeader(e,t){let{rowHeightAccumulation:n,columnWidthAccumulation:r}=this,{startY:i,endY:a,startX:o,endX:s}=vd(e,t,n,r);return{startY:i,endY:a,startX:o,endX:s}}getRowIndexByOffsetY(e,t,n,r){let{rowHeightAccumulation:i}=this;e=bd(e,t,n,this.columnHeaderHeightAndMarginTop);let a=bi(i,e,r==null?void 0:r.firstMatch);if(r!=null&&r.closeFirst){var o;Math.abs(i[a]-e)<Math.abs(e-((o=i[a-1])==null?0:o))&&(a+=1)}return a}getColumnIndexByOffsetX(e,t,n,r){let i=yd(e,t,n,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this,o=bi(a,i,r==null?void 0:r.firstMatch);if(r!=null&&r.closeFirst){var s;Math.abs(a[o]-i)<Math.abs(i-((s=a[o-1])==null?0:s))&&(o+=1)}return o}getCellIndexByOffset(e,t,n,r,i,a){return{row:this.getRowIndexByOffsetY(t,r,i,a),column:this.getColumnIndexByOffsetX(e,n,i,a)}}getCellByOffset(e,t,n,r,i){var a;let o=(a=this)==null?void 0:a.getCellIndexByOffset(e,t,n,r,i,{firstMatch:!0});return o?this.worksheet.getCellInfoInMergeData(o.row,o.column):null}getCellWithCoordByIndex(e,t,n=!0){var r;let{rowHeightAccumulation:i,columnWidthAccumulation:a,rowHeaderWidthAndMarginLeft:o,columnHeaderHeightAndMarginTop:s}=this,c=vd(e,t,i,a,(r=this.worksheet)==null?void 0:r.getCellInfoInMergeData(e,t)),{isMerged:l,isMergedMainCell:u}=c,{startY:d,endY:f,startX:p,endX:m,mergeInfo:h}=c,g=o,_=s;return n===!1&&(g=0,_=0),d+=_,f+=_,p+=g,m+=g,h.startY+=_,h.endY+=_,h.startX+=g,h.endX+=g,{actualRow:e,actualColumn:t,startX:p,startY:d,endX:m,endY:f,isMerged:l,isMergedMainCell:u,mergeInfo:h}}getCellWithCoordByOffset(e,t,n,r,i,a){let{row:o,column:s}=this.getCellIndexByOffset(e,t,n,r,i,a);return this.getCellWithCoordByIndex(o,s)}getOffsetByColumn(e){let{columnWidthAccumulation:t,rowHeaderWidthAndMarginLeft:n}=this,r=t.length-1,i=t[e];return i==null?e<0?n:t[r]+n:i+n}getOffsetByRow(e){let{rowHeightAccumulation:t,columnHeaderHeightAndMarginTop:n}=this,r=t.length-1,i=t[e];return i==null?e<0?n:t[r]+n:i+n}getOffsetRelativeToRowCol(e,t){let n=bi(this.columnWidthAccumulation,e),r=0;r=n===0?e:e-this._columnWidthAccumulation[n-1];let i=bi(this.rowHeightAccumulation,t),a=0;return a=i===0?t:t-this._rowHeightAccumulation[i-1],{row:i,column:n,columnOffset:r,rowOffset:a}}_updateConfigAndGetDocumentModel(e,t,n,r){var i,a,o,s,c;if(!r||!((i=e.body)!=null&&i.dataStream))return;e.documentStyle||(e.documentStyle={}),e.documentStyle.marginTop=(a=n.t)==null?0:a,e.documentStyle.marginBottom=(o=n.b)==null?2:o,e.documentStyle.marginLeft=(s=n.l)==null?2:s,e.documentStyle.marginRight=(c=n.r)==null?2:c,e.documentStyle.pageSize={width:1/0,height:1/0},e.documentStyle.renderConfig={...e.documentStyle.renderConfig,...r};let l=e.body.paragraphs||[];for(let e of l)e.paragraphStyle||(e.paragraphStyle={}),e.paragraphStyle.horizontalAlign=t;return new _c(e)}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,this.worksheet=null}};hd=z([R(2,n(zu)),R(3,Zr),R(4,Yr),R(5,n(a))],hd);function gd(e,t,n,r){let i=e-1,a=t-1,o=n[i]||0,s=n[e];s==null&&(s=n[n.length-1]);let c=r[a]||0,l=r[t];return l==null&&(l=r[r.length-1]),{startY:o,endY:s,startX:c,endX:l}}function _d(e,t,n,r){return gd(e,t,n,r)}function vd(e,t,n,r,i){e=D.clamp(e,0,n.length-1),t=D.clamp(t,0,r.length-1);let{startY:a,endY:o,startX:s,endX:c}=gd(e,t,n,r);if(!i)return{startY:a,endY:o,startX:s,endX:c,isMerged:!1,isMergedMainCell:!1,actualRow:e,actualColumn:t,mergeInfo:{startY:a,endY:o,startX:s,endX:c,startRow:e,startColumn:t,endRow:e,endColumn:t}};let{isMerged:l,isMergedMainCell:u,startRow:d,startColumn:f,endRow:p,endColumn:m}=i,h={startRow:d,startColumn:f,endRow:p,endColumn:m,startY:a,endY:o,startX:s,endX:c},g=n.length-1,_=r.length-1;if(l&&d!==-1&&f!==-1){let e=n[d-1]||0,t=n[p]||n[g],i=r[f-1]||0,a=r[m]||r[_];h={...h,startY:e,endY:t,startX:i,endX:a}}else if(!l&&p!==-1&&m!==-1){let e=n[p]||n[g],t=r[m]||r[_];h={...h,startY:a,endY:e,startX:s,endX:t}}return{isMerged:l,isMergedMainCell:u,actualRow:e,actualColumn:t,startY:a,endY:o,startX:s,endX:c,mergeInfo:h}}function yd(e,t,n,r){let{x:i}=n;return e/t+i-r}function bd(e,t,n,r){let{y:i}=n;return e=e/t+i-r,e}const xd=[`script`,`style`,`meta`,`comment`,`link`];let Sd=function(e){return e[e.INFO=0]=`INFO`,e[e.STOP=1]=`STOP`,e[e.WARNING=2]=`WARNING`,e}({}),Cd=function(e){return 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}({}),wd=function(e){return 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}({}),Td=function(e){return e[e.TEXT=0]=`TEXT`,e[e.ARROW=1]=`ARROW`,e[e.CUSTOM=2]=`CUSTOM`,e}({}),Ed=function(e){return e.VALID=`valid`,e.INVALID=`invalid`,e.VALIDATING=`validating`,e}({}),Dd=function(e){return 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}({}),Od=class extends E{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){let e=e=>{e.businesses.forEach(t=>{switch(t){case x.UNRECOGNIZED:case x.UNIVER_UNKNOWN:case x.UNIVER_SLIDE:case x.UNIVER_DOC:this._univerInstanceService.getAllUnitsForType(x.UNIVER_DOC).forEach(t=>{let n=(t.getSnapshot().resources||[]).find(t=>t.name===e.pluginName);if(n)try{let r=e.parseJson(n.data);e.onLoad(t.getUnitId(),r)}catch{console.error(`Load Document{${t.getUnitId()}} Resources{${e.pluginName}} Data Error.`)}});break;case x.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(x.UNIVER_SHEET).forEach(t=>{let n=(t.getSnapshot().resources||[]).find(t=>t.name===e.pluginName);if(n)try{let r=e.parseJson(n.data);e.onLoad(t.getUnitId(),r)}catch{console.error(`Load Workbook{${t.getUnitId()}} Resources{${e.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(t=>e(t)),this.disposeWithMe(this._resourceManagerService.register$.subscribe(t=>e(t))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(x.UNIVER_SHEET).subscribe(e=>{this._resourceManagerService.loadResources(e.getUnitId(),e.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(x.UNIVER_DOC).subscribe(e=>{yt(e.getUnitId())||this._resourceManagerService.loadResources(e.getUnitId(),e.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(x.UNIVER_SHEET).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),x.UNIVER_SHEET)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(x.UNIVER_DOC).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),x.UNIVER_DOC)}))}saveUnit(e){let t=this._univerInstanceService.getUnit(e);if(!t)return null;let n=this._resourceManagerService.getResources(e,t.type),r=D.deepClone(t.getSnapshot());return r.resources=n,r}};Od=z([R(0,t(ll)),R(1,t(Mu))],Od);var kd=class{get _univerInstanceService(){return this._injector.get(Mu)}get _pluginService(){return this._injector.get(Xu)}constructor(e={},t){C(this,`_startedTypes`,new Set),C(this,`_injector`,void 0),C(this,`_disposingCallbacks`,new un);let n=this._injector=Ad(t,e==null?void 0:e.override),{theme:r,darkMode:i,locale:a,locales:o,logLevel:s,logCommandExecution:c}=e;r&&this._injector.get($u).setTheme(r),i&&this._injector.get($u).setDarkMode(i),o&&this._injector.get(zu).load(o),a&&this._injector.get(zu).setLocale(a),s&&this._injector.get(L).setLogLevel(s),c!==void 0&&this._injector.get(Yr).setConfig(ni,c),this._init(n)}__getInjector(){return this._injector}onDispose(e){let t=this._disposingCallbacks.add(T(e));return T(()=>t.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(e){this._injector.get(zu).setLocale(e)}createUnit(e,t){return this._univerInstanceService.createUnit(e,t)}createUniverSheet(e){return this._injector.get(L).warn(`[Univer]`,`Univer.createUniverSheet is deprecated, use createUnit instead`),this._univerInstanceService.createUnit(x.UNIVER_SHEET,e)}createUniverDoc(e){return this._injector.get(L).warn(`[Univer]`,`Univer.createUniverDoc is deprecated, use createUnit instead`),this._univerInstanceService.createUnit(x.UNIVER_DOC,e)}createUniverSlide(e){return this._injector.get(L).warn(`[Univer]`,`Univer.createUniverSlide is deprecated, use createUnit instead`),this._univerInstanceService.createUnit(x.UNIVER_SLIDE,e)}_init(e){this._univerInstanceService.registerCtorForType(x.UNIVER_SHEET,Au),this._univerInstanceService.registerCtorForType(x.UNIVER_DOC,_c),this._univerInstanceService.registerCtorForType(x.UNIVER_SLIDE,ju);let t=e.get(Mu);t.__setCreateHandler((n,r,i,a)=>{if(!this._startedTypes.has(n)){this._pluginService.startPluginsForType(n),this._startedTypes.add(n);let o=e.createInstance(i,r);return t.__addUnit(o,a),this._tryProgressToReady(),o}let o=e.createInstance(i,r);return t.__addUnit(o,a),o})}_tryProgressToReady(){this._injector.get(Iu).stage<$.Ready&&(this._injector.get(Iu).stage=$.Ready)}registerPlugin(e,t){this._pluginService.registerPlugin(e,t)}registerPlugins(e){e.forEach(e=>{let[t,n]=e;this._pluginService.registerPlugin(t,n)})}};function Ad(e,t){let n=Gu([[Pl],[zu],[$u],[Iu],[Xu],[pl],[Mu,{useClass:Nu}],[Uu,{useClass:Wu}],[L,{useClass:ei,lazy:!0}],[ii,{useClass:si}],[td,{useClass:sd,lazy:!0}],[Yr,{useClass:Xr}],[Zr,{useClass:Qr}],[ll,{useClass:Qu,lazy:!0}],[Zu,{useClass:Od,lazy:!0}],[hl,{useClass:ml}],[Vu,{useClass:Bu,lazy:!0}]],t),r=e?e.createChild(n):new i(n);return St(r,[[pl],[Zu]]),r}et();export{Wo as ABCToNumber,_t as AUTO_HEIGHT_FOR_MERGED_CELLS,V as AbsoluteRefType,Ys as ActionIterator,Ar as AlignTypeH,jr as AlignTypeV,Fr as ArrangeTypeEnum,Hn as ArrowsAndMarkersShapes,It as AsyncInterceptorManager,e as AsyncLock,ml as AuthzIoLocalService,Dn as AutoFillSeries,Wr as BORDER_KEYS,Ur as BORDER_STYLE_KEYS,er as BaselineOffset,Vn as BasicShapes,cr as BlockType,A as BooleanNumber,k as BorderStyleTypes,On as BorderType,Z as BuildTextUtils,ar as BulletAlignment,Di as COLORS,Hr as COLOR_STYLE_KEYS,ni as COMMAND_LOG_EXECUTION_CONFIG_KEY,Tt as CanceledError,ea as CellModeEnum,tr as CellValueType,Oi as ColorKit,kn as ColorType,fr as ColumnSeparatorType,si as CommandService,ri as CommandType,An as CommonHideTypes,Xr as ConfigService,Qr as ContextService,jn as CopyPasteType,wt as CustomCommandExecutionError,sr as CustomDecorationType,or as CustomRangeType,go as DEFAULT_CELL,hc as DEFAULT_DOC,al as DEFAULT_DOCUMENT_SUB_COMPONENT_ID,ht as DEFAULT_EMPTY_DOCUMENT_VALUE,ia as DEFAULT_NUMBER_FORMAT,mo as DEFAULT_RANGE,po as DEFAULT_RANGE_ARRAY,ho as DEFAULT_SELECTION,_o as DEFAULT_SLIDE,W as DEFAULT_STYLES,na as DEFAULT_TEXT_FORMAT,ra as DEFAULT_TEXT_FORMAT_EXCEL,pu as DEFAULT_WORKSHEET_COLUMN_COUNT,fu as DEFAULT_WORKSHEET_COLUMN_COUNT_KEY,xu as DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT,bu as DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY,_u as DEFAULT_WORKSHEET_COLUMN_WIDTH,gu as DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY,du as DEFAULT_WORKSHEET_ROW_COUNT,uu as DEFAULT_WORKSHEET_ROW_COUNT_KEY,hu as DEFAULT_WORKSHEET_ROW_HEIGHT,mu as DEFAULT_WORKSHEET_ROW_HEIGHT_KEY,yu as DEFAULT_WORKSHEET_ROW_TITLE_WIDTH,vu as DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY,mt as DOCS_COMMENT_EDITOR_UNIT_ID_KEY,ft as DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,dt as DOCS_NORMAL_EDITOR_UNIT_ID_KEY,pt as DOCS_ZEN_EDITOR_UNIT_ID_KEY,So as DOC_DRAWING_PRINTING_COMPONENT_KEY,Qi as DOC_RANGE_TYPE,vr as DashStyleType,lc as DataStreamTreeNodeType,X as DataStreamTreeTokenType,Sd as DataValidationErrorStyle,Cd as DataValidationImeMode,wd as DataValidationOperator,Td as DataValidationRenderMode,Ed as DataValidationStatus,Dd as DataValidationType,Mn as DeleteDirection,Yu as DependentOn,ei as DesktopLogService,Nn as DeveloperMetadataVisibility,Pn as Dimension,Fn as Direction,E as Disposable,un as DisposableCollection,rr as DocStyleType,_c as DocumentDataModel,lr as DocumentFlavor,Ir as DrawingTypeEnum,Cl as EDITOR_ACTIVATED,Co as EXTENSION_NAMES,Pl as ErrorService,ol as EventState,sl as EventSubject,Ol as FOCUSING_COMMENT_EDITOR,jl as FOCUSING_COMMON_DRAWINGS,bl as FOCUSING_DOC,Sl as FOCUSING_EDITOR_BUT_HIDDEN,wl as FOCUSING_EDITOR_INPUT_FORMULA,Dl as FOCUSING_EDITOR_STANDALONE,Tl as FOCUSING_FX_BAR_EDITOR,kl as FOCUSING_PANEL_EDITOR,Ml as FOCUSING_SHAPE_TEXT_EDITOR,yl as FOCUSING_SHEET,xl as FOCUSING_SLIDE,vl as FOCUSING_UNIT,El as FOCUSING_UNIVER_EDITOR,Al as FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE,Nl as FORMULA_EDITOR_ACTIVATED,ir as FollowNumberWithType,Qn as FontItalic,Er as FontStyleType,$n as FontWeight,ur as GridType,Yn as HorizontalAlign,hl as IAuthzIoService,ii as ICommandService,Yr as IConfigService,gl as IConfirmService,Zr as IContextService,Ll as IImageIoService,Ru as ILocalStorageService,L as ILogService,Vu as IMentionIOService,Uu as IPermissionService,Zu as IResourceLoaderService,ll as IResourceManagerService,gt as IS_ROW_STYLE_PRECEDE_COLUMN_STYLE,Rl as IURLImageService,td as IUndoRedoService,Mu as IUniverInstanceService,cd as ImageCacheMap,Fl as ImageSourceType,Il as ImageUploadStatusType,t as Inject,r as InjectSelf,i as Injector,At as InterceptorEffectEnum,Nt as InterceptorManager,Ln as InterpolationPointType,S as JSON1,cc as JSONX,co as LRUHelper,so as LRUMap,Iu as LifecycleService,$ as LifecycleStages,Fu as LifecycleUnreachableError,M as ListGlyphType,sd as LocalUndoRedoService,zu as LocaleService,Rn as LocaleType,$r as LogLevel,o as LookUp,fo as MAX_COLUMN_COUNT,uo as MAX_ROW_COUNT,Si as MOVE_BUFFER_VALUE,s as Many,Zt as MemoryCursor,Bu as MentionIOLocalService,zn as MentionType,yo as NAMED_STYLE_MAP,bo as NAMED_STYLE_SPACE_MAP,N as NamedStyleType,oi as NilCommand,kr as NumberUnitType,Sa as ObjectMatrix,Dr as ObjectRelativeFromH,Or as ObjectRelativeFromV,c as Optional,Un as OtherShapes,Kr as PADDING_KEYS,wo as PAGE_SIZE,Pr as PAPER_TYPES,xs as PRESET_LIST_TYPE,xo as PRINT_CHART_COMPONENT_KEY,Rr as PageElementType,Nr as PageOrientType,Lr as PageType,P as PaperType,mr as ParagraphElementType,nl as ParagraphStyleBuilder,tl as ParagraphStyleValue,Wu as PermissionService,Hu as PermissionStatus,qu as Plugin,Xu as PluginService,gr as PositionedObjectLayoutType,q as PresetListType,Bn as ProtectionType,l as Quantity,K as QuickListType,ws as QuickListTypeMap,Zi as RANGE_DIRECTION,B as RANGE_TYPE,Ge as RBush,fn as RCDisposable,Ei as RGBA_PAREN,Ti as RGB_PAREN,Ci as ROTATE_BUFFER_VALUE,dd as RTree,Eo as Range,G as Rectangle,u as RediError,od as RedoCommand,rd as RedoCommandId,Ho as RefAlias,nn as Registry,rn as RegistryAsMap,Gn as RelativeDate,zr as RelativeSlideLink,Qu as ResourceManagerService,il as RichTextBuilder,rl as RichTextValue,dn as RxDisposable,vo as SHEET_EDITOR_UNITS,qr as STYLE_KEYS,dr as SectionType,d as Self,hd as SheetSkeleton,Kn as SheetTypes,wu as SheetViewModel,md as Skeleton,f as SkipSelf,Ps as SliceBodyType,ju as SlideDataModel,_r as SpacingRule,Wn as SpecialShapes,Hl as Styles,Vr as TEXT_DECORATION_KEYS,Gr as TEXT_ROTATION_KEYS,ta as THEME_COLORS,yr as TabStopAlignment,xr as TableAlignmentType,Sr as TableLayoutType,wr as TableRowHeightRule,br as TableSizeType,Cr as TableTextWrapType,_l as TestConfirmService,Jn as TextDecoration,el as TextDecorationBuilder,qn as TextDirection,pr as TextDirectionType,$c as TextStyleBuilder,Qc as TextStyleValue,Y as TextX,I as TextXActionType,j as ThemeColorType,nr as ThemeColors,$u as ThemeService,D as Tools,ad as UndoCommand,id as UndoCommandId,pn as UnitModel,kd as Univer,Nu as UniverInstanceService,x as UniverInstanceType,F as UpdateDocsAttributeType,pl as UserManagerService,Xn as VerticalAlign,Tr as VerticalAlignmentType,p as WithNew,Au as Workbook,Eu as Worksheet,Zn as WrapStrategy,hr as WrapTextType,Xl as addLinkToDocumentModel,gi as afterInitApply,mi as afterTime,fd as awaitTime,yi as binSearchFirstGreaterThanTarget,vi as binarySearchArray,pi as bufferDebounceTime,Ia as cellToRange,Mr as characterSpacingControlType,Va as checkForSubstrings,wi as checkIfMove,Ua as checkParagraphHasBullet,Wa as checkParagraphHasIndent,Ga as checkParagraphHasIndentByStyle,nu as cloneCellData,iu as cloneCellDataMatrix,ru as cloneCellDataWithSpanAndDisplay,Q as cloneValue,su as cloneWorksheetData,xi as codeToBlob,lo as columnLabelToNumber,qs as composeBody,Mt as composeInterceptors,wn as composeStyles,_a as concatMatrixArray,Ca as convertCellToRange,hi as convertObservableToBehaviorSubject,La as covertCellValue,Ra as covertCellValues,Pt as createAsyncInterceptorKey,dl as createDefaultUser,ql as createDocumentModelWithStyle,m as createIdentifier,jt as createInterceptorKey,vt as createInternalEditorID,En as createREGEXFromWildChar,Uo as createRowColIter,ud as customNameCharacterCheck,Ie as dayjs,se as debounce,nt as dedupe,rt as dedupeBy,za as deepCompare,pd as delayAnimationFrame,qa as deleteContent,Du as extractPureTextFromCell,g as forwardRef,di as fromCallback,cl as fromEventSubject,Xa as generateIntervalsByPoints,O as generateRandomId,ce as get,pa as getArrayLength,Bs as getBodySlice,Na as getBorderStyleType,gd as getCellCoordByIndexSimple,$i as getCellInfoInMergeData,_d as getCellPositionByIndexSimple,qi as getCellValueType,vd as getCellWithCoordByIndexCore,Oa as getColorStyle,zs as getCustomBlockSlice,Us as getCustomDecorationSlice,Hs as getCustomRangeSlice,Pa as getDocsUpdateBody,Ql as getEmptyCell,Po as getIntersectRange,da as getNumfmtParseValueFilter,Ou as getOriginCellValue,Ls as getParagraphsSlice,fc as getPlainText,In as getReverseDirection,Rs as getSectionBreakSlice,Is as getTableSlice,Fs as getTextRunSlice,yd as getTransformOffsetX,bd as getTransformOffsetY,ku as getWorksheetUID,ot as groupBy,ja as handleStyleToString,Ya as hashAlgorithm,Ha as horizontalLineSegmentsSubtraction,ha as insertMatrixArray,Ka as insertTextToContent,Jt as invertColorByHSL,Xt as invertColorByMatrix,_ as isAsyncDependencyItem,ee as isAsyncHook,Wi as isBlackColor,lt as isBooleanString,Da as isCellCoverable,Yi as isCellV,te as isClassDependencyItem,bt as isCommentEditorID,ne as isCtor,oa as isDefaultFormat,re as isDisposable,Ea as isEmptyCell,ie as isFactoryDependencyItem,Aa as isFormulaId,ka as isFormulaString,Ki as isICellData,yt as isInternalEditorID,Tn as isNodeEnv,Zl as isNotNullOrUndefined,Ji as isNullCell,$t as isNumeric,sa as isPatternEqualWithoutDecimal,Ul as isRangesEqual,Ja as isRealNum,en as isSafeNumeric,Ba as isSameStyleTextRun,aa as isTextFormat,Wl as isUnitRangesEqual,Fa as isValidRange,ae as isValueDependencyItem,Gi as isWhiteColor,st as makeArray,Ta as makeCellRangeToRangeData,wa as makeCellToSelection,uc as makeCustomRangeStream,fa as mapObjectMatrix,le as merge,Za as mergeIntervals,Qa as mergeLocales,Gu as mergeOverrideWithDependencies,cn as mergeSets,ue as mergeWith,Su as mergeWorksheetSnapshotWithDefault,Qt as mixinClass,ya as moveMatrixArray,Do as moveRangeByOffset,ld as nameCharacterCheck,Vs as normalizeBody,Zo as normalizeTextRuns,Go as numberToABC,qo as numberToListABC,Fe as numfmt,Vo as queryObjectMatrix,xt as registerDependencies,tt as remove,Ko as repeatStringNumTimes,Yc as replaceInDocumentBody,an as requestImmediateMacroTask,bn as resolveWithBasePath,at as rotate,bi as searchArray,_i as searchInOrderedArray,Xi as selectionToArray,sn as sequence,on as sequenceAsync,li as sequenceExecute,ui as sequenceExecuteAsync,de as set,oe as setDependencies,Ct as shallowEqual,xd as skipParseTagNames,va as sliceMatrixArray,Jo as sortRules,Yo as sortRulesByDesc,Xo as sortRulesFactory,ga as spliceArray,ko as splitIntoGrid,fi as takeAfter,qe as textDiff,Et as throttle,T as toDisposable,St as touchDependencies,Xs as updateAttributeByDelete,Zs as updateAttributeByInsert,tn as willLoseNumericPrecision};
|
|
8
|
+
`,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(t){return new e(t==null?e.newEmptyData():t)}constructor(e){super(e),C(this,`_doc`,void 0),this._doc=new _c(e)}insertText(e,t,n){var r,i;let a=((r=(i=this._data.body)==null?void 0:i.dataStream.length)==null?2:r)-2,o,s;if(typeof e==`string`?o=e:(a=Math.min(e,a),o=t),s=typeof t==`object`?t instanceof $c?t.build():t:n instanceof $c?n.build():n,!o)return this;let c={dataStream:o,textRuns:s?[{ts:s,st:a,ed:a+o.length}]:[]},l=Z.selection.replace({doc:this._doc,selection:{startOffset:a,endOffset:a,collapsed:!0},body:c});if(!l)throw Error(`Insert text failed, please check.`);return Y.apply(this._doc.getBody(),l.serialize()),this}insertRichText(e,t){var n,r;let i=((n=(r=this._data.body)==null?void 0:r.dataStream.length)==null?2:n)-2,a;typeof e==`object`?a=e instanceof rl?e.getData():e:(i=Math.min(e,i),a=t instanceof rl?t.getData():t);let o=Z.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:a.body});if(!o)throw Error(`Insert text failed, please check.`);return Y.apply(this._doc.getBody(),o.serialize()),this}delete(e,t){if(t!==void 0){if(!t)return this;let n=Z.selection.delete([{startOffset:e,endOffset:e+t,collapsed:!0}],this._data.body);Y.apply(this._doc.getBody(),n)}return this}setStyle(e,t,n){let r={dataStream:``,textRuns:[{ts:n instanceof $c?n.build():n,st:0,ed:t-e}]},i=Z.selection.retain([{startOffset:e,endOffset:t,collapsed:!0}],r);return Y.apply(this._doc.getBody(),i),this}setLink(e,t,n){let r=Z.customRange.add({rangeType:or.HYPERLINK,rangeId:O(),properties:{url:n},ranges:[{startOffset:e,endOffset:t,collapsed:!1}],body:this._data.body});if(!r)throw Error(`Insert text failed, please check.`);return Y.apply(this._doc.getBody(),r.serialize()),this}cancelLink(e,t){if(typeof e==`string`){let t=Z.customRange.delete({rangeId:e,documentDataModel:this._doc});if(!t)throw Error(`Insert text failed, please check.`);Y.apply(this._doc.getBody(),t.serialize())}else this.slice(e,t).getLinks().forEach(e=>{let t=Z.customRange.delete({rangeId:e.rangeId,documentDataModel:this._doc});if(!t)throw Error(`Insert text failed, please check.`);Y.apply(this._doc.getBody(),t.serialize())});return this}updateLink(e,t){var n;let r=(n=this._data.body)==null||(n=n.customRanges)==null?void 0:n.find(t=>t.rangeId===e);if(!r)throw Error(`Link not found`);return r.properties.url=t,this}insertParagraph(e,t){let n,r;if(typeof e==`object`){var i,a;n={dataStream:`\r`,paragraphs:[{startIndex:0,paragraphStyle:e.build()}]},r=((i=(a=this._data.body)==null?void 0:a.dataStream.length)==null?2:i)-2}else r=e,n={dataStream:`\r`,paragraphs:[{startIndex:0,paragraphStyle:t==null?void 0:t.build()}]};return this.insertRichText(r,rl.create({body:n,id:`d`,documentStyle:{}})),this}insertLink(t,n,r){let i=``,a=``;typeof t==`string`?(i=t,a=n):(i=n,a=r);let o=e.createByBody({dataStream:i,customRanges:[{rangeType:or.HYPERLINK,rangeId:O(),properties:{url:a},startIndex:0,endIndex:i.length-1}]});return typeof t==`number`?this.insertRichText(t,o):this.insertRichText(o)}};const al=`__default_document_sub_component_id20231101__`;var ol=class{constructor(){C(this,`skipNextObservers`,!1),C(this,`lastReturnValue`,void 0),C(this,`isStopPropagation`,!1)}stopPropagation(){this.isStopPropagation=!0}},sl=class extends y{constructor(...e){super(...e),C(this,`_sortedObservers`,[])}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(e){let t;t=typeof e==`function`?{next:([t,n])=>e(t,n)}:e;let n=super.subscribe(t);return this._sortedObservers.push(t),this._sortedObservers.sort((e,t)=>{var n,r;return((n=e.priority)==null?0:n)-((r=t.priority)==null?0:r)}),n.add(()=>this._sortedObservers=this._sortedObservers.filter(e=>e!==t)),n}clearObservers(){this._sortedObservers.forEach(e=>{var t;return(t=e.complete)==null?void 0:t.call(e)}),this._sortedObservers.length=0}emitEvent(e){if(!this.closed){let n=new ol;n.lastReturnValue=e;for(let r of this._sortedObservers){var t;if(n.lastReturnValue=(t=r.next)==null?void 0:t.call(r,[e,n]),n.skipNextObservers)return{handled:!0,lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}throw Error(`[EventSubject]: cannot emit event on a closed subject.`)}};function cl(e){return new fe(t=>{let n=e.subscribeEvent(e=>{t.next(e)});return()=>n.unsubscribe()})}const ll=m(`core.resource-manager.service`),ul={[b.Editor]:`Editor`,[b.Owner]:`Owner`,[b.Reader]:`Reader`,[b.UNRECOGNIZED]:`UNRECOGNIZED`},dl=e=>e?{userID:`${ul[e]}_${O(8)}`,name:ul[e],avatar:``}:{userID:``,name:``,avatar:``,anonymous:!0,canBindAnonymous:!1},fl=(e,t)=>e.startsWith(ul[t]);var pl=class extends E{constructor(...e){super(...e),C(this,`_model`,new Map),C(this,`_userChange$`,new y),C(this,`userChange$`,this._userChange$.asObservable()),C(this,`_currentUser$`,new v(dl())),C(this,`currentUser$`,this._currentUser$.asObservable())}dispose(){super.dispose(),this._model.clear(),this._userChange$.complete(),this._currentUser$.complete()}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(e){this.addUser(e),this._currentUser$.next(e)}addUser(e){this._model.set(e.userID,e),this._userChange$.next({type:`add`,user:e})}getUser(e,t){let n=this._model.get(e);if(n)return n;t&&t()}delete(e){let t=this.getUser(e);this._model.delete(e),t&&this._userChange$.next({type:`delete`,user:t})}clear(){this._model.clear(),this._userChange$.next({type:`clear`})}list(){return Array.from(this._model.values())}};let ml=class{constructor(e,t){this._resourceManagerService=e,this._userManagerService=t,C(this,`_permissionMap`,new Map([])),C(this,`_permissionOverrides`,new Map),this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){let e=this._userManagerService.getCurrentUser();e&&e.userID||this._userManagerService.setCurrentUser(dl(b.Owner))}_getRole(e){let t=this._userManagerService.getCurrentUser();return t?fl(t.userID,e):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:e=>{let t=[...this._permissionMap.keys()].reduce((e,t)=>(e[t]=this._permissionMap.get(t),e),{});return JSON.stringify(t)},parseJson:e=>JSON.parse(e),pluginName:`SHEET_AuthzIoMockService_PLUGIN`,businesses:[Oe.UNIVER_SHEET,Oe.UNIVER_DOC,Oe.UNIVER_SLIDE],onLoad:(e,t)=>{for(let e in t)this._permissionMap.set(e,t[e])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(e){let t=O(8),{objectType:n,selectRangeObject:r,worksheetObject:i}=e,a=r||i,o={objectType:n,unitID:(a==null?void 0:a.unitID)||``,name:(a==null?void 0:a.name)||``,strategies:[{action:6,role:b.Owner},{action:16,role:b.Owner},{action:17,role:b.Owner},{action:18,role:b.Owner},{action:19,role:b.Owner},{action:33,role:b.Owner},{action:34,role:b.Owner},{action:35,role:b.Owner},{action:36,role:b.Owner},{action:37,role:b.Owner},{action:38,role:b.Owner},{action:39,role:b.Owner},{action:40,role:b.Owner}],selectRangeObject:r};return this._permissionMap.set(t,o),t}async allowed(e){let{objectID:t,actions:n}=e,r=this._permissionMap.get(t);return r?n.map(e=>{let n=`${t}:${e}`;if(this._permissionOverrides.has(n))return{action:e,allowed:this._permissionOverrides.get(n)};let i=r.strategies.find(t=>t.action===e);return i?{action:e,allowed:this._getRole(i.role)}:{action:e,allowed:this._getRole(b.Owner)||this._getRole(b.Editor)}}):n.map(e=>({action:e,allowed:this._getRole(b.Owner)||this._getRole(b.Editor)}))}async batchAllowed(e){let t=await Promise.all(e.map(e=>this.allowed(e)));return e.map((e,n)=>({unitID:e.unitID,objectID:e.objectID,actions:t[n]}))}async list(e){let t=[],n=[{action:6,role:b.Owner},{action:16,role:b.Owner},{action:17,role:b.Owner},{action:18,role:b.Owner},{action:19,role:b.Owner},{action:33,role:b.Owner},{action:34,role:b.Owner},{action:35,role:b.Owner},{action:36,role:b.Owner},{action:37,role:b.Owner},{action:38,role:b.Owner},{action:39,role:b.Owner},{action:40,role:b.Owner}];return e.objectIDs.forEach(r=>{let i=this._permissionMap.get(r),a=(i==null?void 0:i.strategies)||n,o={objectID:r,unitID:e.unitID,objectType:(i==null?void 0:i.objectType)||3,name:(i==null?void 0:i.name)||``,shareOn:!1,shareRole:b.Owner,shareScope:-1,scope:{read:De.AllCollaborator,edit:De.AllCollaborator},creator:dl(b.Owner),strategies:a.map(e=>({action:e.action,role:e.role})),actions:e.actions.map(e=>{let t=`${r}:${e}`;if(this._permissionOverrides.has(t))return{action:e,allowed:this._permissionOverrides.get(t)};let n=a.find(t=>t.action===e);return n?{action:e,allowed:this._getRole(n.role)}:{action:e,allowed:this._getRole(b.Owner)||this._getRole(b.Editor)}})};t.push(o)}),t}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(e){let{objectID:t,strategies:n}=e,r=this._permissionMap.get(t);r&&n&&(r.strategies=n.map(e=>({action:e.action,role:e.role})),this._permissionMap.set(t,r),n.forEach(e=>{e.role===b.Reader?this.setPermissionOverride(t,e.action,!1):(e.role===b.Owner||e.role===b.Editor)&&this.clearPermissionOverride(t,e.action)}))}setPermissionOverride(e,t,n){let r=`${e}:${t}`;this._permissionOverrides.set(r,n)}clearPermissionOverride(e,t){let n=`${e}:${t}`;this._permissionOverrides.delete(n)}clearAllOverrides(e){let t=[];this._permissionOverrides.forEach((n,r)=>{r.startsWith(`${e}:`)&&t.push(r)}),t.forEach(e=>this._permissionOverrides.delete(e))}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(e){}};ml=z([R(0,ll),R(1,t(pl))],ml);const hl=m(`IAuthzIoIoService`),gl=m(`univer.confirm-service`);var _l=class{constructor(){C(this,`confirmOptions$`,new y)}dispose(){this.confirmOptions$.complete()}open(e){throw Error(`This is not implemented in the test service!`)}confirm(e){return Promise.resolve(!0)}close(e){throw Error(`This is not implemented in the test service!`)}};const vl=`FOCUSING_UNIT`,yl=`FOCUSING_SHEET`,bl=`FOCUSING_DOC`,xl=`FOCUSING_SLIDE`,Sl=`FOCUSING_EDITOR_BUT_HIDDEN`,Cl=`EDITOR_ACTIVATED`,wl=`FOCUSING_EDITOR_INPUT_FORMULA`,Tl=`FOCUSING_FX_BAR_EDITOR`,El=`FOCUSING_UNIVER_EDITOR`,Dl=`FOCUSING_EDITOR_INPUT_FORMULA`,Ol=`FOCUSING_COMMENT_EDITOR`,kl=`FOCUSING_PANEL_EDITOR`,Al=`FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE`,jl=`FOCUSING_COMMON_DRAWINGS`,Ml=`FOCUSING_SHAPE_TEXT_EDITOR`,Nl=`FORMULA_EDITOR_ACTIVATED`;var Pl=class extends E{constructor(...e){super(...e),C(this,`_error$`,new y),C(this,`error$`,this._error$.asObservable())}dispose(){this._error$.complete()}emit(e){this._error$.next({errorKey:e})}};let Fl=function(e){return e.URL=`URL`,e.UUID=`UUID`,e.BASE64=`BASE64`,e}({}),Il=function(e){return e.SUCCUSS=`0`,e.ERROR_EXCEED_SIZE=`1`,e.ERROR_IMAGE_TYPE=`2`,e.ERROR_UPLOAD_COUNT_LIMIT=`3`,e.ERROR_IMAGE=`4`,e}({});const Ll=m(`core.image-io.service`),Rl=m(`core.url-image.service`);var zl=`@univerjs/core`,Bl=`0.20.0`;function Vl(e=``,t=Rn.ZH_CN,n=``){return{id:e,sheetOrder:[],name:n,appVersion:Bl,locale:t,styles:{},sheets:{},resources:[]}}var Hl=class{constructor(e={}){C(this,`_styles`,void 0),C(this,`_cacheMap`,new so(1e5)),this._styles=e,this._generateCacheMap()}each(e){return Object.entries(this._styles).forEach(e),this}search(e,t){return this._cacheMap.has(t)?this._cacheMap.get(t):this._getExistingStyleId(e)||`-1`}get(e){return typeof e==`string`?(e=String(e),this._styles[e]):e}add(e,t){let n=O(6);return this._styles[n]=e,this._cacheMap.set(t,n),n}setValue(e){if(e==null)return;let t=JSON.stringify(e),n=this.search(e,t);return n===`-1`?this.add(e,t):n}addCustomStyle(e,t){t!=null&&(this._styles[e]=t,this._cacheMap.set(JSON.stringify(t),e))}remove(e){let t=this._styles[e];t&&(delete this._styles[e],this._cacheMap.delete(JSON.stringify(t)))}toJSON(){return this._styles}getStyleByCell(e){let t;t=e&&D.isObject(e.s)?e.s:(e==null?void 0:e.s)&&this.get(e.s);let n=e==null?void 0:e.interceptorStyle;return n?{...t,...n}:t}_generateCacheMap(){let{_styles:e,_cacheMap:t}=this;for(let n in e){let r=JSON.stringify(e[n]);t.set(r,n)}}_getExistingStyleId(e){let{_styles:t}=this;for(let n in t)if(D.diffValue(t[n],e))return n;return null}};const Ul=(e,t)=>t.length===e.length&&!e.some(e=>t.some(t=>!G.equals(t,e))),Wl=(e,t)=>t.length===e.length&&e.every((e,n)=>{let r=t[n];return r.unitId===e.unitId&&r.sheetId===e.sheetId&&G.equals(e.range,r.range)}),Gl={t:0,b:2,l:2,r:2},Kl=e=>({sbr:.6,sbo:e,spr:.6,spo:e});function ql(e,t,n={}){let r=e.length,{textRotation:i,paddingData:a,horizontalAlign:o=Yn.UNSPECIFIED,verticalAlign:s=Xn.UNSPECIFIED,wrapStrategy:c=Zn.UNSPECIFIED,cellValueType:l}=n,{t:u,r:d,b:f,l:p}=a||Gl,{vertexAngle:m,centerAngle:h}=tu(i);return new _c({id:`d`,body:{dataStream:`${e}\r
|
|
9
|
+
`,textRuns:[{ts:t,st:0,ed:r}],paragraphs:[{startIndex:r,paragraphStyle:{horizontalAlign:o}}],sectionBreaks:[{startIndex:r+1}]},documentStyle:{pageSize:{width:1/0,height:1/0},marginTop:u,marginBottom:f,marginRight:d,marginLeft:p,renderConfig:{horizontalAlign:o,verticalAlign:s,centerAngle:h,vertexAngle:m,wrapStrategy:c,cellValueType:l}},drawings:{},drawingsOrder:[]})}function Jl(e){if(!e)return{};let{tr:t,td:n,ht:r,vt:i,tb:a,pd:o}=e;return{textRotation:t,textDirection:n,horizontalAlign:r,verticalAlign:i,wrapStrategy:a,paddingData:o}}function Yl(e){if(!e)return{};let{ff:t,fs:n,it:r,bl:i,ul:a,st:o,ol:s,cl:c}=e,l={};return t&&(l.ff=t),n&&(l.fs=n),r&&(l.it=r),i&&(l.bl=i),a&&(l.ul=a),o&&(l.st=o),s&&(l.ol=s),c&&(l.cl=c),l}function Xl(e,t,n){var r;let i=e.getBody();if((r=i.customRanges)!=null&&r.some(e=>e.rangeType===or.HYPERLINK))return;let a=Z.customRange.add({ranges:[{startOffset:0,endOffset:i.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:or.HYPERLINK,body:i,properties:{url:t,refId:n}});a&&Y.apply(i,a.serialize())}function Zl(e){return e!=null}function Ql(){return{p:null,s:null,v:null,t:null,f:null,si:null,ref:null,xf:null}}function $l(e){let t=W.ff,n=W.fs;if(!e){let e=`${n}pt ${t}`;return{fontCache:e,fontString:e,fontSize:n,originFontSize:n,fontFamily:t}}let r=Er.ITALIC;(e.it===0||e.it===void 0)&&(r=Er.NORMAL);let i=Er.BOLD;(e.bl===0||e.bl===void 0)&&(i=Er.NORMAL);let a=n;e.fs&&(a=Math.ceil(e.fs));let o=t;if(e.ff){let n=e.ff;n=n.replace(/"/g,``).replace(/'/g,``),n.indexOf(` `)>-1&&(n=`"${n}"`),n==null&&(n=t),o=n}let{va:s}=e,c=a;if(s===er.SUBSCRIPT||s===er.SUPERSCRIPT){let{sbr:e,spr:t}=eu(o,c);c*=s===er.SUBSCRIPT?e:t}let l=`${r} ${i} ${c}pt ${o}`;return{fontCache:l,fontString:`${l}, "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif `,fontSize:c,originFontSize:a,fontFamily:o}}function eu(e,t){return Kl(t)}function tu(e){let{a:t=0,v:n=A.FALSE}=e||{a:0,v:A.FALSE},r=0,i=t;return n===A.TRUE&&(r=90,i=90),{centerAngle:r,vertexAngle:i}}function Q(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e)){let t=e.length,n=Array(t);for(let r=0;r<t;r++)n[r]=Q(e[r]);return n}let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r];t[i]=Q(e[i])}return t}function nu(e){if(e==null)return e;let t={};return e.p!==void 0&&(t.p=e.p===null?null:Q(e.p)),e.s!==void 0&&(e.s===null||typeof e.s==`string`?t.s=e.s:t.s=Q(e.s)),e.v!==void 0&&(t.v=e.v),e.t!==void 0&&(t.t=e.t),e.f!==void 0&&(t.f=e.f),e.ref!==void 0&&(t.ref=e.ref),e.xf!==void 0&&(t.xf=e.xf),e.si!==void 0&&(t.si=e.si),e.custom!==void 0&&(t.custom=e.custom===null?null:Q(e.custom)),t}function ru(e){if(e==null)return e;let t={};return e.p!==void 0&&(t.p=e.p===null?null:Q(e.p)),e.s!==void 0&&(e.s===null||typeof e.s==`string`?t.s=e.s:t.s=Q(e.s)),e.v!==void 0&&(t.v=e.v),e.t!==void 0&&(t.t=e.t),e.f!==void 0&&(t.f=e.f),e.ref!==void 0&&(t.ref=e.ref),e.xf!==void 0&&(t.xf=e.xf),e.si!==void 0&&(t.si=e.si),e.custom!==void 0&&(t.custom=e.custom===null?null:Q(e.custom)),e.rowSpan!==void 0&&(t.rowSpan=e.rowSpan),e.colSpan!==void 0&&(t.colSpan=e.colSpan),e.displayV!==void 0&&(t.displayV=e.displayV),t}function iu(e){let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r],a=Number(i),o=e[a];if(o===void 0)continue;let s={},c=Object.keys(o);for(let e=0,t=c.length;e<t;e++){let t=c[e],n=Number(t),r=o[n];r!=null&&(s[n]=nu(r))}t[a]=s}return t}function au(e){let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r],a=Number(i),o=e[a];if(o===void 0)continue;let s={};`h`in o&&o.h!==void 0&&(s.h=o.h),`ia`in o&&o.ia!==void 0&&(s.ia=o.ia),`ah`in o&&o.ah!==void 0&&(s.ah=o.ah),`hd`in o&&o.hd!==void 0&&(s.hd=o.hd),`w`in o&&o.w!==void 0&&(s.w=o.w),`s`in o&&o.s!==void 0&&(o.s===null||typeof o.s==`string`?s.s=o.s:s.s=Q(o.s)),`custom`in o&&o.custom!==void 0&&(s.custom=o.custom===null?null:Q(o.custom)),t[a]=s}return t}function ou(e){let t=e.length,n=Array(t);for(let r=0;r<t;r++){let t=e[r];n[r]={startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn,rangeType:t.rangeType,startAbsoluteRefType:t.startAbsoluteRefType,endAbsoluteRefType:t.endAbsoluteRefType}}return n}function su(e){let t={id:e.id,name:e.name,tabColor:e.tabColor,hidden:e.hidden,rowCount:e.rowCount,columnCount:e.columnCount,zoomRatio:e.zoomRatio,scrollTop:e.scrollTop,scrollLeft:e.scrollLeft,defaultColumnWidth:e.defaultColumnWidth,defaultRowHeight:e.defaultRowHeight,showGridlines:e.showGridlines,rightToLeft:e.rightToLeft,freeze:{xSplit:e.freeze.xSplit,ySplit:e.freeze.ySplit,startRow:e.freeze.startRow,startColumn:e.freeze.startColumn},rowHeader:{width:e.rowHeader.width,hidden:e.rowHeader.hidden},columnHeader:{height:e.columnHeader.height,hidden:e.columnHeader.hidden},mergeData:ou(e.mergeData),cellData:iu(e.cellData),rowData:au(e.rowData),columnData:au(e.columnData)};return e.gridlinesColor!==void 0&&(t.gridlinesColor=e.gridlinesColor),e.defaultStyle!==void 0&&(e.defaultStyle===null||typeof e.defaultStyle==`string`?t.defaultStyle=e.defaultStyle:t.defaultStyle=Q(e.defaultStyle)),e.custom!==void 0&&(t.custom=e.custom===null?null:Q(e.custom)),t}var cu=class{constructor(e,t){this._config=e,C(this,`_columnData`,{}),this._columnData=t}getColumnData(){return this._columnData}getColVisible(e){let{_columnData:t}=this,n=t[e];return n?n.hd!==A.TRUE:!0}getColumnStyle(e){var t;return(t=this._columnData[e])==null?void 0:t.s}setColumnStyle(e,t){let n=this.getColumnOrCreate(e);n.s=t}getHiddenCols(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getColVisible(a);r&&e?(r=!1,n.push({rangeType:B.COLUMN,startColumn:i,endColumn:a-1,startRow:0,endRow:0})):!r&&!e&&(r=!0,i=a)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:t,rangeType:B.COLUMN}),n}getVisibleCols(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getColVisible(a);r&&!e?(r=!1,n.push({rangeType:B.COLUMN,startColumn:i,endColumn:a-1,startRow:0,endRow:0})):!r&&e&&(r=!0,i=a)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:t,rangeType:B.COLUMN}),n}getColumnDatas(e,t){let n={},r=0;for(let i=e;i<e+t;i++){let e=this.getColumn(i);n[r]=e==null?{w:this._config.defaultColumnWidth,hd:A.FALSE}:e,r++}return n}getSize(){return pa(this._columnData)}getColumnWidth(e){var t,n;return(t=(n=this._columnData[e])==null?void 0:n.w)==null?this._config.defaultColumnWidth:t}setColumnWidth(e,t){let n=this._columnData[e];t===this._config.defaultColumnWidth?n&&(delete n.w,Object.keys(n).length===0&&delete this._columnData[e]):this._columnData[e]=n?{...n,w:t}:{w:t}}getColumn(e){return this._columnData[e]}insertColumnsWithData(e,t,n){let r=t-e+1,i=Object.keys(this._columnData);for(let t=i.length-1;t>=0;t--){let n=Number(i[t]);n>=e&&(this._columnData[n+r]=this._columnData[n],delete this._columnData[n])}for(let r=e;r<=t;r++){let t=n==null?void 0:n[r-e];t!=null&&Object.keys(t).length>0&&(this._columnData[r]={...t})}}removeColumn(e){delete this._columnData[e]}getColumnOrCreate(e){let{_columnData:t}=this,n=t[e];if(n)return n;let r={};return this._columnData[e]=r,r}setCustomMetadata(e,t){let n=this.getColumn(e);n&&(n.custom=t)}getCustomMetadata(e){var t;return(t=this.getColumn(e))==null?void 0:t.custom}},lu=class{constructor(e,t,n){this._config=e,this._viewModel=t,C(this,`_rowData`,void 0),this._rowData=n}getRowData(){return this._rowData}getRowStyle(e){var t;return(t=this._rowData[e])==null?void 0:t.s}setRowStyle(e,t){let n=this.getRowOrCreate(e);n.s=t}getRowDatas(e,t){let n={},r=0;for(let i=e;i<e+t;i++){let e=this.getRow(i);n[r]=e==null?{h:this._config.defaultRowHeight,hd:A.FALSE}:e,r++}return n}getRowHeight(e,t=1){let{_rowData:n}=this,r=this._config,i=0;for(let a=0;a<t;a++){let{ia:t,ah:o,h:s=r.defaultRowHeight}=n[a+e]||{hd:A.FALSE,h:r.defaultRowHeight};i+=(t==null||t===A.TRUE)&&typeof o==`number`?o:s}return i}setRowHeight(e,t){let n=this._rowData[e];if(t===this._config.defaultRowHeight)n&&(delete n.h,Object.keys(n).length===0&&delete this._rowData[e]);else{let r=Math.min(t,2e3);this._rowData[e]=n?{...n,h:r}:{h:r}}}getRow(e){return this._rowData[e]}insertRowsWithData(e,t,n){let r=t-e+1,i=Object.keys(this._rowData);for(let t=i.length-1;t>=0;t--){let n=Number(i[t]);n>=e&&(this._rowData[n+r]=this._rowData[n],delete this._rowData[n])}for(let r=e;r<=t;r++){let t=n==null?void 0:n[r-e];t!=null&&Object.keys(t).length>0&&(this._rowData[r]={...t})}}removeRow(e){delete this._rowData[e]}getRowOrCreate(e){let{_rowData:t}=this,n=t[e];if(n)return n;let r={};return t[e]=r,r}getHiddenRows(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getRowRawVisible(a);r&&e?(r=!1,n.push({startRow:i,endRow:a-1,startColumn:0,endColumn:0,rangeType:B.ROW})):!r&&!e&&(r=!0,i=a)}return r&&n.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:B.ROW}),n}getVisibleRows(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getRowRawVisible(a);r&&!e?(r=!1,n.push({startRow:i,endRow:a-1,startColumn:0,endColumn:0,rangeType:B.ROW})):!r&&e&&(r=!0,i=a)}return r&&n.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:B.ROW}),n}getRowRawVisible(e){let t=this.getRow(e);return t?t.hd!==A.TRUE:!0}getSize(){return pa(this._rowData)}setCustomMetadata(e,t){let n=this.getRow(e);n&&(n.custom=t)}getCustomMetadata(e){var t;return(t=this.getRow(e))==null?void 0:t.custom}};const uu=`DEFAULT_WORKSHEET_ROW_COUNT`,du=1e3,fu=`DEFAULT_WORKSHEET_COLUMN_COUNT`,pu=20,mu=`DEFAULT_WORKSHEET_ROW_HEIGHT`,hu=24,gu=`DEFAULT_WORKSHEET_COLUMN_WIDTH`,_u=88,vu=`DEFAULT_WORKSHEET_ROW_TITLE_WIDTH`,yu=46,bu=`DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT`,xu=20;function Su(e){let t={name:`Sheet1`,id:`sheet-01`,tabColor:``,hidden:A.FALSE,rowCount:du,columnCount:20,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:88,defaultRowHeight:24,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:A.TRUE,rowHeader:{width:46,hidden:A.FALSE},columnHeader:{height:20,hidden:A.FALSE},rightToLeft:A.FALSE};return Object.keys(t).forEach(n=>{let r=n;e[r]===void 0&&(e[r]=t[r])}),e}var Cu=class extends E{constructor(e){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`,void 0),C(this,`_rangeMap`,new so(5e4)),this._init(e.concat())}_init(e){this._mergeData=e,this._createCache(e)}_clearCache(){this._cellCache.clear(),this._rowCache.clear(),this._columnCache.clear(),this._hasAll=!1,this._allIndex=-1,this._rangeMap.clear(),this._hasColumn=!1,this._hasRow=!1}_createCache(e){let t=0;for(let n of e){let{rangeType:e}=n;e===B.ROW?this._createRowCache(n,t):e===B.COLUMN?this._createColumnCache(n,t):e===B.ALL?this._createCellAllCache(t):this._createCellCache(n,t),t++}}rebuild(e){this._clearCache(),this._init(e.concat())}_createRowCache(e,t){let{startRow:n,endRow:r}=e;for(let e=n;e<=r;e++)this._rowCache.set(e,t),this._hasRow=!0}_createColumnCache(e,t){let{startColumn:n,endColumn:r}=e;for(let e=n;e<=r;e++)this._columnCache.set(e,t),this._hasColumn=!0}_createCellAllCache(e){this._hasAll=!0,this._allIndex=e}_createCellCache(e,t){for(let n=e.startRow;n<=e.endRow;n++){let r=this._cellCache.get(n);r==null&&(r=new Map,this._cellCache.set(n,r));for(let n=e.startColumn;n<=e.endColumn;n++)r.set(n,t)}}add(e){this._mergeData.push(e),this._clearCache(),this._createCache(this._mergeData)}remove(e,t){let n=this._getMergeDataIndex(e,t);n!==-1&&(this._mergeData.splice(n,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(e,t){let n=this._getMergeDataIndex(e,t);return n===-1?null:this._mergeData[n]}getMergeDataIndex(e,t){return this._getMergeDataIndex(e,t)}isRowContainsMergedCell(e){return this._hasAll||!D.isEmptyObject(this._columnCache)?!0:this._mergeData.some(t=>t.startRow<=e&&e<=t.endRow)}isColumnContainsMergedCell(e){return this._hasAll||!D.isEmptyObject(this._rowCache)?!0:this._mergeData.some(t=>t.startColumn<=e&&e<=t.endColumn)}getMergedCellRange(e,t,n,r){let i=[],a=`${e}-${t}-${n}-${r}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let o=0,s=[];for(let a of this._mergeData||[])G.intersects(a,{startRow:e,endRow:n,startColumn:t,endColumn:r})&&(i.push({...a}),s.push(o)),o++;return this._rangeMap.set(a,s),i}_getRangeFromCache(e){let t=this._rangeMap.get(e)||[],n=[];for(let e of t)n.push({...this._mergeData[e]});return n}_getMergeDataIndex(e,t){var n;if(this._hasAll)return this._allIndex;if(this._hasRow){let t=this._rowCache.get(e);if(t!==void 0)return t}if(this._hasColumn){let e=this._columnCache.get(t);if(e!==void 0)return e}let r=(n=this._cellCache.get(e))==null?void 0:n.get(t);return r===void 0?-1:r}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}},wu=class extends E{constructor(e){super(),this.getRawCell=e,C(this,`_cellContentInterceptor`,null),C(this,`_rowFilteredInterceptor`,null)}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(e,t,n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,At.Value|At.Style,n,r):this.getRawCell(e,t)}getCellValueOnly(e,t){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,At.Value):this.getRawCell(e,t)}getCellStyleOnly(e,t){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,At.Style):this.getRawCell(e,t)}getRowFiltered(e){var t,n;return(t=(n=this._rowFilteredInterceptor)==null?void 0:n.getRowFiltered(e))==null?!1:t}registerCellContentInterceptor(e){if(this._cellContentInterceptor)throw Error(`[SheetViewModel]: Interceptor already registered.`);return this._cellContentInterceptor=e,T(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(e){if(this._rowFilteredInterceptor)throw Error(`[SheetViewModel]: Interceptor already registered.`);return this._rowFilteredInterceptor=e,T(()=>this._rowFilteredInterceptor=null)}};const Tu={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};var Eu=class e{constructor(e,t,n){var r;this.unitId=e,this._styles=n,C(this,`_sheetId`,void 0),C(this,`_snapshot`,void 0),C(this,`_cellData`,void 0),C(this,`_rowManager`,void 0),C(this,`_columnManager`,void 0),C(this,`_viewModel`,void 0),C(this,`_spanModel`,void 0),C(this,`_isRowStylePrecedeColumnStyle`,!0),C(this,`_getCellHeight`,void 0),this._snapshot=Su(t);let{columnData:i,rowData:a,cellData:o}=this._snapshot;this._sheetId=(r=this._snapshot.id)==null?O(6):r,this._cellData=new Sa(o),this._viewModel=new wu((e,t)=>this.getCellRaw(e,t)),this._rowManager=new lu(this._snapshot,this._viewModel,a),this._columnManager=new cu(this._snapshot,i),this._spanModel=new Cu(this._snapshot.mergeData)}__interceptViewModel(e){e(this._viewModel)}__registerGetCellHeight(e){return this._getCellHeight=e,T(()=>{this._getCellHeight=null})}getSnapshot(){return this._snapshot}getCellHeight(e,t){return this._getCellHeight?this._getCellHeight(e,t):this._snapshot.defaultRowHeight}setMergeData(e){this._snapshot.mergeData=e,this.getSpanModel().rebuild(e)}getSpanModel(){return this._spanModel}setIsRowStylePrecedeColumnStyle(e){this._isRowStylePrecedeColumnStyle=e}getStyleDataByHash(e){return{...this._styles.get(e)}}setStyleData(e){return this._styles.setValue(e)}getColumnStyle(e,t=!1){return t?this._columnManager.getColumnStyle(e):this._styles.get(this._columnManager.getColumnStyle(e))}setColumnStyle(e,t){this._columnManager.setColumnStyle(e,t)}getRowStyle(e,t=!1){return t?this._rowManager.getRowStyle(e):this._styles.get(this._rowManager.getRowStyle(e))}setRowStyle(e,t){this._rowManager.setRowStyle(e,t)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){let e=this._snapshot.defaultStyle;return this._styles.get(e)}setDefaultCellStyle(e){this._snapshot.defaultStyle=e}getCellStyle(e,t){let n=this.getCell(e,t);if(n){let e=n.s;return typeof e==`string`?this._styles.get(e):e}return null}getComposedCellStyle(e,t,n){let r=this.getDefaultCellStyleInternal(),i=this.getRowStyle(e),a=this.getColumnStyle(t),o=this.getCell(e,t),s=this._styles.getStyleByCell(o);return(n==null?this._isRowStylePrecedeColumnStyle:n)?wn(r,a,i,o==null?void 0:o.themeStyle,s):wn(r,i,a,o==null?void 0:o.themeStyle,s)}getComposedCellStyleByCellData(e,t,n,r){let i=this.getDefaultCellStyleInternal(),a=this.getRowStyle(e),o=this.getColumnStyle(t),s=this._styles.getStyleByCell(n);return(r==null?this._isRowStylePrecedeColumnStyle:r)?wn(i,o,a,n==null?void 0:n.themeStyle,s):wn(i,a,o,n==null?void 0:n.themeStyle,s)}getComposedCellStyleWithoutSelf(e,t,n,r){let i=n===void 0?this.getComposedCellStyle(e,t,r):this.getComposedCellStyleByCellData(e,t,n,r),a=this.getCellRaw(e,t);if(!a||!a.s)return i;let o=typeof a.s==`string`?this._styles.get(a.s):a.s;if(!o)return i;for(let e in o)e in i&&delete i[e];return i}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){let e=this.getCellMatrix(),t=this.getMergeData(),n=-1,r=-1,i=-1,a=-1,o=!1,s=!1;return e.forEach((t,c)=>{Object.keys(c).forEach(c=>{let l=+c,u=e.getValue(t,l),d=u!=null&&u.s?this._styles.get(u.s):null,f=(d==null?void 0:d.bd)&&(d.bd.b||d.bd.l||d.bd.r||d.bd.t||d.bd.bc_tr||d.bd.bl_tr||d.bd.ml_tr||d.bd.tl_bc||d.bd.tl_br||d.bd.tl_mr);(u&&(u.v!==null&&u.v!==void 0&&u.v!==``||u.p)||d!=null&&d.bg||f)&&(o?n=Math.min(n,t):(n=t,o=!0),r=Math.max(r,t),s?i=Math.min(i,l):(s=!0,i=l),a=Math.max(a,l))})}),t.forEach(e=>{o?n=Math.min(n,e.startRow):(n=e.startRow,o=!0),r=Math.max(r,e.endRow),s?i=Math.min(i,e.startColumn):(i=e.startColumn,o=!0),a=Math.max(a,e.endColumn)}),!o||!s?null:{startColumn:i,startRow:n,endColumn:a,endRow:r}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){let{_snapshot:t}=this,n=su(t);return new e(this.unitId,n,this._styles)}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(e,t){return this._spanModel.getMergedCell(e,t)}getMergedCellRange(e,t,n,r){return this._spanModel.getMergedCellRange(e,t,n,r)}isRowContainsMergedCell(e){return this._spanModel.isRowContainsMergedCell(e)}isColumnContainsMergedCell(e){return this._spanModel.isColumnContainsMergedCell(e)}getCellInfoInMergeData(e,t){let n=this.getMergedCell(e,t),r=!1,i=!1,a=e,o=t,s=e,c=t;if(n){let{startRow:l,endRow:u,startColumn:d,endColumn:f}=n;e===l&&t===d?(a=u,o=f,s=l,c=d,i=!0):e>=l&&e<=u&&t>=d&&t<=f&&(a=u,o=f,s=l,c=d,r=!0)}return{actualRow:e,actualColumn:t,isMergedMainCell:i,isMerged:r,endRow:a,endColumn:o,startRow:s,startColumn:c}}getCell(e,t){return e<0||t<0?null:this._viewModel.getCell(e,t)}getCellValueOnly(e,t){return e<0||t<0?null:this._viewModel.getCellValueOnly(e,t)}getCellStyleOnly(e,t){return e<0||t<0?null:this._viewModel.getCellStyleOnly(e,t)}getCellRaw(e,t){return this.getCellMatrix().getValue(e,t)}getCellWithFilteredInterceptors(e,t,n,r){return this._viewModel.getCell(e,t,n,r)}getRowFiltered(e){return this._viewModel.getRowFiltered(e)}getRangeFilterRows(e){let t=[];for(let n=e.startRow;n<=e.endRow;n++)this.getRowFiltered(n)&&t.push(n);return t}getMatrixWithMergedCells(e,t,n,r,i=ea.Raw){let a=this.getCellMatrix(),o=this._spanModel.getMergedCellRange(e,t,n,r),s=new Sa;return Uo(e,n,t,r).forEach((e,t)=>{let n;if(i===ea.Raw)n=this.getCellRaw(e,t);else if(i===ea.Intercepted)n=this.getCell(e,t);else if(i===ea.Both){let i=this.getCellRaw(e,t);if(i){var r;n={...i};let a=(r=this.getCell(e,t))==null?void 0:r.v;Zl(a)&&n&&(n.displayV=String(a))}}n&&s.setValue(e,t,n)}),o.forEach(e=>{let{startColumn:t,startRow:n,endColumn:r,endRow:i}=e;Uo(n,i,t,r).forEach((e,o)=>{e===n&&o===t&&s.setValue(e,o,{...a.getValue(e,o),rowSpan:i-n+1,colSpan:r-t+1}),(e!==n||o!==t)&&s.realDeleteValue(e,o)})}),s}getRange(e,t,n,r){return typeof e==`object`?new Eo(this,e,{getStyles:()=>this._styles}):new Eo(this,{startRow:e,startColumn:t,endColumn:r||t,endRow:n||e},{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(){let{_snapshot:e}=this,{columnCount:t}=e;return t}getMaxRows(){let{_snapshot:e}=this,{rowCount:t}=e;return t}getRowCount(){return this._snapshot.rowCount}setRowCount(e){this._snapshot.rowCount=e}getColumnCount(){return this._snapshot.columnCount}setColumnCount(e){this._snapshot.columnCount=e}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){let{_snapshot:e}=this,{showGridlines:t}=e;return t===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){let{_snapshot:e}=this,{tabColor:t}=e;return t}getColumnWidth(e){return this.getColumnManager().getColumnWidth(e)}getRowHeight(e){return this._viewModel.getRowFiltered(e)?0:this.getRowManager().getRowHeight(e)}isRowFiltered(e){return this._viewModel.getRowFiltered(e)}getRowVisible(e){return!this.isRowFiltered(e)&&this.getRowRawVisible(e)}getRowRawVisible(e){return this.getRowManager().getRowRawVisible(e)}getHiddenRows(e,t){let n=this.getMaxColumns()-1,r=this._rowManager.getHiddenRows(e,t);return r.forEach(e=>e.endColumn=n),r}getColVisible(e){return this._columnManager.getColVisible(e)}getHiddenCols(e,t){let n=this.getMaxRows()-1,r=this._columnManager.getHiddenCols(e,t);return r.forEach(e=>e.endRow=n),r}getVisibleRows(){let e=this.getRowCount();return this._rowManager.getVisibleRows(0,e-1)}getVisibleCols(){let e=this.getColumnCount();return this._columnManager.getVisibleCols(0,e-1)}isRightToLeft(){let{_snapshot:e}=this,{rightToLeft:t}=e;return t}getLastRowWithContent(){return this._cellData.getRealRowRange().endRow}getLastColumnWithContent(){return this.getDataRealRange().endColumn}getDataRealRange(){return this._cellData.getRealRange()}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(e){return e&&(e.v!==void 0||e.f!==void 0||e.p!==void 0)}iterateByRow(e,t=!0){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e,o=this;return{[Symbol.iterator]:()=>{let e=n,s=r;return{next(){for(;;){if(s>a&&(e+=1,s=r),e>i)return{done:!0,value:void 0};let n=o.getCell(e,s),c=!n,l=o.getMergedCell(e,s);if(l){if(e!==l.startRow||s!==l.startColumn){s=l.endColumn+1;continue}if(c&&t){s=l.endColumn+1;continue}let r={row:e,col:s,value:n};return r.colSpan=l.endColumn-l.startColumn+1,r.rowSpan=l.endRow-l.startRow+1,s=l.endColumn+1,{done:!1,value:r}}if(c&&t)s+=1;else{let t={row:e,col:s,value:n};return s+=1,{done:!1,value:t}}}}}}}}iterateByColumn(e,t=!0,n=!0){let{startRow:r,startColumn:i,endRow:a,endColumn:o}=e,s=this;return{[Symbol.iterator]:()=>{let e=r,c=i;return{next(){for(;;){if(e>a&&(c+=1,e=r),c>o)return{done:!0,value:void 0};let i=s.getMergedCell(e,c);if(i){let r=e!==i.startRow,a=r||c!==i.startColumn;if(n&&a||!n&&r){e=i.endRow+1;continue}let o=s.getCell(i.startRow,i.startColumn);if(!o&&t){e=i.endRow+1;continue}let l={row:e,col:i.startColumn,value:o};return l.colSpan=i.endColumn-i.startColumn+1,l.rowSpan=i.endRow-i.startRow+1,e=i.endRow+1,{done:!1,value:l}}let l=s.getCell(e,c);if(!l&&t)e+=1;else{let t={row:e,col:c,value:l};return e+=1,{done:!1,value:t}}}}}}}}getCellDocumentModel(e,t,n=Tu){var r;if(!e)return;let{isDeepClone:i,displayRawFormula:a,ignoreTextRotation:o}={...Tu,...n},s,c=`document`,l=Jl(t),u=o?W.tr:l.textRotation||W.tr,d=l.horizontalAlign||W.ht,f=l.verticalAlign||W.vt,p=l.wrapStrategy||W.tb,m=l.paddingData||Gl;if(e.f&&a)s=ql(e.f.toString(),{},{verticalAlign:f}),d=W.ht;else if(e.p){let{centerAngle:t,vertexAngle:n}=tu(u);s=this._updateConfigAndGetDocumentModel(i?D.deepClone(e.p):e.p,d,m,{horizontalAlign:d,verticalAlign:f,centerAngle:t,vertexAngle:n,wrapStrategy:p,zeroWidthParagraphBreak:1})}else if(e.v!=null){let n=Yl(t);c=$l(n).fontCache;let r=Du(e);e.t===tr.FORCE_STRING&&a&&(r=`'${r}`),s=ql(r,n,{...l,textRotation:u,cellValueType:e.t})}return s&&e.linkUrl&&e.linkId&&Xl(s,e.linkUrl,e.linkId),{documentModel:s,fontString:c,textRotation:u,wrapStrategy:p,verticalAlign:f,horizontalAlign:d,paddingData:m,fill:t==null||(r=t.bg)==null?void 0:r.rgb}}_updateConfigAndGetDocumentModel(e,t,n,r){var i,a,o,s,c;if(!r||!((i=e.body)!=null&&i.dataStream))return;e.documentStyle||(e.documentStyle={}),e.documentStyle.marginTop=(a=n.t)==null?0:a,e.documentStyle.marginBottom=(o=n.b)==null?2:o,e.documentStyle.marginLeft=(s=n.l)==null?2:s,e.documentStyle.marginRight=(c=n.r)==null?2:c,e.documentStyle.pageSize={width:1/0,height:1/0},e.documentStyle.renderConfig={...e.documentStyle.renderConfig,...r};let l=e.body.paragraphs||[];for(let e of l)e.paragraphStyle||(e.paragraphStyle={}),e.paragraphStyle.horizontalAlign=t;return new _c(e)}getBlankCellDocumentModel(e,t,n){let r=this.getComposedCellStyleByCellData(t,n,e),i=Yl(r),a=this.getCellDocumentModel(e,r,{ignoreTextRotation:!0});if(a!=null)return a.documentModel==null&&(a.documentModel=ql(``,i)),a;let o=`document`,s=W.tr,c=W.ht,l=W.vt,u=W.tb,d=Gl;return o=$l({}).fontCache,{documentModel:ql(``,i),fontString:o,textRotation:s,wrapStrategy:u,verticalAlign:l,horizontalAlign:c,paddingData:d}}getCellDocumentModelWithFormula(e,t,n){let r=this.getComposedCellStyleByCellData(t,n,e);return this.getCellDocumentModel(e,r,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(e){this._snapshot.custom=e}};function Du(e){var t;if(!e)return``;let n=(t=e.p)==null||(t=t.body)==null?void 0:t.dataStream;if(n)return Z.transform.getPlainText(n);let r=e.v;return typeof r==`string`?e.t===tr.BOOLEAN?r.toUpperCase():r.replace(/[\r\n]/g,``):typeof r==`number`?e.t===tr.BOOLEAN?r?`TRUE`:`FALSE`:r.toString():typeof r==`boolean`?r?`TRUE`:`FALSE`:``}function Ou(e){if(e===null)return``;if(e!=null&&e.p){let t=e==null?void 0:e.p.body;if(t==null)return``;let n=t.dataStream;return Z.transform.getPlainText(n)}return e==null?void 0:e.v}function ku(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}let Au=class extends pn{get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(e){return typeof e==`string`||`startRow`in e||`row`in e}constructor(e={},t){super(),this._logService=t,C(this,`type`,x.UNIVER_SHEET),C(this,`_sheetCreated$`,new y),C(this,`sheetCreated$`,this._sheetCreated$.asObservable()),C(this,`_sheetDisposed$`,new y),C(this,`sheetDisposed$`,this._sheetDisposed$.asObservable()),C(this,`_activeSheet$`,new v(null)),C(this,`activeSheet$`,this._activeSheet$.asObservable()),C(this,`_worksheets`,void 0),C(this,`_styles`,void 0),C(this,`_snapshot`,void 0),C(this,`_unitId`,void 0),C(this,`_count`,void 0),C(this,`_name$`,void 0),C(this,`name$`,void 0);let n=Vl();D.isEmptyObject(e)?this._snapshot=n:this._snapshot=D.commonExtend(n,e);let{styles:r}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=O(6)),this._unitId=this._snapshot.id,this._styles=new Hl(r),this._count=1,this._worksheets=new Map,this._name$=new v(e.name||``),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete(),Array.from(this._worksheets.keys()).forEach(e=>{this._removeSheet(e)})}save(){return D.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(e){this._name$.next(e),this._snapshot.name=e}getUnitId(){return this._unitId}getRev(){var e;return(e=this._snapshot.rev)==null?1:e}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(e){this._snapshot.rev=e}addWorksheet(e,t,n){let{sheets:r,sheetOrder:i}=this._snapshot;if(r[e])return!1;r[e]=n,i.splice(t,0,e),this.ensureSheetOrderUnique();let a=new Eu(this._unitId,n,this._styles);return this._worksheets.set(e,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}ensureSheetOrderUnique(){let e=new Set,t=[];for(let n of this._snapshot.sheetOrder)e.has(n)||(e.add(n),t.push(n));this._snapshot.sheetOrder=t,e.clear()}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}addStyles(e){Object.entries(e).forEach(([e,t])=>{this._styles.addCustomStyle(e,t)})}removeStyles(e){e.forEach(e=>{this._styles.remove(e)})}getConfig(){return this._snapshot}getIndexBySheetId(e){let{sheetOrder:t}=this._snapshot;return t.findIndex(t=>t===e)}getActiveSheet(e){if(!this._activeSheet&&e===void 0)throw Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){let e=this._activeSheet;if(e)return e;let t=this._snapshot.sheetOrder;for(let e=0,n=t.length;e<n;e++){let n=this._worksheets.get(t[e]);if(n&&n.isSheetHidden()!==A.TRUE)return this.setActiveSheet(n),n}let n=this._worksheets.get(t[0]);return this.setActiveSheet(n),n}setActiveSheet(e){this._activeSheet$.next(e)}_removeSheet(e){let t=this._worksheets.get(e);return t?(this._worksheets.delete(e),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(e),1),this.ensureSheetOrderUnique(),this._sheetDisposed$.next(t),!0):!1}removeSheet(e){let t=this._removeSheet(e);return t&&delete this._snapshot.sheets[e],t}getActiveSheetIndex(){let{sheetOrder:e}=this._snapshot;return e.findIndex(e=>this._worksheets.get(e)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){let{sheetOrder:e}=this._snapshot;return e.map(e=>this._worksheets.get(e))}getSheetsName(){let{sheetOrder:e}=this._snapshot,t=[];return e.forEach(e=>{let n=this._worksheets.get(e);n&&t.push(n.getName())}),t}getSheetIndex(e){let{sheetOrder:t}=this._snapshot;return t.findIndex(t=>e.getSheetId()===t)}getSheetBySheetName(e){let{sheetOrder:t}=this._snapshot,n=t.find(t=>this._worksheets.get(t).getName()===e);return this._worksheets.get(n)}getSheetBySheetId(e){return this._worksheets.get(e)}getSheetByIndex(e){let{sheetOrder:t}=this._snapshot;return this._worksheets.get(t[e])}getHiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden===A.TRUE).map(e=>e.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden!==A.TRUE).map(e=>e.getConfig().id)}load(e){this._snapshot=e}checkSheetName(e){return this.getSheetsName().some(t=>t.toLowerCase()===e.toLowerCase())}uniqueSheetName(e=`Sheet1`){let t=e;for(;this.checkSheetName(t);)t=e+this._count,this._count++;return t}generateNewSheetName(e){let t=e+this._count;for(;this.checkSheetName(t);)t=e+this._count,this._count++;return t}_parseWorksheetSnapshots(){let{_snapshot:e,_worksheets:t}=this,{sheets:n,sheetOrder:r}=e;if(D.isEmptyObject(n)){let e=O();n[e]={id:e}}for(let e in n){let i=n[e],{name:a}=i;i.name=this.uniqueSheetName(a),i.name!==a&&this._logService.debug(`[Workbook]`,`The worksheet name ${a} is duplicated, we changed it to ${i.name}. Please fix the problem in your snapshot.`);let o=new Eu(this._unitId,i,this._styles);t.set(e,o),r.includes(e)||r.push(e)}this.ensureSheetOrderUnique(),this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(e){this._snapshot.custom=e}};Au=z([R(1,L)],Au);var ju=class extends pn{get _activePage(){let e=this._activePage$.getValue();if(!e){var t,n;let e=(t=this.getPageOrder())==null?void 0:t[0];return e?(n=this.getPages())==null?void 0:n[e]:null}return e}constructor(e){var t;super(),C(this,`type`,x.UNIVER_SLIDE),C(this,`_activePage$`,new v(null)),C(this,`activePage$`,this._activePage$.asObservable()),C(this,`_name$`,void 0),C(this,`name$`,void 0),C(this,`_snapshot`,void 0),C(this,`_unitId`,void 0),this._snapshot={..._o,...e},this._unitId=(t=this._snapshot.id)==null?O(6):t,this._name$=new v(this._snapshot.title),this.name$=this._name$.asObservable()}setName(e){var t;this._snapshot.title=e,this._name$.next(e),this._unitId=(t=this._snapshot.id)==null?O(6):t}getRev(){return 0}incrementRev(){}setRev(e){}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var e;return(e=this._snapshot.body)==null?void 0:e.pages}getPageOrder(){var e;return(e=this._snapshot.body)==null?void 0:e.pageOrder}getPage(e){let t=this.getPages();return t==null?void 0:t[e]}getElementsByPage(e){var t;return(t=this.getPage(e))==null?void 0:t.pageElements}getElement(e,t){var n;return(n=this.getElementsByPage(e))==null?void 0:n[t]}getPageSize(){return this._snapshot.pageSize}getBlankPage(){let e=O(6);return{id:e,pageType:Lr.SLIDE,zIndex:10,title:e,description:``,pageBackgroundFill:{rgb:`rgb(255,255,255)`},pageElements:{}}}setActivePage(e){this._activePage$.next(e)}getActivePage(){return this._activePage}updatePage(e,t){this._snapshot.body&&(this._snapshot.body.pages[e]=t)}appendPage(e){var t;if(!this._snapshot.body)return;this._snapshot.body.pages[e.id]=e;let n=this._activePage,r=this._snapshot.body.pageOrder.indexOf((t=n==null?void 0:n.id)==null?``:t);this._snapshot.body.pageOrder.splice(r+1,0,e.id)}};const Mu=m(`univer.current`);let Nu=class extends E{constructor(e,t,n){super(),this._injector=e,this._contextService=t,this._logService=n,C(this,`_unitsByType`,new Map),C(this,`_createHandler`,void 0),C(this,`_ctorByType`,new Map),C(this,`_currentUnits`,new Map),C(this,`_currentUnits$`,new v(this._currentUnits)),C(this,`currentUnits$`,this._currentUnits$.asObservable()),C(this,`_unitAdded$`,new y),C(this,`unitAdded$`,this._unitAdded$.asObservable()),C(this,`_unitDisposed$`,new y),C(this,`unitDisposed$`,this._unitDisposed$.asObservable()),C(this,`_focused$`,new v(null)),C(this,`focused$`,this._focused$.asObservable())}dispose(){super.dispose(),this._focused$.complete(),this._currentUnits$.complete(),this._unitAdded$.complete(),this._currentUnits.forEach(e=>e==null?void 0:e.dispose()),this._currentUnits.clear(),this._unitsByType.clear()}__setCreateHandler(e){this._createHandler=e}createUnit(e,t,n){return this._createHandler(e,t,this._ctorByType.get(e),n)}registerCtorForType(e,t){return this._ctorByType.set(e,t),{dispose:()=>{this._ctorByType.delete(e)}}}getCurrentTypeOfUnit$(e){return this.currentUnits$.pipe(be(t=>{var n;return(n=t.get(e))==null?null:n}),_e())}getCurrentUnitForType(e){return this._currentUnits.get(e)}getCurrentUnitOfType(e){return this.getCurrentUnitForType(e)}setCurrentUnitForType(e){let t=this._getUnitById(e);if(!t)throw Error(`[UniverInstanceService]: no document with unitId ${e}!`);this._currentUnits.set(t[1],t[0]),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(e){return this._unitAdded$.pipe(ve(t=>t.type===e))}__addUnit(e,t){var n;this._logService.debug(`[UniverInstanceService]: Adding unit with id ${e.getUnitId()}`);let r=e.type;this._unitsByType.has(r)||this._unitsByType.set(r,[]);let i=this._unitsByType.get(r),a=e.getUnitId();if(i.findIndex(e=>e.getUnitId()===a)!==-1)throw Error(`[UniverInstanceService]: cannot create a unit with the same unit id: ${a}.`);i.push(e),this._unitAdded$.next(e),((n=t==null?void 0:t.makeCurrent)==null||n)&&this.setCurrentUnitForType(e.getUnitId())}getTypeOfUnitDisposed$(e){return this.unitDisposed$.pipe(ve(t=>t.type===e))}getUnit(e,t){var n;let r=(n=this._getUnitById(e))==null?void 0:n[0];return t&&(r==null?void 0:r.type)!==t?null:r}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(x.UNIVER_DOC)}getUniverDocInstance(e){return this.getUnit(e,x.UNIVER_DOC)}getUniverSheetInstance(e){return this.getUnit(e,x.UNIVER_SHEET)}getAllUnitsForType(e){var t;return(t=this._unitsByType.get(e))==null?[]:t}changeDoc(e,t){let n=this.getAllUnitsForType(x.UNIVER_DOC),r=n.find(t=>t.getUnitId()===e);if(r!=null){let e=n.indexOf(r);n.splice(e,1)}this.__addUnit(t)}get focused(){var e;let t=this._focused$.getValue();return t?(e=this._getUnitById(t))==null?void 0:e[0]:null}focusUnit(e){this._focused$.next(e),this.focused instanceof Au?(this._contextService.setContextValue(vl,!0),this._contextService.setContextValue(bl,!1),this._contextService.setContextValue(yl,!0),this._contextService.setContextValue(xl,!1),this.setCurrentUnitForType(e)):this.focused instanceof _c?(this._contextService.setContextValue(vl,!0),this._contextService.setContextValue(bl,!0),this._contextService.setContextValue(yl,!1),this._contextService.setContextValue(xl,!1),this.setCurrentUnitForType(e)):this.focused instanceof ju?(this._contextService.setContextValue(vl,!0),this._contextService.setContextValue(bl,!1),this._contextService.setContextValue(yl,!1),this._contextService.setContextValue(xl,!0),this.setCurrentUnitForType(e)):(this._contextService.setContextValue(vl,!1),this._contextService.setContextValue(bl,!1),this._contextService.setContextValue(yl,!1),this._contextService.setContextValue(xl,!1))}getFocusedUnit(){return this.focused}getUnitType(e){let t=this._getUnitById(e);return t?t[1]:x.UNRECOGNIZED}disposeUnit(e){this._logService.debug(`[UniverInstanceService]: Disposing unit with id ${e}`);let t=this._getUnitById(e);if(!t)return this._logService.debug(`[UniverInstanceService]: No unit found with id ${e}`),!1;let[n,r]=t,i=this._unitsByType.get(r),a=i.indexOf(n);return i.splice(a,1),this._tryResetCurrentOnRemoval(e,r),this._tryResetFocusOnRemoval(e),this._unitDisposed$.next(n),n.dispose(),!0}_tryResetCurrentOnRemoval(e,t){let n=this.getCurrentUnitForType(t);(n==null?void 0:n.getUnitId())===e&&(this._currentUnits.set(t,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(e){var t;((t=this.focused)==null?void 0:t.getUnitId())===e&&this._focused$.next(null)}_getUnitById(e){for(let[t,n]of this._unitsByType){let r=n.find(t=>t.getUnitId()===e);if(r)return[r,t]}}};Nu=z([R(0,t(i)),R(1,Zr),R(2,t(L))],Nu);let $=function(e){return e[e.Starting=0]=`Starting`,e[e.Ready=1]=`Ready`,e[e.Rendered=2]=`Rendered`,e[e.Steady=3]=`Steady`,e}({});const Pu={[$.Starting]:`Starting`,[$.Ready]:`Ready`,[$.Rendered]:`Rendered`,[$.Steady]:`Steady`};var Fu=class extends Error{constructor(e){super(`[LifecycleService]: lifecycle stage "${Pu[e]}" will never be reached!`),this.name=`LifecycleUnreachableError`}};let Iu=class extends E{constructor(e){super(),this._logService=e,C(this,`_lifecycle$`,new v($.Starting)),C(this,`lifecycle$`,this._lifecycle$.asObservable()),C(this,`_lock`,!1),this._reportProgress($.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(e){if(this._lock)throw Error(`[LifecycleService]: cannot set new stage when related logic is all handled!`);if(e<this.stage)throw Error(`[LifecycleService]: lifecycle stage cannot go backward!`);e!==this.stage&&(this._lock=!0,this._reportProgress(e),this._lifecycle$.next(e),this._lock=!1)}dispose(){this._lifecycle$.complete(),super.dispose()}onStage(e){return ye(this.lifecycle$.pipe(ve(t=>t>=e),fi(t=>t===e),be(()=>void 0))).catch(t=>t.name===`EmptyError`?Promise.reject(new Fu(e)):Promise.reject(t))}subscribeWithPrevious(){return xe(Lu(this.stage),this._lifecycle$.pipe(Ce(1))).pipe(fi(e=>e===$.Steady))}_reportProgress(e){this._logService.debug(`[LifecycleService]`,`lifecycle progressed to "${Pu[e]}".`)}};Iu=z([R(0,L)],Iu);function Lu(e){switch(e){case $.Starting:return Se($.Starting);case $.Ready:return Se($.Starting,$.Ready);case $.Rendered:return Se($.Starting,$.Ready,$.Rendered);default:return Se($.Starting,$.Ready,$.Rendered,$.Steady)}}const Ru=m(`ILocalStorageService`);var zu=class extends E{get _currentLocale(){return this._currentLocale$.value}constructor(){super(),C(this,`_currentLocale$`,new v(Rn.ZH_CN)),C(this,`currentLocale$`,this._currentLocale$.asObservable()),C(this,`_locales`,null),C(this,`localeChanged$`,new y),C(this,`t`,(e,...t)=>{if(!this._locales)throw Error(`[LocaleService]: Locale not initialized`);let n=e.split(`.`),r=this.resolveKeyPath(this._locales[this._currentLocale],n);if(typeof r==`string`){let e=r;return t.forEach((t,n)=>{e=e.replace(`{${n}}`,t)}),e}else return e}),this.disposeWithMe(T(()=>{this._locales=null,this._currentLocale$.complete(),this.localeChanged$.complete()}))}load(e){var t;this._locales=le((t=this._locales)==null?{}:t,e)}setLocale(e){this._currentLocale$.next(e),this.localeChanged$.next()}getLocales(){var e;return(e=this._locales)==null?void 0:e[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(e,t){let n=t.shift();if(n&&e&&n in e){let r=e[n];return t.length>0&&(typeof r==`object`||Array.isArray(r))?this.resolveKeyPath(r,t):r}return null}};let Bu=class{constructor(e){this._userManagerService=e}async list(e){return{list:[{type:zn.PERSON,mentions:[{objectType:zn.PERSON,objectId:this._userManagerService.getCurrentUser().userID,label:this._userManagerService.getCurrentUser().name,metadata:{icon:this._userManagerService.getCurrentUser().avatar}}],metadata:{},title:`PEOPLE`}],page:e.page,size:e.size,total:1}}};Bu=z([R(0,n(pl))],Bu);const Vu=h(`univer.service.mention-io`);let Hu=function(e){return e.INIT=`init`,e.FETCHING=`fetching`,e.DONE=`done`,e}({});const Uu=m(`univer.permission-service`);var Wu=class extends E{constructor(...e){super(...e),C(this,`_permissionPointMap`,new Map),C(this,`_permissionPointUpdate$`,new y),C(this,`permissionPointUpdate$`,this._permissionPointUpdate$.asObservable()),C(this,`_showComponents`,!0)}setShowComponents(e){this._showComponents=e}getShowComponents(){return this._showComponents}deletePermissionPoint(e){let t=this._permissionPointMap.get(e);t&&(t.complete(),this._permissionPointMap.delete(e))}addPermissionPoint(e){let t=e instanceof v,n=t?e.getValue():e;return n.id?this._permissionPointMap.get(n.id)?(console.warn(`${n.id} PermissionPoint already exists`),!1):(this._permissionPointMap.set(n.id,t?e:new v(n)),this._permissionPointUpdate$.next(n),!0):!1}updatePermissionPoint(e,t){let n=this._permissionPointMap.get(e);if(!n)return;let r=n.getValue();r.value=t,r.status=Hu.DONE,n.next(r),this._permissionPointUpdate$.next(r)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(e){let t=this._permissionPointMap.get(e);if(t)return t.getValue()}getPermissionPoint$(e){let t=this._permissionPointMap.get(e);if(t)return t}composePermission$(e){return he(e.map(e=>{var t;let n=(t=this._permissionPointMap)==null?void 0:t.get(e);if(!n)throw Error(`[PermissionService]: ${e} permissionPoint does not exist!`);return n.asObservable()})).pipe(Pe(e=>e))}composePermission(e){return e.map(e=>{var t;let n=(t=this._permissionPointMap)==null?void 0:t.get(e);if(!n)throw Error(`[PermissionService]: ${e} permissionPoint does not exist!`);return n.getValue()})}getAllPermissionPoint(){let e=new Map;return this._permissionPointMap.forEach((t,n)=>{e.set(n,t)}),e}};function Gu(e,t){if(!t)return e;let n=[];for(let r of e){let e=t.find(([e])=>e===r[0]);if(e){if(e[1]===null)continue;n.push([r[0],e[1]])}else n.push(r)}return n}const Ku=Symbol(`DependentOn`);var qu=class extends E{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}};C(qu,`pluginName`,void 0),C(qu,`packageName`,zl),C(qu,`version`,Bl),C(qu,`type`,x.UNIVER_UNKNOWN);var Ju=class{constructor(){C(this,`_plugins`,[])}addPlugin(e){this._plugins.push(e)}removePlugins(){let e=this._plugins.slice();return this._plugins.length=0,e}forEachPlugin(e){this._plugins.forEach(e)}};function Yu(...e){return function(t){t[Ku]=e}}let Xu=class{constructor(e,t,n){this._injector=e,this._lifecycleService=t,this._logService=n,C(this,`_pluginRegistry`,new Map),C(this,`_pluginStore`,new Ju),C(this,`_seenPlugins`,new Set),C(this,`_loadedPlugins`,new Set),C(this,`_loadedPluginTypes`,new Set([x.UNIVER_UNKNOWN])),C(this,`_flushTimerByType`,new Map)}dispose(){this._pluginStore.removePlugins().forEach(e=>e.dispose()),this._flushTimerByType.forEach(e=>clearTimeout(e))}registerPlugin(e,t){this._assertPluginValid(e);let n={plugin:e,options:t};this._pluginRegistry.set(e.pluginName,n),this._logService.debug(`[PluginService]`,`Plugin "${e.pluginName}" registered.`);let{type:r}=e;this._loadedPluginTypes.has(r)&&(r===x.UNIVER_UNKNOWN?this._loadFromPlugins([n]):this._flushType(r))}startPluginsForType(e){this._loadedPluginTypes.has(e)||this._loadPluginsForType(e)}_loadPluginsForType(e){let t=Array.from(this._pluginRegistry.keys()),n=[];t.forEach(t=>{let r=this._pluginRegistry.get(t);r.plugin.type===e&&n.push(r)}),this._loadFromPlugins(n),this._loadedPluginTypes.add(e)}_assertPluginValid(e){let{type:t,pluginName:n,packageName:r,version:i}=e;if(t===x.UNRECOGNIZED)throw Error(`[PluginService]: invalid plugin type for ${e.name}. Please assign a "type" to your plugin.`);if(!n)throw Error(`[PluginService]: no plugin name for ${e.name}. Please assign a "pluginName" to your plugin.`);if(i&&i!==qu.version)throw Error(`[PluginService]: package "${r==null?`UNKNOWN`:r}" version mismatch. Plugin version is "${i}" but @univerjs/core version is "${qu.version}". Please make sure all @univerjs packages use the same version.`);if(this._seenPlugins.has(n))throw Error(`[PluginService]: duplicated plugin name for "${n}". Maybe a plugin that dependents on "${n} has already registered it. In that case please register "${n}" before the that plugin.`);this._seenPlugins.add(e.pluginName)}_flushType(e){this._flushTimerByType.get(e)===void 0&&this._flushTimerByType.set(e,setTimeout(()=>{this._loadPluginsForType(e),this._flushTimerByType.delete(e)},4))}_loadFromPlugins(e){let t=[],n=new Set,r=e=>{let{plugin:i}=e,{pluginName:a}=i;if(this._loadedPlugins.has(a)||n.has(a))return;n.add(a),this._pluginRegistry.delete(a);let o=i[Ku];o&&o.forEach(e=>{let t=this._pluginRegistry.get(e.pluginName);if(t)r(t);else if(!this._seenPlugins.has(e.pluginName)&&!n.has(e.pluginName)){if(i.type===x.UNIVER_UNKNOWN&&e.type!==x.UNIVER_UNKNOWN)throw Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${i.pluginName} and the dependency is ${e.pluginName}.`);i.type!==e.type&&e.type!==x.UNIVER_UNKNOWN&&this._logService.debug(`[PluginService]`,`Plugin "${a}" depends on "${e.pluginName}" which has different type.`),this._logService.debug(`[PluginService]`,`Plugin "${a}" depends on "${e.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(e),r({plugin:e,options:void 0})}}),t.push(e)};e.forEach(e=>r(e));let i=t.map(e=>this._initPlugin(e.plugin,e.options));this._pluginsRunLifecycle(i)}_pluginsRunLifecycle(e){let t=this._lifecycleService.stage;if(Lu(t).subscribe(t=>this._runStage(e,t)),t!==$.Steady){let t=this._lifecycleService.lifecycle$.pipe(Ce(1)).subscribe(n=>{this._runStage(e,n),n===$.Steady&&t.unsubscribe()})}}_runStage(e,t){e.forEach(e=>{switch(t){case $.Starting:e.onStarting();break;case $.Ready:e.onReady();break;case $.Rendered:e.onRendered();break;case $.Steady:e.onSteady();break}})}_initPlugin(e,t){let n=this._injector.createInstance(e,t);return this._pluginStore.addPlugin(n),this._loadedPlugins.add(e.pluginName),this._logService.debug(`[PluginService]`,`Plugin "${n.getPluginName()}" loaded.`),n}};Xu=z([R(0,t(i)),R(1,t(Iu)),R(2,L)],Xu);const Zu=m(`resource-loader-service`);let Qu=class extends E{constructor(e){super(),this._logService=e,C(this,`_resourceMap`,new Map),C(this,`_register$`,new y),C(this,`register$`,this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(e,t){return t?this.getResourcesByType(e,t):this.getAllResourceHooks().map(t=>{let n=t.toJson(e);return{name:t.pluginName,data:n}})}getResourcesByType(e,t){return this.getAllResourceHooks().filter(e=>e.businesses.includes(t)).map(t=>{let n=t.toJson(e);return{name:t.pluginName,data:n}})}registerPluginResource(e){let t=e.pluginName;if(this._resourceMap.has(t))throw Error(`the pluginName is registered {${t}}`);return this._resourceMap.set(t,e),this._register$.next(e),T(()=>this._resourceMap.delete(t))}disposePluginResource(e){this._resourceMap.delete(e)}loadResources(e,t){this.getAllResourceHooks().forEach(n=>{var r;let i=t==null||(r=t.find(e=>e.name===n.pluginName))==null?void 0:r.data;if(i)try{let t=n.parseJson(i);n.onLoad(e,t)}catch(e){this._logService.error(`[ResourceManagerService]`,`loadResources error`,e)}})}unloadResources(e,t){this.getAllResourceHooks().filter(e=>e.businesses.includes(t)).forEach(t=>{t.onUnLoad(e)})}dispose(){this._register$.complete(),this._resourceMap.clear()}};Qu=z([R(0,L)],Qu);var $u=class extends E{get darkMode(){return this._darkMode$.getValue()}constructor(){super(),C(this,`_darkMode$`,new v(!1)),C(this,`darkMode$`,this._darkMode$.asObservable()),C(this,`_validColorCache`,new Map),C(this,`_currentTheme`,Je),C(this,`_currentTheme$`,new v(this._currentTheme)),C(this,`currentTheme$`,this._currentTheme$.asObservable()),this.disposeWithMe(T(()=>{this._currentTheme=Je,this._currentTheme$.complete(),this._darkMode$.complete()}))}isValidThemeColor(e){if(this._validColorCache.has(e))return this._validColorCache.get(e);let t=!1,n=e.split(`.`);if(n.length===1)t=e in Je;else if(n.length===2){let[e,r]=n;t=e in Je&&r in this._currentTheme[e]}return this._validColorCache.set(e,t),t}getCurrentTheme(){return this._currentTheme}setTheme(e){this._currentTheme=e,this._currentTheme$.next(e)}setDarkMode(e){this._darkMode$.next(e)}getColorFromTheme(e){return ce(this._currentTheme,e)}},ed=function(e){return e[e.WAITING=0]=`WAITING`,e[e.CREATED=1]=`CREATED`,e}(ed||{});const td=m(`univer.undo-redo.service`);var nd=class{dispose(){}async dispatchToHandlers(){return!1}};const rd=`univer.command.redo`,id=`univer.command.undo`,ad=new class extends nd{constructor(...e){super(...e),C(this,`type`,ri.COMMAND),C(this,`id`,id)}handler(e){let t=e.get(td),n=t.pitchTopUndoElement();if(!n)return!1;let r=e.get(ii);return li(n.undoMutations,r)?(t.popUndoToRedo(),!0):!1}},od=new class extends nd{constructor(...e){super(...e),C(this,`type`,ri.COMMAND),C(this,`id`,rd)}handler(e){let t=e.get(td),n=t.pitchTopRedoElement();if(!n)return!1;let r=e.get(ii);return li(n.redoMutations,r)?(t.popRedoToUndo(),!0):!1}};let sd=class extends E{constructor(e,t,n){super(),this._univerInstanceService=e,this._commandService=t,this._contextService=n,C(this,`undoRedoStatus$`,void 0),C(this,`_undoRedoStatus$`,new v({undos:0,redos:0})),C(this,`_undoStacks`,new Map),C(this,`_redoStacks`,new Map),C(this,`_batchingStatus`,new Map),this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(ad)),this.disposeWithMe(this._commandService.registerCommand(od)),this.disposeWithMe(T(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(T(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(e){let{unitID:t}=e,n=this._getRedoStack(t,!0),r=this._getUndoStack(t,!0);if(n.length=0,this._batchingStatus.has(e.unitID)){let t=this._batchingStatus.get(e.unitID),n=this._pitchUndoElement(e.unitID);t===ed.WAITING||!n?(i(e),this._batchingStatus.set(e.unitID,ed.CREATED)):this._tryBatchingElements(n,e)}else i(e);function i(e){r.push(e),r.length>20&&r.splice(0,1)}this._updateStatus()}clearUndoRedo(e){let t=this._getRedoStack(e);t&&(t.length=0);let n=this._getUndoStack(e);n&&(n.length=0),this._updateStatus()}pitchTopUndoElement(){let e=this._getFocusedUnitId();return this._pitchUndoElement(e)}pitchTopRedoElement(){let e=this._getFocusedUnitId();return this._pitchRedoElement(e)}_pitchUndoElement(e){let t=this._getUndoStack(e);return t!=null&&t.length?t[t.length-1]:null}_pitchRedoElement(e){let t=this._getRedoStack(e);return t!=null&&t.length?t[t.length-1]:null}popUndoToRedo(){let e=this._getUndoStackForFocused().pop();e&&(e.redoMutations.length>0&&this._getRedoStackForFocused().push(e),this._updateStatus())}popRedoToUndo(){let e=this._getRedoStackForFocused().pop();e&&(this._getUndoStackForFocused().push(e),this._updateStatus())}rollback(e,t){let n=t||this._getFocusedUnitId(),r=this._getUndoStack(n),i=r==null?void 0:r[(r==null?void 0:r.length)-1];i&&i.id===e&&(r.pop(),li(i.undoMutations,this._commandService))}__tempBatchingUndoRedo(e){if(this._batchingStatus.has(e))throw Error(`[LocalUndoRedoService]: cannot batching undo redo twice at the same time!`);return this._batchingStatus.set(e,ed.WAITING),T(()=>this._batchingStatus.delete(e))}_updateStatus(){var e,t;let n=this._getFocusedUnitId(),r=n&&((e=this._undoStacks.get(n))==null?void 0:e.length)||0,i=n&&((t=this._redoStacks.get(n))==null?void 0:t.length)||0;this._undoRedoStatus$.next({undos:r,redos:i})}_getUndoStack(e,t=!1){let n=this._undoStacks.get(e);return!n&&t&&(n=[],this._undoStacks.set(e,n)),n||null}_getRedoStack(e,t=!1){let n=this._redoStacks.get(e);return!n&&t&&(n=[],this._redoStacks.set(e,n)),n||null}_getUndoStackForFocused(){let e=this._getFocusedUnitId();if(!e)throw Error(`No focused univer instance!`);return this._getUndoStack(e,!0)}_getRedoStackForFocused(){let e=this._getFocusedUnitId();if(!e)throw Error(`No focused univer instance!`);return this._getRedoStack(e,!0)}_tryBatchingElements(e,t){e.redoMutations.push(...t.redoMutations),e.undoMutations.push(...t.undoMutations)}_getFocusedUnitId(){let e=``,t=this._contextService.getContextValue(yl),n=this._contextService.getContextValue(Tl),r=this._contextService.getContextValue(Cl);if(t)if(n)e=ft;else if(r)e=dt;else{var i,a;e=(i=(a=this._univerInstanceService.getFocusedUnit())==null?void 0:a.getUnitId())==null?``:i}else{var o,s;e=(o=(s=this._univerInstanceService.getFocusedUnit())==null?void 0:s.getUnitId())==null?``:o}return e}};sd=z([R(0,Mu),R(1,ii),R(2,Zr)],sd);var cd=class{constructor(e,t=1e3){this._injector=e,C(this,`_imageCacheMap`,void 0),this._imageCacheMap=new so(t)}_getImageCacheKey(e,t){return`${e}-${t}`}getImage(e,t,n,r){let i=this._getImageCacheKey(e,t);return this._imageCacheMap.get(i)||((async()=>{let a=new Image,o=this._injector.has(Ll)?this._injector.get(Ll):null,s=this._injector.has(Rl)?this._injector.get(Rl):null;if(e===Fl.UUID)try{a.src=await(o==null?void 0:o.getImage(t))||``}catch(e){console.error(e)}else if(e===Fl.URL)try{a.src=await(s==null?void 0:s.getImage(t))||t}catch{a.src=t}else a.src=t;a.onload=()=>{a.removeAttribute(`data-error`),n==null||n()},a.onerror=()=>{a.setAttribute(`data-error`,`true`),r==null||r()},this._imageCacheMap.set(i,a)})(),null)}};function ld(e){return!(e.length===0||e.length>31||e.startsWith(`'`)||e.endsWith(`'`)||/[:\\\/\?\*\[\]]/.test(e))}function ud(e,t){return!(!e||e.length===0||e.length>255||t.has(e)||/[ :\\\/\?\*\[\]]/.test(e)||!/^[\p{L}_]/u.test(e)||/^\$?[A-Za-z]{1,3}\$?[0-9]+$/.test(e)||/^[rR]\d+[cC]\d+$/.test(e)||/^\d+$/.test(e))}var dd=class{constructor(e=!1){this._enableOneCellCache=e,C(this,`_tree`,new Map),C(this,`_oneCellCache`,new Map),C(this,`_kdTree`,new Map)}dispose(){this.clear()}getTree(e,t){return this._tree.has(e)||this._tree.set(e,new Map),this._tree.get(e).has(t)||this._tree.get(e).set(t,new Ge),this._tree.get(e).get(t)}_getOneCellCache(e,t,n,r){return this._oneCellCache.has(e)||this._oneCellCache.set(e,new Map),this._oneCellCache.get(e).has(t)||this._oneCellCache.get(e).set(t,new Map),this._oneCellCache.get(e).get(t).has(n)||this._oneCellCache.get(e).get(t).set(n,new Map),this._oneCellCache.get(e).get(t).get(n).has(r)||this._oneCellCache.get(e).get(t).get(n).set(r,new Set),this._oneCellCache.get(e).get(t).get(n).get(r)}_removeOneCellCache(e,t,n,r,i){let a=this._oneCellCache.get(e);if(!a)return;let o=a.get(t);if(!o)return;let s=o.get(n);if(!s)return;let c=s.get(r);c&&c.delete(i)}_removeCellCacheByRange(e){let{unitId:t,sheetId:n,range:r,id:i}=e,a=this._oneCellCache.get(t);if(!a)return;let o=a.get(n);if(!o)return;let{startRow:s,startColumn:c,endRow:l,endColumn:u}=r;for(let e=s;e<=l;e++){let t=o.get(e);if(t)for(let e=c;e<=u;e++){let n=t.get(e);n&&n.delete(i)}}}_insertOneCellCache(e,t,n,r,i){this._getOneCellCache(e,t,n,r).add(i)}_getRdTreeItems(e){let t=[];for(let[n,r]of e)for(let[e,i]of r)t.push({x:e,y:n,ids:i});return t}_searchByOneCellCache(e){var t;let{unitId:n,sheetId:r,range:i}=e,{startRow:a,startColumn:o,endRow:s,endColumn:c}=i,l=(t=this._kdTree.get(n))==null?void 0:t.get(r);if(!l)return[];let{tree:u,items:d}=l,f=u.range(o,a,c,s),p=[];for(let e of f){let t=d[e];p.push(...Array.from(t.ids))}return p}openKdTree(){for(let[t,n]of this._oneCellCache){this._kdTree.has(t)||this._kdTree.set(t,new Map);for(let[r,i]of n){var e;let n=this._getRdTreeItems(i),a=new Ye(n.length);(e=this._kdTree.get(t))==null||e.set(r,{tree:a,items:n});for(let e of n)a.add(e.x,e.y);a.finish()}}}closeKdTree(){for(let[t,n]of this._oneCellCache)for(let[r,i]of n){var e;(e=this._kdTree.get(t))==null||e.set(r,void 0)}}insert(e){let{unitId:t,sheetId:n,range:r,id:i}=e;if(!t||t.length===0)return;let{startRow:a,endRow:o,startColumn:s,endColumn:c}=r;if(this._enableOneCellCache&&a===o&&s===c){this._insertOneCellCache(t,n,a,s,i);return}let l=this.getTree(t,n);Number.isNaN(a)&&(a=0),Number.isNaN(s)&&(s=0),Number.isNaN(o)&&(o=1/0),Number.isNaN(c)&&(c=1/0),l.insert({minX:s,minY:a,maxX:c,maxY:o,id:i})}bulkInsert(e){for(let t of e)this.insert(t)}*searchGenerator(e){var t;let{unitId:n,sheetId:r,range:i}=e;if(this._enableOneCellCache){let t=this._searchByOneCellCache(e);for(let e of t)yield e}let a=(t=this._tree.get(n))==null?void 0:t.get(r);if(!a)return;let o=a.search({minX:i.startColumn,minY:i.startRow,maxX:i.endColumn,maxY:i.endRow});for(let e of o)yield e.id}bulkSearch(e,t){let n=new Set;for(let r of e)for(let e of this.searchGenerator(r))(t==null?void 0:t.has(e))!==!0&&n.add(e);return n}removeById(e,t){if(t){var n,r;(n=this._tree.get(e))==null||n.delete(t),(r=this._oneCellCache.get(e))==null||r.delete(t)}else this._tree.delete(e),this._oneCellCache.delete(e)}_removeRTreeItem(e){let{unitId:t,sheetId:n,range:r,id:i}=e,a=this.getTree(t,n),o=a.search({minX:r.startColumn,minY:r.startRow,maxX:r.endColumn,maxY:r.endRow});for(let e=0;e<o.length;e++)o[e].id===i&&a.remove(o[e])}remove(e){let{unitId:t,sheetId:n,range:r,id:i}=e,{startRow:a,startColumn:o,endRow:s,endColumn:c}=r;this._enableOneCellCache?a===s&&o===c?this._removeOneCellCache(t,n,r.startRow,r.startColumn,i):(this._removeCellCacheByRange(e),this._removeRTreeItem(e)):this._removeRTreeItem(e)}bulkRemove(e){for(let t of e)this.remove(t)}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){let e={};return this._tree.forEach((t,n)=>{e[n]={},t.forEach((t,r)=>{e[n][r]=t.toJSON()})}),e}fromJSON(e){this._tree.clear();for(let t in e){this._tree.set(t,new Map);for(let n in e[t]){let r=new Ge;r.fromJSON(e[t][n]),this._tree.get(t).set(n,r)}}}};function fd(e){return new Promise(t=>setTimeout(t,e))}function pd(e=1){return new Promise(t=>{let n=0,r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}let md=class extends E{constructor(e){super(),this._localeService=e,C(this,`_fontLocale`,void 0),C(this,`_dirty`,!0),this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(e){this._dirty=e}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}};md=z([R(0,n(zu))],md);let hd=class extends md{constructor(e,t,n,r,i,a){super(n),this.worksheet=e,this._styles=t,this._contextService=r,this._configService=i,this._injector=a,C(this,`_worksheetData`,void 0),C(this,`_renderRawFormula`,!1),C(this,`_cellData`,void 0),C(this,`_imageCacheMap`,void 0),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`,1),C(this,`_scaleY`,1),C(this,`_scrollX`,0),C(this,`_scrollY`,0),this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new cd(this._injector),this.initConfig()}initConfig(){var e,t;this._skipAutoHeightForMergedCells=!((e=this._configService.getConfig(_t))!=null&&e),this.worksheet.setIsRowStylePrecedeColumnStyle((t=this._configService.getConfig(`isRowStylePrecedeColumnStyle`))==null?!1:t)}resetCache(){}getWorksheetConfig(){return this._worksheetData}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(e){this._columnHeaderHeight=e,this._worksheetData.columnHeader.height=e}set rowHeaderWidth(e){this._rowHeaderWidth=e,this._worksheetData.rowHeader.width=e}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(e){this._marginLeft=e}setMarginTop(e){this._marginTop=e}setScale(e,t){this._updateLayout(),this._scaleX=e,this._scaleY=t||e,this._updateLayout()}setScroll(e,t){D.isDefine(e)&&(this._scrollX=e),D.isDefine(t)&&(this._scrollY=t)}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(e,t,n){let r=0,i=[],a=t;for(let t=0;t<e;t++){let e=n;if(this.worksheet.getRowFiltered(t))e=0;else if(a[t]!=null){let r=a[t];if(!r)continue;let{h:i=n,ah:o,ia:s}=r;e=(s==null||s===A.TRUE)&&typeof o==`number`&&o>0?o:i,r.hd===A.TRUE&&(e=0)}r+=e,i.push(r)}return{rowTotalHeight:r,rowHeightAccumulation:i}}_generateColumnMatrixCache(e,t,n){let r=0,i=[],a=t;for(let t=0;t<e;t++){let e=n;if(a[t]!=null){let n=a[t];if(!n)continue;n.w!=null&&(e=n.w),n.hd===A.TRUE&&(e=0)}r+=e,i.push(r)}return{columnTotalWidth:r,columnWidthAccumulation:i}}intersectMergeRange(e,t){return!!this.worksheet.getMergedCell(e,t)}_getOverflowBound(e,t,n,r,i=Yn.LEFT){let a=0;if(t>n){let o=this._columnWidthAccumulation.length-1;for(let s=t;s>=n;s--){let n=s;if(!Da(this.worksheet.getCell(e,n))&&n!==t||this.intersectMergeRange(e,n))return n===t?n:n+1>o?o:n+1;let{startX:c,endX:l}=_d(e,n,this.rowHeightAccumulation,this.columnWidthAccumulation);if(i===Yn.CENTER&&n===t?a+=(l-c)/2:a+=l-c,r<a)return n}return t}for(let o=t;o<=n;o++){let n=o;if(!Da(this.worksheet.getCell(e,n))&&n!==t||this.intersectMergeRange(e,n))return n===t?n:n-1<0?0:n-1;let{startX:s,endX:c}=_d(e,n,this.rowHeightAccumulation,this.columnWidthAccumulation);if(i===Yn.CENTER&&n===t?a+=(c-s)/2:a+=c-s,r<a)return n}return n}_updateLayout(){if(!this.dirty)return;let{rowData:e,columnData:t,defaultRowHeight:n,defaultColumnWidth:r,rowCount:i,columnCount:a,rowHeader:o,columnHeader:s}=this._worksheetData,{rowTotalHeight:c,rowHeightAccumulation:l}=this._generateRowMatrixCache(i,e,n),{columnTotalWidth:u,columnWidthAccumulation:d}=this._generateColumnMatrixCache(a,t,r);this._rowHeaderWidth=o.hidden===A.TRUE?0:this._dynamicallyUpdateRowHeaderWidth(o),this._columnHeaderHeight=s.hidden===A.TRUE?0:s.height,this._rowTotalHeight=c,this._rowHeightAccumulation=l,this._columnTotalWidth=u,this._columnWidthAccumulation=d,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(e){}_dynamicallyUpdateRowHeaderWidth(e){let t=`${this.worksheet.getRowCount()}`.length*8;return Math.max(e.width,t)}_hasUnMergedCellInRow(e,t,n){if(!this.worksheet.getMergeData())return!1;for(let r=t;r<=n;r++){let{isMerged:t,isMergedMainCell:n}=this.worksheet.getCellInfoInMergeData(e,r);if(!t&&!n)return!0}return!1}expandRangeByMerge(e,t){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e,o=this._worksheetData.mergeData;if(!o)return{startRow:n,startColumn:r,endRow:i,endColumn:a};let s=!0,c=new Sa,l=0,u=null;for(;s;){s=!1;for(let e=0;e<o.length;e++){let{startRow:t,startColumn:d,endRow:f,endColumn:p}=o[e];if(c.getValue(t,d))continue;let m={startColumn:r,startRow:n,endColumn:a,endRow:i},h={startColumn:d,startRow:t,endColumn:p,endRow:f};Po(m,h)&&(n=Math.min(n,t),r=Math.min(r,d),i=Math.max(i,f),a=Math.max(a,p),c.setValue(t,d,!0),s=!0,l++,u=h)}}return t&&l===1&&G.contains(u,e)?{startRow:u.startRow,startColumn:u.startColumn,endRow:u.startRow,endColumn:u.startColumn}:{startRow:n,startColumn:r,endRow:i,endColumn:a}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(e,t){return this.worksheet.getCellInfoInMergeData(e,t)}getNoMergeCellWithCoordByIndex(e,t,n=!0){let{rowHeightAccumulation:r,columnWidthAccumulation:i,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:o}=this,{startY:s,endY:c,startX:l,endX:u}=_d(e,t,r,i);return n&&(s+=o,c+=o,l+=a,u+=a),{startY:s,endY:c,startX:l,endX:u}}getRowIndexByOffsetY(e,t,n,r){let{rowHeightAccumulation:i}=this;e=yd(e,t,n,this.columnHeaderHeightAndMarginTop);let a=bi(i,e,r==null?void 0:r.firstMatch);if(r!=null&&r.closeFirst){var o;Math.abs(i[a]-e)<Math.abs(e-((o=i[a-1])==null?0:o))&&(a+=1)}return a}getColumnIndexByOffsetX(e,t,n,r){let i=vd(e,t,n,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this,o=bi(a,i,r==null?void 0:r.firstMatch);if(r!=null&&r.closeFirst){var s;Math.abs(a[o]-i)<Math.abs(i-((s=a[o-1])==null?0:s))&&(o+=1)}return o}getCellIndexByOffset(e,t,n,r,i,a){return{row:this.getRowIndexByOffsetY(t,r,i,a),column:this.getColumnIndexByOffsetX(e,n,i,a)}}getCellByOffset(e,t,n,r,i){var a;let o=(a=this)==null?void 0:a.getCellIndexByOffset(e,t,n,r,i,{firstMatch:!0});return o?this.worksheet.getCellInfoInMergeData(o.row,o.column):null}getCellWithCoordByIndex(e,t,n=!0){var r;let{rowHeightAccumulation:i,columnWidthAccumulation:a,rowHeaderWidthAndMarginLeft:o,columnHeaderHeightAndMarginTop:s}=this,c=_d(e,t,i,a,(r=this.worksheet)==null?void 0:r.getCellInfoInMergeData(e,t)),{isMerged:l,isMergedMainCell:u}=c,{startY:d,endY:f,startX:p,endX:m,mergeInfo:h}=c,g=o,_=s;return n===!1&&(g=0,_=0),d+=_,f+=_,p+=g,m+=g,h.startY+=_,h.endY+=_,h.startX+=g,h.endX+=g,{actualRow:e,actualColumn:t,startX:p,startY:d,endX:m,endY:f,isMerged:l,isMergedMainCell:u,mergeInfo:h}}getCellWithCoordByOffset(e,t,n,r,i,a){let{row:o,column:s}=this.getCellIndexByOffset(e,t,n,r,i,a);return this.getCellWithCoordByIndex(o,s)}getOffsetByColumn(e){let{columnWidthAccumulation:t,rowHeaderWidthAndMarginLeft:n}=this,r=t.length-1,i=t[e];return i==null?e<0?n:t[r]+n:i+n}getOffsetByRow(e){let{rowHeightAccumulation:t,columnHeaderHeightAndMarginTop:n}=this,r=t.length-1,i=t[e];return i==null?e<0?n:t[r]+n:i+n}getOffsetRelativeToRowCol(e,t){let n=bi(this.columnWidthAccumulation,e),r=0;r=n===0?e:e-this._columnWidthAccumulation[n-1];let i=bi(this.rowHeightAccumulation,t),a=0;return a=i===0?t:t-this._rowHeightAccumulation[i-1],{row:i,column:n,columnOffset:r,rowOffset:a}}getCellIndexAndOffsetByPosition(e,t){let{actualRow:n,actualColumn:r,startX:i,startY:a}=this.getCellWithCoordByOffset(e,t,this._scaleX,this._scaleY,{x:this._scrollX,y:this._scrollY});return{row:n,rowOffset:t-a,column:r,columnOffset:e-i}}_updateConfigAndGetDocumentModel(e,t,n,r){var i,a,o,s,c;if(!r||!((i=e.body)!=null&&i.dataStream))return;e.documentStyle||(e.documentStyle={}),e.documentStyle.marginTop=(a=n.t)==null?0:a,e.documentStyle.marginBottom=(o=n.b)==null?2:o,e.documentStyle.marginLeft=(s=n.l)==null?2:s,e.documentStyle.marginRight=(c=n.r)==null?2:c,e.documentStyle.pageSize={width:1/0,height:1/0},e.documentStyle.renderConfig={...e.documentStyle.renderConfig,...r};let l=e.body.paragraphs||[];for(let e of l)e.paragraphStyle||(e.paragraphStyle={}),e.paragraphStyle.horizontalAlign=t;return new _c(e)}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,this.worksheet=null}};hd=z([R(2,n(zu)),R(3,Zr),R(4,Yr),R(5,n(a))],hd);function gd(e,t,n,r){let i=e-1,a=t-1,o=n[i]||0,s=n[e];s==null&&(s=n[n.length-1]);let c=r[a]||0,l=r[t];return l==null&&(l=r[r.length-1]),{startY:o,endY:s,startX:c,endX:l}}function _d(e,t,n,r,i){e=D.clamp(e,0,n.length-1),t=D.clamp(t,0,r.length-1);let{startY:a,endY:o,startX:s,endX:c}=gd(e,t,n,r);if(!i)return{startY:a,endY:o,startX:s,endX:c,isMerged:!1,isMergedMainCell:!1,actualRow:e,actualColumn:t,mergeInfo:{startY:a,endY:o,startX:s,endX:c,startRow:e,startColumn:t,endRow:e,endColumn:t}};let{isMerged:l,isMergedMainCell:u,startRow:d,startColumn:f,endRow:p,endColumn:m}=i,h={startRow:d,startColumn:f,endRow:p,endColumn:m,startY:a,endY:o,startX:s,endX:c},g=n.length-1,_=r.length-1;if(l&&d!==-1&&f!==-1){let e=n[d-1]||0,t=n[p]||n[g],i=r[f-1]||0,a=r[m]||r[_];h={...h,startY:e,endY:t,startX:i,endX:a}}else if(!l&&p!==-1&&m!==-1){let e=n[p]||n[g],t=r[m]||r[_];h={...h,startY:a,endY:e,startX:s,endX:t}}return{isMerged:l,isMergedMainCell:u,actualRow:e,actualColumn:t,startY:a,endY:o,startX:s,endX:c,mergeInfo:h}}function vd(e,t,n,r){let{x:i}=n;return e/t+i-r}function yd(e,t,n,r){let{y:i}=n;return e=e/t+i-r,e}const bd=[`script`,`style`,`meta`,`comment`,`link`];let xd=function(e){return e[e.INFO=0]=`INFO`,e[e.STOP=1]=`STOP`,e[e.WARNING=2]=`WARNING`,e}({}),Sd=function(e){return 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}({}),Cd=function(e){return 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}({}),wd=function(e){return e[e.TEXT=0]=`TEXT`,e[e.ARROW=1]=`ARROW`,e[e.CUSTOM=2]=`CUSTOM`,e}({}),Td=function(e){return e.VALID=`valid`,e.INVALID=`invalid`,e.VALIDATING=`validating`,e}({}),Ed=function(e){return 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}({}),Dd=class extends E{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){let e=e=>{e.businesses.forEach(t=>{switch(t){case x.UNRECOGNIZED:case x.UNIVER_UNKNOWN:case x.UNIVER_SLIDE:case x.UNIVER_DOC:this._univerInstanceService.getAllUnitsForType(x.UNIVER_DOC).forEach(t=>{let n=(t.getSnapshot().resources||[]).find(t=>t.name===e.pluginName);if(n)try{let r=e.parseJson(n.data);e.onLoad(t.getUnitId(),r)}catch{console.error(`Load Document{${t.getUnitId()}} Resources{${e.pluginName}} Data Error.`)}});break;case x.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(x.UNIVER_SHEET).forEach(t=>{let n=(t.getSnapshot().resources||[]).find(t=>t.name===e.pluginName);if(n)try{let r=e.parseJson(n.data);e.onLoad(t.getUnitId(),r)}catch{console.error(`Load Workbook{${t.getUnitId()}} Resources{${e.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(t=>e(t)),this.disposeWithMe(this._resourceManagerService.register$.subscribe(t=>e(t))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(x.UNIVER_SHEET).subscribe(e=>{this._resourceManagerService.loadResources(e.getUnitId(),e.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(x.UNIVER_DOC).subscribe(e=>{yt(e.getUnitId())||this._resourceManagerService.loadResources(e.getUnitId(),e.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(x.UNIVER_SHEET).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),x.UNIVER_SHEET)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(x.UNIVER_DOC).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),x.UNIVER_DOC)}))}saveUnit(e){let t=this._univerInstanceService.getUnit(e);if(!t)return null;let n=this._resourceManagerService.getResources(e,t.type),r=D.deepClone(t.getSnapshot());return r.resources=n,r}};Dd=z([R(0,t(ll)),R(1,t(Mu))],Dd);var Od=class{get _univerInstanceService(){return this._injector.get(Mu)}get _pluginService(){return this._injector.get(Xu)}constructor(e={},t){C(this,`_startedTypes`,new Set),C(this,`_injector`,void 0),C(this,`_disposingCallbacks`,new un);let n=this._injector=kd(t,e==null?void 0:e.override),{theme:r,darkMode:i,locale:a,locales:o,logLevel:s,logCommandExecution:c}=e;r&&this._injector.get($u).setTheme(r),i&&this._injector.get($u).setDarkMode(i),o&&this._injector.get(zu).load(o),a&&this._injector.get(zu).setLocale(a),s&&this._injector.get(L).setLogLevel(s),c!==void 0&&this._injector.get(Yr).setConfig(ni,c),this._init(n)}__getInjector(){return this._injector}onDispose(e){let t=this._disposingCallbacks.add(T(e));return T(()=>t.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(e){this._injector.get(zu).setLocale(e)}createUnit(e,t){return this._univerInstanceService.createUnit(e,t)}createUniverSheet(e){return this._injector.get(L).warn(`[Univer]`,`Univer.createUniverSheet is deprecated, use createUnit instead`),this._univerInstanceService.createUnit(x.UNIVER_SHEET,e)}createUniverDoc(e){return this._injector.get(L).warn(`[Univer]`,`Univer.createUniverDoc is deprecated, use createUnit instead`),this._univerInstanceService.createUnit(x.UNIVER_DOC,e)}createUniverSlide(e){return this._injector.get(L).warn(`[Univer]`,`Univer.createUniverSlide is deprecated, use createUnit instead`),this._univerInstanceService.createUnit(x.UNIVER_SLIDE,e)}_init(e){this._univerInstanceService.registerCtorForType(x.UNIVER_SHEET,Au),this._univerInstanceService.registerCtorForType(x.UNIVER_DOC,_c),this._univerInstanceService.registerCtorForType(x.UNIVER_SLIDE,ju);let t=e.get(Mu);t.__setCreateHandler((n,r,i,a)=>{if(!this._startedTypes.has(n)){this._pluginService.startPluginsForType(n),this._startedTypes.add(n);let o=e.createInstance(i,r);return t.__addUnit(o,a),this._tryProgressToReady(),o}let o=e.createInstance(i,r);return t.__addUnit(o,a),o})}_tryProgressToReady(){this._injector.get(Iu).stage<$.Ready&&(this._injector.get(Iu).stage=$.Ready)}registerPlugin(e,t){this._pluginService.registerPlugin(e,t)}registerPlugins(e){e.forEach(e=>{let[t,n]=e;this._pluginService.registerPlugin(t,n)})}};function kd(e,t){let n=Gu([[Pl],[zu],[$u],[Iu],[Xu],[pl],[Mu,{useClass:Nu}],[Uu,{useClass:Wu}],[L,{useClass:ei,lazy:!0}],[ii,{useClass:si}],[td,{useClass:sd,lazy:!0}],[Yr,{useClass:Xr}],[Zr,{useClass:Qr}],[ll,{useClass:Qu,lazy:!0}],[Zu,{useClass:Dd,lazy:!0}],[hl,{useClass:ml}],[Vu,{useClass:Bu,lazy:!0}]],t),r=e?e.createChild(n):new i(n);return St(r,[[pl],[Zu]]),r}et();export{Wo as ABCToNumber,_t as AUTO_HEIGHT_FOR_MERGED_CELLS,V as AbsoluteRefType,Ys as ActionIterator,Ar as AlignTypeH,jr as AlignTypeV,Fr as ArrangeTypeEnum,Hn as ArrowsAndMarkersShapes,It as AsyncInterceptorManager,e as AsyncLock,ml as AuthzIoLocalService,Dn as AutoFillSeries,Wr as BORDER_KEYS,Ur as BORDER_STYLE_KEYS,er as BaselineOffset,Vn as BasicShapes,cr as BlockType,A as BooleanNumber,k as BorderStyleTypes,On as BorderType,Z as BuildTextUtils,ar as BulletAlignment,Di as COLORS,Hr as COLOR_STYLE_KEYS,ni as COMMAND_LOG_EXECUTION_CONFIG_KEY,Tt as CanceledError,ea as CellModeEnum,tr as CellValueType,Oi as ColorKit,kn as ColorType,fr as ColumnSeparatorType,si as CommandService,ri as CommandType,An as CommonHideTypes,Xr as ConfigService,Qr as ContextService,jn as CopyPasteType,wt as CustomCommandExecutionError,sr as CustomDecorationType,or as CustomRangeType,go as DEFAULT_CELL,hc as DEFAULT_DOC,al as DEFAULT_DOCUMENT_SUB_COMPONENT_ID,ht as DEFAULT_EMPTY_DOCUMENT_VALUE,ia as DEFAULT_NUMBER_FORMAT,mo as DEFAULT_RANGE,po as DEFAULT_RANGE_ARRAY,ho as DEFAULT_SELECTION,_o as DEFAULT_SLIDE,W as DEFAULT_STYLES,na as DEFAULT_TEXT_FORMAT,ra as DEFAULT_TEXT_FORMAT_EXCEL,pu as DEFAULT_WORKSHEET_COLUMN_COUNT,fu as DEFAULT_WORKSHEET_COLUMN_COUNT_KEY,xu as DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT,bu as DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY,_u as DEFAULT_WORKSHEET_COLUMN_WIDTH,gu as DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY,du as DEFAULT_WORKSHEET_ROW_COUNT,uu as DEFAULT_WORKSHEET_ROW_COUNT_KEY,hu as DEFAULT_WORKSHEET_ROW_HEIGHT,mu as DEFAULT_WORKSHEET_ROW_HEIGHT_KEY,yu as DEFAULT_WORKSHEET_ROW_TITLE_WIDTH,vu as DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY,mt as DOCS_COMMENT_EDITOR_UNIT_ID_KEY,ft as DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,dt as DOCS_NORMAL_EDITOR_UNIT_ID_KEY,pt as DOCS_ZEN_EDITOR_UNIT_ID_KEY,So as DOC_DRAWING_PRINTING_COMPONENT_KEY,Qi as DOC_RANGE_TYPE,vr as DashStyleType,lc as DataStreamTreeNodeType,X as DataStreamTreeTokenType,xd as DataValidationErrorStyle,Sd as DataValidationImeMode,Cd as DataValidationOperator,wd as DataValidationRenderMode,Td as DataValidationStatus,Ed as DataValidationType,Mn as DeleteDirection,Yu as DependentOn,ei as DesktopLogService,Nn as DeveloperMetadataVisibility,Pn as Dimension,Fn as Direction,E as Disposable,un as DisposableCollection,rr as DocStyleType,_c as DocumentDataModel,lr as DocumentFlavor,Ir as DrawingTypeEnum,Cl as EDITOR_ACTIVATED,Co as EXTENSION_NAMES,Pl as ErrorService,ol as EventState,sl as EventSubject,Ol as FOCUSING_COMMENT_EDITOR,jl as FOCUSING_COMMON_DRAWINGS,bl as FOCUSING_DOC,Sl as FOCUSING_EDITOR_BUT_HIDDEN,wl as FOCUSING_EDITOR_INPUT_FORMULA,Dl as FOCUSING_EDITOR_STANDALONE,Tl as FOCUSING_FX_BAR_EDITOR,kl as FOCUSING_PANEL_EDITOR,Ml as FOCUSING_SHAPE_TEXT_EDITOR,yl as FOCUSING_SHEET,xl as FOCUSING_SLIDE,vl as FOCUSING_UNIT,El as FOCUSING_UNIVER_EDITOR,Al as FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE,Nl as FORMULA_EDITOR_ACTIVATED,ir as FollowNumberWithType,Qn as FontItalic,Er as FontStyleType,$n as FontWeight,ur as GridType,Yn as HorizontalAlign,hl as IAuthzIoService,ii as ICommandService,Yr as IConfigService,gl as IConfirmService,Zr as IContextService,Ll as IImageIoService,Ru as ILocalStorageService,L as ILogService,Vu as IMentionIOService,Uu as IPermissionService,Zu as IResourceLoaderService,ll as IResourceManagerService,gt as IS_ROW_STYLE_PRECEDE_COLUMN_STYLE,Rl as IURLImageService,td as IUndoRedoService,Mu as IUniverInstanceService,cd as ImageCacheMap,Fl as ImageSourceType,Il as ImageUploadStatusType,t as Inject,r as InjectSelf,i as Injector,At as InterceptorEffectEnum,Nt as InterceptorManager,Ln as InterpolationPointType,S as JSON1,cc as JSONX,co as LRUHelper,so as LRUMap,Iu as LifecycleService,$ as LifecycleStages,Fu as LifecycleUnreachableError,M as ListGlyphType,sd as LocalUndoRedoService,zu as LocaleService,Rn as LocaleType,$r as LogLevel,o as LookUp,fo as MAX_COLUMN_COUNT,uo as MAX_ROW_COUNT,Si as MOVE_BUFFER_VALUE,s as Many,Zt as MemoryCursor,Bu as MentionIOLocalService,zn as MentionType,yo as NAMED_STYLE_MAP,bo as NAMED_STYLE_SPACE_MAP,N as NamedStyleType,oi as NilCommand,kr as NumberUnitType,Sa as ObjectMatrix,Dr as ObjectRelativeFromH,Or as ObjectRelativeFromV,c as Optional,Un as OtherShapes,Kr as PADDING_KEYS,wo as PAGE_SIZE,Pr as PAPER_TYPES,xs as PRESET_LIST_TYPE,xo as PRINT_CHART_COMPONENT_KEY,Rr as PageElementType,Nr as PageOrientType,Lr as PageType,P as PaperType,mr as ParagraphElementType,nl as ParagraphStyleBuilder,tl as ParagraphStyleValue,Wu as PermissionService,Hu as PermissionStatus,qu as Plugin,Xu as PluginService,gr as PositionedObjectLayoutType,q as PresetListType,Bn as ProtectionType,l as Quantity,K as QuickListType,ws as QuickListTypeMap,Zi as RANGE_DIRECTION,B as RANGE_TYPE,Ge as RBush,fn as RCDisposable,Ei as RGBA_PAREN,Ti as RGB_PAREN,Ci as ROTATE_BUFFER_VALUE,dd as RTree,Eo as Range,G as Rectangle,u as RediError,od as RedoCommand,rd as RedoCommandId,Ho as RefAlias,nn as Registry,rn as RegistryAsMap,Gn as RelativeDate,zr as RelativeSlideLink,Qu as ResourceManagerService,il as RichTextBuilder,rl as RichTextValue,dn as RxDisposable,vo as SHEET_EDITOR_UNITS,qr as STYLE_KEYS,dr as SectionType,d as Self,hd as SheetSkeleton,Kn as SheetTypes,wu as SheetViewModel,md as Skeleton,f as SkipSelf,Ps as SliceBodyType,ju as SlideDataModel,_r as SpacingRule,Wn as SpecialShapes,Hl as Styles,Vr as TEXT_DECORATION_KEYS,Gr as TEXT_ROTATION_KEYS,ta as THEME_COLORS,yr as TabStopAlignment,xr as TableAlignmentType,Sr as TableLayoutType,wr as TableRowHeightRule,br as TableSizeType,Cr as TableTextWrapType,_l as TestConfirmService,Jn as TextDecoration,el as TextDecorationBuilder,qn as TextDirection,pr as TextDirectionType,$c as TextStyleBuilder,Qc as TextStyleValue,Y as TextX,I as TextXActionType,j as ThemeColorType,nr as ThemeColors,$u as ThemeService,D as Tools,ad as UndoCommand,id as UndoCommandId,pn as UnitModel,Od as Univer,Nu as UniverInstanceService,x as UniverInstanceType,F as UpdateDocsAttributeType,pl as UserManagerService,Xn as VerticalAlign,Tr as VerticalAlignmentType,p as WithNew,Au as Workbook,Eu as Worksheet,Zn as WrapStrategy,hr as WrapTextType,Xl as addLinkToDocumentModel,gi as afterInitApply,mi as afterTime,fd as awaitTime,yi as binSearchFirstGreaterThanTarget,vi as binarySearchArray,pi as bufferDebounceTime,Ia as cellToRange,Mr as characterSpacingControlType,Va as checkForSubstrings,wi as checkIfMove,Ua as checkParagraphHasBullet,Wa as checkParagraphHasIndent,Ga as checkParagraphHasIndentByStyle,nu as cloneCellData,iu as cloneCellDataMatrix,ru as cloneCellDataWithSpanAndDisplay,Q as cloneValue,su as cloneWorksheetData,xi as codeToBlob,lo as columnLabelToNumber,qs as composeBody,Mt as composeInterceptors,wn as composeStyles,_a as concatMatrixArray,Ca as convertCellToRange,hi as convertObservableToBehaviorSubject,La as covertCellValue,Ra as covertCellValues,Pt as createAsyncInterceptorKey,dl as createDefaultUser,ql as createDocumentModelWithStyle,m as createIdentifier,jt as createInterceptorKey,vt as createInternalEditorID,En as createREGEXFromWildChar,Uo as createRowColIter,ud as customNameCharacterCheck,Ie as dayjs,se as debounce,nt as dedupe,rt as dedupeBy,za as deepCompare,pd as delayAnimationFrame,qa as deleteContent,Du as extractPureTextFromCell,g as forwardRef,di as fromCallback,cl as fromEventSubject,Xa as generateIntervalsByPoints,O as generateRandomId,ce as get,pa as getArrayLength,Bs as getBodySlice,Na as getBorderStyleType,gd as getCellCoordByIndexSimple,$i as getCellInfoInMergeData,qi as getCellValueType,_d as getCellWithCoordByIndexCore,Oa as getColorStyle,zs as getCustomBlockSlice,Us as getCustomDecorationSlice,Hs as getCustomRangeSlice,Pa as getDocsUpdateBody,Ql as getEmptyCell,Po as getIntersectRange,da as getNumfmtParseValueFilter,Ou as getOriginCellValue,Ls as getParagraphsSlice,fc as getPlainText,In as getReverseDirection,Rs as getSectionBreakSlice,Is as getTableSlice,Fs as getTextRunSlice,vd as getTransformOffsetX,yd as getTransformOffsetY,ku as getWorksheetUID,ot as groupBy,ja as handleStyleToString,Ya as hashAlgorithm,Ha as horizontalLineSegmentsSubtraction,ha as insertMatrixArray,Ka as insertTextToContent,Jt as invertColorByHSL,Xt as invertColorByMatrix,_ as isAsyncDependencyItem,ee as isAsyncHook,Wi as isBlackColor,lt as isBooleanString,Da as isCellCoverable,Yi as isCellV,te as isClassDependencyItem,bt as isCommentEditorID,ne as isCtor,oa as isDefaultFormat,re as isDisposable,Ea as isEmptyCell,ie as isFactoryDependencyItem,Aa as isFormulaId,ka as isFormulaString,Ki as isICellData,yt as isInternalEditorID,Tn as isNodeEnv,Zl as isNotNullOrUndefined,Ji as isNullCell,$t as isNumeric,sa as isPatternEqualWithoutDecimal,Ul as isRangesEqual,Ja as isRealNum,en as isSafeNumeric,Ba as isSameStyleTextRun,aa as isTextFormat,Wl as isUnitRangesEqual,Fa as isValidRange,ae as isValueDependencyItem,Gi as isWhiteColor,st as makeArray,Ta as makeCellRangeToRangeData,wa as makeCellToSelection,uc as makeCustomRangeStream,fa as mapObjectMatrix,le as merge,Za as mergeIntervals,Qa as mergeLocales,Gu as mergeOverrideWithDependencies,cn as mergeSets,ue as mergeWith,Su as mergeWorksheetSnapshotWithDefault,Qt as mixinClass,ya as moveMatrixArray,Do as moveRangeByOffset,ld as nameCharacterCheck,Vs as normalizeBody,Zo as normalizeTextRuns,Go as numberToABC,qo as numberToListABC,Fe as numfmt,Vo as queryObjectMatrix,xt as registerDependencies,tt as remove,Ko as repeatStringNumTimes,Yc as replaceInDocumentBody,an as requestImmediateMacroTask,bn as resolveWithBasePath,at as rotate,bi as searchArray,_i as searchInOrderedArray,Xi as selectionToArray,sn as sequence,on as sequenceAsync,li as sequenceExecute,ui as sequenceExecuteAsync,de as set,oe as setDependencies,Ct as shallowEqual,bd as skipParseTagNames,va as sliceMatrixArray,Jo as sortRules,Yo as sortRulesByDesc,Xo as sortRulesFactory,ga as spliceArray,ko as splitIntoGrid,fi as takeAfter,qe as textDiff,Et as throttle,T as toDisposable,St as touchDependencies,Xs as updateAttributeByDelete,Zs as updateAttributeByInsert,tn as willLoseNumericPrecision};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -102,7 +102,7 @@ export { awaitTime, delayAnimationFrame } from './shared/timer';
|
|
|
102
102
|
export { isNodeEnv } from './shared/tools';
|
|
103
103
|
export * from './sheets/clone';
|
|
104
104
|
export { Range } from './sheets/range';
|
|
105
|
-
export { getCellCoordByIndexSimple,
|
|
105
|
+
export { getCellCoordByIndexSimple, getCellWithCoordByIndexCore, SheetSkeleton } from './sheets/sheet-skeleton';
|
|
106
106
|
export type { IGetRowColByPosOptions } from './sheets/sheet-skeleton';
|
|
107
107
|
export * from './sheets/sheet-skeleton';
|
|
108
108
|
export { DEFAULT_WORKSHEET_COLUMN_COUNT, DEFAULT_WORKSHEET_COLUMN_COUNT_KEY, DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT, DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY, DEFAULT_WORKSHEET_COLUMN_WIDTH, DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY, DEFAULT_WORKSHEET_ROW_COUNT, DEFAULT_WORKSHEET_ROW_COUNT_KEY, DEFAULT_WORKSHEET_ROW_HEIGHT, DEFAULT_WORKSHEET_ROW_HEIGHT_KEY, DEFAULT_WORKSHEET_ROW_TITLE_WIDTH, DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY, mergeWorksheetSnapshotWithDefault, } from './sheets/sheet-snapshot-utils';
|