@univerjs/core 0.6.6 → 0.6.7

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
@@ -5,6 +5,6 @@
5
5
  `)===r?ve.TRUE:ve.FALSE}const fr=class fr{constructor(t,n,r){R(this,"_range");R(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 Ot;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 Ot;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=re.numToWord(r+1)+(t+1),o=re.numToWord(s+1)+(n+1)):(i=re.numToWord(s+1)+(n+1),o=re.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)||lt.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 fr(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 u=0;u<=r-n;u++)for(let c=0;c<=i-s;c++){if(o==null||((a=o==null?void 0:o[u])==null?void 0:a[c])==null)continue;const h=o[u][c].s;h&&(o[u][c].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)||lt.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?xr("ul",t.body)===ve.TRUE?{s:ve.TRUE}:{s:ve.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?xr("st",t.body)===ve.TRUE?{s:ve.TRUE}:{s:ve.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?xr("it",t.body)===ve.TRUE?Er.ITALIC:Er.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?xr("bl",t.body)===ve.TRUE?Cr.BOLD:Cr.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()===tn.WRAP?ve.TRUE:ve.FALSE}getWrapStrategies(){return this._getStyles("tb")}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(t){fr.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]||lt[t]}))}};R(fr,"transformRange",(t,n)=>{const r=n.getMaxColumns()-1,s=n.getMaxRows()-1;return t.rangeType===Le.ALL?{startColumn:0,startRow:0,endColumn:r,endRow:s}:t.rangeType===Le.COLUMN?{startRow:0,endRow:s,startColumn:t.startColumn,endColumn:t.endColumn}:t.rangeType===Le.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 gn=fr;function xo(e,t,n=0,r=e.length-1,s=Rd){for(;r>n;){if(r-n>600){const l=r-n+1,u=t-n+1,c=Math.log(l),h=.5*Math.exp(2*c/3),f=.5*Math.sqrt(c*h*(l-h)/l)*(u-l/2<0?-1:1),g=Math.max(n,Math.floor(t-u*h/l+f)),C=Math.min(r,Math.floor(t+(l-u)*h/l+f));xo(e,t,g,C,s)}const i=e[t];let o=n,a=r;for(Yn(e,n,t),s(e[r],i)>0&&Yn(e,n,r);o<a;){for(Yn(e,o,a),o++,a--;s(e[o],i)<0;)o++;for(;s(e[a],i)>0;)a--}s(e[n],i)===0?Yn(e,n,a):(a++,Yn(e,a,r)),a<=t&&(n=a+1),t<=a&&(r=a-1)}}function Yn(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function Rd(e,t){return e<t?-1:e>t?1:0}class $r{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(!Hr(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;Hr(t,l)&&(n.leaf?r.push(a):ws(t,l)?this._all(a,r):i.push(a))}n=i.pop()}return r}collides(t){let n=this.data;if(!Hr(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(Hr(t,o)){if(n.leaf||ws(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,u;for(;r||i.length;){if(r||(r=i.pop(),l=i[i.length-1],a=o.pop(),u=!0),r.leaf){const c=Id(t,r.children,n);if(c!==-1)return r.children.splice(c,1),i.push(r),this._condense(i),this}!u&&!r.leaf&&ws(r,s)?(i.push(r),o.push(a),a=0,l=r,r=r.children[0]):l?(a++,r=l.children[a],u=!1):r=null}return this}toBBox(t){return t}compareMinX(t,n){return t.minX-n.minX}compareMinY(t,n){return t.minY-n.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,n){const r=[];for(;t;)t.leaf?n.push(...t.children):r.push(...t.children),t=r.pop();return n}_build(t,n,r,s){const i=r-n+1;let o=this._maxEntries,a;if(i<=o)return a=_n(t.slice(n,r+1)),mn(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),u=l*Math.ceil(Math.sqrt(o));$o(t,n,r,u,this.compareMinX);for(let c=n;c<=r;c+=u){const h=Math.min(c+u-1,r);$o(t,c,h,l,this.compareMinY);for(let f=c;f<=h;f+=l){const g=Math.min(f+l-1,h);a.children.push(this._build(t,f,g,s-1))}}return mn(a,this.toBBox),a}_chooseSubtree(t,n,r,s){for(;s.push(n),!(n.leaf||s.length-1===r);){let i=1/0,o=1/0,a;for(let l=0;l<n.children.length;l++){const u=n.children[l],c=Os(u),h=Od(t,u)-c;h<o?(o=h,i=c<i?c:i,a=u):h===o&&c<i&&(i=c,a=u)}n=a||n.children[0]}return n}_insert(t,n,r){const s=r?t:this.toBBox(t),i=[],o=this._chooseSubtree(s,this.data,n,i);for(o.children.push(t),Vn(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,mn(r,this.toBBox),mn(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,mn(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=zn(t,0,a,this.toBBox),u=zn(t,a,r,this.toBBox),c=wd(l,u),h=Os(l)+Os(u);c<i?(i=c,s=a,o=h<o?h:o):c===i&&h<o&&(o=h,s=a)}return s||r-n}_chooseSplitAxis(t,n,r){const s=t.leaf?this.compareMinX:Sd,i=t.leaf?this.compareMinY:vd,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=zn(t,0,n,i),a=zn(t,r-n,r,i);let l=Br(o)+Br(a);for(let u=n;u<r-n;u++){const c=t.children[u];Vn(o,t.leaf?i(c):c),l+=Br(o)}for(let u=r-n-1;u>=n;u--){const c=t.children[u];Vn(a,t.leaf?i(c):c),l+=Br(a)}return l}_adjustParentBBoxes(t,n,r){for(let s=r;s>=0;s--)Vn(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():mn(t[n],this.toBBox)}}function Id(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 mn(e,t){zn(e,0,e.children.length,t,e)}function zn(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];Vn(s,e.leaf?r(o):o)}return s}function Vn(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 Sd(e,t){return e.minX-t.minX}function vd(e,t){return e.minY-t.minY}function Os(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function Br(e){return e.maxX-e.minX+(e.maxY-e.minY)}function Od(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 wd(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 ws(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function Hr(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 $o(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;xo(e,o,t,n,s),i.push(t,o,o,n)}}function bd(e,t,n,r=!1){if(t===0&&n===0)return e;let s={...e};const i=s.startAbsoluteRefType||nt.NONE,o=s.endAbsoluteRefType||nt.NONE,a=s.rangeType||Le.NORMAL;if(!r&&i===nt.ALL&&o===nt.ALL)return s;const l=Bo(s.startRow,n,s.startColumn,t,a),u=Bo(s.endRow,n,s.endColumn,t,a);return r||i===nt.NONE&&o===nt.NONE?s={...s,startRow:l.row,startColumn:l.column,endRow:u.row,endColumn:u.column}:(i===nt.NONE?s={...s,startRow:l.row,startColumn:l.column}:i===nt.COLUMN?s={...s,startRow:l.row}:i===nt.ROW&&(s={...s,startColumn:l.column}),o===nt.NONE?s={...s,endRow:u.row,endColumn:u.column}:o===nt.COLUMN?s={...s,endRow:u.row}:o===nt.ROW&&(s={...s,endColumn:u.column}),s)}function Bo(e,t,n,r,s){return s===Le.NORMAL?{row:e+t,column:n+r}:s===Le.ROW?{row:e+t,column:n}:s===Le.COLUMN?{row:e,column:n+r}:{row:e,column:n}}function bs(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],u=r[a+1]-1,c=s[o],h=s[o+1]-1;for(const f of e){if(f.startRow>h)break;if(f.startRow<=c&&f.endRow>=h&&f.startColumn<=l&&f.endColumn>=u){i.push({startColumn:l,endColumn:u,startRow:c,endRow:h});break}}}return i}function yd(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 Ad(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 Td(e){const t=bs(e),n=yd(t);return Ad(n)}function Nd(e,t){const n=[];return e.forEach(r=>{n.push(...Yt.subtract(r,t))}),Yt.mergeRanges(n)}function Ho(e,t){const n=Wo(e.startRow,e.endRow,t.startRow,t.endRow),r=Wo(e.startColumn,e.endColumn,t.startColumn,t.endColumn);if(!n||!r)return null;const[s,i]=n,[o,a]=r,l=Md(e.rangeType,t.rangeType,s,i,o,a);return{startRow:s,endRow:i,startColumn:o,endColumn:a,rangeType:l}}function Wo(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),u=Math.min(i,a);if(l<=u){const c=l===-1/0?Number.NaN:l,h=u===1/0?Number.NaN:u;return[c,h]}else return null}function Md(e,t,n,r,s,i){const o=e!==void 0?e:jo(n,r,s,i),a=t!==void 0?t:jo(n,r,s,i);return o===Le.ALL||a===Le.ALL?o===a?o:o===Le.ALL?a:o:o===a?o:(o===Le.NORMAL||a===Le.NORMAL,Le.NORMAL)}function jo(e,t,n,r){const s=!isNaN(e)&&!isNaN(t),i=!isNaN(n)&&!isNaN(r);return s&&i?Le.NORMAL:s?Le.ROW:i?Le.COLUMN:Le.ALL}const $t=class $t{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===Le.NORMAL||n.rangeType===void 0&&t.rangeType===Le.NORMAL)}static simpleRangesIntersect(t,n){const{startRow:r,endRow:s,startColumn:i,endColumn:o}=t,{startRow:a,endRow:l,startColumn:u,endColumn:c}=n,h=r<=l&&s>=a,f=i<=c&&o>=u;return h&&f}static intersects(t,n){if(t.rangeType===Le.ROW&&n.rangeType===Le.COLUMN||t.rangeType===Le.COLUMN&&n.rangeType===Le.ROW)return!0;if(t.rangeType===Le.ROW&&n.rangeType===Le.ROW)return t.startRow<=n.endRow&&t.endRow>=n.startRow;if(t.rangeType===Le.COLUMN&&n.rangeType===Le.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,u=Number.isNaN(n.endRow)?r:n.endRow,c=Number.isNaN(n.startColumn)?0:n.startColumn,h=Number.isNaN(n.endColumn)?r:n.endColumn,f=Math.abs(o+a-c-h),g=Math.abs(o-a)+Math.abs(c-h),C=Math.abs(s+i-l-u),I=Math.abs(s-i)+Math.abs(l-u);return f<=g&&C<=I}static doAnyRangesIntersect(t,n){const r=new $r;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,u=n.startColumn,c=n.endColumn;let h,f,g,C;if(a<=s)a>=r?f=a:f=r;else return null;if(l>=r)l>=s?C=s:C=l;else return null;if(u<=o)u>i?h=u:h=i;else return null;if(c>=i)c>=o?g=o:g=c;else return null;return{startRow:f,endRow:C,startColumn:h,endColumn:g,rangeType:Le.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 $t.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:Le.NORMAL}),t[0])}static realUnion(...t){const n=t.some(i=>i.rangeType===Le.COLUMN),r=t.some(i=>i.rangeType===Le.ROW),s=$t.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?Le.ROW:n?Le.COLUMN:Le.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 Td(t)}static splitIntoGrid(t){return bs(t)}static subtractMulti(t,n){if(!n.length)return t;let r=t;return n.forEach(s=>{r=Nd(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)}};R($t,"getRelativeRange",(t,n)=>({startRow:t.startRow-n.startRow,endRow:t.endRow-t.startRow,startColumn:t.startColumn-n.startColumn,endColumn:t.endColumn-t.startColumn})),R($t,"getPositionRange",(t,n,r)=>({...r||{},startRow:r&&[nt.ROW,nt.ALL].includes(r.startAbsoluteRefType||0)?r.startRow:t.startRow+n.startRow,endRow:r&&[nt.ROW,nt.ALL].includes(r.endAbsoluteRefType||0)?r.endRow:t.endRow+t.startRow+n.startRow,startColumn:r&&[nt.COLUMN,nt.ALL].includes(r.startAbsoluteRefType||0)?r.startColumn:t.startColumn+n.startColumn,endColumn:r&&[nt.COLUMN,nt.ALL].includes(r.endAbsoluteRefType||0)?r.endColumn:t.endColumn+t.startColumn+n.startColumn})),R($t,"moveHorizontal",(t,n=0,r=0)=>({...t,startColumn:t.startColumn+n,endColumn:t.endColumn+n+r})),R($t,"moveVertical",(t,n=0,r=0)=>({...t,startRow:t.startRow+n,endRow:t.endRow+n+r})),R($t,"moveOffset",(t,n,r)=>({...t,startRow:t.startRow+r,endRow:t.endRow+r,startColumn:t.startColumn+n,endColumn:t.endColumn+n}));let Yt=$t;function Dd(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=Ld(n);o.area>r&&(r=o.area,s={startColumn:o.start,startRow:i-o.height+1,endColumn:o.end,endRow:i})}return s}function Ld(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 Ud(e,t){gn.foreach(t,(n,r)=>{e[n][r]=void 0})}function kd(e,t){const n=e.toFullArray(),r=[];for(;;){const s=Dd(n,t);if(!s)break;r.push(s),Ud(n,s)}return r}class Pd{constructor(t,n){R(this,"_values",[]);R(this,"_keys",[]);R(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 ys(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 Fd(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 Wr=65,Yo=90,xd=97;function $d(e){const t=Yo-Wr+1;let n="";for(;e>=0;)n=String.fromCharCode(e%t+Wr)+n,e=Math.floor(e/t)-1;return n}function zo(e,t){let n="";for(;t>0;)n+=e,t--;return n}function Bd(e,t=!1){const n=Yo-Wr+1;let r=xd;t&&(r=Wr);const s=String.fromCharCode(e%n+r),i=Math.floor(e/n)+1;return zo(s,i)}function Hd(e,t){return e.zIndex>t.zIndex?1:e.zIndex===t.zIndex?0:-1}function Wd(e,t){return e.zIndex>t.zIndex?-1:e.zIndex===t.zIndex?0:1}function Gn(e="index",t=1){return(n,r)=>n[e]>r[e]?t:n[e]===r[e]?0:-t}var Vo=(e=>(e[e.character=0]="character",e[e.paragraph=1]="paragraph",e[e.table=2]="table",e[e.numbering=3]="numbering",e))(Vo||{}),Go=(e=>(e[e.TAB=0]="TAB",e[e.SPACE=1]="SPACE",e[e.NOTHING=2]="NOTHING",e))(Go||{}),Ne=(e=>(e[e.BULLET=0]="BULLET",e[e.NONE=1]="NONE",e[e.DECIMAL=2]="DECIMAL",e[e.DECIMAL_ZERO=3]="DECIMAL_ZERO",e[e.UPPER_LETTER=4]="UPPER_LETTER",e[e.LOWER_LETTER=5]="LOWER_LETTER",e[e.UPPER_ROMAN=6]="UPPER_ROMAN",e[e.LOWER_ROMAN=7]="LOWER_ROMAN",e[e.ORDINAL=8]="ORDINAL",e[e.CARDINAL_TEXT=9]="CARDINAL_TEXT",e[e.ORDINAL_TEXT=10]="ORDINAL_TEXT",e[e.HEX=11]="HEX",e[e.CHICAGO=12]="CHICAGO",e[e.IDEOGRAPH_DIGITAL=13]="IDEOGRAPH_DIGITAL",e[e.JAPANESE_COUNTING=14]="JAPANESE_COUNTING",e[e.AIUEO=15]="AIUEO",e[e.IROHA=16]="IROHA",e[e.DECIMAL_FULL_WIDTH=17]="DECIMAL_FULL_WIDTH",e[e.DECIMAL_HALF_WIDTH=18]="DECIMAL_HALF_WIDTH",e[e.JAPANESE_LEGAL=19]="JAPANESE_LEGAL",e[e.JAPANESE_DIGITAL_TEN_THOUSAND=20]="JAPANESE_DIGITAL_TEN_THOUSAND",e[e.DECIMAL_ENCLOSED_CIRCLE=21]="DECIMAL_ENCLOSED_CIRCLE",e[e.DECIMAL_FULL_WIDTH2=22]="DECIMAL_FULL_WIDTH2",e[e.AIUEO_FULL_WIDTH=23]="AIUEO_FULL_WIDTH",e[e.IROHA_FULL_WIDTH=24]="IROHA_FULL_WIDTH",e[e.GANADA=25]="GANADA",e[e.CHOSUNG=26]="CHOSUNG",e[e.DECIMAL_ENCLOSED_FULLSTOP=27]="DECIMAL_ENCLOSED_FULLSTOP",e[e.DECIMAL_ENCLOSED_PAREN=28]="DECIMAL_ENCLOSED_PAREN",e[e.DECIMAL_ENCLOSED_CIRCLE_CHINESE=29]="DECIMAL_ENCLOSED_CIRCLE_CHINESE",e[e.IDEOGRAPH_ENCLOSED_CIRCLE=30]="IDEOGRAPH_ENCLOSED_CIRCLE",e[e.IDEOGRAPH_TRADITIONAL=31]="IDEOGRAPH_TRADITIONAL",e[e.IDEOGRAPH_ZODIAC=32]="IDEOGRAPH_ZODIAC",e[e.IDEOGRAPH_ZODIAC_TRADITIONAL=33]="IDEOGRAPH_ZODIAC_TRADITIONAL",e[e.TAIWANESE_COUNTING=34]="TAIWANESE_COUNTING",e[e.IDEOGRAPH_LEGAL_TRADITIONAL=35]="IDEOGRAPH_LEGAL_TRADITIONAL",e[e.TAIWANESE_COUNTING_THOUSAND=36]="TAIWANESE_COUNTING_THOUSAND",e[e.TAIWANESE_DIGITAL=37]="TAIWANESE_DIGITAL",e[e.CHINESE_COUNTING=38]="CHINESE_COUNTING",e[e.CHINESE_LEGAL_SIMPLIFIED=39]="CHINESE_LEGAL_SIMPLIFIED",e[e.CHINESE_COUNTING_THOUSAND=40]="CHINESE_COUNTING_THOUSAND",e[e.KOREAN_DIGITAL=41]="KOREAN_DIGITAL",e[e.KOREAN_COUNTING=42]="KOREAN_COUNTING",e[e.KOREAN_LEGAL=43]="KOREAN_LEGAL",e[e.KOREAN_DIGITAL2=44]="KOREAN_DIGITAL2",e[e.VIETNAMESE_COUNTING=45]="VIETNAMESE_COUNTING",e[e.RUSSIAN_LOWER=46]="RUSSIAN_LOWER",e[e.RUSSIAN_UPPER=47]="RUSSIAN_UPPER",e[e.NUMBER_IN_DASH=48]="NUMBER_IN_DASH",e[e.HEBREW1=49]="HEBREW1",e[e.HEBREW2=50]="HEBREW2",e[e.ARABIC_ALPHA=51]="ARABIC_ALPHA",e[e.ARABIC_ABJAD=52]="ARABIC_ABJAD",e[e.HINDI_VOWELS=53]="HINDI_VOWELS",e[e.HINDI_CONSONANTS=54]="HINDI_CONSONANTS",e[e.HINDI_NUMBERS=55]="HINDI_NUMBERS",e[e.HINDI_COUNTING=56]="HINDI_COUNTING",e[e.THAI_LETTERS=57]="THAI_LETTERS",e[e.THAI_NUMBERS=58]="THAI_NUMBERS",e[e.THAI_COUNTING=59]="THAI_COUNTING",e[e.CUSTOM=60]="CUSTOM",e))(Ne||{}),Kn=(e=>(e[e.BULLET_ALIGNMENT_UNSPECIFIED=0]="BULLET_ALIGNMENT_UNSPECIFIED",e[e.START=1]="START",e[e.CENTER=2]="CENTER",e[e.END=3]="END",e[e.BOTH=4]="BOTH",e))(Kn||{}),zt=(e=>(e[e.HYPERLINK=0]="HYPERLINK",e[e.FIELD=1]="FIELD",e[e.SDT=2]="SDT",e[e.BOOKMARK=3]="BOOKMARK",e[e.COMMENT=4]="COMMENT",e[e.CUSTOM=5]="CUSTOM",e[e.MENTION=6]="MENTION",e[e.UNI_FORMULA=7]="UNI_FORMULA",e[e.DELTED=9999]="DELTED",e))(zt||{}),rn=(e=>(e[e.COMMENT=0]="COMMENT",e[e.DELETED=9999]="DELETED",e))(rn||{}),Ko=(e=>(e[e.DRAWING=0]="DRAWING",e[e.CUSTOM=1]="CUSTOM",e))(Ko||{}),As=(e=>(e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.TRADITIONAL=1]="TRADITIONAL",e[e.MODERN=2]="MODERN",e))(As||{}),Xo=(e=>(e[e.DEFAULT=0]="DEFAULT",e[e.LINES=1]="LINES",e[e.LINES_AND_CHARS=2]="LINES_AND_CHARS",e[e.SNAP_TO_CHARS=3]="SNAP_TO_CHARS",e))(Xo||{}),qo=(e=>(e[e.SECTION_TYPE_UNSPECIFIED=0]="SECTION_TYPE_UNSPECIFIED",e[e.CONTINUOUS=1]="CONTINUOUS",e[e.NEXT_PAGE=2]="NEXT_PAGE",e[e.EVEN_PAGE=3]="EVEN_PAGE",e[e.ODD_PAGE=4]="ODD_PAGE",e))(qo||{}),Jo=(e=>(e[e.COLUMN_SEPARATOR_STYLE_UNSPECIFIED=0]="COLUMN_SEPARATOR_STYLE_UNSPECIFIED",e[e.NONE=1]="NONE",e[e.BETWEEN_EACH_COLUMN=2]="BETWEEN_EACH_COLUMN",e))(Jo||{}),Zo=(e=>(e[e.NORMAL=0]="NORMAL",e[e.TBRL=1]="TBRL",e[e.LRTBV=2]="LRTBV",e))(Zo||{}),Qo=(e=>(e[e.TEXT_RUN=0]="TEXT_RUN",e[e.AUTO_TEXT=1]="AUTO_TEXT",e[e.PAGE_BREAK=2]="PAGE_BREAK",e[e.COLUMN_BREAK=3]="COLUMN_BREAK",e[e.FOOT_NOTE_REFERENCE=4]="FOOT_NOTE_REFERENCE",e[e.HORIZONTAL_RULE=5]="HORIZONTAL_RULE",e[e.EQUATION=6]="EQUATION",e[e.DRAWING=7]="DRAWING",e[e.PERSON=8]="PERSON",e[e.RICH_LINK=9]="RICH_LINK",e))(Qo||{}),ea=(e=>(e[e.BOTH_SIDES=0]="BOTH_SIDES",e[e.LEFT=1]="LEFT",e[e.RIGHT=2]="RIGHT",e[e.LARGEST=3]="LARGEST",e))(ea||{}),ta=(e=>(e[e.INLINE=0]="INLINE",e[e.WRAP_NONE=1]="WRAP_NONE",e[e.WRAP_POLYGON=2]="WRAP_POLYGON",e[e.WRAP_SQUARE=3]="WRAP_SQUARE",e[e.WRAP_THROUGH=4]="WRAP_THROUGH",e[e.WRAP_TIGHT=5]="WRAP_TIGHT",e[e.WRAP_TOP_AND_BOTTOM=6]="WRAP_TOP_AND_BOTTOM",e))(ta||{}),na=(e=>(e[e.NAMED_STYLE_TYPE_UNSPECIFIED=0]="NAMED_STYLE_TYPE_UNSPECIFIED",e[e.NORMAL_TEXT=1]="NORMAL_TEXT",e[e.TITLE=2]="TITLE",e[e.SUBTITLE=3]="SUBTITLE",e[e.HEADING_1=4]="HEADING_1",e[e.HEADING_2=5]="HEADING_2",e[e.HEADING_3=6]="HEADING_3",e[e.HEADING_4=7]="HEADING_4",e[e.HEADING_5=8]="HEADING_5",e[e.HEADING_6=9]="HEADING_6",e))(na||{}),ra=(e=>(e[e.AUTO=0]="AUTO",e[e.AT_LEAST=1]="AT_LEAST",e[e.EXACT=2]="EXACT",e))(ra||{}),sa=(e=>(e[e.DASH_STYLE_UNSPECIFIED=0]="DASH_STYLE_UNSPECIFIED",e[e.SOLID=1]="SOLID",e[e.DOT=2]="DOT",e[e.DASH=3]="DASH",e))(sa||{}),ia=(e=>(e[e.TAB_STOP_ALIGNMENT_UNSPECIFIED=0]="TAB_STOP_ALIGNMENT_UNSPECIFIED",e[e.START=1]="START",e[e.CENTER=2]="CENTER",e[e.END=3]="END",e))(ia||{}),oa=(e=>(e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.SPECIFIED=1]="SPECIFIED",e))(oa||{}),aa=(e=>(e[e.START=0]="START",e[e.CENTER=1]="CENTER",e[e.END=2]="END",e))(aa||{}),la=(e=>(e[e.AUTO_FIT=0]="AUTO_FIT",e[e.FIXED=1]="FIXED",e))(la||{}),ua=(e=>(e[e.NONE=0]="NONE",e[e.WRAP=1]="WRAP",e))(ua||{}),ca=(e=>(e[e.AUTO=0]="AUTO",e[e.AT_LEAST=1]="AT_LEAST",e[e.EXACT=2]="EXACT",e))(ca||{}),ha=(e=>(e[e.CONTENT_ALIGNMENT_UNSPECIFIED=0]="CONTENT_ALIGNMENT_UNSPECIFIED",e[e.BOTH=1]="BOTH",e[e.TOP=2]="TOP",e[e.CENTER=3]="CENTER",e[e.BOTTOM=4]="BOTTOM",e))(ha||{}),pn=(e=>(e.NORMAL="normal",e.BOLD="bold",e.ITALIC="italic",e))(pn||{}),da=(e=>(e[e.PAGE=0]="PAGE",e[e.COLUMN=1]="COLUMN",e[e.CHARACTER=2]="CHARACTER",e[e.MARGIN=3]="MARGIN",e[e.INSIDE_MARGIN=4]="INSIDE_MARGIN",e[e.OUTSIDE_MARGIN=5]="OUTSIDE_MARGIN",e[e.LEFT_MARGIN=6]="LEFT_MARGIN",e[e.RIGHT_MARGIN=7]="RIGHT_MARGIN",e))(da||{}),fa=(e=>(e[e.PAGE=0]="PAGE",e[e.PARAGRAPH=1]="PARAGRAPH",e[e.LINE=2]="LINE",e[e.MARGIN=3]="MARGIN",e[e.TOP_MARGIN=4]="TOP_MARGIN",e[e.BOTTOM_MARGIN=5]="BOTTOM_MARGIN",e[e.INSIDE_MARGIN=6]="INSIDE_MARGIN",e[e.OUTSIDE_MARGIN=7]="OUTSIDE_MARGIN",e))(fa||{}),ga=(e=>(e[e.POINT=0]="POINT",e[e.LINE=1]="LINE",e[e.CHARACTER=2]="CHARACTER",e[e.PIXEL=3]="PIXEL",e[e.PERCENT=4]="PERCENT",e))(ga||{}),ma=(e=>(e[e.CENTER=0]="CENTER",e[e.INSIDE=1]="INSIDE",e[e.LEFT=2]="LEFT",e[e.OUTSIDE=3]="OUTSIDE",e[e.RIGHT=4]="RIGHT",e[e.BOTH=5]="BOTH",e[e.DISTRIBUTE=6]="DISTRIBUTE",e))(ma||{}),_a=(e=>(e[e.BOTTOM=0]="BOTTOM",e[e.CENTER=1]="CENTER",e[e.INSIDE=2]="INSIDE",e[e.OUTSIDE=3]="OUTSIDE",e[e.TOP=4]="TOP",e))(_a||{}),pa=(e=>(e[e.compressPunctuation=0]="compressPunctuation",e[e.compressPunctuationAndJapaneseKana=1]="compressPunctuationAndJapaneseKana",e[e.doNotCompress=2]="doNotCompress",e))(pa||{}),Ea=(e=>(e[e.PORTRAIT=0]="PORTRAIT",e[e.LANDSCAPE=1]="LANDSCAPE",e))(Ea||{}),Ca=(e=>(e[e.forward=0]="forward",e[e.backward=1]="backward",e[e.front=2]="front",e[e.back=3]="back",e))(Ca||{}),Ra=(e=>(e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e[e.DRAWING_IMAGE=0]="DRAWING_IMAGE",e[e.DRAWING_SHAPE=1]="DRAWING_SHAPE",e[e.DRAWING_CHART=2]="DRAWING_CHART",e[e.DRAWING_TABLE=3]="DRAWING_TABLE",e[e.DRAWING_SMART_ART=4]="DRAWING_SMART_ART",e[e.DRAWING_VIDEO=5]="DRAWING_VIDEO",e[e.DRAWING_GROUP=6]="DRAWING_GROUP",e[e.DRAWING_UNIT=7]="DRAWING_UNIT",e[e.DRAWING_DOM=8]="DRAWING_DOM",e))(Ra||{}),Ts=(e=>(e[e.SLIDE=0]="SLIDE",e[e.MASTER=1]="MASTER",e[e.LAYOUT=2]="LAYOUT",e[e.HANDOUT_MASTER=3]="HANDOUT_MASTER",e[e.NOTES_MASTER=4]="NOTES_MASTER",e))(Ts||{}),Ia=(e=>(e[e.SHAPE=0]="SHAPE",e[e.IMAGE=1]="IMAGE",e[e.TEXT=2]="TEXT",e[e.SPREADSHEET=3]="SPREADSHEET",e[e.DOCUMENT=4]="DOCUMENT",e[e.SLIDE=5]="SLIDE",e))(Ia||{}),Sa=(e=>(e[e.RELATIVE_SLIDE_LINK_UNSPECIFIED=0]="RELATIVE_SLIDE_LINK_UNSPECIFIED",e[e.NEXT_SLIDE=1]="NEXT_SLIDE",e[e.PREVIOUS_SLIDE=2]="PREVIOUS_SLIDE",e[e.FIRST_SLIDE=3]="FIRST_SLIDE",e[e.LAST_SLIDE=4]="LAST_SLIDE",e))(Sa||{}),va=(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))(va||{}),Vt=(e=>(e.PARAGRAPH="\r",e.SECTION_BREAK=`
6
6
  `,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))(Vt||{});function jd(e){return`${e}`}const Yd=[Vt.TABLE_START,Vt.TABLE_ROW_START,Vt.TABLE_CELL_START,Vt.TABLE_CELL_END,Vt.TABLE_ROW_END,Vt.TABLE_END],jr=e=>{const t=e.endsWith(`\r
7
7
  `)?e.slice(0,-2):e;return Yd.reduce((n,r)=>n.replaceAll(r,""),t)},zd=e=>e?jr(e).replaceAll("\r","")==="":!0,Vd=e=>{const t=e.replace(/\n/g,"\r"),n=[],r=[];let s=0,i="";const o=(l,u=!0)=>{const c=t.slice(s,l);if(re.isLegalUrl(c)){const h=kt(),f=`${c}`,g={startIndex:s,endIndex:s+f.length-1,rangeId:h,rangeType:zt.HYPERLINK,properties:{url:e}};r.push(g),i+=f,s=l+1,u&&(i+="\r",n.push({startIndex:l}))}else i+=t.slice(s,l+1),s=l+1,u&&n.push({startIndex:l})};let a=0;for(let l=0;l<t.length;l++)t[l]==="\r"&&(o(l),a=l);return(a!==t.length-1||t.length===1)&&o(t.length,!1),{dataStream:i,paragraphs:n,customRanges:r}};var Oa=typeof global=="object"&&global&&global.Object===Object&&global,Gd=typeof self=="object"&&self&&self.Object===Object&&self,sn=Oa||Gd||Function("return this")(),En=sn.Symbol,wa=Object.prototype,Kd=wa.hasOwnProperty,Xd=wa.toString,Xn=En?En.toStringTag:void 0;function qd(e){var t=Kd.call(e,Xn),n=e[Xn];try{e[Xn]=void 0;var r=!0}catch{}var s=Xd.call(e);return r&&(t?e[Xn]=n:delete e[Xn]),s}var Jd=Object.prototype,Zd=Jd.toString;function Qd(e){return Zd.call(e)}var ef="[object Null]",tf="[object Undefined]",ba=En?En.toStringTag:void 0;function qn(e){return e==null?e===void 0?tf:ef:ba&&ba in Object(e)?qd(e):Qd(e)}function Cn(e){return e!=null&&typeof e=="object"}var nf="[object Symbol]";function Yr(e){return typeof e=="symbol"||Cn(e)&&qn(e)==nf}function rf(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 Rn=Array.isArray,ya=En?En.prototype:void 0,Aa=ya?ya.toString:void 0;function Ta(e){if(typeof e=="string")return e;if(Rn(e))return rf(e,Ta)+"";if(Yr(e))return Aa?Aa.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}var sf=/\s/;function of(e){for(var t=e.length;t--&&sf.test(e.charAt(t)););return t}var af=/^\s+/;function lf(e){return e&&e.slice(0,of(e)+1).replace(af,"")}function Et(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Na=NaN,uf=/^[-+]0x[0-9a-f]+$/i,cf=/^0b[01]+$/i,hf=/^0o[0-7]+$/i,df=parseInt;function Ma(e){if(typeof e=="number")return e;if(Yr(e))return Na;if(Et(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Et(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=lf(e);var n=cf.test(e);return n||hf.test(e)?df(e.slice(2),n?2:8):uf.test(e)?Na:+e}function Da(e){return e}var ff="[object AsyncFunction]",gf="[object Function]",mf="[object GeneratorFunction]",_f="[object Proxy]";function Ns(e){if(!Et(e))return!1;var t=qn(e);return t==gf||t==mf||t==ff||t==_f}var Ms=sn["__core-js_shared__"],La=function(){var e=/[^.]+$/.exec(Ms&&Ms.keys&&Ms.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function pf(e){return!!La&&La in e}var Ef=Function.prototype,Cf=Ef.toString;function Rf(e){if(e!=null){try{return Cf.call(e)}catch{}try{return e+""}catch{}}return""}var If=/[\\^$.*+?()[\]{}|]/g,Sf=/^\[object .+?Constructor\]$/,vf=Function.prototype,Of=Object.prototype,wf=vf.toString,bf=Of.hasOwnProperty,yf=RegExp("^"+wf.call(bf).replace(If,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Af(e){if(!Et(e)||pf(e))return!1;var t=Ns(e)?yf:Sf;return t.test(Rf(e))}function Tf(e,t){return e==null?void 0:e[t]}function Ds(e,t){var n=Tf(e,t);return Af(n)?n:void 0}var Ua=Object.create,Nf=function(){function e(){}return function(t){if(!Et(t))return{};if(Ua)return Ua(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function Mf(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 Df(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}var Lf=800,Uf=16,kf=Date.now;function Pf(e){var t=0,n=0;return function(){var r=kf(),s=Uf-(r-n);if(n=r,s>0){if(++t>=Lf)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function Ff(e){return function(){return e}}var zr=function(){try{var e=Ds(Object,"defineProperty");return e({},"",{}),e}catch{}}(),xf=zr?function(e,t){return zr(e,"toString",{configurable:!0,enumerable:!1,value:Ff(t),writable:!0})}:Da,$f=Pf(xf),Bf=9007199254740991,Hf=/^(?:0|[1-9]\d*)$/;function Ls(e,t){var n=typeof e;return t=t==null?Bf:t,!!t&&(n=="number"||n!="symbol"&&Hf.test(e))&&e>-1&&e%1==0&&e<t}function Us(e,t,n){t=="__proto__"&&zr?zr(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function Vr(e,t){return e===t||e!==e&&t!==t}var Wf=Object.prototype,jf=Wf.hasOwnProperty;function ka(e,t,n){var r=e[t];(!(jf.call(e,t)&&Vr(r,n))||n===void 0&&!(t in e))&&Us(e,t,n)}function Yf(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?Us(n,a,l):ka(n,a,l)}return n}var Pa=Math.max;function zf(e,t,n){return t=Pa(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,i=Pa(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),Mf(e,this,a)}}function Vf(e,t){return $f(zf(e,t,Da),e+"")}var Gf=9007199254740991;function Fa(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Gf}function ks(e){return e!=null&&Fa(e.length)&&!Ns(e)}function Kf(e,t,n){if(!Et(n))return!1;var r=typeof t;return(r=="number"?ks(n)&&Ls(t,n.length):r=="string"&&t in n)?Vr(n[t],e):!1}function xa(e){return Vf(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&&Kf(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 Xf=Object.prototype;function $a(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||Xf;return e===n}function qf(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var Jf="[object Arguments]";function Ba(e){return Cn(e)&&qn(e)==Jf}var Ha=Object.prototype,Zf=Ha.hasOwnProperty,Qf=Ha.propertyIsEnumerable,Ps=Ba(function(){return arguments}())?Ba:function(e){return Cn(e)&&Zf.call(e,"callee")&&!Qf.call(e,"callee")};function eg(){return!1}var Wa=typeof d=="object"&&d&&!d.nodeType&&d,ja=Wa&&typeof module=="object"&&module&&!module.nodeType&&module,tg=ja&&ja.exports===Wa,Ya=tg?sn.Buffer:void 0,ng=Ya?Ya.isBuffer:void 0,za=ng||eg,rg="[object Arguments]",sg="[object Array]",ig="[object Boolean]",og="[object Date]",ag="[object Error]",lg="[object Function]",ug="[object Map]",cg="[object Number]",hg="[object Object]",dg="[object RegExp]",fg="[object Set]",gg="[object String]",mg="[object WeakMap]",_g="[object ArrayBuffer]",pg="[object DataView]",Eg="[object Float32Array]",Cg="[object Float64Array]",Rg="[object Int8Array]",Ig="[object Int16Array]",Sg="[object Int32Array]",vg="[object Uint8Array]",Og="[object Uint8ClampedArray]",wg="[object Uint16Array]",bg="[object Uint32Array]",Qe={};Qe[Eg]=Qe[Cg]=Qe[Rg]=Qe[Ig]=Qe[Sg]=Qe[vg]=Qe[Og]=Qe[wg]=Qe[bg]=!0,Qe[rg]=Qe[sg]=Qe[_g]=Qe[ig]=Qe[pg]=Qe[og]=Qe[ag]=Qe[lg]=Qe[ug]=Qe[cg]=Qe[hg]=Qe[dg]=Qe[fg]=Qe[gg]=Qe[mg]=!1;function yg(e){return Cn(e)&&Fa(e.length)&&!!Qe[qn(e)]}function Ag(e){return function(t){return e(t)}}var Va=typeof d=="object"&&d&&!d.nodeType&&d,Jn=Va&&typeof module=="object"&&module&&!module.nodeType&&module,Tg=Jn&&Jn.exports===Va,Fs=Tg&&Oa.process,Ga=function(){try{var e=Jn&&Jn.require&&Jn.require("util").types;return e||Fs&&Fs.binding&&Fs.binding("util")}catch{}}(),Ka=Ga&&Ga.isTypedArray,Xa=Ka?Ag(Ka):yg;function Ng(e,t){var n=Rn(e),r=!n&&Ps(e),s=!n&&!r&&za(e),i=!n&&!r&&!s&&Xa(e),o=n||r||s||i,a=o?qf(e.length,String):[],l=a.length;for(var u in e)o&&(u=="length"||s&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||Ls(u,l))||a.push(u);return a}function Mg(e,t){return function(n){return e(t(n))}}function Dg(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var Lg=Object.prototype,Ug=Lg.hasOwnProperty;function kg(e){if(!Et(e))return Dg(e);var t=$a(e),n=[];for(var r in e)r=="constructor"&&(t||!Ug.call(e,r))||n.push(r);return n}function qa(e){return ks(e)?Ng(e):kg(e)}var Pg=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Fg=/^\w*$/;function xg(e,t){if(Rn(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Yr(e)?!0:Fg.test(e)||!Pg.test(e)||t!=null&&e in Object(t)}var Zn=Ds(Object,"create");function $g(){this.__data__=Zn?Zn(null):{},this.size=0}function Bg(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Hg="__lodash_hash_undefined__",Wg=Object.prototype,jg=Wg.hasOwnProperty;function Yg(e){var t=this.__data__;if(Zn){var n=t[e];return n===Hg?void 0:n}return jg.call(t,e)?t[e]:void 0}var zg=Object.prototype,Vg=zg.hasOwnProperty;function Gg(e){var t=this.__data__;return Zn?t[e]!==void 0:Vg.call(t,e)}var Kg="__lodash_hash_undefined__";function Xg(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Zn&&t===void 0?Kg:t,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=$g,on.prototype.delete=Bg,on.prototype.get=Yg,on.prototype.has=Gg,on.prototype.set=Xg;function qg(){this.__data__=[],this.size=0}function Gr(e,t){for(var n=e.length;n--;)if(Vr(e[n][0],t))return n;return-1}var Jg=Array.prototype,Zg=Jg.splice;function Qg(e){var t=this.__data__,n=Gr(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():Zg.call(t,n,1),--this.size,!0}function em(e){var t=this.__data__,n=Gr(t,e);return n<0?void 0:t[n][1]}function tm(e){return Gr(this.__data__,e)>-1}function nm(e,t){var n=this.__data__,r=Gr(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function Ft(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])}}Ft.prototype.clear=qg,Ft.prototype.delete=Qg,Ft.prototype.get=em,Ft.prototype.has=tm,Ft.prototype.set=nm;var Ja=Ds(sn,"Map");function rm(){this.size=0,this.__data__={hash:new on,map:new(Ja||Ft),string:new on}}function sm(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Kr(e,t){var n=e.__data__;return sm(t)?n[typeof t=="string"?"string":"hash"]:n.map}function im(e){var t=Kr(this,e).delete(e);return this.size-=t?1:0,t}function om(e){return Kr(this,e).get(e)}function am(e){return Kr(this,e).has(e)}function lm(e,t){var n=Kr(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function Gt(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])}}Gt.prototype.clear=rm,Gt.prototype.delete=im,Gt.prototype.get=om,Gt.prototype.has=am,Gt.prototype.set=lm;var um="Expected a function";function xs(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(um);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(xs.Cache||Gt),n}xs.Cache=Gt;var cm=500;function hm(e){var t=xs(e,function(r){return n.size===cm&&n.clear(),r}),n=t.cache;return t}var dm=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,fm=/\\(\\)?/g,gm=hm(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(dm,function(n,r,s,i){t.push(s?i.replace(fm,"$1"):r||n)}),t});function mm(e){return e==null?"":Ta(e)}function Za(e,t){return Rn(e)?e:xg(e,t)?[e]:gm(mm(e))}function Qa(e){if(typeof e=="string"||Yr(e))return e;var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function _m(e,t){t=Za(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[Qa(t[n++])];return n&&n==r?e:void 0}function pm(e,t,n){var r=e==null?void 0:_m(e,t);return r===void 0?n:r}var el=Mg(Object.getPrototypeOf,Object),Em="[object Object]",Cm=Function.prototype,Rm=Object.prototype,tl=Cm.toString,Im=Rm.hasOwnProperty,Sm=tl.call(Object);function vm(e){if(!Cn(e)||qn(e)!=Em)return!1;var t=el(e);if(t===null)return!0;var n=Im.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&tl.call(n)==Sm}function Om(){this.__data__=new Ft,this.size=0}function wm(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function bm(e){return this.__data__.get(e)}function ym(e){return this.__data__.has(e)}var Am=200;function Tm(e,t){var n=this.__data__;if(n instanceof Ft){var r=n.__data__;if(!Ja||r.length<Am-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Gt(r)}return n.set(e,t),this.size=n.size,this}function In(e){var t=this.__data__=new Ft(e);this.size=t.size}In.prototype.clear=Om,In.prototype.delete=wm,In.prototype.get=bm,In.prototype.has=ym,In.prototype.set=Tm;var nl=typeof d=="object"&&d&&!d.nodeType&&d,rl=nl&&typeof module=="object"&&module&&!module.nodeType&&module,Nm=rl&&rl.exports===nl,sl=Nm?sn.Buffer:void 0;sl&&sl.allocUnsafe;function Mm(e,t){return e.slice()}var il=sn.Uint8Array;function Dm(e){var t=new e.constructor(e.byteLength);return new il(t).set(new il(e)),t}function Lm(e,t){var n=Dm(e.buffer);return new e.constructor(n,e.byteOffset,e.length)}function Um(e){return typeof e.constructor=="function"&&!$a(e)?Nf(el(e)):{}}function km(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 Pm=km(),$s=function(){return sn.Date.now()},Fm="Expected a function",xm=Math.max,$m=Math.min;function Bm(e,t,n){var r,s,i,o,a,l,u=0,c=!1,h=!1,f=!0;if(typeof e!="function")throw new TypeError(Fm);t=Ma(t)||0,Et(n)&&(c=!!n.leading,h="maxWait"in n,i=h?xm(Ma(n.maxWait)||0,t):i,f="trailing"in n?!!n.trailing:f);function g(T){var j=r,Q=s;return r=s=void 0,u=T,o=e.apply(Q,j),o}function C(T){return u=T,a=setTimeout(U,t),c?g(T):o}function I(T){var j=T-l,Q=T-u,ge=t-j;return h?$m(ge,i-Q):ge}function b(T){var j=T-l,Q=T-u;return l===void 0||j>=t||j<0||h&&Q>=i}function U(){var T=$s();if(b(T))return Z(T);a=setTimeout(U,I(T))}function Z(T){return a=void 0,f&&r?g(T):(r=s=void 0,o)}function V(){a!==void 0&&clearTimeout(a),u=0,r=l=s=a=void 0}function fe(){return a===void 0?o:Z($s())}function M(){var T=$s(),j=b(T);if(r=arguments,s=this,l=T,j){if(a===void 0)return C(l);if(h)return clearTimeout(a),a=setTimeout(U,t),g(l)}return a===void 0&&(a=setTimeout(U,t)),o}return M.cancel=V,M.flush=fe,M}function Bs(e,t,n){(n!==void 0&&!Vr(e[t],n)||n===void 0&&!(t in e))&&Us(e,t,n)}function Hm(e){return Cn(e)&&ks(e)}function Hs(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}function Wm(e){return Yf(e,qa(e))}function jm(e,t,n,r,s,i,o){var a=Hs(e,n),l=Hs(t,n),u=o.get(l);if(u){Bs(e,n,u);return}var c=i?i(a,l,n+"",e,t,o):void 0,h=c===void 0;if(h){var f=Rn(l),g=!f&&za(l),C=!f&&!g&&Xa(l);c=l,f||g||C?Rn(a)?c=a:Hm(a)?c=Df(a):g?(h=!1,c=Mm(l)):C?(h=!1,c=Lm(l)):c=[]:vm(l)||Ps(l)?(c=a,Ps(a)?c=Wm(a):(!Et(a)||Ns(a))&&(c=Um(l))):h=!1}h&&(o.set(l,c),s(c,l,r,i,o),o.delete(l)),Bs(e,n,c)}function Ws(e,t,n,r,s){e!==t&&Pm(t,function(i,o){if(s||(s=new In),Et(i))jm(e,t,o,n,Ws,r,s);else{var a=r?r(Hs(e,o),i,o+"",e,t,s):void 0;a===void 0&&(a=i),Bs(e,o,a)}},qa)}var Ym=xa(function(e,t,n,r){Ws(e,t,n,r)}),js=xa(function(e,t,n){Ws(e,t,n)});function zm(e,t,n,r){if(!Et(e))return e;t=Za(t,e);for(var s=-1,i=t.length,o=i-1,a=e;a!=null&&++s<i;){var l=Qa(t[s]),u=n;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=o){var c=a[l];u=void 0,u===void 0&&(u=Et(c)?c:Ls(t[s+1])?[]:{})}ka(a,l,u),a=a[l]}return e}function Vm(e,t,n){return e==null?e:zm(e,t,n)}var Ys,ol;function Gm(){if(ol)return Ys;ol=1;var e=-1,t=1,n=0;function r(p,W,O,D,y){if(p===W)return p?[[n,p]]:[];if(O!=null){var w=ge(p,W,O);if(w)return w}var x=a(p,W),B=p.substring(0,x);p=p.substring(x),W=W.substring(x),x=u(p,W);var G=p.substring(p.length-x);p=p.substring(0,p.length-x),W=W.substring(0,W.length-x);var ie=s(p,W);return B&&ie.unshift([n,B]),G&&ie.push([n,G]),Z(ie,y),D&&h(ie),ie}function s(p,W){var O;if(!p)return[[t,W]];if(!W)return[[e,p]];var D=p.length>W.length?p:W,y=p.length>W.length?W:p,w=D.indexOf(y);if(w!==-1)return O=[[t,D.substring(0,w)],[n,y],[t,D.substring(w+y.length)]],p.length>W.length&&(O[0][0]=O[2][0]=e),O;if(y.length===1)return[[e,p],[t,W]];var x=c(p,W);if(x){var B=x[0],G=x[1],ie=x[2],de=x[3],me=x[4],Me=r(B,ie),Ae=r(G,de);return Me.concat([[n,me]],Ae)}return i(p,W)}function i(p,W){for(var O=p.length,D=W.length,y=Math.ceil((O+D)/2),w=y,x=2*y,B=new Array(x),G=new Array(x),ie=0;ie<x;ie++)B[ie]=-1,G[ie]=-1;B[w+1]=0,G[w+1]=0;for(var de=O-D,me=de%2!==0,Me=0,Ae=0,v=0,$=0,K=0;K<y;K++){for(var q=-K+Me;q<=K-Ae;q+=2){var z=w+q,Y;q===-K||q!==K&&B[z-1]<B[z+1]?Y=B[z+1]:Y=B[z-1]+1;for(var ue=Y-q;Y<O&&ue<D&&p.charAt(Y)===W.charAt(ue);)Y++,ue++;if(B[z]=Y,Y>O)Ae+=2;else if(ue>D)Me+=2;else if(me){var ae=w+de-q;if(ae>=0&&ae<x&&G[ae]!==-1){var H=O-G[ae];if(Y>=H)return o(p,W,Y,ue)}}}for(var ne=-K+v;ne<=K-$;ne+=2){var ae=w+ne,H;ne===-K||ne!==K&&G[ae-1]<G[ae+1]?H=G[ae+1]:H=G[ae-1]+1;for(var oe=H-ne;H<O&&oe<D&&p.charAt(O-H-1)===W.charAt(D-oe-1);)H++,oe++;if(G[ae]=H,H>O)$+=2;else if(oe>D)v+=2;else if(!me){var z=w+de-ne;if(z>=0&&z<x&&B[z]!==-1){var Y=B[z],ue=w+Y-z;if(H=O-H,Y>=H)return o(p,W,Y,ue)}}}}return[[e,p],[t,W]]}function o(p,W,O,D){var y=p.substring(0,O),w=W.substring(0,D),x=p.substring(O),B=W.substring(D),G=r(y,w),ie=r(x,B);return G.concat(ie)}function a(p,W){if(!p||!W||p.charAt(0)!==W.charAt(0))return 0;for(var O=0,D=Math.min(p.length,W.length),y=D,w=0;O<y;)p.substring(w,y)==W.substring(w,y)?(O=y,w=O):D=y,y=Math.floor((D-O)/2+O);return V(p.charCodeAt(y-1))&&y--,y}function l(p,W){var O=p.length,D=W.length;if(O==0||D==0)return 0;O>D?p=p.substring(O-D):O<D&&(W=W.substring(0,O));var y=Math.min(O,D);if(p==W)return y;for(var w=0,x=1;;){var B=p.substring(y-x),G=W.indexOf(B);if(G==-1)return w;x+=G,(G==0||p.substring(y-x)==W.substring(0,x))&&(w=x,x++)}}function u(p,W){if(!p||!W||p.slice(-1)!==W.slice(-1))return 0;for(var O=0,D=Math.min(p.length,W.length),y=D,w=0;O<y;)p.substring(p.length-y,p.length-w)==W.substring(W.length-y,W.length-w)?(O=y,w=O):D=y,y=Math.floor((D-O)/2+O);return fe(p.charCodeAt(p.length-y))&&y--,y}function c(p,W){var O=p.length>W.length?p:W,D=p.length>W.length?W:p;if(O.length<4||D.length*2<O.length)return null;function y(Ae,v,$){for(var K=Ae.substring($,$+Math.floor(Ae.length/4)),q=-1,z="",Y,ue,ae,H;(q=v.indexOf(K,q+1))!==-1;){var ne=a(Ae.substring($),v.substring(q)),oe=u(Ae.substring(0,$),v.substring(0,q));z.length<oe+ne&&(z=v.substring(q-oe,q)+v.substring(q,q+ne),Y=Ae.substring(0,$-oe),ue=Ae.substring($+ne),ae=v.substring(0,q-oe),H=v.substring(q+ne))}return z.length*2>=Ae.length?[Y,ue,ae,H,z]:null}var w=y(O,D,Math.ceil(O.length/4)),x=y(O,D,Math.ceil(O.length/2)),B;if(!w&&!x)return null;x?w?B=w[4].length>x[4].length?w:x:B=x:B=w;var G,ie,de,me;p.length>W.length?(G=B[0],ie=B[1],de=B[2],me=B[3]):(de=B[0],me=B[1],G=B[2],ie=B[3]);var Me=B[4];return[G,ie,de,me,Me]}function h(p){for(var W=!1,O=[],D=0,y=null,w=0,x=0,B=0,G=0,ie=0;w<p.length;)p[w][0]==n?(O[D++]=w,x=G,B=ie,G=0,ie=0,y=p[w][1]):(p[w][0]==t?G+=p[w][1].length:ie+=p[w][1].length,y&&y.length<=Math.max(x,B)&&y.length<=Math.max(G,ie)&&(p.splice(O[D-1],0,[e,y]),p[O[D-1]+1][0]=t,D--,D--,w=D>0?O[D-1]:-1,x=0,B=0,G=0,ie=0,y=null,W=!0)),w++;for(W&&Z(p),U(p),w=1;w<p.length;){if(p[w-1][0]==e&&p[w][0]==t){var de=p[w-1][1],me=p[w][1],Me=l(de,me),Ae=l(me,de);Me>=Ae?(Me>=de.length/2||Me>=me.length/2)&&(p.splice(w,0,[n,me.substring(0,Me)]),p[w-1][1]=de.substring(0,de.length-Me),p[w+1][1]=me.substring(Me),w++):(Ae>=de.length/2||Ae>=me.length/2)&&(p.splice(w,0,[n,de.substring(0,Ae)]),p[w-1][0]=t,p[w-1][1]=me.substring(0,me.length-Ae),p[w+1][0]=e,p[w+1][1]=de.substring(Ae),w++),w++}w++}}var f=/[^a-zA-Z0-9]/,g=/\s/,C=/[\r\n]/,I=/\n\r?\n$/,b=/^\r?\n\r?\n/;function U(p){function W(Ae,v){if(!Ae||!v)return 6;var $=Ae.charAt(Ae.length-1),K=v.charAt(0),q=$.match(f),z=K.match(f),Y=q&&$.match(g),ue=z&&K.match(g),ae=Y&&$.match(C),H=ue&&K.match(C),ne=ae&&Ae.match(I),oe=H&&v.match(b);return ne||oe?5:ae||H?4:q&&!Y&&ue?3:Y||ue?2:q||z?1:0}for(var O=1;O<p.length-1;){if(p[O-1][0]==n&&p[O+1][0]==n){var D=p[O-1][1],y=p[O][1],w=p[O+1][1],x=u(D,y);if(x){var B=y.substring(y.length-x);D=D.substring(0,D.length-x),y=B+y.substring(0,y.length-x),w=B+w}for(var G=D,ie=y,de=w,me=W(D,y)+W(y,w);y.charAt(0)===w.charAt(0);){D+=y.charAt(0),y=y.substring(1)+w.charAt(0),w=w.substring(1);var Me=W(D,y)+W(y,w);Me>=me&&(me=Me,G=D,ie=y,de=w)}p[O-1][1]!=G&&(G?p[O-1][1]=G:(p.splice(O-1,1),O--),p[O][1]=ie,de?p[O+1][1]=de:(p.splice(O+1,1),O--))}O++}}function Z(p,W){p.push([n,""]);for(var O=0,D=0,y=0,w="",x="",B;O<p.length;){if(O<p.length-1&&!p[O][1]){p.splice(O,1);continue}switch(p[O][0]){case t:y++,x+=p[O][1],O++;break;case e:D++,w+=p[O][1],O++;break;case n:var G=O-y-D-1;if(W){if(G>=0&&T(p[G][1])){var ie=p[G][1].slice(-1);if(p[G][1]=p[G][1].slice(0,-1),w=ie+w,x=ie+x,!p[G][1]){p.splice(G,1),O--;var de=G-1;p[de]&&p[de][0]===t&&(y++,x=p[de][1]+x,de--),p[de]&&p[de][0]===e&&(D++,w=p[de][1]+w,de--),G=de}}if(M(p[O][1])){var ie=p[O][1].charAt(0);p[O][1]=p[O][1].slice(1),w+=ie,x+=ie}}if(O<p.length-1&&!p[O][1]){p.splice(O,1);break}if(w.length>0||x.length>0){w.length>0&&x.length>0&&(B=a(x,w),B!==0&&(G>=0?p[G][1]+=x.substring(0,B):(p.splice(0,0,[n,x.substring(0,B)]),O++),x=x.substring(B),w=w.substring(B)),B=u(x,w),B!==0&&(p[O][1]=x.substring(x.length-B)+p[O][1],x=x.substring(0,x.length-B),w=w.substring(0,w.length-B)));var me=y+D;w.length===0&&x.length===0?(p.splice(O-me,me),O=O-me):w.length===0?(p.splice(O-me,me,[t,x]),O=O-me+1):x.length===0?(p.splice(O-me,me,[e,w]),O=O-me+1):(p.splice(O-me,me,[e,w],[t,x]),O=O-me+2)}O!==0&&p[O-1][0]===n?(p[O-1][1]+=p[O][1],p.splice(O,1)):O++,y=0,D=0,w="",x="";break}}p[p.length-1][1]===""&&p.pop();var Me=!1;for(O=1;O<p.length-1;)p[O-1][0]===n&&p[O+1][0]===n&&(p[O][1].substring(p[O][1].length-p[O-1][1].length)===p[O-1][1]?(p[O][1]=p[O-1][1]+p[O][1].substring(0,p[O][1].length-p[O-1][1].length),p[O+1][1]=p[O-1][1]+p[O+1][1],p.splice(O-1,1),Me=!0):p[O][1].substring(0,p[O+1][1].length)==p[O+1][1]&&(p[O-1][1]+=p[O+1][1],p[O][1]=p[O][1].substring(p[O+1][1].length)+p[O+1][1],p.splice(O+1,1),Me=!0)),O++;Me&&Z(p,W)}function V(p){return p>=55296&&p<=56319}function fe(p){return p>=56320&&p<=57343}function M(p){return fe(p.charCodeAt(0))}function T(p){return V(p.charCodeAt(p.length-1))}function j(p){for(var W=[],O=0;O<p.length;O++)p[O][1].length>0&&W.push(p[O]);return W}function Q(p,W,O,D){return T(p)||M(D)?null:j([[n,p],[e,W],[t,O],[n,D]])}function ge(p,W,O){var D=typeof O=="number"?{index:O,length:0}:O.oldRange,y=typeof O=="number"?null:O.newRange,w=p.length,x=W.length;if(D.length===0&&(y===null||y.length===0)){var B=D.index,G=p.slice(0,B),ie=p.slice(B),de=y?y.index:null;e:{var me=B+x-w;if(de!==null&&de!==me||me<0||me>x)break e;var Me=W.slice(0,me),Ae=W.slice(me);if(Ae!==ie)break e;var v=Math.min(B,me),$=G.slice(0,v),K=Me.slice(0,v);if($!==K)break e;var q=G.slice(v),z=Me.slice(v);return Q($,q,z,ie)}e:{if(de!==null&&de!==B)break e;var Y=B,Me=W.slice(0,Y),Ae=W.slice(Y);if(Me!==G)break e;var ue=Math.min(w-Y,x-Y),ae=ie.slice(ie.length-ue),H=Ae.slice(Ae.length-ue);if(ae!==H)break e;var q=ie.slice(0,ie.length-ue),z=Ae.slice(0,Ae.length-ue);return Q(G,q,z,ae)}}if(D.length>0&&y&&y.length===0)e:{var $=p.slice(0,D.index),ae=p.slice(D.index+D.length),v=$.length,ue=ae.length;if(x<v+ue)break e;var K=W.slice(0,v),H=W.slice(x-ue);if($!==K||ae!==H)break e;var q=p.slice(v,w-ue),z=W.slice(v,x-ue);return Q($,q,z,ae)}return null}function le(p,W,O,D){return r(p,W,O,D,!0)}return le.INSERT=t,le.DELETE=e,le.EQUAL=n,Ys=le,Ys}var Km=Gm();const zs=pt(Km),Xm=new Set(["true","false"]);function qm(e){return Xm.has(e.toLowerCase())}function al(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||!e||typeof t!="object"||!t)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;const s=Object.prototype.hasOwnProperty.bind(t);for(let i=0;i<n.length;i++){const o=n[i];if(!s(o))return!1;const a=e[o],l=t[o];if(a!==l)return!1}return!0}var Be=(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))(Be||{}),Nt=(e=>(e[e.Reader=0]="Reader",e[e.Editor=1]="Editor",e[e.Owner=2]="Owner",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Nt||{}),Vs=(e=>(e[e.SomeCollaborator=0]="SomeCollaborator",e[e.AllCollaborator=1]="AllCollaborator",e[e.OneSelf=2]="OneSelf",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Vs||{});class Xr extends st{}function Jm(e=re.generateRandomId(6),t=$n.EN_US,n=""){return{id:e,locale:t,title:n,tableSource:{},drawings:{},drawingsOrder:[],headers:{},footers:{},body:{dataStream:`\r
8
- `,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:As.TRADITIONAL,marginTop:50,marginBottom:50,marginRight:50,marginLeft:50,renderConfig:{zeroWidthParagraphBreak:ve.FALSE,vertexAngle:0,centerAngle:0,background:{rgb:"#ccc"}},autoHyphenation:ve.TRUE,doNotHyphenateCaps:ve.FALSE,consecutiveHyphenLimit:2,defaultHeaderId:"",defaultFooterId:"",evenPageHeaderId:"",evenPageFooterId:"",firstPageHeaderId:"",firstPageFooterId:"",evenAndOddHeaders:ve.FALSE,useFirstPageHeaderFooter:ve.FALSE,marginHeader:30,marginFooter:30},settings:{}}}var an={},Qn={},qr={},ll;function Zm(){if(ll)return qr;ll=1,Object.defineProperty(qr,"__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 qr.default=n,qr}var Jr={},ul;function Qm(){if(ul)return Jr;ul=1,Object.defineProperty(Jr,"__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 Jr.default=e,Jr}var Gs={},cl;function hl(){return cl||(cl=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(c,h){if(!c)throw new Error(h)}const n=c=>c!=null&&typeof c=="object"&&!Array.isArray(c),r=(c,h)=>typeof c==typeof h?c>h:typeof c=="string"&&typeof h=="number";function s(c,h){for(let f in c){const g=f;h.write(g,c[g])}}e.isValidPathItem=c=>typeof c=="number"||typeof c=="string"&&c!=="__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 f=this.container,g=this.parents.length-1,C=this.idx;for(;C>=0;)h.unshift(f[C]),C===0?(C=this.indexes[g*2],f=this.parents[g--]):C-=n(f[C-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 f=this.container[h];return Array.isArray(f)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(h),this.idx=0,this.container=f):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,f=this.parents[this.parents.length-1];return h>=f.length?!1:(t(!isNaN(h)),this.indexes[this.indexes.length-1]=h,this.container=f[h],!0)}_init(h,f,g,C){this.container=h,this.idx=f,this.parents=g.slice(),this.indexes=C.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,f){const g=this.getComponent();g&&f(g,h);for(const C of this)h&&h.descend(C),this.traverse(h,f),h&&h.ascend()}eachPick(h,f){this.traverse(h,(g,C)=>{g.p!=null&&f(g.p,C)})}eachDrop(h,f){this.traverse(h,(g,C)=>{g.d!=null&&f(g.d,C)})}}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 f=this.pendingDescent[h];let g=this.idx+1;if(g<this.container.length&&n(this.container[g])&&g++,t(g===this.container.length||!n(this.container[g])),g===this.container.length)this.container.push(f),this.idx=g;else if(this.container[g]===f)this.idx=g;else{if(!Array.isArray(this.container[g])){const C=this.container.splice(g,this.container.length-g);this.container.push(C),this.lcIdx>-1&&(this.lcIdx=g)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(t(r(f,this.container[this.lcIdx][0])),g=this.lcIdx+1,this.lcIdx=-1);g<this.container.length&&r(f,this.container[g][0]);)g++;if(this.indexes.push(g),this.idx=0,g<this.container.length&&this.container[g][0]===f)this.container=this.container[g];else{const C=[f];this.container.splice(g,0,C),this.container=C}}}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 f={};return this.container.splice(h,0,f),f}}write(h,f){const g=this.getComponent();t(g[h]==null||g[h]===f,"Internal consistency error: Overwritten component. File a bug"),g[h]=f}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,f=s){if(h===null)return;if(t(Array.isArray(h)),h===this._op)throw Error("Cannot merge into my own tree");const g=this.lcIdx,C=this.parents.length;let I=0;for(let b=0;b<h.length;b++){const U=h[b];typeof U=="string"||typeof U=="number"?(I++,this.descend(U)):Array.isArray(U)?this.mergeTree(U,f):typeof U=="object"&&f(U,this)}for(;I--;)this.ascend();this.lcIdx=this.parents.length===C?g:-1}at(h,f){this.descendPath(h),f(this);for(let g=0;g<h.length;g++)this.ascend();return this}writeAtPath(h,f,g){return this.at(h,()=>this.write(f,g)),this.reset(),this}writeMove(h,f,g=0){return this.writeAtPath(h,"p",g).writeAtPath(f,"d",g)}getPath(){const h=super.getPath();return h.push(...this.pendingDescent),h}}e.WriteCursor=a,e.writeCursor=()=>new a,e.readCursor=c=>new o(c);function l(c,h,f){let g,C;C=g=c?c.descendFirst():!1;function I(b){let U;for(;C;){const Z=U=c.getKey();if(b!=null){let V=!1;if(h&&typeof Z=="number"&&(U=h(Z,c.getComponent()),U<0&&(U=~U,V=!0)),r(U,b))return null;if(U===b&&!V)return c}f&&typeof U=="number"&&f(U,c.getComponent()),C=c.nextSibling()}return null}return I.end=()=>{g&&c.ascend()},I}e.advancer=l;function u(c,h,f){let g,C,I,b;for(g=C=c&&c.descendFirst(),I=b=h&&h.descendFirst();g||I;){let U=g?c.getKey():null,Z=I?h.getKey():null;U!==null&&Z!==null&&(r(Z,U)?Z=null:U!==Z&&(U=null)),f(U==null?Z:U,U!=null?c:null,Z!=null?h:null),U!=null&&g&&(g=c.nextSibling()),Z!=null&&I&&(I=h.nextSibling())}C&&c.ascend(),b&&h.ascend()}e.eachChildOf=u}(Gs)),Gs}var Ks={},dl;function fl(){return dl||(dl=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={}))}(Ks)),Ks}var wt={},ln={},gl;function Xs(){return gl||(gl=1,Object.defineProperty(ln,"__esModule",{value:!0}),ln.uniToStrPos=ln.strPosToUni=void 0,ln.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},ln.uniToStrPos=(e,t)=>{let n=0;for(;t>0;t--){const r=e.charCodeAt(n);n+=r>=55296&&r<=57343?2:1}return n}),ln}var qs={},ml;function Js(){return ml||(ml=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.uniSlice=e.dlen=e.eachOp=void 0;const t=Xs(),n=M=>{if(!Array.isArray(M))throw Error("Op must be an array of components");let T=null;for(let j=0;j<M.length;j++){const Q=M[j];switch(typeof Q){case"object":if(typeof Q.d!="number"&&typeof Q.d!="string")throw Error("Delete must be number or string");if(e.dlen(Q.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(Q.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(Q>0))throw Error("Skip components must be >0");if(typeof T=="number")throw Error("Adjacent skip components should be combined");break}T=Q}if(typeof T=="number")throw Error("Op has a trailing skip")};function r(M,T){let j=0,Q=0;for(let ge=0;ge<M.length;ge++){const le=M[ge];switch(T(le,j,Q),typeof le){case"object":j+=e.dlen(le.d);break;case"string":Q+=t.strPosToUni(le);break;case"number":j+=le,Q+=le;break}}}e.eachOp=r;function s(M,T){const j=[],Q=a(j);return r(M,(ge,le,p)=>{Q(T(ge,le,p))}),h(j)}const i=M=>M,o=M=>s(M,i);e.dlen=M=>typeof M=="number"?M:t.strPosToUni(M);const a=M=>T=>{if(!(!T||T.d===0||T.d===""))if(M.length===0)M.push(T);else if(typeof T==typeof M[M.length-1])if(typeof T=="object"){const j=M[M.length-1];j.d=typeof j.d=="string"&&typeof T.d=="string"?j.d+T.d:e.dlen(j.d)+e.dlen(T.d)}else M[M.length-1]+=T;else M.push(T)},l=M=>typeof M=="number"?M:typeof M=="string"?t.strPosToUni(M):typeof M.d=="number"?M.d:t.strPosToUni(M.d);e.uniSlice=(M,T,j)=>{const Q=t.uniToStrPos(M,T),ge=j==null?1/0:t.uniToStrPos(M,j);return M.slice(Q,ge)};const u=(M,T,j)=>typeof M=="number"?j==null?M-T:Math.min(M,j)-T:e.uniSlice(M,T,j),c=M=>{let T=0,j=0;return{take:(le,p)=>{if(T===M.length)return le===-1?null:le;const W=M[T];let O;if(typeof W=="number")return le===-1||W-j<=le?(O=W-j,++T,j=0,O):(j+=le,le);if(typeof W=="string"){if(le===-1||p==="i"||t.strPosToUni(W.slice(j))<=le)return O=W.slice(j),++T,j=0,O;{const D=j+t.uniToStrPos(W.slice(j),le);return O=W.slice(j,D),j=D,O}}else{if(le===-1||p==="d"||e.dlen(W.d)-j<=le)return O={d:u(W.d,j)},++T,j=0,O;{let D=u(W.d,j,j+le);return j+=le,{d:D}}}},peek:()=>M[T]}},h=M=>(M.length>0&&typeof M[M.length-1]=="number"&&M.pop(),M);function f(M,T,j){if(j!=="left"&&j!=="right")throw Error("side ("+j+") must be 'left' or 'right'");n(M),n(T);const Q=[],ge=a(Q),{take:le,peek:p}=c(M);for(let O=0;O<T.length;O++){const D=T[O];let y,w;switch(typeof D){case"number":for(y=D;y>0;)w=le(y,"i"),ge(w),typeof w!="string"&&(y-=l(w));break;case"string":j==="left"&&typeof p()=="string"&&ge(le(-1)),ge(t.strPosToUni(D));break;case"object":for(y=e.dlen(D.d);y>0;)switch(w=le(y,"i"),typeof w){case"number":y-=w;break;case"string":ge(w);break;case"object":y-=e.dlen(w.d)}break}}let W;for(;W=le(-1);)ge(W);return h(Q)}function g(M,T){n(M),n(T);const j=[],Q=a(j),{take:ge}=c(M);for(let p=0;p<T.length;p++){const W=T[p];let O,D;switch(typeof W){case"number":for(O=W;O>0;)D=ge(O,"d"),Q(D),typeof D!="object"&&(O-=l(D));break;case"string":Q(W);break;case"object":O=e.dlen(W.d);let y=0;for(;y<O;)switch(D=ge(O-y,"d"),typeof D){case"number":Q({d:u(W.d,y,y+D)}),y+=D;break;case"string":y+=t.strPosToUni(D);break;case"object":Q(D)}break}}let le;for(;le=ge(-1);)Q(le);return h(j)}const C=(M,T)=>{let j=0;for(let Q=0;Q<T.length&&M>j;Q++){const ge=T[Q];switch(typeof ge){case"number":{j+=ge;break}case"string":const le=t.strPosToUni(ge);j+=le,M+=le;break;case"object":M-=Math.min(e.dlen(ge.d),M-j);break}}return M},I=(M,T)=>typeof M=="number"?C(M,T):M.map(j=>C(j,T));function b(M,T,j){return s(M,(Q,ge)=>typeof Q=="object"&&typeof Q.d=="number"?{d:j.slice(T,ge,ge+Q.d)}:Q)}function U(M){return s(M,T=>{switch(typeof T){case"object":if(typeof T.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return T.d;case"string":return{d:T};case"number":return T}})}function Z(M){return s(M,T=>typeof T=="object"&&typeof T.d=="string"?{d:t.strPosToUni(T.d)}:T)}function V(M){let T=!0;return r(M,j=>{typeof j=="object"&&typeof j.d=="number"&&(T=!1)}),T}function fe(M){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:h,normalize:o,checkOp:n,create(T=""){if(typeof T!="string")throw Error("Initial data must be a string");return M.create(T)},apply(T,j){n(j);const Q=M.builder(T);for(let ge=0;ge<j.length;ge++){const le=j[ge];switch(typeof le){case"number":Q.skip(le);break;case"string":Q.append(le);break;case"object":Q.del(e.dlen(le.d));break}}return Q.build()},transform:f,compose:g,transformPosition:C,transformSelection:I,isInvertible:V,makeInvertible(T,j){return b(T,j,M)},stripInvertible:Z,invert:U,invertWithDoc(T,j){return U(b(T,j,M))},isNoop:T=>T.length===0}}e.default=fe}(qs)),qs}var Zr={},_l;function e_(){if(_l)return Zr;_l=1,Object.defineProperty(Zr,"__esModule",{value:!0});const e=Js(),t=Xs();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 u=e.dlen(o.d);this.onRemove&&this.onRemove(l,u)}})},onInsert:null,onRemove:null}}return Zr.default=n,n.provides={text:!0},Zr}var pl;function t_(){return pl||(pl=1,function(e){var t=wt&&wt.__createBinding||(Object.create?function(f,g,C,I){I===void 0&&(I=C),Object.defineProperty(f,I,{enumerable:!0,get:function(){return g[C]}})}:function(f,g,C,I){I===void 0&&(I=C),f[I]=g[C]}),n=wt&&wt.__setModuleDefault||(Object.create?function(f,g){Object.defineProperty(f,"default",{enumerable:!0,value:g})}:function(f,g){f.default=g}),r=wt&&wt.__importStar||function(f){if(f&&f.__esModule)return f;var g={};if(f!=null)for(var C in f)Object.hasOwnProperty.call(f,C)&&t(g,f,C);return n(g,f),g},s=wt&&wt.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(e,"__esModule",{value:!0}),e.type=e.remove=e.insert=void 0;const i=Xs(),o=r(Js()),a=s(e_()),l={create(f){return f},toString(f){return f},builder(f){if(typeof f!="string")throw Error("Invalid document snapshot: "+f);const g=[];return{skip(C){let I=i.uniToStrPos(f,C);if(I>f.length)throw Error("The op is too long for this document");g.push(f.slice(0,I)),f=f.slice(I)},append(C){g.push(C)},del(C){f=f.slice(i.uniToStrPos(f,C))},build(){return g.join("")+f}}},slice:o.uniSlice},u=o.default(l),c=Object.assign(Object.assign({},u),{api:a.default});e.type=c,e.insert=(f,g)=>g.length===0?[]:f===0?[g]:[f,g],e.remove=(f,g)=>o.dlen(g)===0?[]:f===0?[{d:g}]:[f,{d:g}];var h=Js();Object.defineProperty(e,"makeType",{enumerable:!0,get:function(){return h.default}})}(wt)),wt}var El;function n_(){return El||(El=1,function(e){var t=Qn&&Qn.__importDefault||function(v){return v&&v.__esModule?v:{default:v}};Object.defineProperty(e,"__esModule",{value:!0}),e.editOp=e.replaceOp=e.insertOp=e.moveOp=e.removeOp=e.type=void 0;const n=t(Zm()),r=t(Qm()),s=hl(),i=fl();function o(v,$){if(!v)throw new Error($)}e.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:s.readCursor,writeCursor:s.writeCursor,create:v=>v,isNoop:v=>v==null,setDebug(v){},registerSubtype:U,checkValidOp:ge,normalize:le,apply:p,transformPosition:W,compose:O,tryTransform:G,transform:de,makeInvertible:w,invert:D,invertWithDoc:x,RM_UNEXPECTED_CONTENT:i.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:i.ConflictType.DROP_COLLISION,BLACKHOLE:i.ConflictType.BLACKHOLE,transformNoConflict:(v,$,K)=>Ae(()=>!0,v,$,K),typeAllowingConflictsPred:v=>Object.assign(Object.assign({},e.type),{transform:($,K,q)=>Ae(v,$,K,q)})};const a=v=>v?v.getComponent():null;function l(v){return v&&typeof v=="object"&&!Array.isArray(v)}const u=v=>Array.isArray(v)?v.slice():v!==null&&typeof v=="object"?Object.assign({},v):v,c=v=>v&&(v.p!=null||v.r!==void 0),h=v=>v&&(v.d!=null||v.i!==void 0);function f(v,$){return o(v!=null),typeof $=="number"?(o(Array.isArray(v),"Invalid key - child is not an array"),(v=v.slice()).splice($,1)):(o(l(v),"Invalid key - child is not an object"),delete(v=Object.assign({},v))[$]),v}function g(v,$,K){return typeof $=="number"?(o(v!=null,"Container is missing for key"),o(Array.isArray(v),"Cannot use numerical key for object container"),o(v.length>=$,"Cannot insert into out of bounds index"),v.splice($,0,K)):(o(l(v),"Cannot insert into missing item"),o(v[$]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),v[$]=K),K}e.removeOp=(v,$=!0)=>s.writeCursor().writeAtPath(v,"r",$).get(),e.moveOp=(v,$)=>s.writeCursor().writeMove(v,$).get(),e.insertOp=(v,$)=>s.writeCursor().writeAtPath(v,"i",$).get(),e.replaceOp=(v,$,K)=>s.writeCursor().at(v,q=>{q.write("r",$),q.write("i",K)}).get(),e.editOp=(v,$,K,q=!1)=>s.writeCursor().at(v,z=>T(z,$,K,q)).get();const C=(v,$)=>v!=null&&(typeof $=="number"?Array.isArray(v):typeof v=="object"),I=(v,$)=>C(v,$)?v[$]:void 0,b={};function U(v){let $=v.type?v.type:v;$.name&&(b[$.name]=$),$.uri&&(b[$.uri]=$)}const Z=v=>{const $=b[v];if($)return $;throw Error("Missing type: "+v)};U(t_());const V=(v,$)=>v+$;U({name:"number",apply:V,compose:V,invert:v=>-v,transform:v=>v});const fe=v=>v==null?null:v.et?Z(v.et):v.es?b["text-unicode"]:v.ena!=null?b.number:null,M=v=>v.es?v.es:v.ena!=null?v.ena:v.e,T=(v,$,K,q=!1)=>{const[z,Y]=typeof $=="string"?[Z($),$]:[$,$.name];!q&&z.isNoop&&z.isNoop(K)||(Y==="number"?v.write("ena",K):Y==="text-unicode"?v.write("es",K):(v.write("et",Y),v.write("e",K)))};function j(v){o(typeof v=="number"),o(v>=0),o(v===(0|v))}function Q(v){typeof v=="number"?j(v):o(typeof v=="string")}function ge(v){if(v===null)return;const $=new Set,K=new Set,q=Y=>{let ue=!0,ae=!1;for(let H in Y){const ne=Y[H];if(ue=!1,o(H==="p"||H==="r"||H==="d"||H==="i"||H==="e"||H==="es"||H==="ena"||H==="et","Invalid component item '"+H+"'"),H==="p")j(ne),o(!$.has(ne)),$.add(ne),o(Y.r===void 0);else if(H==="d")j(ne),o(!K.has(ne)),K.add(ne),o(Y.i===void 0);else if(H==="e"||H==="es"||H==="ena"){o(!ae),ae=!0;const oe=fe(Y);o(oe,"Missing type in edit"),oe.checkValidOp&&oe.checkValidOp(M(Y))}}o(!ue)},z=(Y,ue,ae)=>{if(!Array.isArray(Y))throw Error("Op must be null or a list");if(Y.length===0)throw Error("Empty descent");ue||Q(Y[0]);let H=1,ne=0,oe=0;for(let _e=0;_e<Y.length;_e++){const ye=Y[_e];if(o(ye!=null),Array.isArray(ye)){const Ue=z(ye,!1);if(ne){const X=typeof oe,Se=typeof Ue;X===Se?o(oe<Ue,"descent keys are not in order"):o(X==="number"&&Se==="string")}oe=Ue,ne++,H=3}else typeof ye=="object"?(o(H===1,`Prev not scalar - instead ${H}`),q(ye),H=2):(o(H!==3),Q(ye),o(s.isValidPathItem(ye),"Invalid path key"),H=1)}return o(ne!==1,"Operation makes multiple descents. Remove some []"),o(H===2||H===3),Y[0]};z(v,!0),o($.size===K.size,"Mismatched picks and drops in op");for(let Y=0;Y<$.size;Y++)o($.has(Y)),o(K.has(Y))}function le(v){let $=0,K=[];const q=s.writeCursor();return q.mergeTree(v,(z,Y)=>{const ue=fe(z);if(ue){const H=M(z);T(Y,ue,ue.normalize?ue.normalize(H):H)}for(const H of["r","p","i","d"])if(z[H]!==void 0){const ne=H==="p"||H==="d"?(ae=z[H],K[ae]==null&&(K[ae]=$++),K[ae]):z[H];Y.write(H,ne)}var ae}),q.get()}function p(v,$){if(ge($),$===null)return v;const K=[];return function q(z,Y){let ue=z,ae=0,H={root:z},ne=0,oe=H,_e="root";function ye(){for(;ne<ae;ne++){let Ue=Y[ne];typeof Ue!="object"&&(o(C(oe,_e)),oe=oe[_e]=u(oe[_e]),_e=Ue)}}for(;ae<Y.length;ae++){const Ue=Y[ae];if(Array.isArray(Ue)){const X=q(ue,Ue);X!==ue&&X!==void 0&&(ye(),ue=oe[_e]=X)}else if(typeof Ue=="object"){Ue.d!=null?(ye(),ue=g(oe,_e,K[Ue.d])):Ue.i!==void 0&&(ye(),ue=g(oe,_e,Ue.i));const X=fe(Ue);if(X)ye(),ue=oe[_e]=X.apply(ue,M(Ue));else if(Ue.e!==void 0)throw Error("Subtype "+Ue.et+" undefined")}else ue=I(ue,Ue)}return H.root}(v=function q(z,Y){const ue=[];let ae=0;for(;ae<Y.length;ae++){const _e=Y[ae];if(Array.isArray(_e))break;typeof _e!="object"&&(ue.push(z),z=I(z,_e))}for(let _e=Y.length-1;_e>=ae;_e--)z=q(z,Y[_e]);for(--ae;ae>=0;ae--){const _e=Y[ae];if(typeof _e!="object"){const ye=ue.pop();z=z===I(ye,_e)?ye:z===void 0?f(ye,_e):(ne=_e,oe=z,(H=u(H=ye))[ne]=oe,H)}else c(_e)&&(o(z!==void 0,"Cannot pick up or remove undefined"),_e.p!=null&&(K[_e.p]=z),z=void 0)}var H,ne,oe;return z}(v,$),$)}function W(v,$){v=v.slice(),ge($);const K=s.readCursor($);let q,z,Y=!1;const ue=[];for(let H=0;;H++){const ne=v[H],oe=K.getComponent();if(oe&&(oe.r!==void 0?Y=!0:oe.p!=null&&(Y=!1,q=oe.p,z=H)),H>=v.length)break;let _e=0;const ye=s.advancer(K,void 0,(X,Se)=>{c(Se)&&_e++});ue.unshift(ye);const Ue=ye(ne);if(typeof ne=="number"&&(v[H]-=_e),!Ue)break}if(ue.forEach(H=>H.end()),Y)return null;const ae=()=>{let H=0;if(q!=null){const ne=K.getPath();H=ne.length,v=ne.concat(v.slice(z))}for(;H<v.length;H++){const ne=v[H],oe=a(K),_e=fe(oe);if(_e){const X=M(oe);_e.transformPosition&&(v[H]=_e.transformPosition(v[H],X));break}let ye=0;const Ue=s.advancer(K,(X,Se)=>h(Se)?~(X-ye):X-ye,(X,Se)=>{h(Se)&&ye++})(ne);if(typeof ne=="number"&&(v[H]+=ye),!Ue)break}};return q!=null?K.eachDrop(null,H=>{H===q&&ae()}):ae(),v}function O(v,$){if(ge(v),ge($),v==null)return $;if($==null)return v;let K=0;const q=s.readCursor(v),z=s.readCursor($),Y=s.writeCursor(),ue=[],ae=[],H=[],ne=[],oe=[],_e=[],ye=new Set;q.traverse(null,X=>{X.p!=null&&(H[X.p]=q.clone())}),z.traverse(null,X=>{X.d!=null&&(ne[X.d]=z.clone())});const Ue=s.writeCursor();return function X(Se,Ge,je,Pe,Ze,Rt,Ke,rt){o(Ge||je);const Xe=a(Ge),ht=a(je),at=!!ht&&ht.r!==void 0,Bt=!!Xe&&Xe.i!==void 0,$e=Xe?Xe.d:null,dt=ht?ht.p:null,E=(Rt||at)&&dt==null;if(dt!=null)Pe=ne[dt],Ke=ae[dt]=new s.WriteCursor;else if(ht&&ht.r!==void 0)Pe=null;else{const L=a(Pe);L&&L.d!=null&&(Pe=null)}const m=a(Pe);if($e!=null)if(Se=H[$e],rt=ue[$e]=new s.WriteCursor,E)Rt&&!at&&rt.write("r",!0);else{const L=oe[$e]=K++;Ke.write("d",L)}else if(Xe&&Xe.i!==void 0)Se=null;else{const L=a(Se);L&&L.p!=null&&(Se=null)}let _;Bt?(o(Ze===void 0),_=Xe.i):_=Ze;const A=(dt==null?!Bt||Rt||at:_===void 0)?null:Ke.getComponent();if(dt!=null){if(!(Ze!==void 0||Bt)){const L=$e!=null?oe[$e]:K++;_e[dt]=L,rt.write("p",L)}}else at&&(Bt||Ze!==void 0||(ht.r,rt.write("r",ht.r)));const N=E?null:fe(Xe),P=fe(m);if((N||P)&&(N&&N.name,P&&P.name),N&&P){o(N===P);const L=M(Xe),te=M(m),Re=N.compose(L,te);T(Ke,N,Re),ye.add(m)}else N?T(Ke,N,M(Xe)):P&&(T(Ke,P,M(m)),ye.add(m));const k=typeof _=="object"&&_!=null;let F=!1,S=0,ee=0,Ee=0,J=0,pe=0;const be=s.advancer(Pe,(L,te)=>h(te)?J-L-1:L-J,(L,te)=>{h(te)&&J++}),ce=s.advancer(Se,(L,te)=>c(te)?S-L-1:L-S,(L,te)=>{c(te)&&S++});if(s.eachChildOf(Ge,je,(L,te,Re)=>{let Te,Fe,xe=L,Ye=L,ft=L;if(typeof L=="number"){let De=L+Ee;Fe=be(De),Ye=De+J;let se=L+ee;Te=ce(se),h(a(Fe))&&(Te=null),xe=se+S,ft=L+pe,o(xe>=0,"p1PickKey is negative"),o(Ye>=0,"p2DropKey is negative");const ut=h(a(te)),He=c(a(Re));(ut||He&&!E)&&pe--,ut&&ee--,He&&Ee--}else Te=ce(L),Fe=be(L);rt.descend(xe),Ke.descend(Ye);const mt=k&&!h(a(te))?_[ft]:void 0,Ce=X(Te,te,Re,Fe,mt,E,Ke,rt);var et,we,Oe;k&&!E?mt!==Ce&&(F||(_=Array.isArray(_)?_.slice():Object.assign({},_),F=!0),et=_,Oe=Ce,typeof(we=ft)=="number"?(o(Array.isArray(et)),o(we<et.length)):(o(!Array.isArray(et)),o(et[we]!==void 0)),Oe===void 0?typeof we=="number"?et.splice(we,1):delete et[we]:et[we]=Oe):o(Ce===void 0),Ke.ascend(),rt.ascend()}),ce.end(),be.end(),A!=null)A.i=_;else if(!Rt&&!at&&dt==null)return _}(q,q.clone(),z,z.clone(),void 0,!1,Y,Ue),Y.reset(),Y.mergeTree(Ue.get()),Y.reset(),Y.get(),ue.map(X=>X.get()),ae.map(X=>X.get()),q.traverse(Y,(X,Se)=>{const Ge=X.p;if(Ge!=null){const je=oe[Ge];je!=null&&Se.write("p",je);const Pe=ue[Ge];Pe&&Pe.get(),Pe&&Se.mergeTree(Pe.get())}else X.r!==void 0&&Se.write("r",X.r)}),Y.reset(),Y.get(),z.traverse(Y,(X,Se)=>{const Ge=X.d;if(Ge!=null){const Pe=_e[Ge];Pe!=null&&Se.write("d",Pe);const Ze=ae[Ge];Ze&&Se.mergeTree(Ze.get())}else X.i!==void 0&&Se.write("i",X.i);const je=fe(X);je&&!ye.has(X)&&T(Se,je,M(X))}),Y.get()}function D(v){if(v==null)return null;const $=new s.ReadCursor(v),K=new s.WriteCursor;let q;const z=[],Y=[];return function ue(ae,H,ne){const oe=ae.getComponent();let _e,ye=!1;if(oe){oe.p!=null&&(H.write("d",oe.p),z[oe.p]=ae.clone()),oe.r!==void 0&&H.write("i",oe.r),oe.d!=null&&(H.write("p",oe.d),ne=void 0),oe.i!==void 0&&(ne=_e=oe.i);const X=fe(oe);X&&(ne===void 0?(q||(q=new Set),q.add(oe)):(M(oe),ne=X.apply(ne,M(oe)),ye=!0))}let Ue=0;for(const X of ae){H.descend(X);const Se=typeof X=="number"?X-Ue:X,Ge=I(ne,Se);h(ae.getComponent())&&Ue++;const je=ue(ae,H,Ge);if(ne!==void 0&&je!==void 0){if(ye||(ye=!0,ne=u(ne)),!C(ne,Se))throw Error("Cannot modify child - invalid operation");ne[Se]=je}H.ascend()}if(_e===void 0)return ye?ne:void 0;H.write("r",ne)}($,K,void 0),q&&(K.reset(),function ue(ae,H,ne){const oe=H.getComponent();if(oe){const X=oe.d;if(X!=null&&(ae=z[X],ne=Y[X]=s.writeCursor()),q.has(oe)){const Se=fe(oe);if(!Se.invert)throw Error(`Cannot invert subtype ${Se.name}`);T(ne,Se,Se.invert(M(oe)))}}let _e=0,ye=0;const Ue=s.advancer(ae,(X,Se)=>c(Se)?_e-X-1:X-_e,(X,Se)=>{c(Se)&&_e++});for(const X of H)if(typeof X=="number"){const Se=X-ye,Ge=Ue(Se),je=Se+_e;ne.descend(je),ue(Ge,H,ne),h(H.getComponent())&&ye++,ne.ascend()}else ne.descend(X),ue(Ue(X),H,ne),ne.ascend();Ue.end()}($.clone(),$,K),Y.length&&(K.reset(),$.traverse(K,(ue,ae)=>{const H=ue.p;if(H!=null){const ne=Y[H];ne&&ne.get(),ne&&ae.mergeTree(ne.get())}}))),K.get()}const y=(v,$)=>v.some(K=>typeof K=="object"&&(Array.isArray(K)?y(K,$):$(K)));function w(v,$){if(v==null||!y(v,H=>{var ne;return H.r!==void 0||((ne=fe(H))===null||ne===void 0?void 0:ne.makeInvertible)!=null}))return v;const K=new s.ReadCursor(v),q=new s.WriteCursor;let z=!1;const Y=[],ue=[],ae=(H,ne,oe)=>{const _e=H.getComponent();let ye=!1;if(_e){_e.d!=null&&ne.write("d",_e.d),_e.i!==void 0&&ne.write("i",_e.i);const X=_e.p;if(X!=null&&(Y[X]=H.clone(),o(oe!==void 0,"Operation picks up at an invalid key"),ue[X]=oe,ne.write("p",_e.p)),_e.r!==void 0&&oe===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const Se=fe(_e);Se&&(Se.makeInvertible?z=!0:T(ne,Se,M(_e),!0))}let Ue=0;for(const X of H){ne.descend(X);const Se=typeof X=="number"?X-Ue:X,Ge=I(oe,Se),je=ae(H,ne,Ge);Ge!==je&&(ye||(ye=!0,oe=u(oe)),je===void 0?(oe=f(oe,Se),typeof X=="number"&&Ue++):oe[Se]=je),ne.ascend()}return _e&&(_e.r!==void 0?(ne.write("r",r.default(oe)),oe=void 0):_e.p!=null&&(oe=void 0)),oe};return ae(K,q,$),q.get(),z&&(q.reset(),function H(ne,oe,_e,ye,Ue){const X=oe.getComponent();if(X){X.i!==void 0?(ye=X.i,Ue=!0):X.d!=null&&(ye=ue[X.d],ne=Y[X.d],Ue=!1,X.d);let Pe=fe(X);if(Pe&&Pe.makeInvertible){const Ze=M(X);T(_e,Pe,Pe.makeInvertible(Ze,ye),!0)}}let Se=0,Ge=0;const je=s.advancer(ne,(Pe,Ze)=>c(Ze)?Se-Pe-1:Pe-Se,(Pe,Ze)=>{c(Ze)&&Se++});for(const Pe of oe)if(typeof Pe=="number"){const Ze=Pe-Ge,Rt=je(Ze),Ke=Ze+Se,rt=I(ye,Ue?Ze:Ke);_e.descend(Pe),H(Rt,oe,_e,rt,Ue),h(oe.getComponent())&&Ge++,_e.ascend()}else{const Ze=I(ye,Pe);_e.descend(Pe),H(je(Pe),oe,_e,Ze,Ue),_e.ascend()}je.end()}(K.clone(),K,q,$,!1)),q.get()}function x(v,$){return D(w(v,$))}const B=v=>{if(v==null)return null;const $=v.slice();for(let K=0;K<v.length;K++){const q=$[K];Array.isArray(q)&&($[K]=B(q))}return $};function G(v,$,K){o(K==="left"||K==="right","Direction must be left or right");const q=K==="left"?0:1;if($==null)return{ok:!0,result:v};ge(v),ge($);let z=null;const Y=[],ue=[],ae=[],H=[],ne=[],oe=[],_e=[],ye=[],Ue=[],X=[],Se=[],Ge=[],je=[],Pe=[],Ze=[];let Rt=0;const Ke=s.readCursor(v),rt=s.readCursor($),Xe=s.writeCursor();if(function m(_,A=null,N){const P=a(A);P&&(P.r!==void 0?N=A.clone():P.p!=null&&(N=null,oe[P.p]=_.clone()));const k=_.getComponent();let F;k&&(F=k.p)!=null&&(ne[F]=A?A.clone():null,ae[F]=_.clone(),N&&(X[F]=!0,Ue[F]=N),P&&P.p!=null&&(Pe[F]=P.p));const S=s.advancer(A);for(const ee of _)m(_,S(ee),N);S.end()}(rt,Ke,null),function m(_,A,N,P,k){const F=N.getComponent();let S,ee=!1;F&&((S=F.d)!=null?(H[S]=N.clone(),P!=null&&(Ze[P]==null&&(Ze[P]=[]),Ze[P].push(S)),X[S],_=ne[S]||null,A=ae[S]||null,X[S]?(k&&(Se[S]=!0),k=Ue[S]||null):!k||q!==1&&Pe[S]!=null||z==null&&(z={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(k.getPath()),op2:e.moveOp(A.getPath(),N.getPath())}),ee=!0):F.i!==void 0&&(_=A=null,ee=!0,k&&z==null&&(z={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(k.getPath()),op2:e.insertOp(N.getPath(),F.i)})));const Ee=a(_);Ee&&(Ee.r!==void 0?k=_.clone():Ee.p!=null&&(Ee.p,P=Ee.p,k=null));const J=fe(F);J&&k&&z==null&&(z={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(k.getPath()),op2:e.editOp(N.getPath(),J,M(F),!0)});let pe=0,be=0;const ce=s.advancer(A,(te,Re)=>c(Re)?pe-te-1:te-pe,(te,Re)=>{c(Re)&&pe++}),L=s.advancer(_);for(const te of N)if(typeof te=="number"){const Re=te-be,Te=ce(Re);be+=+m(L(Re+pe),Te,N,P,k)}else{const Re=ce(te);m(L(te),Re,N,P,k)}return ce.end(),L.end(),ee}(Ke,rt,rt.clone(),null,null),H.map(m=>m&&m.get()),z)return{ok:!1,conflict:z};Se.map(m=>!!m);const ht=[];let at=null;(function m(_,A,N,P,k){let F=!1;const S=a(A);if(c(S)){const ce=S.p;ce!=null?(N=H[ce],P=Ge[ce]=s.writeCursor(),F=!0,k=null):(N=null,k=A.clone())}else h(a(N))&&(N=null);const ee=_.getComponent();if(ee){const ce=ee.p;ce!=null?(k&&(ye[ce]=k),ht[ce]=k||q===1&&F?null:P.getComponent(),Y[ce]=_.clone(),N&&(_e[ce]=N.clone())):ee.r!==void 0&&(k||P.write("r",!0),(k||F)&&(at==null&&(at=new Set),at.add(ee)))}let Ee=0,J=0;const pe=s.advancer(A,void 0,(ce,L)=>{c(L)&&Ee++}),be=s.advancer(N,(ce,L)=>h(L)?~(ce-J):ce-J,(ce,L)=>{h(L)&&J++});if(_)for(const ce of _)if(typeof ce=="string"){const L=pe(ce),te=be(ce);P.descend(ce),m(_,L,te,P,k),P.ascend()}else{const L=pe(ce),te=ce-Ee,Re=c(a(L))?null:be(te),Te=te+J;o(Te>=0),P.descend(Te),m(_,L,Re,P,k),P.ascend()}pe.end(),be.end()})(Ke,rt,rt.clone(),Xe,null),Xe.reset();let Bt=[];if(function m(_,A,N,P,k,F){o(A);const S=A.getComponent();let ee=a(P),Ee=!1;const J=(we,Oe,De)=>we?e.moveOp(we.getPath(),Oe.getPath()):e.insertOp(Oe.getPath(),De.i);if(h(S)){const we=S.d;we!=null&&(ue[we]=A.clone());const Oe=we!=null?ht[we]:null;let De=!1;if(S.i!==void 0||we!=null&&Oe){let se;ee&&(ee.i!==void 0||(se=ee.d)!=null&&!X[se])&&(De=se!=null?we!=null&&we===Pe[se]:n.default(ee.i,S.i),De||se!=null&&q!==1&&Pe[se]!=null||z==null&&(z={type:i.ConflictType.DROP_COLLISION,op1:J(we!=null?Y[we]:null,A,S),op2:J(se!=null?ae[se]:null,P,ee)})),De||(F?z==null&&(z={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:J(we!=null?Y[we]:null,A,S),op2:e.removeOp(F.getPath())}):(we!=null?(Bt[Rt]=we,k.write("d",Oe.p=Rt++)):k.write("i",r.default(S.i)),Ee=!0))}else if(we!=null&&!Oe){const se=ye[we];se&&(F=se.clone())}we!=null?(_=Y[we],N=oe[we],P=_e[we]):S.i!==void 0&&(_=N=null,De||(P=null))}else c(a(_))&&(_=N=P=null);const pe=a(_),be=a(N);if(c(be)){const we=be.p;be.r!==void 0&&(!pe||pe.r===void 0)||X[we]?(P=null,F=N.clone()):we!=null&&(P=H[we],q!==1&&Pe[we]!=null||((k=je[we])||(k=je[we]=s.writeCursor()),k.reset(),F=null))}else!h(S)&&h(ee)&&(P=null);ee=P!=null?P.getComponent():null;const ce=fe(S);if(ce){const we=M(S);if(F)z==null&&(z={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.editOp(A.getPath(),ce,we,!0),op2:e.removeOp(F.getPath())});else{const Oe=fe(ee);let De;if(Oe){if(ce!==Oe)throw Error("Transforming incompatible types");const se=M(ee);De=ce.transform(we,se,K)}else De=r.default(we);T(k,ce,De)}}let L=0,te=0,Re=0,Te=0,Fe=0,xe=0,Ye=_!=null&&_.descendFirst(),ft=Ye;const mt=s.advancer(N,void 0,(we,Oe)=>{c(Oe)&&Re++});let Ce=P!=null&&P.descendFirst(),et=Ce;for(const we of A)if(typeof we=="number"){let Oe;const De=h(A.getComponent()),se=we-te;{let Zt;for(;Ye&&typeof(Zt=_.getKey())=="number";){Zt+=L;const At=_.getComponent(),Dn=c(At);if(Zt>se||Zt===se&&(!Dn||q===0&&De))break;if(Dn){L--;const hn=At.p;Pe.includes(hn),At.d,a(je[At.d]),c(a(je[At.d])),(At.r===void 0||at&&at.has(At))&&(hn==null||!ht[hn]||q!==1&&Pe.includes(hn))||Fe--}Ye=_.nextSibling()}Oe=Ye&&Zt===se?_:null}const ut=se-L;let He=mt(ut);const Dt=ut-Re;let os=null;{let Zt,At;for(;Ce&&typeof(Zt=P.getKey())=="number";){At=Zt-Te;const Dn=P.getComponent(),hn=h(Dn);if(At>Dt)break;if(At===Dt){if(!hn){os=P;break}{if(q===0&&De){os=P;break}const Qt=He&&c(He.getComponent());if(q===0&&Qt)break}}if(hn){const Qt=Dn.d;X[Qt],Pe[Qt],Dn.i===void 0&&(X[Qt]||Pe[Qt]!=null&&q!==1)?(X[Qt]||Pe[Qt]!=null&&q===0)&&(Te++,xe--):Te++}Ce=P.nextSibling()}}const qu=Dt+Te+Fe+xe;o(qu>=0,"trying to descend to a negative index"),k.descend(qu),De&&(Oe=He=os=null,te++),m(Oe,A,He,os,k,F)&&xe++,k.ascend()}else{let Oe;for(;Ye&&(Oe=_.getKey(),typeof Oe!="string"||!(Oe>we||Oe===we));)Ye=_.nextSibling();const De=Ye&&Oe===we?_:null,se=mt(we);let ut;for(;Ce&&(ut=P.getKey(),typeof ut!="string"||!(ut>we||ut===we));)Ce=P.nextSibling();const He=Ce&&ut===we?P:null;k.descend(we),m(De,A,se,He,k,F),k.ascend()}return mt.end(),ft&&_.ascend(),et&&P.ascend(),Ee}(Ke,Ke.clone(),rt,rt.clone(),Xe,null),z)return{ok:!1,conflict:z};Xe.reset();const $e=(m,_,A)=>m.traverse(_,(N,P)=>{N.d!=null&&A(N.d,m,P)});(X.length||Ge.length)&&($e(rt,Xe,(m,_,A)=>{X[m]&&!Se[m]&&A.write("r",!0),Ge[m]&&A.mergeTree(Ge[m].get())}),Xe.reset());const dt=[],E=[];if((je.length||X.length)&&!z){const m=s.readCursor(B(Xe.get()));if($e(m,null,(_,A)=>{dt[_]=A.clone()}),je.forEach(_=>{_&&$e(s.readCursor(_.get()),null,(A,N)=>{dt[A]=N.clone()})}),function _(A,N,P,k,F,S){const ee=a(N);if(ee&&c(ee))if(ee.p!=null){const L=ee.p;dt[L].getPath(),P=dt[L],k=E[L]=s.writeCursor()}else ee.r!==void 0&&(P=null);else h(a(P))&&(P=null);const Ee=A.getComponent();if(Ee){let L;if((L=Ee.d)!=null){const te=je[L];te&&(te.get(),k.mergeTree(te.get()),P=s.readCursor(te.get()))}}let J=0,pe=0;const be=s.advancer(N,void 0,(L,te)=>{c(te)&&J--}),ce=s.advancer(P,(L,te)=>h(te)?-(L-pe)-1:L-pe,(L,te)=>{h(te)&&pe++});for(const L of A)if(typeof L=="number"){const te=be(L),Re=L+J,Te=ce(Re),Fe=Re+pe;k.descend(Fe),_(A,te,Te,k),k.ascend()}else k.descend(L),_(A,be(L),ce(L),k),k.ascend();be.end(),ce.end()}(rt,m,m.clone(),Xe),Xe.reset(),z)return{ok:!1,conflict:z};if(Xe.get(),E.length){const _=E.map(N=>N?N.get():null),A=s.readCursor(B(Xe.get()));if($e(A,Xe,(N,P,k)=>{const F=_[N];F&&(k.mergeTree(F),_[N]=null)}),_.find(N=>N)){const N=s.writeCursor(),P=s.writeCursor();let k=0,F=0;_.forEach(S=>{S!=null&&$e(s.readCursor(S),null,ee=>{const Ee=Bt[ee];N.writeMove(Y[Ee].getPath(),ue[Ee].getPath(),k++);const J=Ze[Ee];J&&J.forEach(pe=>{X[pe]||q!==1&&Pe[pe]!=null||P.writeMove(ae[pe].getPath(),H[pe].getPath(),F++)})})}),z={type:i.ConflictType.BLACKHOLE,op1:N.get(),op2:P.get()}}}}return z?{ok:!1,conflict:z}:{ok:!0,result:Xe.get()}}const ie=v=>{const $=new Error("Transform detected write conflict");throw $.conflict=v,$.type=$.name="writeConflict",$};function de(v,$,K){const q=G(v,$,K);if(q.ok)return q.result;ie(q.conflict)}const me=v=>{const $=s.writeCursor();return s.readCursor(v).traverse($,(K,q)=>{(h(K)||fe(K))&&q.write("r",!0)}),$.get()},Me=(v,$)=>{const{type:K,op1:q,op2:z}=v;switch(K){case i.ConflictType.DROP_COLLISION:return $==="left"?[null,me(z)]:[me(q),null];case i.ConflictType.RM_UNEXPECTED_CONTENT:let Y=!1;return s.readCursor(q).traverse(null,ue=>{ue.r!==void 0&&(Y=!0)}),Y?[null,me(z)]:[me(q),null];case i.ConflictType.BLACKHOLE:return[me(q),me(z)];default:throw Error("Unrecognised conflict: "+K)}};function Ae(v,$,K,q){let z=null;for(;;){const Y=G($,K,q);if(Y.ok)return O(z,Y.result);{const{conflict:ue}=Y;v(ue)||ie(ue);const[ae,H]=Me(ue,q);$=O(le($),ae),K=O(le(K),H),z=O(z,H)}}}}(Qn)),Qn}var Cl;function r_(){return Cl||(Cl=1,function(e){var t=an&&an.__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=an&&an.__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(n_(),e);var r=hl();Object.defineProperty(e,"ReadCursor",{enumerable:!0,get:function(){return r.ReadCursor}}),Object.defineProperty(e,"WriteCursor",{enumerable:!0,get:function(){return r.WriteCursor}});var s=fl();Object.defineProperty(e,"ConflictType",{enumerable:!0,get:function(){return s.ConflictType}})}(an)),an}var gt=r_();const s_=Ju({__proto__:null,default:pt(gt)},[gt]);var he=(e=>(e.RETAIN="r",e.INSERT="i",e.DELETE="d",e))(he||{});function er(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&&re.isEmptyObject(o)&&r.sId==null)continue;if(n.length===0){n.push(r);continue}const a=n.pop();mo(r,a)&&re.hasIntersectionBetweenTwoRanges(a.st,a.ed,r.st,r.ed)?n.push({...r,st:a.st,ed:i}):n.push(a,r)}return n}function Rl(e,t,n,r){var u;const{textRuns:s}=e;if(s==null)return;const i=[],o=s.length;let a=!1;const l=(u=t.textRuns)!=null?u:[];if(l.length)for(const c of l)c.st+=r,c.ed+=r;for(let c=0;c<o;c++){const h=s[c],{st:f,ed:g}=h;if(g<=r)i.push(h);else if(r>f&&r<g){a=!0;const C={...h,ed:r};i.push(C),l.length&&i.push(...l);const I={...h,st:r+n,ed:g+n};i.push(I)}else h.st+=n,h.ed+=n,a||(a=!0,i.push(...l)),i.push(h)}a||(a=!0,i.push(...l)),e.textRuns=er(i)}function Il(e,t,n,r){const{paragraphs:s}=e;if(s==null)return;const{paragraphs:i}=t,o=[];for(let l=0,u=s.length;l<u;l++){const c=s[l],{startIndex:h}=c;h>=r&&(c.startIndex+=n),o.push(c.startIndex)}let a=-1;if(i){for(let l=0,u=i.length;l<u;l++){const c=i[l];c.startIndex+=r;const h=c.startIndex;a=o.indexOf(h)}a!==-1&&s.splice(a,1),s.push(...i),s.sort(Gn("startIndex"))}}function Sl(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:u}=l;u>=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(Gn("startIndex"))}}function vl(e,t,n,r){const{customBlocks:s=[]}=e;for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:u}=l;u>=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(Gn("startIndex"))}s.length&&!e.customBlocks&&(e.customBlocks=s)}function Ol(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:u,endIndex:c}=l;u>r?(l.startIndex+=n,l.endIndex+=n):c>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(Gn("startIndex"))}}const wl="$",bl=e=>e.split(wl)[0];function Zs(e){if(e.length<=1)return e;e.sort((s,i)=>s.startIndex-i.startIndex);const t=[];let n={...e[0]};n.rangeId=bl(n.rangeId);for(let s=1;s<e.length;s++){const i=e[s];i.rangeId=bl(i.rangeId),i.rangeId===n.rangeId&&al(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}${wl}${r[a]}`,r[a]=r[a]+1):r[a]=1}return t}function Qs(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 yl(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 ei(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 i_(e,t,n,r){e.customRanges||(e.customRanges=[]);const{customRanges:s}=e;Qs(s,r);for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:u}=l;u>=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=Zs(s)}function o_(e,t,n,r){e.customDecorations||(e.customDecorations=[]);const{customDecorations:s}=e;ei(s,r);for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:u}=l;u>=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=yl(s)}function Al(e,t,n){const{textRuns:r}=e,s=n,i=n+t,o=[];if(r){const a=[];for(let l=0,u=r.length;l<u;l++){const c=r[l],{st:h,ed:f}=c;if(s<=h&&i>=f){o.push({...c,st:h-s,ed:f-s});continue}else h<=s&&f>=i?(o.push({...c,st:s-s,ed:i-s}),c.ed-=t):s>=h&&s<f?(o.push({...c,st:s-s,ed:f-s}),c.ed=s):i>h&&i<=f?(o.push({...c,st:h-s,ed:i-s}),c.st=i-t,c.ed-=t):h>=i&&(c.st-=t,c.ed-=t);a.push(c)}e.textRuns=a}return o.length===0&&o.push({st:0,ed:t,ts:{}}),o}function Tl(e,t,n){const{paragraphs:r}=e,s=n,i=n+t,o=[];if(r){const a=[];for(let l=0,u=r.length;l<u;l++){const c=r[l],{startIndex:h}=c;if(h>=s&&h<i){o.push({...c,startIndex:h-n});continue}else h>=i&&(c.startIndex-=t);a.push(c)}e.paragraphs=a}return o}function Nl(e,t,n){const{sectionBreaks:r}=e,s=n,i=n+t-1,o=[];if(r){const a=[];for(let l=0,u=r.length;l<u;l++){const c=r[l],{startIndex:h}=c;if(h>=s&&h<=i){o.push({...c,startIndex:h-n});continue}else h>i&&(c.startIndex-=t);a.push(c)}e.sectionBreaks=a}return o}function Ml(e,t,n){const{customBlocks:r=[]}=e,s=n,i=n+t-1,o=[];if(r){const a=[];for(let l=0,u=r.length;l<u;l++){const c=r[l],{startIndex:h}=c;if(h>=s&&h<=i){o.push({...c,startIndex:h-n});continue}else h>i&&(c.startIndex-=t);a.push(c)}e.customBlocks=a}return r.length&&!e.customBlocks&&(e.customBlocks=r),o}function Dl(e,t,n){const{tables:r}=e,s=n,i=n+t-1,o=[];if(r){const a=[];for(let l=0,u=r.length;l<u;l++){const c=r[l],{startIndex:h,endIndex:f}=c;if(s<=h&&i>=f){o.push({...c,startIndex:h-n,endIndex:f-n});continue}else if(h<=s&&f>=i){const g=Pr(h,f,s,i);if(g.length===0||(c.startIndex=g[0],c.endIndex=g[1],c.startIndex===c.endIndex))continue}else i<h&&(c.startIndex-=t,c.endIndex-=t);a.push(c)}e.tables=a}return o}function a_(e,t,n){const{customRanges:r}=e,s=n,i=n+t-1,o=[];if(r){const a=[];for(let l=0,u=r.length;l<u;l++){const c=r[l],{startIndex:h,endIndex:f}=c;if(h>=s&&f<=i){o.push(c);continue}else if(Math.max(s,h)<=Math.min(i,f)){const g=Pr(h,f,s,i);if(g.length===0)continue;c.startIndex=g[0],c.endIndex=g[1]}else i<h&&(c.startIndex-=t,c.endIndex-=t);a.push(c)}e.customRanges=Zs(a)}return o}function l_(e,t,n,r=!0){const{customDecorations:s}=e,i=n,o=n+t-1,a=[];if(s){const l=[];for(let u=0,c=s.length;u<c;u++){const h=s[u],{startIndex:f,endIndex:g}=h;if(f>=i&&g<=o){a.push(h);continue}else if(Math.max(i,f)<=Math.min(o,g)){const C=Pr(f,g,i,o);if(C.length===0)continue;h.startIndex=C[0],h.endIndex=C[1]}else o<f&&r&&(h.startIndex-=t,h.endIndex-=t);l.push(h)}e.customDecorations=l}return a}var Ll=(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))(Ll||{}),Mt=(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))(Mt||{});const Qr={"a)":{glyphFormat:"%1)",glyphType:Ne.DECIMAL},"1.":{glyphType:Ne.DECIMAL},"a.":{glyphFormat:"%1.",glyphType:Ne.LOWER_LETTER},"A.":{glyphType:Ne.UPPER_LETTER},"i.":{glyphFormat:"%1.",glyphType:Ne.LOWER_ROMAN},"I.":{glyphFormat:"%1.",glyphType:Ne.UPPER_LETTER}},Sn=e=>[...e,...e,...e].map((t,n)=>({glyphFormat:` %${n+1}`,glyphSymbol:t,bulletAlignment:Kn.START,textStyle:{fs:12},startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*n}}})),vn=e=>e.map((t,n)=>({...t,bulletAlignment:Kn.START,textStyle:{fs:12},startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*n}}})),Ul=(e,t)=>new Array(9).fill(0).map((n,r)=>({glyphFormat:` %${r+1}`,glyphSymbol:e,bulletAlignment:Kn.START,textStyle:{fs:16},startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*r},textStyle:t}})),tr={BULLET_LIST:{listType:"BULLET_LIST",nestingLevel:Sn(["●","○","■"])},BULLET_LIST_1:{listType:"BULLET_LIST",nestingLevel:Sn(["❖","➢","■"])},BULLET_LIST_2:{listType:"BULLET_LIST",nestingLevel:Sn(["✔","●","◆"])},BULLET_LIST_3:{listType:"BULLET_LIST",nestingLevel:Sn(["■","◆","○"])},BULLET_LIST_4:{listType:"BULLET_LIST",nestingLevel:Sn(["✧","○","■"])},BULLET_LIST_5:{listType:"BULLET_LIST",nestingLevel:Sn(["➢","○","◆"])},ORDER_LIST:{listType:"ORDER_LIST",nestingLevel:vn([{glyphFormat:"%1.",glyphType:Ne.DECIMAL},{glyphFormat:"%2.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%3.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%4.",glyphType:Ne.DECIMAL},{glyphFormat:"%5.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%6.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%7.",glyphType:Ne.DECIMAL},{glyphFormat:"%8.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%9.",glyphType:Ne.LOWER_ROMAN}])},ORDER_LIST_1:{listType:"ORDER_LIST",nestingLevel:vn([{glyphFormat:"%1)",glyphType:Ne.DECIMAL},{glyphFormat:"%2)",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%3)",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%4)",glyphType:Ne.DECIMAL},{glyphFormat:"%5)",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%6)",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%7)",glyphType:Ne.DECIMAL},{glyphFormat:"%8)",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%9)",glyphType:Ne.LOWER_ROMAN}])},ORDER_LIST_2:{listType:"ORDER_LIST",nestingLevel:vn(["%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:Ne.DECIMAL})))},ORDER_LIST_3:{listType:"ORDER_LIST",nestingLevel:vn([{glyphFormat:"%1.",glyphType:Ne.UPPER_LETTER},{glyphFormat:"%2.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%3.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%4.",glyphType:Ne.UPPER_LETTER},{glyphFormat:"%5.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%6.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%7.",glyphType:Ne.UPPER_LETTER},{glyphFormat:"%8.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%9.",glyphType:Ne.LOWER_ROMAN}])},ORDER_LIST_4:{listType:"ORDER_LIST",nestingLevel:vn([{glyphFormat:"%1.",glyphType:Ne.UPPER_LETTER},{glyphFormat:"%2.",glyphType:Ne.DECIMAL},{glyphFormat:"%3.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%4.",glyphType:Ne.UPPER_LETTER},{glyphFormat:"%5.",glyphType:Ne.DECIMAL},{glyphFormat:"%6.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%7.",glyphType:Ne.UPPER_LETTER},{glyphFormat:"%8.",glyphType:Ne.DECIMAL},{glyphFormat:"%9.",glyphType:Ne.LOWER_ROMAN}])},ORDER_LIST_5:{listType:"ORDER_LIST",nestingLevel:vn([{glyphFormat:"%1.",glyphType:Ne.DECIMAL_ZERO},{glyphFormat:"%2.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%3.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%4.",glyphType:Ne.DECIMAL_ZERO},{glyphFormat:"%5.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%6.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%7.",glyphType:Ne.DECIMAL_ZERO},{glyphFormat:"%8.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%9.",glyphType:Ne.LOWER_ROMAN}])},CHECK_LIST:{listType:"CHECK_LIST",nestingLevel:Ul("☐")},CHECK_LIST_CHECKED:{listType:"CHECK_LIST_CHECKED",nestingLevel:Ul("☑",{st:{s:ve.TRUE}})}},es=e=>{const{glyphFormat:t,glyphType:n}=e,r=re.deepClone(tr.ORDER_LIST);return r.nestingLevel[0].glyphFormat=t,r.nestingLevel[0].glyphType=n,r},u_={ORDER_LIST_QUICK_2:es(Qr["a)"]),ORDER_LIST_QUICK_3:es(Qr["a."]),ORDER_LIST_QUICK_4:es(Qr["i."]),ORDER_LIST_QUICK_6:es(Qr["I."])};Object.assign(tr,u_);const c_={"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"};function h_(e,t,n,r,s){const i=d_(e,t,n,r,s),o=f_(e,t,n,r,s),a=g_(e,t,n,r,s),l=m_(e,t,n,r,s),u=__(e,t,n,r,s),c=p_(e,t,n,r),h=E_(e,t,n,r,s);return{dataStream:"",textRuns:i,paragraphs:o,sectionBreaks:a,customBlocks:l,tables:u,customRanges:c,customDecorations:h}}function d_(e,t,n,r,s){const{textRuns:i}=e,{textRuns:o}=t;if(i==null||o==null)return;const a=Al(e,n,r);if(s!==ke.REPLACE){const l=kl(o,a,s);t.textRuns=l}return Rl(e,t,n,r),a}function kl(e,t,n){if(t.length===0)return e;e=re.deepClone(e),t=re.deepClone(t);const r=[],s=e.length,i=t.length;let o=0,a=0,l=null;function u(){return l?(r.push(l),l=null,!0):!1}for(;o<s&&a<i;){const{st:g,ed:C,ts:I}=e[o],{st:b,ed:U,ts:Z,sId:V}=t[a];let fe;if(n===ke.COVER?fe={...Z,...I}:fe={...I},C<b)u()||r.push(e[o]),o++;else if(U<g)u()||r.push(t[a]),a++;else{const M={st:Math.min(g,b),ed:Math.max(g,b),ts:g<b?{...I}:{...Z},sId:g<b?void 0:V};M.ed>M.st&&r.push(M),r.push({st:Math.max(g,b),ed:Math.min(C,U),ts:fe,sId:V}),C<U?(o++,t[a].st=C,t[a].st===t[a].ed&&a++):(a++,e[o].st=U,e[o].st===e[o].ed&&o++);const T={st:Math.min(C,U),ed:Math.max(C,U),ts:C<U?{...Z}:{...I},sId:C<U?V:void 0};l=T.ed>T.st?T:null}}u();const c=r[r.length-1],h=e[s-1],f=t[i-1];return c&&c.ed!==Math.max(h.ed,f.ed)&&(h.ed>f.ed?r.push(h):r.push(f)),er(r)}function f_(e,t,n,r,s){const{paragraphs:i}=e,{paragraphs:o}=t;if(i==null||o==null)return;const a=Tl(e,n,r);if(s!==ke.REPLACE){const l=[];for(const u of o){const{startIndex:c,paragraphStyle:h,bullet:f}=u;let g=[];for(const C of a){const{startIndex:I,paragraphStyle:b,bullet:U}=C;let Z,V;if(s===ke.COVER?(Z={...b,...h},V={listId:"",listType:Mt.BULLET_LIST,nestingLevel:0,textStyle:{},...U,...f}):(Z={...h,...b},V={listId:"",listType:Mt.BULLET_LIST,nestingLevel:0,textStyle:{},...f,...U}),c===I){g.push({startIndex:c,paragraphStyle:Z,bullet:V});break}}l.push(...g),g=[]}t.paragraphs=l}return Il(e,t,n,r),a}function g_(e,t,n,r,s){const{sectionBreaks:i}=e,{sectionBreaks:o}=t;if(i==null||o==null)return;const a=Nl(e,n,r);if(s!==ke.REPLACE){const l=[];for(const u of o){const{startIndex:c}=u;let h=[];for(const f of a){const{startIndex:g}=f;if(c===g){s===ke.COVER?h.push({...f,...u}):h.push({...u,...f});break}}l.push(...h),h=[]}t.sectionBreaks=l}return Sl(e,t,n,r),a}function m_(e,t,n,r,s){const{customBlocks:i=[]}=e,{customBlocks:o}=t;if(i==null||o==null)return;const a=Ml(e,n,r);if(s!==ke.REPLACE){const l=[];for(const u of o){const{startIndex:c}=u;let h=[];for(const f of a){const{startIndex:g}=f;if(c===g){s===ke.COVER?h.push({...f,...u}):h.push({...u,...f});break}}l.push(...h),h=[]}t.customBlocks=l}return vl(e,t,n,r),i.length&&!e.customBlocks&&(e.customBlocks=i),a}function __(e,t,n,r,s){const{tables:i}=e,{tables:o}=t;if(i==null||o==null)return;const a=Dl(e,n,r);if(s!==ke.REPLACE){const l=[];for(const u of o){const{startIndex:c,endIndex:h}=u;let f=[];for(const g of a){const{startIndex:C,endIndex:I}=g;if(C>=c&&I<=h){s===ke.COVER?f.push({...g,...u}):f.push({...u,...g});break}}l.push(...f),f=[]}t.tables=l}return Ol(e,t,n,r),a}function p_(e,t,n,r,s){e.customRanges||(e.customRanges=[]),Qs(e.customRanges,r),Qs(e.customRanges,r+n);const i=r,o=r+n-1,{customRanges:a}=t,l=[],u=new Map;e.customRanges.forEach(h=>{const{startIndex:f,endIndex:g}=h;f>=i&&g<=o?u.set(h.rangeId,h):l.push(h)});const c=[];return a?(a.forEach(h=>{const{startIndex:f,endIndex:g}=h;l.push({...h,startIndex:f+r,endIndex:g+r})}),e.customRanges=Zs(l),c):[]}function E_(e,t,n,r,s){e.customDecorations||(e.customDecorations=[]),ei(e.customDecorations,r),ei(e.customDecorations,r+n);const i=[],{customDecorations:o}=e,{customDecorations:a=[]}=t;if(s===ke.REPLACE){for(let l=0;l<o.length;l++){const u=o[l],{startIndex:c,endIndex:h}=u;c>=r&&h<=r+n-1&&i.push(u)}a.forEach(l=>{const{startIndex:u,endIndex:c}=l;o.push({...l,startIndex:u+r,endIndex:c+r})})}else for(const l of a){const{id:u}=l;if(l.type===rn.DELETED){const c=o.filter(h=>h.id===u);c.length&&i.push(...c)}else o.push({...l,startIndex:l.startIndex+r,endIndex:l.endIndex+r})}for(const l of i){const{id:u}=l,c=o.findIndex(h=>h.id===u);c!==-1&&o.splice(c,1)}return e.customDecorations=yl(o),i}var ti=(e=>(e[e.copy=0]="copy",e[e.cut=1]="cut",e))(ti||{});function ts(e,t,n,r=!0){const{textRuns:s}=e;if(s){const i=[];for(const o of s){const a=re.deepClone(o),{st:l,ed:u}=a;re.hasIntersectionBetweenTwoRanges(l,u,t,n)&&(t>=l&&t<=u?i.push({...a,st:t,ed:Math.min(n,u)}):n>=l&&n<=u?i.push({...a,st:Math.max(t,l),ed:n}):i.push(a))}return er(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 Pl(e,t,n){const{tables:r=[]}=e,s=[];for(const i of r){const o=re.deepClone(i),{startIndex:a,endIndex:l}=o;a>=t&&l<=n&&s.push({...o,startIndex:a-t,endIndex:l-t})}return s}function Fl(e,t,n){const{paragraphs:r=[]}=e,s=[];for(const i of r){const{startIndex:o}=i;o>=t&&o<n&&s.push(re.deepClone(i))}if(s.length)return s.map(i=>({...i,startIndex:i.startIndex-t}))}function C_(e,t,n){const{sectionBreaks:r=[]}=e,s=[];for(const i of r){const{startIndex:o}=i;o>=t&&o<=n&&s.push(re.deepClone(i))}if(s.length)return s.map(i=>({...i,startIndex:i.startIndex-t}))}function xl(e,t,n){const{customBlocks:r=[]}=e,s=[];for(const i of r){const{startIndex:o}=i;o>=t&&o<=n&&s.push(re.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=ts(e,t,n,r);const a=Pl(e,t,n);if(a.length&&(o.tables=a),o.paragraphs=Fl(e,t,n),s===1){const u=Bl(e,t,n);u?o.customDecorations=u:r&&(o.customDecorations=[])}const{customRanges:l}=$l(e,t,n);return l?o.customRanges=l:r&&(o.customRanges=[]),o.customBlocks=xl(e,t,n),o}function R_(e){const{dataStream:t,textRuns:n,paragraphs:r,customRanges:s,customDecorations:i,tables:o}=e;let a=0,l=0;s==null||s.forEach(c=>{c.startIndex<0&&(a=Math.max(a,-c.startIndex)),c.endIndex>t.length-1&&(l=Math.max(l,c.endIndex-t.length+1))});const u=`${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(c=>{c.st+=a,c.ed+=a}),r==null||r.forEach(c=>{c.startIndex+=a}),s==null||s.forEach(c=>{c.startIndex+=a,c.endIndex+=a}),i==null||i.forEach(c=>{c.startIndex+=a,c.endIndex+=l}),o==null||o.forEach(c=>{c.startIndex+=a,c.endIndex+=l}),{...e,dataStream:u,textRuns:n,paragraphs:r,customRanges:s,customDecorations:i,tables:o}}function $l(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 Bl(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=re.deepClone(i);s.push({...o,startIndex:Math.max(o.startIndex-t,0),endIndex:Math.min(o.endIndex,n-1)-t})}}),s}function I_(e,t,n){return e==null||t==null?e!=null?e:t:kl(e,t,n)}function S_(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===ke.REPLACE?[{...e[0]}]:[{...t[0],...e[0]}]}function v_(e,t,n){return t.length===0||e.length===0||n===ke.REPLACE?e:[...e,...t.filter(r=>!e.some(s=>r.id===s.id))]}function ni(e,t,n=ke.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:u=[],customRanges:c,customDecorations:h=[]}=t;r.textRuns=I_(l,s,n),r.customRanges=S_(c,o,n);const f=v_(h,a,n);f.length&&(r.customDecorations=f);const g=[];let C=0,I=0;for(;C<i.length&&I<u.length;){const b=i[C],U=u[I],{startIndex:Z}=b,{startIndex:V}=U;Z===V?(g.push(re.deepMerge(b,U)),C++,I++):Z<V?(g.push(re.deepClone(b)),C++):(g.push(re.deepClone(U)),I++)}return C<i.length&&g.push(...i.slice(C)),I<u.length&&g.push(...u.slice(I)),g.length&&(r.paragraphs=g),r}function O_(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 On{constructor(t){R(this,"_index",0);R(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===he.DELETE||n.t===he.RETAIN&&n.body==null?re.deepClone({...n,len:t}):re.deepClone({...n,len:t,body:bt(n.body,r,r+t,!1)})}else return{t:he.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:he.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[]}}class wn{constructor(){R(this,"cursor",0)}reset(){return this.cursor=0,this}moveCursor(t){this.cursor+=t}moveCursorTo(t){this.cursor=t}}function Hl(e,t,n){const{dataStream:r}=e,s=n,i=n+t,o=Al(e,t,n),a=Tl(e,t,n),l=Nl(e,t,n),u=Ml(e,t,n),c=Dl(e,t,n),h=a_(e,t,n),f=l_(e,t,n);let g="";return r&&(e.dataStream=yo(r,s,i),g=r.slice(s,i)),{dataStream:g,textRuns:o,paragraphs:a,sectionBreaks:l,customBlocks:u,tables:c,customRanges:h,customDecorations:f}}function Wl(e,t,n,r){e.dataStream=bo(e.dataStream,r,t.dataStream),Rl(e,t,n,r),Il(e,t,n,r),Sl(e,t,n,r),vl(e,t,n,r),Ol(e,t,n,r),i_(e,t,n,r),o_(e,t,n,r)}function w_(e,t,n,r,s=ke.COVER){return h_(e,t,n,r,s)}function b_(e,t,n){return t<=0?{dataStream:""}:Hl(e,t,n)}function y_(e,t,n,r){n!==0&&Wl(e,t,n,r)}function A_(e,t){const n=new wn;return n.reset(),t.forEach(r=>{const s=re.deepClone(r);switch(s.t){case he.RETAIN:{const{coverType:i,body:o,len:a}=s;o!=null&&w_(e,o,a,n.cursor,i),n.moveCursor(a);break}case he.INSERT:{const{body:i,len:o}=s;y_(e,i,o,n.cursor),n.moveCursor(o);break}case he.DELETE:{const{len:i}=s;b_(e,i,n.cursor);break}default:throw new Error(`Unknown action type for action: ${s}.`)}}),e}function T_(e,t,n,r,s){if(e==null||t==null)return t;if(e.length===0||t.length===0)return[];t=re.deepClone(t),e=re.deepClone(e);const i=[],o=t.length,a=e.length;let l=0,u=0,c=null;function h(){return c?(i.push(c),c=null,!0):!1}for(;l<o&&u<a;){const{st:I,ed:b,ts:U}=t[l],{st:Z,ed:V,ts:fe,sId:M}=e[u];let T={};if(s===0)T={...U},n===ke.COVER&&r===ke.REPLACE&&fe&&(T=Object.assign({},fe,T));else if(T={...U},n===ke.REPLACE){if(r===ke.REPLACE)T={...fe};else if(U&&fe){const j=Object.keys(U);for(const Q of j)fe[Q]&&delete T[Q]}}else if(r===ke.REPLACE){if(fe){const j=Object.keys(fe);for(const Q of j)fe[Q]!==void 0&&(T[Q]=fe[Q])}}else if(fe){const j=Object.keys(fe);for(const Q of j)T[Q]!==void 0&&delete T[Q]}if(b<Z)h()||i.push(t[l]),l++;else if(V<I)h()||i.push(e[u]),u++;else{const j={st:Math.min(I,Z),ed:Math.max(I,Z),ts:I<Z?{...U}:{...fe}};j.ed>j.st&&i.push(),i.push({st:Math.max(I,Z),ed:Math.min(b,V),ts:T,sId:M}),b<V?(l++,e[u].st=b,e[u].st===e[u].ed&&u++):(u++,t[l].st=V,t[l].st===t[l].ed&&l++);const Q={st:Math.min(b,V),ed:Math.max(b,V),ts:b<V?{...fe}:{...U},sId:b<V?M:void 0};c=Q.ed>Q.st?Q:null}}h();const f=i[i.length-1],g=t[o-1],C=e[a-1];return f.ed!==Math.max(g.ed,C.ed)&&(g.ed>C.ed?i.push(g):i.push(C)),er(i,!0)}function N_(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===ke.REPLACE)return s===1?[re.deepClone(i)]:[re.deepClone(o)];if(r===ke.REPLACE){const a=re.deepClone(o);return s===1&&Object.assign(a,re.deepClone(i)),[a]}else{const a=re.deepClone(o);return s===1&&Object.assign(a,re.deepClone(i)),[a]}}function jl(e,t,n,r,s){const i={startIndex:t.startIndex};if(t.paragraphStyle&&(i.paragraphStyle=re.deepClone(t.paragraphStyle),e.paragraphStyle)){if(n===ke.REPLACE)if(r===ke.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===ke.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===ke.REPLACE&&r===ke.REPLACE?i.bullet=s===1?re.deepClone(e.bullet):re.deepClone(t.bullet):e.bullet===void 0?i.bullet=re.deepClone(t.bullet):n===ke.REPLACE||r===ke.REPLACE?i.bullet=s===0&&t.bullet?re.deepClone(t.bullet):re.deepClone(e.bullet):s===0&&t.bullet!==void 0&&(i.bullet=re.deepClone(t.bullet)),i}function M_(e,t){if(e==null||t==null)return t;if(e.length===0||t.length===0)return re.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===rn.DELETED||i===rn.DELETED)&&(o=!0,n.push({...r,type:rn.DELETED}));break}o||n.push(r)}return n}function D_(e,t,n=!1){const{body:r,coverType:s=ke.COVER}=e,{body:i,coverType:o=ke.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:u,paragraphs:c=[],customRanges:h,customDecorations:f}=r,{textRuns:g,paragraphs:C=[],customRanges:I,customDecorations:b}=i,U=T_(u,g,s,o,n?1:0);U&&(a.textRuns=U);const Z=N_(h,I,s,o,n?1:0);Z&&(a.customRanges=Z);const V=M_(f,b);V&&(a.customDecorations=V);const fe=[];let M=0,T=0;for(;M<c.length&&T<C.length;){const j=c[M],Q=C[T],{startIndex:ge}=j,{startIndex:le}=Q;if(ge===le){let p={startIndex:ge};n?p=jl(j,Q,s,o,1):p=jl(j,Q,s,o,0),fe.push(p),M++,T++}else ge<le?M++:(fe.push(re.deepClone(Q)),T++)}return T<C.length&&fe.push(...C.slice(T)),fe.length&&(a.paragraphs=fe),{coverType:l,body:a}}function Yl(e){return Object.keys(e).length===1}const Nn=class Nn{constructor(){R(this,"_actions",[])}static apply(t,n){return A_(t,n)}static compose(t,n){const r=new On(t),s=new On(n),i=new Nn;for(;r.hasNext()||s.hasNext();)if(s.peekType()===he.INSERT)i.push(s.next());else if(r.peekType()===he.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===he.INSERT&&l.t===he.RETAIN)l.body==null?i.push(a):i.push({...a,body:ni(a.body,l.body,l.coverType)});else if(a.t===he.RETAIN&&l.t===he.RETAIN)if(a.body==null&&l.body==null)i.push(a.len!==Number.POSITIVE_INFINITY?a:l);else if(a.body&&l.body){const u=a.coverType===ke.REPLACE||l.coverType===ke.REPLACE?ke.REPLACE:ke.COVER;i.push({...a,t:he.RETAIN,coverType:u,body:ni(a.body,l.body,l.coverType)})}else i.push(a.body?a:l);else a.t===he.RETAIN&&l.t===he.DELETE?i.push(l):a.t===he.INSERT&&(l.t,he.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 On(t),i=new On(n),o=new Nn;for(;s.hasNext()||i.hasNext();)if(s.peekType()===he.INSERT&&(r==="left"||i.peekType()!==he.INSERT)){const a=s.next();o.retain(a.len)}else if(i.peekType()===he.INSERT)o.push(i.next());else{const a=Math.min(s.peekLength(),i.peekLength()),l=s.next(a),u=i.next(a);if(l.t===he.DELETE)continue;if(u.t===he.DELETE){o.push(u);continue}if(l.body==null||u.body==null)o.push(u);else{const{coverType:c,body:h}=D_(l,u,r==="left");o.push({...u,t:he.RETAIN,coverType:c,body:h})}}return o.trimEndUselessRetainAction(),o.serialize()}static transformPosition(t,n,r=!1){const s=new On(t);let i=0;for(;s.hasNext()&&i<=n;){const o=s.peekLength(),a=s.peekType();if(s.next(),a===he.DELETE){n-=Math.min(o,n-i);continue}else a===he.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===he.INSERT)n.push({t:he.DELETE,len:r.len,body:r.body});else if(r.t===he.DELETE){if(r.body==null)throw new Error("Can not invert DELETE action without body property, makeInvertible must be called first.");n.push({t:he.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:he.RETAIN,body:r.oldBody,oldBody:r.body,len:r.len,coverType:ke.REPLACE})}else n.push(r);return n}static makeInvertible(t,n){const r=[];let s=0;for(const i of t){if(i.t===he.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===he.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!==he.INSERT&&(s+=i.len)}return r}insert(t,n){const r={t:he.INSERT,body:n,len:t};return this.push(r),this}retain(t,n,r){const s={t:he.RETAIN,len:t};return n!=null&&(s.body=n),r!=null&&(s.coverType=r),this.push(s),this}delete(t){const n={t:he.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=re.deepClone(t[0]);if(s.t===he.RETAIN&&s.len===0&&s.body==null)return this;if(typeof r=="object"){if(r.t===he.DELETE&&s.t===he.DELETE)return r.len+=s.len,this;if(r.t===he.DELETE&&s.t===he.INSERT&&(n-=1,r=this._actions[n-1],r==null))return this._actions.unshift(s),this;if(r.t===he.RETAIN&&s.t===he.RETAIN&&r.body==null&&s.body==null)return r.len+=s.len,this;if(r.t===he.INSERT&&Yl(r.body)&&s.t===he.INSERT&&Yl(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===he.RETAIN&&O_(t);)this._actions.pop(),t=this._actions[this._actions.length-1];return this}};R(Nn,"id","text-x"),R(Nn,"uri","https://github.com/dream-num/univer#text-x");let ze=Nn;Object.defineProperty(ze,"name",{value:"text-x"});const Mn=class Mn{static registerSubtype(t){var n;t==null||this._subTypes.has(t.name)&&((n=this._subTypes.get(t.name))==null?void 0:n.id)!==ze.id||(this._subTypes.set(t.name,t),gt.type.registerSubtype(t))}static apply(t,n){if(!gt.type.isNoop(n))return gt.type.apply(t,n)}static compose(t,n){return gt.type.compose(t,n)}static transform(t,n,r){return gt.type.transform(t,n,r)}static transformPosition(t,n,r="right"){return t&&t.length===2&&t[0]==="body"&&t[1].et===ze.name?ze.transformPosition(t[1].e,n,r==="left"):n}static invertWithDoc(t,n){return gt.type.invertWithDoc(t,n)}static isNoop(t){return gt.type.isNoop(t)}static getInstance(){return this._instance==null&&(this._instance=new Mn),this._instance}removeOp(t,n){return gt.removeOp(t,n)}moveOp(t,n){return gt.moveOp(t,n)}insertOp(t,n){return gt.insertOp(t,n)}replaceOp(t,n,r){return gt.replaceOp(t,n,r)}editOp(t,n=["body"]){return gt.editOp(n,ze.name,t)}};R(Mn,"uri","https://github.com/dream-num/univer#json-x"),R(Mn,"_subTypes",new Map),R(Mn,"_instance",null);let xt=Mn;xt.registerSubtype(ze);const ri={id:"default_doc",documentStyle:{}};class L_ extends Xr{constructor(n){var r;super();R(this,"type",Be.UNIVER_DOC);R(this,"_name$",new Ie.BehaviorSubject(""));R(this,"name$",this._name$.asObservable());R(this,"snapshot");this.snapshot={...ri,...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{...tr,...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}}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,u=s==null?void 0:s[n];if(!u)return;const c=u.docTransform;c.size.width=i,c.size.height=o,c.positionH.posOffset=a,c.positionV.posOffset=l}setZoomRatio(n=1){this.snapshot.settings==null?this.snapshot.settings={zoomRatio:n}:this.snapshot.settings.zoomRatio=1}}class yt extends L_{constructor(n){var s,i;super(re.isEmptyObject(n)?Jm():n);R(this,"_unitId");R(this,"headerModelMap",new Map);R(this,"footerModelMap",new Map);R(this,"change$",new Ie.BehaviorSubject(0));const r=6;this._unitId=(s=this.snapshot.id)!=null?s:re.generateRandomId(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={...ri,...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(!xt.isNoop(n))return this.snapshot=xt.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=ti.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 yt(i)),this.headerModelMap.get(s).updateDocumentId(this.getUnitId())}if(r)for(const s in r){const i=r[s];this.footerModelMap.set(s,new yt(i)),this.footerModelMap.get(s).updateDocumentId(this.getUnitId())}}updateDocumentId(n){super.updateDocumentId(n),this._unitId=n}getPlainText(){var n,r;return jr((r=(n=this.getBody())==null?void 0:n.dataStream)!=null?r:"")}}function U_(e){const{ranges:t,id:n,type:r}=e,s=new ze;let i=0;for(let o=0;o<t.length;o++){const a=t[o],{startOffset:l,endOffset:u}=a;l>0&&s.push({t:he.RETAIN,len:l-i}),s.push({t:he.RETAIN,body:{dataStream:"",customDecorations:[{id:n,type:r,startIndex:0,endIndex:u-l-1}]},len:u-l}),i=u}return s}function k_(e){var c,h,f;const{id:t,segmentId:n,documentDataModel:r}=e,s=r==null?void 0:r.getBody();if(!r||!s)return!1;const i=(f=(h=(c=r.getSelfOrHeaderFooterModel(n))==null?void 0:c.getBody())==null?void 0:h.customDecorations)==null?void 0:f.find(g=>g.id===t);if(!i)return!1;const o=new ze,{startIndex:a,endIndex:l}=i,u=l-a+1;return o.push({t:he.RETAIN,len:a}),o.push({t:he.RETAIN,len:u,body:{dataStream:"",customDecorations:[{startIndex:0,endIndex:u-1,id:t,type:rn.DELETED}]}}),o}function zl(e,t,n,r){return e<=n&&t>=n||e>=n&&e<=r}function P_(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):zl(e.startOffset,e.endOffset-1,i.startIndex,i.endIndex)&&n.push(i)}return n}function F_(e){return{...re.deepClone(e),rangeId:kt()}}function x_(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 Vl(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 $_(e,t){var i,o,a,l,u;const n=Vl(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,((u=(l=n[n.length-1])==null?void 0:l.endIndex)!=null?u:-1/0)+1);return{startOffset:r,endOffset:s,collapsed:r===s}}function B_(e){var h,f,g;const{rangeId:t,segmentId:n,documentDataModel:r,insert:s}=e,i=(f=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.customRanges)==null?void 0:f.find(C=>C.rangeId===t);if(!i)return!1;const{startIndex:o,endIndex:a}=i,l=new ze,u=a-o+1;l.push({t:he.RETAIN,len:o}),l.push({t:he.RETAIN,len:u,body:{dataStream:"",customRanges:[]}}),s&&l.push({t:he.INSERT,body:s,len:s.dataStream.length});const c=a+1+((g=s==null?void 0:s.dataStream.length)!=null?g:0);return l.selections=[{startOffset:c,endOffset:c,collapsed:!0}],l}function H_(e){const{ranges:t,rangeId:n,rangeType:r,wholeEntity:s,properties:i,body:o}=e;let a=0;const l=new ze;let u=!1;return t.forEach(c=>{var V,fe,M;const h=$_(c,o);if(!h||!o)return!1;const{startOffset:f,endOffset:g}=h,C=(V=o.customRanges)!=null?V:[],I=(T,j,Q)=>{var O,D,y,w;const ge=Vl(T,j,C,r),le=Math.min((D=(O=ge[0])==null?void 0:O.startIndex)!=null?D:1/0,T),p=Math.max((w=(y=ge[ge.length-1])==null?void 0:y.endIndex)!=null?w:-1/0,j),W={rangeId:Q?`${n}$${Q}`:n,rangeType:r,startIndex:0,endIndex:p-le,wholeEntity:s,properties:{...i}};l.push({t:he.RETAIN,len:le-a}),l.push({t:he.RETAIN,len:p-le+1,body:{dataStream:"",customRanges:[W]},coverType:ke.COVER}),a=p+1},b=((fe=o.paragraphs)!=null?fe:[]).filter(T=>T.startIndex<g&&T.startIndex>f),U=((M=o.customBlocks)!=null?M:[]).filter(T=>T.startIndex<g&&T.startIndex>f);x_([f,g-1],[...b.map(T=>T.startIndex),...U.map(T=>T.startIndex)]).forEach(([T,j],Q)=>I(T,j,Q)),u=!0,l.selections=[{startOffset:h.endOffset,endOffset:h.endOffset,collapsed:!0}]}),u?l:!1}function Gl(e,t,n=0,r=null,s=!0){e.sort((u,c)=>u.startOffset-c.startOffset);const i=[],{paragraphs:o=[]}=t,a=o==null?void 0:o.find(u=>u.startIndex>=e[0].startOffset&&u.startIndex<e[0].endOffset);let l=n;if(e.forEach(u=>{const{startOffset:c,endOffset:h}=u;c>l&&(i.push({t:he.RETAIN,len:c-l}),l=c),l<h&&(i.push({t:he.DELETE,len:h-l}),l=h)}),r&&i.push({t:he.INSERT,body:r,len:r.dataStream.length}),a&&s){const u=o.find(c=>c.startIndex-n>=e[e.length-1].endOffset-1);u&&(u.startIndex>l&&(i.push({t:he.RETAIN,len:u.startIndex-l}),l=u.startIndex),i.push({t:he.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...u,startIndex:0,bullet:a==null?void 0:a.bullet}]},coverType:ke.REPLACE}))}return i}function W_(e,t,n=0){const r=[];let s=n;return e.forEach(i=>{const{startOffset:o,endOffset:a}=i;o>s&&(r.push({t:he.RETAIN,len:o-s}),s=o),a>s&&(r.push({t:he.RETAIN,len:a-s,body:{...re.deepClone(t),dataStream:""}}),s=a)}),r}const j_=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=zs(o?o.dataStream:"",n.dataStream);let l=0;const u=a.map(([f,g])=>{switch(f){case 0:{const C={t:he.RETAIN,body:{...bt(n,l,l+g.length,!1),dataStream:""},len:g.length};return l+=g.length,C}case 1:{const C={t:he.INSERT,body:bt(n,l,l+g.length),len:g.length};return l+=g.length,C}default:return{t:he.DELETE,len:g.length}}}),c=new ze;return c.push({t:he.RETAIN,len:t.startOffset}),c.push(...u),c};function Y_(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 z_=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=zs(o?o.dataStream:"",n.dataStream);let l=0;const u=a.map(([f,g])=>{switch(f){case 0:{const C=ts(n,l,l+g.length,!1),I=ts(o,l,l+g.length,!1),b={t:he.RETAIN,body:Y_(C,I)?void 0:{textRuns:C,dataStream:""},len:g.length};return l+=g.length,b}case 1:{const C={t:he.INSERT,body:bt(n,l,l+g.length),len:g.length};return l+=g.length,C}default:return{t:he.DELETE,len:g.length}}});if(u.every(f=>f.t===he.RETAIN&&!f.body))return!1;const c=new ze;return c.push({t:he.RETAIN,len:t.startOffset}),c.push(...u),c};function V_(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 G_(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 K_=e=>{var I,b,U,Z;const{selection:t,documentDataModel:n,drawings:r}=e,{collapsed:s,startOffset:i,segmentId:o}=t,a=new ze,l=xt.getInstance(),u=[],c=n.getSelfOrHeaderFooterModel(o).getBody();if(!c)return!1;const h=(b=(I=n.getSnapshot().drawingsOrder)==null?void 0:I.length)!=null?b:0;let f=0;if(s)i>0&&a.push({t:he.RETAIN,len:i});else{const V=Gl([t],c,0,null,!1);a.push(...V);const fe=V_(c,[t]),M=(U=n.getDrawings())!=null?U:{},T=(Z=n.getDrawingsOrder())!=null?Z:[],j=fe.sort((Q,ge)=>T.indexOf(Q)>T.indexOf(ge)?-1:T.indexOf(Q)<T.indexOf(ge)?1:0);if(j.length>0)for(const Q of j){const ge=M[Q],le=T.indexOf(Q);if(ge==null||le<0)continue;const p=l.removeOp(["drawings",Q],ge),W=l.removeOp(["drawingsOrder",le],Q);u.push(p),u.push(W),f++}}a.push({t:he.INSERT,body:{dataStream:"\b".repeat(r.length),customBlocks:r.map((V,fe)=>({startIndex:fe,blockId:V.drawingId}))},len:r.length});const g=G_(n,o),C=l.editOp(a.serialize(),g);u.push(C);for(const V of r){const{drawingId:fe}=V,M=l.insertOp(["drawings",fe],V),T=l.insertOp(["drawingsOrder",h-f],fe);u.push(M),u.push(T)}return u.reduce((V,fe)=>xt.compose(V,fe),null)},X_=e=>{var h,f,g;const{paragraphs:t,segmentId:n,document:r}=e;let s=e.listType;const i=(f=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.paragraphs)!=null?f:[],o=t.every(C=>{var I;return((I=C.bullet)==null?void 0:I.listType.indexOf(s))===0});let l=re.generateRandomId(6);if(t.length===1){const C=i.indexOf(t[0]),I=i[C-1],b=i[C+1];I&&I.bullet&&I.bullet.listType.indexOf(s)===0?(l=I.bullet.listId,s!==Mt.CHECK_LIST&&(s=I.bullet.listType)):b&&b.bullet&&b.bullet.listType.indexOf(s)===0&&(l=b.bullet.listId,s!==Mt.CHECK_LIST&&(s=b.bullet.listType))}const u=new wn;u.reset();const c=new ze;for(const C of t){const{startIndex:I,paragraphStyle:b={},bullet:U}=C;c.push({t:he.RETAIN,len:I-u.cursor}),c.push({t:he.RETAIN,len:1,body:{dataStream:"",paragraphs:[o?{paragraphStyle:b,startIndex:0}:{startIndex:0,paragraphStyle:{...b},bullet:{nestingLevel:(g=U==null?void 0:U.nestingLevel)!=null?g:0,textStyle:{fs:20},listType:s,listId:l}}]},coverType:ke.REPLACE}),u.moveCursorTo(I+1)}return c},q_=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(f=>f.startIndex===t);if(!(i!=null&&i.bullet)||i.bullet.listType.indexOf(Mt.CHECK_LIST)===-1)return!1;const o=new wn;o.reset();const a=new ze,{startIndex:l,paragraphStyle:u={}}=i,c=i.bullet.listType===Mt.CHECK_LIST?Mt.CHECK_LIST_CHECKED:Mt.CHECK_LIST;return a.push({t:he.RETAIN,len:l-o.cursor}),a.push({t:he.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...i,paragraphStyle:u,startIndex:0,bullet:{...i.bullet,listType:c}}]},coverType:ke.REPLACE}),o.moveCursorTo(l+1),a},J_=e=>{var c,h;const{paragraphs:t,listType:n,segmentId:r,document:s}=e;if(((c=s.getSelfOrHeaderFooterModel(r).getBody())==null?void 0:c.paragraphs)==null)return!1;const a=re.generateRandomId(6),l=new wn;l.reset();const u=new ze;for(const f of t){const{startIndex:g,paragraphStyle:C={},bullet:I}=f;u.push({t:he.RETAIN,len:g-l.cursor}),u.push({t:he.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:C,bullet:{nestingLevel:(h=I==null?void 0:I.nestingLevel)!=null?h:0,textStyle:(I==null?void 0:I.listType)===n?I.textStyle:{fs:20},listType:n,listId:a}}]},coverType:ke.REPLACE}),l.moveCursorTo(g+1)}return u};function Z_(e,t){return t.some(n=>e.startIndex>n.startIndex&&e.startIndex<n.endIndex)}const Q_=e=>{var c,h,f;const{paragraphs:t,segmentId:n,document:r,type:s}=e,i=new wn;i.reset();const o=new ze,a=(c=r.getSnapshot().lists)!=null?c:{},l=(f=(h=r.getBody())==null?void 0:h.tables)!=null?f:[],u={...tr,...a};for(const g of t){const{startIndex:C,paragraphStyle:I={},bullet:b}=g,U=Z_(g,l);if(o.push({t:he.RETAIN,len:C-i.cursor}),b){const Z=b.listType;let V=u[Z].nestingLevel.length-1;U&&(V=Math.min(V,2)),o.push({t:he.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:{...I},bullet:{...b,nestingLevel:Math.max(Math.min(b.nestingLevel+s,V),0)}}]},coverType:ke.REPLACE})}else o.push({t:he.RETAIN,len:1});i.moveCursorTo(C+1)}return o};function ep(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 tp(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 np(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}class ot{}R(ot,"customRange",{add:H_,delete:B_,copyCustomRange:F_,getCustomRangesInterestsWithSelection:P_,isIntersecting:zl}),R(ot,"customDecoration",{add:U_,delete:k_}),R(ot,"selection",{replace:j_,makeSelection:ep,normalizeSelection:tp,delete:Gl,replaceTextRuns:z_,retain:W_}),R(ot,"range",{isIntersects:np}),R(ot,"transform",{getPlainText:jr,fromPlainText:Vd,isEmptyDocument:zd}),R(ot,"paragraph",{bullet:{set:J_,switch:X_,toggleChecklist:q_,changeNestLevel:Q_}}),R(ot,"drawing",{add:K_});function rp(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 Kl(e){var t;return e.body=rp((t=e.body)!=null?t:{dataStream:""}),e.drawingsOrder||(e.drawingsOrder=[]),e.drawings||(e.drawings={}),e.documentStyle||(e.documentStyle={}),e}class nr{constructor(t={}){R(this,"_style");this._style=t}static create(t={}){return new nr(t)}get fontFamily(){return this._style.ff}get fontSize(){return this._style.fs}get italic(){return this._style.it===ve.TRUE}get bold(){return this._style.bl===ve.TRUE}get underline(){return this._style.ul&&Xt.create(this._style.ul)}get bottomBorderLine(){return this._style.bbl&&Xt.create(this._style.bbl)}get strikethrough(){return this._style.st&&Xt.create(this._style.st)}get overline(){return this._style.ol&&Xt.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 Kt.create(re.deepClone(this._style))}getValue(){return{...this._style}}}class Kt extends nr{static create(t={}){return new Kt(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 Kt.create(re.deepClone(this._style))}build(){return this.getValue()}}class Xt{constructor(t={s:1}){R(this,"_decoration");this._decoration=t}static create(t={s:1}){return new Xt(t)}get show(){return this._decoration.s===ve.TRUE}get followFontColor(){return this._decoration.c===ve.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 Xt.create(re.deepClone(this._decoration))}build(){return{...this._decoration}}}class rr{constructor(t={}){R(this,"_style");this._style=t}static create(t={}){return new rr(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===ve.TRUE}get keepNext(){return this._style.keepNext===ve.TRUE}get wordWrap(){return this._style.wordWrap===ve.TRUE}get widowControl(){return this._style.widowControl===ve.TRUE}get shading(){return this._style.shading}get suppressHyphenation(){return this._style.suppressHyphenation===ve.TRUE}copy(){return sr.create(re.deepClone(this._style))}getValue(){return this._style}}class sr extends rr{static create(t={}){return new sr(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 sr.create(re.deepClone(this._style))}build(){return this.getValue()}}class qt{constructor(t){R(this,"_data");if(!t.body)throw new Error("Invalid document data, body is required");this._data=Kl(t)}static create(t){return new qt(t)}static createByBody(t){return new qt({body:t,id:"d",documentStyle:{}})}copy(){return un.create(re.deepClone(this._data))}slice(t,n){const{body:r,...s}=this._data;return un.create({...re.deepClone(s),body:bt(r,t,n)})}toPlainText(){var t,n;return ot.transform.getPlainText((n=(t=this._data.body)==null?void 0:t.dataStream)!=null?n:"").replaceAll("\r",`
8
+ `,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:As.TRADITIONAL,marginTop:50,marginBottom:50,marginRight:50,marginLeft:50,renderConfig:{zeroWidthParagraphBreak:ve.FALSE,vertexAngle:0,centerAngle:0,background:{rgb:"#ccc"}},autoHyphenation:ve.TRUE,doNotHyphenateCaps:ve.FALSE,consecutiveHyphenLimit:2,defaultHeaderId:"",defaultFooterId:"",evenPageHeaderId:"",evenPageFooterId:"",firstPageHeaderId:"",firstPageFooterId:"",evenAndOddHeaders:ve.FALSE,useFirstPageHeaderFooter:ve.FALSE,marginHeader:30,marginFooter:30},settings:{}}}var an={},Qn={},qr={},ll;function Zm(){if(ll)return qr;ll=1,Object.defineProperty(qr,"__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 qr.default=n,qr}var Jr={},ul;function Qm(){if(ul)return Jr;ul=1,Object.defineProperty(Jr,"__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 Jr.default=e,Jr}var Gs={},cl;function hl(){return cl||(cl=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(c,h){if(!c)throw new Error(h)}const n=c=>c!=null&&typeof c=="object"&&!Array.isArray(c),r=(c,h)=>typeof c==typeof h?c>h:typeof c=="string"&&typeof h=="number";function s(c,h){for(let f in c){const g=f;h.write(g,c[g])}}e.isValidPathItem=c=>typeof c=="number"||typeof c=="string"&&c!=="__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 f=this.container,g=this.parents.length-1,C=this.idx;for(;C>=0;)h.unshift(f[C]),C===0?(C=this.indexes[g*2],f=this.parents[g--]):C-=n(f[C-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 f=this.container[h];return Array.isArray(f)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(h),this.idx=0,this.container=f):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,f=this.parents[this.parents.length-1];return h>=f.length?!1:(t(!isNaN(h)),this.indexes[this.indexes.length-1]=h,this.container=f[h],!0)}_init(h,f,g,C){this.container=h,this.idx=f,this.parents=g.slice(),this.indexes=C.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,f){const g=this.getComponent();g&&f(g,h);for(const C of this)h&&h.descend(C),this.traverse(h,f),h&&h.ascend()}eachPick(h,f){this.traverse(h,(g,C)=>{g.p!=null&&f(g.p,C)})}eachDrop(h,f){this.traverse(h,(g,C)=>{g.d!=null&&f(g.d,C)})}}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 f=this.pendingDescent[h];let g=this.idx+1;if(g<this.container.length&&n(this.container[g])&&g++,t(g===this.container.length||!n(this.container[g])),g===this.container.length)this.container.push(f),this.idx=g;else if(this.container[g]===f)this.idx=g;else{if(!Array.isArray(this.container[g])){const C=this.container.splice(g,this.container.length-g);this.container.push(C),this.lcIdx>-1&&(this.lcIdx=g)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(t(r(f,this.container[this.lcIdx][0])),g=this.lcIdx+1,this.lcIdx=-1);g<this.container.length&&r(f,this.container[g][0]);)g++;if(this.indexes.push(g),this.idx=0,g<this.container.length&&this.container[g][0]===f)this.container=this.container[g];else{const C=[f];this.container.splice(g,0,C),this.container=C}}}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 f={};return this.container.splice(h,0,f),f}}write(h,f){const g=this.getComponent();t(g[h]==null||g[h]===f,"Internal consistency error: Overwritten component. File a bug"),g[h]=f}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,f=s){if(h===null)return;if(t(Array.isArray(h)),h===this._op)throw Error("Cannot merge into my own tree");const g=this.lcIdx,C=this.parents.length;let I=0;for(let b=0;b<h.length;b++){const U=h[b];typeof U=="string"||typeof U=="number"?(I++,this.descend(U)):Array.isArray(U)?this.mergeTree(U,f):typeof U=="object"&&f(U,this)}for(;I--;)this.ascend();this.lcIdx=this.parents.length===C?g:-1}at(h,f){this.descendPath(h),f(this);for(let g=0;g<h.length;g++)this.ascend();return this}writeAtPath(h,f,g){return this.at(h,()=>this.write(f,g)),this.reset(),this}writeMove(h,f,g=0){return this.writeAtPath(h,"p",g).writeAtPath(f,"d",g)}getPath(){const h=super.getPath();return h.push(...this.pendingDescent),h}}e.WriteCursor=a,e.writeCursor=()=>new a,e.readCursor=c=>new o(c);function l(c,h,f){let g,C;C=g=c?c.descendFirst():!1;function I(b){let U;for(;C;){const Z=U=c.getKey();if(b!=null){let V=!1;if(h&&typeof Z=="number"&&(U=h(Z,c.getComponent()),U<0&&(U=~U,V=!0)),r(U,b))return null;if(U===b&&!V)return c}f&&typeof U=="number"&&f(U,c.getComponent()),C=c.nextSibling()}return null}return I.end=()=>{g&&c.ascend()},I}e.advancer=l;function u(c,h,f){let g,C,I,b;for(g=C=c&&c.descendFirst(),I=b=h&&h.descendFirst();g||I;){let U=g?c.getKey():null,Z=I?h.getKey():null;U!==null&&Z!==null&&(r(Z,U)?Z=null:U!==Z&&(U=null)),f(U==null?Z:U,U!=null?c:null,Z!=null?h:null),U!=null&&g&&(g=c.nextSibling()),Z!=null&&I&&(I=h.nextSibling())}C&&c.ascend(),b&&h.ascend()}e.eachChildOf=u}(Gs)),Gs}var Ks={},dl;function fl(){return dl||(dl=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={}))}(Ks)),Ks}var wt={},ln={},gl;function Xs(){return gl||(gl=1,Object.defineProperty(ln,"__esModule",{value:!0}),ln.uniToStrPos=ln.strPosToUni=void 0,ln.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},ln.uniToStrPos=(e,t)=>{let n=0;for(;t>0;t--){const r=e.charCodeAt(n);n+=r>=55296&&r<=57343?2:1}return n}),ln}var qs={},ml;function Js(){return ml||(ml=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.uniSlice=e.dlen=e.eachOp=void 0;const t=Xs(),n=M=>{if(!Array.isArray(M))throw Error("Op must be an array of components");let T=null;for(let j=0;j<M.length;j++){const Q=M[j];switch(typeof Q){case"object":if(typeof Q.d!="number"&&typeof Q.d!="string")throw Error("Delete must be number or string");if(e.dlen(Q.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(Q.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(Q>0))throw Error("Skip components must be >0");if(typeof T=="number")throw Error("Adjacent skip components should be combined");break}T=Q}if(typeof T=="number")throw Error("Op has a trailing skip")};function r(M,T){let j=0,Q=0;for(let ge=0;ge<M.length;ge++){const le=M[ge];switch(T(le,j,Q),typeof le){case"object":j+=e.dlen(le.d);break;case"string":Q+=t.strPosToUni(le);break;case"number":j+=le,Q+=le;break}}}e.eachOp=r;function s(M,T){const j=[],Q=a(j);return r(M,(ge,le,p)=>{Q(T(ge,le,p))}),h(j)}const i=M=>M,o=M=>s(M,i);e.dlen=M=>typeof M=="number"?M:t.strPosToUni(M);const a=M=>T=>{if(!(!T||T.d===0||T.d===""))if(M.length===0)M.push(T);else if(typeof T==typeof M[M.length-1])if(typeof T=="object"){const j=M[M.length-1];j.d=typeof j.d=="string"&&typeof T.d=="string"?j.d+T.d:e.dlen(j.d)+e.dlen(T.d)}else M[M.length-1]+=T;else M.push(T)},l=M=>typeof M=="number"?M:typeof M=="string"?t.strPosToUni(M):typeof M.d=="number"?M.d:t.strPosToUni(M.d);e.uniSlice=(M,T,j)=>{const Q=t.uniToStrPos(M,T),ge=j==null?1/0:t.uniToStrPos(M,j);return M.slice(Q,ge)};const u=(M,T,j)=>typeof M=="number"?j==null?M-T:Math.min(M,j)-T:e.uniSlice(M,T,j),c=M=>{let T=0,j=0;return{take:(le,p)=>{if(T===M.length)return le===-1?null:le;const W=M[T];let O;if(typeof W=="number")return le===-1||W-j<=le?(O=W-j,++T,j=0,O):(j+=le,le);if(typeof W=="string"){if(le===-1||p==="i"||t.strPosToUni(W.slice(j))<=le)return O=W.slice(j),++T,j=0,O;{const D=j+t.uniToStrPos(W.slice(j),le);return O=W.slice(j,D),j=D,O}}else{if(le===-1||p==="d"||e.dlen(W.d)-j<=le)return O={d:u(W.d,j)},++T,j=0,O;{let D=u(W.d,j,j+le);return j+=le,{d:D}}}},peek:()=>M[T]}},h=M=>(M.length>0&&typeof M[M.length-1]=="number"&&M.pop(),M);function f(M,T,j){if(j!=="left"&&j!=="right")throw Error("side ("+j+") must be 'left' or 'right'");n(M),n(T);const Q=[],ge=a(Q),{take:le,peek:p}=c(M);for(let O=0;O<T.length;O++){const D=T[O];let y,w;switch(typeof D){case"number":for(y=D;y>0;)w=le(y,"i"),ge(w),typeof w!="string"&&(y-=l(w));break;case"string":j==="left"&&typeof p()=="string"&&ge(le(-1)),ge(t.strPosToUni(D));break;case"object":for(y=e.dlen(D.d);y>0;)switch(w=le(y,"i"),typeof w){case"number":y-=w;break;case"string":ge(w);break;case"object":y-=e.dlen(w.d)}break}}let W;for(;W=le(-1);)ge(W);return h(Q)}function g(M,T){n(M),n(T);const j=[],Q=a(j),{take:ge}=c(M);for(let p=0;p<T.length;p++){const W=T[p];let O,D;switch(typeof W){case"number":for(O=W;O>0;)D=ge(O,"d"),Q(D),typeof D!="object"&&(O-=l(D));break;case"string":Q(W);break;case"object":O=e.dlen(W.d);let y=0;for(;y<O;)switch(D=ge(O-y,"d"),typeof D){case"number":Q({d:u(W.d,y,y+D)}),y+=D;break;case"string":y+=t.strPosToUni(D);break;case"object":Q(D)}break}}let le;for(;le=ge(-1);)Q(le);return h(j)}const C=(M,T)=>{let j=0;for(let Q=0;Q<T.length&&M>j;Q++){const ge=T[Q];switch(typeof ge){case"number":{j+=ge;break}case"string":const le=t.strPosToUni(ge);j+=le,M+=le;break;case"object":M-=Math.min(e.dlen(ge.d),M-j);break}}return M},I=(M,T)=>typeof M=="number"?C(M,T):M.map(j=>C(j,T));function b(M,T,j){return s(M,(Q,ge)=>typeof Q=="object"&&typeof Q.d=="number"?{d:j.slice(T,ge,ge+Q.d)}:Q)}function U(M){return s(M,T=>{switch(typeof T){case"object":if(typeof T.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return T.d;case"string":return{d:T};case"number":return T}})}function Z(M){return s(M,T=>typeof T=="object"&&typeof T.d=="string"?{d:t.strPosToUni(T.d)}:T)}function V(M){let T=!0;return r(M,j=>{typeof j=="object"&&typeof j.d=="number"&&(T=!1)}),T}function fe(M){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:h,normalize:o,checkOp:n,create(T=""){if(typeof T!="string")throw Error("Initial data must be a string");return M.create(T)},apply(T,j){n(j);const Q=M.builder(T);for(let ge=0;ge<j.length;ge++){const le=j[ge];switch(typeof le){case"number":Q.skip(le);break;case"string":Q.append(le);break;case"object":Q.del(e.dlen(le.d));break}}return Q.build()},transform:f,compose:g,transformPosition:C,transformSelection:I,isInvertible:V,makeInvertible(T,j){return b(T,j,M)},stripInvertible:Z,invert:U,invertWithDoc(T,j){return U(b(T,j,M))},isNoop:T=>T.length===0}}e.default=fe}(qs)),qs}var Zr={},_l;function e_(){if(_l)return Zr;_l=1,Object.defineProperty(Zr,"__esModule",{value:!0});const e=Js(),t=Xs();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 u=e.dlen(o.d);this.onRemove&&this.onRemove(l,u)}})},onInsert:null,onRemove:null}}return Zr.default=n,n.provides={text:!0},Zr}var pl;function t_(){return pl||(pl=1,function(e){var t=wt&&wt.__createBinding||(Object.create?function(f,g,C,I){I===void 0&&(I=C),Object.defineProperty(f,I,{enumerable:!0,get:function(){return g[C]}})}:function(f,g,C,I){I===void 0&&(I=C),f[I]=g[C]}),n=wt&&wt.__setModuleDefault||(Object.create?function(f,g){Object.defineProperty(f,"default",{enumerable:!0,value:g})}:function(f,g){f.default=g}),r=wt&&wt.__importStar||function(f){if(f&&f.__esModule)return f;var g={};if(f!=null)for(var C in f)Object.hasOwnProperty.call(f,C)&&t(g,f,C);return n(g,f),g},s=wt&&wt.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(e,"__esModule",{value:!0}),e.type=e.remove=e.insert=void 0;const i=Xs(),o=r(Js()),a=s(e_()),l={create(f){return f},toString(f){return f},builder(f){if(typeof f!="string")throw Error("Invalid document snapshot: "+f);const g=[];return{skip(C){let I=i.uniToStrPos(f,C);if(I>f.length)throw Error("The op is too long for this document");g.push(f.slice(0,I)),f=f.slice(I)},append(C){g.push(C)},del(C){f=f.slice(i.uniToStrPos(f,C))},build(){return g.join("")+f}}},slice:o.uniSlice},u=o.default(l),c=Object.assign(Object.assign({},u),{api:a.default});e.type=c,e.insert=(f,g)=>g.length===0?[]:f===0?[g]:[f,g],e.remove=(f,g)=>o.dlen(g)===0?[]:f===0?[{d:g}]:[f,{d:g}];var h=Js();Object.defineProperty(e,"makeType",{enumerable:!0,get:function(){return h.default}})}(wt)),wt}var El;function n_(){return El||(El=1,function(e){var t=Qn&&Qn.__importDefault||function(v){return v&&v.__esModule?v:{default:v}};Object.defineProperty(e,"__esModule",{value:!0}),e.editOp=e.replaceOp=e.insertOp=e.moveOp=e.removeOp=e.type=void 0;const n=t(Zm()),r=t(Qm()),s=hl(),i=fl();function o(v,$){if(!v)throw new Error($)}e.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:s.readCursor,writeCursor:s.writeCursor,create:v=>v,isNoop:v=>v==null,setDebug(v){},registerSubtype:U,checkValidOp:ge,normalize:le,apply:p,transformPosition:W,compose:O,tryTransform:G,transform:de,makeInvertible:w,invert:D,invertWithDoc:x,RM_UNEXPECTED_CONTENT:i.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:i.ConflictType.DROP_COLLISION,BLACKHOLE:i.ConflictType.BLACKHOLE,transformNoConflict:(v,$,K)=>Ae(()=>!0,v,$,K),typeAllowingConflictsPred:v=>Object.assign(Object.assign({},e.type),{transform:($,K,q)=>Ae(v,$,K,q)})};const a=v=>v?v.getComponent():null;function l(v){return v&&typeof v=="object"&&!Array.isArray(v)}const u=v=>Array.isArray(v)?v.slice():v!==null&&typeof v=="object"?Object.assign({},v):v,c=v=>v&&(v.p!=null||v.r!==void 0),h=v=>v&&(v.d!=null||v.i!==void 0);function f(v,$){return o(v!=null),typeof $=="number"?(o(Array.isArray(v),"Invalid key - child is not an array"),(v=v.slice()).splice($,1)):(o(l(v),"Invalid key - child is not an object"),delete(v=Object.assign({},v))[$]),v}function g(v,$,K){return typeof $=="number"?(o(v!=null,"Container is missing for key"),o(Array.isArray(v),"Cannot use numerical key for object container"),o(v.length>=$,"Cannot insert into out of bounds index"),v.splice($,0,K)):(o(l(v),"Cannot insert into missing item"),o(v[$]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),v[$]=K),K}e.removeOp=(v,$=!0)=>s.writeCursor().writeAtPath(v,"r",$).get(),e.moveOp=(v,$)=>s.writeCursor().writeMove(v,$).get(),e.insertOp=(v,$)=>s.writeCursor().writeAtPath(v,"i",$).get(),e.replaceOp=(v,$,K)=>s.writeCursor().at(v,q=>{q.write("r",$),q.write("i",K)}).get(),e.editOp=(v,$,K,q=!1)=>s.writeCursor().at(v,z=>T(z,$,K,q)).get();const C=(v,$)=>v!=null&&(typeof $=="number"?Array.isArray(v):typeof v=="object"),I=(v,$)=>C(v,$)?v[$]:void 0,b={};function U(v){let $=v.type?v.type:v;$.name&&(b[$.name]=$),$.uri&&(b[$.uri]=$)}const Z=v=>{const $=b[v];if($)return $;throw Error("Missing type: "+v)};U(t_());const V=(v,$)=>v+$;U({name:"number",apply:V,compose:V,invert:v=>-v,transform:v=>v});const fe=v=>v==null?null:v.et?Z(v.et):v.es?b["text-unicode"]:v.ena!=null?b.number:null,M=v=>v.es?v.es:v.ena!=null?v.ena:v.e,T=(v,$,K,q=!1)=>{const[z,Y]=typeof $=="string"?[Z($),$]:[$,$.name];!q&&z.isNoop&&z.isNoop(K)||(Y==="number"?v.write("ena",K):Y==="text-unicode"?v.write("es",K):(v.write("et",Y),v.write("e",K)))};function j(v){o(typeof v=="number"),o(v>=0),o(v===(0|v))}function Q(v){typeof v=="number"?j(v):o(typeof v=="string")}function ge(v){if(v===null)return;const $=new Set,K=new Set,q=Y=>{let ue=!0,ae=!1;for(let H in Y){const ne=Y[H];if(ue=!1,o(H==="p"||H==="r"||H==="d"||H==="i"||H==="e"||H==="es"||H==="ena"||H==="et","Invalid component item '"+H+"'"),H==="p")j(ne),o(!$.has(ne)),$.add(ne),o(Y.r===void 0);else if(H==="d")j(ne),o(!K.has(ne)),K.add(ne),o(Y.i===void 0);else if(H==="e"||H==="es"||H==="ena"){o(!ae),ae=!0;const oe=fe(Y);o(oe,"Missing type in edit"),oe.checkValidOp&&oe.checkValidOp(M(Y))}}o(!ue)},z=(Y,ue,ae)=>{if(!Array.isArray(Y))throw Error("Op must be null or a list");if(Y.length===0)throw Error("Empty descent");ue||Q(Y[0]);let H=1,ne=0,oe=0;for(let _e=0;_e<Y.length;_e++){const ye=Y[_e];if(o(ye!=null),Array.isArray(ye)){const Ue=z(ye,!1);if(ne){const X=typeof oe,Se=typeof Ue;X===Se?o(oe<Ue,"descent keys are not in order"):o(X==="number"&&Se==="string")}oe=Ue,ne++,H=3}else typeof ye=="object"?(o(H===1,`Prev not scalar - instead ${H}`),q(ye),H=2):(o(H!==3),Q(ye),o(s.isValidPathItem(ye),"Invalid path key"),H=1)}return o(ne!==1,"Operation makes multiple descents. Remove some []"),o(H===2||H===3),Y[0]};z(v,!0),o($.size===K.size,"Mismatched picks and drops in op");for(let Y=0;Y<$.size;Y++)o($.has(Y)),o(K.has(Y))}function le(v){let $=0,K=[];const q=s.writeCursor();return q.mergeTree(v,(z,Y)=>{const ue=fe(z);if(ue){const H=M(z);T(Y,ue,ue.normalize?ue.normalize(H):H)}for(const H of["r","p","i","d"])if(z[H]!==void 0){const ne=H==="p"||H==="d"?(ae=z[H],K[ae]==null&&(K[ae]=$++),K[ae]):z[H];Y.write(H,ne)}var ae}),q.get()}function p(v,$){if(ge($),$===null)return v;const K=[];return function q(z,Y){let ue=z,ae=0,H={root:z},ne=0,oe=H,_e="root";function ye(){for(;ne<ae;ne++){let Ue=Y[ne];typeof Ue!="object"&&(o(C(oe,_e)),oe=oe[_e]=u(oe[_e]),_e=Ue)}}for(;ae<Y.length;ae++){const Ue=Y[ae];if(Array.isArray(Ue)){const X=q(ue,Ue);X!==ue&&X!==void 0&&(ye(),ue=oe[_e]=X)}else if(typeof Ue=="object"){Ue.d!=null?(ye(),ue=g(oe,_e,K[Ue.d])):Ue.i!==void 0&&(ye(),ue=g(oe,_e,Ue.i));const X=fe(Ue);if(X)ye(),ue=oe[_e]=X.apply(ue,M(Ue));else if(Ue.e!==void 0)throw Error("Subtype "+Ue.et+" undefined")}else ue=I(ue,Ue)}return H.root}(v=function q(z,Y){const ue=[];let ae=0;for(;ae<Y.length;ae++){const _e=Y[ae];if(Array.isArray(_e))break;typeof _e!="object"&&(ue.push(z),z=I(z,_e))}for(let _e=Y.length-1;_e>=ae;_e--)z=q(z,Y[_e]);for(--ae;ae>=0;ae--){const _e=Y[ae];if(typeof _e!="object"){const ye=ue.pop();z=z===I(ye,_e)?ye:z===void 0?f(ye,_e):(ne=_e,oe=z,(H=u(H=ye))[ne]=oe,H)}else c(_e)&&(o(z!==void 0,"Cannot pick up or remove undefined"),_e.p!=null&&(K[_e.p]=z),z=void 0)}var H,ne,oe;return z}(v,$),$)}function W(v,$){v=v.slice(),ge($);const K=s.readCursor($);let q,z,Y=!1;const ue=[];for(let H=0;;H++){const ne=v[H],oe=K.getComponent();if(oe&&(oe.r!==void 0?Y=!0:oe.p!=null&&(Y=!1,q=oe.p,z=H)),H>=v.length)break;let _e=0;const ye=s.advancer(K,void 0,(X,Se)=>{c(Se)&&_e++});ue.unshift(ye);const Ue=ye(ne);if(typeof ne=="number"&&(v[H]-=_e),!Ue)break}if(ue.forEach(H=>H.end()),Y)return null;const ae=()=>{let H=0;if(q!=null){const ne=K.getPath();H=ne.length,v=ne.concat(v.slice(z))}for(;H<v.length;H++){const ne=v[H],oe=a(K),_e=fe(oe);if(_e){const X=M(oe);_e.transformPosition&&(v[H]=_e.transformPosition(v[H],X));break}let ye=0;const Ue=s.advancer(K,(X,Se)=>h(Se)?~(X-ye):X-ye,(X,Se)=>{h(Se)&&ye++})(ne);if(typeof ne=="number"&&(v[H]+=ye),!Ue)break}};return q!=null?K.eachDrop(null,H=>{H===q&&ae()}):ae(),v}function O(v,$){if(ge(v),ge($),v==null)return $;if($==null)return v;let K=0;const q=s.readCursor(v),z=s.readCursor($),Y=s.writeCursor(),ue=[],ae=[],H=[],ne=[],oe=[],_e=[],ye=new Set;q.traverse(null,X=>{X.p!=null&&(H[X.p]=q.clone())}),z.traverse(null,X=>{X.d!=null&&(ne[X.d]=z.clone())});const Ue=s.writeCursor();return function X(Se,Ge,je,Pe,Ze,Rt,Ke,rt){o(Ge||je);const Xe=a(Ge),ht=a(je),at=!!ht&&ht.r!==void 0,Bt=!!Xe&&Xe.i!==void 0,$e=Xe?Xe.d:null,dt=ht?ht.p:null,E=(Rt||at)&&dt==null;if(dt!=null)Pe=ne[dt],Ke=ae[dt]=new s.WriteCursor;else if(ht&&ht.r!==void 0)Pe=null;else{const L=a(Pe);L&&L.d!=null&&(Pe=null)}const m=a(Pe);if($e!=null)if(Se=H[$e],rt=ue[$e]=new s.WriteCursor,E)Rt&&!at&&rt.write("r",!0);else{const L=oe[$e]=K++;Ke.write("d",L)}else if(Xe&&Xe.i!==void 0)Se=null;else{const L=a(Se);L&&L.p!=null&&(Se=null)}let _;Bt?(o(Ze===void 0),_=Xe.i):_=Ze;const A=(dt==null?!Bt||Rt||at:_===void 0)?null:Ke.getComponent();if(dt!=null){if(!(Ze!==void 0||Bt)){const L=$e!=null?oe[$e]:K++;_e[dt]=L,rt.write("p",L)}}else at&&(Bt||Ze!==void 0||(ht.r,rt.write("r",ht.r)));const N=E?null:fe(Xe),P=fe(m);if((N||P)&&(N&&N.name,P&&P.name),N&&P){o(N===P);const L=M(Xe),te=M(m),Re=N.compose(L,te);T(Ke,N,Re),ye.add(m)}else N?T(Ke,N,M(Xe)):P&&(T(Ke,P,M(m)),ye.add(m));const k=typeof _=="object"&&_!=null;let F=!1,S=0,ee=0,Ee=0,J=0,pe=0;const be=s.advancer(Pe,(L,te)=>h(te)?J-L-1:L-J,(L,te)=>{h(te)&&J++}),ce=s.advancer(Se,(L,te)=>c(te)?S-L-1:L-S,(L,te)=>{c(te)&&S++});if(s.eachChildOf(Ge,je,(L,te,Re)=>{let Te,Fe,xe=L,Ye=L,ft=L;if(typeof L=="number"){let De=L+Ee;Fe=be(De),Ye=De+J;let se=L+ee;Te=ce(se),h(a(Fe))&&(Te=null),xe=se+S,ft=L+pe,o(xe>=0,"p1PickKey is negative"),o(Ye>=0,"p2DropKey is negative");const ut=h(a(te)),He=c(a(Re));(ut||He&&!E)&&pe--,ut&&ee--,He&&Ee--}else Te=ce(L),Fe=be(L);rt.descend(xe),Ke.descend(Ye);const mt=k&&!h(a(te))?_[ft]:void 0,Ce=X(Te,te,Re,Fe,mt,E,Ke,rt);var et,we,Oe;k&&!E?mt!==Ce&&(F||(_=Array.isArray(_)?_.slice():Object.assign({},_),F=!0),et=_,Oe=Ce,typeof(we=ft)=="number"?(o(Array.isArray(et)),o(we<et.length)):(o(!Array.isArray(et)),o(et[we]!==void 0)),Oe===void 0?typeof we=="number"?et.splice(we,1):delete et[we]:et[we]=Oe):o(Ce===void 0),Ke.ascend(),rt.ascend()}),ce.end(),be.end(),A!=null)A.i=_;else if(!Rt&&!at&&dt==null)return _}(q,q.clone(),z,z.clone(),void 0,!1,Y,Ue),Y.reset(),Y.mergeTree(Ue.get()),Y.reset(),Y.get(),ue.map(X=>X.get()),ae.map(X=>X.get()),q.traverse(Y,(X,Se)=>{const Ge=X.p;if(Ge!=null){const je=oe[Ge];je!=null&&Se.write("p",je);const Pe=ue[Ge];Pe&&Pe.get(),Pe&&Se.mergeTree(Pe.get())}else X.r!==void 0&&Se.write("r",X.r)}),Y.reset(),Y.get(),z.traverse(Y,(X,Se)=>{const Ge=X.d;if(Ge!=null){const Pe=_e[Ge];Pe!=null&&Se.write("d",Pe);const Ze=ae[Ge];Ze&&Se.mergeTree(Ze.get())}else X.i!==void 0&&Se.write("i",X.i);const je=fe(X);je&&!ye.has(X)&&T(Se,je,M(X))}),Y.get()}function D(v){if(v==null)return null;const $=new s.ReadCursor(v),K=new s.WriteCursor;let q;const z=[],Y=[];return function ue(ae,H,ne){const oe=ae.getComponent();let _e,ye=!1;if(oe){oe.p!=null&&(H.write("d",oe.p),z[oe.p]=ae.clone()),oe.r!==void 0&&H.write("i",oe.r),oe.d!=null&&(H.write("p",oe.d),ne=void 0),oe.i!==void 0&&(ne=_e=oe.i);const X=fe(oe);X&&(ne===void 0?(q||(q=new Set),q.add(oe)):(M(oe),ne=X.apply(ne,M(oe)),ye=!0))}let Ue=0;for(const X of ae){H.descend(X);const Se=typeof X=="number"?X-Ue:X,Ge=I(ne,Se);h(ae.getComponent())&&Ue++;const je=ue(ae,H,Ge);if(ne!==void 0&&je!==void 0){if(ye||(ye=!0,ne=u(ne)),!C(ne,Se))throw Error("Cannot modify child - invalid operation");ne[Se]=je}H.ascend()}if(_e===void 0)return ye?ne:void 0;H.write("r",ne)}($,K,void 0),q&&(K.reset(),function ue(ae,H,ne){const oe=H.getComponent();if(oe){const X=oe.d;if(X!=null&&(ae=z[X],ne=Y[X]=s.writeCursor()),q.has(oe)){const Se=fe(oe);if(!Se.invert)throw Error(`Cannot invert subtype ${Se.name}`);T(ne,Se,Se.invert(M(oe)))}}let _e=0,ye=0;const Ue=s.advancer(ae,(X,Se)=>c(Se)?_e-X-1:X-_e,(X,Se)=>{c(Se)&&_e++});for(const X of H)if(typeof X=="number"){const Se=X-ye,Ge=Ue(Se),je=Se+_e;ne.descend(je),ue(Ge,H,ne),h(H.getComponent())&&ye++,ne.ascend()}else ne.descend(X),ue(Ue(X),H,ne),ne.ascend();Ue.end()}($.clone(),$,K),Y.length&&(K.reset(),$.traverse(K,(ue,ae)=>{const H=ue.p;if(H!=null){const ne=Y[H];ne&&ne.get(),ne&&ae.mergeTree(ne.get())}}))),K.get()}const y=(v,$)=>v.some(K=>typeof K=="object"&&(Array.isArray(K)?y(K,$):$(K)));function w(v,$){if(v==null||!y(v,H=>{var ne;return H.r!==void 0||((ne=fe(H))===null||ne===void 0?void 0:ne.makeInvertible)!=null}))return v;const K=new s.ReadCursor(v),q=new s.WriteCursor;let z=!1;const Y=[],ue=[],ae=(H,ne,oe)=>{const _e=H.getComponent();let ye=!1;if(_e){_e.d!=null&&ne.write("d",_e.d),_e.i!==void 0&&ne.write("i",_e.i);const X=_e.p;if(X!=null&&(Y[X]=H.clone(),o(oe!==void 0,"Operation picks up at an invalid key"),ue[X]=oe,ne.write("p",_e.p)),_e.r!==void 0&&oe===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const Se=fe(_e);Se&&(Se.makeInvertible?z=!0:T(ne,Se,M(_e),!0))}let Ue=0;for(const X of H){ne.descend(X);const Se=typeof X=="number"?X-Ue:X,Ge=I(oe,Se),je=ae(H,ne,Ge);Ge!==je&&(ye||(ye=!0,oe=u(oe)),je===void 0?(oe=f(oe,Se),typeof X=="number"&&Ue++):oe[Se]=je),ne.ascend()}return _e&&(_e.r!==void 0?(ne.write("r",r.default(oe)),oe=void 0):_e.p!=null&&(oe=void 0)),oe};return ae(K,q,$),q.get(),z&&(q.reset(),function H(ne,oe,_e,ye,Ue){const X=oe.getComponent();if(X){X.i!==void 0?(ye=X.i,Ue=!0):X.d!=null&&(ye=ue[X.d],ne=Y[X.d],Ue=!1,X.d);let Pe=fe(X);if(Pe&&Pe.makeInvertible){const Ze=M(X);T(_e,Pe,Pe.makeInvertible(Ze,ye),!0)}}let Se=0,Ge=0;const je=s.advancer(ne,(Pe,Ze)=>c(Ze)?Se-Pe-1:Pe-Se,(Pe,Ze)=>{c(Ze)&&Se++});for(const Pe of oe)if(typeof Pe=="number"){const Ze=Pe-Ge,Rt=je(Ze),Ke=Ze+Se,rt=I(ye,Ue?Ze:Ke);_e.descend(Pe),H(Rt,oe,_e,rt,Ue),h(oe.getComponent())&&Ge++,_e.ascend()}else{const Ze=I(ye,Pe);_e.descend(Pe),H(je(Pe),oe,_e,Ze,Ue),_e.ascend()}je.end()}(K.clone(),K,q,$,!1)),q.get()}function x(v,$){return D(w(v,$))}const B=v=>{if(v==null)return null;const $=v.slice();for(let K=0;K<v.length;K++){const q=$[K];Array.isArray(q)&&($[K]=B(q))}return $};function G(v,$,K){o(K==="left"||K==="right","Direction must be left or right");const q=K==="left"?0:1;if($==null)return{ok:!0,result:v};ge(v),ge($);let z=null;const Y=[],ue=[],ae=[],H=[],ne=[],oe=[],_e=[],ye=[],Ue=[],X=[],Se=[],Ge=[],je=[],Pe=[],Ze=[];let Rt=0;const Ke=s.readCursor(v),rt=s.readCursor($),Xe=s.writeCursor();if(function m(_,A=null,N){const P=a(A);P&&(P.r!==void 0?N=A.clone():P.p!=null&&(N=null,oe[P.p]=_.clone()));const k=_.getComponent();let F;k&&(F=k.p)!=null&&(ne[F]=A?A.clone():null,ae[F]=_.clone(),N&&(X[F]=!0,Ue[F]=N),P&&P.p!=null&&(Pe[F]=P.p));const S=s.advancer(A);for(const ee of _)m(_,S(ee),N);S.end()}(rt,Ke,null),function m(_,A,N,P,k){const F=N.getComponent();let S,ee=!1;F&&((S=F.d)!=null?(H[S]=N.clone(),P!=null&&(Ze[P]==null&&(Ze[P]=[]),Ze[P].push(S)),X[S],_=ne[S]||null,A=ae[S]||null,X[S]?(k&&(Se[S]=!0),k=Ue[S]||null):!k||q!==1&&Pe[S]!=null||z==null&&(z={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(k.getPath()),op2:e.moveOp(A.getPath(),N.getPath())}),ee=!0):F.i!==void 0&&(_=A=null,ee=!0,k&&z==null&&(z={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(k.getPath()),op2:e.insertOp(N.getPath(),F.i)})));const Ee=a(_);Ee&&(Ee.r!==void 0?k=_.clone():Ee.p!=null&&(Ee.p,P=Ee.p,k=null));const J=fe(F);J&&k&&z==null&&(z={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(k.getPath()),op2:e.editOp(N.getPath(),J,M(F),!0)});let pe=0,be=0;const ce=s.advancer(A,(te,Re)=>c(Re)?pe-te-1:te-pe,(te,Re)=>{c(Re)&&pe++}),L=s.advancer(_);for(const te of N)if(typeof te=="number"){const Re=te-be,Te=ce(Re);be+=+m(L(Re+pe),Te,N,P,k)}else{const Re=ce(te);m(L(te),Re,N,P,k)}return ce.end(),L.end(),ee}(Ke,rt,rt.clone(),null,null),H.map(m=>m&&m.get()),z)return{ok:!1,conflict:z};Se.map(m=>!!m);const ht=[];let at=null;(function m(_,A,N,P,k){let F=!1;const S=a(A);if(c(S)){const ce=S.p;ce!=null?(N=H[ce],P=Ge[ce]=s.writeCursor(),F=!0,k=null):(N=null,k=A.clone())}else h(a(N))&&(N=null);const ee=_.getComponent();if(ee){const ce=ee.p;ce!=null?(k&&(ye[ce]=k),ht[ce]=k||q===1&&F?null:P.getComponent(),Y[ce]=_.clone(),N&&(_e[ce]=N.clone())):ee.r!==void 0&&(k||P.write("r",!0),(k||F)&&(at==null&&(at=new Set),at.add(ee)))}let Ee=0,J=0;const pe=s.advancer(A,void 0,(ce,L)=>{c(L)&&Ee++}),be=s.advancer(N,(ce,L)=>h(L)?~(ce-J):ce-J,(ce,L)=>{h(L)&&J++});if(_)for(const ce of _)if(typeof ce=="string"){const L=pe(ce),te=be(ce);P.descend(ce),m(_,L,te,P,k),P.ascend()}else{const L=pe(ce),te=ce-Ee,Re=c(a(L))?null:be(te),Te=te+J;o(Te>=0),P.descend(Te),m(_,L,Re,P,k),P.ascend()}pe.end(),be.end()})(Ke,rt,rt.clone(),Xe,null),Xe.reset();let Bt=[];if(function m(_,A,N,P,k,F){o(A);const S=A.getComponent();let ee=a(P),Ee=!1;const J=(we,Oe,De)=>we?e.moveOp(we.getPath(),Oe.getPath()):e.insertOp(Oe.getPath(),De.i);if(h(S)){const we=S.d;we!=null&&(ue[we]=A.clone());const Oe=we!=null?ht[we]:null;let De=!1;if(S.i!==void 0||we!=null&&Oe){let se;ee&&(ee.i!==void 0||(se=ee.d)!=null&&!X[se])&&(De=se!=null?we!=null&&we===Pe[se]:n.default(ee.i,S.i),De||se!=null&&q!==1&&Pe[se]!=null||z==null&&(z={type:i.ConflictType.DROP_COLLISION,op1:J(we!=null?Y[we]:null,A,S),op2:J(se!=null?ae[se]:null,P,ee)})),De||(F?z==null&&(z={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:J(we!=null?Y[we]:null,A,S),op2:e.removeOp(F.getPath())}):(we!=null?(Bt[Rt]=we,k.write("d",Oe.p=Rt++)):k.write("i",r.default(S.i)),Ee=!0))}else if(we!=null&&!Oe){const se=ye[we];se&&(F=se.clone())}we!=null?(_=Y[we],N=oe[we],P=_e[we]):S.i!==void 0&&(_=N=null,De||(P=null))}else c(a(_))&&(_=N=P=null);const pe=a(_),be=a(N);if(c(be)){const we=be.p;be.r!==void 0&&(!pe||pe.r===void 0)||X[we]?(P=null,F=N.clone()):we!=null&&(P=H[we],q!==1&&Pe[we]!=null||((k=je[we])||(k=je[we]=s.writeCursor()),k.reset(),F=null))}else!h(S)&&h(ee)&&(P=null);ee=P!=null?P.getComponent():null;const ce=fe(S);if(ce){const we=M(S);if(F)z==null&&(z={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.editOp(A.getPath(),ce,we,!0),op2:e.removeOp(F.getPath())});else{const Oe=fe(ee);let De;if(Oe){if(ce!==Oe)throw Error("Transforming incompatible types");const se=M(ee);De=ce.transform(we,se,K)}else De=r.default(we);T(k,ce,De)}}let L=0,te=0,Re=0,Te=0,Fe=0,xe=0,Ye=_!=null&&_.descendFirst(),ft=Ye;const mt=s.advancer(N,void 0,(we,Oe)=>{c(Oe)&&Re++});let Ce=P!=null&&P.descendFirst(),et=Ce;for(const we of A)if(typeof we=="number"){let Oe;const De=h(A.getComponent()),se=we-te;{let Zt;for(;Ye&&typeof(Zt=_.getKey())=="number";){Zt+=L;const At=_.getComponent(),Dn=c(At);if(Zt>se||Zt===se&&(!Dn||q===0&&De))break;if(Dn){L--;const hn=At.p;Pe.includes(hn),At.d,a(je[At.d]),c(a(je[At.d])),(At.r===void 0||at&&at.has(At))&&(hn==null||!ht[hn]||q!==1&&Pe.includes(hn))||Fe--}Ye=_.nextSibling()}Oe=Ye&&Zt===se?_:null}const ut=se-L;let He=mt(ut);const Dt=ut-Re;let os=null;{let Zt,At;for(;Ce&&typeof(Zt=P.getKey())=="number";){At=Zt-Te;const Dn=P.getComponent(),hn=h(Dn);if(At>Dt)break;if(At===Dt){if(!hn){os=P;break}{if(q===0&&De){os=P;break}const Qt=He&&c(He.getComponent());if(q===0&&Qt)break}}if(hn){const Qt=Dn.d;X[Qt],Pe[Qt],Dn.i===void 0&&(X[Qt]||Pe[Qt]!=null&&q!==1)?(X[Qt]||Pe[Qt]!=null&&q===0)&&(Te++,xe--):Te++}Ce=P.nextSibling()}}const qu=Dt+Te+Fe+xe;o(qu>=0,"trying to descend to a negative index"),k.descend(qu),De&&(Oe=He=os=null,te++),m(Oe,A,He,os,k,F)&&xe++,k.ascend()}else{let Oe;for(;Ye&&(Oe=_.getKey(),typeof Oe!="string"||!(Oe>we||Oe===we));)Ye=_.nextSibling();const De=Ye&&Oe===we?_:null,se=mt(we);let ut;for(;Ce&&(ut=P.getKey(),typeof ut!="string"||!(ut>we||ut===we));)Ce=P.nextSibling();const He=Ce&&ut===we?P:null;k.descend(we),m(De,A,se,He,k,F),k.ascend()}return mt.end(),ft&&_.ascend(),et&&P.ascend(),Ee}(Ke,Ke.clone(),rt,rt.clone(),Xe,null),z)return{ok:!1,conflict:z};Xe.reset();const $e=(m,_,A)=>m.traverse(_,(N,P)=>{N.d!=null&&A(N.d,m,P)});(X.length||Ge.length)&&($e(rt,Xe,(m,_,A)=>{X[m]&&!Se[m]&&A.write("r",!0),Ge[m]&&A.mergeTree(Ge[m].get())}),Xe.reset());const dt=[],E=[];if((je.length||X.length)&&!z){const m=s.readCursor(B(Xe.get()));if($e(m,null,(_,A)=>{dt[_]=A.clone()}),je.forEach(_=>{_&&$e(s.readCursor(_.get()),null,(A,N)=>{dt[A]=N.clone()})}),function _(A,N,P,k,F,S){const ee=a(N);if(ee&&c(ee))if(ee.p!=null){const L=ee.p;dt[L].getPath(),P=dt[L],k=E[L]=s.writeCursor()}else ee.r!==void 0&&(P=null);else h(a(P))&&(P=null);const Ee=A.getComponent();if(Ee){let L;if((L=Ee.d)!=null){const te=je[L];te&&(te.get(),k.mergeTree(te.get()),P=s.readCursor(te.get()))}}let J=0,pe=0;const be=s.advancer(N,void 0,(L,te)=>{c(te)&&J--}),ce=s.advancer(P,(L,te)=>h(te)?-(L-pe)-1:L-pe,(L,te)=>{h(te)&&pe++});for(const L of A)if(typeof L=="number"){const te=be(L),Re=L+J,Te=ce(Re),Fe=Re+pe;k.descend(Fe),_(A,te,Te,k),k.ascend()}else k.descend(L),_(A,be(L),ce(L),k),k.ascend();be.end(),ce.end()}(rt,m,m.clone(),Xe),Xe.reset(),z)return{ok:!1,conflict:z};if(Xe.get(),E.length){const _=E.map(N=>N?N.get():null),A=s.readCursor(B(Xe.get()));if($e(A,Xe,(N,P,k)=>{const F=_[N];F&&(k.mergeTree(F),_[N]=null)}),_.find(N=>N)){const N=s.writeCursor(),P=s.writeCursor();let k=0,F=0;_.forEach(S=>{S!=null&&$e(s.readCursor(S),null,ee=>{const Ee=Bt[ee];N.writeMove(Y[Ee].getPath(),ue[Ee].getPath(),k++);const J=Ze[Ee];J&&J.forEach(pe=>{X[pe]||q!==1&&Pe[pe]!=null||P.writeMove(ae[pe].getPath(),H[pe].getPath(),F++)})})}),z={type:i.ConflictType.BLACKHOLE,op1:N.get(),op2:P.get()}}}}return z?{ok:!1,conflict:z}:{ok:!0,result:Xe.get()}}const ie=v=>{const $=new Error("Transform detected write conflict");throw $.conflict=v,$.type=$.name="writeConflict",$};function de(v,$,K){const q=G(v,$,K);if(q.ok)return q.result;ie(q.conflict)}const me=v=>{const $=s.writeCursor();return s.readCursor(v).traverse($,(K,q)=>{(h(K)||fe(K))&&q.write("r",!0)}),$.get()},Me=(v,$)=>{const{type:K,op1:q,op2:z}=v;switch(K){case i.ConflictType.DROP_COLLISION:return $==="left"?[null,me(z)]:[me(q),null];case i.ConflictType.RM_UNEXPECTED_CONTENT:let Y=!1;return s.readCursor(q).traverse(null,ue=>{ue.r!==void 0&&(Y=!0)}),Y?[null,me(z)]:[me(q),null];case i.ConflictType.BLACKHOLE:return[me(q),me(z)];default:throw Error("Unrecognised conflict: "+K)}};function Ae(v,$,K,q){let z=null;for(;;){const Y=G($,K,q);if(Y.ok)return O(z,Y.result);{const{conflict:ue}=Y;v(ue)||ie(ue);const[ae,H]=Me(ue,q);$=O(le($),ae),K=O(le(K),H),z=O(z,H)}}}}(Qn)),Qn}var Cl;function r_(){return Cl||(Cl=1,function(e){var t=an&&an.__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=an&&an.__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(n_(),e);var r=hl();Object.defineProperty(e,"ReadCursor",{enumerable:!0,get:function(){return r.ReadCursor}}),Object.defineProperty(e,"WriteCursor",{enumerable:!0,get:function(){return r.WriteCursor}});var s=fl();Object.defineProperty(e,"ConflictType",{enumerable:!0,get:function(){return s.ConflictType}})}(an)),an}var gt=r_();const s_=Ju({__proto__:null,default:pt(gt)},[gt]);var he=(e=>(e.RETAIN="r",e.INSERT="i",e.DELETE="d",e))(he||{});function er(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&&re.isEmptyObject(o)&&r.sId==null)continue;if(n.length===0){n.push(r);continue}const a=n.pop();mo(r,a)&&re.hasIntersectionBetweenTwoRanges(a.st,a.ed,r.st,r.ed)?n.push({...r,st:a.st,ed:i}):n.push(a,r)}return n}function Rl(e,t,n,r){var u;const{textRuns:s}=e;if(s==null)return;const i=[],o=s.length;let a=!1;const l=(u=t.textRuns)!=null?u:[];if(l.length)for(const c of l)c.st+=r,c.ed+=r;for(let c=0;c<o;c++){const h=s[c],{st:f,ed:g}=h;if(g<=r)i.push(h);else if(r>f&&r<g){a=!0;const C={...h,ed:r};i.push(C),l.length&&i.push(...l);const I={...h,st:r+n,ed:g+n};i.push(I)}else h.st+=n,h.ed+=n,a||(a=!0,i.push(...l)),i.push(h)}a||(a=!0,i.push(...l)),e.textRuns=er(i)}function Il(e,t,n,r){const{paragraphs:s}=e;if(s==null)return;const{paragraphs:i}=t,o=[];for(let l=0,u=s.length;l<u;l++){const c=s[l],{startIndex:h}=c;h>=r&&(c.startIndex+=n),o.push(c.startIndex)}let a=-1;if(i){for(let l=0,u=i.length;l<u;l++){const c=i[l];c.startIndex+=r;const h=c.startIndex;a=o.indexOf(h)}a!==-1&&s.splice(a,1),s.push(...i),s.sort(Gn("startIndex"))}}function Sl(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:u}=l;u>=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(Gn("startIndex"))}}function vl(e,t,n,r){const{customBlocks:s=[]}=e;for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:u}=l;u>=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(Gn("startIndex"))}s.length&&!e.customBlocks&&(e.customBlocks=s)}function Ol(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:u,endIndex:c}=l;u>r?(l.startIndex+=n,l.endIndex+=n):c>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(Gn("startIndex"))}}const wl="$",bl=e=>e.split(wl)[0];function Zs(e){if(e.length<=1)return e;e.sort((s,i)=>s.startIndex-i.startIndex);const t=[];let n={...e[0]};n.rangeId=bl(n.rangeId);for(let s=1;s<e.length;s++){const i=e[s];i.rangeId=bl(i.rangeId),i.rangeId===n.rangeId&&al(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}${wl}${r[a]}`,r[a]=r[a]+1):r[a]=1}return t}function Qs(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 yl(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 ei(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 i_(e,t,n,r){e.customRanges||(e.customRanges=[]);const{customRanges:s}=e;Qs(s,r);for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:u}=l;u>=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=Zs(s)}function o_(e,t,n,r){e.customDecorations||(e.customDecorations=[]);const{customDecorations:s}=e;ei(s,r);for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:u}=l;u>=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=yl(s)}function Al(e,t,n){const{textRuns:r}=e,s=n,i=n+t,o=[];if(r){const a=[];for(let l=0,u=r.length;l<u;l++){const c=r[l],{st:h,ed:f}=c;if(s<=h&&i>=f){o.push({...c,st:h-s,ed:f-s});continue}else h<=s&&f>=i?(o.push({...c,st:s-s,ed:i-s}),c.ed-=t):s>=h&&s<f?(o.push({...c,st:s-s,ed:f-s}),c.ed=s):i>h&&i<=f?(o.push({...c,st:h-s,ed:i-s}),c.st=i-t,c.ed-=t):h>=i&&(c.st-=t,c.ed-=t);a.push(c)}e.textRuns=a}return o.length===0&&o.push({st:0,ed:t,ts:{}}),o}function Tl(e,t,n){const{paragraphs:r}=e,s=n,i=n+t,o=[];if(r){const a=[];for(let l=0,u=r.length;l<u;l++){const c=r[l],{startIndex:h}=c;if(h>=s&&h<i){o.push({...c,startIndex:h-n});continue}else h>=i&&(c.startIndex-=t);a.push(c)}e.paragraphs=a}return o}function Nl(e,t,n){const{sectionBreaks:r}=e,s=n,i=n+t-1,o=[];if(r){const a=[];for(let l=0,u=r.length;l<u;l++){const c=r[l],{startIndex:h}=c;if(h>=s&&h<=i){o.push({...c,startIndex:h-n});continue}else h>i&&(c.startIndex-=t);a.push(c)}e.sectionBreaks=a}return o}function Ml(e,t,n){const{customBlocks:r=[]}=e,s=n,i=n+t-1,o=[];if(r){const a=[];for(let l=0,u=r.length;l<u;l++){const c=r[l],{startIndex:h}=c;if(h>=s&&h<=i){o.push({...c,startIndex:h-n});continue}else h>i&&(c.startIndex-=t);a.push(c)}e.customBlocks=a}return r.length&&!e.customBlocks&&(e.customBlocks=r),o}function Dl(e,t,n){const{tables:r}=e,s=n,i=n+t-1,o=[];if(r){const a=[];for(let l=0,u=r.length;l<u;l++){const c=r[l],{startIndex:h,endIndex:f}=c;if(s<=h&&i>=f){o.push({...c,startIndex:h-n,endIndex:f-n});continue}else if(h<=s&&f>=i){const g=Pr(h,f,s,i);if(g.length===0||(c.startIndex=g[0],c.endIndex=g[1],c.startIndex===c.endIndex))continue}else i<h&&(c.startIndex-=t,c.endIndex-=t);a.push(c)}e.tables=a}return o}function a_(e,t,n){const{customRanges:r}=e,s=n,i=n+t-1,o=[];if(r){const a=[];for(let l=0,u=r.length;l<u;l++){const c=r[l],{startIndex:h,endIndex:f}=c;if(h>=s&&f<=i){o.push(c);continue}else if(Math.max(s,h)<=Math.min(i,f)){const g=Pr(h,f,s,i);if(g.length===0)continue;c.startIndex=g[0],c.endIndex=g[1]}else i<h&&(c.startIndex-=t,c.endIndex-=t);a.push(c)}e.customRanges=Zs(a)}return o}function l_(e,t,n,r=!0){const{customDecorations:s}=e,i=n,o=n+t-1,a=[];if(s){const l=[];for(let u=0,c=s.length;u<c;u++){const h=s[u],{startIndex:f,endIndex:g}=h;if(f>=i&&g<=o){a.push(h);continue}else if(Math.max(i,f)<=Math.min(o,g)){const C=Pr(f,g,i,o);if(C.length===0)continue;h.startIndex=C[0],h.endIndex=C[1]}else o<f&&r&&(h.startIndex-=t,h.endIndex-=t);l.push(h)}e.customDecorations=l}return a}var Ll=(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))(Ll||{}),Mt=(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))(Mt||{});const Qr={"a)":{glyphFormat:"%1)",glyphType:Ne.DECIMAL},"1.":{glyphType:Ne.DECIMAL},"a.":{glyphFormat:"%1.",glyphType:Ne.LOWER_LETTER},"A.":{glyphType:Ne.UPPER_LETTER},"i.":{glyphFormat:"%1.",glyphType:Ne.LOWER_ROMAN},"I.":{glyphFormat:"%1.",glyphType:Ne.UPPER_LETTER}},Sn=e=>[...e,...e,...e].map((t,n)=>({glyphFormat:` %${n+1}`,glyphSymbol:t,bulletAlignment:Kn.START,textStyle:{fs:12},startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*n}}})),vn=e=>e.map((t,n)=>({...t,bulletAlignment:Kn.START,textStyle:{fs:12},startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*n}}})),Ul=(e,t)=>new Array(9).fill(0).map((n,r)=>({glyphFormat:` %${r+1}`,glyphSymbol:e,bulletAlignment:Kn.START,textStyle:{fs:16},startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*r},textStyle:t}})),tr={BULLET_LIST:{listType:"BULLET_LIST",nestingLevel:Sn(["●","○","■"])},BULLET_LIST_1:{listType:"BULLET_LIST",nestingLevel:Sn(["❖","➢","■"])},BULLET_LIST_2:{listType:"BULLET_LIST",nestingLevel:Sn(["✔","●","◆"])},BULLET_LIST_3:{listType:"BULLET_LIST",nestingLevel:Sn(["■","◆","○"])},BULLET_LIST_4:{listType:"BULLET_LIST",nestingLevel:Sn(["✧","○","■"])},BULLET_LIST_5:{listType:"BULLET_LIST",nestingLevel:Sn(["➢","○","◆"])},ORDER_LIST:{listType:"ORDER_LIST",nestingLevel:vn([{glyphFormat:"%1.",glyphType:Ne.DECIMAL},{glyphFormat:"%2.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%3.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%4.",glyphType:Ne.DECIMAL},{glyphFormat:"%5.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%6.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%7.",glyphType:Ne.DECIMAL},{glyphFormat:"%8.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%9.",glyphType:Ne.LOWER_ROMAN}])},ORDER_LIST_1:{listType:"ORDER_LIST",nestingLevel:vn([{glyphFormat:"%1)",glyphType:Ne.DECIMAL},{glyphFormat:"%2)",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%3)",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%4)",glyphType:Ne.DECIMAL},{glyphFormat:"%5)",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%6)",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%7)",glyphType:Ne.DECIMAL},{glyphFormat:"%8)",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%9)",glyphType:Ne.LOWER_ROMAN}])},ORDER_LIST_2:{listType:"ORDER_LIST",nestingLevel:vn(["%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:Ne.DECIMAL})))},ORDER_LIST_3:{listType:"ORDER_LIST",nestingLevel:vn([{glyphFormat:"%1.",glyphType:Ne.UPPER_LETTER},{glyphFormat:"%2.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%3.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%4.",glyphType:Ne.UPPER_LETTER},{glyphFormat:"%5.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%6.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%7.",glyphType:Ne.UPPER_LETTER},{glyphFormat:"%8.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%9.",glyphType:Ne.LOWER_ROMAN}])},ORDER_LIST_4:{listType:"ORDER_LIST",nestingLevel:vn([{glyphFormat:"%1.",glyphType:Ne.UPPER_LETTER},{glyphFormat:"%2.",glyphType:Ne.DECIMAL},{glyphFormat:"%3.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%4.",glyphType:Ne.UPPER_LETTER},{glyphFormat:"%5.",glyphType:Ne.DECIMAL},{glyphFormat:"%6.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%7.",glyphType:Ne.UPPER_LETTER},{glyphFormat:"%8.",glyphType:Ne.DECIMAL},{glyphFormat:"%9.",glyphType:Ne.LOWER_ROMAN}])},ORDER_LIST_5:{listType:"ORDER_LIST",nestingLevel:vn([{glyphFormat:"%1.",glyphType:Ne.DECIMAL_ZERO},{glyphFormat:"%2.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%3.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%4.",glyphType:Ne.DECIMAL_ZERO},{glyphFormat:"%5.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%6.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%7.",glyphType:Ne.DECIMAL_ZERO},{glyphFormat:"%8.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%9.",glyphType:Ne.LOWER_ROMAN}])},CHECK_LIST:{listType:"CHECK_LIST",nestingLevel:Ul("☐")},CHECK_LIST_CHECKED:{listType:"CHECK_LIST_CHECKED",nestingLevel:Ul("☑",{st:{s:ve.TRUE}})}},es=e=>{const{glyphFormat:t,glyphType:n}=e,r=re.deepClone(tr.ORDER_LIST);return r.nestingLevel[0].glyphFormat=t,r.nestingLevel[0].glyphType=n,r},u_={ORDER_LIST_QUICK_2:es(Qr["a)"]),ORDER_LIST_QUICK_3:es(Qr["a."]),ORDER_LIST_QUICK_4:es(Qr["i."]),ORDER_LIST_QUICK_6:es(Qr["I."])};Object.assign(tr,u_);const c_={"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"};function h_(e,t,n,r,s){const i=d_(e,t,n,r,s),o=f_(e,t,n,r,s),a=g_(e,t,n,r,s),l=m_(e,t,n,r,s),u=__(e,t,n,r,s),c=p_(e,t,n,r),h=E_(e,t,n,r,s);return{dataStream:"",textRuns:i,paragraphs:o,sectionBreaks:a,customBlocks:l,tables:u,customRanges:c,customDecorations:h}}function d_(e,t,n,r,s){const{textRuns:i}=e,{textRuns:o}=t;if(i==null||o==null)return;const a=Al(e,n,r);if(s!==ke.REPLACE){const l=kl(o,a,s);t.textRuns=l}return Rl(e,t,n,r),a}function kl(e,t,n){if(t.length===0)return e;e=re.deepClone(e),t=re.deepClone(t);const r=[],s=e.length,i=t.length;let o=0,a=0,l=null;function u(){return l?(r.push(l),l=null,!0):!1}for(;o<s&&a<i;){const{st:g,ed:C,ts:I}=e[o],{st:b,ed:U,ts:Z,sId:V}=t[a];let fe;if(n===ke.COVER?fe={...Z,...I}:fe={...I},C<b)u()||r.push(e[o]),o++;else if(U<g)u()||r.push(t[a]),a++;else{const M={st:Math.min(g,b),ed:Math.max(g,b),ts:g<b?{...I}:{...Z},sId:g<b?void 0:V};M.ed>M.st&&r.push(M),r.push({st:Math.max(g,b),ed:Math.min(C,U),ts:fe,sId:V}),C<U?(o++,t[a].st=C,t[a].st===t[a].ed&&a++):(a++,e[o].st=U,e[o].st===e[o].ed&&o++);const T={st:Math.min(C,U),ed:Math.max(C,U),ts:C<U?{...Z}:{...I},sId:C<U?V:void 0};l=T.ed>T.st?T:null}}u();const c=r[r.length-1],h=e[s-1],f=t[i-1];return c&&c.ed!==Math.max(h.ed,f.ed)&&(h.ed>f.ed?r.push(h):r.push(f)),er(r)}function f_(e,t,n,r,s){const{paragraphs:i}=e,{paragraphs:o}=t;if(i==null||o==null)return;const a=Tl(e,n,r);if(s!==ke.REPLACE){const l=[];for(const u of o){const{startIndex:c,paragraphStyle:h,bullet:f}=u;let g=[];for(const C of a){const{startIndex:I,paragraphStyle:b,bullet:U}=C;let Z,V;if(s===ke.COVER?(Z={...b,...h},V={listId:"",listType:Mt.BULLET_LIST,nestingLevel:0,textStyle:{},...U,...f}):(Z={...h,...b},V={listId:"",listType:Mt.BULLET_LIST,nestingLevel:0,textStyle:{},...f,...U}),c===I){g.push({startIndex:c,paragraphStyle:Z,bullet:V});break}}l.push(...g),g=[]}t.paragraphs=l}return Il(e,t,n,r),a}function g_(e,t,n,r,s){const{sectionBreaks:i}=e,{sectionBreaks:o}=t;if(i==null||o==null)return;const a=Nl(e,n,r);if(s!==ke.REPLACE){const l=[];for(const u of o){const{startIndex:c}=u;let h=[];for(const f of a){const{startIndex:g}=f;if(c===g){s===ke.COVER?h.push({...f,...u}):h.push({...u,...f});break}}l.push(...h),h=[]}t.sectionBreaks=l}return Sl(e,t,n,r),a}function m_(e,t,n,r,s){const{customBlocks:i=[]}=e,{customBlocks:o}=t;if(i==null||o==null)return;const a=Ml(e,n,r);if(s!==ke.REPLACE){const l=[];for(const u of o){const{startIndex:c}=u;let h=[];for(const f of a){const{startIndex:g}=f;if(c===g){s===ke.COVER?h.push({...f,...u}):h.push({...u,...f});break}}l.push(...h),h=[]}t.customBlocks=l}return vl(e,t,n,r),i.length&&!e.customBlocks&&(e.customBlocks=i),a}function __(e,t,n,r,s){const{tables:i}=e,{tables:o}=t;if(i==null||o==null)return;const a=Dl(e,n,r);if(s!==ke.REPLACE){const l=[];for(const u of o){const{startIndex:c,endIndex:h}=u;let f=[];for(const g of a){const{startIndex:C,endIndex:I}=g;if(C>=c&&I<=h){s===ke.COVER?f.push({...g,...u}):f.push({...u,...g});break}}l.push(...f),f=[]}t.tables=l}return Ol(e,t,n,r),a}function p_(e,t,n,r,s){e.customRanges||(e.customRanges=[]),Qs(e.customRanges,r),Qs(e.customRanges,r+n);const i=r,o=r+n-1,{customRanges:a}=t,l=[],u=new Map;e.customRanges.forEach(h=>{const{startIndex:f,endIndex:g}=h;f>=i&&g<=o?u.set(h.rangeId,h):l.push(h)});const c=[];return a?(a.forEach(h=>{const{startIndex:f,endIndex:g}=h;l.push({...h,startIndex:f+r,endIndex:g+r})}),e.customRanges=Zs(l),c):[]}function E_(e,t,n,r,s){e.customDecorations||(e.customDecorations=[]),ei(e.customDecorations,r),ei(e.customDecorations,r+n);const i=[],{customDecorations:o}=e,{customDecorations:a=[]}=t;if(s===ke.REPLACE){for(let l=0;l<o.length;l++){const u=o[l],{startIndex:c,endIndex:h}=u;c>=r&&h<=r+n-1&&i.push(u)}a.forEach(l=>{const{startIndex:u,endIndex:c}=l;o.push({...l,startIndex:u+r,endIndex:c+r})})}else for(const l of a){const{id:u}=l;if(l.type===rn.DELETED){const c=o.filter(h=>h.id===u);c.length&&i.push(...c)}else o.push({...l,startIndex:l.startIndex+r,endIndex:l.endIndex+r})}for(const l of i){const{id:u}=l,c=o.findIndex(h=>h.id===u);c!==-1&&o.splice(c,1)}return e.customDecorations=yl(o),i}var ti=(e=>(e[e.copy=0]="copy",e[e.cut=1]="cut",e))(ti||{});function ts(e,t,n,r=!0){const{textRuns:s}=e;if(s){const i=[];for(const o of s){const a=re.deepClone(o),{st:l,ed:u}=a;re.hasIntersectionBetweenTwoRanges(l,u,t,n)&&(t>=l&&t<=u?i.push({...a,st:t,ed:Math.min(n,u)}):n>=l&&n<=u?i.push({...a,st:Math.max(t,l),ed:n}):i.push(a))}return er(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 Pl(e,t,n){const{tables:r=[]}=e,s=[];for(const i of r){const o=re.deepClone(i),{startIndex:a,endIndex:l}=o;a>=t&&l<=n&&s.push({...o,startIndex:a-t,endIndex:l-t})}return s}function Fl(e,t,n){const{paragraphs:r=[]}=e,s=[];for(const i of r){const{startIndex:o}=i;o>=t&&o<n&&s.push(re.deepClone(i))}if(s.length)return s.map(i=>({...i,startIndex:i.startIndex-t}))}function C_(e,t,n){const{sectionBreaks:r=[]}=e,s=[];for(const i of r){const{startIndex:o}=i;o>=t&&o<=n&&s.push(re.deepClone(i))}if(s.length)return s.map(i=>({...i,startIndex:i.startIndex-t}))}function xl(e,t,n){const{customBlocks:r=[]}=e,s=[];for(const i of r){const{startIndex:o}=i;o>=t&&o<=n&&s.push(re.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=ts(e,t,n,r);const a=Pl(e,t,n);if(a.length&&(o.tables=a),o.paragraphs=Fl(e,t,n),s===1){const u=Bl(e,t,n);u?o.customDecorations=u:r&&(o.customDecorations=[])}const{customRanges:l}=$l(e,t,n);return l?o.customRanges=l:r&&(o.customRanges=[]),o.customBlocks=xl(e,t,n),o}function R_(e){const{dataStream:t,textRuns:n,paragraphs:r,customRanges:s,customDecorations:i,tables:o}=e;let a=0,l=0;s==null||s.forEach(c=>{c.startIndex<0&&(a=Math.max(a,-c.startIndex)),c.endIndex>t.length-1&&(l=Math.max(l,c.endIndex-t.length+1))});const u=`${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(c=>{c.st+=a,c.ed+=a}),r==null||r.forEach(c=>{c.startIndex+=a}),s==null||s.forEach(c=>{c.startIndex+=a,c.endIndex+=a}),i==null||i.forEach(c=>{c.startIndex+=a,c.endIndex+=l}),o==null||o.forEach(c=>{c.startIndex+=a,c.endIndex+=l}),{...e,dataStream:u,textRuns:n,paragraphs:r,customRanges:s,customDecorations:i,tables:o}}function $l(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 Bl(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=re.deepClone(i);s.push({...o,startIndex:Math.max(o.startIndex-t,0),endIndex:Math.min(o.endIndex,n-1)-t})}}),s}function I_(e,t,n){return e==null||t==null?e!=null?e:t:kl(e,t,n)}function S_(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===ke.REPLACE?[{...e[0]}]:[{...t[0],...e[0]}]}function v_(e,t,n){return t.length===0||e.length===0||n===ke.REPLACE?e:[...e,...t.filter(r=>!e.some(s=>r.id===s.id))]}function ni(e,t,n=ke.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:u=[],customRanges:c,customDecorations:h=[]}=t;r.textRuns=I_(l,s,n),r.customRanges=S_(c,o,n);const f=v_(h,a,n);f.length&&(r.customDecorations=f);const g=[];let C=0,I=0;for(;C<i.length&&I<u.length;){const b=i[C],U=u[I],{startIndex:Z}=b,{startIndex:V}=U;Z===V?(g.push(re.deepMerge(b,U)),C++,I++):Z<V?(g.push(re.deepClone(b)),C++):(g.push(re.deepClone(U)),I++)}return C<i.length&&g.push(...i.slice(C)),I<u.length&&g.push(...u.slice(I)),g.length&&(r.paragraphs=g),r}function O_(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 On{constructor(t){R(this,"_index",0);R(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===he.DELETE||n.t===he.RETAIN&&n.body==null?re.deepClone({...n,len:t}):re.deepClone({...n,len:t,body:bt(n.body,r,r+t,!1)})}else return{t:he.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:he.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[]}}class wn{constructor(){R(this,"cursor",0)}reset(){return this.cursor=0,this}moveCursor(t){this.cursor+=t}moveCursorTo(t){this.cursor=t}}function Hl(e,t,n){const{dataStream:r}=e,s=n,i=n+t,o=Al(e,t,n),a=Tl(e,t,n),l=Nl(e,t,n),u=Ml(e,t,n),c=Dl(e,t,n),h=a_(e,t,n),f=l_(e,t,n);let g="";return r&&(e.dataStream=yo(r,s,i),g=r.slice(s,i)),{dataStream:g,textRuns:o,paragraphs:a,sectionBreaks:l,customBlocks:u,tables:c,customRanges:h,customDecorations:f}}function Wl(e,t,n,r){e.dataStream=bo(e.dataStream,r,t.dataStream),Rl(e,t,n,r),Il(e,t,n,r),Sl(e,t,n,r),vl(e,t,n,r),Ol(e,t,n,r),i_(e,t,n,r),o_(e,t,n,r)}function w_(e,t,n,r,s=ke.COVER){return h_(e,t,n,r,s)}function b_(e,t,n){return t<=0?{dataStream:""}:Hl(e,t,n)}function y_(e,t,n,r){n!==0&&Wl(e,t,n,r)}function A_(e,t){const n=new wn;return n.reset(),t.forEach(r=>{const s=re.deepClone(r);switch(s.t){case he.RETAIN:{const{coverType:i,body:o,len:a}=s;o!=null&&w_(e,o,a,n.cursor,i),n.moveCursor(a);break}case he.INSERT:{const{body:i,len:o}=s;y_(e,i,o,n.cursor),n.moveCursor(o);break}case he.DELETE:{const{len:i}=s;b_(e,i,n.cursor);break}default:throw new Error(`Unknown action type for action: ${s}.`)}}),e}function T_(e,t,n,r,s){if(e==null||t==null)return t;if(e.length===0||t.length===0)return[];t=re.deepClone(t),e=re.deepClone(e);const i=[],o=t.length,a=e.length;let l=0,u=0,c=null;function h(){return c?(i.push(c),c=null,!0):!1}for(;l<o&&u<a;){const{st:I,ed:b,ts:U}=t[l],{st:Z,ed:V,ts:fe,sId:M}=e[u];let T={};if(s===0)T={...U},n===ke.COVER&&r===ke.REPLACE&&fe&&(T=Object.assign({},fe,T));else if(T={...U},n===ke.REPLACE){if(r===ke.REPLACE)T={...fe};else if(U&&fe){const j=Object.keys(U);for(const Q of j)fe[Q]&&delete T[Q]}}else if(r===ke.REPLACE){if(fe){const j=Object.keys(fe);for(const Q of j)fe[Q]!==void 0&&(T[Q]=fe[Q])}}else if(fe){const j=Object.keys(fe);for(const Q of j)T[Q]!==void 0&&delete T[Q]}if(b<Z)h()||i.push(t[l]),l++;else if(V<I)h()||i.push(e[u]),u++;else{const j={st:Math.min(I,Z),ed:Math.max(I,Z),ts:I<Z?{...U}:{...fe}};j.ed>j.st&&i.push(),i.push({st:Math.max(I,Z),ed:Math.min(b,V),ts:T,sId:M}),b<V?(l++,e[u].st=b,e[u].st===e[u].ed&&u++):(u++,t[l].st=V,t[l].st===t[l].ed&&l++);const Q={st:Math.min(b,V),ed:Math.max(b,V),ts:b<V?{...fe}:{...U},sId:b<V?M:void 0};c=Q.ed>Q.st?Q:null}}h();const f=i[i.length-1],g=t[o-1],C=e[a-1];return f.ed!==Math.max(g.ed,C.ed)&&(g.ed>C.ed?i.push(g):i.push(C)),er(i,!0)}function N_(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===ke.REPLACE)return s===1?[re.deepClone(i)]:[re.deepClone(o)];if(r===ke.REPLACE){const a=re.deepClone(o);return s===1&&Object.assign(a,re.deepClone(i)),[a]}else{const a=re.deepClone(o);return s===1&&Object.assign(a,re.deepClone(i)),[a]}}function jl(e,t,n,r,s){const i={startIndex:t.startIndex};if(t.paragraphStyle&&(i.paragraphStyle=re.deepClone(t.paragraphStyle),e.paragraphStyle)){if(n===ke.REPLACE)if(r===ke.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===ke.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===ke.REPLACE&&r===ke.REPLACE?i.bullet=s===1?re.deepClone(e.bullet):re.deepClone(t.bullet):e.bullet===void 0?i.bullet=re.deepClone(t.bullet):n===ke.REPLACE||r===ke.REPLACE?i.bullet=s===0&&t.bullet?re.deepClone(t.bullet):re.deepClone(e.bullet):s===0&&t.bullet!==void 0&&(i.bullet=re.deepClone(t.bullet)),i}function M_(e,t){if(e==null||t==null)return t;if(e.length===0||t.length===0)return re.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===rn.DELETED||i===rn.DELETED)&&(o=!0,n.push({...r,type:rn.DELETED}));break}o||n.push(r)}return n}function D_(e,t,n=!1){const{body:r,coverType:s=ke.COVER}=e,{body:i,coverType:o=ke.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:u,paragraphs:c=[],customRanges:h,customDecorations:f}=r,{textRuns:g,paragraphs:C=[],customRanges:I,customDecorations:b}=i,U=T_(u,g,s,o,n?1:0);U&&(a.textRuns=U);const Z=N_(h,I,s,o,n?1:0);Z&&(a.customRanges=Z);const V=M_(f,b);V&&(a.customDecorations=V);const fe=[];let M=0,T=0;for(;M<c.length&&T<C.length;){const j=c[M],Q=C[T],{startIndex:ge}=j,{startIndex:le}=Q;if(ge===le){let p={startIndex:ge};n?p=jl(j,Q,s,o,1):p=jl(j,Q,s,o,0),fe.push(p),M++,T++}else ge<le?M++:(fe.push(re.deepClone(Q)),T++)}return T<C.length&&fe.push(...C.slice(T)),fe.length&&(a.paragraphs=fe),{coverType:l,body:a}}function Yl(e){return Object.keys(e).length===1}const Nn=class Nn{constructor(){R(this,"_actions",[])}static apply(t,n){return A_(t,n)}static compose(t,n){const r=new On(t),s=new On(n),i=new Nn;for(;r.hasNext()||s.hasNext();)if(s.peekType()===he.INSERT)i.push(s.next());else if(r.peekType()===he.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===he.INSERT&&l.t===he.RETAIN)l.body==null?i.push(a):i.push({...a,body:ni(a.body,l.body,l.coverType)});else if(a.t===he.RETAIN&&l.t===he.RETAIN)if(a.body==null&&l.body==null)i.push(a.len!==Number.POSITIVE_INFINITY?a:l);else if(a.body&&l.body){const u=a.coverType===ke.REPLACE||l.coverType===ke.REPLACE?ke.REPLACE:ke.COVER;i.push({...a,t:he.RETAIN,coverType:u,body:ni(a.body,l.body,l.coverType)})}else i.push(a.body?a:l);else a.t===he.RETAIN&&l.t===he.DELETE?i.push(l):a.t===he.INSERT&&(l.t,he.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 On(t),i=new On(n),o=new Nn;for(;s.hasNext()||i.hasNext();)if(s.peekType()===he.INSERT&&(r==="left"||i.peekType()!==he.INSERT)){const a=s.next();o.retain(a.len)}else if(i.peekType()===he.INSERT)o.push(i.next());else{const a=Math.min(s.peekLength(),i.peekLength()),l=s.next(a),u=i.next(a);if(l.t===he.DELETE)continue;if(u.t===he.DELETE){o.push(u);continue}if(l.body==null||u.body==null)o.push(u);else{const{coverType:c,body:h}=D_(l,u,r==="left");o.push({...u,t:he.RETAIN,coverType:c,body:h})}}return o.trimEndUselessRetainAction(),o.serialize()}static transformPosition(t,n,r=!1){const s=new On(t);let i=0;for(;s.hasNext()&&i<=n;){const o=s.peekLength(),a=s.peekType();if(s.next(),a===he.DELETE){n-=Math.min(o,n-i);continue}else a===he.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===he.INSERT)n.push({t:he.DELETE,len:r.len,body:r.body});else if(r.t===he.DELETE){if(r.body==null)throw new Error("Can not invert DELETE action without body property, makeInvertible must be called first.");n.push({t:he.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:he.RETAIN,body:r.oldBody,oldBody:r.body,len:r.len,coverType:ke.REPLACE})}else n.push(r);return n}static makeInvertible(t,n){const r=[];let s=0;for(const i of t){if(i.t===he.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===he.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!==he.INSERT&&(s+=i.len)}return r}insert(t,n){const r={t:he.INSERT,body:n,len:t};return this.push(r),this}retain(t,n,r){const s={t:he.RETAIN,len:t};return n!=null&&(s.body=n),r!=null&&(s.coverType=r),this.push(s),this}delete(t){const n={t:he.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=re.deepClone(t[0]);if(s.t===he.RETAIN&&s.len===0&&s.body==null)return this;if(typeof r=="object"){if(r.t===he.DELETE&&s.t===he.DELETE)return r.len+=s.len,this;if(r.t===he.DELETE&&s.t===he.INSERT&&(n-=1,r=this._actions[n-1],r==null))return this._actions.unshift(s),this;if(r.t===he.RETAIN&&s.t===he.RETAIN&&r.body==null&&s.body==null)return r.len+=s.len,this;if(r.t===he.INSERT&&Yl(r.body)&&s.t===he.INSERT&&Yl(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===he.RETAIN&&O_(t);)this._actions.pop(),t=this._actions[this._actions.length-1];return this}};R(Nn,"id","text-x"),R(Nn,"uri","https://github.com/dream-num/univer#text-x");let ze=Nn;Object.defineProperty(ze,"name",{value:"text-x"});const Mn=class Mn{static registerSubtype(t){var n;t==null||this._subTypes.has(t.name)&&((n=this._subTypes.get(t.name))==null?void 0:n.id)!==ze.id||(this._subTypes.set(t.name,t),gt.type.registerSubtype(t))}static apply(t,n){if(!gt.type.isNoop(n))return gt.type.apply(t,n)}static compose(t,n){return gt.type.compose(t,n)}static transform(t,n,r){return gt.type.transform(t,n,r)}static transformPosition(t,n,r="right"){return t&&t.length===2&&t[0]==="body"&&t[1].et===ze.name?ze.transformPosition(t[1].e,n,r==="left"):n}static invertWithDoc(t,n){return gt.type.invertWithDoc(t,n)}static isNoop(t){return gt.type.isNoop(t)}static getInstance(){return this._instance==null&&(this._instance=new Mn),this._instance}removeOp(t,n){return gt.removeOp(t,n)}moveOp(t,n){return gt.moveOp(t,n)}insertOp(t,n){return gt.insertOp(t,n)}replaceOp(t,n,r){return gt.replaceOp(t,n,r)}editOp(t,n=["body"]){return gt.editOp(n,ze.name,t)}};R(Mn,"uri","https://github.com/dream-num/univer#json-x"),R(Mn,"_subTypes",new Map),R(Mn,"_instance",null);let xt=Mn;xt.registerSubtype(ze);const ri={id:"default_doc",documentStyle:{}};class L_ extends Xr{constructor(n){var r;super();R(this,"type",Be.UNIVER_DOC);R(this,"_name$",new Ie.BehaviorSubject(""));R(this,"name$",this._name$.asObservable());R(this,"snapshot");this.snapshot={...ri,...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{...tr,...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}}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,u=s==null?void 0:s[n];if(!u)return;const c=u.docTransform;c.size.width=i,c.size.height=o,c.positionH.posOffset=a,c.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}}class yt extends L_{constructor(n){var s,i;super(re.isEmptyObject(n)?Jm():n);R(this,"_unitId");R(this,"headerModelMap",new Map);R(this,"footerModelMap",new Map);R(this,"change$",new Ie.BehaviorSubject(0));const r=6;this._unitId=(s=this.snapshot.id)!=null?s:re.generateRandomId(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={...ri,...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(!xt.isNoop(n))return this.snapshot=xt.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=ti.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 yt(i)),this.headerModelMap.get(s).updateDocumentId(this.getUnitId())}if(r)for(const s in r){const i=r[s];this.footerModelMap.set(s,new yt(i)),this.footerModelMap.get(s).updateDocumentId(this.getUnitId())}}updateDocumentId(n){super.updateDocumentId(n),this._unitId=n}getPlainText(){var n,r;return jr((r=(n=this.getBody())==null?void 0:n.dataStream)!=null?r:"")}}function U_(e){const{ranges:t,id:n,type:r}=e,s=new ze;let i=0;for(let o=0;o<t.length;o++){const a=t[o],{startOffset:l,endOffset:u}=a;l>0&&s.push({t:he.RETAIN,len:l-i}),s.push({t:he.RETAIN,body:{dataStream:"",customDecorations:[{id:n,type:r,startIndex:0,endIndex:u-l-1}]},len:u-l}),i=u}return s}function k_(e){var c,h,f;const{id:t,segmentId:n,documentDataModel:r}=e,s=r==null?void 0:r.getBody();if(!r||!s)return!1;const i=(f=(h=(c=r.getSelfOrHeaderFooterModel(n))==null?void 0:c.getBody())==null?void 0:h.customDecorations)==null?void 0:f.find(g=>g.id===t);if(!i)return!1;const o=new ze,{startIndex:a,endIndex:l}=i,u=l-a+1;return o.push({t:he.RETAIN,len:a}),o.push({t:he.RETAIN,len:u,body:{dataStream:"",customDecorations:[{startIndex:0,endIndex:u-1,id:t,type:rn.DELETED}]}}),o}function zl(e,t,n,r){return e<=n&&t>=n||e>=n&&e<=r}function P_(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):zl(e.startOffset,e.endOffset-1,i.startIndex,i.endIndex)&&n.push(i)}return n}function F_(e){return{...re.deepClone(e),rangeId:kt()}}function x_(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 Vl(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 $_(e,t){var i,o,a,l,u;const n=Vl(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,((u=(l=n[n.length-1])==null?void 0:l.endIndex)!=null?u:-1/0)+1);return{startOffset:r,endOffset:s,collapsed:r===s}}function B_(e){var h,f,g;const{rangeId:t,segmentId:n,documentDataModel:r,insert:s}=e,i=(f=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.customRanges)==null?void 0:f.find(C=>C.rangeId===t);if(!i)return!1;const{startIndex:o,endIndex:a}=i,l=new ze,u=a-o+1;l.push({t:he.RETAIN,len:o}),l.push({t:he.RETAIN,len:u,body:{dataStream:"",customRanges:[]}}),s&&l.push({t:he.INSERT,body:s,len:s.dataStream.length});const c=a+1+((g=s==null?void 0:s.dataStream.length)!=null?g:0);return l.selections=[{startOffset:c,endOffset:c,collapsed:!0}],l}function H_(e){const{ranges:t,rangeId:n,rangeType:r,wholeEntity:s,properties:i,body:o}=e;let a=0;const l=new ze;let u=!1;return t.forEach(c=>{var V,fe,M;const h=$_(c,o);if(!h||!o)return!1;const{startOffset:f,endOffset:g}=h,C=(V=o.customRanges)!=null?V:[],I=(T,j,Q)=>{var O,D,y,w;const ge=Vl(T,j,C,r),le=Math.min((D=(O=ge[0])==null?void 0:O.startIndex)!=null?D:1/0,T),p=Math.max((w=(y=ge[ge.length-1])==null?void 0:y.endIndex)!=null?w:-1/0,j),W={rangeId:Q?`${n}$${Q}`:n,rangeType:r,startIndex:0,endIndex:p-le,wholeEntity:s,properties:{...i}};l.push({t:he.RETAIN,len:le-a}),l.push({t:he.RETAIN,len:p-le+1,body:{dataStream:"",customRanges:[W]},coverType:ke.COVER}),a=p+1},b=((fe=o.paragraphs)!=null?fe:[]).filter(T=>T.startIndex<g&&T.startIndex>f),U=((M=o.customBlocks)!=null?M:[]).filter(T=>T.startIndex<g&&T.startIndex>f);x_([f,g-1],[...b.map(T=>T.startIndex),...U.map(T=>T.startIndex)]).forEach(([T,j],Q)=>I(T,j,Q)),u=!0,l.selections=[{startOffset:h.endOffset,endOffset:h.endOffset,collapsed:!0}]}),u?l:!1}function Gl(e,t,n=0,r=null,s=!0){e.sort((u,c)=>u.startOffset-c.startOffset);const i=[],{paragraphs:o=[]}=t,a=o==null?void 0:o.find(u=>u.startIndex>=e[0].startOffset&&u.startIndex<e[0].endOffset);let l=n;if(e.forEach(u=>{const{startOffset:c,endOffset:h}=u;c>l&&(i.push({t:he.RETAIN,len:c-l}),l=c),l<h&&(i.push({t:he.DELETE,len:h-l}),l=h)}),r&&i.push({t:he.INSERT,body:r,len:r.dataStream.length}),a&&s){const u=o.find(c=>c.startIndex-n>=e[e.length-1].endOffset-1);u&&(u.startIndex>l&&(i.push({t:he.RETAIN,len:u.startIndex-l}),l=u.startIndex),i.push({t:he.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...u,startIndex:0,bullet:a==null?void 0:a.bullet}]},coverType:ke.REPLACE}))}return i}function W_(e,t,n=0){const r=[];let s=n;return e.forEach(i=>{const{startOffset:o,endOffset:a}=i;o>s&&(r.push({t:he.RETAIN,len:o-s}),s=o),a>s&&(r.push({t:he.RETAIN,len:a-s,body:{...re.deepClone(t),dataStream:""}}),s=a)}),r}const j_=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=zs(o?o.dataStream:"",n.dataStream);let l=0;const u=a.map(([f,g])=>{switch(f){case 0:{const C={t:he.RETAIN,body:{...bt(n,l,l+g.length,!1),dataStream:""},len:g.length};return l+=g.length,C}case 1:{const C={t:he.INSERT,body:bt(n,l,l+g.length),len:g.length};return l+=g.length,C}default:return{t:he.DELETE,len:g.length}}}),c=new ze;return c.push({t:he.RETAIN,len:t.startOffset}),c.push(...u),c};function Y_(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 z_=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=zs(o?o.dataStream:"",n.dataStream);let l=0;const u=a.map(([f,g])=>{switch(f){case 0:{const C=ts(n,l,l+g.length,!1),I=ts(o,l,l+g.length,!1),b={t:he.RETAIN,body:Y_(C,I)?void 0:{textRuns:C,dataStream:""},len:g.length};return l+=g.length,b}case 1:{const C={t:he.INSERT,body:bt(n,l,l+g.length),len:g.length};return l+=g.length,C}default:return{t:he.DELETE,len:g.length}}});if(u.every(f=>f.t===he.RETAIN&&!f.body))return!1;const c=new ze;return c.push({t:he.RETAIN,len:t.startOffset}),c.push(...u),c};function V_(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 G_(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 K_=e=>{var I,b,U,Z;const{selection:t,documentDataModel:n,drawings:r}=e,{collapsed:s,startOffset:i,segmentId:o}=t,a=new ze,l=xt.getInstance(),u=[],c=n.getSelfOrHeaderFooterModel(o).getBody();if(!c)return!1;const h=(b=(I=n.getSnapshot().drawingsOrder)==null?void 0:I.length)!=null?b:0;let f=0;if(s)i>0&&a.push({t:he.RETAIN,len:i});else{const V=Gl([t],c,0,null,!1);a.push(...V);const fe=V_(c,[t]),M=(U=n.getDrawings())!=null?U:{},T=(Z=n.getDrawingsOrder())!=null?Z:[],j=fe.sort((Q,ge)=>T.indexOf(Q)>T.indexOf(ge)?-1:T.indexOf(Q)<T.indexOf(ge)?1:0);if(j.length>0)for(const Q of j){const ge=M[Q],le=T.indexOf(Q);if(ge==null||le<0)continue;const p=l.removeOp(["drawings",Q],ge),W=l.removeOp(["drawingsOrder",le],Q);u.push(p),u.push(W),f++}}a.push({t:he.INSERT,body:{dataStream:"\b".repeat(r.length),customBlocks:r.map((V,fe)=>({startIndex:fe,blockId:V.drawingId}))},len:r.length});const g=G_(n,o),C=l.editOp(a.serialize(),g);u.push(C);for(const V of r){const{drawingId:fe}=V,M=l.insertOp(["drawings",fe],V),T=l.insertOp(["drawingsOrder",h-f],fe);u.push(M),u.push(T)}return u.reduce((V,fe)=>xt.compose(V,fe),null)},X_=e=>{var h,f,g;const{paragraphs:t,segmentId:n,document:r}=e;let s=e.listType;const i=(f=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.paragraphs)!=null?f:[],o=t.every(C=>{var I;return((I=C.bullet)==null?void 0:I.listType.indexOf(s))===0});let l=re.generateRandomId(6);if(t.length===1){const C=i.indexOf(t[0]),I=i[C-1],b=i[C+1];I&&I.bullet&&I.bullet.listType.indexOf(s)===0?(l=I.bullet.listId,s!==Mt.CHECK_LIST&&(s=I.bullet.listType)):b&&b.bullet&&b.bullet.listType.indexOf(s)===0&&(l=b.bullet.listId,s!==Mt.CHECK_LIST&&(s=b.bullet.listType))}const u=new wn;u.reset();const c=new ze;for(const C of t){const{startIndex:I,paragraphStyle:b={},bullet:U}=C;c.push({t:he.RETAIN,len:I-u.cursor}),c.push({t:he.RETAIN,len:1,body:{dataStream:"",paragraphs:[o?{paragraphStyle:b,startIndex:0}:{startIndex:0,paragraphStyle:{...b},bullet:{nestingLevel:(g=U==null?void 0:U.nestingLevel)!=null?g:0,textStyle:{fs:20},listType:s,listId:l}}]},coverType:ke.REPLACE}),u.moveCursorTo(I+1)}return c},q_=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(f=>f.startIndex===t);if(!(i!=null&&i.bullet)||i.bullet.listType.indexOf(Mt.CHECK_LIST)===-1)return!1;const o=new wn;o.reset();const a=new ze,{startIndex:l,paragraphStyle:u={}}=i,c=i.bullet.listType===Mt.CHECK_LIST?Mt.CHECK_LIST_CHECKED:Mt.CHECK_LIST;return a.push({t:he.RETAIN,len:l-o.cursor}),a.push({t:he.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...i,paragraphStyle:u,startIndex:0,bullet:{...i.bullet,listType:c}}]},coverType:ke.REPLACE}),o.moveCursorTo(l+1),a},J_=e=>{var c,h;const{paragraphs:t,listType:n,segmentId:r,document:s}=e;if(((c=s.getSelfOrHeaderFooterModel(r).getBody())==null?void 0:c.paragraphs)==null)return!1;const a=re.generateRandomId(6),l=new wn;l.reset();const u=new ze;for(const f of t){const{startIndex:g,paragraphStyle:C={},bullet:I}=f;u.push({t:he.RETAIN,len:g-l.cursor}),u.push({t:he.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:C,bullet:{nestingLevel:(h=I==null?void 0:I.nestingLevel)!=null?h:0,textStyle:(I==null?void 0:I.listType)===n?I.textStyle:{fs:20},listType:n,listId:a}}]},coverType:ke.REPLACE}),l.moveCursorTo(g+1)}return u};function Z_(e,t){return t.some(n=>e.startIndex>n.startIndex&&e.startIndex<n.endIndex)}const Q_=e=>{var c,h,f;const{paragraphs:t,segmentId:n,document:r,type:s}=e,i=new wn;i.reset();const o=new ze,a=(c=r.getSnapshot().lists)!=null?c:{},l=(f=(h=r.getBody())==null?void 0:h.tables)!=null?f:[],u={...tr,...a};for(const g of t){const{startIndex:C,paragraphStyle:I={},bullet:b}=g,U=Z_(g,l);if(o.push({t:he.RETAIN,len:C-i.cursor}),b){const Z=b.listType;let V=u[Z].nestingLevel.length-1;U&&(V=Math.min(V,2)),o.push({t:he.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:{...I},bullet:{...b,nestingLevel:Math.max(Math.min(b.nestingLevel+s,V),0)}}]},coverType:ke.REPLACE})}else o.push({t:he.RETAIN,len:1});i.moveCursorTo(C+1)}return o};function ep(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 tp(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 np(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}class ot{}R(ot,"customRange",{add:H_,delete:B_,copyCustomRange:F_,getCustomRangesInterestsWithSelection:P_,isIntersecting:zl}),R(ot,"customDecoration",{add:U_,delete:k_}),R(ot,"selection",{replace:j_,makeSelection:ep,normalizeSelection:tp,delete:Gl,replaceTextRuns:z_,retain:W_}),R(ot,"range",{isIntersects:np}),R(ot,"transform",{getPlainText:jr,fromPlainText:Vd,isEmptyDocument:zd}),R(ot,"paragraph",{bullet:{set:J_,switch:X_,toggleChecklist:q_,changeNestLevel:Q_}}),R(ot,"drawing",{add:K_});function rp(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 Kl(e){var t;return e.body=rp((t=e.body)!=null?t:{dataStream:""}),e.drawingsOrder||(e.drawingsOrder=[]),e.drawings||(e.drawings={}),e.documentStyle||(e.documentStyle={}),e}class nr{constructor(t={}){R(this,"_style");this._style=t}static create(t={}){return new nr(t)}get fontFamily(){return this._style.ff}get fontSize(){return this._style.fs}get italic(){return this._style.it===ve.TRUE}get bold(){return this._style.bl===ve.TRUE}get underline(){return this._style.ul&&Xt.create(this._style.ul)}get bottomBorderLine(){return this._style.bbl&&Xt.create(this._style.bbl)}get strikethrough(){return this._style.st&&Xt.create(this._style.st)}get overline(){return this._style.ol&&Xt.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 Kt.create(re.deepClone(this._style))}getValue(){return{...this._style}}}class Kt extends nr{static create(t={}){return new Kt(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 Kt.create(re.deepClone(this._style))}build(){return this.getValue()}}class Xt{constructor(t={s:1}){R(this,"_decoration");this._decoration=t}static create(t={s:1}){return new Xt(t)}get show(){return this._decoration.s===ve.TRUE}get followFontColor(){return this._decoration.c===ve.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 Xt.create(re.deepClone(this._decoration))}build(){return{...this._decoration}}}class rr{constructor(t={}){R(this,"_style");this._style=t}static create(t={}){return new rr(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===ve.TRUE}get keepNext(){return this._style.keepNext===ve.TRUE}get wordWrap(){return this._style.wordWrap===ve.TRUE}get widowControl(){return this._style.widowControl===ve.TRUE}get shading(){return this._style.shading}get suppressHyphenation(){return this._style.suppressHyphenation===ve.TRUE}copy(){return sr.create(re.deepClone(this._style))}getValue(){return this._style}}class sr extends rr{static create(t={}){return new sr(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 sr.create(re.deepClone(this._style))}build(){return this.getValue()}}class qt{constructor(t){R(this,"_data");if(!t.body)throw new Error("Invalid document data, body is required");this._data=Kl(t)}static create(t){return new qt(t)}static createByBody(t){return new qt({body:t,id:"d",documentStyle:{}})}copy(){return un.create(re.deepClone(this._data))}slice(t,n){const{body:r,...s}=this._data;return un.create({...re.deepClone(s),body:bt(r,t,n)})}toPlainText(){var t,n;return ot.transform.getPlainText((n=(t=this._data.body)==null?void 0:t.dataStream)!=null?n:"").replaceAll("\r",`
9
9
  `)}getParagraphStyle(){var t,n;return rr.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?nr.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===zt.HYPERLINK))!=null?r:[]}getData(){return this._data}}class un extends qt{constructor(n){super(n);R(this,"_doc");this._doc=new yt(n)}static newEmptyData(){return Kl({id:"d",documentStyle:{},drawings:{},drawingsOrder:[],body:{dataStream:`\r
10
- `,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(n){return new un(n!=null?n:un.newEmptyData())}insertText(n,r,s){var c,h;let i=((h=(c=this._data.body)==null?void 0:c.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 Kt?r.build():r:a=s instanceof Kt?s.build():s,!o)return this;const l={dataStream:o,textRuns:a?[{ts:a,st:i,ed:i+o.length}]:[]},u=ot.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:l});if(!u)throw new Error("Insert text failed, please check.");return ze.apply(this._doc.getBody(),u.serialize()),this}insertRichText(n,r){var a,l;let s=((l=(a=this._data.body)==null?void 0:a.dataStream.length)!=null?l:2)-2,i;typeof n=="object"?i=n instanceof qt?n.getData():n:(s=Math.min(n,s),i=r instanceof qt?r.getData():r);const o=ot.selection.replace({doc:this._doc,selection:{startOffset:s,endOffset:s,collapsed:!0},body:i.body});if(!o)throw new Error("Insert text failed, please check.");return ze.apply(this._doc.getBody(),o.serialize()),this}delete(n,r){if(r!==void 0){if(!r)return this;const s=ot.selection.delete([{startOffset:n,endOffset:n+r,collapsed:!0}],this._data.body);ze.apply(this._doc.getBody(),s)}return this}setStyle(n,r,s){const i={dataStream:"",textRuns:[{ts:s instanceof Kt?s.build():s,st:0,ed:r-n}]},o=ot.selection.retain([{startOffset:n,endOffset:r,collapsed:!0}],i);return ze.apply(this._doc.getBody(),o),this}setLink(n,r,s){const i=ot.customRange.add({rangeType:zt.HYPERLINK,rangeId:kt(),properties:{url:s},ranges:[{startOffset:n,endOffset:r,collapsed:!1}],body:this._data.body});if(!i)throw new Error("Insert text failed, please check.");return ze.apply(this._doc.getBody(),i.serialize()),this}cancelLink(n,r){if(typeof n=="string"){const s=ot.customRange.delete({rangeId:n,documentDataModel:this._doc});if(!s)throw new Error("Insert text failed, please check.");ze.apply(this._doc.getBody(),s.serialize())}else this.slice(n,r).getLinks().forEach(i=>{const o=ot.customRange.delete({rangeId:i.rangeId,documentDataModel:this._doc});if(!o)throw new Error("Insert text failed, please check.");ze.apply(this._doc.getBody(),o.serialize())});return this}updateLink(n,r){var i,o;const s=(o=(i=this._data.body)==null?void 0:i.customRanges)==null?void 0:o.find(a=>a.rangeId===n);if(!s)throw new Error("Link not found");return s.properties.url=r,this}insertParagraph(n,r){var o,a;let s,i;return typeof n=="object"?(s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:n.build()}]},i=((a=(o=this._data.body)==null?void 0:o.dataStream.length)!=null?a:2)-2):(i=n,s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:r==null?void 0:r.build()}]}),this.insertRichText(i,qt.create({body:s,id:"d",documentStyle:{}})),this}insertLink(n,r,s){let i="",o="";typeof n=="string"?(i=n,o=r):(i=r,o=s);const a=un.createByBody({dataStream:i,customRanges:[{rangeType:zt.HYPERLINK,rangeId:kt(),properties:{url:o},startIndex:0,endIndex:i.length-1}]});return typeof n=="number"?this.insertRichText(n,a):this.insertRichText(a)}}function sp(e,t=16){let n=0,r=null;return function(...i){const o=Date.now();o-n<t?(r&&clearTimeout(r),r=setTimeout(()=>{n=o,e.apply(this,i)},t)):(n=o,e.apply(this,i))}}var bn=(e=>(e[e.Style=1]="Style",e[e.Value=2]="Value",e))(bn||{});function ip(e){return`sheet_interceptor_${e}`}const Xl=e=>function(t,n){let r=-1,s=t;for(let i=0;i<=e.length;i++){if(i<=r)throw new Error("[SheetInterceptorService]: next() called multiple times!");if(r=i,i===e.length)return s;const o=e[i];let a=!1;if(s=o.handler(s,n,l=>(a=!0,l)),!a)break}return s};class op{constructor(t){R(this,"_interceptorsByName",new Map);R(this,"_interceptorPoints");this._interceptorPoints=t}fetchThroughInterceptors(t,n){const r=t;let s=this._interceptorsByName.get(r);return n&&(s=s.filter(n)),Xl(s||[])}intercept(t,n){const r=t;this._interceptorsByName.has(r)||this._interceptorsByName.set(r,[]);const s=this._interceptorsByName.get(r);return s.push(n),this._interceptorsByName.set(r,s.sort((i,o)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)})),()=>Ln(this._interceptorsByName.get(r),n)}getInterceptPoints(){return this._interceptorPoints}dispose(){this._interceptorsByName.clear()}}function ap(e){return`sheet_async_interceptor_${e}`}const lp=e=>async function(t,n){let r=-1,s=t;for(let i=0;i<=e.length;i++){if(i<=r)throw new Error("[SheetInterceptorService]: next() called multiple times!");if(r=i,i===e.length)return s;const o=e[i];let a=!1;if(s=await o.handler(s,n,async l=>(a=!0,l)),!a)break}return s};class up{constructor(t){R(this,"_asyncInterceptorsByName",new Map);R(this,"_asyncInterceptorPoints");this._asyncInterceptorPoints=t}fetchThroughAsyncInterceptors(t,n){const r=t;let s=this._asyncInterceptorsByName.get(r);return n&&(s=s.filter(n)),lp(s||[])}async interceptAsync(t,n){const r=t;this._asyncInterceptorsByName.has(r)||this._asyncInterceptorsByName.set(r,[]);const s=this._asyncInterceptorsByName.get(r);return s.push(n),this._asyncInterceptorsByName.set(r,s.sort((i,o)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)})),()=>Ln(this._asyncInterceptorsByName.get(r),n)}getInterceptPoints(){return this._asyncInterceptorPoints}dispose(){this._asyncInterceptorsByName.clear()}}function cp(e,t){for(const n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}function ql(e){return/^-?\d+(\.\d+)?$/.test(e)}function hp(e){return ql(e)?Number(e)<=Number.MAX_SAFE_INTEGER:!1}class si{constructor(){R(this,"_data",[])}static create(){return new si}add(t){this._data.indexOf(t)>-1||this._data.push(t)}delete(t){const n=this._data.indexOf(t);this._data.splice(n,1)}getData(){return this._data}}class ii{constructor(){R(this,"_data",new Map)}static create(){return new ii}add(t,n){this._data.has(t)||this._data.set(t,n)}delete(t){this._data.delete(t)}getData(){return this._data}}function dp(e){const t=new MessageChannel;let n=!1;const r=()=>{n||e()};return t.port1.onmessage=r,t.port2.postMessage(null),()=>{n=!0,t.port1.onmessage=null,t.port1.close(),t.port2.close()}}function fp(e,t){return t.forEach(n=>e.add(n)),e}function gp(e,t,n,r){var u;if(t==="")return e;const s={id:"mock-id",body:e,documentStyle:{}},i=new yt(s),o=t.length;let a;for(;(a=(r?i.getBody().dataStream:i.getBody().dataStream.toLowerCase()).indexOf(t))>=0;){const c=new ze,h=xt.getInstance();if(a>0&&c.retain(a),n.length>0){const f=i.sliceBody(a,a+o),g={dataStream:n};if(Array.isArray(f==null?void 0:f.textRuns)&&f.textRuns.length&&(g.textRuns=[{...f.textRuns[0],st:0,ed:n.length}]),(u=f==null?void 0:f.customRanges)!=null&&u.length){const C=f.customRanges[0];g.customRanges=[{...C,startIndex:0,endIndex:n.length-1}]}c.insert(n.length,g)}c.delete(o),i.apply(h.editOp(c.serialize()))}const l=i.getBody();return i.dispose(),l}const mp="__default_document_sub_component_id20231101__";class Jl{constructor(){R(this,"skipNextObservers",!1);R(this,"lastReturnValue");R(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class _p extends Ie.Subject{constructor(){super(...arguments);R(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 Jl;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 pp(e){return new Ie.Observable(t=>{const n=e.subscribeEvent(r=>{t.next(r)});return()=>n.unsubscribe()})}const ns=We.createIdentifier("core.resource-manager.service"),oi={[Nt.Editor]:"Editor",[Nt.Owner]:"Owner",[Nt.Reader]:"Reader",[Nt.UNRECOGNIZED]:"UNRECOGNIZED"},rs=e=>e?{userID:`${oi[e]}_${re.generateRandomId(8)}`,name:oi[e],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},Ep=(e,t)=>e.startsWith(oi[t]);class ir{constructor(){R(this,"_model",new Map);R(this,"_userChange$",new Ie.Subject);R(this,"userChange$",this._userChange$.asObservable());R(this,"_currentUser$",new Ie.BehaviorSubject(rs()));R(this,"currentUser$",this._currentUser$.asObservable())}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(t){this.addUser(t),this._currentUser$.next(t)}addUser(t){this._model.set(t.userID,t),this._userChange$.next({type:"add",user:t})}getUser(t,n){const r=this._model.get(t);if(r)return r;n&&n()}delete(t){const n=this.getUser(t);this._model.delete(t),n&&this._userChange$.next({type:"delete",user:n})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}list(){return Array.from(this._model.values())}}var Cp=Object.getOwnPropertyDescriptor,Rp=(e,t,n,r)=>{for(var s=r>1?void 0:r?Cp(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Zl=(e,t)=>(n,r)=>t(n,r,e);d.AuthzIoLocalService=class{constructor(t,n){R(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(rs(Nt.Owner))}_getRole(t){const n=this._userManagerService.getCurrentUser();return n?Ep(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:[Be.UNIVER_SHEET,Be.UNIVER_DOC,Be.UNIVER_SLIDE],onLoad:(t,n)=>{for(const r in n)this._permissionMap.set(r,n[r])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(t){return kt(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:Nt.Owner,shareScope:-1,scope:{read:Vs.AllCollaborator,edit:Vs.AllCollaborator},creator:rs(Nt.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(Nt.Owner)||this._getRole(Nt.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){}},d.AuthzIoLocalService=Rp([Zl(0,ns),Zl(1,We.Inject(ir))],d.AuthzIoLocalService);const Ql=We.createIdentifier("IAuthzIoIoService");var Ip=Object.getOwnPropertyDescriptor,Sp=(e,t,n,r)=>{for(var s=r>1?void 0:r?Ip(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},vp=(e,t)=>(n,r)=>t(n,r,e);d.MentionIOLocalService=class{constructor(t){this._userManagerService=t}async list(t){return{list:[{type:pr.PERSON,mentions:[{objectType:pr.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}}},d.MentionIOLocalService=Sp([vp(0,We.Inject(ir))],d.MentionIOLocalService);const eu=We.createIdentifier("univer.service.mention-io"),ai=We.createIdentifier("univer.config-service");class tu{constructor(){R(this,"_configChanged$",new Ie.Subject);R(this,"configChanged$",this._configChanged$.asObservable());R(this,"_config",new Map)}dispose(){this._configChanged$.complete()}getConfig(t){return this._config.get(t)}setConfig(t,n,r){var o;const{merge:s=!1}=r||{};let i=(o=this._config.get(t))!=null?o:{};s?i=js(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 Ie.Observable(n=>{Object.prototype.hasOwnProperty.call(this._config,t)&&n.next(this._config.get(t));const r=this.configChanged$.pipe(Ie.filter(s=>Object.prototype.hasOwnProperty.call(s,t))).subscribe(s=>n.next(s[t]));return()=>r.unsubscribe()})}}const or="FOCUSING_UNIT",yn="FOCUSING_SHEET",ar="FOCUSING_DOC",lr="FOCUSING_SLIDE",Op="FOCUSING_EDITOR_BUT_HIDDEN",nu="EDITOR_ACTIVATED",wp="FOCUSING_EDITOR_INPUT_FORMULA",ru="FOCUSING_FX_BAR_EDITOR",bp="FOCUSING_UNIVER_EDITOR",yp="FOCUSING_EDITOR_INPUT_FORMULA",Ap="FOCUSING_PANEL_EDITOR",Tp="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",Np="FOCUSING_COMMON_DRAWINGS",Mp="FORMULA_EDITOR_ACTIVATED";class su extends st{constructor(){super(...arguments);R(this,"_error$",new Ie.Subject);R(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(n){this._error$.next({errorKey:n})}}const Dp={version:"0.6.6"};function Lp(e="",t=$n.ZH_CN,n=""){return{id:e,sheetOrder:[],name:n,appVersion:Dp.version,locale:t,styles:{},sheets:{},resources:[]}}class iu{constructor(t={}){R(this,"_styles");R(this,"_cacheMap",new Hn(1e5));this._styles=t,this._generateCacheMap()}each(t){return Object.entries(this._styles).forEach(t),this}search(t,n){if(this._cacheMap.has(n))return this._cacheMap.get(n);const r=this._getExistingStyleId(t);return r||"-1"}get(t){return typeof t!="string"?t:(t=String(t),this._styles[t])}add(t,n){const r=re.generateRandomId(6);return this._styles[r]=t,this._cacheMap.set(n,r),r}setValue(t){if(t==null)return;const n=JSON.stringify(t),r=this.search(t,n);return r!=="-1"?r:this.add(t,n)}toJSON(){return this._styles}getStyleByCell(t){let n;t&&re.isObject(t.s)?n=t.s:n=(t==null?void 0:t.s)&&this.get(t.s);const r=t==null?void 0:t.interceptorStyle;return r?{...n,...r}:n}_generateCacheMap(){const{_styles:t,_cacheMap:n}=this;for(const r in t){const s=JSON.stringify(t[r]);n.set(s,r)}}_getExistingStyleId(t){const{_styles:n}=this;for(const r in n)if(re.diffValue(n[r],t))return r;return null}}const Up=(e,t)=>t.length===e.length&&!e.some(n=>t.some(r=>!Yt.equals(r,n))),kp=(e,t)=>t.length===e.length&&e.every((n,r)=>{const s=t[r];return s.unitId===n.unitId&&s.sheetId===n.sheetId&&Yt.equals(n.range,s.range)}),li={t:0,b:2,l:2,r:2},Pp=e=>({sbr:.6,sbo:e,spr:.6,spo:e}),ou=90;function ur(e,t,n={}){const r=e.length,{textRotation:s,paddingData:i,horizontalAlign:o=St.UNSPECIFIED,verticalAlign:a=en.UNSPECIFIED,wrapStrategy:l=tn.UNSPECIFIED,cellValueType:u}=n,{t:c,r:h,b:f,l:g}=i||li,{vertexAngle:C,centerAngle:I}=hu(s),b={id:"d",body:{dataStream:`${e}${Do}`,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:c,marginBottom:f,marginRight:h,marginLeft:g,renderConfig:{horizontalAlign:o,verticalAlign:a,centerAngle:I,vertexAngle:C,wrapStrategy:l,cellValueType:u,zeroWidthParagraphBreak:1}},drawings:{},drawingsOrder:[]};return new yt(b)}function Fp(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 au(e){if(!e)return{};const{ff:t,fs:n,it:r,bl:s,ul:i,st:o,ol:a,cl:l}=e,u={};return t&&(u.ff=t),n&&(u.fs=n),r&&(u.it=r),s&&(u.bl=s),i&&(u.ul=i),o&&(u.st=o),a&&(u.ol=a),l&&(u.cl=l),u}function lu(e,t,n){var i;const r=e.getBody();if((i=r.customRanges)!=null&&i.some(o=>o.rangeType===zt.HYPERLINK))return;const s=ot.customRange.add({ranges:[{startOffset:0,endOffset:r.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:zt.HYPERLINK,body:r,properties:{url:t,refId:n}});s&&ze.apply(r,s.serialize())}function uu(e){return e!=null}const xp='"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';function cu(e){const t=lt.ff,n=lt.fs;if(!e){const h=`${n}pt ${t}`;return{fontCache:h,fontString:h,fontSize:n,originFontSize:n,fontFamily:t}}let r=pn.ITALIC;(e.it===0||e.it===void 0)&&(r=pn.NORMAL);let s=pn.BOLD;(e.bl===0||e.bl===void 0)&&(s=pn.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===Ut.SUBSCRIPT||a===Ut.SUPERSCRIPT){const h=$p(o,l),{sbr:f,spr:g}=h;l*=a===Ut.SUBSCRIPT?f:g}const u=`${r} ${s} ${l}pt ${o}`,c=`${u}, ${xp} `;return{fontCache:u,fontString:c,fontSize:l,originFontSize:i,fontFamily:o}}function $p(e,t){return Pp(t)}function hu(e){const{a:t=0,v:n=ve.FALSE}=e||{a:0,v:ve.FALSE};let r=0,s=t;return n===ve.TRUE&&(r=ou,s=ou),{centerAngle:r,vertexAngle:s}}class Bp{constructor(t,n){R(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!==ve.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:Le.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:Le.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:Le.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:Le.COLUMN}),r}getColumnDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getColumnOrCreate(i);r[s]=o,s++}return r}getSize(){return jt(this._columnData)}getColumnWidth(t){const{_columnData:n}=this,r=this._config;let s=0;return s=(n[t]||{hd:ve.FALSE,w:r.defaultColumnWidth}).w||r.defaultColumnWidth,s}getColumn(t){const n=this._columnData[t];if(n)return n}removeColumn(t){delete this._columnData[t]}getColumnOrCreate(t){const{_columnData:n}=this,r=n[t];if(r)return r;const s={};return this._columnData[t]=s,s}setCustomMetadata(t,n){const r=this.getColumn(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getColumn(t))==null?void 0:n.custom}}class Hp{constructor(t,n,r){R(this,"_rowData");this._config=t,this._viewModel=n,this._rowData=r}getRowData(){return this._rowData}getRowStyle(t){var n;return(n=this._rowData[t])==null?void 0:n.s}setRowStyle(t,n){const r=this.getRowOrCreate(t);r.s=n}getRowDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getRowOrCreate(i);r[s]=o,s++}return r}getRowHeight(t,n=1){const{_rowData:r}=this,s=this._config;let i=0;for(let o=0;o<n;o++){const a=r[o+t]||{hd:ve.FALSE,h:s.defaultRowHeight},{ia:l,ah:u,h:c=s.defaultRowHeight}=a;i+=(l==null||l===ve.TRUE)&&typeof u=="number"?u:c}return i}getRow(t){return this._rowData[t]}removeRow(t){delete this._rowData[t]}getRowOrCreate(t){const{_rowData:n}=this,r=n[t];if(r)return r;const s={};return n[t]=s,s}getHiddenRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:Le.ROW})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:Le.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:Le.ROW})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:Le.ROW}),r}getRowRawVisible(t){const n=this.getRow(t);return n?n.hd!==ve.TRUE:!0}getSize(){return jt(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 Wp="DEFAULT_WORKSHEET_ROW_COUNT",du=1e3,jp="DEFAULT_WORKSHEET_COLUMN_COUNT",fu=20,Yp="DEFAULT_WORKSHEET_ROW_HEIGHT",gu=24,zp="DEFAULT_WORKSHEET_COLUMN_WIDTH",mu=88,Vp="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",_u=46,Gp="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",pu=20;function Eu(e){const t={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:ve.FALSE,rowCount:du,columnCount:fu,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:mu,defaultRowHeight:gu,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:ve.TRUE,rowHeader:{width:_u,hidden:ve.FALSE},columnHeader:{height:pu,hidden:ve.FALSE},rightToLeft:ve.FALSE};return Object.keys(t).forEach(n=>{const r=n;typeof e[r]>"u"&&(e[r]=t[r])}),e}class Kp extends st{constructor(n){super();R(this,"_cellCache",new Map);R(this,"_rowCache",new Map);R(this,"_columnCache",new Map);R(this,"_hasRow",!1);R(this,"_hasColumn",!1);R(this,"_hasAll",!1);R(this,"_allIndex",-1);R(this,"_mergeData");R(this,"_rangeMap",new Hn(5e4));R(this,"_skeletonCache",new Hn(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===Le.ROW?this._createRowCache(s,r):i===Le.COLUMN?this._createColumnCache(s,r):i===Le.ALL?this._createCellAllCache(r):this._createCellCache(s,r),r++}}rebuild(n){this._clearCache(),this._init(n.concat())}_createRowCache(n,r){const{startRow:s,endRow:i}=n;for(let o=s;o<=i;o++)this._rowCache.set(o,r),this._hasRow=!0}_createColumnCache(n,r){const{startColumn:s,endColumn:i}=n;for(let o=s;o<=i;o++)this._columnCache.set(o,r),this._hasColumn=!0}_createCellAllCache(n){this._hasAll=!0,this._allIndex=n}_createCellCache(n,r){for(let s=n.startRow;s<=n.endRow;s++){let i=this._cellCache.get(s);i==null&&(i=new Map,this._cellCache.set(s,i));for(let o=n.startColumn;o<=n.endColumn;o++)i.set(o,r)}}add(n){this._mergeData.push(n),this._clearCache(),this._createCache(this._mergeData)}remove(n,r){const s=this._getMergeDataIndex(n,r);s!==-1&&(this._mergeData.splice(s,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(n,r){const s=this._getMergeDataIndex(n,r);return s!==-1?this._mergeData[s]:null}getMergeDataIndex(n,r){return this._getMergeDataIndex(n,r)}isRowContainsMergedCell(n){return this._hasAll||!re.isEmptyObject(this._columnCache)?!0:this._mergeData.some(r=>r.startRow<=n&&n<=r.endRow)}isColumnContainsMergedCell(n){return this._hasAll||!re.isEmptyObject(this._rowCache)?!0:this._mergeData.some(r=>r.startColumn<=n&&n<=r.endColumn)}getMergedCellRange(n,r,s,i){const o=[],a=`${n}-${r}-${s}-${i}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let l=0;const u=[];for(const c of this._mergeData||[])Yt.intersects(c,{startRow:n,endRow:s,startColumn:r,endColumn:i})&&(o.push({...c}),u.push(l)),l++;return this._rangeMap.set(a,u),o}getMergedCellRangeForSkeleton(n,r,s,i){const o=[],a=this._mergeData,l=`${n}-${r}-${s}-${i}`;if(this._skeletonCache.has(l))return this._getSkeletonRangeFromCache(l);const u=[];for(let c=0;c<a.length;c++){const{startRow:h,endRow:f,startColumn:g,endColumn:C}=a[c];for(let I=n;I<=s;I++){let b=!1;for(let U=r;U<=i;U++)if(I>=h&&I<=f&&U>=g&&U<=C){o.push({startRow:h,endRow:f,startColumn:g,endColumn:C}),u.push(c),b=!0;break}if(b)break}}return this._skeletonCache.set(l,u),o}_getRangeFromCache(n){const r=this._rangeMap.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getSkeletonRangeFromCache(n){const r=this._skeletonCache.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getMergeDataIndex(n,r){var i;if(this._hasAll)return this._allIndex;if(this._hasRow){const o=this._rowCache.get(n);if(o!==void 0)return o}if(this._hasColumn){const o=this._columnCache.get(r);if(o!==void 0)return o}const s=(i=this._cellCache.get(n))==null?void 0:i.get(r);return s!==void 0?s:-1}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}}class Cu extends st{constructor(n){super();R(this,"_cellContentInterceptor",null);R(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,tt(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(n){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=n,tt(()=>this._rowFilteredInterceptor=null)}}const Ru={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};class cr{constructor(t,n,r){R(this,"_sheetId");R(this,"_snapshot");R(this,"_cellData");R(this,"_rowManager");R(this,"_columnManager");R(this,"_viewModel");R(this,"_spanModel");var a;this.unitId=t,this._styles=r,this._snapshot=Eu(n);const{columnData:s,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:re.generateRandomId(6),this._cellData=new Ot(o),this._viewModel=new Cu((l,u)=>this.getCellRaw(l,u)),this._rowManager=new Hp(this._snapshot,this._viewModel,i),this._columnManager=new Bp(this._snapshot,s),this._spanModel=new Kp(this._snapshot.mergeData)}__interceptViewModel(t){t(this._viewModel)}getSnapshot(){return this._snapshot}setMergeData(t){this._snapshot.mergeData=t,this.getSpanModel().rebuild(t)}getSpanModel(){return this._spanModel}getStyleDataByHash(t){return{...this._styles.get(t)}}setStyleData(t){return this._styles.setValue(t)}getColumnStyle(t,n=!1){return n?this._columnManager.getColumnStyle(t):this._styles.get(this._columnManager.getColumnStyle(t))}setColumnStyle(t,n){this._columnManager.setColumnStyle(t,n)}getRowStyle(t,n=!1){return n?this._rowManager.getRowStyle(t):this._styles.get(this._rowManager.getRowStyle(t))}setRowStyle(t,n){this._rowManager.setRowStyle(t,n)}mixinDefaultStyleToCellRaw(t,n,r,s){const i=this.getColumnStyle(n),o=this.getRowStyle(t),a=this.getDefaultCellStyleInternal();if(a||i||o){let l=r==null?void 0:r.s;typeof l=="string"&&(l=this._styles.get(l));const u=s?hs(a,i,o,l):hs(a,o,i,l);r||(r={}),r.s=u}}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){const t=this._snapshot.defaultStyle;return this._styles.get(t)}setDefaultCellStyle(t){this._snapshot.defaultStyle=t}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const t=this.getCellMatrix(),n=this.getMergeData();let r=-1,s=-1,i=-1,o=-1,a=!1,l=!1;return t.forEach((u,c)=>{Object.keys(c).forEach(h=>{const f=+h,g=t.getValue(u,f),C=g!=null&&g.s?this._styles.get(g.s):null,I=(C==null?void 0:C.bd)&&(C.bd.b||C.bd.l||C.bd.r||C.bd.t||C.bd.bc_tr||C.bd.bl_tr||C.bd.ml_tr||C.bd.tl_bc||C.bd.tl_br||C.bd.tl_mr);(g&&(g.v||g.p)||C!=null&&C.bg||I)&&(a?r=Math.min(r,u):(r=u,a=!0),s=Math.max(s,u),l?i=Math.min(i,f):(l=!0,i=f),o=Math.max(o,f))})}),n.forEach(u=>{a?r=Math.min(r,u.startRow):(r=u.startRow,a=!0),s=Math.max(s,u.endRow),l?i=Math.min(i,u.startColumn):(i=u.startColumn,a=!0),o=Math.max(o,u.endColumn)}),!a||!l?null:{startColumn:i,startRow:r,endColumn:o,endRow:s}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:t}=this,n=re.deepClone(t);return new cr(this.unitId,n,this._styles)}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(t,n){return this._spanModel.getMergedCell(t,n)}getMergedCellRange(t,n,r,s){return this._spanModel.getMergedCellRange(t,n,r,s)}isRowContainsMergedCell(t){return this._spanModel.isRowContainsMergedCell(t)}isColumnContainsMergedCell(t){return this._spanModel.isColumnContainsMergedCell(t)}getCellInfoInMergeData(t,n){const r=this.getMergedCell(t,n);let s=!1,i=!1,o=t,a=n,l=t,u=n;if(r){const{startRow:c,endRow:h,startColumn:f,endColumn:g}=r;t===c&&n===f?(o=h,a=g,l=c,u=f,i=!0):t>=c&&t<=h&&n>=f&&n<=g&&(o=h,a=g,l=c,u=f,s=!0)}return{actualRow:t,actualColumn:n,isMergedMainCell:i,isMerged:s,endRow:o,endColumn:a,startRow:l,startColumn:u}}getCell(t,n){return t<0||n<0?null:this._viewModel.getCell(t,n)}getCellValueOnly(t,n){return t<0||n<0?null:this._viewModel.getCellValueOnly(t,n)}getCellStyleOnly(t,n){return t<0||n<0?null:this._viewModel.getCellStyleOnly(t,n)}getCellRaw(t,n){return this.getCellMatrix().getValue(t,n)}getCellWithFilteredInterceptors(t,n,r,s){return this._viewModel.getCell(t,n,r,s)}getRowFiltered(t){return this._viewModel.getRowFiltered(t)}getMatrixWithMergedCells(t,n,r,s,i=fn.Raw){const o=this.getCellMatrix(),a=this._spanModel.getMergedCellRange(t,n,r,s),l=new Ot;return ys(t,r,n,s).forEach((u,c)=>{var f;let h;if(i===fn.Raw)h=this.getCellRaw(u,c);else if(i===fn.Intercepted)h=this.getCell(u,c);else if(i===fn.Both){const g=this.getCellRaw(u,c);if(g){h={...g};const C=(f=this.getCell(u,c))==null?void 0:f.v;uu(C)&&h&&(h.displayV=String(C))}}h&&l.setValue(u,c,h)}),a.forEach(u=>{const{startColumn:c,startRow:h,endColumn:f,endRow:g}=u;ys(h,g,c,f).forEach((C,I)=>{C===h&&I===c&&l.setValue(C,I,{...o.getValue(C,I),rowSpan:g-h+1,colSpan:f-c+1}),(C!==h||I!==c)&&l.realDeleteValue(C,I)})}),l}getRange(t,n,r,s){return typeof t=="object"?new gn(this,t,{getStyles:()=>this._styles}):new gn(this,{startRow:t,startColumn:n,endColumn:s||n,endRow:r||t},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:t}=this,{columnCount:n}=t;return n}getMaxRows(){const{_snapshot:t}=this,{rowCount:n}=t;return n}getRowCount(){return this._snapshot.rowCount}setRowCount(t){this._snapshot.rowCount=t}getColumnCount(){return this._snapshot.columnCount}setColumnCount(t){this._snapshot.columnCount=t}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:t}=this,{showGridlines:n}=t;return n===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){const{_snapshot:t}=this,{tabColor:n}=t;return n}getColumnWidth(t){return this.getColumnManager().getColumnWidth(t)}getRowHeight(t){return this._viewModel.getRowFiltered(t)?0:this.getRowManager().getRowHeight(t)}isRowFiltered(t){return this._viewModel.getRowFiltered(t)}getRowVisible(t){return!this.isRowFiltered(t)&&this.getRowRawVisible(t)}getRowRawVisible(t){return this.getRowManager().getRowRawVisible(t)}getHiddenRows(t,n){const r=this.getMaxColumns()-1,s=this._rowManager.getHiddenRows(t,n);return s.forEach(i=>i.endColumn=r),s}getColVisible(t){return this._columnManager.getColVisible(t)}getHiddenCols(t,n){const r=this.getMaxRows()-1,s=this._columnManager.getHiddenCols(t,n);return s.forEach(i=>i.endRow=r),s}getVisibleRows(){const t=this.getRowCount();return this._rowManager.getVisibleRows(0,t-1)}getVisibleCols(){const t=this.getColumnCount();return this._columnManager.getVisibleCols(0,t-1)}isRightToLeft(){const{_snapshot:t}=this,{rightToLeft:n}=t;return n}getLastRowWithContent(){return this._cellData.getLength()-1}getLastColumnWithContent(){return this._cellData.getRange().endColumn}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(t){return t&&(t.v!==void 0||t.f!==void 0||t.p!==void 0)}iterateByRow(t,n=!0){const{startRow:r,startColumn:s,endRow:i,endColumn:o}=t,a=this;return{[Symbol.iterator]:()=>{let l=r,u=s;return{next(){for(;;){if(u>o&&(l+=1,u=s),l>i)return{done:!0,value:void 0};const c=a.getCell(l,u),h=!c,f=a.getMergedCell(l,u);if(f){if(l!==f.startRow||u!==f.startColumn){u=f.endColumn+1;continue}if(h&&n){u=f.endColumn+1;continue}const C={row:l,col:u,value:c};return C.colSpan=f.endColumn-f.startColumn+1,C.rowSpan=f.endRow-f.startRow+1,u=f.endColumn+1,{done:!1,value:C}}if(h&&n)u+=1;else{const g={row:l,col:u,value:c};return u+=1,{done:!1,value:g}}}}}}}}iterateByColumn(t,n=!0,r=!0){const{startRow:s,startColumn:i,endRow:o,endColumn:a}=t,l=this;return{[Symbol.iterator]:()=>{let u=s,c=i;return{next(){for(;;){if(u>o&&(c+=1,u=s),c>a)return{done:!0,value:void 0};const h=l.getMergedCell(u,c);if(h){const C=u!==h.startRow,I=C||c!==h.startColumn;if(r&&I||!r&&C){u=h.endRow+1;continue}const b=l.getCell(h.startRow,h.startColumn);if(!b&&n){u=h.endRow+1;continue}const Z={row:u,col:h.startColumn,value:b};return Z.colSpan=h.endColumn-h.startColumn+1,Z.rowSpan=h.endRow-h.startRow+1,u=h.endRow+1,{done:!1,value:Z}}const f=l.getCell(u,c);if(!f&&n)u+=1;else{const C={row:u,col:c,value:f};return u+=1,{done:!1,value:C}}}}}}}}_getCellDocumentModel(t,n=Ru){var I;const{isDeepClone:r,displayRawFormula:s,ignoreTextRotation:i}={...Ru,...n},o=this._styles.getStyleByCell(t);if(!t)return;let a,l="document";const u=Fp(o),c=i?lt.tr:u.textRotation||lt.tr;let h=u.horizontalAlign||lt.ht;const f=u.verticalAlign||lt.vt,g=u.wrapStrategy||lt.tb,C=u.paddingData||li;if(t.f&&s)a=ur(t.f.toString(),{},{verticalAlign:f}),h=lt.ht;else if(t.p){const{centerAngle:b,vertexAngle:U}=hu(c);a=this._updateConfigAndGetDocumentModel(r?re.deepClone(t.p):t.p,h,C,{horizontalAlign:h,verticalAlign:f,centerAngle:b,vertexAngle:U,wrapStrategy:g,zeroWidthParagraphBreak:1})}else if(t.v!=null){const b=au(o);l=cu(b).fontCache;let U=Iu(t);t.t===Ht.FORCE_STRING&&s&&(U=`'${U}`),a=ur(U,b,{...u,textRotation:c,cellValueType:t.t})}return a&&t.linkUrl&&t.linkId&&lu(a,t.linkUrl,t.linkId),{documentModel:a,fontString:l,textRotation:c,wrapStrategy:g,verticalAlign:f,horizontalAlign:h,paddingData:C,fill:(I=o==null?void 0:o.bg)==null?void 0:I.rgb}}_updateConfigAndGetDocumentModel(t,n,r,s){var o,a,l,u,c;if(!s||!((o=t.body)!=null&&o.dataStream))return;t.documentStyle||(t.documentStyle={}),t.documentStyle.marginTop=(a=r.t)!=null?a:0,t.documentStyle.marginBottom=(l=r.b)!=null?l:2,t.documentStyle.marginLeft=(u=r.l)!=null?u:2,t.documentStyle.marginRight=(c=r.r)!=null?c: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 yt(t)}getBlankCellDocumentModel(t){const n=this._getCellDocumentModel(t,{ignoreTextRotation:!0}),r=this._styles.getStyleByCell(t),s=au(r);if(n!=null)return n.documentModel==null&&(n.documentModel=ur("",s)),n;const i="";let o="document";const a=lt.tr,l=lt.ht,u=lt.vt,c=lt.tb,h=li;return o=cu({}).fontCache,{documentModel:ur(i,s),fontString:o,textRotation:a,wrapStrategy:c,verticalAlign:u,horizontalAlign:l,paddingData:h}}getCellDocumentModelWithFormula(t){return this._getCellDocumentModel(t,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(t){this._snapshot.custom=t}}function Iu(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 ot.transform.getPlainText(t);const n=e.v;return typeof n=="string"?e.t===Ht.BOOLEAN?n.toUpperCase():n.replace(/[\r\n]/g,""):typeof n=="number"?e.t===Ht.BOOLEAN?n?"TRUE":"FALSE":n.toString():typeof n=="boolean"?n?"TRUE":"FALSE":""}function Xp(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 ot.transform.getPlainText(n)}return e==null?void 0:e.v}var qp=Object.getOwnPropertyDescriptor,Jp=(e,t,n,r)=>{for(var s=r>1?void 0:r?qp(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Zp=(e,t)=>(n,r)=>t(n,r,e);function Qp(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}d.Workbook=class extends Xr{constructor(n={},r){super();R(this,"type",Be.UNIVER_SHEET);R(this,"_sheetCreated$",new Ie.Subject);R(this,"sheetCreated$",this._sheetCreated$.asObservable());R(this,"_sheetDisposed$",new Ie.Subject);R(this,"sheetDisposed$",this._sheetDisposed$.asObservable());R(this,"_activeSheet$",new Ie.BehaviorSubject(null));R(this,"activeSheet$",this._activeSheet$.asObservable());R(this,"_worksheets");R(this,"_styles");R(this,"_snapshot");R(this,"_unitId");R(this,"_count");R(this,"_name$");R(this,"name$");this._logService=r;const s=Lp();re.isEmptyObject(n)?this._snapshot=s:this._snapshot=re.commonExtend(s,n);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=re.generateRandomId(6)),this._unitId=this._snapshot.id,this._styles=new iu(i),this._count=1,this._worksheets=new Map,this._name$=new Ie.BehaviorSubject(n.name||""),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(n){return typeof n=="string"||"startRow"in n||"row"in n}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete()}save(){return re.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(n){this._name$.next(n),this._snapshot.name=n}getUnitId(){return this._unitId}getRev(){var n;return(n=this._snapshot.rev)!=null?n:1}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(n){this._snapshot.rev=n}addWorksheet(n,r,s){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[n])return!1;i[n]=s,o.splice(r,0,n);const a=new cr(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()!==ve.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===ve.TRUE).map(n=>n.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden!==ve.TRUE).map(n=>n.getConfig().id)}load(n){this._snapshot=n}checkSheetName(n){return this.getSheetsName().includes(n)}uniqueSheetName(n="Sheet1"){let r=n;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}generateNewSheetName(n){let r=n+this._count;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}_parseWorksheetSnapshots(){const{_snapshot:n,_worksheets:r}=this,{sheets:s,sheetOrder:i}=n;if(re.isEmptyObject(s)){const o=re.generateRandomId();s[o]={id:o}}for(const o in s){const a=s[o],{name:l}=a;a.name=this.uniqueSheetName(l),a.name!==l&&this._logService.debug("[Workbook]",`The worksheet name ${l} is duplicated, we changed it to ${a.name}. Please fix the problem in your snapshot.`);const u=new cr(this._unitId,a,this._styles);r.set(o,u),i.includes(o)||i.push(o)}this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(n){this._snapshot.custom=n}},d.Workbook=Jp([Zp(1,It)],d.Workbook);class ui extends Xr{constructor(n){var r;super();R(this,"type",Be.UNIVER_SLIDE);R(this,"_activePage$",new Ie.BehaviorSubject(null));R(this,"activePage$",this._activePage$.asObservable());R(this,"_name$");R(this,"name$");R(this,"_snapshot");R(this,"_unitId");this._snapshot={...Po,...n},this._unitId=(r=this._snapshot.id)!=null?r:re.generateRandomId(6),this._name$=new Ie.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:kt(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=kt(6);return{id:n,pageType:Ts.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 eE=Object.getOwnPropertyDescriptor,tE=(e,t,n,r)=>{for(var s=r>1?void 0:r?eE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Su=(e,t)=>(n,r)=>t(n,r,e);const An=We.createIdentifier("univer.current");d.UniverInstanceService=class extends st{constructor(n,r){super();R(this,"_unitsByType",new Map);R(this,"_createHandler");R(this,"_ctorByType",new Map);R(this,"_currentUnits",new Map);R(this,"_currentUnits$",new Ie.BehaviorSubject(this._currentUnits));R(this,"currentUnits$",this._currentUnits$.asObservable());R(this,"_unitAdded$",new Ie.Subject);R(this,"unitAdded$",this._unitAdded$.asObservable());R(this,"_unitDisposed$",new Ie.Subject);R(this,"unitDisposed$",this._unitDisposed$.asObservable());R(this,"_focused$",new Ie.BehaviorSubject(null));R(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(Ie.map(r=>{var s;return(s=r.get(n))!=null?s:null}),Ie.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(Ie.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(Ie.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(Be.UNIVER_DOC)}getUniverDocInstance(n){return this.getUnit(n,Be.UNIVER_DOC)}getUniverSheetInstance(n){return this.getUnit(n,Be.UNIVER_SHEET)}getAllUnitsForType(n){var r;return(r=this._unitsByType.get(n))!=null?r:[]}changeDoc(n,r){const s=this.getAllUnitsForType(Be.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 d.Workbook?(this._contextService.setContextValue(or,!0),this._contextService.setContextValue(ar,!1),this._contextService.setContextValue(yn,!0),this._contextService.setContextValue(lr,!1),this.setCurrentUnitForType(n)):this.focused instanceof yt?(this._contextService.setContextValue(or,!0),this._contextService.setContextValue(ar,!0),this._contextService.setContextValue(yn,!1),this._contextService.setContextValue(lr,!1),this.setCurrentUnitForType(n)):this.focused instanceof ui?(this._contextService.setContextValue(or,!0),this._contextService.setContextValue(ar,!1),this._contextService.setContextValue(yn,!1),this._contextService.setContextValue(lr,!0),this.setCurrentUnitForType(n)):(this._contextService.setContextValue(or,!1),this._contextService.setContextValue(ar,!1),this._contextService.setContextValue(yn,!1),this._contextService.setContextValue(lr,!1))}getFocusedUnit(){return this.focused}getUnitType(n){const r=this._getUnitById(n);return r?r[1]:Be.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]}}},d.UniverInstanceService=tE([Su(0,We.Inject(We.Injector)),Su(1,dn)],d.UniverInstanceService);var Je=(e=>(e[e.Starting=0]="Starting",e[e.Ready=1]="Ready",e[e.Rendered=2]="Rendered",e[e.Steady=3]="Steady",e))(Je||{});const nE={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"};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},iE=(e,t)=>(n,r)=>t(n,r,e);d.LifecycleService=class extends st{constructor(n){super();R(this,"_lifecycle$",new Ie.BehaviorSubject(Je.Starting));R(this,"lifecycle$",this._lifecycle$.asObservable());R(this,"_lock",!1);this._logService=n,this._reportProgress(Je.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 Ie.firstValueFrom(this.lifecycle$.pipe(Ie.filter(r=>r>=n),us(r=>r===n),Ie.map(()=>{})))}subscribeWithPrevious(){return Ie.merge(vu(this.stage),this._lifecycle$.pipe(Ie.skip(1))).pipe(us(n=>n===Je.Steady))}_reportProgress(n){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${nE[n]}".`)}},d.LifecycleService=sE([iE(0,It)],d.LifecycleService);function vu(e){switch(e){case Je.Starting:return Ie.of(Je.Starting);case Je.Ready:return Ie.of(Je.Starting,Je.Ready);case Je.Rendered:return Ie.of(Je.Starting,Je.Ready,Je.Rendered);default:return Ie.of(Je.Starting,Je.Ready,Je.Rendered,Je.Steady)}}const oE=We.createIdentifier("ILocalStorageService");class cn extends st{constructor(){super();R(this,"_currentLocale$",new Ie.BehaviorSubject($n.ZH_CN));R(this,"currentLocale$",this._currentLocale$.asObservable());R(this,"_locales",null);R(this,"localeChanged$",new Ie.Subject);R(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(tt(()=>this.localeChanged$.complete()))}get _currentLocale(){return this._currentLocale$.value}load(n){var r;this._locales=js((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 ci=(e=>(e.INIT="init",e.FETCHING="fetching",e.DONE="done",e))(ci||{});const Ou=We.createIdentifier("univer.permission-service");class wu extends st{constructor(){super(...arguments);R(this,"_permissionPointMap",new Map);R(this,"_permissionPointUpdate$",new Ie.Subject);R(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable());R(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 Ie.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 Ie.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=ci.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 Ie.combineLatest(r).pipe(Lt.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}}var aE=Object.getOwnPropertyDescriptor,lE=(e,t,n,r)=>{for(var s=r>1?void 0:r?aE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},hi=(e,t)=>(n,r)=>t(n,r,e);const uE=4,bu=Symbol("DependentOn");class di extends st{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}R(di,"pluginName"),R(di,"type",Be.UNIVER_UNKNOWN);class cE{constructor(){R(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 hE(...e){return function(t){t[bu]=e}}d.PluginService=class{constructor(t,n,r){R(this,"_pluginRegistry",new Map);R(this,"_pluginStore",new cE);R(this,"_seenPlugins",new Set);R(this,"_loadedPlugins",new Set);R(this,"_loadedPluginTypes",new Set([Be.UNIVER_UNKNOWN]));R(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===Be.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===Be.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)},uE))}_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 u=a[bu];u&&u.forEach(c=>{const h=this._pluginRegistry.get(c.pluginName);if(h)s(h);else if(!this._seenPlugins.has(c.pluginName)&&!r.has(c.pluginName)){if(a.type===Be.UNIVER_UNKNOWN&&c.type!==Be.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 ${c.pluginName}.`);a.type!==c.type&&c.type!==Be.UNIVER_UNKNOWN&&this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${c.pluginName}" which has different type.`),this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${c.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(c),s({plugin:c,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(vu(n).subscribe(r=>this._runStage(t,r)),n!==Je.Steady){const r=this._lifecycleService.lifecycle$.pipe(Ie.skip(1)).subscribe(s=>{this._runStage(t,s),s===Je.Steady&&r.unsubscribe()})}}_runStage(t,n){t.forEach(r=>{switch(n){case Je.Starting:r.onStarting();break;case Je.Ready:r.onReady();break;case Je.Rendered:r.onRendered();break;case Je.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}},d.PluginService=lE([hi(0,We.Inject(We.Injector)),hi(1,We.Inject(d.LifecycleService)),hi(2,It)],d.PluginService);function yu(e,t){if(!t)return e;const n=[];for(const r of e){const s=t.find(([i])=>i===r[0]);if(s){if(s[1]===null)continue;n.push([r[0],s[1]])}else n.push(r)}return n}const fi=We.createIdentifier("resource-loader-service");class Au extends st{constructor(){super(...arguments);R(this,"_resourceMap",new Map);R(this,"_register$",new Ie.Subject);R(this,"register$",this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(n,r){return r?this.getResourcesByType(n,r):this.getAllResourceHooks().map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}getResourcesByType(n,r){return this.getAllResourceHooks().filter(o=>o.businesses.includes(r)).map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}registerPluginResource(n){const r=n.pluginName;if(this._resourceMap.has(r))throw new Error(`the pluginName is registered {${r}}`);return this._resourceMap.set(r,n),this._register$.next(n),tt(()=>this._resourceMap.delete(r))}disposePluginResource(n){this._resourceMap.delete(n)}loadResources(n,r){this.getAllResourceHooks().forEach(s=>{var o;const i=(o=r==null?void 0:r.find(a=>a.name===s.pluginName))==null?void 0:o.data;if(i)try{const a=s.parseJson(i);s.onLoad(n,a)}catch{console.error("LoadResources Error!")}})}unloadResources(n){this.getAllResourceHooks().forEach(r=>{r.onUnLoad(n)})}dispose(){this._register$.complete(),this._resourceMap.clear()}}class gi extends st{constructor(){super();R(this,"_currentTheme");R(this,"_currentTheme$",new Ie.BehaviorSubject({}));R(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(tt(()=>this._currentTheme$.complete()))}getCurrentTheme(){if(!this._currentTheme)throw new Error("[ThemeService]: current theme is not set!");return this._currentTheme}setTheme(n){this._currentTheme=n,this._currentTheme$.next(n)}}var dE=Object.getOwnPropertyDescriptor,fE=(e,t,n,r)=>{for(var s=r>1?void 0:r?dE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},mi=(e,t)=>(n,r)=>t(n,r,e);const ss=We.createIdentifier("univer.undo-redo.service"),gE=20;class Tu{dispose(){}async dispatchToHandlers(){return!1}}const Nu="univer.command.redo",Mu="univer.command.undo",Du=new class extends Tu{constructor(){super(...arguments);R(this,"type",kn.COMMAND);R(this,"id",Mu)}handler(t){const n=t.get(ss),r=n.pitchTopUndoElement();if(!r)return!1;const s=t.get(Pn);return _r(r.undoMutations,s)?(n.popUndoToRedo(),!0):!1}},Lu=new class extends Tu{constructor(){super(...arguments);R(this,"type",kn.COMMAND);R(this,"id",Nu)}handler(t){const n=t.get(ss),r=n.pitchTopRedoElement();if(!r)return!1;const s=t.get(Pn);return _r(r.redoMutations,s)?(n.popRedoToUndo(),!0):!1}};d.LocalUndoRedoService=class extends st{constructor(n,r,s){super();R(this,"undoRedoStatus$");R(this,"_undoRedoStatus$",new Ie.BehaviorSubject({undos:0,redos:0}));R(this,"_undoStacks",new Map);R(this,"_redoStacks",new Map);R(this,"_batchingStatus",new Map);this._univerInstanceService=n,this._commandService=r,this._contextService=s,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(Du)),this.disposeWithMe(this._commandService.registerCommand(Lu)),this.disposeWithMe(tt(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(tt(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>gE&&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(),_r(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),tt(()=>this._batchingStatus.delete(n))}_updateStatus(){var i,o;const n=this._getFocusedUnitId(),r=n&&((i=this._undoStacks.get(n))==null?void 0:i.length)||0,s=n&&((o=this._redoStacks.get(n))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:r,redos:s})}_getUndoStack(n,r=!1){let s=this._undoStacks.get(n);return!s&&r&&(s=[],this._undoStacks.set(n,s)),s||null}_getRedoStack(n,r=!1){let s=this._redoStacks.get(n);return!s&&r&&(s=[],this._redoStacks.set(n,s)),s||null}_getUndoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getUndoStack(n,!0)}_getRedoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getRedoStack(n,!0)}_tryBatchingElements(n,r){n.redoMutations.push(...r.redoMutations),n.undoMutations.push(...r.undoMutations)}_getFocusedUnitId(){var o,a,l,u;let n="";const r=this._contextService.getContextValue(yn),s=this._contextService.getContextValue(ru),i=this._contextService.getContextValue(nu);return r?s?n=vs:i?n=Ss:n=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":n=(u=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?u:"",n}},d.LocalUndoRedoService=fE([mi(0,An),mi(1,Pn),mi(2,dn)],d.LocalUndoRedoService);function mE(e){return!(e.length===0||e.length>31||e.startsWith("'")||e.endsWith("'")||/[:\\\/\?\*\[\]]/.test(e))}function _E(e){return new Promise(t=>setTimeout(t,e))}function pE(e=1){return new Promise(t=>{let n=0;const r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}var _i=(e=>(e.URL="URL",e.UUID="UUID",e.BASE64="BASE64",e))(_i||{}),Uu=(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))(Uu||{});const pi=We.createIdentifier("core.image-io.service");class ku{constructor(t,n=100){R(this,"_imageCacheMap");this._injector=t,this._imageCacheMap=new Hn(n)}_getImageCacheKey(t,n){return`${t}-${n}`}getImage(t,n,r,s){const i=this._getImageCacheKey(t,n);let o=this._imageCacheMap.get(i);return o||((async()=>{o=new Image;const a=this._injector.has(pi)?this._injector.get(pi):null;if(t===_i.UUID)try{o.src=await(a==null?void 0:a.getImage(n))||""}catch(l){console.error(l)}else o.src=n;o.onload=()=>{r==null||r()},o.onerror=()=>{s==null||s()},this._imageCacheMap.set(i,o)})(),null)}}const EE=["script","style","meta","comment","link"];var Pu=(e=>(e[e.INFO=0]="INFO",e[e.STOP=1]="STOP",e[e.WARNING=2]="WARNING",e))(Pu||{}),Fu=(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))(Fu||{}),xu=(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))(xu||{}),$u=(e=>(e[e.TEXT=0]="TEXT",e[e.ARROW=1]="ARROW",e[e.CUSTOM=2]="CUSTOM",e))($u||{}),Bu=(e=>(e.VALID="valid",e.INVALID="invalid",e.VALIDATING="validating",e))(Bu||{}),Hu=(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))(Hu||{}),CE=Object.getOwnPropertyDescriptor,RE=(e,t,n,r)=>{for(var s=r>1?void 0:r?CE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},IE=(e,t)=>(n,r)=>t(n,r,e);d.Skeleton=class extends st{constructor(n){super();R(this,"_fontLocale");R(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(){}},d.Skeleton=RE([IE(0,We.Inject(cn))],d.Skeleton);var SE=Object.getOwnPropertyDescriptor,vE=(e,t,n,r)=>{for(var s=r>1?void 0:r?SE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},is=(e,t)=>(n,r)=>t(n,r,e);d.SheetSkeleton=class extends d.Skeleton{constructor(n,r,s,i,o,a){super(s);R(this,"_worksheetData");R(this,"_renderRawFormula",!1);R(this,"_cellData");R(this,"_imageCacheMap");R(this,"_isRowStylePrecedeColumnStyle",!1);R(this,"_skipAutoHeightForMergedCells",!0);R(this,"_rowTotalHeight",0);R(this,"_columnTotalWidth",0);R(this,"_rowHeaderWidth",0);R(this,"_columnHeaderHeight",0);R(this,"_rowHeightAccumulation",[]);R(this,"_columnWidthAccumulation",[]);R(this,"_marginTop",0);R(this,"_marginLeft",0);R(this,"_scaleX");R(this,"_scaleY");R(this,"_scrollX");R(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 ku(this._injector),this.initConfig()}initConfig(){var n,r;this._skipAutoHeightForMergedCells=!((n=this._configService.getConfig(Uo))!=null&&n),this._isRowStylePrecedeColumnStyle=(r=this._configService.getConfig(Lo))!=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){re.isDefine(n)&&(this._scrollX=n),re.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 u=s;if(this.worksheet.getRowFiltered(l))u=0;else if(a[l]!=null){const c=a[l];if(!c)continue;const{h=s,ah:f,ia:g}=c;(g==null||g===ve.TRUE)&&typeof f=="number"?u=f:u=h,c.hd===ve.TRUE&&(u=0)}i+=u,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 u=s;if(a[l]!=null){const c=a[l];if(!c)continue;c.w!=null&&(u=c.w),c.hd===ve.TRUE&&(u=0)}i+=u,o.push(i)}return{columnTotalWidth:i,columnWidthAccumulation:o}}intersectMergeRange(n,r){return!!this.worksheet.getMergedCell(n,r)}_getOverflowBound(n,r,s,i,o=St.LEFT){let a=0;if(r>s){const l=this._columnWidthAccumulation.length-1;for(let u=r;u>=s;u--){const c=u,h=this.worksheet.getCell(n,c);if(!_s(h)&&c!==r||this.intersectMergeRange(n,c))return c===r?c:c+1>l?l:c+1;const{startX:f,endX:g}=Tn(n,c,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===St.CENTER&&c===r?a+=(g-f)/2:a+=g-f,i<a)return c}return r}for(let l=r;l<=s;l++){const u=l,c=this.worksheet.getCell(n,u);if(!_s(c)&&u!==r||this.intersectMergeRange(n,u))return u===r?u:u-1<0?0:u-1;const{startX:h,endX:f}=Tn(n,u,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===St.CENTER&&u===r?a+=(f-h)/2:a+=f-h,i<a)return u}return s}_updateLayout(){if(!this.dirty)return;const{rowData:n,columnData:r,defaultRowHeight:s,defaultColumnWidth:i,rowCount:o,columnCount:a,rowHeader:l,columnHeader:u}=this._worksheetData,{rowTotalHeight:c,rowHeightAccumulation:h}=this._generateRowMatrixCache(o,n,s),{columnTotalWidth:f,columnWidthAccumulation:g}=this._generateColumnMatrixCache(a,r,i);this._rowHeaderWidth=l.hidden!==ve.TRUE?this._dynamicallyUpdateRowHeaderWidth(l):0,this._columnHeaderHeight=u.hidden!==ve.TRUE?u.height:0,this._rowTotalHeight=c,this._rowHeightAccumulation=h,this._columnTotalWidth=f,this._columnWidthAccumulation=g,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 u=new Ot;for(;l;){l=!1;for(let c=0;c<a.length;c++){const{startRow:h,startColumn:f,endRow:g,endColumn:C}=a[c];if(u.getValue(h,f))continue;Ho({startColumn:s,startRow:r,endColumn:o,endRow:i},{startColumn:f,startRow:h,endColumn:C,endRow:g})&&(r=Math.min(r,h),s=Math.min(s,f),i=Math.max(i,g),o=Math.max(o,C),u.setValue(h,f,!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:u,endY:c,startX:h,endX:f}=Tn(n,r,i,o);return s&&(u+=l,c+=l,h+=a,f+=a),{startY:u,endY:c,startX:h,endX:f}}getNoMergeCellPositionByIndexWithNoHeader(n,r){const{rowHeightAccumulation:s,columnWidthAccumulation:i}=this,{startY:o,endY:a,startX:l,endX:u}=Tn(n,r,s,i);return{startY:o,endY:a,startX:l,endX:u}}getRowIndexByOffsetY(n,r,s,i){var l;const{rowHeightAccumulation:o}=this;n=ju(n,r,s,this.columnHeaderHeightAndMarginTop);let a=Fn(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 u;const o=Wu(n,r,s,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this;let l=Fn(a,o,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(a[l]-o)<Math.abs(o-((u=a[l-1])!=null?u:0))&&(l=l+1),l}getCellIndexByOffset(n,r,s,i,o,a){const l=this.getRowIndexByOffsetY(r,i,o,a),u=this.getColumnIndexByOffsetX(n,s,o,a);return{row:l,column:u}}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,u=Tn(n,r,i,o,this.worksheet.getCellInfoInMergeData(n,r)),{isMerged:c,isMergedMainCell:h}=u;let{startY:f,endY:g,startX:C,endX:I,mergeInfo:b}=u,U=a,Z=l;return s===!1&&(U=0,Z=0),f+=Z,g+=Z,C+=U,I+=U,b.startY+=Z,b.endY+=Z,b.startX+=U,b.endX+=U,{actualRow:n,actualColumn:r,startX:C,startY:f,endX:I,endY:g,isMerged:c,isMergedMainCell:h,mergeInfo:b}}getCellWithCoordByOffset(n,r,s,i,o,a){const{row:l,column:u}=this.getCellIndexByOffset(n,r,s,i,o,a);return this.getCellWithCoordByIndex(l,u)}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=Fn(this.columnWidthAccumulation,n);let i=0;s===0?i=n:i=n-this._columnWidthAccumulation[s-1];const o=Fn(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,u,c,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=(u=s.b)!=null?u:2,n.documentStyle.marginLeft=(c=s.l)!=null?c: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 f of o)f.paragraphStyle||(f.paragraphStyle={}),f.paragraphStyle.horizontalAlign=r;return new yt(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}},d.SheetSkeleton=vE([is(2,We.Inject(cn)),is(3,dn),is(4,ai),is(5,We.Inject(We.Injector))],d.SheetSkeleton);function Ei(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 u=r[t];return u==null&&(u=r[r.length-1]),{startY:o,endY:a,startX:l,endX:u}}function OE(e,t,n,r){return Ei(e,t,n,r)}function Tn(e,t,n,r,s){e=re.clamp(e,0,n.length-1),t=re.clamp(t,0,r.length-1);let{startY:i,endY:o,startX:a,endX:l}=Ei(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:u,isMergedMainCell:c,startRow:h,startColumn:f,endRow:g,endColumn:C}=s;let I={startRow:h,startColumn:f,endRow:g,endColumn:C,startY:i,endY:o,startX:a,endX:l};const b=n.length-1,U=r.length-1;if(u&&h!==-1&&f!==-1){const Z=n[h-1]||0,V=n[g]||n[b],fe=r[f-1]||0,M=r[C]||r[U];I={...I,startY:Z,endY:V,startX:fe,endX:M}}else if(!u&&g!==-1&&C!==-1){const Z=n[g]||n[b],V=r[C]||r[U];I={...I,startY:i,endY:Z,startX:a,endX:V}}return{isMerged:u,isMergedMainCell:c,actualRow:e,actualColumn:t,startY:i,endY:o,startX:a,endX:l,mergeInfo:I}}function Wu(e,t,n,r){const{x:s}=n;return e/t+s-r}function ju(e,t,n,r){const{y:s}=n;return e=e/t+s-r,e}const Yu=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],Ci=1,hr=8;class Ri{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!==Ci)throw new Error(`Got v${s} data when expected v${Ci}.`);const i=Yu[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 Ri(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=Yu.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,hr,t),this.coords=new this.ArrayType(this.data,hr+a+l,t*2),this._pos=t*2,this._finished=!0):(this.data=new ArrayBuffer(hr+o+a+l),this.ids=new this.IndexArrayType(this.data,hr,t),this.coords=new this.ArrayType(this.data,hr+a+l,t*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(Ci<<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 Ii(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,n,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:o,nodeSize:a}=this,l=[0,i.length-1,0],u=[];for(;l.length;){const c=l.pop()||0,h=l.pop()||0,f=l.pop()||0;if(h-f<=a){for(let b=f;b<=h;b++){const U=o[2*b],Z=o[2*b+1];U>=t&&U<=r&&Z>=n&&Z<=s&&u.push(i[b])}continue}const g=f+h>>1,C=o[2*g],I=o[2*g+1];C>=t&&C<=r&&I>=n&&I<=s&&u.push(i[g]),(c===0?t<=C:n<=I)&&(l.push(f),l.push(g-1),l.push(1-c)),(c===0?r>=C:s>=I)&&(l.push(g+1),l.push(h),l.push(1-c))}return u}within(t,n,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:i,nodeSize:o}=this,a=[0,s.length-1,0],l=[],u=r*r;for(;a.length;){const c=a.pop()||0,h=a.pop()||0,f=a.pop()||0;if(h-f<=o){for(let b=f;b<=h;b++)Vu(i[2*b],i[2*b+1],t,n)<=u&&l.push(s[b]);continue}const g=f+h>>1,C=i[2*g],I=i[2*g+1];Vu(C,I,t,n)<=u&&l.push(s[g]),(c===0?t-r<=C:n-r<=I)&&(a.push(f),a.push(g-1),a.push(1-c)),(c===0?t+r>=C:n+r>=I)&&(a.push(g+1),a.push(h),a.push(1-c))}return l}}function Ii(e,t,n,r,s,i){if(s-r<=n)return;const o=r+s>>1;zu(e,t,o,r,s,i),Ii(e,t,n,r,o-1,1-i),Ii(e,t,n,o+1,s,1-i)}function zu(e,t,n,r,s,i){for(;s>r;){if(s-r>600){const u=s-r+1,c=n-r+1,h=Math.log(u),f=.5*Math.exp(2*h/3),g=.5*Math.sqrt(h*f*(u-f)/u)*(c-u/2<0?-1:1),C=Math.max(r,Math.floor(n-c*f/u+g)),I=Math.min(s,Math.floor(n+(u-c)*f/u+g));zu(e,t,n,C,I,i)}const o=t[2*n+i];let a=r,l=s;for(dr(e,t,r,n),t[2*s+i]>o&&dr(e,t,r,s);a<l;){for(dr(e,t,a,l),a++,l--;t[2*a+i]<o;)a++;for(;t[2*l+i]>o;)l--}t[2*r+i]===o?dr(e,t,r,l):(l++,dr(e,t,l,s)),l<=n&&(r=l+1),n<=l&&(s=l-1)}}function dr(e,t,n,r){Si(e,n,r),Si(t,2*n,2*r),Si(t,2*n+1,2*r+1)}function Si(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function Vu(e,t,n,r){const s=e-n,i=t-r;return s*s+i*i}class wE{constructor(t=!1){R(this,"_tree",new Map);R(this,"_oneCellCache",new Map);R(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 $r),this._tree.get(t).get(n)}_getOneCellCache(t,n,r,s){return this._oneCellCache.has(t)||this._oneCellCache.set(t,new Map),this._oneCellCache.get(t).has(n)||this._oneCellCache.get(t).set(n,new Map),this._oneCellCache.get(t).get(n).has(r)||this._oneCellCache.get(t).get(n).set(r,new Map),this._oneCellCache.get(t).get(n).get(r).has(s)||this._oneCellCache.get(t).get(n).get(r).set(s,new Set),this._oneCellCache.get(t).get(n).get(r).get(s)}_removeOneCellCache(t,n,r,s,i){const o=this._oneCellCache.get(t);if(!o)return;const a=o.get(n);if(!a)return;const l=a.get(r);if(!l)return;const u=l.get(s);u&&u.delete(i)}_removeCellCacheByRange(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this._oneCellCache.get(n);if(!o)return;const a=o.get(r);if(!a)return;const{startRow:l,startColumn:u,endRow:c,endColumn:h}=s;for(let f=l;f<=c;f++){const g=a.get(f);if(g)for(let C=u;C<=h;C++){const I=g.get(C);I&&I.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 C;const{unitId:n,sheetId:r,range:s}=t,{startRow:i,startColumn:o,endRow:a,endColumn:l}=s,u=(C=this._kdTree.get(n))==null?void 0:C.get(r);if(!u)return[];const{tree:c,items:h}=u,f=c.range(o,i,l,a),g=[];for(const I of f){const b=h[I];g.push(...Array.from(b.ids))}return g}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 Ri(o.length);(t=this._kdTree.get(n))==null||t.set(s,{tree:a,items:o});for(const l of o)a.add(l.x,l.y);a.finish()}}}closeKdTree(){var t;for(const[n,r]of this._oneCellCache)for(const[s,i]of r)(t=this._kdTree.get(n))==null||t.set(s,void 0)}insert(t){const{unitId:n,sheetId:r,range:s,id:i}=t;if(!n||n.length===0)return;let{startRow:o,endRow:a,startColumn:l,endColumn:u}=s;if(this._enableOneCellCache&&o===a&&l===u){this._insertOneCellCache(n,r,o,l,i);return}const c=this.getTree(n,r);Number.isNaN(o)&&(o=0),Number.isNaN(l)&&(l=0),Number.isNaN(a)&&(a=Number.POSITIVE_INFINITY),Number.isNaN(u)&&(u=Number.POSITIVE_INFINITY),c.insert({minX:l,minY:o,maxX:u,maxY:a,id:i})}bulkInsert(t){for(const n of t)this.insert(n)}*searchGenerator(t){var a;const{unitId:n,sheetId:r,range:s}=t;if(this._enableOneCellCache){const l=this._searchByOneCellCache(t);for(const u of l)yield u}const i=(a=this._tree.get(n))==null?void 0:a.get(r);if(!i)return;const o=i.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(const l of o)yield l.id}bulkSearch(t,n){const r=new Set;for(const s of t)for(const i of this.searchGenerator(s))(n==null?void 0:n.has(i))!==!0&&r.add(i);return r}removeById(t,n){var r,s;n?((r=this._tree.get(t))==null||r.delete(n),(s=this._oneCellCache.get(t))==null||s.delete(n)):(this._tree.delete(t),this._oneCellCache.delete(t))}_removeRTreeItem(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this.getTree(n,r),a=o.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(let l=0;l<a.length;l++)a[l].id===i&&o.remove(a[l])}remove(t){const{unitId:n,sheetId:r,range:s,id:i}=t,{startRow:o,startColumn:a,endRow:l,endColumn:u}=s;this._enableOneCellCache?o===l&&a===u?this._removeOneCellCache(n,r,s.startRow,s.startColumn,i):(this._removeCellCacheByRange(t),this._removeRTreeItem(t)):this._removeRTreeItem(t)}bulkRemove(t){for(const n of t)this.remove(n)}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){const t={};return this._tree.forEach((n,r)=>{t[r]={},n.forEach((s,i)=>{t[r][i]=s.toJSON()})}),t}fromJSON(t){this._tree.clear();for(const n in t){this._tree.set(n,new Map);for(const r in t[n]){const s=new $r;s.fromJSON(t[n][r]),this._tree.get(n).set(r,s)}}}}var bE=Object.getOwnPropertyDescriptor,yE=(e,t,n,r)=>{for(var s=r>1?void 0:r?bE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Gu=(e,t)=>(n,r)=>t(n,r,e);let vi=class extends st{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){const e=n=>{n.businesses.forEach(r=>{switch(r){case Be.UNRECOGNIZED:case Be.UNIVER_UNKNOWN:case Be.UNIVER_SLIDE:case Be.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType(Be.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 Be.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(Be.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$(Be.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(Be.UNIVER_DOC).subscribe(n=>{const r=n.getUnitId();ko(r)||this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(Be.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(Be.UNIVER_DOC).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())}))}saveUnit(e){const t=this._univerInstanceService.getUnit(e);if(!t)return null;const n=this._resourceManagerService.getResources(e,t.type),r=re.deepClone(t.getSnapshot());return r.resources=n,r}};vi=yE([Gu(0,We.Inject(ns)),Gu(1,We.Inject(An))],vi);class AE{constructor(t={},n){R(this,"_startedTypes",new Set);R(this,"_injector");R(this,"_disposingCallbacks",new mr);const r=this._injector=TE(n,t==null?void 0:t.override),{theme:s,locale:i,locales:o,logLevel:a}=t;s&&this._injector.get(gi).setTheme(s),o&&this._injector.get(cn).load(o),i&&this._injector.get(cn).setLocale(i),a&&this._injector.get(It).setLogLevel(a),this._init(r)}get _univerInstanceService(){return this._injector.get(An)}get _pluginService(){return this._injector.get(d.PluginService)}__getInjector(){return this._injector}onDispose(t){const n=this._disposingCallbacks.add(tt(t));return tt(()=>n.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(t){this._injector.get(cn).setLocale(t)}createUnit(t,n){return this._univerInstanceService.createUnit(t,n)}createUniverSheet(t){return this._injector.get(It).warn("[Univer]","Univer.createUniverSheet is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(Be.UNIVER_SHEET,t)}createUniverDoc(t){return this._injector.get(It).warn("[Univer]","Univer.createUniverDoc is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(Be.UNIVER_DOC,t)}createUniverSlide(t){return this._injector.get(It).warn("[Univer]","Univer.createUniverSlide is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(Be.UNIVER_SLIDE,t)}_init(t){this._univerInstanceService.registerCtorForType(Be.UNIVER_SHEET,d.Workbook),this._univerInstanceService.registerCtorForType(Be.UNIVER_DOC,yt),this._univerInstanceService.registerCtorForType(Be.UNIVER_SLIDE,ui);const n=t.get(An);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(d.LifecycleService).stage<Je.Ready&&(this._injector.get(d.LifecycleService).stage=Je.Ready)}registerPlugin(t,n){this._pluginService.registerPlugin(t,n)}}function TE(e,t){const n=yu([[su],[cn],[gi],[d.LifecycleService],[d.PluginService],[ir],[An,{useClass:d.UniverInstanceService}],[Ou,{useClass:wu}],[It,{useClass:Ui,lazy:!0}],[Pn,{useClass:d.CommandService}],[ss,{useClass:d.LocalUndoRedoService,lazy:!0}],[ai,{useClass:tu}],[dn,{useClass:Di}],[ns,{useClass:Au,lazy:!0}],[fi,{useClass:vi,lazy:!0}],[Ql,{useClass:d.AuthzIoLocalService}],[eu,{useClass:d.MentionIOLocalService,lazy:!0}]],t),r=e?e.createChild(n):new We.Injector(n);return Oi(r,[[ir],[fi]]),r}Qu(),d.ABCToNumber=Fd,d.AUTO_HEIGHT_FOR_MERGED_CELLS=Uo,d.AbsoluteRefType=nt,d.ActionIterator=On,d.AlignTypeH=ma,d.AlignTypeV=_a,d.ArrangeTypeEnum=Ca,d.ArrowsAndMarkersShapes=Zi,d.AsyncInterceptorManager=up,d.AutoFillSeries=Hi,d.BaselineOffset=Ut,d.BasicShapes=Ji,d.BlockType=Ko,d.BooleanNumber=ve,d.BorderStyleTypes=qe,d.BorderType=Wi,d.BuildTextUtils=ot,d.BulletAlignment=Kn,d.COLORS=fs,d.CanceledError=oc,d.CellModeEnum=fn,d.CellValueType=Ht,d.Color=nn,d.ColorBuilder=Sr,d.ColorKit=vt,d.ColorType=_t,d.ColumnSeparatorType=Jo,d.CommandType=kn,d.CommonHideTypes=ji,d.ConfigService=tu,d.ContextService=Di,d.CopyPasteType=Yi,d.CustomCommandExecutionError=as,d.CustomDecorationType=rn,d.CustomRangeType=zt,d.DEFAULT_CELL=Ed,d.DEFAULT_DOC=ri,d.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=mp,d.DEFAULT_EMPTY_DOCUMENT_VALUE=Do,d.DEFAULT_RANGE=_d,d.DEFAULT_RANGE_ARRAY=md,d.DEFAULT_SELECTION=pd,d.DEFAULT_SLIDE=Po,d.DEFAULT_STYLES=lt,d.DEFAULT_WORKSHEET_COLUMN_COUNT=fu,d.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=jp,d.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=pu,d.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=Gp,d.DEFAULT_WORKSHEET_COLUMN_WIDTH=mu,d.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=zp,d.DEFAULT_WORKSHEET_ROW_COUNT=du,d.DEFAULT_WORKSHEET_ROW_COUNT_KEY=Wp,d.DEFAULT_WORKSHEET_ROW_HEIGHT=gu,d.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=Yp,d.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=_u,d.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=Vp,d.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=vs,d.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=Ss,d.DOCS_ZEN_EDITOR_UNIT_ID_KEY=Mo,d.DOC_RANGE_TYPE=ho,d.DashStyleType=sa,d.DataStreamTreeNodeType=va,d.DataStreamTreeTokenType=Vt,d.DataValidationErrorStyle=Pu,d.DataValidationImeMode=Fu,d.DataValidationOperator=xu,d.DataValidationRenderMode=$u,d.DataValidationStatus=Bu,d.DataValidationType=Hu,d.DeleteDirection=zi,d.DependentOn=hE,d.DesktopLogService=Ui,d.DeveloperMetadataVisibility=Vi,d.Dimension=Gi,d.Direction=Ki,d.Disposable=st,d.DisposableCollection=mr,d.DocStyleType=Vo,d.DocumentDataModel=yt,d.DocumentFlavor=As,d.DrawingTypeEnum=Ra,d.EDITOR_ACTIVATED=nu,d.EXTENSION_NAMES=Fo,d.ErrorService=su,d.EventState=Jl,d.EventSubject=_p,d.FOCUSING_COMMON_DRAWINGS=Np,d.FOCUSING_DOC=ar,d.FOCUSING_EDITOR_BUT_HIDDEN=Op,d.FOCUSING_EDITOR_INPUT_FORMULA=wp,d.FOCUSING_EDITOR_STANDALONE=yp,d.FOCUSING_FX_BAR_EDITOR=ru,d.FOCUSING_PANEL_EDITOR=Ap,d.FOCUSING_SHEET=yn,d.FOCUSING_SLIDE=lr,d.FOCUSING_UNIT=or,d.FOCUSING_UNIVER_EDITOR=bp,d.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=Tp,d.FORMULA_EDITOR_ACTIVATED=Mp,d.FollowNumberWithType=Go,d.FontItalic=Er,d.FontStyleType=pn,d.FontWeight=Cr,d.GridType=Xo,d.HLSColor=lo,d.HorizontalAlign=St,d.IAuthzIoService=Ql,d.ICommandService=Pn,d.IConfigService=ai,d.IContextService=dn,d.IImageIoService=pi,d.ILocalStorageService=oE,d.ILogService=It,d.IMentionIOService=eu,d.IPermissionService=Ou,d.IResourceLoaderService=fi,d.IResourceManagerService=ns,d.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=Lo,d.IUndoRedoService=ss,d.IUniverInstanceService=An,d.ImageCacheMap=ku,d.ImageSourceType=_i,d.ImageUploadStatusType=Uu,d.InterceptorEffectEnum=bn,d.InterceptorManager=op,d.InterpolationPointType=Xi,d.JSON1=s_,d.JSONX=xt,d.LRUHelper=Wn,d.LRUMap=Hn,d.LifecycleStages=Je,d.ListGlyphType=Ne,d.LocaleService=cn,d.LocaleType=$n,d.LogLevel=Li,d.MOVE_BUFFER_VALUE=xn,d.MemoryCursor=wn,d.MentionType=pr,d.NamedStyleType=na,d.NilCommand=Pi,d.NumberUnitType=ga,d.ObjectMatrix=Ot,d.ObjectRelativeFromH=da,d.ObjectRelativeFromV=fa,d.OtherShapes=Qi,d.PRESET_LIST_TYPE=tr,d.PageElementType=Ia,d.PageOrientType=Ea,d.PageType=Ts,d.ParagraphElementType=Qo,d.ParagraphStyleBuilder=sr,d.ParagraphStyleValue=rr,d.PermissionService=wu,d.PermissionStatus=ci,d.Plugin=di,d.PositionedObjectLayoutType=ta,d.PresetListType=Mt,d.ProtectionType=qi,d.QuickListType=Ll,d.QuickListTypeMap=c_,d.RANGE_DIRECTION=co,d.RANGE_TYPE=Le,d.RBush=$r,d.RCDisposable=dc,d.RGBA_PAREN=Hc,d.RGB_PAREN=Bc,d.ROTATE_BUFFER_VALUE=Bi,d.RTree=wE,d.Range=gn,d.Rectangle=Yt,d.RedoCommand=Lu,d.RedoCommandId=Nu,d.RefAlias=Pd,d.Registry=si,d.RegistryAsMap=ii,d.RelativeDate=to,d.RelativeSlideLink=Sa,d.ResourceManagerService=Au,d.RgbColor=vr,d.RichTextBuilder=un,d.RichTextValue=qt,d.RxDisposable=hc,d.SHEET_EDITOR_UNITS=Cd,d.SectionType=qo,d.SheetTypes=no,d.SheetViewModel=Cu,d.SliceBodyType=ti,d.SlideDataModel=ui,d.SpacingRule=ra,d.SpecialShapes=eo,d.Styles=iu,d.THEME_COLORS=ao,d.TabStopAlignment=ia,d.TableAlignmentType=aa,d.TableLayoutType=la,d.TableRowHeightRule=ca,d.TableSizeType=oa,d.TableTextWrapType=ua,d.TextDecoration=ro,d.TextDecorationBuilder=Xt,d.TextDirection=Bn,d.TextDirectionType=Zo,d.TextStyleBuilder=Kt,d.TextStyleValue=nr,d.TextX=ze,d.TextXActionType=he,d.ThemeColor=Or,d.ThemeColorType=ct,d.ThemeColors=Rr,d.ThemeService=gi,d.Tools=re,d.UndoCommand=Du,d.UndoCommandId=Mu,d.UnitModel=Xr,d.Univer=AE,d.UniverInstanceType=Be,d.UpdateDocsAttributeType=ke,d.UserManagerService=ir,d.VerticalAlign=en,d.VerticalAlignmentType=ha,d.Worksheet=cr,d.WrapStrategy=tn,d.WrapTextType=ea,d.addLinkToDocumentModel=lu,d.afterInitApply=Ic,d.afterTime=Rc,d.awaitTime=_E,d.binSearchFirstGreaterThanTarget=$i,d.binarySearchArray=Sc,d.bufferDebounceTime=Cc,d.cellToRange=mh,d.characterSpacingControlType=pa,d.checkForSubstrings=_h,d.checkIfMove=Oc,d.checkParagraphHasBullet=Zh,d.checkParagraphHasIndent=Qh,d.checkParagraphHasIndentByStyle=wo,d.codeToBlob=vc,d.composeBody=ni,d.composeInterceptors=Xl,d.composeStyles=hs,d.concatMatrixArray=cd,d.convertBodyToHtml=$c,d.convertCellToRange=fo,d.covertTextRunToHtml=ds,d.createAsyncInterceptorKey=ap,d.createDefaultUser=rs,d.createDocumentModelWithStyle=ur,d.createInterceptorKey=ip,d.createInternalEditorID=gd,d.createRowColIter=ys,d.dayjs=Pt,d.debounce=Bm,d.dedupe=ec,d.deepCompare=ps,d.delayAnimationFrame=pE,d.deleteContent=yo,d.extractPureTextFromCell=Iu,d.fromCallback=Fi,d.fromEventSubject=pp,d.fromObservable=cc,d.generateRandomId=kt,d.get=pm,d.getArrayLength=jt,d.getBodySlice=bt,d.getBodySliceHtml=Ir,d.getBorderStyleType=dh,d.getCellCoordByIndexSimple=Ei,d.getCellInfoInMergeData=oh,d.getCellPositionByIndexSimple=OE,d.getCellValueType=nh,d.getCellWithCoordByIndexCore=Tn,d.getColorStyle=Tt,d.getCustomBlockSlice=xl,d.getCustomDecorationSlice=Bl,d.getCustomRangeSlice=$l,d.getDocsUpdateBody=fh,d.getIntersectRange=Ho,d.getOriginCellValue=Xp,d.getParagraphsSlice=Fl,d.getPlainText=jr,d.getReverseDirection=wc,d.getSectionBreakSlice=C_,d.getTableSlice=Pl,d.getTextRunSlice=ts,d.getTransformOffsetX=Wu,d.getTransformOffsetY=ju,d.getWorksheetUID=Qp,d.groupBy=rc,d.handleStyleToString=hh,d.hashAlgorithm=td,d.horizontalLineSegmentsSubtraction=Pr,d.insertMatrixArray=Cs,d.insertTextToContent=bo,d.isBlackColor=Qc,d.isBooleanString=qm,d.isCellCoverable=_s,d.isCellV=sh,d.isEmptyCell=go,d.isFormulaId=ch,d.isFormulaString=uh,d.isICellData=th,d.isInternalEditorID=ko,d.isNodeEnv=xc,d.isNotNullOrUndefined=uu,d.isNullCell=rh,d.isNumeric=ql,d.isRangesEqual=Up,d.isRealNum=ed,d.isSafeNumeric=hp,d.isSameStyleTextRun=mo,d.isUnitRangesEqual=kp,d.isValidRange=gh,d.isWhiteColor=eh,d.makeArray=sc,d.makeCellRangeToRangeData=lh,d.makeCellToSelection=ah,d.makeCustomRangeStream=jd,d.merge=js,d.mergeOverrideWithDependencies=yu,d.mergeSets=fp,d.mergeWith=Ym,d.mergeWorksheetSnapshotWithDefault=Eu,d.mixinClass=cp,d.moveMatrixArray=Is,d.moveRangeByOffset=bd,d.nameCharacterCheck=mE,d.normalizeBody=R_,d.normalizeTextRuns=er,d.numberToABC=$d,d.numberToListABC=Bd,d.numfmt=ud,d.queryObjectMatrix=kd,d.registerDependencies=ic,d.remove=Ln,d.repeatStringNumTimes=zo,d.replaceInDocumentBody=gp,d.requestImmediateMacroTask=dp,d.rotate=nc,d.searchArray=Fn,d.searchInOrderedArray=xi,d.selectionToArray=ih,d.sequence=bi,d.sequenceAsync=wi,d.sequenceExecute=_r,d.sequenceExecuteAsync=Ec,d.set=Vm,d.shallowEqual=al,d.skipParseTagNames=EE,d.sliceMatrixArray=hd,d.sortRules=Hd,d.sortRulesByDesc=Wd,d.sortRulesFactory=Gn,d.spliceArray=Rs,d.splitIntoGrid=bs,d.takeAfter=us,d.textDiff=zs,d.throttle=sp,d.toDisposable=tt,d.touchDependencies=Oi,d.updateAttributeByDelete=Hl,d.updateAttributeByInsert=Wl,Object.keys(We).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(d,e)&&Object.defineProperty(d,e,{enumerable:!0,get:()=>We[e]})}),Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
10
+ `,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(n){return new un(n!=null?n:un.newEmptyData())}insertText(n,r,s){var c,h;let i=((h=(c=this._data.body)==null?void 0:c.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 Kt?r.build():r:a=s instanceof Kt?s.build():s,!o)return this;const l={dataStream:o,textRuns:a?[{ts:a,st:i,ed:i+o.length}]:[]},u=ot.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:l});if(!u)throw new Error("Insert text failed, please check.");return ze.apply(this._doc.getBody(),u.serialize()),this}insertRichText(n,r){var a,l;let s=((l=(a=this._data.body)==null?void 0:a.dataStream.length)!=null?l:2)-2,i;typeof n=="object"?i=n instanceof qt?n.getData():n:(s=Math.min(n,s),i=r instanceof qt?r.getData():r);const o=ot.selection.replace({doc:this._doc,selection:{startOffset:s,endOffset:s,collapsed:!0},body:i.body});if(!o)throw new Error("Insert text failed, please check.");return ze.apply(this._doc.getBody(),o.serialize()),this}delete(n,r){if(r!==void 0){if(!r)return this;const s=ot.selection.delete([{startOffset:n,endOffset:n+r,collapsed:!0}],this._data.body);ze.apply(this._doc.getBody(),s)}return this}setStyle(n,r,s){const i={dataStream:"",textRuns:[{ts:s instanceof Kt?s.build():s,st:0,ed:r-n}]},o=ot.selection.retain([{startOffset:n,endOffset:r,collapsed:!0}],i);return ze.apply(this._doc.getBody(),o),this}setLink(n,r,s){const i=ot.customRange.add({rangeType:zt.HYPERLINK,rangeId:kt(),properties:{url:s},ranges:[{startOffset:n,endOffset:r,collapsed:!1}],body:this._data.body});if(!i)throw new Error("Insert text failed, please check.");return ze.apply(this._doc.getBody(),i.serialize()),this}cancelLink(n,r){if(typeof n=="string"){const s=ot.customRange.delete({rangeId:n,documentDataModel:this._doc});if(!s)throw new Error("Insert text failed, please check.");ze.apply(this._doc.getBody(),s.serialize())}else this.slice(n,r).getLinks().forEach(i=>{const o=ot.customRange.delete({rangeId:i.rangeId,documentDataModel:this._doc});if(!o)throw new Error("Insert text failed, please check.");ze.apply(this._doc.getBody(),o.serialize())});return this}updateLink(n,r){var i,o;const s=(o=(i=this._data.body)==null?void 0:i.customRanges)==null?void 0:o.find(a=>a.rangeId===n);if(!s)throw new Error("Link not found");return s.properties.url=r,this}insertParagraph(n,r){var o,a;let s,i;return typeof n=="object"?(s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:n.build()}]},i=((a=(o=this._data.body)==null?void 0:o.dataStream.length)!=null?a:2)-2):(i=n,s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:r==null?void 0:r.build()}]}),this.insertRichText(i,qt.create({body:s,id:"d",documentStyle:{}})),this}insertLink(n,r,s){let i="",o="";typeof n=="string"?(i=n,o=r):(i=r,o=s);const a=un.createByBody({dataStream:i,customRanges:[{rangeType:zt.HYPERLINK,rangeId:kt(),properties:{url:o},startIndex:0,endIndex:i.length-1}]});return typeof n=="number"?this.insertRichText(n,a):this.insertRichText(a)}}function sp(e,t=16){let n=0,r=null;return function(...i){const o=Date.now();o-n<t?(r&&clearTimeout(r),r=setTimeout(()=>{n=o,e.apply(this,i)},t)):(n=o,e.apply(this,i))}}var bn=(e=>(e[e.Style=1]="Style",e[e.Value=2]="Value",e))(bn||{});function ip(e){return`sheet_interceptor_${e}`}const Xl=e=>function(t,n){let r=-1,s=t;for(let i=0;i<=e.length;i++){if(i<=r)throw new Error("[SheetInterceptorService]: next() called multiple times!");if(r=i,i===e.length)return s;const o=e[i];let a=!1;if(s=o.handler(s,n,l=>(a=!0,l)),!a)break}return s};class op{constructor(t){R(this,"_interceptorsByName",new Map);R(this,"_interceptorPoints");this._interceptorPoints=t}fetchThroughInterceptors(t,n){const r=t;let s=this._interceptorsByName.get(r);return n&&(s=s.filter(n)),Xl(s||[])}intercept(t,n){const r=t;this._interceptorsByName.has(r)||this._interceptorsByName.set(r,[]);const s=this._interceptorsByName.get(r);return s.push(n),this._interceptorsByName.set(r,s.sort((i,o)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)})),()=>Ln(this._interceptorsByName.get(r),n)}getInterceptPoints(){return this._interceptorPoints}dispose(){this._interceptorsByName.clear()}}function ap(e){return`sheet_async_interceptor_${e}`}const lp=e=>async function(t,n){let r=-1,s=t;for(let i=0;i<=e.length;i++){if(i<=r)throw new Error("[SheetInterceptorService]: next() called multiple times!");if(r=i,i===e.length)return s;const o=e[i];let a=!1;if(s=await o.handler(s,n,async l=>(a=!0,l)),!a)break}return s};class up{constructor(t){R(this,"_asyncInterceptorsByName",new Map);R(this,"_asyncInterceptorPoints");this._asyncInterceptorPoints=t}fetchThroughAsyncInterceptors(t,n){const r=t;let s=this._asyncInterceptorsByName.get(r);return n&&(s=s.filter(n)),lp(s||[])}async interceptAsync(t,n){const r=t;this._asyncInterceptorsByName.has(r)||this._asyncInterceptorsByName.set(r,[]);const s=this._asyncInterceptorsByName.get(r);return s.push(n),this._asyncInterceptorsByName.set(r,s.sort((i,o)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)})),()=>Ln(this._asyncInterceptorsByName.get(r),n)}getInterceptPoints(){return this._asyncInterceptorPoints}dispose(){this._asyncInterceptorsByName.clear()}}function cp(e,t){for(const n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}function ql(e){return/^-?\d+(\.\d+)?$/.test(e)}function hp(e){return ql(e)?Number(e)<=Number.MAX_SAFE_INTEGER:!1}class si{constructor(){R(this,"_data",[])}static create(){return new si}add(t){this._data.indexOf(t)>-1||this._data.push(t)}delete(t){const n=this._data.indexOf(t);this._data.splice(n,1)}getData(){return this._data}}class ii{constructor(){R(this,"_data",new Map)}static create(){return new ii}add(t,n){this._data.has(t)||this._data.set(t,n)}delete(t){this._data.delete(t)}getData(){return this._data}}function dp(e){const t=new MessageChannel;let n=!1;const r=()=>{n||e()};return t.port1.onmessage=r,t.port2.postMessage(null),()=>{n=!0,t.port1.onmessage=null,t.port1.close(),t.port2.close()}}function fp(e,t){return t.forEach(n=>e.add(n)),e}function gp(e,t,n,r){var u;if(t==="")return e;const s={id:"mock-id",body:e,documentStyle:{}},i=new yt(s),o=t.length;let a;for(;(a=(r?i.getBody().dataStream:i.getBody().dataStream.toLowerCase()).indexOf(t))>=0;){const c=new ze,h=xt.getInstance();if(a>0&&c.retain(a),n.length>0){const f=i.sliceBody(a,a+o),g={dataStream:n};if(Array.isArray(f==null?void 0:f.textRuns)&&f.textRuns.length&&(g.textRuns=[{...f.textRuns[0],st:0,ed:n.length}]),(u=f==null?void 0:f.customRanges)!=null&&u.length){const C=f.customRanges[0];g.customRanges=[{...C,startIndex:0,endIndex:n.length-1}]}c.insert(n.length,g)}c.delete(o),i.apply(h.editOp(c.serialize()))}const l=i.getBody();return i.dispose(),l}const mp="__default_document_sub_component_id20231101__";class Jl{constructor(){R(this,"skipNextObservers",!1);R(this,"lastReturnValue");R(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class _p extends Ie.Subject{constructor(){super(...arguments);R(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 Jl;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 pp(e){return new Ie.Observable(t=>{const n=e.subscribeEvent(r=>{t.next(r)});return()=>n.unsubscribe()})}const ns=We.createIdentifier("core.resource-manager.service"),oi={[Nt.Editor]:"Editor",[Nt.Owner]:"Owner",[Nt.Reader]:"Reader",[Nt.UNRECOGNIZED]:"UNRECOGNIZED"},rs=e=>e?{userID:`${oi[e]}_${re.generateRandomId(8)}`,name:oi[e],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},Ep=(e,t)=>e.startsWith(oi[t]);class ir{constructor(){R(this,"_model",new Map);R(this,"_userChange$",new Ie.Subject);R(this,"userChange$",this._userChange$.asObservable());R(this,"_currentUser$",new Ie.BehaviorSubject(rs()));R(this,"currentUser$",this._currentUser$.asObservable())}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(t){this.addUser(t),this._currentUser$.next(t)}addUser(t){this._model.set(t.userID,t),this._userChange$.next({type:"add",user:t})}getUser(t,n){const r=this._model.get(t);if(r)return r;n&&n()}delete(t){const n=this.getUser(t);this._model.delete(t),n&&this._userChange$.next({type:"delete",user:n})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}list(){return Array.from(this._model.values())}}var Cp=Object.getOwnPropertyDescriptor,Rp=(e,t,n,r)=>{for(var s=r>1?void 0:r?Cp(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Zl=(e,t)=>(n,r)=>t(n,r,e);d.AuthzIoLocalService=class{constructor(t,n){R(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(rs(Nt.Owner))}_getRole(t){const n=this._userManagerService.getCurrentUser();return n?Ep(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:[Be.UNIVER_SHEET,Be.UNIVER_DOC,Be.UNIVER_SLIDE],onLoad:(t,n)=>{for(const r in n)this._permissionMap.set(r,n[r])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(t){return kt(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:Nt.Owner,shareScope:-1,scope:{read:Vs.AllCollaborator,edit:Vs.AllCollaborator},creator:rs(Nt.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(Nt.Owner)||this._getRole(Nt.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){}},d.AuthzIoLocalService=Rp([Zl(0,ns),Zl(1,We.Inject(ir))],d.AuthzIoLocalService);const Ql=We.createIdentifier("IAuthzIoIoService");var Ip=Object.getOwnPropertyDescriptor,Sp=(e,t,n,r)=>{for(var s=r>1?void 0:r?Ip(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},vp=(e,t)=>(n,r)=>t(n,r,e);d.MentionIOLocalService=class{constructor(t){this._userManagerService=t}async list(t){return{list:[{type:pr.PERSON,mentions:[{objectType:pr.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}}},d.MentionIOLocalService=Sp([vp(0,We.Inject(ir))],d.MentionIOLocalService);const eu=We.createIdentifier("univer.service.mention-io"),ai=We.createIdentifier("univer.config-service");class tu{constructor(){R(this,"_configChanged$",new Ie.Subject);R(this,"configChanged$",this._configChanged$.asObservable());R(this,"_config",new Map)}dispose(){this._configChanged$.complete()}getConfig(t){return this._config.get(t)}setConfig(t,n,r){var o;const{merge:s=!1}=r||{};let i=(o=this._config.get(t))!=null?o:{};s?i=js(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 Ie.Observable(n=>{Object.prototype.hasOwnProperty.call(this._config,t)&&n.next(this._config.get(t));const r=this.configChanged$.pipe(Ie.filter(s=>Object.prototype.hasOwnProperty.call(s,t))).subscribe(s=>n.next(s[t]));return()=>r.unsubscribe()})}}const or="FOCUSING_UNIT",yn="FOCUSING_SHEET",ar="FOCUSING_DOC",lr="FOCUSING_SLIDE",Op="FOCUSING_EDITOR_BUT_HIDDEN",nu="EDITOR_ACTIVATED",wp="FOCUSING_EDITOR_INPUT_FORMULA",ru="FOCUSING_FX_BAR_EDITOR",bp="FOCUSING_UNIVER_EDITOR",yp="FOCUSING_EDITOR_INPUT_FORMULA",Ap="FOCUSING_PANEL_EDITOR",Tp="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",Np="FOCUSING_COMMON_DRAWINGS",Mp="FORMULA_EDITOR_ACTIVATED";class su extends st{constructor(){super(...arguments);R(this,"_error$",new Ie.Subject);R(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(n){this._error$.next({errorKey:n})}}const Dp={version:"0.6.7"};function Lp(e="",t=$n.ZH_CN,n=""){return{id:e,sheetOrder:[],name:n,appVersion:Dp.version,locale:t,styles:{},sheets:{},resources:[]}}class iu{constructor(t={}){R(this,"_styles");R(this,"_cacheMap",new Hn(1e5));this._styles=t,this._generateCacheMap()}each(t){return Object.entries(this._styles).forEach(t),this}search(t,n){if(this._cacheMap.has(n))return this._cacheMap.get(n);const r=this._getExistingStyleId(t);return r||"-1"}get(t){return typeof t!="string"?t:(t=String(t),this._styles[t])}add(t,n){const r=re.generateRandomId(6);return this._styles[r]=t,this._cacheMap.set(n,r),r}setValue(t){if(t==null)return;const n=JSON.stringify(t),r=this.search(t,n);return r!=="-1"?r:this.add(t,n)}toJSON(){return this._styles}getStyleByCell(t){let n;t&&re.isObject(t.s)?n=t.s:n=(t==null?void 0:t.s)&&this.get(t.s);const r=t==null?void 0:t.interceptorStyle;return r?{...n,...r}:n}_generateCacheMap(){const{_styles:t,_cacheMap:n}=this;for(const r in t){const s=JSON.stringify(t[r]);n.set(s,r)}}_getExistingStyleId(t){const{_styles:n}=this;for(const r in n)if(re.diffValue(n[r],t))return r;return null}}const Up=(e,t)=>t.length===e.length&&!e.some(n=>t.some(r=>!Yt.equals(r,n))),kp=(e,t)=>t.length===e.length&&e.every((n,r)=>{const s=t[r];return s.unitId===n.unitId&&s.sheetId===n.sheetId&&Yt.equals(n.range,s.range)}),li={t:0,b:2,l:2,r:2},Pp=e=>({sbr:.6,sbo:e,spr:.6,spo:e}),ou=90;function ur(e,t,n={}){const r=e.length,{textRotation:s,paddingData:i,horizontalAlign:o=St.UNSPECIFIED,verticalAlign:a=en.UNSPECIFIED,wrapStrategy:l=tn.UNSPECIFIED,cellValueType:u}=n,{t:c,r:h,b:f,l:g}=i||li,{vertexAngle:C,centerAngle:I}=hu(s),b={id:"d",body:{dataStream:`${e}${Do}`,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:c,marginBottom:f,marginRight:h,marginLeft:g,renderConfig:{horizontalAlign:o,verticalAlign:a,centerAngle:I,vertexAngle:C,wrapStrategy:l,cellValueType:u,zeroWidthParagraphBreak:1}},drawings:{},drawingsOrder:[]};return new yt(b)}function Fp(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 au(e){if(!e)return{};const{ff:t,fs:n,it:r,bl:s,ul:i,st:o,ol:a,cl:l}=e,u={};return t&&(u.ff=t),n&&(u.fs=n),r&&(u.it=r),s&&(u.bl=s),i&&(u.ul=i),o&&(u.st=o),a&&(u.ol=a),l&&(u.cl=l),u}function lu(e,t,n){var i;const r=e.getBody();if((i=r.customRanges)!=null&&i.some(o=>o.rangeType===zt.HYPERLINK))return;const s=ot.customRange.add({ranges:[{startOffset:0,endOffset:r.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:zt.HYPERLINK,body:r,properties:{url:t,refId:n}});s&&ze.apply(r,s.serialize())}function uu(e){return e!=null}const xp='"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';function cu(e){const t=lt.ff,n=lt.fs;if(!e){const h=`${n}pt ${t}`;return{fontCache:h,fontString:h,fontSize:n,originFontSize:n,fontFamily:t}}let r=pn.ITALIC;(e.it===0||e.it===void 0)&&(r=pn.NORMAL);let s=pn.BOLD;(e.bl===0||e.bl===void 0)&&(s=pn.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===Ut.SUBSCRIPT||a===Ut.SUPERSCRIPT){const h=$p(o,l),{sbr:f,spr:g}=h;l*=a===Ut.SUBSCRIPT?f:g}const u=`${r} ${s} ${l}pt ${o}`,c=`${u}, ${xp} `;return{fontCache:u,fontString:c,fontSize:l,originFontSize:i,fontFamily:o}}function $p(e,t){return Pp(t)}function hu(e){const{a:t=0,v:n=ve.FALSE}=e||{a:0,v:ve.FALSE};let r=0,s=t;return n===ve.TRUE&&(r=ou,s=ou),{centerAngle:r,vertexAngle:s}}class Bp{constructor(t,n){R(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!==ve.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:Le.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:Le.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:Le.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:Le.COLUMN}),r}getColumnDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getColumnOrCreate(i);r[s]=o,s++}return r}getSize(){return jt(this._columnData)}getColumnWidth(t){const{_columnData:n}=this,r=this._config;let s=0;return s=(n[t]||{hd:ve.FALSE,w:r.defaultColumnWidth}).w||r.defaultColumnWidth,s}getColumn(t){const n=this._columnData[t];if(n)return n}removeColumn(t){delete this._columnData[t]}getColumnOrCreate(t){const{_columnData:n}=this,r=n[t];if(r)return r;const s={};return this._columnData[t]=s,s}setCustomMetadata(t,n){const r=this.getColumn(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getColumn(t))==null?void 0:n.custom}}class Hp{constructor(t,n,r){R(this,"_rowData");this._config=t,this._viewModel=n,this._rowData=r}getRowData(){return this._rowData}getRowStyle(t){var n;return(n=this._rowData[t])==null?void 0:n.s}setRowStyle(t,n){const r=this.getRowOrCreate(t);r.s=n}getRowDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getRowOrCreate(i);r[s]=o,s++}return r}getRowHeight(t,n=1){const{_rowData:r}=this,s=this._config;let i=0;for(let o=0;o<n;o++){const a=r[o+t]||{hd:ve.FALSE,h:s.defaultRowHeight},{ia:l,ah:u,h:c=s.defaultRowHeight}=a;i+=(l==null||l===ve.TRUE)&&typeof u=="number"?u:c}return i}getRow(t){return this._rowData[t]}removeRow(t){delete this._rowData[t]}getRowOrCreate(t){const{_rowData:n}=this,r=n[t];if(r)return r;const s={};return n[t]=s,s}getHiddenRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:Le.ROW})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:Le.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:Le.ROW})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:Le.ROW}),r}getRowRawVisible(t){const n=this.getRow(t);return n?n.hd!==ve.TRUE:!0}getSize(){return jt(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 Wp="DEFAULT_WORKSHEET_ROW_COUNT",du=1e3,jp="DEFAULT_WORKSHEET_COLUMN_COUNT",fu=20,Yp="DEFAULT_WORKSHEET_ROW_HEIGHT",gu=24,zp="DEFAULT_WORKSHEET_COLUMN_WIDTH",mu=88,Vp="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",_u=46,Gp="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",pu=20;function Eu(e){const t={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:ve.FALSE,rowCount:du,columnCount:fu,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:mu,defaultRowHeight:gu,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:ve.TRUE,rowHeader:{width:_u,hidden:ve.FALSE},columnHeader:{height:pu,hidden:ve.FALSE},rightToLeft:ve.FALSE};return Object.keys(t).forEach(n=>{const r=n;typeof e[r]>"u"&&(e[r]=t[r])}),e}class Kp extends st{constructor(n){super();R(this,"_cellCache",new Map);R(this,"_rowCache",new Map);R(this,"_columnCache",new Map);R(this,"_hasRow",!1);R(this,"_hasColumn",!1);R(this,"_hasAll",!1);R(this,"_allIndex",-1);R(this,"_mergeData");R(this,"_rangeMap",new Hn(5e4));R(this,"_skeletonCache",new Hn(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===Le.ROW?this._createRowCache(s,r):i===Le.COLUMN?this._createColumnCache(s,r):i===Le.ALL?this._createCellAllCache(r):this._createCellCache(s,r),r++}}rebuild(n){this._clearCache(),this._init(n.concat())}_createRowCache(n,r){const{startRow:s,endRow:i}=n;for(let o=s;o<=i;o++)this._rowCache.set(o,r),this._hasRow=!0}_createColumnCache(n,r){const{startColumn:s,endColumn:i}=n;for(let o=s;o<=i;o++)this._columnCache.set(o,r),this._hasColumn=!0}_createCellAllCache(n){this._hasAll=!0,this._allIndex=n}_createCellCache(n,r){for(let s=n.startRow;s<=n.endRow;s++){let i=this._cellCache.get(s);i==null&&(i=new Map,this._cellCache.set(s,i));for(let o=n.startColumn;o<=n.endColumn;o++)i.set(o,r)}}add(n){this._mergeData.push(n),this._clearCache(),this._createCache(this._mergeData)}remove(n,r){const s=this._getMergeDataIndex(n,r);s!==-1&&(this._mergeData.splice(s,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(n,r){const s=this._getMergeDataIndex(n,r);return s!==-1?this._mergeData[s]:null}getMergeDataIndex(n,r){return this._getMergeDataIndex(n,r)}isRowContainsMergedCell(n){return this._hasAll||!re.isEmptyObject(this._columnCache)?!0:this._mergeData.some(r=>r.startRow<=n&&n<=r.endRow)}isColumnContainsMergedCell(n){return this._hasAll||!re.isEmptyObject(this._rowCache)?!0:this._mergeData.some(r=>r.startColumn<=n&&n<=r.endColumn)}getMergedCellRange(n,r,s,i){const o=[],a=`${n}-${r}-${s}-${i}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let l=0;const u=[];for(const c of this._mergeData||[])Yt.intersects(c,{startRow:n,endRow:s,startColumn:r,endColumn:i})&&(o.push({...c}),u.push(l)),l++;return this._rangeMap.set(a,u),o}getMergedCellRangeForSkeleton(n,r,s,i){const o=[],a=this._mergeData,l=`${n}-${r}-${s}-${i}`;if(this._skeletonCache.has(l))return this._getSkeletonRangeFromCache(l);const u=[];for(let c=0;c<a.length;c++){const{startRow:h,endRow:f,startColumn:g,endColumn:C}=a[c];for(let I=n;I<=s;I++){let b=!1;for(let U=r;U<=i;U++)if(I>=h&&I<=f&&U>=g&&U<=C){o.push({startRow:h,endRow:f,startColumn:g,endColumn:C}),u.push(c),b=!0;break}if(b)break}}return this._skeletonCache.set(l,u),o}_getRangeFromCache(n){const r=this._rangeMap.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getSkeletonRangeFromCache(n){const r=this._skeletonCache.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getMergeDataIndex(n,r){var i;if(this._hasAll)return this._allIndex;if(this._hasRow){const o=this._rowCache.get(n);if(o!==void 0)return o}if(this._hasColumn){const o=this._columnCache.get(r);if(o!==void 0)return o}const s=(i=this._cellCache.get(n))==null?void 0:i.get(r);return s!==void 0?s:-1}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}}class Cu extends st{constructor(n){super();R(this,"_cellContentInterceptor",null);R(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,tt(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(n){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=n,tt(()=>this._rowFilteredInterceptor=null)}}const Ru={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};class cr{constructor(t,n,r){R(this,"_sheetId");R(this,"_snapshot");R(this,"_cellData");R(this,"_rowManager");R(this,"_columnManager");R(this,"_viewModel");R(this,"_spanModel");var a;this.unitId=t,this._styles=r,this._snapshot=Eu(n);const{columnData:s,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:re.generateRandomId(6),this._cellData=new Ot(o),this._viewModel=new Cu((l,u)=>this.getCellRaw(l,u)),this._rowManager=new Hp(this._snapshot,this._viewModel,i),this._columnManager=new Bp(this._snapshot,s),this._spanModel=new Kp(this._snapshot.mergeData)}__interceptViewModel(t){t(this._viewModel)}getSnapshot(){return this._snapshot}setMergeData(t){this._snapshot.mergeData=t,this.getSpanModel().rebuild(t)}getSpanModel(){return this._spanModel}getStyleDataByHash(t){return{...this._styles.get(t)}}setStyleData(t){return this._styles.setValue(t)}getColumnStyle(t,n=!1){return n?this._columnManager.getColumnStyle(t):this._styles.get(this._columnManager.getColumnStyle(t))}setColumnStyle(t,n){this._columnManager.setColumnStyle(t,n)}getRowStyle(t,n=!1){return n?this._rowManager.getRowStyle(t):this._styles.get(this._rowManager.getRowStyle(t))}setRowStyle(t,n){this._rowManager.setRowStyle(t,n)}mixinDefaultStyleToCellRaw(t,n,r,s){const i=this.getColumnStyle(n),o=this.getRowStyle(t),a=this.getDefaultCellStyleInternal();if(a||i||o){let l=r==null?void 0:r.s;typeof l=="string"&&(l=this._styles.get(l));const u=s?hs(a,i,o,l):hs(a,o,i,l);r||(r={}),r.s=u}}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){const t=this._snapshot.defaultStyle;return this._styles.get(t)}setDefaultCellStyle(t){this._snapshot.defaultStyle=t}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}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const t=this.getCellMatrix(),n=this.getMergeData();let r=-1,s=-1,i=-1,o=-1,a=!1,l=!1;return t.forEach((u,c)=>{Object.keys(c).forEach(h=>{const f=+h,g=t.getValue(u,f),C=g!=null&&g.s?this._styles.get(g.s):null,I=(C==null?void 0:C.bd)&&(C.bd.b||C.bd.l||C.bd.r||C.bd.t||C.bd.bc_tr||C.bd.bl_tr||C.bd.ml_tr||C.bd.tl_bc||C.bd.tl_br||C.bd.tl_mr);(g&&(g.v||g.p)||C!=null&&C.bg||I)&&(a?r=Math.min(r,u):(r=u,a=!0),s=Math.max(s,u),l?i=Math.min(i,f):(l=!0,i=f),o=Math.max(o,f))})}),n.forEach(u=>{a?r=Math.min(r,u.startRow):(r=u.startRow,a=!0),s=Math.max(s,u.endRow),l?i=Math.min(i,u.startColumn):(i=u.startColumn,a=!0),o=Math.max(o,u.endColumn)}),!a||!l?null:{startColumn:i,startRow:r,endColumn:o,endRow:s}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:t}=this,n=re.deepClone(t);return new cr(this.unitId,n,this._styles)}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(t,n){return this._spanModel.getMergedCell(t,n)}getMergedCellRange(t,n,r,s){return this._spanModel.getMergedCellRange(t,n,r,s)}isRowContainsMergedCell(t){return this._spanModel.isRowContainsMergedCell(t)}isColumnContainsMergedCell(t){return this._spanModel.isColumnContainsMergedCell(t)}getCellInfoInMergeData(t,n){const r=this.getMergedCell(t,n);let s=!1,i=!1,o=t,a=n,l=t,u=n;if(r){const{startRow:c,endRow:h,startColumn:f,endColumn:g}=r;t===c&&n===f?(o=h,a=g,l=c,u=f,i=!0):t>=c&&t<=h&&n>=f&&n<=g&&(o=h,a=g,l=c,u=f,s=!0)}return{actualRow:t,actualColumn:n,isMergedMainCell:i,isMerged:s,endRow:o,endColumn:a,startRow:l,startColumn:u}}getCell(t,n){return t<0||n<0?null:this._viewModel.getCell(t,n)}getCellValueOnly(t,n){return t<0||n<0?null:this._viewModel.getCellValueOnly(t,n)}getCellStyleOnly(t,n){return t<0||n<0?null:this._viewModel.getCellStyleOnly(t,n)}getCellRaw(t,n){return this.getCellMatrix().getValue(t,n)}getCellWithFilteredInterceptors(t,n,r,s){return this._viewModel.getCell(t,n,r,s)}getRowFiltered(t){return this._viewModel.getRowFiltered(t)}getMatrixWithMergedCells(t,n,r,s,i=fn.Raw){const o=this.getCellMatrix(),a=this._spanModel.getMergedCellRange(t,n,r,s),l=new Ot;return ys(t,r,n,s).forEach((u,c)=>{var f;let h;if(i===fn.Raw)h=this.getCellRaw(u,c);else if(i===fn.Intercepted)h=this.getCell(u,c);else if(i===fn.Both){const g=this.getCellRaw(u,c);if(g){h={...g};const C=(f=this.getCell(u,c))==null?void 0:f.v;uu(C)&&h&&(h.displayV=String(C))}}h&&l.setValue(u,c,h)}),a.forEach(u=>{const{startColumn:c,startRow:h,endColumn:f,endRow:g}=u;ys(h,g,c,f).forEach((C,I)=>{C===h&&I===c&&l.setValue(C,I,{...o.getValue(C,I),rowSpan:g-h+1,colSpan:f-c+1}),(C!==h||I!==c)&&l.realDeleteValue(C,I)})}),l}getRange(t,n,r,s){return typeof t=="object"?new gn(this,t,{getStyles:()=>this._styles}):new gn(this,{startRow:t,startColumn:n,endColumn:s||n,endRow:r||t},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:t}=this,{columnCount:n}=t;return n}getMaxRows(){const{_snapshot:t}=this,{rowCount:n}=t;return n}getRowCount(){return this._snapshot.rowCount}setRowCount(t){this._snapshot.rowCount=t}getColumnCount(){return this._snapshot.columnCount}setColumnCount(t){this._snapshot.columnCount=t}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:t}=this,{showGridlines:n}=t;return n===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){const{_snapshot:t}=this,{tabColor:n}=t;return n}getColumnWidth(t){return this.getColumnManager().getColumnWidth(t)}getRowHeight(t){return this._viewModel.getRowFiltered(t)?0:this.getRowManager().getRowHeight(t)}isRowFiltered(t){return this._viewModel.getRowFiltered(t)}getRowVisible(t){return!this.isRowFiltered(t)&&this.getRowRawVisible(t)}getRowRawVisible(t){return this.getRowManager().getRowRawVisible(t)}getHiddenRows(t,n){const r=this.getMaxColumns()-1,s=this._rowManager.getHiddenRows(t,n);return s.forEach(i=>i.endColumn=r),s}getColVisible(t){return this._columnManager.getColVisible(t)}getHiddenCols(t,n){const r=this.getMaxRows()-1,s=this._columnManager.getHiddenCols(t,n);return s.forEach(i=>i.endRow=r),s}getVisibleRows(){const t=this.getRowCount();return this._rowManager.getVisibleRows(0,t-1)}getVisibleCols(){const t=this.getColumnCount();return this._columnManager.getVisibleCols(0,t-1)}isRightToLeft(){const{_snapshot:t}=this,{rightToLeft:n}=t;return n}getLastRowWithContent(){return this._cellData.getLength()-1}getLastColumnWithContent(){return this._cellData.getRange().endColumn}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(t){return t&&(t.v!==void 0||t.f!==void 0||t.p!==void 0)}iterateByRow(t,n=!0){const{startRow:r,startColumn:s,endRow:i,endColumn:o}=t,a=this;return{[Symbol.iterator]:()=>{let l=r,u=s;return{next(){for(;;){if(u>o&&(l+=1,u=s),l>i)return{done:!0,value:void 0};const c=a.getCell(l,u),h=!c,f=a.getMergedCell(l,u);if(f){if(l!==f.startRow||u!==f.startColumn){u=f.endColumn+1;continue}if(h&&n){u=f.endColumn+1;continue}const C={row:l,col:u,value:c};return C.colSpan=f.endColumn-f.startColumn+1,C.rowSpan=f.endRow-f.startRow+1,u=f.endColumn+1,{done:!1,value:C}}if(h&&n)u+=1;else{const g={row:l,col:u,value:c};return u+=1,{done:!1,value:g}}}}}}}}iterateByColumn(t,n=!0,r=!0){const{startRow:s,startColumn:i,endRow:o,endColumn:a}=t,l=this;return{[Symbol.iterator]:()=>{let u=s,c=i;return{next(){for(;;){if(u>o&&(c+=1,u=s),c>a)return{done:!0,value:void 0};const h=l.getMergedCell(u,c);if(h){const C=u!==h.startRow,I=C||c!==h.startColumn;if(r&&I||!r&&C){u=h.endRow+1;continue}const b=l.getCell(h.startRow,h.startColumn);if(!b&&n){u=h.endRow+1;continue}const Z={row:u,col:h.startColumn,value:b};return Z.colSpan=h.endColumn-h.startColumn+1,Z.rowSpan=h.endRow-h.startRow+1,u=h.endRow+1,{done:!1,value:Z}}const f=l.getCell(u,c);if(!f&&n)u+=1;else{const C={row:u,col:c,value:f};return u+=1,{done:!1,value:C}}}}}}}}_getCellDocumentModel(t,n=Ru){var I;const{isDeepClone:r,displayRawFormula:s,ignoreTextRotation:i}={...Ru,...n},o=this._styles.getStyleByCell(t);if(!t)return;let a,l="document";const u=Fp(o),c=i?lt.tr:u.textRotation||lt.tr;let h=u.horizontalAlign||lt.ht;const f=u.verticalAlign||lt.vt,g=u.wrapStrategy||lt.tb,C=u.paddingData||li;if(t.f&&s)a=ur(t.f.toString(),{},{verticalAlign:f}),h=lt.ht;else if(t.p){const{centerAngle:b,vertexAngle:U}=hu(c);a=this._updateConfigAndGetDocumentModel(r?re.deepClone(t.p):t.p,h,C,{horizontalAlign:h,verticalAlign:f,centerAngle:b,vertexAngle:U,wrapStrategy:g,zeroWidthParagraphBreak:1})}else if(t.v!=null){const b=au(o);l=cu(b).fontCache;let U=Iu(t);t.t===Ht.FORCE_STRING&&s&&(U=`'${U}`),a=ur(U,b,{...u,textRotation:c,cellValueType:t.t})}return a&&t.linkUrl&&t.linkId&&lu(a,t.linkUrl,t.linkId),{documentModel:a,fontString:l,textRotation:c,wrapStrategy:g,verticalAlign:f,horizontalAlign:h,paddingData:C,fill:(I=o==null?void 0:o.bg)==null?void 0:I.rgb}}_updateConfigAndGetDocumentModel(t,n,r,s){var o,a,l,u,c;if(!s||!((o=t.body)!=null&&o.dataStream))return;t.documentStyle||(t.documentStyle={}),t.documentStyle.marginTop=(a=r.t)!=null?a:0,t.documentStyle.marginBottom=(l=r.b)!=null?l:2,t.documentStyle.marginLeft=(u=r.l)!=null?u:2,t.documentStyle.marginRight=(c=r.r)!=null?c: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 yt(t)}getBlankCellDocumentModel(t){const n=this._getCellDocumentModel(t,{ignoreTextRotation:!0}),r=this._styles.getStyleByCell(t),s=au(r);if(n!=null)return n.documentModel==null&&(n.documentModel=ur("",s)),n;const i="";let o="document";const a=lt.tr,l=lt.ht,u=lt.vt,c=lt.tb,h=li;return o=cu({}).fontCache,{documentModel:ur(i,s),fontString:o,textRotation:a,wrapStrategy:c,verticalAlign:u,horizontalAlign:l,paddingData:h}}getCellDocumentModelWithFormula(t){return this._getCellDocumentModel(t,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(t){this._snapshot.custom=t}}function Iu(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 ot.transform.getPlainText(t);const n=e.v;return typeof n=="string"?e.t===Ht.BOOLEAN?n.toUpperCase():n.replace(/[\r\n]/g,""):typeof n=="number"?e.t===Ht.BOOLEAN?n?"TRUE":"FALSE":n.toString():typeof n=="boolean"?n?"TRUE":"FALSE":""}function Xp(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 ot.transform.getPlainText(n)}return e==null?void 0:e.v}var qp=Object.getOwnPropertyDescriptor,Jp=(e,t,n,r)=>{for(var s=r>1?void 0:r?qp(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Zp=(e,t)=>(n,r)=>t(n,r,e);function Qp(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}d.Workbook=class extends Xr{constructor(n={},r){super();R(this,"type",Be.UNIVER_SHEET);R(this,"_sheetCreated$",new Ie.Subject);R(this,"sheetCreated$",this._sheetCreated$.asObservable());R(this,"_sheetDisposed$",new Ie.Subject);R(this,"sheetDisposed$",this._sheetDisposed$.asObservable());R(this,"_activeSheet$",new Ie.BehaviorSubject(null));R(this,"activeSheet$",this._activeSheet$.asObservable());R(this,"_worksheets");R(this,"_styles");R(this,"_snapshot");R(this,"_unitId");R(this,"_count");R(this,"_name$");R(this,"name$");this._logService=r;const s=Lp();re.isEmptyObject(n)?this._snapshot=s:this._snapshot=re.commonExtend(s,n);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=re.generateRandomId(6)),this._unitId=this._snapshot.id,this._styles=new iu(i),this._count=1,this._worksheets=new Map,this._name$=new Ie.BehaviorSubject(n.name||""),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(n){return typeof n=="string"||"startRow"in n||"row"in n}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete()}save(){return re.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(n){this._name$.next(n),this._snapshot.name=n}getUnitId(){return this._unitId}getRev(){var n;return(n=this._snapshot.rev)!=null?n:1}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(n){this._snapshot.rev=n}addWorksheet(n,r,s){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[n])return!1;i[n]=s,o.splice(r,0,n);const a=new cr(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()!==ve.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===ve.TRUE).map(n=>n.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden!==ve.TRUE).map(n=>n.getConfig().id)}load(n){this._snapshot=n}checkSheetName(n){return this.getSheetsName().includes(n)}uniqueSheetName(n="Sheet1"){let r=n;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}generateNewSheetName(n){let r=n+this._count;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}_parseWorksheetSnapshots(){const{_snapshot:n,_worksheets:r}=this,{sheets:s,sheetOrder:i}=n;if(re.isEmptyObject(s)){const o=re.generateRandomId();s[o]={id:o}}for(const o in s){const a=s[o],{name:l}=a;a.name=this.uniqueSheetName(l),a.name!==l&&this._logService.debug("[Workbook]",`The worksheet name ${l} is duplicated, we changed it to ${a.name}. Please fix the problem in your snapshot.`);const u=new cr(this._unitId,a,this._styles);r.set(o,u),i.includes(o)||i.push(o)}this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(n){this._snapshot.custom=n}},d.Workbook=Jp([Zp(1,It)],d.Workbook);class ui extends Xr{constructor(n){var r;super();R(this,"type",Be.UNIVER_SLIDE);R(this,"_activePage$",new Ie.BehaviorSubject(null));R(this,"activePage$",this._activePage$.asObservable());R(this,"_name$");R(this,"name$");R(this,"_snapshot");R(this,"_unitId");this._snapshot={...Po,...n},this._unitId=(r=this._snapshot.id)!=null?r:re.generateRandomId(6),this._name$=new Ie.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:kt(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=kt(6);return{id:n,pageType:Ts.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 eE=Object.getOwnPropertyDescriptor,tE=(e,t,n,r)=>{for(var s=r>1?void 0:r?eE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Su=(e,t)=>(n,r)=>t(n,r,e);const An=We.createIdentifier("univer.current");d.UniverInstanceService=class extends st{constructor(n,r){super();R(this,"_unitsByType",new Map);R(this,"_createHandler");R(this,"_ctorByType",new Map);R(this,"_currentUnits",new Map);R(this,"_currentUnits$",new Ie.BehaviorSubject(this._currentUnits));R(this,"currentUnits$",this._currentUnits$.asObservable());R(this,"_unitAdded$",new Ie.Subject);R(this,"unitAdded$",this._unitAdded$.asObservable());R(this,"_unitDisposed$",new Ie.Subject);R(this,"unitDisposed$",this._unitDisposed$.asObservable());R(this,"_focused$",new Ie.BehaviorSubject(null));R(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(Ie.map(r=>{var s;return(s=r.get(n))!=null?s:null}),Ie.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(Ie.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(Ie.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(Be.UNIVER_DOC)}getUniverDocInstance(n){return this.getUnit(n,Be.UNIVER_DOC)}getUniverSheetInstance(n){return this.getUnit(n,Be.UNIVER_SHEET)}getAllUnitsForType(n){var r;return(r=this._unitsByType.get(n))!=null?r:[]}changeDoc(n,r){const s=this.getAllUnitsForType(Be.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 d.Workbook?(this._contextService.setContextValue(or,!0),this._contextService.setContextValue(ar,!1),this._contextService.setContextValue(yn,!0),this._contextService.setContextValue(lr,!1),this.setCurrentUnitForType(n)):this.focused instanceof yt?(this._contextService.setContextValue(or,!0),this._contextService.setContextValue(ar,!0),this._contextService.setContextValue(yn,!1),this._contextService.setContextValue(lr,!1),this.setCurrentUnitForType(n)):this.focused instanceof ui?(this._contextService.setContextValue(or,!0),this._contextService.setContextValue(ar,!1),this._contextService.setContextValue(yn,!1),this._contextService.setContextValue(lr,!0),this.setCurrentUnitForType(n)):(this._contextService.setContextValue(or,!1),this._contextService.setContextValue(ar,!1),this._contextService.setContextValue(yn,!1),this._contextService.setContextValue(lr,!1))}getFocusedUnit(){return this.focused}getUnitType(n){const r=this._getUnitById(n);return r?r[1]:Be.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]}}},d.UniverInstanceService=tE([Su(0,We.Inject(We.Injector)),Su(1,dn)],d.UniverInstanceService);var Je=(e=>(e[e.Starting=0]="Starting",e[e.Ready=1]="Ready",e[e.Rendered=2]="Rendered",e[e.Steady=3]="Steady",e))(Je||{});const nE={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"};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},iE=(e,t)=>(n,r)=>t(n,r,e);d.LifecycleService=class extends st{constructor(n){super();R(this,"_lifecycle$",new Ie.BehaviorSubject(Je.Starting));R(this,"lifecycle$",this._lifecycle$.asObservable());R(this,"_lock",!1);this._logService=n,this._reportProgress(Je.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 Ie.firstValueFrom(this.lifecycle$.pipe(Ie.filter(r=>r>=n),us(r=>r===n),Ie.map(()=>{})))}subscribeWithPrevious(){return Ie.merge(vu(this.stage),this._lifecycle$.pipe(Ie.skip(1))).pipe(us(n=>n===Je.Steady))}_reportProgress(n){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${nE[n]}".`)}},d.LifecycleService=sE([iE(0,It)],d.LifecycleService);function vu(e){switch(e){case Je.Starting:return Ie.of(Je.Starting);case Je.Ready:return Ie.of(Je.Starting,Je.Ready);case Je.Rendered:return Ie.of(Je.Starting,Je.Ready,Je.Rendered);default:return Ie.of(Je.Starting,Je.Ready,Je.Rendered,Je.Steady)}}const oE=We.createIdentifier("ILocalStorageService");class cn extends st{constructor(){super();R(this,"_currentLocale$",new Ie.BehaviorSubject($n.ZH_CN));R(this,"currentLocale$",this._currentLocale$.asObservable());R(this,"_locales",null);R(this,"localeChanged$",new Ie.Subject);R(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(tt(()=>this.localeChanged$.complete()))}get _currentLocale(){return this._currentLocale$.value}load(n){var r;this._locales=js((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 ci=(e=>(e.INIT="init",e.FETCHING="fetching",e.DONE="done",e))(ci||{});const Ou=We.createIdentifier("univer.permission-service");class wu extends st{constructor(){super(...arguments);R(this,"_permissionPointMap",new Map);R(this,"_permissionPointUpdate$",new Ie.Subject);R(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable());R(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 Ie.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 Ie.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=ci.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 Ie.combineLatest(r).pipe(Lt.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}}var aE=Object.getOwnPropertyDescriptor,lE=(e,t,n,r)=>{for(var s=r>1?void 0:r?aE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},hi=(e,t)=>(n,r)=>t(n,r,e);const uE=4,bu=Symbol("DependentOn");class di extends st{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}R(di,"pluginName"),R(di,"type",Be.UNIVER_UNKNOWN);class cE{constructor(){R(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 hE(...e){return function(t){t[bu]=e}}d.PluginService=class{constructor(t,n,r){R(this,"_pluginRegistry",new Map);R(this,"_pluginStore",new cE);R(this,"_seenPlugins",new Set);R(this,"_loadedPlugins",new Set);R(this,"_loadedPluginTypes",new Set([Be.UNIVER_UNKNOWN]));R(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===Be.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===Be.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)},uE))}_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 u=a[bu];u&&u.forEach(c=>{const h=this._pluginRegistry.get(c.pluginName);if(h)s(h);else if(!this._seenPlugins.has(c.pluginName)&&!r.has(c.pluginName)){if(a.type===Be.UNIVER_UNKNOWN&&c.type!==Be.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 ${c.pluginName}.`);a.type!==c.type&&c.type!==Be.UNIVER_UNKNOWN&&this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${c.pluginName}" which has different type.`),this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${c.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(c),s({plugin:c,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(vu(n).subscribe(r=>this._runStage(t,r)),n!==Je.Steady){const r=this._lifecycleService.lifecycle$.pipe(Ie.skip(1)).subscribe(s=>{this._runStage(t,s),s===Je.Steady&&r.unsubscribe()})}}_runStage(t,n){t.forEach(r=>{switch(n){case Je.Starting:r.onStarting();break;case Je.Ready:r.onReady();break;case Je.Rendered:r.onRendered();break;case Je.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}},d.PluginService=lE([hi(0,We.Inject(We.Injector)),hi(1,We.Inject(d.LifecycleService)),hi(2,It)],d.PluginService);function yu(e,t){if(!t)return e;const n=[];for(const r of e){const s=t.find(([i])=>i===r[0]);if(s){if(s[1]===null)continue;n.push([r[0],s[1]])}else n.push(r)}return n}const fi=We.createIdentifier("resource-loader-service");class Au extends st{constructor(){super(...arguments);R(this,"_resourceMap",new Map);R(this,"_register$",new Ie.Subject);R(this,"register$",this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(n,r){return r?this.getResourcesByType(n,r):this.getAllResourceHooks().map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}getResourcesByType(n,r){return this.getAllResourceHooks().filter(o=>o.businesses.includes(r)).map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}registerPluginResource(n){const r=n.pluginName;if(this._resourceMap.has(r))throw new Error(`the pluginName is registered {${r}}`);return this._resourceMap.set(r,n),this._register$.next(n),tt(()=>this._resourceMap.delete(r))}disposePluginResource(n){this._resourceMap.delete(n)}loadResources(n,r){this.getAllResourceHooks().forEach(s=>{var o;const i=(o=r==null?void 0:r.find(a=>a.name===s.pluginName))==null?void 0:o.data;if(i)try{const a=s.parseJson(i);s.onLoad(n,a)}catch{console.error("LoadResources Error!")}})}unloadResources(n){this.getAllResourceHooks().forEach(r=>{r.onUnLoad(n)})}dispose(){this._register$.complete(),this._resourceMap.clear()}}class gi extends st{constructor(){super();R(this,"_currentTheme");R(this,"_currentTheme$",new Ie.BehaviorSubject({}));R(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(tt(()=>this._currentTheme$.complete()))}getCurrentTheme(){if(!this._currentTheme)throw new Error("[ThemeService]: current theme is not set!");return this._currentTheme}setTheme(n){this._currentTheme=n,this._currentTheme$.next(n)}}var dE=Object.getOwnPropertyDescriptor,fE=(e,t,n,r)=>{for(var s=r>1?void 0:r?dE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},mi=(e,t)=>(n,r)=>t(n,r,e);const ss=We.createIdentifier("univer.undo-redo.service"),gE=20;class Tu{dispose(){}async dispatchToHandlers(){return!1}}const Nu="univer.command.redo",Mu="univer.command.undo",Du=new class extends Tu{constructor(){super(...arguments);R(this,"type",kn.COMMAND);R(this,"id",Mu)}handler(t){const n=t.get(ss),r=n.pitchTopUndoElement();if(!r)return!1;const s=t.get(Pn);return _r(r.undoMutations,s)?(n.popUndoToRedo(),!0):!1}},Lu=new class extends Tu{constructor(){super(...arguments);R(this,"type",kn.COMMAND);R(this,"id",Nu)}handler(t){const n=t.get(ss),r=n.pitchTopRedoElement();if(!r)return!1;const s=t.get(Pn);return _r(r.redoMutations,s)?(n.popRedoToUndo(),!0):!1}};d.LocalUndoRedoService=class extends st{constructor(n,r,s){super();R(this,"undoRedoStatus$");R(this,"_undoRedoStatus$",new Ie.BehaviorSubject({undos:0,redos:0}));R(this,"_undoStacks",new Map);R(this,"_redoStacks",new Map);R(this,"_batchingStatus",new Map);this._univerInstanceService=n,this._commandService=r,this._contextService=s,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(Du)),this.disposeWithMe(this._commandService.registerCommand(Lu)),this.disposeWithMe(tt(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(tt(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>gE&&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(),_r(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),tt(()=>this._batchingStatus.delete(n))}_updateStatus(){var i,o;const n=this._getFocusedUnitId(),r=n&&((i=this._undoStacks.get(n))==null?void 0:i.length)||0,s=n&&((o=this._redoStacks.get(n))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:r,redos:s})}_getUndoStack(n,r=!1){let s=this._undoStacks.get(n);return!s&&r&&(s=[],this._undoStacks.set(n,s)),s||null}_getRedoStack(n,r=!1){let s=this._redoStacks.get(n);return!s&&r&&(s=[],this._redoStacks.set(n,s)),s||null}_getUndoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getUndoStack(n,!0)}_getRedoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getRedoStack(n,!0)}_tryBatchingElements(n,r){n.redoMutations.push(...r.redoMutations),n.undoMutations.push(...r.undoMutations)}_getFocusedUnitId(){var o,a,l,u;let n="";const r=this._contextService.getContextValue(yn),s=this._contextService.getContextValue(ru),i=this._contextService.getContextValue(nu);return r?s?n=vs:i?n=Ss:n=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":n=(u=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?u:"",n}},d.LocalUndoRedoService=fE([mi(0,An),mi(1,Pn),mi(2,dn)],d.LocalUndoRedoService);function mE(e){return!(e.length===0||e.length>31||e.startsWith("'")||e.endsWith("'")||/[:\\\/\?\*\[\]]/.test(e))}function _E(e){return new Promise(t=>setTimeout(t,e))}function pE(e=1){return new Promise(t=>{let n=0;const r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}var _i=(e=>(e.URL="URL",e.UUID="UUID",e.BASE64="BASE64",e))(_i||{}),Uu=(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))(Uu||{});const pi=We.createIdentifier("core.image-io.service");class ku{constructor(t,n=100){R(this,"_imageCacheMap");this._injector=t,this._imageCacheMap=new Hn(n)}_getImageCacheKey(t,n){return`${t}-${n}`}getImage(t,n,r,s){const i=this._getImageCacheKey(t,n);let o=this._imageCacheMap.get(i);return o||((async()=>{o=new Image;const a=this._injector.has(pi)?this._injector.get(pi):null;if(t===_i.UUID)try{o.src=await(a==null?void 0:a.getImage(n))||""}catch(l){console.error(l)}else o.src=n;o.onload=()=>{r==null||r()},o.onerror=()=>{s==null||s()},this._imageCacheMap.set(i,o)})(),null)}}const EE=["script","style","meta","comment","link"];var Pu=(e=>(e[e.INFO=0]="INFO",e[e.STOP=1]="STOP",e[e.WARNING=2]="WARNING",e))(Pu||{}),Fu=(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))(Fu||{}),xu=(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))(xu||{}),$u=(e=>(e[e.TEXT=0]="TEXT",e[e.ARROW=1]="ARROW",e[e.CUSTOM=2]="CUSTOM",e))($u||{}),Bu=(e=>(e.VALID="valid",e.INVALID="invalid",e.VALIDATING="validating",e))(Bu||{}),Hu=(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))(Hu||{}),CE=Object.getOwnPropertyDescriptor,RE=(e,t,n,r)=>{for(var s=r>1?void 0:r?CE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},IE=(e,t)=>(n,r)=>t(n,r,e);d.Skeleton=class extends st{constructor(n){super();R(this,"_fontLocale");R(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(){}},d.Skeleton=RE([IE(0,We.Inject(cn))],d.Skeleton);var SE=Object.getOwnPropertyDescriptor,vE=(e,t,n,r)=>{for(var s=r>1?void 0:r?SE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},is=(e,t)=>(n,r)=>t(n,r,e);d.SheetSkeleton=class extends d.Skeleton{constructor(n,r,s,i,o,a){super(s);R(this,"_worksheetData");R(this,"_renderRawFormula",!1);R(this,"_cellData");R(this,"_imageCacheMap");R(this,"_isRowStylePrecedeColumnStyle",!1);R(this,"_skipAutoHeightForMergedCells",!0);R(this,"_rowTotalHeight",0);R(this,"_columnTotalWidth",0);R(this,"_rowHeaderWidth",0);R(this,"_columnHeaderHeight",0);R(this,"_rowHeightAccumulation",[]);R(this,"_columnWidthAccumulation",[]);R(this,"_marginTop",0);R(this,"_marginLeft",0);R(this,"_scaleX");R(this,"_scaleY");R(this,"_scrollX");R(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 ku(this._injector),this.initConfig()}initConfig(){var n,r;this._skipAutoHeightForMergedCells=!((n=this._configService.getConfig(Uo))!=null&&n),this._isRowStylePrecedeColumnStyle=(r=this._configService.getConfig(Lo))!=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){re.isDefine(n)&&(this._scrollX=n),re.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 u=s;if(this.worksheet.getRowFiltered(l))u=0;else if(a[l]!=null){const c=a[l];if(!c)continue;const{h=s,ah:f,ia:g}=c;(g==null||g===ve.TRUE)&&typeof f=="number"?u=f:u=h,c.hd===ve.TRUE&&(u=0)}i+=u,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 u=s;if(a[l]!=null){const c=a[l];if(!c)continue;c.w!=null&&(u=c.w),c.hd===ve.TRUE&&(u=0)}i+=u,o.push(i)}return{columnTotalWidth:i,columnWidthAccumulation:o}}intersectMergeRange(n,r){return!!this.worksheet.getMergedCell(n,r)}_getOverflowBound(n,r,s,i,o=St.LEFT){let a=0;if(r>s){const l=this._columnWidthAccumulation.length-1;for(let u=r;u>=s;u--){const c=u,h=this.worksheet.getCell(n,c);if(!_s(h)&&c!==r||this.intersectMergeRange(n,c))return c===r?c:c+1>l?l:c+1;const{startX:f,endX:g}=Tn(n,c,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===St.CENTER&&c===r?a+=(g-f)/2:a+=g-f,i<a)return c}return r}for(let l=r;l<=s;l++){const u=l,c=this.worksheet.getCell(n,u);if(!_s(c)&&u!==r||this.intersectMergeRange(n,u))return u===r?u:u-1<0?0:u-1;const{startX:h,endX:f}=Tn(n,u,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===St.CENTER&&u===r?a+=(f-h)/2:a+=f-h,i<a)return u}return s}_updateLayout(){if(!this.dirty)return;const{rowData:n,columnData:r,defaultRowHeight:s,defaultColumnWidth:i,rowCount:o,columnCount:a,rowHeader:l,columnHeader:u}=this._worksheetData,{rowTotalHeight:c,rowHeightAccumulation:h}=this._generateRowMatrixCache(o,n,s),{columnTotalWidth:f,columnWidthAccumulation:g}=this._generateColumnMatrixCache(a,r,i);this._rowHeaderWidth=l.hidden!==ve.TRUE?this._dynamicallyUpdateRowHeaderWidth(l):0,this._columnHeaderHeight=u.hidden!==ve.TRUE?u.height:0,this._rowTotalHeight=c,this._rowHeightAccumulation=h,this._columnTotalWidth=f,this._columnWidthAccumulation=g,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 u=new Ot;for(;l;){l=!1;for(let c=0;c<a.length;c++){const{startRow:h,startColumn:f,endRow:g,endColumn:C}=a[c];if(u.getValue(h,f))continue;Ho({startColumn:s,startRow:r,endColumn:o,endRow:i},{startColumn:f,startRow:h,endColumn:C,endRow:g})&&(r=Math.min(r,h),s=Math.min(s,f),i=Math.max(i,g),o=Math.max(o,C),u.setValue(h,f,!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:u,endY:c,startX:h,endX:f}=Tn(n,r,i,o);return s&&(u+=l,c+=l,h+=a,f+=a),{startY:u,endY:c,startX:h,endX:f}}getNoMergeCellPositionByIndexWithNoHeader(n,r){const{rowHeightAccumulation:s,columnWidthAccumulation:i}=this,{startY:o,endY:a,startX:l,endX:u}=Tn(n,r,s,i);return{startY:o,endY:a,startX:l,endX:u}}getRowIndexByOffsetY(n,r,s,i){var l;const{rowHeightAccumulation:o}=this;n=ju(n,r,s,this.columnHeaderHeightAndMarginTop);let a=Fn(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 u;const o=Wu(n,r,s,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this;let l=Fn(a,o,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(a[l]-o)<Math.abs(o-((u=a[l-1])!=null?u:0))&&(l=l+1),l}getCellIndexByOffset(n,r,s,i,o,a){const l=this.getRowIndexByOffsetY(r,i,o,a),u=this.getColumnIndexByOffsetX(n,s,o,a);return{row:l,column:u}}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,u=Tn(n,r,i,o,this.worksheet.getCellInfoInMergeData(n,r)),{isMerged:c,isMergedMainCell:h}=u;let{startY:f,endY:g,startX:C,endX:I,mergeInfo:b}=u,U=a,Z=l;return s===!1&&(U=0,Z=0),f+=Z,g+=Z,C+=U,I+=U,b.startY+=Z,b.endY+=Z,b.startX+=U,b.endX+=U,{actualRow:n,actualColumn:r,startX:C,startY:f,endX:I,endY:g,isMerged:c,isMergedMainCell:h,mergeInfo:b}}getCellWithCoordByOffset(n,r,s,i,o,a){const{row:l,column:u}=this.getCellIndexByOffset(n,r,s,i,o,a);return this.getCellWithCoordByIndex(l,u)}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=Fn(this.columnWidthAccumulation,n);let i=0;s===0?i=n:i=n-this._columnWidthAccumulation[s-1];const o=Fn(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,u,c,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=(u=s.b)!=null?u:2,n.documentStyle.marginLeft=(c=s.l)!=null?c: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 f of o)f.paragraphStyle||(f.paragraphStyle={}),f.paragraphStyle.horizontalAlign=r;return new yt(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}},d.SheetSkeleton=vE([is(2,We.Inject(cn)),is(3,dn),is(4,ai),is(5,We.Inject(We.Injector))],d.SheetSkeleton);function Ei(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 u=r[t];return u==null&&(u=r[r.length-1]),{startY:o,endY:a,startX:l,endX:u}}function OE(e,t,n,r){return Ei(e,t,n,r)}function Tn(e,t,n,r,s){e=re.clamp(e,0,n.length-1),t=re.clamp(t,0,r.length-1);let{startY:i,endY:o,startX:a,endX:l}=Ei(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:u,isMergedMainCell:c,startRow:h,startColumn:f,endRow:g,endColumn:C}=s;let I={startRow:h,startColumn:f,endRow:g,endColumn:C,startY:i,endY:o,startX:a,endX:l};const b=n.length-1,U=r.length-1;if(u&&h!==-1&&f!==-1){const Z=n[h-1]||0,V=n[g]||n[b],fe=r[f-1]||0,M=r[C]||r[U];I={...I,startY:Z,endY:V,startX:fe,endX:M}}else if(!u&&g!==-1&&C!==-1){const Z=n[g]||n[b],V=r[C]||r[U];I={...I,startY:i,endY:Z,startX:a,endX:V}}return{isMerged:u,isMergedMainCell:c,actualRow:e,actualColumn:t,startY:i,endY:o,startX:a,endX:l,mergeInfo:I}}function Wu(e,t,n,r){const{x:s}=n;return e/t+s-r}function ju(e,t,n,r){const{y:s}=n;return e=e/t+s-r,e}const Yu=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],Ci=1,hr=8;class Ri{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!==Ci)throw new Error(`Got v${s} data when expected v${Ci}.`);const i=Yu[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 Ri(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=Yu.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,hr,t),this.coords=new this.ArrayType(this.data,hr+a+l,t*2),this._pos=t*2,this._finished=!0):(this.data=new ArrayBuffer(hr+o+a+l),this.ids=new this.IndexArrayType(this.data,hr,t),this.coords=new this.ArrayType(this.data,hr+a+l,t*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(Ci<<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 Ii(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,n,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:o,nodeSize:a}=this,l=[0,i.length-1,0],u=[];for(;l.length;){const c=l.pop()||0,h=l.pop()||0,f=l.pop()||0;if(h-f<=a){for(let b=f;b<=h;b++){const U=o[2*b],Z=o[2*b+1];U>=t&&U<=r&&Z>=n&&Z<=s&&u.push(i[b])}continue}const g=f+h>>1,C=o[2*g],I=o[2*g+1];C>=t&&C<=r&&I>=n&&I<=s&&u.push(i[g]),(c===0?t<=C:n<=I)&&(l.push(f),l.push(g-1),l.push(1-c)),(c===0?r>=C:s>=I)&&(l.push(g+1),l.push(h),l.push(1-c))}return u}within(t,n,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:i,nodeSize:o}=this,a=[0,s.length-1,0],l=[],u=r*r;for(;a.length;){const c=a.pop()||0,h=a.pop()||0,f=a.pop()||0;if(h-f<=o){for(let b=f;b<=h;b++)Vu(i[2*b],i[2*b+1],t,n)<=u&&l.push(s[b]);continue}const g=f+h>>1,C=i[2*g],I=i[2*g+1];Vu(C,I,t,n)<=u&&l.push(s[g]),(c===0?t-r<=C:n-r<=I)&&(a.push(f),a.push(g-1),a.push(1-c)),(c===0?t+r>=C:n+r>=I)&&(a.push(g+1),a.push(h),a.push(1-c))}return l}}function Ii(e,t,n,r,s,i){if(s-r<=n)return;const o=r+s>>1;zu(e,t,o,r,s,i),Ii(e,t,n,r,o-1,1-i),Ii(e,t,n,o+1,s,1-i)}function zu(e,t,n,r,s,i){for(;s>r;){if(s-r>600){const u=s-r+1,c=n-r+1,h=Math.log(u),f=.5*Math.exp(2*h/3),g=.5*Math.sqrt(h*f*(u-f)/u)*(c-u/2<0?-1:1),C=Math.max(r,Math.floor(n-c*f/u+g)),I=Math.min(s,Math.floor(n+(u-c)*f/u+g));zu(e,t,n,C,I,i)}const o=t[2*n+i];let a=r,l=s;for(dr(e,t,r,n),t[2*s+i]>o&&dr(e,t,r,s);a<l;){for(dr(e,t,a,l),a++,l--;t[2*a+i]<o;)a++;for(;t[2*l+i]>o;)l--}t[2*r+i]===o?dr(e,t,r,l):(l++,dr(e,t,l,s)),l<=n&&(r=l+1),n<=l&&(s=l-1)}}function dr(e,t,n,r){Si(e,n,r),Si(t,2*n,2*r),Si(t,2*n+1,2*r+1)}function Si(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function Vu(e,t,n,r){const s=e-n,i=t-r;return s*s+i*i}class wE{constructor(t=!1){R(this,"_tree",new Map);R(this,"_oneCellCache",new Map);R(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 $r),this._tree.get(t).get(n)}_getOneCellCache(t,n,r,s){return this._oneCellCache.has(t)||this._oneCellCache.set(t,new Map),this._oneCellCache.get(t).has(n)||this._oneCellCache.get(t).set(n,new Map),this._oneCellCache.get(t).get(n).has(r)||this._oneCellCache.get(t).get(n).set(r,new Map),this._oneCellCache.get(t).get(n).get(r).has(s)||this._oneCellCache.get(t).get(n).get(r).set(s,new Set),this._oneCellCache.get(t).get(n).get(r).get(s)}_removeOneCellCache(t,n,r,s,i){const o=this._oneCellCache.get(t);if(!o)return;const a=o.get(n);if(!a)return;const l=a.get(r);if(!l)return;const u=l.get(s);u&&u.delete(i)}_removeCellCacheByRange(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this._oneCellCache.get(n);if(!o)return;const a=o.get(r);if(!a)return;const{startRow:l,startColumn:u,endRow:c,endColumn:h}=s;for(let f=l;f<=c;f++){const g=a.get(f);if(g)for(let C=u;C<=h;C++){const I=g.get(C);I&&I.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 C;const{unitId:n,sheetId:r,range:s}=t,{startRow:i,startColumn:o,endRow:a,endColumn:l}=s,u=(C=this._kdTree.get(n))==null?void 0:C.get(r);if(!u)return[];const{tree:c,items:h}=u,f=c.range(o,i,l,a),g=[];for(const I of f){const b=h[I];g.push(...Array.from(b.ids))}return g}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 Ri(o.length);(t=this._kdTree.get(n))==null||t.set(s,{tree:a,items:o});for(const l of o)a.add(l.x,l.y);a.finish()}}}closeKdTree(){var t;for(const[n,r]of this._oneCellCache)for(const[s,i]of r)(t=this._kdTree.get(n))==null||t.set(s,void 0)}insert(t){const{unitId:n,sheetId:r,range:s,id:i}=t;if(!n||n.length===0)return;let{startRow:o,endRow:a,startColumn:l,endColumn:u}=s;if(this._enableOneCellCache&&o===a&&l===u){this._insertOneCellCache(n,r,o,l,i);return}const c=this.getTree(n,r);Number.isNaN(o)&&(o=0),Number.isNaN(l)&&(l=0),Number.isNaN(a)&&(a=Number.POSITIVE_INFINITY),Number.isNaN(u)&&(u=Number.POSITIVE_INFINITY),c.insert({minX:l,minY:o,maxX:u,maxY:a,id:i})}bulkInsert(t){for(const n of t)this.insert(n)}*searchGenerator(t){var a;const{unitId:n,sheetId:r,range:s}=t;if(this._enableOneCellCache){const l=this._searchByOneCellCache(t);for(const u of l)yield u}const i=(a=this._tree.get(n))==null?void 0:a.get(r);if(!i)return;const o=i.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(const l of o)yield l.id}bulkSearch(t,n){const r=new Set;for(const s of t)for(const i of this.searchGenerator(s))(n==null?void 0:n.has(i))!==!0&&r.add(i);return r}removeById(t,n){var r,s;n?((r=this._tree.get(t))==null||r.delete(n),(s=this._oneCellCache.get(t))==null||s.delete(n)):(this._tree.delete(t),this._oneCellCache.delete(t))}_removeRTreeItem(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this.getTree(n,r),a=o.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(let l=0;l<a.length;l++)a[l].id===i&&o.remove(a[l])}remove(t){const{unitId:n,sheetId:r,range:s,id:i}=t,{startRow:o,startColumn:a,endRow:l,endColumn:u}=s;this._enableOneCellCache?o===l&&a===u?this._removeOneCellCache(n,r,s.startRow,s.startColumn,i):(this._removeCellCacheByRange(t),this._removeRTreeItem(t)):this._removeRTreeItem(t)}bulkRemove(t){for(const n of t)this.remove(n)}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){const t={};return this._tree.forEach((n,r)=>{t[r]={},n.forEach((s,i)=>{t[r][i]=s.toJSON()})}),t}fromJSON(t){this._tree.clear();for(const n in t){this._tree.set(n,new Map);for(const r in t[n]){const s=new $r;s.fromJSON(t[n][r]),this._tree.get(n).set(r,s)}}}}var bE=Object.getOwnPropertyDescriptor,yE=(e,t,n,r)=>{for(var s=r>1?void 0:r?bE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Gu=(e,t)=>(n,r)=>t(n,r,e);let vi=class extends st{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){const e=n=>{n.businesses.forEach(r=>{switch(r){case Be.UNRECOGNIZED:case Be.UNIVER_UNKNOWN:case Be.UNIVER_SLIDE:case Be.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType(Be.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 Be.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(Be.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$(Be.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(Be.UNIVER_DOC).subscribe(n=>{const r=n.getUnitId();ko(r)||this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(Be.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(Be.UNIVER_DOC).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())}))}saveUnit(e){const t=this._univerInstanceService.getUnit(e);if(!t)return null;const n=this._resourceManagerService.getResources(e,t.type),r=re.deepClone(t.getSnapshot());return r.resources=n,r}};vi=yE([Gu(0,We.Inject(ns)),Gu(1,We.Inject(An))],vi);class AE{constructor(t={},n){R(this,"_startedTypes",new Set);R(this,"_injector");R(this,"_disposingCallbacks",new mr);const r=this._injector=TE(n,t==null?void 0:t.override),{theme:s,locale:i,locales:o,logLevel:a}=t;s&&this._injector.get(gi).setTheme(s),o&&this._injector.get(cn).load(o),i&&this._injector.get(cn).setLocale(i),a&&this._injector.get(It).setLogLevel(a),this._init(r)}get _univerInstanceService(){return this._injector.get(An)}get _pluginService(){return this._injector.get(d.PluginService)}__getInjector(){return this._injector}onDispose(t){const n=this._disposingCallbacks.add(tt(t));return tt(()=>n.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(t){this._injector.get(cn).setLocale(t)}createUnit(t,n){return this._univerInstanceService.createUnit(t,n)}createUniverSheet(t){return this._injector.get(It).warn("[Univer]","Univer.createUniverSheet is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(Be.UNIVER_SHEET,t)}createUniverDoc(t){return this._injector.get(It).warn("[Univer]","Univer.createUniverDoc is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(Be.UNIVER_DOC,t)}createUniverSlide(t){return this._injector.get(It).warn("[Univer]","Univer.createUniverSlide is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(Be.UNIVER_SLIDE,t)}_init(t){this._univerInstanceService.registerCtorForType(Be.UNIVER_SHEET,d.Workbook),this._univerInstanceService.registerCtorForType(Be.UNIVER_DOC,yt),this._univerInstanceService.registerCtorForType(Be.UNIVER_SLIDE,ui);const n=t.get(An);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(d.LifecycleService).stage<Je.Ready&&(this._injector.get(d.LifecycleService).stage=Je.Ready)}registerPlugin(t,n){this._pluginService.registerPlugin(t,n)}}function TE(e,t){const n=yu([[su],[cn],[gi],[d.LifecycleService],[d.PluginService],[ir],[An,{useClass:d.UniverInstanceService}],[Ou,{useClass:wu}],[It,{useClass:Ui,lazy:!0}],[Pn,{useClass:d.CommandService}],[ss,{useClass:d.LocalUndoRedoService,lazy:!0}],[ai,{useClass:tu}],[dn,{useClass:Di}],[ns,{useClass:Au,lazy:!0}],[fi,{useClass:vi,lazy:!0}],[Ql,{useClass:d.AuthzIoLocalService}],[eu,{useClass:d.MentionIOLocalService,lazy:!0}]],t),r=e?e.createChild(n):new We.Injector(n);return Oi(r,[[ir],[fi]]),r}Qu(),d.ABCToNumber=Fd,d.AUTO_HEIGHT_FOR_MERGED_CELLS=Uo,d.AbsoluteRefType=nt,d.ActionIterator=On,d.AlignTypeH=ma,d.AlignTypeV=_a,d.ArrangeTypeEnum=Ca,d.ArrowsAndMarkersShapes=Zi,d.AsyncInterceptorManager=up,d.AutoFillSeries=Hi,d.BaselineOffset=Ut,d.BasicShapes=Ji,d.BlockType=Ko,d.BooleanNumber=ve,d.BorderStyleTypes=qe,d.BorderType=Wi,d.BuildTextUtils=ot,d.BulletAlignment=Kn,d.COLORS=fs,d.CanceledError=oc,d.CellModeEnum=fn,d.CellValueType=Ht,d.Color=nn,d.ColorBuilder=Sr,d.ColorKit=vt,d.ColorType=_t,d.ColumnSeparatorType=Jo,d.CommandType=kn,d.CommonHideTypes=ji,d.ConfigService=tu,d.ContextService=Di,d.CopyPasteType=Yi,d.CustomCommandExecutionError=as,d.CustomDecorationType=rn,d.CustomRangeType=zt,d.DEFAULT_CELL=Ed,d.DEFAULT_DOC=ri,d.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=mp,d.DEFAULT_EMPTY_DOCUMENT_VALUE=Do,d.DEFAULT_RANGE=_d,d.DEFAULT_RANGE_ARRAY=md,d.DEFAULT_SELECTION=pd,d.DEFAULT_SLIDE=Po,d.DEFAULT_STYLES=lt,d.DEFAULT_WORKSHEET_COLUMN_COUNT=fu,d.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=jp,d.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=pu,d.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=Gp,d.DEFAULT_WORKSHEET_COLUMN_WIDTH=mu,d.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=zp,d.DEFAULT_WORKSHEET_ROW_COUNT=du,d.DEFAULT_WORKSHEET_ROW_COUNT_KEY=Wp,d.DEFAULT_WORKSHEET_ROW_HEIGHT=gu,d.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=Yp,d.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=_u,d.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=Vp,d.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=vs,d.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=Ss,d.DOCS_ZEN_EDITOR_UNIT_ID_KEY=Mo,d.DOC_RANGE_TYPE=ho,d.DashStyleType=sa,d.DataStreamTreeNodeType=va,d.DataStreamTreeTokenType=Vt,d.DataValidationErrorStyle=Pu,d.DataValidationImeMode=Fu,d.DataValidationOperator=xu,d.DataValidationRenderMode=$u,d.DataValidationStatus=Bu,d.DataValidationType=Hu,d.DeleteDirection=zi,d.DependentOn=hE,d.DesktopLogService=Ui,d.DeveloperMetadataVisibility=Vi,d.Dimension=Gi,d.Direction=Ki,d.Disposable=st,d.DisposableCollection=mr,d.DocStyleType=Vo,d.DocumentDataModel=yt,d.DocumentFlavor=As,d.DrawingTypeEnum=Ra,d.EDITOR_ACTIVATED=nu,d.EXTENSION_NAMES=Fo,d.ErrorService=su,d.EventState=Jl,d.EventSubject=_p,d.FOCUSING_COMMON_DRAWINGS=Np,d.FOCUSING_DOC=ar,d.FOCUSING_EDITOR_BUT_HIDDEN=Op,d.FOCUSING_EDITOR_INPUT_FORMULA=wp,d.FOCUSING_EDITOR_STANDALONE=yp,d.FOCUSING_FX_BAR_EDITOR=ru,d.FOCUSING_PANEL_EDITOR=Ap,d.FOCUSING_SHEET=yn,d.FOCUSING_SLIDE=lr,d.FOCUSING_UNIT=or,d.FOCUSING_UNIVER_EDITOR=bp,d.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=Tp,d.FORMULA_EDITOR_ACTIVATED=Mp,d.FollowNumberWithType=Go,d.FontItalic=Er,d.FontStyleType=pn,d.FontWeight=Cr,d.GridType=Xo,d.HLSColor=lo,d.HorizontalAlign=St,d.IAuthzIoService=Ql,d.ICommandService=Pn,d.IConfigService=ai,d.IContextService=dn,d.IImageIoService=pi,d.ILocalStorageService=oE,d.ILogService=It,d.IMentionIOService=eu,d.IPermissionService=Ou,d.IResourceLoaderService=fi,d.IResourceManagerService=ns,d.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=Lo,d.IUndoRedoService=ss,d.IUniverInstanceService=An,d.ImageCacheMap=ku,d.ImageSourceType=_i,d.ImageUploadStatusType=Uu,d.InterceptorEffectEnum=bn,d.InterceptorManager=op,d.InterpolationPointType=Xi,d.JSON1=s_,d.JSONX=xt,d.LRUHelper=Wn,d.LRUMap=Hn,d.LifecycleStages=Je,d.ListGlyphType=Ne,d.LocaleService=cn,d.LocaleType=$n,d.LogLevel=Li,d.MOVE_BUFFER_VALUE=xn,d.MemoryCursor=wn,d.MentionType=pr,d.NamedStyleType=na,d.NilCommand=Pi,d.NumberUnitType=ga,d.ObjectMatrix=Ot,d.ObjectRelativeFromH=da,d.ObjectRelativeFromV=fa,d.OtherShapes=Qi,d.PRESET_LIST_TYPE=tr,d.PageElementType=Ia,d.PageOrientType=Ea,d.PageType=Ts,d.ParagraphElementType=Qo,d.ParagraphStyleBuilder=sr,d.ParagraphStyleValue=rr,d.PermissionService=wu,d.PermissionStatus=ci,d.Plugin=di,d.PositionedObjectLayoutType=ta,d.PresetListType=Mt,d.ProtectionType=qi,d.QuickListType=Ll,d.QuickListTypeMap=c_,d.RANGE_DIRECTION=co,d.RANGE_TYPE=Le,d.RBush=$r,d.RCDisposable=dc,d.RGBA_PAREN=Hc,d.RGB_PAREN=Bc,d.ROTATE_BUFFER_VALUE=Bi,d.RTree=wE,d.Range=gn,d.Rectangle=Yt,d.RedoCommand=Lu,d.RedoCommandId=Nu,d.RefAlias=Pd,d.Registry=si,d.RegistryAsMap=ii,d.RelativeDate=to,d.RelativeSlideLink=Sa,d.ResourceManagerService=Au,d.RgbColor=vr,d.RichTextBuilder=un,d.RichTextValue=qt,d.RxDisposable=hc,d.SHEET_EDITOR_UNITS=Cd,d.SectionType=qo,d.SheetTypes=no,d.SheetViewModel=Cu,d.SliceBodyType=ti,d.SlideDataModel=ui,d.SpacingRule=ra,d.SpecialShapes=eo,d.Styles=iu,d.THEME_COLORS=ao,d.TabStopAlignment=ia,d.TableAlignmentType=aa,d.TableLayoutType=la,d.TableRowHeightRule=ca,d.TableSizeType=oa,d.TableTextWrapType=ua,d.TextDecoration=ro,d.TextDecorationBuilder=Xt,d.TextDirection=Bn,d.TextDirectionType=Zo,d.TextStyleBuilder=Kt,d.TextStyleValue=nr,d.TextX=ze,d.TextXActionType=he,d.ThemeColor=Or,d.ThemeColorType=ct,d.ThemeColors=Rr,d.ThemeService=gi,d.Tools=re,d.UndoCommand=Du,d.UndoCommandId=Mu,d.UnitModel=Xr,d.Univer=AE,d.UniverInstanceType=Be,d.UpdateDocsAttributeType=ke,d.UserManagerService=ir,d.VerticalAlign=en,d.VerticalAlignmentType=ha,d.Worksheet=cr,d.WrapStrategy=tn,d.WrapTextType=ea,d.addLinkToDocumentModel=lu,d.afterInitApply=Ic,d.afterTime=Rc,d.awaitTime=_E,d.binSearchFirstGreaterThanTarget=$i,d.binarySearchArray=Sc,d.bufferDebounceTime=Cc,d.cellToRange=mh,d.characterSpacingControlType=pa,d.checkForSubstrings=_h,d.checkIfMove=Oc,d.checkParagraphHasBullet=Zh,d.checkParagraphHasIndent=Qh,d.checkParagraphHasIndentByStyle=wo,d.codeToBlob=vc,d.composeBody=ni,d.composeInterceptors=Xl,d.composeStyles=hs,d.concatMatrixArray=cd,d.convertBodyToHtml=$c,d.convertCellToRange=fo,d.covertTextRunToHtml=ds,d.createAsyncInterceptorKey=ap,d.createDefaultUser=rs,d.createDocumentModelWithStyle=ur,d.createInterceptorKey=ip,d.createInternalEditorID=gd,d.createRowColIter=ys,d.dayjs=Pt,d.debounce=Bm,d.dedupe=ec,d.deepCompare=ps,d.delayAnimationFrame=pE,d.deleteContent=yo,d.extractPureTextFromCell=Iu,d.fromCallback=Fi,d.fromEventSubject=pp,d.fromObservable=cc,d.generateRandomId=kt,d.get=pm,d.getArrayLength=jt,d.getBodySlice=bt,d.getBodySliceHtml=Ir,d.getBorderStyleType=dh,d.getCellCoordByIndexSimple=Ei,d.getCellInfoInMergeData=oh,d.getCellPositionByIndexSimple=OE,d.getCellValueType=nh,d.getCellWithCoordByIndexCore=Tn,d.getColorStyle=Tt,d.getCustomBlockSlice=xl,d.getCustomDecorationSlice=Bl,d.getCustomRangeSlice=$l,d.getDocsUpdateBody=fh,d.getIntersectRange=Ho,d.getOriginCellValue=Xp,d.getParagraphsSlice=Fl,d.getPlainText=jr,d.getReverseDirection=wc,d.getSectionBreakSlice=C_,d.getTableSlice=Pl,d.getTextRunSlice=ts,d.getTransformOffsetX=Wu,d.getTransformOffsetY=ju,d.getWorksheetUID=Qp,d.groupBy=rc,d.handleStyleToString=hh,d.hashAlgorithm=td,d.horizontalLineSegmentsSubtraction=Pr,d.insertMatrixArray=Cs,d.insertTextToContent=bo,d.isBlackColor=Qc,d.isBooleanString=qm,d.isCellCoverable=_s,d.isCellV=sh,d.isEmptyCell=go,d.isFormulaId=ch,d.isFormulaString=uh,d.isICellData=th,d.isInternalEditorID=ko,d.isNodeEnv=xc,d.isNotNullOrUndefined=uu,d.isNullCell=rh,d.isNumeric=ql,d.isRangesEqual=Up,d.isRealNum=ed,d.isSafeNumeric=hp,d.isSameStyleTextRun=mo,d.isUnitRangesEqual=kp,d.isValidRange=gh,d.isWhiteColor=eh,d.makeArray=sc,d.makeCellRangeToRangeData=lh,d.makeCellToSelection=ah,d.makeCustomRangeStream=jd,d.merge=js,d.mergeOverrideWithDependencies=yu,d.mergeSets=fp,d.mergeWith=Ym,d.mergeWorksheetSnapshotWithDefault=Eu,d.mixinClass=cp,d.moveMatrixArray=Is,d.moveRangeByOffset=bd,d.nameCharacterCheck=mE,d.normalizeBody=R_,d.normalizeTextRuns=er,d.numberToABC=$d,d.numberToListABC=Bd,d.numfmt=ud,d.queryObjectMatrix=kd,d.registerDependencies=ic,d.remove=Ln,d.repeatStringNumTimes=zo,d.replaceInDocumentBody=gp,d.requestImmediateMacroTask=dp,d.rotate=nc,d.searchArray=Fn,d.searchInOrderedArray=xi,d.selectionToArray=ih,d.sequence=bi,d.sequenceAsync=wi,d.sequenceExecute=_r,d.sequenceExecuteAsync=Ec,d.set=Vm,d.shallowEqual=al,d.skipParseTagNames=EE,d.sliceMatrixArray=hd,d.sortRules=Hd,d.sortRulesByDesc=Wd,d.sortRulesFactory=Gn,d.spliceArray=Rs,d.splitIntoGrid=bs,d.takeAfter=us,d.textDiff=zs,d.throttle=sp,d.toDisposable=tt,d.touchDependencies=Oi,d.updateAttributeByDelete=Hl,d.updateAttributeByInsert=Wl,Object.keys(We).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(d,e)&&Object.defineProperty(d,e,{enumerable:!0,get:()=>We[e]})}),Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});