@univerjs/core 0.9.3 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/umd/index.js CHANGED
@@ -3,6 +3,6 @@
3
3
  `)===r?ae.TRUE:ae.FALSE}const Vr=class Vr{constructor(t,n,r){C(this,"_range");C(this,"_worksheet");this._deps=r,this._range=n,this._worksheet=t}static foreach(t,n){const{startRow:r,startColumn:s,endRow:i,endColumn:o}=t;for(let a=r;a<=i;a++)for(let l=s;l<=o;l++)n(a,l)}getRangeData(){return this._range}getValue(){return this.getValues()[0][0]}getValues(){const{startRow:t,endRow:n,startColumn:r,endColumn:s}=this._range,i=[];for(let o=t;o<=n;o++){const a=[];for(let l=r;l<=s;l++)a.push(this.getMatrix().getValue(o,l)||null);i.push(a)}return i}getMatrix(){const{startRow:t,endRow:n,startColumn:r,endColumn:s}=this._range,i=this._worksheet.getCellMatrix(),o=new ct;for(let a=t;a<=n;a++)for(let l=r;l<=s;l++)o.setValue(a,l,i.getValue(a,l)||null);return o}getMatrixObject(){const{startRow:t,endRow:n,startColumn:r,endColumn:s}=this._range,i=this._worksheet.getCellMatrix(),o=new ct;for(let a=t;a<=n;a++)for(let l=r;l<=s;l++)o.setValue(a-t,l-r,i.getValue(a,l)||{});return o}getA1Notation(){const{startRow:t,endRow:n,startColumn:r,endColumn:s}=this._range;let i,o;return r<s?(i=Z.numToWord(r+1)+(t+1),o=Z.numToWord(s+1)+(n+1)):(i=Z.numToWord(s+1)+(n+1),o=Z.numToWord(r+1)+(t+1)),i===o?`${i}`:`${i}:${o}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){const t=this._deps.getStyles();return this.getValues().map(n=>n.map(r=>{var i;const s=t.getStyleByCell(r);return((i=s==null?void 0:s.bg)==null?void 0:i.rgb)||st.bg.rgb}))}getCell(t,n){const{startRow:r,startColumn:s}=this._range,i={startRow:r+t,endRow:r+t,startColumn:s+n,endColumn:s+n};return new Vr(this._worksheet,i,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(t={}){return this.getObjectValues(t)[0][0]}getObjectValues(t={}){var a;const{startRow:n,endRow:r,startColumn:s,endColumn:i}=this._range,o=this._worksheet.getCellMatrix().getFragment(n,r,s,i).getData();if(t.isIncludeStyle){const l=this._deps.getStyles();for(let c=0;c<=r-n;c++)for(let u=0;u<=i-s;u++){if(o==null||((a=o==null?void 0:o[c])==null?void 0:a[u])==null)continue;const h=o[c][u].s;h&&(o[c][u].s=l.get(h))}}return o}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){const t=this._deps.getStyles();return this.getValues().map(n=>n.map(r=>{var i;const s=t.getStyleByCell(r);return((i=s==null?void 0:s.cl)==null?void 0:i.rgb)||st.cl.rgb}))}getFontFamilies(){return this._getStyles("ff")}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles("ul")}getUnderline(){var n,r;const{p:t}=(n=this.getValue())!=null?n:{};return t&&Array.isArray((r=t.body)==null?void 0:r.textRuns)&&t.body.textRuns.length>0?Ns("ul",t.body)===ae.TRUE?{s:ae.TRUE}:{s:ae.FALSE}:this.getUnderlines()[0][0]}getOverlines(){return this._getStyles("ol")}getOverline(){return this.getOverlines()[0][0]}getStrikeThrough(){var n,r;const{p:t}=(n=this.getValue())!=null?n:{};return t&&Array.isArray((r=t.body)==null?void 0:r.textRuns)&&t.body.textRuns.length>0?Ns("st",t.body)===ae.TRUE?{s:ae.TRUE}:{s:ae.FALSE}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles("st")}getFontSize(){var n,r;const t=((n=this.getValue())==null?void 0:n.p)||{};return t&&Array.isArray((r=t.body)==null?void 0:r.textRuns)&&t.body.textRuns.length>0?t.body.textRuns.some(s=>{var i;return((i=s==null?void 0:s.ts)==null?void 0:i.fs)!=null})?Math.max(...t.body.textRuns.map(s=>{var i;return((i=s==null?void 0:s.ts)==null?void 0:i.fs)||0})):this.getFontSizes()[0][0]:this.getFontSizes()[0][0]}getFontSizes(){return this._getStyles("fs")}getBorder(){return this.getBorders()[0][0]}getBorders(){return this._getStyles("bd")}getFontStyle(){var n,r;const{p:t}=(n=this.getValue())!=null?n:{};return t&&Array.isArray((r=t.body)==null?void 0:r.textRuns)&&t.body.textRuns.length>0?Ns("it",t.body)===ae.TRUE?ts.ITALIC:ts.NORMAL:this._getFontStyles()[0][0]}_getFontStyles(){return this._getStyles("it")}getFontWeight(){var n,r;const{p:t}=(n=this.getValue())!=null?n:{};return t&&Array.isArray((r=t.body)==null?void 0:r.textRuns)&&t.body.textRuns.length>0?Ns("bl",t.body)===ae.TRUE?ns.BOLD:ns.NORMAL:this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles("bl")}getGridId(){return this._worksheet.getSheetId()}getHeight(){const{_range:t,_worksheet:n}=this,{startRow:r,endRow:s}=t;let i=0;for(let o=0;o<=s-r;o++){const a=n.getRowHeight(o);i+=a}return i}getHorizontalAlignment(){return this.getHorizontalAlignments()[0][0]}getHorizontalAlignments(){return this._getStyles("ht")}getLastColumn(){return this._range.endColumn}getLastRow(){return this._range.endRow}getNumColumns(){const{startColumn:t,endColumn:n}=this._range;return n-t+1}getNumRows(){const{startRow:t,endRow:n}=this._range;return n-t+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(t=>t.map(n=>(n==null?void 0:n.p)||""))}getRowIndex(){return this._range.startRow}getSheet(){return this._worksheet}getTextDirection(){return this.getTextDirections()[0][0]}getTextDirections(){return this._getStyles("td")}getTextRotation(){return this.getTextRotations()[0][0]}getTextRotations(){return this._getStyles("tr")}getTextStyle(){return this.getTextStyles()[0][0]}getTextStyles(){const t=this._deps.getStyles();return this.getValues().map(n=>n.map(r=>t.getStyleByCell(r)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles("vt")}getWidth(){const{_range:t,_worksheet:n}=this,{startColumn:r,endColumn:s}=t;let i=0;for(let o=0;o<=s-r;o++)i+=n.getColumnWidth(o);return i}getWrap(){return this.getWrapStrategy()===dn.WRAP?ae.TRUE:ae.FALSE}getWrapStrategies(){return this._getStyles("tb")}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(t){Vr.foreach(this._range,t)}_getStyles(t){const n=this._deps.getStyles();return this.getValues().map(r=>r.map(s=>{const i=n&&n.getStyleByCell(s);return i&&i[t]||st[t]}))}};C(Vr,"transformRange",(t,n)=>{const r=n.getMaxColumns()-1,s=n.getMaxRows()-1;return t.rangeType===pe.ALL?{startColumn:0,startRow:0,endColumn:r,endRow:s}:t.rangeType===pe.COLUMN?{startRow:0,endRow:s,startColumn:t.startColumn,endColumn:t.endColumn}:t.rangeType===pe.ROW?{startColumn:0,endColumn:r,startRow:t.startRow,endRow:t.endRow}:{startColumn:t.startColumn,endColumn:Math.min(t.endColumn,r),startRow:t.startRow,endRow:Math.min(t.endRow,s)}});let xn=Vr;function Hc(e,t,n=0,r=e.length-1,s=m_){for(;r>n;){if(r-n>600){const l=r-n+1,c=t-n+1,u=Math.log(l),h=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*h*(l-h)/l)*(c-l/2<0?-1:1),m=Math.max(n,Math.floor(t-c*h/l+d)),_=Math.min(r,Math.floor(t+(l-c)*h/l+d));Hc(e,t,m,_,s)}const i=e[t];let o=n,a=r;for(vr(e,n,t),s(e[r],i)>0&&vr(e,n,r);o<a;){for(vr(e,o,a),o++,a--;s(e[o],i)<0;)o++;for(;s(e[a],i)>0;)a--}s(e[n],i)===0?vr(e,n,a):(a++,vr(e,a,r)),a<=t&&(n=a+1),t<=a&&(r=a-1)}}function vr(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function m_(e,t){return e<t?-1:e>t?1:0}class Ms{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let n=this.data;const r=[];if(!Ds(t,n))return r;const s=this.toBBox,i=[];for(;n;){for(let o=0;o<n.children.length;o++){const a=n.children[o],l=n.leaf?s(a):a;Ds(t,l)&&(n.leaf?r.push(a):go(t,l)?this._all(a,r):i.push(a))}n=i.pop()}return r}collides(t){let n=this.data;if(!Ds(t,n))return!1;const r=[];for(;n;){for(let s=0;s<n.children.length;s++){const i=n.children[s],o=n.leaf?this.toBBox(i):i;if(Ds(t,o)){if(n.leaf||go(t,o))return!0;r.push(i)}}n=r.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let r=0;r<t.length;r++)this.insert(t[r]);return this}let n=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=n;else if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){const r=this.data;this.data=n,n=r}this._insert(n,this.data.height-n.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=$n([]),this}remove(t,n){if(!t)return this;let r=this.data;const s=this.toBBox(t),i=[],o=[];let a,l,c;for(;r||i.length;){if(r||(r=i.pop(),l=i[i.length-1],a=o.pop(),c=!0),r.leaf){const u=g_(t,r.children,n);if(u!==-1)return r.children.splice(u,1),i.push(r),this._condense(i),this}!c&&!r.leaf&&go(r,s)?(i.push(r),o.push(a),a=0,l=r,r=r.children[0]):l?(a++,r=l.children[a],c=!1):r=null}return this}toBBox(t){return t}compareMinX(t,n){return t.minX-n.minX}compareMinY(t,n){return t.minY-n.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,n){const r=[];for(;t;)t.leaf?n.push(...t.children):r.push(...t.children),t=r.pop();return n}_build(t,n,r,s){const i=r-n+1;let o=this._maxEntries,a;if(i<=o)return a=$n(t.slice(n,r+1)),Bn(a,this.toBBox),a;s||(s=Math.ceil(Math.log(i)/Math.log(o)),o=Math.ceil(i/Math.pow(o,s-1))),a=$n([]),a.leaf=!1,a.height=s;const l=Math.ceil(i/o),c=l*Math.ceil(Math.sqrt(o));Wc(t,n,r,c,this.compareMinX);for(let u=n;u<=r;u+=c){const h=Math.min(u+c-1,r);Wc(t,u,h,l,this.compareMinY);for(let d=u;d<=h;d+=l){const m=Math.min(d+l-1,h);a.children.push(this._build(t,d,m,s-1))}}return Bn(a,this.toBBox),a}_chooseSubtree(t,n,r,s){for(;s.push(n),!(n.leaf||s.length-1===r);){let i=1/0,o=1/0,a;for(let l=0;l<n.children.length;l++){const c=n.children[l],u=mo(c),h=E_(t,c)-u;h<o?(o=h,i=u<i?u:i,a=c):h===o&&u<i&&(i=u,a=c)}n=a||n.children[0]}return n}_insert(t,n,r){const s=r?t:this.toBBox(t),i=[],o=this._chooseSubtree(s,this.data,n,i);for(o.children.push(t),br(o,s);n>=0&&i[n].children.length>this._maxEntries;)this._split(i,n),n--;this._adjustParentBBoxes(s,i,n)}_split(t,n){const r=t[n],s=r.children.length,i=this._minEntries;this._chooseSplitAxis(r,i,s);const o=this._chooseSplitIndex(r,i,s),a=$n(r.children.splice(o,r.children.length-o));a.height=r.height,a.leaf=r.leaf,Bn(r,this.toBBox),Bn(a,this.toBBox),n?t[n-1].children.push(a):this._splitRoot(r,a)}_splitRoot(t,n){this.data=$n([t,n]),this.data.height=t.height+1,this.data.leaf=!1,Bn(this.data,this.toBBox)}_chooseSplitIndex(t,n,r){let s,i=1/0,o=1/0;for(let a=n;a<=r-n;a++){const l=wr(t,0,a,this.toBBox),c=wr(t,a,r,this.toBBox),u=C_(l,c),h=mo(l)+mo(c);u<i?(i=u,s=a,o=h<o?h:o):u===i&&h<o&&(o=h,s=a)}return s||r-n}_chooseSplitAxis(t,n,r){const s=t.leaf?this.compareMinX:__,i=t.leaf?this.compareMinY:p_,o=this._allDistMargin(t,n,r,s),a=this._allDistMargin(t,n,r,i);o<a&&t.children.sort(s)}_allDistMargin(t,n,r,s){t.children.sort(s);const i=this.toBBox,o=wr(t,0,n,i),a=wr(t,r-n,r,i);let l=Ls(o)+Ls(a);for(let c=n;c<r-n;c++){const u=t.children[c];br(o,t.leaf?i(u):u),l+=Ls(o)}for(let c=r-n-1;c>=n;c--){const u=t.children[c];br(a,t.leaf?i(u):u),l+=Ls(a)}return l}_adjustParentBBoxes(t,n,r){for(let s=r;s>=0;s--)br(n[s],t)}_condense(t){for(let n=t.length-1,r;n>=0;n--)t[n].children.length===0?n>0?(r=t[n-1].children,r.splice(r.indexOf(t[n]),1)):this.clear():Bn(t[n],this.toBBox)}}function g_(e,t,n){if(!n)return t.indexOf(e);for(let r=0;r<t.length;r++)if(n(e,t[r]))return r;return-1}function Bn(e,t){wr(e,0,e.children.length,t,e)}function wr(e,t,n,r,s){s||(s=$n(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let i=t;i<n;i++){const o=e.children[i];br(s,e.leaf?r(o):o)}return s}function br(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function __(e,t){return e.minX-t.minX}function p_(e,t){return e.minY-t.minY}function mo(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function Ls(e){return e.maxX-e.minX+(e.maxY-e.minY)}function E_(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function C_(e,t){const n=Math.max(e.minX,t.minX),r=Math.max(e.minY,t.minY),s=Math.min(e.maxX,t.maxX),i=Math.min(e.maxY,t.maxY);return Math.max(0,s-n)*Math.max(0,i-r)}function go(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function Ds(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function $n(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Wc(e,t,n,r,s){const i=[t,n];for(;i.length;){if(n=i.pop(),t=i.pop(),n-t<=r)continue;const o=t+Math.ceil((n-t)/r/2)*r;Hc(e,o,t,n,s),i.push(t,o,o,n)}}function R_(e,t,n,r=!1){if(t===0&&n===0)return e;let s={...e};const i=s.startAbsoluteRefType||Ne.NONE,o=s.endAbsoluteRefType||Ne.NONE,a=s.rangeType||pe.NORMAL;if(!r&&i===Ne.ALL&&o===Ne.ALL)return s;const l=jc(s.startRow,n,s.startColumn,t,a),c=jc(s.endRow,n,s.endColumn,t,a);return r||i===Ne.NONE&&o===Ne.NONE?s={...s,startRow:l.row,startColumn:l.column,endRow:c.row,endColumn:c.column}:(i===Ne.NONE?s={...s,startRow:l.row,startColumn:l.column}:i===Ne.COLUMN?s={...s,startRow:l.row}:i===Ne.ROW&&(s={...s,startColumn:l.column}),o===Ne.NONE?s={...s,endRow:c.row,endColumn:c.column}:o===Ne.COLUMN?s={...s,endRow:c.row}:o===Ne.ROW&&(s={...s,endColumn:c.column}),s)}function jc(e,t,n,r,s){return s===pe.NORMAL?{row:e+t,column:n+r}:s===pe.ROW?{row:e+t,column:n}:s===pe.COLUMN?{row:e,column:n+r}:{row:e,column:n}}function _o(e){const t=new Set,n=new Set;for(const o of e)t.add(o.startColumn),t.add(o.endColumn+1),n.add(o.startRow),n.add(o.endRow+1);const r=Array.from(t).sort((o,a)=>o-a),s=Array.from(n).sort((o,a)=>o-a);e.sort((o,a)=>o.startRow-a.startRow||o.startColumn-a.startColumn);const i=[];for(let o=0;o<s.length-1;o++)for(let a=0;a<r.length-1;a++){const l=r[a],c=r[a+1]-1,u=s[o],h=s[o+1]-1;for(const d of e){if(d.startRow>h)break;if(d.startRow<=u&&d.endRow>=h&&d.startColumn<=l&&d.endColumn>=c){i.push({startColumn:l,endColumn:c,startRow:u,endRow:h});break}}}return i}function I_(e){e.sort((r,s)=>r.startRow-s.startRow||r.startColumn-s.startColumn);const t={};for(const r of e)t[r.startRow]||(t[r.startRow]=[]),t[r.startRow].push(r);const n=[];for(const r in t){const s=t[+r];s.sort((o,a)=>o.startColumn-a.startColumn);let i=s[0];for(let o=1;o<s.length;o++){const a=s[o];a.startColumn<=i.endColumn+1&&a.startRow===i.startRow&&a.endRow===i.endRow?i.endColumn=Math.max(i.endColumn,a.endColumn):(n.push(i),i=a)}n.push(i)}return n}function S_(e){e.sort((r,s)=>r.startColumn-s.startColumn||r.startRow-s.startRow);const t={};for(const r of e)t[r.startColumn]||(t[r.startColumn]=[]),t[r.startColumn].push(r);const n=[];for(const r in t){const s=t[+r];s.sort((o,a)=>o.startRow-a.startRow);let i=s[0];for(let o=1;o<s.length;o++){const a=s[o];a.startRow<=i.endRow+1&&a.startColumn===i.startColumn&&a.endColumn===i.endColumn?i.endRow=Math.max(i.endRow,a.endRow):(n.push(i),i=a)}n.push(i)}return n}function O_(e){const t=_o(e),n=I_(t);return S_(n)}function v_(e,t){const n=[];return e.forEach(r=>{n.push(...tn.subtract(r,t))}),tn.mergeRanges(n)}function Yc(e,t){const n=Gc(e.startRow,e.endRow,t.startRow,t.endRow),r=Gc(e.startColumn,e.endColumn,t.startColumn,t.endColumn);if(!n||!r)return null;const[s,i]=n,[o,a]=r,l=w_(e.rangeType,t.rangeType,s,i,o,a);return{startRow:s,endRow:i,startColumn:o,endColumn:a,rangeType:l}}function Gc(e,t,n,r){const s=isNaN(e)?-1/0:e,i=isNaN(t)?1/0:t,o=isNaN(n)?-1/0:n,a=isNaN(r)?1/0:r,l=Math.max(s,o),c=Math.min(i,a);if(l<=c){const u=l===-1/0?Number.NaN:l,h=c===1/0?Number.NaN:c;return[u,h]}else return null}function w_(e,t,n,r,s,i){const o=e!==void 0?e:Vc(n,r,s,i),a=t!==void 0?t:Vc(n,r,s,i);return o===pe.ALL||a===pe.ALL?o===a?o:o===pe.ALL?a:o:o===a?o:(o===pe.NORMAL||a===pe.NORMAL,pe.NORMAL)}function Vc(e,t,n,r){const s=!isNaN(e)&&!isNaN(t),i=!isNaN(n)&&!isNaN(r);return s&&i?pe.NORMAL:s?pe.ROW:i?pe.COLUMN:pe.ALL}const Yt=class Yt{static clone(t){return t.rangeType!==void 0?{startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn,rangeType:t.rangeType}:{startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn}}static equals(t,n){return t==null||n==null?!1:t.endRow===n.endRow&&t.endColumn===n.endColumn&&t.startRow===n.startRow&&t.startColumn===n.startColumn&&(t.rangeType===n.rangeType||t.rangeType===void 0&&n.rangeType===pe.NORMAL||n.rangeType===void 0&&t.rangeType===pe.NORMAL)}static simpleRangesIntersect(t,n){const{startRow:r,endRow:s,startColumn:i,endColumn:o}=t,{startRow:a,endRow:l,startColumn:c,endColumn:u}=n,h=r<=l&&s>=a,d=i<=u&&o>=c;return h&&d}static intersects(t,n){if(t.rangeType===pe.ROW&&n.rangeType===pe.COLUMN||t.rangeType===pe.COLUMN&&n.rangeType===pe.ROW)return!0;if(t.rangeType===pe.ROW&&n.rangeType===pe.ROW)return t.startRow<=n.endRow&&t.endRow>=n.startRow;if(t.rangeType===pe.COLUMN&&n.rangeType===pe.COLUMN)return t.startColumn<=n.endColumn&&t.endColumn>=n.startColumn;const r=Math.floor(Number.MAX_SAFE_INTEGER/10),s=Number.isNaN(t.startRow)?0:t.startRow,i=Number.isNaN(t.endRow)?r:t.endRow,o=Number.isNaN(t.startColumn)?0:t.startColumn,a=Number.isNaN(t.endColumn)?r:t.endColumn,l=Number.isNaN(n.startRow)?0:n.startRow,c=Number.isNaN(n.endRow)?r:n.endRow,u=Number.isNaN(n.startColumn)?0:n.startColumn,h=Number.isNaN(n.endColumn)?r:n.endColumn,d=Math.abs(o+a-u-h),m=Math.abs(o-a)+Math.abs(u-h),_=Math.abs(s+i-l-c),p=Math.abs(s-i)+Math.abs(l-c);return d<=m&&_<=p}static doAnyRangesIntersect(t,n){const r=new Ms;return r.load(t.map(s=>({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow}))),n.some(s=>r.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow}).length>0)}static getIntersects(t,n){const r=t.startRow,s=t.endRow,i=t.startColumn,o=t.endColumn,a=n.startRow,l=n.endRow,c=n.startColumn,u=n.endColumn;let h,d,m,_;if(a<=s)a>=r?d=a:d=r;else return null;if(l>=r)l>=s?_=s:_=l;else return null;if(c<=o)c>i?h=c:h=i;else return null;if(u>=i)u>=o?m=o:m=u;else return null;return{startRow:d,endRow:_,startColumn:h,endColumn:m,rangeType:pe.NORMAL}}static contains(t,n){return t.startRow<=n.startRow&&t.endRow>=n.endRow&&t.startColumn<=n.startColumn&&t.endColumn>=n.endColumn}static realContain(t,n){return Yt.contains(t,n)&&(t.startRow<n.startRow||t.endRow>n.endRow||t.startColumn<n.startColumn||t.endColumn>n.endColumn)}static union(...t){return t.reduce((n,r)=>({startRow:Math.min(n.startRow,r.startRow),startColumn:Math.min(n.startColumn,r.startColumn),endRow:Math.max(n.endRow,r.endRow),endColumn:Math.max(n.endColumn,r.endColumn),rangeType:pe.NORMAL}),t[0])}static realUnion(...t){const n=t.some(i=>i.rangeType===pe.COLUMN),r=t.some(i=>i.rangeType===pe.ROW),s=Yt.union(...t);return{startColumn:r?Number.NaN:s.startColumn,endColumn:r?Number.NaN:s.endColumn,startRow:n?Number.NaN:s.startRow,endRow:n?Number.NaN:s.endRow,rangeType:r?pe.ROW:n?pe.COLUMN:pe.NORMAL}}static subtract(t,n){if(n.startRow>t.endRow||n.endRow<t.startRow||n.startColumn>t.endColumn||n.endColumn<t.startColumn)return[t];const r=[];n.startRow>=t.startRow&&r.push({startRow:t.startRow,startColumn:t.startColumn,endRow:n.startRow-1,endColumn:t.endColumn}),n.endRow<=t.endRow&&r.push({startRow:n.endRow+1,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn});const s=Math.max(t.startRow,n.startRow),i=Math.min(t.endRow,n.endRow);return n.startColumn>=t.startColumn&&r.push({startRow:s,startColumn:t.startColumn,endRow:i,endColumn:n.startColumn-1}),n.endColumn<=t.endColumn&&r.push({startRow:s,startColumn:n.endColumn+1,endRow:i,endColumn:t.endColumn}),r.filter(a=>a.startRow<=a.endRow&&a.startColumn<=a.endColumn)}static mergeRanges(t){return O_(t)}static splitIntoGrid(t){return _o(t)}static subtractMulti(t,n){if(!n.length)return t;let r=t;return n.forEach(s=>{r=v_(r,s)}),r}static hasIntersectionBetweenTwoRect(t,n){return!(t.left>n.right||t.right<n.left||t.top>n.bottom||t.bottom<n.top)}static getIntersectionBetweenTwoRect(t,n){const r=Math.max(t.left,n.left),s=Math.min(t.right,n.right),i=Math.max(t.top,n.top),o=Math.min(t.bottom,n.bottom);return s<=r||o<=i?null:{left:r,right:s,top:i,bottom:o,width:s-r,height:o-i}}static sort(t){return t.sort((n,r)=>n.startRow-r.startRow||n.startColumn-r.startColumn)}};C(Yt,"getRelativeRange",(t,n)=>({startRow:t.startRow-n.startRow,endRow:t.endRow-t.startRow,startColumn:t.startColumn-n.startColumn,endColumn:t.endColumn-t.startColumn})),C(Yt,"getPositionRange",(t,n,r)=>({...r||{},startRow:r&&[Ne.ROW,Ne.ALL].includes(r.startAbsoluteRefType||0)?r.startRow:t.startRow+n.startRow,endRow:r&&[Ne.ROW,Ne.ALL].includes(r.endAbsoluteRefType||0)?r.endRow:t.endRow+t.startRow+n.startRow,startColumn:r&&[Ne.COLUMN,Ne.ALL].includes(r.startAbsoluteRefType||0)?r.startColumn:t.startColumn+n.startColumn,endColumn:r&&[Ne.COLUMN,Ne.ALL].includes(r.endAbsoluteRefType||0)?r.endColumn:t.endColumn+t.startColumn+n.startColumn})),C(Yt,"moveHorizontal",(t,n=0,r=0)=>({...t,startColumn:t.startColumn+n,endColumn:t.endColumn+n+r})),C(Yt,"moveVertical",(t,n=0,r=0)=>({...t,startRow:t.startRow+n,endRow:t.endRow+n+r})),C(Yt,"moveOffset",(t,n,r)=>{const s={...t};switch(t.startAbsoluteRefType){case Ne.ROW:s.startColumn+=n;break;case Ne.COLUMN:s.startRow+=r;break;case Ne.ALL:break;case Ne.NONE:default:s.startRow+=r,s.startColumn+=n;break}switch(t.endAbsoluteRefType){case Ne.ROW:s.endColumn+=n;break;case Ne.COLUMN:s.endRow+=r;break;case Ne.ALL:break;case Ne.NONE:default:s.endRow+=r,s.endColumn+=n;break}return s});let tn=Yt;function b_(e,t){if(e.length===0||e[0].length===0)return null;const n=new Array(e[0].length).fill(0);let r=0,s=null;for(let i=0;i<e.length;i++){for(let a=0;a<e[0].length;a++)n[a]=t(e[i][a])?n[a]+1:0;const o=A_(n);o.area>r&&(r=o.area,s={startColumn:o.start,startRow:i-o.height+1,endColumn:o.end,endRow:i})}return s}function A_(e){const t=[];let n=0,r={area:0,height:0,start:0,end:0},s=0;for(;s<e.length;)if(t.length===0||e[s]>=e[t[t.length-1]])t.push(s++);else{const i=e[t.pop()],o=t.length===0?s:s-t[t.length-1]-1;i*o>n&&(n=i*o,r={area:n,height:i,start:t.length===0?0:t[t.length-1]+1,end:s-1})}for(;t.length>0;){const i=e[t.pop()],o=t.length===0?s:s-t[t.length-1]-1;i*o>n&&(n=i*o,r={area:n,height:i,start:t.length===0?0:t[t.length-1]+1,end:s-1})}return r}function T_(e,t){xn.foreach(t,(n,r)=>{e[n][r]=void 0})}function y_(e,t){const n=e.toFullArray(),r=[];for(;;){const s=b_(n,t);if(!s)break;r.push(s),T_(n,s)}return r}class N_{constructor(t,n){C(this,"_values",[]);C(this,"_keys",[]);C(this,"_keyMaps",new Map);this._values=t,this._keys=n,t.forEach(r=>{this._initKeyMap(r)})}_initKeyMap(t){this._keys.forEach(n=>{const r=t[n],s=this._keyMaps.get(n)||new Map;s.set(r,t),this._keyMaps.set(n,s)})}getValue(t,n){const r=n||this._keys;for(let s=0;s<r.length;s++){const i=this._keyMaps.get(r[s]);if(i!=null&&i.has(t))return i.get(t)}return null}hasValue(t){for(let n=0;n<this._keys.length;n++){const r=this._keyMaps.get(this._keys[n]);if(r!=null&&r.has(t))return!0}return!1}addValue(t){this._values.push(t),this._initKeyMap(t)}setValue(t,n,r){const s=this.getValue(t);s&&Object.keys(s).includes(n)&&(s[n]=r)}deleteValue(t,n){const r=this.getValue(t,n);if(r){this._keys.forEach(i=>{const o=this._keyMaps.get(i),a=r[i];o==null||o.delete(a)});const s=this._values.findIndex(i=>i===r);this._values.splice(s,1)}}getValues(){return this._values}getKeyMap(t){var n;return[...((n=this._keyMaps.get(t))==null?void 0:n.keys())||[]]}clear(){this._values=[],this._keys=[],this._keyMaps.clear()}}function po(e,t,n,r){return{forEach(s){for(let i=e;i<=t;i++)for(let o=n;o<=r;o++)s(i,o)}}}function M_(e){if(e==null||e.length===0)return Number.NaN;const t=e.toLowerCase().split(""),n=t.length,r=o=>o.charCodeAt(0)-96;let s=0,i=0;for(let o=0;o<n;o++)i=r(t[o]),s+=i*26**(n-o-1);return s===0?Number.NaN:s-1}const Us=65,zc=90,L_=97;function D_(e){const t=zc-Us+1;let n="";for(;e>=0;)n=String.fromCharCode(e%t+Us)+n,e=Math.floor(e/t)-1;return n}function Kc(e,t){let n="";for(;t>0;)n+=e,t--;return n}function U_(e,t=!1){const n=zc-Us+1;let r=L_;t&&(r=Us);const s=String.fromCharCode(e%n+r),i=Math.floor(e/n)+1;return Kc(s,i)}function P_(e,t){return e.zIndex>t.zIndex?1:e.zIndex===t.zIndex?0:-1}function k_(e,t){return e.zIndex>t.zIndex?-1:e.zIndex===t.zIndex?0:1}function Ar(e="index",t=1){return(n,r)=>n[e]>r[e]?t:n[e]===r[e]?0:-t}var we=(e=>(e[e.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",e[e.UNIVER_DOC=1]="UNIVER_DOC",e[e.UNIVER_SHEET=2]="UNIVER_SHEET",e[e.UNIVER_SLIDE=3]="UNIVER_SLIDE",e[e.UNIVER_PROJECT=4]="UNIVER_PROJECT",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(we||{}),kt=(e=>(e[e.Reader=0]="Reader",e[e.Editor=1]="Editor",e[e.Owner=2]="Owner",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(kt||{}),Eo=(e=>(e[e.SomeCollaborator=0]="SomeCollaborator",e[e.AllCollaborator=1]="AllCollaborator",e[e.OneSelf=2]="OneSelf",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Eo||{});class Ps extends ze{}function F_(e=tt(6),t=ar.EN_US,n=""){return{id:e,locale:t,title:n,tableSource:{},drawings:{},drawingsOrder:[],headers:{},footers:{},body:{dataStream:`\r
4
4
  `,textRuns:[],customBlocks:[],tables:[],paragraphs:[{startIndex:0,paragraphStyle:{spaceAbove:{v:5},lineSpacing:1,spaceBelow:{v:0}}}],sectionBreaks:[{startIndex:1}]},documentStyle:{pageSize:{width:793.3333333333334,height:1122.6666666666667},documentFlavor:ho.TRADITIONAL,marginTop:50,marginBottom:50,marginRight:50,marginLeft:50,renderConfig:{zeroWidthParagraphBreak:ae.FALSE,vertexAngle:0,centerAngle:0,background:{rgb:"#ccc"}},autoHyphenation:ae.TRUE,doNotHyphenateCaps:ae.FALSE,consecutiveHyphenLimit:2,defaultHeaderId:"",defaultFooterId:"",evenPageHeaderId:"",evenPageFooterId:"",firstPageHeaderId:"",firstPageFooterId:"",evenAndOddHeaders:ae.FALSE,useFirstPageHeaderFooter:ae.FALSE,marginHeader:30,marginFooter:30},settings:{}}}var pn={},Tr={},ks={},Xc;function x_(){if(Xc)return ks;Xc=1,Object.defineProperty(ks,"__esModule",{value:!0});function e(r,s){if(Array.isArray(s))return!1;for(let i in r)if(!n(r[i],s[i]))return!1;for(let i in s)if(r[i]===void 0)return!1;return!0}function t(r,s){if(!Array.isArray(s)||r.length!==s.length)return!1;for(let i=0;i<r.length;i++)if(!n(r[i],s[i]))return!1;return!0}function n(r,s){return r===s?!0:r===null||s===null||typeof r!="object"||typeof s!="object"?!1:Array.isArray(r)?t(r,s):e(r,s)}return ks.default=n,ks}var Fs={},qc;function B_(){if(qc)return Fs;qc=1,Object.defineProperty(Fs,"__esModule",{value:!0});function e(t){if(t===null)return null;if(Array.isArray(t))return t.map(e);if(typeof t=="object"){const n={};for(let r in t)n[r]=e(t[r]);return n}else return t}return Fs.default=e,Fs}var Co={},Zc;function Jc(){return Zc||(Zc=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.eachChildOf=e.advancer=e.readCursor=e.writeCursor=e.WriteCursor=e.ReadCursor=e.isValidPathItem=void 0;function t(u,h){if(!u)throw new Error(h)}const n=u=>u!=null&&typeof u=="object"&&!Array.isArray(u),r=(u,h)=>typeof u==typeof h?u>h:typeof u=="string"&&typeof h=="number";function s(u,h){for(let d in u){const m=d;h.write(m,u[m])}}e.isValidPathItem=u=>typeof u=="number"||typeof u=="string"&&u!=="__proto__";class i{constructor(h=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=h}ascend(){t(this.parents.length===this.indexes.length/2),this.idx===0?this.parents.length?(this.lcIdx=this.indexes.pop(),this.container=this.parents.pop(),this.idx=this.indexes.pop()):(this.lcIdx=0,this.idx=-1):(t(this.idx>0),this.idx--,n(this.container[this.idx])&&this.idx--)}getPath(){const h=[];let d=this.container,m=this.parents.length-1,_=this.idx;for(;_>=0;)h.unshift(d[_]),_===0?(_=this.indexes[m*2],d=this.parents[m--]):_-=n(d[_-1])?2:1;return h}}class o extends i{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return t(this.container!=null,"Invalid call to getKey before cursor descended"),this.container[this.idx]}getComponent(){let h;return this.container&&this.container.length>this.idx+1&&n(h=this.container[this.idx+1])?h:null}descendFirst(){let h=this.idx+1;if(!this.container||h>=this.container.length||n(this.container[h])&&h+1>=this.container.length)return!1;n(this.container[h])&&h++;const d=this.container[h];return Array.isArray(d)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(h),this.idx=0,this.container=d):this.idx=h,!0}nextSibling(){if(t(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;const h=this.indexes[this.indexes.length-1]+1,d=this.parents[this.parents.length-1];return h>=d.length?!1:(t(!isNaN(h)),this.indexes[this.indexes.length-1]=h,this.container=d[h],!0)}_init(h,d,m,_){this.container=h,this.idx=d,this.parents=m.slice(),this.indexes=_.slice()}clone(){const h=new o;return h._init(this.container,this.idx,this.parents,this.indexes),h}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(h,d){const m=this.getComponent();m&&d(m,h);for(const _ of this)h&&h.descend(_),this.traverse(h,d),h&&h.ascend()}eachPick(h,d){this.traverse(h,(m,_)=>{m.p!=null&&d(m.p,_)})}eachDrop(h,d){this.traverse(h,(m,_)=>{m.d!=null&&d(m.d,_)})}}e.ReadCursor=o;class a extends i{constructor(h=null){super(h),this.pendingDescent=[],this._op=h}flushDescent(){t(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let h=0;h<this.pendingDescent.length;h++){const d=this.pendingDescent[h];let m=this.idx+1;if(m<this.container.length&&n(this.container[m])&&m++,t(m===this.container.length||!n(this.container[m])),m===this.container.length)this.container.push(d),this.idx=m;else if(this.container[m]===d)this.idx=m;else{if(!Array.isArray(this.container[m])){const _=this.container.splice(m,this.container.length-m);this.container.push(_),this.lcIdx>-1&&(this.lcIdx=m)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(t(r(d,this.container[this.lcIdx][0])),m=this.lcIdx+1,this.lcIdx=-1);m<this.container.length&&r(d,this.container[m][0]);)m++;if(this.indexes.push(m),this.idx=0,m<this.container.length&&this.container[m][0]===d)this.container=this.container[m];else{const _=[d];this.container.splice(m,0,_),this.container=_}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const h=this.idx+1;if(h<this.container.length&&n(this.container[h]))return this.container[h];{const d={};return this.container.splice(h,0,d),d}}write(h,d){const m=this.getComponent();t(m[h]==null||m[h]===d,"Internal consistency error: Overwritten component. File a bug"),m[h]=d}get(){return this._op}descend(h){if(!e.isValidPathItem(h))throw Error("Invalid JSON key");this.pendingDescent.push(h)}descendPath(h){return this.pendingDescent.push(...h),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(h,d=s){if(h===null)return;if(t(Array.isArray(h)),h===this._op)throw Error("Cannot merge into my own tree");const m=this.lcIdx,_=this.parents.length;let p=0;for(let I=0;I<h.length;I++){const A=h[I];typeof A=="string"||typeof A=="number"?(p++,this.descend(A)):Array.isArray(A)?this.mergeTree(A,d):typeof A=="object"&&d(A,this)}for(;p--;)this.ascend();this.lcIdx=this.parents.length===_?m:-1}at(h,d){this.descendPath(h),d(this);for(let m=0;m<h.length;m++)this.ascend();return this}writeAtPath(h,d,m){return this.at(h,()=>this.write(d,m)),this.reset(),this}writeMove(h,d,m=0){return this.writeAtPath(h,"p",m).writeAtPath(d,"d",m)}getPath(){const h=super.getPath();return h.push(...this.pendingDescent),h}}e.WriteCursor=a,e.writeCursor=()=>new a,e.readCursor=u=>new o(u);function l(u,h,d){let m,_;_=m=u?u.descendFirst():!1;function p(I){let A;for(;_;){const B=A=u.getKey();if(I!=null){let x=!1;if(h&&typeof B=="number"&&(A=h(B,u.getComponent()),A<0&&(A=~A,x=!0)),r(A,I))return null;if(A===I&&!x)return u}d&&typeof A=="number"&&d(A,u.getComponent()),_=u.nextSibling()}return null}return p.end=()=>{m&&u.ascend()},p}e.advancer=l;function c(u,h,d){let m,_,p,I;for(m=_=u&&u.descendFirst(),p=I=h&&h.descendFirst();m||p;){let A=m?u.getKey():null,B=p?h.getKey():null;A!==null&&B!==null&&(r(B,A)?B=null:A!==B&&(A=null)),d(A==null?B:A,A!=null?u:null,B!=null?h:null),A!=null&&m&&(m=u.nextSibling()),B!=null&&p&&(p=h.nextSibling())}_&&u.ascend(),I&&h.ascend()}e.eachChildOf=c}(Co)),Co}var Ro={},Qc;function eu(){return Qc||(Qc=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ConflictType=void 0,function(t){t[t.RM_UNEXPECTED_CONTENT=1]="RM_UNEXPECTED_CONTENT",t[t.DROP_COLLISION=2]="DROP_COLLISION",t[t.BLACKHOLE=3]="BLACKHOLE"}(e.ConflictType||(e.ConflictType={}))}(Ro)),Ro}var wt={},En={},tu;function Io(){return tu||(tu=1,Object.defineProperty(En,"__esModule",{value:!0}),En.uniToStrPos=En.strPosToUni=void 0,En.strPosToUni=(e,t=e.length)=>{let n=0,r=0;for(;r<t;r++){const s=e.charCodeAt(r);s>=55296&&s<=57343&&(n++,r++)}if(r!==t)throw Error("Invalid offset - splits unicode bytes");return r-n},En.uniToStrPos=(e,t)=>{let n=0;for(;t>0;t--){const r=e.charCodeAt(n);n+=r>=55296&&r<=57343?2:1}return n}),En}var So={},nu;function Oo(){return nu||(nu=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.uniSlice=e.dlen=e.eachOp=void 0;const t=Io(),n=O=>{if(!Array.isArray(O))throw Error("Op must be an array of components");let R=null;for(let b=0;b<O.length;b++){const y=O[b];switch(typeof y){case"object":if(typeof y.d!="number"&&typeof y.d!="string")throw Error("Delete must be number or string");if(e.dlen(y.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(y.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(y>0))throw Error("Skip components must be >0");if(typeof R=="number")throw Error("Adjacent skip components should be combined");break}R=y}if(typeof R=="number")throw Error("Op has a trailing skip")};function r(O,R){let b=0,y=0;for(let $=0;$<O.length;$++){const H=O[$];switch(R(H,b,y),typeof H){case"object":b+=e.dlen(H.d);break;case"string":y+=t.strPosToUni(H);break;case"number":b+=H,y+=H;break}}}e.eachOp=r;function s(O,R){const b=[],y=a(b);return r(O,($,H,g)=>{y(R($,H,g))}),h(b)}const i=O=>O,o=O=>s(O,i);e.dlen=O=>typeof O=="number"?O:t.strPosToUni(O);const a=O=>R=>{if(!(!R||R.d===0||R.d===""))if(O.length===0)O.push(R);else if(typeof R==typeof O[O.length-1])if(typeof R=="object"){const b=O[O.length-1];b.d=typeof b.d=="string"&&typeof R.d=="string"?b.d+R.d:e.dlen(b.d)+e.dlen(R.d)}else O[O.length-1]+=R;else O.push(R)},l=O=>typeof O=="number"?O:typeof O=="string"?t.strPosToUni(O):typeof O.d=="number"?O.d:t.strPosToUni(O.d);e.uniSlice=(O,R,b)=>{const y=t.uniToStrPos(O,R),$=b==null?1/0:t.uniToStrPos(O,b);return O.slice(y,$)};const c=(O,R,b)=>typeof O=="number"?b==null?O-R:Math.min(O,b)-R:e.uniSlice(O,R,b),u=O=>{let R=0,b=0;return{take:(H,g)=>{if(R===O.length)return H===-1?null:H;const P=O[R];let v;if(typeof P=="number")return H===-1||P-b<=H?(v=P-b,++R,b=0,v):(b+=H,H);if(typeof P=="string"){if(H===-1||g==="i"||t.strPosToUni(P.slice(b))<=H)return v=P.slice(b),++R,b=0,v;{const M=b+t.uniToStrPos(P.slice(b),H);return v=P.slice(b,M),b=M,v}}else{if(H===-1||g==="d"||e.dlen(P.d)-b<=H)return v={d:c(P.d,b)},++R,b=0,v;{let M=c(P.d,b,b+H);return b+=H,{d:M}}}},peek:()=>O[R]}},h=O=>(O.length>0&&typeof O[O.length-1]=="number"&&O.pop(),O);function d(O,R,b){if(b!=="left"&&b!=="right")throw Error("side ("+b+") must be 'left' or 'right'");n(O),n(R);const y=[],$=a(y),{take:H,peek:g}=u(O);for(let v=0;v<R.length;v++){const M=R[v];let T,w;switch(typeof M){case"number":for(T=M;T>0;)w=H(T,"i"),$(w),typeof w!="string"&&(T-=l(w));break;case"string":b==="left"&&typeof g()=="string"&&$(H(-1)),$(t.strPosToUni(M));break;case"object":for(T=e.dlen(M.d);T>0;)switch(w=H(T,"i"),typeof w){case"number":T-=w;break;case"string":$(w);break;case"object":T-=e.dlen(w.d)}break}}let P;for(;P=H(-1);)$(P);return h(y)}function m(O,R){n(O),n(R);const b=[],y=a(b),{take:$}=u(O);for(let g=0;g<R.length;g++){const P=R[g];let v,M;switch(typeof P){case"number":for(v=P;v>0;)M=$(v,"d"),y(M),typeof M!="object"&&(v-=l(M));break;case"string":y(P);break;case"object":v=e.dlen(P.d);let T=0;for(;T<v;)switch(M=$(v-T,"d"),typeof M){case"number":y({d:c(P.d,T,T+M)}),T+=M;break;case"string":T+=t.strPosToUni(M);break;case"object":y(M)}break}}let H;for(;H=$(-1);)y(H);return h(b)}const _=(O,R)=>{let b=0;for(let y=0;y<R.length&&O>b;y++){const $=R[y];switch(typeof $){case"number":{b+=$;break}case"string":const H=t.strPosToUni($);b+=H,O+=H;break;case"object":O-=Math.min(e.dlen($.d),O-b);break}}return O},p=(O,R)=>typeof O=="number"?_(O,R):O.map(b=>_(b,R));function I(O,R,b){return s(O,(y,$)=>typeof y=="object"&&typeof y.d=="number"?{d:b.slice(R,$,$+y.d)}:y)}function A(O){return s(O,R=>{switch(typeof R){case"object":if(typeof R.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return R.d;case"string":return{d:R};case"number":return R}})}function B(O){return s(O,R=>typeof R=="object"&&typeof R.d=="string"?{d:t.strPosToUni(R.d)}:R)}function x(O){let R=!0;return r(O,b=>{typeof b=="object"&&typeof b.d=="number"&&(R=!1)}),R}function Y(O){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:h,normalize:o,checkOp:n,create(R=""){if(typeof R!="string")throw Error("Initial data must be a string");return O.create(R)},apply(R,b){n(b);const y=O.builder(R);for(let $=0;$<b.length;$++){const H=b[$];switch(typeof H){case"number":y.skip(H);break;case"string":y.append(H);break;case"object":y.del(e.dlen(H.d));break}}return y.build()},transform:d,compose:m,transformPosition:_,transformSelection:p,isInvertible:x,makeInvertible(R,b){return I(R,b,O)},stripInvertible:B,invert:A,invertWithDoc(R,b){return A(I(R,b,O))},isNoop:R=>R.length===0}}e.default=Y}(So)),So}var xs={},ru;function $_(){if(ru)return xs;ru=1,Object.defineProperty(xs,"__esModule",{value:!0});const e=Oo(),t=Io();function n(r,s){return{get:r,getLength(){return r().length},insert(i,o,a){const l=t.strPosToUni(r(),i);return s([l,o],a)},remove(i,o,a){const l=t.strPosToUni(r(),i);return s([l,{d:o}],a)},_onOp(i){e.eachOp(i,(o,a,l)=>{switch(typeof o){case"string":this.onInsert&&this.onInsert(l,o);break;case"object":const c=e.dlen(o.d);this.onRemove&&this.onRemove(l,c)}})},onInsert:null,onRemove:null}}return xs.default=n,n.provides={text:!0},xs}var su;function H_(){return su||(su=1,function(e){var t=wt&&wt.__createBinding||(Object.create?function(d,m,_,p){p===void 0&&(p=_),Object.defineProperty(d,p,{enumerable:!0,get:function(){return m[_]}})}:function(d,m,_,p){p===void 0&&(p=_),d[p]=m[_]}),n=wt&&wt.__setModuleDefault||(Object.create?function(d,m){Object.defineProperty(d,"default",{enumerable:!0,value:m})}:function(d,m){d.default=m}),r=wt&&wt.__importStar||function(d){if(d&&d.__esModule)return d;var m={};if(d!=null)for(var _ in d)Object.hasOwnProperty.call(d,_)&&t(m,d,_);return n(m,d),m},s=wt&&wt.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(e,"__esModule",{value:!0}),e.type=e.remove=e.insert=void 0;const i=Io(),o=r(Oo()),a=s($_()),l={create(d){return d},toString(d){return d},builder(d){if(typeof d!="string")throw Error("Invalid document snapshot: "+d);const m=[];return{skip(_){let p=i.uniToStrPos(d,_);if(p>d.length)throw Error("The op is too long for this document");m.push(d.slice(0,p)),d=d.slice(p)},append(_){m.push(_)},del(_){d=d.slice(i.uniToStrPos(d,_))},build(){return m.join("")+d}}},slice:o.uniSlice},c=o.default(l),u=Object.assign(Object.assign({},c),{api:a.default});e.type=u,e.insert=(d,m)=>m.length===0?[]:d===0?[m]:[d,m],e.remove=(d,m)=>o.dlen(m)===0?[]:d===0?[{d:m}]:[d,{d:m}];var h=Oo();Object.defineProperty(e,"makeType",{enumerable:!0,get:function(){return h.default}})}(wt)),wt}var iu;function W_(){return iu||(iu=1,function(e){var t=Tr&&Tr.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(e,"__esModule",{value:!0}),e.editOp=e.replaceOp=e.insertOp=e.moveOp=e.removeOp=e.type=void 0;const n=t(x_()),r=t(B_()),s=Jc(),i=eu();function o(S,U){if(!S)throw new Error(U)}e.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:s.readCursor,writeCursor:s.writeCursor,create:S=>S,isNoop:S=>S==null,setDebug(S){},registerSubtype:A,checkValidOp:$,normalize:H,apply:g,transformPosition:P,compose:v,tryTransform:D,transform:Q,makeInvertible:w,invert:M,invertWithDoc:N,RM_UNEXPECTED_CONTENT:i.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:i.ConflictType.DROP_COLLISION,BLACKHOLE:i.ConflictType.BLACKHOLE,transformNoConflict:(S,U,G)=>ue(()=>!0,S,U,G),typeAllowingConflictsPred:S=>Object.assign(Object.assign({},e.type),{transform:(U,G,V)=>ue(S,U,G,V)})};const a=S=>S?S.getComponent():null;function l(S){return S&&typeof S=="object"&&!Array.isArray(S)}const c=S=>Array.isArray(S)?S.slice():S!==null&&typeof S=="object"?Object.assign({},S):S,u=S=>S&&(S.p!=null||S.r!==void 0),h=S=>S&&(S.d!=null||S.i!==void 0);function d(S,U){return o(S!=null),typeof U=="number"?(o(Array.isArray(S),"Invalid key - child is not an array"),(S=S.slice()).splice(U,1)):(o(l(S),"Invalid key - child is not an object"),delete(S=Object.assign({},S))[U]),S}function m(S,U,G){return typeof U=="number"?(o(S!=null,"Container is missing for key"),o(Array.isArray(S),"Cannot use numerical key for object container"),o(S.length>=U,"Cannot insert into out of bounds index"),S.splice(U,0,G)):(o(l(S),"Cannot insert into missing item"),o(S[U]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),S[U]=G),G}e.removeOp=(S,U=!0)=>s.writeCursor().writeAtPath(S,"r",U).get(),e.moveOp=(S,U)=>s.writeCursor().writeMove(S,U).get(),e.insertOp=(S,U)=>s.writeCursor().writeAtPath(S,"i",U).get(),e.replaceOp=(S,U,G)=>s.writeCursor().at(S,V=>{V.write("r",U),V.write("i",G)}).get(),e.editOp=(S,U,G,V=!1)=>s.writeCursor().at(S,W=>R(W,U,G,V)).get();const _=(S,U)=>S!=null&&(typeof U=="number"?Array.isArray(S):typeof S=="object"),p=(S,U)=>_(S,U)?S[U]:void 0,I={};function A(S){let U=S.type?S.type:S;U.name&&(I[U.name]=U),U.uri&&(I[U.uri]=U)}const B=S=>{const U=I[S];if(U)return U;throw Error("Missing type: "+S)};A(H_());const x=(S,U)=>S+U;A({name:"number",apply:x,compose:x,invert:S=>-S,transform:S=>S});const Y=S=>S==null?null:S.et?B(S.et):S.es?I["text-unicode"]:S.ena!=null?I.number:null,O=S=>S.es?S.es:S.ena!=null?S.ena:S.e,R=(S,U,G,V=!1)=>{const[W,j]=typeof U=="string"?[B(U),U]:[U,U.name];!V&&W.isNoop&&W.isNoop(G)||(j==="number"?S.write("ena",G):j==="text-unicode"?S.write("es",G):(S.write("et",j),S.write("e",G)))};function b(S){o(typeof S=="number"),o(S>=0),o(S===(0|S))}function y(S){typeof S=="number"?b(S):o(typeof S=="string")}function $(S){if(S===null)return;const U=new Set,G=new Set,V=j=>{let ee=!0,te=!1;for(let k in j){const K=j[k];if(ee=!1,o(k==="p"||k==="r"||k==="d"||k==="i"||k==="e"||k==="es"||k==="ena"||k==="et","Invalid component item '"+k+"'"),k==="p")b(K),o(!U.has(K)),U.add(K),o(j.r===void 0);else if(k==="d")b(K),o(!G.has(K)),G.add(K),o(j.i===void 0);else if(k==="e"||k==="es"||k==="ena"){o(!te),te=!0;const q=Y(j);o(q,"Missing type in edit"),q.checkValidOp&&q.checkValidOp(O(j))}}o(!ee)},W=(j,ee,te)=>{if(!Array.isArray(j))throw Error("Op must be null or a list");if(j.length===0)throw Error("Empty descent");ee||y(j[0]);let k=1,K=0,q=0;for(let re=0;re<j.length;re++){const ge=j[re];if(o(ge!=null),Array.isArray(ge)){const Ee=W(ge,!1);if(K){const X=typeof q,de=typeof Ee;X===de?o(q<Ee,"descent keys are not in order"):o(X==="number"&&de==="string")}q=Ee,K++,k=3}else typeof ge=="object"?(o(k===1,`Prev not scalar - instead ${k}`),V(ge),k=2):(o(k!==3),y(ge),o(s.isValidPathItem(ge),"Invalid path key"),k=1)}return o(K!==1,"Operation makes multiple descents. Remove some []"),o(k===2||k===3),j[0]};W(S,!0),o(U.size===G.size,"Mismatched picks and drops in op");for(let j=0;j<U.size;j++)o(U.has(j)),o(G.has(j))}function H(S){let U=0,G=[];const V=s.writeCursor();return V.mergeTree(S,(W,j)=>{const ee=Y(W);if(ee){const k=O(W);R(j,ee,ee.normalize?ee.normalize(k):k)}for(const k of["r","p","i","d"])if(W[k]!==void 0){const K=k==="p"||k==="d"?(te=W[k],G[te]==null&&(G[te]=U++),G[te]):W[k];j.write(k,K)}var te}),V.get()}function g(S,U){if($(U),U===null)return S;const G=[];return function V(W,j){let ee=W,te=0,k={root:W},K=0,q=k,re="root";function ge(){for(;K<te;K++){let Ee=j[K];typeof Ee!="object"&&(o(_(q,re)),q=q[re]=c(q[re]),re=Ee)}}for(;te<j.length;te++){const Ee=j[te];if(Array.isArray(Ee)){const X=V(ee,Ee);X!==ee&&X!==void 0&&(ge(),ee=q[re]=X)}else if(typeof Ee=="object"){Ee.d!=null?(ge(),ee=m(q,re,G[Ee.d])):Ee.i!==void 0&&(ge(),ee=m(q,re,Ee.i));const X=Y(Ee);if(X)ge(),ee=q[re]=X.apply(ee,O(Ee));else if(Ee.e!==void 0)throw Error("Subtype "+Ee.et+" undefined")}else ee=p(ee,Ee)}return k.root}(S=function V(W,j){const ee=[];let te=0;for(;te<j.length;te++){const re=j[te];if(Array.isArray(re))break;typeof re!="object"&&(ee.push(W),W=p(W,re))}for(let re=j.length-1;re>=te;re--)W=V(W,j[re]);for(--te;te>=0;te--){const re=j[te];if(typeof re!="object"){const ge=ee.pop();W=W===p(ge,re)?ge:W===void 0?d(ge,re):(K=re,q=W,(k=c(k=ge))[K]=q,k)}else u(re)&&(o(W!==void 0,"Cannot pick up or remove undefined"),re.p!=null&&(G[re.p]=W),W=void 0)}var k,K,q;return W}(S,U),U)}function P(S,U){S=S.slice(),$(U);const G=s.readCursor(U);let V,W,j=!1;const ee=[];for(let k=0;;k++){const K=S[k],q=G.getComponent();if(q&&(q.r!==void 0?j=!0:q.p!=null&&(j=!1,V=q.p,W=k)),k>=S.length)break;let re=0;const ge=s.advancer(G,void 0,(X,de)=>{u(de)&&re++});ee.unshift(ge);const Ee=ge(K);if(typeof K=="number"&&(S[k]-=re),!Ee)break}if(ee.forEach(k=>k.end()),j)return null;const te=()=>{let k=0;if(V!=null){const K=G.getPath();k=K.length,S=K.concat(S.slice(W))}for(;k<S.length;k++){const K=S[k],q=a(G),re=Y(q);if(re){const X=O(q);re.transformPosition&&(S[k]=re.transformPosition(S[k],X));break}let ge=0;const Ee=s.advancer(G,(X,de)=>h(de)?~(X-ge):X-ge,(X,de)=>{h(de)&&ge++})(K);if(typeof K=="number"&&(S[k]+=ge),!Ee)break}};return V!=null?G.eachDrop(null,k=>{k===V&&te()}):te(),S}function v(S,U){if($(S),$(U),S==null)return U;if(U==null)return S;let G=0;const V=s.readCursor(S),W=s.readCursor(U),j=s.writeCursor(),ee=[],te=[],k=[],K=[],q=[],re=[],ge=new Set;V.traverse(null,X=>{X.p!=null&&(k[X.p]=V.clone())}),W.traverse(null,X=>{X.d!=null&&(K[X.d]=W.clone())});const Ee=s.writeCursor();return function X(de,Fe,Le,Oe,$e,Gt,rt,Qe){o(Fe||Le);const He=a(Fe),It=a(Le),Tt=!!It&&It.r!==void 0,On=!!He&&He.i!==void 0,St=He?He.d:null,ft=It?It.p:null,Vt=(Gt||Tt)&&ft==null;if(ft!=null)Oe=K[ft],rt=te[ft]=new s.WriteCursor;else if(It&&It.r!==void 0)Oe=null;else{const ie=a(Oe);ie&&ie.d!=null&&(Oe=null)}const Te=a(Oe);if(St!=null)if(de=k[St],Qe=ee[St]=new s.WriteCursor,Vt)Gt&&!Tt&&Qe.write("r",!0);else{const ie=q[St]=G++;rt.write("d",ie)}else if(He&&He.i!==void 0)de=null;else{const ie=a(de);ie&&ie.p!=null&&(de=null)}let ce;On?(o($e===void 0),ce=He.i):ce=$e;const Ie=(ft==null?!On||Gt||Tt:ce===void 0)?null:rt.getComponent();if(ft!=null){if(!($e!==void 0||On)){const ie=St!=null?q[St]:G++;re[ft]=ie,Qe.write("p",ie)}}else Tt&&(On||$e!==void 0||(It.r,Qe.write("r",It.r)));const he=Vt?null:Y(He),se=Y(Te);if((he||se)&&(he&&he.name,se&&se.name),he&&se){o(he===se);const ie=O(He),Se=O(Te),Xe=he.compose(ie,Se);R(rt,he,Xe),ge.add(Te)}else he?R(rt,he,O(He)):se&&(R(rt,se,O(Te)),ge.add(Te));const me=typeof ce=="object"&&ce!=null;let Ae=!1,be=0,ye=0,Ke=0,Ve=0,We=0;const nt=s.advancer(Oe,(ie,Se)=>h(Se)?Ve-ie-1:ie-Ve,(ie,Se)=>{h(Se)&&Ve++}),ve=s.advancer(de,(ie,Se)=>u(Se)?be-ie-1:ie-be,(ie,Se)=>{u(Se)&&be++});if(s.eachChildOf(Fe,Le,(ie,Se,Xe)=>{let it,zt,vn=ie,yt=ie,zr=ie;if(typeof ie=="number"){let et=ie+Ke;zt=nt(et),yt=et+Ve;let Ye=ie+ye;it=ve(Ye),h(a(zt))&&(it=null),vn=Ye+be,zr=ie+We,o(vn>=0,"p1PickKey is negative"),o(yt>=0,"p2DropKey is negative");const Nt=h(a(Se)),Kt=u(a(Xe));(Nt||Kt&&!Vt)&&We--,Nt&&ye--,Kt&&Ke--}else it=ve(ie),zt=nt(ie);Qe.descend(vn),rt.descend(yt);const Qn=me&&!h(a(Se))?ce[zr]:void 0,xt=X(it,Se,Xe,zt,Qn,Vt,rt,Qe);var Bt,_e,Be;me&&!Vt?Qn!==xt&&(Ae||(ce=Array.isArray(ce)?ce.slice():Object.assign({},ce),Ae=!0),Bt=ce,Be=xt,typeof(_e=zr)=="number"?(o(Array.isArray(Bt)),o(_e<Bt.length)):(o(!Array.isArray(Bt)),o(Bt[_e]!==void 0)),Be===void 0?typeof _e=="number"?Bt.splice(_e,1):delete Bt[_e]:Bt[_e]=Be):o(xt===void 0),rt.ascend(),Qe.ascend()}),ve.end(),nt.end(),Ie!=null)Ie.i=ce;else if(!Gt&&!Tt&&ft==null)return ce}(V,V.clone(),W,W.clone(),void 0,!1,j,Ee),j.reset(),j.mergeTree(Ee.get()),j.reset(),j.get(),ee.map(X=>X.get()),te.map(X=>X.get()),V.traverse(j,(X,de)=>{const Fe=X.p;if(Fe!=null){const Le=q[Fe];Le!=null&&de.write("p",Le);const Oe=ee[Fe];Oe&&Oe.get(),Oe&&de.mergeTree(Oe.get())}else X.r!==void 0&&de.write("r",X.r)}),j.reset(),j.get(),W.traverse(j,(X,de)=>{const Fe=X.d;if(Fe!=null){const Oe=re[Fe];Oe!=null&&de.write("d",Oe);const $e=te[Fe];$e&&de.mergeTree($e.get())}else X.i!==void 0&&de.write("i",X.i);const Le=Y(X);Le&&!ge.has(X)&&R(de,Le,O(X))}),j.get()}function M(S){if(S==null)return null;const U=new s.ReadCursor(S),G=new s.WriteCursor;let V;const W=[],j=[];return function ee(te,k,K){const q=te.getComponent();let re,ge=!1;if(q){q.p!=null&&(k.write("d",q.p),W[q.p]=te.clone()),q.r!==void 0&&k.write("i",q.r),q.d!=null&&(k.write("p",q.d),K=void 0),q.i!==void 0&&(K=re=q.i);const X=Y(q);X&&(K===void 0?(V||(V=new Set),V.add(q)):(O(q),K=X.apply(K,O(q)),ge=!0))}let Ee=0;for(const X of te){k.descend(X);const de=typeof X=="number"?X-Ee:X,Fe=p(K,de);h(te.getComponent())&&Ee++;const Le=ee(te,k,Fe);if(K!==void 0&&Le!==void 0){if(ge||(ge=!0,K=c(K)),!_(K,de))throw Error("Cannot modify child - invalid operation");K[de]=Le}k.ascend()}if(re===void 0)return ge?K:void 0;k.write("r",K)}(U,G,void 0),V&&(G.reset(),function ee(te,k,K){const q=k.getComponent();if(q){const X=q.d;if(X!=null&&(te=W[X],K=j[X]=s.writeCursor()),V.has(q)){const de=Y(q);if(!de.invert)throw Error(`Cannot invert subtype ${de.name}`);R(K,de,de.invert(O(q)))}}let re=0,ge=0;const Ee=s.advancer(te,(X,de)=>u(de)?re-X-1:X-re,(X,de)=>{u(de)&&re++});for(const X of k)if(typeof X=="number"){const de=X-ge,Fe=Ee(de),Le=de+re;K.descend(Le),ee(Fe,k,K),h(k.getComponent())&&ge++,K.ascend()}else K.descend(X),ee(Ee(X),k,K),K.ascend();Ee.end()}(U.clone(),U,G),j.length&&(G.reset(),U.traverse(G,(ee,te)=>{const k=ee.p;if(k!=null){const K=j[k];K&&K.get(),K&&te.mergeTree(K.get())}}))),G.get()}const T=(S,U)=>S.some(G=>typeof G=="object"&&(Array.isArray(G)?T(G,U):U(G)));function w(S,U){if(S==null||!T(S,k=>{var K;return k.r!==void 0||((K=Y(k))===null||K===void 0?void 0:K.makeInvertible)!=null}))return S;const G=new s.ReadCursor(S),V=new s.WriteCursor;let W=!1;const j=[],ee=[],te=(k,K,q)=>{const re=k.getComponent();let ge=!1;if(re){re.d!=null&&K.write("d",re.d),re.i!==void 0&&K.write("i",re.i);const X=re.p;if(X!=null&&(j[X]=k.clone(),o(q!==void 0,"Operation picks up at an invalid key"),ee[X]=q,K.write("p",re.p)),re.r!==void 0&&q===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const de=Y(re);de&&(de.makeInvertible?W=!0:R(K,de,O(re),!0))}let Ee=0;for(const X of k){K.descend(X);const de=typeof X=="number"?X-Ee:X,Fe=p(q,de),Le=te(k,K,Fe);Fe!==Le&&(ge||(ge=!0,q=c(q)),Le===void 0?(q=d(q,de),typeof X=="number"&&Ee++):q[de]=Le),K.ascend()}return re&&(re.r!==void 0?(K.write("r",r.default(q)),q=void 0):re.p!=null&&(q=void 0)),q};return te(G,V,U),V.get(),W&&(V.reset(),function k(K,q,re,ge,Ee){const X=q.getComponent();if(X){X.i!==void 0?(ge=X.i,Ee=!0):X.d!=null&&(ge=ee[X.d],K=j[X.d],Ee=!1,X.d);let Oe=Y(X);if(Oe&&Oe.makeInvertible){const $e=O(X);R(re,Oe,Oe.makeInvertible($e,ge),!0)}}let de=0,Fe=0;const Le=s.advancer(K,(Oe,$e)=>u($e)?de-Oe-1:Oe-de,(Oe,$e)=>{u($e)&&de++});for(const Oe of q)if(typeof Oe=="number"){const $e=Oe-Fe,Gt=Le($e),rt=$e+de,Qe=p(ge,Ee?$e:rt);re.descend(Oe),k(Gt,q,re,Qe,Ee),h(q.getComponent())&&Fe++,re.ascend()}else{const $e=p(ge,Oe);re.descend(Oe),k(Le(Oe),q,re,$e,Ee),re.ascend()}Le.end()}(G.clone(),G,V,U,!1)),V.get()}function N(S,U){return M(w(S,U))}const L=S=>{if(S==null)return null;const U=S.slice();for(let G=0;G<S.length;G++){const V=U[G];Array.isArray(V)&&(U[G]=L(V))}return U};function D(S,U,G){o(G==="left"||G==="right","Direction must be left or right");const V=G==="left"?0:1;if(U==null)return{ok:!0,result:S};$(S),$(U);let W=null;const j=[],ee=[],te=[],k=[],K=[],q=[],re=[],ge=[],Ee=[],X=[],de=[],Fe=[],Le=[],Oe=[],$e=[];let Gt=0;const rt=s.readCursor(S),Qe=s.readCursor(U),He=s.writeCursor();if(function Te(ce,Ie=null,he){const se=a(Ie);se&&(se.r!==void 0?he=Ie.clone():se.p!=null&&(he=null,q[se.p]=ce.clone()));const me=ce.getComponent();let Ae;me&&(Ae=me.p)!=null&&(K[Ae]=Ie?Ie.clone():null,te[Ae]=ce.clone(),he&&(X[Ae]=!0,Ee[Ae]=he),se&&se.p!=null&&(Oe[Ae]=se.p));const be=s.advancer(Ie);for(const ye of ce)Te(ce,be(ye),he);be.end()}(Qe,rt,null),function Te(ce,Ie,he,se,me){const Ae=he.getComponent();let be,ye=!1;Ae&&((be=Ae.d)!=null?(k[be]=he.clone(),se!=null&&($e[se]==null&&($e[se]=[]),$e[se].push(be)),X[be],ce=K[be]||null,Ie=te[be]||null,X[be]?(me&&(de[be]=!0),me=Ee[be]||null):!me||V!==1&&Oe[be]!=null||W==null&&(W={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(me.getPath()),op2:e.moveOp(Ie.getPath(),he.getPath())}),ye=!0):Ae.i!==void 0&&(ce=Ie=null,ye=!0,me&&W==null&&(W={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(me.getPath()),op2:e.insertOp(he.getPath(),Ae.i)})));const Ke=a(ce);Ke&&(Ke.r!==void 0?me=ce.clone():Ke.p!=null&&(Ke.p,se=Ke.p,me=null));const Ve=Y(Ae);Ve&&me&&W==null&&(W={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(me.getPath()),op2:e.editOp(he.getPath(),Ve,O(Ae),!0)});let We=0,nt=0;const ve=s.advancer(Ie,(Se,Xe)=>u(Xe)?We-Se-1:Se-We,(Se,Xe)=>{u(Xe)&&We++}),ie=s.advancer(ce);for(const Se of he)if(typeof Se=="number"){const Xe=Se-nt,it=ve(Xe);nt+=+Te(ie(Xe+We),it,he,se,me)}else{const Xe=ve(Se);Te(ie(Se),Xe,he,se,me)}return ve.end(),ie.end(),ye}(rt,Qe,Qe.clone(),null,null),k.map(Te=>Te&&Te.get()),W)return{ok:!1,conflict:W};de.map(Te=>!!Te);const It=[];let Tt=null;(function Te(ce,Ie,he,se,me){let Ae=!1;const be=a(Ie);if(u(be)){const ve=be.p;ve!=null?(he=k[ve],se=Fe[ve]=s.writeCursor(),Ae=!0,me=null):(he=null,me=Ie.clone())}else h(a(he))&&(he=null);const ye=ce.getComponent();if(ye){const ve=ye.p;ve!=null?(me&&(ge[ve]=me),It[ve]=me||V===1&&Ae?null:se.getComponent(),j[ve]=ce.clone(),he&&(re[ve]=he.clone())):ye.r!==void 0&&(me||se.write("r",!0),(me||Ae)&&(Tt==null&&(Tt=new Set),Tt.add(ye)))}let Ke=0,Ve=0;const We=s.advancer(Ie,void 0,(ve,ie)=>{u(ie)&&Ke++}),nt=s.advancer(he,(ve,ie)=>h(ie)?~(ve-Ve):ve-Ve,(ve,ie)=>{h(ie)&&Ve++});if(ce)for(const ve of ce)if(typeof ve=="string"){const ie=We(ve),Se=nt(ve);se.descend(ve),Te(ce,ie,Se,se,me),se.ascend()}else{const ie=We(ve),Se=ve-Ke,Xe=u(a(ie))?null:nt(Se),it=Se+Ve;o(it>=0),se.descend(it),Te(ce,ie,Xe,se,me),se.ascend()}We.end(),nt.end()})(rt,Qe,Qe.clone(),He,null),He.reset();let On=[];if(function Te(ce,Ie,he,se,me,Ae){o(Ie);const be=Ie.getComponent();let ye=a(se),Ke=!1;const Ve=(_e,Be,et)=>_e?e.moveOp(_e.getPath(),Be.getPath()):e.insertOp(Be.getPath(),et.i);if(h(be)){const _e=be.d;_e!=null&&(ee[_e]=Ie.clone());const Be=_e!=null?It[_e]:null;let et=!1;if(be.i!==void 0||_e!=null&&Be){let Ye;ye&&(ye.i!==void 0||(Ye=ye.d)!=null&&!X[Ye])&&(et=Ye!=null?_e!=null&&_e===Oe[Ye]:n.default(ye.i,be.i),et||Ye!=null&&V!==1&&Oe[Ye]!=null||W==null&&(W={type:i.ConflictType.DROP_COLLISION,op1:Ve(_e!=null?j[_e]:null,Ie,be),op2:Ve(Ye!=null?te[Ye]:null,se,ye)})),et||(Ae?W==null&&(W={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:Ve(_e!=null?j[_e]:null,Ie,be),op2:e.removeOp(Ae.getPath())}):(_e!=null?(On[Gt]=_e,me.write("d",Be.p=Gt++)):me.write("i",r.default(be.i)),Ke=!0))}else if(_e!=null&&!Be){const Ye=ge[_e];Ye&&(Ae=Ye.clone())}_e!=null?(ce=j[_e],he=q[_e],se=re[_e]):be.i!==void 0&&(ce=he=null,et||(se=null))}else u(a(ce))&&(ce=he=se=null);const We=a(ce),nt=a(he);if(u(nt)){const _e=nt.p;nt.r!==void 0&&(!We||We.r===void 0)||X[_e]?(se=null,Ae=he.clone()):_e!=null&&(se=k[_e],V!==1&&Oe[_e]!=null||((me=Le[_e])||(me=Le[_e]=s.writeCursor()),me.reset(),Ae=null))}else!h(be)&&h(ye)&&(se=null);ye=se!=null?se.getComponent():null;const ve=Y(be);if(ve){const _e=O(be);if(Ae)W==null&&(W={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.editOp(Ie.getPath(),ve,_e,!0),op2:e.removeOp(Ae.getPath())});else{const Be=Y(ye);let et;if(Be){if(ve!==Be)throw Error("Transforming incompatible types");const Ye=O(ye);et=ve.transform(_e,Ye,G)}else et=r.default(_e);R(me,ve,et)}}let ie=0,Se=0,Xe=0,it=0,zt=0,vn=0,yt=ce!=null&&ce.descendFirst(),zr=yt;const Qn=s.advancer(he,void 0,(_e,Be)=>{u(Be)&&Xe++});let xt=se!=null&&se.descendFirst(),Bt=xt;for(const _e of Ie)if(typeof _e=="number"){let Be;const et=h(Ie.getComponent()),Ye=_e-Se;{let ln;for(;yt&&typeof(ln=ce.getKey())=="number";){ln+=ie;const Mt=ce.getComponent(),er=u(Mt);if(ln>Ye||ln===Ye&&(!er||V===0&&et))break;if(er){ie--;const wn=Mt.p;Oe.includes(wn),Mt.d,a(Le[Mt.d]),u(a(Le[Mt.d])),(Mt.r===void 0||Tt&&Tt.has(Mt))&&(wn==null||!It[wn]||V!==1&&Oe.includes(wn))||zt--}yt=ce.nextSibling()}Be=yt&&ln===Ye?ce:null}const Nt=Ye-ie;let Kt=Qn(Nt);const da=Nt-Xe;let Qs=null;{let ln,Mt;for(;xt&&typeof(ln=se.getKey())=="number";){Mt=ln-it;const er=se.getComponent(),wn=h(er);if(Mt>da)break;if(Mt===da){if(!wn){Qs=se;break}{if(V===0&&et){Qs=se;break}const cn=Kt&&u(Kt.getComponent());if(V===0&&cn)break}}if(wn){const cn=er.d;X[cn],Oe[cn],er.i===void 0&&(X[cn]||Oe[cn]!=null&&V!==1)?(X[cn]||Oe[cn]!=null&&V===0)&&(it++,vn--):it++}xt=se.nextSibling()}}const Id=da+it+zt+vn;o(Id>=0,"trying to descend to a negative index"),me.descend(Id),et&&(Be=Kt=Qs=null,Se++),Te(Be,Ie,Kt,Qs,me,Ae)&&vn++,me.ascend()}else{let Be;for(;yt&&(Be=ce.getKey(),typeof Be!="string"||!(Be>_e||Be===_e));)yt=ce.nextSibling();const et=yt&&Be===_e?ce:null,Ye=Qn(_e);let Nt;for(;xt&&(Nt=se.getKey(),typeof Nt!="string"||!(Nt>_e||Nt===_e));)xt=se.nextSibling();const Kt=xt&&Nt===_e?se:null;me.descend(_e),Te(et,Ie,Ye,Kt,me,Ae),me.ascend()}return Qn.end(),zr&&ce.ascend(),Bt&&se.ascend(),Ke}(rt,rt.clone(),Qe,Qe.clone(),He,null),W)return{ok:!1,conflict:W};He.reset();const St=(Te,ce,Ie)=>Te.traverse(ce,(he,se)=>{he.d!=null&&Ie(he.d,Te,se)});(X.length||Fe.length)&&(St(Qe,He,(Te,ce,Ie)=>{X[Te]&&!de[Te]&&Ie.write("r",!0),Fe[Te]&&Ie.mergeTree(Fe[Te].get())}),He.reset());const ft=[],Vt=[];if((Le.length||X.length)&&!W){const Te=s.readCursor(L(He.get()));if(St(Te,null,(ce,Ie)=>{ft[ce]=Ie.clone()}),Le.forEach(ce=>{ce&&St(s.readCursor(ce.get()),null,(Ie,he)=>{ft[Ie]=he.clone()})}),function ce(Ie,he,se,me,Ae,be){const ye=a(he);if(ye&&u(ye))if(ye.p!=null){const ie=ye.p;ft[ie].getPath(),se=ft[ie],me=Vt[ie]=s.writeCursor()}else ye.r!==void 0&&(se=null);else h(a(se))&&(se=null);const Ke=Ie.getComponent();if(Ke){let ie;if((ie=Ke.d)!=null){const Se=Le[ie];Se&&(Se.get(),me.mergeTree(Se.get()),se=s.readCursor(Se.get()))}}let Ve=0,We=0;const nt=s.advancer(he,void 0,(ie,Se)=>{u(Se)&&Ve--}),ve=s.advancer(se,(ie,Se)=>h(Se)?-(ie-We)-1:ie-We,(ie,Se)=>{h(Se)&&We++});for(const ie of Ie)if(typeof ie=="number"){const Se=nt(ie),Xe=ie+Ve,it=ve(Xe),zt=Xe+We;me.descend(zt),ce(Ie,Se,it,me),me.ascend()}else me.descend(ie),ce(Ie,nt(ie),ve(ie),me),me.ascend();nt.end(),ve.end()}(Qe,Te,Te.clone(),He),He.reset(),W)return{ok:!1,conflict:W};if(He.get(),Vt.length){const ce=Vt.map(he=>he?he.get():null),Ie=s.readCursor(L(He.get()));if(St(Ie,He,(he,se,me)=>{const Ae=ce[he];Ae&&(me.mergeTree(Ae),ce[he]=null)}),ce.find(he=>he)){const he=s.writeCursor(),se=s.writeCursor();let me=0,Ae=0;ce.forEach(be=>{be!=null&&St(s.readCursor(be),null,ye=>{const Ke=On[ye];he.writeMove(j[Ke].getPath(),ee[Ke].getPath(),me++);const Ve=$e[Ke];Ve&&Ve.forEach(We=>{X[We]||V!==1&&Oe[We]!=null||se.writeMove(te[We].getPath(),k[We].getPath(),Ae++)})})}),W={type:i.ConflictType.BLACKHOLE,op1:he.get(),op2:se.get()}}}}return W?{ok:!1,conflict:W}:{ok:!0,result:He.get()}}const F=S=>{const U=new Error("Transform detected write conflict");throw U.conflict=S,U.type=U.name="writeConflict",U};function Q(S,U,G){const V=D(S,U,G);if(V.ok)return V.result;F(V.conflict)}const z=S=>{const U=s.writeCursor();return s.readCursor(S).traverse(U,(G,V)=>{(h(G)||Y(G))&&V.write("r",!0)}),U.get()},le=(S,U)=>{const{type:G,op1:V,op2:W}=S;switch(G){case i.ConflictType.DROP_COLLISION:return U==="left"?[null,z(W)]:[z(V),null];case i.ConflictType.RM_UNEXPECTED_CONTENT:let j=!1;return s.readCursor(V).traverse(null,ee=>{ee.r!==void 0&&(j=!0)}),j?[null,z(W)]:[z(V),null];case i.ConflictType.BLACKHOLE:return[z(V),z(W)];default:throw Error("Unrecognised conflict: "+G)}};function ue(S,U,G,V){let W=null;for(;;){const j=D(U,G,V);if(j.ok)return v(W,j.result);{const{conflict:ee}=j;S(ee)||F(ee);const[te,k]=le(ee,V);U=v(H(U),te),G=v(H(G),k),W=v(W,k)}}}}(Tr)),Tr}var ou;function j_(){return ou||(ou=1,function(e){var t=pn&&pn.__createBinding||(Object.create?function(i,o,a,l){l===void 0&&(l=a),Object.defineProperty(i,l,{enumerable:!0,get:function(){return o[a]}})}:function(i,o,a,l){l===void 0&&(l=a),i[l]=o[a]}),n=pn&&pn.__exportStar||function(i,o){for(var a in i)a!=="default"&&!o.hasOwnProperty(a)&&t(o,i,a)};Object.defineProperty(e,"__esModule",{value:!0}),n(W_(),e);var r=Jc();Object.defineProperty(e,"ReadCursor",{enumerable:!0,get:function(){return r.ReadCursor}}),Object.defineProperty(e,"WriteCursor",{enumerable:!0,get:function(){return r.WriteCursor}});var s=eu();Object.defineProperty(e,"ConflictType",{enumerable:!0,get:function(){return s.ConflictType}})}(pn)),pn}var at=j_();const Y_=Sd({__proto__:null,default:mt(at)},[at]);var J=(e=>(e.RETAIN="r",e.INSERT="i",e.DELETE="d",e))(J||{});function yr(e,t=!1){const n=[];for(const r of e){const{st:s,ed:i,ts:o}=r;if(r.sId===void 0&&delete r.sId,s===i||!t&&Z.isEmptyObject(o)&&r.sId==null)continue;if(n.length===0){n.push(r);continue}const a=n.pop();ml(r,a)&&Z.hasIntersectionBetweenTwoRanges(a.st,a.ed,r.st,r.ed)?n.push({...r,st:a.st,ed:i}):n.push(a,r)}return n}function au(e,t,n,r){var c;const{textRuns:s}=e;if(s==null)return;const i=[],o=s.length;let a=!1;const l=(c=t.textRuns)!=null?c:[];if(l.length)for(const u of l)u.st+=r,u.ed+=r;for(let u=0;u<o;u++){const h=s[u],{st:d,ed:m}=h;if(m<=r)i.push(h);else if(r>d&&r<m){a=!0;const _={...h,ed:r};i.push(_),l.length&&i.push(...l);const p={...h,st:r+n,ed:m+n};i.push(p)}else h.st+=n,h.ed+=n,a||(a=!0,i.push(...l)),i.push(h)}a||(a=!0,i.push(...l)),e.textRuns=yr(i)}function lu(e,t,n,r){const{paragraphs:s}=e;if(s==null)return;const{paragraphs:i}=t,o=[];for(let l=0,c=s.length;l<c;l++){const u=s[l],{startIndex:h}=u;h>=r&&(u.startIndex+=n),o.push(u.startIndex)}let a=-1;if(i){for(let l=0,c=i.length;l<c;l++){const u=i[l];u.startIndex+=r;const h=u.startIndex;a=o.indexOf(h)}a!==-1&&s.splice(a,1),s.push(...i),s.sort(Ar("startIndex"))}}function cu(e,t,n,r){const{sectionBreaks:s}=e;if(s==null)return;for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:c}=l;c>=r&&(l.startIndex+=n)}const i=t.sectionBreaks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=r}s.push(...i),s.sort(Ar("startIndex"))}}function uu(e,t,n,r){const{customBlocks:s=[]}=e;for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:c}=l;c>=r&&(l.startIndex+=n)}const i=t.customBlocks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=r}s.push(...i),s.sort(Ar("startIndex"))}s.length&&!e.customBlocks&&(e.customBlocks=s)}function hu(e,t,n,r){const{tables:s}=e;if(s==null)return;for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:c,endIndex:u}=l;c>r?(l.startIndex+=n,l.endIndex+=n):u>r&&(l.endIndex+=n)}const i=t.tables;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=r,l.endIndex+=r}s.push(...i),s.sort(Ar("startIndex"))}}const du="$",fu=e=>e.split(du)[0];function vo(e){if(e.length<=1)return e;e.sort((s,i)=>s.startIndex-i.startIndex);const t=[];let n={...e[0]};n.rangeId=fu(n.rangeId);for(let s=1;s<e.length;s++){const i=e[s];i.rangeId=fu(i.rangeId),i.rangeId===n.rangeId&&Ia(n.properties,i.properties)&&n.endIndex+1>=i.startIndex?n.endIndex=i.endIndex:(t.push(n),n={...i})}t.push(n);const r=Object.create(null);for(let s=0,i=t.length;s<i;s++){const o=t[s],a=o.rangeId;r[a]?(o.rangeId=`${a}${du}${r[a]}`,r[a]=r[a]+1):r[a]=1}return t}function wo(e,t){const n=e.findIndex(s=>s.startIndex<t&&s.endIndex>=t),r=e[n];r&&e.splice(n,1,{rangeId:r.rangeId,rangeType:r.rangeType,startIndex:r.startIndex,endIndex:t-1,properties:{...r.properties}},{rangeId:r.rangeId,rangeType:r.rangeType,startIndex:t,endIndex:r.endIndex,properties:{...r.properties}})}function mu(e){if(e.length<=1)return e;e.sort((r,s)=>r.startIndex-s.startIndex);const t=[];let n={...e[0]};for(let r=1;r<e.length;r++){const s=e[r];s.id===n.id&&n.endIndex+1>=s.startIndex?n.endIndex=s.endIndex:(t.push(n),n={...s})}return t.push(n),t}function bo(e,t){e.filter(r=>r.startIndex<t&&r.endIndex>=t).forEach(r=>{const s=e.indexOf(r);e.splice(s,1,{id:r.id,type:r.type,startIndex:r.startIndex,endIndex:t-1},{id:r.id,type:r.type,startIndex:t,endIndex:r.endIndex})})}function G_(e,t,n,r){e.customRanges||(e.customRanges=[]);const{customRanges:s}=e;wo(s,r);for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:c}=l;c>=r&&(l.startIndex+=n,l.endIndex+=n)}const i=[];if(t.customRanges){for(let o=0,a=t.customRanges.length;o<a;o++){const l=t.customRanges[o];l.startIndex+=r,l.endIndex+=r,i.push(l)}s.push(...i)}e.customRanges=vo(s)}function V_(e,t,n,r){e.customDecorations||(e.customDecorations=[]);const{customDecorations:s}=e;bo(s,r);for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:c}=l;c>=r&&(l.startIndex+=n,l.endIndex+=n)}const i=[];if(t.customDecorations){for(let o=0,a=t.customDecorations.length;o<a;o++){const l=t.customDecorations[o];l.startIndex+=r,l.endIndex+=r,i.push(l)}s.push(...i)}e.customDecorations=mu(s)}function gu(e,t,n){const{textRuns:r}=e,s=n,i=n+t,o=[];if(r){const a=[];for(let l=0,c=r.length;l<c;l++){const u=r[l],{st:h,ed:d}=u;if(s<=h&&i>=d){o.push({...u,st:h-s,ed:d-s});continue}else h<=s&&d>=i?(o.push({...u,st:s-s,ed:i-s}),u.ed-=t):s>=h&&s<d?(o.push({...u,st:s-s,ed:d-s}),u.ed=s):i>h&&i<=d?(o.push({...u,st:h-s,ed:i-s}),u.st=i-t,u.ed-=t):h>=i&&(u.st-=t,u.ed-=t);a.push(u)}e.textRuns=a}return o.length===0&&o.push({st:0,ed:t,ts:{}}),o}function _u(e,t,n){const{paragraphs:r}=e,s=n,i=n+t,o=[];if(r){const a=[];for(let l=0,c=r.length;l<c;l++){const u=r[l],{startIndex:h}=u;if(h>=s&&h<i){o.push({...u,startIndex:h-n});continue}else h>=i&&(u.startIndex-=t);a.push(u)}e.paragraphs=a}return o}function pu(e,t,n){const{sectionBreaks:r}=e,s=n,i=n+t-1,o=[];if(r){const a=[];for(let l=0,c=r.length;l<c;l++){const u=r[l],{startIndex:h}=u;if(h>=s&&h<=i){o.push({...u,startIndex:h-n});continue}else h>i&&(u.startIndex-=t);a.push(u)}e.sectionBreaks=a}return o}function Eu(e,t,n){const{customBlocks:r=[]}=e,s=n,i=n+t-1,o=[];if(r){const a=[];for(let l=0,c=r.length;l<c;l++){const u=r[l],{startIndex:h}=u;if(h>=s&&h<=i){o.push({...u,startIndex:h-n});continue}else h>i&&(u.startIndex-=t);a.push(u)}e.customBlocks=a}return r.length&&!e.customBlocks&&(e.customBlocks=r),o}function Cu(e,t,n){const{tables:r}=e,s=n,i=n+t-1,o=[];if(r){const a=[];for(let l=0,c=r.length;l<c;l++){const u=r[l],{startIndex:h,endIndex:d}=u;if(s<=h&&i>=d){o.push({...u,startIndex:h-n,endIndex:d-n});continue}else if(h<=s&&d>=i){const m=Cs(h,d,s,i);if(m.length===0||(u.startIndex=m[0],u.endIndex=m[1],u.startIndex===u.endIndex))continue}else i<h&&(u.startIndex-=t,u.endIndex-=t);a.push(u)}e.tables=a}return o}function z_(e,t,n){const{customRanges:r}=e,s=n,i=n+t-1,o=[];if(r){const a=[];for(let l=0,c=r.length;l<c;l++){const u=r[l],{startIndex:h,endIndex:d}=u;if(h>=s&&d<=i){o.push(u);continue}else if(Math.max(s,h)<=Math.min(i,d)){const m=Cs(h,d,s,i);if(m.length===0)continue;u.startIndex=m[0],u.endIndex=m[1]}else i<h&&(u.startIndex-=t,u.endIndex-=t);a.push(u)}e.customRanges=vo(a)}return o}function K_(e,t,n,r=!0){const{customDecorations:s}=e,i=n,o=n+t-1,a=[];if(s){const l=[];for(let c=0,u=s.length;c<u;c++){const h=s[c],{startIndex:d,endIndex:m}=h;if(d>=i&&m<=o){a.push(h);continue}else if(Math.max(i,d)<=Math.min(o,m)){const _=Cs(d,m,i,o);if(_.length===0)continue;h.startIndex=_[0],h.endIndex=_[1]}else o<d&&r&&(h.startIndex-=t,h.endIndex-=t);l.push(h)}e.customDecorations=l}return a}var Ru=(e=>(e.ORDER_LIST_QUICK_1="1.",e.ORDER_LIST_QUICK_2="a)",e.ORDER_LIST_QUICK_3="a.",e.ORDER_LIST_QUICK_4="i.",e.ORDER_LIST_QUICK_5="A.",e.ORDER_LIST_QUICK_6="I.",e.ORDER_LIST_QUICK_7="01.",e.BULLET_LIST="*",e))(Ru||{}),Ft=(e=>(e.BULLET_LIST="BULLET_LIST",e.BULLET_LIST_1="BULLET_LIST_1",e.BULLET_LIST_2="BULLET_LIST_2",e.BULLET_LIST_3="BULLET_LIST_3",e.BULLET_LIST_4="BULLET_LIST_4",e.BULLET_LIST_5="BULLET_LIST_5",e.ORDER_LIST="ORDER_LIST",e.ORDER_LIST_1="ORDER_LIST_1",e.ORDER_LIST_2="ORDER_LIST_2",e.ORDER_LIST_3="ORDER_LIST_3",e.ORDER_LIST_4="ORDER_LIST_4",e.ORDER_LIST_5="ORDER_LIST_5",e.ORDER_LIST_QUICK_2="ORDER_LIST_QUICK_2",e.ORDER_LIST_QUICK_3="ORDER_LIST_QUICK_3",e.ORDER_LIST_QUICK_4="ORDER_LIST_QUICK_4",e.ORDER_LIST_QUICK_5="ORDER_LIST_QUICK_5",e.ORDER_LIST_QUICK_6="ORDER_LIST_QUICK_6",e.CHECK_LIST="CHECK_LIST",e.CHECK_LIST_CHECKED="CHECK_LIST_CHECKED",e))(Ft||{});const Bs={"a)":{glyphFormat:"%1)",glyphType:fe.DECIMAL},"1.":{glyphType:fe.DECIMAL},"a.":{glyphFormat:"%1.",glyphType:fe.LOWER_LETTER},"A.":{glyphType:fe.UPPER_LETTER},"i.":{glyphFormat:"%1.",glyphType:fe.LOWER_ROMAN},"I.":{glyphFormat:"%1.",glyphType:fe.UPPER_LETTER}},Hn=e=>[...e,...e,...e].map((t,n)=>({glyphFormat:` %${n+1}`,glyphSymbol:t,bulletAlignment:Or.START,textStyle:{fs:12},startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*n}}})),Wn=e=>e.map((t,n)=>({...t,bulletAlignment:Or.START,textStyle:{fs:12},startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*n}}})),Iu=(e,t)=>new Array(9).fill(0).map((n,r)=>({glyphFormat:` %${r+1}`,glyphSymbol:e,bulletAlignment:Or.START,textStyle:{fs:16},startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*r},textStyle:t}})),Nr={BULLET_LIST:{listType:"BULLET_LIST",nestingLevel:Hn(["●","○","■"])},BULLET_LIST_1:{listType:"BULLET_LIST",nestingLevel:Hn(["❖","➢","■"])},BULLET_LIST_2:{listType:"BULLET_LIST",nestingLevel:Hn(["✔","●","◆"])},BULLET_LIST_3:{listType:"BULLET_LIST",nestingLevel:Hn(["■","◆","○"])},BULLET_LIST_4:{listType:"BULLET_LIST",nestingLevel:Hn(["✧","○","■"])},BULLET_LIST_5:{listType:"BULLET_LIST",nestingLevel:Hn(["➢","○","◆"])},ORDER_LIST:{listType:"ORDER_LIST",nestingLevel:Wn([{glyphFormat:"%1.",glyphType:fe.DECIMAL},{glyphFormat:"%2.",glyphType:fe.LOWER_LETTER},{glyphFormat:"%3.",glyphType:fe.LOWER_ROMAN},{glyphFormat:"%4.",glyphType:fe.DECIMAL},{glyphFormat:"%5.",glyphType:fe.LOWER_LETTER},{glyphFormat:"%6.",glyphType:fe.LOWER_ROMAN},{glyphFormat:"%7.",glyphType:fe.DECIMAL},{glyphFormat:"%8.",glyphType:fe.LOWER_LETTER},{glyphFormat:"%9.",glyphType:fe.LOWER_ROMAN}])},ORDER_LIST_1:{listType:"ORDER_LIST",nestingLevel:Wn([{glyphFormat:"%1)",glyphType:fe.DECIMAL},{glyphFormat:"%2)",glyphType:fe.LOWER_LETTER},{glyphFormat:"%3)",glyphType:fe.LOWER_ROMAN},{glyphFormat:"%4)",glyphType:fe.DECIMAL},{glyphFormat:"%5)",glyphType:fe.LOWER_LETTER},{glyphFormat:"%6)",glyphType:fe.LOWER_ROMAN},{glyphFormat:"%7)",glyphType:fe.DECIMAL},{glyphFormat:"%8)",glyphType:fe.LOWER_LETTER},{glyphFormat:"%9)",glyphType:fe.LOWER_ROMAN}])},ORDER_LIST_2:{listType:"ORDER_LIST",nestingLevel:Wn(["%1.","%1.%2.","%1.%2.%3.","%1.%2.%3.%4.","%1.%2.%3.%4.%5.","%1.%2.%3.%4.%5.%6.","%1.%2.%3.%4.%5.%6.%7."].map(e=>({glyphFormat:e,glyphType:fe.DECIMAL})))},ORDER_LIST_3:{listType:"ORDER_LIST",nestingLevel:Wn([{glyphFormat:"%1.",glyphType:fe.UPPER_LETTER},{glyphFormat:"%2.",glyphType:fe.LOWER_LETTER},{glyphFormat:"%3.",glyphType:fe.LOWER_ROMAN},{glyphFormat:"%4.",glyphType:fe.UPPER_LETTER},{glyphFormat:"%5.",glyphType:fe.LOWER_LETTER},{glyphFormat:"%6.",glyphType:fe.LOWER_ROMAN},{glyphFormat:"%7.",glyphType:fe.UPPER_LETTER},{glyphFormat:"%8.",glyphType:fe.LOWER_LETTER},{glyphFormat:"%9.",glyphType:fe.LOWER_ROMAN}])},ORDER_LIST_4:{listType:"ORDER_LIST",nestingLevel:Wn([{glyphFormat:"%1.",glyphType:fe.UPPER_LETTER},{glyphFormat:"%2.",glyphType:fe.DECIMAL},{glyphFormat:"%3.",glyphType:fe.LOWER_ROMAN},{glyphFormat:"%4.",glyphType:fe.UPPER_LETTER},{glyphFormat:"%5.",glyphType:fe.DECIMAL},{glyphFormat:"%6.",glyphType:fe.LOWER_ROMAN},{glyphFormat:"%7.",glyphType:fe.UPPER_LETTER},{glyphFormat:"%8.",glyphType:fe.DECIMAL},{glyphFormat:"%9.",glyphType:fe.LOWER_ROMAN}])},ORDER_LIST_5:{listType:"ORDER_LIST",nestingLevel:Wn([{glyphFormat:"%1.",glyphType:fe.DECIMAL_ZERO},{glyphFormat:"%2.",glyphType:fe.LOWER_LETTER},{glyphFormat:"%3.",glyphType:fe.LOWER_ROMAN},{glyphFormat:"%4.",glyphType:fe.DECIMAL_ZERO},{glyphFormat:"%5.",glyphType:fe.LOWER_LETTER},{glyphFormat:"%6.",glyphType:fe.LOWER_ROMAN},{glyphFormat:"%7.",glyphType:fe.DECIMAL_ZERO},{glyphFormat:"%8.",glyphType:fe.LOWER_LETTER},{glyphFormat:"%9.",glyphType:fe.LOWER_ROMAN}])},CHECK_LIST:{listType:"CHECK_LIST",nestingLevel:Iu("☐")},CHECK_LIST_CHECKED:{listType:"CHECK_LIST_CHECKED",nestingLevel:Iu("☑",{st:{s:ae.TRUE}})}},$s=e=>{const{glyphFormat:t,glyphType:n}=e,r=Z.deepClone(Nr.ORDER_LIST);return r.nestingLevel[0].glyphFormat=t,r.nestingLevel[0].glyphType=n,r},X_={ORDER_LIST_QUICK_2:$s(Bs["a)"]),ORDER_LIST_QUICK_3:$s(Bs["a."]),ORDER_LIST_QUICK_4:$s(Bs["i."]),ORDER_LIST_QUICK_6:$s(Bs["I."])};Object.assign(Nr,X_);const q_={"1.":"ORDER_LIST","a)":"ORDER_LIST_QUICK_2","a.":"ORDER_LIST_QUICK_3","i.":"ORDER_LIST_QUICK_4","A.":"ORDER_LIST_3","I.":"ORDER_LIST_QUICK_6","01.":"ORDER_LIST_5","*":"BULLET_LIST"};function Z_(e,t,n,r,s){const i=J_(e,t,n,r,s),o=Q_(e,t,n,r,s),a=ep(e,t,n,r,s),l=tp(e,t,n,r,s),c=np(e,t,n,r,s),u=rp(e,t,n,r),h=sp(e,t,n,r,s);return{dataStream:"",textRuns:i,paragraphs:o,sectionBreaks:a,customBlocks:l,tables:c,customRanges:u,customDecorations:h}}function J_(e,t,n,r,s){const{textRuns:i}=e,{textRuns:o}=t;if(i==null||o==null)return;const a=gu(e,n,r);if(s!==Ce.REPLACE){const l=Su(o,a,s);t.textRuns=l}return au(e,t,n,r),a}function Su(e,t,n){if(t.length===0)return e;e=Z.deepClone(e),t=Z.deepClone(t);const r=[],s=e.length,i=t.length;let o=0,a=0,l=null;function c(){return l?(r.push(l),l=null,!0):!1}for(;o<s&&a<i;){const{st:m,ed:_,ts:p}=e[o],{st:I,ed:A,ts:B,sId:x}=t[a];let Y;if(n===Ce.COVER?Y={...B,...p}:Y={...p},_<I)c()||r.push(e[o]),o++;else if(A<m)c()||r.push(t[a]),a++;else{const O={st:Math.min(m,I),ed:Math.max(m,I),ts:m<I?{...p}:{...B},sId:m<I?void 0:x};O.ed>O.st&&r.push(O),r.push({st:Math.max(m,I),ed:Math.min(_,A),ts:Y,sId:x}),_<A?(o++,t[a].st=_,t[a].st===t[a].ed&&a++):(a++,e[o].st=A,e[o].st===e[o].ed&&o++);const R={st:Math.min(_,A),ed:Math.max(_,A),ts:_<A?{...B}:{...p},sId:_<A?x:void 0};l=R.ed>R.st?R:null}}c();const u=r[r.length-1],h=e[s-1],d=t[i-1];return u&&u.ed!==Math.max(h.ed,d.ed)&&(h.ed>d.ed?r.push(h):r.push(d)),yr(r)}function Q_(e,t,n,r,s){const{paragraphs:i}=e,{paragraphs:o}=t;if(i==null||o==null)return;const a=_u(e,n,r);if(s!==Ce.REPLACE){const l=[];for(const c of o){const{startIndex:u,paragraphStyle:h,bullet:d}=c;let m=[];for(const _ of a){const{startIndex:p,paragraphStyle:I,bullet:A}=_;let B,x;if(s===Ce.COVER?(B={...I,...h},x={listId:"",listType:Ft.BULLET_LIST,nestingLevel:0,textStyle:{},...A,...d}):(B={...h,...I},x={listId:"",listType:Ft.BULLET_LIST,nestingLevel:0,textStyle:{},...d,...A}),u===p){m.push({startIndex:u,paragraphStyle:B,bullet:x});break}}l.push(...m),m=[]}t.paragraphs=l}return lu(e,t,n,r),a}function ep(e,t,n,r,s){const{sectionBreaks:i}=e,{sectionBreaks:o}=t;if(i==null||o==null)return;const a=pu(e,n,r);if(s!==Ce.REPLACE){const l=[];for(const c of o){const{startIndex:u}=c;let h=[];for(const d of a){const{startIndex:m}=d;if(u===m){s===Ce.COVER?h.push({...d,...c}):h.push({...c,...d});break}}l.push(...h),h=[]}t.sectionBreaks=l}return cu(e,t,n,r),a}function tp(e,t,n,r,s){const{customBlocks:i=[]}=e,{customBlocks:o}=t;if(i==null||o==null)return;const a=Eu(e,n,r);if(s!==Ce.REPLACE){const l=[];for(const c of o){const{startIndex:u}=c;let h=[];for(const d of a){const{startIndex:m}=d;if(u===m){s===Ce.COVER?h.push({...d,...c}):h.push({...c,...d});break}}l.push(...h),h=[]}t.customBlocks=l}return uu(e,t,n,r),i.length&&!e.customBlocks&&(e.customBlocks=i),a}function np(e,t,n,r,s){const{tables:i}=e,{tables:o}=t;if(i==null||o==null)return;const a=Cu(e,n,r);if(s!==Ce.REPLACE){const l=[];for(const c of o){const{startIndex:u,endIndex:h}=c;let d=[];for(const m of a){const{startIndex:_,endIndex:p}=m;if(_>=u&&p<=h){s===Ce.COVER?d.push({...m,...c}):d.push({...c,...m});break}}l.push(...d),d=[]}t.tables=l}return hu(e,t,n,r),a}function rp(e,t,n,r,s){e.customRanges||(e.customRanges=[]),wo(e.customRanges,r),wo(e.customRanges,r+n);const i=r,o=r+n-1,{customRanges:a}=t,l=[],c=new Map;e.customRanges.forEach(h=>{const{startIndex:d,endIndex:m}=h;d>=i&&m<=o?c.set(h.rangeId,h):l.push(h)});const u=[];return a?(a.forEach(h=>{const{startIndex:d,endIndex:m}=h;l.push({...h,startIndex:d+r,endIndex:m+r})}),e.customRanges=vo(l),u):[]}function sp(e,t,n,r,s){e.customDecorations||(e.customDecorations=[]),bo(e.customDecorations,r),bo(e.customDecorations,r+n);const i=[],{customDecorations:o}=e,{customDecorations:a=[]}=t;if(s===Ce.REPLACE){for(let l=0;l<o.length;l++){const c=o[l],{startIndex:u,endIndex:h}=c;u>=r&&h<=r+n-1&&i.push(c)}a.forEach(l=>{const{startIndex:c,endIndex:u}=l;o.push({...l,startIndex:c+r,endIndex:u+r})})}else for(const l of a){const{id:c}=l;if(l.type===_n.DELETED){const u=o.filter(h=>h.id===c);u.length&&i.push(...u)}else o.push({...l,startIndex:l.startIndex+r,endIndex:l.endIndex+r})}for(const l of i){const{id:c}=l,u=o.findIndex(h=>h.id===c);u!==-1&&o.splice(u,1)}return e.customDecorations=mu(o),i}var Ao=(e=>(e[e.copy=0]="copy",e[e.cut=1]="cut",e))(Ao||{});function Hs(e,t,n,r=!0){const{textRuns:s}=e;if(s){const i=[];for(const o of s){const a=Z.deepClone(o),{st:l,ed:c}=a;Z.hasIntersectionBetweenTwoRanges(l,c,t,n)&&(t>=l&&t<=c?i.push({...a,st:t,ed:Math.min(n,c)}):n>=l&&n<=c?i.push({...a,st:Math.max(t,l),ed:n}):i.push(a))}return yr(i.map(o=>{const{st:a,ed:l}=o;return{...o,st:a-t,ed:l-t}}))}else if(r)return[{st:0,ed:n-t,ts:{}}]}function Ou(e,t,n){const{tables:r=[]}=e,s=[];for(const i of r){const o=Z.deepClone(i),{startIndex:a,endIndex:l}=o;a>=t&&l<=n&&s.push({...o,startIndex:a-t,endIndex:l-t})}return s}function vu(e,t,n){const{paragraphs:r=[]}=e,s=[];for(const i of r){const{startIndex:o}=i;if(o>=t&&o<n){const a=Z.deepClone(i);s.push(a)}}if(s.length)return s.map(i=>({...i,startIndex:i.startIndex-t}))}function ip(e,t,n){const{sectionBreaks:r=[]}=e,s=[];for(const i of r){const{startIndex:o}=i;o>=t&&o<=n&&s.push(Z.deepClone(i))}if(s.length)return s.map(i=>({...i,startIndex:i.startIndex-t}))}function wu(e,t,n){const{customBlocks:r=[]}=e,s=[];for(const i of r){const{startIndex:o}=i;o>=t&&o<n&&s.push(Z.deepClone(i))}if(s.length)return s.map(i=>({...i,startIndex:i.startIndex-t}))}function bt(e,t,n,r=!0,s=1){const{dataStream:i}=e,o={dataStream:i.slice(t,n)};o.textRuns=Hs(e,t,n,r);const a=Ou(e,t,n);if(a.length&&(o.tables=a),o.paragraphs=vu(e,t,n),s===1){const c=Au(e,t,n);c?o.customDecorations=c:r&&(o.customDecorations=[])}const{customRanges:l}=bu(e,t,n);return l?o.customRanges=l:r&&(o.customRanges=[]),o.customBlocks=wu(e,t,n),o}function op(e){const{dataStream:t,textRuns:n,paragraphs:r,customRanges:s,customDecorations:i,tables:o}=e;let a=0,l=0;s==null||s.forEach(u=>{u.startIndex<0&&(a=Math.max(a,-u.startIndex)),u.endIndex>t.length-1&&(l=Math.max(l,u.endIndex-t.length+1))});const c=`${t}`;return n&&(n[0]&&(n[0].st=n[0].st-a),n[n.length-1]&&(n[n.length-1].ed=n[n.length-1].ed+l)),n==null||n.forEach(u=>{u.st+=a,u.ed+=a}),r==null||r.forEach(u=>{u.startIndex+=a}),s==null||s.forEach(u=>{u.startIndex+=a,u.endIndex+=a}),i==null||i.forEach(u=>{u.startIndex+=a,u.endIndex+=l}),o==null||o.forEach(u=>{u.startIndex+=a,u.endIndex+=l}),{...e,dataStream:c,textRuns:n,paragraphs:r,customRanges:s,customDecorations:i,tables:o}}function bu(e,t,n){if(e.customRanges==null)return{};const{customRanges:r}=e;return{customRanges:r.filter(a=>Math.max(a.startIndex,t)<=Math.min(a.endIndex,n-1)).map(a=>({...a,startIndex:Math.max(a.startIndex,t),endIndex:Math.min(a.endIndex,n-1)})).map(a=>({...a,startIndex:a.startIndex-t,endIndex:a.endIndex-t})),leftOffset:0,rightOffset:0}}function Au(e,t,n){if(e.customDecorations==null)return;const{customDecorations:r=[]}=e,s=[];return r.forEach(i=>{if(Math.max(i.startIndex,t)<=Math.min(i.endIndex,n-1)){const o=Z.deepClone(i);s.push({...o,startIndex:Math.max(o.startIndex-t,0),endIndex:Math.min(o.endIndex,n-1)-t})}}),s}function ap(e,t,n){return e==null||t==null?e!=null?e:t:Su(e,t,n)}function lp(e,t,n){if(e==null||t==null)return e!=null?e:t;if(t.length===0||e.length===0)return e;if(t.length>1||e.length>1)throw new Error("Cannot cover multiple customRanges");return n===Ce.REPLACE?[{...e[0]}]:[{...t[0],...e[0]}]}function cp(e,t,n){return t.length===0||e.length===0||n===Ce.REPLACE?e:[...e,...t.filter(r=>!e.some(s=>r.id===s.id))]}function To(e,t,n=Ce.COVER){if(t.dataStream!=="")throw new Error("Cannot compose other body with non-empty dataStream");const r={dataStream:e.dataStream},{textRuns:s,paragraphs:i=[],customRanges:o,customDecorations:a=[]}=e,{textRuns:l,paragraphs:c=[],customRanges:u,customDecorations:h=[]}=t;r.textRuns=ap(l,s,n),r.customRanges=lp(u,o,n);const d=cp(h,a,n);d.length&&(r.customDecorations=d);const m=[];let _=0,p=0;for(;_<i.length&&p<c.length;){const I=i[_],A=c[p],{startIndex:B}=I,{startIndex:x}=A;B===x?(m.push(Z.deepMerge(I,A)),_++,p++):B<x?(m.push(Z.deepClone(I)),_++):(m.push(Z.deepClone(A)),p++)}return _<i.length&&m.push(...i.slice(_)),p<c.length&&m.push(...c.slice(p)),m.length&&(r.paragraphs=m),r}function up(e){const{body:t}=e;if(t==null)return!0;const{textRuns:n,paragraphs:r,customRanges:s,customBlocks:i,customDecorations:o,tables:a}=t;return n==null&&r==null&&s==null&&i==null&&o==null&&a==null}class jn{constructor(t){C(this,"_index",0);C(this,"_offset",0);this._actions=t}hasNext(){return this.peekLength()<Number.POSITIVE_INFINITY}next(t){t||(t=Number.POSITIVE_INFINITY);const n=this._actions[this._index];if(n){const r=this._offset,s=n.len;return t>=s-r?(t=s-r,this._index+=1,this._offset=0):this._offset+=t,n.t===J.DELETE||n.t===J.RETAIN&&n.body==null?Z.deepClone({...n,len:t}):Z.deepClone({...n,len:t,body:bt(n.body,r,r+t,!1)})}else return{t:J.RETAIN,len:Number.POSITIVE_INFINITY}}peek(){return this._actions[this._index]}peekLength(){return this._actions[this._index]?this._actions[this._index].len-this._offset:Number.POSITIVE_INFINITY}peekType(){const t=this._actions[this._index];return t?t.t:J.RETAIN}rest(){if(this.hasNext()){if(this._offset===0)return this._actions.slice(this._index);{const t=this._offset,n=this._index,r=this.next(),s=this._actions.slice(this._index);return this._offset=t,this._index=n,[r].concat(s)}}else return[]}}function Tu(e,t,n){const{dataStream:r}=e,s=n,i=n+t,o=gu(e,t,n),a=_u(e,t,n),l=pu(e,t,n),c=Eu(e,t,n),u=Cu(e,t,n),h=z_(e,t,n),d=K_(e,t,n);let m="";return r&&(e.dataStream=bl(r,s,i),m=r.slice(s,i)),{dataStream:m,textRuns:o,paragraphs:a,sectionBreaks:l,customBlocks:c,tables:u,customRanges:h,customDecorations:d}}function yu(e,t,n,r){e.dataStream=wl(e.dataStream,r,t.dataStream),au(e,t,n,r),lu(e,t,n,r),cu(e,t,n,r),uu(e,t,n,r),hu(e,t,n,r),G_(e,t,n,r),V_(e,t,n,r)}function hp(e,t,n,r,s=Ce.COVER){return Z_(e,t,n,r,s)}function dp(e,t,n){return t<=0?{dataStream:""}:Tu(e,t,n)}function fp(e,t,n,r){n!==0&&yu(e,t,n,r)}function mp(e,t){const n=new un;return n.reset(),t.forEach(r=>{const s=Z.deepClone(r);switch(s.t){case J.RETAIN:{const{coverType:i,body:o,len:a}=s;o!=null&&hp(e,o,a,n.cursor,i),n.moveCursor(a);break}case J.INSERT:{const{body:i,len:o}=s;fp(e,i,o,n.cursor),n.moveCursor(o);break}case J.DELETE:{const{len:i}=s;dp(e,i,n.cursor);break}default:throw new Error(`Unknown action type for action: ${s}.`)}}),e}function gp(e,t,n,r,s){if(e==null||t==null)return t;if(e.length===0||t.length===0)return[];t=Z.deepClone(t),e=Z.deepClone(e);const i=[],o=t.length,a=e.length;let l=0,c=0,u=null;function h(){return u?(i.push(u),u=null,!0):!1}for(;l<o&&c<a;){const{st:p,ed:I,ts:A}=t[l],{st:B,ed:x,ts:Y,sId:O}=e[c];let R={};if(s===0)R={...A},n===Ce.COVER&&r===Ce.REPLACE&&Y&&(R=Object.assign({},Y,R));else if(R={...A},n===Ce.REPLACE){if(r===Ce.REPLACE)R={...Y};else if(A&&Y){const b=Object.keys(A);for(const y of b)Y[y]&&delete R[y]}}else if(r===Ce.REPLACE){if(Y){const b=Object.keys(Y);for(const y of b)Y[y]!==void 0&&(R[y]=Y[y])}}else if(Y){const b=Object.keys(Y);for(const y of b)R[y]!==void 0&&delete R[y]}if(I<B)h()||i.push(t[l]),l++;else if(x<p)h()||i.push(e[c]),c++;else{const b={st:Math.min(p,B),ed:Math.max(p,B),ts:p<B?{...A}:{...Y}};b.ed>b.st&&i.push(),i.push({st:Math.max(p,B),ed:Math.min(I,x),ts:R,sId:O}),I<x?(l++,e[c].st=I,e[c].st===e[c].ed&&c++):(c++,t[l].st=x,t[l].st===t[l].ed&&l++);const y={st:Math.min(I,x),ed:Math.max(I,x),ts:I<x?{...Y}:{...A},sId:I<x?O:void 0};u=y.ed>y.st?y:null}}h();const d=i[i.length-1],m=t[o-1],_=e[a-1];return d.ed!==Math.max(m.ed,_.ed)&&(m.ed>_.ed?i.push(m):i.push(_)),yr(i,!0)}function _p(e,t,n,r,s){if(e==null||t==null)return t;if(e.length===0||t.length===0)return[];if(e.length>1||t.length>1)throw new Error("CustomRanges is only supported transform for length one now.");const i=e[0],o=t[0];if(n===Ce.REPLACE)return s===1?[Z.deepClone(i)]:[Z.deepClone(o)];if(r===Ce.REPLACE){const a=Z.deepClone(o);return s===1&&Object.assign(a,Z.deepClone(i)),[a]}else{const a=Z.deepClone(o);return s===1&&Object.assign(a,Z.deepClone(i)),[a]}}function Nu(e,t,n,r,s){const i={startIndex:t.startIndex};if(t.paragraphStyle&&(i.paragraphStyle=Z.deepClone(t.paragraphStyle),e.paragraphStyle)){if(n===Ce.REPLACE)if(r===Ce.REPLACE)s===1&&(i.paragraphStyle={...e.paragraphStyle});else if(s===1){const o=Object.keys(e.paragraphStyle);for(const a of o)e.paragraphStyle[a]!==void 0&&(i.paragraphStyle[a]=e.paragraphStyle[a])}else{const o=Object.keys(e.paragraphStyle);for(const a of o)i.paragraphStyle[a]===void 0&&(i.paragraphStyle[a]=e.paragraphStyle[a])}else if(r===Ce.REPLACE)if(s===1){const o=Object.keys(e.paragraphStyle);for(const a of o)e.paragraphStyle[a]!==void 0&&(i.paragraphStyle[a]=e.paragraphStyle[a])}else{const o=Object.keys(e.paragraphStyle);for(const a of o)i.paragraphStyle[a]===void 0&&(i.paragraphStyle[a]=e.paragraphStyle[a])}else if(s===1){const o=Object.keys(e.paragraphStyle);for(const a of o)i.paragraphStyle[a]&&delete i.paragraphStyle[a]}}return n===Ce.REPLACE&&r===Ce.REPLACE?i.bullet=s===1?Z.deepClone(e.bullet):Z.deepClone(t.bullet):e.bullet===void 0?i.bullet=Z.deepClone(t.bullet):n===Ce.REPLACE||r===Ce.REPLACE?i.bullet=s===0&&t.bullet?Z.deepClone(t.bullet):Z.deepClone(e.bullet):s===0&&t.bullet!==void 0&&(i.bullet=Z.deepClone(t.bullet)),i}function pp(e,t){if(e==null||t==null)return t;if(e.length===0||t.length===0)return Z.deepClone(t);const n=[];for(const r of t){const{id:s,type:i}=r;let o=!1;for(const a of e)if(a.id===s){(a.type===_n.DELETED||i===_n.DELETED)&&(o=!0,n.push({...r,type:_n.DELETED}));break}o||n.push(r)}return n}function Ep(e,t,n=!1){const{body:r,coverType:s=Ce.COVER}=e,{body:i,coverType:o=Ce.COVER}=t;if(r==null||r.dataStream!==""||i==null||i.dataStream!=="")throw new Error("Data stream is not supported in retain transform.");const a={dataStream:""},l=o,{textRuns:c,paragraphs:u=[],customRanges:h,customDecorations:d}=r,{textRuns:m,paragraphs:_=[],customRanges:p,customDecorations:I}=i,A=gp(c,m,s,o,n?1:0);A&&(a.textRuns=A);const B=_p(h,p,s,o,n?1:0);B&&(a.customRanges=B);const x=pp(d,I);x&&(a.customDecorations=x);const Y=[];let O=0,R=0;for(;O<u.length&&R<_.length;){const b=u[O],y=_[R],{startIndex:$}=b,{startIndex:H}=y;if($===H){let g={startIndex:$};n?g=Nu(b,y,s,o,1):g=Nu(b,y,s,o,0),Y.push(g),O++,R++}else $<H?O++:(Y.push(Z.deepClone(y)),R++)}return R<_.length&&Y.push(..._.slice(R)),Y.length&&(a.paragraphs=Y),{coverType:l,body:a}}function Mu(e){return Object.keys(e).length===1}const Zn=class Zn{constructor(){C(this,"_actions",[])}static apply(t,n){return mp(t,n)}static compose(t,n){const r=new jn(t),s=new jn(n),i=new Zn;for(;r.hasNext()||s.hasNext();)if(s.peekType()===J.INSERT)i.push(s.next());else if(r.peekType()===J.DELETE)i.push(r.next());else{const o=Math.min(r.peekLength(),s.peekLength()),a=r.next(o),l=s.next(o);if(a.t===J.INSERT&&l.t===J.RETAIN)l.body==null?i.push(a):i.push({...a,body:To(a.body,l.body,l.coverType)});else if(a.t===J.RETAIN&&l.t===J.RETAIN)if(a.body==null&&l.body==null)i.push(a.len!==Number.POSITIVE_INFINITY?a:l);else if(a.body&&l.body){const c=a.coverType===Ce.REPLACE||l.coverType===Ce.REPLACE?Ce.REPLACE:Ce.COVER;i.push({...a,t:J.RETAIN,coverType:c,body:To(a.body,l.body,l.coverType)})}else i.push(a.body?a:l);else a.t===J.RETAIN&&l.t===J.DELETE?i.push(l):a.t===J.INSERT&&(l.t,J.DELETE)}return i.trimEndUselessRetainAction(),i.serialize()}static transform(t,n,r="right"){return this._transform(n,t,r==="left"?"right":"left")}static _transform(t,n,r="right"){const s=new jn(t),i=new jn(n),o=new Zn;for(;s.hasNext()||i.hasNext();)if(s.peekType()===J.INSERT&&(r==="left"||i.peekType()!==J.INSERT)){const a=s.next();o.retain(a.len)}else if(i.peekType()===J.INSERT)o.push(i.next());else{const a=Math.min(s.peekLength(),i.peekLength()),l=s.next(a),c=i.next(a);if(l.t===J.DELETE)continue;if(c.t===J.DELETE){o.push(c);continue}if(l.body==null||c.body==null)o.push(c);else{const{coverType:u,body:h}=Ep(l,c,r==="left");o.push({...c,t:J.RETAIN,coverType:u,body:h})}}return o.trimEndUselessRetainAction(),o.serialize()}static transformPosition(t,n,r=!1){const s=new jn(t);let i=0;for(;s.hasNext()&&i<=n;){const o=s.peekLength(),a=s.peekType();if(s.next(),a===J.DELETE){n-=Math.min(o,n-i);continue}else a===J.INSERT&&(i<n||!r)&&(n+=o);i+=o}return n}static isNoop(t){return t.length===0}static invert(t){const n=[];for(const r of t)if(r.t===J.INSERT)n.push({t:J.DELETE,len:r.len,body:r.body});else if(r.t===J.DELETE){if(r.body==null)throw new Error("Can not invert DELETE action without body property, makeInvertible must be called first.");n.push({t:J.INSERT,body:r.body,len:r.len})}else if(r.body!=null){if(r.oldBody==null)throw new Error("Can not invert RETAIN action without oldBody property, makeInvertible must be called first.");n.push({t:J.RETAIN,body:r.oldBody,oldBody:r.body,len:r.len,coverType:Ce.REPLACE})}else n.push(r);return n}static makeInvertible(t,n){const r=[];let s=0;for(const i of t){if(i.t===J.DELETE&&(i.body==null||i.body&&i.body.dataStream.length!==i.len)){const o=bt(n,s,s+i.len,!1);i.len=o.dataStream.length,i.body=o}if(i.t===J.RETAIN&&i.body!=null){const o=bt(n,s,s+i.len,!0);i.oldBody={...o,dataStream:""},i.len=o.dataStream.length}r.push(i),i.t!==J.INSERT&&(s+=i.len)}return r}insert(t,n){const r={t:J.INSERT,body:n,len:t};return this.push(r),this}retain(t,n,r){const s={t:J.RETAIN,len:t};return n!=null&&(s.body=n),r!=null&&(s.coverType=r),this.push(s),this}delete(t){const n={t:J.DELETE,len:t};return this.push(n),this}empty(){return this._actions=[],this}serialize(){return this._actions}push(...t){if(t.length>1){for(const i of t)this.push(i);return this}let n=this._actions.length,r=this._actions[n-1];const s=Z.deepClone(t[0]);if(s.t===J.RETAIN&&s.len===0&&s.body==null)return this;if(typeof r=="object"){if(r.t===J.DELETE&&s.t===J.DELETE)return r.len+=s.len,this;if(r.t===J.DELETE&&s.t===J.INSERT&&(n-=1,r=this._actions[n-1],r==null))return this._actions.unshift(s),this;if(r.t===J.RETAIN&&s.t===J.RETAIN&&r.body==null&&s.body==null)return r.len+=s.len,this;if(r.t===J.INSERT&&Mu(r.body)&&s.t===J.INSERT&&Mu(s.body))return r.len+=s.len,r.body.dataStream+=s.body.dataStream,this}return n===this._actions.length?this._actions.push(s):this._actions.splice(n,0,s),this}trimEndUselessRetainAction(){let t=this._actions[this._actions.length-1];for(;t&&t.t===J.RETAIN&&up(t);)this._actions.pop(),t=this._actions[this._actions.length-1];return this}};C(Zn,"id","text-x"),C(Zn,"uri","https://github.com/dream-num/univer#text-x");let Me=Zn;Object.defineProperty(Me,"name",{value:"text-x"});const Jn=class Jn{static registerSubtype(t){var n;t==null||this._subTypes.has(t.name)&&((n=this._subTypes.get(t.name))==null?void 0:n.id)!==Me.id||(this._subTypes.set(t.name,t),at.type.registerSubtype(t))}static apply(t,n){if(!at.type.isNoop(n))return at.type.apply(t,n)}static compose(t,n){return at.type.compose(t,n)}static transform(t,n,r){return at.type.transform(t,n,r)}static transformPosition(t,n,r="right"){return t&&t.length===2&&t[0]==="body"&&t[1].et===Me.name?Me.transformPosition(t[1].e,n,r==="left"):n}static invertWithDoc(t,n){return at.type.invertWithDoc(t,n)}static isNoop(t){return at.type.isNoop(t)}static getInstance(){return this._instance==null&&(this._instance=new Jn),this._instance}removeOp(t,n){return at.removeOp(t,n)}moveOp(t,n){return at.moveOp(t,n)}insertOp(t,n){return at.insertOp(t,n)}replaceOp(t,n,r){return at.replaceOp(t,n,r)}editOp(t,n=["body"]){return at.editOp(n,Me.name,t)}};C(Jn,"uri","https://github.com/dream-num/univer#json-x"),C(Jn,"_subTypes",new Map),C(Jn,"_instance",null);let Wt=Jn;Wt.registerSubtype(Me);var Lu=(e=>(e.PARAGRAPH="PARAGRAPH",e.SECTION_BREAK="SECTION_BREAK",e.TABLE="TABLE",e.TABLE_ROW="TABLE_ROW",e.TABLE_CELL="TABLE_CELL",e.CUSTOM_BLOCK="CUSTOM_BLOCK",e))(Lu||{}),lt=(e=>(e.PARAGRAPH="\r",e.SECTION_BREAK=`
5
5
  `,e.TABLE_START="",e.TABLE_ROW_START="\x1B",e.TABLE_CELL_START="",e.TABLE_CELL_END="",e.TABLE_ROW_END="",e.TABLE_END="",e.CUSTOM_RANGE_START="",e.CUSTOM_RANGE_END="",e.COLUMN_BREAK="\v",e.PAGE_BREAK="\f",e.DOCS_END="\0",e.TAB=" ",e.CUSTOM_BLOCK="\b",e.LETTER="",e.SPACE=" ",e))(lt||{});function Cp(e){return`${e}`}const Rp=[lt.TABLE_START,lt.TABLE_ROW_START,lt.TABLE_CELL_START,lt.TABLE_CELL_END,lt.TABLE_ROW_END,lt.TABLE_END],Ws=e=>{const t=e.endsWith(`\r
6
- `)?e.slice(0,-2):e;return Rp.reduce((n,r)=>n.replaceAll(r,""),t)},Ip=e=>e?Ws(e).replaceAll("\r","")==="":!0,Sp=e=>{const t=e.replace(/\n/g,"\r"),n=[],r=[];let s=0,i="";const o=(l,c=!0)=>{const u=t.slice(s,l);if(Z.isLegalUrl(u)){const h=tt(),d=`${u}`,m={startIndex:s,endIndex:s+d.length-1,rangeId:h,rangeType:en.HYPERLINK,properties:{url:e}};r.push(m),i+=d,s=l+1,c&&(i+="\r",n.push({startIndex:l}))}else i+=t.slice(s,l+1),s=l+1,c&&n.push({startIndex:l})};let a=0;for(let l=0;l<t.length;l++)t[l]==="\r"&&(o(l),a=l);return(a!==t.length-1||t.length===1)&&o(t.length,!1),{dataStream:i,paragraphs:n,customRanges:r}},yo={id:"default_doc",documentStyle:{}};class Op extends Ps{constructor(n){var r;super();C(this,"type",we.UNIVER_DOC);C(this,"_name$",new oe.BehaviorSubject(""));C(this,"name$",this._name$.asObservable());C(this,"snapshot");this.snapshot={...yo,...n},this._name$.next((r=this.snapshot.title)!=null?r:"No Title")}getUnitId(){throw new Error("Method not implemented.")}getRev(){var n;return(n=this.snapshot.rev)!=null?n:1}incrementRev(){this.snapshot.rev=this.getRev()+1}setRev(n){this.snapshot.rev=n}setName(n){this.snapshot.title=n,this._name$.next(n)}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get zoomRatio(){var n;return((n=this.snapshot.settings)==null?void 0:n.zoomRatio)||1}resetDrawing(n,r){this.snapshot.drawings=n,this.snapshot.drawingsOrder=r}getBody(){return this.snapshot.body}getSnapshot(){return this.snapshot}getBulletPresetList(){var s;const n=(s=this.snapshot.lists)!=null?s:{};return{...Nr,...n}}updateDocumentId(n){this.snapshot.id=n}updateDocumentRenderConfig(n){const{documentStyle:r}=this.snapshot;r.renderConfig==null?r.renderConfig=n:r.renderConfig={...r.renderConfig,...n}}getDocumentStyle(){return this.snapshot.documentStyle}updateDocumentStyle(n){this.snapshot.documentStyle==null?this.snapshot.documentStyle=n:this.snapshot.documentStyle={...this.snapshot.documentStyle,...n}}updateDocumentDataMargin(n){const{t:r,l:s,b:i,r:o}=n,{documentStyle:a}=this.snapshot;r!=null&&(a.marginTop=r),s!=null&&(a.marginLeft=s),i!=null&&(a.marginBottom=i),o!=null&&(a.marginRight=o)}updateDocumentDataPageSize(n,r){const{documentStyle:s}=this.snapshot;if(!s.pageSize){n=n!=null?n:Number.POSITIVE_INFINITY,r=r!=null?r:Number.POSITIVE_INFINITY,s.pageSize={width:n,height:r};return}n!==void 0&&(s.pageSize.width=n),r!==void 0&&(s.pageSize.height=r)}updateDrawing(n,r){const{drawings:s}=this,{width:i,height:o,left:a,top:l}=r,c=s==null?void 0:s[n];if(!c)return;const u=c.docTransform;u.size.width=i,u.size.height=o,u.positionH.posOffset=a,u.positionV.posOffset=l}setZoomRatio(n=1){this.snapshot.settings==null?this.snapshot.settings={zoomRatio:n}:this.snapshot.settings.zoomRatio=1}setDisabled(n){this.snapshot.disabled=n}getDisabled(){return this.snapshot.disabled}getTitle(){return this.snapshot.title}}class At extends Op{constructor(n){var s,i;super(Z.isEmptyObject(n)?F_():n);C(this,"_unitId");C(this,"headerModelMap",new Map);C(this,"footerModelMap",new Map);C(this,"change$",new oe.BehaviorSubject(0));const r=6;this._unitId=(s=this.snapshot.id)!=null?s:tt(r),this._initializeHeaderFooterModel(),this._name$.next((i=this.snapshot.title)!=null?i:"")}dispose(){super.dispose(),this.headerModelMap.forEach(n=>{n.dispose()}),this.footerModelMap.forEach(n=>{n.dispose()}),this._name$.complete()}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getCustomRanges(){var n;return(n=this.snapshot.body)==null?void 0:n.customRanges}getCustomDecorations(){var n;return(n=this.snapshot.body)==null?void 0:n.customDecorations}getSettings(){return this.snapshot.settings}reset(n){if(n.id&&n.id!==this._unitId)throw new Error("Cannot reset a document model with a different unit id!");this.snapshot={...yo,...n},this._initializeHeaderFooterModel(),this.change$.next(this.change$.value+1)}getSelfOrHeaderFooterModel(n){if(n!=null){if(this.headerModelMap.has(n))return this.headerModelMap.get(n);if(this.footerModelMap.has(n))return this.footerModelMap.get(n)}return this}getUnitId(){return this._unitId}apply(n){if(!Wt.isNoop(n))return this.snapshot=Wt.apply(this.snapshot,n),n!=null&&n.some(r=>Array.isArray(r)&&((r==null?void 0:r[0])==="headers"||(r==null?void 0:r[0])==="footers"))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.change$.next(this.change$.value+1),this.snapshot}sliceBody(n,r,s=Ao.copy){const i=this.getBody();if(i!=null)return bt(i,n,r,!1,s)}_initializeHeaderFooterModel(){const{headers:n,footers:r}=this.getSnapshot();if(n)for(const s in n){const i=n[s];this.headerModelMap.set(s,new At(i)),this.headerModelMap.get(s).updateDocumentId(this.getUnitId())}if(r)for(const s in r){const i=r[s];this.footerModelMap.set(s,new At(i)),this.footerModelMap.get(s).updateDocumentId(this.getUnitId())}}updateDocumentId(n){super.updateDocumentId(n),this._unitId=n}getPlainText(){var n,r;return Ws((r=(n=this.getBody())==null?void 0:n.dataStream)!=null?r:"")}}function vp(e){const{ranges:t,id:n,type:r}=e,s=new Me;let i=0;for(let o=0;o<t.length;o++){const a=t[o],{startOffset:l,endOffset:c}=a;l>0&&s.push({t:J.RETAIN,len:l-i}),s.push({t:J.RETAIN,body:{dataStream:"",customDecorations:[{id:n,type:r,startIndex:0,endIndex:c-l-1}]},len:c-l}),i=c}return s}function wp(e){var u,h,d;const{id:t,segmentId:n,documentDataModel:r}=e,s=r==null?void 0:r.getBody();if(!r||!s)return!1;const i=(d=(h=(u=r.getSelfOrHeaderFooterModel(n))==null?void 0:u.getBody())==null?void 0:h.customDecorations)==null?void 0:d.find(m=>m.id===t);if(!i)return!1;const o=new Me,{startIndex:a,endIndex:l}=i,c=l-a+1;return o.push({t:J.RETAIN,len:a}),o.push({t:J.RETAIN,len:c,body:{dataStream:"",customDecorations:[{startIndex:0,endIndex:c-1,id:t,type:_n.DELETED}]}}),o}function Du(e,t,n,r){return e<=n&&t>=n||e>=n&&e<=r}function bp(e,t){const n=[];for(let r=0,s=t.length;r<s;r++){const i=t[r];e.collapsed?i.startIndex<e.startOffset&&e.startOffset<=i.endIndex&&n.push(i):Du(e.startOffset,e.endOffset-1,i.startIndex,i.endIndex)&&n.push(i)}return n}function Ap(e){return{...Z.deepClone(e),rangeId:tt()}}function Tp(e,t){const n=[];let r=e[0];for(const s of t)s<e[0]||s>e[1]||(r<s&&n.push([r,s-1]),r=s+1);return r<=e[1]&&n.push([r,e[1]]),n}function Uu(e,t,n,r){const s=[];for(let i=0,o=n.length;i<o;i++){const a=n[i];if((r===void 0||a.rangeType===r)&&Math.max(a.startIndex,e)<=Math.min(a.endIndex,t)&&s.push({...a}),a.startIndex>t)break}return s}function yp(e,t){var i,o,a,l,c;const n=Uu(e.startOffset,e.collapsed?e.startOffset:e.endOffset-1,(i=t.customRanges)!=null?i:[]),r=Math.min(e.startOffset,(a=(o=n[0])==null?void 0:o.startIndex)!=null?a:1/0),s=Math.max(e.endOffset,((c=(l=n[n.length-1])==null?void 0:l.endIndex)!=null?c:-1/0)+1);return{startOffset:r,endOffset:s,collapsed:r===s}}var No,Pu;function Np(){if(Pu)return No;Pu=1;var e=-1,t=1,n=0;function r(g,P,v,M,T){if(g===P)return g?[[n,g]]:[];if(v!=null){var w=$(g,P,v);if(w)return w}var N=a(g,P),L=g.substring(0,N);g=g.substring(N),P=P.substring(N),N=c(g,P);var D=g.substring(g.length-N);g=g.substring(0,g.length-N),P=P.substring(0,P.length-N);var F=s(g,P);return L&&F.unshift([n,L]),D&&F.push([n,D]),B(F,T),M&&h(F),F}function s(g,P){var v;if(!g)return[[t,P]];if(!P)return[[e,g]];var M=g.length>P.length?g:P,T=g.length>P.length?P:g,w=M.indexOf(T);if(w!==-1)return v=[[t,M.substring(0,w)],[n,T],[t,M.substring(w+T.length)]],g.length>P.length&&(v[0][0]=v[2][0]=e),v;if(T.length===1)return[[e,g],[t,P]];var N=u(g,P);if(N){var L=N[0],D=N[1],F=N[2],Q=N[3],z=N[4],le=r(L,F),ue=r(D,Q);return le.concat([[n,z]],ue)}return i(g,P)}function i(g,P){for(var v=g.length,M=P.length,T=Math.ceil((v+M)/2),w=T,N=2*T,L=new Array(N),D=new Array(N),F=0;F<N;F++)L[F]=-1,D[F]=-1;L[w+1]=0,D[w+1]=0;for(var Q=v-M,z=Q%2!==0,le=0,ue=0,S=0,U=0,G=0;G<T;G++){for(var V=-G+le;V<=G-ue;V+=2){var W=w+V,j;V===-G||V!==G&&L[W-1]<L[W+1]?j=L[W+1]:j=L[W-1]+1;for(var ee=j-V;j<v&&ee<M&&g.charAt(j)===P.charAt(ee);)j++,ee++;if(L[W]=j,j>v)ue+=2;else if(ee>M)le+=2;else if(z){var te=w+Q-V;if(te>=0&&te<N&&D[te]!==-1){var k=v-D[te];if(j>=k)return o(g,P,j,ee)}}}for(var K=-G+S;K<=G-U;K+=2){var te=w+K,k;K===-G||K!==G&&D[te-1]<D[te+1]?k=D[te+1]:k=D[te-1]+1;for(var q=k-K;k<v&&q<M&&g.charAt(v-k-1)===P.charAt(M-q-1);)k++,q++;if(D[te]=k,k>v)U+=2;else if(q>M)S+=2;else if(!z){var W=w+Q-K;if(W>=0&&W<N&&L[W]!==-1){var j=L[W],ee=w+j-W;if(k=v-k,j>=k)return o(g,P,j,ee)}}}}return[[e,g],[t,P]]}function o(g,P,v,M){var T=g.substring(0,v),w=P.substring(0,M),N=g.substring(v),L=P.substring(M),D=r(T,w),F=r(N,L);return D.concat(F)}function a(g,P){if(!g||!P||g.charAt(0)!==P.charAt(0))return 0;for(var v=0,M=Math.min(g.length,P.length),T=M,w=0;v<T;)g.substring(w,T)==P.substring(w,T)?(v=T,w=v):M=T,T=Math.floor((M-v)/2+v);return x(g.charCodeAt(T-1))&&T--,T}function l(g,P){var v=g.length,M=P.length;if(v==0||M==0)return 0;v>M?g=g.substring(v-M):v<M&&(P=P.substring(0,v));var T=Math.min(v,M);if(g==P)return T;for(var w=0,N=1;;){var L=g.substring(T-N),D=P.indexOf(L);if(D==-1)return w;N+=D,(D==0||g.substring(T-N)==P.substring(0,N))&&(w=N,N++)}}function c(g,P){if(!g||!P||g.slice(-1)!==P.slice(-1))return 0;for(var v=0,M=Math.min(g.length,P.length),T=M,w=0;v<T;)g.substring(g.length-T,g.length-w)==P.substring(P.length-T,P.length-w)?(v=T,w=v):M=T,T=Math.floor((M-v)/2+v);return Y(g.charCodeAt(g.length-T))&&T--,T}function u(g,P){var v=g.length>P.length?g:P,M=g.length>P.length?P:g;if(v.length<4||M.length*2<v.length)return null;function T(ue,S,U){for(var G=ue.substring(U,U+Math.floor(ue.length/4)),V=-1,W="",j,ee,te,k;(V=S.indexOf(G,V+1))!==-1;){var K=a(ue.substring(U),S.substring(V)),q=c(ue.substring(0,U),S.substring(0,V));W.length<q+K&&(W=S.substring(V-q,V)+S.substring(V,V+K),j=ue.substring(0,U-q),ee=ue.substring(U+K),te=S.substring(0,V-q),k=S.substring(V+K))}return W.length*2>=ue.length?[j,ee,te,k,W]:null}var w=T(v,M,Math.ceil(v.length/4)),N=T(v,M,Math.ceil(v.length/2)),L;if(!w&&!N)return null;N?w?L=w[4].length>N[4].length?w:N:L=N:L=w;var D,F,Q,z;g.length>P.length?(D=L[0],F=L[1],Q=L[2],z=L[3]):(Q=L[0],z=L[1],D=L[2],F=L[3]);var le=L[4];return[D,F,Q,z,le]}function h(g){for(var P=!1,v=[],M=0,T=null,w=0,N=0,L=0,D=0,F=0;w<g.length;)g[w][0]==n?(v[M++]=w,N=D,L=F,D=0,F=0,T=g[w][1]):(g[w][0]==t?D+=g[w][1].length:F+=g[w][1].length,T&&T.length<=Math.max(N,L)&&T.length<=Math.max(D,F)&&(g.splice(v[M-1],0,[e,T]),g[v[M-1]+1][0]=t,M--,M--,w=M>0?v[M-1]:-1,N=0,L=0,D=0,F=0,T=null,P=!0)),w++;for(P&&B(g),A(g),w=1;w<g.length;){if(g[w-1][0]==e&&g[w][0]==t){var Q=g[w-1][1],z=g[w][1],le=l(Q,z),ue=l(z,Q);le>=ue?(le>=Q.length/2||le>=z.length/2)&&(g.splice(w,0,[n,z.substring(0,le)]),g[w-1][1]=Q.substring(0,Q.length-le),g[w+1][1]=z.substring(le),w++):(ue>=Q.length/2||ue>=z.length/2)&&(g.splice(w,0,[n,Q.substring(0,ue)]),g[w-1][0]=t,g[w-1][1]=z.substring(0,z.length-ue),g[w+1][0]=e,g[w+1][1]=Q.substring(ue),w++),w++}w++}}var d=/[^a-zA-Z0-9]/,m=/\s/,_=/[\r\n]/,p=/\n\r?\n$/,I=/^\r?\n\r?\n/;function A(g){function P(ue,S){if(!ue||!S)return 6;var U=ue.charAt(ue.length-1),G=S.charAt(0),V=U.match(d),W=G.match(d),j=V&&U.match(m),ee=W&&G.match(m),te=j&&U.match(_),k=ee&&G.match(_),K=te&&ue.match(p),q=k&&S.match(I);return K||q?5:te||k?4:V&&!j&&ee?3:j||ee?2:V||W?1:0}for(var v=1;v<g.length-1;){if(g[v-1][0]==n&&g[v+1][0]==n){var M=g[v-1][1],T=g[v][1],w=g[v+1][1],N=c(M,T);if(N){var L=T.substring(T.length-N);M=M.substring(0,M.length-N),T=L+T.substring(0,T.length-N),w=L+w}for(var D=M,F=T,Q=w,z=P(M,T)+P(T,w);T.charAt(0)===w.charAt(0);){M+=T.charAt(0),T=T.substring(1)+w.charAt(0),w=w.substring(1);var le=P(M,T)+P(T,w);le>=z&&(z=le,D=M,F=T,Q=w)}g[v-1][1]!=D&&(D?g[v-1][1]=D:(g.splice(v-1,1),v--),g[v][1]=F,Q?g[v+1][1]=Q:(g.splice(v+1,1),v--))}v++}}function B(g,P){g.push([n,""]);for(var v=0,M=0,T=0,w="",N="",L;v<g.length;){if(v<g.length-1&&!g[v][1]){g.splice(v,1);continue}switch(g[v][0]){case t:T++,N+=g[v][1],v++;break;case e:M++,w+=g[v][1],v++;break;case n:var D=v-T-M-1;if(P){if(D>=0&&R(g[D][1])){var F=g[D][1].slice(-1);if(g[D][1]=g[D][1].slice(0,-1),w=F+w,N=F+N,!g[D][1]){g.splice(D,1),v--;var Q=D-1;g[Q]&&g[Q][0]===t&&(T++,N=g[Q][1]+N,Q--),g[Q]&&g[Q][0]===e&&(M++,w=g[Q][1]+w,Q--),D=Q}}if(O(g[v][1])){var F=g[v][1].charAt(0);g[v][1]=g[v][1].slice(1),w+=F,N+=F}}if(v<g.length-1&&!g[v][1]){g.splice(v,1);break}if(w.length>0||N.length>0){w.length>0&&N.length>0&&(L=a(N,w),L!==0&&(D>=0?g[D][1]+=N.substring(0,L):(g.splice(0,0,[n,N.substring(0,L)]),v++),N=N.substring(L),w=w.substring(L)),L=c(N,w),L!==0&&(g[v][1]=N.substring(N.length-L)+g[v][1],N=N.substring(0,N.length-L),w=w.substring(0,w.length-L)));var z=T+M;w.length===0&&N.length===0?(g.splice(v-z,z),v=v-z):w.length===0?(g.splice(v-z,z,[t,N]),v=v-z+1):N.length===0?(g.splice(v-z,z,[e,w]),v=v-z+1):(g.splice(v-z,z,[e,w],[t,N]),v=v-z+2)}v!==0&&g[v-1][0]===n?(g[v-1][1]+=g[v][1],g.splice(v,1)):v++,T=0,M=0,w="",N="";break}}g[g.length-1][1]===""&&g.pop();var le=!1;for(v=1;v<g.length-1;)g[v-1][0]===n&&g[v+1][0]===n&&(g[v][1].substring(g[v][1].length-g[v-1][1].length)===g[v-1][1]?(g[v][1]=g[v-1][1]+g[v][1].substring(0,g[v][1].length-g[v-1][1].length),g[v+1][1]=g[v-1][1]+g[v+1][1],g.splice(v-1,1),le=!0):g[v][1].substring(0,g[v+1][1].length)==g[v+1][1]&&(g[v-1][1]+=g[v+1][1],g[v][1]=g[v][1].substring(g[v+1][1].length)+g[v+1][1],g.splice(v+1,1),le=!0)),v++;le&&B(g,P)}function x(g){return g>=55296&&g<=56319}function Y(g){return g>=56320&&g<=57343}function O(g){return Y(g.charCodeAt(0))}function R(g){return x(g.charCodeAt(g.length-1))}function b(g){for(var P=[],v=0;v<g.length;v++)g[v][1].length>0&&P.push(g[v]);return P}function y(g,P,v,M){return R(g)||O(M)?null:b([[n,g],[e,P],[t,v],[n,M]])}function $(g,P,v){var M=typeof v=="number"?{index:v,length:0}:v.oldRange,T=typeof v=="number"?null:v.newRange,w=g.length,N=P.length;if(M.length===0&&(T===null||T.length===0)){var L=M.index,D=g.slice(0,L),F=g.slice(L),Q=T?T.index:null;e:{var z=L+N-w;if(Q!==null&&Q!==z||z<0||z>N)break e;var le=P.slice(0,z),ue=P.slice(z);if(ue!==F)break e;var S=Math.min(L,z),U=D.slice(0,S),G=le.slice(0,S);if(U!==G)break e;var V=D.slice(S),W=le.slice(S);return y(U,V,W,F)}e:{if(Q!==null&&Q!==L)break e;var j=L,le=P.slice(0,j),ue=P.slice(j);if(le!==D)break e;var ee=Math.min(w-j,N-j),te=F.slice(F.length-ee),k=ue.slice(ue.length-ee);if(te!==k)break e;var V=F.slice(0,F.length-ee),W=ue.slice(0,ue.length-ee);return y(D,V,W,te)}}if(M.length>0&&T&&T.length===0)e:{var U=g.slice(0,M.index),te=g.slice(M.index+M.length),S=U.length,ee=te.length;if(N<S+ee)break e;var G=P.slice(0,S),k=P.slice(N-ee);if(U!==G||te!==k)break e;var V=g.slice(S,w-ee),W=P.slice(S,N-ee);return y(U,V,W,te)}return null}function H(g,P,v,M){return r(g,P,v,M,!0)}return H.INSERT=t,H.DELETE=e,H.EQUAL=n,No=H,No}var Mp=Np();const Mo=mt(Mp);function Lp(e){var h,d,m;const{rangeId:t,segmentId:n,documentDataModel:r,insert:s}=e,i=(d=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.customRanges)==null?void 0:d.find(_=>_.rangeId===t);if(!i)return!1;const{startIndex:o,endIndex:a}=i,l=new Me,c=a-o+1;l.push({t:J.RETAIN,len:o}),l.push({t:J.RETAIN,len:c,body:{dataStream:"",customRanges:[]}}),s&&l.push({t:J.INSERT,body:s,len:s.dataStream.length});const u=a+1+((m=s==null?void 0:s.dataStream.length)!=null?m:0);return l.selections=[{startOffset:u,endOffset:u,collapsed:!0}],l}function Dp(e){const{ranges:t,rangeId:n,rangeType:r,wholeEntity:s,properties:i,body:o}=e;let a=0;const l=new Me;let c=!1;return t.forEach(u=>{var x,Y,O;const h=yp(u,o);if(!h||!o)return!1;const{startOffset:d,endOffset:m}=h,_=(x=o.customRanges)!=null?x:[],p=(R,b,y)=>{var v,M,T,w;const $=Uu(R,b,_,r),H=Math.min((M=(v=$[0])==null?void 0:v.startIndex)!=null?M:1/0,R),g=Math.max((w=(T=$[$.length-1])==null?void 0:T.endIndex)!=null?w:-1/0,b),P={rangeId:y?`${n}$${y}`:n,rangeType:r,startIndex:0,endIndex:g-H,wholeEntity:s,properties:{...i}};l.push({t:J.RETAIN,len:H-a}),l.push({t:J.RETAIN,len:g-H+1,body:{dataStream:"",customRanges:[P]},coverType:Ce.COVER}),a=g+1},I=((Y=o.paragraphs)!=null?Y:[]).filter(R=>R.startIndex<m&&R.startIndex>d),A=((O=o.customBlocks)!=null?O:[]).filter(R=>R.startIndex<m&&R.startIndex>d);Tp([d,m-1],[...I.map(R=>R.startIndex),...A.map(R=>R.startIndex)]).forEach(([R,b],y)=>p(R,b,y)),c=!0,l.selections=[{startOffset:h.endOffset,endOffset:h.endOffset,collapsed:!0}]}),c?l:!1}function ku(e,t,n=0,r=null,s=!0){e.sort((c,u)=>c.startOffset-u.startOffset);const i=[],{paragraphs:o=[]}=t,a=o==null?void 0:o.find(c=>c.startIndex>=e[0].startOffset&&c.startIndex<e[0].endOffset);let l=n;if(e.forEach(c=>{const{startOffset:u,endOffset:h}=c;u>l&&(i.push({t:J.RETAIN,len:u-l}),l=u),l<h&&(i.push({t:J.DELETE,len:h-l}),l=h)}),r&&i.push({t:J.INSERT,body:r,len:r.dataStream.length}),a&&s){const c=o.find(u=>u.startIndex-n>=e[e.length-1].endOffset-1);c&&(c.startIndex>l&&(i.push({t:J.RETAIN,len:c.startIndex-l}),l=c.startIndex),i.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...c,startIndex:0,bullet:a==null?void 0:a.bullet}]},coverType:Ce.REPLACE}))}return i}function Up(e,t,n=0){const r=[];let s=n;return e.forEach(i=>{const{startOffset:o,endOffset:a}=i;o>s&&(r.push({t:J.RETAIN,len:o-s}),s=o),a>s&&(r.push({t:J.RETAIN,len:a-s,body:{...Z.deepClone(t),dataStream:""}}),s=a)}),r}const Pp=e=>{var h;const{selection:t,body:n,doc:r}=e,s=t.segmentId,i=(h=r.getSelfOrHeaderFooterModel(s))==null?void 0:h.getBody();if(!i)return!1;const o=t.collapsed?null:bt(i,t.startOffset,t.endOffset),a=Mo(o?o.dataStream:"",n.dataStream);let l=0;const c=a.map(([d,m])=>{switch(d){case 0:{const _={t:J.RETAIN,body:{...bt(n,l,l+m.length,!1),dataStream:""},len:m.length};return l+=m.length,_}case 1:{const _={t:J.INSERT,body:bt(n,l,l+m.length),len:m.length};return l+=m.length,_}default:return{t:J.DELETE,len:m.length}}}),u=new Me;return u.push({t:J.RETAIN,len:t.startOffset}),u.push(...c),u};function kp(e,t){return!!((e==null?void 0:e.length)===(t==null?void 0:t.length)&&(e!=null&&e.every((n,r)=>JSON.stringify(n)===JSON.stringify(t==null?void 0:t[r]))))}const Fp=e=>{var d;const{selection:t,body:n,doc:r,themeService:s}=e,i=t.segmentId,o=(d=r.getSelfOrHeaderFooterModel(i))==null?void 0:d.getBody();if(!o)return!1;const a=t.collapsed?null:bt(o,t.startOffset,t.endOffset),l=Mo(a?a.dataStream:"",n.dataStream);let c=0;const u=l.map(([m,_])=>{switch(m){case 0:{const p=Hs(n,c,c+_.length,!1),I=Hs(a,c,c+_.length,!1),A={t:J.RETAIN,body:kp(p,I)?void 0:{textRuns:p==null?void 0:p.map(B=>{var x,Y,O,R,b,y,$;return{...B,ts:{...B.ts,cl:(O=(Y=(x=B.ts)==null?void 0:x.cl)==null?void 0:Y.rgb)!=null&&O.includes(".")?{rgb:s.getColorFromTheme((y=(b=(R=B.ts)==null?void 0:R.cl)==null?void 0:b.rgb)!=null?y:"")}:($=B.ts)==null?void 0:$.cl}}}),dataStream:""},len:_.length};return c+=_.length,A}case 1:{const p={t:J.INSERT,body:bt(n,c,c+_.length),len:_.length};return c+=_.length,p}default:return{t:J.DELETE,len:_.length}}});if(u.every(m=>m.t===J.RETAIN&&!m.body))return!1;const h=new Me;return h.push({t:J.RETAIN,len:t.startOffset}),h.push(...u),h};function xp(e,t){const n=[],{customBlocks:r=[]}=e;for(const s of t){const{startOffset:i,endOffset:o}=s;if(!(i==null||o==null))for(const a of r){const{startIndex:l}=a;l>=i&&l<o&&n.push(a.blockId)}}return n}function Bp(e,t=""){if(!t)return["body"];const{headers:n,footers:r}=e.getSnapshot();if(n==null&&r==null)throw new Error("Document data model must have headers or footers when update by segment id");if((n==null?void 0:n[t])!=null)return["headers",t,"body"];if((r==null?void 0:r[t])!=null)return["footers",t,"body"];throw new Error("Segment id not found in headers or footers")}const $p=e=>{var p,I,A,B;const{selection:t,documentDataModel:n,drawings:r}=e,{collapsed:s,startOffset:i,segmentId:o}=t,a=new Me,l=Wt.getInstance(),c=[],u=n.getSelfOrHeaderFooterModel(o).getBody();if(!u)return!1;const h=(I=(p=n.getSnapshot().drawingsOrder)==null?void 0:p.length)!=null?I:0;let d=0;if(s)i>0&&a.push({t:J.RETAIN,len:i});else{const x=ku([t],u,0,null,!1);a.push(...x);const Y=xp(u,[t]),O=(A=n.getDrawings())!=null?A:{},R=(B=n.getDrawingsOrder())!=null?B:[],b=Y.sort((y,$)=>R.indexOf(y)>R.indexOf($)?-1:R.indexOf(y)<R.indexOf($)?1:0);if(b.length>0)for(const y of b){const $=O[y],H=R.indexOf(y);if($==null||H<0)continue;const g=l.removeOp(["drawings",y],$),P=l.removeOp(["drawingsOrder",H],y);c.push(g),c.push(P),d++}}a.push({t:J.INSERT,body:{dataStream:"\b".repeat(r.length),customBlocks:r.map((x,Y)=>({startIndex:Y,blockId:x.drawingId}))},len:r.length});const m=Bp(n,o),_=l.editOp(a.serialize(),m);c.push(_);for(const x of r){const{drawingId:Y}=x,O=l.insertOp(["drawings",Y],x),R=l.insertOp(["drawingsOrder",h-d],Y);c.push(O),c.push(R)}return c.reduce((x,Y)=>Wt.compose(x,Y),null)};function Hp(e,t){if(typeof t>"u")return{startOffset:e,endOffset:e,collapsed:!0};if(t<e)throw new Error(`Cannot make a doc selection when endOffset ${t} is less than startOffset ${e}.`);return{startOffset:e,endOffset:t,collapsed:e===t}}function Wp(e){const{startOffset:t,endOffset:n,collapsed:r}=e,s=Math.min(t,n),i=Math.max(t,n);return{startOffset:s,endOffset:i,collapsed:r}}function jp(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function Lo(e,t,n,r){const{startOffset:s,endOffset:i}=e,o=r!=null?r:Uo(t,n),a=[];let l=-1;for(let c=0;c<o.length;c++){const u=o[c],{startIndex:h}=u;(s>l&&s<=h||i>l&&i<=h||h>=s&&h<=i)&&a.push(u),l=h}return a}function Do(e,t,n){const r=[],s=Uo(t,n);for(const i of e){const o=Lo(i,t,n,s);r.push(...o)}return r}const Yp=[lt.PARAGRAPH,lt.TABLE_START,lt.TABLE_END,lt.TABLE_ROW_START,lt.TABLE_CELL_START,lt.TABLE_CELL_END];function Uo(e,t){const n=[];for(let r=0;r<e.length;r++){const s=e[r],{startIndex:i}=s;let o=i-1;for(;!Yp.includes(t[o])&&o>=0;)o--;n.push({...s,paragraphStart:o+1,paragraphEnd:s.startIndex})}return n}const Gp=e=>{var h,d,m;const{paragraphs:t,segmentId:n,document:r}=e;let s=e.listType;const i=(d=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.paragraphs)!=null?d:[],o=t.every(_=>{var p;return((p=_.bullet)==null?void 0:p.listType.indexOf(s))===0});let l=tt(6);if(t.length===1){const _=i.indexOf(t[0]),p=i[_-1],I=i[_+1];p&&p.bullet&&p.bullet.listType.indexOf(s)===0?(l=p.bullet.listId,s!==Ft.CHECK_LIST&&(s=p.bullet.listType)):I&&I.bullet&&I.bullet.listType.indexOf(s)===0&&(l=I.bullet.listId,s!==Ft.CHECK_LIST&&(s=I.bullet.listType))}const c=new un;c.reset();const u=new Me;for(const _ of t){const{startIndex:p,paragraphStyle:I={},bullet:A}=_;u.push({t:J.RETAIN,len:p-c.cursor}),u.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[o?{paragraphStyle:I,startIndex:0}:{startIndex:0,paragraphStyle:{...I},bullet:{nestingLevel:(m=A==null?void 0:A.nestingLevel)!=null?m:0,textStyle:{fs:20},listType:s,listId:l}}]},coverType:Ce.REPLACE}),c.moveCursorTo(p+1)}return u},Vp=e=>{var h;const{paragraphIndex:t,segmentId:n,document:r}=e,s=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.paragraphs;if(s==null)return!1;const i=s.find(d=>d.startIndex===t);if(!(i!=null&&i.bullet)||i.bullet.listType.indexOf(Ft.CHECK_LIST)===-1)return!1;const o=new un;o.reset();const a=new Me,{startIndex:l,paragraphStyle:c={}}=i,u=i.bullet.listType===Ft.CHECK_LIST?Ft.CHECK_LIST_CHECKED:Ft.CHECK_LIST;return a.push({t:J.RETAIN,len:l-o.cursor}),a.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...i,paragraphStyle:c,startIndex:0,bullet:{...i.bullet,listType:u}}]},coverType:Ce.REPLACE}),o.moveCursorTo(l+1),a},zp=e=>{var u,h;const{paragraphs:t,listType:n,segmentId:r,document:s}=e;if(((u=s.getSelfOrHeaderFooterModel(r).getBody())==null?void 0:u.paragraphs)==null)return!1;const a=tt(6),l=new un;l.reset();const c=new Me;for(const d of t){const{startIndex:m,paragraphStyle:_={},bullet:p}=d;c.push({t:J.RETAIN,len:m-l.cursor}),c.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:_,bullet:{nestingLevel:(h=p==null?void 0:p.nestingLevel)!=null?h:0,textStyle:(p==null?void 0:p.listType)===n?p.textStyle:{fs:20},listType:n,listId:a}}]},coverType:Ce.REPLACE}),l.moveCursorTo(m+1)}return c};function Kp(e,t){return t.some(n=>e.startIndex>n.startIndex&&e.startIndex<n.endIndex)}const Xp=e=>{var c,u,h;const{paragraphs:t,document:n,type:r}=e,s=new un;s.reset();const i=new Me,o=(c=n.getSnapshot().lists)!=null?c:{},a=(h=(u=n.getBody())==null?void 0:u.tables)!=null?h:[],l={...Nr,...o};for(const d of t){const{startIndex:m,paragraphStyle:_={},bullet:p}=d,I=Kp(d,a);if(i.push({t:J.RETAIN,len:m-s.cursor}),p){const A=p.listType;let B=l[A].nestingLevel.length-1;I&&(B=Math.min(B,2)),i.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:{..._},bullet:{...p,nestingLevel:Math.max(Math.min(p.nestingLevel+r,B),0)}}]},coverType:Ce.REPLACE})}else i.push({t:J.RETAIN,len:1});s.moveCursorTo(m+1)}return i},qp=e=>{var I,A,B,x;const{textRanges:t,segmentId:n,document:r,style:s,paragraphTextRun:i,cursor:o,deleteLen:a,textX:l}=e,c=r.getSelfOrHeaderFooterModel(n),u=(A=(I=c.getBody())==null?void 0:I.paragraphs)!=null?A:[],h=(x=(B=c.getBody())==null?void 0:B.dataStream)!=null?x:"",d=Do(t,u,h),m=new un;o&&m.moveCursorTo(o);const _=l!=null?l:new Me;d.sort((Y,O)=>Y.startIndex-O.startIndex);const p=Math.max(0,d[0].paragraphStart-1);p>m.cursor&&(_.push({t:J.RETAIN,len:p-m.cursor}),m.moveCursorTo(p)),a&&_.push({t:J.DELETE,len:a});for(const Y of d){const{startIndex:O,paragraphStyle:R={}}=Y,b=O-m.cursor;_.push({t:J.RETAIN,len:b,...i?{body:{dataStream:"",textRuns:[{ts:i,st:0,ed:b}]},coverType:Ce.REPLACE}:null}),_.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:{...R,...s}}]},coverType:Ce.REPLACE}),m.moveCursorTo(O+1)}return _};class Je{}C(Je,"customRange",{add:Dp,delete:Lp,copyCustomRange:Ap,getCustomRangesInterestsWithSelection:bp,isIntersecting:Du}),C(Je,"customDecoration",{add:vp,delete:wp}),C(Je,"selection",{replace:Pp,makeSelection:Hp,normalizeSelection:Wp,delete:ku,replaceTextRuns:Fp,retain:Up}),C(Je,"range",{isIntersects:jp,getParagraphsInRange:Lo,getParagraphsInRanges:Do}),C(Je,"transform",{getPlainText:Ws,fromPlainText:Sp,isEmptyDocument:Ip}),C(Je,"paragraph",{bullet:{set:zp,switch:Gp,toggleChecklist:Vp,changeNestLevel:Xp},style:{set:qp},util:{transform:Uo,getParagraphsInRange:Lo,getParagraphsInRanges:Do}}),C(Je,"drawing",{add:$p});function Zp(e,t,n,r){var c;if(t==="")return e;const s={id:"mock-id",body:e,documentStyle:{}},i=new At(s),o=t.length;let a;for(;(a=(r?i.getBody().dataStream:i.getBody().dataStream.toLowerCase()).indexOf(t))>=0;){const u=new Me,h=Wt.getInstance();if(a>0&&u.retain(a),n.length>0){const d=i.sliceBody(a,a+o),m={dataStream:n};if(Array.isArray(d==null?void 0:d.textRuns)&&d.textRuns.length&&(m.textRuns=[{...d.textRuns[0],st:0,ed:n.length}]),(c=d==null?void 0:d.customRanges)!=null&&c.length){const _=d.customRanges[0];m.customRanges=[{..._,startIndex:0,endIndex:n.length-1}]}u.insert(n.length,m)}u.delete(o),i.apply(h.editOp(u.serialize()))}const l=i.getBody();return i.dispose(),l}function Jp(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 Fu(e){var t;return e.body=Jp((t=e.body)!=null?t:{dataStream:""}),e.drawingsOrder||(e.drawingsOrder=[]),e.drawings||(e.drawings={}),e.documentStyle||(e.documentStyle={}),e}class Mr{constructor(t={}){C(this,"_style");this._style=t}static create(t={}){return new Mr(t)}get fontFamily(){return this._style.ff}get fontSize(){return this._style.fs}get italic(){return this._style.it===ae.TRUE}get bold(){return this._style.bl===ae.TRUE}get underline(){return this._style.ul&&rn.create(this._style.ul)}get bottomBorderLine(){return this._style.bbl&&rn.create(this._style.bbl)}get strikethrough(){return this._style.st&&rn.create(this._style.st)}get overline(){return this._style.ol&&rn.create(this._style.ol)}get background(){return this._style.bg}get border(){return this._style.bd}get color(){return this._style.cl}get verticalAlign(){return this._style.va}get numberFormat(){return this._style.n}copy(){return nn.create(Z.deepClone(this._style))}getValue(){return{...this._style}}}class nn extends Mr{static create(t={}){return new nn(t)}constructor(t={}){super(t)}setFontFamily(t){return this._style.ff=t,this}setFontSize(t){return this._style.fs=t,this}setItalic(t){return this._style.it=t?1:0,this}setBold(t){return this._style.bl=t?1:0,this}setUnderline(t){return this._style.ul=t.build(),this}setBottomBorderLine(t){return this._style.bbl=t.build(),this}setStrikethrough(t){return this._style.st=t.build(),this}setOverline(t){return this._style.ol=t.build(),this}setBackground(t){return this._style.bg=t,this}setBorder(t){return this._style.bd=t,this}setColor(t){return this._style.cl=t,this}setVerticalAlign(t){return this._style.va=t,this}copy(){return nn.create(Z.deepClone(this._style))}build(){return this.getValue()}}class rn{constructor(t={s:1}){C(this,"_decoration");this._decoration=t}static create(t={s:1}){return new rn(t)}get show(){return this._decoration.s===ae.TRUE}get followFontColor(){return this._decoration.c===ae.TRUE}get color(){return this._decoration.cl}get type(){return this._decoration.t}setShow(t){return this._decoration.s=t?1:0,this}setFollowFontColor(t){return this._decoration.c=t?1:0,this}setColor(t){return this._decoration.cl=t,this}setLineType(t){return this._decoration.t=t,this}copy(){return rn.create(Z.deepClone(this._decoration))}build(){return{...this._decoration}}}class Lr{constructor(t={}){C(this,"_style");this._style=t}static create(t={}){return new Lr(t)}get indentFirstLine(){return this._style.indentFirstLine}get hanging(){return this._style.hanging}get indentStart(){return this._style.indentStart}get tabStops(){return this._style.tabStops}get indentEnd(){return this._style.indentEnd}get textStyle(){return this._style.textStyle}get headingId(){return this._style.headingId}get namedStyleType(){return this._style.namedStyleType}get horizontalAlign(){return this._style.horizontalAlign}get lineSpacing(){return this._style.lineSpacing}get direction(){return this._style.direction}get spacingRule(){return this._style.spacingRule}get snapToGrid(){return this._style.snapToGrid}get spaceAbove(){return this._style.spaceAbove}get spaceBelow(){return this._style.spaceBelow}get borderBetween(){return this._style.borderBetween}get borderTop(){return this._style.borderTop}get borderBottom(){return this._style.borderBottom}get borderLeft(){return this._style.borderLeft}get borderRight(){return this._style.borderRight}get keepLines(){return this._style.keepLines===ae.TRUE}get keepNext(){return this._style.keepNext===ae.TRUE}get wordWrap(){return this._style.wordWrap===ae.TRUE}get widowControl(){return this._style.widowControl===ae.TRUE}get shading(){return this._style.shading}get suppressHyphenation(){return this._style.suppressHyphenation===ae.TRUE}copy(){return Dr.create(Z.deepClone(this._style))}getValue(){return this._style}}class Dr extends Lr{static create(t={}){return new Dr(t)}constructor(t={}){super(t)}setIndentFirstLine(t){return this._style.indentFirstLine=t,this}setHanging(t){return this._style.hanging=t,this}setIndentStart(t){return this._style.indentStart=t,this}setTabStops(t){return this._style.tabStops=t,this}setIndentEnd(t){return this._style.indentEnd=t,this}setTextStyle(t){return this._style.textStyle=t,this}setHeadingId(t){return this._style.headingId=t,this}setNamedStyleType(t){return this._style.namedStyleType=t,this}setHorizontalAlign(t){return this._style.horizontalAlign=t,this}setLineSpacing(t){return this._style.lineSpacing=t,this}setDirection(t){return this._style.direction=t,this}setSpacingRule(t){return this._style.spacingRule=t,this}setSnapToGrid(t){return this._style.snapToGrid=t?1:0,this}setSpaceAbove(t){return this._style.spaceAbove=t,this}setSpaceBelow(t){return this._style.spaceBelow=t,this}setBorderBetween(t){return this._style.borderBetween=t,this}setBorderTop(t){return this._style.borderTop=t,this}setBorderBottom(t){return this._style.borderBottom=t,this}setBorderLeft(t){return this._style.borderLeft=t,this}setBorderRight(t){return this._style.borderRight=t,this}setKeepLines(t){return this._style.keepLines=t?1:0,this}setKeepNext(t){return this._style.keepNext=t?1:0,this}setWordWrap(t){return this._style.wordWrap=t?1:0,this}setWidowControl(t){return this._style.widowControl=t?1:0,this}setShading(t){return this._style.shading=t,this}setSuppressHyphenation(t){return this._style.suppressHyphenation=t?1:0,this}copy(){return Dr.create(Z.deepClone(this._style))}build(){return this.getValue()}}class sn{constructor(t){C(this,"_data");if(!t.body)throw new Error("Invalid document data, body is required");this._data=Fu(t)}static create(t){return new sn(t)}static createByBody(t){return new sn({body:t,id:"d",documentStyle:{}})}copy(){return Cn.create(Z.deepClone(this._data))}slice(t,n){const{body:r,...s}=this._data;return Cn.create({...Z.deepClone(s),body:bt(r,t,n)})}toPlainText(){var t,n;return Je.transform.getPlainText((n=(t=this._data.body)==null?void 0:t.dataStream)!=null?n:"").replaceAll("\r",`
6
+ `)?e.slice(0,-2):e;return Rp.reduce((n,r)=>n.replaceAll(r,""),t)},Ip=e=>e?Ws(e).replaceAll("\r","")==="":!0,Sp=e=>{const t=e.replace(/\n/g,"\r"),n=[],r=[];let s=0,i="";const o=(l,c=!0)=>{const u=t.slice(s,l);if(Z.isLegalUrl(u)){const h=tt(),d=`${u}`,m={startIndex:s,endIndex:s+d.length-1,rangeId:h,rangeType:en.HYPERLINK,properties:{url:e}};r.push(m),i+=d,s=l+1,c&&(i+="\r",n.push({startIndex:l}))}else i+=t.slice(s,l+1),s=l+1,c&&n.push({startIndex:l})};let a=0;for(let l=0;l<t.length;l++)t[l]==="\r"&&(o(l),a=l);return(a!==t.length-1||t.length===1)&&o(t.length,!1),{dataStream:i,paragraphs:n,customRanges:r}},yo={id:"default_doc",documentStyle:{}};class Op extends Ps{constructor(n){var r;super();C(this,"type",we.UNIVER_DOC);C(this,"_name$",new oe.BehaviorSubject(""));C(this,"name$",this._name$.asObservable());C(this,"snapshot");this.snapshot={...yo,...n},this._name$.next((r=this.snapshot.title)!=null?r:"No Title")}getUnitId(){throw new Error("Method not implemented.")}getRev(){var n;return(n=this.snapshot.rev)!=null?n:1}incrementRev(){this.snapshot.rev=this.getRev()+1}setRev(n){this.snapshot.rev=n}setName(n){this.snapshot.title=n,this._name$.next(n)}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get zoomRatio(){var n;return((n=this.snapshot.settings)==null?void 0:n.zoomRatio)||1}resetDrawing(n,r){this.snapshot.drawings=n,this.snapshot.drawingsOrder=r}getBody(){return this.snapshot.body}getSnapshot(){return this.snapshot}getBulletPresetList(){var s;const n=(s=this.snapshot.lists)!=null?s:{};return{...Nr,...n}}updateDocumentId(n){this.snapshot.id=n}updateDocumentRenderConfig(n){const{documentStyle:r}=this.snapshot;r.renderConfig==null?r.renderConfig=n:r.renderConfig={...r.renderConfig,...n}}getDocumentStyle(){return this.snapshot.documentStyle}updateDocumentStyle(n){this.snapshot.documentStyle==null?this.snapshot.documentStyle=n:this.snapshot.documentStyle={...this.snapshot.documentStyle,...n}}updateDocumentDataMargin(n){const{t:r,l:s,b:i,r:o}=n,{documentStyle:a}=this.snapshot;r!=null&&(a.marginTop=r),s!=null&&(a.marginLeft=s),i!=null&&(a.marginBottom=i),o!=null&&(a.marginRight=o)}updateDocumentDataPageSize(n,r){const{documentStyle:s}=this.snapshot;if(!s.pageSize){s.pageSize={width:n!=null?n:Number.POSITIVE_INFINITY,height:r!=null?r:Number.POSITIVE_INFINITY};return}n!==void 0&&(s.pageSize.width=n),r!==void 0&&(s.pageSize.height=r)}updateDrawing(n,r){const{drawings:s}=this,{width:i,height:o,left:a,top:l}=r,c=s==null?void 0:s[n];if(!c)return;const u=c.docTransform;u.size.width=i,u.size.height=o,u.positionH.posOffset=a,u.positionV.posOffset=l}setZoomRatio(n=1){this.snapshot.settings?this.snapshot.settings.zoomRatio=n:this.snapshot.settings={zoomRatio:n}}setDisabled(n){this.snapshot.disabled=n}getDisabled(){return this.snapshot.disabled}getTitle(){return this.snapshot.title}}class At extends Op{constructor(n){var s,i;super(Z.isEmptyObject(n)?F_():n);C(this,"_unitId");C(this,"headerModelMap",new Map);C(this,"footerModelMap",new Map);C(this,"change$",new oe.BehaviorSubject(0));const r=6;this._unitId=(s=this.snapshot.id)!=null?s:tt(r),this._initializeHeaderFooterModel(),this._name$.next((i=this.snapshot.title)!=null?i:"")}dispose(){super.dispose(),this.headerModelMap.forEach(n=>{n.dispose()}),this.footerModelMap.forEach(n=>{n.dispose()}),this._name$.complete()}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getCustomRanges(){var n;return(n=this.snapshot.body)==null?void 0:n.customRanges}getCustomDecorations(){var n;return(n=this.snapshot.body)==null?void 0:n.customDecorations}getSettings(){return this.snapshot.settings}reset(n){if(n.id&&n.id!==this._unitId)throw new Error("Cannot reset a document model with a different unit id!");this.snapshot={...yo,...n},this._initializeHeaderFooterModel(),this.change$.next(this.change$.value+1)}getSelfOrHeaderFooterModel(n){if(n!=null){if(this.headerModelMap.has(n))return this.headerModelMap.get(n);if(this.footerModelMap.has(n))return this.footerModelMap.get(n)}return this}getUnitId(){return this._unitId}apply(n){if(!Wt.isNoop(n))return this.snapshot=Wt.apply(this.snapshot,n),n!=null&&n.some(r=>Array.isArray(r)&&((r==null?void 0:r[0])==="headers"||(r==null?void 0:r[0])==="footers"))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.change$.next(this.change$.value+1),this.snapshot}sliceBody(n,r,s=Ao.copy){const i=this.getBody();if(i!=null)return bt(i,n,r,!1,s)}_initializeHeaderFooterModel(){const{headers:n,footers:r}=this.getSnapshot();if(n)for(const s in n){const i=n[s];this.headerModelMap.set(s,new At(i)),this.headerModelMap.get(s).updateDocumentId(this.getUnitId())}if(r)for(const s in r){const i=r[s];this.footerModelMap.set(s,new At(i)),this.footerModelMap.get(s).updateDocumentId(this.getUnitId())}}updateDocumentId(n){super.updateDocumentId(n),this._unitId=n}getPlainText(){var n,r;return Ws((r=(n=this.getBody())==null?void 0:n.dataStream)!=null?r:"")}}function vp(e){const{ranges:t,id:n,type:r}=e,s=new Me;let i=0;for(let o=0;o<t.length;o++){const a=t[o],{startOffset:l,endOffset:c}=a;l>0&&s.push({t:J.RETAIN,len:l-i}),s.push({t:J.RETAIN,body:{dataStream:"",customDecorations:[{id:n,type:r,startIndex:0,endIndex:c-l-1}]},len:c-l}),i=c}return s}function wp(e){var u,h,d;const{id:t,segmentId:n,documentDataModel:r}=e,s=r==null?void 0:r.getBody();if(!r||!s)return!1;const i=(d=(h=(u=r.getSelfOrHeaderFooterModel(n))==null?void 0:u.getBody())==null?void 0:h.customDecorations)==null?void 0:d.find(m=>m.id===t);if(!i)return!1;const o=new Me,{startIndex:a,endIndex:l}=i,c=l-a+1;return o.push({t:J.RETAIN,len:a}),o.push({t:J.RETAIN,len:c,body:{dataStream:"",customDecorations:[{startIndex:0,endIndex:c-1,id:t,type:_n.DELETED}]}}),o}function Du(e,t,n,r){return e<=n&&t>=n||e>=n&&e<=r}function bp(e,t){const n=[];for(let r=0,s=t.length;r<s;r++){const i=t[r];e.collapsed?i.startIndex<e.startOffset&&e.startOffset<=i.endIndex&&n.push(i):Du(e.startOffset,e.endOffset-1,i.startIndex,i.endIndex)&&n.push(i)}return n}function Ap(e){return{...Z.deepClone(e),rangeId:tt()}}function Tp(e,t){const n=[];let r=e[0];for(const s of t)s<e[0]||s>e[1]||(r<s&&n.push([r,s-1]),r=s+1);return r<=e[1]&&n.push([r,e[1]]),n}function Uu(e,t,n,r){const s=[];for(let i=0,o=n.length;i<o;i++){const a=n[i];if((r===void 0||a.rangeType===r)&&Math.max(a.startIndex,e)<=Math.min(a.endIndex,t)&&s.push({...a}),a.startIndex>t)break}return s}function yp(e,t){var i,o,a,l,c;const n=Uu(e.startOffset,e.collapsed?e.startOffset:e.endOffset-1,(i=t.customRanges)!=null?i:[]),r=Math.min(e.startOffset,(a=(o=n[0])==null?void 0:o.startIndex)!=null?a:1/0),s=Math.max(e.endOffset,((c=(l=n[n.length-1])==null?void 0:l.endIndex)!=null?c:-1/0)+1);return{startOffset:r,endOffset:s,collapsed:r===s}}var No,Pu;function Np(){if(Pu)return No;Pu=1;var e=-1,t=1,n=0;function r(g,P,v,M,T){if(g===P)return g?[[n,g]]:[];if(v!=null){var w=$(g,P,v);if(w)return w}var N=a(g,P),L=g.substring(0,N);g=g.substring(N),P=P.substring(N),N=c(g,P);var D=g.substring(g.length-N);g=g.substring(0,g.length-N),P=P.substring(0,P.length-N);var F=s(g,P);return L&&F.unshift([n,L]),D&&F.push([n,D]),B(F,T),M&&h(F),F}function s(g,P){var v;if(!g)return[[t,P]];if(!P)return[[e,g]];var M=g.length>P.length?g:P,T=g.length>P.length?P:g,w=M.indexOf(T);if(w!==-1)return v=[[t,M.substring(0,w)],[n,T],[t,M.substring(w+T.length)]],g.length>P.length&&(v[0][0]=v[2][0]=e),v;if(T.length===1)return[[e,g],[t,P]];var N=u(g,P);if(N){var L=N[0],D=N[1],F=N[2],Q=N[3],z=N[4],le=r(L,F),ue=r(D,Q);return le.concat([[n,z]],ue)}return i(g,P)}function i(g,P){for(var v=g.length,M=P.length,T=Math.ceil((v+M)/2),w=T,N=2*T,L=new Array(N),D=new Array(N),F=0;F<N;F++)L[F]=-1,D[F]=-1;L[w+1]=0,D[w+1]=0;for(var Q=v-M,z=Q%2!==0,le=0,ue=0,S=0,U=0,G=0;G<T;G++){for(var V=-G+le;V<=G-ue;V+=2){var W=w+V,j;V===-G||V!==G&&L[W-1]<L[W+1]?j=L[W+1]:j=L[W-1]+1;for(var ee=j-V;j<v&&ee<M&&g.charAt(j)===P.charAt(ee);)j++,ee++;if(L[W]=j,j>v)ue+=2;else if(ee>M)le+=2;else if(z){var te=w+Q-V;if(te>=0&&te<N&&D[te]!==-1){var k=v-D[te];if(j>=k)return o(g,P,j,ee)}}}for(var K=-G+S;K<=G-U;K+=2){var te=w+K,k;K===-G||K!==G&&D[te-1]<D[te+1]?k=D[te+1]:k=D[te-1]+1;for(var q=k-K;k<v&&q<M&&g.charAt(v-k-1)===P.charAt(M-q-1);)k++,q++;if(D[te]=k,k>v)U+=2;else if(q>M)S+=2;else if(!z){var W=w+Q-K;if(W>=0&&W<N&&L[W]!==-1){var j=L[W],ee=w+j-W;if(k=v-k,j>=k)return o(g,P,j,ee)}}}}return[[e,g],[t,P]]}function o(g,P,v,M){var T=g.substring(0,v),w=P.substring(0,M),N=g.substring(v),L=P.substring(M),D=r(T,w),F=r(N,L);return D.concat(F)}function a(g,P){if(!g||!P||g.charAt(0)!==P.charAt(0))return 0;for(var v=0,M=Math.min(g.length,P.length),T=M,w=0;v<T;)g.substring(w,T)==P.substring(w,T)?(v=T,w=v):M=T,T=Math.floor((M-v)/2+v);return x(g.charCodeAt(T-1))&&T--,T}function l(g,P){var v=g.length,M=P.length;if(v==0||M==0)return 0;v>M?g=g.substring(v-M):v<M&&(P=P.substring(0,v));var T=Math.min(v,M);if(g==P)return T;for(var w=0,N=1;;){var L=g.substring(T-N),D=P.indexOf(L);if(D==-1)return w;N+=D,(D==0||g.substring(T-N)==P.substring(0,N))&&(w=N,N++)}}function c(g,P){if(!g||!P||g.slice(-1)!==P.slice(-1))return 0;for(var v=0,M=Math.min(g.length,P.length),T=M,w=0;v<T;)g.substring(g.length-T,g.length-w)==P.substring(P.length-T,P.length-w)?(v=T,w=v):M=T,T=Math.floor((M-v)/2+v);return Y(g.charCodeAt(g.length-T))&&T--,T}function u(g,P){var v=g.length>P.length?g:P,M=g.length>P.length?P:g;if(v.length<4||M.length*2<v.length)return null;function T(ue,S,U){for(var G=ue.substring(U,U+Math.floor(ue.length/4)),V=-1,W="",j,ee,te,k;(V=S.indexOf(G,V+1))!==-1;){var K=a(ue.substring(U),S.substring(V)),q=c(ue.substring(0,U),S.substring(0,V));W.length<q+K&&(W=S.substring(V-q,V)+S.substring(V,V+K),j=ue.substring(0,U-q),ee=ue.substring(U+K),te=S.substring(0,V-q),k=S.substring(V+K))}return W.length*2>=ue.length?[j,ee,te,k,W]:null}var w=T(v,M,Math.ceil(v.length/4)),N=T(v,M,Math.ceil(v.length/2)),L;if(!w&&!N)return null;N?w?L=w[4].length>N[4].length?w:N:L=N:L=w;var D,F,Q,z;g.length>P.length?(D=L[0],F=L[1],Q=L[2],z=L[3]):(Q=L[0],z=L[1],D=L[2],F=L[3]);var le=L[4];return[D,F,Q,z,le]}function h(g){for(var P=!1,v=[],M=0,T=null,w=0,N=0,L=0,D=0,F=0;w<g.length;)g[w][0]==n?(v[M++]=w,N=D,L=F,D=0,F=0,T=g[w][1]):(g[w][0]==t?D+=g[w][1].length:F+=g[w][1].length,T&&T.length<=Math.max(N,L)&&T.length<=Math.max(D,F)&&(g.splice(v[M-1],0,[e,T]),g[v[M-1]+1][0]=t,M--,M--,w=M>0?v[M-1]:-1,N=0,L=0,D=0,F=0,T=null,P=!0)),w++;for(P&&B(g),A(g),w=1;w<g.length;){if(g[w-1][0]==e&&g[w][0]==t){var Q=g[w-1][1],z=g[w][1],le=l(Q,z),ue=l(z,Q);le>=ue?(le>=Q.length/2||le>=z.length/2)&&(g.splice(w,0,[n,z.substring(0,le)]),g[w-1][1]=Q.substring(0,Q.length-le),g[w+1][1]=z.substring(le),w++):(ue>=Q.length/2||ue>=z.length/2)&&(g.splice(w,0,[n,Q.substring(0,ue)]),g[w-1][0]=t,g[w-1][1]=z.substring(0,z.length-ue),g[w+1][0]=e,g[w+1][1]=Q.substring(ue),w++),w++}w++}}var d=/[^a-zA-Z0-9]/,m=/\s/,_=/[\r\n]/,p=/\n\r?\n$/,I=/^\r?\n\r?\n/;function A(g){function P(ue,S){if(!ue||!S)return 6;var U=ue.charAt(ue.length-1),G=S.charAt(0),V=U.match(d),W=G.match(d),j=V&&U.match(m),ee=W&&G.match(m),te=j&&U.match(_),k=ee&&G.match(_),K=te&&ue.match(p),q=k&&S.match(I);return K||q?5:te||k?4:V&&!j&&ee?3:j||ee?2:V||W?1:0}for(var v=1;v<g.length-1;){if(g[v-1][0]==n&&g[v+1][0]==n){var M=g[v-1][1],T=g[v][1],w=g[v+1][1],N=c(M,T);if(N){var L=T.substring(T.length-N);M=M.substring(0,M.length-N),T=L+T.substring(0,T.length-N),w=L+w}for(var D=M,F=T,Q=w,z=P(M,T)+P(T,w);T.charAt(0)===w.charAt(0);){M+=T.charAt(0),T=T.substring(1)+w.charAt(0),w=w.substring(1);var le=P(M,T)+P(T,w);le>=z&&(z=le,D=M,F=T,Q=w)}g[v-1][1]!=D&&(D?g[v-1][1]=D:(g.splice(v-1,1),v--),g[v][1]=F,Q?g[v+1][1]=Q:(g.splice(v+1,1),v--))}v++}}function B(g,P){g.push([n,""]);for(var v=0,M=0,T=0,w="",N="",L;v<g.length;){if(v<g.length-1&&!g[v][1]){g.splice(v,1);continue}switch(g[v][0]){case t:T++,N+=g[v][1],v++;break;case e:M++,w+=g[v][1],v++;break;case n:var D=v-T-M-1;if(P){if(D>=0&&R(g[D][1])){var F=g[D][1].slice(-1);if(g[D][1]=g[D][1].slice(0,-1),w=F+w,N=F+N,!g[D][1]){g.splice(D,1),v--;var Q=D-1;g[Q]&&g[Q][0]===t&&(T++,N=g[Q][1]+N,Q--),g[Q]&&g[Q][0]===e&&(M++,w=g[Q][1]+w,Q--),D=Q}}if(O(g[v][1])){var F=g[v][1].charAt(0);g[v][1]=g[v][1].slice(1),w+=F,N+=F}}if(v<g.length-1&&!g[v][1]){g.splice(v,1);break}if(w.length>0||N.length>0){w.length>0&&N.length>0&&(L=a(N,w),L!==0&&(D>=0?g[D][1]+=N.substring(0,L):(g.splice(0,0,[n,N.substring(0,L)]),v++),N=N.substring(L),w=w.substring(L)),L=c(N,w),L!==0&&(g[v][1]=N.substring(N.length-L)+g[v][1],N=N.substring(0,N.length-L),w=w.substring(0,w.length-L)));var z=T+M;w.length===0&&N.length===0?(g.splice(v-z,z),v=v-z):w.length===0?(g.splice(v-z,z,[t,N]),v=v-z+1):N.length===0?(g.splice(v-z,z,[e,w]),v=v-z+1):(g.splice(v-z,z,[e,w],[t,N]),v=v-z+2)}v!==0&&g[v-1][0]===n?(g[v-1][1]+=g[v][1],g.splice(v,1)):v++,T=0,M=0,w="",N="";break}}g[g.length-1][1]===""&&g.pop();var le=!1;for(v=1;v<g.length-1;)g[v-1][0]===n&&g[v+1][0]===n&&(g[v][1].substring(g[v][1].length-g[v-1][1].length)===g[v-1][1]?(g[v][1]=g[v-1][1]+g[v][1].substring(0,g[v][1].length-g[v-1][1].length),g[v+1][1]=g[v-1][1]+g[v+1][1],g.splice(v-1,1),le=!0):g[v][1].substring(0,g[v+1][1].length)==g[v+1][1]&&(g[v-1][1]+=g[v+1][1],g[v][1]=g[v][1].substring(g[v+1][1].length)+g[v+1][1],g.splice(v+1,1),le=!0)),v++;le&&B(g,P)}function x(g){return g>=55296&&g<=56319}function Y(g){return g>=56320&&g<=57343}function O(g){return Y(g.charCodeAt(0))}function R(g){return x(g.charCodeAt(g.length-1))}function b(g){for(var P=[],v=0;v<g.length;v++)g[v][1].length>0&&P.push(g[v]);return P}function y(g,P,v,M){return R(g)||O(M)?null:b([[n,g],[e,P],[t,v],[n,M]])}function $(g,P,v){var M=typeof v=="number"?{index:v,length:0}:v.oldRange,T=typeof v=="number"?null:v.newRange,w=g.length,N=P.length;if(M.length===0&&(T===null||T.length===0)){var L=M.index,D=g.slice(0,L),F=g.slice(L),Q=T?T.index:null;e:{var z=L+N-w;if(Q!==null&&Q!==z||z<0||z>N)break e;var le=P.slice(0,z),ue=P.slice(z);if(ue!==F)break e;var S=Math.min(L,z),U=D.slice(0,S),G=le.slice(0,S);if(U!==G)break e;var V=D.slice(S),W=le.slice(S);return y(U,V,W,F)}e:{if(Q!==null&&Q!==L)break e;var j=L,le=P.slice(0,j),ue=P.slice(j);if(le!==D)break e;var ee=Math.min(w-j,N-j),te=F.slice(F.length-ee),k=ue.slice(ue.length-ee);if(te!==k)break e;var V=F.slice(0,F.length-ee),W=ue.slice(0,ue.length-ee);return y(D,V,W,te)}}if(M.length>0&&T&&T.length===0)e:{var U=g.slice(0,M.index),te=g.slice(M.index+M.length),S=U.length,ee=te.length;if(N<S+ee)break e;var G=P.slice(0,S),k=P.slice(N-ee);if(U!==G||te!==k)break e;var V=g.slice(S,w-ee),W=P.slice(S,N-ee);return y(U,V,W,te)}return null}function H(g,P,v,M){return r(g,P,v,M,!0)}return H.INSERT=t,H.DELETE=e,H.EQUAL=n,No=H,No}var Mp=Np();const Mo=mt(Mp);function Lp(e){var h,d,m;const{rangeId:t,segmentId:n,documentDataModel:r,insert:s}=e,i=(d=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.customRanges)==null?void 0:d.find(_=>_.rangeId===t);if(!i)return!1;const{startIndex:o,endIndex:a}=i,l=new Me,c=a-o+1;l.push({t:J.RETAIN,len:o}),l.push({t:J.RETAIN,len:c,body:{dataStream:"",customRanges:[]}}),s&&l.push({t:J.INSERT,body:s,len:s.dataStream.length});const u=a+1+((m=s==null?void 0:s.dataStream.length)!=null?m:0);return l.selections=[{startOffset:u,endOffset:u,collapsed:!0}],l}function Dp(e){const{ranges:t,rangeId:n,rangeType:r,wholeEntity:s,properties:i,body:o}=e;let a=0;const l=new Me;let c=!1;return t.forEach(u=>{var x,Y,O;const h=yp(u,o);if(!h||!o)return!1;const{startOffset:d,endOffset:m}=h,_=(x=o.customRanges)!=null?x:[],p=(R,b,y)=>{var v,M,T,w;const $=Uu(R,b,_,r),H=Math.min((M=(v=$[0])==null?void 0:v.startIndex)!=null?M:1/0,R),g=Math.max((w=(T=$[$.length-1])==null?void 0:T.endIndex)!=null?w:-1/0,b),P={rangeId:y?`${n}$${y}`:n,rangeType:r,startIndex:0,endIndex:g-H,wholeEntity:s,properties:{...i}};l.push({t:J.RETAIN,len:H-a}),l.push({t:J.RETAIN,len:g-H+1,body:{dataStream:"",customRanges:[P]},coverType:Ce.COVER}),a=g+1},I=((Y=o.paragraphs)!=null?Y:[]).filter(R=>R.startIndex<m&&R.startIndex>d),A=((O=o.customBlocks)!=null?O:[]).filter(R=>R.startIndex<m&&R.startIndex>d);Tp([d,m-1],[...I.map(R=>R.startIndex),...A.map(R=>R.startIndex)]).forEach(([R,b],y)=>p(R,b,y)),c=!0,l.selections=[{startOffset:h.endOffset,endOffset:h.endOffset,collapsed:!0}]}),c?l:!1}function ku(e,t,n=0,r=null,s=!0){e.sort((c,u)=>c.startOffset-u.startOffset);const i=[],{paragraphs:o=[]}=t,a=o==null?void 0:o.find(c=>c.startIndex>=e[0].startOffset&&c.startIndex<e[0].endOffset);let l=n;if(e.forEach(c=>{const{startOffset:u,endOffset:h}=c;u>l&&(i.push({t:J.RETAIN,len:u-l}),l=u),l<h&&(i.push({t:J.DELETE,len:h-l}),l=h)}),r&&i.push({t:J.INSERT,body:r,len:r.dataStream.length}),a&&s){const c=o.find(u=>u.startIndex-n>=e[e.length-1].endOffset-1);c&&(c.startIndex>l&&(i.push({t:J.RETAIN,len:c.startIndex-l}),l=c.startIndex),i.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...c,startIndex:0,bullet:a==null?void 0:a.bullet}]},coverType:Ce.REPLACE}))}return i}function Up(e,t,n=0){const r=[];let s=n;return e.forEach(i=>{const{startOffset:o,endOffset:a}=i;o>s&&(r.push({t:J.RETAIN,len:o-s}),s=o),a>s&&(r.push({t:J.RETAIN,len:a-s,body:{...Z.deepClone(t),dataStream:""}}),s=a)}),r}const Pp=e=>{var h;const{selection:t,body:n,doc:r}=e,s=t.segmentId,i=(h=r.getSelfOrHeaderFooterModel(s))==null?void 0:h.getBody();if(!i)return!1;const o=t.collapsed?null:bt(i,t.startOffset,t.endOffset),a=Mo(o?o.dataStream:"",n.dataStream);let l=0;const c=a.map(([d,m])=>{switch(d){case 0:{const _={t:J.RETAIN,body:{...bt(n,l,l+m.length,!1),dataStream:""},len:m.length};return l+=m.length,_}case 1:{const _={t:J.INSERT,body:bt(n,l,l+m.length),len:m.length};return l+=m.length,_}default:return{t:J.DELETE,len:m.length}}}),u=new Me;return u.push({t:J.RETAIN,len:t.startOffset}),u.push(...c),u};function kp(e,t){return!!((e==null?void 0:e.length)===(t==null?void 0:t.length)&&(e!=null&&e.every((n,r)=>JSON.stringify(n)===JSON.stringify(t==null?void 0:t[r]))))}const Fp=e=>{var d;const{selection:t,body:n,doc:r,themeService:s}=e,i=t.segmentId,o=(d=r.getSelfOrHeaderFooterModel(i))==null?void 0:d.getBody();if(!o)return!1;const a=t.collapsed?null:bt(o,t.startOffset,t.endOffset),l=Mo(a?a.dataStream:"",n.dataStream);let c=0;const u=l.map(([m,_])=>{switch(m){case 0:{const p=Hs(n,c,c+_.length,!1),I=Hs(a,c,c+_.length,!1),A={t:J.RETAIN,body:kp(p,I)?void 0:{textRuns:p==null?void 0:p.map(B=>{var x,Y,O,R,b,y,$;return{...B,ts:{...B.ts,cl:(O=(Y=(x=B.ts)==null?void 0:x.cl)==null?void 0:Y.rgb)!=null&&O.includes(".")?{rgb:s.getColorFromTheme((y=(b=(R=B.ts)==null?void 0:R.cl)==null?void 0:b.rgb)!=null?y:"")}:($=B.ts)==null?void 0:$.cl}}}),dataStream:""},len:_.length};return c+=_.length,A}case 1:{const p={t:J.INSERT,body:bt(n,c,c+_.length),len:_.length};return c+=_.length,p}default:return{t:J.DELETE,len:_.length}}});if(u.every(m=>m.t===J.RETAIN&&!m.body))return!1;const h=new Me;return h.push({t:J.RETAIN,len:t.startOffset}),h.push(...u),h};function xp(e,t){const n=[],{customBlocks:r=[]}=e;for(const s of t){const{startOffset:i,endOffset:o}=s;if(!(i==null||o==null))for(const a of r){const{startIndex:l}=a;l>=i&&l<o&&n.push(a.blockId)}}return n}function Bp(e,t=""){if(!t)return["body"];const{headers:n,footers:r}=e.getSnapshot();if(n==null&&r==null)throw new Error("Document data model must have headers or footers when update by segment id");if((n==null?void 0:n[t])!=null)return["headers",t,"body"];if((r==null?void 0:r[t])!=null)return["footers",t,"body"];throw new Error("Segment id not found in headers or footers")}const $p=e=>{var p,I,A,B;const{selection:t,documentDataModel:n,drawings:r}=e,{collapsed:s,startOffset:i,segmentId:o}=t,a=new Me,l=Wt.getInstance(),c=[],u=n.getSelfOrHeaderFooterModel(o).getBody();if(!u)return!1;const h=(I=(p=n.getSnapshot().drawingsOrder)==null?void 0:p.length)!=null?I:0;let d=0;if(s)i>0&&a.push({t:J.RETAIN,len:i});else{const x=ku([t],u,0,null,!1);a.push(...x);const Y=xp(u,[t]),O=(A=n.getDrawings())!=null?A:{},R=(B=n.getDrawingsOrder())!=null?B:[],b=Y.sort((y,$)=>R.indexOf(y)>R.indexOf($)?-1:R.indexOf(y)<R.indexOf($)?1:0);if(b.length>0)for(const y of b){const $=O[y],H=R.indexOf(y);if($==null||H<0)continue;const g=l.removeOp(["drawings",y],$),P=l.removeOp(["drawingsOrder",H],y);c.push(g),c.push(P),d++}}a.push({t:J.INSERT,body:{dataStream:"\b".repeat(r.length),customBlocks:r.map((x,Y)=>({startIndex:Y,blockId:x.drawingId}))},len:r.length});const m=Bp(n,o),_=l.editOp(a.serialize(),m);c.push(_);for(const x of r){const{drawingId:Y}=x,O=l.insertOp(["drawings",Y],x),R=l.insertOp(["drawingsOrder",h-d],Y);c.push(O),c.push(R)}return c.reduce((x,Y)=>Wt.compose(x,Y),null)};function Hp(e,t){if(typeof t>"u")return{startOffset:e,endOffset:e,collapsed:!0};if(t<e)throw new Error(`Cannot make a doc selection when endOffset ${t} is less than startOffset ${e}.`);return{startOffset:e,endOffset:t,collapsed:e===t}}function Wp(e){const{startOffset:t,endOffset:n,collapsed:r}=e,s=Math.min(t,n),i=Math.max(t,n);return{startOffset:s,endOffset:i,collapsed:r}}function jp(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function Lo(e,t,n,r){const{startOffset:s,endOffset:i}=e,o=r!=null?r:Uo(t,n),a=[];let l=-1;for(let c=0;c<o.length;c++){const u=o[c],{startIndex:h}=u;(s>l&&s<=h||i>l&&i<=h||h>=s&&h<=i)&&a.push(u),l=h}return a}function Do(e,t,n){const r=[],s=Uo(t,n);for(const i of e){const o=Lo(i,t,n,s);r.push(...o)}return r}const Yp=[lt.PARAGRAPH,lt.TABLE_START,lt.TABLE_END,lt.TABLE_ROW_START,lt.TABLE_CELL_START,lt.TABLE_CELL_END];function Uo(e,t){const n=[];for(let r=0;r<e.length;r++){const s=e[r],{startIndex:i}=s;let o=i-1;for(;!Yp.includes(t[o])&&o>=0;)o--;n.push({...s,paragraphStart:o+1,paragraphEnd:s.startIndex})}return n}const Gp=e=>{var h,d,m;const{paragraphs:t,segmentId:n,document:r}=e;let s=e.listType;const i=(d=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.paragraphs)!=null?d:[],o=t.every(_=>{var p;return((p=_.bullet)==null?void 0:p.listType.indexOf(s))===0});let l=tt(6);if(t.length===1){const _=i.indexOf(t[0]),p=i[_-1],I=i[_+1];p&&p.bullet&&p.bullet.listType.indexOf(s)===0?(l=p.bullet.listId,s!==Ft.CHECK_LIST&&(s=p.bullet.listType)):I&&I.bullet&&I.bullet.listType.indexOf(s)===0&&(l=I.bullet.listId,s!==Ft.CHECK_LIST&&(s=I.bullet.listType))}const c=new un;c.reset();const u=new Me;for(const _ of t){const{startIndex:p,paragraphStyle:I={},bullet:A}=_;u.push({t:J.RETAIN,len:p-c.cursor}),u.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[o?{paragraphStyle:I,startIndex:0}:{startIndex:0,paragraphStyle:{...I},bullet:{nestingLevel:(m=A==null?void 0:A.nestingLevel)!=null?m:0,textStyle:{fs:20},listType:s,listId:l}}]},coverType:Ce.REPLACE}),c.moveCursorTo(p+1)}return u},Vp=e=>{var h;const{paragraphIndex:t,segmentId:n,document:r}=e,s=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.paragraphs;if(s==null)return!1;const i=s.find(d=>d.startIndex===t);if(!(i!=null&&i.bullet)||i.bullet.listType.indexOf(Ft.CHECK_LIST)===-1)return!1;const o=new un;o.reset();const a=new Me,{startIndex:l,paragraphStyle:c={}}=i,u=i.bullet.listType===Ft.CHECK_LIST?Ft.CHECK_LIST_CHECKED:Ft.CHECK_LIST;return a.push({t:J.RETAIN,len:l-o.cursor}),a.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...i,paragraphStyle:c,startIndex:0,bullet:{...i.bullet,listType:u}}]},coverType:Ce.REPLACE}),o.moveCursorTo(l+1),a},zp=e=>{var u,h;const{paragraphs:t,listType:n,segmentId:r,document:s}=e;if(((u=s.getSelfOrHeaderFooterModel(r).getBody())==null?void 0:u.paragraphs)==null)return!1;const a=tt(6),l=new un;l.reset();const c=new Me;for(const d of t){const{startIndex:m,paragraphStyle:_={},bullet:p}=d;c.push({t:J.RETAIN,len:m-l.cursor}),c.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:_,bullet:{nestingLevel:(h=p==null?void 0:p.nestingLevel)!=null?h:0,textStyle:(p==null?void 0:p.listType)===n?p.textStyle:{fs:20},listType:n,listId:a}}]},coverType:Ce.REPLACE}),l.moveCursorTo(m+1)}return c};function Kp(e,t){return t.some(n=>e.startIndex>n.startIndex&&e.startIndex<n.endIndex)}const Xp=e=>{var c,u,h;const{paragraphs:t,document:n,type:r}=e,s=new un;s.reset();const i=new Me,o=(c=n.getSnapshot().lists)!=null?c:{},a=(h=(u=n.getBody())==null?void 0:u.tables)!=null?h:[],l={...Nr,...o};for(const d of t){const{startIndex:m,paragraphStyle:_={},bullet:p}=d,I=Kp(d,a);if(i.push({t:J.RETAIN,len:m-s.cursor}),p){const A=p.listType;let B=l[A].nestingLevel.length-1;I&&(B=Math.min(B,2)),i.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:{..._},bullet:{...p,nestingLevel:Math.max(Math.min(p.nestingLevel+r,B),0)}}]},coverType:Ce.REPLACE})}else i.push({t:J.RETAIN,len:1});s.moveCursorTo(m+1)}return i},qp=e=>{var I,A,B,x;const{textRanges:t,segmentId:n,document:r,style:s,paragraphTextRun:i,cursor:o,deleteLen:a,textX:l}=e,c=r.getSelfOrHeaderFooterModel(n),u=(A=(I=c.getBody())==null?void 0:I.paragraphs)!=null?A:[],h=(x=(B=c.getBody())==null?void 0:B.dataStream)!=null?x:"",d=Do(t,u,h),m=new un;o&&m.moveCursorTo(o);const _=l!=null?l:new Me;d.sort((Y,O)=>Y.startIndex-O.startIndex);const p=Math.max(0,d[0].paragraphStart-1);p>m.cursor&&(_.push({t:J.RETAIN,len:p-m.cursor}),m.moveCursorTo(p)),a&&_.push({t:J.DELETE,len:a});for(const Y of d){const{startIndex:O,paragraphStyle:R={}}=Y,b=O-m.cursor;_.push({t:J.RETAIN,len:b,...i?{body:{dataStream:"",textRuns:[{ts:i,st:0,ed:b}]},coverType:Ce.REPLACE}:null}),_.push({t:J.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:{...R,...s}}]},coverType:Ce.REPLACE}),m.moveCursorTo(O+1)}return _};class Je{}C(Je,"customRange",{add:Dp,delete:Lp,copyCustomRange:Ap,getCustomRangesInterestsWithSelection:bp,isIntersecting:Du}),C(Je,"customDecoration",{add:vp,delete:wp}),C(Je,"selection",{replace:Pp,makeSelection:Hp,normalizeSelection:Wp,delete:ku,replaceTextRuns:Fp,retain:Up}),C(Je,"range",{isIntersects:jp,getParagraphsInRange:Lo,getParagraphsInRanges:Do}),C(Je,"transform",{getPlainText:Ws,fromPlainText:Sp,isEmptyDocument:Ip}),C(Je,"paragraph",{bullet:{set:zp,switch:Gp,toggleChecklist:Vp,changeNestLevel:Xp},style:{set:qp},util:{transform:Uo,getParagraphsInRange:Lo,getParagraphsInRanges:Do}}),C(Je,"drawing",{add:$p});function Zp(e,t,n,r){var c;if(t==="")return e;const s={id:"mock-id",body:e,documentStyle:{}},i=new At(s),o=t.length;let a;for(;(a=(r?i.getBody().dataStream:i.getBody().dataStream.toLowerCase()).indexOf(t))>=0;){const u=new Me,h=Wt.getInstance();if(a>0&&u.retain(a),n.length>0){const d=i.sliceBody(a,a+o),m={dataStream:n};if(Array.isArray(d==null?void 0:d.textRuns)&&d.textRuns.length&&(m.textRuns=[{...d.textRuns[0],st:0,ed:n.length}]),(c=d==null?void 0:d.customRanges)!=null&&c.length){const _=d.customRanges[0];m.customRanges=[{..._,startIndex:0,endIndex:n.length-1}]}u.insert(n.length,m)}u.delete(o),i.apply(h.editOp(u.serialize()))}const l=i.getBody();return i.dispose(),l}function Jp(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 Fu(e){var t;return e.body=Jp((t=e.body)!=null?t:{dataStream:""}),e.drawingsOrder||(e.drawingsOrder=[]),e.drawings||(e.drawings={}),e.documentStyle||(e.documentStyle={}),e}class Mr{constructor(t={}){C(this,"_style");this._style=t}static create(t={}){return new Mr(t)}get fontFamily(){return this._style.ff}get fontSize(){return this._style.fs}get italic(){return this._style.it===ae.TRUE}get bold(){return this._style.bl===ae.TRUE}get underline(){return this._style.ul&&rn.create(this._style.ul)}get bottomBorderLine(){return this._style.bbl&&rn.create(this._style.bbl)}get strikethrough(){return this._style.st&&rn.create(this._style.st)}get overline(){return this._style.ol&&rn.create(this._style.ol)}get background(){return this._style.bg}get border(){return this._style.bd}get color(){return this._style.cl}get verticalAlign(){return this._style.va}get numberFormat(){return this._style.n}copy(){return nn.create(Z.deepClone(this._style))}getValue(){return{...this._style}}}class nn extends Mr{static create(t={}){return new nn(t)}constructor(t={}){super(t)}setFontFamily(t){return this._style.ff=t,this}setFontSize(t){return this._style.fs=t,this}setItalic(t){return this._style.it=t?1:0,this}setBold(t){return this._style.bl=t?1:0,this}setUnderline(t){return this._style.ul=t.build(),this}setBottomBorderLine(t){return this._style.bbl=t.build(),this}setStrikethrough(t){return this._style.st=t.build(),this}setOverline(t){return this._style.ol=t.build(),this}setBackground(t){return this._style.bg=t,this}setBorder(t){return this._style.bd=t,this}setColor(t){return this._style.cl=t,this}setVerticalAlign(t){return this._style.va=t,this}copy(){return nn.create(Z.deepClone(this._style))}build(){return this.getValue()}}class rn{constructor(t={s:1}){C(this,"_decoration");this._decoration=t}static create(t={s:1}){return new rn(t)}get show(){return this._decoration.s===ae.TRUE}get followFontColor(){return this._decoration.c===ae.TRUE}get color(){return this._decoration.cl}get type(){return this._decoration.t}setShow(t){return this._decoration.s=t?1:0,this}setFollowFontColor(t){return this._decoration.c=t?1:0,this}setColor(t){return this._decoration.cl=t,this}setLineType(t){return this._decoration.t=t,this}copy(){return rn.create(Z.deepClone(this._decoration))}build(){return{...this._decoration}}}class Lr{constructor(t={}){C(this,"_style");this._style=t}static create(t={}){return new Lr(t)}get indentFirstLine(){return this._style.indentFirstLine}get hanging(){return this._style.hanging}get indentStart(){return this._style.indentStart}get tabStops(){return this._style.tabStops}get indentEnd(){return this._style.indentEnd}get textStyle(){return this._style.textStyle}get headingId(){return this._style.headingId}get namedStyleType(){return this._style.namedStyleType}get horizontalAlign(){return this._style.horizontalAlign}get lineSpacing(){return this._style.lineSpacing}get direction(){return this._style.direction}get spacingRule(){return this._style.spacingRule}get snapToGrid(){return this._style.snapToGrid}get spaceAbove(){return this._style.spaceAbove}get spaceBelow(){return this._style.spaceBelow}get borderBetween(){return this._style.borderBetween}get borderTop(){return this._style.borderTop}get borderBottom(){return this._style.borderBottom}get borderLeft(){return this._style.borderLeft}get borderRight(){return this._style.borderRight}get keepLines(){return this._style.keepLines===ae.TRUE}get keepNext(){return this._style.keepNext===ae.TRUE}get wordWrap(){return this._style.wordWrap===ae.TRUE}get widowControl(){return this._style.widowControl===ae.TRUE}get shading(){return this._style.shading}get suppressHyphenation(){return this._style.suppressHyphenation===ae.TRUE}copy(){return Dr.create(Z.deepClone(this._style))}getValue(){return this._style}}class Dr extends Lr{static create(t={}){return new Dr(t)}constructor(t={}){super(t)}setIndentFirstLine(t){return this._style.indentFirstLine=t,this}setHanging(t){return this._style.hanging=t,this}setIndentStart(t){return this._style.indentStart=t,this}setTabStops(t){return this._style.tabStops=t,this}setIndentEnd(t){return this._style.indentEnd=t,this}setTextStyle(t){return this._style.textStyle=t,this}setHeadingId(t){return this._style.headingId=t,this}setNamedStyleType(t){return this._style.namedStyleType=t,this}setHorizontalAlign(t){return this._style.horizontalAlign=t,this}setLineSpacing(t){return this._style.lineSpacing=t,this}setDirection(t){return this._style.direction=t,this}setSpacingRule(t){return this._style.spacingRule=t,this}setSnapToGrid(t){return this._style.snapToGrid=t?1:0,this}setSpaceAbove(t){return this._style.spaceAbove=t,this}setSpaceBelow(t){return this._style.spaceBelow=t,this}setBorderBetween(t){return this._style.borderBetween=t,this}setBorderTop(t){return this._style.borderTop=t,this}setBorderBottom(t){return this._style.borderBottom=t,this}setBorderLeft(t){return this._style.borderLeft=t,this}setBorderRight(t){return this._style.borderRight=t,this}setKeepLines(t){return this._style.keepLines=t?1:0,this}setKeepNext(t){return this._style.keepNext=t?1:0,this}setWordWrap(t){return this._style.wordWrap=t?1:0,this}setWidowControl(t){return this._style.widowControl=t?1:0,this}setShading(t){return this._style.shading=t,this}setSuppressHyphenation(t){return this._style.suppressHyphenation=t?1:0,this}copy(){return Dr.create(Z.deepClone(this._style))}build(){return this.getValue()}}class sn{constructor(t){C(this,"_data");if(!t.body)throw new Error("Invalid document data, body is required");this._data=Fu(t)}static create(t){return new sn(t)}static createByBody(t){return new sn({body:t,id:"d",documentStyle:{}})}copy(){return Cn.create(Z.deepClone(this._data))}slice(t,n){const{body:r,...s}=this._data;return Cn.create({...Z.deepClone(s),body:bt(r,t,n)})}toPlainText(){var t,n;return Je.transform.getPlainText((n=(t=this._data.body)==null?void 0:t.dataStream)!=null?n:"").replaceAll("\r",`
7
7
  `)}getParagraphStyle(){var t,n;return Lr.create((n=(t=this._data.body)==null?void 0:t.paragraphs)==null?void 0:n[0].paragraphStyle)}getParagraphBullet(){var t,n;return(n=(t=this._data.body)==null?void 0:t.paragraphs)==null?void 0:n[0].bullet}getParagraphs(){var r,s;const t=(s=(r=this._data.body)==null?void 0:r.paragraphs)!=null?s:[];let n=0;return t.map(i=>{const o=this.slice(n,i.startIndex);return n=i.startIndex,o})}getTextRuns(){var t,n;return((n=(t=this._data.body)==null?void 0:t.textRuns)!=null?n:[]).map(r=>({...r,ts:r.ts?Mr.create(r.ts):null}))}getLinks(){var t,n,r;return(r=(n=(t=this._data.body)==null?void 0:t.customRanges)==null?void 0:n.filter(s=>s.rangeType===en.HYPERLINK))!=null?r:[]}getData(){return this._data}}class Cn extends sn{constructor(n){super(n);C(this,"_doc");this._doc=new At(n)}static newEmptyData(){return Fu({id:"d",documentStyle:{},drawings:{},drawingsOrder:[],body:{dataStream:`\r
8
- `,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(n){return new Cn(n!=null?n:Cn.newEmptyData())}insertText(n,r,s){var u,h;let i=((h=(u=this._data.body)==null?void 0:u.dataStream.length)!=null?h:2)-2,o,a;if(typeof n=="string"?o=n:(i=Math.min(n,i),o=r),typeof r=="object"?a=r instanceof nn?r.build():r:a=s instanceof nn?s.build():s,!o)return this;const l={dataStream:o,textRuns:a?[{ts:a,st:i,ed:i+o.length}]:[]},c=Je.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:l});if(!c)throw new Error("Insert text failed, please check.");return Me.apply(this._doc.getBody(),c.serialize()),this}insertRichText(n,r){var a,l;let s=((l=(a=this._data.body)==null?void 0:a.dataStream.length)!=null?l:2)-2,i;typeof n=="object"?i=n instanceof sn?n.getData():n:(s=Math.min(n,s),i=r instanceof sn?r.getData():r);const o=Je.selection.replace({doc:this._doc,selection:{startOffset:s,endOffset:s,collapsed:!0},body:i.body});if(!o)throw new Error("Insert text failed, please check.");return Me.apply(this._doc.getBody(),o.serialize()),this}delete(n,r){if(r!==void 0){if(!r)return this;const s=Je.selection.delete([{startOffset:n,endOffset:n+r,collapsed:!0}],this._data.body);Me.apply(this._doc.getBody(),s)}return this}setStyle(n,r,s){const i={dataStream:"",textRuns:[{ts:s instanceof nn?s.build():s,st:0,ed:r-n}]},o=Je.selection.retain([{startOffset:n,endOffset:r,collapsed:!0}],i);return Me.apply(this._doc.getBody(),o),this}setLink(n,r,s){const i=Je.customRange.add({rangeType:en.HYPERLINK,rangeId:tt(),properties:{url:s},ranges:[{startOffset:n,endOffset:r,collapsed:!1}],body:this._data.body});if(!i)throw new Error("Insert text failed, please check.");return Me.apply(this._doc.getBody(),i.serialize()),this}cancelLink(n,r){if(typeof n=="string"){const s=Je.customRange.delete({rangeId:n,documentDataModel:this._doc});if(!s)throw new Error("Insert text failed, please check.");Me.apply(this._doc.getBody(),s.serialize())}else this.slice(n,r).getLinks().forEach(i=>{const o=Je.customRange.delete({rangeId:i.rangeId,documentDataModel:this._doc});if(!o)throw new Error("Insert text failed, please check.");Me.apply(this._doc.getBody(),o.serialize())});return this}updateLink(n,r){var i,o;const s=(o=(i=this._data.body)==null?void 0:i.customRanges)==null?void 0:o.find(a=>a.rangeId===n);if(!s)throw new Error("Link not found");return s.properties.url=r,this}insertParagraph(n,r){var o,a;let s,i;return typeof n=="object"?(s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:n.build()}]},i=((a=(o=this._data.body)==null?void 0:o.dataStream.length)!=null?a:2)-2):(i=n,s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:r==null?void 0:r.build()}]}),this.insertRichText(i,sn.create({body:s,id:"d",documentStyle:{}})),this}insertLink(n,r,s){let i="",o="";typeof n=="string"?(i=n,o=r):(i=r,o=s);const a=Cn.createByBody({dataStream:i,customRanges:[{rangeType:en.HYPERLINK,rangeId:tt(),properties:{url:o},startIndex:0,endIndex:i.length-1}]});return typeof n=="number"?this.insertRichText(n,a):this.insertRichText(a)}}const Qp="__default_document_sub_component_id20231101__";class xu{constructor(){C(this,"skipNextObservers",!1);C(this,"lastReturnValue");C(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class eE extends oe.Subject{constructor(){super(...arguments);C(this,"_sortedObservers",[])}subscribe(){throw new Error("[EventSubject]: please use `subscribeEvent` instead of `subscribe` method for `EventSubject`.")}next(){throw new Error("[EventSubject]: please use `emitEvent` instead of `next` method for `EventSubject`.")}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(n){let r;typeof n=="function"?r={next:([i,o])=>n(i,o)}:r=n;const s=super.subscribe(r);return this._sortedObservers.push(r),this._sortedObservers.sort((i,o)=>{var a,l;return((a=i.priority)!=null?a:0)-((l=o.priority)!=null?l:0)}),s.add(()=>this._sortedObservers=this._sortedObservers.filter(i=>i!==r)),s}clearObservers(){this._sortedObservers.forEach(n=>{var r;return(r=n.complete)==null?void 0:r.call(n)}),this._sortedObservers.length=0}emitEvent(n){var r;if(!this.closed){const s=new xu;s.lastReturnValue=n;for(const i of this._sortedObservers){const o=(r=i.next)==null?void 0:r.call(i,[n,s]);if(s.lastReturnValue=o,s.skipNextObservers)return{handled:!0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}throw new Error("[EventSubject]: cannot emit event on a closed subject.")}}function tE(e){return new oe.Observable(t=>{const n=e.subscribeEvent(r=>{t.next(r)});return()=>n.unsubscribe()})}const js=Re.createIdentifier("core.resource-manager.service"),Po={[kt.Editor]:"Editor",[kt.Owner]:"Owner",[kt.Reader]:"Reader",[kt.UNRECOGNIZED]:"UNRECOGNIZED"},Ys=e=>e?{userID:`${Po[e]}_${tt(8)}`,name:Po[e],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},nE=(e,t)=>e.startsWith(Po[t]);class Ur extends ze{constructor(){super(...arguments);C(this,"_model",new Map);C(this,"_userChange$",new oe.Subject);C(this,"userChange$",this._userChange$.asObservable());C(this,"_currentUser$",new oe.BehaviorSubject(Ys()));C(this,"currentUser$",this._currentUser$.asObservable())}dispose(){super.dispose(),this._model.clear(),this._userChange$.complete(),this._currentUser$.complete()}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(n){this.addUser(n),this._currentUser$.next(n)}addUser(n){this._model.set(n.userID,n),this._userChange$.next({type:"add",user:n})}getUser(n,r){const s=this._model.get(n);if(s)return s;r&&r()}delete(n){const r=this.getUser(n);this._model.delete(n),r&&this._userChange$.next({type:"delete",user:r})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}list(){return Array.from(this._model.values())}}var rE=Object.getOwnPropertyDescriptor,sE=(e,t,n,r)=>{for(var s=r>1?void 0:r?rE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Bu=(e,t)=>(n,r)=>t(n,r,e);f.AuthzIoLocalService=class{constructor(t,n){C(this,"_permissionMap",new Map([]));this._resourceManagerService=t,this._userManagerService=n,this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){const t=this._userManagerService.getCurrentUser();t&&t.userID||this._userManagerService.setCurrentUser(Ys(kt.Owner))}_getRole(t){const n=this._userManagerService.getCurrentUser();return n?nE(n.userID,t):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:t=>{const n=[...this._permissionMap.keys()].reduce((r,s)=>{const i=this._permissionMap.get(s);return r[s]=i,r},{});return JSON.stringify(n)},parseJson:t=>JSON.parse(t),pluginName:"SHEET_AuthzIoMockService_PLUGIN",businesses:[we.UNIVER_SHEET,we.UNIVER_DOC,we.UNIVER_SLIDE],onLoad:(t,n)=>{for(const r in n)this._permissionMap.set(r,n[r])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(t){return tt(8)}async allowed(t){return Promise.resolve([])}async batchAllowed(t){return Promise.resolve([])}async list(t){const n=[];return t.objectIDs.forEach(r=>{const s=this._permissionMap.get(r);if(s){const i={objectID:r,unitID:t.unitID,objectType:s.objectType,name:s.name,shareOn:!1,shareRole:kt.Owner,shareScope:-1,scope:{read:Eo.AllCollaborator,edit:Eo.AllCollaborator},creator:Ys(kt.Owner),strategies:[{action:6,role:1},{action:16,role:1},{action:17,role:1},{action:18,role:1},{action:19,role:1},{action:33,role:1},{action:34,role:1},{action:35,role:1},{action:36,role:1},{action:37,role:1},{action:38,role:1},{action:39,role:1},{action:40,role:1}],actions:t.actions.map(o=>({action:o,allowed:this._getRole(kt.Owner)||this._getRole(kt.Editor)}))};n.push(i)}}),n}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(t){}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(t){}},f.AuthzIoLocalService=sE([Bu(0,js),Bu(1,Re.Inject(Ur))],f.AuthzIoLocalService);const $u=Re.createIdentifier("IAuthzIoIoService");var Hu=typeof global=="object"&&global&&global.Object===Object&&global,iE=typeof self=="object"&&self&&self.Object===Object&&self,Rn=Hu||iE||Function("return this")(),Yn=Rn.Symbol,Wu=Object.prototype,oE=Wu.hasOwnProperty,aE=Wu.toString,Pr=Yn?Yn.toStringTag:void 0;function lE(e){var t=oE.call(e,Pr),n=e[Pr];try{e[Pr]=void 0;var r=!0}catch{}var s=aE.call(e);return r&&(t?e[Pr]=n:delete e[Pr]),s}var cE=Object.prototype,uE=cE.toString;function hE(e){return uE.call(e)}var dE="[object Null]",fE="[object Undefined]",ju=Yn?Yn.toStringTag:void 0;function kr(e){return e==null?e===void 0?fE:dE:ju&&ju in Object(e)?lE(e):hE(e)}function Gn(e){return e!=null&&typeof e=="object"}var mE="[object Symbol]";function Gs(e){return typeof e=="symbol"||Gn(e)&&kr(e)==mE}function gE(e,t){for(var n=-1,r=e==null?0:e.length,s=Array(r);++n<r;)s[n]=t(e[n],n,e);return s}var Vn=Array.isArray,Yu=Yn?Yn.prototype:void 0,Gu=Yu?Yu.toString:void 0;function Vu(e){if(typeof e=="string")return e;if(Vn(e))return gE(e,Vu)+"";if(Gs(e))return Gu?Gu.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}var _E=/\s/;function pE(e){for(var t=e.length;t--&&_E.test(e.charAt(t)););return t}var EE=/^\s+/;function CE(e){return e&&e.slice(0,pE(e)+1).replace(EE,"")}function Ct(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var zu=NaN,RE=/^[-+]0x[0-9a-f]+$/i,IE=/^0b[01]+$/i,SE=/^0o[0-7]+$/i,OE=parseInt;function Ku(e){if(typeof e=="number")return e;if(Gs(e))return zu;if(Ct(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Ct(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=CE(e);var n=IE.test(e);return n||SE.test(e)?OE(e.slice(2),n?2:8):RE.test(e)?zu:+e}function Xu(e){return e}var vE="[object AsyncFunction]",wE="[object Function]",bE="[object GeneratorFunction]",AE="[object Proxy]";function ko(e){if(!Ct(e))return!1;var t=kr(e);return t==wE||t==bE||t==vE||t==AE}var Fo=Rn["__core-js_shared__"],qu=function(){var e=/[^.]+$/.exec(Fo&&Fo.keys&&Fo.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function TE(e){return!!qu&&qu in e}var yE=Function.prototype,NE=yE.toString;function ME(e){if(e!=null){try{return NE.call(e)}catch{}try{return e+""}catch{}}return""}var LE=/[\\^$.*+?()[\]{}|]/g,DE=/^\[object .+?Constructor\]$/,UE=Function.prototype,PE=Object.prototype,kE=UE.toString,FE=PE.hasOwnProperty,xE=RegExp("^"+kE.call(FE).replace(LE,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function BE(e){if(!Ct(e)||TE(e))return!1;var t=ko(e)?xE:DE;return t.test(ME(e))}function $E(e,t){return e==null?void 0:e[t]}function xo(e,t){var n=$E(e,t);return BE(n)?n:void 0}var Zu=Object.create,HE=function(){function e(){}return function(t){if(!Ct(t))return{};if(Zu)return Zu(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function WE(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function jE(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}var YE=800,GE=16,VE=Date.now;function zE(e){var t=0,n=0;return function(){var r=VE(),s=GE-(r-n);if(n=r,s>0){if(++t>=YE)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function KE(e){return function(){return e}}var Vs=function(){try{var e=xo(Object,"defineProperty");return e({},"",{}),e}catch{}}(),XE=Vs?function(e,t){return Vs(e,"toString",{configurable:!0,enumerable:!1,value:KE(t),writable:!0})}:Xu,qE=zE(XE),ZE=9007199254740991,JE=/^(?:0|[1-9]\d*)$/;function Bo(e,t){var n=typeof e;return t=t==null?ZE:t,!!t&&(n=="number"||n!="symbol"&&JE.test(e))&&e>-1&&e%1==0&&e<t}function $o(e,t,n){t=="__proto__"&&Vs?Vs(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function zs(e,t){return e===t||e!==e&&t!==t}var QE=Object.prototype,e0=QE.hasOwnProperty;function Ju(e,t,n){var r=e[t];(!(e0.call(e,t)&&zs(r,n))||n===void 0&&!(t in e))&&$o(e,t,n)}function t0(e,t,n,r){var s=!n;n||(n={});for(var i=-1,o=t.length;++i<o;){var a=t[i],l=void 0;l===void 0&&(l=e[a]),s?$o(n,a,l):Ju(n,a,l)}return n}var Qu=Math.max;function n0(e,t,n){return t=Qu(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,i=Qu(r.length-t,0),o=Array(i);++s<i;)o[s]=r[t+s];s=-1;for(var a=Array(t+1);++s<t;)a[s]=r[s];return a[t]=n(o),WE(e,this,a)}}function r0(e,t){return qE(n0(e,t,Xu),e+"")}var s0=9007199254740991;function eh(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=s0}function Ho(e){return e!=null&&eh(e.length)&&!ko(e)}function i0(e,t,n){if(!Ct(n))return!1;var r=typeof t;return(r=="number"?Ho(n)&&Bo(t,n.length):r=="string"&&t in n)?zs(n[t],e):!1}function th(e){return r0(function(t,n){var r=-1,s=n.length,i=s>1?n[s-1]:void 0,o=s>2?n[2]:void 0;for(i=e.length>3&&typeof i=="function"?(s--,i):void 0,o&&i0(n[0],n[1],o)&&(i=s<3?void 0:i,s=1),t=Object(t);++r<s;){var a=n[r];a&&e(t,a,r,i)}return t})}var o0=Object.prototype;function nh(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||o0;return e===n}function a0(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var l0="[object Arguments]";function rh(e){return Gn(e)&&kr(e)==l0}var sh=Object.prototype,c0=sh.hasOwnProperty,u0=sh.propertyIsEnumerable,Wo=rh(function(){return arguments}())?rh:function(e){return Gn(e)&&c0.call(e,"callee")&&!u0.call(e,"callee")};function h0(){return!1}var ih=typeof f=="object"&&f&&!f.nodeType&&f,oh=ih&&typeof module=="object"&&module&&!module.nodeType&&module,d0=oh&&oh.exports===ih,ah=d0?Rn.Buffer:void 0,f0=ah?ah.isBuffer:void 0,lh=f0||h0,m0="[object Arguments]",g0="[object Array]",_0="[object Boolean]",p0="[object Date]",E0="[object Error]",C0="[object Function]",R0="[object Map]",I0="[object Number]",S0="[object Object]",O0="[object RegExp]",v0="[object Set]",w0="[object String]",b0="[object WeakMap]",A0="[object ArrayBuffer]",T0="[object DataView]",y0="[object Float32Array]",N0="[object Float64Array]",M0="[object Int8Array]",L0="[object Int16Array]",D0="[object Int32Array]",U0="[object Uint8Array]",P0="[object Uint8ClampedArray]",k0="[object Uint16Array]",F0="[object Uint32Array]",xe={};xe[y0]=xe[N0]=xe[M0]=xe[L0]=xe[D0]=xe[U0]=xe[P0]=xe[k0]=xe[F0]=!0,xe[m0]=xe[g0]=xe[A0]=xe[_0]=xe[T0]=xe[p0]=xe[E0]=xe[C0]=xe[R0]=xe[I0]=xe[S0]=xe[O0]=xe[v0]=xe[w0]=xe[b0]=!1;function x0(e){return Gn(e)&&eh(e.length)&&!!xe[kr(e)]}function B0(e){return function(t){return e(t)}}var ch=typeof f=="object"&&f&&!f.nodeType&&f,Fr=ch&&typeof module=="object"&&module&&!module.nodeType&&module,$0=Fr&&Fr.exports===ch,jo=$0&&Hu.process,uh=function(){try{var e=Fr&&Fr.require&&Fr.require("util").types;return e||jo&&jo.binding&&jo.binding("util")}catch{}}(),hh=uh&&uh.isTypedArray,dh=hh?B0(hh):x0;function H0(e,t){var n=Vn(e),r=!n&&Wo(e),s=!n&&!r&&lh(e),i=!n&&!r&&!s&&dh(e),o=n||r||s||i,a=o?a0(e.length,String):[],l=a.length;for(var c in e)o&&(c=="length"||s&&(c=="offset"||c=="parent")||i&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Bo(c,l))||a.push(c);return a}function W0(e,t){return function(n){return e(t(n))}}function j0(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var Y0=Object.prototype,G0=Y0.hasOwnProperty;function V0(e){if(!Ct(e))return j0(e);var t=nh(e),n=[];for(var r in e)r=="constructor"&&(t||!G0.call(e,r))||n.push(r);return n}function fh(e){return Ho(e)?H0(e):V0(e)}var z0=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,K0=/^\w*$/;function X0(e,t){if(Vn(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Gs(e)?!0:K0.test(e)||!z0.test(e)||t!=null&&e in Object(t)}var xr=xo(Object,"create");function q0(){this.__data__=xr?xr(null):{},this.size=0}function Z0(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var J0="__lodash_hash_undefined__",Q0=Object.prototype,eC=Q0.hasOwnProperty;function tC(e){var t=this.__data__;if(xr){var n=t[e];return n===J0?void 0:n}return eC.call(t,e)?t[e]:void 0}var nC=Object.prototype,rC=nC.hasOwnProperty;function sC(e){var t=this.__data__;return xr?t[e]!==void 0:rC.call(t,e)}var iC="__lodash_hash_undefined__";function oC(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=xr&&t===void 0?iC:t,this}function In(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}In.prototype.clear=q0,In.prototype.delete=Z0,In.prototype.get=tC,In.prototype.has=sC,In.prototype.set=oC;function aC(){this.__data__=[],this.size=0}function Ks(e,t){for(var n=e.length;n--;)if(zs(e[n][0],t))return n;return-1}var lC=Array.prototype,cC=lC.splice;function uC(e){var t=this.__data__,n=Ks(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():cC.call(t,n,1),--this.size,!0}function hC(e){var t=this.__data__,n=Ks(t,e);return n<0?void 0:t[n][1]}function dC(e){return Ks(this.__data__,e)>-1}function fC(e,t){var n=this.__data__,r=Ks(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function jt(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}jt.prototype.clear=aC,jt.prototype.delete=uC,jt.prototype.get=hC,jt.prototype.has=dC,jt.prototype.set=fC;var mh=xo(Rn,"Map");function mC(){this.size=0,this.__data__={hash:new In,map:new(mh||jt),string:new In}}function gC(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Xs(e,t){var n=e.__data__;return gC(t)?n[typeof t=="string"?"string":"hash"]:n.map}function _C(e){var t=Xs(this,e).delete(e);return this.size-=t?1:0,t}function pC(e){return Xs(this,e).get(e)}function EC(e){return Xs(this,e).has(e)}function CC(e,t){var n=Xs(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function on(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}on.prototype.clear=mC,on.prototype.delete=_C,on.prototype.get=pC,on.prototype.has=EC,on.prototype.set=CC;var RC="Expected a function";function Yo(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(RC);var n=function(){var r=arguments,s=t?t.apply(this,r):r[0],i=n.cache;if(i.has(s))return i.get(s);var o=e.apply(this,r);return n.cache=i.set(s,o)||i,o};return n.cache=new(Yo.Cache||on),n}Yo.Cache=on;var IC=500;function SC(e){var t=Yo(e,function(r){return n.size===IC&&n.clear(),r}),n=t.cache;return t}var OC=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,vC=/\\(\\)?/g,wC=SC(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(OC,function(n,r,s,i){t.push(s?i.replace(vC,"$1"):r||n)}),t});function bC(e){return e==null?"":Vu(e)}function gh(e,t){return Vn(e)?e:X0(e,t)?[e]:wC(bC(e))}function _h(e){if(typeof e=="string"||Gs(e))return e;var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function AC(e,t){t=gh(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[_h(t[n++])];return n&&n==r?e:void 0}function ph(e,t,n){var r=e==null?void 0:AC(e,t);return r===void 0?n:r}var Eh=W0(Object.getPrototypeOf,Object),TC="[object Object]",yC=Function.prototype,NC=Object.prototype,Ch=yC.toString,MC=NC.hasOwnProperty,LC=Ch.call(Object);function DC(e){if(!Gn(e)||kr(e)!=TC)return!1;var t=Eh(e);if(t===null)return!0;var n=MC.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Ch.call(n)==LC}function UC(){this.__data__=new jt,this.size=0}function PC(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function kC(e){return this.__data__.get(e)}function FC(e){return this.__data__.has(e)}var xC=200;function BC(e,t){var n=this.__data__;if(n instanceof jt){var r=n.__data__;if(!mh||r.length<xC-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new on(r)}return n.set(e,t),this.size=n.size,this}function zn(e){var t=this.__data__=new jt(e);this.size=t.size}zn.prototype.clear=UC,zn.prototype.delete=PC,zn.prototype.get=kC,zn.prototype.has=FC,zn.prototype.set=BC;var Rh=typeof f=="object"&&f&&!f.nodeType&&f,Ih=Rh&&typeof module=="object"&&module&&!module.nodeType&&module,$C=Ih&&Ih.exports===Rh,Sh=$C?Rn.Buffer:void 0;Sh&&Sh.allocUnsafe;function HC(e,t){return e.slice()}var Oh=Rn.Uint8Array;function WC(e){var t=new e.constructor(e.byteLength);return new Oh(t).set(new Oh(e)),t}function jC(e,t){var n=WC(e.buffer);return new e.constructor(n,e.byteOffset,e.length)}function YC(e){return typeof e.constructor=="function"&&!nh(e)?HE(Eh(e)):{}}function GC(e){return function(t,n,r){for(var s=-1,i=Object(t),o=r(t),a=o.length;a--;){var l=o[++s];if(n(i[l],l,i)===!1)break}return t}}var VC=GC(),Go=function(){return Rn.Date.now()},zC="Expected a function",KC=Math.max,XC=Math.min;function qC(e,t,n){var r,s,i,o,a,l,c=0,u=!1,h=!1,d=!0;if(typeof e!="function")throw new TypeError(zC);t=Ku(t)||0,Ct(n)&&(u=!!n.leading,h="maxWait"in n,i=h?KC(Ku(n.maxWait)||0,t):i,d="trailing"in n?!!n.trailing:d);function m(R){var b=r,y=s;return r=s=void 0,c=R,o=e.apply(y,b),o}function _(R){return c=R,a=setTimeout(A,t),u?m(R):o}function p(R){var b=R-l,y=R-c,$=t-b;return h?XC($,i-y):$}function I(R){var b=R-l,y=R-c;return l===void 0||b>=t||b<0||h&&y>=i}function A(){var R=Go();if(I(R))return B(R);a=setTimeout(A,p(R))}function B(R){return a=void 0,d&&r?m(R):(r=s=void 0,o)}function x(){a!==void 0&&clearTimeout(a),c=0,r=l=s=a=void 0}function Y(){return a===void 0?o:B(Go())}function O(){var R=Go(),b=I(R);if(r=arguments,s=this,l=R,b){if(a===void 0)return _(l);if(h)return clearTimeout(a),a=setTimeout(A,t),m(l)}return a===void 0&&(a=setTimeout(A,t)),o}return O.cancel=x,O.flush=Y,O}function Vo(e,t,n){(n!==void 0&&!zs(e[t],n)||n===void 0&&!(t in e))&&$o(e,t,n)}function ZC(e){return Gn(e)&&Ho(e)}function zo(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}function JC(e){return t0(e,fh(e))}function QC(e,t,n,r,s,i,o){var a=zo(e,n),l=zo(t,n),c=o.get(l);if(c){Vo(e,n,c);return}var u=i?i(a,l,n+"",e,t,o):void 0,h=u===void 0;if(h){var d=Vn(l),m=!d&&lh(l),_=!d&&!m&&dh(l);u=l,d||m||_?Vn(a)?u=a:ZC(a)?u=jE(a):m?(h=!1,u=HC(l)):_?(h=!1,u=jC(l)):u=[]:DC(l)||Wo(l)?(u=a,Wo(a)?u=JC(a):(!Ct(a)||ko(a))&&(u=YC(l))):h=!1}h&&(o.set(l,u),s(u,l,r,i,o),o.delete(l)),Vo(e,n,u)}function Ko(e,t,n,r,s){e!==t&&VC(t,function(i,o){if(s||(s=new zn),Ct(i))QC(e,t,o,n,Ko,r,s);else{var a=r?r(zo(e,o),i,o+"",e,t,s):void 0;a===void 0&&(a=i),Vo(e,o,a)}},fh)}var eR=th(function(e,t,n,r){Ko(e,t,n,r)}),Xo=th(function(e,t,n){Ko(e,t,n)});function tR(e,t,n,r){if(!Ct(e))return e;t=gh(t,e);for(var s=-1,i=t.length,o=i-1,a=e;a!=null&&++s<i;){var l=_h(t[s]),c=n;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=o){var u=a[l];c=void 0,c===void 0&&(c=Ct(u)?u:Bo(t[s+1])?[]:{})}Ju(a,l,c),a=a[l]}return e}function nR(e,t,n){return e==null?e:tR(e,t,n)}const qo=Re.createIdentifier("univer.config-service");class vh{constructor(){C(this,"_configChanged$",new oe.Subject);C(this,"configChanged$",this._configChanged$.asObservable());C(this,"_config",new Map)}dispose(){this._config.clear(),this._configChanged$.complete()}getConfig(t){return this._config.get(t)}setConfig(t,n,r){var o;const{merge:s=!1}=r||{};let i=(o=this._config.get(t))!=null?o:{};s?i=Xo(i,n):i=n,this._config.set(t,i),this._configChanged$.next({[t]:i})}deleteConfig(t){return this._config.delete(t)}subscribeConfigValue$(t){return new oe.Observable(n=>{Object.prototype.hasOwnProperty.call(this._config,t)&&n.next(this._config.get(t));const r=this.configChanged$.pipe(oe.filter(s=>Object.prototype.hasOwnProperty.call(s,t))).subscribe(s=>n.next(s[t]));return()=>r.unsubscribe()})}}const Br="FOCUSING_UNIT",Kn="FOCUSING_SHEET",$r="FOCUSING_DOC",Hr="FOCUSING_SLIDE",rR="FOCUSING_EDITOR_BUT_HIDDEN",wh="EDITOR_ACTIVATED",sR="FOCUSING_EDITOR_INPUT_FORMULA",bh="FOCUSING_FX_BAR_EDITOR",iR="FOCUSING_UNIVER_EDITOR",oR="FOCUSING_EDITOR_INPUT_FORMULA",aR="FOCUSING_PANEL_EDITOR",lR="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",cR="FOCUSING_COMMON_DRAWINGS",uR="FORMULA_EDITOR_ACTIVATED";class Ah extends ze{constructor(){super(...arguments);C(this,"_error$",new oe.Subject);C(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(n){this._error$.next({errorKey:n})}}var Zo=(e=>(e.URL="URL",e.UUID="UUID",e.BASE64="BASE64",e))(Zo||{}),Th=(e=>(e.SUCCUSS="0",e.ERROR_EXCEED_SIZE="1",e.ERROR_IMAGE_TYPE="2",e.ERROR_UPLOAD_COUNT_LIMIT="3",e.ERROR_IMAGE="4",e))(Th||{});const Jo=Re.createIdentifier("core.image-io.service"),hR={version:"0.9.3"};function dR(e="",t=ar.ZH_CN,n=""){return{id:e,sheetOrder:[],name:n,appVersion:hR.version,locale:t,styles:{},sheets:{},resources:[]}}class yh{constructor(t={}){C(this,"_styles");C(this,"_cacheMap",new ur(1e5));this._styles=t,this._generateCacheMap()}each(t){return Object.entries(this._styles).forEach(t),this}search(t,n){if(this._cacheMap.has(n))return this._cacheMap.get(n);const r=this._getExistingStyleId(t);return r||"-1"}get(t){return typeof t!="string"?t:(t=String(t),this._styles[t])}add(t,n){const r=tt(6);return this._styles[r]=t,this._cacheMap.set(n,r),r}setValue(t){if(t==null)return;const n=JSON.stringify(t),r=this.search(t,n);return r!=="-1"?r:this.add(t,n)}toJSON(){return this._styles}getStyleByCell(t){let n;t&&Z.isObject(t.s)?n=t.s:n=(t==null?void 0:t.s)&&this.get(t.s);const r=t==null?void 0:t.interceptorStyle;return r?{...n,...r}:n}_generateCacheMap(){const{_styles:t,_cacheMap:n}=this;for(const r in t){const s=JSON.stringify(t[r]);n.set(s,r)}}_getExistingStyleId(t){const{_styles:n}=this;for(const r in n)if(Z.diffValue(n[r],t))return r;return null}}const fR=(e,t)=>t.length===e.length&&!e.some(n=>t.some(r=>!tn.equals(r,n))),mR=(e,t)=>t.length===e.length&&e.every((n,r)=>{const s=t[r];return s.unitId===n.unitId&&s.sheetId===n.sheetId&&tn.equals(n.range,s.range)}),Qo={t:0,b:2,l:2,r:2},gR=e=>({sbr:.6,sbo:e,spr:.6,spo:e}),Nh=90;function Wr(e,t,n={}){const r=e.length,{textRotation:s,paddingData:i,horizontalAlign:o=Ot.UNSPECIFIED,verticalAlign:a=hn.UNSPECIFIED,wrapStrategy:l=dn.UNSPECIFIED,cellValueType:c}=n,{t:u,r:h,b:d,l:m}=i||Qo,{vertexAngle:_,centerAngle:p}=Ph(s),I={id:"d",body:{dataStream:`${e}${_a}`,textRuns:[{ts:t,st:0,ed:r}],paragraphs:[{startIndex:r,paragraphStyle:{horizontalAlign:o}}],sectionBreaks:[{startIndex:r+1}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},marginTop:u,marginBottom:d,marginRight:h,marginLeft:m,renderConfig:{horizontalAlign:o,verticalAlign:a,centerAngle:p,vertexAngle:_,wrapStrategy:l,cellValueType:c,zeroWidthParagraphBreak:1}},drawings:{},drawingsOrder:[]};return new At(I)}function _R(e){if(!e)return{};const{tr:t,td:n,ht:r,vt:s,tb:i,pd:o}=e;return{textRotation:t,textDirection:n,horizontalAlign:r,verticalAlign:s,wrapStrategy:i,paddingData:o}}function Mh(e){if(!e)return{};const{ff:t,fs:n,it:r,bl:s,ul:i,st:o,ol:a,cl:l}=e,c={};return t&&(c.ff=t),n&&(c.fs=n),r&&(c.it=r),s&&(c.bl=s),i&&(c.ul=i),o&&(c.st=o),a&&(c.ol=a),l&&(c.cl=l),c}function Lh(e,t,n){var i;const r=e.getBody();if((i=r.customRanges)!=null&&i.some(o=>o.rangeType===en.HYPERLINK))return;const s=Je.customRange.add({ranges:[{startOffset:0,endOffset:r.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:en.HYPERLINK,body:r,properties:{url:t,refId:n}});s&&Me.apply(r,s.serialize())}function Dh(e){return e!=null}const pR='"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';function Uh(e){const t=st.ff,n=st.fs;if(!e){const h=`${n}pt ${t}`;return{fontCache:h,fontString:h,fontSize:n,originFontSize:n,fontFamily:t}}let r=kn.ITALIC;(e.it===0||e.it===void 0)&&(r=kn.NORMAL);let s=kn.BOLD;(e.bl===0||e.bl===void 0)&&(s=kn.NORMAL);let i=n;e.fs&&(i=Math.ceil(e.fs));let o=t;if(e.ff){let h=e.ff;h=h.replace(/"/g,"").replace(/'/g,""),h.indexOf(" ")>-1&&(h=`"${h}"`),h==null&&(h=t),o=h}const{va:a}=e;let l=i;if(a===$t.SUBSCRIPT||a===$t.SUPERSCRIPT){const h=ER(o,l),{sbr:d,spr:m}=h;l*=a===$t.SUBSCRIPT?d:m}const c=`${r} ${s} ${l}pt ${o}`,u=`${c}, ${pR} `;return{fontCache:c,fontString:u,fontSize:l,originFontSize:i,fontFamily:o}}function ER(e,t){return gR(t)}function Ph(e){const{a:t=0,v:n=ae.FALSE}=e||{a:0,v:ae.FALSE};let r=0,s=t;return n===ae.TRUE&&(r=Nh,s=Nh),{centerAngle:r,vertexAngle:s}}class CR{constructor(t,n){C(this,"_columnData",{});this._config=t,this._columnData=n}getColumnData(){return this._columnData}getColVisible(t){const{_columnData:n}=this,r=n[t];return r?r.hd!==ae.TRUE:!0}getColumnStyle(t){var n;return(n=this._columnData[t])==null?void 0:n.s}setColumnStyle(t,n){const r=this.getColumnOrCreate(t);r.s=n}getHiddenCols(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getColVisible(o);s&&a?(s=!1,r.push({rangeType:pe.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:pe.COLUMN}),r}getVisibleCols(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getColVisible(o);s&&!a?(s=!1,r.push({rangeType:pe.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:pe.COLUMN}),r}getColumnDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getColumn(i);r[s]=o!=null?o:{w:this._config.defaultColumnWidth,hd:ae.FALSE},s++}return r}getSize(){return Zt(this._columnData)}getColumnWidth(t){var n,r;return(r=(n=this._columnData[t])==null?void 0:n.w)!=null?r:this._config.defaultColumnWidth}setColumnWidth(t,n){const r=this._columnData[t];n===this._config.defaultColumnWidth?r&&(delete r.w,Object.keys(r).length===0&&delete this._columnData[t]):this._columnData[t]=r?{...r,w:n}:{w:n}}getColumn(t){return this._columnData[t]}removeColumn(t){delete this._columnData[t]}getColumnOrCreate(t){const{_columnData:n}=this,r=n[t];if(r)return r;const s={};return this._columnData[t]=s,s}setCustomMetadata(t,n){const r=this.getColumn(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getColumn(t))==null?void 0:n.custom}}const RR=2e3;class IR{constructor(t,n,r){C(this,"_rowData");this._config=t,this._viewModel=n,this._rowData=r}getRowData(){return this._rowData}getRowStyle(t){var n;return(n=this._rowData[t])==null?void 0:n.s}setRowStyle(t,n){const r=this.getRowOrCreate(t);r.s=n}getRowDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getRow(i);r[s]=o!=null?o:{h:this._config.defaultRowHeight,hd:ae.FALSE},s++}return r}getRowHeight(t,n=1){const{_rowData:r}=this,s=this._config;let i=0;for(let o=0;o<n;o++){const a=r[o+t]||{hd:ae.FALSE,h:s.defaultRowHeight},{ia:l,ah:c,h:u=s.defaultRowHeight}=a;i+=(l==null||l===ae.TRUE)&&typeof c=="number"?c:u}return i}setRowHeight(t,n){const r=this._rowData[t];if(n===this._config.defaultRowHeight)r&&(delete r.h,Object.keys(r).length===0&&delete this._rowData[t]);else{const s=Math.min(n,RR);this._rowData[t]=r?{...r,h:s}:{h:s}}}getRow(t){return this._rowData[t]}removeRow(t){delete this._rowData[t]}getRowOrCreate(t){const{_rowData:n}=this,r=n[t];if(r)return r;const s={};return n[t]=s,s}getHiddenRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:pe.ROW})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:pe.ROW}),r}getVisibleRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&!a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:pe.ROW})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:pe.ROW}),r}getRowRawVisible(t){const n=this.getRow(t);return n?n.hd!==ae.TRUE:!0}getSize(){return Zt(this._rowData)}setCustomMetadata(t,n){const r=this.getRow(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getRow(t))==null?void 0:n.custom}}const SR="DEFAULT_WORKSHEET_ROW_COUNT",kh=1e3,OR="DEFAULT_WORKSHEET_COLUMN_COUNT",Fh=20,vR="DEFAULT_WORKSHEET_ROW_HEIGHT",xh=24,wR="DEFAULT_WORKSHEET_COLUMN_WIDTH",Bh=88,bR="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",$h=46,AR="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Hh=20;function Wh(e){const t={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:ae.FALSE,rowCount:kh,columnCount:Fh,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Bh,defaultRowHeight:xh,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:ae.TRUE,rowHeader:{width:$h,hidden:ae.FALSE},columnHeader:{height:Hh,hidden:ae.FALSE},rightToLeft:ae.FALSE};return Object.keys(t).forEach(n=>{const r=n;typeof e[r]>"u"&&(e[r]=t[r])}),e}class TR extends ze{constructor(n){super();C(this,"_cellCache",new Map);C(this,"_rowCache",new Map);C(this,"_columnCache",new Map);C(this,"_hasRow",!1);C(this,"_hasColumn",!1);C(this,"_hasAll",!1);C(this,"_allIndex",-1);C(this,"_mergeData");C(this,"_rangeMap",new ur(5e4));C(this,"_skeletonCache",new ur(5e4));this._init(n.concat())}_init(n){this._mergeData=n,this._createCache(n)}_clearCache(){this._cellCache.clear(),this._rowCache.clear(),this._columnCache.clear(),this._hasAll=!1,this._allIndex=-1,this._rangeMap.clear(),this._skeletonCache.clear(),this._hasColumn=!1,this._hasRow=!1}_createCache(n){let r=0;for(const s of n){const{rangeType:i}=s;i===pe.ROW?this._createRowCache(s,r):i===pe.COLUMN?this._createColumnCache(s,r):i===pe.ALL?this._createCellAllCache(r):this._createCellCache(s,r),r++}}rebuild(n){this._clearCache(),this._init(n.concat())}_createRowCache(n,r){const{startRow:s,endRow:i}=n;for(let o=s;o<=i;o++)this._rowCache.set(o,r),this._hasRow=!0}_createColumnCache(n,r){const{startColumn:s,endColumn:i}=n;for(let o=s;o<=i;o++)this._columnCache.set(o,r),this._hasColumn=!0}_createCellAllCache(n){this._hasAll=!0,this._allIndex=n}_createCellCache(n,r){for(let s=n.startRow;s<=n.endRow;s++){let i=this._cellCache.get(s);i==null&&(i=new Map,this._cellCache.set(s,i));for(let o=n.startColumn;o<=n.endColumn;o++)i.set(o,r)}}add(n){this._mergeData.push(n),this._clearCache(),this._createCache(this._mergeData)}remove(n,r){const s=this._getMergeDataIndex(n,r);s!==-1&&(this._mergeData.splice(s,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(n,r){const s=this._getMergeDataIndex(n,r);return s!==-1?this._mergeData[s]:null}getMergeDataIndex(n,r){return this._getMergeDataIndex(n,r)}isRowContainsMergedCell(n){return this._hasAll||!Z.isEmptyObject(this._columnCache)?!0:this._mergeData.some(r=>r.startRow<=n&&n<=r.endRow)}isColumnContainsMergedCell(n){return this._hasAll||!Z.isEmptyObject(this._rowCache)?!0:this._mergeData.some(r=>r.startColumn<=n&&n<=r.endColumn)}getMergedCellRange(n,r,s,i){const o=[],a=`${n}-${r}-${s}-${i}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let l=0;const c=[];for(const u of this._mergeData||[])tn.intersects(u,{startRow:n,endRow:s,startColumn:r,endColumn:i})&&(o.push({...u}),c.push(l)),l++;return this._rangeMap.set(a,c),o}getMergedCellRangeForSkeleton(n,r,s,i){const o=[],a=this._mergeData,l=`${n}-${r}-${s}-${i}`;if(this._skeletonCache.has(l))return this._getSkeletonRangeFromCache(l);const c=[];for(let u=0;u<a.length;u++){const{startRow:h,endRow:d,startColumn:m,endColumn:_}=a[u];for(let p=n;p<=s;p++){let I=!1;for(let A=r;A<=i;A++)if(p>=h&&p<=d&&A>=m&&A<=_){o.push({startRow:h,endRow:d,startColumn:m,endColumn:_}),c.push(u),I=!0;break}if(I)break}}return this._skeletonCache.set(l,c),o}_getRangeFromCache(n){const r=this._rangeMap.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getSkeletonRangeFromCache(n){const r=this._skeletonCache.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getMergeDataIndex(n,r){var i;if(this._hasAll)return this._allIndex;if(this._hasRow){const o=this._rowCache.get(n);if(o!==void 0)return o}if(this._hasColumn){const o=this._columnCache.get(r);if(o!==void 0)return o}const s=(i=this._cellCache.get(n))==null?void 0:i.get(r);return s!==void 0?s:-1}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}}class jh extends ze{constructor(n){super();C(this,"_cellContentInterceptor",null);C(this,"_rowFilteredInterceptor",null);this.getRawCell=n}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(n,r,s,i){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,bn.Value|bn.Style,s,i):this.getRawCell(n,r)}getCellValueOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,bn.Value):this.getRawCell(n,r)}getCellStyleOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,bn.Style):this.getRawCell(n,r)}getRowFiltered(n){var r,s;return(s=(r=this._rowFilteredInterceptor)==null?void 0:r.getRowFiltered(n))!=null?s:!1}registerCellContentInterceptor(n){if(this._cellContentInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptor=n,je(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(n){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=n,je(()=>this._rowFilteredInterceptor=null)}}const Yh={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};class jr{constructor(t,n,r){C(this,"_sheetId");C(this,"_snapshot");C(this,"_cellData");C(this,"_rowManager");C(this,"_columnManager");C(this,"_viewModel");C(this,"_spanModel");C(this,"_isRowStylePrecedeColumnStyle",!0);C(this,"_getCellHeight");var a;this.unitId=t,this._styles=r,this._snapshot=Wh(n);const{columnData:s,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:tt(6),this._cellData=new ct(o),this._viewModel=new jh((l,c)=>this.getCellRaw(l,c)),this._rowManager=new IR(this._snapshot,this._viewModel,i),this._columnManager=new CR(this._snapshot,s),this._spanModel=new TR(this._snapshot.mergeData)}__interceptViewModel(t){t(this._viewModel)}__registerGetCellHeight(t){return this._getCellHeight=t,je(()=>{this._getCellHeight=null})}getSnapshot(){return this._snapshot}getCellHeight(t,n){return this._getCellHeight?this._getCellHeight(t,n):this._snapshot.defaultRowHeight}setMergeData(t){this._snapshot.mergeData=t,this.getSpanModel().rebuild(t)}getSpanModel(){return this._spanModel}setIsRowStylePrecedeColumnStyle(t){this._isRowStylePrecedeColumnStyle=t}getStyleDataByHash(t){return{...this._styles.get(t)}}setStyleData(t){return this._styles.setValue(t)}getColumnStyle(t,n=!1){return n?this._columnManager.getColumnStyle(t):this._styles.get(this._columnManager.getColumnStyle(t))}setColumnStyle(t,n){this._columnManager.setColumnStyle(t,n)}getRowStyle(t,n=!1){return n?this._rowManager.getRowStyle(t):this._styles.get(this._rowManager.getRowStyle(t))}setRowStyle(t,n){this._rowManager.setRowStyle(t,n)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){const t=this._snapshot.defaultStyle;return this._styles.get(t)}setDefaultCellStyle(t){this._snapshot.defaultStyle=t}getCellStyle(t,n){const r=this.getCell(t,n);if(r){const s=r.s;return typeof s=="string"?this._styles.get(s):s}return null}getComposedCellStyle(t,n,r){const s=this.getDefaultCellStyleInternal(),i=this.getRowStyle(t),o=this.getColumnStyle(n),a=this.getCell(t,n),l=this._styles.getStyleByCell(a);return(r!=null?r:this._isRowStylePrecedeColumnStyle)?cr(s,o,i,a==null?void 0:a.themeStyle,l):cr(s,i,o,a==null?void 0:a.themeStyle,l)}getComposedCellStyleByCellData(t,n,r,s){const i=this.getDefaultCellStyleInternal(),o=this.getRowStyle(t),a=this.getColumnStyle(n),l=this._styles.getStyleByCell(r);return(s!=null?s:this._isRowStylePrecedeColumnStyle)?cr(i,a,o,r==null?void 0:r.themeStyle,l):cr(i,o,a,r==null?void 0:r.themeStyle,l)}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const t=this.getCellMatrix(),n=this.getMergeData();let r=-1,s=-1,i=-1,o=-1,a=!1,l=!1;return t.forEach((c,u)=>{Object.keys(u).forEach(h=>{const d=+h,m=t.getValue(c,d),_=m!=null&&m.s?this._styles.get(m.s):null,p=(_==null?void 0:_.bd)&&(_.bd.b||_.bd.l||_.bd.r||_.bd.t||_.bd.bc_tr||_.bd.bl_tr||_.bd.ml_tr||_.bd.tl_bc||_.bd.tl_br||_.bd.tl_mr);(m&&(m.v||m.p)||_!=null&&_.bg||p)&&(a?r=Math.min(r,c):(r=c,a=!0),s=Math.max(s,c),l?i=Math.min(i,d):(l=!0,i=d),o=Math.max(o,d))})}),n.forEach(c=>{a?r=Math.min(r,c.startRow):(r=c.startRow,a=!0),s=Math.max(s,c.endRow),l?i=Math.min(i,c.startColumn):(i=c.startColumn,a=!0),o=Math.max(o,c.endColumn)}),!a||!l?null:{startColumn:i,startRow:r,endColumn:o,endRow:s}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:t}=this,n=Z.deepClone(t);return new jr(this.unitId,n,this._styles)}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(t,n){return this._spanModel.getMergedCell(t,n)}getMergedCellRange(t,n,r,s){return this._spanModel.getMergedCellRange(t,n,r,s)}isRowContainsMergedCell(t){return this._spanModel.isRowContainsMergedCell(t)}isColumnContainsMergedCell(t){return this._spanModel.isColumnContainsMergedCell(t)}getCellInfoInMergeData(t,n){const r=this.getMergedCell(t,n);let s=!1,i=!1,o=t,a=n,l=t,c=n;if(r){const{startRow:u,endRow:h,startColumn:d,endColumn:m}=r;t===u&&n===d?(o=h,a=m,l=u,c=d,i=!0):t>=u&&t<=h&&n>=d&&n<=m&&(o=h,a=m,l=u,c=d,s=!0)}return{actualRow:t,actualColumn:n,isMergedMainCell:i,isMerged:s,endRow:o,endColumn:a,startRow:l,startColumn:c}}getCell(t,n){return t<0||n<0?null:this._viewModel.getCell(t,n)}getCellValueOnly(t,n){return t<0||n<0?null:this._viewModel.getCellValueOnly(t,n)}getCellStyleOnly(t,n){return t<0||n<0?null:this._viewModel.getCellStyleOnly(t,n)}getCellRaw(t,n){return this.getCellMatrix().getValue(t,n)}getCellWithFilteredInterceptors(t,n,r,s){return this._viewModel.getCell(t,n,r,s)}getRowFiltered(t){return this._viewModel.getRowFiltered(t)}getRangeFilterRows(t){const n=[];for(let r=t.startRow;r<=t.endRow;r++)this.getRowFiltered(r)&&n.push(r);return n}getMatrixWithMergedCells(t,n,r,s,i=Tn.Raw){const o=this.getCellMatrix(),a=this._spanModel.getMergedCellRange(t,n,r,s),l=new ct;return po(t,r,n,s).forEach((c,u)=>{var d;let h;if(i===Tn.Raw)h=this.getCellRaw(c,u);else if(i===Tn.Intercepted)h=this.getCell(c,u);else if(i===Tn.Both){const m=this.getCellRaw(c,u);if(m){h={...m};const _=(d=this.getCell(c,u))==null?void 0:d.v;Dh(_)&&h&&(h.displayV=String(_))}}h&&l.setValue(c,u,h)}),a.forEach(c=>{const{startColumn:u,startRow:h,endColumn:d,endRow:m}=c;po(h,m,u,d).forEach((_,p)=>{_===h&&p===u&&l.setValue(_,p,{...o.getValue(_,p),rowSpan:m-h+1,colSpan:d-u+1}),(_!==h||p!==u)&&l.realDeleteValue(_,p)})}),l}getRange(t,n,r,s){return typeof t=="object"?new xn(this,t,{getStyles:()=>this._styles}):new xn(this,{startRow:t,startColumn:n,endColumn:s||n,endRow:r||t},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:t}=this,{columnCount:n}=t;return n}getMaxRows(){const{_snapshot:t}=this,{rowCount:n}=t;return n}getRowCount(){return this._snapshot.rowCount}setRowCount(t){this._snapshot.rowCount=t}getColumnCount(){return this._snapshot.columnCount}setColumnCount(t){this._snapshot.columnCount=t}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:t}=this,{showGridlines:n}=t;return n===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){const{_snapshot:t}=this,{tabColor:n}=t;return n}getColumnWidth(t){return this.getColumnManager().getColumnWidth(t)}getRowHeight(t){return this._viewModel.getRowFiltered(t)?0:this.getRowManager().getRowHeight(t)}isRowFiltered(t){return this._viewModel.getRowFiltered(t)}getRowVisible(t){return!this.isRowFiltered(t)&&this.getRowRawVisible(t)}getRowRawVisible(t){return this.getRowManager().getRowRawVisible(t)}getHiddenRows(t,n){const r=this.getMaxColumns()-1,s=this._rowManager.getHiddenRows(t,n);return s.forEach(i=>i.endColumn=r),s}getColVisible(t){return this._columnManager.getColVisible(t)}getHiddenCols(t,n){const r=this.getMaxRows()-1,s=this._columnManager.getHiddenCols(t,n);return s.forEach(i=>i.endRow=r),s}getVisibleRows(){const t=this.getRowCount();return this._rowManager.getVisibleRows(0,t-1)}getVisibleCols(){const t=this.getColumnCount();return this._columnManager.getVisibleCols(0,t-1)}isRightToLeft(){const{_snapshot:t}=this,{rightToLeft:n}=t;return n}getLastRowWithContent(){return this._cellData.getLength()-1}getLastColumnWithContent(){return this._cellData.getRange().endColumn}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(t){return t&&(t.v!==void 0||t.f!==void 0||t.p!==void 0)}iterateByRow(t,n=!0){const{startRow:r,startColumn:s,endRow:i,endColumn:o}=t,a=this;return{[Symbol.iterator]:()=>{let l=r,c=s;return{next(){for(;;){if(c>o&&(l+=1,c=s),l>i)return{done:!0,value:void 0};const u=a.getCell(l,c),h=!u,d=a.getMergedCell(l,c);if(d){if(l!==d.startRow||c!==d.startColumn){c=d.endColumn+1;continue}if(h&&n){c=d.endColumn+1;continue}const _={row:l,col:c,value:u};return _.colSpan=d.endColumn-d.startColumn+1,_.rowSpan=d.endRow-d.startRow+1,c=d.endColumn+1,{done:!1,value:_}}if(h&&n)c+=1;else{const m={row:l,col:c,value:u};return c+=1,{done:!1,value:m}}}}}}}}iterateByColumn(t,n=!0,r=!0){const{startRow:s,startColumn:i,endRow:o,endColumn:a}=t,l=this;return{[Symbol.iterator]:()=>{let c=s,u=i;return{next(){for(;;){if(c>o&&(u+=1,c=s),u>a)return{done:!0,value:void 0};const h=l.getMergedCell(c,u);if(h){const _=c!==h.startRow,p=_||u!==h.startColumn;if(r&&p||!r&&_){c=h.endRow+1;continue}const I=l.getCell(h.startRow,h.startColumn);if(!I&&n){c=h.endRow+1;continue}const B={row:c,col:h.startColumn,value:I};return B.colSpan=h.endColumn-h.startColumn+1,B.rowSpan=h.endRow-h.startRow+1,c=h.endRow+1,{done:!1,value:B}}const d=l.getCell(c,u);if(!d&&n)c+=1;else{const _={row:c,col:u,value:d};return c+=1,{done:!1,value:_}}}}}}}}getCellDocumentModel(t,n,r=Yh){var p;if(!t)return;const{isDeepClone:s,displayRawFormula:i,ignoreTextRotation:o}={...Yh,...r};let a,l="document";const c=_R(n),u=o?st.tr:c.textRotation||st.tr;let h=c.horizontalAlign||st.ht;const d=c.verticalAlign||st.vt,m=c.wrapStrategy||st.tb,_=c.paddingData||Qo;if(t.f&&i)a=Wr(t.f.toString(),{},{verticalAlign:d}),h=st.ht;else if(t.p){const{centerAngle:I,vertexAngle:A}=Ph(u);a=this._updateConfigAndGetDocumentModel(s?Z.deepClone(t.p):t.p,h,_,{horizontalAlign:h,verticalAlign:d,centerAngle:I,vertexAngle:A,wrapStrategy:m,zeroWidthParagraphBreak:1})}else if(t.v!=null){const I=Mh(n);l=Uh(I).fontCache;let A=Gh(t);t.t===Xt.FORCE_STRING&&i&&(A=`'${A}`),a=Wr(A,I,{...c,textRotation:u,cellValueType:t.t})}return a&&t.linkUrl&&t.linkId&&Lh(a,t.linkUrl,t.linkId),{documentModel:a,fontString:l,textRotation:u,wrapStrategy:m,verticalAlign:d,horizontalAlign:h,paddingData:_,fill:(p=n==null?void 0:n.bg)==null?void 0:p.rgb}}_updateConfigAndGetDocumentModel(t,n,r,s){var o,a,l,c,u;if(!s||!((o=t.body)!=null&&o.dataStream))return;t.documentStyle||(t.documentStyle={}),t.documentStyle.marginTop=(a=r.t)!=null?a:0,t.documentStyle.marginBottom=(l=r.b)!=null?l:2,t.documentStyle.marginLeft=(c=r.l)!=null?c:2,t.documentStyle.marginRight=(u=r.r)!=null?u:2,t.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},t.documentStyle.renderConfig={...t.documentStyle.renderConfig,...s};const i=t.body.paragraphs||[];for(const h of i)h.paragraphStyle||(h.paragraphStyle={}),h.paragraphStyle.horizontalAlign=n;return new At(t)}getBlankCellDocumentModel(t,n,r){const s=this.getComposedCellStyleByCellData(n,r,t),i=Mh(s),o=this.getCellDocumentModel(t,s,{ignoreTextRotation:!0});if(o!=null)return o.documentModel==null&&(o.documentModel=Wr("",i)),o;const a="";let l="document";const c=st.tr,u=st.ht,h=st.vt,d=st.tb,m=Qo;return l=Uh({}).fontCache,{documentModel:Wr(a,i),fontString:l,textRotation:c,wrapStrategy:d,verticalAlign:h,horizontalAlign:u,paddingData:m}}getCellDocumentModelWithFormula(t,n,r){const s=this.getComposedCellStyleByCellData(n,r,t);return this.getCellDocumentModel(t,s,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(t){this._snapshot.custom=t}}function Gh(e){var r,s;if(!e)return"";const t=(s=(r=e.p)==null?void 0:r.body)==null?void 0:s.dataStream;if(t)return Je.transform.getPlainText(t);const n=e.v;return typeof n=="string"?e.t===Xt.BOOLEAN?n.toUpperCase():n.replace(/[\r\n]/g,""):typeof n=="number"?e.t===Xt.BOOLEAN?n?"TRUE":"FALSE":n.toString():typeof n=="boolean"?n?"TRUE":"FALSE":""}function yR(e){if(e===null)return"";if(e!=null&&e.p){const t=e==null?void 0:e.p.body;if(t==null)return"";const n=t.dataStream;return Je.transform.getPlainText(n)}return e==null?void 0:e.v}var NR=Object.getOwnPropertyDescriptor,MR=(e,t,n,r)=>{for(var s=r>1?void 0:r?NR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},LR=(e,t)=>(n,r)=>t(n,r,e);function DR(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}f.Workbook=class extends Ps{constructor(n={},r){super();C(this,"type",we.UNIVER_SHEET);C(this,"_sheetCreated$",new oe.Subject);C(this,"sheetCreated$",this._sheetCreated$.asObservable());C(this,"_sheetDisposed$",new oe.Subject);C(this,"sheetDisposed$",this._sheetDisposed$.asObservable());C(this,"_activeSheet$",new oe.BehaviorSubject(null));C(this,"activeSheet$",this._activeSheet$.asObservable());C(this,"_worksheets");C(this,"_styles");C(this,"_snapshot");C(this,"_unitId");C(this,"_count");C(this,"_name$");C(this,"name$");this._logService=r;const s=dR();Z.isEmptyObject(n)?this._snapshot=s:this._snapshot=Z.commonExtend(s,n);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=tt(6)),this._unitId=this._snapshot.id,this._styles=new yh(i),this._count=1,this._worksheets=new Map,this._name$=new oe.BehaviorSubject(n.name||""),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(n){return typeof n=="string"||"startRow"in n||"row"in n}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete()}save(){return Z.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(n){this._name$.next(n),this._snapshot.name=n}getUnitId(){return this._unitId}getRev(){var n;return(n=this._snapshot.rev)!=null?n:1}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(n){this._snapshot.rev=n}addWorksheet(n,r,s){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[n])return!1;i[n]=s,o.splice(r,0,n);const a=new jr(this._unitId,s,this._styles);return this._worksheets.set(n,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}getConfig(){return this._snapshot}getIndexBySheetId(n){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>s===n)}getActiveSheet(n){if(!this._activeSheet&&typeof n>"u")throw new Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){const n=this._activeSheet;if(n)return n;const r=this._snapshot.sheetOrder;for(let i=0,o=r.length;i<o;i++){const a=this._worksheets.get(r[i]);if(a&&a.isSheetHidden()!==ae.TRUE)return this.setActiveSheet(a),a}const s=this._worksheets.get(r[0]);return this.setActiveSheet(s),s}setActiveSheet(n){this._activeSheet$.next(n)}removeSheet(n){const r=this._worksheets.get(n);return r?(this._worksheets.delete(n),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(n),1),delete this._snapshot.sheets[n],this._sheetDisposed$.next(r),!0):!1}getActiveSheetIndex(){const{sheetOrder:n}=this._snapshot;return n.findIndex(r=>this._worksheets.get(r)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:n}=this._snapshot;return n.map(r=>this._worksheets.get(r))}getSheetsName(){const{sheetOrder:n}=this._snapshot,r=[];return n.forEach(s=>{const i=this._worksheets.get(s);i&&r.push(i.getName())}),r}getSheetIndex(n){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>n.getSheetId()===s)}getSheetBySheetName(n){const{sheetOrder:r}=this._snapshot,s=r.find(i=>this._worksheets.get(i).getName()===n);return this._worksheets.get(s)}getSheetBySheetId(n){return this._worksheets.get(n)}getSheetByIndex(n){const{sheetOrder:r}=this._snapshot;return this._worksheets.get(r[n])}getHiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden===ae.TRUE).map(n=>n.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden!==ae.TRUE).map(n=>n.getConfig().id)}load(n){this._snapshot=n}checkSheetName(n){return this.getSheetsName().includes(n)}uniqueSheetName(n="Sheet1"){let r=n;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}generateNewSheetName(n){let r=n+this._count;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}_parseWorksheetSnapshots(){const{_snapshot:n,_worksheets:r}=this,{sheets:s,sheetOrder:i}=n;if(Z.isEmptyObject(s)){const o=tt();s[o]={id:o}}for(const o in s){const a=s[o],{name:l}=a;a.name=this.uniqueSheetName(l),a.name!==l&&this._logService.debug("[Workbook]",`The worksheet name ${l} is duplicated, we changed it to ${a.name}. Please fix the problem in your snapshot.`);const c=new jr(this._unitId,a,this._styles);r.set(o,c),i.includes(o)||i.push(o)}this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(n){this._snapshot.custom=n}},f.Workbook=MR([LR(1,_t)],f.Workbook);class ea extends Ps{constructor(n){var r;super();C(this,"type",we.UNIVER_SLIDE);C(this,"_activePage$",new oe.BehaviorSubject(null));C(this,"activePage$",this._activePage$.asObservable());C(this,"_name$");C(this,"name$");C(this,"_snapshot");C(this,"_unitId");this._snapshot={...Bc,...n},this._unitId=(r=this._snapshot.id)!=null?r:tt(6),this._name$=new oe.BehaviorSubject(this._snapshot.title),this.name$=this._name$.asObservable()}get _activePage(){var r,s;const n=this._activePage$.getValue();if(!n){const i=(r=this.getPageOrder())==null?void 0:r[0];return i?(s=this.getPages())==null?void 0:s[i]:null}return n}setName(n){var r;this._snapshot.title=n,this._name$.next(n),this._unitId=(r=this._snapshot.id)!=null?r:tt(6)}getRev(){return 0}incrementRev(){}setRev(n){}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var n;return(n=this._snapshot.body)==null?void 0:n.pages}getPageOrder(){var n;return(n=this._snapshot.body)==null?void 0:n.pageOrder}getPage(n){const r=this.getPages();return r==null?void 0:r[n]}getElementsByPage(n){var r;return(r=this.getPage(n))==null?void 0:r.pageElements}getElement(n,r){var s;return(s=this.getElementsByPage(n))==null?void 0:s[r]}getPageSize(){return this._snapshot.pageSize}getBlankPage(){const n=tt(6);return{id:n,pageType:fo.SLIDE,zIndex:10,title:n,description:"",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}setActivePage(n){this._activePage$.next(n)}getActivePage(){return this._activePage}updatePage(n,r){this._snapshot.body&&(this._snapshot.body.pages[n]=r)}appendPage(n){var i;if(!this._snapshot.body)return;this._snapshot.body.pages[n.id]=n;const r=this._activePage,s=this._snapshot.body.pageOrder.indexOf((i=r==null?void 0:r.id)!=null?i:"");this._snapshot.body.pageOrder.splice(s+1,0,n.id)}}var UR=Object.getOwnPropertyDescriptor,PR=(e,t,n,r)=>{for(var s=r>1?void 0:r?UR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Vh=(e,t)=>(n,r)=>t(n,r,e);const Xn=Re.createIdentifier("univer.current");f.UniverInstanceService=class extends ze{constructor(n,r){super();C(this,"_unitsByType",new Map);C(this,"_createHandler");C(this,"_ctorByType",new Map);C(this,"_currentUnits",new Map);C(this,"_currentUnits$",new oe.BehaviorSubject(this._currentUnits));C(this,"currentUnits$",this._currentUnits$.asObservable());C(this,"_unitAdded$",new oe.Subject);C(this,"unitAdded$",this._unitAdded$.asObservable());C(this,"_unitDisposed$",new oe.Subject);C(this,"unitDisposed$",this._unitDisposed$.asObservable());C(this,"_focused$",new oe.BehaviorSubject(null));C(this,"focused$",this._focused$.asObservable());this._injector=n,this._contextService=r}dispose(){super.dispose(),this._focused$.complete()}__setCreateHandler(n){this._createHandler=n}createUnit(n,r,s){return this._createHandler(n,r,this._ctorByType.get(n),s)}registerCtorForType(n,r){return this._ctorByType.set(n,r),{dispose:()=>{this._ctorByType.delete(n)}}}getCurrentTypeOfUnit$(n){return this.currentUnits$.pipe(oe.map(r=>{var s;return(s=r.get(n))!=null?s:null}),oe.distinctUntilChanged())}getCurrentUnitForType(n){return this._currentUnits.get(n)}getCurrentUnitOfType(n){return this.getCurrentUnitForType(n)}setCurrentUnitForType(n){const r=this._getUnitById(n);if(!r)throw new Error(`[UniverInstanceService]: no document with unitId ${n}!`);this._currentUnits.set(r[1],r[0]),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(n){return this._unitAdded$.pipe(oe.filter(r=>r.type===n))}__addUnit(n,r){var a;const s=n.type;this._unitsByType.has(s)||this._unitsByType.set(s,[]);const i=this._unitsByType.get(s),o=n.getUnitId();if(i.findIndex(l=>l.getUnitId()===o)!==-1)throw new Error(`[UniverInstanceService]: cannot create a unit with the same unit id: ${o}.`);i.push(n),this._unitAdded$.next(n),((a=r==null?void 0:r.makeCurrent)==null||a)&&this.setCurrentUnitForType(n.getUnitId())}getTypeOfUnitDisposed$(n){return this.unitDisposed$.pipe(oe.filter(r=>r.type===n))}getUnit(n,r){var i;const s=(i=this._getUnitById(n))==null?void 0:i[0];return r&&(s==null?void 0:s.type)!==r?null:s}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(we.UNIVER_DOC)}getUniverDocInstance(n){return this.getUnit(n,we.UNIVER_DOC)}getUniverSheetInstance(n){return this.getUnit(n,we.UNIVER_SHEET)}getAllUnitsForType(n){var r;return(r=this._unitsByType.get(n))!=null?r:[]}changeDoc(n,r){const s=this.getAllUnitsForType(we.UNIVER_DOC),i=s.find(o=>o.getUnitId()===n);if(i!=null){const o=s.indexOf(i);s.splice(o,1)}this.__addUnit(r)}get focused(){var r;const n=this._focused$.getValue();return n?(r=this._getUnitById(n))==null?void 0:r[0]:null}focusUnit(n){this._focused$.next(n),this.focused instanceof f.Workbook?(this._contextService.setContextValue(Br,!0),this._contextService.setContextValue($r,!1),this._contextService.setContextValue(Kn,!0),this._contextService.setContextValue(Hr,!1),this.setCurrentUnitForType(n)):this.focused instanceof At?(this._contextService.setContextValue(Br,!0),this._contextService.setContextValue($r,!0),this._contextService.setContextValue(Kn,!1),this._contextService.setContextValue(Hr,!1),this.setCurrentUnitForType(n)):this.focused instanceof ea?(this._contextService.setContextValue(Br,!0),this._contextService.setContextValue($r,!1),this._contextService.setContextValue(Kn,!1),this._contextService.setContextValue(Hr,!0),this.setCurrentUnitForType(n)):(this._contextService.setContextValue(Br,!1),this._contextService.setContextValue($r,!1),this._contextService.setContextValue(Kn,!1),this._contextService.setContextValue(Hr,!1))}getFocusedUnit(){return this.focused}getUnitType(n){const r=this._getUnitById(n);return r?r[1]:we.UNRECOGNIZED}disposeUnit(n){const r=this._getUnitById(n);if(!r)return!1;const[s,i]=r,o=this._unitsByType.get(i),a=o.indexOf(s);return o.splice(a,1),this._tryResetCurrentOnRemoval(n,i),this._tryResetFocusOnRemoval(n),this._unitDisposed$.next(s),!0}_tryResetCurrentOnRemoval(n,r){const s=this.getCurrentUnitForType(r);(s==null?void 0:s.getUnitId())===n&&(this._currentUnits.set(r,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(n){var r;((r=this.focused)==null?void 0:r.getUnitId())===n&&this._focused$.next(null)}_getUnitById(n){for(const[r,s]of this._unitsByType){const i=s.find(o=>o.getUnitId()===n);if(i)return[i,r]}}},f.UniverInstanceService=PR([Vh(0,Re.Inject(Re.Injector)),Vh(1,An)],f.UniverInstanceService);var ke=(e=>(e[e.Starting=0]="Starting",e[e.Ready=1]="Ready",e[e.Rendered=2]="Rendered",e[e.Steady=3]="Steady",e))(ke||{});const zh={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"};var kR=Object.getOwnPropertyDescriptor,FR=(e,t,n,r)=>{for(var s=r>1?void 0:r?kR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},xR=(e,t)=>(n,r)=>t(n,r,e);class Kh extends Error{constructor(t){super(`[LifecycleService]: lifecycle stage "${zh[t]}" will never be reached!`),this.name="LifecycleUnreachableError"}}f.LifecycleService=class extends ze{constructor(n){super();C(this,"_lifecycle$",new oe.BehaviorSubject(ke.Starting));C(this,"lifecycle$",this._lifecycle$.asObservable());C(this,"_lock",!1);this._logService=n,this._reportProgress(ke.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(n){if(this._lock)throw new Error("[LifecycleService]: cannot set new stage when related logic is all handled!");if(n<this.stage)throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");n!==this.stage&&(this._lock=!0,this._reportProgress(n),this._lifecycle$.next(n),this._lock=!1)}dispose(){this._lifecycle$.complete(),super.dispose()}onStage(n){return oe.firstValueFrom(this.lifecycle$.pipe(oe.filter(r=>r>=n),li(r=>r===n),oe.map(()=>{}))).catch(r=>r.name==="EmptyError"?Promise.reject(new Kh(n)):Promise.reject(r))}subscribeWithPrevious(){return oe.merge(Xh(this.stage),this._lifecycle$.pipe(oe.skip(1))).pipe(li(n=>n===ke.Steady))}_reportProgress(n){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${zh[n]}".`)}},f.LifecycleService=FR([xR(0,_t)],f.LifecycleService);function Xh(e){switch(e){case ke.Starting:return oe.of(ke.Starting);case ke.Ready:return oe.of(ke.Starting,ke.Ready);case ke.Rendered:return oe.of(ke.Starting,ke.Ready,ke.Rendered);default:return oe.of(ke.Starting,ke.Ready,ke.Rendered,ke.Steady)}}const BR=Re.createIdentifier("ILocalStorageService");class Sn extends ze{constructor(){super();C(this,"_currentLocale$",new oe.BehaviorSubject(ar.ZH_CN));C(this,"currentLocale$",this._currentLocale$.asObservable());C(this,"_locales",null);C(this,"localeChanged$",new oe.Subject);C(this,"t",(n,...r)=>{if(!this._locales)throw new Error("[LocaleService]: Locale not initialized");const s=n.split("."),i=this.resolveKeyPath(this._locales[this._currentLocale],s);if(typeof i=="string"){let o=i;return r.forEach((a,l)=>{o=o.replace(`{${l}}`,a)}),o}else return n});this.disposeWithMe(je(()=>{this._locales=null,this._currentLocale$.complete(),this.localeChanged$.complete()}))}get _currentLocale(){return this._currentLocale$.value}load(n){var r;this._locales=Xo((r=this._locales)!=null?r:{},n)}setLocale(n){this._currentLocale$.next(n),this.localeChanged$.next()}getLocales(){var n;return(n=this._locales)==null?void 0:n[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(n,r){const s=r.shift();if(s&&n&&s in n){const i=n[s];return r.length>0&&(typeof i=="object"||Array.isArray(i))?this.resolveKeyPath(i,r):i}return null}}var $R=Object.getOwnPropertyDescriptor,HR=(e,t,n,r)=>{for(var s=r>1?void 0:r?$R(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},WR=(e,t)=>(n,r)=>t(n,r,e);f.MentionIOLocalService=class{constructor(t){this._userManagerService=t}async list(t){return{list:[{type:es.PERSON,mentions:[{objectType:es.PERSON,objectId:this._userManagerService.getCurrentUser().userID,label:this._userManagerService.getCurrentUser().name,metadata:{icon:this._userManagerService.getCurrentUser().avatar}}],metadata:{},title:"PEOPLE"}],page:t.page,size:t.size,total:1}}},f.MentionIOLocalService=HR([WR(0,Re.Inject(Ur))],f.MentionIOLocalService);const qh=Re.createIdentifier("univer.service.mention-io");var ta=(e=>(e.INIT="init",e.FETCHING="fetching",e.DONE="done",e))(ta||{});const Zh=Re.createIdentifier("univer.permission-service");class Jh extends ze{constructor(){super(...arguments);C(this,"_permissionPointMap",new Map);C(this,"_permissionPointUpdate$",new oe.Subject);C(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable());C(this,"_showComponents",!0)}setShowComponents(n){this._showComponents=n}getShowComponents(){return this._showComponents}deletePermissionPoint(n){const r=this._permissionPointMap.get(n);r&&(r.complete(),this._permissionPointMap.delete(n))}addPermissionPoint(n){const r=n instanceof oe.BehaviorSubject,s=r?n.getValue():n;if(!s.id)return!1;if(this._permissionPointMap.get(s.id))throw new Error(`${s.id} PermissionPoint already exists`);return this._permissionPointMap.set(s.id,r?n:new oe.BehaviorSubject(s)),this._permissionPointUpdate$.next(s),!0}updatePermissionPoint(n,r){const s=this._permissionPointMap.get(n);if(!s)return;const i=s.getValue();i.value=r,i.status=ta.DONE,s.next(i),this._permissionPointUpdate$.next(i)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(n){const r=this._permissionPointMap.get(n);if(r)return r.getValue()}getPermissionPoint$(n){const r=this._permissionPointMap.get(n);if(r)return r}composePermission$(n){const r=n.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.asObservable()});return oe.combineLatest(r).pipe(Kr.map(s=>s))}composePermission(n){return n.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.getValue()})}getAllPermissionPoint(){const n=new Map;return this._permissionPointMap.forEach((r,s)=>{n.set(s,r)}),n}}function Qh(e,t){if(!t)return e;const n=[];for(const r of e){const s=t.find(([i])=>i===r[0]);if(s){if(s[1]===null)continue;n.push([r[0],s[1]])}else n.push(r)}return n}var jR=Object.getOwnPropertyDescriptor,YR=(e,t,n,r)=>{for(var s=r>1?void 0:r?jR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},na=(e,t)=>(n,r)=>t(n,r,e);const GR=4,ed=Symbol("DependentOn");class ra extends ze{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}C(ra,"pluginName"),C(ra,"type",we.UNIVER_UNKNOWN);class VR{constructor(){C(this,"_plugins",[])}addPlugin(t){this._plugins.push(t)}removePlugins(){const t=this._plugins.slice();return this._plugins.length=0,t}forEachPlugin(t){this._plugins.forEach(t)}}function zR(...e){return function(t){t[ed]=e}}f.PluginService=class{constructor(t,n,r){C(this,"_pluginRegistry",new Map);C(this,"_pluginStore",new VR);C(this,"_seenPlugins",new Set);C(this,"_loadedPlugins",new Set);C(this,"_loadedPluginTypes",new Set([we.UNIVER_UNKNOWN]));C(this,"_flushTimerByType",new Map);this._injector=t,this._lifecycleService=n,this._logService=r}dispose(){this._pluginStore.removePlugins().forEach(t=>t.dispose()),this._flushTimerByType.forEach(t=>clearTimeout(t))}registerPlugin(t,n){this._assertPluginValid(t);const r={plugin:t,options:n};this._pluginRegistry.set(t.pluginName,r),this._logService.debug("[PluginService]",`Plugin "${t.pluginName}" registered.`);const{type:s}=t;this._loadedPluginTypes.has(s)&&(s===we.UNIVER_UNKNOWN?this._loadFromPlugins([r]):this._flushType(s))}startPluginsForType(t){this._loadedPluginTypes.has(t)||this._loadPluginsForType(t)}_loadPluginsForType(t){const n=Array.from(this._pluginRegistry.keys()),r=[];n.forEach(s=>{const i=this._pluginRegistry.get(s);i.plugin.type===t&&r.push(i)}),this._loadFromPlugins(r),this._loadedPluginTypes.add(t)}_assertPluginValid(t){const{type:n,pluginName:r}=t;if(n===we.UNRECOGNIZED)throw new Error(`[PluginService]: invalid plugin type for ${t.name}. Please assign a "type" to your plugin.`);if(!r)throw new Error(`[PluginService]: no plugin name for ${t.name}. Please assign a "pluginName" to your plugin.`);if(this._seenPlugins.has(r))throw new Error(`[PluginService]: duplicated plugin name for "${r}". Maybe a plugin that dependents on "${r} has already registered it. In that case please register "${r}" before the that plugin.`);this._seenPlugins.add(t.pluginName)}_flushType(t){this._flushTimerByType.get(t)===void 0&&this._flushTimerByType.set(t,setTimeout(()=>{this._loadPluginsForType(t),this._flushTimerByType.delete(t)},GR))}_loadFromPlugins(t){const n=[],r=new Set,s=o=>{const{plugin:a}=o,{pluginName:l}=a;if(this._loadedPlugins.has(l)||r.has(l))return;r.add(l),this._pluginRegistry.delete(l);const c=a[ed];c&&c.forEach(u=>{const h=this._pluginRegistry.get(u.pluginName);if(h)s(h);else if(!this._seenPlugins.has(u.pluginName)&&!r.has(u.pluginName)){if(a.type===we.UNIVER_UNKNOWN&&u.type!==we.UNIVER_UNKNOWN)throw new Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${a.pluginName} and the dependency is ${u.pluginName}.`);a.type!==u.type&&u.type!==we.UNIVER_UNKNOWN&&this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${u.pluginName}" which has different type.`),this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${u.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(u),s({plugin:u,options:void 0})}}),n.push(o)};t.forEach(o=>s(o));const i=n.map(o=>this._initPlugin(o.plugin,o.options));this._pluginsRunLifecycle(i)}_pluginsRunLifecycle(t){const n=this._lifecycleService.stage;if(Xh(n).subscribe(r=>this._runStage(t,r)),n!==ke.Steady){const r=this._lifecycleService.lifecycle$.pipe(oe.skip(1)).subscribe(s=>{this._runStage(t,s),s===ke.Steady&&r.unsubscribe()})}}_runStage(t,n){t.forEach(r=>{switch(n){case ke.Starting:r.onStarting();break;case ke.Ready:r.onReady();break;case ke.Rendered:r.onRendered();break;case ke.Steady:r.onSteady();break}})}_initPlugin(t,n){const r=this._injector.createInstance(t,n);return this._pluginStore.addPlugin(r),this._loadedPlugins.add(t.pluginName),this._logService.debug("[PluginService]",`Plugin "${r.getPluginName()}" loaded.`),r}},f.PluginService=YR([na(0,Re.Inject(Re.Injector)),na(1,Re.Inject(f.LifecycleService)),na(2,_t)],f.PluginService);const sa=Re.createIdentifier("resource-loader-service");var KR=Object.getOwnPropertyDescriptor,XR=(e,t,n,r)=>{for(var s=r>1?void 0:r?KR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},qR=(e,t)=>(n,r)=>t(n,r,e);f.ResourceManagerService=class extends ze{constructor(n){super();C(this,"_resourceMap",new Map);C(this,"_register$",new oe.Subject);C(this,"register$",this._register$.asObservable());this._logService=n}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(n,r){return r?this.getResourcesByType(n,r):this.getAllResourceHooks().map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}getResourcesByType(n,r){return this.getAllResourceHooks().filter(o=>o.businesses.includes(r)).map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}registerPluginResource(n){const r=n.pluginName;if(this._resourceMap.has(r))throw new Error(`the pluginName is registered {${r}}`);return this._resourceMap.set(r,n),this._register$.next(n),je(()=>this._resourceMap.delete(r))}disposePluginResource(n){this._resourceMap.delete(n)}loadResources(n,r){this.getAllResourceHooks().forEach(s=>{var o;const i=(o=r==null?void 0:r.find(a=>a.name===s.pluginName))==null?void 0:o.data;if(i)try{const a=s.parseJson(i);s.onLoad(n,a)}catch(a){this._logService.error("[ResourceManagerService]","loadResources error",a)}})}unloadResources(n){this.getAllResourceHooks().forEach(r=>{r.onUnLoad(n)})}dispose(){this._register$.complete(),this._resourceMap.clear()}},f.ResourceManagerService=XR([qR(0,_t)],f.ResourceManagerService);class qs extends ze{constructor(){super();C(this,"_darkMode$",new oe.BehaviorSubject(!1));C(this,"darkMode$",this._darkMode$.asObservable());C(this,"_validColorCache",new Map);C(this,"_currentTheme",Xr.defaultTheme);C(this,"_currentTheme$",new oe.BehaviorSubject(this._currentTheme));C(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(je(()=>{this._currentTheme=Xr.defaultTheme,this._currentTheme$.complete(),this._darkMode$.complete()}))}get darkMode(){return this._darkMode$.getValue()}isValidThemeColor(n){if(this._validColorCache.has(n))return this._validColorCache.get(n);let r=!1;const s=n.split(".");if(s.length===1)r=n in Xr.defaultTheme;else if(s.length===2){const[i,o]=s;r=i in Xr.defaultTheme&&o in this._currentTheme[i]}return this._validColorCache.set(n,r),r}getCurrentTheme(){return this._currentTheme}setTheme(n){this._currentTheme=n,this._currentTheme$.next(n)}setDarkMode(n){this._darkMode$.next(n)}getColorFromTheme(n){return ph(this._currentTheme,n)}}var ZR=Object.getOwnPropertyDescriptor,JR=(e,t,n,r)=>{for(var s=r>1?void 0:r?ZR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},ia=(e,t)=>(n,r)=>t(n,r,e);const Zs=Re.createIdentifier("univer.undo-redo.service"),QR=20;class td{dispose(){}async dispatchToHandlers(){return!1}}const nd="univer.command.redo",rd="univer.command.undo",sd=new class extends td{constructor(){super(...arguments);C(this,"type",rr.COMMAND);C(this,"id",rd)}handler(t){const n=t.get(Zs),r=n.pitchTopUndoElement();if(!r)return!1;const s=t.get(sr);return Qr(r.undoMutations,s)?(n.popUndoToRedo(),!0):!1}},id=new class extends td{constructor(){super(...arguments);C(this,"type",rr.COMMAND);C(this,"id",nd)}handler(t){const n=t.get(Zs),r=n.pitchTopRedoElement();if(!r)return!1;const s=t.get(sr);return Qr(r.redoMutations,s)?(n.popRedoToUndo(),!0):!1}};f.LocalUndoRedoService=class extends ze{constructor(n,r,s){super();C(this,"undoRedoStatus$");C(this,"_undoRedoStatus$",new oe.BehaviorSubject({undos:0,redos:0}));C(this,"_undoStacks",new Map);C(this,"_redoStacks",new Map);C(this,"_batchingStatus",new Map);this._univerInstanceService=n,this._commandService=r,this._contextService=s,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(sd)),this.disposeWithMe(this._commandService.registerCommand(id)),this.disposeWithMe(je(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(je(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(n){const{unitID:r}=n,s=this._getRedoStack(r,!0),i=this._getUndoStack(r,!0);if(s.length=0,this._batchingStatus.has(n.unitID)){const a=this._batchingStatus.get(n.unitID),l=this._pitchUndoElement(n.unitID);a===0||!l?(o(n),this._batchingStatus.set(n.unitID,1)):this._tryBatchingElements(l,n)}else o(n);function o(a){i.push(a),i.length>QR&&i.splice(0,1)}this._updateStatus()}clearUndoRedo(n){const r=this._getRedoStack(n);r&&(r.length=0);const s=this._getUndoStack(n);s&&(s.length=0),this._updateStatus()}pitchTopUndoElement(){const n=this._getFocusedUnitId();return this._pitchUndoElement(n)}pitchTopRedoElement(){const n=this._getFocusedUnitId();return this._pitchRedoElement(n)}_pitchUndoElement(n){const r=this._getUndoStack(n);return r!=null&&r.length?r[r.length-1]:null}_pitchRedoElement(n){const r=this._getRedoStack(n);return r!=null&&r.length?r[r.length-1]:null}popUndoToRedo(){const r=this._getUndoStackForFocused().pop();r&&(this._getRedoStackForFocused().push(r),this._updateStatus())}popRedoToUndo(){const r=this._getRedoStackForFocused().pop();r&&(this._getUndoStackForFocused().push(r),this._updateStatus())}rollback(n,r){const s=r||this._getFocusedUnitId(),i=this._getUndoStack(s),o=i==null?void 0:i[(i==null?void 0:i.length)-1];o&&o.id===n&&(i.pop(),Qr(o.undoMutations,this._commandService))}__tempBatchingUndoRedo(n){if(this._batchingStatus.has(n))throw new Error("[LocalUndoRedoService]: cannot batching undo redo twice at the same time!");return this._batchingStatus.set(n,0),je(()=>this._batchingStatus.delete(n))}_updateStatus(){var i,o;const n=this._getFocusedUnitId(),r=n&&((i=this._undoStacks.get(n))==null?void 0:i.length)||0,s=n&&((o=this._redoStacks.get(n))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:r,redos:s})}_getUndoStack(n,r=!1){let s=this._undoStacks.get(n);return!s&&r&&(s=[],this._undoStacks.set(n,s)),s||null}_getRedoStack(n,r=!1){let s=this._redoStacks.get(n);return!s&&r&&(s=[],this._redoStacks.set(n,s)),s||null}_getUndoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getUndoStack(n,!0)}_getRedoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getRedoStack(n,!0)}_tryBatchingElements(n,r){n.redoMutations.push(...r.redoMutations),n.undoMutations.push(...r.undoMutations)}_getFocusedUnitId(){var o,a,l,c;let n="";const r=this._contextService.getContextValue(Kn),s=this._contextService.getContextValue(bh),i=this._contextService.getContextValue(wh);return r?s?n=ri:i?n=ni:n=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":n=(c=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?c:"",n}},f.LocalUndoRedoService=JR([ia(0,Xn),ia(1,sr),ia(2,An)],f.LocalUndoRedoService);class od{constructor(t,n=100){C(this,"_imageCacheMap");this._injector=t,this._imageCacheMap=new ur(n)}_getImageCacheKey(t,n){return`${t}-${n}`}getImage(t,n,r,s){const i=this._getImageCacheKey(t,n),o=this._imageCacheMap.get(i);return o||((async()=>{const a=new Image,l=this._injector.has(Jo)?this._injector.get(Jo):null;if(t===Zo.UUID)try{a.src=await(l==null?void 0:l.getImage(n))||""}catch(c){console.error(c)}else a.src=n;a.onload=()=>{a.removeAttribute("data-error"),r==null||r()},a.onerror=()=>{a.setAttribute("data-error","true"),s==null||s()},this._imageCacheMap.set(i,a)})(),null)}}function eI(e){return!(e.length===0||e.length>31||e.startsWith("'")||e.endsWith("'")||/[:\\\/\?\*\[\]]/.test(e))}const ad=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],oa=1,Yr=8;class aa{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[n,r]=new Uint8Array(t,0,2);if(n!==219)throw new Error("Data does not appear to be in a KDBush format.");const s=r>>4;if(s!==oa)throw new Error(`Got v${s} data when expected v${oa}.`);const i=ad[r&15];if(!i)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new aa(a,o,i,t)}constructor(t,n=64,r=Float64Array,s){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+n,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=ad.indexOf(this.ArrayType),o=t*2*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);s&&s instanceof ArrayBuffer?(this.data=s,this.ids=new this.IndexArrayType(this.data,Yr,t),this.coords=new this.ArrayType(this.data,Yr+a+l,t*2),this._pos=t*2,this._finished=!0):(this.data=new ArrayBuffer(Yr+o+a+l),this.ids=new this.IndexArrayType(this.data,Yr,t),this.coords=new this.ArrayType(this.data,Yr+a+l,t*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(oa<<4)+i]),new Uint16Array(this.data,2,1)[0]=n,new Uint32Array(this.data,4,1)[0]=t)}add(t,n){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=n,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return la(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,n,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:o,nodeSize:a}=this,l=[0,i.length-1,0],c=[];for(;l.length;){const u=l.pop()||0,h=l.pop()||0,d=l.pop()||0;if(h-d<=a){for(let I=d;I<=h;I++){const A=o[2*I],B=o[2*I+1];A>=t&&A<=r&&B>=n&&B<=s&&c.push(i[I])}continue}const m=d+h>>1,_=o[2*m],p=o[2*m+1];_>=t&&_<=r&&p>=n&&p<=s&&c.push(i[m]),(u===0?t<=_:n<=p)&&(l.push(d),l.push(m-1),l.push(1-u)),(u===0?r>=_:s>=p)&&(l.push(m+1),l.push(h),l.push(1-u))}return c}within(t,n,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:i,nodeSize:o}=this,a=[0,s.length-1,0],l=[],c=r*r;for(;a.length;){const u=a.pop()||0,h=a.pop()||0,d=a.pop()||0;if(h-d<=o){for(let I=d;I<=h;I++)cd(i[2*I],i[2*I+1],t,n)<=c&&l.push(s[I]);continue}const m=d+h>>1,_=i[2*m],p=i[2*m+1];cd(_,p,t,n)<=c&&l.push(s[m]),(u===0?t-r<=_:n-r<=p)&&(a.push(d),a.push(m-1),a.push(1-u)),(u===0?t+r>=_:n+r>=p)&&(a.push(m+1),a.push(h),a.push(1-u))}return l}}function la(e,t,n,r,s,i){if(s-r<=n)return;const o=r+s>>1;ld(e,t,o,r,s,i),la(e,t,n,r,o-1,1-i),la(e,t,n,o+1,s,1-i)}function ld(e,t,n,r,s,i){for(;s>r;){if(s-r>600){const c=s-r+1,u=n-r+1,h=Math.log(c),d=.5*Math.exp(2*h/3),m=.5*Math.sqrt(h*d*(c-d)/c)*(u-c/2<0?-1:1),_=Math.max(r,Math.floor(n-u*d/c+m)),p=Math.min(s,Math.floor(n+(c-u)*d/c+m));ld(e,t,n,_,p,i)}const o=t[2*n+i];let a=r,l=s;for(Gr(e,t,r,n),t[2*s+i]>o&&Gr(e,t,r,s);a<l;){for(Gr(e,t,a,l),a++,l--;t[2*a+i]<o;)a++;for(;t[2*l+i]>o;)l--}t[2*r+i]===o?Gr(e,t,r,l):(l++,Gr(e,t,l,s)),l<=n&&(r=l+1),n<=l&&(s=l-1)}}function Gr(e,t,n,r){ca(e,n,r),ca(t,2*n,2*r),ca(t,2*n+1,2*r+1)}function ca(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function cd(e,t,n,r){const s=e-n,i=t-r;return s*s+i*i}class tI{constructor(t=!1){C(this,"_tree",new Map);C(this,"_oneCellCache",new Map);C(this,"_kdTree",new Map);this._enableOneCellCache=t}dispose(){this.clear()}getTree(t,n){return this._tree.has(t)||this._tree.set(t,new Map),this._tree.get(t).has(n)||this._tree.get(t).set(n,new Ms),this._tree.get(t).get(n)}_getOneCellCache(t,n,r,s){return this._oneCellCache.has(t)||this._oneCellCache.set(t,new Map),this._oneCellCache.get(t).has(n)||this._oneCellCache.get(t).set(n,new Map),this._oneCellCache.get(t).get(n).has(r)||this._oneCellCache.get(t).get(n).set(r,new Map),this._oneCellCache.get(t).get(n).get(r).has(s)||this._oneCellCache.get(t).get(n).get(r).set(s,new Set),this._oneCellCache.get(t).get(n).get(r).get(s)}_removeOneCellCache(t,n,r,s,i){const o=this._oneCellCache.get(t);if(!o)return;const a=o.get(n);if(!a)return;const l=a.get(r);if(!l)return;const c=l.get(s);c&&c.delete(i)}_removeCellCacheByRange(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this._oneCellCache.get(n);if(!o)return;const a=o.get(r);if(!a)return;const{startRow:l,startColumn:c,endRow:u,endColumn:h}=s;for(let d=l;d<=u;d++){const m=a.get(d);if(m)for(let _=c;_<=h;_++){const p=m.get(_);p&&p.delete(i)}}}_insertOneCellCache(t,n,r,s,i){this._getOneCellCache(t,n,r,s).add(i)}_getRdTreeItems(t){const n=[];for(const[r,s]of t)for(const[i,o]of s)n.push({x:i,y:r,ids:o});return n}_searchByOneCellCache(t){var _;const{unitId:n,sheetId:r,range:s}=t,{startRow:i,startColumn:o,endRow:a,endColumn:l}=s,c=(_=this._kdTree.get(n))==null?void 0:_.get(r);if(!c)return[];const{tree:u,items:h}=c,d=u.range(o,i,l,a),m=[];for(const p of d){const I=h[p];m.push(...Array.from(I.ids))}return m}openKdTree(){var t;for(const[n,r]of this._oneCellCache){this._kdTree.has(n)||this._kdTree.set(n,new Map);for(const[s,i]of r){const o=this._getRdTreeItems(i),a=new aa(o.length);(t=this._kdTree.get(n))==null||t.set(s,{tree:a,items:o});for(const l of o)a.add(l.x,l.y);a.finish()}}}closeKdTree(){var t;for(const[n,r]of this._oneCellCache)for(const[s,i]of r)(t=this._kdTree.get(n))==null||t.set(s,void 0)}insert(t){const{unitId:n,sheetId:r,range:s,id:i}=t;if(!n||n.length===0)return;let{startRow:o,endRow:a,startColumn:l,endColumn:c}=s;if(this._enableOneCellCache&&o===a&&l===c){this._insertOneCellCache(n,r,o,l,i);return}const u=this.getTree(n,r);Number.isNaN(o)&&(o=0),Number.isNaN(l)&&(l=0),Number.isNaN(a)&&(a=Number.POSITIVE_INFINITY),Number.isNaN(c)&&(c=Number.POSITIVE_INFINITY),u.insert({minX:l,minY:o,maxX:c,maxY:a,id:i})}bulkInsert(t){for(const n of t)this.insert(n)}*searchGenerator(t){var a;const{unitId:n,sheetId:r,range:s}=t;if(this._enableOneCellCache){const l=this._searchByOneCellCache(t);for(const c of l)yield c}const i=(a=this._tree.get(n))==null?void 0:a.get(r);if(!i)return;const o=i.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(const l of o)yield l.id}bulkSearch(t,n){const r=new Set;for(const s of t)for(const i of this.searchGenerator(s))(n==null?void 0:n.has(i))!==!0&&r.add(i);return r}removeById(t,n){var r,s;n?((r=this._tree.get(t))==null||r.delete(n),(s=this._oneCellCache.get(t))==null||s.delete(n)):(this._tree.delete(t),this._oneCellCache.delete(t))}_removeRTreeItem(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this.getTree(n,r),a=o.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(let l=0;l<a.length;l++)a[l].id===i&&o.remove(a[l])}remove(t){const{unitId:n,sheetId:r,range:s,id:i}=t,{startRow:o,startColumn:a,endRow:l,endColumn:c}=s;this._enableOneCellCache?o===l&&a===c?this._removeOneCellCache(n,r,s.startRow,s.startColumn,i):(this._removeCellCacheByRange(t),this._removeRTreeItem(t)):this._removeRTreeItem(t)}bulkRemove(t){for(const n of t)this.remove(n)}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){const t={};return this._tree.forEach((n,r)=>{t[r]={},n.forEach((s,i)=>{t[r][i]=s.toJSON()})}),t}fromJSON(t){this._tree.clear();for(const n in t){this._tree.set(n,new Map);for(const r in t[n]){const s=new Ms;s.fromJSON(t[n][r]),this._tree.get(n).set(r,s)}}}}function nI(e){return new Promise(t=>setTimeout(t,e))}function rI(e=1){return new Promise(t=>{let n=0;const r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}var sI=Object.getOwnPropertyDescriptor,iI=(e,t,n,r)=>{for(var s=r>1?void 0:r?sI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},oI=(e,t)=>(n,r)=>t(n,r,e);f.Skeleton=class extends ze{constructor(n){super();C(this,"_fontLocale");C(this,"_dirty",!0);this._localeService=n,this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(n){this._dirty=n}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}},f.Skeleton=iI([oI(0,Re.Inject(Sn))],f.Skeleton);var aI=Object.getOwnPropertyDescriptor,lI=(e,t,n,r)=>{for(var s=r>1?void 0:r?aI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Js=(e,t)=>(n,r)=>t(n,r,e);f.SheetSkeleton=class extends f.Skeleton{constructor(n,r,s,i,o,a){super(s);C(this,"_worksheetData");C(this,"_renderRawFormula",!1);C(this,"_cellData");C(this,"_imageCacheMap");C(this,"_skipAutoHeightForMergedCells",!0);C(this,"_rowTotalHeight",0);C(this,"_columnTotalWidth",0);C(this,"_rowHeaderWidth",0);C(this,"_columnHeaderHeight",0);C(this,"_rowHeightAccumulation",[]);C(this,"_columnWidthAccumulation",[]);C(this,"_marginTop",0);C(this,"_marginLeft",0);C(this,"_scaleX");C(this,"_scaleY");C(this,"_scrollX");C(this,"_scrollY");this.worksheet=n,this._styles=r,this._contextService=i,this._configService=o,this._injector=a,this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new od(this._injector),this.initConfig()}initConfig(){var n,r;this._skipAutoHeightForMergedCells=!((n=this._configService.getConfig(Ea))!=null&&n),this.worksheet.setIsRowStylePrecedeColumnStyle((r=this._configService.getConfig(pa))!=null?r:!1)}resetCache(){}getWorksheetConfig(){return this._worksheetData}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(n){this._columnHeaderHeight=n,this._worksheetData.columnHeader.height=n}set rowHeaderWidth(n){this._rowHeaderWidth=n,this._worksheetData.rowHeader.width=n}get rowHeightAccumulation(){return this._rowHeightAccumulation}get rowTotalHeight(){return this._rowTotalHeight}get columnWidthAccumulation(){return this._columnWidthAccumulation}get columnTotalWidth(){return this._columnTotalWidth}get rowHeaderWidth(){return this._rowHeaderWidth}get columnHeaderHeight(){return this._columnHeaderHeight}setMarginLeft(n){this._marginLeft=n}setMarginTop(n){this._marginTop=n}setScale(n,r){this._updateLayout(),this._scaleX=n,this._scaleY=r||n,this._updateLayout()}setScroll(n,r){Z.isDefine(n)&&(this._scrollX=n),Z.isDefine(r)&&(this._scrollY=r)}get scrollX(){return this._scrollX}get scrollY(){return this._scrollY}get scaleX(){return this._scaleX}get scaleY(){return this._scaleY}get rowHeaderWidthAndMarginLeft(){return this.rowHeaderWidth+this._marginLeft}get columnHeaderHeightAndMarginTop(){return this.columnHeaderHeight+this._marginTop}get imageCacheMap(){return this._imageCacheMap}_generateRowMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let c=s;if(this.worksheet.getRowFiltered(l))c=0;else if(a[l]!=null){const u=a[l];if(!u)continue;const{h=s,ah:d,ia:m}=u;(m==null||m===ae.TRUE)&&typeof d=="number"?c=d:c=h,u.hd===ae.TRUE&&(c=0)}i+=c,o.push(i)}return{rowTotalHeight:i,rowHeightAccumulation:o}}_generateColumnMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let c=s;if(a[l]!=null){const u=a[l];if(!u)continue;u.w!=null&&(c=u.w),u.hd===ae.TRUE&&(c=0)}i+=c,o.push(i)}return{columnTotalWidth:i,columnWidthAccumulation:o}}intersectMergeRange(n,r){return!!this.worksheet.getMergedCell(n,r)}_getOverflowBound(n,r,s,i,o=Ot.LEFT){let a=0;if(r>s){const l=this._columnWidthAccumulation.length-1;for(let c=r;c>=s;c--){const u=c,h=this.worksheet.getCell(n,u);if(!pi(h)&&u!==r||this.intersectMergeRange(n,u))return u===r?u:u+1>l?l:u+1;const{startX:d,endX:m}=qn(n,u,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===Ot.CENTER&&u===r?a+=(m-d)/2:a+=m-d,i<a)return u}return r}for(let l=r;l<=s;l++){const c=l,u=this.worksheet.getCell(n,c);if(!pi(u)&&c!==r||this.intersectMergeRange(n,c))return c===r?c:c-1<0?0:c-1;const{startX:h,endX:d}=qn(n,c,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===Ot.CENTER&&c===r?a+=(d-h)/2:a+=d-h,i<a)return c}return s}_updateLayout(){if(!this.dirty)return;const{rowData:n,columnData:r,defaultRowHeight:s,defaultColumnWidth:i,rowCount:o,columnCount:a,rowHeader:l,columnHeader:c}=this._worksheetData,{rowTotalHeight:u,rowHeightAccumulation:h}=this._generateRowMatrixCache(o,n,s),{columnTotalWidth:d,columnWidthAccumulation:m}=this._generateColumnMatrixCache(a,r,i);this._rowHeaderWidth=l.hidden!==ae.TRUE?this._dynamicallyUpdateRowHeaderWidth(l):0,this._columnHeaderHeight=c.hidden!==ae.TRUE?c.height:0,this._rowTotalHeight=u,this._rowHeightAccumulation=h,this._columnTotalWidth=d,this._columnWidthAccumulation=m,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(n){}_dynamicallyUpdateRowHeaderWidth(n){const s=`${this.worksheet.getRowCount()}`.length*8;return Math.max(n.width,s)}_hasUnMergedCellInRow(n,r,s){if(!this.worksheet.getMergeData())return!1;for(let o=r;o<=s;o++){const{isMerged:a,isMergedMainCell:l}=this.worksheet.getCellInfoInMergeData(n,o);if(!a&&!l)return!0}return!1}expandRangeByMerge(n){let{startRow:r,startColumn:s,endRow:i,endColumn:o}=n;const a=this._worksheetData.mergeData;if(!a)return{startRow:r,startColumn:s,endRow:i,endColumn:o};let l=!0;const c=new ct;for(;l;){l=!1;for(let u=0;u<a.length;u++){const{startRow:h,startColumn:d,endRow:m,endColumn:_}=a[u];if(c.getValue(h,d))continue;Yc({startColumn:s,startRow:r,endColumn:o,endRow:i},{startColumn:d,startRow:h,endColumn:_,endRow:m})&&(r=Math.min(r,h),s=Math.min(s,d),i=Math.max(i,m),o=Math.max(o,_),c.setValue(h,d,!0),l=!0)}}return{startRow:r,startColumn:s,endRow:i,endColumn:o}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(n,r){return this.worksheet.getCellInfoInMergeData(n,r)}getNoMergeCellPositionByIndex(n,r,s=!0){return this.getNoMergeCellWithCoordByIndex(n,r,s)}getNoMergeCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this;let{startY:c,endY:u,startX:h,endX:d}=qn(n,r,i,o);return s&&(c+=l,u+=l,h+=a,d+=a),{startY:c,endY:u,startX:h,endX:d}}getNoMergeCellPositionByIndexWithNoHeader(n,r){const{rowHeightAccumulation:s,columnWidthAccumulation:i}=this,{startY:o,endY:a,startX:l,endX:c}=qn(n,r,s,i);return{startY:o,endY:a,startX:l,endX:c}}getRowIndexByOffsetY(n,r,s,i){var l;const{rowHeightAccumulation:o}=this;n=hd(n,r,s,this.columnHeaderHeightAndMarginTop);let a=ir(o,n,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(o[a]-n)<Math.abs(n-((l=o[a-1])!=null?l:0))&&(a=a+1),a}getColumnIndexByOffsetX(n,r,s,i){var c;const o=ud(n,r,s,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this;let l=ir(a,o,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(a[l]-o)<Math.abs(o-((c=a[l-1])!=null?c:0))&&(l=l+1),l}getCellIndexByOffset(n,r,s,i,o,a){const l=this.getRowIndexByOffsetY(r,i,o,a),c=this.getColumnIndexByOffsetX(n,s,o,a);return{row:l,column:c}}getCellByOffset(n,r,s,i,o){const a=this==null?void 0:this.getCellIndexByOffset(n,r,s,i,o,{firstMatch:!0});return a?this.worksheet.getCellInfoInMergeData(a.row,a.column):null}getCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this,c=qn(n,r,i,o,this.worksheet.getCellInfoInMergeData(n,r)),{isMerged:u,isMergedMainCell:h}=c;let{startY:d,endY:m,startX:_,endX:p,mergeInfo:I}=c,A=a,B=l;return s===!1&&(A=0,B=0),d+=B,m+=B,_+=A,p+=A,I.startY+=B,I.endY+=B,I.startX+=A,I.endX+=A,{actualRow:n,actualColumn:r,startX:_,startY:d,endX:p,endY:m,isMerged:u,isMergedMainCell:h,mergeInfo:I}}getCellWithCoordByOffset(n,r,s,i,o,a){const{row:l,column:c}=this.getCellIndexByOffset(n,r,s,i,o,a);return this.getCellWithCoordByIndex(l,c)}getOffsetByColumn(n){const{columnWidthAccumulation:r,rowHeaderWidthAndMarginLeft:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetByRow(n){const{rowHeightAccumulation:r,columnHeaderHeightAndMarginTop:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetRelativeToRowCol(n,r){const s=ir(this.columnWidthAccumulation,n);let i=0;s===0?i=n:i=n-this._columnWidthAccumulation[s-1];const o=ir(this.rowHeightAccumulation,r);let a=0;return o===0?a=r:a=r-this._rowHeightAccumulation[o-1],{row:o,column:s,columnOffset:i,rowOffset:a}}_updateConfigAndGetDocumentModel(n,r,s,i){var a,l,c,u,h;if(!i||!((a=n.body)!=null&&a.dataStream))return;n.documentStyle||(n.documentStyle={}),n.documentStyle.marginTop=(l=s.t)!=null?l:0,n.documentStyle.marginBottom=(c=s.b)!=null?c:2,n.documentStyle.marginLeft=(u=s.l)!=null?u:2,n.documentStyle.marginRight=(h=s.r)!=null?h:2,n.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},n.documentStyle.renderConfig={...n.documentStyle.renderConfig,...i};const o=n.body.paragraphs||[];for(const d of o)d.paragraphStyle||(d.paragraphStyle={}),d.paragraphStyle.horizontalAlign=r;return new At(n)}dispose(){super.dispose(),this._rowHeightAccumulation=[],this._columnWidthAccumulation=[],this._rowTotalHeight=0,this._columnTotalWidth=0,this._rowHeaderWidth=0,this._columnHeaderHeight=0,this._worksheetData=null,this._cellData=null,this._styles=null}},f.SheetSkeleton=lI([Js(2,Re.Inject(Sn)),Js(3,An),Js(4,qo),Js(5,Re.Inject(Re.Injector))],f.SheetSkeleton);function ua(e,t,n,r){const s=e-1,i=t-1,o=n[s]||0;let a=n[e];a==null&&(a=n[n.length-1]);const l=r[i]||0;let c=r[t];return c==null&&(c=r[r.length-1]),{startY:o,endY:a,startX:l,endX:c}}function cI(e,t,n,r){return ua(e,t,n,r)}function qn(e,t,n,r,s){e=Z.clamp(e,0,n.length-1),t=Z.clamp(t,0,r.length-1);let{startY:i,endY:o,startX:a,endX:l}=ua(e,t,n,r);if(!s)return{startY:i,endY:o,startX:a,endX:l,isMerged:!1,isMergedMainCell:!1,actualRow:e,actualColumn:t,mergeInfo:{startY:i,endY:o,startX:a,endX:l,startRow:e,startColumn:t,endRow:e,endColumn:t}};const{isMerged:c,isMergedMainCell:u,startRow:h,startColumn:d,endRow:m,endColumn:_}=s;let p={startRow:h,startColumn:d,endRow:m,endColumn:_,startY:i,endY:o,startX:a,endX:l};const I=n.length-1,A=r.length-1;if(c&&h!==-1&&d!==-1){const B=n[h-1]||0,x=n[m]||n[I],Y=r[d-1]||0,O=r[_]||r[A];p={...p,startY:B,endY:x,startX:Y,endX:O}}else if(!c&&m!==-1&&_!==-1){const B=n[m]||n[I],x=r[_]||r[A];p={...p,startY:i,endY:B,startX:a,endX:x}}return{isMerged:c,isMergedMainCell:u,actualRow:e,actualColumn:t,startY:i,endY:o,startX:a,endX:l,mergeInfo:p}}function ud(e,t,n,r){const{x:s}=n;return e/t+s-r}function hd(e,t,n,r){const{y:s}=n;return e=e/t+s-r,e}const uI=["script","style","meta","comment","link"];var dd=(e=>(e[e.INFO=0]="INFO",e[e.STOP=1]="STOP",e[e.WARNING=2]="WARNING",e))(dd||{}),fd=(e=>(e[e.DISABLED=0]="DISABLED",e[e.FULL_ALPHA=1]="FULL_ALPHA",e[e.FULL_HANGUL=2]="FULL_HANGUL",e[e.FULL_KATAKANA=3]="FULL_KATAKANA",e[e.HALF_ALPHA=4]="HALF_ALPHA",e[e.HALF_HANGUL=5]="HALF_HANGUL",e[e.HALF_KATAKANA=6]="HALF_KATAKANA",e[e.HIRAGANA=7]="HIRAGANA",e[e.NO_CONTROL=8]="NO_CONTROL",e[e.OFF=9]="OFF",e[e.ON=10]="ON",e))(fd||{}),md=(e=>(e.BETWEEN="between",e.EQUAL="equal",e.GREATER_THAN="greaterThan",e.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",e.LESS_THAN="lessThan",e.LESS_THAN_OR_EQUAL="lessThanOrEqual",e.NOT_BETWEEN="notBetween",e.NOT_EQUAL="notEqual",e))(md||{}),gd=(e=>(e[e.TEXT=0]="TEXT",e[e.ARROW=1]="ARROW",e[e.CUSTOM=2]="CUSTOM",e))(gd||{}),_d=(e=>(e.VALID="valid",e.INVALID="invalid",e.VALIDATING="validating",e))(_d||{}),pd=(e=>(e.CUSTOM="custom",e.LIST="list",e.LIST_MULTIPLE="listMultiple",e.NONE="none",e.TEXT_LENGTH="textLength",e.DATE="date",e.TIME="time",e.WHOLE="whole",e.DECIMAL="decimal",e.CHECKBOX="checkbox",e.ANY="any",e))(pd||{}),hI=Object.getOwnPropertyDescriptor,dI=(e,t,n,r)=>{for(var s=r>1?void 0:r?hI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Ed=(e,t)=>(n,r)=>t(n,r,e);let ha=class extends ze{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){const e=n=>{n.businesses.forEach(r=>{switch(r){case we.UNRECOGNIZED:case we.UNIVER_UNKNOWN:case we.UNIVER_SLIDE:case we.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType(we.UNIVER_DOC).forEach(s=>{const o=(s.getSnapshot().resources||[]).find(a=>a.name===n.pluginName);if(o)try{const a=n.parseJson(o.data);n.onLoad(s.getUnitId(),a)}catch{console.error(`Load Document{${s.getUnitId()}} Resources{${n.pluginName}} Data Error.`)}});break}case we.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(we.UNIVER_SHEET).forEach(s=>{const o=(s.getSnapshot().resources||[]).find(a=>a.name===n.pluginName);if(o)try{const a=n.parseJson(o.data);n.onLoad(s.getUnitId(),a)}catch{console.error(`Load Workbook{${s.getUnitId()}} Resources{${n.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(n=>e(n)),this.disposeWithMe(this._resourceManagerService.register$.subscribe(n=>e(n))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(we.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(we.UNIVER_DOC).subscribe(n=>{const r=n.getUnitId();Ca(r)||this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(we.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(we.UNIVER_DOC).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())}))}saveUnit(e){const t=this._univerInstanceService.getUnit(e);if(!t)return null;const n=this._resourceManagerService.getResources(e,t.type),r=Z.deepClone(t.getSnapshot());return r.resources=n,r}};ha=dI([Ed(0,Re.Inject(js)),Ed(1,Re.Inject(Xn))],ha);class fI{constructor(t={},n){C(this,"_startedTypes",new Set);C(this,"_injector");C(this,"_disposingCallbacks",new Jr);const r=this._injector=mI(n,t==null?void 0:t.override),{theme:s,darkMode:i,locale:o,locales:a,logLevel:l}=t;s&&this._injector.get(qs).setTheme(s),i&&this._injector.get(qs).setDarkMode(i),a&&this._injector.get(Sn).load(a),o&&this._injector.get(Sn).setLocale(o),l&&this._injector.get(_t).setLogLevel(l),this._init(r)}get _univerInstanceService(){return this._injector.get(Xn)}get _pluginService(){return this._injector.get(f.PluginService)}__getInjector(){return this._injector}onDispose(t){const n=this._disposingCallbacks.add(je(t));return je(()=>n.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(t){this._injector.get(Sn).setLocale(t)}createUnit(t,n){return this._univerInstanceService.createUnit(t,n)}createUniverSheet(t){return this._injector.get(_t).warn("[Univer]","Univer.createUniverSheet is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(we.UNIVER_SHEET,t)}createUniverDoc(t){return this._injector.get(_t).warn("[Univer]","Univer.createUniverDoc is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(we.UNIVER_DOC,t)}createUniverSlide(t){return this._injector.get(_t).warn("[Univer]","Univer.createUniverSlide is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(we.UNIVER_SLIDE,t)}_init(t){this._univerInstanceService.registerCtorForType(we.UNIVER_SHEET,f.Workbook),this._univerInstanceService.registerCtorForType(we.UNIVER_DOC,At),this._univerInstanceService.registerCtorForType(we.UNIVER_SLIDE,ea);const n=t.get(Xn);n.__setCreateHandler((r,s,i,o)=>{if(!this._startedTypes.has(r)){this._pluginService.startPluginsForType(r),this._startedTypes.add(r);const l=t.createInstance(i,s);return n.__addUnit(l,o),this._tryProgressToReady(),l}const a=t.createInstance(i,s);return n.__addUnit(a,o),a})}_tryProgressToReady(){this._injector.get(f.LifecycleService).stage<ke.Ready&&(this._injector.get(f.LifecycleService).stage=ke.Ready)}registerPlugin(t,n){this._pluginService.registerPlugin(t,n)}}function mI(e,t){const n=Qh([[Ah],[Sn],[qs],[f.LifecycleService],[f.PluginService],[Ur],[Xn,{useClass:f.UniverInstanceService}],[Zh,{useClass:Jh}],[_t,{useClass:Ma,lazy:!0}],[sr,{useClass:f.CommandService}],[Zs,{useClass:f.LocalUndoRedoService,lazy:!0}],[qo,{useClass:vh}],[An,{useClass:ya}],[js,{useClass:f.ResourceManagerService,lazy:!0}],[sa,{useClass:ha,lazy:!0}],[$u,{useClass:f.AuthzIoLocalService}],[qh,{useClass:f.MentionIOLocalService,lazy:!0}]],t),r=e?e.createChild(n):new Re.Injector(n);return Ra(r,[[Ur],[sa]]),r}bd(),f.ABCToNumber=M_,f.AUTO_HEIGHT_FOR_MERGED_CELLS=Ea,f.AbsoluteRefType=Ne,f.ActionIterator=jn,f.AlignTypeH=Mc,f.AlignTypeV=Lc,f.ArrangeTypeEnum=Pc,f.ArrowsAndMarkersShapes=Xa,f.AsyncInterceptorManager=zd,f.AsyncLock=kd,f.AutoFillSeries=xa,f.BaselineOffset=$t,f.BasicShapes=Ka,f.BlockType=hc,f.BooleanNumber=ae,f.BorderStyleTypes=Ue,f.BorderType=Ba,f.BuildTextUtils=Je,f.BulletAlignment=Or,f.COLORS=hi,f.CanceledError=Hd,f.CellModeEnum=Tn,f.CellValueType=Xt,f.Color=fn,f.ColorBuilder=is,f.ColorKit=vt,f.ColorType=pt,f.ColumnSeparatorType=mc,f.CommandType=rr,f.CommonHideTypes=$a,f.ConfigService=vh,f.ContextService=ya,f.CopyPasteType=Ha,f.CustomCommandExecutionError=qr,f.CustomDecorationType=_n,f.CustomRangeType=en,f.DEFAULT_CELL=a_,f.DEFAULT_DOC=yo,f.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=Qp,f.DEFAULT_EMPTY_DOCUMENT_VALUE=_a,f.DEFAULT_NUMBER_FORMAT=lc,f.DEFAULT_RANGE=i_,f.DEFAULT_RANGE_ARRAY=s_,f.DEFAULT_SELECTION=o_,f.DEFAULT_SLIDE=Bc,f.DEFAULT_STYLES=st,f.DEFAULT_TEXT_FORMAT=oc,f.DEFAULT_TEXT_FORMAT_EXCEL=ac,f.DEFAULT_WORKSHEET_COLUMN_COUNT=Fh,f.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=OR,f.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Hh,f.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=AR,f.DEFAULT_WORKSHEET_COLUMN_WIDTH=Bh,f.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=wR,f.DEFAULT_WORKSHEET_ROW_COUNT=kh,f.DEFAULT_WORKSHEET_ROW_COUNT_KEY=SR,f.DEFAULT_WORKSHEET_ROW_HEIGHT=xh,f.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=vR,f.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=$h,f.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=bR,f.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=ri,f.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=ni,f.DOCS_ZEN_EDITOR_UNIT_ID_KEY=ga,f.DOC_DRAWING_PRINTING_COMPONENT_KEY=d_,f.DOC_RANGE_TYPE=ul,f.DashStyleType=Rc,f.DataStreamTreeNodeType=Lu,f.DataStreamTreeTokenType=lt,f.DataValidationErrorStyle=dd,f.DataValidationImeMode=fd,f.DataValidationOperator=md,f.DataValidationRenderMode=gd,f.DataValidationStatus=_d,f.DataValidationType=pd,f.DeleteDirection=Wa,f.DependentOn=zR,f.DesktopLogService=Ma,f.DeveloperMetadataVisibility=ja,f.Dimension=Ya,f.Direction=Ga,f.Disposable=ze,f.DisposableCollection=Jr,f.DocStyleType=cc,f.DocumentDataModel=At,f.DocumentFlavor=ho,f.DrawingTypeEnum=kc,f.EDITOR_ACTIVATED=wh,f.EXTENSION_NAMES=$c,f.ErrorService=Ah,f.EventState=xu,f.EventSubject=eE,f.FOCUSING_COMMON_DRAWINGS=cR,f.FOCUSING_DOC=$r,f.FOCUSING_EDITOR_BUT_HIDDEN=rR,f.FOCUSING_EDITOR_INPUT_FORMULA=sR,f.FOCUSING_EDITOR_STANDALONE=oR,f.FOCUSING_FX_BAR_EDITOR=bh,f.FOCUSING_PANEL_EDITOR=aR,f.FOCUSING_SHEET=Kn,f.FOCUSING_SLIDE=Hr,f.FOCUSING_UNIT=Br,f.FOCUSING_UNIVER_EDITOR=iR,f.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=lR,f.FORMULA_EDITOR_ACTIVATED=uR,f.FollowNumberWithType=uc,f.FontItalic=ts,f.FontStyleType=kn,f.FontWeight=ns,f.GridType=dc,f.HLSColor=il,f.HorizontalAlign=Ot,f.IAuthzIoService=$u,f.ICommandService=sr,f.IConfigService=qo,f.IContextService=An,f.IImageIoService=Jo,f.ILocalStorageService=BR,f.ILogService=_t,f.IMentionIOService=qh,f.IPermissionService=Zh,f.IResourceLoaderService=sa,f.IResourceManagerService=js,f.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=pa,f.IUndoRedoService=Zs,f.IUniverInstanceService=Xn,f.ImageCacheMap=od,f.ImageSourceType=Zo,f.ImageUploadStatusType=Th,f.InterceptorEffectEnum=bn,f.InterceptorManager=Yd,f.InterpolationPointType=Va,f.JSON1=Y_,f.JSONX=Wt,f.LRUHelper=hr,f.LRUMap=ur,f.LifecycleStages=ke,f.LifecycleUnreachableError=Kh,f.ListGlyphType=fe,f.LocaleService=Sn,f.LocaleType=ar,f.LogLevel=Na,f.MOVE_BUFFER_VALUE=or,f.MemoryCursor=un,f.MentionType=es,f.NAMED_STYLE_MAP=c_,f.NAMED_STYLE_SPACE_MAP=u_,f.NamedStyleType=qe,f.NilCommand=Da,f.NumberUnitType=Nc,f.ObjectMatrix=ct,f.ObjectRelativeFromH=Tc,f.ObjectRelativeFromV=yc,f.OtherShapes=qa,f.PAGE_SIZE=f_,f.PAPER_TYPES=r_,f.PRESET_LIST_TYPE=Nr,f.PRINT_CHART_COMPONENT_KEY=h_,f.PageElementType=Fc,f.PageOrientType=Uc,f.PageType=fo,f.PaperType=dt,f.ParagraphElementType=_c,f.ParagraphStyleBuilder=Dr,f.ParagraphStyleValue=Lr,f.PermissionService=Jh,f.PermissionStatus=ta,f.Plugin=ra,f.PositionedObjectLayoutType=Ec,f.PresetListType=Ft,f.ProtectionType=za,f.QuickListType=Ru,f.QuickListTypeMap=q_,f.RANGE_DIRECTION=cl,f.RANGE_TYPE=pe,f.RBush=Ms,f.RCDisposable=hf,f.RGBA_PAREN=Hf,f.RGB_PAREN=$f,f.ROTATE_BUFFER_VALUE=Fa,f.RTree=tI,f.Range=xn,f.Rectangle=tn,f.RedoCommand=id,f.RedoCommandId=nd,f.RefAlias=N_,f.Registry=oi,f.RegistryAsMap=ai,f.RelativeDate=Ja,f.RelativeSlideLink=xc,f.RgbColor=os,f.RichTextBuilder=Cn,f.RichTextValue=sn,f.RxDisposable=uf,f.SHEET_EDITOR_UNITS=l_,f.SectionType=fc,f.SheetTypes=Qa,f.SheetViewModel=jh,f.SliceBodyType=Ao,f.SlideDataModel=ea,f.SpacingRule=Cc,f.SpecialShapes=Za,f.Styles=yh,f.THEME_COLORS=sl,f.TabStopAlignment=Ic,f.TableAlignmentType=Oc,f.TableLayoutType=vc,f.TableRowHeightRule=bc,f.TableSizeType=Sc,f.TableTextWrapType=wc,f.TextDecoration=el,f.TextDecorationBuilder=rn,f.TextDirection=lr,f.TextDirectionType=gc,f.TextStyleBuilder=nn,f.TextStyleValue=Mr,f.TextX=Me,f.TextXActionType=J,f.ThemeColor=as,f.ThemeColorType=ot,f.ThemeColors=rs,f.ThemeService=qs,f.Tools=Z,f.UndoCommand=sd,f.UndoCommandId=rd,f.UnitModel=Ps,f.Univer=fI,f.UniverInstanceType=we,f.UpdateDocsAttributeType=Ce,f.UserManagerService=Ur,f.VerticalAlign=hn,f.VerticalAlignmentType=Ac,f.Worksheet=jr,f.WrapStrategy=dn,f.WrapTextType=pc,f.addLinkToDocumentModel=Lh,f.afterInitApply=If,f.afterTime=Cf,f.awaitTime=nI,f.binSearchFirstGreaterThanTarget=ka,f.binarySearchArray=Sf,f.bufferDebounceTime=Ef,f.cellToRange=pm,f.characterSpacingControlType=Dc,f.checkForSubstrings=Cm,f.checkIfMove=vf,f.checkParagraphHasBullet=tg,f.checkParagraphHasIndent=ng,f.checkParagraphHasIndentByStyle=vl,f.codeToBlob=Of,f.composeBody=To,f.composeInterceptors=Sa,f.composeStyles=cr,f.concatMatrixArray=om,f.convertBodyToHtml=Bf,f.convertCellToRange=hl,f.convertObservableToBehaviorSubject=Rf,f.covertCellValue=Ei,f.covertCellValues=Em,f.covertTextRunToHtml=ui,f.createAsyncInterceptorKey=Gd,f.createDefaultUser=Ys,f.createDocumentModelWithStyle=Wr,f.createInterceptorKey=jd,f.createInternalEditorID=Bd,f.createRowColIter=po,f.dayjs=Ht,f.debounce=qC,f.dedupe=Ad,f.dedupeBy=Td,f.deepCompare=Ci,f.delayAnimationFrame=rI,f.deleteContent=bl,f.extractPureTextFromCell=Gh,f.fromCallback=Ua,f.fromEventSubject=tE,f.fromObservable=cf,f.generateRandomId=tt,f.get=ph,f.getArrayLength=Zt,f.getBodySlice=bt,f.getBodySliceHtml=ss,f.getBorderStyleType=mm,f.getCellCoordByIndexSimple=ua,f.getCellInfoInMergeData=sm,f.getCellPositionByIndexSimple=cI,f.getCellValueType=tm,f.getCellWithCoordByIndexCore=qn,f.getColorStyle=Dt,f.getCustomBlockSlice=wu,f.getCustomDecorationSlice=Au,f.getCustomRangeSlice=bu,f.getDocsUpdateBody=gm,f.getIntersectRange=Yc,f.getOriginCellValue=yR,f.getParagraphsSlice=vu,f.getPlainText=Ws,f.getReverseDirection=wf,f.getSectionBreakSlice=ip,f.getTableSlice=Ou,f.getTextRunSlice=Hs,f.getTransformOffsetX=ud,f.getTransformOffsetY=hd,f.getWorksheetUID=DR,f.groupBy=Md,f.handleStyleToString=fm,f.hashAlgorithm=sg,f.horizontalLineSegmentsSubtraction=Cs,f.insertMatrixArray=mi,f.insertTextToContent=wl,f.invertColorByHSL=Qd,f.invertColorByMatrix=tf,f.isBlackColor=Qf,f.isBooleanString=xd,f.isCellCoverable=pi,f.isCellV=ll,f.isDefaultFormat=t_,f.isEmptyCell=dl,f.isFormulaId=dm,f.isFormulaString=fl,f.isICellData=al,f.isInternalEditorID=Ca,f.isNodeEnv=xf,f.isNotNullOrUndefined=Dh,f.isNullCell=nm,f.isNumeric=ba,f.isPatternEqualWithoutDecimal=n_,f.isRangesEqual=fR,f.isRealNum=rg,f.isSafeNumeric=rf,f.isSameStyleTextRun=ml,f.isTextFormat=e_,f.isUnitRangesEqual=mR,f.isValidRange=_m,f.isWhiteColor=em,f.makeArray=Ld,f.makeCellRangeToRangeData=hm,f.makeCellToSelection=um,f.makeCustomRangeStream=Cp,f.mapObjectMatrix=im,f.merge=Xo,f.mergeOverrideWithDependencies=Qh,f.mergeSets=af,f.mergeWith=eR,f.mergeWorksheetSnapshotWithDefault=Wh,f.mixinClass=nf,f.moveMatrixArray=_i,f.moveRangeByOffset=R_,f.nameCharacterCheck=eI,f.normalizeBody=op,f.normalizeTextRuns=yr,f.numberToABC=D_,f.numberToListABC=U_,f.numfmt=Qg,f.queryObjectMatrix=y_,f.registerDependencies=$d,f.remove=tr,f.repeatStringNumTimes=Kc,f.replaceInDocumentBody=Zp,f.requestImmediateMacroTask=of,f.rotate=Nd,f.searchArray=ir,f.searchInOrderedArray=Pa,f.selectionToArray=rm,f.sequence=Ta,f.sequenceAsync=Aa,f.sequenceExecute=Qr,f.sequenceExecuteAsync=pf,f.set=nR,f.shallowEqual=Ia,f.skipParseTagNames=uI,f.sliceMatrixArray=am,f.sortRules=P_,f.sortRulesByDesc=k_,f.sortRulesFactory=Ar,f.spliceArray=gi,f.splitIntoGrid=_o,f.takeAfter=li,f.textDiff=Mo,f.throttle=Wd,f.toDisposable=je,f.touchDependencies=Ra,f.updateAttributeByDelete=Tu,f.updateAttributeByInsert=yu,f.willLoseNumericPrecision=sf,Object.keys(Re).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(f,e)&&Object.defineProperty(f,e,{enumerable:!0,get:()=>Re[e]})}),Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
8
+ `,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(n){return new Cn(n!=null?n:Cn.newEmptyData())}insertText(n,r,s){var u,h;let i=((h=(u=this._data.body)==null?void 0:u.dataStream.length)!=null?h:2)-2,o,a;if(typeof n=="string"?o=n:(i=Math.min(n,i),o=r),typeof r=="object"?a=r instanceof nn?r.build():r:a=s instanceof nn?s.build():s,!o)return this;const l={dataStream:o,textRuns:a?[{ts:a,st:i,ed:i+o.length}]:[]},c=Je.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:l});if(!c)throw new Error("Insert text failed, please check.");return Me.apply(this._doc.getBody(),c.serialize()),this}insertRichText(n,r){var a,l;let s=((l=(a=this._data.body)==null?void 0:a.dataStream.length)!=null?l:2)-2,i;typeof n=="object"?i=n instanceof sn?n.getData():n:(s=Math.min(n,s),i=r instanceof sn?r.getData():r);const o=Je.selection.replace({doc:this._doc,selection:{startOffset:s,endOffset:s,collapsed:!0},body:i.body});if(!o)throw new Error("Insert text failed, please check.");return Me.apply(this._doc.getBody(),o.serialize()),this}delete(n,r){if(r!==void 0){if(!r)return this;const s=Je.selection.delete([{startOffset:n,endOffset:n+r,collapsed:!0}],this._data.body);Me.apply(this._doc.getBody(),s)}return this}setStyle(n,r,s){const i={dataStream:"",textRuns:[{ts:s instanceof nn?s.build():s,st:0,ed:r-n}]},o=Je.selection.retain([{startOffset:n,endOffset:r,collapsed:!0}],i);return Me.apply(this._doc.getBody(),o),this}setLink(n,r,s){const i=Je.customRange.add({rangeType:en.HYPERLINK,rangeId:tt(),properties:{url:s},ranges:[{startOffset:n,endOffset:r,collapsed:!1}],body:this._data.body});if(!i)throw new Error("Insert text failed, please check.");return Me.apply(this._doc.getBody(),i.serialize()),this}cancelLink(n,r){if(typeof n=="string"){const s=Je.customRange.delete({rangeId:n,documentDataModel:this._doc});if(!s)throw new Error("Insert text failed, please check.");Me.apply(this._doc.getBody(),s.serialize())}else this.slice(n,r).getLinks().forEach(i=>{const o=Je.customRange.delete({rangeId:i.rangeId,documentDataModel:this._doc});if(!o)throw new Error("Insert text failed, please check.");Me.apply(this._doc.getBody(),o.serialize())});return this}updateLink(n,r){var i,o;const s=(o=(i=this._data.body)==null?void 0:i.customRanges)==null?void 0:o.find(a=>a.rangeId===n);if(!s)throw new Error("Link not found");return s.properties.url=r,this}insertParagraph(n,r){var o,a;let s,i;return typeof n=="object"?(s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:n.build()}]},i=((a=(o=this._data.body)==null?void 0:o.dataStream.length)!=null?a:2)-2):(i=n,s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:r==null?void 0:r.build()}]}),this.insertRichText(i,sn.create({body:s,id:"d",documentStyle:{}})),this}insertLink(n,r,s){let i="",o="";typeof n=="string"?(i=n,o=r):(i=r,o=s);const a=Cn.createByBody({dataStream:i,customRanges:[{rangeType:en.HYPERLINK,rangeId:tt(),properties:{url:o},startIndex:0,endIndex:i.length-1}]});return typeof n=="number"?this.insertRichText(n,a):this.insertRichText(a)}}const Qp="__default_document_sub_component_id20231101__";class xu{constructor(){C(this,"skipNextObservers",!1);C(this,"lastReturnValue");C(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class eE extends oe.Subject{constructor(){super(...arguments);C(this,"_sortedObservers",[])}subscribe(){throw new Error("[EventSubject]: please use `subscribeEvent` instead of `subscribe` method for `EventSubject`.")}next(){throw new Error("[EventSubject]: please use `emitEvent` instead of `next` method for `EventSubject`.")}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(n){let r;typeof n=="function"?r={next:([i,o])=>n(i,o)}:r=n;const s=super.subscribe(r);return this._sortedObservers.push(r),this._sortedObservers.sort((i,o)=>{var a,l;return((a=i.priority)!=null?a:0)-((l=o.priority)!=null?l:0)}),s.add(()=>this._sortedObservers=this._sortedObservers.filter(i=>i!==r)),s}clearObservers(){this._sortedObservers.forEach(n=>{var r;return(r=n.complete)==null?void 0:r.call(n)}),this._sortedObservers.length=0}emitEvent(n){var r;if(!this.closed){const s=new xu;s.lastReturnValue=n;for(const i of this._sortedObservers){const o=(r=i.next)==null?void 0:r.call(i,[n,s]);if(s.lastReturnValue=o,s.skipNextObservers)return{handled:!0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}throw new Error("[EventSubject]: cannot emit event on a closed subject.")}}function tE(e){return new oe.Observable(t=>{const n=e.subscribeEvent(r=>{t.next(r)});return()=>n.unsubscribe()})}const js=Re.createIdentifier("core.resource-manager.service"),Po={[kt.Editor]:"Editor",[kt.Owner]:"Owner",[kt.Reader]:"Reader",[kt.UNRECOGNIZED]:"UNRECOGNIZED"},Ys=e=>e?{userID:`${Po[e]}_${tt(8)}`,name:Po[e],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},nE=(e,t)=>e.startsWith(Po[t]);class Ur extends ze{constructor(){super(...arguments);C(this,"_model",new Map);C(this,"_userChange$",new oe.Subject);C(this,"userChange$",this._userChange$.asObservable());C(this,"_currentUser$",new oe.BehaviorSubject(Ys()));C(this,"currentUser$",this._currentUser$.asObservable())}dispose(){super.dispose(),this._model.clear(),this._userChange$.complete(),this._currentUser$.complete()}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(n){this.addUser(n),this._currentUser$.next(n)}addUser(n){this._model.set(n.userID,n),this._userChange$.next({type:"add",user:n})}getUser(n,r){const s=this._model.get(n);if(s)return s;r&&r()}delete(n){const r=this.getUser(n);this._model.delete(n),r&&this._userChange$.next({type:"delete",user:r})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}list(){return Array.from(this._model.values())}}var rE=Object.getOwnPropertyDescriptor,sE=(e,t,n,r)=>{for(var s=r>1?void 0:r?rE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Bu=(e,t)=>(n,r)=>t(n,r,e);f.AuthzIoLocalService=class{constructor(t,n){C(this,"_permissionMap",new Map([]));this._resourceManagerService=t,this._userManagerService=n,this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){const t=this._userManagerService.getCurrentUser();t&&t.userID||this._userManagerService.setCurrentUser(Ys(kt.Owner))}_getRole(t){const n=this._userManagerService.getCurrentUser();return n?nE(n.userID,t):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:t=>{const n=[...this._permissionMap.keys()].reduce((r,s)=>{const i=this._permissionMap.get(s);return r[s]=i,r},{});return JSON.stringify(n)},parseJson:t=>JSON.parse(t),pluginName:"SHEET_AuthzIoMockService_PLUGIN",businesses:[we.UNIVER_SHEET,we.UNIVER_DOC,we.UNIVER_SLIDE],onLoad:(t,n)=>{for(const r in n)this._permissionMap.set(r,n[r])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(t){return tt(8)}async allowed(t){return Promise.resolve([])}async batchAllowed(t){return Promise.resolve([])}async list(t){const n=[];return t.objectIDs.forEach(r=>{const s=this._permissionMap.get(r);if(s){const i={objectID:r,unitID:t.unitID,objectType:s.objectType,name:s.name,shareOn:!1,shareRole:kt.Owner,shareScope:-1,scope:{read:Eo.AllCollaborator,edit:Eo.AllCollaborator},creator:Ys(kt.Owner),strategies:[{action:6,role:1},{action:16,role:1},{action:17,role:1},{action:18,role:1},{action:19,role:1},{action:33,role:1},{action:34,role:1},{action:35,role:1},{action:36,role:1},{action:37,role:1},{action:38,role:1},{action:39,role:1},{action:40,role:1}],actions:t.actions.map(o=>({action:o,allowed:this._getRole(kt.Owner)||this._getRole(kt.Editor)}))};n.push(i)}}),n}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(t){}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(t){}},f.AuthzIoLocalService=sE([Bu(0,js),Bu(1,Re.Inject(Ur))],f.AuthzIoLocalService);const $u=Re.createIdentifier("IAuthzIoIoService");var Hu=typeof global=="object"&&global&&global.Object===Object&&global,iE=typeof self=="object"&&self&&self.Object===Object&&self,Rn=Hu||iE||Function("return this")(),Yn=Rn.Symbol,Wu=Object.prototype,oE=Wu.hasOwnProperty,aE=Wu.toString,Pr=Yn?Yn.toStringTag:void 0;function lE(e){var t=oE.call(e,Pr),n=e[Pr];try{e[Pr]=void 0;var r=!0}catch{}var s=aE.call(e);return r&&(t?e[Pr]=n:delete e[Pr]),s}var cE=Object.prototype,uE=cE.toString;function hE(e){return uE.call(e)}var dE="[object Null]",fE="[object Undefined]",ju=Yn?Yn.toStringTag:void 0;function kr(e){return e==null?e===void 0?fE:dE:ju&&ju in Object(e)?lE(e):hE(e)}function Gn(e){return e!=null&&typeof e=="object"}var mE="[object Symbol]";function Gs(e){return typeof e=="symbol"||Gn(e)&&kr(e)==mE}function gE(e,t){for(var n=-1,r=e==null?0:e.length,s=Array(r);++n<r;)s[n]=t(e[n],n,e);return s}var Vn=Array.isArray,Yu=Yn?Yn.prototype:void 0,Gu=Yu?Yu.toString:void 0;function Vu(e){if(typeof e=="string")return e;if(Vn(e))return gE(e,Vu)+"";if(Gs(e))return Gu?Gu.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}var _E=/\s/;function pE(e){for(var t=e.length;t--&&_E.test(e.charAt(t)););return t}var EE=/^\s+/;function CE(e){return e&&e.slice(0,pE(e)+1).replace(EE,"")}function Ct(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var zu=NaN,RE=/^[-+]0x[0-9a-f]+$/i,IE=/^0b[01]+$/i,SE=/^0o[0-7]+$/i,OE=parseInt;function Ku(e){if(typeof e=="number")return e;if(Gs(e))return zu;if(Ct(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Ct(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=CE(e);var n=IE.test(e);return n||SE.test(e)?OE(e.slice(2),n?2:8):RE.test(e)?zu:+e}function Xu(e){return e}var vE="[object AsyncFunction]",wE="[object Function]",bE="[object GeneratorFunction]",AE="[object Proxy]";function ko(e){if(!Ct(e))return!1;var t=kr(e);return t==wE||t==bE||t==vE||t==AE}var Fo=Rn["__core-js_shared__"],qu=function(){var e=/[^.]+$/.exec(Fo&&Fo.keys&&Fo.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function TE(e){return!!qu&&qu in e}var yE=Function.prototype,NE=yE.toString;function ME(e){if(e!=null){try{return NE.call(e)}catch{}try{return e+""}catch{}}return""}var LE=/[\\^$.*+?()[\]{}|]/g,DE=/^\[object .+?Constructor\]$/,UE=Function.prototype,PE=Object.prototype,kE=UE.toString,FE=PE.hasOwnProperty,xE=RegExp("^"+kE.call(FE).replace(LE,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function BE(e){if(!Ct(e)||TE(e))return!1;var t=ko(e)?xE:DE;return t.test(ME(e))}function $E(e,t){return e==null?void 0:e[t]}function xo(e,t){var n=$E(e,t);return BE(n)?n:void 0}var Zu=Object.create,HE=function(){function e(){}return function(t){if(!Ct(t))return{};if(Zu)return Zu(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function WE(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function jE(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}var YE=800,GE=16,VE=Date.now;function zE(e){var t=0,n=0;return function(){var r=VE(),s=GE-(r-n);if(n=r,s>0){if(++t>=YE)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function KE(e){return function(){return e}}var Vs=function(){try{var e=xo(Object,"defineProperty");return e({},"",{}),e}catch{}}(),XE=Vs?function(e,t){return Vs(e,"toString",{configurable:!0,enumerable:!1,value:KE(t),writable:!0})}:Xu,qE=zE(XE),ZE=9007199254740991,JE=/^(?:0|[1-9]\d*)$/;function Bo(e,t){var n=typeof e;return t=t==null?ZE:t,!!t&&(n=="number"||n!="symbol"&&JE.test(e))&&e>-1&&e%1==0&&e<t}function $o(e,t,n){t=="__proto__"&&Vs?Vs(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function zs(e,t){return e===t||e!==e&&t!==t}var QE=Object.prototype,e0=QE.hasOwnProperty;function Ju(e,t,n){var r=e[t];(!(e0.call(e,t)&&zs(r,n))||n===void 0&&!(t in e))&&$o(e,t,n)}function t0(e,t,n,r){var s=!n;n||(n={});for(var i=-1,o=t.length;++i<o;){var a=t[i],l=void 0;l===void 0&&(l=e[a]),s?$o(n,a,l):Ju(n,a,l)}return n}var Qu=Math.max;function n0(e,t,n){return t=Qu(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,i=Qu(r.length-t,0),o=Array(i);++s<i;)o[s]=r[t+s];s=-1;for(var a=Array(t+1);++s<t;)a[s]=r[s];return a[t]=n(o),WE(e,this,a)}}function r0(e,t){return qE(n0(e,t,Xu),e+"")}var s0=9007199254740991;function eh(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=s0}function Ho(e){return e!=null&&eh(e.length)&&!ko(e)}function i0(e,t,n){if(!Ct(n))return!1;var r=typeof t;return(r=="number"?Ho(n)&&Bo(t,n.length):r=="string"&&t in n)?zs(n[t],e):!1}function th(e){return r0(function(t,n){var r=-1,s=n.length,i=s>1?n[s-1]:void 0,o=s>2?n[2]:void 0;for(i=e.length>3&&typeof i=="function"?(s--,i):void 0,o&&i0(n[0],n[1],o)&&(i=s<3?void 0:i,s=1),t=Object(t);++r<s;){var a=n[r];a&&e(t,a,r,i)}return t})}var o0=Object.prototype;function nh(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||o0;return e===n}function a0(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var l0="[object Arguments]";function rh(e){return Gn(e)&&kr(e)==l0}var sh=Object.prototype,c0=sh.hasOwnProperty,u0=sh.propertyIsEnumerable,Wo=rh(function(){return arguments}())?rh:function(e){return Gn(e)&&c0.call(e,"callee")&&!u0.call(e,"callee")};function h0(){return!1}var ih=typeof f=="object"&&f&&!f.nodeType&&f,oh=ih&&typeof module=="object"&&module&&!module.nodeType&&module,d0=oh&&oh.exports===ih,ah=d0?Rn.Buffer:void 0,f0=ah?ah.isBuffer:void 0,lh=f0||h0,m0="[object Arguments]",g0="[object Array]",_0="[object Boolean]",p0="[object Date]",E0="[object Error]",C0="[object Function]",R0="[object Map]",I0="[object Number]",S0="[object Object]",O0="[object RegExp]",v0="[object Set]",w0="[object String]",b0="[object WeakMap]",A0="[object ArrayBuffer]",T0="[object DataView]",y0="[object Float32Array]",N0="[object Float64Array]",M0="[object Int8Array]",L0="[object Int16Array]",D0="[object Int32Array]",U0="[object Uint8Array]",P0="[object Uint8ClampedArray]",k0="[object Uint16Array]",F0="[object Uint32Array]",xe={};xe[y0]=xe[N0]=xe[M0]=xe[L0]=xe[D0]=xe[U0]=xe[P0]=xe[k0]=xe[F0]=!0,xe[m0]=xe[g0]=xe[A0]=xe[_0]=xe[T0]=xe[p0]=xe[E0]=xe[C0]=xe[R0]=xe[I0]=xe[S0]=xe[O0]=xe[v0]=xe[w0]=xe[b0]=!1;function x0(e){return Gn(e)&&eh(e.length)&&!!xe[kr(e)]}function B0(e){return function(t){return e(t)}}var ch=typeof f=="object"&&f&&!f.nodeType&&f,Fr=ch&&typeof module=="object"&&module&&!module.nodeType&&module,$0=Fr&&Fr.exports===ch,jo=$0&&Hu.process,uh=function(){try{var e=Fr&&Fr.require&&Fr.require("util").types;return e||jo&&jo.binding&&jo.binding("util")}catch{}}(),hh=uh&&uh.isTypedArray,dh=hh?B0(hh):x0;function H0(e,t){var n=Vn(e),r=!n&&Wo(e),s=!n&&!r&&lh(e),i=!n&&!r&&!s&&dh(e),o=n||r||s||i,a=o?a0(e.length,String):[],l=a.length;for(var c in e)o&&(c=="length"||s&&(c=="offset"||c=="parent")||i&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Bo(c,l))||a.push(c);return a}function W0(e,t){return function(n){return e(t(n))}}function j0(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var Y0=Object.prototype,G0=Y0.hasOwnProperty;function V0(e){if(!Ct(e))return j0(e);var t=nh(e),n=[];for(var r in e)r=="constructor"&&(t||!G0.call(e,r))||n.push(r);return n}function fh(e){return Ho(e)?H0(e):V0(e)}var z0=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,K0=/^\w*$/;function X0(e,t){if(Vn(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Gs(e)?!0:K0.test(e)||!z0.test(e)||t!=null&&e in Object(t)}var xr=xo(Object,"create");function q0(){this.__data__=xr?xr(null):{},this.size=0}function Z0(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var J0="__lodash_hash_undefined__",Q0=Object.prototype,eC=Q0.hasOwnProperty;function tC(e){var t=this.__data__;if(xr){var n=t[e];return n===J0?void 0:n}return eC.call(t,e)?t[e]:void 0}var nC=Object.prototype,rC=nC.hasOwnProperty;function sC(e){var t=this.__data__;return xr?t[e]!==void 0:rC.call(t,e)}var iC="__lodash_hash_undefined__";function oC(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=xr&&t===void 0?iC:t,this}function In(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}In.prototype.clear=q0,In.prototype.delete=Z0,In.prototype.get=tC,In.prototype.has=sC,In.prototype.set=oC;function aC(){this.__data__=[],this.size=0}function Ks(e,t){for(var n=e.length;n--;)if(zs(e[n][0],t))return n;return-1}var lC=Array.prototype,cC=lC.splice;function uC(e){var t=this.__data__,n=Ks(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():cC.call(t,n,1),--this.size,!0}function hC(e){var t=this.__data__,n=Ks(t,e);return n<0?void 0:t[n][1]}function dC(e){return Ks(this.__data__,e)>-1}function fC(e,t){var n=this.__data__,r=Ks(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function jt(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}jt.prototype.clear=aC,jt.prototype.delete=uC,jt.prototype.get=hC,jt.prototype.has=dC,jt.prototype.set=fC;var mh=xo(Rn,"Map");function mC(){this.size=0,this.__data__={hash:new In,map:new(mh||jt),string:new In}}function gC(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Xs(e,t){var n=e.__data__;return gC(t)?n[typeof t=="string"?"string":"hash"]:n.map}function _C(e){var t=Xs(this,e).delete(e);return this.size-=t?1:0,t}function pC(e){return Xs(this,e).get(e)}function EC(e){return Xs(this,e).has(e)}function CC(e,t){var n=Xs(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function on(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}on.prototype.clear=mC,on.prototype.delete=_C,on.prototype.get=pC,on.prototype.has=EC,on.prototype.set=CC;var RC="Expected a function";function Yo(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(RC);var n=function(){var r=arguments,s=t?t.apply(this,r):r[0],i=n.cache;if(i.has(s))return i.get(s);var o=e.apply(this,r);return n.cache=i.set(s,o)||i,o};return n.cache=new(Yo.Cache||on),n}Yo.Cache=on;var IC=500;function SC(e){var t=Yo(e,function(r){return n.size===IC&&n.clear(),r}),n=t.cache;return t}var OC=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,vC=/\\(\\)?/g,wC=SC(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(OC,function(n,r,s,i){t.push(s?i.replace(vC,"$1"):r||n)}),t});function bC(e){return e==null?"":Vu(e)}function gh(e,t){return Vn(e)?e:X0(e,t)?[e]:wC(bC(e))}function _h(e){if(typeof e=="string"||Gs(e))return e;var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function AC(e,t){t=gh(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[_h(t[n++])];return n&&n==r?e:void 0}function ph(e,t,n){var r=e==null?void 0:AC(e,t);return r===void 0?n:r}var Eh=W0(Object.getPrototypeOf,Object),TC="[object Object]",yC=Function.prototype,NC=Object.prototype,Ch=yC.toString,MC=NC.hasOwnProperty,LC=Ch.call(Object);function DC(e){if(!Gn(e)||kr(e)!=TC)return!1;var t=Eh(e);if(t===null)return!0;var n=MC.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Ch.call(n)==LC}function UC(){this.__data__=new jt,this.size=0}function PC(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function kC(e){return this.__data__.get(e)}function FC(e){return this.__data__.has(e)}var xC=200;function BC(e,t){var n=this.__data__;if(n instanceof jt){var r=n.__data__;if(!mh||r.length<xC-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new on(r)}return n.set(e,t),this.size=n.size,this}function zn(e){var t=this.__data__=new jt(e);this.size=t.size}zn.prototype.clear=UC,zn.prototype.delete=PC,zn.prototype.get=kC,zn.prototype.has=FC,zn.prototype.set=BC;var Rh=typeof f=="object"&&f&&!f.nodeType&&f,Ih=Rh&&typeof module=="object"&&module&&!module.nodeType&&module,$C=Ih&&Ih.exports===Rh,Sh=$C?Rn.Buffer:void 0;Sh&&Sh.allocUnsafe;function HC(e,t){return e.slice()}var Oh=Rn.Uint8Array;function WC(e){var t=new e.constructor(e.byteLength);return new Oh(t).set(new Oh(e)),t}function jC(e,t){var n=WC(e.buffer);return new e.constructor(n,e.byteOffset,e.length)}function YC(e){return typeof e.constructor=="function"&&!nh(e)?HE(Eh(e)):{}}function GC(e){return function(t,n,r){for(var s=-1,i=Object(t),o=r(t),a=o.length;a--;){var l=o[++s];if(n(i[l],l,i)===!1)break}return t}}var VC=GC(),Go=function(){return Rn.Date.now()},zC="Expected a function",KC=Math.max,XC=Math.min;function qC(e,t,n){var r,s,i,o,a,l,c=0,u=!1,h=!1,d=!0;if(typeof e!="function")throw new TypeError(zC);t=Ku(t)||0,Ct(n)&&(u=!!n.leading,h="maxWait"in n,i=h?KC(Ku(n.maxWait)||0,t):i,d="trailing"in n?!!n.trailing:d);function m(R){var b=r,y=s;return r=s=void 0,c=R,o=e.apply(y,b),o}function _(R){return c=R,a=setTimeout(A,t),u?m(R):o}function p(R){var b=R-l,y=R-c,$=t-b;return h?XC($,i-y):$}function I(R){var b=R-l,y=R-c;return l===void 0||b>=t||b<0||h&&y>=i}function A(){var R=Go();if(I(R))return B(R);a=setTimeout(A,p(R))}function B(R){return a=void 0,d&&r?m(R):(r=s=void 0,o)}function x(){a!==void 0&&clearTimeout(a),c=0,r=l=s=a=void 0}function Y(){return a===void 0?o:B(Go())}function O(){var R=Go(),b=I(R);if(r=arguments,s=this,l=R,b){if(a===void 0)return _(l);if(h)return clearTimeout(a),a=setTimeout(A,t),m(l)}return a===void 0&&(a=setTimeout(A,t)),o}return O.cancel=x,O.flush=Y,O}function Vo(e,t,n){(n!==void 0&&!zs(e[t],n)||n===void 0&&!(t in e))&&$o(e,t,n)}function ZC(e){return Gn(e)&&Ho(e)}function zo(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}function JC(e){return t0(e,fh(e))}function QC(e,t,n,r,s,i,o){var a=zo(e,n),l=zo(t,n),c=o.get(l);if(c){Vo(e,n,c);return}var u=i?i(a,l,n+"",e,t,o):void 0,h=u===void 0;if(h){var d=Vn(l),m=!d&&lh(l),_=!d&&!m&&dh(l);u=l,d||m||_?Vn(a)?u=a:ZC(a)?u=jE(a):m?(h=!1,u=HC(l)):_?(h=!1,u=jC(l)):u=[]:DC(l)||Wo(l)?(u=a,Wo(a)?u=JC(a):(!Ct(a)||ko(a))&&(u=YC(l))):h=!1}h&&(o.set(l,u),s(u,l,r,i,o),o.delete(l)),Vo(e,n,u)}function Ko(e,t,n,r,s){e!==t&&VC(t,function(i,o){if(s||(s=new zn),Ct(i))QC(e,t,o,n,Ko,r,s);else{var a=r?r(zo(e,o),i,o+"",e,t,s):void 0;a===void 0&&(a=i),Vo(e,o,a)}},fh)}var eR=th(function(e,t,n,r){Ko(e,t,n,r)}),Xo=th(function(e,t,n){Ko(e,t,n)});function tR(e,t,n,r){if(!Ct(e))return e;t=gh(t,e);for(var s=-1,i=t.length,o=i-1,a=e;a!=null&&++s<i;){var l=_h(t[s]),c=n;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=o){var u=a[l];c=void 0,c===void 0&&(c=Ct(u)?u:Bo(t[s+1])?[]:{})}Ju(a,l,c),a=a[l]}return e}function nR(e,t,n){return e==null?e:tR(e,t,n)}const qo=Re.createIdentifier("univer.config-service");class vh{constructor(){C(this,"_configChanged$",new oe.Subject);C(this,"configChanged$",this._configChanged$.asObservable());C(this,"_config",new Map)}dispose(){this._config.clear(),this._configChanged$.complete()}getConfig(t){return this._config.get(t)}setConfig(t,n,r){var o;const{merge:s=!1}=r||{};let i=(o=this._config.get(t))!=null?o:{};s?i=Xo(i,n):i=n,this._config.set(t,i),this._configChanged$.next({[t]:i})}deleteConfig(t){return this._config.delete(t)}subscribeConfigValue$(t){return new oe.Observable(n=>{Object.prototype.hasOwnProperty.call(this._config,t)&&n.next(this._config.get(t));const r=this.configChanged$.pipe(oe.filter(s=>Object.prototype.hasOwnProperty.call(s,t))).subscribe(s=>n.next(s[t]));return()=>r.unsubscribe()})}}const Br="FOCUSING_UNIT",Kn="FOCUSING_SHEET",$r="FOCUSING_DOC",Hr="FOCUSING_SLIDE",rR="FOCUSING_EDITOR_BUT_HIDDEN",wh="EDITOR_ACTIVATED",sR="FOCUSING_EDITOR_INPUT_FORMULA",bh="FOCUSING_FX_BAR_EDITOR",iR="FOCUSING_UNIVER_EDITOR",oR="FOCUSING_EDITOR_INPUT_FORMULA",aR="FOCUSING_PANEL_EDITOR",lR="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",cR="FOCUSING_COMMON_DRAWINGS",uR="FORMULA_EDITOR_ACTIVATED";class Ah extends ze{constructor(){super(...arguments);C(this,"_error$",new oe.Subject);C(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(n){this._error$.next({errorKey:n})}}var Zo=(e=>(e.URL="URL",e.UUID="UUID",e.BASE64="BASE64",e))(Zo||{}),Th=(e=>(e.SUCCUSS="0",e.ERROR_EXCEED_SIZE="1",e.ERROR_IMAGE_TYPE="2",e.ERROR_UPLOAD_COUNT_LIMIT="3",e.ERROR_IMAGE="4",e))(Th||{});const Jo=Re.createIdentifier("core.image-io.service"),hR={version:"0.9.4"};function dR(e="",t=ar.ZH_CN,n=""){return{id:e,sheetOrder:[],name:n,appVersion:hR.version,locale:t,styles:{},sheets:{},resources:[]}}class yh{constructor(t={}){C(this,"_styles");C(this,"_cacheMap",new ur(1e5));this._styles=t,this._generateCacheMap()}each(t){return Object.entries(this._styles).forEach(t),this}search(t,n){if(this._cacheMap.has(n))return this._cacheMap.get(n);const r=this._getExistingStyleId(t);return r||"-1"}get(t){return typeof t!="string"?t:(t=String(t),this._styles[t])}add(t,n){const r=tt(6);return this._styles[r]=t,this._cacheMap.set(n,r),r}setValue(t){if(t==null)return;const n=JSON.stringify(t),r=this.search(t,n);return r!=="-1"?r:this.add(t,n)}toJSON(){return this._styles}getStyleByCell(t){let n;t&&Z.isObject(t.s)?n=t.s:n=(t==null?void 0:t.s)&&this.get(t.s);const r=t==null?void 0:t.interceptorStyle;return r?{...n,...r}:n}_generateCacheMap(){const{_styles:t,_cacheMap:n}=this;for(const r in t){const s=JSON.stringify(t[r]);n.set(s,r)}}_getExistingStyleId(t){const{_styles:n}=this;for(const r in n)if(Z.diffValue(n[r],t))return r;return null}}const fR=(e,t)=>t.length===e.length&&!e.some(n=>t.some(r=>!tn.equals(r,n))),mR=(e,t)=>t.length===e.length&&e.every((n,r)=>{const s=t[r];return s.unitId===n.unitId&&s.sheetId===n.sheetId&&tn.equals(n.range,s.range)}),Qo={t:0,b:2,l:2,r:2},gR=e=>({sbr:.6,sbo:e,spr:.6,spo:e}),Nh=90;function Wr(e,t,n={}){const r=e.length,{textRotation:s,paddingData:i,horizontalAlign:o=Ot.UNSPECIFIED,verticalAlign:a=hn.UNSPECIFIED,wrapStrategy:l=dn.UNSPECIFIED,cellValueType:c}=n,{t:u,r:h,b:d,l:m}=i||Qo,{vertexAngle:_,centerAngle:p}=Ph(s),I={id:"d",body:{dataStream:`${e}${_a}`,textRuns:[{ts:t,st:0,ed:r}],paragraphs:[{startIndex:r,paragraphStyle:{horizontalAlign:o}}],sectionBreaks:[{startIndex:r+1}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},marginTop:u,marginBottom:d,marginRight:h,marginLeft:m,renderConfig:{horizontalAlign:o,verticalAlign:a,centerAngle:p,vertexAngle:_,wrapStrategy:l,cellValueType:c,zeroWidthParagraphBreak:1}},drawings:{},drawingsOrder:[]};return new At(I)}function _R(e){if(!e)return{};const{tr:t,td:n,ht:r,vt:s,tb:i,pd:o}=e;return{textRotation:t,textDirection:n,horizontalAlign:r,verticalAlign:s,wrapStrategy:i,paddingData:o}}function Mh(e){if(!e)return{};const{ff:t,fs:n,it:r,bl:s,ul:i,st:o,ol:a,cl:l}=e,c={};return t&&(c.ff=t),n&&(c.fs=n),r&&(c.it=r),s&&(c.bl=s),i&&(c.ul=i),o&&(c.st=o),a&&(c.ol=a),l&&(c.cl=l),c}function Lh(e,t,n){var i;const r=e.getBody();if((i=r.customRanges)!=null&&i.some(o=>o.rangeType===en.HYPERLINK))return;const s=Je.customRange.add({ranges:[{startOffset:0,endOffset:r.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:en.HYPERLINK,body:r,properties:{url:t,refId:n}});s&&Me.apply(r,s.serialize())}function Dh(e){return e!=null}const pR='"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';function Uh(e){const t=st.ff,n=st.fs;if(!e){const h=`${n}pt ${t}`;return{fontCache:h,fontString:h,fontSize:n,originFontSize:n,fontFamily:t}}let r=kn.ITALIC;(e.it===0||e.it===void 0)&&(r=kn.NORMAL);let s=kn.BOLD;(e.bl===0||e.bl===void 0)&&(s=kn.NORMAL);let i=n;e.fs&&(i=Math.ceil(e.fs));let o=t;if(e.ff){let h=e.ff;h=h.replace(/"/g,"").replace(/'/g,""),h.indexOf(" ")>-1&&(h=`"${h}"`),h==null&&(h=t),o=h}const{va:a}=e;let l=i;if(a===$t.SUBSCRIPT||a===$t.SUPERSCRIPT){const h=ER(o,l),{sbr:d,spr:m}=h;l*=a===$t.SUBSCRIPT?d:m}const c=`${r} ${s} ${l}pt ${o}`,u=`${c}, ${pR} `;return{fontCache:c,fontString:u,fontSize:l,originFontSize:i,fontFamily:o}}function ER(e,t){return gR(t)}function Ph(e){const{a:t=0,v:n=ae.FALSE}=e||{a:0,v:ae.FALSE};let r=0,s=t;return n===ae.TRUE&&(r=Nh,s=Nh),{centerAngle:r,vertexAngle:s}}class CR{constructor(t,n){C(this,"_columnData",{});this._config=t,this._columnData=n}getColumnData(){return this._columnData}getColVisible(t){const{_columnData:n}=this,r=n[t];return r?r.hd!==ae.TRUE:!0}getColumnStyle(t){var n;return(n=this._columnData[t])==null?void 0:n.s}setColumnStyle(t,n){const r=this.getColumnOrCreate(t);r.s=n}getHiddenCols(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getColVisible(o);s&&a?(s=!1,r.push({rangeType:pe.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:pe.COLUMN}),r}getVisibleCols(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getColVisible(o);s&&!a?(s=!1,r.push({rangeType:pe.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:pe.COLUMN}),r}getColumnDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getColumn(i);r[s]=o!=null?o:{w:this._config.defaultColumnWidth,hd:ae.FALSE},s++}return r}getSize(){return Zt(this._columnData)}getColumnWidth(t){var n,r;return(r=(n=this._columnData[t])==null?void 0:n.w)!=null?r:this._config.defaultColumnWidth}setColumnWidth(t,n){const r=this._columnData[t];n===this._config.defaultColumnWidth?r&&(delete r.w,Object.keys(r).length===0&&delete this._columnData[t]):this._columnData[t]=r?{...r,w:n}:{w:n}}getColumn(t){return this._columnData[t]}removeColumn(t){delete this._columnData[t]}getColumnOrCreate(t){const{_columnData:n}=this,r=n[t];if(r)return r;const s={};return this._columnData[t]=s,s}setCustomMetadata(t,n){const r=this.getColumn(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getColumn(t))==null?void 0:n.custom}}const RR=2e3;class IR{constructor(t,n,r){C(this,"_rowData");this._config=t,this._viewModel=n,this._rowData=r}getRowData(){return this._rowData}getRowStyle(t){var n;return(n=this._rowData[t])==null?void 0:n.s}setRowStyle(t,n){const r=this.getRowOrCreate(t);r.s=n}getRowDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getRow(i);r[s]=o!=null?o:{h:this._config.defaultRowHeight,hd:ae.FALSE},s++}return r}getRowHeight(t,n=1){const{_rowData:r}=this,s=this._config;let i=0;for(let o=0;o<n;o++){const a=r[o+t]||{hd:ae.FALSE,h:s.defaultRowHeight},{ia:l,ah:c,h:u=s.defaultRowHeight}=a;i+=(l==null||l===ae.TRUE)&&typeof c=="number"?c:u}return i}setRowHeight(t,n){const r=this._rowData[t];if(n===this._config.defaultRowHeight)r&&(delete r.h,Object.keys(r).length===0&&delete this._rowData[t]);else{const s=Math.min(n,RR);this._rowData[t]=r?{...r,h:s}:{h:s}}}getRow(t){return this._rowData[t]}removeRow(t){delete this._rowData[t]}getRowOrCreate(t){const{_rowData:n}=this,r=n[t];if(r)return r;const s={};return n[t]=s,s}getHiddenRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:pe.ROW})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:pe.ROW}),r}getVisibleRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&!a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:pe.ROW})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:pe.ROW}),r}getRowRawVisible(t){const n=this.getRow(t);return n?n.hd!==ae.TRUE:!0}getSize(){return Zt(this._rowData)}setCustomMetadata(t,n){const r=this.getRow(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getRow(t))==null?void 0:n.custom}}const SR="DEFAULT_WORKSHEET_ROW_COUNT",kh=1e3,OR="DEFAULT_WORKSHEET_COLUMN_COUNT",Fh=20,vR="DEFAULT_WORKSHEET_ROW_HEIGHT",xh=24,wR="DEFAULT_WORKSHEET_COLUMN_WIDTH",Bh=88,bR="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",$h=46,AR="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Hh=20;function Wh(e){const t={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:ae.FALSE,rowCount:kh,columnCount:Fh,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Bh,defaultRowHeight:xh,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:ae.TRUE,rowHeader:{width:$h,hidden:ae.FALSE},columnHeader:{height:Hh,hidden:ae.FALSE},rightToLeft:ae.FALSE};return Object.keys(t).forEach(n=>{const r=n;typeof e[r]>"u"&&(e[r]=t[r])}),e}class TR extends ze{constructor(n){super();C(this,"_cellCache",new Map);C(this,"_rowCache",new Map);C(this,"_columnCache",new Map);C(this,"_hasRow",!1);C(this,"_hasColumn",!1);C(this,"_hasAll",!1);C(this,"_allIndex",-1);C(this,"_mergeData");C(this,"_rangeMap",new ur(5e4));C(this,"_skeletonCache",new ur(5e4));this._init(n.concat())}_init(n){this._mergeData=n,this._createCache(n)}_clearCache(){this._cellCache.clear(),this._rowCache.clear(),this._columnCache.clear(),this._hasAll=!1,this._allIndex=-1,this._rangeMap.clear(),this._skeletonCache.clear(),this._hasColumn=!1,this._hasRow=!1}_createCache(n){let r=0;for(const s of n){const{rangeType:i}=s;i===pe.ROW?this._createRowCache(s,r):i===pe.COLUMN?this._createColumnCache(s,r):i===pe.ALL?this._createCellAllCache(r):this._createCellCache(s,r),r++}}rebuild(n){this._clearCache(),this._init(n.concat())}_createRowCache(n,r){const{startRow:s,endRow:i}=n;for(let o=s;o<=i;o++)this._rowCache.set(o,r),this._hasRow=!0}_createColumnCache(n,r){const{startColumn:s,endColumn:i}=n;for(let o=s;o<=i;o++)this._columnCache.set(o,r),this._hasColumn=!0}_createCellAllCache(n){this._hasAll=!0,this._allIndex=n}_createCellCache(n,r){for(let s=n.startRow;s<=n.endRow;s++){let i=this._cellCache.get(s);i==null&&(i=new Map,this._cellCache.set(s,i));for(let o=n.startColumn;o<=n.endColumn;o++)i.set(o,r)}}add(n){this._mergeData.push(n),this._clearCache(),this._createCache(this._mergeData)}remove(n,r){const s=this._getMergeDataIndex(n,r);s!==-1&&(this._mergeData.splice(s,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(n,r){const s=this._getMergeDataIndex(n,r);return s!==-1?this._mergeData[s]:null}getMergeDataIndex(n,r){return this._getMergeDataIndex(n,r)}isRowContainsMergedCell(n){return this._hasAll||!Z.isEmptyObject(this._columnCache)?!0:this._mergeData.some(r=>r.startRow<=n&&n<=r.endRow)}isColumnContainsMergedCell(n){return this._hasAll||!Z.isEmptyObject(this._rowCache)?!0:this._mergeData.some(r=>r.startColumn<=n&&n<=r.endColumn)}getMergedCellRange(n,r,s,i){const o=[],a=`${n}-${r}-${s}-${i}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let l=0;const c=[];for(const u of this._mergeData||[])tn.intersects(u,{startRow:n,endRow:s,startColumn:r,endColumn:i})&&(o.push({...u}),c.push(l)),l++;return this._rangeMap.set(a,c),o}getMergedCellRangeForSkeleton(n,r,s,i){const o=[],a=this._mergeData,l=`${n}-${r}-${s}-${i}`;if(this._skeletonCache.has(l))return this._getSkeletonRangeFromCache(l);const c=[];for(let u=0;u<a.length;u++){const{startRow:h,endRow:d,startColumn:m,endColumn:_}=a[u];for(let p=n;p<=s;p++){let I=!1;for(let A=r;A<=i;A++)if(p>=h&&p<=d&&A>=m&&A<=_){o.push({startRow:h,endRow:d,startColumn:m,endColumn:_}),c.push(u),I=!0;break}if(I)break}}return this._skeletonCache.set(l,c),o}_getRangeFromCache(n){const r=this._rangeMap.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getSkeletonRangeFromCache(n){const r=this._skeletonCache.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getMergeDataIndex(n,r){var i;if(this._hasAll)return this._allIndex;if(this._hasRow){const o=this._rowCache.get(n);if(o!==void 0)return o}if(this._hasColumn){const o=this._columnCache.get(r);if(o!==void 0)return o}const s=(i=this._cellCache.get(n))==null?void 0:i.get(r);return s!==void 0?s:-1}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}}class jh extends ze{constructor(n){super();C(this,"_cellContentInterceptor",null);C(this,"_rowFilteredInterceptor",null);this.getRawCell=n}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(n,r,s,i){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,bn.Value|bn.Style,s,i):this.getRawCell(n,r)}getCellValueOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,bn.Value):this.getRawCell(n,r)}getCellStyleOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,bn.Style):this.getRawCell(n,r)}getRowFiltered(n){var r,s;return(s=(r=this._rowFilteredInterceptor)==null?void 0:r.getRowFiltered(n))!=null?s:!1}registerCellContentInterceptor(n){if(this._cellContentInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptor=n,je(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(n){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=n,je(()=>this._rowFilteredInterceptor=null)}}const Yh={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};class jr{constructor(t,n,r){C(this,"_sheetId");C(this,"_snapshot");C(this,"_cellData");C(this,"_rowManager");C(this,"_columnManager");C(this,"_viewModel");C(this,"_spanModel");C(this,"_isRowStylePrecedeColumnStyle",!0);C(this,"_getCellHeight");var a;this.unitId=t,this._styles=r,this._snapshot=Wh(n);const{columnData:s,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:tt(6),this._cellData=new ct(o),this._viewModel=new jh((l,c)=>this.getCellRaw(l,c)),this._rowManager=new IR(this._snapshot,this._viewModel,i),this._columnManager=new CR(this._snapshot,s),this._spanModel=new TR(this._snapshot.mergeData)}__interceptViewModel(t){t(this._viewModel)}__registerGetCellHeight(t){return this._getCellHeight=t,je(()=>{this._getCellHeight=null})}getSnapshot(){return this._snapshot}getCellHeight(t,n){return this._getCellHeight?this._getCellHeight(t,n):this._snapshot.defaultRowHeight}setMergeData(t){this._snapshot.mergeData=t,this.getSpanModel().rebuild(t)}getSpanModel(){return this._spanModel}setIsRowStylePrecedeColumnStyle(t){this._isRowStylePrecedeColumnStyle=t}getStyleDataByHash(t){return{...this._styles.get(t)}}setStyleData(t){return this._styles.setValue(t)}getColumnStyle(t,n=!1){return n?this._columnManager.getColumnStyle(t):this._styles.get(this._columnManager.getColumnStyle(t))}setColumnStyle(t,n){this._columnManager.setColumnStyle(t,n)}getRowStyle(t,n=!1){return n?this._rowManager.getRowStyle(t):this._styles.get(this._rowManager.getRowStyle(t))}setRowStyle(t,n){this._rowManager.setRowStyle(t,n)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){const t=this._snapshot.defaultStyle;return this._styles.get(t)}setDefaultCellStyle(t){this._snapshot.defaultStyle=t}getCellStyle(t,n){const r=this.getCell(t,n);if(r){const s=r.s;return typeof s=="string"?this._styles.get(s):s}return null}getComposedCellStyle(t,n,r){const s=this.getDefaultCellStyleInternal(),i=this.getRowStyle(t),o=this.getColumnStyle(n),a=this.getCell(t,n),l=this._styles.getStyleByCell(a);return(r!=null?r:this._isRowStylePrecedeColumnStyle)?cr(s,o,i,a==null?void 0:a.themeStyle,l):cr(s,i,o,a==null?void 0:a.themeStyle,l)}getComposedCellStyleByCellData(t,n,r,s){const i=this.getDefaultCellStyleInternal(),o=this.getRowStyle(t),a=this.getColumnStyle(n),l=this._styles.getStyleByCell(r);return(s!=null?s:this._isRowStylePrecedeColumnStyle)?cr(i,a,o,r==null?void 0:r.themeStyle,l):cr(i,o,a,r==null?void 0:r.themeStyle,l)}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const t=this.getCellMatrix(),n=this.getMergeData();let r=-1,s=-1,i=-1,o=-1,a=!1,l=!1;return t.forEach((c,u)=>{Object.keys(u).forEach(h=>{const d=+h,m=t.getValue(c,d),_=m!=null&&m.s?this._styles.get(m.s):null,p=(_==null?void 0:_.bd)&&(_.bd.b||_.bd.l||_.bd.r||_.bd.t||_.bd.bc_tr||_.bd.bl_tr||_.bd.ml_tr||_.bd.tl_bc||_.bd.tl_br||_.bd.tl_mr);(m&&(m.v||m.p)||_!=null&&_.bg||p)&&(a?r=Math.min(r,c):(r=c,a=!0),s=Math.max(s,c),l?i=Math.min(i,d):(l=!0,i=d),o=Math.max(o,d))})}),n.forEach(c=>{a?r=Math.min(r,c.startRow):(r=c.startRow,a=!0),s=Math.max(s,c.endRow),l?i=Math.min(i,c.startColumn):(i=c.startColumn,a=!0),o=Math.max(o,c.endColumn)}),!a||!l?null:{startColumn:i,startRow:r,endColumn:o,endRow:s}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:t}=this,n=Z.deepClone(t);return new jr(this.unitId,n,this._styles)}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(t,n){return this._spanModel.getMergedCell(t,n)}getMergedCellRange(t,n,r,s){return this._spanModel.getMergedCellRange(t,n,r,s)}isRowContainsMergedCell(t){return this._spanModel.isRowContainsMergedCell(t)}isColumnContainsMergedCell(t){return this._spanModel.isColumnContainsMergedCell(t)}getCellInfoInMergeData(t,n){const r=this.getMergedCell(t,n);let s=!1,i=!1,o=t,a=n,l=t,c=n;if(r){const{startRow:u,endRow:h,startColumn:d,endColumn:m}=r;t===u&&n===d?(o=h,a=m,l=u,c=d,i=!0):t>=u&&t<=h&&n>=d&&n<=m&&(o=h,a=m,l=u,c=d,s=!0)}return{actualRow:t,actualColumn:n,isMergedMainCell:i,isMerged:s,endRow:o,endColumn:a,startRow:l,startColumn:c}}getCell(t,n){return t<0||n<0?null:this._viewModel.getCell(t,n)}getCellValueOnly(t,n){return t<0||n<0?null:this._viewModel.getCellValueOnly(t,n)}getCellStyleOnly(t,n){return t<0||n<0?null:this._viewModel.getCellStyleOnly(t,n)}getCellRaw(t,n){return this.getCellMatrix().getValue(t,n)}getCellWithFilteredInterceptors(t,n,r,s){return this._viewModel.getCell(t,n,r,s)}getRowFiltered(t){return this._viewModel.getRowFiltered(t)}getRangeFilterRows(t){const n=[];for(let r=t.startRow;r<=t.endRow;r++)this.getRowFiltered(r)&&n.push(r);return n}getMatrixWithMergedCells(t,n,r,s,i=Tn.Raw){const o=this.getCellMatrix(),a=this._spanModel.getMergedCellRange(t,n,r,s),l=new ct;return po(t,r,n,s).forEach((c,u)=>{var d;let h;if(i===Tn.Raw)h=this.getCellRaw(c,u);else if(i===Tn.Intercepted)h=this.getCell(c,u);else if(i===Tn.Both){const m=this.getCellRaw(c,u);if(m){h={...m};const _=(d=this.getCell(c,u))==null?void 0:d.v;Dh(_)&&h&&(h.displayV=String(_))}}h&&l.setValue(c,u,h)}),a.forEach(c=>{const{startColumn:u,startRow:h,endColumn:d,endRow:m}=c;po(h,m,u,d).forEach((_,p)=>{_===h&&p===u&&l.setValue(_,p,{...o.getValue(_,p),rowSpan:m-h+1,colSpan:d-u+1}),(_!==h||p!==u)&&l.realDeleteValue(_,p)})}),l}getRange(t,n,r,s){return typeof t=="object"?new xn(this,t,{getStyles:()=>this._styles}):new xn(this,{startRow:t,startColumn:n,endColumn:s||n,endRow:r||t},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:t}=this,{columnCount:n}=t;return n}getMaxRows(){const{_snapshot:t}=this,{rowCount:n}=t;return n}getRowCount(){return this._snapshot.rowCount}setRowCount(t){this._snapshot.rowCount=t}getColumnCount(){return this._snapshot.columnCount}setColumnCount(t){this._snapshot.columnCount=t}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:t}=this,{showGridlines:n}=t;return n===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){const{_snapshot:t}=this,{tabColor:n}=t;return n}getColumnWidth(t){return this.getColumnManager().getColumnWidth(t)}getRowHeight(t){return this._viewModel.getRowFiltered(t)?0:this.getRowManager().getRowHeight(t)}isRowFiltered(t){return this._viewModel.getRowFiltered(t)}getRowVisible(t){return!this.isRowFiltered(t)&&this.getRowRawVisible(t)}getRowRawVisible(t){return this.getRowManager().getRowRawVisible(t)}getHiddenRows(t,n){const r=this.getMaxColumns()-1,s=this._rowManager.getHiddenRows(t,n);return s.forEach(i=>i.endColumn=r),s}getColVisible(t){return this._columnManager.getColVisible(t)}getHiddenCols(t,n){const r=this.getMaxRows()-1,s=this._columnManager.getHiddenCols(t,n);return s.forEach(i=>i.endRow=r),s}getVisibleRows(){const t=this.getRowCount();return this._rowManager.getVisibleRows(0,t-1)}getVisibleCols(){const t=this.getColumnCount();return this._columnManager.getVisibleCols(0,t-1)}isRightToLeft(){const{_snapshot:t}=this,{rightToLeft:n}=t;return n}getLastRowWithContent(){return this._cellData.getLength()-1}getLastColumnWithContent(){return this._cellData.getRange().endColumn}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(t){return t&&(t.v!==void 0||t.f!==void 0||t.p!==void 0)}iterateByRow(t,n=!0){const{startRow:r,startColumn:s,endRow:i,endColumn:o}=t,a=this;return{[Symbol.iterator]:()=>{let l=r,c=s;return{next(){for(;;){if(c>o&&(l+=1,c=s),l>i)return{done:!0,value:void 0};const u=a.getCell(l,c),h=!u,d=a.getMergedCell(l,c);if(d){if(l!==d.startRow||c!==d.startColumn){c=d.endColumn+1;continue}if(h&&n){c=d.endColumn+1;continue}const _={row:l,col:c,value:u};return _.colSpan=d.endColumn-d.startColumn+1,_.rowSpan=d.endRow-d.startRow+1,c=d.endColumn+1,{done:!1,value:_}}if(h&&n)c+=1;else{const m={row:l,col:c,value:u};return c+=1,{done:!1,value:m}}}}}}}}iterateByColumn(t,n=!0,r=!0){const{startRow:s,startColumn:i,endRow:o,endColumn:a}=t,l=this;return{[Symbol.iterator]:()=>{let c=s,u=i;return{next(){for(;;){if(c>o&&(u+=1,c=s),u>a)return{done:!0,value:void 0};const h=l.getMergedCell(c,u);if(h){const _=c!==h.startRow,p=_||u!==h.startColumn;if(r&&p||!r&&_){c=h.endRow+1;continue}const I=l.getCell(h.startRow,h.startColumn);if(!I&&n){c=h.endRow+1;continue}const B={row:c,col:h.startColumn,value:I};return B.colSpan=h.endColumn-h.startColumn+1,B.rowSpan=h.endRow-h.startRow+1,c=h.endRow+1,{done:!1,value:B}}const d=l.getCell(c,u);if(!d&&n)c+=1;else{const _={row:c,col:u,value:d};return c+=1,{done:!1,value:_}}}}}}}}getCellDocumentModel(t,n,r=Yh){var p;if(!t)return;const{isDeepClone:s,displayRawFormula:i,ignoreTextRotation:o}={...Yh,...r};let a,l="document";const c=_R(n),u=o?st.tr:c.textRotation||st.tr;let h=c.horizontalAlign||st.ht;const d=c.verticalAlign||st.vt,m=c.wrapStrategy||st.tb,_=c.paddingData||Qo;if(t.f&&i)a=Wr(t.f.toString(),{},{verticalAlign:d}),h=st.ht;else if(t.p){const{centerAngle:I,vertexAngle:A}=Ph(u);a=this._updateConfigAndGetDocumentModel(s?Z.deepClone(t.p):t.p,h,_,{horizontalAlign:h,verticalAlign:d,centerAngle:I,vertexAngle:A,wrapStrategy:m,zeroWidthParagraphBreak:1})}else if(t.v!=null){const I=Mh(n);l=Uh(I).fontCache;let A=Gh(t);t.t===Xt.FORCE_STRING&&i&&(A=`'${A}`),a=Wr(A,I,{...c,textRotation:u,cellValueType:t.t})}return a&&t.linkUrl&&t.linkId&&Lh(a,t.linkUrl,t.linkId),{documentModel:a,fontString:l,textRotation:u,wrapStrategy:m,verticalAlign:d,horizontalAlign:h,paddingData:_,fill:(p=n==null?void 0:n.bg)==null?void 0:p.rgb}}_updateConfigAndGetDocumentModel(t,n,r,s){var o,a,l,c,u;if(!s||!((o=t.body)!=null&&o.dataStream))return;t.documentStyle||(t.documentStyle={}),t.documentStyle.marginTop=(a=r.t)!=null?a:0,t.documentStyle.marginBottom=(l=r.b)!=null?l:2,t.documentStyle.marginLeft=(c=r.l)!=null?c:2,t.documentStyle.marginRight=(u=r.r)!=null?u:2,t.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},t.documentStyle.renderConfig={...t.documentStyle.renderConfig,...s};const i=t.body.paragraphs||[];for(const h of i)h.paragraphStyle||(h.paragraphStyle={}),h.paragraphStyle.horizontalAlign=n;return new At(t)}getBlankCellDocumentModel(t,n,r){const s=this.getComposedCellStyleByCellData(n,r,t),i=Mh(s),o=this.getCellDocumentModel(t,s,{ignoreTextRotation:!0});if(o!=null)return o.documentModel==null&&(o.documentModel=Wr("",i)),o;const a="";let l="document";const c=st.tr,u=st.ht,h=st.vt,d=st.tb,m=Qo;return l=Uh({}).fontCache,{documentModel:Wr(a,i),fontString:l,textRotation:c,wrapStrategy:d,verticalAlign:h,horizontalAlign:u,paddingData:m}}getCellDocumentModelWithFormula(t,n,r){const s=this.getComposedCellStyleByCellData(n,r,t);return this.getCellDocumentModel(t,s,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(t){this._snapshot.custom=t}}function Gh(e){var r,s;if(!e)return"";const t=(s=(r=e.p)==null?void 0:r.body)==null?void 0:s.dataStream;if(t)return Je.transform.getPlainText(t);const n=e.v;return typeof n=="string"?e.t===Xt.BOOLEAN?n.toUpperCase():n.replace(/[\r\n]/g,""):typeof n=="number"?e.t===Xt.BOOLEAN?n?"TRUE":"FALSE":n.toString():typeof n=="boolean"?n?"TRUE":"FALSE":""}function yR(e){if(e===null)return"";if(e!=null&&e.p){const t=e==null?void 0:e.p.body;if(t==null)return"";const n=t.dataStream;return Je.transform.getPlainText(n)}return e==null?void 0:e.v}var NR=Object.getOwnPropertyDescriptor,MR=(e,t,n,r)=>{for(var s=r>1?void 0:r?NR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},LR=(e,t)=>(n,r)=>t(n,r,e);function DR(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}f.Workbook=class extends Ps{constructor(n={},r){super();C(this,"type",we.UNIVER_SHEET);C(this,"_sheetCreated$",new oe.Subject);C(this,"sheetCreated$",this._sheetCreated$.asObservable());C(this,"_sheetDisposed$",new oe.Subject);C(this,"sheetDisposed$",this._sheetDisposed$.asObservable());C(this,"_activeSheet$",new oe.BehaviorSubject(null));C(this,"activeSheet$",this._activeSheet$.asObservable());C(this,"_worksheets");C(this,"_styles");C(this,"_snapshot");C(this,"_unitId");C(this,"_count");C(this,"_name$");C(this,"name$");this._logService=r;const s=dR();Z.isEmptyObject(n)?this._snapshot=s:this._snapshot=Z.commonExtend(s,n);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=tt(6)),this._unitId=this._snapshot.id,this._styles=new yh(i),this._count=1,this._worksheets=new Map,this._name$=new oe.BehaviorSubject(n.name||""),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(n){return typeof n=="string"||"startRow"in n||"row"in n}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete()}save(){return Z.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(n){this._name$.next(n),this._snapshot.name=n}getUnitId(){return this._unitId}getRev(){var n;return(n=this._snapshot.rev)!=null?n:1}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(n){this._snapshot.rev=n}addWorksheet(n,r,s){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[n])return!1;i[n]=s,o.splice(r,0,n);const a=new jr(this._unitId,s,this._styles);return this._worksheets.set(n,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}getConfig(){return this._snapshot}getIndexBySheetId(n){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>s===n)}getActiveSheet(n){if(!this._activeSheet&&typeof n>"u")throw new Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){const n=this._activeSheet;if(n)return n;const r=this._snapshot.sheetOrder;for(let i=0,o=r.length;i<o;i++){const a=this._worksheets.get(r[i]);if(a&&a.isSheetHidden()!==ae.TRUE)return this.setActiveSheet(a),a}const s=this._worksheets.get(r[0]);return this.setActiveSheet(s),s}setActiveSheet(n){this._activeSheet$.next(n)}removeSheet(n){const r=this._worksheets.get(n);return r?(this._worksheets.delete(n),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(n),1),delete this._snapshot.sheets[n],this._sheetDisposed$.next(r),!0):!1}getActiveSheetIndex(){const{sheetOrder:n}=this._snapshot;return n.findIndex(r=>this._worksheets.get(r)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:n}=this._snapshot;return n.map(r=>this._worksheets.get(r))}getSheetsName(){const{sheetOrder:n}=this._snapshot,r=[];return n.forEach(s=>{const i=this._worksheets.get(s);i&&r.push(i.getName())}),r}getSheetIndex(n){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>n.getSheetId()===s)}getSheetBySheetName(n){const{sheetOrder:r}=this._snapshot,s=r.find(i=>this._worksheets.get(i).getName()===n);return this._worksheets.get(s)}getSheetBySheetId(n){return this._worksheets.get(n)}getSheetByIndex(n){const{sheetOrder:r}=this._snapshot;return this._worksheets.get(r[n])}getHiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden===ae.TRUE).map(n=>n.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden!==ae.TRUE).map(n=>n.getConfig().id)}load(n){this._snapshot=n}checkSheetName(n){return this.getSheetsName().includes(n)}uniqueSheetName(n="Sheet1"){let r=n;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}generateNewSheetName(n){let r=n+this._count;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}_parseWorksheetSnapshots(){const{_snapshot:n,_worksheets:r}=this,{sheets:s,sheetOrder:i}=n;if(Z.isEmptyObject(s)){const o=tt();s[o]={id:o}}for(const o in s){const a=s[o],{name:l}=a;a.name=this.uniqueSheetName(l),a.name!==l&&this._logService.debug("[Workbook]",`The worksheet name ${l} is duplicated, we changed it to ${a.name}. Please fix the problem in your snapshot.`);const c=new jr(this._unitId,a,this._styles);r.set(o,c),i.includes(o)||i.push(o)}this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(n){this._snapshot.custom=n}},f.Workbook=MR([LR(1,_t)],f.Workbook);class ea extends Ps{constructor(n){var r;super();C(this,"type",we.UNIVER_SLIDE);C(this,"_activePage$",new oe.BehaviorSubject(null));C(this,"activePage$",this._activePage$.asObservable());C(this,"_name$");C(this,"name$");C(this,"_snapshot");C(this,"_unitId");this._snapshot={...Bc,...n},this._unitId=(r=this._snapshot.id)!=null?r:tt(6),this._name$=new oe.BehaviorSubject(this._snapshot.title),this.name$=this._name$.asObservable()}get _activePage(){var r,s;const n=this._activePage$.getValue();if(!n){const i=(r=this.getPageOrder())==null?void 0:r[0];return i?(s=this.getPages())==null?void 0:s[i]:null}return n}setName(n){var r;this._snapshot.title=n,this._name$.next(n),this._unitId=(r=this._snapshot.id)!=null?r:tt(6)}getRev(){return 0}incrementRev(){}setRev(n){}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var n;return(n=this._snapshot.body)==null?void 0:n.pages}getPageOrder(){var n;return(n=this._snapshot.body)==null?void 0:n.pageOrder}getPage(n){const r=this.getPages();return r==null?void 0:r[n]}getElementsByPage(n){var r;return(r=this.getPage(n))==null?void 0:r.pageElements}getElement(n,r){var s;return(s=this.getElementsByPage(n))==null?void 0:s[r]}getPageSize(){return this._snapshot.pageSize}getBlankPage(){const n=tt(6);return{id:n,pageType:fo.SLIDE,zIndex:10,title:n,description:"",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}setActivePage(n){this._activePage$.next(n)}getActivePage(){return this._activePage}updatePage(n,r){this._snapshot.body&&(this._snapshot.body.pages[n]=r)}appendPage(n){var i;if(!this._snapshot.body)return;this._snapshot.body.pages[n.id]=n;const r=this._activePage,s=this._snapshot.body.pageOrder.indexOf((i=r==null?void 0:r.id)!=null?i:"");this._snapshot.body.pageOrder.splice(s+1,0,n.id)}}var UR=Object.getOwnPropertyDescriptor,PR=(e,t,n,r)=>{for(var s=r>1?void 0:r?UR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Vh=(e,t)=>(n,r)=>t(n,r,e);const Xn=Re.createIdentifier("univer.current");f.UniverInstanceService=class extends ze{constructor(n,r){super();C(this,"_unitsByType",new Map);C(this,"_createHandler");C(this,"_ctorByType",new Map);C(this,"_currentUnits",new Map);C(this,"_currentUnits$",new oe.BehaviorSubject(this._currentUnits));C(this,"currentUnits$",this._currentUnits$.asObservable());C(this,"_unitAdded$",new oe.Subject);C(this,"unitAdded$",this._unitAdded$.asObservable());C(this,"_unitDisposed$",new oe.Subject);C(this,"unitDisposed$",this._unitDisposed$.asObservable());C(this,"_focused$",new oe.BehaviorSubject(null));C(this,"focused$",this._focused$.asObservable());this._injector=n,this._contextService=r}dispose(){super.dispose(),this._focused$.complete()}__setCreateHandler(n){this._createHandler=n}createUnit(n,r,s){return this._createHandler(n,r,this._ctorByType.get(n),s)}registerCtorForType(n,r){return this._ctorByType.set(n,r),{dispose:()=>{this._ctorByType.delete(n)}}}getCurrentTypeOfUnit$(n){return this.currentUnits$.pipe(oe.map(r=>{var s;return(s=r.get(n))!=null?s:null}),oe.distinctUntilChanged())}getCurrentUnitForType(n){return this._currentUnits.get(n)}getCurrentUnitOfType(n){return this.getCurrentUnitForType(n)}setCurrentUnitForType(n){const r=this._getUnitById(n);if(!r)throw new Error(`[UniverInstanceService]: no document with unitId ${n}!`);this._currentUnits.set(r[1],r[0]),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(n){return this._unitAdded$.pipe(oe.filter(r=>r.type===n))}__addUnit(n,r){var a;const s=n.type;this._unitsByType.has(s)||this._unitsByType.set(s,[]);const i=this._unitsByType.get(s),o=n.getUnitId();if(i.findIndex(l=>l.getUnitId()===o)!==-1)throw new Error(`[UniverInstanceService]: cannot create a unit with the same unit id: ${o}.`);i.push(n),this._unitAdded$.next(n),((a=r==null?void 0:r.makeCurrent)==null||a)&&this.setCurrentUnitForType(n.getUnitId())}getTypeOfUnitDisposed$(n){return this.unitDisposed$.pipe(oe.filter(r=>r.type===n))}getUnit(n,r){var i;const s=(i=this._getUnitById(n))==null?void 0:i[0];return r&&(s==null?void 0:s.type)!==r?null:s}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(we.UNIVER_DOC)}getUniverDocInstance(n){return this.getUnit(n,we.UNIVER_DOC)}getUniverSheetInstance(n){return this.getUnit(n,we.UNIVER_SHEET)}getAllUnitsForType(n){var r;return(r=this._unitsByType.get(n))!=null?r:[]}changeDoc(n,r){const s=this.getAllUnitsForType(we.UNIVER_DOC),i=s.find(o=>o.getUnitId()===n);if(i!=null){const o=s.indexOf(i);s.splice(o,1)}this.__addUnit(r)}get focused(){var r;const n=this._focused$.getValue();return n?(r=this._getUnitById(n))==null?void 0:r[0]:null}focusUnit(n){this._focused$.next(n),this.focused instanceof f.Workbook?(this._contextService.setContextValue(Br,!0),this._contextService.setContextValue($r,!1),this._contextService.setContextValue(Kn,!0),this._contextService.setContextValue(Hr,!1),this.setCurrentUnitForType(n)):this.focused instanceof At?(this._contextService.setContextValue(Br,!0),this._contextService.setContextValue($r,!0),this._contextService.setContextValue(Kn,!1),this._contextService.setContextValue(Hr,!1),this.setCurrentUnitForType(n)):this.focused instanceof ea?(this._contextService.setContextValue(Br,!0),this._contextService.setContextValue($r,!1),this._contextService.setContextValue(Kn,!1),this._contextService.setContextValue(Hr,!0),this.setCurrentUnitForType(n)):(this._contextService.setContextValue(Br,!1),this._contextService.setContextValue($r,!1),this._contextService.setContextValue(Kn,!1),this._contextService.setContextValue(Hr,!1))}getFocusedUnit(){return this.focused}getUnitType(n){const r=this._getUnitById(n);return r?r[1]:we.UNRECOGNIZED}disposeUnit(n){const r=this._getUnitById(n);if(!r)return!1;const[s,i]=r,o=this._unitsByType.get(i),a=o.indexOf(s);return o.splice(a,1),this._tryResetCurrentOnRemoval(n,i),this._tryResetFocusOnRemoval(n),this._unitDisposed$.next(s),!0}_tryResetCurrentOnRemoval(n,r){const s=this.getCurrentUnitForType(r);(s==null?void 0:s.getUnitId())===n&&(this._currentUnits.set(r,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(n){var r;((r=this.focused)==null?void 0:r.getUnitId())===n&&this._focused$.next(null)}_getUnitById(n){for(const[r,s]of this._unitsByType){const i=s.find(o=>o.getUnitId()===n);if(i)return[i,r]}}},f.UniverInstanceService=PR([Vh(0,Re.Inject(Re.Injector)),Vh(1,An)],f.UniverInstanceService);var ke=(e=>(e[e.Starting=0]="Starting",e[e.Ready=1]="Ready",e[e.Rendered=2]="Rendered",e[e.Steady=3]="Steady",e))(ke||{});const zh={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"};var kR=Object.getOwnPropertyDescriptor,FR=(e,t,n,r)=>{for(var s=r>1?void 0:r?kR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},xR=(e,t)=>(n,r)=>t(n,r,e);class Kh extends Error{constructor(t){super(`[LifecycleService]: lifecycle stage "${zh[t]}" will never be reached!`),this.name="LifecycleUnreachableError"}}f.LifecycleService=class extends ze{constructor(n){super();C(this,"_lifecycle$",new oe.BehaviorSubject(ke.Starting));C(this,"lifecycle$",this._lifecycle$.asObservable());C(this,"_lock",!1);this._logService=n,this._reportProgress(ke.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(n){if(this._lock)throw new Error("[LifecycleService]: cannot set new stage when related logic is all handled!");if(n<this.stage)throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");n!==this.stage&&(this._lock=!0,this._reportProgress(n),this._lifecycle$.next(n),this._lock=!1)}dispose(){this._lifecycle$.complete(),super.dispose()}onStage(n){return oe.firstValueFrom(this.lifecycle$.pipe(oe.filter(r=>r>=n),li(r=>r===n),oe.map(()=>{}))).catch(r=>r.name==="EmptyError"?Promise.reject(new Kh(n)):Promise.reject(r))}subscribeWithPrevious(){return oe.merge(Xh(this.stage),this._lifecycle$.pipe(oe.skip(1))).pipe(li(n=>n===ke.Steady))}_reportProgress(n){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${zh[n]}".`)}},f.LifecycleService=FR([xR(0,_t)],f.LifecycleService);function Xh(e){switch(e){case ke.Starting:return oe.of(ke.Starting);case ke.Ready:return oe.of(ke.Starting,ke.Ready);case ke.Rendered:return oe.of(ke.Starting,ke.Ready,ke.Rendered);default:return oe.of(ke.Starting,ke.Ready,ke.Rendered,ke.Steady)}}const BR=Re.createIdentifier("ILocalStorageService");class Sn extends ze{constructor(){super();C(this,"_currentLocale$",new oe.BehaviorSubject(ar.ZH_CN));C(this,"currentLocale$",this._currentLocale$.asObservable());C(this,"_locales",null);C(this,"localeChanged$",new oe.Subject);C(this,"t",(n,...r)=>{if(!this._locales)throw new Error("[LocaleService]: Locale not initialized");const s=n.split("."),i=this.resolveKeyPath(this._locales[this._currentLocale],s);if(typeof i=="string"){let o=i;return r.forEach((a,l)=>{o=o.replace(`{${l}}`,a)}),o}else return n});this.disposeWithMe(je(()=>{this._locales=null,this._currentLocale$.complete(),this.localeChanged$.complete()}))}get _currentLocale(){return this._currentLocale$.value}load(n){var r;this._locales=Xo((r=this._locales)!=null?r:{},n)}setLocale(n){this._currentLocale$.next(n),this.localeChanged$.next()}getLocales(){var n;return(n=this._locales)==null?void 0:n[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(n,r){const s=r.shift();if(s&&n&&s in n){const i=n[s];return r.length>0&&(typeof i=="object"||Array.isArray(i))?this.resolveKeyPath(i,r):i}return null}}var $R=Object.getOwnPropertyDescriptor,HR=(e,t,n,r)=>{for(var s=r>1?void 0:r?$R(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},WR=(e,t)=>(n,r)=>t(n,r,e);f.MentionIOLocalService=class{constructor(t){this._userManagerService=t}async list(t){return{list:[{type:es.PERSON,mentions:[{objectType:es.PERSON,objectId:this._userManagerService.getCurrentUser().userID,label:this._userManagerService.getCurrentUser().name,metadata:{icon:this._userManagerService.getCurrentUser().avatar}}],metadata:{},title:"PEOPLE"}],page:t.page,size:t.size,total:1}}},f.MentionIOLocalService=HR([WR(0,Re.Inject(Ur))],f.MentionIOLocalService);const qh=Re.createIdentifier("univer.service.mention-io");var ta=(e=>(e.INIT="init",e.FETCHING="fetching",e.DONE="done",e))(ta||{});const Zh=Re.createIdentifier("univer.permission-service");class Jh extends ze{constructor(){super(...arguments);C(this,"_permissionPointMap",new Map);C(this,"_permissionPointUpdate$",new oe.Subject);C(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable());C(this,"_showComponents",!0)}setShowComponents(n){this._showComponents=n}getShowComponents(){return this._showComponents}deletePermissionPoint(n){const r=this._permissionPointMap.get(n);r&&(r.complete(),this._permissionPointMap.delete(n))}addPermissionPoint(n){const r=n instanceof oe.BehaviorSubject,s=r?n.getValue():n;if(!s.id)return!1;if(this._permissionPointMap.get(s.id))throw new Error(`${s.id} PermissionPoint already exists`);return this._permissionPointMap.set(s.id,r?n:new oe.BehaviorSubject(s)),this._permissionPointUpdate$.next(s),!0}updatePermissionPoint(n,r){const s=this._permissionPointMap.get(n);if(!s)return;const i=s.getValue();i.value=r,i.status=ta.DONE,s.next(i),this._permissionPointUpdate$.next(i)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(n){const r=this._permissionPointMap.get(n);if(r)return r.getValue()}getPermissionPoint$(n){const r=this._permissionPointMap.get(n);if(r)return r}composePermission$(n){const r=n.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.asObservable()});return oe.combineLatest(r).pipe(Kr.map(s=>s))}composePermission(n){return n.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.getValue()})}getAllPermissionPoint(){const n=new Map;return this._permissionPointMap.forEach((r,s)=>{n.set(s,r)}),n}}function Qh(e,t){if(!t)return e;const n=[];for(const r of e){const s=t.find(([i])=>i===r[0]);if(s){if(s[1]===null)continue;n.push([r[0],s[1]])}else n.push(r)}return n}var jR=Object.getOwnPropertyDescriptor,YR=(e,t,n,r)=>{for(var s=r>1?void 0:r?jR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},na=(e,t)=>(n,r)=>t(n,r,e);const GR=4,ed=Symbol("DependentOn");class ra extends ze{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}C(ra,"pluginName"),C(ra,"type",we.UNIVER_UNKNOWN);class VR{constructor(){C(this,"_plugins",[])}addPlugin(t){this._plugins.push(t)}removePlugins(){const t=this._plugins.slice();return this._plugins.length=0,t}forEachPlugin(t){this._plugins.forEach(t)}}function zR(...e){return function(t){t[ed]=e}}f.PluginService=class{constructor(t,n,r){C(this,"_pluginRegistry",new Map);C(this,"_pluginStore",new VR);C(this,"_seenPlugins",new Set);C(this,"_loadedPlugins",new Set);C(this,"_loadedPluginTypes",new Set([we.UNIVER_UNKNOWN]));C(this,"_flushTimerByType",new Map);this._injector=t,this._lifecycleService=n,this._logService=r}dispose(){this._pluginStore.removePlugins().forEach(t=>t.dispose()),this._flushTimerByType.forEach(t=>clearTimeout(t))}registerPlugin(t,n){this._assertPluginValid(t);const r={plugin:t,options:n};this._pluginRegistry.set(t.pluginName,r),this._logService.debug("[PluginService]",`Plugin "${t.pluginName}" registered.`);const{type:s}=t;this._loadedPluginTypes.has(s)&&(s===we.UNIVER_UNKNOWN?this._loadFromPlugins([r]):this._flushType(s))}startPluginsForType(t){this._loadedPluginTypes.has(t)||this._loadPluginsForType(t)}_loadPluginsForType(t){const n=Array.from(this._pluginRegistry.keys()),r=[];n.forEach(s=>{const i=this._pluginRegistry.get(s);i.plugin.type===t&&r.push(i)}),this._loadFromPlugins(r),this._loadedPluginTypes.add(t)}_assertPluginValid(t){const{type:n,pluginName:r}=t;if(n===we.UNRECOGNIZED)throw new Error(`[PluginService]: invalid plugin type for ${t.name}. Please assign a "type" to your plugin.`);if(!r)throw new Error(`[PluginService]: no plugin name for ${t.name}. Please assign a "pluginName" to your plugin.`);if(this._seenPlugins.has(r))throw new Error(`[PluginService]: duplicated plugin name for "${r}". Maybe a plugin that dependents on "${r} has already registered it. In that case please register "${r}" before the that plugin.`);this._seenPlugins.add(t.pluginName)}_flushType(t){this._flushTimerByType.get(t)===void 0&&this._flushTimerByType.set(t,setTimeout(()=>{this._loadPluginsForType(t),this._flushTimerByType.delete(t)},GR))}_loadFromPlugins(t){const n=[],r=new Set,s=o=>{const{plugin:a}=o,{pluginName:l}=a;if(this._loadedPlugins.has(l)||r.has(l))return;r.add(l),this._pluginRegistry.delete(l);const c=a[ed];c&&c.forEach(u=>{const h=this._pluginRegistry.get(u.pluginName);if(h)s(h);else if(!this._seenPlugins.has(u.pluginName)&&!r.has(u.pluginName)){if(a.type===we.UNIVER_UNKNOWN&&u.type!==we.UNIVER_UNKNOWN)throw new Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${a.pluginName} and the dependency is ${u.pluginName}.`);a.type!==u.type&&u.type!==we.UNIVER_UNKNOWN&&this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${u.pluginName}" which has different type.`),this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${u.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(u),s({plugin:u,options:void 0})}}),n.push(o)};t.forEach(o=>s(o));const i=n.map(o=>this._initPlugin(o.plugin,o.options));this._pluginsRunLifecycle(i)}_pluginsRunLifecycle(t){const n=this._lifecycleService.stage;if(Xh(n).subscribe(r=>this._runStage(t,r)),n!==ke.Steady){const r=this._lifecycleService.lifecycle$.pipe(oe.skip(1)).subscribe(s=>{this._runStage(t,s),s===ke.Steady&&r.unsubscribe()})}}_runStage(t,n){t.forEach(r=>{switch(n){case ke.Starting:r.onStarting();break;case ke.Ready:r.onReady();break;case ke.Rendered:r.onRendered();break;case ke.Steady:r.onSteady();break}})}_initPlugin(t,n){const r=this._injector.createInstance(t,n);return this._pluginStore.addPlugin(r),this._loadedPlugins.add(t.pluginName),this._logService.debug("[PluginService]",`Plugin "${r.getPluginName()}" loaded.`),r}},f.PluginService=YR([na(0,Re.Inject(Re.Injector)),na(1,Re.Inject(f.LifecycleService)),na(2,_t)],f.PluginService);const sa=Re.createIdentifier("resource-loader-service");var KR=Object.getOwnPropertyDescriptor,XR=(e,t,n,r)=>{for(var s=r>1?void 0:r?KR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},qR=(e,t)=>(n,r)=>t(n,r,e);f.ResourceManagerService=class extends ze{constructor(n){super();C(this,"_resourceMap",new Map);C(this,"_register$",new oe.Subject);C(this,"register$",this._register$.asObservable());this._logService=n}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(n,r){return r?this.getResourcesByType(n,r):this.getAllResourceHooks().map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}getResourcesByType(n,r){return this.getAllResourceHooks().filter(o=>o.businesses.includes(r)).map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}registerPluginResource(n){const r=n.pluginName;if(this._resourceMap.has(r))throw new Error(`the pluginName is registered {${r}}`);return this._resourceMap.set(r,n),this._register$.next(n),je(()=>this._resourceMap.delete(r))}disposePluginResource(n){this._resourceMap.delete(n)}loadResources(n,r){this.getAllResourceHooks().forEach(s=>{var o;const i=(o=r==null?void 0:r.find(a=>a.name===s.pluginName))==null?void 0:o.data;if(i)try{const a=s.parseJson(i);s.onLoad(n,a)}catch(a){this._logService.error("[ResourceManagerService]","loadResources error",a)}})}unloadResources(n){this.getAllResourceHooks().forEach(r=>{r.onUnLoad(n)})}dispose(){this._register$.complete(),this._resourceMap.clear()}},f.ResourceManagerService=XR([qR(0,_t)],f.ResourceManagerService);class qs extends ze{constructor(){super();C(this,"_darkMode$",new oe.BehaviorSubject(!1));C(this,"darkMode$",this._darkMode$.asObservable());C(this,"_validColorCache",new Map);C(this,"_currentTheme",Xr.defaultTheme);C(this,"_currentTheme$",new oe.BehaviorSubject(this._currentTheme));C(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(je(()=>{this._currentTheme=Xr.defaultTheme,this._currentTheme$.complete(),this._darkMode$.complete()}))}get darkMode(){return this._darkMode$.getValue()}isValidThemeColor(n){if(this._validColorCache.has(n))return this._validColorCache.get(n);let r=!1;const s=n.split(".");if(s.length===1)r=n in Xr.defaultTheme;else if(s.length===2){const[i,o]=s;r=i in Xr.defaultTheme&&o in this._currentTheme[i]}return this._validColorCache.set(n,r),r}getCurrentTheme(){return this._currentTheme}setTheme(n){this._currentTheme=n,this._currentTheme$.next(n)}setDarkMode(n){this._darkMode$.next(n)}getColorFromTheme(n){return ph(this._currentTheme,n)}}var ZR=Object.getOwnPropertyDescriptor,JR=(e,t,n,r)=>{for(var s=r>1?void 0:r?ZR(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},ia=(e,t)=>(n,r)=>t(n,r,e);const Zs=Re.createIdentifier("univer.undo-redo.service"),QR=20;class td{dispose(){}async dispatchToHandlers(){return!1}}const nd="univer.command.redo",rd="univer.command.undo",sd=new class extends td{constructor(){super(...arguments);C(this,"type",rr.COMMAND);C(this,"id",rd)}handler(t){const n=t.get(Zs),r=n.pitchTopUndoElement();if(!r)return!1;const s=t.get(sr);return Qr(r.undoMutations,s)?(n.popUndoToRedo(),!0):!1}},id=new class extends td{constructor(){super(...arguments);C(this,"type",rr.COMMAND);C(this,"id",nd)}handler(t){const n=t.get(Zs),r=n.pitchTopRedoElement();if(!r)return!1;const s=t.get(sr);return Qr(r.redoMutations,s)?(n.popRedoToUndo(),!0):!1}};f.LocalUndoRedoService=class extends ze{constructor(n,r,s){super();C(this,"undoRedoStatus$");C(this,"_undoRedoStatus$",new oe.BehaviorSubject({undos:0,redos:0}));C(this,"_undoStacks",new Map);C(this,"_redoStacks",new Map);C(this,"_batchingStatus",new Map);this._univerInstanceService=n,this._commandService=r,this._contextService=s,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(sd)),this.disposeWithMe(this._commandService.registerCommand(id)),this.disposeWithMe(je(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(je(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(n){const{unitID:r}=n,s=this._getRedoStack(r,!0),i=this._getUndoStack(r,!0);if(s.length=0,this._batchingStatus.has(n.unitID)){const a=this._batchingStatus.get(n.unitID),l=this._pitchUndoElement(n.unitID);a===0||!l?(o(n),this._batchingStatus.set(n.unitID,1)):this._tryBatchingElements(l,n)}else o(n);function o(a){i.push(a),i.length>QR&&i.splice(0,1)}this._updateStatus()}clearUndoRedo(n){const r=this._getRedoStack(n);r&&(r.length=0);const s=this._getUndoStack(n);s&&(s.length=0),this._updateStatus()}pitchTopUndoElement(){const n=this._getFocusedUnitId();return this._pitchUndoElement(n)}pitchTopRedoElement(){const n=this._getFocusedUnitId();return this._pitchRedoElement(n)}_pitchUndoElement(n){const r=this._getUndoStack(n);return r!=null&&r.length?r[r.length-1]:null}_pitchRedoElement(n){const r=this._getRedoStack(n);return r!=null&&r.length?r[r.length-1]:null}popUndoToRedo(){const r=this._getUndoStackForFocused().pop();r&&(this._getRedoStackForFocused().push(r),this._updateStatus())}popRedoToUndo(){const r=this._getRedoStackForFocused().pop();r&&(this._getUndoStackForFocused().push(r),this._updateStatus())}rollback(n,r){const s=r||this._getFocusedUnitId(),i=this._getUndoStack(s),o=i==null?void 0:i[(i==null?void 0:i.length)-1];o&&o.id===n&&(i.pop(),Qr(o.undoMutations,this._commandService))}__tempBatchingUndoRedo(n){if(this._batchingStatus.has(n))throw new Error("[LocalUndoRedoService]: cannot batching undo redo twice at the same time!");return this._batchingStatus.set(n,0),je(()=>this._batchingStatus.delete(n))}_updateStatus(){var i,o;const n=this._getFocusedUnitId(),r=n&&((i=this._undoStacks.get(n))==null?void 0:i.length)||0,s=n&&((o=this._redoStacks.get(n))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:r,redos:s})}_getUndoStack(n,r=!1){let s=this._undoStacks.get(n);return!s&&r&&(s=[],this._undoStacks.set(n,s)),s||null}_getRedoStack(n,r=!1){let s=this._redoStacks.get(n);return!s&&r&&(s=[],this._redoStacks.set(n,s)),s||null}_getUndoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getUndoStack(n,!0)}_getRedoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getRedoStack(n,!0)}_tryBatchingElements(n,r){n.redoMutations.push(...r.redoMutations),n.undoMutations.push(...r.undoMutations)}_getFocusedUnitId(){var o,a,l,c;let n="";const r=this._contextService.getContextValue(Kn),s=this._contextService.getContextValue(bh),i=this._contextService.getContextValue(wh);return r?s?n=ri:i?n=ni:n=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":n=(c=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?c:"",n}},f.LocalUndoRedoService=JR([ia(0,Xn),ia(1,sr),ia(2,An)],f.LocalUndoRedoService);class od{constructor(t,n=100){C(this,"_imageCacheMap");this._injector=t,this._imageCacheMap=new ur(n)}_getImageCacheKey(t,n){return`${t}-${n}`}getImage(t,n,r,s){const i=this._getImageCacheKey(t,n),o=this._imageCacheMap.get(i);return o||((async()=>{const a=new Image,l=this._injector.has(Jo)?this._injector.get(Jo):null;if(t===Zo.UUID)try{a.src=await(l==null?void 0:l.getImage(n))||""}catch(c){console.error(c)}else a.src=n;a.onload=()=>{a.removeAttribute("data-error"),r==null||r()},a.onerror=()=>{a.setAttribute("data-error","true"),s==null||s()},this._imageCacheMap.set(i,a)})(),null)}}function eI(e){return!(e.length===0||e.length>31||e.startsWith("'")||e.endsWith("'")||/[:\\\/\?\*\[\]]/.test(e))}const ad=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],oa=1,Yr=8;class aa{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[n,r]=new Uint8Array(t,0,2);if(n!==219)throw new Error("Data does not appear to be in a KDBush format.");const s=r>>4;if(s!==oa)throw new Error(`Got v${s} data when expected v${oa}.`);const i=ad[r&15];if(!i)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new aa(a,o,i,t)}constructor(t,n=64,r=Float64Array,s){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+n,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=ad.indexOf(this.ArrayType),o=t*2*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);s&&s instanceof ArrayBuffer?(this.data=s,this.ids=new this.IndexArrayType(this.data,Yr,t),this.coords=new this.ArrayType(this.data,Yr+a+l,t*2),this._pos=t*2,this._finished=!0):(this.data=new ArrayBuffer(Yr+o+a+l),this.ids=new this.IndexArrayType(this.data,Yr,t),this.coords=new this.ArrayType(this.data,Yr+a+l,t*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(oa<<4)+i]),new Uint16Array(this.data,2,1)[0]=n,new Uint32Array(this.data,4,1)[0]=t)}add(t,n){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=n,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return la(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,n,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:o,nodeSize:a}=this,l=[0,i.length-1,0],c=[];for(;l.length;){const u=l.pop()||0,h=l.pop()||0,d=l.pop()||0;if(h-d<=a){for(let I=d;I<=h;I++){const A=o[2*I],B=o[2*I+1];A>=t&&A<=r&&B>=n&&B<=s&&c.push(i[I])}continue}const m=d+h>>1,_=o[2*m],p=o[2*m+1];_>=t&&_<=r&&p>=n&&p<=s&&c.push(i[m]),(u===0?t<=_:n<=p)&&(l.push(d),l.push(m-1),l.push(1-u)),(u===0?r>=_:s>=p)&&(l.push(m+1),l.push(h),l.push(1-u))}return c}within(t,n,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:i,nodeSize:o}=this,a=[0,s.length-1,0],l=[],c=r*r;for(;a.length;){const u=a.pop()||0,h=a.pop()||0,d=a.pop()||0;if(h-d<=o){for(let I=d;I<=h;I++)cd(i[2*I],i[2*I+1],t,n)<=c&&l.push(s[I]);continue}const m=d+h>>1,_=i[2*m],p=i[2*m+1];cd(_,p,t,n)<=c&&l.push(s[m]),(u===0?t-r<=_:n-r<=p)&&(a.push(d),a.push(m-1),a.push(1-u)),(u===0?t+r>=_:n+r>=p)&&(a.push(m+1),a.push(h),a.push(1-u))}return l}}function la(e,t,n,r,s,i){if(s-r<=n)return;const o=r+s>>1;ld(e,t,o,r,s,i),la(e,t,n,r,o-1,1-i),la(e,t,n,o+1,s,1-i)}function ld(e,t,n,r,s,i){for(;s>r;){if(s-r>600){const c=s-r+1,u=n-r+1,h=Math.log(c),d=.5*Math.exp(2*h/3),m=.5*Math.sqrt(h*d*(c-d)/c)*(u-c/2<0?-1:1),_=Math.max(r,Math.floor(n-u*d/c+m)),p=Math.min(s,Math.floor(n+(c-u)*d/c+m));ld(e,t,n,_,p,i)}const o=t[2*n+i];let a=r,l=s;for(Gr(e,t,r,n),t[2*s+i]>o&&Gr(e,t,r,s);a<l;){for(Gr(e,t,a,l),a++,l--;t[2*a+i]<o;)a++;for(;t[2*l+i]>o;)l--}t[2*r+i]===o?Gr(e,t,r,l):(l++,Gr(e,t,l,s)),l<=n&&(r=l+1),n<=l&&(s=l-1)}}function Gr(e,t,n,r){ca(e,n,r),ca(t,2*n,2*r),ca(t,2*n+1,2*r+1)}function ca(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function cd(e,t,n,r){const s=e-n,i=t-r;return s*s+i*i}class tI{constructor(t=!1){C(this,"_tree",new Map);C(this,"_oneCellCache",new Map);C(this,"_kdTree",new Map);this._enableOneCellCache=t}dispose(){this.clear()}getTree(t,n){return this._tree.has(t)||this._tree.set(t,new Map),this._tree.get(t).has(n)||this._tree.get(t).set(n,new Ms),this._tree.get(t).get(n)}_getOneCellCache(t,n,r,s){return this._oneCellCache.has(t)||this._oneCellCache.set(t,new Map),this._oneCellCache.get(t).has(n)||this._oneCellCache.get(t).set(n,new Map),this._oneCellCache.get(t).get(n).has(r)||this._oneCellCache.get(t).get(n).set(r,new Map),this._oneCellCache.get(t).get(n).get(r).has(s)||this._oneCellCache.get(t).get(n).get(r).set(s,new Set),this._oneCellCache.get(t).get(n).get(r).get(s)}_removeOneCellCache(t,n,r,s,i){const o=this._oneCellCache.get(t);if(!o)return;const a=o.get(n);if(!a)return;const l=a.get(r);if(!l)return;const c=l.get(s);c&&c.delete(i)}_removeCellCacheByRange(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this._oneCellCache.get(n);if(!o)return;const a=o.get(r);if(!a)return;const{startRow:l,startColumn:c,endRow:u,endColumn:h}=s;for(let d=l;d<=u;d++){const m=a.get(d);if(m)for(let _=c;_<=h;_++){const p=m.get(_);p&&p.delete(i)}}}_insertOneCellCache(t,n,r,s,i){this._getOneCellCache(t,n,r,s).add(i)}_getRdTreeItems(t){const n=[];for(const[r,s]of t)for(const[i,o]of s)n.push({x:i,y:r,ids:o});return n}_searchByOneCellCache(t){var _;const{unitId:n,sheetId:r,range:s}=t,{startRow:i,startColumn:o,endRow:a,endColumn:l}=s,c=(_=this._kdTree.get(n))==null?void 0:_.get(r);if(!c)return[];const{tree:u,items:h}=c,d=u.range(o,i,l,a),m=[];for(const p of d){const I=h[p];m.push(...Array.from(I.ids))}return m}openKdTree(){var t;for(const[n,r]of this._oneCellCache){this._kdTree.has(n)||this._kdTree.set(n,new Map);for(const[s,i]of r){const o=this._getRdTreeItems(i),a=new aa(o.length);(t=this._kdTree.get(n))==null||t.set(s,{tree:a,items:o});for(const l of o)a.add(l.x,l.y);a.finish()}}}closeKdTree(){var t;for(const[n,r]of this._oneCellCache)for(const[s,i]of r)(t=this._kdTree.get(n))==null||t.set(s,void 0)}insert(t){const{unitId:n,sheetId:r,range:s,id:i}=t;if(!n||n.length===0)return;let{startRow:o,endRow:a,startColumn:l,endColumn:c}=s;if(this._enableOneCellCache&&o===a&&l===c){this._insertOneCellCache(n,r,o,l,i);return}const u=this.getTree(n,r);Number.isNaN(o)&&(o=0),Number.isNaN(l)&&(l=0),Number.isNaN(a)&&(a=Number.POSITIVE_INFINITY),Number.isNaN(c)&&(c=Number.POSITIVE_INFINITY),u.insert({minX:l,minY:o,maxX:c,maxY:a,id:i})}bulkInsert(t){for(const n of t)this.insert(n)}*searchGenerator(t){var a;const{unitId:n,sheetId:r,range:s}=t;if(this._enableOneCellCache){const l=this._searchByOneCellCache(t);for(const c of l)yield c}const i=(a=this._tree.get(n))==null?void 0:a.get(r);if(!i)return;const o=i.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(const l of o)yield l.id}bulkSearch(t,n){const r=new Set;for(const s of t)for(const i of this.searchGenerator(s))(n==null?void 0:n.has(i))!==!0&&r.add(i);return r}removeById(t,n){var r,s;n?((r=this._tree.get(t))==null||r.delete(n),(s=this._oneCellCache.get(t))==null||s.delete(n)):(this._tree.delete(t),this._oneCellCache.delete(t))}_removeRTreeItem(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this.getTree(n,r),a=o.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(let l=0;l<a.length;l++)a[l].id===i&&o.remove(a[l])}remove(t){const{unitId:n,sheetId:r,range:s,id:i}=t,{startRow:o,startColumn:a,endRow:l,endColumn:c}=s;this._enableOneCellCache?o===l&&a===c?this._removeOneCellCache(n,r,s.startRow,s.startColumn,i):(this._removeCellCacheByRange(t),this._removeRTreeItem(t)):this._removeRTreeItem(t)}bulkRemove(t){for(const n of t)this.remove(n)}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){const t={};return this._tree.forEach((n,r)=>{t[r]={},n.forEach((s,i)=>{t[r][i]=s.toJSON()})}),t}fromJSON(t){this._tree.clear();for(const n in t){this._tree.set(n,new Map);for(const r in t[n]){const s=new Ms;s.fromJSON(t[n][r]),this._tree.get(n).set(r,s)}}}}function nI(e){return new Promise(t=>setTimeout(t,e))}function rI(e=1){return new Promise(t=>{let n=0;const r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}var sI=Object.getOwnPropertyDescriptor,iI=(e,t,n,r)=>{for(var s=r>1?void 0:r?sI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},oI=(e,t)=>(n,r)=>t(n,r,e);f.Skeleton=class extends ze{constructor(n){super();C(this,"_fontLocale");C(this,"_dirty",!0);this._localeService=n,this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(n){this._dirty=n}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}},f.Skeleton=iI([oI(0,Re.Inject(Sn))],f.Skeleton);var aI=Object.getOwnPropertyDescriptor,lI=(e,t,n,r)=>{for(var s=r>1?void 0:r?aI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Js=(e,t)=>(n,r)=>t(n,r,e);f.SheetSkeleton=class extends f.Skeleton{constructor(n,r,s,i,o,a){super(s);C(this,"_worksheetData");C(this,"_renderRawFormula",!1);C(this,"_cellData");C(this,"_imageCacheMap");C(this,"_skipAutoHeightForMergedCells",!0);C(this,"_rowTotalHeight",0);C(this,"_columnTotalWidth",0);C(this,"_rowHeaderWidth",0);C(this,"_columnHeaderHeight",0);C(this,"_rowHeightAccumulation",[]);C(this,"_columnWidthAccumulation",[]);C(this,"_marginTop",0);C(this,"_marginLeft",0);C(this,"_scaleX");C(this,"_scaleY");C(this,"_scrollX");C(this,"_scrollY");this.worksheet=n,this._styles=r,this._contextService=i,this._configService=o,this._injector=a,this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new od(this._injector),this.initConfig()}initConfig(){var n,r;this._skipAutoHeightForMergedCells=!((n=this._configService.getConfig(Ea))!=null&&n),this.worksheet.setIsRowStylePrecedeColumnStyle((r=this._configService.getConfig(pa))!=null?r:!1)}resetCache(){}getWorksheetConfig(){return this._worksheetData}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(n){this._columnHeaderHeight=n,this._worksheetData.columnHeader.height=n}set rowHeaderWidth(n){this._rowHeaderWidth=n,this._worksheetData.rowHeader.width=n}get rowHeightAccumulation(){return this._rowHeightAccumulation}get rowTotalHeight(){return this._rowTotalHeight}get columnWidthAccumulation(){return this._columnWidthAccumulation}get columnTotalWidth(){return this._columnTotalWidth}get rowHeaderWidth(){return this._rowHeaderWidth}get columnHeaderHeight(){return this._columnHeaderHeight}setMarginLeft(n){this._marginLeft=n}setMarginTop(n){this._marginTop=n}setScale(n,r){this._updateLayout(),this._scaleX=n,this._scaleY=r||n,this._updateLayout()}setScroll(n,r){Z.isDefine(n)&&(this._scrollX=n),Z.isDefine(r)&&(this._scrollY=r)}get scrollX(){return this._scrollX}get scrollY(){return this._scrollY}get scaleX(){return this._scaleX}get scaleY(){return this._scaleY}get rowHeaderWidthAndMarginLeft(){return this.rowHeaderWidth+this._marginLeft}get columnHeaderHeightAndMarginTop(){return this.columnHeaderHeight+this._marginTop}get imageCacheMap(){return this._imageCacheMap}_generateRowMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let c=s;if(this.worksheet.getRowFiltered(l))c=0;else if(a[l]!=null){const u=a[l];if(!u)continue;const{h=s,ah:d,ia:m}=u;(m==null||m===ae.TRUE)&&typeof d=="number"?c=d:c=h,u.hd===ae.TRUE&&(c=0)}i+=c,o.push(i)}return{rowTotalHeight:i,rowHeightAccumulation:o}}_generateColumnMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let c=s;if(a[l]!=null){const u=a[l];if(!u)continue;u.w!=null&&(c=u.w),u.hd===ae.TRUE&&(c=0)}i+=c,o.push(i)}return{columnTotalWidth:i,columnWidthAccumulation:o}}intersectMergeRange(n,r){return!!this.worksheet.getMergedCell(n,r)}_getOverflowBound(n,r,s,i,o=Ot.LEFT){let a=0;if(r>s){const l=this._columnWidthAccumulation.length-1;for(let c=r;c>=s;c--){const u=c,h=this.worksheet.getCell(n,u);if(!pi(h)&&u!==r||this.intersectMergeRange(n,u))return u===r?u:u+1>l?l:u+1;const{startX:d,endX:m}=qn(n,u,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===Ot.CENTER&&u===r?a+=(m-d)/2:a+=m-d,i<a)return u}return r}for(let l=r;l<=s;l++){const c=l,u=this.worksheet.getCell(n,c);if(!pi(u)&&c!==r||this.intersectMergeRange(n,c))return c===r?c:c-1<0?0:c-1;const{startX:h,endX:d}=qn(n,c,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===Ot.CENTER&&c===r?a+=(d-h)/2:a+=d-h,i<a)return c}return s}_updateLayout(){if(!this.dirty)return;const{rowData:n,columnData:r,defaultRowHeight:s,defaultColumnWidth:i,rowCount:o,columnCount:a,rowHeader:l,columnHeader:c}=this._worksheetData,{rowTotalHeight:u,rowHeightAccumulation:h}=this._generateRowMatrixCache(o,n,s),{columnTotalWidth:d,columnWidthAccumulation:m}=this._generateColumnMatrixCache(a,r,i);this._rowHeaderWidth=l.hidden!==ae.TRUE?this._dynamicallyUpdateRowHeaderWidth(l):0,this._columnHeaderHeight=c.hidden!==ae.TRUE?c.height:0,this._rowTotalHeight=u,this._rowHeightAccumulation=h,this._columnTotalWidth=d,this._columnWidthAccumulation=m,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(n){}_dynamicallyUpdateRowHeaderWidth(n){const s=`${this.worksheet.getRowCount()}`.length*8;return Math.max(n.width,s)}_hasUnMergedCellInRow(n,r,s){if(!this.worksheet.getMergeData())return!1;for(let o=r;o<=s;o++){const{isMerged:a,isMergedMainCell:l}=this.worksheet.getCellInfoInMergeData(n,o);if(!a&&!l)return!0}return!1}expandRangeByMerge(n){let{startRow:r,startColumn:s,endRow:i,endColumn:o}=n;const a=this._worksheetData.mergeData;if(!a)return{startRow:r,startColumn:s,endRow:i,endColumn:o};let l=!0;const c=new ct;for(;l;){l=!1;for(let u=0;u<a.length;u++){const{startRow:h,startColumn:d,endRow:m,endColumn:_}=a[u];if(c.getValue(h,d))continue;Yc({startColumn:s,startRow:r,endColumn:o,endRow:i},{startColumn:d,startRow:h,endColumn:_,endRow:m})&&(r=Math.min(r,h),s=Math.min(s,d),i=Math.max(i,m),o=Math.max(o,_),c.setValue(h,d,!0),l=!0)}}return{startRow:r,startColumn:s,endRow:i,endColumn:o}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(n,r){return this.worksheet.getCellInfoInMergeData(n,r)}getNoMergeCellPositionByIndex(n,r,s=!0){return this.getNoMergeCellWithCoordByIndex(n,r,s)}getNoMergeCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this;let{startY:c,endY:u,startX:h,endX:d}=qn(n,r,i,o);return s&&(c+=l,u+=l,h+=a,d+=a),{startY:c,endY:u,startX:h,endX:d}}getNoMergeCellPositionByIndexWithNoHeader(n,r){const{rowHeightAccumulation:s,columnWidthAccumulation:i}=this,{startY:o,endY:a,startX:l,endX:c}=qn(n,r,s,i);return{startY:o,endY:a,startX:l,endX:c}}getRowIndexByOffsetY(n,r,s,i){var l;const{rowHeightAccumulation:o}=this;n=hd(n,r,s,this.columnHeaderHeightAndMarginTop);let a=ir(o,n,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(o[a]-n)<Math.abs(n-((l=o[a-1])!=null?l:0))&&(a=a+1),a}getColumnIndexByOffsetX(n,r,s,i){var c;const o=ud(n,r,s,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this;let l=ir(a,o,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(a[l]-o)<Math.abs(o-((c=a[l-1])!=null?c:0))&&(l=l+1),l}getCellIndexByOffset(n,r,s,i,o,a){const l=this.getRowIndexByOffsetY(r,i,o,a),c=this.getColumnIndexByOffsetX(n,s,o,a);return{row:l,column:c}}getCellByOffset(n,r,s,i,o){const a=this==null?void 0:this.getCellIndexByOffset(n,r,s,i,o,{firstMatch:!0});return a?this.worksheet.getCellInfoInMergeData(a.row,a.column):null}getCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this,c=qn(n,r,i,o,this.worksheet.getCellInfoInMergeData(n,r)),{isMerged:u,isMergedMainCell:h}=c;let{startY:d,endY:m,startX:_,endX:p,mergeInfo:I}=c,A=a,B=l;return s===!1&&(A=0,B=0),d+=B,m+=B,_+=A,p+=A,I.startY+=B,I.endY+=B,I.startX+=A,I.endX+=A,{actualRow:n,actualColumn:r,startX:_,startY:d,endX:p,endY:m,isMerged:u,isMergedMainCell:h,mergeInfo:I}}getCellWithCoordByOffset(n,r,s,i,o,a){const{row:l,column:c}=this.getCellIndexByOffset(n,r,s,i,o,a);return this.getCellWithCoordByIndex(l,c)}getOffsetByColumn(n){const{columnWidthAccumulation:r,rowHeaderWidthAndMarginLeft:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetByRow(n){const{rowHeightAccumulation:r,columnHeaderHeightAndMarginTop:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetRelativeToRowCol(n,r){const s=ir(this.columnWidthAccumulation,n);let i=0;s===0?i=n:i=n-this._columnWidthAccumulation[s-1];const o=ir(this.rowHeightAccumulation,r);let a=0;return o===0?a=r:a=r-this._rowHeightAccumulation[o-1],{row:o,column:s,columnOffset:i,rowOffset:a}}_updateConfigAndGetDocumentModel(n,r,s,i){var a,l,c,u,h;if(!i||!((a=n.body)!=null&&a.dataStream))return;n.documentStyle||(n.documentStyle={}),n.documentStyle.marginTop=(l=s.t)!=null?l:0,n.documentStyle.marginBottom=(c=s.b)!=null?c:2,n.documentStyle.marginLeft=(u=s.l)!=null?u:2,n.documentStyle.marginRight=(h=s.r)!=null?h:2,n.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},n.documentStyle.renderConfig={...n.documentStyle.renderConfig,...i};const o=n.body.paragraphs||[];for(const d of o)d.paragraphStyle||(d.paragraphStyle={}),d.paragraphStyle.horizontalAlign=r;return new At(n)}dispose(){super.dispose(),this._rowHeightAccumulation=[],this._columnWidthAccumulation=[],this._rowTotalHeight=0,this._columnTotalWidth=0,this._rowHeaderWidth=0,this._columnHeaderHeight=0,this._worksheetData=null,this._cellData=null,this._styles=null}},f.SheetSkeleton=lI([Js(2,Re.Inject(Sn)),Js(3,An),Js(4,qo),Js(5,Re.Inject(Re.Injector))],f.SheetSkeleton);function ua(e,t,n,r){const s=e-1,i=t-1,o=n[s]||0;let a=n[e];a==null&&(a=n[n.length-1]);const l=r[i]||0;let c=r[t];return c==null&&(c=r[r.length-1]),{startY:o,endY:a,startX:l,endX:c}}function cI(e,t,n,r){return ua(e,t,n,r)}function qn(e,t,n,r,s){e=Z.clamp(e,0,n.length-1),t=Z.clamp(t,0,r.length-1);let{startY:i,endY:o,startX:a,endX:l}=ua(e,t,n,r);if(!s)return{startY:i,endY:o,startX:a,endX:l,isMerged:!1,isMergedMainCell:!1,actualRow:e,actualColumn:t,mergeInfo:{startY:i,endY:o,startX:a,endX:l,startRow:e,startColumn:t,endRow:e,endColumn:t}};const{isMerged:c,isMergedMainCell:u,startRow:h,startColumn:d,endRow:m,endColumn:_}=s;let p={startRow:h,startColumn:d,endRow:m,endColumn:_,startY:i,endY:o,startX:a,endX:l};const I=n.length-1,A=r.length-1;if(c&&h!==-1&&d!==-1){const B=n[h-1]||0,x=n[m]||n[I],Y=r[d-1]||0,O=r[_]||r[A];p={...p,startY:B,endY:x,startX:Y,endX:O}}else if(!c&&m!==-1&&_!==-1){const B=n[m]||n[I],x=r[_]||r[A];p={...p,startY:i,endY:B,startX:a,endX:x}}return{isMerged:c,isMergedMainCell:u,actualRow:e,actualColumn:t,startY:i,endY:o,startX:a,endX:l,mergeInfo:p}}function ud(e,t,n,r){const{x:s}=n;return e/t+s-r}function hd(e,t,n,r){const{y:s}=n;return e=e/t+s-r,e}const uI=["script","style","meta","comment","link"];var dd=(e=>(e[e.INFO=0]="INFO",e[e.STOP=1]="STOP",e[e.WARNING=2]="WARNING",e))(dd||{}),fd=(e=>(e[e.DISABLED=0]="DISABLED",e[e.FULL_ALPHA=1]="FULL_ALPHA",e[e.FULL_HANGUL=2]="FULL_HANGUL",e[e.FULL_KATAKANA=3]="FULL_KATAKANA",e[e.HALF_ALPHA=4]="HALF_ALPHA",e[e.HALF_HANGUL=5]="HALF_HANGUL",e[e.HALF_KATAKANA=6]="HALF_KATAKANA",e[e.HIRAGANA=7]="HIRAGANA",e[e.NO_CONTROL=8]="NO_CONTROL",e[e.OFF=9]="OFF",e[e.ON=10]="ON",e))(fd||{}),md=(e=>(e.BETWEEN="between",e.EQUAL="equal",e.GREATER_THAN="greaterThan",e.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",e.LESS_THAN="lessThan",e.LESS_THAN_OR_EQUAL="lessThanOrEqual",e.NOT_BETWEEN="notBetween",e.NOT_EQUAL="notEqual",e))(md||{}),gd=(e=>(e[e.TEXT=0]="TEXT",e[e.ARROW=1]="ARROW",e[e.CUSTOM=2]="CUSTOM",e))(gd||{}),_d=(e=>(e.VALID="valid",e.INVALID="invalid",e.VALIDATING="validating",e))(_d||{}),pd=(e=>(e.CUSTOM="custom",e.LIST="list",e.LIST_MULTIPLE="listMultiple",e.NONE="none",e.TEXT_LENGTH="textLength",e.DATE="date",e.TIME="time",e.WHOLE="whole",e.DECIMAL="decimal",e.CHECKBOX="checkbox",e.ANY="any",e))(pd||{}),hI=Object.getOwnPropertyDescriptor,dI=(e,t,n,r)=>{for(var s=r>1?void 0:r?hI(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Ed=(e,t)=>(n,r)=>t(n,r,e);let ha=class extends ze{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){const e=n=>{n.businesses.forEach(r=>{switch(r){case we.UNRECOGNIZED:case we.UNIVER_UNKNOWN:case we.UNIVER_SLIDE:case we.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType(we.UNIVER_DOC).forEach(s=>{const o=(s.getSnapshot().resources||[]).find(a=>a.name===n.pluginName);if(o)try{const a=n.parseJson(o.data);n.onLoad(s.getUnitId(),a)}catch{console.error(`Load Document{${s.getUnitId()}} Resources{${n.pluginName}} Data Error.`)}});break}case we.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(we.UNIVER_SHEET).forEach(s=>{const o=(s.getSnapshot().resources||[]).find(a=>a.name===n.pluginName);if(o)try{const a=n.parseJson(o.data);n.onLoad(s.getUnitId(),a)}catch{console.error(`Load Workbook{${s.getUnitId()}} Resources{${n.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(n=>e(n)),this.disposeWithMe(this._resourceManagerService.register$.subscribe(n=>e(n))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(we.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(we.UNIVER_DOC).subscribe(n=>{const r=n.getUnitId();Ca(r)||this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(we.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(we.UNIVER_DOC).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())}))}saveUnit(e){const t=this._univerInstanceService.getUnit(e);if(!t)return null;const n=this._resourceManagerService.getResources(e,t.type),r=Z.deepClone(t.getSnapshot());return r.resources=n,r}};ha=dI([Ed(0,Re.Inject(js)),Ed(1,Re.Inject(Xn))],ha);class fI{constructor(t={},n){C(this,"_startedTypes",new Set);C(this,"_injector");C(this,"_disposingCallbacks",new Jr);const r=this._injector=mI(n,t==null?void 0:t.override),{theme:s,darkMode:i,locale:o,locales:a,logLevel:l}=t;s&&this._injector.get(qs).setTheme(s),i&&this._injector.get(qs).setDarkMode(i),a&&this._injector.get(Sn).load(a),o&&this._injector.get(Sn).setLocale(o),l&&this._injector.get(_t).setLogLevel(l),this._init(r)}get _univerInstanceService(){return this._injector.get(Xn)}get _pluginService(){return this._injector.get(f.PluginService)}__getInjector(){return this._injector}onDispose(t){const n=this._disposingCallbacks.add(je(t));return je(()=>n.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(t){this._injector.get(Sn).setLocale(t)}createUnit(t,n){return this._univerInstanceService.createUnit(t,n)}createUniverSheet(t){return this._injector.get(_t).warn("[Univer]","Univer.createUniverSheet is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(we.UNIVER_SHEET,t)}createUniverDoc(t){return this._injector.get(_t).warn("[Univer]","Univer.createUniverDoc is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(we.UNIVER_DOC,t)}createUniverSlide(t){return this._injector.get(_t).warn("[Univer]","Univer.createUniverSlide is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(we.UNIVER_SLIDE,t)}_init(t){this._univerInstanceService.registerCtorForType(we.UNIVER_SHEET,f.Workbook),this._univerInstanceService.registerCtorForType(we.UNIVER_DOC,At),this._univerInstanceService.registerCtorForType(we.UNIVER_SLIDE,ea);const n=t.get(Xn);n.__setCreateHandler((r,s,i,o)=>{if(!this._startedTypes.has(r)){this._pluginService.startPluginsForType(r),this._startedTypes.add(r);const l=t.createInstance(i,s);return n.__addUnit(l,o),this._tryProgressToReady(),l}const a=t.createInstance(i,s);return n.__addUnit(a,o),a})}_tryProgressToReady(){this._injector.get(f.LifecycleService).stage<ke.Ready&&(this._injector.get(f.LifecycleService).stage=ke.Ready)}registerPlugin(t,n){this._pluginService.registerPlugin(t,n)}}function mI(e,t){const n=Qh([[Ah],[Sn],[qs],[f.LifecycleService],[f.PluginService],[Ur],[Xn,{useClass:f.UniverInstanceService}],[Zh,{useClass:Jh}],[_t,{useClass:Ma,lazy:!0}],[sr,{useClass:f.CommandService}],[Zs,{useClass:f.LocalUndoRedoService,lazy:!0}],[qo,{useClass:vh}],[An,{useClass:ya}],[js,{useClass:f.ResourceManagerService,lazy:!0}],[sa,{useClass:ha,lazy:!0}],[$u,{useClass:f.AuthzIoLocalService}],[qh,{useClass:f.MentionIOLocalService,lazy:!0}]],t),r=e?e.createChild(n):new Re.Injector(n);return Ra(r,[[Ur],[sa]]),r}bd(),f.ABCToNumber=M_,f.AUTO_HEIGHT_FOR_MERGED_CELLS=Ea,f.AbsoluteRefType=Ne,f.ActionIterator=jn,f.AlignTypeH=Mc,f.AlignTypeV=Lc,f.ArrangeTypeEnum=Pc,f.ArrowsAndMarkersShapes=Xa,f.AsyncInterceptorManager=zd,f.AsyncLock=kd,f.AutoFillSeries=xa,f.BaselineOffset=$t,f.BasicShapes=Ka,f.BlockType=hc,f.BooleanNumber=ae,f.BorderStyleTypes=Ue,f.BorderType=Ba,f.BuildTextUtils=Je,f.BulletAlignment=Or,f.COLORS=hi,f.CanceledError=Hd,f.CellModeEnum=Tn,f.CellValueType=Xt,f.Color=fn,f.ColorBuilder=is,f.ColorKit=vt,f.ColorType=pt,f.ColumnSeparatorType=mc,f.CommandType=rr,f.CommonHideTypes=$a,f.ConfigService=vh,f.ContextService=ya,f.CopyPasteType=Ha,f.CustomCommandExecutionError=qr,f.CustomDecorationType=_n,f.CustomRangeType=en,f.DEFAULT_CELL=a_,f.DEFAULT_DOC=yo,f.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=Qp,f.DEFAULT_EMPTY_DOCUMENT_VALUE=_a,f.DEFAULT_NUMBER_FORMAT=lc,f.DEFAULT_RANGE=i_,f.DEFAULT_RANGE_ARRAY=s_,f.DEFAULT_SELECTION=o_,f.DEFAULT_SLIDE=Bc,f.DEFAULT_STYLES=st,f.DEFAULT_TEXT_FORMAT=oc,f.DEFAULT_TEXT_FORMAT_EXCEL=ac,f.DEFAULT_WORKSHEET_COLUMN_COUNT=Fh,f.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=OR,f.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Hh,f.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=AR,f.DEFAULT_WORKSHEET_COLUMN_WIDTH=Bh,f.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=wR,f.DEFAULT_WORKSHEET_ROW_COUNT=kh,f.DEFAULT_WORKSHEET_ROW_COUNT_KEY=SR,f.DEFAULT_WORKSHEET_ROW_HEIGHT=xh,f.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=vR,f.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=$h,f.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=bR,f.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=ri,f.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=ni,f.DOCS_ZEN_EDITOR_UNIT_ID_KEY=ga,f.DOC_DRAWING_PRINTING_COMPONENT_KEY=d_,f.DOC_RANGE_TYPE=ul,f.DashStyleType=Rc,f.DataStreamTreeNodeType=Lu,f.DataStreamTreeTokenType=lt,f.DataValidationErrorStyle=dd,f.DataValidationImeMode=fd,f.DataValidationOperator=md,f.DataValidationRenderMode=gd,f.DataValidationStatus=_d,f.DataValidationType=pd,f.DeleteDirection=Wa,f.DependentOn=zR,f.DesktopLogService=Ma,f.DeveloperMetadataVisibility=ja,f.Dimension=Ya,f.Direction=Ga,f.Disposable=ze,f.DisposableCollection=Jr,f.DocStyleType=cc,f.DocumentDataModel=At,f.DocumentFlavor=ho,f.DrawingTypeEnum=kc,f.EDITOR_ACTIVATED=wh,f.EXTENSION_NAMES=$c,f.ErrorService=Ah,f.EventState=xu,f.EventSubject=eE,f.FOCUSING_COMMON_DRAWINGS=cR,f.FOCUSING_DOC=$r,f.FOCUSING_EDITOR_BUT_HIDDEN=rR,f.FOCUSING_EDITOR_INPUT_FORMULA=sR,f.FOCUSING_EDITOR_STANDALONE=oR,f.FOCUSING_FX_BAR_EDITOR=bh,f.FOCUSING_PANEL_EDITOR=aR,f.FOCUSING_SHEET=Kn,f.FOCUSING_SLIDE=Hr,f.FOCUSING_UNIT=Br,f.FOCUSING_UNIVER_EDITOR=iR,f.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=lR,f.FORMULA_EDITOR_ACTIVATED=uR,f.FollowNumberWithType=uc,f.FontItalic=ts,f.FontStyleType=kn,f.FontWeight=ns,f.GridType=dc,f.HLSColor=il,f.HorizontalAlign=Ot,f.IAuthzIoService=$u,f.ICommandService=sr,f.IConfigService=qo,f.IContextService=An,f.IImageIoService=Jo,f.ILocalStorageService=BR,f.ILogService=_t,f.IMentionIOService=qh,f.IPermissionService=Zh,f.IResourceLoaderService=sa,f.IResourceManagerService=js,f.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=pa,f.IUndoRedoService=Zs,f.IUniverInstanceService=Xn,f.ImageCacheMap=od,f.ImageSourceType=Zo,f.ImageUploadStatusType=Th,f.InterceptorEffectEnum=bn,f.InterceptorManager=Yd,f.InterpolationPointType=Va,f.JSON1=Y_,f.JSONX=Wt,f.LRUHelper=hr,f.LRUMap=ur,f.LifecycleStages=ke,f.LifecycleUnreachableError=Kh,f.ListGlyphType=fe,f.LocaleService=Sn,f.LocaleType=ar,f.LogLevel=Na,f.MOVE_BUFFER_VALUE=or,f.MemoryCursor=un,f.MentionType=es,f.NAMED_STYLE_MAP=c_,f.NAMED_STYLE_SPACE_MAP=u_,f.NamedStyleType=qe,f.NilCommand=Da,f.NumberUnitType=Nc,f.ObjectMatrix=ct,f.ObjectRelativeFromH=Tc,f.ObjectRelativeFromV=yc,f.OtherShapes=qa,f.PAGE_SIZE=f_,f.PAPER_TYPES=r_,f.PRESET_LIST_TYPE=Nr,f.PRINT_CHART_COMPONENT_KEY=h_,f.PageElementType=Fc,f.PageOrientType=Uc,f.PageType=fo,f.PaperType=dt,f.ParagraphElementType=_c,f.ParagraphStyleBuilder=Dr,f.ParagraphStyleValue=Lr,f.PermissionService=Jh,f.PermissionStatus=ta,f.Plugin=ra,f.PositionedObjectLayoutType=Ec,f.PresetListType=Ft,f.ProtectionType=za,f.QuickListType=Ru,f.QuickListTypeMap=q_,f.RANGE_DIRECTION=cl,f.RANGE_TYPE=pe,f.RBush=Ms,f.RCDisposable=hf,f.RGBA_PAREN=Hf,f.RGB_PAREN=$f,f.ROTATE_BUFFER_VALUE=Fa,f.RTree=tI,f.Range=xn,f.Rectangle=tn,f.RedoCommand=id,f.RedoCommandId=nd,f.RefAlias=N_,f.Registry=oi,f.RegistryAsMap=ai,f.RelativeDate=Ja,f.RelativeSlideLink=xc,f.RgbColor=os,f.RichTextBuilder=Cn,f.RichTextValue=sn,f.RxDisposable=uf,f.SHEET_EDITOR_UNITS=l_,f.SectionType=fc,f.SheetTypes=Qa,f.SheetViewModel=jh,f.SliceBodyType=Ao,f.SlideDataModel=ea,f.SpacingRule=Cc,f.SpecialShapes=Za,f.Styles=yh,f.THEME_COLORS=sl,f.TabStopAlignment=Ic,f.TableAlignmentType=Oc,f.TableLayoutType=vc,f.TableRowHeightRule=bc,f.TableSizeType=Sc,f.TableTextWrapType=wc,f.TextDecoration=el,f.TextDecorationBuilder=rn,f.TextDirection=lr,f.TextDirectionType=gc,f.TextStyleBuilder=nn,f.TextStyleValue=Mr,f.TextX=Me,f.TextXActionType=J,f.ThemeColor=as,f.ThemeColorType=ot,f.ThemeColors=rs,f.ThemeService=qs,f.Tools=Z,f.UndoCommand=sd,f.UndoCommandId=rd,f.UnitModel=Ps,f.Univer=fI,f.UniverInstanceType=we,f.UpdateDocsAttributeType=Ce,f.UserManagerService=Ur,f.VerticalAlign=hn,f.VerticalAlignmentType=Ac,f.Worksheet=jr,f.WrapStrategy=dn,f.WrapTextType=pc,f.addLinkToDocumentModel=Lh,f.afterInitApply=If,f.afterTime=Cf,f.awaitTime=nI,f.binSearchFirstGreaterThanTarget=ka,f.binarySearchArray=Sf,f.bufferDebounceTime=Ef,f.cellToRange=pm,f.characterSpacingControlType=Dc,f.checkForSubstrings=Cm,f.checkIfMove=vf,f.checkParagraphHasBullet=tg,f.checkParagraphHasIndent=ng,f.checkParagraphHasIndentByStyle=vl,f.codeToBlob=Of,f.composeBody=To,f.composeInterceptors=Sa,f.composeStyles=cr,f.concatMatrixArray=om,f.convertBodyToHtml=Bf,f.convertCellToRange=hl,f.convertObservableToBehaviorSubject=Rf,f.covertCellValue=Ei,f.covertCellValues=Em,f.covertTextRunToHtml=ui,f.createAsyncInterceptorKey=Gd,f.createDefaultUser=Ys,f.createDocumentModelWithStyle=Wr,f.createInterceptorKey=jd,f.createInternalEditorID=Bd,f.createRowColIter=po,f.dayjs=Ht,f.debounce=qC,f.dedupe=Ad,f.dedupeBy=Td,f.deepCompare=Ci,f.delayAnimationFrame=rI,f.deleteContent=bl,f.extractPureTextFromCell=Gh,f.fromCallback=Ua,f.fromEventSubject=tE,f.fromObservable=cf,f.generateRandomId=tt,f.get=ph,f.getArrayLength=Zt,f.getBodySlice=bt,f.getBodySliceHtml=ss,f.getBorderStyleType=mm,f.getCellCoordByIndexSimple=ua,f.getCellInfoInMergeData=sm,f.getCellPositionByIndexSimple=cI,f.getCellValueType=tm,f.getCellWithCoordByIndexCore=qn,f.getColorStyle=Dt,f.getCustomBlockSlice=wu,f.getCustomDecorationSlice=Au,f.getCustomRangeSlice=bu,f.getDocsUpdateBody=gm,f.getIntersectRange=Yc,f.getOriginCellValue=yR,f.getParagraphsSlice=vu,f.getPlainText=Ws,f.getReverseDirection=wf,f.getSectionBreakSlice=ip,f.getTableSlice=Ou,f.getTextRunSlice=Hs,f.getTransformOffsetX=ud,f.getTransformOffsetY=hd,f.getWorksheetUID=DR,f.groupBy=Md,f.handleStyleToString=fm,f.hashAlgorithm=sg,f.horizontalLineSegmentsSubtraction=Cs,f.insertMatrixArray=mi,f.insertTextToContent=wl,f.invertColorByHSL=Qd,f.invertColorByMatrix=tf,f.isBlackColor=Qf,f.isBooleanString=xd,f.isCellCoverable=pi,f.isCellV=ll,f.isDefaultFormat=t_,f.isEmptyCell=dl,f.isFormulaId=dm,f.isFormulaString=fl,f.isICellData=al,f.isInternalEditorID=Ca,f.isNodeEnv=xf,f.isNotNullOrUndefined=Dh,f.isNullCell=nm,f.isNumeric=ba,f.isPatternEqualWithoutDecimal=n_,f.isRangesEqual=fR,f.isRealNum=rg,f.isSafeNumeric=rf,f.isSameStyleTextRun=ml,f.isTextFormat=e_,f.isUnitRangesEqual=mR,f.isValidRange=_m,f.isWhiteColor=em,f.makeArray=Ld,f.makeCellRangeToRangeData=hm,f.makeCellToSelection=um,f.makeCustomRangeStream=Cp,f.mapObjectMatrix=im,f.merge=Xo,f.mergeOverrideWithDependencies=Qh,f.mergeSets=af,f.mergeWith=eR,f.mergeWorksheetSnapshotWithDefault=Wh,f.mixinClass=nf,f.moveMatrixArray=_i,f.moveRangeByOffset=R_,f.nameCharacterCheck=eI,f.normalizeBody=op,f.normalizeTextRuns=yr,f.numberToABC=D_,f.numberToListABC=U_,f.numfmt=Qg,f.queryObjectMatrix=y_,f.registerDependencies=$d,f.remove=tr,f.repeatStringNumTimes=Kc,f.replaceInDocumentBody=Zp,f.requestImmediateMacroTask=of,f.rotate=Nd,f.searchArray=ir,f.searchInOrderedArray=Pa,f.selectionToArray=rm,f.sequence=Ta,f.sequenceAsync=Aa,f.sequenceExecute=Qr,f.sequenceExecuteAsync=pf,f.set=nR,f.shallowEqual=Ia,f.skipParseTagNames=uI,f.sliceMatrixArray=am,f.sortRules=P_,f.sortRulesByDesc=k_,f.sortRulesFactory=Ar,f.spliceArray=gi,f.splitIntoGrid=_o,f.takeAfter=li,f.textDiff=Mo,f.throttle=Wd,f.toDisposable=je,f.touchDependencies=Ra,f.updateAttributeByDelete=Tu,f.updateAttributeByInsert=yu,f.willLoseNumericPrecision=sf,Object.keys(Re).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(f,e)&&Object.defineProperty(f,e,{enumerable:!0,get:()=>Re[e]})}),Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});