@univerjs/core 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +9 -9
- package/lib/es/index.js +8 -8
- package/lib/index.js +8 -8
- package/lib/types/common/const.d.ts +1 -1
- package/lib/types/types/enum/theme-color-type.d.ts +2 -0
- package/lib/types/types/interfaces/i-style-data.d.ts +62 -0
- package/lib/umd/index.js +9 -9
- package/package.json +5 -5
package/lib/es/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import e from"async-lock";import{Inject as t,Inject as n,InjectSelf as r,Injector as i,Injector as a,LookUp as o,Many as s,Optional as c,Quantity as l,RediError as u,Self as d,SkipSelf as f,WithNew as p,createIdentifier as m,createIdentifier as h,forwardRef as g,isAsyncDependencyItem as _,isAsyncHook as ee,isClassDependencyItem as te,isCtor as ne,isDisposable as re,isFactoryDependencyItem as ie,isValueDependencyItem as ae,setDependencies as oe}from"@wendellhu/redi";import{debounce as se,get as ce,merge as le,mergeWith as ue,set as de}from"lodash-es";import{BehaviorSubject as v,Observable as fe,ReplaySubject as pe,Subject as y,Subscription as me,combineLatest as he,debounceTime as ge,distinctUntilChanged as _e,filter as ve,firstValueFrom as ye,map as be,merge as xe,of as Se,skip as Ce,take as we,tap as Te,timer as Ee}from"rxjs";import{ObjectScope as De,UnitRole as b,UniverType as Oe,UniverType as x}from"@univerjs/protocol";import{customAlphabet as ke,nanoid as Ae}from"nanoid";import*as S from"ot-json1";import{debounceTime as je,filter as Me,first as Ne,map as Pe}from"rxjs/operators";import*as Fe from"numfmt";import Ie from"dayjs";import Le from"dayjs/plugin/advancedFormat";import Re from"dayjs/plugin/customParseFormat";import ze from"dayjs/plugin/localeData";import Be from"dayjs/plugin/localizedFormat";import Ve from"dayjs/plugin/utc";import He from"dayjs/plugin/weekday";import Ue from"dayjs/plugin/weekOfYear";import We from"dayjs/plugin/weekYear";import Ge,{default as Ke}from"rbush";import qe from"fast-diff";import{defaultTheme as Je}from"@univerjs/themes";import Ye from"kdbush";const Xe=typeof global<`u`?global:typeof self<`u`?self:window;function Ze(){let e=new Map,t=0;typeof Xe.requestIdleCallback!=`function`&&(Xe.requestIdleCallback=function(n){let r=Date.now(),i=++t,a=setTimeout(function(){e.delete(i);let t=Math.max(0,50-(Date.now()-r));n({didTimeout:t===0,timeRemaining(){return t}})},1);return e.set(i,a),i}),typeof Xe.cancelIdleCallback!=`function`&&(Xe.cancelIdleCallback=function(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))})}function Qe(){typeof Xe.Array.prototype.findLastIndex!=`function`&&(Xe.Array.prototype.findLastIndex=function(e,t){if(this==null)throw TypeError(`Array.prototype.findLastIndex called on null or undefined`);if(typeof e!=`function`)throw TypeError(`callback must be a function`);let n=this.length>>>0;for(let r=n-1;r>=0;r--)if(r in this&&e.call(t,this[r],r,this))return r;return-1}),typeof Xe.Array.prototype.findLast!=`function`&&(Xe.Array.prototype.findLast=function(e,t){let n=this.findLastIndex(e,t);return n===-1?void 0:this[n]})}function $e(){typeof Xe.String.prototype.at!=`function`&&(Xe.String.prototype.at=function(e){if(this==null)throw TypeError(`String.prototype.at called on null or undefined`);let t=this.length;if(e<0&&(e=t+e),!(e<0||e>=t))return this.charAt(e)})}function et(){Ze(),Qe(),$e()}function tt(e,t){let n=e.indexOf(t);return n>-1?(e.splice(n,1),!0):!1}function nt(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}function rt(e,t){let n=new Set,r=[];for(let i of e){let e=t(i);n.has(e)||(n.add(e),r.push(i))}return r}function it(e,t){for(let n=e.length-1;n>-1;n--){let r=e[n];if(t(r,n))return r}return null}function at(e,t){if(e.length===0)return e;let n=t%e.length;return e.slice(n).concat(e.slice(0,n))}function ot(e,t){let n=new Map;return e.forEach(e=>{let r=t(e),i=n.get(r);n.has(r)||(i=[],n.set(r,i)),i.push(e)}),n}function st(e){return Array.isArray(e)?e:[e]}const ct=new Set([`true`,`false`]);function lt(e){return ct.has(e.toLowerCase())}const ut=`__INTERNAL_EDITOR__`,dt=`${ut}DOCS_NORMAL`,ft=`${ut}DOCS_FORMULA_BAR`,pt=`${ut}ZEN_EDITOR`,mt=`${ut}COMMENT_EDITOR`,ht=`\r
|
|
2
|
-
`,gt=`isRowStylePrecedeColumnStyle`,_t=Symbol(`AUTO_HEIGHT_FOR_MERGED_CELLS`);function vt(e){return`${ut}${e}`}function yt(e){return e.startsWith(ut)}function bt(e){return e===mt}function xt(e,t){t.forEach(t=>e.add(t))}function St(e,t){t.forEach(([t])=>{e.has(t)&&e.get(t)})}function Ct(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;let i=Object.prototype.hasOwnProperty.bind(t);for(let r=0;r<n.length;r++){let a=n[r];if(!i(a)||e[a]!==t[a])return!1}return!0}var wt=class extends Error{constructor(e){super(e),this.name=`CustomCommandExecutionError`}},Tt=class extends wt{constructor(){super(`Canceled by facade`),this.name=`CanceledError`}};function Et(e,t=16){let n=0,r=null;return function(...i){let a=Date.now();a-n<t?(r&&clearTimeout(r),r=setTimeout(()=>{n=a,e.apply(this,i)},t)):(n=a,e.apply(this,i))}}function Dt(e){"@babel/helpers - typeof";return Dt=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Dt(e)}function Ot(e,t){if(Dt(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Dt(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function kt(e){var t=Ot(e,`string`);return Dt(t)==`symbol`?t:t+``}function C(e,t,n){return(t=kt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let At=function(e){return e[e.Style=1]=`Style`,e[e.Value=2]=`Value`,e}({});function jt(e){return`sheet_interceptor_${e}`}const Mt=e=>function(t,n){let r=-1,i=t;for(let t=0;t<=e.length;t++){if(t<=r)throw Error(`[SheetInterceptorService]: next() called multiple times!`);if(r=t,t===e.length)return i;let a=e[t],o=!1;if(i=a.handler(i,n,e=>(o=!0,e)),!o)break}return i};var Nt=class{constructor(e){C(this,`_interceptorsByName`,new Map),C(this,`_interceptorPoints`,void 0),this._interceptorPoints=e}fetchThroughInterceptors(e,t){let n=e,r=this._interceptorsByName.get(n);return t&&(r=r.filter(t)),Mt(r||[])}intercept(e,t){let n=e;this._interceptorsByName.has(n)||this._interceptorsByName.set(n,[]);let r=this._interceptorsByName.get(n);return r.push(t),this._interceptorsByName.set(n,r.sort((e,t)=>{var n,r;return((n=t.priority)==null?0:n)-((r=e.priority)==null?0:r)})),()=>tt(this._interceptorsByName.get(n),t)}getInterceptPoints(){return this._interceptorPoints}dispose(){this._interceptorsByName.clear()}};function Pt(e){return`sheet_async_interceptor_${e}`}const Ft=e=>async function(t,n){let r=-1,i=t;for(let t=0;t<=e.length;t++){if(t<=r)throw Error(`[SheetInterceptorService]: next() called multiple times!`);if(r=t,t===e.length)return i;let a=e[t],o=!1;if(i=await a.handler(i,n,async e=>(o=!0,e)),!o)break}return i};var It=class{constructor(e){C(this,`_asyncInterceptorsByName`,new Map),C(this,`_asyncInterceptorPoints`,void 0),this._asyncInterceptorPoints=e}fetchThroughAsyncInterceptors(e,t){let n=e,r=this._asyncInterceptorsByName.get(n);return t&&(r=r.filter(t)),Ft(r||[])}async interceptAsync(e,t){let n=e;this._asyncInterceptorsByName.has(n)||this._asyncInterceptorsByName.set(n,[]);let r=this._asyncInterceptorsByName.get(n);return r.push(t),this._asyncInterceptorsByName.set(n,r.sort((e,t)=>{var n,r;return((n=t.priority)==null?0:n)-((r=e.priority)==null?0:r)})),()=>tt(this._asyncInterceptorsByName.get(n),t)}getInterceptPoints(){return this._asyncInterceptorPoints}dispose(){this._asyncInterceptorsByName.clear()}};function Lt(e){return e.map(e=>e/255)}function Rt(e){return e.map(e=>Math.round(e*255))}function zt([e,t,n]){let r=Math.max(e,t,n),i=Math.min(e,t,n),a=(r+i)/2,o=0,s=0;if(r!==i){let c=r-i;switch(s=a>.5?c/(2-r-i):c/(r+i),r){case e:o=(t-n)/c+(t<n?6:0);break;case t:o=(n-e)/c+2;break;case n:o=(e-t)/c+4;break}o/=6}return[o,s,a]}function Bt(e,t,n){let r=[e,t,n].map(e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4);return .2126*r[0]+.7152*r[1]+.0722*r[2]}function Vt(e,t){return(Math.max(e,t)+.05)/(Math.min(e,t)+.05)}function Ht(e,t,n){let r,i,a;if(t===0)r=i=a=n;else{let o=(e,t,n)=>{let r=n;return r<0&&(r+=1),r>1&&--r,r<1/6?e+(t-e)*6*r:r<1/2?t:r<2/3?e+(t-e)*(2/3-r)*6:e},s=n<.5?n*(1+t):n+t-n*t,c=2*n-s;r=o(c,s,e+1/3),i=o(c,s,e),a=o(c,s,e-1/3)}return[r,i,a]}const Ut={r:1,g:1,b:1},Wt={r:0,g:0,b:0},Gt=Bt(Ut.r,Ut.g,Ut.b),Kt=Bt(Wt.r,Wt.g,Wt.b);function qt(e){let t=Vt(Gt,Bt(e[0],e[1],e[2])),n=zt(e),r=1-n[2],i,a,o;do i=Ht(n[0],n[1],r),a=Bt(i[0],i[1],i[2]),o=Vt(a,Kt),r+=.01;while(r<=1&&r>=0&&Math.abs(o-t)<.01);return i}function Jt(e){return Rt(qt(Lt(e)))}const w=[[.333,-.667,-.667,0,1],[-.667,.333,-.667,0,1],[-.667,-.667,.333,0,1],[0,0,0,1,0]];function Yt(e){let t=e[0],n=e[1],r=e[2],i=[w[0][0]*t+w[0][1]*n+w[0][2]*r+w[0][4],w[1][0]*t+w[1][1]*n+w[1][2]*r+w[1][4],w[2][0]*t+w[2][1]*n+w[2][2]*r+w[2][4]];return i=i.map(e=>e>1?1:e<0?0:e),i}function Xt(e){return Rt(Yt(Lt(e)))}var Zt=class{constructor(){C(this,`cursor`,0)}reset(){return this.cursor=0,this}moveCursor(e){this.cursor+=e}moveCursorTo(e){this.cursor=e}};function Qt(e,t){for(let n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}function $t(e){return/^-?\d+(\.\d+)?$/.test(e)}function en(e){return $t(e)?Number(e)<=2**53-1:!1}function tn(e){return Number(e)>2**53-1||e.length>=18}var nn=class e{constructor(){C(this,`_data`,[])}static create(){return new e}add(e){this._data.indexOf(e)>-1||this._data.push(e)}delete(e){let t=this._data.indexOf(e);this._data.splice(t,1)}getData(){return this._data}},rn=class e{constructor(){C(this,`_data`,new Map)}static create(){return new e}add(e,t){this._data.has(e)||this._data.set(e,t)}delete(e){this._data.delete(e)}getData(){return this._data}};function an(e){let t=new MessageChannel,n=!1,r=()=>{n||e()};return t.port1.onmessage=r,t.port2.postMessage(null),()=>{n=!0,t.port1.onmessage=null,t.port1.close(),t.port2.close()}}async function on(e){for(let[t,n]of e.entries())try{if(!await n())return{index:t,result:!1}}catch(e){return{index:t,result:!1,error:e}}return{result:!0,index:-1}}function sn(e){for(let[t,n]of e.entries())try{if(!n())return{index:t,result:!1}}catch(e){return{index:t,result:!1,error:e}}return{result:!0,index:-1}}function cn(e,t){return t.forEach(t=>e.add(t)),e}function ln(e){return e instanceof me||e instanceof y||e&&`closed`in e&&e.unsubscribe!==void 0}function T(e){let t=!1;return e?ln(e)?{dispose:()=>e.unsubscribe()}:typeof e==`function`?{dispose:()=>{t||(t=!0,e())}}:e:T(()=>{})}var un=class{constructor(){C(this,`_disposables`,new Set)}add(e){let t=T(e);return this._disposables.add(t),{dispose:(e=!1)=>{e||t.dispose(),this._disposables.delete(t)}}}dispose(){this._disposables.forEach(e=>{e.dispose()}),this._disposables.clear()}},E=class{constructor(){C(this,`_disposed`,!1),C(this,`_collection`,new un)}disposeWithMe(e){return this._collection.add(e)}ensureNotDisposed(){if(this._disposed)throw Error(`[Disposable]: object is disposed!`)}dispose(){this._disposed||(this._disposed=!0,this._collection.dispose())}},dn=class extends E{constructor(...e){super(...e),C(this,`dispose$`,new y)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}},fn=class extends E{constructor(e){super(),this._rootDisposable=e,C(this,`_ref`,0)}inc(){if(this._disposed)throw Error(`[RCDisposable]: should not ref to a disposed.`);this._ref+=1}dec(){--this._ref,this._ref===0&&(this._rootDisposable.dispose(),this.dispose())}},pn=class extends E{};const mn=new Set(`ac.ad.ae.aero.af.ag.ai.al.am.ao.aq.ar.arpa.as.asia.at.au.aw.ax.az.ba.bb.bd.be.bf.bg.bh.bi.biz.bj.bm.bn.bo.br.bs.bt.bv.bw.by.bz.ca.cat.cc.cd.cf.cg.ch.ci.ck.cl.cm.cn.co.com.coop.cr.cu.cv.cw.cx.cy.cz.de.dj.dk.dm.do.dz.ec.edu.ee.eg.er.es.et.eu.fi.fj.fk.fm.fo.fr.ga.gb.gd.ge.gf.gg.gh.gi.gl.gm.gn.gov.gp.gq.gr.gs.gt.gu.gw.gy.hk.hm.hn.hr.ht.hu.id.ie.il.im.in.info.int.io.iq.ir.is.it.je.jm.jo.jobs.jp.ke.kg.kh.ki.km.kn.kp.kr.kw.ky.kz.la.lb.lc.li.lk.lr.ls.lt.lu.lv.ly.ma.mc.md.me.mg.mh.mil.mk.ml.mm.mn.mo.mobi.mp.mq.mr.ms.mt.mu.museum.mv.mw.mx.my.mz.na.name.nc.ne.net.nf.ng.ni.nl.no.np.nr.nu.nz.om.onion.org.pa.pe.pf.pg.ph.pk.pl.pm.pn.post.pr.pro.ps.pt.pw.py.qa.re.ro.rs.ru.rw.sa.sb.sc.sd.se.sg.sh.si.sj.sk.sl.sm.sn.so.sr.ss.st.su.sv.sx.sy.sz.tc.td.tel.tf.tg.th.tj.tk.tl.tm.tn.to.tr.tt.tv.tw.tz.ua.ug.uk.us.uy.uz.va.vc.ve.vg.vi.vn.vu.wf.ws.yt.za.zm.zw`.split(`.`)),hn=RegExp(`^(?:(?:(?:https?|ftp):)?\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62})?[a-z0-9\\u00a1-\\uffff]\\.)+(?:[a-z\\u00a1-\\uffff]{2,}\\.?))(?::\\d{2,5})?(?:[/?#]\\S*)?$`,`i`);function gn(e){if(!Number.isNaN(+e))return!1;if(e.startsWith(`http://localhost:3002`)||e.startsWith(`localhost:3002`))return!0;if(hn.test(e)){if(_n(e))return!0;try{let t=new URL(yn(e)).hostname.split(`.`).pop();if(t&&mn.has(t))return!0}catch{return!1}}return!1}function _n(e){return/^[a-zA-Z]+:\/\//.test(e)}function vn(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function yn(e){return _n(e)?e:vn(e)?`mailto://${e}`:`https://${e}`}function bn(e,t){try{let n=new URL(t),r=n.pathname.endsWith(`/`)?n.pathname:`${n.pathname}/`,i=e.startsWith(`/`)?e.substring(1):e;return new URL(i,n.origin+r).toString()}catch(t){return console.error(`Error resolving URL with base URL:`,t),e}}function xn(e,t){return D.getValueType(e)===D.getValueType(t)?D.isArray(e)?Sn(e,t):D.isObject(e)?Cn(e,t):D.isDate(e)?e.getTime()===t.getTime():D.isRegExp(e)?e.toString()===t.toString():e===t:!1}function Sn(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++){let r=e[n],i=t[n];if(!xn(r,i))return!1}return!0}function Cn(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i of n){if(!r.includes(i))return!1;let n=e[i],a=t[i];if(!xn(n,a))return!1}return!0}var D=class e{static deleteNull(e){for(let t in e)(e[t]===null||e[t]===void 0)&&delete e[t];return e}static getSystemType(){let e=navigator.userAgent,t=navigator.platform===`Win32`||navigator.platform===`Windows`,n=navigator.platform===`Mac68K`||navigator.platform===`MacPPC`||navigator.platform===`Macintosh`||navigator.platform===`MacIntel`;if(n)return`Mac`;if(navigator.platform===`X11`&&!t&&!n)return`Unix`;if(String(navigator.platform).indexOf(`Linux`)>-1)return`Linux`;if(t){if(e.indexOf(`Windows NT 5.0`)>-1||e.indexOf(`Windows 2000`)>-1)return`Windows 2000`;if(e.indexOf(`Windows NT 5.1`)>-1||e.indexOf(`Windows XP`)>-1)return`Windows XP`;if(e.indexOf(`Windows NT 5.2`)>-1||e.indexOf(`Windows 2003`)>-1)return`Windows 2003`;if(e.indexOf(`Windows NT 6.0`)>-1||e.indexOf(`Windows Vista`)>-1)return`Windows Vista`;if(e.indexOf(`Windows NT 6.1`)>-1||e.indexOf(`Windows 7`)>-1)return`Windows 7`;if(e.indexOf(`Windows NT 10`)>-1||e.indexOf(`Windows 10`)>-1)return`Windows 10`;if(e.indexOf(`Windows NT 11`)>-1||e.indexOf(`Windows 11`)>-1)return`Windows 11`}return`Unknown system`}static getBrowserType(){let e=navigator.userAgent,t=e.indexOf(`Opera`)>-1,n=e.indexOf(`compatible`)>-1&&e.indexOf(`MSIE`)>-1&&!t,r=e.indexOf(`Trident`)>-1&&e.indexOf(`rv:11.0`)>-1,i=e.indexOf(`Edge`)>-1,a=e.indexOf(`Firefox`)>-1,o=e.indexOf(`Safari`)>-1&&e.indexOf(`Chrome`)===-1,s=e.indexOf(`Chrome`)>-1&&e.indexOf(`Safari`)>-1;if(n){RegExp(`MSIE (\\d+\\.\\d+);`).test(e);let t=Number.parseFloat(RegExp.$1);return t===7?`IE7`:t===8?`IE8`:t===9?`IE9`:t===10?`IE10`:`0`}return a?`FF`:t?`Opera`:o?`Safari`:s?`Chrome`:i?`Edge`:r?`IE11`:`Unknown browser`}static deepMerge(t,...n){n.forEach(e=>e&&a(e));function r(t,n){t.forEach((t,a)=>{if(e.isArray(t)){var o;let e=(o=n[a])==null?[]:o;n[a]=e,r(t,e);return}if(e.isObject(t)){var s;let e=(s=n[a])==null?{}:s;n[a]=e,i(t,e);return}n[a]=t})}function i(t,n){Object.keys(t).forEach(a=>{let o=t[a];if(e.isObject(o)){var s;let e=(s=n[a])==null?{}:s;n[a]=e,i(o,e);return}if(e.isArray(o)){var c;let e=(c=n[a])==null?[]:c;n[a]=e,r(o,e);return}n[a]=o})}function a(n){Object.keys(n).forEach(a=>{let o=n[a];if(e.isArray(o)){var s;let e=(s=t[a])==null?[]:s;t[a]=e,r(o,e);return}if(e.isObject(o)){var c;let e=(c=t[a])==null?{}:c;t[a]=e,i(o,e);return}t[a]=o})}return t}static diffValue(e,t){return xn(e,t)}static deepClone(t){if(!this.isDefine(t))return t;if(this.isRegExp(t))return new RegExp(t);if(this.isDate(t))return new Date(t);if(this.isArray(t)){let n=[];return t.forEach((t,r)=>{n[r]=e.deepClone(t)}),n}if(this.isObject(t)){let n={};return Object.keys(t).forEach(r=>{let i=t[r];n[r]=e.deepClone(i)}),Object.setPrototypeOf(n,Object.getPrototypeOf(t)),n}return t}static getValueType(e){return Object.prototype.toString.apply(e)}static isDefine(e){return e!=null}static isBlank(e){return this.isDefine(e)?this.isString(e)?e.trim()===``:!1:!0}static isPlainObject(e){return this.isDefine(e)?Object.getPrototypeOf(e)===Object.getPrototypeOf({}):!1}static isDate(e){return this.getValueType(e)===`[object Date]`}static isRegExp(e){return this.getValueType(e)===`[object RegExp]`}static isArray(e){return this.getValueType(e)===`[object Array]`}static isString(e){return this.getValueType(e)===`[object String]`}static isNumber(e){return this.getValueType(e)===`[object Number]`}static isStringNumber(e){return!isNaN(Number.parseFloat(e))&&isFinite(e)}static isObject(e){return this.getValueType(e)===`[object Object]`}static isEmptyObject(e){for(let t in e)return!1;return!0}static isTablet(){return/ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase())}static isIPhone(){return/iPhone/i.test(navigator.userAgent)}static isLegalUrl(e){return gn(e)}static normalizeUrl(e){return yn(e)}static topLevelDomainCombiningString(){return[...mn].join(`|`)}static removeNull(t){return this.isObject(t)&&Object.keys(t).forEach(n=>{let r=t[n];r==null?delete t[n]:e.removeNull(r)}),t}static numToWord(e){let t=``;for(;e>0;){let n=e%26;n=n===0?n=26:n,t=String.fromCharCode(96+n)+t,e=(e-n)/26}return t.toLocaleUpperCase()}static ABCatNum(e){if(e==null||e.length===0)return NaN;let t=e.toLowerCase().split(``),n=t.length,r=0,i=0;for(let e=0;e<n;e++)i=t[e].charCodeAt(0)-96,r+=i*26**(n-e-1);return r===0?NaN:r-1}static chatAtABC(e){let t=``;for(;e>=0;)t=String.fromCharCode(e%26+97)+t,e=Math.floor(e/26)-1;return t.toUpperCase()}static commonExtend(e,t){let n={};for(let t in e)n[t]=e[t];for(let e in t)t[e]!=null&&(n[e]=t[e]);return n}static hasIntersectionBetweenTwoRanges(e,t,n,r){return t>=n&&r>=e}static isStartValidPosition(e){return/^[A-Za-zА-Яа-яЁё_]/.test(e)}static isValidParameter(e){let t=/[~!@#$%^&*()+=\-{}\[\]\|:;"'<>,?\/ ]+/.test(e),n=e.length<=255;return!t&&n}static clamp(e,t,n){return Math.max(t,Math.min(n,e))}static now(){return performance&&performance.now?performance.now():Date.now()}};function O(e=21,t){return t?ke(t,e)():Ae(e)}function wn(...e){let t={},n=e.length;for(let r=n-1;r>=0;r--){let n=e[r];if(n){let e=Object.keys(n);for(let r of e)t[r]===void 0&&(t[r]=n[r])}}return t}const Tn=()=>typeof process<`u`&&process.versions!=null&&process.versions.node!=null;function En(e){let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/\\\*/g,`.*`).replace(/\\\?/g,`.`);return RegExp(`^${t}$`,`i`)}let Dn=function(e){return e[e.DEFAULT_SERIES=0]=`DEFAULT_SERIES`,e[e.ALTERNATE_SERIES=1]=`ALTERNATE_SERIES`,e}({}),k=function(e){return e[e.NONE=0]=`NONE`,e[e.THIN=1]=`THIN`,e[e.HAIR=2]=`HAIR`,e[e.DOTTED=3]=`DOTTED`,e[e.DASHED=4]=`DASHED`,e[e.DASH_DOT=5]=`DASH_DOT`,e[e.DASH_DOT_DOT=6]=`DASH_DOT_DOT`,e[e.DOUBLE=7]=`DOUBLE`,e[e.MEDIUM=8]=`MEDIUM`,e[e.MEDIUM_DASHED=9]=`MEDIUM_DASHED`,e[e.MEDIUM_DASH_DOT=10]=`MEDIUM_DASH_DOT`,e[e.MEDIUM_DASH_DOT_DOT=11]=`MEDIUM_DASH_DOT_DOT`,e[e.SLANT_DASH_DOT=12]=`SLANT_DASH_DOT`,e[e.THICK=13]=`THICK`,e}({}),On=function(e){return e.TOP=`top`,e.BOTTOM=`bottom`,e.LEFT=`left`,e.RIGHT=`right`,e.NONE=`none`,e.ALL=`all`,e.OUTSIDE=`outside`,e.INSIDE=`inside`,e.HORIZONTAL=`horizontal`,e.VERTICAL=`vertical`,e.TLBR=`tlbr`,e.TLBC_TLMR=`tlbc_tlmr`,e.TLBR_TLBC_TLMR=`tlbr_tlbc_tlmr`,e.BLTR=`bl_tr`,e.MLTR_BCTR=`mltr_bctr`,e}({}),kn=function(e){return e[e.UNSUPPORTED=0]=`UNSUPPORTED`,e[e.RGB=1]=`RGB`,e[e.HEX=2]=`HEX`,e[e.THEME=3]=`THEME`,e}({}),An=function(e){return e[e.ON=0]=`ON`,e[e.OFF=1]=`OFF`,e}({}),jn=function(e){return e[e.PASTE_NORMAL=0]=`PASTE_NORMAL`,e[e.PASTE_NO_BORDERS=1]=`PASTE_NO_BORDERS`,e[e.PASTE_FORMAT=2]=`PASTE_FORMAT`,e[e.PASTE_FORMULA=3]=`PASTE_FORMULA`,e[e.PASTE_DATA_VALIDATION=4]=`PASTE_DATA_VALIDATION`,e[e.PASTE_VALUES=5]=`PASTE_VALUES`,e[e.PASTE_CONDITIONAL_FORMATTING=6]=`PASTE_CONDITIONAL_FORMATTING`,e[e.PASTE_COLUMN_WIDTHS=7]=`PASTE_COLUMN_WIDTHS`,e}({}),Mn=function(e){return e[e.LEFT=0]=`LEFT`,e[e.RIGHT=1]=`RIGHT`,e}({}),Nn=function(e){return e[e.DOCUMENT=0]=`DOCUMENT`,e[e.PROJECT=1]=`PROJECT`,e}({}),Pn=function(e){return e[e.COLUMNS=0]=`COLUMNS`,e[e.ROWS=1]=`ROWS`,e}({}),Fn=function(e){return e[e.UP=0]=`UP`,e[e.RIGHT=1]=`RIGHT`,e[e.DOWN=2]=`DOWN`,e[e.LEFT=3]=`LEFT`,e}({});function In(e){switch(e){case Fn.LEFT:return Fn.RIGHT;case Fn.RIGHT:return Fn.LEFT;case Fn.UP:return Fn.DOWN;case Fn.DOWN:return Fn.UP}}let Ln=function(e){return e[e.INTERPOLATION_POINT_TYPE_UNSPECIFIED=0]=`INTERPOLATION_POINT_TYPE_UNSPECIFIED`,e[e.MIN=1]=`MIN`,e[e.MAX=2]=`MAX`,e[e.NUMBER=3]=`NUMBER`,e[e.PERCENT=4]=`PERCENT`,e[e.PERCENTILE=5]=`PERCENTILE`,e}({}),Rn=function(e){return e.EN_US=`enUS`,e.FR_FR=`frFR`,e.ZH_CN=`zhCN`,e.RU_RU=`ruRU`,e.ZH_TW=`zhTW`,e.VI_VN=`viVN`,e.FA_IR=`faIR`,e.JA_JP=`jaJP`,e.KO_KR=`koKR`,e.ES_ES=`esES`,e.CA_ES=`caES`,e.SK_SK=`skSK`,e}({}),zn=function(e){return e[e.PERSON=0]=`PERSON`,e[e.FILE=1]=`FILE`,e[e.DATE=2]=`DATE`,e[e.LOCATION=3]=`LOCATION`,e[e.EVENT=4]=`EVENT`,e}({}),Bn=function(e){return e[e.RANGE=0]=`RANGE`,e[e.SHEET=1]=`SHEET`,e}({}),Vn=function(e){return e.Line=`line`,e.LineInv=`lineInv`,e.Triangle=`triangle`,e.RtTriangle=`rtTriangle`,e.Rect=`rect`,e.Diamond=`diamond`,e.Parallelogram=`parallelogram`,e.Trapezoid=`trapezoid`,e.NonIsocelesTrapezoid=`nonIsocelesTrapezoid`,e.Pentagon=`pentagon`,e.Hexagon=`hexagon`,e.Heptagon=`heptagon`,e.Octagon=`octagon`,e.Decagon=`decagon`,e.Dodecagon=`dodecagon`,e.Star4=`star4`,e.Star5=`star5`,e.Star6=`star6`,e.Star7=`star7`,e.Star8=`star8`,e.Star10=`star10`,e.Star12=`star12`,e.Star16=`star16`,e.Star24=`star24`,e.Star32=`star32`,e.RoundRect=`roundRect`,e.Round1Rect=`round1Rect`,e.Round2SameRect=`round2SameRect`,e.Round2DiagRect=`round2DiagRect`,e.Ellipse=`ellipse`,e}({}),Hn=function(e){return e.RightArrow=`rightArrow`,e.LeftArrow=`leftArrow`,e.UpArrow=`upArrow`,e.DownArrow=`downArrow`,e.LeftRightArrow=`leftRightArrow`,e.UpDownArrow=`upDownArrow`,e.QuadArrow=`quadArrow`,e.LeftRightUpArrow=`leftRightUpArrow`,e.BentArrow=`bentArrow`,e.UturnArrow=`uturnArrow`,e.CircularArrow=`circularArrow`,e.NotchedRightArrow=`notchedRightArrow`,e.HomePlate=`homePlate`,e.Chevron=`chevron`,e.LeftCircularArrow=`leftCircularArrow`,e.LeftRightCircularArrow=`leftRightCircularArrow`,e}({}),Un=function(e){return e.Plaque=`plaque`,e.Can=`can`,e.Cube=`cube`,e.Bevel=`bevel`,e.Donut=`donut`,e.NoSmoking=`noSmoking`,e.BlockArc=`blockArc`,e.FoldedCorner=`foldedCorner`,e}({}),Wn=function(e){return e.SmileyFace=`smileyFace`,e.Heart=`heart`,e.LightningBolt=`lightningBolt`,e.Sun=`sun`,e.Moon=`moon`,e.Cloud=`cloud`,e.Arc=`arc`,e.Backpack=`backpack`,e.Frame=`frame`,e.HalfFrame=`halfFrame`,e.Corner=`corner`,e.Chord=`chord`,e.Pie=`pie`,e.Teardrop=`teardrop`,e.WedgeRectCallout=`wedgeRectCallout`,e.WedgeRRectCallout=`wedgeRRectCallout`,e.WedgeEllipseCallout=`wedgeEllipseCallout`,e.CloudCallout=`cloudCallout`,e.BorderCallout1=`borderCallout1`,e.BorderCallout2=`borderCallout2`,e.BorderCallout3=`borderCallout3`,e.AccentCallout1=`accentCallout1`,e.AccentCallout2=`accentCallout2`,e.AccentCallout3=`accentCallout3`,e.Callout1=`callout1`,e.Callout2=`callout2`,e.Callout3=`callout3`,e.ActionButtonBackPrevious=`actionButtonBackPrevious`,e.ActionButtonEnd=`actionButtonEnd`,e.ActionButtonForwardNext=`actionButtonForwardNext`,e.ActionButtonHelp=`actionButtonHelp`,e.ActionButtonHome=`actionButtonHome`,e.ActionButtonInformation=`actionButtonInformation`,e.ActionButtonMovie=`actionButtonMovie`,e.ActionButtonReturn=`actionButtonReturn`,e.ActionButtonSound=`actionButtonSound`,e}({}),Gn=function(e){return e[e.RELATIVE_DATE_UNSPECIFIED=0]=`RELATIVE_DATE_UNSPECIFIED`,e[e.PAST_YEAR=1]=`PAST_YEAR`,e[e.PAST_MONTH=2]=`PAST_MONTH`,e[e.PAST_WEEK=3]=`PAST_WEEK`,e[e.YESTERDAY=4]=`YESTERDAY`,e[e.TODAY=5]=`TODAY`,e[e.TOMORROW=6]=`TOMORROW`,e}({}),Kn=function(e){return e[e.GRID=0]=`GRID`,e[e.KANBAN=1]=`KANBAN`,e[e.GANTT=2]=`GANTT`,e}({}),qn=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.LEFT_TO_RIGHT=1]=`LEFT_TO_RIGHT`,e[e.RIGHT_TO_LEFT=2]=`RIGHT_TO_LEFT`,e}({}),Jn=function(e){return e[e.DASH=0]=`DASH`,e[e.DASH_DOT_DOT_HEAVY=1]=`DASH_DOT_DOT_HEAVY`,e[e.DASH_DOT_HEAVY=2]=`DASH_DOT_HEAVY`,e[e.DASHED_HEAVY=3]=`DASHED_HEAVY`,e[e.DASH_LONG=4]=`DASH_LONG`,e[e.DASH_LONG_HEAVY=5]=`DASH_LONG_HEAVY`,e[e.DOT_DASH=6]=`DOT_DASH`,e[e.DOT_DOT_DASH=7]=`DOT_DOT_DASH`,e[e.DOTTED=8]=`DOTTED`,e[e.DOTTED_HEAVY=9]=`DOTTED_HEAVY`,e[e.DOUBLE=10]=`DOUBLE`,e[e.NONE=11]=`NONE`,e[e.SINGLE=12]=`SINGLE`,e[e.THICK=13]=`THICK`,e[e.WAVE=14]=`WAVE`,e[e.WAVY_DOUBLE=15]=`WAVY_DOUBLE`,e[e.WAVY_HEAVY=16]=`WAVY_HEAVY`,e[e.WORDS=17]=`WORDS`,e}({}),Yn=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.LEFT=1]=`LEFT`,e[e.CENTER=2]=`CENTER`,e[e.RIGHT=3]=`RIGHT`,e[e.JUSTIFIED=4]=`JUSTIFIED`,e[e.BOTH=5]=`BOTH`,e[e.DISTRIBUTED=6]=`DISTRIBUTED`,e}({}),Xn=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.TOP=1]=`TOP`,e[e.MIDDLE=2]=`MIDDLE`,e[e.BOTTOM=3]=`BOTTOM`,e}({}),Zn=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.OVERFLOW=1]=`OVERFLOW`,e[e.CLIP=2]=`CLIP`,e[e.WRAP=3]=`WRAP`,e}({}),Qn=function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.ITALIC=1]=`ITALIC`,e}({}),$n=function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.BOLD=1]=`BOLD`,e}({}),er=function(e){return e[e.NORMAL=1]=`NORMAL`,e[e.SUBSCRIPT=2]=`SUBSCRIPT`,e[e.SUPERSCRIPT=3]=`SUPERSCRIPT`,e}({}),A=function(e){return e[e.FALSE=0]=`FALSE`,e[e.TRUE=1]=`TRUE`,e}({}),tr=function(e){return e[e.STRING=1]=`STRING`,e[e.NUMBER=2]=`NUMBER`,e[e.BOOLEAN=3]=`BOOLEAN`,e[e.FORCE_STRING=4]=`FORCE_STRING`,e}({}),j=function(e){return e[e.DARK1=0]=`DARK1`,e[e.LIGHT1=1]=`LIGHT1`,e[e.DARK2=2]=`DARK2`,e[e.LIGHT2=3]=`LIGHT2`,e[e.ACCENT1=4]=`ACCENT1`,e[e.ACCENT2=5]=`ACCENT2`,e[e.ACCENT3=6]=`ACCENT3`,e[e.ACCENT4=7]=`ACCENT4`,e[e.ACCENT5=8]=`ACCENT5`,e[e.ACCENT6=9]=`ACCENT6`,e[e.HYPERLINK=10]=`HYPERLINK`,e[e.FOLLOWED_HYPERLINK=11]=`FOLLOWED_HYPERLINK`,e}({}),nr=function(e){return e.OFFICE=`Office`,e.OFFICE_2007_2010=`Office 2007-2010`,e.GRAYSCALE=`Grayscale`,e.BLUE_WARM=`Blue Warm`,e.BLUE=`Blue`,e.BLUE_II=`Blue II`,e.BLUE_GREEN=`Blue Green`,e.GREEN=`Green`,e.GREEN_YELLOW=`Green Yellow`,e.YELLOW=`Yellow`,e.YELLOW_ORANGE=`Yellow Orange`,e.ORANGE=`Orange`,e.ORANGE_RED=`Orange Red`,e.RED_ORANGE=`Red Orange`,e.RED=`Red`,e.RED_VIOLET=`Red Violet`,e.VIOLET=`Violet`,e.VIOLET_II=`Violet II`,e.MEDIAN=`Median`,e.PAPER=`Paper`,e.MARQUEE=`Marquee`,e.SLIPSTREAM=`Slipstream`,e.Aspect=`Aspect`,e}({}),rr=function(e){return e[e.character=0]=`character`,e[e.paragraph=1]=`paragraph`,e[e.table=2]=`table`,e[e.numbering=3]=`numbering`,e}({}),ir=function(e){return e[e.TAB=0]=`TAB`,e[e.SPACE=1]=`SPACE`,e[e.NOTHING=2]=`NOTHING`,e}({}),M=function(e){return 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}({}),ar=function(e){return 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}({}),or=function(e){return 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}({}),sr=function(e){return e[e.COMMENT=0]=`COMMENT`,e[e.DELETED=9999]=`DELETED`,e}({}),cr=function(e){return e[e.DRAWING=0]=`DRAWING`,e[e.CUSTOM=1]=`CUSTOM`,e}({}),lr=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.TRADITIONAL=1]=`TRADITIONAL`,e[e.MODERN=2]=`MODERN`,e}({}),ur=function(e){return 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}({}),dr=function(e){return 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}({}),fr=function(e){return 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}({}),pr=function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.TBRL=1]=`TBRL`,e[e.LRTBV=2]=`LRTBV`,e}({}),mr=function(e){return 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}({}),hr=function(e){return e[e.BOTH_SIDES=0]=`BOTH_SIDES`,e[e.LEFT=1]=`LEFT`,e[e.RIGHT=2]=`RIGHT`,e[e.LARGEST=3]=`LARGEST`,e}({}),gr=function(e){return 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}({}),N=function(e){return 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}({}),_r=function(e){return e[e.AUTO=0]=`AUTO`,e[e.AT_LEAST=1]=`AT_LEAST`,e[e.EXACT=2]=`EXACT`,e}({}),vr=function(e){return 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}({}),yr=function(e){return 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}({}),br=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.SPECIFIED=1]=`SPECIFIED`,e}({}),xr=function(e){return e[e.START=0]=`START`,e[e.CENTER=1]=`CENTER`,e[e.END=2]=`END`,e}({}),Sr=function(e){return e[e.AUTO_FIT=0]=`AUTO_FIT`,e[e.FIXED=1]=`FIXED`,e}({}),Cr=function(e){return e[e.NONE=0]=`NONE`,e[e.WRAP=1]=`WRAP`,e}({}),wr=function(e){return e[e.AUTO=0]=`AUTO`,e[e.AT_LEAST=1]=`AT_LEAST`,e[e.EXACT=2]=`EXACT`,e}({}),Tr=function(e){return 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}({}),Er=function(e){return e.NORMAL=`normal`,e.BOLD=`bold`,e.ITALIC=`italic`,e}({}),Dr=function(e){return 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}({}),Or=function(e){return 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}({}),kr=function(e){return 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}({}),Ar=function(e){return 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}({}),jr=function(e){return 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}({}),Mr=function(e){return e[e.compressPunctuation=0]=`compressPunctuation`,e[e.compressPunctuationAndJapaneseKana=1]=`compressPunctuationAndJapaneseKana`,e[e.doNotCompress=2]=`doNotCompress`,e}({}),Nr=function(e){return e[e.PORTRAIT=0]=`PORTRAIT`,e[e.LANDSCAPE=1]=`LANDSCAPE`,e}({}),P=function(e){return e.Letter=`Letter`,e.Tabloid=`Tabloid`,e.Legal=`Legal`,e.Statement=`Statement`,e.Executive=`Executive`,e.Folio=`Folio`,e.A3=`A3`,e.A4=`A4`,e.A5=`A5`,e.B4=`B4`,e.B5=`B5`,e}({});const Pr=[P.A3,P.A4,P.A5,P.B4,P.B5,P.Letter,P.Tabloid,P.Legal,P.Statement,P.Executive,P.Folio];let Fr=function(e){return e[e.forward=0]=`forward`,e[e.backward=1]=`backward`,e[e.front=2]=`front`,e[e.back=3]=`back`,e}({}),Ir=function(e){return 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}({}),Lr=function(e){return 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}({}),Rr=function(e){return 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}({}),zr=function(e){return 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}({});function Br(e=O(6),t=Rn.EN_US,n=``){return{id:e,locale:t,title:n,tableSource:{},drawings:{},drawingsOrder:[],headers:{},footers:{},body:{dataStream:`\r
|
|
3
|
-
`,textRuns:[],customBlocks:[],tables:[],paragraphs:[{startIndex:0,paragraphStyle:{spaceAbove:{v:5},lineSpacing:1,spaceBelow:{v:0}}}],sectionBreaks:[{startIndex:1}]},documentStyle:{pageSize:{width:595/.75,height:842/.75},documentFlavor:lr.TRADITIONAL,marginTop:50,marginBottom:50,marginRight:50,marginLeft:50,renderConfig:{zeroWidthParagraphBreak:A.FALSE,vertexAngle:0,centerAngle:0,background:{rgb:`#ccc`}},autoHyphenation:A.TRUE,doNotHyphenateCaps:A.FALSE,consecutiveHyphenLimit:2,defaultHeaderId:``,defaultFooterId:``,evenPageHeaderId:``,evenPageFooterId:``,firstPageHeaderId:``,firstPageFooterId:``,evenAndOddHeaders:A.FALSE,useFirstPageHeaderFooter:A.FALSE,marginHeader:30,marginFooter:30},settings:{}}}let F=function(e){return e[e.COVER=0]=`COVER`,e[e.REPLACE=1]=`REPLACE`,e}({}),I=function(e){return e.RETAIN=`r`,e.INSERT=`i`,e.DELETE=`d`,e}({});const Vr=m(`univer.config-service`);var Hr=class{constructor(){C(this,`_configChanged$`,new y),C(this,`configChanged$`,this._configChanged$.asObservable()),C(this,`_config`,new Map)}dispose(){this._config.clear(),this._configChanged$.complete()}getConfig(e){return this._config.get(e)}setConfig(e,t,n){var r;let{merge:i=!1}=n||{},a=(r=this._config.get(e))==null?{}:r;a=i?le(a,t):t,this._config.set(e,a),this._configChanged$.next({[e]:a})}deleteConfig(e){return this._config.delete(e)}subscribeConfigValue$(e){return new fe(t=>{Object.prototype.hasOwnProperty.call(this._config,e)&&t.next(this._config.get(e));let n=this.configChanged$.pipe(ve(t=>Object.prototype.hasOwnProperty.call(t,e))).subscribe(n=>t.next(n[e]));return()=>n.unsubscribe()})}};const Ur=m(`univer.context-service`);var Wr=class extends E{constructor(...e){super(...e),C(this,`_contextChanged$`,new y),C(this,`contextChanged$`,this._contextChanged$.asObservable()),C(this,`_contextMap`,new Map)}dispose(){super.dispose(),this._contextChanged$.complete(),this._contextMap.clear()}getContextValue(e){var t;return(t=this._contextMap.get(e))==null?!1:t}setContextValue(e,t){this._contextMap.set(e,t),this._contextChanged$.next({[e]:t})}subscribeContextValue$(e){return new fe(t=>{let n=this._contextChanged$.pipe(ve(t=>t[e]!==void 0)).subscribe(n=>t.next(n[e]));return this._contextMap.has(e)&&t.next(this._contextMap.get(e)),()=>n.unsubscribe()})}};let Gr=function(e){return e[e.SILENT=0]=`SILENT`,e[e.ERROR=1]=`ERROR`,e[e.WARN=2]=`WARN`,e[e.INFO=3]=`INFO`,e[e.VERBOSE=4]=`VERBOSE`,e}({});const L=m(`univer.log`);var Kr=class extends E{constructor(...e){super(...e),C(this,`_logLevel`,Gr.INFO),C(this,`_deduction`,new Set)}dispose(){super.dispose(),this._logLevel=Gr.INFO,this._deduction.clear()}debug(...e){this._logLevel>=Gr.VERBOSE&&this._log(console.debug,...e)}log(...e){this._logLevel>=Gr.INFO&&this._log(console.log,...e)}warn(...e){this._logLevel>=Gr.WARN&&this._log(console.warn,...e)}error(...e){this._logLevel>=Gr.ERROR&&this._log(console.error,...e)}deprecate(...e){this._logLevel>=Gr.WARN&&this._logWithDeduplication(console.error,...e)}setLogLevel(e){this._logLevel=e}_log(e,...t){let n=t[0];/^\[(.*?)\]/g.test(n)?e(`\x1B[97;104m${n}\x1B[0m`,...t.slice(1)):e(...t)}_logWithDeduplication(e,...t){let n=qr(...t);this._deduction.has(n)||(this._deduction.add(n),this._log(e,...t))}};function qr(...e){return e.map(e=>JSON.stringify(e)).join(``)}function R(e,t){return function(n,r){t(n,r,e)}}function z(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}const Jr=`command.logExecution`;let Yr=function(e){return e[e.COMMAND=0]=`COMMAND`,e[e.OPERATION=1]=`OPERATION`,e[e.MUTATION=2]=`MUTATION`,e}({});const Xr=m(`univer.core.command-service`);var Zr=class{constructor(){C(this,`_commands`,new Map),C(this,`_commandTypes`,new Map)}registerCommand(e){if(this._commands.has(e.id))throw Error(`[CommandRegistry]: command "${e.id}" has been registered before.`);return this._commands.set(e.id,e),this._commandTypes.set(e.id,e.type),T(()=>{this.unregisterCommand(e.id)})}unregisterCommand(e){this._commands.delete(e),this._commandTypes.delete(e)}hasCommand(e){return this._commands.has(e)}getCommand(e){return this._commands.has(e)?[this._commands.get(e)]:null}getCommandType(e){return this._commandTypes.get(e)}};const Qr={id:`nil`,type:Yr.COMMAND,handler:()=>!0};let $r=class extends E{constructor(e,t,n){super(),this._injector=e,this._logService=t,this._configService=n,C(this,`_commandRegistry`,void 0),C(this,`_beforeCommandExecutionListeners`,[]),C(this,`_commandExecutedListeners`,[]),C(this,`_collabMutationListeners`,[]),C(this,`_multiCommandDisposables`,new Map),C(this,`_commandExecutingLevel`,0),C(this,`_commandExecutionStack`,[]),this._commandRegistry=new Zr,this.registerCommand(Qr)}dispose(){super.dispose(),this._commandExecutedListeners.length=0,this._beforeCommandExecutionListeners.length=0,this._collabMutationListeners.length=0}disposed(){return this._disposed}hasCommand(e){return this._commandRegistry.hasCommand(e)}registerCommand(e){return this._commandRegistry.registerCommand(e)}unregisterCommand(e){var t;this._commandRegistry.unregisterCommand(e),(t=this._multiCommandDisposables.get(e))==null||t.dispose()}registerMultipleCommand(e){return this._registerMultiCommand(e)}beforeCommandExecuted(e){if(this._beforeCommandExecutionListeners.indexOf(e)===-1)return this._beforeCommandExecutionListeners.push(e),T(()=>{let t=this._beforeCommandExecutionListeners.indexOf(e);this._beforeCommandExecutionListeners.splice(t,1)});throw Error(`[CommandService]: could not add a listener twice.`)}onCommandExecuted(e){if(this._commandExecutedListeners.indexOf(e)===-1)return this._commandExecutedListeners.push(e),T(()=>{let t=this._commandExecutedListeners.indexOf(e);this._commandExecutedListeners.splice(t,1)});throw Error(`[CommandService]: could not add a listener twice.`)}onMutationExecutedForCollab(e){if(this._collabMutationListeners.indexOf(e)===-1)return this._collabMutationListeners.push(e),T(()=>{let t=this._collabMutationListeners.indexOf(e);this._collabMutationListeners.splice(t,1)});throw Error(`[CommandService]: could not add a collab mutation listener twice.`)}async executeCommand(e,t,n){try{let r=this._commandRegistry.getCommand(e);if(r){let[e]=r,i={id:e.id,type:e.type,params:t},a=this._pushCommandExecutionStack(i),o=n==null?{}:n;this._beforeCommandExecutionListeners.forEach(e=>e(i,o));let s=await this._execute(e,t,o);return o.syncOnly||this._commandExecutedListeners.forEach(e=>e(i,o)),e.type===Yr.MUTATION&&this._collabMutationListeners.forEach(e=>e(i,o)),a.dispose(),s}throw Error(`[CommandService]: command "${e}" is not registered.`)}catch(e){if(e instanceof wt)return!1;throw e}}syncExecuteCommand(e,t,n){try{let i=this._commandRegistry.getCommand(e);if(i){let[e]=i,a={id:e.id,type:e.type,params:t};if(e.type===Yr.MUTATION){let e=it(this._commandExecutionStack,e=>e.type===Yr.COMMAND);if(e){var r;a.params=(r=a.params)==null?{}:r,a.params.trigger=e.id}}let o=this._pushCommandExecutionStack(a),s=n==null?{}:n;this._beforeCommandExecutionListeners.forEach(e=>e(a,s));let c=this._syncExecute(e,t,s);return s.syncOnly||this._commandExecutedListeners.forEach(e=>e(a,s)),e.type===Yr.MUTATION&&this._collabMutationListeners.forEach(e=>e(a,s)),o.dispose(),c}throw Error(`[CommandService]: command "${e}" is not registered.`)}catch(e){if(e instanceof wt)return!1;throw e}}_pushCommandExecutionStack(e){return this._commandExecutionStack.push(e),T(()=>tt(this._commandExecutionStack,e))}_registerMultiCommand(e){let t=this._commandRegistry.getCommand(e.id),n;if(!t){n=new ei(e.id);let t=new un;t.add(this._commandRegistry.registerCommand(n)),t.add(T(()=>{this._multiCommandDisposables.delete(e.id)})),this._multiCommandDisposables.set(e.id,t)}else if(t[0].multi!==!0)throw Error(`Command has registered as a single command.`);else n=t[0];let r=n.registerImplementation(e);return T(()=>{if(r.dispose(),!n.hasImplementations()){var t;(t=this._multiCommandDisposables.get(e.id))==null||t.dispose()}})}async _execute(e,t,n){if(n!=null&&n.syncOnly)return!0;this._configService.getConfig(`command.logExecution`)!==!1&&this._logService.debug(`[CommandService]`,`${`|-`.repeat(Math.max(this._commandExecutingLevel,0))}executing command "${e.id}"`),this._commandExecutingLevel++;let r;try{r=await this._injector.invoke(e.handler,t,n),this._commandExecutingLevel--}catch(e){throw r=!1,this._commandExecutingLevel=0,e}return r}_syncExecute(e,t,n){if(n!=null&&n.syncOnly)return!0;this._configService.getConfig(`command.logExecution`)!==!1&&this._logService.debug(`[CommandService]`,`${`|-`.repeat(Math.max(0,this._commandExecutingLevel))}executing command "${e.id}".`),this._commandExecutingLevel++;let r;try{if(r=this._injector.invoke(e.handler,t,n),r instanceof Promise)throw TypeError(`[CommandService]: Command handler should not return a promise.`);this._commandExecutingLevel--}catch(e){throw r=!1,this._commandExecutingLevel=0,e}return r}};$r=z([R(0,t(i)),R(1,L),R(2,Vr)],$r);var ei=class{constructor(e){this.id=e,C(this,`name`,void 0),C(this,`multi`,!0),C(this,`type`,Yr.COMMAND),C(this,`priority`,0),C(this,`_implementations`,[]),C(this,`handler`,async(e,t)=>{if(!this._implementations.length)return!1;let n=e.get(L),r=e.get(Ur),a=e.get(i);for(let e of this._implementations){let i=e.command.preconditions;if((!i||i&&i(r))&&(n.debug(`[MultiCommand]`,`executing implementation "${e.command.name}".`),await a.invoke(e.command.handler,t)))return!0}return!1}),this.name=e}registerImplementation(e){let t={command:e};return this._implementations.push(t),this._implementations.sort((e,t)=>t.command.priority-e.command.priority),T(()=>{let e=this._implementations.indexOf(t);this._implementations.splice(e,1)})}hasImplementations(){return this._implementations.length>0}};function ti(e,t,n){return sn(e.map(e=>()=>t.syncExecuteCommand(e.id,e.params,n)))}function ni(e,t,n){return on(e.map(e=>()=>t.executeCommand(e.id,e.params,n)))}function ri(e){return new fe(t=>{let n=e((...e)=>t.next(e));return()=>n==null?void 0:n.dispose()})}function ii(e){return function(t){return new fe(n=>(t.subscribe({next:t=>{n.next(t),e(t)&&n.complete()},complete:()=>n.complete(),error:e=>n.error(e)}),()=>n.unsubscribe()))}}function ai(e=0){return t=>{let n=[];return t.pipe(Te(e=>n.push(e)),ge(e),be(()=>n),Te(()=>n=[]))}}function oi(e){let t=new pe(1);return setTimeout(()=>t.next(),e),t.pipe(we(1))}function si(e,t){let n=new v(t);return e.subscribe(n),n}const ci=e=>new Promise(t=>{xe(ri(e.onCommandExecuted.bind(e)).pipe(Me(([e])=>e.type===Yr.MUTATION)),Ee(300)).pipe(je(16),Ne()).subscribe(()=>{t()})});function li(e,t){let n=0,r=e.length-1;if(t<e[0])return 0;if(t>=e[e.length-1])return e.length-1;for(;n<=r;){if(e[n]===t){for(;n<e.length&&e[n]===t;)n++;return n}if(t>e[n]&&t<e[n+1])return n+1;if(e[r]===t){for(;r<e.length&&e[r]===t;)r++;return r}if(t>e[r-1]&&t<e[r])return r;n++,r--}return-1}function ui(e,t){let n=0,r=e.length-1;for(;n<=r;){let i=Math.floor((r+n)/2);if(t<e[i]&&(i===0||t>=e[i-1]))return i;if(t>=e[i])n=i+1;else if(t<e[i])r=i-1;else return-1}return-1}function di(e,t){let n=0,r=e.length;for(;n<r;){let i=Math.floor((n+r)/2);e[i]<=t?n=i+1:r=i}return n<e.length?n:e.length-1}function fi(e,t,n=!1){let r=e.length-1;if(t<0||t<e[0])return 0;if(r=e.length<40||t<=e[20]||t>=e[r-20]?li(e,t):di(e,t),n){let t=e[r];return e.indexOf(t)}return r}function pi(e){let t=new Blob([e],{type:`text/javascript`});return window.URL.createObjectURL(t)}const mi=2,hi=1;function gi(e,t){if(t==null||e==null)return!0;let{left:n=0,top:r=0,height:i=0,width:a=0,angle:o=0}=t,{left:s=0,top:c=0,height:l=0,width:u=0,angle:d=0}=e,f=u,p=l,m=a,h=i;return Math.abs(s-n)>2||Math.abs(c-r)>2||Math.abs(f-m)>2||Math.abs(p-h)>2||Math.abs(d-o)>1}const _i=`rgb(`,vi=`rgba(`,yi={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchealmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],darkyellow:[139,128,0],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midbightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]};var bi=class e{static mix(t,n,r){var i,a;r=Math.min(1,Math.max(0,r));let o=new e(t).toRgb(),s=new e(n).toRgb(),c=(i=o.a)==null?1:i,l=(a=s.a)==null?1:a;return new e({r:(s.r-o.r)*r+o.r,g:(s.g-o.g)*r+o.g,b:(s.b-o.b)*r+o.b,a:(l-c)*r+c})}static getContrastRatio(t,n){let r=new e(t).getLuminance(),i=new e(n).getLuminance();return(Math.max(r,i)+.05)/(Math.min(r,i)+.05)}constructor(t){if(C(this,`_color`,void 0),C(this,`_rgbColor`,void 0),C(this,`_isValid`,!1),t==null){this._setNullColor();return}if(t instanceof e){this._color={...t._color},this._rgbColor={...t._rgbColor};return}let n=Ci(t);if(n==null){this._setNullColor();return}this._color=n;let r=Oi(this._color);if(r==null){this._setNullColor();return}this._rgbColor=r,this._isValid=!0}get isValid(){return this._isValid}toRgb(){return this._rgbColor}toRgbString(){let{r:e,g:t,b:n,a:r=1}=this.toRgb(),i=r<1;return`rgb${i?`a`:``}(${e},${t},${n}${i?`,${r}`:``})`}toString(){return this.toRgbString()}toHexString(e){let{r:t,g:n,b:r,a:i=1}=this.toRgb(),a=i<1,o=[xi(Math.round(t).toString(16)),xi(Math.round(n).toString(16)),xi(Math.round(r).toString(16)),xi(Math.round(i*255).toString(16))];return e&&o[0][0]===o[0][1]&&o[1][0]===o[1][1]&&o[2][0]===o[2][1]&&o[3][0]===o[3][1]?a?`#${o[0][0]}${o[1][0]}${o[2][0]}${o[3][0]}`:`#${o[0][0]}${o[1][0]}${o[2][0]}`:a?`#${o[0]}${o[1]}${o[2]}${o[3]}`:`#${o[0]}${o[1]}${o[2]}`}toHsv(){return Ni(this.toRgb())}toHsl(){return Mi(this.toRgb())}lighten(t=10){let n=this.toHsl();return n.l+=t,n.l=Math.min(Math.max(n.l,0),100),new e(n)}darken(t=10){let n=this.toHsl();return n.l-=t,n.l=Math.min(Math.max(n.l,0),100),new e(n)}setAlpha(t){return new e({...this._rgbColor,a:t})}getLuminance(){let{r:e,g:t,b:n}=this.toRgb();return e=Si(e),t=Si(t),n=Si(n),Number((.2126*e+.7152*t+.0722*n).toFixed(3))}getBrightness(){let{r:e,g:t,b:n}=this.toRgb();return(e*299+t*587+n*114)/1e3}getAlpha(){var e;return(e=this._color.a)==null?1:e}isDark(){return this.getBrightness()<128}isLight(){return!this.isDark()}_setNullColor(){this._isValid=!1,this._color={r:0,g:0,b:0,a:0},this._rgbColor={r:0,g:0,b:0,a:0}}};const xi=e=>e.length===1?`0${e}`:e,Si=e=>(e/=255,e<=.03928?e/12.92:((e+.055)/1.055)**2.4),Ci=e=>{if(Fi(e)){if(`r`in e){let t={r:Math.round(e.r),g:Math.round(e.g),b:Math.round(e.b)};return e.a!==void 0&&(t.a=e.a),t}if(`l`in e){let t={h:Math.round(e.h),s:e.s,l:e.l};return e.a!==void 0&&(t.a=e.a),t}let t={h:Math.round(e.h),s:e.s,v:e.v};return e.a!==void 0&&(t.a=e.a),t}let t=e.trim().toLowerCase();if(yi[t]){let e=yi[t],n={r:Math.round(e[0]),g:Math.round(e[1]),b:Math.round(e[2])};return n.a=e[3]||1,n}if(t.startsWith(`#`))return wi(t);if(t.startsWith(`rgb`))return Ti(t);if(t.startsWith(`hsl`))return Ei(t);if(t.startsWith(`hsv`))return Di(t)},wi=e=>{let t=e.substring(1),n=RegExp(`.{1,${t.length>=6?2:1}}`,`g`),r=t.match(n);if(!r||r.length<3)throw Error(`The color '${e}' is illegal hex color`);r[0].length===1&&(r=r.map(e=>e+e));let i={r:Number.parseInt(r[0],16),g:Number.parseInt(r[1],16),b:Number.parseInt(r[2],16)};return r.length>3&&(i.a=Number.parseInt(r[3],16)/255),i},Ti=e=>{let t=e.indexOf(`(`);if(t===-1)throw Error(`The color '${e}' is illegal rgb color`);let n=e.substring(t+1,e.length-1).split(`,`);if(n.length<3)throw Error(`The color '${e}' is illegal rgb color`);let r={r:Number.parseInt(n[0],10),g:Number.parseInt(n[1],10),b:Number.parseInt(n[2],10)};return n.length>3&&(r.a=Number.parseFloat(n[3])),r},Ei=e=>{let t=e.indexOf(`(`);if(t===-1)throw Error(`The color '${e}' is illegal hsl color`);let n=e.substring(t+1,e.length-1).split(`,`);if(n.length<3)throw Error(`The color '${e}' is illegal hsl color`);let r={h:Number.parseInt(n[0],10),s:Number.parseFloat(n[1]),l:Number.parseFloat(n[2])};return n.length>3&&(r.a=Number.parseFloat(n[3])),r},Di=e=>{let t=e.indexOf(`(`);if(t===-1)throw Error(`The color '${e}' is illegal hsv color`);let n=e.substring(t+1,e.length-1).split(`,`);if(n.length<3)throw Error(`The color '${e}' is illegal hsv color`);let r={h:Number.parseInt(n[0],10),s:Number.parseFloat(n[1]),v:Number.parseFloat(n[2])};return n.length>3&&(r.a=Number.parseFloat(n[3])),r},Oi=e=>{let t=Ci(e);if(t!=null)return`r`in t?t:`l`in t?Ai(t):ji(t)},ki=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),Ai=e=>{let{h:t,s:n,l:r}=e;t/=360,n/=100,r/=100;let i=0,a=0,o=0;if(n===0)i=a=o=r;else{let e=r<.5?r*(1+n):r+n-r*n,s=2*r-e;i=ki(s,e,t+1/3),a=ki(s,e,t),o=ki(s,e,t-1/3)}let s={r:Math.round(i*255),g:Math.round(a*255),b:Math.round(o*255)};return e.a!==void 0&&(s.a=e.a),s},ji=e=>{let{h:t,s:n,v:r}=e;t=t/360*6,n/=100,r/=100;let i=Math.floor(t),a=t-i,o=r*(1-n),s=r*(1-a*n),c=r*(1-(1-a)*n),l=i%6,u=[r,s,o,o,c,r][l],d=[c,r,r,s,o,o][l],f=[o,o,c,r,r,s][l],p={r:u*255,g:d*255,b:f*255};return e.a!==void 0&&(p.a=e.a),p},Mi=e=>{let{r:t,g:n,b:r}=e;t/=255,n/=255,r/=255;let i=Math.max(t,n,r),a=Math.min(t,n,r),o=(i+a)/2,s,c;if(i===a)s=c=0;else{let e=i-a;switch(c=o>.5?e/(2-i-a):e/(i+a),i){case t:s=(n-r)/e+(n<r?6:0);break;case n:s=(r-t)/e+2;break;default:s=(t-n)/e+4;break}s/=6}let l={h:Math.round(s*360),s:Math.round(c*100),l:Math.round(o*100)};return e.a!==void 0&&(l.a=e.a),l},Ni=e=>{let{r:t,g:n,b:r}=e;t/=255,n/=255,r/=255;let i=Math.max(t,n,r),a=Math.min(t,n,r),o,s=i,c=i-a,l=i===0?0:c/i;if(i===a)o=0;else{switch(i){case t:o=(n-r)/c+(n<r?6:0);break;case n:o=(r-t)/c+2;break;default:o=(t-n)/c+4;break}o/=6}let u={h:Math.round(o*360),s:Math.round(l*100),v:Math.round(s*100)};return e.a!==void 0&&(u.a=e.a),u},Pi=e=>e==null,Fi=e=>!Pi(e)&&typeof e==`object`;function Ii(e){return!!(/^#(?:[0]{3}|[0]{6})\b/.test(e)||/^rgb\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*\)$/.test(e)||/^rgba\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e)||/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*\)$/.test(e)||/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e))}function Li(e){return!!(/^#(?:[Ff]{3}|[Ff]{6})\b/.test(e)||/^rgb\s*\(\s*255\s*,\s*255\s*,\s*255\s*\)$/.test(e)||/^rgba\s*\(\s*255\s*,\s*255\s*,\s*255\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e)||/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*\)$/.test(e)||/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e))}function Ri(e){return e&&(e.s!==void 0||e.p!==void 0||e.v!==void 0||e.t!==void 0||e.f!==void 0||e.si!==void 0||e.custom!==void 0)}function zi(e){if(e.t!==void 0)return e.t;if(typeof e.v==`string`)return tr.STRING;if(typeof e.v==`number`)return tr.NUMBER;if(typeof e.v==`boolean`)return tr.BOOLEAN}function Bi(e){if(e==null)return!0;let{v:t,f:n,si:r,p:i,custom:a}=e;return!(!(t==null||typeof t==`string`&&t.length===0)||n!=null&&n.length>0||r!=null&&r.length>0||i!=null||a!=null)}function Vi(e){return e!=null&&(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)}let B=function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.ROW=1]=`ROW`,e[e.COLUMN=2]=`COLUMN`,e[e.ALL=3]=`ALL`,e}({}),V=function(e){return e[e.NONE=0]=`NONE`,e[e.ROW=1]=`ROW`,e[e.COLUMN=2]=`COLUMN`,e[e.ALL=3]=`ALL`,e}({});function Hi(e){return[e.startRow,e.startColumn,e.endRow,e.endColumn]}let Ui=function(e){return e.NONE=`none`,e.BACKWARD=`backward`,e.FORWARD=`forward`,e}({}),Wi=function(e){return e.RECT=`RECT`,e.TEXT=`TEXT`,e}({});function Gi(e,t,n){let r=!1,i=!1,a=e,o=t,s=e,c=t;if(n==null)return{actualRow:e,actualColumn:t,isMergedMainCell:i,isMerged:r,endRow:a,endColumn:o,startRow:s,startColumn:c};for(let l=0;l<n.length;l++){let{startRow:u,endRow:d,startColumn:f,endColumn:p}=n[l];if(e===u&&t===f){a=d,o=p,s=u,c=f,i=!0;break}if(e>=u&&e<=d&&t>=f&&t<=p){a=d,o=p,s=u,c=f,r=!0;break}}return{actualRow:e,actualColumn:t,isMergedMainCell:i,isMerged:r,endRow:a,endColumn:o,startRow:s,startColumn:c}}let Ki=function(e){return e.Raw=`raw`,e.Intercepted=`intercepted`,e.Both=`both`,e}({});const qi={[nr.OFFICE]:{[j.ACCENT1]:`#4472C4`,[j.ACCENT2]:`#ED7D31`,[j.ACCENT3]:`#A5A5A5`,[j.ACCENT4]:`#70AD47`,[j.ACCENT5]:`#5B9BD5`,[j.ACCENT6]:`#70AD47`,[j.DARK1]:`#000000`,[j.DARK2]:`#44546A`,[j.LIGHT1]:`#FFFFFF`,[j.LIGHT2]:`#E7E6E6`,[j.HYPERLINK]:`#0563C1`,[j.FOLLOWED_HYPERLINK]:`#954F72`}},Ji=`@@@`,Yi=`@`,Xi=`General`;function Zi(e){return e===`@@@`||e===`@`}function Qi(e){return e==null||e===`General`}const $i=(e,t)=>{if(e&&!t||!e&&t)return!1;let n=e=>{let t=Fe.tokenize(e),n=``,r=!1,i=!1;for(let e of t){if(e.type===Fe.tokenTypes.POINT){r=!0;continue}if(!(i&&e.type===Fe.tokenTypes.MINUS)&&e.type!==Fe.tokenTypes.SKIP){if(e.type===Fe.tokenTypes.COLOR){i=!0;continue}else i=!1;r&&e.type===Fe.tokenTypes.ZERO||(r=!1,r||(n+=e.value||``))}}return n};return n(e)===n(t)},ea=new Set([`m d`]),ta=new Set([`h:mm AM/PM`,`hh:mm AM/PM`]),na=new Set([`$`,`¥`,`₽`,`₫`,`NT$`,`€`,`₩`,`﷼`]),ra=e=>{var t,n;let r=(t=(n=Fe.parseDate(e))==null?Fe.parseTime(e):n)==null?Fe.parseNumber(e):t;if(!r)return null;let{z:i}=r;if(i){if(ea.has(i)||ta.has(i)&&!/\s(A|AM|P|PM)$/i.test(e))return null;if(i.includes(`#,##0`)){if(/[.,]$/.test(e))return null;let t=e.replace(RegExp(`^[${[...na].join(``)}]+`),``).trim();if(t.includes(`,`)&&!/^-?\d{1,3}(,\d{3})*(\.\d+)?$/.test(t))return null}}return r};function ia(e,t){let n={};for(let r in e){let i=Number(r),a=e[i];for(let e in a){let r=Number(e),o=a[r],s=t(i,r,o);s!==void 0&&(n[i]?n[i][r]=s:n[i]={[r]:s})}}return n}function aa(e){let t=0,n=Object.keys(e);for(let e of n){let n=Number(e);t=Math.max(t,n)}return t+1}const oa=e=>e==null||typeof e==`object`&&Object.keys(e).length===0;function sa(e,t,n){let r=aa(n),i=n;for(let t=r-1;t>=e;t--)oa(i[t])?delete i[t+1]:i[t+1]=i[t];oa(t)||(i[e]=t)}function ca(e,t,n){let r=Object.keys(n).reduce((e,t)=>Math.max(e,Number.parseInt(t)),0)+1;for(let i=e;i<r;i++)i<e+t?delete n[i]:n[i]!==void 0&&(n[i-t]=n[i],delete n[i])}function la(e,t){let n=e,r=Object.keys(n),i=r.length,a=t,o=Object.keys(a),s=o.length,c={},l=0;for(let e=0;e<i;e++,l++)c[l]=n[r[e]];for(let e=0;e<s;e++,l++)c[l]=a[o[e]];return c}function ua(e,t,n){let r=n;if(aa(n)>0){let n={},i=0;for(let a=e;a<=t;a++)r[a]&&(n[i]=r[a],i++);return n}return{}}function da(e,t,n,r){let i=e>n;if(!i&&e+t>n)throw Error(`Invalid move operation`);i?fa(e,t,n,r):pa(e,t,n,r)}function fa(e,t,n,r){let i=r,a=[];for(let n=e;n<e+t;n++)a.push(i[n]);for(let r=e-1;r>=n;r--){let e=i[r];i[r+t]=e,e===void 0&&delete i[r+t]}a.forEach((e,t)=>{i[n+t]=e,e===void 0&&delete i[n+t]})}function pa(e,t,n,r){let i=r,a=[];for(let n=e;n<e+t;n++)a.push(i[n]);for(let r=e+t;r<n;r++){let e=i[r];i[r-t]=e,e===void 0&&delete i[r-t]}a.forEach((e,r)=>{i[n+r-t]=e,e===void 0&&delete i[n+r-t]})}var ma=class e{constructor(e={}){C(this,`_matrix`,void 0),this._setOriginValue(e)}static MakeObjectMatrixSize(t){return new e({[t-1]:{}})}getMatrix(){return this._matrix}forEach(e){let t=this._matrix,n=Object.keys(t);for(let r of n){let n=Number(r),i=t[n];if(e(n,i)===!1)return this}return this}forRow(e){let t=this._matrix,n=Object.keys(t);for(let r of n){let n=Number(r),i=t[n];if(e(n,Object.keys(i).map(e=>Number(e)))===!1)return this}return this}forValue(e){let t=this._matrix;for(let n in t){let r=Number(n),i=t[r];if(i)for(let t in i){let n=Number(t),a=i[n];if(e(r,n,a)===!1)return this}}return this}swapRow(e,t){let n=this._matrix[e],r=this._matrix[t];this._matrix[e]=r,this._matrix[t]=n}getRow(e){return this._matrix[e]}getRowOrCreate(e){let t=this.getRow(e);return t==null&&(t={},this._matrix[e]=t),t}reset(){this._setOriginValue({})}hasValue(){let e=this._matrix,t=Object.keys(e);if(t.length===0)return!1;for(let n of t){let t=e[Number(n)];if(Object.keys(t).length>0)return!0}return!1}getValue(e,t){var n;return(n=this._matrix)==null||(n=n[e])==null?void 0:n[t]}setValue(e,t,n){let r=this.getRowOrCreate(e);r[t]=n}deleteValue(e,t){var n;(n=this._matrix)==null||(n=n[e])==null||delete n[t]}realDeleteValue(e,t){var n;if((n=this._matrix)==null||(n=n[e])==null||delete n[t],this.getRow(e)){let t=this.getRow(e);if(t==null)return;if(Object.keys(t).length===0){var r;(r=this._matrix)==null||delete r[e]}}}setRow(e,t){this._matrix[e]=t}moveRows(e,t,n){da(e,t,n,this._matrix)}moveColumns(e,t,n){this.forEach((r,i)=>{da(e,t,n,i)})}insertRows(e,t){let n=Object.keys(this._matrix);for(let r=n.length-1;r>=0;r--){let i=Number(n[r]);if(i>=e){let e=this._matrix[i];delete this._matrix[i],this._matrix[i+t]=e}}}insertColumns(e,t){let n=Object.keys(this._matrix);for(let r=0;r<n.length;r++){let i=Number(n[r]),a=this._matrix[i],o=Object.keys(a);for(let n=o.length-1;n>=0;n--){let r=Number(o[n]);if(r>=e){let e=a[r];delete a[r],a[r+t]=e}}}}removeRows(e,t){ca(e,t,this._matrix)}removeColumns(e,t){this.forEach((n,r)=>{r&&ca(e,t,r)})}getFragment(t,n,r,i){let a=new e,o=0;for(let e=t;e<=n;e++){let t={},n=0;for(let a=r;a<=i;a++)t[n]=this.getValue(e,a),n++;a.setRow(o,t),o++}return a}getSlice(t,n,r,i){let a=new e;for(let e=t;e<=n;e++)for(let t=r;t<=i;t++){let n=this.getValue(e,t);n&&a.setValue(e,t,D.deepClone(n))}return a}getSliceDataAndCellCountByRows(t,n){let r=new e,i=0;for(let e=t;e<=n;e++){let t=this.getRow(e);t&&(r.setRow(e,t),i+=Object.keys(t).length)}return{sliceData:r,cellCount:i}}getSizeOf(){return Object.keys(this._matrix).length}getLength(){return aa(this._matrix)}getRange(){let e=this.getLength()-1,t=0,n=this.getLength();for(let e=0;e<n;e++){let n=this.getRow(e);if(n){let e=aa(n)-1;t=e>t?e:t}}return{startRow:0,startColumn:0,endRow:e,endColumn:t}}getRealRange(){let e=Object.keys(this._matrix),t=e.length,n=t>0?Number(e[0]):0,r=t>0?Number(e[t-1]):0,i=-1/0,a=0;for(let t of e){let e=this.getRow(Number(t));if(e){let t=Object.keys(e);if(t.length>0){let e=Number(t[0]),n=Number(t[t.length-1]);(i===-1/0||e<i)&&(i=e),n>a&&(a=n)}}}return i===-1/0&&(i=0),{startRow:n,endRow:r,startColumn:i,endColumn:a}}getRealRowRange(){let e=Object.keys(this._matrix),t=e.length;return{startRow:t>0?Number(e[0]):0,endRow:t>0?Number(e[t-1]):0}}toNativeArray(){let e=[];return this.forValue((t,n,r)=>{e.push(r)}),e}toArray(){let e=[];return this.forRow((t,n)=>{e[t]==null&&(e[t]=[]),n.forEach(n=>{e[t][n]=this.getValue(t,n)})}),e}toFullArray(){let{endColumn:e,endRow:t}=this.getRange(),n=[];for(let r=0;r<=t;r++){let t=Array(e+1).fill(void 0);n.push(t)}return this.forValue((e,t,r)=>{n[e][t]=r}),n}toJSON(){return this._matrix}clone(){let e=JSON.stringify(this._matrix);return JSON.parse(e)}getData(){let e=JSON.stringify(this._matrix);return JSON.parse(e)}getArrayData(){let t=0,n=0,r=!1,i=!1,a=new e;return this.forEach((e,o)=>{r||(r=!0,t=e),Object.keys(o).forEach(r=>{let o=Number(r);i?o<n&&(n=o):(i=!0,n=o);let s=this.getValue(e,o);a.setValue(e-t,o-n,s)})}),a.getData()}getStartEndScope(){let e=1/0,t=-1/0,n=1/0,r=-1/0,i=Object.keys(this._matrix);i.length>0&&(e=+i[0],t=+i[i.length-1]);for(let e of i){let t=Object.keys(this._matrix[e]);t.length>0&&(n=Math.min(n,+t[0]),r=Math.max(r,+t[t.length-1]))}return{startRow:e,endRow:t,startColumn:n,endColumn:r}}getDataRange(){let e=0,t=0,n=0,r=-1,i=!1,a=!1;return this.forEach((o,s)=>{if(i||(i=!0,e=o),s==null)return;let c=aa(s)-1;c>n&&(n=c),Object.keys(s).forEach(e=>{let n=Number(e);a?n<t&&(t=n):(a=!0,t=n)}),o>r&&(r=o)}),{startRow:e,startColumn:t,endRow:r,endColumn:n}}getDiscreteRanges(){let e=[];return this.forEach((t,n)=>{Object.keys(n).forEach(n=>{let r=Number(n),i=!1;for(let n of e)if(t>=n.startRow&&t<=n.endRow+1&&r>=n.startColumn&&r<=n.endColumn+1){n.endRow=Math.max(t,n.endRow),n.endColumn=Math.max(r,n.endColumn),i=!0;break}i||e.push({startRow:t,endRow:t,startColumn:r,endColumn:r})})}),e}merge(e){this.forValue((t,n)=>{let r=e.getValue(t,n);r!=null&&this.setValue(t,n,r)})}concatRows(e){let t=e.getMatrix();for(let e in t){let n=Number(e);this.setRow(n,t[n])}}_setOriginValue(e={}){this._matrix=e}};function ha(e){let{actualRow:t,actualColumn:n,isMerged:r,isMergedMainCell:i,mergeInfo:a}=e,{startY:o,endY:s,startX:c,endX:l}=e,u=t,d=n,f=t,p=n;if(r&&a){let{startRow:e,startColumn:t,endRow:n,endColumn:r,startY:i,endY:m,startX:h,endX:g}=a;u=e,d=t,f=n,p=r,o=i,s=m,c=h,l=g}return i&&(o=a.startY,s=a.endY,c=a.startX,l=a.endX,f=a.endRow,p=a.endColumn),{startRow:u,startColumn:d,endRow:f,endColumn:p,startY:o,endY:s,startX:c,endX:l}}const ga=ha;function _a(e){if(!e)return;let{actualRow:t,actualColumn:n,isMerged:r,isMergedMainCell:i,startRow:a,startColumn:o,endRow:s,endColumn:c}=e,l=t,u=n,d=t,f=n;return(r||i)&&(l=a,u=o,d=s,f=c),{startRow:l,startColumn:u,endRow:d,endColumn:f}}function va(e){var t;return!e||((e==null||(t=e.v)==null?void 0:t.toString())||``).length===0&&!e.p}function ya(e){return va(e)&&(e==null?void 0:e.coverable)!==!1}function ba(e){if(e){if(e.rgb)return new bi(e.rgb).toHexString();if(e.th!=null){var t;let n=(t=qi[nr.OFFICE])==null?void 0:t[e.th];if(n)return new bi(n).toRgbString()}}return null}function xa(e){return D.isString(e)&&e.substring(0,1)===`=`&&e.length>1}function Sa(e){return D.isString(e)&&e.length>0}function Ca(e,t=!1){let n=``,r=new Map([[`ff`,()=>{e.ff&&(n+=`font-family: ${e.ff}; `)}],[`fs`,()=>{if(e.fs){let t=e.fs;e.va&&(t/=2),n+=`font-size: ${t}pt; `}}],[`it`,()=>{e.it&&(n+=`font-style: italic; `)}],[`bl`,()=>{e.bl&&(n+=`font-weight: bold; `)}],[`ul`,()=>{var t;(t=e.ul)!=null&&t.s&&(n.indexOf(`text-decoration-line`)>-1?n=n.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(e,t)=>`${t} underline`):n+=`text-decoration: underline; `,e.ul.cl&&n.indexOf(`text-decoration-color`)===-1&&(n+=`text-decoration-color: ${ba(e.ul.cl)}; `),e.ul.t&&n.indexOf(`text-decoration-style`)===-1&&(n+=`text-decoration-style: ${e.ul.t} `))}],[`st`,()=>{var t;(t=e.st)!=null&&t.s&&(n.indexOf(`text-decoration-line`)>-1?n=n.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(e,t)=>`${t} line-through`):n+=`text-decoration-line: line-through; `,e.st.cl&&n.indexOf(`text-decoration-color`)===-1&&(n+=`text-decoration-color: ${ba(e.st.cl)}; `),e.st.t&&n.indexOf(`text-decoration-style`)===-1&&(n+=`text-decoration-style: ${e.st.t} `))}],[`ol`,()=>{var t;(t=e.ol)!=null&&t.s&&(n.indexOf(`text-decoration-line`)>-1?n=n.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(e,t)=>`${t} overline`):n+=`text-decoration-line: overline; `,e.ol.cl&&n.indexOf(`text-decoration-color`)===-1&&(n+=`text-decoration-color: ${ba(e.ol.cl)}; `),e.ol.t&&n.indexOf(`text-decoration-style`)===-1&&(n+=`text-decoration-style: ${e.ol.t} `))}],[`bg`,()=>{e.bg&&(n+=`background: ${ba(e.bg)}; `)}],[`bd`,()=>{var t,r,i,a;if((t=e.bd)!=null&&t.b){var o,s;n+=`border-bottom: ${wa((o=e.bd)==null?void 0:o.b.s)} ${(s=ba(e.bd.b.cl))==null?``:s}; `}if((r=e.bd)!=null&&r.t){var c,l;n+=`border-top: ${wa((c=e.bd)==null?void 0:c.t.s)} ${(l=ba(e.bd.t.cl))==null?``:l}; `}if((i=e.bd)!=null&&i.r){var u,d;n+=`border-right: ${wa((u=e.bd)==null?void 0:u.r.s)} ${(d=ba(e.bd.r.cl))==null?``:d}; `}if((a=e.bd)!=null&&a.l){var f,p;n+=`border-left: ${wa((f=e.bd)==null?void 0:f.l.s)} ${(p=ba(e.bd.l.cl))==null?``:p}; `}}],[`cl`,()=>{e.cl&&(n+=`color: ${ba(e.cl)}; `)}],[`va`,()=>{e.va===er.SUBSCRIPT?n+=`vertical-align: sub; `:e.va===er.SUPERSCRIPT&&(n+=`vertical-align: super; `)}],[`td`,()=>{e.td===qn.LEFT_TO_RIGHT?n+=`direction: ltr; `:e.td===qn.RIGHT_TO_LEFT&&(n+=`direction: rtl; `)}],[`tr`,()=>{if(e.tr){var t,r,i;n+=`--data-rotate: (${(t=e.tr)==null?void 0:t.a}deg${(r=e.tr)!=null&&r.v?` ,${(i=e.tr)==null?void 0:i.v}`:``});`}}],[`ht`,()=>{e.ht===Yn.LEFT?n+=`text-align: left; `:e.ht===Yn.RIGHT?n+=`text-align: right; `:e.ht===Yn.CENTER?n+=`text-align: center; `:e.ht===Yn.JUSTIFIED&&(n+=`text-align: justify; `)}],[`vt`,()=>{e.vt===Xn.BOTTOM?n+=`vertical-align: bottom; `:e.vt===Xn.TOP?n+=`vertical-align: top; `:e.vt===Xn.MIDDLE&&(n+=`vertical-align: middle; `)}],[`tb`,()=>{e.tb===Zn.CLIP?n+=`white-space: nowrap; overflow-x: hidden; `:e.tb===Zn.WRAP&&(n+=`white-space: normal;`)}],[`pd`,()=>{var t,r,i,a,o,s,c,l;let u=`${(t=e.pd)==null?void 0:t.b}pt`,d=`${(r=e.pd)==null?void 0:r.t}pt`,f=`${(i=e.pd)==null?void 0:i.l}pt`,p=`${(a=e.pd)==null?void 0:a.r}pt`;(o=e.pd)!=null&&o.b&&(n+=`padding-bottom: ${u}; `),(s=e.pd)!=null&&s.t&&(n+=`padding-top: ${d}; `),(c=e.pd)!=null&&c.l&&(n+=`padding-left: ${f}; `),(l=e.pd)!=null&&l.r&&(n+=`padding-right: ${p}; `)}]]),i=[`bd`,`tr`,`tb`];for(let n in e){var a;t&&i.includes(n)||(a=r.get(n))==null||a()}return n}function wa(e){let t=``;return e===k.NONE?t=`none`:e===k.THIN?t=`0.5pt solid`:e===k.HAIR?t=`0.5pt double`:e===k.DOTTED?t=`0.5pt dotted`:e===k.DASHED||e===k.DASH_DOT?t=`0.5pt dashed`:e===k.DASH_DOT_DOT?t=`0.5pt dotted`:e===k.DOUBLE?t=`0.5pt double`:e===k.MEDIUM?t=`1pt solid`:e===k.MEDIUM_DASHED||e===k.MEDIUM_DASH_DOT?t=`1pt dashed`:e===k.MEDIUM_DASH_DOT_DOT?t=`1pt dotted`:e===k.SLANT_DASH_DOT?t=`0.5pt dashed`:e===k.THICK&&(t=`1.5pt solid`),t}function Ta(e){let t=0;if(e=e.trim(),e===`none`)t=k.NONE;else if(e===`0.5pt solid`)t=k.THIN;else if(e===`0.5pt double`)t=k.HAIR;else if(e===`0.5pt dotted`)t=k.DOTTED;else if(e===`0.5pt dashed`)t=k.DASHED;else if(e===`1pt solid`)t=k.MEDIUM;else if(e===`1pt dashed`)t=k.MEDIUM_DASHED;else if(e===`1pt dotted`)t=k.MEDIUM_DASH_DOT_DOT;else if(e===`1.5pt solid`)t=k.THICK;else if(!e.includes(`none`))t=k.THIN;else return k.NONE;return t}function Ea(e,t){let n=e.body;if(t){let{headers:r,footers:i}=e;r!=null&&r[t]?n=r[t].body:i!=null&&i[t]&&(n=i[t].body)}return n}function Da(e,t){let{startRow:n,endRow:r,startColumn:i,endColumn:a,rangeType:o}=e;if(n<0||i<0||r<0||a<0||!(Number.isNaN(n)&&Number.isNaN(r))&&o===B.COLUMN||!(Number.isNaN(i)&&Number.isNaN(a))&&o===B.ROW||o!==B.ROW&&o!==B.COLUMN&&(Number.isNaN(i)||Number.isNaN(n)||Number.isNaN(a)||Number.isNaN(r)))return!1;if(t){let e=t.getRowCount(),n=t.getColumnCount();if(r>=e||a>=n)return!1}return!0}function Oa(e,t){return{startRow:e,endRow:e,startColumn:t,endColumn:t}}function ka(e){if(xa(e))return{f:e,v:null,p:null};if(Vi(e)){if(typeof e==`string`){let t=ra(e);if(t&&t.z)return{v:t.v,p:null,f:null,s:{n:{pattern:t.z||`General`}}}}return{v:e,p:null,f:null}}return Ri(e),e}function Aa(e,t){let n=new ma,{startRow:r,startColumn:i,endRow:a,endColumn:o}=t;if(D.isArray(e))for(let t=0;t<=a-r;t++)for(let a=0;a<=o-i;a++)n.setValue(t+r,a+i,ka(e[t][a]));else new ma(e).forValue((e,t,r)=>{n.setValue(e,t,ka(r))});return n.getMatrix()}function ja(e,t){return Object.prototype.toString.call(e)===Object.prototype.toString.call(t)?Object.prototype.toString.call(e)===`[object Object]`||Object.prototype.toString.call(e)===`[object Array]`?Object.keys(e).length===Object.keys(t).length?Object.keys(e).every(n=>ja(e[n],t[n])):!1:e===t:!1}function Ma(e,t){let n=e.ts||{},r=t.ts||{};return e.sId===t.sId?ja(n,r):!1}function Na(e,t){return t.some(t=>e.indexOf(t)>-1)}Ie.extend(Re),Ie.extend(Le),Ie.extend(He),Ie.extend(ze),Ie.extend(Ue),Ie.extend(We),Ie.extend(Ve),Ie.extend(Be);function Pa(e,t,n,r){if(e>t)throw Error(`a1 should be less than a2`);if(n>r)throw Error(`b1 should be less than b2`);if(t<n||r<e)return[e,t];if(n<=e&&r>=t)return[];let i=r-n+1;return e<n&&t>r?[e,t-i]:n<=e&&r<t?[r+1-i,t-i]:n>e&&r>=t?[e,n-1]:[e,t]}function Fa(e){if(e==null)return!1;let t=e.bullet;return(t==null?void 0:t.listId)!=null}function Ia(e){if(e==null)return!1;let t=e.paragraphStyle;return La(t)}function La(e){var t;return!(e==null||(e.indentStart==null||e.indentStart.v===0)&&e.hanging==null||((t=e.hanging)==null?void 0:t.v)===0)}function Ra(e,t,n){return e.slice(0,t)+n+e.slice(t)}function za(e,t,n){return t>n?e:e.slice(0,t)+e.slice(n)}function Ba(e){if(e==null||typeof e==`boolean`)return!1;if(typeof e==`number`)return!isNaN(e);if(typeof e==`string`){let t=e.trim();return t===``?!1:!isNaN(Number(t))}return!1}function Va(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+(t<<6)+(t<<16)-t;return t>>>0}function Ha(e){if(e.length===0)return[];let t=e.slice().sort((e,t)=>(Array.isArray(e)?e[0]:e)-(Array.isArray(t)?t[0]:t)),n=[],r=Array.isArray(t[0])?t[0][0]:t[0],i=r;for(let e=1;e<t.length;e++){let a=t[e],o,s;Array.isArray(a)?(o=a[0],s=a[1]):(o=a,s=a),o<=i+1?i=Math.max(i,s):(n.push([r,i]),r=o,i=s)}return n.push([r,i]),n}function Ua(e){if(e.length===0)return[];let t=e.slice().sort((e,t)=>e[0]-t[0]),n=[],[r,i]=t[0];for(let e=1;e<t.length;e++){let[a,o]=t[e];a<=i+1?i=Math.max(i,o):(n.push([r,i]),r=a,i=o)}return n.push([r,i]),n}function Wa(...e){let t;return t=e.length===1&&Array.isArray(e[0])?e[0]:e,le({},...t)}let Ga,Ka,qa,Ja;const H=Symbol(`newer`),U=Symbol(`older`);Ga=Symbol.iterator;var Ya=class{constructor(e){C(this,`entry`,void 0),this.entry=e}[Ga](){return this}next(){let e=this.entry;return e?(this.entry=e[H],{done:!1,value:e.key}):{done:!0,value:void 0}}};Ka=Symbol.iterator;var Xa=class{constructor(e){C(this,`entry`,void 0),this.entry=e}[Ka](){return this}next(){let e=this.entry;return e?(this.entry=e[H],{done:!1,value:e.value}):{done:!0,value:void 0}}};qa=Symbol.iterator;var Za=class{constructor(e){C(this,`entry`,void 0),this.entry=e}[qa](){return this}next(){let e=this.entry;return e?(this.entry=e[H],{done:!1,value:[e.key,e.value]}):{done:!0,value:void 0}}},Qa=class{constructor(e,t){C(this,`key`,void 0),C(this,`value`,void 0),C(this,H,void 0),C(this,U,void 0),this.key=e,this.value=t,this[H]=void 0,this[U]=void 0}toJSON(){return{key:this.key,value:this.value}}};Ja=Symbol.iterator;var $a=class{onShift(e){if(this._onShiftListeners.indexOf(e)===-1)return this._onShiftListeners.push(e),T(()=>tt(this._onShiftListeners,e));throw Error(`[LRUMap]: the listener has been registered!`)}constructor(...e){if(C(this,`_keymap`,void 0),C(this,`size`,0),C(this,`limit`,void 0),C(this,`oldest`,void 0),C(this,`newest`,void 0),C(this,`_onShiftListeners`,[]),eo.hasLength(e,1)){if(eo.isNumber(e[0])){let t=e[0];this._initialize(t,void 0);return}if(eo.isIterable(e[0])){let t=e[0];this._initialize(0,t);return}return}if(eo.hasLength(e,2)){let t=e[0],n=e[1];this._initialize(t,n)}}_initialize(e,t){this.oldest=void 0,this.newest=void 0,this.size=0,this.limit=e,this._keymap=new Map,t&&(this.assign(t),e<1&&(this.limit=this.size))}_markEntryAsUsed(e){e!==this.newest&&(e[H]&&(e===this.oldest&&(this.oldest=e[H]),e[H][U]=e[U]),e[U]&&(e[U][H]=e[H]),e[H]=void 0,e[U]=this.newest,this.newest&&(this.newest[H]=e),this.newest=e)}assign(e){let t,n=this.limit||Number.MAX_VALUE;this._keymap.clear();let r=e[Symbol.iterator]();for(let e=r.next();!e.done;e=r.next()){let r=new Qa(e.value[0],e.value[1]);if(this._keymap.set(r.key,r),t?(t[H]=r,r[U]=t):this.oldest=r,t=r,n--===0)throw Error(`overflow`)}this.newest=t,this.size=this._keymap.size}set(e,t){let n=this._keymap.get(e);return n?(n.value=t,this._markEntryAsUsed(n),this):(this._keymap.set(e,n=new Qa(e,t)),this.newest?(this.newest[H]=n,n[U]=this.newest):this.oldest=n,this.newest=n,++this.size,this.size>this.limit&&this.shift(),this)}shift(){let e=this.oldest;if(e)return this.oldest&&this.oldest[H]?(this.oldest=this.oldest[H],this.oldest[U]=void 0):(this.oldest=void 0,this.newest=void 0),e[H]=e[U]=void 0,this._keymap.delete(e.key),--this.size,this._onShiftListeners.forEach(t=>t(e)),[e.key,e.value]}get(e){let t=this._keymap.get(e);if(t)return this._markEntryAsUsed(t),t.value}has(e){return this._keymap.has(e)}find(e){let t=this._keymap.get(e);return t?t.value:void 0}delete(e){let t=this._keymap.get(e);if(t)return this._keymap.delete(t.key),t[H]&&t[U]?(t[U][H]=t[H],t[H][U]=t[U]):t[H]?(t[H][U]=void 0,this.oldest=t[H]):t[U]?(t[U][H]=void 0,this.newest=t[U]):this.oldest=this.newest=void 0,this.size--,t.value}clear(){this.oldest=void 0,this.newest=void 0,this.size=0,this._keymap.clear()}keys(){return new Ya(this.oldest)}values(){return new Xa(this.oldest)}entries(){return this[Symbol.iterator]()}[Ja](){return new Za(this.oldest)}forEach(e,t){typeof t!=`object`&&(t=this);let n=this.oldest;for(;n;)e.call(t,n.value,n.key,this),n=n[H]}toJSON(){let e=Array(this.size),t=0,n=this.oldest;for(;n;)e[t++]={key:n.key,value:n.value},n=n[H];return e}toString(){let e=``,t=this.oldest;for(;t;)e+=`${String(t.key)}:${t.value}`,t=t[H],t&&(e+=` < `);return e}},eo=class{static hasLength(e,t){return e.length===t}static getValueType(e){return Object.prototype.toString.apply(e)}static isObject(e){return this.getValueType(e)===`[object Object]`}static isIterable(e){return e[Symbol.iterator]!=null}static isNumber(e){return this.getValueType(e)===`[object Number]`}};function to(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r<65||r>90)return-1;t=t*26+(r-64)}return t}const no=1048576,ro=16384,io={sheetId:``,range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},ao={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},oo={startRow:0,startColumn:0,endRow:0,endColumn:0},so={row:0,column:0},W={ff:`Arial`,fs:11,it:A.FALSE,bl:A.FALSE,ul:{s:A.FALSE},st:{s:A.FALSE},ol:{s:A.FALSE},tr:{a:0,v:A.FALSE},td:qn.UNSPECIFIED,cl:{rgb:`#000000`},bg:{rgb:`#fff`},ht:Yn.UNSPECIFIED,vt:Xn.UNSPECIFIED,tb:Zn.UNSPECIFIED,pd:{t:0,r:0,b:0,l:0},n:null,bd:{b:null,l:null,r:null,t:null}},co={id:`default_slide`,title:`defaultSlide`,pageSize:{width:300,height:300}},lo=[dt,pt,ft],uo={[N.HEADING_1]:{fs:20,bl:1},[N.HEADING_2]:{fs:18,bl:1},[N.HEADING_3]:{fs:16,bl:1},[N.HEADING_4]:{fs:14,bl:1},[N.HEADING_5]:{fs:12,bl:1},[N.NORMAL_TEXT]:null,[N.TITLE]:{fs:26,bl:1},[N.SUBTITLE]:{fs:15,cl:{rgb:`#999999`}},[N.NAMED_STYLE_TYPE_UNSPECIFIED]:null},fo={[N.HEADING_1]:{spaceAbove:{v:20},spaceBelow:{v:10}},[N.HEADING_2]:{spaceAbove:{v:18},spaceBelow:{v:10}},[N.HEADING_3]:{spaceAbove:{v:16},spaceBelow:{v:10}},[N.HEADING_4]:{spaceAbove:{v:14},spaceBelow:{v:8}},[N.HEADING_5]:{spaceAbove:{v:12},spaceBelow:{v:8}},[N.NORMAL_TEXT]:{spaceAbove:{v:0},spaceBelow:{v:0}},[N.TITLE]:{spaceAbove:{v:0},spaceBelow:{v:7}},[N.SUBTITLE]:{spaceAbove:{v:0},spaceBelow:{v:16}},[N.NAMED_STYLE_TYPE_UNSPECIFIED]:null},po=`univer-sheets-chart-print-chart`,mo=`univer-docs-drawing-printing`;let ho=function(e){return e.ARRAY_CONVERTOR=`ARRAY_CONVERTOR`,e.MATRIX_CONVERTOR=`MATRIX_CONVERTOR`,e}({});const go={[P.A3]:{width:1123,height:1587},[P.A4]:{width:794,height:1124},[P.A5]:{width:559,height:794},[P.B4]:{width:944,height:1344},[P.B5]:{width:665,height:944},[P.Executive]:{width:696,height:1008},[P.Folio]:{width:816,height:1248},[P.Legal]:{width:816,height:1344},[P.Letter]:{width:816,height:1056},[P.Statement]:{width:528,height:816},[P.Tabloid]:{width:1056,height:1632}};function _o(e,t){let{textRuns:n=[]}=t,r=0;for(let t of n){let{ts:n={},st:i,ed:a}=t;if(n[e]==null)return A.FALSE;switch(e){case`bl`:case`it`:if(n[e]===A.FALSE)return A.FALSE;break;case`ul`:case`st`:if(n[e].s===A.FALSE)return A.FALSE;break;default:throw Error(`unknown style key: ${e} in IStyleBase`)}r+=a-i}return t.dataStream.indexOf(`\r
|
|
4
|
-
`)===r?A.TRUE:A.FALSE}var vo=class e{constructor(e,t,n){this._deps=n,C(this,`_range`,void 0),C(this,`_worksheet`,void 0),this._range=t,this._worksheet=e}static foreach(e,t){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e;for(let e=n;e<=i;e++)for(let n=r;n<=a;n++)t(e,n)}getRangeData(){return this._range}getValue(){return this.getValues()[0][0]}getValues(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i=[];for(let a=e;a<=t;a++){let e=[];for(let t=n;t<=r;t++)e.push(this.getMatrix().getValue(a,t)||null);i.push(e)}return i}getMatrix(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),a=new ma;for(let o=e;o<=t;o++)for(let e=n;e<=r;e++)a.setValue(o,e,i.getValue(o,e)||null);return a}getMatrixObject(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),a=new ma;for(let o=e;o<=t;o++)for(let t=n;t<=r;t++)a.setValue(o-e,t-n,i.getValue(o,t)||{});return a}getA1Notation(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i,a;return n<r?(i=D.numToWord(n+1)+(e+1),a=D.numToWord(r+1)+(t+1)):(i=D.numToWord(r+1)+(t+1),a=D.numToWord(n+1)+(e+1)),i===a?`${i}`:`${i}:${a}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){let e=this._deps.getStyles();return this.getValues().map(t=>t.map(t=>{var n;let r=e.getStyleByCell(t);return(r==null||(n=r.bg)==null?void 0:n.rgb)||W.bg.rgb}))}getCell(t,n){let{startRow:r,startColumn:i}=this._range,a={startRow:r+t,endRow:r+t,startColumn:i+n,endColumn:i+n};return new e(this._worksheet,a,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(e={}){return this.getObjectValues(e)[0][0]}getObjectValues(e={}){let{startRow:t,endRow:n,startColumn:r,endColumn:i}=this._range,a=this._worksheet.getCellMatrix().getFragment(t,n,r,i).getData();if(e.isIncludeStyle){let e=this._deps.getStyles();for(let s=0;s<=n-t;s++)for(let t=0;t<=i-r;t++){var o;if(a==null||(a==null||(o=a[s])==null?void 0:o[t])==null)continue;let n=a[s][t].s;n&&(a[s][t].s=e.get(n))}}return a}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){let e=this._deps.getStyles();return this.getValues().map(t=>t.map(t=>{var n;let r=e.getStyleByCell(t);return(r==null||(n=r.cl)==null?void 0:n.rgb)||W.cl.rgb}))}getFontFamilies(){return this._getStyles(`ff`)}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles(`ul`)}getUnderline(){var e,t;let{p:n}=(e=this.getValue())==null?{}:e;return n&&Array.isArray((t=n.body)==null?void 0:t.textRuns)&&n.body.textRuns.length>0?_o(`ul`,n.body)===A.TRUE?{s:A.TRUE}:{s:A.FALSE}:this.getUnderlines()[0][0]}getOverlines(){return this._getStyles(`ol`)}getOverline(){return this.getOverlines()[0][0]}getStrikeThrough(){var e,t;let{p:n}=(e=this.getValue())==null?{}:e;return n&&Array.isArray((t=n.body)==null?void 0:t.textRuns)&&n.body.textRuns.length>0?_o(`st`,n.body)===A.TRUE?{s:A.TRUE}:{s:A.FALSE}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles(`st`)}getFontSize(){var e,t;let n=((e=this.getValue())==null?void 0:e.p)||{};return n&&Array.isArray((t=n.body)==null?void 0:t.textRuns)&&n.body.textRuns.length>0&&n.body.textRuns.some(e=>{var t;return(e==null||(t=e.ts)==null?void 0:t.fs)!=null})?Math.max(...n.body.textRuns.map(e=>{var t;return(e==null||(t=e.ts)==null?void 0:t.fs)||0})):this.getFontSizes()[0][0]}getFontSizes(){return this._getStyles(`fs`)}getBorder(){return this.getBorders()[0][0]}getBorders(){return this._getStyles(`bd`)}getFontStyle(){var e,t;let{p:n}=(e=this.getValue())==null?{}:e;return n&&Array.isArray((t=n.body)==null?void 0:t.textRuns)&&n.body.textRuns.length>0?_o(`it`,n.body)===A.TRUE?Qn.ITALIC:Qn.NORMAL:this._getFontStyles()[0][0]}_getFontStyles(){return this._getStyles(`it`)}getFontWeight(){var e,t;let{p:n}=(e=this.getValue())==null?{}:e;return n&&Array.isArray((t=n.body)==null?void 0:t.textRuns)&&n.body.textRuns.length>0?_o(`bl`,n.body)===A.TRUE?$n.BOLD:$n.NORMAL:this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles(`bl`)}getGridId(){return this._worksheet.getSheetId()}getHeight(){let{_range:e,_worksheet:t}=this,{startRow:n,endRow:r}=e,i=0;for(let e=0;e<=r-n;e++){let n=t.getRowHeight(e);i+=n}return i}getHorizontalAlignment(){return this.getHorizontalAlignments()[0][0]}getHorizontalAlignments(){return this._getStyles(`ht`)}getLastColumn(){return this._range.endColumn}getLastRow(){return this._range.endRow}getNumColumns(){let{startColumn:e,endColumn:t}=this._range;return t-e+1}getNumRows(){let{startRow:e,endRow:t}=this._range;return t-e+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(e=>e.map(e=>(e==null?void 0:e.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(){let e=this._deps.getStyles();return this.getValues().map(t=>t.map(t=>e.getStyleByCell(t)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles(`vt`)}getWidth(){let{_range:e,_worksheet:t}=this,{startColumn:n,endColumn:r}=e,i=0;for(let e=0;e<=r-n;e++)i+=t.getColumnWidth(e);return i}getWrap(){return this.getWrapStrategy()===Zn.WRAP?A.TRUE:A.FALSE}getWrapStrategies(){return this._getStyles(`tb`)}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(t){e.foreach(this._range,t)}_getStyles(e){let t=this._deps.getStyles();return this.getValues().map(n=>n.map(n=>{let r=t&&t.getStyleByCell(n);return r&&r[e]||W[e]}))}};C(vo,`transformRange`,(e,t)=>{let n=t.getMaxColumns()-1,r=t.getMaxRows()-1;return e.rangeType===B.ALL?{startColumn:0,startRow:0,endColumn:n,endRow:r}:e.rangeType===B.COLUMN?{startRow:0,endRow:r,startColumn:e.startColumn,endColumn:e.endColumn}:e.rangeType===B.ROW?{startColumn:0,endColumn:n,startRow:e.startRow,endRow:e.endRow}:{startColumn:e.startColumn,endColumn:Math.min(e.endColumn,n),startRow:e.startRow,endRow:Math.min(e.endRow,r)}});function yo(e,t,n,r=!1){if(t===0&&n===0)return e;let i={...e},a=i.startAbsoluteRefType||V.NONE,o=i.endAbsoluteRefType||V.NONE,s=i.rangeType||B.NORMAL;if(!r&&a===V.ALL&&o===V.ALL)return i;let c=bo(i.startRow,n,i.startColumn,t,s),l=bo(i.endRow,n,i.endColumn,t,s);return r||a===V.NONE&&o===V.NONE?i={...i,startRow:c.row,startColumn:c.column,endRow:l.row,endColumn:l.column}:(a===V.NONE?i={...i,startRow:c.row,startColumn:c.column}:a===V.COLUMN?i={...i,startRow:c.row}:a===V.ROW&&(i={...i,startColumn:c.column}),o===V.NONE?i={...i,endRow:l.row,endColumn:l.column}:o===V.COLUMN?i={...i,endRow:l.row}:o===V.ROW&&(i={...i,endColumn:l.column}),i)}function bo(e,t,n,r,i){return i===B.NORMAL?{row:e+t,column:n+r}:i===B.ROW?{row:e+t,column:n}:i===B.COLUMN?{row:e,column:n+r}:{row:e,column:n}}function xo(e){let t=new Set,n=new Set;for(let r of e)t.add(r.startColumn),t.add(r.endColumn+1),n.add(r.startRow),n.add(r.endRow+1);let r=Array.from(t).sort((e,t)=>e-t),i=Array.from(n).sort((e,t)=>e-t);e.sort((e,t)=>e.startRow-t.startRow||e.startColumn-t.startColumn);let a=[];for(let t=0;t<i.length-1;t++)for(let n=0;n<r.length-1;n++){let o=r[n],s=r[n+1]-1,c=i[t],l=i[t+1]-1;for(let t of e){if(t.startRow>l)break;if(t.startRow<=c&&t.endRow>=l&&t.startColumn<=o&&t.endColumn>=s){a.push({startColumn:o,endColumn:s,startRow:c,endRow:l});break}}}return a}function So(e){e.sort((e,t)=>e.startRow-t.startRow||e.startColumn-t.startColumn);let t={};for(let n of e)t[n.startRow]||(t[n.startRow]=[]),t[n.startRow].push(n);let n=[];for(let e in t){let r=t[+e];r.sort((e,t)=>e.startColumn-t.startColumn);let i=r[0];for(let e=1;e<r.length;e++){let t=r[e];t.startColumn<=i.endColumn+1&&t.startRow===i.startRow&&t.endRow===i.endRow?i.endColumn=Math.max(i.endColumn,t.endColumn):(n.push(i),i=t)}n.push(i)}return n}function Co(e){e.sort((e,t)=>e.startColumn-t.startColumn||e.startRow-t.startRow);let t={};for(let n of e)t[n.startColumn]||(t[n.startColumn]=[]),t[n.startColumn].push(n);let n=[];for(let e in t){let r=t[+e];r.sort((e,t)=>e.startRow-t.startRow);let i=r[0];for(let e=1;e<r.length;e++){let t=r[e];t.startRow<=i.endRow+1&&t.startColumn===i.startColumn&&t.endColumn===i.endColumn?i.endRow=Math.max(i.endRow,t.endRow):(n.push(i),i=t)}n.push(i)}return n}function wo(e){return Co(So(xo(e)))}function To(e,t){let n=[];return e.forEach(e=>{n.push(...G.subtract(e,t))}),G.mergeRanges(n)}function Eo(e,t){let n=Do(e.startRow,e.endRow,t.startRow,t.endRow),r=Do(e.startColumn,e.endColumn,t.startColumn,t.endColumn);if(!n||!r)return null;let[i,a]=n,[o,s]=r;return{startRow:i,endRow:a,startColumn:o,endColumn:s,rangeType:Oo(e.rangeType,t.rangeType,i,a,o,s)}}function Do(e,t,n,r){let i=isNaN(e)?-1/0:e,a=isNaN(t)?1/0:t,o=isNaN(n)?-1/0:n,s=isNaN(r)?1/0:r,c=Math.max(i,o),l=Math.min(a,s);return c<=l?[c===-1/0?NaN:c,l===1/0?NaN:l]:null}function Oo(e,t,n,r,i,a){let o=e===void 0?ko(n,r,i,a):e,s=t===void 0?ko(n,r,i,a):t;return o===B.ALL||s===B.ALL?o===s?o:o===B.ALL?s:o:o===s?o:(o===B.NORMAL||B.NORMAL,B.NORMAL)}function ko(e,t,n,r){let i=!isNaN(e)&&!isNaN(t),a=!isNaN(n)&&!isNaN(r);return i&&a?B.NORMAL:i?B.ROW:a?B.COLUMN:B.ALL}var G=class e{static clone(e){return e.rangeType===void 0?{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn}:{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn,rangeType:e.rangeType}}static equals(e,t){return e==null||t==null?!1:e.endRow===t.endRow&&e.endColumn===t.endColumn&&e.startRow===t.startRow&&e.startColumn===t.startColumn&&(e.rangeType===t.rangeType||e.rangeType===void 0&&t.rangeType===B.NORMAL||t.rangeType===void 0&&e.rangeType===B.NORMAL)}static simpleRangesIntersect(e,t){let{startRow:n,endRow:r,startColumn:i,endColumn:a}=e,{startRow:o,endRow:s,startColumn:c,endColumn:l}=t;return n<=s&&r>=o&&i<=l&&a>=c}static intersects(e,t){if(e.rangeType===B.ROW&&t.rangeType===B.COLUMN||e.rangeType===B.COLUMN&&t.rangeType===B.ROW)return!0;if(e.rangeType===B.ROW&&t.rangeType===B.ROW)return e.startRow<=t.endRow&&e.endRow>=t.startRow;if(e.rangeType===B.COLUMN&&t.rangeType===B.COLUMN)return e.startColumn<=t.endColumn&&e.endColumn>=t.startColumn;let n=Number.isNaN(e.startRow)?0:e.startRow,r=Number.isNaN(e.endRow)?no-1:e.endRow,i=Number.isNaN(e.startColumn)?0:e.startColumn,a=Number.isNaN(e.endColumn)?ro-1:e.endColumn,o=Number.isNaN(t.startRow)?0:t.startRow,s=Number.isNaN(t.endRow)?no-1:t.endRow,c=Number.isNaN(t.startColumn)?0:t.startColumn,l=Number.isNaN(t.endColumn)?ro-1:t.endColumn,u=Math.abs(i+a-c-l),d=Math.abs(i-a)+Math.abs(c-l),f=Math.abs(n+r-o-s),p=Math.abs(n-r)+Math.abs(o-s);return u<=d&&f<=p}static doAnyRangesIntersect(e,t){let n=new Ke;return n.load(e.map(e=>({minX:e.startColumn,minY:e.startRow,maxX:e.endColumn,maxY:e.endRow}))),t.some(e=>n.search({minX:e.startColumn,minY:e.startRow,maxX:e.endColumn,maxY:e.endRow}).length>0)}static getIntersects(e,t){let n=e.startRow,r=e.endRow,i=e.startColumn,a=e.endColumn,o=t.startRow,s=t.endRow,c=t.startColumn,l=t.endColumn,u,d,f,p;if(o<=r)d=o>=n?o:n;else return null;if(s>=n)p=s>=r?r:s;else return null;if(c<=a)u=c>i?c:i;else return null;if(l>=i)f=l>=a?a:l;else return null;return{startRow:d,endRow:p,startColumn:u,endColumn:f,rangeType:B.NORMAL}}static contains(e,t){return e.startRow<=t.startRow&&e.endRow>=t.endRow&&e.startColumn<=t.startColumn&&e.endColumn>=t.endColumn}static realContain(t,n){return e.contains(t,n)&&(t.startRow<n.startRow||t.endRow>n.endRow||t.startColumn<n.startColumn||t.endColumn>n.endColumn)}static union(...e){return e.reduce((e,t)=>({startRow:Math.min(e.startRow,t.startRow),startColumn:Math.min(e.startColumn,t.startColumn),endRow:Math.max(e.endRow,t.endRow),endColumn:Math.max(e.endColumn,t.endColumn),rangeType:B.NORMAL}),e[0])}static realUnion(...t){let n=t.some(e=>e.rangeType===B.COLUMN),r=t.some(e=>e.rangeType===B.ROW),i=e.union(...t);return{startColumn:r?NaN:i.startColumn,endColumn:r?NaN:i.endColumn,startRow:n?NaN:i.startRow,endRow:n?NaN:i.endRow,rangeType:r?B.ROW:n?B.COLUMN:B.NORMAL}}static subtract(e,t){if(t.startRow>e.endRow||t.endRow<e.startRow||t.startColumn>e.endColumn||t.endColumn<e.startColumn)return[e];let n=[];t.startRow>=e.startRow&&n.push({startRow:e.startRow,startColumn:e.startColumn,endRow:t.startRow-1,endColumn:e.endColumn}),t.endRow<=e.endRow&&n.push({startRow:t.endRow+1,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn});let r=Math.max(e.startRow,t.startRow),i=Math.min(e.endRow,t.endRow);return t.startColumn>=e.startColumn&&n.push({startRow:r,startColumn:e.startColumn,endRow:i,endColumn:t.startColumn-1}),t.endColumn<=e.endColumn&&n.push({startRow:r,startColumn:t.endColumn+1,endRow:i,endColumn:e.endColumn}),n.filter(e=>e.startRow<=e.endRow&&e.startColumn<=e.endColumn)}static mergeRanges(e){return wo(e)}static splitIntoGrid(e){return xo(e)}static subtractMulti(e,t){if(!t.length)return e;let n=e;return t.forEach(e=>{n=To(n,e)}),n}static hasIntersectionBetweenTwoRect(e,t){return!(e.left>t.right||e.right<t.left||e.top>t.bottom||e.bottom<t.top)}static getIntersectionBetweenTwoRect(e,t){let n=Math.max(e.left,t.left),r=Math.min(e.right,t.right),i=Math.max(e.top,t.top),a=Math.min(e.bottom,t.bottom);return r<=n||a<=i?null:{left:n,right:r,top:i,bottom:a,width:r-n,height:a-i}}static sort(e){return e.sort((e,t)=>e.startRow-t.startRow||e.startColumn-t.startColumn)}};C(G,`getRelativeRange`,(e,t)=>({startRow:e.startRow-t.startRow,endRow:e.endRow-e.startRow,startColumn:e.startColumn-t.startColumn,endColumn:e.endColumn-e.startColumn})),C(G,`getPositionRange`,(e,t,n)=>({...n||{},startRow:n&&[V.ROW,V.ALL].includes(n.startAbsoluteRefType||0)?n.startRow:e.startRow+t.startRow,endRow:n&&[V.ROW,V.ALL].includes(n.endAbsoluteRefType||0)?n.endRow:e.endRow+e.startRow+t.startRow,startColumn:n&&[V.COLUMN,V.ALL].includes(n.startAbsoluteRefType||0)?n.startColumn:e.startColumn+t.startColumn,endColumn:n&&[V.COLUMN,V.ALL].includes(n.endAbsoluteRefType||0)?n.endColumn:e.endColumn+e.startColumn+t.startColumn})),C(G,`moveHorizontal`,(e,t=0,n=0)=>({...e,startColumn:e.startColumn+t,endColumn:e.endColumn+t+n})),C(G,`moveVertical`,(e,t=0,n=0)=>({...e,startRow:e.startRow+t,endRow:e.endRow+t+n})),C(G,`moveOffset`,(e,t,n)=>{let r={...e};switch(e.startAbsoluteRefType){case V.ROW:r.startColumn+=t;break;case V.COLUMN:r.startRow+=n;break;case V.ALL:break;case V.NONE:default:r.startRow+=n,r.startColumn+=t;break}switch(e.endAbsoluteRefType){case V.ROW:r.endColumn+=t;break;case V.COLUMN:r.endRow+=n;break;case V.ALL:break;case V.NONE:default:r.endRow+=n,r.endColumn+=t;break}return r});function Ao(e,t){if(e.length===0||e[0].length===0)return null;let n=Array(e[0].length).fill(0),r=0,i=null;for(let a=0;a<e.length;a++){for(let r=0;r<e[0].length;r++)n[r]=t(e[a][r])?n[r]+1:0;let o=jo(n);o.area>r&&(r=o.area,i={startColumn:o.start,startRow:a-o.height+1,endColumn:o.end,endRow:a})}return i}function jo(e){let t=[],n=0,r={area:0,height:0,start:0,end:0},i=0;for(;i<e.length;)if(t.length===0||e[i]>=e[t[t.length-1]])t.push(i++);else{let a=e[t.pop()],o=t.length===0?i:i-t[t.length-1]-1;a*o>n&&(n=a*o,r={area:n,height:a,start:t.length===0?0:t[t.length-1]+1,end:i-1})}for(;t.length>0;){let a=e[t.pop()],o=t.length===0?i:i-t[t.length-1]-1;a*o>n&&(n=a*o,r={area:n,height:a,start:t.length===0?0:t[t.length-1]+1,end:i-1})}return r}function Mo(e,t){vo.foreach(t,(t,n)=>{e[t][n]=void 0})}function No(e,t){let n=e.toFullArray(),r=[];for(;;){let e=Ao(n,t);if(!e)break;r.push(e),Mo(n,e)}return r}var Po=class{constructor(e,t){C(this,`_values`,[]),C(this,`_keys`,[]),C(this,`_keyMaps`,new Map),this._values=e,this._keys=t,e.forEach(e=>{this._initKeyMap(e)})}_initKeyMap(e){this._keys.forEach(t=>{let n=e[t],r=this._keyMaps.get(t)||new Map;r.set(n,e),this._keyMaps.set(t,r)})}getValue(e,t){let n=t||this._keys;for(let t=0;t<n.length;t++){let r=this._keyMaps.get(n[t]);if(r!=null&&r.has(e))return r.get(e)}return null}hasValue(e){for(let t=0;t<this._keys.length;t++){let n=this._keyMaps.get(this._keys[t]);if(n!=null&&n.has(e))return!0}return!1}addValue(e){this._values.push(e),this._initKeyMap(e)}setValue(e,t,n){let r=this.getValue(e);r&&Object.keys(r).includes(t)&&(r[t]=n)}deleteValue(e,t){let n=this.getValue(e,t);if(n){this._keys.forEach(e=>{let t=this._keyMaps.get(e),r=n[e];t==null||t.delete(r)});let e=this._values.findIndex(e=>e===n);this._values.splice(e,1)}}getValues(){return this._values}getKeyMap(e){var t;return[...((t=this._keyMaps.get(e))==null?void 0:t.keys())||[]]}clear(){this._values=[],this._keys=[],this._keyMaps.clear()}};function Fo(e,t,n,r){return{forEach(i){for(let a=e;a<=t;a++)for(let e=n;e<=r;e++)i(a,e)}}}function Io(e){if(e==null||e.length===0)return NaN;let t=e.toLowerCase().split(``),n=t.length,r=e=>e.charCodeAt(0)-96,i=0,a=0;for(let e=0;e<n;e++)a=r(t[e]),i+=a*26**(n-e-1);return i===0?NaN:i-1}function Lo(e){let t=``;for(;e>=0;)t=String.fromCharCode(e%26+65)+t,e=Math.floor(e/26)-1;return t}function Ro(e,t){let n=``;for(;t>0;)n+=e,t--;return n}function zo(e,t=!1){let n=97;return t&&(n=65),Ro(String.fromCharCode(e%26+n),Math.floor(e/26)+1)}function Bo(e,t){return e.zIndex>t.zIndex?1:e.zIndex===t.zIndex?0:-1}function Vo(e,t){return e.zIndex>t.zIndex?-1:e.zIndex===t.zIndex?0:1}function Ho(e=`index`,t=1){return(n,r)=>n[e]>r[e]?t:n[e]===r[e]?0:-t}function Uo(e,t=!1){let n=[];for(let r of e){let{st:e,ed:i,ts:a}=r;if(r.sId===void 0&&delete r.sId,e===i||!t&&D.isEmptyObject(a)&&r.sId==null)continue;if(n.length===0){n.push(r);continue}let o=n.pop();Ma(r,o)&&D.hasIntersectionBetweenTwoRanges(o.st,o.ed,r.st,r.ed)?n.push({...r,st:o.st,ed:i}):n.push(o,r)}return n}function Wo(e,t,n,r){var i;let{textRuns:a}=e;if(a==null)return;let o=[],s=a.length,c=!1,l=(i=t.textRuns)==null?[]:i;if(l.length)for(let e of l)e.st+=r,e.ed+=r;for(let e=0;e<s;e++){let t=a[e],{st:i,ed:s}=t;if(s<=r)o.push(t);else if(r>i&&r<s){c=!0;let e={...t,ed:r};o.push(e),l.length&&o.push(...l);let i={...t,st:r+n,ed:s+n};o.push(i)}else t.st+=n,t.ed+=n,c||(c=!0,o.push(...l)),o.push(t)}c||(c=!0,o.push(...l)),e.textRuns=Uo(o)}function Go(e,t,n,r){let{paragraphs:i}=e;if(i==null)return;let{paragraphs:a}=t,o=[],s=-1;for(let e=0,t=i.length;e<t;e++){let t=i[e],{startIndex:a}=t;a>=r&&(t.startIndex+=n),s===-1&&a>=r&&(s=e),o.push(t.startIndex)}let c=-1;if(a){for(let e=0,t=a.length;e<t;e++){let t=a[e];t.startIndex+=r;let n=t.startIndex;c=o.indexOf(n)}c!==-1&&i.splice(c,1),i.push(...a),i.sort(Ho(`startIndex`))}}function Ko(e,t,n,r){let{sectionBreaks:i}=e;if(i==null)return;for(let e=0,t=i.length;e<t;e++){let t=i[e],{startIndex:a}=t;a>=r&&(t.startIndex+=n)}let a=t.sectionBreaks;if(a){for(let e=0,t=a.length;e<t;e++){let t=a[e];t.startIndex+=r}i.push(...a),i.sort(Ho(`startIndex`))}}function qo(e,t,n,r){let{customBlocks:i=[]}=e;for(let e=0,t=i.length;e<t;e++){let t=i[e],{startIndex:a}=t;a>=r&&(t.startIndex+=n)}let a=t.customBlocks;if(a){for(let e=0,t=a.length;e<t;e++){let t=a[e];t.startIndex+=r}i.push(...a),i.sort(Ho(`startIndex`))}i.length&&!e.customBlocks&&(e.customBlocks=i)}function Jo(e,t,n,r){let{tables:i}=e;if(i==null)return;for(let e=0,t=i.length;e<t;e++){let t=i[e],{startIndex:a,endIndex:o}=t;a>r?(t.startIndex+=n,t.endIndex+=n):o>r&&(t.endIndex+=n)}let a=t.tables;if(a){for(let e=0,t=a.length;e<t;e++){let t=a[e];t.startIndex+=r,t.endIndex+=r}i.push(...a),i.sort(Ho(`startIndex`))}}const Yo=e=>e.split(`$`)[0];function Xo(e){if(e.length<=1)return e;e.sort((e,t)=>e.startIndex-t.startIndex);let t=[],n={...e[0]};n.rangeId=Yo(n.rangeId);for(let r=1;r<e.length;r++){let i=e[r];i.rangeId=Yo(i.rangeId),i.rangeId===n.rangeId&&Ct(n.properties,i.properties)&&n.endIndex+1>=i.startIndex?n.endIndex=i.endIndex:(t.push(n),n={...i})}t.push(n);let r=Object.create(null);for(let e=0,n=t.length;e<n;e++){let n=t[e],i=n.rangeId;r[i]?(n.rangeId=`${i}\$${r[i]}`,r[i]=r[i]+1):r[i]=1}return t}function Zo(e,t){let n=e.findIndex(e=>e.startIndex<t&&e.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 Qo(e){if(e.length<=1)return e;e.sort((e,t)=>e.startIndex-t.startIndex);let t=[],n={...e[0]};for(let r=1;r<e.length;r++){let i=e[r];i.id===n.id&&n.endIndex+1>=i.startIndex?n.endIndex=i.endIndex:(t.push(n),n={...i})}return t.push(n),t}function $o(e,t){e.filter(e=>e.startIndex<t&&e.endIndex>=t).forEach(n=>{let r=e.indexOf(n);e.splice(r,1,{id:n.id,type:n.type,startIndex:n.startIndex,endIndex:t-1},{id:n.id,type:n.type,startIndex:t,endIndex:n.endIndex})})}function es(e,t,n,r){e.customRanges||(e.customRanges=[]);let{customRanges:i}=e;Zo(i,r);for(let e=0,t=i.length;e<t;e++){let t=i[e],{startIndex:a}=t;a>=r&&(t.startIndex+=n,t.endIndex+=n)}let a=[];if(t.customRanges){for(let e=0,n=t.customRanges.length;e<n;e++){let n=t.customRanges[e];n.startIndex+=r,n.endIndex+=r,a.push(n)}i.push(...a)}e.customRanges=Xo(i)}function ts(e,t,n,r){e.customDecorations||(e.customDecorations=[]);let{customDecorations:i}=e;$o(i,r);for(let e=0,t=i.length;e<t;e++){let t=i[e],{startIndex:a}=t;a>=r&&(t.startIndex+=n,t.endIndex+=n)}let a=[];if(t.customDecorations){for(let e=0,n=t.customDecorations.length;e<n;e++){let n=t.customDecorations[e];n.startIndex+=r,n.endIndex+=r,a.push(n)}i.push(...a)}e.customDecorations=Qo(i)}function ns(e,t,n){let{textRuns:r}=e,i=n,a=n+t,o=[];if(r){let n=[];for(let e=0,s=r.length;e<s;e++){let s=r[e],{st:c,ed:l}=s;if(i<=c&&a>=l){o.push({...s,st:c-i,ed:l-i});continue}else c<=i&&l>=a?(o.push({...s,st:i-i,ed:a-i}),s.ed-=t):i>=c&&i<l?(o.push({...s,st:i-i,ed:l-i}),s.ed=i):a>c&&a<=l?(o.push({...s,st:c-i,ed:a-i}),s.st=a-t,s.ed-=t):c>=a&&(s.st-=t,s.ed-=t);n.push(s)}e.textRuns=n}return o.length===0&&o.push({st:0,ed:t,ts:{}}),o}function rs(e,t,n){let{paragraphs:r}=e,i=n,a=n+t,o=[],s=null,c=!1;if(r){let l=[];for(let e=0,u=r.length;e<u;e++){let u=r[e],{startIndex:d}=u;if(d>=i&&d<a){o.push({...u,startIndex:d-n}),c=!0;continue}else d>=a&&(u.startIndex-=t);l.push(u),s==null&&c&&(s=u)}e.paragraphs=l}return o}function is(e,t,n){let{sectionBreaks:r}=e,i=n,a=n+t-1,o=[];if(r){let s=[];for(let e=0,c=r.length;e<c;e++){let c=r[e],{startIndex:l}=c;if(l>=i&&l<=a){o.push({...c,startIndex:l-n});continue}else l>a&&(c.startIndex-=t);s.push(c)}e.sectionBreaks=s}return o}function as(e,t,n){let{customBlocks:r=[]}=e,i=n,a=n+t-1,o=[];if(r){let s=[];for(let e=0,c=r.length;e<c;e++){let c=r[e],{startIndex:l}=c;if(l>=i&&l<=a){o.push({...c,startIndex:l-n});continue}else l>a&&(c.startIndex-=t);s.push(c)}e.customBlocks=s}return r.length&&!e.customBlocks&&(e.customBlocks=r),o}function os(e,t,n){let{tables:r}=e,i=n,a=n+t-1,o=[];if(r){let s=[];for(let e=0,c=r.length;e<c;e++){let c=r[e],{startIndex:l,endIndex:u}=c;if(i<=l&&a>=u){o.push({...c,startIndex:l-n,endIndex:u-n});continue}else if(l<=i&&u>=a){let e=Pa(l,u,i,a);if(e.length===0||(c.startIndex=e[0],c.endIndex=e[1],c.startIndex===c.endIndex))continue}else a<l&&(c.startIndex-=t,c.endIndex-=t);s.push(c)}e.tables=s}return o}function ss(e,t,n){let{customRanges:r}=e,i=n,a=n+t-1,o=[];if(r){let n=[];for(let e=0,s=r.length;e<s;e++){let s=r[e],{startIndex:c,endIndex:l}=s;if(c>=i&&l<=a){o.push(s);continue}else if(Math.max(i,c)<=Math.min(a,l)){let e=Pa(c,l,i,a);if(e.length===0)continue;s.startIndex=e[0],s.endIndex=e[1]}else a<c&&(s.startIndex-=t,s.endIndex-=t);n.push(s)}e.customRanges=Xo(n)}return o}function cs(e,t,n,r=!0){let{customDecorations:i}=e,a=n,o=n+t-1,s=[];if(i){let n=[];for(let e=0,c=i.length;e<c;e++){let c=i[e],{startIndex:l,endIndex:u}=c;if(l>=a&&u<=o){s.push(c);continue}else if(Math.max(a,l)<=Math.min(o,u)){let e=Pa(l,u,a,o);if(e.length===0)continue;c.startIndex=e[0],c.endIndex=e[1]}else o<l&&r&&(c.startIndex-=t,c.endIndex-=t);n.push(c)}e.customDecorations=n}return s}let K=function(e){return e.ORDER_LIST_QUICK_1=`1.`,e.ORDER_LIST_QUICK_2=`a)`,e.ORDER_LIST_QUICK_3=`a.`,e.ORDER_LIST_QUICK_4=`i.`,e.ORDER_LIST_QUICK_5=`A.`,e.ORDER_LIST_QUICK_6=`I.`,e.ORDER_LIST_QUICK_7=`01.`,e.BULLET_LIST=`*`,e}({}),q=function(e){return 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}({});const ls={"a)":{glyphFormat:`%1)`,glyphType:M.DECIMAL},"1.":{glyphFormat:`%1.`,glyphType:M.DECIMAL},"a.":{glyphFormat:`%1.`,glyphType:M.LOWER_LETTER},"A.":{glyphFormat:`%1.`,glyphType:M.UPPER_LETTER},"i.":{glyphFormat:`%1.`,glyphType:M.LOWER_ROMAN},"I.":{glyphFormat:`%1.`,glyphType:M.UPPER_LETTER}},us=e=>[...e,...e,...e].map((e,t)=>({glyphFormat:` %${t+1}`,glyphSymbol:e,bulletAlignment:ar.START,textStyle:{fs:12},startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*t}}})),ds=e=>e.map((e,t)=>({...e,bulletAlignment:ar.START,textStyle:{fs:12},startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*t}}})),fs=(e,t)=>Array(9).fill(0).map((n,r)=>({glyphFormat:` %${r+1}`,glyphSymbol:e,bulletAlignment:ar.START,textStyle:{fs:16},startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*r},textStyle:t}})),ps={[q.BULLET_LIST]:{listType:q.BULLET_LIST,nestingLevel:us([`●`,`○`,`■`])},[q.BULLET_LIST_1]:{listType:q.BULLET_LIST,nestingLevel:us([`❖`,`➢`,`■`])},[q.BULLET_LIST_2]:{listType:q.BULLET_LIST,nestingLevel:us([`✔`,`●`,`◆`])},[q.BULLET_LIST_3]:{listType:q.BULLET_LIST,nestingLevel:us([`■`,`◆`,`○`])},[q.BULLET_LIST_4]:{listType:q.BULLET_LIST,nestingLevel:us([`✧`,`○`,`■`])},[q.BULLET_LIST_5]:{listType:q.BULLET_LIST,nestingLevel:us([`➢`,`○`,`◆`])},[q.ORDER_LIST]:{listType:q.ORDER_LIST,nestingLevel:ds([{glyphFormat:`%1.`,glyphType:M.DECIMAL},{glyphFormat:`%2.`,glyphType:M.LOWER_LETTER},{glyphFormat:`%3.`,glyphType:M.LOWER_ROMAN},{glyphFormat:`%4.`,glyphType:M.DECIMAL},{glyphFormat:`%5.`,glyphType:M.LOWER_LETTER},{glyphFormat:`%6.`,glyphType:M.LOWER_ROMAN},{glyphFormat:`%7.`,glyphType:M.DECIMAL},{glyphFormat:`%8.`,glyphType:M.LOWER_LETTER},{glyphFormat:`%9.`,glyphType:M.LOWER_ROMAN}])},[q.ORDER_LIST_1]:{listType:q.ORDER_LIST,nestingLevel:ds([{glyphFormat:`%1)`,glyphType:M.DECIMAL},{glyphFormat:`%2)`,glyphType:M.LOWER_LETTER},{glyphFormat:`%3)`,glyphType:M.LOWER_ROMAN},{glyphFormat:`%4)`,glyphType:M.DECIMAL},{glyphFormat:`%5)`,glyphType:M.LOWER_LETTER},{glyphFormat:`%6)`,glyphType:M.LOWER_ROMAN},{glyphFormat:`%7)`,glyphType:M.DECIMAL},{glyphFormat:`%8)`,glyphType:M.LOWER_LETTER},{glyphFormat:`%9)`,glyphType:M.LOWER_ROMAN}])},[q.ORDER_LIST_2]:{listType:q.ORDER_LIST,nestingLevel:ds([`%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:M.DECIMAL})))},[q.ORDER_LIST_3]:{listType:q.ORDER_LIST,nestingLevel:ds([{glyphFormat:`%1.`,glyphType:M.UPPER_LETTER},{glyphFormat:`%2.`,glyphType:M.LOWER_LETTER},{glyphFormat:`%3.`,glyphType:M.LOWER_ROMAN},{glyphFormat:`%4.`,glyphType:M.UPPER_LETTER},{glyphFormat:`%5.`,glyphType:M.LOWER_LETTER},{glyphFormat:`%6.`,glyphType:M.LOWER_ROMAN},{glyphFormat:`%7.`,glyphType:M.UPPER_LETTER},{glyphFormat:`%8.`,glyphType:M.LOWER_LETTER},{glyphFormat:`%9.`,glyphType:M.LOWER_ROMAN}])},[q.ORDER_LIST_4]:{listType:q.ORDER_LIST,nestingLevel:ds([{glyphFormat:`%1.`,glyphType:M.UPPER_LETTER},{glyphFormat:`%2.`,glyphType:M.DECIMAL},{glyphFormat:`%3.`,glyphType:M.LOWER_ROMAN},{glyphFormat:`%4.`,glyphType:M.UPPER_LETTER},{glyphFormat:`%5.`,glyphType:M.DECIMAL},{glyphFormat:`%6.`,glyphType:M.LOWER_ROMAN},{glyphFormat:`%7.`,glyphType:M.UPPER_LETTER},{glyphFormat:`%8.`,glyphType:M.DECIMAL},{glyphFormat:`%9.`,glyphType:M.LOWER_ROMAN}])},[q.ORDER_LIST_5]:{listType:q.ORDER_LIST,nestingLevel:ds([{glyphFormat:`%1.`,glyphType:M.DECIMAL_ZERO},{glyphFormat:`%2.`,glyphType:M.LOWER_LETTER},{glyphFormat:`%3.`,glyphType:M.LOWER_ROMAN},{glyphFormat:`%4.`,glyphType:M.DECIMAL_ZERO},{glyphFormat:`%5.`,glyphType:M.LOWER_LETTER},{glyphFormat:`%6.`,glyphType:M.LOWER_ROMAN},{glyphFormat:`%7.`,glyphType:M.DECIMAL_ZERO},{glyphFormat:`%8.`,glyphType:M.LOWER_LETTER},{glyphFormat:`%9.`,glyphType:M.LOWER_ROMAN}])},[q.CHECK_LIST]:{listType:q.CHECK_LIST,nestingLevel:fs(`☐`)},[q.CHECK_LIST_CHECKED]:{listType:q.CHECK_LIST_CHECKED,nestingLevel:fs(`☑`,{st:{s:A.TRUE}})}},ms=e=>{let{glyphFormat:t,glyphType:n}=e,r=D.deepClone(ps[q.ORDER_LIST]);return r.nestingLevel[0].glyphFormat=t,r.nestingLevel[0].glyphType=n,r},hs={[q.ORDER_LIST_QUICK_2]:ms(ls[K.ORDER_LIST_QUICK_2]),[q.ORDER_LIST_QUICK_3]:ms(ls[K.ORDER_LIST_QUICK_3]),[q.ORDER_LIST_QUICK_4]:ms(ls[K.ORDER_LIST_QUICK_4]),[q.ORDER_LIST_QUICK_6]:ms(ls[K.ORDER_LIST_QUICK_6])};Object.assign(ps,hs);const gs={[K.ORDER_LIST_QUICK_1]:q.ORDER_LIST,[K.ORDER_LIST_QUICK_2]:q.ORDER_LIST_QUICK_2,[K.ORDER_LIST_QUICK_3]:q.ORDER_LIST_QUICK_3,[K.ORDER_LIST_QUICK_4]:q.ORDER_LIST_QUICK_4,[K.ORDER_LIST_QUICK_5]:q.ORDER_LIST_3,[K.ORDER_LIST_QUICK_6]:q.ORDER_LIST_QUICK_6,[K.ORDER_LIST_QUICK_7]:q.ORDER_LIST_5,[K.BULLET_LIST]:q.BULLET_LIST};function _s(e,t,n,r,i){return{dataStream:``,textRuns:vs(e,t,n,r,i),paragraphs:bs(e,t,n,r,i),sectionBreaks:xs(e,t,n,r,i),customBlocks:Ss(e,t,n,r,i),tables:Cs(e,t,n,r,i),customRanges:ws(e,t,n,r,i),customDecorations:Ts(e,t,n,r,i)}}function vs(e,t,n,r,i){let{textRuns:a}=e,{textRuns:o}=t;if(a==null||o==null)return;let s=ns(e,n,r);return i!==F.REPLACE&&(t.textRuns=ys(o,s,i)),Wo(e,t,n,r),s}function ys(e,t,n){if(t.length===0)return e;e=D.deepClone(e),t=D.deepClone(t);let r=[],i=e.length,a=t.length,o=0,s=0,c=null;function l(){return c?(r.push(c),c=null,!0):!1}for(;o<i&&s<a;){let{st:i,ed:a,ts:u}=e[o],{st:d,ed:f,ts:p,sId:m}=t[s],h;if(h=n===F.COVER?{...p,...u}:{...u},a<d)l()||r.push(e[o]),o++;else if(f<i)l()||r.push(t[s]),s++;else{let n={st:Math.min(i,d),ed:Math.max(i,d),ts:i<d?{...u}:{...p},sId:i<d?void 0:m};n.ed>n.st&&r.push(n),r.push({st:Math.max(i,d),ed:Math.min(a,f),ts:h,sId:m}),a<f?(o++,t[s].st=a,t[s].st===t[s].ed&&s++):(s++,e[o].st=f,e[o].st===e[o].ed&&o++);let l={st:Math.min(a,f),ed:Math.max(a,f),ts:a<f?{...p}:{...u},sId:a<f?m:void 0};c=l.ed>l.st?l:null}}l();let u=r[r.length-1],d=e[i-1],f=t[a-1];return u&&u.ed!==Math.max(d.ed,f.ed)&&(d.ed>f.ed?r.push(d):r.push(f)),Uo(r)}function bs(e,t,n,r,i){let{paragraphs:a}=e,{paragraphs:o}=t;if(a==null||o==null)return;let s=rs(e,n,r);if(i!==F.REPLACE){let e=[];for(let t of o){let{startIndex:n,paragraphStyle:r,bullet:a}=t,o=[];for(let e of s){let{startIndex:t,paragraphStyle:s,bullet:c}=e,l,u;if(i===F.COVER?(l={...s,...r},u={listId:``,listType:q.BULLET_LIST,nestingLevel:0,textStyle:{},...c,...a}):(l={...r,...s},u={listId:``,listType:q.BULLET_LIST,nestingLevel:0,textStyle:{},...a,...c}),n===t){o.push({startIndex:n,paragraphStyle:l,bullet:u});break}}e.push(...o),o=[]}t.paragraphs=e}return Go(e,t,n,r),s}function xs(e,t,n,r,i){let{sectionBreaks:a}=e,{sectionBreaks:o}=t;if(a==null||o==null)return;let s=is(e,n,r);if(i!==F.REPLACE){let e=[];for(let t of o){let{startIndex:n}=t,r=[];for(let e of s){let{startIndex:a}=e;if(n===a){i===F.COVER?r.push({...e,...t}):r.push({...t,...e});break}}e.push(...r),r=[]}t.sectionBreaks=e}return Ko(e,t,n,r),s}function Ss(e,t,n,r,i){let{customBlocks:a=[]}=e,{customBlocks:o}=t;if(a==null||o==null)return;let s=as(e,n,r);if(i!==F.REPLACE){let e=[];for(let t of o){let{startIndex:n}=t,r=[];for(let e of s){let{startIndex:a}=e;if(n===a){i===F.COVER?r.push({...e,...t}):r.push({...t,...e});break}}e.push(...r),r=[]}t.customBlocks=e}return qo(e,t,n,r),a.length&&!e.customBlocks&&(e.customBlocks=a),s}function Cs(e,t,n,r,i){let{tables:a}=e,{tables:o}=t;if(a==null||o==null)return;let s=os(e,n,r);if(i!==F.REPLACE){let e=[];for(let t of o){let{startIndex:n,endIndex:r}=t,a=[];for(let e of s){let{startIndex:o,endIndex:s}=e;if(o>=n&&s<=r){i===F.COVER?a.push({...e,...t}):a.push({...t,...e});break}}e.push(...a),a=[]}t.tables=e}return Jo(e,t,n,r),s}function ws(e,t,n,r,i){e.customRanges||(e.customRanges=[]),Zo(e.customRanges,r),Zo(e.customRanges,r+n);let a=r,o=r+n-1,{customRanges:s}=t,c=[],l=new Map;return e.customRanges.forEach(e=>{let{startIndex:t,endIndex:n}=e;t>=a&&n<=o?l.set(e.rangeId,e):c.push(e)}),s?(s.forEach(e=>{let{startIndex:t,endIndex:n}=e;c.push({...e,startIndex:t+r,endIndex:n+r})}),e.customRanges=Xo(c),[]):[]}function Ts(e,t,n,r,i){e.customDecorations||(e.customDecorations=[]),$o(e.customDecorations,r),$o(e.customDecorations,r+n);let a=[],{customDecorations:o}=e,{customDecorations:s=[]}=t;if(i===F.REPLACE){for(let e=0;e<o.length;e++){let t=o[e],{startIndex:i,endIndex:s}=t;i>=r&&s<=r+n-1&&a.push(t)}s.forEach(e=>{let{startIndex:t,endIndex:n}=e;o.push({...e,startIndex:t+r,endIndex:n+r})})}else for(let e of s){let{id:t}=e;if(e.type===sr.DELETED){let e=o.filter(e=>e.id===t);e.length&&a.push(...e)}else o.push({...e,startIndex:e.startIndex+r,endIndex:e.endIndex+r})}for(let e of a){let{id:t}=e,n=o.findIndex(e=>e.id===t);n!==-1&&o.splice(n,1)}return e.customDecorations=Qo(o),a}let Es=function(e){return e[e.copy=0]=`copy`,e[e.cut=1]=`cut`,e}({});function Ds(e,t,n,r=!0){let{textRuns:i}=e;if(i){let e=[];for(let r of i){let i=D.deepClone(r),{st:a,ed:o}=i;D.hasIntersectionBetweenTwoRanges(a,o,t,n)&&(t>=a&&t<=o?e.push({...i,st:t,ed:Math.min(n,o)}):n>=a&&n<=o?e.push({...i,st:Math.max(t,a),ed:n}):e.push(i))}return Uo(e.map(e=>{let{st:n,ed:r}=e;return{...e,st:n-t,ed:r-t}}))}else if(r)return[{st:0,ed:n-t,ts:{}}]}function Os(e,t,n){let{tables:r=[]}=e,i=[];for(let e of r){let r=D.deepClone(e),{startIndex:a,endIndex:o}=r;a>=t&&o<=n&&i.push({...r,startIndex:a-t,endIndex:o-t})}return i}function ks(e,t,n){let{paragraphs:r=[]}=e,i=[];for(let e of r){let{startIndex:r}=e;if(r>=t&&r<n){let t=D.deepClone(e);i.push(t)}}if(i.length)return i.map(e=>({...e,startIndex:e.startIndex-t}))}function As(e,t,n){let{sectionBreaks:r=[]}=e,i=[];for(let e of r){let{startIndex:r}=e;r>=t&&r<=n&&i.push(D.deepClone(e))}if(i.length)return i.map(e=>({...e,startIndex:e.startIndex-t}))}function js(e,t,n){let{customBlocks:r=[]}=e,i=[];for(let e of r){let{startIndex:r}=e;r>=t&&r<n&&i.push(D.deepClone(e))}if(i.length)return i.map(e=>({...e,startIndex:e.startIndex-t}))}function Ms(e,t,n,r=!0,i=Es.cut){let{dataStream:a}=e,o={dataStream:a.slice(t,n)};o.textRuns=Ds(e,t,n,r);let s=Os(e,t,n);if(s.length&&(o.tables=s),o.paragraphs=ks(e,t,n),i===Es.cut){let i=Fs(e,t,n);i?o.customDecorations=i:r&&(o.customDecorations=[])}let{customRanges:c}=Ps(e,t,n);return c?o.customRanges=c:r&&(o.customRanges=[]),o.customBlocks=js(e,t,n),o}function Ns(e){let{dataStream:t,textRuns:n,paragraphs:r,customRanges:i,customDecorations:a,tables:o}=e,s=0,c=0;i==null||i.forEach(e=>{e.startIndex<0&&(s=Math.max(s,-e.startIndex)),e.endIndex>t.length-1&&(c=Math.max(c,e.endIndex-t.length+1))});let l=`${t}`;return n&&(n[0]&&(n[0].st=n[0].st-s),n[n.length-1]&&(n[n.length-1].ed=n[n.length-1].ed+c)),n==null||n.forEach(e=>{e.st+=s,e.ed+=s}),r==null||r.forEach(e=>{e.startIndex+=s}),i==null||i.forEach(e=>{e.startIndex+=s,e.endIndex+=s}),a==null||a.forEach(e=>{e.startIndex+=s,e.endIndex+=c}),o==null||o.forEach(e=>{e.startIndex+=s,e.endIndex+=c}),{...e,dataStream:l,textRuns:n,paragraphs:r,customRanges:i,customDecorations:a,tables:o}}function Ps(e,t,n){if(e.customRanges==null)return{};let{customRanges:r}=e;return{customRanges:r.filter(e=>Math.max(e.startIndex,t)<=Math.min(e.endIndex,n-1)).map(e=>({...e,startIndex:Math.max(e.startIndex,t),endIndex:Math.min(e.endIndex,n-1)})).map(e=>({...e,startIndex:e.startIndex-t,endIndex:e.endIndex-t})),leftOffset:0,rightOffset:0}}function Fs(e,t,n){if(e.customDecorations==null)return;let{customDecorations:r=[]}=e,i=[];return r.forEach(e=>{if(Math.max(e.startIndex,t)<=Math.min(e.endIndex,n-1)){let r=D.deepClone(e);i.push({...r,startIndex:Math.max(r.startIndex-t,0),endIndex:Math.min(r.endIndex,n-1)-t})}}),i}function Is(e,t,n){return e==null||t==null?e==null?t:e:ys(e,t,n)}function Ls(e,t,n){if(e==null||t==null)return e==null?t:e;if(t.length===0||e.length===0)return e;if(t.length>1||e.length>1)throw Error(`Cannot cover multiple customRanges`);return n===F.REPLACE?[{...e[0]}]:[{...t[0],...e[0]}]}function Rs(e,t,n){return t.length===0||e.length===0||n===F.REPLACE?e:[...e,...t.filter(t=>!e.some(e=>t.id===e.id))]}function zs(e,t,n=F.COVER){if(t.dataStream!==``)throw Error(`Cannot compose other body with non-empty dataStream`);let r={dataStream:e.dataStream},{textRuns:i,paragraphs:a=[],customRanges:o,customDecorations:s=[]}=e,{textRuns:c,paragraphs:l=[],customRanges:u,customDecorations:d=[]}=t;r.textRuns=Is(c,i,n),r.customRanges=Ls(u,o,n);let f=Rs(d,s,n);f.length&&(r.customDecorations=f);let p=[],m=0,h=0;for(;m<a.length&&h<l.length;){let e=a[m],t=l[h],{startIndex:n}=e,{startIndex:r}=t;n===r?(p.push(D.deepMerge(e,t)),m++,h++):n<r?(p.push(D.deepClone(e)),m++):(p.push(D.deepClone(t)),h++)}return m<a.length&&p.push(...a.slice(m)),h<l.length&&p.push(...l.slice(h)),p.length&&(r.paragraphs=p),r}function Bs(e){let{body:t}=e;if(t==null)return!0;let{textRuns:n,paragraphs:r,customRanges:i,customBlocks:a,customDecorations:o,tables:s}=t;return n==null&&r==null&&i==null&&a==null&&o==null&&s==null}var Vs=class{constructor(e){this._actions=e,C(this,`_index`,0),C(this,`_offset`,0)}hasNext(){return this.peekLength()<1/0}next(e){e||(e=1/0);let t=this._actions[this._index];if(t){let n=this._offset,r=t.len;return e>=r-n?(e=r-n,this._index+=1,this._offset=0):this._offset+=e,t.t===I.DELETE||t.t===I.RETAIN&&t.body==null?D.deepClone({...t,len:e}):D.deepClone({...t,len:e,body:Ms(t.body,n,n+e,!1)})}else return{t:I.RETAIN,len:1/0}}peek(){return this._actions[this._index]}peekLength(){return this._actions[this._index]?this._actions[this._index].len-this._offset:1/0}peekType(){let e=this._actions[this._index];return e?e.t:I.RETAIN}rest(){if(!this.hasNext())return[];if(this._offset===0)return this._actions.slice(this._index);{let e=this._offset,t=this._index,n=this.next(),r=this._actions.slice(this._index);return this._offset=e,this._index=t,[n].concat(r)}}};function Hs(e,t,n){let{dataStream:r}=e,i=n,a=n+t,o=ns(e,t,n),s=rs(e,t,n),c=is(e,t,n),l=as(e,t,n),u=os(e,t,n),d=ss(e,t,n),f=cs(e,t,n),p=``;return r&&(e.dataStream=za(r,i,a),p=r.slice(i,a)),{dataStream:p,textRuns:o,paragraphs:s,sectionBreaks:c,customBlocks:l,tables:u,customRanges:d,customDecorations:f}}function Us(e,t,n,r){e.dataStream=Ra(e.dataStream,r,t.dataStream),Wo(e,t,n,r),Go(e,t,n,r),Ko(e,t,n,r),qo(e,t,n,r),Jo(e,t,n,r),es(e,t,n,r),ts(e,t,n,r)}function Ws(e,t,n,r,i=F.COVER){return _s(e,t,n,r,i)}function Gs(e,t,n){return t<=0?{dataStream:``}:Hs(e,t,n)}function Ks(e,t,n,r){n!==0&&Us(e,t,n,r)}function qs(e,t){let n=new Zt;return n.reset(),t.forEach(t=>{let r=D.deepClone(t);switch(r.t){case I.RETAIN:{let{coverType:t,body:i,len:a}=r;i!=null&&Ws(e,i,a,n.cursor,t),n.moveCursor(a);break}case I.INSERT:{let{body:t,len:i}=r;Ks(e,t,i,n.cursor),n.moveCursor(i);break}case I.DELETE:{let{len:t}=r;Gs(e,t,n.cursor);break}default:throw Error(`Unknown action type for action: ${r}.`)}}),e}var J=function(e){return e[e.COVER=0]=`COVER`,e[e.COVER_ONLY_NOT_EXISTED=1]=`COVER_ONLY_NOT_EXISTED`,e}(J||{});function Js(e,t,n,r,i){if(e==null||t==null)return t;if(e.length===0||t.length===0)return[];t=D.deepClone(t),e=D.deepClone(e);let a=[],o=t.length,s=e.length,c=0,l=0,u=null;function d(){return u?(a.push(u),u=null,!0):!1}for(;c<o&&l<s;){let{st:o,ed:s,ts:f}=t[c],{st:p,ed:m,ts:h,sId:g}=e[l],_={};if(i===J.COVER)_={...f},n===F.COVER&&r===F.REPLACE&&h&&(_=Object.assign({},h,_));else if(_={...f},n===F.REPLACE){if(r===F.REPLACE)_={...h};else if(f&&h){let e=Object.keys(f);for(let t of e)h[t]&&delete _[t]}}else if(r===F.REPLACE){if(h){let e=Object.keys(h);for(let t of e)h[t]!==void 0&&(_[t]=h[t])}}else if(h){let e=Object.keys(h);for(let t of e)_[t]!==void 0&&delete _[t]}if(s<p)d()||a.push(t[c]),c++;else if(m<o)d()||a.push(e[l]),l++;else{let n={st:Math.min(o,p),ed:Math.max(o,p),ts:o<p?{...f}:{...h},sId:o<p?void 0:g};n.ed>n.st&&a.push(),a.push({st:Math.max(o,p),ed:Math.min(s,m),ts:_,sId:g}),s<m?(c++,e[l].st=s,e[l].st===e[l].ed&&l++):(l++,t[c].st=m,t[c].st===t[c].ed&&c++);let r={st:Math.min(s,m),ed:Math.max(s,m),ts:s<m?{...h}:{...f},sId:s<m?g:void 0};u=r.ed>r.st?r:null}}d();let f=a[a.length-1],p=t[o-1],m=e[s-1];return f.ed!==Math.max(p.ed,m.ed)&&(p.ed>m.ed?a.push(p):a.push(m)),Uo(a,!0)}function Ys(e,t,n,r,i){if(e==null||t==null)return t;if(e.length===0||t.length===0)return[];if(e.length>1||t.length>1)throw Error(`CustomRanges is only supported transform for length one now.`);let a=e[0],o=t[0];if(n===F.REPLACE)return i===J.COVER_ONLY_NOT_EXISTED?[D.deepClone(a)]:[D.deepClone(o)];if(r===F.REPLACE){let e=D.deepClone(o);return i===J.COVER_ONLY_NOT_EXISTED&&Object.assign(e,D.deepClone(a)),[e]}else{let e=D.deepClone(o);return i===J.COVER_ONLY_NOT_EXISTED&&Object.assign(e,D.deepClone(a)),[e]}}function Xs(e,t,n,r,i){let a={startIndex:t.startIndex};if(t.paragraphStyle&&(a.paragraphStyle=D.deepClone(t.paragraphStyle),e.paragraphStyle)){if(n===F.REPLACE)if(r===F.REPLACE)i===J.COVER_ONLY_NOT_EXISTED&&(a.paragraphStyle={...e.paragraphStyle});else if(i===J.COVER_ONLY_NOT_EXISTED){let t=Object.keys(e.paragraphStyle);for(let n of t)e.paragraphStyle[n]!==void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}else{let t=Object.keys(e.paragraphStyle);for(let n of t)a.paragraphStyle[n]===void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}else if(r===F.REPLACE)if(i===J.COVER_ONLY_NOT_EXISTED){let t=Object.keys(e.paragraphStyle);for(let n of t)e.paragraphStyle[n]!==void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}else{let t=Object.keys(e.paragraphStyle);for(let n of t)a.paragraphStyle[n]===void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}else if(i===J.COVER_ONLY_NOT_EXISTED){let t=Object.keys(e.paragraphStyle);for(let e of t)a.paragraphStyle[e]&&delete a.paragraphStyle[e]}}return n===F.REPLACE&&r===F.REPLACE?a.bullet=i===J.COVER_ONLY_NOT_EXISTED?D.deepClone(e.bullet):D.deepClone(t.bullet):e.bullet===void 0?a.bullet=D.deepClone(t.bullet):n===F.REPLACE||r===F.REPLACE?a.bullet=i===J.COVER&&t.bullet?D.deepClone(t.bullet):D.deepClone(e.bullet):i===J.COVER&&t.bullet!==void 0&&(a.bullet=D.deepClone(t.bullet)),a}function Zs(e,t){if(e==null||t==null)return t;if(e.length===0||t.length===0)return D.deepClone(t);let n=[];for(let r of t){let{id:t,type:i}=r,a=!1;for(let o of e)if(o.id===t){(o.type===sr.DELETED||i===sr.DELETED)&&(a=!0,n.push({...r,type:sr.DELETED}));break}a||n.push(r)}return n}function Qs(e,t,n=!1){let{body:r,coverType:i=F.COVER}=e,{body:a,coverType:o=F.COVER}=t;if(r==null||r.dataStream!==``||a==null||a.dataStream!==``)throw Error(`Data stream is not supported in retain transform.`);let s={dataStream:``},c=o,{textRuns:l,paragraphs:u=[],customRanges:d,customDecorations:f}=r,{textRuns:p,paragraphs:m=[],customRanges:h,customDecorations:g}=a,_=Js(l,p,i,o,n?J.COVER_ONLY_NOT_EXISTED:J.COVER);_&&(s.textRuns=_);let ee=Ys(d,h,i,o,n?J.COVER_ONLY_NOT_EXISTED:J.COVER);ee&&(s.customRanges=ee);let te=Zs(f,g);te&&(s.customDecorations=te);let ne=[],re=0,ie=0;for(;re<u.length&&ie<m.length;){let e=u[re],t=m[ie],{startIndex:r}=e,{startIndex:a}=t;if(r===a){let a={startIndex:r};a=n?Xs(e,t,i,o,J.COVER_ONLY_NOT_EXISTED):Xs(e,t,i,o,J.COVER),ne.push(a),re++,ie++}else r<a?re++:(ne.push(D.deepClone(t)),ie++)}return ie<m.length&&ne.push(...m.slice(ie)),ne.length&&(s.paragraphs=ne),{coverType:c,body:s}}function $s(e){return Object.keys(e).length===1}var Y=class e{constructor(){C(this,`_actions`,[])}static apply(e,t){return qs(e,t)}static compose(t,n){let r=new Vs(t),i=new Vs(n),a=new e;for(;r.hasNext()||i.hasNext();)if(i.peekType()===I.INSERT)a.push(i.next());else if(r.peekType()===I.DELETE)a.push(r.next());else{let e=Math.min(r.peekLength(),i.peekLength()),t=r.next(e),n=i.next(e);if(t.t===I.INSERT&&n.t===I.RETAIN)n.body==null?a.push(t):a.push({...t,body:zs(t.body,n.body,n.coverType)});else if(t.t===I.RETAIN&&n.t===I.RETAIN)if(t.body==null&&n.body==null)a.push(t.len===1/0?n:t);else if(t.body&&n.body){let e=t.coverType===F.REPLACE||n.coverType===F.REPLACE?F.REPLACE:F.COVER;a.push({...t,t:I.RETAIN,coverType:e,body:zs(t.body,n.body,n.coverType)})}else a.push(t.body?t:n);else t.t===I.RETAIN&&n.t===I.DELETE?a.push(n):t.t===I.INSERT&&(n.t,I.DELETE)}return a.trimEndUselessRetainAction(),a.serialize()}static transform(e,t,n=`right`){return this._transform(t,e,n===`left`?`right`:`left`)}static _transform(t,n,r=`right`){let i=new Vs(t),a=new Vs(n),o=new e;for(;i.hasNext()||a.hasNext();)if(i.peekType()===I.INSERT&&(r===`left`||a.peekType()!==I.INSERT)){let e=i.next();o.retain(e.len)}else if(a.peekType()===I.INSERT)o.push(a.next());else{let e=Math.min(i.peekLength(),a.peekLength()),t=i.next(e),n=a.next(e);if(t.t===I.DELETE)continue;if(n.t===I.DELETE){o.push(n);continue}if(t.body==null||n.body==null)o.push(n);else{let{coverType:e,body:i}=Qs(t,n,r===`left`);o.push({...n,t:I.RETAIN,coverType:e,body:i})}}return o.trimEndUselessRetainAction(),o.serialize()}static transformPosition(e,t,n=!1){let r=new Vs(e),i=0;for(;r.hasNext()&&i<=t;){let e=r.peekLength(),a=r.peekType();if(r.next(),a===I.DELETE){t-=Math.min(e,t-i);continue}else a===I.INSERT&&(i<t||!n)&&(t+=e);i+=e}return t}static isNoop(e){return e.length===0}static invert(e){let t=[];for(let n of e)if(n.t===I.INSERT)t.push({t:I.DELETE,len:n.len,body:n.body});else if(n.t===I.DELETE){if(n.body==null)throw Error(`Can not invert DELETE action without body property, makeInvertible must be called first.`);t.push({t:I.INSERT,body:n.body,len:n.len})}else if(n.body!=null){if(n.oldBody==null)throw Error(`Can not invert RETAIN action without oldBody property, makeInvertible must be called first.`);t.push({t:I.RETAIN,body:n.oldBody,oldBody:n.body,len:n.len,coverType:F.REPLACE})}else t.push(n);return t}static makeInvertible(e,t){let n=[],r=0;for(let i of e){if(i.t===I.DELETE&&(i.body==null||i.body&&i.body.dataStream.length!==i.len)){let e=Ms(t,r,r+i.len,!1);i.len=e.dataStream.length,i.body=e}if(i.t===I.RETAIN&&i.body!=null){let e=Ms(t,r,r+i.len,!0);i.oldBody={...e,dataStream:``},i.len=e.dataStream.length}n.push(i),i.t!==I.INSERT&&(r+=i.len)}return n}insert(e,t){let n={t:I.INSERT,body:t,len:e};return this.push(n),this}retain(e,t,n){let r={t:I.RETAIN,len:e};return t!=null&&(r.body=t),n!=null&&(r.coverType=n),this.push(r),this}delete(e){let t={t:I.DELETE,len:e};return this.push(t),this}empty(){return this._actions=[],this}serialize(){return this._actions}push(...e){if(e.length>1){for(let t of e)this.push(t);return this}let t=this._actions.length,n=this._actions[t-1],r=D.deepClone(e[0]);if(r.t===I.RETAIN&&r.len===0&&r.body==null)return this;if(typeof n==`object`){if(n.t===I.DELETE&&r.t===I.DELETE)return n.len+=r.len,this;if(n.t===I.DELETE&&r.t===I.INSERT&&(--t,n=this._actions[t-1],n==null))return this._actions.unshift(r),this;if(n.t===I.RETAIN&&r.t===I.RETAIN&&n.body==null&&r.body==null)return n.len+=r.len,this;if(n.t===I.INSERT&&$s(n.body)&&r.t===I.INSERT&&$s(r.body))return n.len+=r.len,n.body.dataStream+=r.body.dataStream,this}return t===this._actions.length?this._actions.push(r):this._actions.splice(t,0,r),this}trimEndUselessRetainAction(){let e=this._actions[this._actions.length-1];for(;e&&e.t===I.RETAIN&&Bs(e);)this._actions.pop(),e=this._actions[this._actions.length-1];return this}};C(Y,`id`,`text-x`),C(Y,`uri`,`https://github.com/dream-num/univer#text-x`),Object.defineProperty(Y,`name`,{value:`text-x`});var ec=class e{static registerSubtype(e){var t;e==null||this._subTypes.has(e.name)&&((t=this._subTypes.get(e.name))==null?void 0:t.id)!==Y.id||(this._subTypes.set(e.name,e),S.type.registerSubtype(e))}static apply(e,t){if(!S.type.isNoop(t))return S.type.apply(e,t)}static compose(e,t){return S.type.compose(e,t)}static transform(e,t,n){return S.type.transform(e,t,n)}static transformPosition(e,t,n=`right`){return e&&e.length===2&&e[0]===`body`&&e[1].et===Y.name?Y.transformPosition(e[1].e,t,n===`left`):t}static invertWithDoc(e,t){return S.type.invertWithDoc(e,t)}static isNoop(e){return S.type.isNoop(e)}static getInstance(){return this._instance==null&&(this._instance=new e),this._instance}removeOp(e,t){return S.removeOp(e,t)}moveOp(e,t){return S.moveOp(e,t)}insertOp(e,t){return S.insertOp(e,t)}replaceOp(e,t,n){return S.replaceOp(e,t,n)}editOp(e,t=[`body`]){return S.editOp(t,Y.name,e)}};C(ec,`uri`,`https://github.com/dream-num/univer#json-x`),C(ec,`_subTypes`,new Map),C(ec,`_instance`,null),ec.registerSubtype(Y);let tc=function(e){return 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}({}),X=function(e){return e.PARAGRAPH=`\r`,e.SECTION_BREAK=`
|
|
5
|
-
`,e.TABLE_START=``,e.TABLE_ROW_START=`\x1B`,e.TABLE_CELL_START=``,e.TABLE_CELL_END=``,e.TABLE_ROW_END=``,e.TABLE_END=``,e.CUSTOM_RANGE_START=``,e.CUSTOM_RANGE_END=``,e.COLUMN_BREAK=`\v`,e.PAGE_BREAK=`\f`,e.DOCS_END=`\0`,e.TAB=` `,e.CUSTOM_BLOCK=`\b`,e.LETTER=``,e.SPACE=` `,e}({});function
|
|
6
|
-
`)?e.slice(0,-2):e;return rc.reduce((e,t)=>e.replaceAll(t,``),t)},ac=e=>e?ic(e).replaceAll(`\r`,``)===``:!0,oc=e=>{let t=e.replace(/\n/g,`\r`),n=[],r=[],i=0,a=``,o=(o,s=!0)=>{let c=t.slice(i,o);if(D.isLegalUrl(c)){let t=O(),l=`${c}`,u={startIndex:i,endIndex:i+l.length-1,rangeId:t,rangeType:or.HYPERLINK,properties:{url:e}};r.push(u),a+=l,i=o+1,s&&(a+=`\r`,n.push({startIndex:o}))}else a+=t.slice(i,o+1),i=o+1,s&&n.push({startIndex:o})},s=0;for(let e=0;e<t.length;e++)t[e]===`\r`&&(o(e),s=e);return(s!==t.length-1||t.length===1)&&o(t.length,!1),{dataStream:a,paragraphs:n,customRanges:r}},sc={id:`default_doc`,documentStyle:{}};var cc=class extends pn{getUnitId(){throw Error(`Method not implemented.`)}constructor(e){var t;super(),C(this,`type`,x.UNIVER_DOC),C(this,`_name$`,new v(``)),C(this,`name$`,this._name$.asObservable()),C(this,`snapshot`,void 0),this.snapshot={...sc,...e},this._name$.next((t=this.snapshot.title)==null?`No Title`:t)}getRev(){var e;return(e=this.snapshot.rev)==null?1:e}incrementRev(){this.snapshot.rev=this.getRev()+1}setRev(e){this.snapshot.rev=e}setName(e){this.snapshot.title=e,this._name$.next(e)}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get zoomRatio(){var e;return((e=this.snapshot.settings)==null?void 0:e.zoomRatio)||1}resetDrawing(e,t){this.snapshot.drawings=e,this.snapshot.drawingsOrder=t}getBody(){return this.snapshot.body}getSnapshot(){return this.snapshot}getBulletPresetList(){var e;let t=(e=this.snapshot.lists)==null?{}:e;return{...ps,...t}}updateDocumentId(e){this.snapshot.id=e}updateDocumentRenderConfig(e){let{documentStyle:t}=this.snapshot;t.renderConfig==null?t.renderConfig=e:t.renderConfig={...t.renderConfig,...e}}getDocumentStyle(){return this.snapshot.documentStyle}updateDocumentStyle(e){this.snapshot.documentStyle==null?this.snapshot.documentStyle=e:this.snapshot.documentStyle={...this.snapshot.documentStyle,...e}}updateDocumentDataMargin(e){let{t,l:n,b:r,r:i}=e,{documentStyle:a}=this.snapshot;t!=null&&(a.marginTop=t),n!=null&&(a.marginLeft=n),r!=null&&(a.marginBottom=r),i!=null&&(a.marginRight=i)}updateDocumentDataPageSize(e,t){let{documentStyle:n}=this.snapshot;if(!n.pageSize){n.pageSize={width:e==null?1/0:e,height:t==null?1/0:t};return}e!==void 0&&(n.pageSize.width=e),t!==void 0&&(n.pageSize.height=t)}updateDrawing(e,t){let{drawings:n}=this,{width:r,height:i,left:a,top:o}=t,s=n==null?void 0:n[e];if(!s)return;let c=s.docTransform;c.size.width=r,c.size.height=i,c.positionH.posOffset=a,c.positionV.posOffset=o}setZoomRatio(e=1){this.snapshot.settings?this.snapshot.settings.zoomRatio=e:this.snapshot.settings={zoomRatio:e}}setDisabled(e){this.snapshot.disabled=e}getDisabled(){return this.snapshot.disabled}getTitle(){return this.snapshot.title}},lc=class e extends cc{constructor(e){var t,n;super(D.isEmptyObject(e)?Br():e),C(this,`_unitId`,void 0),C(this,`headerModelMap`,new Map),C(this,`footerModelMap`,new Map),C(this,`change$`,new v(0)),this._unitId=(t=this.snapshot.id)==null?O(6):t,this._initializeHeaderFooterModel(),this._name$.next((n=this.snapshot.title)==null?``:n)}dispose(){super.dispose(),this.headerModelMap.forEach(e=>{e.dispose()}),this.footerModelMap.forEach(e=>{e.dispose()}),this._name$.complete()}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getCustomRanges(){var e;return(e=this.snapshot.body)==null?void 0:e.customRanges}getCustomDecorations(){var e;return(e=this.snapshot.body)==null?void 0:e.customDecorations}getSettings(){return this.snapshot.settings}reset(e){if(e.id&&e.id!==this._unitId)throw Error(`Cannot reset a document model with a different unit id!`);this.snapshot={...sc,...e},this._initializeHeaderFooterModel(),this.change$.next(this.change$.value+1)}getSelfOrHeaderFooterModel(e){if(e!=null){if(this.headerModelMap.has(e))return this.headerModelMap.get(e);if(this.footerModelMap.has(e))return this.footerModelMap.get(e)}return this}getUnitId(){return this._unitId}apply(e){if(!ec.isNoop(e))return this.snapshot=ec.apply(this.snapshot,e),e!=null&&e.some(e=>Array.isArray(e)&&((e==null?void 0:e[0])===`headers`||(e==null?void 0:e[0])===`footers`))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.change$.next(this.change$.value+1),this.snapshot}sliceBody(e,t,n=Es.copy){let r=this.getBody();if(r!=null)return Ms(r,e,t,!1,n)}_initializeHeaderFooterModel(){let{headers:t,footers:n}=this.getSnapshot();if(t)for(let n in t){let r=t[n];this.headerModelMap.set(n,new e(r)),this.headerModelMap.get(n).updateDocumentId(this.getUnitId())}if(n)for(let t in n){let r=n[t];this.footerModelMap.set(t,new e(r)),this.footerModelMap.get(t).updateDocumentId(this.getUnitId())}}updateDocumentId(e){super.updateDocumentId(e),this._unitId=e}getPlainText(){var e,t;return ic((e=(t=this.getBody())==null?void 0:t.dataStream)==null?``:e)}};function uc(e){let{ranges:t,id:n,type:r}=e,i=new Y,a=0;for(let e=0;e<t.length;e++){let{startOffset:o,endOffset:s}=t[e];o>0&&i.push({t:I.RETAIN,len:o-a}),i.push({t:I.RETAIN,body:{dataStream:``,customDecorations:[{id:n,type:r,startIndex:0,endIndex:s-o-1}]},len:s-o}),a=s}return i}function dc(e){var t;let{id:n,segmentId:r,documentDataModel:i}=e,a=i==null?void 0:i.getBody();if(!i||!a)return!1;let o=(t=i.getSelfOrHeaderFooterModel(r))==null||(t=t.getBody())==null||(t=t.customDecorations)==null?void 0:t.find(e=>e.id===n);if(!o)return!1;let s=new Y,{startIndex:c,endIndex:l}=o,u=l-c+1;return s.push({t:I.RETAIN,len:c}),s.push({t:I.RETAIN,len:u,body:{dataStream:``,customDecorations:[{startIndex:0,endIndex:u-1,id:n,type:sr.DELETED}]}}),s}function fc(e,t,n,r){return e<=n&&t>=n||e>=n&&e<=r}function pc(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];e.collapsed?i.startIndex<e.startOffset&&e.startOffset<=i.endIndex&&n.push(i):fc(e.startOffset,e.endOffset-1,i.startIndex,i.endIndex)&&n.push(i)}return n}function mc(e){return{...D.deepClone(e),rangeId:O()}}function hc(e,t){let n=[],r=e[0];for(let i of t)i<e[0]||i>e[1]||(r<i&&n.push([r,i-1]),r=i+1);return r<=e[1]&&n.push([r,e[1]]),n}function gc(e,t,n,r){let i=[];for(let a=0,o=n.length;a<o;a++){let o=n[a];if((r===void 0||o.rangeType===r)&&Math.max(o.startIndex,e)<=Math.min(o.endIndex,t)&&i.push({...o}),o.startIndex>t)break}return i}function _c(e,t){var n,r,i,a,o;let s=gc(e.startOffset,e.collapsed?e.startOffset:e.endOffset-1,(n=t.customRanges)==null?[]:n),c=Math.min(e.startOffset,(r=(i=s[0])==null?void 0:i.startIndex)==null?1/0:r),l=Math.max(e.endOffset,((a=(o=s[s.length-1])==null?void 0:o.endIndex)==null?-1/0:a)+1);return{startOffset:c,endOffset:l,collapsed:c===l}}function vc(e){var t,n;let{rangeId:r,segmentId:i,documentDataModel:a,insert:o}=e,s=(t=a.getSelfOrHeaderFooterModel(i).getBody())==null||(t=t.customRanges)==null?void 0:t.find(e=>e.rangeId===r);if(!s)return!1;let{startIndex:c,endIndex:l}=s,u=new Y,d=l-c+1;u.push({t:I.RETAIN,len:c}),u.push({t:I.RETAIN,len:d,body:{dataStream:``,customRanges:[]}}),o&&u.push({t:I.INSERT,body:o,len:o.dataStream.length});let f=l+1+((n=o==null?void 0:o.dataStream.length)==null?0:n);return u.selections=[{startOffset:f,endOffset:f,collapsed:!0}],u}function yc(e){let{ranges:t,rangeId:n,rangeType:r,wholeEntity:i,properties:a,body:o}=e,s=0,c=new Y,l=!1;return t.forEach(e=>{var t,u,d;let f=_c(e,o);if(!f||!o)return!1;let{startOffset:p,endOffset:m}=f,h=(t=o.customRanges)==null?[]:t,g=(e,t,o)=>{var l,u,d,f;let p=gc(e,t,h,r),m=Math.min((l=(u=p[0])==null?void 0:u.startIndex)==null?1/0:l,e),g=Math.max((d=(f=p[p.length-1])==null?void 0:f.endIndex)==null?-1/0:d,t),_={rangeId:o?`${n}$${o}`:n,rangeType:r,startIndex:0,endIndex:g-m,wholeEntity:i,properties:{...a}};c.push({t:I.RETAIN,len:m-s}),c.push({t:I.RETAIN,len:g-m+1,body:{dataStream:``,customRanges:[_]},coverType:F.COVER}),s=g+1},_=((u=o.paragraphs)==null?[]:u).filter(e=>e.startIndex<m&&e.startIndex>p),ee=((d=o.customBlocks)==null?[]:d).filter(e=>e.startIndex<m&&e.startIndex>p);hc([p,m-1],[..._.map(e=>e.startIndex),...ee.map(e=>e.startIndex)]).forEach(([e,t],n)=>g(e,t,n)),l=!0,c.selections=[{startOffset:f.endOffset,endOffset:f.endOffset,collapsed:!0}]}),l?c:!1}function bc(e,t,n=0,r=null,i=!0){e.sort((e,t)=>e.startOffset-t.startOffset);let a=[],{paragraphs:o=[]}=t,s=o==null?void 0:o.find(t=>t.startIndex>=e[0].startOffset&&t.startIndex<e[0].endOffset),c=n;if(e.forEach(e=>{let{startOffset:t,endOffset:n}=e;t>c&&(a.push({t:I.RETAIN,len:t-c}),c=t),c<n&&(a.push({t:I.DELETE,len:n-c}),c=n)}),r&&a.push({t:I.INSERT,body:r,len:r.dataStream.length}),s&&i){let t=o.find(t=>t.startIndex-n>=e[e.length-1].endOffset-1);t&&(t.startIndex>c&&(a.push({t:I.RETAIN,len:t.startIndex-c}),c=t.startIndex),a.push({t:I.RETAIN,len:1,body:{dataStream:``,paragraphs:[{...t,startIndex:0,bullet:s==null?void 0:s.bullet}]},coverType:F.REPLACE}))}return a}function xc(e,t,n=0){let r=[],i=n;return e.forEach(e=>{let{startOffset:n,endOffset:a}=e;n>i&&(r.push({t:I.RETAIN,len:n-i}),i=n),a>i&&(r.push({t:I.RETAIN,len:a-i,body:{...D.deepClone(t),dataStream:``}}),i=a)}),r}const Sc=e=>{var t;let{selection:n,body:r,doc:i}=e,a=n.segmentId,o=(t=i.getSelfOrHeaderFooterModel(a))==null?void 0:t.getBody();if(!o)return!1;let s=n.collapsed?null:Ms(o,n.startOffset,n.endOffset),c=qe(s?s.dataStream:``,r.dataStream),l=0,u=c.map(([e,t])=>{switch(e){case 0:{let e={t:I.RETAIN,body:{...Ms(r,l,l+t.length,!1),dataStream:``},len:t.length};return l+=t.length,e}case 1:{let e={t:I.INSERT,body:Ms(r,l,l+t.length),len:t.length};return l+=t.length,e}default:return{t:I.DELETE,len:t.length}}}),d=new Y;return d.push({t:I.RETAIN,len:n.startOffset}),d.push(...u),d};function Cc(e,t){return!!((e==null?void 0:e.length)===(t==null?void 0:t.length)&&e!=null&&e.every((e,n)=>JSON.stringify(e)===JSON.stringify(t==null?void 0:t[n])))}const wc=e=>{var t;let{selection:n,body:r,doc:i,themeService:a}=e,o=n.segmentId,s=(t=i.getSelfOrHeaderFooterModel(o))==null?void 0:t.getBody();if(!s)return!1;let c=n.collapsed?null:Ms(s,n.startOffset,n.endOffset),l=qe(c?c.dataStream:``,r.dataStream),u=0,d=l.map(([e,t])=>{switch(e){case 0:{let e=Ds(r,u,u+t.length,!1),n=Ds(c,u,u+t.length,!1),i={t:I.RETAIN,body:Cc(e,n)?void 0:{textRuns:e==null?void 0:e.map(e=>{var t,n,r,i;return{...e,ts:{...e.ts,cl:!((t=e.ts)==null||(t=t.cl)==null||(t=t.rgb)==null)&&t.includes(`.`)?{rgb:a.getColorFromTheme((n=(r=e.ts)==null||(r=r.cl)==null?void 0:r.rgb)==null?``:n)}:(i=e.ts)==null?void 0:i.cl}}}),dataStream:``},len:t.length};return u+=t.length,i}case 1:{let e={t:I.INSERT,body:Ms(r,u,u+t.length),len:t.length};return u+=t.length,e}default:return{t:I.DELETE,len:t.length}}});if(d.every(e=>e.t===I.RETAIN&&!e.body))return!1;let f=new Y;return f.push({t:I.RETAIN,len:n.startOffset}),f.push(...d),f};function Tc(e,t){let n=[],{customBlocks:r=[]}=e;for(let e of t){let{startOffset:t,endOffset:i}=e;if(!(t==null||i==null))for(let e of r){let{startIndex:r}=e;r>=t&&r<i&&n.push(e.blockId)}}return n}function Ec(e,t=``){if(!t)return[`body`];let{headers:n,footers:r}=e.getSnapshot();if(n==null&&r==null)throw Error(`Document data model must have headers or footers when update by segment id`);if((n==null?void 0:n[t])!=null)return[`headers`,t,`body`];if((r==null?void 0:r[t])!=null)return[`footers`,t,`body`];throw Error(`Segment id not found in headers or footers`)}const Dc=e=>{var t,n;let{selection:r,documentDataModel:i,drawings:a}=e,{collapsed:o,startOffset:s,segmentId:c}=r,l=new Y,u=ec.getInstance(),d=[],f=i.getSelfOrHeaderFooterModel(c).getBody();if(!f)return!1;let p=(t=(n=i.getSnapshot().drawingsOrder)==null?void 0:n.length)==null?0:t,m=0;if(o)s>0&&l.push({t:I.RETAIN,len:s});else{var h,g;let e=bc([r],f,0,null,!1);l.push(...e);let t=Tc(f,[r]),n=(h=i.getDrawings())==null?{}:h,a=(g=i.getDrawingsOrder())==null?[]:g,o=t.sort((e,t)=>a.indexOf(e)>a.indexOf(t)?-1:a.indexOf(e)<a.indexOf(t)?1:0);if(o.length>0)for(let e of o){let t=n[e],r=a.indexOf(e);if(t==null||r<0)continue;let i=u.removeOp([`drawings`,e],t),o=u.removeOp([`drawingsOrder`,r],e);d.push(i),d.push(o),m++}}l.push({t:I.INSERT,body:{dataStream:`\b`.repeat(a.length),customBlocks:a.map((e,t)=>({startIndex:t,blockId:e.drawingId}))},len:a.length});let _=Ec(i,c),ee=u.editOp(l.serialize(),_);d.push(ee);for(let e of a){let{drawingId:t}=e,n=u.insertOp([`drawings`,t],e),r=u.insertOp([`drawingsOrder`,p-m],t);d.push(n),d.push(r)}return d.reduce((e,t)=>ec.compose(e,t),null)};function Oc(e,t){if(t===void 0)return{startOffset:e,endOffset:e,collapsed:!0};if(t<e)throw Error(`Cannot make a doc selection when endOffset ${t} is less than startOffset ${e}.`);return{startOffset:e,endOffset:t,collapsed:e===t}}function kc(e){let{startOffset:t,endOffset:n,collapsed:r}=e;return{startOffset:Math.min(t,n),endOffset:Math.max(t,n),collapsed:r}}function Ac(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function jc(e,t,n,r){let{startOffset:i,endOffset:a}=e,o=r==null?Pc(t,n):r,s=[],c=-1;for(let e=0;e<o.length;e++){let t=o[e],{startIndex:n}=t;(i>c&&i<=n||a>c&&a<=n||n>=i&&n<=a)&&s.push(t),c=n}return s}function Mc(e,t,n){let r=[],i=Pc(t,n);for(let a of e){let e=jc(a,t,n,i);r.push(...e)}return r}const Nc=[X.PARAGRAPH,X.TABLE_START,X.TABLE_END,X.TABLE_ROW_START,X.TABLE_CELL_START,X.TABLE_CELL_END];function Pc(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r],{startIndex:a}=i,o=a-1;for(;!Nc.includes(t[o])&&o>=0;)o--;n.push({...i,paragraphStart:o+1,paragraphEnd:i.startIndex})}return n}const Fc=e=>{var t,n;let{paragraphs:r,segmentId:i,document:a}=e,o=e.listType,s=(t=(n=a.getSelfOrHeaderFooterModel(i).getBody())==null?void 0:n.paragraphs)==null?[]:t,c=r.every(e=>{var t;return((t=e.bullet)==null?void 0:t.listType.indexOf(o))===0}),l=O(6);if(r.length===1){let e=s.indexOf(r[0]),t=s[e-1],n=s[e+1];t&&t.bullet&&t.bullet.listType.indexOf(o)===0?(l=t.bullet.listId,o!==q.CHECK_LIST&&(o=t.bullet.listType)):n&&n.bullet&&n.bullet.listType.indexOf(o)===0&&(l=n.bullet.listId,o!==q.CHECK_LIST&&(o=n.bullet.listType))}let u=new Zt;u.reset();let d=new Y;for(let e of r){var f;let{startIndex:t,paragraphStyle:n={},bullet:r}=e;d.push({t:I.RETAIN,len:t-u.cursor}),d.push({t:I.RETAIN,len:1,body:{dataStream:``,paragraphs:[c?{paragraphStyle:n,startIndex:0}:{startIndex:0,paragraphStyle:{...n},bullet:{nestingLevel:(f=r==null?void 0:r.nestingLevel)==null?0:f,textStyle:{fs:20},listType:o,listId:l}}]},coverType:F.REPLACE}),u.moveCursorTo(t+1)}return d},Ic=e=>{var t;let{paragraphIndex:n,segmentId:r,document:i}=e,a=(t=i.getSelfOrHeaderFooterModel(r).getBody())==null?void 0:t.paragraphs;if(a==null)return!1;let o=a.find(e=>e.startIndex===n);if(!(o!=null&&o.bullet)||o.bullet.listType.indexOf(q.CHECK_LIST)===-1)return!1;let s=new Zt;s.reset();let c=new Y,{startIndex:l,paragraphStyle:u={}}=o,d=o.bullet.listType===q.CHECK_LIST?q.CHECK_LIST_CHECKED:q.CHECK_LIST;return c.push({t:I.RETAIN,len:l-s.cursor}),c.push({t:I.RETAIN,len:1,body:{dataStream:``,paragraphs:[{...o,paragraphStyle:u,startIndex:0,bullet:{...o.bullet,listType:d}}]},coverType:F.REPLACE}),s.moveCursorTo(l+1),c},Lc=e=>{var t;let{paragraphs:n,listType:r,segmentId:i,document:a}=e;if(((t=a.getSelfOrHeaderFooterModel(i).getBody())==null?void 0:t.paragraphs)==null)return!1;let o=O(6),s=new Zt;s.reset();let c=new Y;for(let e of n){var l;let{startIndex:t,paragraphStyle:n={},bullet:i}=e;c.push({t:I.RETAIN,len:t-s.cursor}),c.push({t:I.RETAIN,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphStyle:n,bullet:{nestingLevel:(l=i==null?void 0:i.nestingLevel)==null?0:l,textStyle:(i==null?void 0:i.listType)===r?i.textStyle:{fs:20},listType:r,listId:o}}]},coverType:F.REPLACE}),s.moveCursorTo(t+1)}return c};function Rc(e,t){return t.some(t=>e.startIndex>t.startIndex&&e.startIndex<t.endIndex)}const zc=e=>{var t,n,r;let{paragraphs:i,document:a,type:o}=e,s=new Zt;s.reset();let c=new Y,l=(t=a.getSnapshot().lists)==null?{}:t,u=(n=(r=a.getBody())==null?void 0:r.tables)==null?[]:n,d={...ps,...l};for(let e of i){let{startIndex:t,paragraphStyle:n={},bullet:r}=e,i=Rc(e,u);if(c.push({t:I.RETAIN,len:t-s.cursor}),r){let e=d[r.listType].nestingLevel.length-1;i&&(e=Math.min(e,2)),c.push({t:I.RETAIN,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphStyle:{...n},bullet:{...r,nestingLevel:Math.max(Math.min(r.nestingLevel+o,e),0)}}]},coverType:F.REPLACE})}else c.push({t:I.RETAIN,len:1});s.moveCursorTo(t+1)}return c},Bc=e=>{var t,n,r,i;let{textRanges:a,segmentId:o,document:s,style:c,paragraphTextRun:l,cursor:u,deleteLen:d,textX:f}=e,p=s.getSelfOrHeaderFooterModel(o),m=Mc(a,(t=(n=p.getBody())==null?void 0:n.paragraphs)==null?[]:t,(r=(i=p.getBody())==null?void 0:i.dataStream)==null?``:r),h=new Zt;u&&h.moveCursorTo(u);let g=f==null?new Y:f;m.sort((e,t)=>e.startIndex-t.startIndex);let _=Math.max(0,m[0].paragraphStart-1);_>h.cursor&&(g.push({t:I.RETAIN,len:_-h.cursor}),h.moveCursorTo(_)),d&&g.push({t:I.DELETE,len:d});for(let e of m){let{startIndex:t,paragraphStyle:n={}}=e,r=t-h.cursor;g.push({t:I.RETAIN,len:r,...l?{body:{dataStream:``,textRuns:[{ts:l,st:0,ed:r}]},coverType:F.REPLACE}:null}),g.push({t:I.RETAIN,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphStyle:{...n,...c}}]},coverType:F.REPLACE}),h.moveCursorTo(t+1)}return g};var Z=class{};C(Z,`customRange`,{add:yc,delete:vc,copyCustomRange:mc,getCustomRangesInterestsWithSelection:pc,isIntersecting:fc}),C(Z,`customDecoration`,{add:uc,delete:dc}),C(Z,`selection`,{replace:Sc,makeSelection:Oc,normalizeSelection:kc,delete:bc,replaceTextRuns:wc,retain:xc}),C(Z,`range`,{isIntersects:Ac,getParagraphsInRange:jc,getParagraphsInRanges:Mc}),C(Z,`transform`,{getPlainText:ic,fromPlainText:oc,isEmptyDocument:ac}),C(Z,`paragraph`,{bullet:{set:Lc,switch:Fc,toggleChecklist:Ic,changeNestLevel:zc},style:{set:Bc},util:{transform:Pc,getParagraphsInRange:jc,getParagraphsInRanges:Mc}}),C(Z,`drawing`,{add:Dc});function Vc(e,t,n,r){if(t===``)return e;let i=new lc({id:`mock-id`,body:e,documentStyle:{}}),a=t.length,o;for(;(o=(r?i.getBody().dataStream:i.getBody().dataStream.toLowerCase()).indexOf(t))>=0;){let e=new Y,t=ec.getInstance();if(o>0&&e.retain(o),n.length>0){var s;let t=i.sliceBody(o,o+a),r={dataStream:n};Array.isArray(t==null?void 0:t.textRuns)&&t.textRuns.length&&(r.textRuns=[{...t.textRuns[0],st:0,ed:n.length}]),!(t==null||(s=t.customRanges)==null)&&s.length&&(r.customRanges=[{...t.customRanges[0],startIndex:0,endIndex:n.length-1}]),e.insert(n.length,r)}e.delete(a),i.apply(t.editOp(e.serialize()))}let c=i.getBody();return i.dispose(),c}function Hc(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 Uc(e){var t;return e.body=Hc((t=e.body)==null?{dataStream:``}:t),e.drawingsOrder||(e.drawingsOrder=[]),e.drawings||(e.drawings={}),e.documentStyle||(e.documentStyle={}),e}var Wc=class e{static create(t={}){return new e(t)}constructor(e={}){C(this,`_style`,void 0),this._style=e}get fontFamily(){return this._style.ff}get fontSize(){return this._style.fs}get italic(){return this._style.it===A.TRUE}get bold(){return this._style.bl===A.TRUE}get underline(){return this._style.ul&&Kc.create(this._style.ul)}get bottomBorderLine(){return this._style.bbl&&Kc.create(this._style.bbl)}get strikethrough(){return this._style.st&&Kc.create(this._style.st)}get overline(){return this._style.ol&&Kc.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 Gc.create(D.deepClone(this._style))}getValue(){return{...this._style}}},Gc=class e extends Wc{static create(t={}){return new e(t)}constructor(e={}){super(e)}setFontFamily(e){return this._style.ff=e,this}setFontSize(e){return this._style.fs=e,this}setItalic(e){return this._style.it=e?1:0,this}setBold(e){return this._style.bl=e?1:0,this}setUnderline(e){return this._style.ul=e.build(),this}setBottomBorderLine(e){return this._style.bbl=e.build(),this}setStrikethrough(e){return this._style.st=e.build(),this}setOverline(e){return this._style.ol=e.build(),this}setBackground(e){return this._style.bg=e,this}setBorder(e){return this._style.bd=e,this}setColor(e){return this._style.cl=e,this}setVerticalAlign(e){return this._style.va=e,this}copy(){return e.create(D.deepClone(this._style))}build(){return this.getValue()}},Kc=class e{static create(t={s:1}){return new e(t)}constructor(e={s:1}){C(this,`_decoration`,void 0),this._decoration=e}get show(){return this._decoration.s===A.TRUE}get followFontColor(){return this._decoration.c===A.TRUE}get color(){return this._decoration.cl}get type(){return this._decoration.t}setShow(e){return this._decoration.s=e?1:0,this}setFollowFontColor(e){return this._decoration.c=e?1:0,this}setColor(e){return this._decoration.cl=e,this}setLineType(e){return this._decoration.t=e,this}copy(){return e.create(D.deepClone(this._decoration))}build(){return{...this._decoration}}},qc=class e{static create(t={}){return new e(t)}constructor(e={}){C(this,`_style`,void 0),this._style=e}get indentFirstLine(){return this._style.indentFirstLine}get hanging(){return this._style.hanging}get indentStart(){return this._style.indentStart}get tabStops(){return this._style.tabStops}get indentEnd(){return this._style.indentEnd}get textStyle(){return this._style.textStyle}get headingId(){return this._style.headingId}get namedStyleType(){return this._style.namedStyleType}get horizontalAlign(){return this._style.horizontalAlign}get lineSpacing(){return this._style.lineSpacing}get direction(){return this._style.direction}get spacingRule(){return this._style.spacingRule}get snapToGrid(){return this._style.snapToGrid}get spaceAbove(){return this._style.spaceAbove}get spaceBelow(){return this._style.spaceBelow}get borderBetween(){return this._style.borderBetween}get borderTop(){return this._style.borderTop}get borderBottom(){return this._style.borderBottom}get borderLeft(){return this._style.borderLeft}get borderRight(){return this._style.borderRight}get keepLines(){return this._style.keepLines===A.TRUE}get keepNext(){return this._style.keepNext===A.TRUE}get wordWrap(){return this._style.wordWrap===A.TRUE}get widowControl(){return this._style.widowControl===A.TRUE}get shading(){return this._style.shading}get suppressHyphenation(){return this._style.suppressHyphenation===A.TRUE}copy(){return Jc.create(D.deepClone(this._style))}getValue(){return this._style}},Jc=class e extends qc{static create(t={}){return new e(t)}constructor(e={}){super(e)}setIndentFirstLine(e){return this._style.indentFirstLine=e,this}setHanging(e){return this._style.hanging=e,this}setIndentStart(e){return this._style.indentStart=e,this}setTabStops(e){return this._style.tabStops=e,this}setIndentEnd(e){return this._style.indentEnd=e,this}setTextStyle(e){return this._style.textStyle=e,this}setHeadingId(e){return this._style.headingId=e,this}setNamedStyleType(e){return this._style.namedStyleType=e,this}setHorizontalAlign(e){return this._style.horizontalAlign=e,this}setLineSpacing(e){return this._style.lineSpacing=e,this}setDirection(e){return this._style.direction=e,this}setSpacingRule(e){return this._style.spacingRule=e,this}setSnapToGrid(e){return this._style.snapToGrid=e?1:0,this}setSpaceAbove(e){return this._style.spaceAbove=e,this}setSpaceBelow(e){return this._style.spaceBelow=e,this}setBorderBetween(e){return this._style.borderBetween=e,this}setBorderTop(e){return this._style.borderTop=e,this}setBorderBottom(e){return this._style.borderBottom=e,this}setBorderLeft(e){return this._style.borderLeft=e,this}setBorderRight(e){return this._style.borderRight=e,this}setKeepLines(e){return this._style.keepLines=e?1:0,this}setKeepNext(e){return this._style.keepNext=e?1:0,this}setWordWrap(e){return this._style.wordWrap=e?1:0,this}setWidowControl(e){return this._style.widowControl=e?1:0,this}setShading(e){return this._style.shading=e,this}setSuppressHyphenation(e){return this._style.suppressHyphenation=e?1:0,this}copy(){return e.create(D.deepClone(this._style))}build(){return this.getValue()}},Yc=class e{static create(t){return new e(t)}static createByBody(t){return new e({body:t,id:`d`,documentStyle:{}})}constructor(e){if(C(this,`_data`,void 0),!e.body)throw Error(`Invalid document data, body is required`);this._data=Uc(e)}copy(){return Xc.create(D.deepClone(this._data))}slice(e,t){let{body:n,...r}=this._data;return Xc.create({...D.deepClone(r),body:Ms(n,e,t)})}toPlainText(){var e,t;return Z.transform.getPlainText((e=(t=this._data.body)==null?void 0:t.dataStream)==null?``:e).replaceAll(`\r`,`
|
|
7
|
-
`)}getParagraphStyle(){var e;return
|
|
8
|
-
`,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(t){return new e(t==null?e.newEmptyData():t)}constructor(e){super(e),C(this,`_doc`,void 0),this._doc=new lc(e)}insertText(e,t,n){var r,i;let a=((r=(i=this._data.body)==null?void 0:i.dataStream.length)==null?2:r)-2,o,s;if(typeof e==`string`?o=e:(a=Math.min(e,a),o=t),s=typeof t==`object`?t instanceof Gc?t.build():t:n instanceof Gc?n.build():n,!o)return this;let c={dataStream:o,textRuns:s?[{ts:s,st:a,ed:a+o.length}]:[]},l=Z.selection.replace({doc:this._doc,selection:{startOffset:a,endOffset:a,collapsed:!0},body:c});if(!l)throw Error(`Insert text failed, please check.`);return Y.apply(this._doc.getBody(),l.serialize()),this}insertRichText(e,t){var n,r;let i=((n=(r=this._data.body)==null?void 0:r.dataStream.length)==null?2:n)-2,a;typeof e==`object`?a=e instanceof Yc?e.getData():e:(i=Math.min(e,i),a=t instanceof Yc?t.getData():t);let o=Z.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:a.body});if(!o)throw Error(`Insert text failed, please check.`);return Y.apply(this._doc.getBody(),o.serialize()),this}delete(e,t){if(t!==void 0){if(!t)return this;let n=Z.selection.delete([{startOffset:e,endOffset:e+t,collapsed:!0}],this._data.body);Y.apply(this._doc.getBody(),n)}return this}setStyle(e,t,n){let r={dataStream:``,textRuns:[{ts:n instanceof Gc?n.build():n,st:0,ed:t-e}]},i=Z.selection.retain([{startOffset:e,endOffset:t,collapsed:!0}],r);return Y.apply(this._doc.getBody(),i),this}setLink(e,t,n){let r=Z.customRange.add({rangeType:or.HYPERLINK,rangeId:O(),properties:{url:n},ranges:[{startOffset:e,endOffset:t,collapsed:!1}],body:this._data.body});if(!r)throw Error(`Insert text failed, please check.`);return Y.apply(this._doc.getBody(),r.serialize()),this}cancelLink(e,t){if(typeof e==`string`){let t=Z.customRange.delete({rangeId:e,documentDataModel:this._doc});if(!t)throw Error(`Insert text failed, please check.`);Y.apply(this._doc.getBody(),t.serialize())}else this.slice(e,t).getLinks().forEach(e=>{let t=Z.customRange.delete({rangeId:e.rangeId,documentDataModel:this._doc});if(!t)throw Error(`Insert text failed, please check.`);Y.apply(this._doc.getBody(),t.serialize())});return this}updateLink(e,t){var n;let r=(n=this._data.body)==null||(n=n.customRanges)==null?void 0:n.find(t=>t.rangeId===e);if(!r)throw Error(`Link not found`);return r.properties.url=t,this}insertParagraph(e,t){let n,r;if(typeof e==`object`){var i,a;n={dataStream:`\r`,paragraphs:[{startIndex:0,paragraphStyle:e.build()}]},r=((i=(a=this._data.body)==null?void 0:a.dataStream.length)==null?2:i)-2}else r=e,n={dataStream:`\r`,paragraphs:[{startIndex:0,paragraphStyle:t==null?void 0:t.build()}]};return this.insertRichText(r,Yc.create({body:n,id:`d`,documentStyle:{}})),this}insertLink(t,n,r){let i=``,a=``;typeof t==`string`?(i=t,a=n):(i=n,a=r);let o=e.createByBody({dataStream:i,customRanges:[{rangeType:or.HYPERLINK,rangeId:O(),properties:{url:a},startIndex:0,endIndex:i.length-1}]});return typeof t==`number`?this.insertRichText(t,o):this.insertRichText(o)}};const Zc=`__default_document_sub_component_id20231101__`;var Qc=class{constructor(){C(this,`skipNextObservers`,!1),C(this,`lastReturnValue`,void 0),C(this,`isStopPropagation`,!1)}stopPropagation(){this.isStopPropagation=!0}},$c=class extends y{constructor(...e){super(...e),C(this,`_sortedObservers`,[])}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(e){let t;t=typeof e==`function`?{next:([t,n])=>e(t,n)}:e;let n=super.subscribe(t);return this._sortedObservers.push(t),this._sortedObservers.sort((e,t)=>{var n,r;return((n=e.priority)==null?0:n)-((r=t.priority)==null?0:r)}),n.add(()=>this._sortedObservers=this._sortedObservers.filter(e=>e!==t)),n}clearObservers(){this._sortedObservers.forEach(e=>{var t;return(t=e.complete)==null?void 0:t.call(e)}),this._sortedObservers.length=0}emitEvent(e){if(!this.closed){let n=new Qc;n.lastReturnValue=e;for(let r of this._sortedObservers){var t;if(n.lastReturnValue=(t=r.next)==null?void 0:t.call(r,[e,n]),n.skipNextObservers)return{handled:!0,lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}throw Error(`[EventSubject]: cannot emit event on a closed subject.`)}};function el(e){return new fe(t=>{let n=e.subscribeEvent(e=>{t.next(e)});return()=>n.unsubscribe()})}const tl=m(`core.resource-manager.service`),nl={[b.Editor]:`Editor`,[b.Owner]:`Owner`,[b.Reader]:`Reader`,[b.UNRECOGNIZED]:`UNRECOGNIZED`},rl=e=>e?{userID:`${nl[e]}_${O(8)}`,name:nl[e],avatar:``}:{userID:``,name:``,avatar:``,anonymous:!0,canBindAnonymous:!1},il=(e,t)=>e.startsWith(nl[t]);var al=class extends E{constructor(...e){super(...e),C(this,`_model`,new Map),C(this,`_userChange$`,new y),C(this,`userChange$`,this._userChange$.asObservable()),C(this,`_currentUser$`,new v(rl())),C(this,`currentUser$`,this._currentUser$.asObservable())}dispose(){super.dispose(),this._model.clear(),this._userChange$.complete(),this._currentUser$.complete()}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(e){this.addUser(e),this._currentUser$.next(e)}addUser(e){this._model.set(e.userID,e),this._userChange$.next({type:`add`,user:e})}getUser(e,t){let n=this._model.get(e);if(n)return n;t&&t()}delete(e){let t=this.getUser(e);this._model.delete(e),t&&this._userChange$.next({type:`delete`,user:t})}clear(){this._model.clear(),this._userChange$.next({type:`clear`})}list(){return Array.from(this._model.values())}};let ol=class{constructor(e,t){this._resourceManagerService=e,this._userManagerService=t,C(this,`_permissionMap`,new Map([])),C(this,`_permissionOverrides`,new Map),this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){let e=this._userManagerService.getCurrentUser();e&&e.userID||this._userManagerService.setCurrentUser(rl(b.Owner))}_getRole(e){let t=this._userManagerService.getCurrentUser();return t?il(t.userID,e):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:e=>{let t=[...this._permissionMap.keys()].reduce((e,t)=>(e[t]=this._permissionMap.get(t),e),{});return JSON.stringify(t)},parseJson:e=>JSON.parse(e),pluginName:`SHEET_AuthzIoMockService_PLUGIN`,businesses:[Oe.UNIVER_SHEET,Oe.UNIVER_DOC,Oe.UNIVER_SLIDE],onLoad:(e,t)=>{for(let e in t)this._permissionMap.set(e,t[e])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(e){let t=O(8),{objectType:n,selectRangeObject:r,worksheetObject:i}=e,a=r||i,o={objectType:n,unitID:(a==null?void 0:a.unitID)||``,name:(a==null?void 0:a.name)||``,strategies:[{action:6,role:b.Owner},{action:16,role:b.Owner},{action:17,role:b.Owner},{action:18,role:b.Owner},{action:19,role:b.Owner},{action:33,role:b.Owner},{action:34,role:b.Owner},{action:35,role:b.Owner},{action:36,role:b.Owner},{action:37,role:b.Owner},{action:38,role:b.Owner},{action:39,role:b.Owner},{action:40,role:b.Owner}],selectRangeObject:r};return this._permissionMap.set(t,o),t}async allowed(e){let{objectID:t,actions:n}=e,r=this._permissionMap.get(t);return r?n.map(e=>{let n=`${t}:${e}`;if(this._permissionOverrides.has(n))return{action:e,allowed:this._permissionOverrides.get(n)};let i=r.strategies.find(t=>t.action===e);return i?{action:e,allowed:this._getRole(i.role)}:{action:e,allowed:this._getRole(b.Owner)||this._getRole(b.Editor)}}):n.map(e=>({action:e,allowed:this._getRole(b.Owner)||this._getRole(b.Editor)}))}async batchAllowed(e){let t=await Promise.all(e.map(e=>this.allowed(e)));return e.map((e,n)=>({unitID:e.unitID,objectID:e.objectID,actions:t[n]}))}async list(e){let t=[],n=[{action:6,role:b.Owner},{action:16,role:b.Owner},{action:17,role:b.Owner},{action:18,role:b.Owner},{action:19,role:b.Owner},{action:33,role:b.Owner},{action:34,role:b.Owner},{action:35,role:b.Owner},{action:36,role:b.Owner},{action:37,role:b.Owner},{action:38,role:b.Owner},{action:39,role:b.Owner},{action:40,role:b.Owner}];return e.objectIDs.forEach(r=>{let i=this._permissionMap.get(r),a=(i==null?void 0:i.strategies)||n,o={objectID:r,unitID:e.unitID,objectType:(i==null?void 0:i.objectType)||3,name:(i==null?void 0:i.name)||``,shareOn:!1,shareRole:b.Owner,shareScope:-1,scope:{read:De.AllCollaborator,edit:De.AllCollaborator},creator:rl(b.Owner),strategies:a.map(e=>({action:e.action,role:e.role})),actions:e.actions.map(e=>{let t=`${r}:${e}`;if(this._permissionOverrides.has(t))return{action:e,allowed:this._permissionOverrides.get(t)};let n=a.find(t=>t.action===e);return n?{action:e,allowed:this._getRole(n.role)}:{action:e,allowed:this._getRole(b.Owner)||this._getRole(b.Editor)}})};t.push(o)}),t}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(e){let{objectID:t,strategies:n}=e,r=this._permissionMap.get(t);r&&n&&(r.strategies=n.map(e=>({action:e.action,role:e.role})),this._permissionMap.set(t,r),n.forEach(e=>{e.role===b.Reader?this.setPermissionOverride(t,e.action,!1):(e.role===b.Owner||e.role===b.Editor)&&this.clearPermissionOverride(t,e.action)}))}setPermissionOverride(e,t,n){let r=`${e}:${t}`;this._permissionOverrides.set(r,n)}clearPermissionOverride(e,t){let n=`${e}:${t}`;this._permissionOverrides.delete(n)}clearAllOverrides(e){let t=[];this._permissionOverrides.forEach((n,r)=>{r.startsWith(`${e}:`)&&t.push(r)}),t.forEach(e=>this._permissionOverrides.delete(e))}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(e){}};ol=z([R(0,tl),R(1,t(al))],ol);const sl=m(`IAuthzIoIoService`),cl=m(`univer.confirm-service`);var ll=class{constructor(){C(this,`confirmOptions$`,new y)}dispose(){this.confirmOptions$.complete()}open(e){throw Error(`This is not implemented in the test service!`)}confirm(e){return Promise.resolve(!0)}close(e){throw Error(`This is not implemented in the test service!`)}};const ul=`FOCUSING_UNIT`,dl=`FOCUSING_SHEET`,fl=`FOCUSING_DOC`,pl=`FOCUSING_SLIDE`,ml=`FOCUSING_EDITOR_BUT_HIDDEN`,hl=`EDITOR_ACTIVATED`,gl=`FOCUSING_EDITOR_INPUT_FORMULA`,_l=`FOCUSING_FX_BAR_EDITOR`,vl=`FOCUSING_UNIVER_EDITOR`,yl=`FOCUSING_EDITOR_INPUT_FORMULA`,bl=`FOCUSING_COMMENT_EDITOR`,xl=`FOCUSING_PANEL_EDITOR`,Sl=`FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE`,Cl=`FOCUSING_COMMON_DRAWINGS`,wl=`FOCUSING_SHAPE_TEXT_EDITOR`,Tl=`FORMULA_EDITOR_ACTIVATED`;var El=class extends E{constructor(...e){super(...e),C(this,`_error$`,new y),C(this,`error$`,this._error$.asObservable())}dispose(){this._error$.complete()}emit(e){this._error$.next({errorKey:e})}};let Dl=function(e){return e.URL=`URL`,e.UUID=`UUID`,e.BASE64=`BASE64`,e}({}),Ol=function(e){return e.SUCCUSS=`0`,e.ERROR_EXCEED_SIZE=`1`,e.ERROR_IMAGE_TYPE=`2`,e.ERROR_UPLOAD_COUNT_LIMIT=`3`,e.ERROR_IMAGE=`4`,e}({});const kl=m(`core.image-io.service`),Al=m(`core.url-image.service`);var jl=`@univerjs/core`,Ml=`0.18.0`;function Nl(e=``,t=Rn.ZH_CN,n=``){return{id:e,sheetOrder:[],name:n,appVersion:Ml,locale:t,styles:{},sheets:{},resources:[]}}var Pl=class{constructor(e={}){C(this,`_styles`,void 0),C(this,`_cacheMap`,new $a(1e5)),this._styles=e,this._generateCacheMap()}each(e){return Object.entries(this._styles).forEach(e),this}search(e,t){return this._cacheMap.has(t)?this._cacheMap.get(t):this._getExistingStyleId(e)||`-1`}get(e){return typeof e==`string`?(e=String(e),this._styles[e]):e}add(e,t){let n=O(6);return this._styles[n]=e,this._cacheMap.set(t,n),n}setValue(e){if(e==null)return;let t=JSON.stringify(e),n=this.search(e,t);return n===`-1`?this.add(e,t):n}addCustomStyle(e,t){t!=null&&(this._styles[e]=t,this._cacheMap.set(JSON.stringify(t),e))}remove(e){let t=this._styles[e];t&&(delete this._styles[e],this._cacheMap.delete(JSON.stringify(t)))}toJSON(){return this._styles}getStyleByCell(e){let t;t=e&&D.isObject(e.s)?e.s:(e==null?void 0:e.s)&&this.get(e.s);let n=e==null?void 0:e.interceptorStyle;return n?{...t,...n}:t}_generateCacheMap(){let{_styles:e,_cacheMap:t}=this;for(let n in e){let r=JSON.stringify(e[n]);t.set(r,n)}}_getExistingStyleId(e){let{_styles:t}=this;for(let n in t)if(D.diffValue(t[n],e))return n;return null}};const Fl=(e,t)=>t.length===e.length&&!e.some(e=>t.some(t=>!G.equals(t,e))),Il=(e,t)=>t.length===e.length&&e.every((e,n)=>{let r=t[n];return r.unitId===e.unitId&&r.sheetId===e.sheetId&&G.equals(e.range,r.range)}),Ll={t:0,b:2,l:2,r:2},Rl=e=>({sbr:.6,sbo:e,spr:.6,spo:e});function zl(e,t,n={}){let r=e.length,{textRotation:i,paddingData:a,horizontalAlign:o=Yn.UNSPECIFIED,verticalAlign:s=Xn.UNSPECIFIED,wrapStrategy:c=Zn.UNSPECIFIED,cellValueType:l}=n,{t:u,r:d,b:f,l:p}=a||Ll,{vertexAngle:m,centerAngle:h}=ql(i);return new lc({id:`d`,body:{dataStream:`${e}\r
|
|
9
|
-
`,textRuns:[{ts:t,st:0,ed:r}],paragraphs:[{startIndex:r,paragraphStyle:{horizontalAlign:o}}],sectionBreaks:[{startIndex:r+1}]},documentStyle:{pageSize:{width:1/0,height:1/0},marginTop:u,marginBottom:f,marginRight:d,marginLeft:p,renderConfig:{horizontalAlign:o,verticalAlign:s,centerAngle:h,vertexAngle:m,wrapStrategy:c,cellValueType:l}},drawings:{},drawingsOrder:[]})}function Bl(e){if(!e)return{};let{tr:t,td:n,ht:r,vt:i,tb:a,pd:o}=e;return{textRotation:t,textDirection:n,horizontalAlign:r,verticalAlign:i,wrapStrategy:a,paddingData:o}}function Vl(e){if(!e)return{};let{ff:t,fs:n,it:r,bl:i,ul:a,st:o,ol:s,cl:c}=e,l={};return t&&(l.ff=t),n&&(l.fs=n),r&&(l.it=r),i&&(l.bl=i),a&&(l.ul=a),o&&(l.st=o),s&&(l.ol=s),c&&(l.cl=c),l}function Hl(e,t,n){var r;let i=e.getBody();if((r=i.customRanges)!=null&&r.some(e=>e.rangeType===or.HYPERLINK))return;let a=Z.customRange.add({ranges:[{startOffset:0,endOffset:i.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:or.HYPERLINK,body:i,properties:{url:t,refId:n}});a&&Y.apply(i,a.serialize())}function Ul(e){return e!=null}function Wl(){return{p:null,s:null,v:null,t:null,f:null,si:null,ref:null,xf:null}}function Gl(e){let t=W.ff,n=W.fs;if(!e){let e=`${n}pt ${t}`;return{fontCache:e,fontString:e,fontSize:n,originFontSize:n,fontFamily:t}}let r=Er.ITALIC;(e.it===0||e.it===void 0)&&(r=Er.NORMAL);let i=Er.BOLD;(e.bl===0||e.bl===void 0)&&(i=Er.NORMAL);let a=n;e.fs&&(a=Math.ceil(e.fs));let o=t;if(e.ff){let n=e.ff;n=n.replace(/"/g,``).replace(/'/g,``),n.indexOf(` `)>-1&&(n=`"${n}"`),n==null&&(n=t),o=n}let{va:s}=e,c=a;if(s===er.SUBSCRIPT||s===er.SUPERSCRIPT){let{sbr:e,spr:t}=Kl(o,c);c*=s===er.SUBSCRIPT?e:t}let l=`${r} ${i} ${c}pt ${o}`;return{fontCache:l,fontString:`${l}, "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif `,fontSize:c,originFontSize:a,fontFamily:o}}function Kl(e,t){return Rl(t)}function ql(e){let{a:t=0,v:n=A.FALSE}=e||{a:0,v:A.FALSE},r=0,i=t;return n===A.TRUE&&(r=90,i=90),{centerAngle:r,vertexAngle:i}}function Q(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e)){let t=e.length,n=Array(t);for(let r=0;r<t;r++)n[r]=Q(e[r]);return n}let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r];t[i]=Q(e[i])}return t}function Jl(e){if(e==null)return e;let t={};return e.p!==void 0&&(t.p=e.p===null?null:Q(e.p)),e.s!==void 0&&(e.s===null||typeof e.s==`string`?t.s=e.s:t.s=Q(e.s)),e.v!==void 0&&(t.v=e.v),e.t!==void 0&&(t.t=e.t),e.f!==void 0&&(t.f=e.f),e.ref!==void 0&&(t.ref=e.ref),e.xf!==void 0&&(t.xf=e.xf),e.si!==void 0&&(t.si=e.si),e.custom!==void 0&&(t.custom=e.custom===null?null:Q(e.custom)),t}function Yl(e){if(e==null)return e;let t={};return e.p!==void 0&&(t.p=e.p===null?null:Q(e.p)),e.s!==void 0&&(e.s===null||typeof e.s==`string`?t.s=e.s:t.s=Q(e.s)),e.v!==void 0&&(t.v=e.v),e.t!==void 0&&(t.t=e.t),e.f!==void 0&&(t.f=e.f),e.ref!==void 0&&(t.ref=e.ref),e.xf!==void 0&&(t.xf=e.xf),e.si!==void 0&&(t.si=e.si),e.custom!==void 0&&(t.custom=e.custom===null?null:Q(e.custom)),e.rowSpan!==void 0&&(t.rowSpan=e.rowSpan),e.colSpan!==void 0&&(t.colSpan=e.colSpan),e.displayV!==void 0&&(t.displayV=e.displayV),t}function Xl(e){let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r],a=Number(i),o=e[a];if(o===void 0)continue;let s={},c=Object.keys(o);for(let e=0,t=c.length;e<t;e++){let t=c[e],n=Number(t),r=o[n];r!=null&&(s[n]=Jl(r))}t[a]=s}return t}function Zl(e){let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r],a=Number(i),o=e[a];if(o===void 0)continue;let s={};`h`in o&&o.h!==void 0&&(s.h=o.h),`ia`in o&&o.ia!==void 0&&(s.ia=o.ia),`ah`in o&&o.ah!==void 0&&(s.ah=o.ah),`hd`in o&&o.hd!==void 0&&(s.hd=o.hd),`w`in o&&o.w!==void 0&&(s.w=o.w),`s`in o&&o.s!==void 0&&(o.s===null||typeof o.s==`string`?s.s=o.s:s.s=Q(o.s)),`custom`in o&&o.custom!==void 0&&(s.custom=o.custom===null?null:Q(o.custom)),t[a]=s}return t}function Ql(e){let t=e.length,n=Array(t);for(let r=0;r<t;r++){let t=e[r];n[r]={startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn,rangeType:t.rangeType,startAbsoluteRefType:t.startAbsoluteRefType,endAbsoluteRefType:t.endAbsoluteRefType}}return n}function $l(e){let t={id:e.id,name:e.name,tabColor:e.tabColor,hidden:e.hidden,rowCount:e.rowCount,columnCount:e.columnCount,zoomRatio:e.zoomRatio,scrollTop:e.scrollTop,scrollLeft:e.scrollLeft,defaultColumnWidth:e.defaultColumnWidth,defaultRowHeight:e.defaultRowHeight,showGridlines:e.showGridlines,rightToLeft:e.rightToLeft,freeze:{xSplit:e.freeze.xSplit,ySplit:e.freeze.ySplit,startRow:e.freeze.startRow,startColumn:e.freeze.startColumn},rowHeader:{width:e.rowHeader.width,hidden:e.rowHeader.hidden},columnHeader:{height:e.columnHeader.height,hidden:e.columnHeader.hidden},mergeData:Ql(e.mergeData),cellData:Xl(e.cellData),rowData:Zl(e.rowData),columnData:Zl(e.columnData)};return e.gridlinesColor!==void 0&&(t.gridlinesColor=e.gridlinesColor),e.defaultStyle!==void 0&&(e.defaultStyle===null||typeof e.defaultStyle==`string`?t.defaultStyle=e.defaultStyle:t.defaultStyle=Q(e.defaultStyle)),e.custom!==void 0&&(t.custom=e.custom===null?null:Q(e.custom)),t}var eu=class{constructor(e,t){this._config=e,C(this,`_columnData`,{}),this._columnData=t}getColumnData(){return this._columnData}getColVisible(e){let{_columnData:t}=this,n=t[e];return n?n.hd!==A.TRUE:!0}getColumnStyle(e){var t;return(t=this._columnData[e])==null?void 0:t.s}setColumnStyle(e,t){let n=this.getColumnOrCreate(e);n.s=t}getHiddenCols(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getColVisible(a);r&&e?(r=!1,n.push({rangeType:B.COLUMN,startColumn:i,endColumn:a-1,startRow:0,endRow:0})):!r&&!e&&(r=!0,i=a)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:t,rangeType:B.COLUMN}),n}getVisibleCols(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getColVisible(a);r&&!e?(r=!1,n.push({rangeType:B.COLUMN,startColumn:i,endColumn:a-1,startRow:0,endRow:0})):!r&&e&&(r=!0,i=a)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:t,rangeType:B.COLUMN}),n}getColumnDatas(e,t){let n={},r=0;for(let i=e;i<e+t;i++){let e=this.getColumn(i);n[r]=e==null?{w:this._config.defaultColumnWidth,hd:A.FALSE}:e,r++}return n}getSize(){return aa(this._columnData)}getColumnWidth(e){var t,n;return(t=(n=this._columnData[e])==null?void 0:n.w)==null?this._config.defaultColumnWidth:t}setColumnWidth(e,t){let n=this._columnData[e];t===this._config.defaultColumnWidth?n&&(delete n.w,Object.keys(n).length===0&&delete this._columnData[e]):this._columnData[e]=n?{...n,w:t}:{w:t}}getColumn(e){return this._columnData[e]}insertColumnsWithData(e,t,n){let r=t-e+1,i=Object.keys(this._columnData);for(let t=i.length-1;t>=0;t--){let n=Number(i[t]);n>=e&&(this._columnData[n+r]=this._columnData[n],delete this._columnData[n])}for(let r=e;r<=t;r++){let t=n==null?void 0:n[r-e];t!=null&&Object.keys(t).length>0&&(this._columnData[r]={...t})}}removeColumn(e){delete this._columnData[e]}getColumnOrCreate(e){let{_columnData:t}=this,n=t[e];if(n)return n;let r={};return this._columnData[e]=r,r}setCustomMetadata(e,t){let n=this.getColumn(e);n&&(n.custom=t)}getCustomMetadata(e){var t;return(t=this.getColumn(e))==null?void 0:t.custom}},tu=class{constructor(e,t,n){this._config=e,this._viewModel=t,C(this,`_rowData`,void 0),this._rowData=n}getRowData(){return this._rowData}getRowStyle(e){var t;return(t=this._rowData[e])==null?void 0:t.s}setRowStyle(e,t){let n=this.getRowOrCreate(e);n.s=t}getRowDatas(e,t){let n={},r=0;for(let i=e;i<e+t;i++){let e=this.getRow(i);n[r]=e==null?{h:this._config.defaultRowHeight,hd:A.FALSE}:e,r++}return n}getRowHeight(e,t=1){let{_rowData:n}=this,r=this._config,i=0;for(let a=0;a<t;a++){let{ia:t,ah:o,h:s=r.defaultRowHeight}=n[a+e]||{hd:A.FALSE,h:r.defaultRowHeight};i+=(t==null||t===A.TRUE)&&typeof o==`number`?o:s}return i}setRowHeight(e,t){let n=this._rowData[e];if(t===this._config.defaultRowHeight)n&&(delete n.h,Object.keys(n).length===0&&delete this._rowData[e]);else{let r=Math.min(t,2e3);this._rowData[e]=n?{...n,h:r}:{h:r}}}getRow(e){return this._rowData[e]}insertRowsWithData(e,t,n){let r=t-e+1,i=Object.keys(this._rowData);for(let t=i.length-1;t>=0;t--){let n=Number(i[t]);n>=e&&(this._rowData[n+r]=this._rowData[n],delete this._rowData[n])}for(let r=e;r<=t;r++){let t=n==null?void 0:n[r-e];t!=null&&Object.keys(t).length>0&&(this._rowData[r]={...t})}}removeRow(e){delete this._rowData[e]}getRowOrCreate(e){let{_rowData:t}=this,n=t[e];if(n)return n;let r={};return t[e]=r,r}getHiddenRows(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getRowRawVisible(a);r&&e?(r=!1,n.push({startRow:i,endRow:a-1,startColumn:0,endColumn:0,rangeType:B.ROW})):!r&&!e&&(r=!0,i=a)}return r&&n.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:B.ROW}),n}getVisibleRows(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getRowRawVisible(a);r&&!e?(r=!1,n.push({startRow:i,endRow:a-1,startColumn:0,endColumn:0,rangeType:B.ROW})):!r&&e&&(r=!0,i=a)}return r&&n.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:B.ROW}),n}getRowRawVisible(e){let t=this.getRow(e);return t?t.hd!==A.TRUE:!0}getSize(){return aa(this._rowData)}setCustomMetadata(e,t){let n=this.getRow(e);n&&(n.custom=t)}getCustomMetadata(e){var t;return(t=this.getRow(e))==null?void 0:t.custom}};const nu=`DEFAULT_WORKSHEET_ROW_COUNT`,ru=1e3,iu=`DEFAULT_WORKSHEET_COLUMN_COUNT`,au=20,ou=`DEFAULT_WORKSHEET_ROW_HEIGHT`,su=24,cu=`DEFAULT_WORKSHEET_COLUMN_WIDTH`,lu=88,uu=`DEFAULT_WORKSHEET_ROW_TITLE_WIDTH`,du=46,fu=`DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT`,pu=20;function mu(e){let t={name:`Sheet1`,id:`sheet-01`,tabColor:``,hidden:A.FALSE,rowCount:ru,columnCount:20,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:88,defaultRowHeight:24,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:A.TRUE,rowHeader:{width:46,hidden:A.FALSE},columnHeader:{height:20,hidden:A.FALSE},rightToLeft:A.FALSE};return Object.keys(t).forEach(n=>{let r=n;e[r]===void 0&&(e[r]=t[r])}),e}var hu=class extends E{constructor(e){super(),C(this,`_cellCache`,new Map),C(this,`_rowCache`,new Map),C(this,`_columnCache`,new Map),C(this,`_hasRow`,!1),C(this,`_hasColumn`,!1),C(this,`_hasAll`,!1),C(this,`_allIndex`,-1),C(this,`_mergeData`,void 0),C(this,`_rangeMap`,new $a(5e4)),this._init(e.concat())}_init(e){this._mergeData=e,this._createCache(e)}_clearCache(){this._cellCache.clear(),this._rowCache.clear(),this._columnCache.clear(),this._hasAll=!1,this._allIndex=-1,this._rangeMap.clear(),this._hasColumn=!1,this._hasRow=!1}_createCache(e){let t=0;for(let n of e){let{rangeType:e}=n;e===B.ROW?this._createRowCache(n,t):e===B.COLUMN?this._createColumnCache(n,t):e===B.ALL?this._createCellAllCache(t):this._createCellCache(n,t),t++}}rebuild(e){this._clearCache(),this._init(e.concat())}_createRowCache(e,t){let{startRow:n,endRow:r}=e;for(let e=n;e<=r;e++)this._rowCache.set(e,t),this._hasRow=!0}_createColumnCache(e,t){let{startColumn:n,endColumn:r}=e;for(let e=n;e<=r;e++)this._columnCache.set(e,t),this._hasColumn=!0}_createCellAllCache(e){this._hasAll=!0,this._allIndex=e}_createCellCache(e,t){for(let n=e.startRow;n<=e.endRow;n++){let r=this._cellCache.get(n);r==null&&(r=new Map,this._cellCache.set(n,r));for(let n=e.startColumn;n<=e.endColumn;n++)r.set(n,t)}}add(e){this._mergeData.push(e),this._clearCache(),this._createCache(this._mergeData)}remove(e,t){let n=this._getMergeDataIndex(e,t);n!==-1&&(this._mergeData.splice(n,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(e,t){let n=this._getMergeDataIndex(e,t);return n===-1?null:this._mergeData[n]}getMergeDataIndex(e,t){return this._getMergeDataIndex(e,t)}isRowContainsMergedCell(e){return this._hasAll||!D.isEmptyObject(this._columnCache)?!0:this._mergeData.some(t=>t.startRow<=e&&e<=t.endRow)}isColumnContainsMergedCell(e){return this._hasAll||!D.isEmptyObject(this._rowCache)?!0:this._mergeData.some(t=>t.startColumn<=e&&e<=t.endColumn)}getMergedCellRange(e,t,n,r){let i=[],a=`${e}-${t}-${n}-${r}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let o=0,s=[];for(let a of this._mergeData||[])G.intersects(a,{startRow:e,endRow:n,startColumn:t,endColumn:r})&&(i.push({...a}),s.push(o)),o++;return this._rangeMap.set(a,s),i}_getRangeFromCache(e){let t=this._rangeMap.get(e)||[],n=[];for(let e of t)n.push({...this._mergeData[e]});return n}_getMergeDataIndex(e,t){var n;if(this._hasAll)return this._allIndex;if(this._hasRow){let t=this._rowCache.get(e);if(t!==void 0)return t}if(this._hasColumn){let e=this._columnCache.get(t);if(e!==void 0)return e}let r=(n=this._cellCache.get(e))==null?void 0:n.get(t);return r===void 0?-1:r}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}},gu=class extends E{constructor(e){super(),this.getRawCell=e,C(this,`_cellContentInterceptor`,null),C(this,`_rowFilteredInterceptor`,null)}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(e,t,n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,At.Value|At.Style,n,r):this.getRawCell(e,t)}getCellValueOnly(e,t){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,At.Value):this.getRawCell(e,t)}getCellStyleOnly(e,t){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,At.Style):this.getRawCell(e,t)}getRowFiltered(e){var t,n;return(t=(n=this._rowFilteredInterceptor)==null?void 0:n.getRowFiltered(e))==null?!1:t}registerCellContentInterceptor(e){if(this._cellContentInterceptor)throw Error(`[SheetViewModel]: Interceptor already registered.`);return this._cellContentInterceptor=e,T(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(e){if(this._rowFilteredInterceptor)throw Error(`[SheetViewModel]: Interceptor already registered.`);return this._rowFilteredInterceptor=e,T(()=>this._rowFilteredInterceptor=null)}};const _u={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};var vu=class e{constructor(e,t,n){var r;this.unitId=e,this._styles=n,C(this,`_sheetId`,void 0),C(this,`_snapshot`,void 0),C(this,`_cellData`,void 0),C(this,`_rowManager`,void 0),C(this,`_columnManager`,void 0),C(this,`_viewModel`,void 0),C(this,`_spanModel`,void 0),C(this,`_isRowStylePrecedeColumnStyle`,!0),C(this,`_getCellHeight`,void 0),this._snapshot=mu(t);let{columnData:i,rowData:a,cellData:o}=this._snapshot;this._sheetId=(r=this._snapshot.id)==null?O(6):r,this._cellData=new ma(o),this._viewModel=new gu((e,t)=>this.getCellRaw(e,t)),this._rowManager=new tu(this._snapshot,this._viewModel,a),this._columnManager=new eu(this._snapshot,i),this._spanModel=new hu(this._snapshot.mergeData)}__interceptViewModel(e){e(this._viewModel)}__registerGetCellHeight(e){return this._getCellHeight=e,T(()=>{this._getCellHeight=null})}getSnapshot(){return this._snapshot}getCellHeight(e,t){return this._getCellHeight?this._getCellHeight(e,t):this._snapshot.defaultRowHeight}setMergeData(e){this._snapshot.mergeData=e,this.getSpanModel().rebuild(e)}getSpanModel(){return this._spanModel}setIsRowStylePrecedeColumnStyle(e){this._isRowStylePrecedeColumnStyle=e}getStyleDataByHash(e){return{...this._styles.get(e)}}setStyleData(e){return this._styles.setValue(e)}getColumnStyle(e,t=!1){return t?this._columnManager.getColumnStyle(e):this._styles.get(this._columnManager.getColumnStyle(e))}setColumnStyle(e,t){this._columnManager.setColumnStyle(e,t)}getRowStyle(e,t=!1){return t?this._rowManager.getRowStyle(e):this._styles.get(this._rowManager.getRowStyle(e))}setRowStyle(e,t){this._rowManager.setRowStyle(e,t)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){let e=this._snapshot.defaultStyle;return this._styles.get(e)}setDefaultCellStyle(e){this._snapshot.defaultStyle=e}getCellStyle(e,t){let n=this.getCell(e,t);if(n){let e=n.s;return typeof e==`string`?this._styles.get(e):e}return null}getComposedCellStyle(e,t,n){let r=this.getDefaultCellStyleInternal(),i=this.getRowStyle(e),a=this.getColumnStyle(t),o=this.getCell(e,t),s=this._styles.getStyleByCell(o);return(n==null?this._isRowStylePrecedeColumnStyle:n)?wn(r,a,i,o==null?void 0:o.themeStyle,s):wn(r,i,a,o==null?void 0:o.themeStyle,s)}getComposedCellStyleByCellData(e,t,n,r){let i=this.getDefaultCellStyleInternal(),a=this.getRowStyle(e),o=this.getColumnStyle(t),s=this._styles.getStyleByCell(n);return(r==null?this._isRowStylePrecedeColumnStyle:r)?wn(i,o,a,n==null?void 0:n.themeStyle,s):wn(i,a,o,n==null?void 0:n.themeStyle,s)}getComposedCellStyleWithoutSelf(e,t,n,r){let i=n===void 0?this.getComposedCellStyle(e,t,r):this.getComposedCellStyleByCellData(e,t,n,r),a=this.getCellRaw(e,t);if(!a||!a.s)return i;let o=typeof a.s==`string`?this._styles.get(a.s):a.s;if(!o)return i;for(let e in o)e in i&&delete i[e];return i}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){let e=this.getCellMatrix(),t=this.getMergeData(),n=-1,r=-1,i=-1,a=-1,o=!1,s=!1;return e.forEach((t,c)=>{Object.keys(c).forEach(c=>{let l=+c,u=e.getValue(t,l),d=u!=null&&u.s?this._styles.get(u.s):null,f=(d==null?void 0:d.bd)&&(d.bd.b||d.bd.l||d.bd.r||d.bd.t||d.bd.bc_tr||d.bd.bl_tr||d.bd.ml_tr||d.bd.tl_bc||d.bd.tl_br||d.bd.tl_mr);(u&&(u.v!==null&&u.v!==void 0&&u.v!==``||u.p)||d!=null&&d.bg||f)&&(o?n=Math.min(n,t):(n=t,o=!0),r=Math.max(r,t),s?i=Math.min(i,l):(s=!0,i=l),a=Math.max(a,l))})}),t.forEach(e=>{o?n=Math.min(n,e.startRow):(n=e.startRow,o=!0),r=Math.max(r,e.endRow),s?i=Math.min(i,e.startColumn):(i=e.startColumn,o=!0),a=Math.max(a,e.endColumn)}),!o||!s?null:{startColumn:i,startRow:n,endColumn:a,endRow:r}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){let{_snapshot:t}=this,n=$l(t);return new e(this.unitId,n,this._styles)}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(e,t){return this._spanModel.getMergedCell(e,t)}getMergedCellRange(e,t,n,r){return this._spanModel.getMergedCellRange(e,t,n,r)}isRowContainsMergedCell(e){return this._spanModel.isRowContainsMergedCell(e)}isColumnContainsMergedCell(e){return this._spanModel.isColumnContainsMergedCell(e)}getCellInfoInMergeData(e,t){let n=this.getMergedCell(e,t),r=!1,i=!1,a=e,o=t,s=e,c=t;if(n){let{startRow:l,endRow:u,startColumn:d,endColumn:f}=n;e===l&&t===d?(a=u,o=f,s=l,c=d,i=!0):e>=l&&e<=u&&t>=d&&t<=f&&(a=u,o=f,s=l,c=d,r=!0)}return{actualRow:e,actualColumn:t,isMergedMainCell:i,isMerged:r,endRow:a,endColumn:o,startRow:s,startColumn:c}}getCell(e,t){return e<0||t<0?null:this._viewModel.getCell(e,t)}getCellValueOnly(e,t){return e<0||t<0?null:this._viewModel.getCellValueOnly(e,t)}getCellStyleOnly(e,t){return e<0||t<0?null:this._viewModel.getCellStyleOnly(e,t)}getCellRaw(e,t){return this.getCellMatrix().getValue(e,t)}getCellWithFilteredInterceptors(e,t,n,r){return this._viewModel.getCell(e,t,n,r)}getRowFiltered(e){return this._viewModel.getRowFiltered(e)}getRangeFilterRows(e){let t=[];for(let n=e.startRow;n<=e.endRow;n++)this.getRowFiltered(n)&&t.push(n);return t}getMatrixWithMergedCells(e,t,n,r,i=Ki.Raw){let a=this.getCellMatrix(),o=this._spanModel.getMergedCellRange(e,t,n,r),s=new ma;return Fo(e,n,t,r).forEach((e,t)=>{let n;if(i===Ki.Raw)n=this.getCellRaw(e,t);else if(i===Ki.Intercepted)n=this.getCell(e,t);else if(i===Ki.Both){let i=this.getCellRaw(e,t);if(i){var r;n={...i};let a=(r=this.getCell(e,t))==null?void 0:r.v;Ul(a)&&n&&(n.displayV=String(a))}}n&&s.setValue(e,t,n)}),o.forEach(e=>{let{startColumn:t,startRow:n,endColumn:r,endRow:i}=e;Fo(n,i,t,r).forEach((e,o)=>{e===n&&o===t&&s.setValue(e,o,{...a.getValue(e,o),rowSpan:i-n+1,colSpan:r-t+1}),(e!==n||o!==t)&&s.realDeleteValue(e,o)})}),s}getRange(e,t,n,r){return typeof e==`object`?new vo(this,e,{getStyles:()=>this._styles}):new vo(this,{startRow:e,startColumn:t,endColumn:r||t,endRow:n||e},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){let{_snapshot:e}=this,{columnCount:t}=e;return t}getMaxRows(){let{_snapshot:e}=this,{rowCount:t}=e;return t}getRowCount(){return this._snapshot.rowCount}setRowCount(e){this._snapshot.rowCount=e}getColumnCount(){return this._snapshot.columnCount}setColumnCount(e){this._snapshot.columnCount=e}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){let{_snapshot:e}=this,{showGridlines:t}=e;return t===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){let{_snapshot:e}=this,{tabColor:t}=e;return t}getColumnWidth(e){return this.getColumnManager().getColumnWidth(e)}getRowHeight(e){return this._viewModel.getRowFiltered(e)?0:this.getRowManager().getRowHeight(e)}isRowFiltered(e){return this._viewModel.getRowFiltered(e)}getRowVisible(e){return!this.isRowFiltered(e)&&this.getRowRawVisible(e)}getRowRawVisible(e){return this.getRowManager().getRowRawVisible(e)}getHiddenRows(e,t){let n=this.getMaxColumns()-1,r=this._rowManager.getHiddenRows(e,t);return r.forEach(e=>e.endColumn=n),r}getColVisible(e){return this._columnManager.getColVisible(e)}getHiddenCols(e,t){let n=this.getMaxRows()-1,r=this._columnManager.getHiddenCols(e,t);return r.forEach(e=>e.endRow=n),r}getVisibleRows(){let e=this.getRowCount();return this._rowManager.getVisibleRows(0,e-1)}getVisibleCols(){let e=this.getColumnCount();return this._columnManager.getVisibleCols(0,e-1)}isRightToLeft(){let{_snapshot:e}=this,{rightToLeft:t}=e;return t}getLastRowWithContent(){return this._cellData.getRealRowRange().endRow}getLastColumnWithContent(){return this.getDataRealRange().endColumn}getDataRealRange(){return this._cellData.getRealRange()}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(e){return e&&(e.v!==void 0||e.f!==void 0||e.p!==void 0)}iterateByRow(e,t=!0){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e,o=this;return{[Symbol.iterator]:()=>{let e=n,s=r;return{next(){for(;;){if(s>a&&(e+=1,s=r),e>i)return{done:!0,value:void 0};let n=o.getCell(e,s),c=!n,l=o.getMergedCell(e,s);if(l){if(e!==l.startRow||s!==l.startColumn){s=l.endColumn+1;continue}if(c&&t){s=l.endColumn+1;continue}let r={row:e,col:s,value:n};return r.colSpan=l.endColumn-l.startColumn+1,r.rowSpan=l.endRow-l.startRow+1,s=l.endColumn+1,{done:!1,value:r}}if(c&&t)s+=1;else{let t={row:e,col:s,value:n};return s+=1,{done:!1,value:t}}}}}}}}iterateByColumn(e,t=!0,n=!0){let{startRow:r,startColumn:i,endRow:a,endColumn:o}=e,s=this;return{[Symbol.iterator]:()=>{let e=r,c=i;return{next(){for(;;){if(e>a&&(c+=1,e=r),c>o)return{done:!0,value:void 0};let i=s.getMergedCell(e,c);if(i){let r=e!==i.startRow,a=r||c!==i.startColumn;if(n&&a||!n&&r){e=i.endRow+1;continue}let o=s.getCell(i.startRow,i.startColumn);if(!o&&t){e=i.endRow+1;continue}let l={row:e,col:i.startColumn,value:o};return l.colSpan=i.endColumn-i.startColumn+1,l.rowSpan=i.endRow-i.startRow+1,e=i.endRow+1,{done:!1,value:l}}let l=s.getCell(e,c);if(!l&&t)e+=1;else{let t={row:e,col:c,value:l};return e+=1,{done:!1,value:t}}}}}}}}getCellDocumentModel(e,t,n=_u){var r;if(!e)return;let{isDeepClone:i,displayRawFormula:a,ignoreTextRotation:o}={..._u,...n},s,c=`document`,l=Bl(t),u=o?W.tr:l.textRotation||W.tr,d=l.horizontalAlign||W.ht,f=l.verticalAlign||W.vt,p=l.wrapStrategy||W.tb,m=l.paddingData||Ll;if(e.f&&a)s=zl(e.f.toString(),{},{verticalAlign:f}),d=W.ht;else if(e.p){let{centerAngle:t,vertexAngle:n}=ql(u);s=this._updateConfigAndGetDocumentModel(i?D.deepClone(e.p):e.p,d,m,{horizontalAlign:d,verticalAlign:f,centerAngle:t,vertexAngle:n,wrapStrategy:p,zeroWidthParagraphBreak:1})}else if(e.v!=null){let n=Vl(t);c=Gl(n).fontCache;let r=yu(e);e.t===tr.FORCE_STRING&&a&&(r=`'${r}`),s=zl(r,n,{...l,textRotation:u,cellValueType:e.t})}return s&&e.linkUrl&&e.linkId&&Hl(s,e.linkUrl,e.linkId),{documentModel:s,fontString:c,textRotation:u,wrapStrategy:p,verticalAlign:f,horizontalAlign:d,paddingData:m,fill:t==null||(r=t.bg)==null?void 0:r.rgb}}_updateConfigAndGetDocumentModel(e,t,n,r){var i,a,o,s,c;if(!r||!((i=e.body)!=null&&i.dataStream))return;e.documentStyle||(e.documentStyle={}),e.documentStyle.marginTop=(a=n.t)==null?0:a,e.documentStyle.marginBottom=(o=n.b)==null?2:o,e.documentStyle.marginLeft=(s=n.l)==null?2:s,e.documentStyle.marginRight=(c=n.r)==null?2:c,e.documentStyle.pageSize={width:1/0,height:1/0},e.documentStyle.renderConfig={...e.documentStyle.renderConfig,...r};let l=e.body.paragraphs||[];for(let e of l)e.paragraphStyle||(e.paragraphStyle={}),e.paragraphStyle.horizontalAlign=t;return new lc(e)}getBlankCellDocumentModel(e,t,n){let r=this.getComposedCellStyleByCellData(t,n,e),i=Vl(r),a=this.getCellDocumentModel(e,r,{ignoreTextRotation:!0});if(a!=null)return a.documentModel==null&&(a.documentModel=zl(``,i)),a;let o=`document`,s=W.tr,c=W.ht,l=W.vt,u=W.tb,d=Ll;return o=Gl({}).fontCache,{documentModel:zl(``,i),fontString:o,textRotation:s,wrapStrategy:u,verticalAlign:l,horizontalAlign:c,paddingData:d}}getCellDocumentModelWithFormula(e,t,n){let r=this.getComposedCellStyleByCellData(t,n,e);return this.getCellDocumentModel(e,r,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(e){this._snapshot.custom=e}};function yu(e){var t;if(!e)return``;let n=(t=e.p)==null||(t=t.body)==null?void 0:t.dataStream;if(n)return Z.transform.getPlainText(n);let r=e.v;return typeof r==`string`?e.t===tr.BOOLEAN?r.toUpperCase():r.replace(/[\r\n]/g,``):typeof r==`number`?e.t===tr.BOOLEAN?r?`TRUE`:`FALSE`:r.toString():typeof r==`boolean`?r?`TRUE`:`FALSE`:``}function bu(e){if(e===null)return``;if(e!=null&&e.p){let t=e==null?void 0:e.p.body;if(t==null)return``;let n=t.dataStream;return Z.transform.getPlainText(n)}return e==null?void 0:e.v}function xu(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}let Su=class extends pn{get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(e){return typeof e==`string`||`startRow`in e||`row`in e}constructor(e={},t){super(),this._logService=t,C(this,`type`,x.UNIVER_SHEET),C(this,`_sheetCreated$`,new y),C(this,`sheetCreated$`,this._sheetCreated$.asObservable()),C(this,`_sheetDisposed$`,new y),C(this,`sheetDisposed$`,this._sheetDisposed$.asObservable()),C(this,`_activeSheet$`,new v(null)),C(this,`activeSheet$`,this._activeSheet$.asObservable()),C(this,`_worksheets`,void 0),C(this,`_styles`,void 0),C(this,`_snapshot`,void 0),C(this,`_unitId`,void 0),C(this,`_count`,void 0),C(this,`_name$`,void 0),C(this,`name$`,void 0);let n=Nl();D.isEmptyObject(e)?this._snapshot=n:this._snapshot=D.commonExtend(n,e);let{styles:r}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=O(6)),this._unitId=this._snapshot.id,this._styles=new Pl(r),this._count=1,this._worksheets=new Map,this._name$=new v(e.name||``),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete(),Array.from(this._worksheets.keys()).forEach(e=>{this._removeSheet(e)})}save(){return D.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(e){this._name$.next(e),this._snapshot.name=e}getUnitId(){return this._unitId}getRev(){var e;return(e=this._snapshot.rev)==null?1:e}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(e){this._snapshot.rev=e}addWorksheet(e,t,n){let{sheets:r,sheetOrder:i}=this._snapshot;if(r[e])return!1;r[e]=n,i.splice(t,0,e),this.ensureSheetOrderUnique();let a=new vu(this._unitId,n,this._styles);return this._worksheets.set(e,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}ensureSheetOrderUnique(){let e=new Set,t=[];for(let n of this._snapshot.sheetOrder)e.has(n)||(e.add(n),t.push(n));this._snapshot.sheetOrder=t,e.clear()}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}addStyles(e){Object.entries(e).forEach(([e,t])=>{this._styles.addCustomStyle(e,t)})}removeStyles(e){e.forEach(e=>{this._styles.remove(e)})}getConfig(){return this._snapshot}getIndexBySheetId(e){let{sheetOrder:t}=this._snapshot;return t.findIndex(t=>t===e)}getActiveSheet(e){if(!this._activeSheet&&e===void 0)throw Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){let e=this._activeSheet;if(e)return e;let t=this._snapshot.sheetOrder;for(let e=0,n=t.length;e<n;e++){let n=this._worksheets.get(t[e]);if(n&&n.isSheetHidden()!==A.TRUE)return this.setActiveSheet(n),n}let n=this._worksheets.get(t[0]);return this.setActiveSheet(n),n}setActiveSheet(e){this._activeSheet$.next(e)}_removeSheet(e){let t=this._worksheets.get(e);return t?(this._worksheets.delete(e),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(e),1),this.ensureSheetOrderUnique(),this._sheetDisposed$.next(t),!0):!1}removeSheet(e){let t=this._removeSheet(e);return t&&delete this._snapshot.sheets[e],t}getActiveSheetIndex(){let{sheetOrder:e}=this._snapshot;return e.findIndex(e=>this._worksheets.get(e)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){let{sheetOrder:e}=this._snapshot;return e.map(e=>this._worksheets.get(e))}getSheetsName(){let{sheetOrder:e}=this._snapshot,t=[];return e.forEach(e=>{let n=this._worksheets.get(e);n&&t.push(n.getName())}),t}getSheetIndex(e){let{sheetOrder:t}=this._snapshot;return t.findIndex(t=>e.getSheetId()===t)}getSheetBySheetName(e){let{sheetOrder:t}=this._snapshot,n=t.find(t=>this._worksheets.get(t).getName()===e);return this._worksheets.get(n)}getSheetBySheetId(e){return this._worksheets.get(e)}getSheetByIndex(e){let{sheetOrder:t}=this._snapshot;return this._worksheets.get(t[e])}getHiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden===A.TRUE).map(e=>e.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden!==A.TRUE).map(e=>e.getConfig().id)}load(e){this._snapshot=e}checkSheetName(e){return this.getSheetsName().some(t=>t.toLowerCase()===e.toLowerCase())}uniqueSheetName(e=`Sheet1`){let t=e;for(;this.checkSheetName(t);)t=e+this._count,this._count++;return t}generateNewSheetName(e){let t=e+this._count;for(;this.checkSheetName(t);)t=e+this._count,this._count++;return t}_parseWorksheetSnapshots(){let{_snapshot:e,_worksheets:t}=this,{sheets:n,sheetOrder:r}=e;if(D.isEmptyObject(n)){let e=O();n[e]={id:e}}for(let e in n){let i=n[e],{name:a}=i;i.name=this.uniqueSheetName(a),i.name!==a&&this._logService.debug(`[Workbook]`,`The worksheet name ${a} is duplicated, we changed it to ${i.name}. Please fix the problem in your snapshot.`);let o=new vu(this._unitId,i,this._styles);t.set(e,o),r.includes(e)||r.push(e)}this.ensureSheetOrderUnique(),this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(e){this._snapshot.custom=e}};Su=z([R(1,L)],Su);var Cu=class extends pn{get _activePage(){let e=this._activePage$.getValue();if(!e){var t,n;let e=(t=this.getPageOrder())==null?void 0:t[0];return e?(n=this.getPages())==null?void 0:n[e]:null}return e}constructor(e){var t;super(),C(this,`type`,x.UNIVER_SLIDE),C(this,`_activePage$`,new v(null)),C(this,`activePage$`,this._activePage$.asObservable()),C(this,`_name$`,void 0),C(this,`name$`,void 0),C(this,`_snapshot`,void 0),C(this,`_unitId`,void 0),this._snapshot={...co,...e},this._unitId=(t=this._snapshot.id)==null?O(6):t,this._name$=new v(this._snapshot.title),this.name$=this._name$.asObservable()}setName(e){var t;this._snapshot.title=e,this._name$.next(e),this._unitId=(t=this._snapshot.id)==null?O(6):t}getRev(){return 0}incrementRev(){}setRev(e){}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var e;return(e=this._snapshot.body)==null?void 0:e.pages}getPageOrder(){var e;return(e=this._snapshot.body)==null?void 0:e.pageOrder}getPage(e){let t=this.getPages();return t==null?void 0:t[e]}getElementsByPage(e){var t;return(t=this.getPage(e))==null?void 0:t.pageElements}getElement(e,t){var n;return(n=this.getElementsByPage(e))==null?void 0:n[t]}getPageSize(){return this._snapshot.pageSize}getBlankPage(){let e=O(6);return{id:e,pageType:Lr.SLIDE,zIndex:10,title:e,description:``,pageBackgroundFill:{rgb:`rgb(255,255,255)`},pageElements:{}}}setActivePage(e){this._activePage$.next(e)}getActivePage(){return this._activePage}updatePage(e,t){this._snapshot.body&&(this._snapshot.body.pages[e]=t)}appendPage(e){var t;if(!this._snapshot.body)return;this._snapshot.body.pages[e.id]=e;let n=this._activePage,r=this._snapshot.body.pageOrder.indexOf((t=n==null?void 0:n.id)==null?``:t);this._snapshot.body.pageOrder.splice(r+1,0,e.id)}};const wu=m(`univer.current`);let Tu=class extends E{constructor(e,t,n){super(),this._injector=e,this._contextService=t,this._logService=n,C(this,`_unitsByType`,new Map),C(this,`_createHandler`,void 0),C(this,`_ctorByType`,new Map),C(this,`_currentUnits`,new Map),C(this,`_currentUnits$`,new v(this._currentUnits)),C(this,`currentUnits$`,this._currentUnits$.asObservable()),C(this,`_unitAdded$`,new y),C(this,`unitAdded$`,this._unitAdded$.asObservable()),C(this,`_unitDisposed$`,new y),C(this,`unitDisposed$`,this._unitDisposed$.asObservable()),C(this,`_focused$`,new v(null)),C(this,`focused$`,this._focused$.asObservable())}dispose(){super.dispose(),this._focused$.complete(),this._currentUnits$.complete(),this._unitAdded$.complete(),this._currentUnits.forEach(e=>e==null?void 0:e.dispose()),this._currentUnits.clear(),this._unitsByType.clear()}__setCreateHandler(e){this._createHandler=e}createUnit(e,t,n){return this._createHandler(e,t,this._ctorByType.get(e),n)}registerCtorForType(e,t){return this._ctorByType.set(e,t),{dispose:()=>{this._ctorByType.delete(e)}}}getCurrentTypeOfUnit$(e){return this.currentUnits$.pipe(be(t=>{var n;return(n=t.get(e))==null?null:n}),_e())}getCurrentUnitForType(e){return this._currentUnits.get(e)}getCurrentUnitOfType(e){return this.getCurrentUnitForType(e)}setCurrentUnitForType(e){let t=this._getUnitById(e);if(!t)throw Error(`[UniverInstanceService]: no document with unitId ${e}!`);this._currentUnits.set(t[1],t[0]),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(e){return this._unitAdded$.pipe(ve(t=>t.type===e))}__addUnit(e,t){var n;this._logService.debug(`[UniverInstanceService]: Adding unit with id ${e.getUnitId()}`);let r=e.type;this._unitsByType.has(r)||this._unitsByType.set(r,[]);let i=this._unitsByType.get(r),a=e.getUnitId();if(i.findIndex(e=>e.getUnitId()===a)!==-1)throw Error(`[UniverInstanceService]: cannot create a unit with the same unit id: ${a}.`);i.push(e),this._unitAdded$.next(e),((n=t==null?void 0:t.makeCurrent)==null||n)&&this.setCurrentUnitForType(e.getUnitId())}getTypeOfUnitDisposed$(e){return this.unitDisposed$.pipe(ve(t=>t.type===e))}getUnit(e,t){var n;let r=(n=this._getUnitById(e))==null?void 0:n[0];return t&&(r==null?void 0:r.type)!==t?null:r}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(x.UNIVER_DOC)}getUniverDocInstance(e){return this.getUnit(e,x.UNIVER_DOC)}getUniverSheetInstance(e){return this.getUnit(e,x.UNIVER_SHEET)}getAllUnitsForType(e){var t;return(t=this._unitsByType.get(e))==null?[]:t}changeDoc(e,t){let n=this.getAllUnitsForType(x.UNIVER_DOC),r=n.find(t=>t.getUnitId()===e);if(r!=null){let e=n.indexOf(r);n.splice(e,1)}this.__addUnit(t)}get focused(){var e;let t=this._focused$.getValue();return t?(e=this._getUnitById(t))==null?void 0:e[0]:null}focusUnit(e){this._focused$.next(e),this.focused instanceof Su?(this._contextService.setContextValue(ul,!0),this._contextService.setContextValue(fl,!1),this._contextService.setContextValue(dl,!0),this._contextService.setContextValue(pl,!1),this.setCurrentUnitForType(e)):this.focused instanceof lc?(this._contextService.setContextValue(ul,!0),this._contextService.setContextValue(fl,!0),this._contextService.setContextValue(dl,!1),this._contextService.setContextValue(pl,!1),this.setCurrentUnitForType(e)):this.focused instanceof Cu?(this._contextService.setContextValue(ul,!0),this._contextService.setContextValue(fl,!1),this._contextService.setContextValue(dl,!1),this._contextService.setContextValue(pl,!0),this.setCurrentUnitForType(e)):(this._contextService.setContextValue(ul,!1),this._contextService.setContextValue(fl,!1),this._contextService.setContextValue(dl,!1),this._contextService.setContextValue(pl,!1))}getFocusedUnit(){return this.focused}getUnitType(e){let t=this._getUnitById(e);return t?t[1]:x.UNRECOGNIZED}disposeUnit(e){this._logService.debug(`[UniverInstanceService]: Disposing unit with id ${e}`);let t=this._getUnitById(e);if(!t)return this._logService.debug(`[UniverInstanceService]: No unit found with id ${e}`),!1;let[n,r]=t,i=this._unitsByType.get(r),a=i.indexOf(n);return i.splice(a,1),this._tryResetCurrentOnRemoval(e,r),this._tryResetFocusOnRemoval(e),this._unitDisposed$.next(n),n.dispose(),!0}_tryResetCurrentOnRemoval(e,t){let n=this.getCurrentUnitForType(t);(n==null?void 0:n.getUnitId())===e&&(this._currentUnits.set(t,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(e){var t;((t=this.focused)==null?void 0:t.getUnitId())===e&&this._focused$.next(null)}_getUnitById(e){for(let[t,n]of this._unitsByType){let r=n.find(t=>t.getUnitId()===e);if(r)return[r,t]}}};Tu=z([R(0,t(i)),R(1,Ur),R(2,t(L))],Tu);let $=function(e){return e[e.Starting=0]=`Starting`,e[e.Ready=1]=`Ready`,e[e.Rendered=2]=`Rendered`,e[e.Steady=3]=`Steady`,e}({});const Eu={[$.Starting]:`Starting`,[$.Ready]:`Ready`,[$.Rendered]:`Rendered`,[$.Steady]:`Steady`};var Du=class extends Error{constructor(e){super(`[LifecycleService]: lifecycle stage "${Eu[e]}" will never be reached!`),this.name=`LifecycleUnreachableError`}};let Ou=class extends E{constructor(e){super(),this._logService=e,C(this,`_lifecycle$`,new v($.Starting)),C(this,`lifecycle$`,this._lifecycle$.asObservable()),C(this,`_lock`,!1),this._reportProgress($.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(e){if(this._lock)throw Error(`[LifecycleService]: cannot set new stage when related logic is all handled!`);if(e<this.stage)throw Error(`[LifecycleService]: lifecycle stage cannot go backward!`);e!==this.stage&&(this._lock=!0,this._reportProgress(e),this._lifecycle$.next(e),this._lock=!1)}dispose(){this._lifecycle$.complete(),super.dispose()}onStage(e){return ye(this.lifecycle$.pipe(ve(t=>t>=e),ii(t=>t===e),be(()=>void 0))).catch(t=>t.name===`EmptyError`?Promise.reject(new Du(e)):Promise.reject(t))}subscribeWithPrevious(){return xe(ku(this.stage),this._lifecycle$.pipe(Ce(1))).pipe(ii(e=>e===$.Steady))}_reportProgress(e){this._logService.debug(`[LifecycleService]`,`lifecycle progressed to "${Eu[e]}".`)}};Ou=z([R(0,L)],Ou);function ku(e){switch(e){case $.Starting:return Se($.Starting);case $.Ready:return Se($.Starting,$.Ready);case $.Rendered:return Se($.Starting,$.Ready,$.Rendered);default:return Se($.Starting,$.Ready,$.Rendered,$.Steady)}}const Au=m(`ILocalStorageService`);var ju=class extends E{get _currentLocale(){return this._currentLocale$.value}constructor(){super(),C(this,`_currentLocale$`,new v(Rn.ZH_CN)),C(this,`currentLocale$`,this._currentLocale$.asObservable()),C(this,`_locales`,null),C(this,`localeChanged$`,new y),C(this,`t`,(e,...t)=>{if(!this._locales)throw Error(`[LocaleService]: Locale not initialized`);let n=e.split(`.`),r=this.resolveKeyPath(this._locales[this._currentLocale],n);if(typeof r==`string`){let e=r;return t.forEach((t,n)=>{e=e.replace(`{${n}}`,t)}),e}else return e}),this.disposeWithMe(T(()=>{this._locales=null,this._currentLocale$.complete(),this.localeChanged$.complete()}))}load(e){var t;this._locales=le((t=this._locales)==null?{}:t,e)}setLocale(e){this._currentLocale$.next(e),this.localeChanged$.next()}getLocales(){var e;return(e=this._locales)==null?void 0:e[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(e,t){let n=t.shift();if(n&&e&&n in e){let r=e[n];return t.length>0&&(typeof r==`object`||Array.isArray(r))?this.resolveKeyPath(r,t):r}return null}};let Mu=class{constructor(e){this._userManagerService=e}async list(e){return{list:[{type:zn.PERSON,mentions:[{objectType:zn.PERSON,objectId:this._userManagerService.getCurrentUser().userID,label:this._userManagerService.getCurrentUser().name,metadata:{icon:this._userManagerService.getCurrentUser().avatar}}],metadata:{},title:`PEOPLE`}],page:e.page,size:e.size,total:1}}};Mu=z([R(0,n(al))],Mu);const Nu=h(`univer.service.mention-io`);let Pu=function(e){return e.INIT=`init`,e.FETCHING=`fetching`,e.DONE=`done`,e}({});const Fu=m(`univer.permission-service`);var Iu=class extends E{constructor(...e){super(...e),C(this,`_permissionPointMap`,new Map),C(this,`_permissionPointUpdate$`,new y),C(this,`permissionPointUpdate$`,this._permissionPointUpdate$.asObservable()),C(this,`_showComponents`,!0)}setShowComponents(e){this._showComponents=e}getShowComponents(){return this._showComponents}deletePermissionPoint(e){let t=this._permissionPointMap.get(e);t&&(t.complete(),this._permissionPointMap.delete(e))}addPermissionPoint(e){let t=e instanceof v,n=t?e.getValue():e;return n.id?this._permissionPointMap.get(n.id)?(console.warn(`${n.id} PermissionPoint already exists`),!1):(this._permissionPointMap.set(n.id,t?e:new v(n)),this._permissionPointUpdate$.next(n),!0):!1}updatePermissionPoint(e,t){let n=this._permissionPointMap.get(e);if(!n)return;let r=n.getValue();r.value=t,r.status=Pu.DONE,n.next(r),this._permissionPointUpdate$.next(r)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(e){let t=this._permissionPointMap.get(e);if(t)return t.getValue()}getPermissionPoint$(e){let t=this._permissionPointMap.get(e);if(t)return t}composePermission$(e){return he(e.map(e=>{var t;let n=(t=this._permissionPointMap)==null?void 0:t.get(e);if(!n)throw Error(`[PermissionService]: ${e} permissionPoint does not exist!`);return n.asObservable()})).pipe(Pe(e=>e))}composePermission(e){return e.map(e=>{var t;let n=(t=this._permissionPointMap)==null?void 0:t.get(e);if(!n)throw Error(`[PermissionService]: ${e} permissionPoint does not exist!`);return n.getValue()})}getAllPermissionPoint(){let e=new Map;return this._permissionPointMap.forEach((t,n)=>{e.set(n,t)}),e}};function Lu(e,t){if(!t)return e;let n=[];for(let r of e){let e=t.find(([e])=>e===r[0]);if(e){if(e[1]===null)continue;n.push([r[0],e[1]])}else n.push(r)}return n}const Ru=Symbol(`DependentOn`);var zu=class extends E{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}};C(zu,`pluginName`,void 0),C(zu,`packageName`,jl),C(zu,`version`,Ml),C(zu,`type`,x.UNIVER_UNKNOWN);var Bu=class{constructor(){C(this,`_plugins`,[])}addPlugin(e){this._plugins.push(e)}removePlugins(){let e=this._plugins.slice();return this._plugins.length=0,e}forEachPlugin(e){this._plugins.forEach(e)}};function Vu(...e){return function(t){t[Ru]=e}}let Hu=class{constructor(e,t,n){this._injector=e,this._lifecycleService=t,this._logService=n,C(this,`_pluginRegistry`,new Map),C(this,`_pluginStore`,new Bu),C(this,`_seenPlugins`,new Set),C(this,`_loadedPlugins`,new Set),C(this,`_loadedPluginTypes`,new Set([x.UNIVER_UNKNOWN])),C(this,`_flushTimerByType`,new Map)}dispose(){this._pluginStore.removePlugins().forEach(e=>e.dispose()),this._flushTimerByType.forEach(e=>clearTimeout(e))}registerPlugin(e,t){this._assertPluginValid(e);let n={plugin:e,options:t};this._pluginRegistry.set(e.pluginName,n),this._logService.debug(`[PluginService]`,`Plugin "${e.pluginName}" registered.`);let{type:r}=e;this._loadedPluginTypes.has(r)&&(r===x.UNIVER_UNKNOWN?this._loadFromPlugins([n]):this._flushType(r))}startPluginsForType(e){this._loadedPluginTypes.has(e)||this._loadPluginsForType(e)}_loadPluginsForType(e){let t=Array.from(this._pluginRegistry.keys()),n=[];t.forEach(t=>{let r=this._pluginRegistry.get(t);r.plugin.type===e&&n.push(r)}),this._loadFromPlugins(n),this._loadedPluginTypes.add(e)}_assertPluginValid(e){let{type:t,pluginName:n,packageName:r,version:i}=e;if(t===x.UNRECOGNIZED)throw Error(`[PluginService]: invalid plugin type for ${e.name}. Please assign a "type" to your plugin.`);if(!n)throw Error(`[PluginService]: no plugin name for ${e.name}. Please assign a "pluginName" to your plugin.`);if(i&&i!==zu.version)throw Error(`[PluginService]: package "${r==null?`UNKNOWN`:r}" version mismatch. Plugin version is "${i}" but @univerjs/core version is "${zu.version}". Please make sure all @univerjs packages use the same version.`);if(this._seenPlugins.has(n))throw Error(`[PluginService]: duplicated plugin name for "${n}". Maybe a plugin that dependents on "${n} has already registered it. In that case please register "${n}" before the that plugin.`);this._seenPlugins.add(e.pluginName)}_flushType(e){this._flushTimerByType.get(e)===void 0&&this._flushTimerByType.set(e,setTimeout(()=>{this._loadPluginsForType(e),this._flushTimerByType.delete(e)},4))}_loadFromPlugins(e){let t=[],n=new Set,r=e=>{let{plugin:i}=e,{pluginName:a}=i;if(this._loadedPlugins.has(a)||n.has(a))return;n.add(a),this._pluginRegistry.delete(a);let o=i[Ru];o&&o.forEach(e=>{let t=this._pluginRegistry.get(e.pluginName);if(t)r(t);else if(!this._seenPlugins.has(e.pluginName)&&!n.has(e.pluginName)){if(i.type===x.UNIVER_UNKNOWN&&e.type!==x.UNIVER_UNKNOWN)throw Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${i.pluginName} and the dependency is ${e.pluginName}.`);i.type!==e.type&&e.type!==x.UNIVER_UNKNOWN&&this._logService.debug(`[PluginService]`,`Plugin "${a}" depends on "${e.pluginName}" which has different type.`),this._logService.debug(`[PluginService]`,`Plugin "${a}" depends on "${e.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(e),r({plugin:e,options:void 0})}}),t.push(e)};e.forEach(e=>r(e));let i=t.map(e=>this._initPlugin(e.plugin,e.options));this._pluginsRunLifecycle(i)}_pluginsRunLifecycle(e){let t=this._lifecycleService.stage;if(ku(t).subscribe(t=>this._runStage(e,t)),t!==$.Steady){let t=this._lifecycleService.lifecycle$.pipe(Ce(1)).subscribe(n=>{this._runStage(e,n),n===$.Steady&&t.unsubscribe()})}}_runStage(e,t){e.forEach(e=>{switch(t){case $.Starting:e.onStarting();break;case $.Ready:e.onReady();break;case $.Rendered:e.onRendered();break;case $.Steady:e.onSteady();break}})}_initPlugin(e,t){let n=this._injector.createInstance(e,t);return this._pluginStore.addPlugin(n),this._loadedPlugins.add(e.pluginName),this._logService.debug(`[PluginService]`,`Plugin "${n.getPluginName()}" loaded.`),n}};Hu=z([R(0,t(i)),R(1,t(Ou)),R(2,L)],Hu);const Uu=m(`resource-loader-service`);let Wu=class extends E{constructor(e){super(),this._logService=e,C(this,`_resourceMap`,new Map),C(this,`_register$`,new y),C(this,`register$`,this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(e,t){return t?this.getResourcesByType(e,t):this.getAllResourceHooks().map(t=>{let n=t.toJson(e);return{name:t.pluginName,data:n}})}getResourcesByType(e,t){return this.getAllResourceHooks().filter(e=>e.businesses.includes(t)).map(t=>{let n=t.toJson(e);return{name:t.pluginName,data:n}})}registerPluginResource(e){let t=e.pluginName;if(this._resourceMap.has(t))throw Error(`the pluginName is registered {${t}}`);return this._resourceMap.set(t,e),this._register$.next(e),T(()=>this._resourceMap.delete(t))}disposePluginResource(e){this._resourceMap.delete(e)}loadResources(e,t){this.getAllResourceHooks().forEach(n=>{var r;let i=t==null||(r=t.find(e=>e.name===n.pluginName))==null?void 0:r.data;if(i)try{let t=n.parseJson(i);n.onLoad(e,t)}catch(e){this._logService.error(`[ResourceManagerService]`,`loadResources error`,e)}})}unloadResources(e,t){this.getAllResourceHooks().filter(e=>e.businesses.includes(t)).forEach(t=>{t.onUnLoad(e)})}dispose(){this._register$.complete(),this._resourceMap.clear()}};Wu=z([R(0,L)],Wu);var Gu=class extends E{get darkMode(){return this._darkMode$.getValue()}constructor(){super(),C(this,`_darkMode$`,new v(!1)),C(this,`darkMode$`,this._darkMode$.asObservable()),C(this,`_validColorCache`,new Map),C(this,`_currentTheme`,Je),C(this,`_currentTheme$`,new v(this._currentTheme)),C(this,`currentTheme$`,this._currentTheme$.asObservable()),this.disposeWithMe(T(()=>{this._currentTheme=Je,this._currentTheme$.complete(),this._darkMode$.complete()}))}isValidThemeColor(e){if(this._validColorCache.has(e))return this._validColorCache.get(e);let t=!1,n=e.split(`.`);if(n.length===1)t=e in Je;else if(n.length===2){let[e,r]=n;t=e in Je&&r in this._currentTheme[e]}return this._validColorCache.set(e,t),t}getCurrentTheme(){return this._currentTheme}setTheme(e){this._currentTheme=e,this._currentTheme$.next(e)}setDarkMode(e){this._darkMode$.next(e)}getColorFromTheme(e){return ce(this._currentTheme,e)}},Ku=function(e){return e[e.WAITING=0]=`WAITING`,e[e.CREATED=1]=`CREATED`,e}(Ku||{});const qu=m(`univer.undo-redo.service`);var Ju=class{dispose(){}async dispatchToHandlers(){return!1}};const Yu=`univer.command.redo`,Xu=`univer.command.undo`,Zu=new class extends Ju{constructor(...e){super(...e),C(this,`type`,Yr.COMMAND),C(this,`id`,Xu)}handler(e){let t=e.get(qu),n=t.pitchTopUndoElement();if(!n)return!1;let r=e.get(Xr);return ti(n.undoMutations,r)?(t.popUndoToRedo(),!0):!1}},Qu=new class extends Ju{constructor(...e){super(...e),C(this,`type`,Yr.COMMAND),C(this,`id`,Yu)}handler(e){let t=e.get(qu),n=t.pitchTopRedoElement();if(!n)return!1;let r=e.get(Xr);return ti(n.redoMutations,r)?(t.popRedoToUndo(),!0):!1}};let $u=class extends E{constructor(e,t,n){super(),this._univerInstanceService=e,this._commandService=t,this._contextService=n,C(this,`undoRedoStatus$`,void 0),C(this,`_undoRedoStatus$`,new v({undos:0,redos:0})),C(this,`_undoStacks`,new Map),C(this,`_redoStacks`,new Map),C(this,`_batchingStatus`,new Map),this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(Zu)),this.disposeWithMe(this._commandService.registerCommand(Qu)),this.disposeWithMe(T(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(T(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(e){let{unitID:t}=e,n=this._getRedoStack(t,!0),r=this._getUndoStack(t,!0);if(n.length=0,this._batchingStatus.has(e.unitID)){let t=this._batchingStatus.get(e.unitID),n=this._pitchUndoElement(e.unitID);t===Ku.WAITING||!n?(i(e),this._batchingStatus.set(e.unitID,Ku.CREATED)):this._tryBatchingElements(n,e)}else i(e);function i(e){r.push(e),r.length>20&&r.splice(0,1)}this._updateStatus()}clearUndoRedo(e){let t=this._getRedoStack(e);t&&(t.length=0);let n=this._getUndoStack(e);n&&(n.length=0),this._updateStatus()}pitchTopUndoElement(){let e=this._getFocusedUnitId();return this._pitchUndoElement(e)}pitchTopRedoElement(){let e=this._getFocusedUnitId();return this._pitchRedoElement(e)}_pitchUndoElement(e){let t=this._getUndoStack(e);return t!=null&&t.length?t[t.length-1]:null}_pitchRedoElement(e){let t=this._getRedoStack(e);return t!=null&&t.length?t[t.length-1]:null}popUndoToRedo(){let e=this._getUndoStackForFocused().pop();e&&(e.redoMutations.length>0&&this._getRedoStackForFocused().push(e),this._updateStatus())}popRedoToUndo(){let e=this._getRedoStackForFocused().pop();e&&(this._getUndoStackForFocused().push(e),this._updateStatus())}rollback(e,t){let n=t||this._getFocusedUnitId(),r=this._getUndoStack(n),i=r==null?void 0:r[(r==null?void 0:r.length)-1];i&&i.id===e&&(r.pop(),ti(i.undoMutations,this._commandService))}__tempBatchingUndoRedo(e){if(this._batchingStatus.has(e))throw Error(`[LocalUndoRedoService]: cannot batching undo redo twice at the same time!`);return this._batchingStatus.set(e,Ku.WAITING),T(()=>this._batchingStatus.delete(e))}_updateStatus(){var e,t;let n=this._getFocusedUnitId(),r=n&&((e=this._undoStacks.get(n))==null?void 0:e.length)||0,i=n&&((t=this._redoStacks.get(n))==null?void 0:t.length)||0;this._undoRedoStatus$.next({undos:r,redos:i})}_getUndoStack(e,t=!1){let n=this._undoStacks.get(e);return!n&&t&&(n=[],this._undoStacks.set(e,n)),n||null}_getRedoStack(e,t=!1){let n=this._redoStacks.get(e);return!n&&t&&(n=[],this._redoStacks.set(e,n)),n||null}_getUndoStackForFocused(){let e=this._getFocusedUnitId();if(!e)throw Error(`No focused univer instance!`);return this._getUndoStack(e,!0)}_getRedoStackForFocused(){let e=this._getFocusedUnitId();if(!e)throw Error(`No focused univer instance!`);return this._getRedoStack(e,!0)}_tryBatchingElements(e,t){e.redoMutations.push(...t.redoMutations),e.undoMutations.push(...t.undoMutations)}_getFocusedUnitId(){let e=``,t=this._contextService.getContextValue(dl),n=this._contextService.getContextValue(_l),r=this._contextService.getContextValue(hl);if(t)if(n)e=ft;else if(r)e=dt;else{var i,a;e=(i=(a=this._univerInstanceService.getFocusedUnit())==null?void 0:a.getUnitId())==null?``:i}else{var o,s;e=(o=(s=this._univerInstanceService.getFocusedUnit())==null?void 0:s.getUnitId())==null?``:o}return e}};$u=z([R(0,wu),R(1,Xr),R(2,Ur)],$u);var ed=class{constructor(e,t=1e3){this._injector=e,C(this,`_imageCacheMap`,void 0),this._imageCacheMap=new $a(t)}_getImageCacheKey(e,t){return`${e}-${t}`}getImage(e,t,n,r){let i=this._getImageCacheKey(e,t);return this._imageCacheMap.get(i)||((async()=>{let a=new Image,o=this._injector.has(kl)?this._injector.get(kl):null,s=this._injector.has(Al)?this._injector.get(Al):null;if(e===Dl.UUID)try{a.src=await(o==null?void 0:o.getImage(t))||``}catch(e){console.error(e)}else if(e===Dl.URL)try{a.src=await(s==null?void 0:s.getImage(t))||t}catch{a.src=t}else a.src=t;a.onload=()=>{a.removeAttribute(`data-error`),n==null||n()},a.onerror=()=>{a.setAttribute(`data-error`,`true`),r==null||r()},this._imageCacheMap.set(i,a)})(),null)}};function td(e){return!(e.length===0||e.length>31||e.startsWith(`'`)||e.endsWith(`'`)||/[:\\\/\?\*\[\]]/.test(e))}function nd(e,t){return!(!e||e.length===0||e.length>255||t.has(e)||/[ :\\\/\?\*\[\]]/.test(e)||!/^[\p{L}_]/u.test(e)||/^\$?[A-Za-z]{1,3}\$?[0-9]+$/.test(e)||/^[rR]\d+[cC]\d+$/.test(e)||/^\d+$/.test(e))}var rd=class{constructor(e=!1){this._enableOneCellCache=e,C(this,`_tree`,new Map),C(this,`_oneCellCache`,new Map),C(this,`_kdTree`,new Map)}dispose(){this.clear()}getTree(e,t){return this._tree.has(e)||this._tree.set(e,new Map),this._tree.get(e).has(t)||this._tree.get(e).set(t,new Ge),this._tree.get(e).get(t)}_getOneCellCache(e,t,n,r){return this._oneCellCache.has(e)||this._oneCellCache.set(e,new Map),this._oneCellCache.get(e).has(t)||this._oneCellCache.get(e).set(t,new Map),this._oneCellCache.get(e).get(t).has(n)||this._oneCellCache.get(e).get(t).set(n,new Map),this._oneCellCache.get(e).get(t).get(n).has(r)||this._oneCellCache.get(e).get(t).get(n).set(r,new Set),this._oneCellCache.get(e).get(t).get(n).get(r)}_removeOneCellCache(e,t,n,r,i){let a=this._oneCellCache.get(e);if(!a)return;let o=a.get(t);if(!o)return;let s=o.get(n);if(!s)return;let c=s.get(r);c&&c.delete(i)}_removeCellCacheByRange(e){let{unitId:t,sheetId:n,range:r,id:i}=e,a=this._oneCellCache.get(t);if(!a)return;let o=a.get(n);if(!o)return;let{startRow:s,startColumn:c,endRow:l,endColumn:u}=r;for(let e=s;e<=l;e++){let t=o.get(e);if(t)for(let e=c;e<=u;e++){let n=t.get(e);n&&n.delete(i)}}}_insertOneCellCache(e,t,n,r,i){this._getOneCellCache(e,t,n,r).add(i)}_getRdTreeItems(e){let t=[];for(let[n,r]of e)for(let[e,i]of r)t.push({x:e,y:n,ids:i});return t}_searchByOneCellCache(e){var t;let{unitId:n,sheetId:r,range:i}=e,{startRow:a,startColumn:o,endRow:s,endColumn:c}=i,l=(t=this._kdTree.get(n))==null?void 0:t.get(r);if(!l)return[];let{tree:u,items:d}=l,f=u.range(o,a,c,s),p=[];for(let e of f){let t=d[e];p.push(...Array.from(t.ids))}return p}openKdTree(){for(let[t,n]of this._oneCellCache){this._kdTree.has(t)||this._kdTree.set(t,new Map);for(let[r,i]of n){var e;let n=this._getRdTreeItems(i),a=new Ye(n.length);(e=this._kdTree.get(t))==null||e.set(r,{tree:a,items:n});for(let e of n)a.add(e.x,e.y);a.finish()}}}closeKdTree(){for(let[t,n]of this._oneCellCache)for(let[r,i]of n){var e;(e=this._kdTree.get(t))==null||e.set(r,void 0)}}insert(e){let{unitId:t,sheetId:n,range:r,id:i}=e;if(!t||t.length===0)return;let{startRow:a,endRow:o,startColumn:s,endColumn:c}=r;if(this._enableOneCellCache&&a===o&&s===c){this._insertOneCellCache(t,n,a,s,i);return}let l=this.getTree(t,n);Number.isNaN(a)&&(a=0),Number.isNaN(s)&&(s=0),Number.isNaN(o)&&(o=1/0),Number.isNaN(c)&&(c=1/0),l.insert({minX:s,minY:a,maxX:c,maxY:o,id:i})}bulkInsert(e){for(let t of e)this.insert(t)}*searchGenerator(e){var t;let{unitId:n,sheetId:r,range:i}=e;if(this._enableOneCellCache){let t=this._searchByOneCellCache(e);for(let e of t)yield e}let a=(t=this._tree.get(n))==null?void 0:t.get(r);if(!a)return;let o=a.search({minX:i.startColumn,minY:i.startRow,maxX:i.endColumn,maxY:i.endRow});for(let e of o)yield e.id}bulkSearch(e,t){let n=new Set;for(let r of e)for(let e of this.searchGenerator(r))(t==null?void 0:t.has(e))!==!0&&n.add(e);return n}removeById(e,t){if(t){var n,r;(n=this._tree.get(e))==null||n.delete(t),(r=this._oneCellCache.get(e))==null||r.delete(t)}else this._tree.delete(e),this._oneCellCache.delete(e)}_removeRTreeItem(e){let{unitId:t,sheetId:n,range:r,id:i}=e,a=this.getTree(t,n),o=a.search({minX:r.startColumn,minY:r.startRow,maxX:r.endColumn,maxY:r.endRow});for(let e=0;e<o.length;e++)o[e].id===i&&a.remove(o[e])}remove(e){let{unitId:t,sheetId:n,range:r,id:i}=e,{startRow:a,startColumn:o,endRow:s,endColumn:c}=r;this._enableOneCellCache?a===s&&o===c?this._removeOneCellCache(t,n,r.startRow,r.startColumn,i):(this._removeCellCacheByRange(e),this._removeRTreeItem(e)):this._removeRTreeItem(e)}bulkRemove(e){for(let t of e)this.remove(t)}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){let e={};return this._tree.forEach((t,n)=>{e[n]={},t.forEach((t,r)=>{e[n][r]=t.toJSON()})}),e}fromJSON(e){this._tree.clear();for(let t in e){this._tree.set(t,new Map);for(let n in e[t]){let r=new Ge;r.fromJSON(e[t][n]),this._tree.get(t).set(n,r)}}}};function id(e){return new Promise(t=>setTimeout(t,e))}function ad(e=1){return new Promise(t=>{let n=0,r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}let od=class extends E{constructor(e){super(),this._localeService=e,C(this,`_fontLocale`,void 0),C(this,`_dirty`,!0),this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(e){this._dirty=e}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}};od=z([R(0,n(ju))],od);let sd=class extends od{constructor(e,t,n,r,i,a){super(n),this.worksheet=e,this._styles=t,this._contextService=r,this._configService=i,this._injector=a,C(this,`_worksheetData`,void 0),C(this,`_renderRawFormula`,!1),C(this,`_cellData`,void 0),C(this,`_imageCacheMap`,void 0),C(this,`_skipAutoHeightForMergedCells`,!0),C(this,`_rowTotalHeight`,0),C(this,`_columnTotalWidth`,0),C(this,`_rowHeaderWidth`,0),C(this,`_columnHeaderHeight`,0),C(this,`_rowHeightAccumulation`,[]),C(this,`_columnWidthAccumulation`,[]),C(this,`_marginTop`,0),C(this,`_marginLeft`,0),C(this,`_scaleX`,void 0),C(this,`_scaleY`,void 0),C(this,`_scrollX`,void 0),C(this,`_scrollY`,void 0),this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new ed(this._injector),this.initConfig()}initConfig(){var e,t;this._skipAutoHeightForMergedCells=!((e=this._configService.getConfig(_t))!=null&&e),this.worksheet.setIsRowStylePrecedeColumnStyle((t=this._configService.getConfig(`isRowStylePrecedeColumnStyle`))==null?!1:t)}resetCache(){}getWorksheetConfig(){return this._worksheetData}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(e){this._columnHeaderHeight=e,this._worksheetData.columnHeader.height=e}set rowHeaderWidth(e){this._rowHeaderWidth=e,this._worksheetData.rowHeader.width=e}get rowHeightAccumulation(){return this._rowHeightAccumulation}get rowTotalHeight(){return this._rowTotalHeight}get columnWidthAccumulation(){return this._columnWidthAccumulation}get columnTotalWidth(){return this._columnTotalWidth}get rowHeaderWidth(){return this._rowHeaderWidth}get columnHeaderHeight(){return this._columnHeaderHeight}setMarginLeft(e){this._marginLeft=e}setMarginTop(e){this._marginTop=e}setScale(e,t){this._updateLayout(),this._scaleX=e,this._scaleY=t||e,this._updateLayout()}setScroll(e,t){D.isDefine(e)&&(this._scrollX=e),D.isDefine(t)&&(this._scrollY=t)}get scrollX(){return this._scrollX}get scrollY(){return this._scrollY}get scaleX(){return this._scaleX}get scaleY(){return this._scaleY}get rowHeaderWidthAndMarginLeft(){return this.rowHeaderWidth+this._marginLeft}get columnHeaderHeightAndMarginTop(){return this.columnHeaderHeight+this._marginTop}get imageCacheMap(){return this._imageCacheMap}_generateRowMatrixCache(e,t,n){let r=0,i=[],a=t;for(let t=0;t<e;t++){let e=n;if(this.worksheet.getRowFiltered(t))e=0;else if(a[t]!=null){let r=a[t];if(!r)continue;let{h:i=n,ah:o,ia:s}=r;e=(s==null||s===A.TRUE)&&typeof o==`number`&&o>0?o:i,r.hd===A.TRUE&&(e=0)}r+=e,i.push(r)}return{rowTotalHeight:r,rowHeightAccumulation:i}}_generateColumnMatrixCache(e,t,n){let r=0,i=[],a=t;for(let t=0;t<e;t++){let e=n;if(a[t]!=null){let n=a[t];if(!n)continue;n.w!=null&&(e=n.w),n.hd===A.TRUE&&(e=0)}r+=e,i.push(r)}return{columnTotalWidth:r,columnWidthAccumulation:i}}intersectMergeRange(e,t){return!!this.worksheet.getMergedCell(e,t)}_getOverflowBound(e,t,n,r,i=Yn.LEFT){let a=0;if(t>n){let o=this._columnWidthAccumulation.length-1;for(let s=t;s>=n;s--){let n=s;if(!ya(this.worksheet.getCell(e,n))&&n!==t||this.intersectMergeRange(e,n))return n===t?n:n+1>o?o:n+1;let{startX:c,endX:l}=ud(e,n,this.rowHeightAccumulation,this.columnWidthAccumulation);if(i===Yn.CENTER&&n===t?a+=(l-c)/2:a+=l-c,r<a)return n}return t}for(let o=t;o<=n;o++){let n=o;if(!ya(this.worksheet.getCell(e,n))&&n!==t||this.intersectMergeRange(e,n))return n===t?n:n-1<0?0:n-1;let{startX:s,endX:c}=ud(e,n,this.rowHeightAccumulation,this.columnWidthAccumulation);if(i===Yn.CENTER&&n===t?a+=(c-s)/2:a+=c-s,r<a)return n}return n}_updateLayout(){if(!this.dirty)return;let{rowData:e,columnData:t,defaultRowHeight:n,defaultColumnWidth:r,rowCount:i,columnCount:a,rowHeader:o,columnHeader:s}=this._worksheetData,{rowTotalHeight:c,rowHeightAccumulation:l}=this._generateRowMatrixCache(i,e,n),{columnTotalWidth:u,columnWidthAccumulation:d}=this._generateColumnMatrixCache(a,t,r);this._rowHeaderWidth=o.hidden===A.TRUE?0:this._dynamicallyUpdateRowHeaderWidth(o),this._columnHeaderHeight=s.hidden===A.TRUE?0:s.height,this._rowTotalHeight=c,this._rowHeightAccumulation=l,this._columnTotalWidth=u,this._columnWidthAccumulation=d,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(e){}_dynamicallyUpdateRowHeaderWidth(e){let t=`${this.worksheet.getRowCount()}`.length*8;return Math.max(e.width,t)}_hasUnMergedCellInRow(e,t,n){if(!this.worksheet.getMergeData())return!1;for(let r=t;r<=n;r++){let{isMerged:t,isMergedMainCell:n}=this.worksheet.getCellInfoInMergeData(e,r);if(!t&&!n)return!0}return!1}expandRangeByMerge(e,t){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e,o=this._worksheetData.mergeData;if(!o)return{startRow:n,startColumn:r,endRow:i,endColumn:a};let s=!0,c=new ma,l=0,u=null;for(;s;){s=!1;for(let e=0;e<o.length;e++){let{startRow:t,startColumn:d,endRow:f,endColumn:p}=o[e];if(c.getValue(t,d))continue;let m={startColumn:r,startRow:n,endColumn:a,endRow:i},h={startColumn:d,startRow:t,endColumn:p,endRow:f};Eo(m,h)&&(n=Math.min(n,t),r=Math.min(r,d),i=Math.max(i,f),a=Math.max(a,p),c.setValue(t,d,!0),s=!0,l++,u=h)}}return t&&l===1&&G.contains(u,e)?{startRow:u.startRow,startColumn:u.startColumn,endRow:u.startRow,endColumn:u.startColumn}:{startRow:n,startColumn:r,endRow:i,endColumn:a}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(e,t){return this.worksheet.getCellInfoInMergeData(e,t)}getNoMergeCellPositionByIndex(e,t,n=!0){return this.getNoMergeCellWithCoordByIndex(e,t,n)}getNoMergeCellWithCoordByIndex(e,t,n=!0){let{rowHeightAccumulation:r,columnWidthAccumulation:i,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:o}=this,{startY:s,endY:c,startX:l,endX:u}=ud(e,t,r,i);return n&&(s+=o,c+=o,l+=a,u+=a),{startY:s,endY:c,startX:l,endX:u}}getNoMergeCellPositionByIndexWithNoHeader(e,t){let{rowHeightAccumulation:n,columnWidthAccumulation:r}=this,{startY:i,endY:a,startX:o,endX:s}=ud(e,t,n,r);return{startY:i,endY:a,startX:o,endX:s}}getRowIndexByOffsetY(e,t,n,r){let{rowHeightAccumulation:i}=this;e=fd(e,t,n,this.columnHeaderHeightAndMarginTop);let a=fi(i,e,r==null?void 0:r.firstMatch);if(r!=null&&r.closeFirst){var o;Math.abs(i[a]-e)<Math.abs(e-((o=i[a-1])==null?0:o))&&(a+=1)}return a}getColumnIndexByOffsetX(e,t,n,r){let i=dd(e,t,n,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this,o=fi(a,i,r==null?void 0:r.firstMatch);if(r!=null&&r.closeFirst){var s;Math.abs(a[o]-i)<Math.abs(i-((s=a[o-1])==null?0:s))&&(o+=1)}return o}getCellIndexByOffset(e,t,n,r,i,a){return{row:this.getRowIndexByOffsetY(t,r,i,a),column:this.getColumnIndexByOffsetX(e,n,i,a)}}getCellByOffset(e,t,n,r,i){var a;let o=(a=this)==null?void 0:a.getCellIndexByOffset(e,t,n,r,i,{firstMatch:!0});return o?this.worksheet.getCellInfoInMergeData(o.row,o.column):null}getCellWithCoordByIndex(e,t,n=!0){var r;let{rowHeightAccumulation:i,columnWidthAccumulation:a,rowHeaderWidthAndMarginLeft:o,columnHeaderHeightAndMarginTop:s}=this,c=ud(e,t,i,a,(r=this.worksheet)==null?void 0:r.getCellInfoInMergeData(e,t)),{isMerged:l,isMergedMainCell:u}=c,{startY:d,endY:f,startX:p,endX:m,mergeInfo:h}=c,g=o,_=s;return n===!1&&(g=0,_=0),d+=_,f+=_,p+=g,m+=g,h.startY+=_,h.endY+=_,h.startX+=g,h.endX+=g,{actualRow:e,actualColumn:t,startX:p,startY:d,endX:m,endY:f,isMerged:l,isMergedMainCell:u,mergeInfo:h}}getCellWithCoordByOffset(e,t,n,r,i,a){let{row:o,column:s}=this.getCellIndexByOffset(e,t,n,r,i,a);return this.getCellWithCoordByIndex(o,s)}getOffsetByColumn(e){let{columnWidthAccumulation:t,rowHeaderWidthAndMarginLeft:n}=this,r=t.length-1,i=t[e];return i==null?e<0?n:t[r]+n:i+n}getOffsetByRow(e){let{rowHeightAccumulation:t,columnHeaderHeightAndMarginTop:n}=this,r=t.length-1,i=t[e];return i==null?e<0?n:t[r]+n:i+n}getOffsetRelativeToRowCol(e,t){let n=fi(this.columnWidthAccumulation,e),r=0;r=n===0?e:e-this._columnWidthAccumulation[n-1];let i=fi(this.rowHeightAccumulation,t),a=0;return a=i===0?t:t-this._rowHeightAccumulation[i-1],{row:i,column:n,columnOffset:r,rowOffset:a}}_updateConfigAndGetDocumentModel(e,t,n,r){var i,a,o,s,c;if(!r||!((i=e.body)!=null&&i.dataStream))return;e.documentStyle||(e.documentStyle={}),e.documentStyle.marginTop=(a=n.t)==null?0:a,e.documentStyle.marginBottom=(o=n.b)==null?2:o,e.documentStyle.marginLeft=(s=n.l)==null?2:s,e.documentStyle.marginRight=(c=n.r)==null?2:c,e.documentStyle.pageSize={width:1/0,height:1/0},e.documentStyle.renderConfig={...e.documentStyle.renderConfig,...r};let l=e.body.paragraphs||[];for(let e of l)e.paragraphStyle||(e.paragraphStyle={}),e.paragraphStyle.horizontalAlign=t;return new lc(e)}dispose(){super.dispose(),this._rowHeightAccumulation=[],this._columnWidthAccumulation=[],this._rowTotalHeight=0,this._columnTotalWidth=0,this._rowHeaderWidth=0,this._columnHeaderHeight=0,this._worksheetData=null,this._cellData=null,this._styles=null,this.worksheet=null}};sd=z([R(2,n(ju)),R(3,Ur),R(4,Vr),R(5,n(a))],sd);function cd(e,t,n,r){let i=e-1,a=t-1,o=n[i]||0,s=n[e];s==null&&(s=n[n.length-1]);let c=r[a]||0,l=r[t];return l==null&&(l=r[r.length-1]),{startY:o,endY:s,startX:c,endX:l}}function ld(e,t,n,r){return cd(e,t,n,r)}function ud(e,t,n,r,i){e=D.clamp(e,0,n.length-1),t=D.clamp(t,0,r.length-1);let{startY:a,endY:o,startX:s,endX:c}=cd(e,t,n,r);if(!i)return{startY:a,endY:o,startX:s,endX:c,isMerged:!1,isMergedMainCell:!1,actualRow:e,actualColumn:t,mergeInfo:{startY:a,endY:o,startX:s,endX:c,startRow:e,startColumn:t,endRow:e,endColumn:t}};let{isMerged:l,isMergedMainCell:u,startRow:d,startColumn:f,endRow:p,endColumn:m}=i,h={startRow:d,startColumn:f,endRow:p,endColumn:m,startY:a,endY:o,startX:s,endX:c},g=n.length-1,_=r.length-1;if(l&&d!==-1&&f!==-1){let e=n[d-1]||0,t=n[p]||n[g],i=r[f-1]||0,a=r[m]||r[_];h={...h,startY:e,endY:t,startX:i,endX:a}}else if(!l&&p!==-1&&m!==-1){let e=n[p]||n[g],t=r[m]||r[_];h={...h,startY:a,endY:e,startX:s,endX:t}}return{isMerged:l,isMergedMainCell:u,actualRow:e,actualColumn:t,startY:a,endY:o,startX:s,endX:c,mergeInfo:h}}function dd(e,t,n,r){let{x:i}=n;return e/t+i-r}function fd(e,t,n,r){let{y:i}=n;return e=e/t+i-r,e}const pd=[`script`,`style`,`meta`,`comment`,`link`];let md=function(e){return e[e.INFO=0]=`INFO`,e[e.STOP=1]=`STOP`,e[e.WARNING=2]=`WARNING`,e}({}),hd=function(e){return e[e.DISABLED=0]=`DISABLED`,e[e.FULL_ALPHA=1]=`FULL_ALPHA`,e[e.FULL_HANGUL=2]=`FULL_HANGUL`,e[e.FULL_KATAKANA=3]=`FULL_KATAKANA`,e[e.HALF_ALPHA=4]=`HALF_ALPHA`,e[e.HALF_HANGUL=5]=`HALF_HANGUL`,e[e.HALF_KATAKANA=6]=`HALF_KATAKANA`,e[e.HIRAGANA=7]=`HIRAGANA`,e[e.NO_CONTROL=8]=`NO_CONTROL`,e[e.OFF=9]=`OFF`,e[e.ON=10]=`ON`,e}({}),gd=function(e){return e.BETWEEN=`between`,e.EQUAL=`equal`,e.GREATER_THAN=`greaterThan`,e.GREATER_THAN_OR_EQUAL=`greaterThanOrEqual`,e.LESS_THAN=`lessThan`,e.LESS_THAN_OR_EQUAL=`lessThanOrEqual`,e.NOT_BETWEEN=`notBetween`,e.NOT_EQUAL=`notEqual`,e}({}),_d=function(e){return e[e.TEXT=0]=`TEXT`,e[e.ARROW=1]=`ARROW`,e[e.CUSTOM=2]=`CUSTOM`,e}({}),vd=function(e){return e.VALID=`valid`,e.INVALID=`invalid`,e.VALIDATING=`validating`,e}({}),yd=function(e){return e.CUSTOM=`custom`,e.LIST=`list`,e.LIST_MULTIPLE=`listMultiple`,e.NONE=`none`,e.TEXT_LENGTH=`textLength`,e.DATE=`date`,e.TIME=`time`,e.WHOLE=`whole`,e.DECIMAL=`decimal`,e.CHECKBOX=`checkbox`,e.ANY=`any`,e}({}),bd=class extends E{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){let e=e=>{e.businesses.forEach(t=>{switch(t){case x.UNRECOGNIZED:case x.UNIVER_UNKNOWN:case x.UNIVER_SLIDE:case x.UNIVER_DOC:this._univerInstanceService.getAllUnitsForType(x.UNIVER_DOC).forEach(t=>{let n=(t.getSnapshot().resources||[]).find(t=>t.name===e.pluginName);if(n)try{let r=e.parseJson(n.data);e.onLoad(t.getUnitId(),r)}catch{console.error(`Load Document{${t.getUnitId()}} Resources{${e.pluginName}} Data Error.`)}});break;case x.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(x.UNIVER_SHEET).forEach(t=>{let n=(t.getSnapshot().resources||[]).find(t=>t.name===e.pluginName);if(n)try{let r=e.parseJson(n.data);e.onLoad(t.getUnitId(),r)}catch{console.error(`Load Workbook{${t.getUnitId()}} Resources{${e.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(t=>e(t)),this.disposeWithMe(this._resourceManagerService.register$.subscribe(t=>e(t))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(x.UNIVER_SHEET).subscribe(e=>{this._resourceManagerService.loadResources(e.getUnitId(),e.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(x.UNIVER_DOC).subscribe(e=>{yt(e.getUnitId())||this._resourceManagerService.loadResources(e.getUnitId(),e.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(x.UNIVER_SHEET).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),x.UNIVER_SHEET)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(x.UNIVER_DOC).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),x.UNIVER_DOC)}))}saveUnit(e){let t=this._univerInstanceService.getUnit(e);if(!t)return null;let n=this._resourceManagerService.getResources(e,t.type),r=D.deepClone(t.getSnapshot());return r.resources=n,r}};bd=z([R(0,t(tl)),R(1,t(wu))],bd);var xd=class{get _univerInstanceService(){return this._injector.get(wu)}get _pluginService(){return this._injector.get(Hu)}constructor(e={},t){C(this,`_startedTypes`,new Set),C(this,`_injector`,void 0),C(this,`_disposingCallbacks`,new un);let n=this._injector=Sd(t,e==null?void 0:e.override),{theme:r,darkMode:i,locale:a,locales:o,logLevel:s,logCommandExecution:c}=e;r&&this._injector.get(Gu).setTheme(r),i&&this._injector.get(Gu).setDarkMode(i),o&&this._injector.get(ju).load(o),a&&this._injector.get(ju).setLocale(a),s&&this._injector.get(L).setLogLevel(s),c!==void 0&&this._injector.get(Vr).setConfig(Jr,c),this._init(n)}__getInjector(){return this._injector}onDispose(e){let t=this._disposingCallbacks.add(T(e));return T(()=>t.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(e){this._injector.get(ju).setLocale(e)}createUnit(e,t){return this._univerInstanceService.createUnit(e,t)}createUniverSheet(e){return this._injector.get(L).warn(`[Univer]`,`Univer.createUniverSheet is deprecated, use createUnit instead`),this._univerInstanceService.createUnit(x.UNIVER_SHEET,e)}createUniverDoc(e){return this._injector.get(L).warn(`[Univer]`,`Univer.createUniverDoc is deprecated, use createUnit instead`),this._univerInstanceService.createUnit(x.UNIVER_DOC,e)}createUniverSlide(e){return this._injector.get(L).warn(`[Univer]`,`Univer.createUniverSlide is deprecated, use createUnit instead`),this._univerInstanceService.createUnit(x.UNIVER_SLIDE,e)}_init(e){this._univerInstanceService.registerCtorForType(x.UNIVER_SHEET,Su),this._univerInstanceService.registerCtorForType(x.UNIVER_DOC,lc),this._univerInstanceService.registerCtorForType(x.UNIVER_SLIDE,Cu);let t=e.get(wu);t.__setCreateHandler((n,r,i,a)=>{if(!this._startedTypes.has(n)){this._pluginService.startPluginsForType(n),this._startedTypes.add(n);let o=e.createInstance(i,r);return t.__addUnit(o,a),this._tryProgressToReady(),o}let o=e.createInstance(i,r);return t.__addUnit(o,a),o})}_tryProgressToReady(){this._injector.get(Ou).stage<$.Ready&&(this._injector.get(Ou).stage=$.Ready)}registerPlugin(e,t){this._pluginService.registerPlugin(e,t)}registerPlugins(e){e.forEach(e=>{let[t,n]=e;this._pluginService.registerPlugin(t,n)})}};function Sd(e,t){let n=Lu([[El],[ju],[Gu],[Ou],[Hu],[al],[wu,{useClass:Tu}],[Fu,{useClass:Iu}],[L,{useClass:Kr,lazy:!0}],[Xr,{useClass:$r}],[qu,{useClass:$u,lazy:!0}],[Vr,{useClass:Hr}],[Ur,{useClass:Wr}],[tl,{useClass:Wu,lazy:!0}],[Uu,{useClass:bd,lazy:!0}],[sl,{useClass:ol}],[Nu,{useClass:Mu,lazy:!0}]],t),r=e?e.createChild(n):new i(n);return St(r,[[al],[Uu]]),r}et();export{Io as ABCToNumber,_t as AUTO_HEIGHT_FOR_MERGED_CELLS,V as AbsoluteRefType,Vs as ActionIterator,Ar as AlignTypeH,jr as AlignTypeV,Fr as ArrangeTypeEnum,Hn as ArrowsAndMarkersShapes,It as AsyncInterceptorManager,e as AsyncLock,ol as AuthzIoLocalService,Dn as AutoFillSeries,er as BaselineOffset,Vn as BasicShapes,cr as BlockType,A as BooleanNumber,k as BorderStyleTypes,On as BorderType,Z as BuildTextUtils,ar as BulletAlignment,yi as COLORS,Jr as COMMAND_LOG_EXECUTION_CONFIG_KEY,Tt as CanceledError,Ki as CellModeEnum,tr as CellValueType,bi as ColorKit,kn as ColorType,fr as ColumnSeparatorType,$r as CommandService,Yr as CommandType,An as CommonHideTypes,Hr as ConfigService,Wr as ContextService,jn as CopyPasteType,wt as CustomCommandExecutionError,sr as CustomDecorationType,or as CustomRangeType,so as DEFAULT_CELL,sc as DEFAULT_DOC,Zc as DEFAULT_DOCUMENT_SUB_COMPONENT_ID,ht as DEFAULT_EMPTY_DOCUMENT_VALUE,Xi as DEFAULT_NUMBER_FORMAT,ao as DEFAULT_RANGE,io as DEFAULT_RANGE_ARRAY,oo as DEFAULT_SELECTION,co as DEFAULT_SLIDE,W as DEFAULT_STYLES,Ji as DEFAULT_TEXT_FORMAT,Yi as DEFAULT_TEXT_FORMAT_EXCEL,au as DEFAULT_WORKSHEET_COLUMN_COUNT,iu as DEFAULT_WORKSHEET_COLUMN_COUNT_KEY,pu as DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT,fu as DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY,lu as DEFAULT_WORKSHEET_COLUMN_WIDTH,cu as DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY,ru as DEFAULT_WORKSHEET_ROW_COUNT,nu as DEFAULT_WORKSHEET_ROW_COUNT_KEY,su as DEFAULT_WORKSHEET_ROW_HEIGHT,ou as DEFAULT_WORKSHEET_ROW_HEIGHT_KEY,du as DEFAULT_WORKSHEET_ROW_TITLE_WIDTH,uu as DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY,mt as DOCS_COMMENT_EDITOR_UNIT_ID_KEY,ft as DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,dt as DOCS_NORMAL_EDITOR_UNIT_ID_KEY,pt as DOCS_ZEN_EDITOR_UNIT_ID_KEY,mo as DOC_DRAWING_PRINTING_COMPONENT_KEY,Wi as DOC_RANGE_TYPE,vr as DashStyleType,tc as DataStreamTreeNodeType,X as DataStreamTreeTokenType,md as DataValidationErrorStyle,hd as DataValidationImeMode,gd as DataValidationOperator,_d as DataValidationRenderMode,vd as DataValidationStatus,yd as DataValidationType,Mn as DeleteDirection,Vu as DependentOn,Kr as DesktopLogService,Nn as DeveloperMetadataVisibility,Pn as Dimension,Fn as Direction,E as Disposable,un as DisposableCollection,rr as DocStyleType,lc as DocumentDataModel,lr as DocumentFlavor,Ir as DrawingTypeEnum,hl as EDITOR_ACTIVATED,ho as EXTENSION_NAMES,El as ErrorService,Qc as EventState,$c as EventSubject,bl as FOCUSING_COMMENT_EDITOR,Cl as FOCUSING_COMMON_DRAWINGS,fl as FOCUSING_DOC,ml as FOCUSING_EDITOR_BUT_HIDDEN,gl as FOCUSING_EDITOR_INPUT_FORMULA,yl as FOCUSING_EDITOR_STANDALONE,_l as FOCUSING_FX_BAR_EDITOR,xl as FOCUSING_PANEL_EDITOR,wl as FOCUSING_SHAPE_TEXT_EDITOR,dl as FOCUSING_SHEET,pl as FOCUSING_SLIDE,ul as FOCUSING_UNIT,vl as FOCUSING_UNIVER_EDITOR,Sl as FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE,Tl as FORMULA_EDITOR_ACTIVATED,ir as FollowNumberWithType,Qn as FontItalic,Er as FontStyleType,$n as FontWeight,ur as GridType,Yn as HorizontalAlign,sl as IAuthzIoService,Xr as ICommandService,Vr as IConfigService,cl as IConfirmService,Ur as IContextService,kl as IImageIoService,Au as ILocalStorageService,L as ILogService,Nu as IMentionIOService,Fu as IPermissionService,Uu as IResourceLoaderService,tl as IResourceManagerService,gt as IS_ROW_STYLE_PRECEDE_COLUMN_STYLE,Al as IURLImageService,qu as IUndoRedoService,wu as IUniverInstanceService,ed as ImageCacheMap,Dl as ImageSourceType,Ol as ImageUploadStatusType,t as Inject,r as InjectSelf,i as Injector,At as InterceptorEffectEnum,Nt as InterceptorManager,Ln as InterpolationPointType,S as JSON1,ec as JSONX,eo as LRUHelper,$a as LRUMap,Ou as LifecycleService,$ as LifecycleStages,Du as LifecycleUnreachableError,M as ListGlyphType,$u as LocalUndoRedoService,ju as LocaleService,Rn as LocaleType,Gr as LogLevel,o as LookUp,ro as MAX_COLUMN_COUNT,no as MAX_ROW_COUNT,mi as MOVE_BUFFER_VALUE,s as Many,Zt as MemoryCursor,Mu as MentionIOLocalService,zn as MentionType,uo as NAMED_STYLE_MAP,fo as NAMED_STYLE_SPACE_MAP,N as NamedStyleType,Qr as NilCommand,kr as NumberUnitType,ma as ObjectMatrix,Dr as ObjectRelativeFromH,Or as ObjectRelativeFromV,c as Optional,Un as OtherShapes,go as PAGE_SIZE,Pr as PAPER_TYPES,ps as PRESET_LIST_TYPE,po as PRINT_CHART_COMPONENT_KEY,Rr as PageElementType,Nr as PageOrientType,Lr as PageType,P as PaperType,mr as ParagraphElementType,Jc as ParagraphStyleBuilder,qc as ParagraphStyleValue,Iu as PermissionService,Pu as PermissionStatus,zu as Plugin,Hu as PluginService,gr as PositionedObjectLayoutType,q as PresetListType,Bn as ProtectionType,l as Quantity,K as QuickListType,gs as QuickListTypeMap,Ui as RANGE_DIRECTION,B as RANGE_TYPE,Ge as RBush,fn as RCDisposable,vi as RGBA_PAREN,_i as RGB_PAREN,hi as ROTATE_BUFFER_VALUE,rd as RTree,vo as Range,G as Rectangle,u as RediError,Qu as RedoCommand,Yu as RedoCommandId,Po as RefAlias,nn as Registry,rn as RegistryAsMap,Gn as RelativeDate,zr as RelativeSlideLink,Wu as ResourceManagerService,Xc as RichTextBuilder,Yc as RichTextValue,dn as RxDisposable,lo as SHEET_EDITOR_UNITS,dr as SectionType,d as Self,sd as SheetSkeleton,Kn as SheetTypes,gu as SheetViewModel,od as Skeleton,f as SkipSelf,Es as SliceBodyType,Cu as SlideDataModel,_r as SpacingRule,Wn as SpecialShapes,Pl as Styles,qi as THEME_COLORS,yr as TabStopAlignment,xr as TableAlignmentType,Sr as TableLayoutType,wr as TableRowHeightRule,br as TableSizeType,Cr as TableTextWrapType,ll as TestConfirmService,Jn as TextDecoration,Kc as TextDecorationBuilder,qn as TextDirection,pr as TextDirectionType,Gc as TextStyleBuilder,Wc as TextStyleValue,Y as TextX,I as TextXActionType,j as ThemeColorType,nr as ThemeColors,Gu as ThemeService,D as Tools,Zu as UndoCommand,Xu as UndoCommandId,pn as UnitModel,xd as Univer,Tu as UniverInstanceService,x as UniverInstanceType,F as UpdateDocsAttributeType,al as UserManagerService,Xn as VerticalAlign,Tr as VerticalAlignmentType,p as WithNew,Su as Workbook,vu as Worksheet,Zn as WrapStrategy,hr as WrapTextType,Hl as addLinkToDocumentModel,ci as afterInitApply,oi as afterTime,id as awaitTime,di as binSearchFirstGreaterThanTarget,ui as binarySearchArray,ai as bufferDebounceTime,Oa as cellToRange,Mr as characterSpacingControlType,Na as checkForSubstrings,gi as checkIfMove,Fa as checkParagraphHasBullet,Ia as checkParagraphHasIndent,La as checkParagraphHasIndentByStyle,Jl as cloneCellData,Xl as cloneCellDataMatrix,Yl as cloneCellDataWithSpanAndDisplay,Q as cloneValue,$l as cloneWorksheetData,pi as codeToBlob,to as columnLabelToNumber,zs as composeBody,Mt as composeInterceptors,wn as composeStyles,la as concatMatrixArray,ha as convertCellToRange,si as convertObservableToBehaviorSubject,ka as covertCellValue,Aa as covertCellValues,Pt as createAsyncInterceptorKey,rl as createDefaultUser,zl as createDocumentModelWithStyle,m as createIdentifier,jt as createInterceptorKey,vt as createInternalEditorID,En as createREGEXFromWildChar,Fo as createRowColIter,nd as customNameCharacterCheck,Ie as dayjs,se as debounce,nt as dedupe,rt as dedupeBy,ja as deepCompare,ad as delayAnimationFrame,za as deleteContent,yu as extractPureTextFromCell,g as forwardRef,ri as fromCallback,el as fromEventSubject,Ha as generateIntervalsByPoints,O as generateRandomId,ce as get,aa as getArrayLength,Ms as getBodySlice,Ta as getBorderStyleType,cd as getCellCoordByIndexSimple,Gi as getCellInfoInMergeData,ld as getCellPositionByIndexSimple,zi as getCellValueType,ud as getCellWithCoordByIndexCore,ba as getColorStyle,js as getCustomBlockSlice,Fs as getCustomDecorationSlice,Ps as getCustomRangeSlice,Ea as getDocsUpdateBody,Wl as getEmptyCell,Eo as getIntersectRange,ra as getNumfmtParseValueFilter,bu as getOriginCellValue,ks as getParagraphsSlice,ic as getPlainText,In as getReverseDirection,As as getSectionBreakSlice,Os as getTableSlice,Ds as getTextRunSlice,dd as getTransformOffsetX,fd as getTransformOffsetY,xu as getWorksheetUID,ot as groupBy,Ca as handleStyleToString,Va as hashAlgorithm,Pa as horizontalLineSegmentsSubtraction,sa as insertMatrixArray,Ra as insertTextToContent,Jt as invertColorByHSL,Xt as invertColorByMatrix,_ as isAsyncDependencyItem,ee as isAsyncHook,Ii as isBlackColor,lt as isBooleanString,ya as isCellCoverable,Vi as isCellV,te as isClassDependencyItem,bt as isCommentEditorID,ne as isCtor,Qi as isDefaultFormat,re as isDisposable,va as isEmptyCell,ie as isFactoryDependencyItem,Sa as isFormulaId,xa as isFormulaString,Ri as isICellData,yt as isInternalEditorID,Tn as isNodeEnv,Ul as isNotNullOrUndefined,Bi as isNullCell,$t as isNumeric,$i as isPatternEqualWithoutDecimal,Fl as isRangesEqual,Ba as isRealNum,en as isSafeNumeric,Ma as isSameStyleTextRun,Zi as isTextFormat,Il as isUnitRangesEqual,Da as isValidRange,ae as isValueDependencyItem,Li as isWhiteColor,st as makeArray,_a as makeCellRangeToRangeData,ga as makeCellToSelection,nc as makeCustomRangeStream,ia as mapObjectMatrix,le as merge,Ua as mergeIntervals,Wa as mergeLocales,Lu as mergeOverrideWithDependencies,cn as mergeSets,ue as mergeWith,mu as mergeWorksheetSnapshotWithDefault,Qt as mixinClass,da as moveMatrixArray,yo as moveRangeByOffset,td as nameCharacterCheck,Ns as normalizeBody,Uo as normalizeTextRuns,Lo as numberToABC,zo as numberToListABC,Fe as numfmt,No as queryObjectMatrix,xt as registerDependencies,tt as remove,Ro as repeatStringNumTimes,Vc as replaceInDocumentBody,an as requestImmediateMacroTask,bn as resolveWithBasePath,at as rotate,fi as searchArray,li as searchInOrderedArray,Hi as selectionToArray,sn as sequence,on as sequenceAsync,ti as sequenceExecute,ni as sequenceExecuteAsync,de as set,oe as setDependencies,Ct as shallowEqual,pd as skipParseTagNames,ua as sliceMatrixArray,Bo as sortRules,Vo as sortRulesByDesc,Ho as sortRulesFactory,ca as spliceArray,xo as splitIntoGrid,ii as takeAfter,qe as textDiff,Et as throttle,T as toDisposable,St as touchDependencies,Hs as updateAttributeByDelete,Us as updateAttributeByInsert,tn as willLoseNumericPrecision};
|
|
2
|
+
`,gt=`isRowStylePrecedeColumnStyle`,_t=Symbol(`AUTO_HEIGHT_FOR_MERGED_CELLS`);function vt(e){return`${ut}${e}`}function yt(e){return e.startsWith(ut)}function bt(e){return e.startsWith(mt)}function xt(e,t){t.forEach(t=>e.add(t))}function St(e,t){t.forEach(([t])=>{e.has(t)&&e.get(t)})}function Ct(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;let i=Object.prototype.hasOwnProperty.bind(t);for(let r=0;r<n.length;r++){let a=n[r];if(!i(a)||e[a]!==t[a])return!1}return!0}var wt=class extends Error{constructor(e){super(e),this.name=`CustomCommandExecutionError`}},Tt=class extends wt{constructor(){super(`Canceled by facade`),this.name=`CanceledError`}};function Et(e,t=16){let n=0,r=null;return function(...i){let a=Date.now();a-n<t?(r&&clearTimeout(r),r=setTimeout(()=>{n=a,e.apply(this,i)},t)):(n=a,e.apply(this,i))}}function Dt(e){"@babel/helpers - typeof";return Dt=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Dt(e)}function Ot(e,t){if(Dt(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Dt(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function kt(e){var t=Ot(e,`string`);return Dt(t)==`symbol`?t:t+``}function C(e,t,n){return(t=kt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let At=function(e){return e[e.Style=1]=`Style`,e[e.Value=2]=`Value`,e}({});function jt(e){return`sheet_interceptor_${e}`}const Mt=e=>function(t,n){let r=-1,i=t;for(let t=0;t<=e.length;t++){if(t<=r)throw Error(`[SheetInterceptorService]: next() called multiple times!`);if(r=t,t===e.length)return i;let a=e[t],o=!1;if(i=a.handler(i,n,e=>(o=!0,e)),!o)break}return i};var Nt=class{constructor(e){C(this,`_interceptorsByName`,new Map),C(this,`_interceptorPoints`,void 0),this._interceptorPoints=e}fetchThroughInterceptors(e,t){let n=e,r=this._interceptorsByName.get(n);return t&&(r=r.filter(t)),Mt(r||[])}intercept(e,t){let n=e;this._interceptorsByName.has(n)||this._interceptorsByName.set(n,[]);let r=this._interceptorsByName.get(n);return r.push(t),this._interceptorsByName.set(n,r.sort((e,t)=>{var n,r;return((n=t.priority)==null?0:n)-((r=e.priority)==null?0:r)})),()=>tt(this._interceptorsByName.get(n),t)}getInterceptPoints(){return this._interceptorPoints}dispose(){this._interceptorsByName.clear()}};function Pt(e){return`sheet_async_interceptor_${e}`}const Ft=e=>async function(t,n){let r=-1,i=t;for(let t=0;t<=e.length;t++){if(t<=r)throw Error(`[SheetInterceptorService]: next() called multiple times!`);if(r=t,t===e.length)return i;let a=e[t],o=!1;if(i=await a.handler(i,n,async e=>(o=!0,e)),!o)break}return i};var It=class{constructor(e){C(this,`_asyncInterceptorsByName`,new Map),C(this,`_asyncInterceptorPoints`,void 0),this._asyncInterceptorPoints=e}fetchThroughAsyncInterceptors(e,t){let n=e,r=this._asyncInterceptorsByName.get(n);return t&&(r=r.filter(t)),Ft(r||[])}async interceptAsync(e,t){let n=e;this._asyncInterceptorsByName.has(n)||this._asyncInterceptorsByName.set(n,[]);let r=this._asyncInterceptorsByName.get(n);return r.push(t),this._asyncInterceptorsByName.set(n,r.sort((e,t)=>{var n,r;return((n=t.priority)==null?0:n)-((r=e.priority)==null?0:r)})),()=>tt(this._asyncInterceptorsByName.get(n),t)}getInterceptPoints(){return this._asyncInterceptorPoints}dispose(){this._asyncInterceptorsByName.clear()}};function Lt(e){return e.map(e=>e/255)}function Rt(e){return e.map(e=>Math.round(e*255))}function zt([e,t,n]){let r=Math.max(e,t,n),i=Math.min(e,t,n),a=(r+i)/2,o=0,s=0;if(r!==i){let c=r-i;switch(s=a>.5?c/(2-r-i):c/(r+i),r){case e:o=(t-n)/c+(t<n?6:0);break;case t:o=(n-e)/c+2;break;case n:o=(e-t)/c+4;break}o/=6}return[o,s,a]}function Bt(e,t,n){let r=[e,t,n].map(e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4);return .2126*r[0]+.7152*r[1]+.0722*r[2]}function Vt(e,t){return(Math.max(e,t)+.05)/(Math.min(e,t)+.05)}function Ht(e,t,n){let r,i,a;if(t===0)r=i=a=n;else{let o=(e,t,n)=>{let r=n;return r<0&&(r+=1),r>1&&--r,r<1/6?e+(t-e)*6*r:r<1/2?t:r<2/3?e+(t-e)*(2/3-r)*6:e},s=n<.5?n*(1+t):n+t-n*t,c=2*n-s;r=o(c,s,e+1/3),i=o(c,s,e),a=o(c,s,e-1/3)}return[r,i,a]}const Ut={r:1,g:1,b:1},Wt={r:0,g:0,b:0},Gt=Bt(Ut.r,Ut.g,Ut.b),Kt=Bt(Wt.r,Wt.g,Wt.b);function qt(e){let t=Vt(Gt,Bt(e[0],e[1],e[2])),n=zt(e),r=1-n[2],i,a,o;do i=Ht(n[0],n[1],r),a=Bt(i[0],i[1],i[2]),o=Vt(a,Kt),r+=.01;while(r<=1&&r>=0&&Math.abs(o-t)<.01);return i}function Jt(e){return Rt(qt(Lt(e)))}const w=[[.333,-.667,-.667,0,1],[-.667,.333,-.667,0,1],[-.667,-.667,.333,0,1],[0,0,0,1,0]];function Yt(e){let t=e[0],n=e[1],r=e[2],i=[w[0][0]*t+w[0][1]*n+w[0][2]*r+w[0][4],w[1][0]*t+w[1][1]*n+w[1][2]*r+w[1][4],w[2][0]*t+w[2][1]*n+w[2][2]*r+w[2][4]];return i=i.map(e=>e>1?1:e<0?0:e),i}function Xt(e){return Rt(Yt(Lt(e)))}var Zt=class{constructor(){C(this,`cursor`,0)}reset(){return this.cursor=0,this}moveCursor(e){this.cursor+=e}moveCursorTo(e){this.cursor=e}};function Qt(e,t){for(let n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}function $t(e){return/^-?\d+(\.\d+)?$/.test(e)}function en(e){return $t(e)?Number(e)<=2**53-1:!1}function tn(e){return Number(e)>2**53-1||e.length>=18}var nn=class e{constructor(){C(this,`_data`,[])}static create(){return new e}add(e){this._data.indexOf(e)>-1||this._data.push(e)}delete(e){let t=this._data.indexOf(e);this._data.splice(t,1)}getData(){return this._data}},rn=class e{constructor(){C(this,`_data`,new Map)}static create(){return new e}add(e,t){this._data.has(e)||this._data.set(e,t)}delete(e){this._data.delete(e)}getData(){return this._data}};function an(e){let t=new MessageChannel,n=!1,r=()=>{n||e()};return t.port1.onmessage=r,t.port2.postMessage(null),()=>{n=!0,t.port1.onmessage=null,t.port1.close(),t.port2.close()}}async function on(e){for(let[t,n]of e.entries())try{if(!await n())return{index:t,result:!1}}catch(e){return{index:t,result:!1,error:e}}return{result:!0,index:-1}}function sn(e){for(let[t,n]of e.entries())try{if(!n())return{index:t,result:!1}}catch(e){return{index:t,result:!1,error:e}}return{result:!0,index:-1}}function cn(e,t){return t.forEach(t=>e.add(t)),e}function ln(e){return e instanceof me||e instanceof y||e&&`closed`in e&&e.unsubscribe!==void 0}function T(e){let t=!1;return e?ln(e)?{dispose:()=>e.unsubscribe()}:typeof e==`function`?{dispose:()=>{t||(t=!0,e())}}:e:T(()=>{})}var un=class{constructor(){C(this,`_disposables`,new Set)}add(e){let t=T(e);return this._disposables.add(t),{dispose:(e=!1)=>{e||t.dispose(),this._disposables.delete(t)}}}dispose(){this._disposables.forEach(e=>{e.dispose()}),this._disposables.clear()}},E=class{constructor(){C(this,`_disposed`,!1),C(this,`_collection`,new un)}disposeWithMe(e){return this._collection.add(e)}ensureNotDisposed(){if(this._disposed)throw Error(`[Disposable]: object is disposed!`)}dispose(){this._disposed||(this._disposed=!0,this._collection.dispose())}},dn=class extends E{constructor(...e){super(...e),C(this,`dispose$`,new y)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}},fn=class extends E{constructor(e){super(),this._rootDisposable=e,C(this,`_ref`,0)}inc(){if(this._disposed)throw Error(`[RCDisposable]: should not ref to a disposed.`);this._ref+=1}dec(){--this._ref,this._ref===0&&(this._rootDisposable.dispose(),this.dispose())}},pn=class extends E{};const mn=new Set(`ac.ad.ae.aero.af.ag.ai.al.am.ao.aq.ar.arpa.as.asia.at.au.aw.ax.az.ba.bb.bd.be.bf.bg.bh.bi.biz.bj.bm.bn.bo.br.bs.bt.bv.bw.by.bz.ca.cat.cc.cd.cf.cg.ch.ci.ck.cl.cm.cn.co.com.coop.cr.cu.cv.cw.cx.cy.cz.de.dj.dk.dm.do.dz.ec.edu.ee.eg.er.es.et.eu.fi.fj.fk.fm.fo.fr.ga.gb.gd.ge.gf.gg.gh.gi.gl.gm.gn.gov.gp.gq.gr.gs.gt.gu.gw.gy.hk.hm.hn.hr.ht.hu.id.ie.il.im.in.info.int.io.iq.ir.is.it.je.jm.jo.jobs.jp.ke.kg.kh.ki.km.kn.kp.kr.kw.ky.kz.la.lb.lc.li.lk.lr.ls.lt.lu.lv.ly.ma.mc.md.me.mg.mh.mil.mk.ml.mm.mn.mo.mobi.mp.mq.mr.ms.mt.mu.museum.mv.mw.mx.my.mz.na.name.nc.ne.net.nf.ng.ni.nl.no.np.nr.nu.nz.om.onion.org.pa.pe.pf.pg.ph.pk.pl.pm.pn.post.pr.pro.ps.pt.pw.py.qa.re.ro.rs.ru.rw.sa.sb.sc.sd.se.sg.sh.si.sj.sk.sl.sm.sn.so.sr.ss.st.su.sv.sx.sy.sz.tc.td.tel.tf.tg.th.tj.tk.tl.tm.tn.to.tr.tt.tv.tw.tz.ua.ug.uk.us.uy.uz.va.vc.ve.vg.vi.vn.vu.wf.ws.yt.za.zm.zw`.split(`.`)),hn=RegExp(`^(?:(?:(?:https?|ftp):)?\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62})?[a-z0-9\\u00a1-\\uffff]\\.)+(?:[a-z\\u00a1-\\uffff]{2,}\\.?))(?::\\d{2,5})?(?:[/?#]\\S*)?$`,`i`);function gn(e){if(!Number.isNaN(+e))return!1;if(e.startsWith(`http://localhost:3002`)||e.startsWith(`localhost:3002`))return!0;if(hn.test(e)){if(_n(e))return!0;try{let t=new URL(yn(e)).hostname.split(`.`).pop();if(t&&mn.has(t))return!0}catch{return!1}}return!1}function _n(e){return/^[a-zA-Z]+:\/\//.test(e)}function vn(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function yn(e){return _n(e)?e:vn(e)?`mailto://${e}`:`https://${e}`}function bn(e,t){try{let n=new URL(t),r=n.pathname.endsWith(`/`)?n.pathname:`${n.pathname}/`,i=e.startsWith(`/`)?e.substring(1):e;return new URL(i,n.origin+r).toString()}catch(t){return console.error(`Error resolving URL with base URL:`,t),e}}function xn(e,t){return D.getValueType(e)===D.getValueType(t)?D.isArray(e)?Sn(e,t):D.isObject(e)?Cn(e,t):D.isDate(e)?e.getTime()===t.getTime():D.isRegExp(e)?e.toString()===t.toString():e===t:!1}function Sn(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++){let r=e[n],i=t[n];if(!xn(r,i))return!1}return!0}function Cn(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i of n){if(!r.includes(i))return!1;let n=e[i],a=t[i];if(!xn(n,a))return!1}return!0}var D=class e{static deleteNull(e){for(let t in e)(e[t]===null||e[t]===void 0)&&delete e[t];return e}static getSystemType(){let e=navigator.userAgent,t=navigator.platform===`Win32`||navigator.platform===`Windows`,n=navigator.platform===`Mac68K`||navigator.platform===`MacPPC`||navigator.platform===`Macintosh`||navigator.platform===`MacIntel`;if(n)return`Mac`;if(navigator.platform===`X11`&&!t&&!n)return`Unix`;if(String(navigator.platform).indexOf(`Linux`)>-1)return`Linux`;if(t){if(e.indexOf(`Windows NT 5.0`)>-1||e.indexOf(`Windows 2000`)>-1)return`Windows 2000`;if(e.indexOf(`Windows NT 5.1`)>-1||e.indexOf(`Windows XP`)>-1)return`Windows XP`;if(e.indexOf(`Windows NT 5.2`)>-1||e.indexOf(`Windows 2003`)>-1)return`Windows 2003`;if(e.indexOf(`Windows NT 6.0`)>-1||e.indexOf(`Windows Vista`)>-1)return`Windows Vista`;if(e.indexOf(`Windows NT 6.1`)>-1||e.indexOf(`Windows 7`)>-1)return`Windows 7`;if(e.indexOf(`Windows NT 10`)>-1||e.indexOf(`Windows 10`)>-1)return`Windows 10`;if(e.indexOf(`Windows NT 11`)>-1||e.indexOf(`Windows 11`)>-1)return`Windows 11`}return`Unknown system`}static getBrowserType(){let e=navigator.userAgent,t=e.indexOf(`Opera`)>-1,n=e.indexOf(`compatible`)>-1&&e.indexOf(`MSIE`)>-1&&!t,r=e.indexOf(`Trident`)>-1&&e.indexOf(`rv:11.0`)>-1,i=e.indexOf(`Edge`)>-1,a=e.indexOf(`Firefox`)>-1,o=e.indexOf(`Safari`)>-1&&e.indexOf(`Chrome`)===-1,s=e.indexOf(`Chrome`)>-1&&e.indexOf(`Safari`)>-1;if(n){RegExp(`MSIE (\\d+\\.\\d+);`).test(e);let t=Number.parseFloat(RegExp.$1);return t===7?`IE7`:t===8?`IE8`:t===9?`IE9`:t===10?`IE10`:`0`}return a?`FF`:t?`Opera`:o?`Safari`:s?`Chrome`:i?`Edge`:r?`IE11`:`Unknown browser`}static deepMerge(t,...n){n.forEach(e=>e&&a(e));function r(t,n){t.forEach((t,a)=>{if(e.isArray(t)){var o;let e=(o=n[a])==null?[]:o;n[a]=e,r(t,e);return}if(e.isObject(t)){var s;let e=(s=n[a])==null?{}:s;n[a]=e,i(t,e);return}n[a]=t})}function i(t,n){Object.keys(t).forEach(a=>{let o=t[a];if(e.isObject(o)){var s;let e=(s=n[a])==null?{}:s;n[a]=e,i(o,e);return}if(e.isArray(o)){var c;let e=(c=n[a])==null?[]:c;n[a]=e,r(o,e);return}n[a]=o})}function a(n){Object.keys(n).forEach(a=>{let o=n[a];if(e.isArray(o)){var s;let e=(s=t[a])==null?[]:s;t[a]=e,r(o,e);return}if(e.isObject(o)){var c;let e=(c=t[a])==null?{}:c;t[a]=e,i(o,e);return}t[a]=o})}return t}static diffValue(e,t){return xn(e,t)}static deepClone(t){if(!this.isDefine(t))return t;if(this.isRegExp(t))return new RegExp(t);if(this.isDate(t))return new Date(t);if(this.isArray(t)){let n=[];return t.forEach((t,r)=>{n[r]=e.deepClone(t)}),n}if(this.isObject(t)){let n={};return Object.keys(t).forEach(r=>{let i=t[r];n[r]=e.deepClone(i)}),Object.setPrototypeOf(n,Object.getPrototypeOf(t)),n}return t}static getValueType(e){return Object.prototype.toString.apply(e)}static isDefine(e){return e!=null}static isBlank(e){return this.isDefine(e)?this.isString(e)?e.trim()===``:!1:!0}static isPlainObject(e){return this.isDefine(e)?Object.getPrototypeOf(e)===Object.getPrototypeOf({}):!1}static isDate(e){return this.getValueType(e)===`[object Date]`}static isRegExp(e){return this.getValueType(e)===`[object RegExp]`}static isArray(e){return this.getValueType(e)===`[object Array]`}static isString(e){return this.getValueType(e)===`[object String]`}static isNumber(e){return this.getValueType(e)===`[object Number]`}static isStringNumber(e){return!isNaN(Number.parseFloat(e))&&isFinite(e)}static isObject(e){return this.getValueType(e)===`[object Object]`}static isEmptyObject(e){for(let t in e)return!1;return!0}static isTablet(){return/ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase())}static isIPhone(){return/iPhone/i.test(navigator.userAgent)}static isLegalUrl(e){return gn(e)}static normalizeUrl(e){return yn(e)}static topLevelDomainCombiningString(){return[...mn].join(`|`)}static removeNull(t){return this.isObject(t)&&Object.keys(t).forEach(n=>{let r=t[n];r==null?delete t[n]:e.removeNull(r)}),t}static numToWord(e){let t=``;for(;e>0;){let n=e%26;n=n===0?n=26:n,t=String.fromCharCode(96+n)+t,e=(e-n)/26}return t.toLocaleUpperCase()}static ABCatNum(e){if(e==null||e.length===0)return NaN;let t=e.toLowerCase().split(``),n=t.length,r=0,i=0;for(let e=0;e<n;e++)i=t[e].charCodeAt(0)-96,r+=i*26**(n-e-1);return r===0?NaN:r-1}static chatAtABC(e){let t=``;for(;e>=0;)t=String.fromCharCode(e%26+97)+t,e=Math.floor(e/26)-1;return t.toUpperCase()}static commonExtend(e,t){let n={};for(let t in e)n[t]=e[t];for(let e in t)t[e]!=null&&(n[e]=t[e]);return n}static hasIntersectionBetweenTwoRanges(e,t,n,r){return t>=n&&r>=e}static isStartValidPosition(e){return/^[A-Za-zА-Яа-яЁё_]/.test(e)}static isValidParameter(e){let t=/[~!@#$%^&*()+=\-{}\[\]\|:;"'<>,?\/ ]+/.test(e),n=e.length<=255;return!t&&n}static clamp(e,t,n){return Math.max(t,Math.min(n,e))}static now(){return performance&&performance.now?performance.now():Date.now()}};function O(e=21,t){return t?ke(t,e)():Ae(e)}function wn(...e){let t={},n=e.length;for(let r=n-1;r>=0;r--){let n=e[r];if(n){let e=Object.keys(n);for(let r of e)t[r]===void 0&&(t[r]=n[r])}}return t}const Tn=()=>typeof process<`u`&&process.versions!=null&&process.versions.node!=null;function En(e){let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/\\\*/g,`.*`).replace(/\\\?/g,`.`);return RegExp(`^${t}$`,`i`)}let Dn=function(e){return e[e.DEFAULT_SERIES=0]=`DEFAULT_SERIES`,e[e.ALTERNATE_SERIES=1]=`ALTERNATE_SERIES`,e}({}),k=function(e){return e[e.NONE=0]=`NONE`,e[e.THIN=1]=`THIN`,e[e.HAIR=2]=`HAIR`,e[e.DOTTED=3]=`DOTTED`,e[e.DASHED=4]=`DASHED`,e[e.DASH_DOT=5]=`DASH_DOT`,e[e.DASH_DOT_DOT=6]=`DASH_DOT_DOT`,e[e.DOUBLE=7]=`DOUBLE`,e[e.MEDIUM=8]=`MEDIUM`,e[e.MEDIUM_DASHED=9]=`MEDIUM_DASHED`,e[e.MEDIUM_DASH_DOT=10]=`MEDIUM_DASH_DOT`,e[e.MEDIUM_DASH_DOT_DOT=11]=`MEDIUM_DASH_DOT_DOT`,e[e.SLANT_DASH_DOT=12]=`SLANT_DASH_DOT`,e[e.THICK=13]=`THICK`,e}({}),On=function(e){return e.TOP=`top`,e.BOTTOM=`bottom`,e.LEFT=`left`,e.RIGHT=`right`,e.NONE=`none`,e.ALL=`all`,e.OUTSIDE=`outside`,e.INSIDE=`inside`,e.HORIZONTAL=`horizontal`,e.VERTICAL=`vertical`,e.TLBR=`tlbr`,e.TLBC_TLMR=`tlbc_tlmr`,e.TLBR_TLBC_TLMR=`tlbr_tlbc_tlmr`,e.BLTR=`bl_tr`,e.MLTR_BCTR=`mltr_bctr`,e}({}),kn=function(e){return e[e.UNSUPPORTED=0]=`UNSUPPORTED`,e[e.RGB=1]=`RGB`,e[e.HEX=2]=`HEX`,e[e.THEME=3]=`THEME`,e}({}),An=function(e){return e[e.ON=0]=`ON`,e[e.OFF=1]=`OFF`,e}({}),jn=function(e){return e[e.PASTE_NORMAL=0]=`PASTE_NORMAL`,e[e.PASTE_NO_BORDERS=1]=`PASTE_NO_BORDERS`,e[e.PASTE_FORMAT=2]=`PASTE_FORMAT`,e[e.PASTE_FORMULA=3]=`PASTE_FORMULA`,e[e.PASTE_DATA_VALIDATION=4]=`PASTE_DATA_VALIDATION`,e[e.PASTE_VALUES=5]=`PASTE_VALUES`,e[e.PASTE_CONDITIONAL_FORMATTING=6]=`PASTE_CONDITIONAL_FORMATTING`,e[e.PASTE_COLUMN_WIDTHS=7]=`PASTE_COLUMN_WIDTHS`,e}({}),Mn=function(e){return e[e.LEFT=0]=`LEFT`,e[e.RIGHT=1]=`RIGHT`,e}({}),Nn=function(e){return e[e.DOCUMENT=0]=`DOCUMENT`,e[e.PROJECT=1]=`PROJECT`,e}({}),Pn=function(e){return e[e.COLUMNS=0]=`COLUMNS`,e[e.ROWS=1]=`ROWS`,e}({}),Fn=function(e){return e[e.UP=0]=`UP`,e[e.RIGHT=1]=`RIGHT`,e[e.DOWN=2]=`DOWN`,e[e.LEFT=3]=`LEFT`,e}({});function In(e){switch(e){case Fn.LEFT:return Fn.RIGHT;case Fn.RIGHT:return Fn.LEFT;case Fn.UP:return Fn.DOWN;case Fn.DOWN:return Fn.UP}}let Ln=function(e){return e[e.INTERPOLATION_POINT_TYPE_UNSPECIFIED=0]=`INTERPOLATION_POINT_TYPE_UNSPECIFIED`,e[e.MIN=1]=`MIN`,e[e.MAX=2]=`MAX`,e[e.NUMBER=3]=`NUMBER`,e[e.PERCENT=4]=`PERCENT`,e[e.PERCENTILE=5]=`PERCENTILE`,e}({}),Rn=function(e){return e.EN_US=`enUS`,e.FR_FR=`frFR`,e.ZH_CN=`zhCN`,e.RU_RU=`ruRU`,e.ZH_TW=`zhTW`,e.VI_VN=`viVN`,e.FA_IR=`faIR`,e.JA_JP=`jaJP`,e.KO_KR=`koKR`,e.ES_ES=`esES`,e.CA_ES=`caES`,e.SK_SK=`skSK`,e}({}),zn=function(e){return e[e.PERSON=0]=`PERSON`,e[e.FILE=1]=`FILE`,e[e.DATE=2]=`DATE`,e[e.LOCATION=3]=`LOCATION`,e[e.EVENT=4]=`EVENT`,e}({}),Bn=function(e){return e[e.RANGE=0]=`RANGE`,e[e.SHEET=1]=`SHEET`,e}({}),Vn=function(e){return e.Line=`line`,e.LineInv=`lineInv`,e.Triangle=`triangle`,e.RtTriangle=`rtTriangle`,e.Rect=`rect`,e.Diamond=`diamond`,e.Parallelogram=`parallelogram`,e.Trapezoid=`trapezoid`,e.NonIsocelesTrapezoid=`nonIsocelesTrapezoid`,e.Pentagon=`pentagon`,e.Hexagon=`hexagon`,e.Heptagon=`heptagon`,e.Octagon=`octagon`,e.Decagon=`decagon`,e.Dodecagon=`dodecagon`,e.Star4=`star4`,e.Star5=`star5`,e.Star6=`star6`,e.Star7=`star7`,e.Star8=`star8`,e.Star10=`star10`,e.Star12=`star12`,e.Star16=`star16`,e.Star24=`star24`,e.Star32=`star32`,e.RoundRect=`roundRect`,e.Round1Rect=`round1Rect`,e.Round2SameRect=`round2SameRect`,e.Round2DiagRect=`round2DiagRect`,e.Ellipse=`ellipse`,e}({}),Hn=function(e){return e.RightArrow=`rightArrow`,e.LeftArrow=`leftArrow`,e.UpArrow=`upArrow`,e.DownArrow=`downArrow`,e.LeftRightArrow=`leftRightArrow`,e.UpDownArrow=`upDownArrow`,e.QuadArrow=`quadArrow`,e.LeftRightUpArrow=`leftRightUpArrow`,e.BentArrow=`bentArrow`,e.UturnArrow=`uturnArrow`,e.CircularArrow=`circularArrow`,e.NotchedRightArrow=`notchedRightArrow`,e.HomePlate=`homePlate`,e.Chevron=`chevron`,e.LeftCircularArrow=`leftCircularArrow`,e.LeftRightCircularArrow=`leftRightCircularArrow`,e}({}),Un=function(e){return e.Plaque=`plaque`,e.Can=`can`,e.Cube=`cube`,e.Bevel=`bevel`,e.Donut=`donut`,e.NoSmoking=`noSmoking`,e.BlockArc=`blockArc`,e.FoldedCorner=`foldedCorner`,e}({}),Wn=function(e){return e.SmileyFace=`smileyFace`,e.Heart=`heart`,e.LightningBolt=`lightningBolt`,e.Sun=`sun`,e.Moon=`moon`,e.Cloud=`cloud`,e.Arc=`arc`,e.Backpack=`backpack`,e.Frame=`frame`,e.HalfFrame=`halfFrame`,e.Corner=`corner`,e.Chord=`chord`,e.Pie=`pie`,e.Teardrop=`teardrop`,e.WedgeRectCallout=`wedgeRectCallout`,e.WedgeRRectCallout=`wedgeRRectCallout`,e.WedgeEllipseCallout=`wedgeEllipseCallout`,e.CloudCallout=`cloudCallout`,e.BorderCallout1=`borderCallout1`,e.BorderCallout2=`borderCallout2`,e.BorderCallout3=`borderCallout3`,e.AccentCallout1=`accentCallout1`,e.AccentCallout2=`accentCallout2`,e.AccentCallout3=`accentCallout3`,e.Callout1=`callout1`,e.Callout2=`callout2`,e.Callout3=`callout3`,e.ActionButtonBackPrevious=`actionButtonBackPrevious`,e.ActionButtonEnd=`actionButtonEnd`,e.ActionButtonForwardNext=`actionButtonForwardNext`,e.ActionButtonHelp=`actionButtonHelp`,e.ActionButtonHome=`actionButtonHome`,e.ActionButtonInformation=`actionButtonInformation`,e.ActionButtonMovie=`actionButtonMovie`,e.ActionButtonReturn=`actionButtonReturn`,e.ActionButtonSound=`actionButtonSound`,e}({}),Gn=function(e){return e[e.RELATIVE_DATE_UNSPECIFIED=0]=`RELATIVE_DATE_UNSPECIFIED`,e[e.PAST_YEAR=1]=`PAST_YEAR`,e[e.PAST_MONTH=2]=`PAST_MONTH`,e[e.PAST_WEEK=3]=`PAST_WEEK`,e[e.YESTERDAY=4]=`YESTERDAY`,e[e.TODAY=5]=`TODAY`,e[e.TOMORROW=6]=`TOMORROW`,e}({}),Kn=function(e){return e[e.GRID=0]=`GRID`,e[e.KANBAN=1]=`KANBAN`,e[e.GANTT=2]=`GANTT`,e}({}),qn=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.LEFT_TO_RIGHT=1]=`LEFT_TO_RIGHT`,e[e.RIGHT_TO_LEFT=2]=`RIGHT_TO_LEFT`,e}({}),Jn=function(e){return e[e.DASH=0]=`DASH`,e[e.DASH_DOT_DOT_HEAVY=1]=`DASH_DOT_DOT_HEAVY`,e[e.DASH_DOT_HEAVY=2]=`DASH_DOT_HEAVY`,e[e.DASHED_HEAVY=3]=`DASHED_HEAVY`,e[e.DASH_LONG=4]=`DASH_LONG`,e[e.DASH_LONG_HEAVY=5]=`DASH_LONG_HEAVY`,e[e.DOT_DASH=6]=`DOT_DASH`,e[e.DOT_DOT_DASH=7]=`DOT_DOT_DASH`,e[e.DOTTED=8]=`DOTTED`,e[e.DOTTED_HEAVY=9]=`DOTTED_HEAVY`,e[e.DOUBLE=10]=`DOUBLE`,e[e.NONE=11]=`NONE`,e[e.SINGLE=12]=`SINGLE`,e[e.THICK=13]=`THICK`,e[e.WAVE=14]=`WAVE`,e[e.WAVY_DOUBLE=15]=`WAVY_DOUBLE`,e[e.WAVY_HEAVY=16]=`WAVY_HEAVY`,e[e.WORDS=17]=`WORDS`,e}({}),Yn=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.LEFT=1]=`LEFT`,e[e.CENTER=2]=`CENTER`,e[e.RIGHT=3]=`RIGHT`,e[e.JUSTIFIED=4]=`JUSTIFIED`,e[e.BOTH=5]=`BOTH`,e[e.DISTRIBUTED=6]=`DISTRIBUTED`,e}({}),Xn=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.TOP=1]=`TOP`,e[e.MIDDLE=2]=`MIDDLE`,e[e.BOTTOM=3]=`BOTTOM`,e}({}),Zn=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.OVERFLOW=1]=`OVERFLOW`,e[e.CLIP=2]=`CLIP`,e[e.WRAP=3]=`WRAP`,e}({}),Qn=function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.ITALIC=1]=`ITALIC`,e}({}),$n=function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.BOLD=1]=`BOLD`,e}({}),er=function(e){return e[e.NORMAL=1]=`NORMAL`,e[e.SUBSCRIPT=2]=`SUBSCRIPT`,e[e.SUPERSCRIPT=3]=`SUPERSCRIPT`,e}({}),A=function(e){return e[e.FALSE=0]=`FALSE`,e[e.TRUE=1]=`TRUE`,e}({}),tr=function(e){return e[e.STRING=1]=`STRING`,e[e.NUMBER=2]=`NUMBER`,e[e.BOOLEAN=3]=`BOOLEAN`,e[e.FORCE_STRING=4]=`FORCE_STRING`,e}({}),j=function(e){return e[e.DARK1=0]=`DARK1`,e[e.LIGHT1=1]=`LIGHT1`,e[e.DARK2=2]=`DARK2`,e[e.LIGHT2=3]=`LIGHT2`,e[e.ACCENT1=4]=`ACCENT1`,e[e.ACCENT2=5]=`ACCENT2`,e[e.ACCENT3=6]=`ACCENT3`,e[e.ACCENT4=7]=`ACCENT4`,e[e.ACCENT5=8]=`ACCENT5`,e[e.ACCENT6=9]=`ACCENT6`,e[e.HYPERLINK=10]=`HYPERLINK`,e[e.FOLLOWED_HYPERLINK=11]=`FOLLOWED_HYPERLINK`,e}({}),nr=function(e){return e.OFFICE=`Office`,e.OFFICE_2007_2010=`Office 2007-2010`,e.GRAYSCALE=`Grayscale`,e.BLUE_WARM=`Blue Warm`,e.BLUE=`Blue`,e.BLUE_II=`Blue II`,e.BLUE_GREEN=`Blue Green`,e.GREEN=`Green`,e.GREEN_YELLOW=`Green Yellow`,e.YELLOW=`Yellow`,e.YELLOW_ORANGE=`Yellow Orange`,e.ORANGE=`Orange`,e.ORANGE_RED=`Orange Red`,e.RED_ORANGE=`Red Orange`,e.RED=`Red`,e.RED_VIOLET=`Red Violet`,e.VIOLET=`Violet`,e.VIOLET_II=`Violet II`,e.MEDIAN=`Median`,e.PAPER=`Paper`,e.MARQUEE=`Marquee`,e.SLIPSTREAM=`Slipstream`,e.Aspect=`Aspect`,e}({}),rr=function(e){return e[e.character=0]=`character`,e[e.paragraph=1]=`paragraph`,e[e.table=2]=`table`,e[e.numbering=3]=`numbering`,e}({}),ir=function(e){return e[e.TAB=0]=`TAB`,e[e.SPACE=1]=`SPACE`,e[e.NOTHING=2]=`NOTHING`,e}({}),M=function(e){return 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}({}),ar=function(e){return 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}({}),or=function(e){return 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}({}),sr=function(e){return e[e.COMMENT=0]=`COMMENT`,e[e.DELETED=9999]=`DELETED`,e}({}),cr=function(e){return e[e.DRAWING=0]=`DRAWING`,e[e.CUSTOM=1]=`CUSTOM`,e}({}),lr=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.TRADITIONAL=1]=`TRADITIONAL`,e[e.MODERN=2]=`MODERN`,e}({}),ur=function(e){return 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}({}),dr=function(e){return 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}({}),fr=function(e){return 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}({}),pr=function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.TBRL=1]=`TBRL`,e[e.LRTBV=2]=`LRTBV`,e}({}),mr=function(e){return 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}({}),hr=function(e){return e[e.BOTH_SIDES=0]=`BOTH_SIDES`,e[e.LEFT=1]=`LEFT`,e[e.RIGHT=2]=`RIGHT`,e[e.LARGEST=3]=`LARGEST`,e}({}),gr=function(e){return 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}({}),N=function(e){return 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}({}),_r=function(e){return e[e.AUTO=0]=`AUTO`,e[e.AT_LEAST=1]=`AT_LEAST`,e[e.EXACT=2]=`EXACT`,e}({}),vr=function(e){return 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}({}),yr=function(e){return 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}({}),br=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.SPECIFIED=1]=`SPECIFIED`,e}({}),xr=function(e){return e[e.START=0]=`START`,e[e.CENTER=1]=`CENTER`,e[e.END=2]=`END`,e}({}),Sr=function(e){return e[e.AUTO_FIT=0]=`AUTO_FIT`,e[e.FIXED=1]=`FIXED`,e}({}),Cr=function(e){return e[e.NONE=0]=`NONE`,e[e.WRAP=1]=`WRAP`,e}({}),wr=function(e){return e[e.AUTO=0]=`AUTO`,e[e.AT_LEAST=1]=`AT_LEAST`,e[e.EXACT=2]=`EXACT`,e}({}),Tr=function(e){return 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}({}),Er=function(e){return e.NORMAL=`normal`,e.BOLD=`bold`,e.ITALIC=`italic`,e}({}),Dr=function(e){return 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}({}),Or=function(e){return 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}({}),kr=function(e){return 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}({}),Ar=function(e){return 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}({}),jr=function(e){return 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}({}),Mr=function(e){return e[e.compressPunctuation=0]=`compressPunctuation`,e[e.compressPunctuationAndJapaneseKana=1]=`compressPunctuationAndJapaneseKana`,e[e.doNotCompress=2]=`doNotCompress`,e}({}),Nr=function(e){return e[e.PORTRAIT=0]=`PORTRAIT`,e[e.LANDSCAPE=1]=`LANDSCAPE`,e}({}),P=function(e){return e.Letter=`Letter`,e.Tabloid=`Tabloid`,e.Legal=`Legal`,e.Statement=`Statement`,e.Executive=`Executive`,e.Folio=`Folio`,e.A3=`A3`,e.A4=`A4`,e.A5=`A5`,e.B4=`B4`,e.B5=`B5`,e}({});const Pr=[P.A3,P.A4,P.A5,P.B4,P.B5,P.Letter,P.Tabloid,P.Legal,P.Statement,P.Executive,P.Folio];let Fr=function(e){return e[e.forward=0]=`forward`,e[e.backward=1]=`backward`,e[e.front=2]=`front`,e[e.back=3]=`back`,e}({}),Ir=function(e){return 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}({}),Lr=function(e){return 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}({}),Rr=function(e){return 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}({}),zr=function(e){return 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}({});function Br(){return e=>e}const Vr=Br()([`s`,`c`,`cl`,`t`]),Hr=Br()([`rgb`,`th`]),Ur=Br()([`s`,`cl`]),Wr=Br()([`t`,`r`,`b`,`l`,`tl_br`,`tl_bc`,`tl_mr`,`bl_tr`,`ml_tr`,`bc_tr`]),Gr=Br()([`a`,`v`]),Kr=Br()([`t`,`r`,`b`,`l`]),qr=Br()([`ff`,`fs`,`it`,`bl`,`ul`,`bbl`,`st`,`ol`,`bg`,`bd`,`cl`,`va`,`n`,`tr`,`td`,`ht`,`vt`,`tb`,`pd`]);function Jr(e=O(6),t=Rn.EN_US,n=``){return{id:e,locale:t,title:n,tableSource:{},drawings:{},drawingsOrder:[],headers:{},footers:{},body:{dataStream:`\r
|
|
3
|
+
`,textRuns:[],customBlocks:[],tables:[],paragraphs:[{startIndex:0,paragraphStyle:{spaceAbove:{v:5},lineSpacing:1,spaceBelow:{v:0}}}],sectionBreaks:[{startIndex:1}]},documentStyle:{pageSize:{width:595/.75,height:842/.75},documentFlavor:lr.TRADITIONAL,marginTop:50,marginBottom:50,marginRight:50,marginLeft:50,renderConfig:{zeroWidthParagraphBreak:A.FALSE,vertexAngle:0,centerAngle:0,background:{rgb:`#ccc`}},autoHyphenation:A.TRUE,doNotHyphenateCaps:A.FALSE,consecutiveHyphenLimit:2,defaultHeaderId:``,defaultFooterId:``,evenPageHeaderId:``,evenPageFooterId:``,firstPageHeaderId:``,firstPageFooterId:``,evenAndOddHeaders:A.FALSE,useFirstPageHeaderFooter:A.FALSE,marginHeader:30,marginFooter:30},settings:{}}}let F=function(e){return e[e.COVER=0]=`COVER`,e[e.REPLACE=1]=`REPLACE`,e}({}),I=function(e){return e.RETAIN=`r`,e.INSERT=`i`,e.DELETE=`d`,e}({});const Yr=m(`univer.config-service`);var Xr=class{constructor(){C(this,`_configChanged$`,new y),C(this,`configChanged$`,this._configChanged$.asObservable()),C(this,`_config`,new Map)}dispose(){this._config.clear(),this._configChanged$.complete()}getConfig(e){return this._config.get(e)}setConfig(e,t,n){var r;let{merge:i=!1}=n||{},a=(r=this._config.get(e))==null?{}:r;a=i?le(a,t):t,this._config.set(e,a),this._configChanged$.next({[e]:a})}deleteConfig(e){return this._config.delete(e)}subscribeConfigValue$(e){return new fe(t=>{Object.prototype.hasOwnProperty.call(this._config,e)&&t.next(this._config.get(e));let n=this.configChanged$.pipe(ve(t=>Object.prototype.hasOwnProperty.call(t,e))).subscribe(n=>t.next(n[e]));return()=>n.unsubscribe()})}};const Zr=m(`univer.context-service`);var Qr=class extends E{constructor(...e){super(...e),C(this,`_contextChanged$`,new y),C(this,`contextChanged$`,this._contextChanged$.asObservable()),C(this,`_contextMap`,new Map)}dispose(){super.dispose(),this._contextChanged$.complete(),this._contextMap.clear()}getContextValue(e){var t;return(t=this._contextMap.get(e))==null?!1:t}setContextValue(e,t){this._contextMap.set(e,t),this._contextChanged$.next({[e]:t})}subscribeContextValue$(e){return new fe(t=>{let n=this._contextChanged$.pipe(ve(t=>t[e]!==void 0)).subscribe(n=>t.next(n[e]));return this._contextMap.has(e)&&t.next(this._contextMap.get(e)),()=>n.unsubscribe()})}};let $r=function(e){return e[e.SILENT=0]=`SILENT`,e[e.ERROR=1]=`ERROR`,e[e.WARN=2]=`WARN`,e[e.INFO=3]=`INFO`,e[e.VERBOSE=4]=`VERBOSE`,e}({});const L=m(`univer.log`);var ei=class extends E{constructor(...e){super(...e),C(this,`_logLevel`,$r.INFO),C(this,`_deduction`,new Set)}dispose(){super.dispose(),this._logLevel=$r.INFO,this._deduction.clear()}debug(...e){this._logLevel>=$r.VERBOSE&&this._log(console.debug,...e)}log(...e){this._logLevel>=$r.INFO&&this._log(console.log,...e)}warn(...e){this._logLevel>=$r.WARN&&this._log(console.warn,...e)}error(...e){this._logLevel>=$r.ERROR&&this._log(console.error,...e)}deprecate(...e){this._logLevel>=$r.WARN&&this._logWithDeduplication(console.error,...e)}setLogLevel(e){this._logLevel=e}_log(e,...t){let n=t[0];/^\[(.*?)\]/g.test(n)?e(`\x1B[97;104m${n}\x1B[0m`,...t.slice(1)):e(...t)}_logWithDeduplication(e,...t){let n=ti(...t);this._deduction.has(n)||(this._deduction.add(n),this._log(e,...t))}};function ti(...e){return e.map(e=>JSON.stringify(e)).join(``)}function R(e,t){return function(n,r){t(n,r,e)}}function z(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}const ni=`command.logExecution`;let ri=function(e){return e[e.COMMAND=0]=`COMMAND`,e[e.OPERATION=1]=`OPERATION`,e[e.MUTATION=2]=`MUTATION`,e}({});const ii=m(`univer.core.command-service`);var ai=class{constructor(){C(this,`_commands`,new Map),C(this,`_commandTypes`,new Map)}registerCommand(e){if(this._commands.has(e.id))throw Error(`[CommandRegistry]: command "${e.id}" has been registered before.`);return this._commands.set(e.id,e),this._commandTypes.set(e.id,e.type),T(()=>{this.unregisterCommand(e.id)})}unregisterCommand(e){this._commands.delete(e),this._commandTypes.delete(e)}hasCommand(e){return this._commands.has(e)}getCommand(e){return this._commands.has(e)?[this._commands.get(e)]:null}getCommandType(e){return this._commandTypes.get(e)}};const oi={id:`nil`,type:ri.COMMAND,handler:()=>!0};let si=class extends E{constructor(e,t,n){super(),this._injector=e,this._logService=t,this._configService=n,C(this,`_commandRegistry`,void 0),C(this,`_beforeCommandExecutionListeners`,[]),C(this,`_commandExecutedListeners`,[]),C(this,`_collabMutationListeners`,[]),C(this,`_multiCommandDisposables`,new Map),C(this,`_commandExecutingLevel`,0),C(this,`_commandExecutionStack`,[]),this._commandRegistry=new ai,this.registerCommand(oi)}dispose(){super.dispose(),this._commandExecutedListeners.length=0,this._beforeCommandExecutionListeners.length=0,this._collabMutationListeners.length=0}disposed(){return this._disposed}hasCommand(e){return this._commandRegistry.hasCommand(e)}registerCommand(e){return this._commandRegistry.registerCommand(e)}unregisterCommand(e){var t;this._commandRegistry.unregisterCommand(e),(t=this._multiCommandDisposables.get(e))==null||t.dispose()}registerMultipleCommand(e){return this._registerMultiCommand(e)}beforeCommandExecuted(e){if(this._beforeCommandExecutionListeners.indexOf(e)===-1)return this._beforeCommandExecutionListeners.push(e),T(()=>{let t=this._beforeCommandExecutionListeners.indexOf(e);this._beforeCommandExecutionListeners.splice(t,1)});throw Error(`[CommandService]: could not add a listener twice.`)}onCommandExecuted(e){if(this._commandExecutedListeners.indexOf(e)===-1)return this._commandExecutedListeners.push(e),T(()=>{let t=this._commandExecutedListeners.indexOf(e);this._commandExecutedListeners.splice(t,1)});throw Error(`[CommandService]: could not add a listener twice.`)}onMutationExecutedForCollab(e){if(this._collabMutationListeners.indexOf(e)===-1)return this._collabMutationListeners.push(e),T(()=>{let t=this._collabMutationListeners.indexOf(e);this._collabMutationListeners.splice(t,1)});throw Error(`[CommandService]: could not add a collab mutation listener twice.`)}async executeCommand(e,t,n){try{let r=this._commandRegistry.getCommand(e);if(r){let[e]=r,i={id:e.id,type:e.type,params:t},a=this._pushCommandExecutionStack(i),o=n==null?{}:n;this._beforeCommandExecutionListeners.forEach(e=>e(i,o));let s=await this._execute(e,t,o);return o.syncOnly||this._commandExecutedListeners.forEach(e=>e(i,o)),e.type===ri.MUTATION&&this._collabMutationListeners.forEach(e=>e(i,o)),a.dispose(),s}throw Error(`[CommandService]: command "${e}" is not registered.`)}catch(e){if(e instanceof wt)return!1;throw e}}syncExecuteCommand(e,t,n){try{let i=this._commandRegistry.getCommand(e);if(i){let[e]=i,a={id:e.id,type:e.type,params:t};if(e.type===ri.MUTATION){let e=it(this._commandExecutionStack,e=>e.type===ri.COMMAND);if(e){var r;a.params=(r=a.params)==null?{}:r,a.params.trigger=e.id}}let o=this._pushCommandExecutionStack(a),s=n==null?{}:n;this._beforeCommandExecutionListeners.forEach(e=>e(a,s));let c=this._syncExecute(e,t,s);return s.syncOnly||this._commandExecutedListeners.forEach(e=>e(a,s)),e.type===ri.MUTATION&&this._collabMutationListeners.forEach(e=>e(a,s)),o.dispose(),c}throw Error(`[CommandService]: command "${e}" is not registered.`)}catch(e){if(e instanceof wt)return!1;throw e}}_pushCommandExecutionStack(e){return this._commandExecutionStack.push(e),T(()=>tt(this._commandExecutionStack,e))}_registerMultiCommand(e){let t=this._commandRegistry.getCommand(e.id),n;if(!t){n=new ci(e.id);let t=new un;t.add(this._commandRegistry.registerCommand(n)),t.add(T(()=>{this._multiCommandDisposables.delete(e.id)})),this._multiCommandDisposables.set(e.id,t)}else if(t[0].multi!==!0)throw Error(`Command has registered as a single command.`);else n=t[0];let r=n.registerImplementation(e);return T(()=>{if(r.dispose(),!n.hasImplementations()){var t;(t=this._multiCommandDisposables.get(e.id))==null||t.dispose()}})}async _execute(e,t,n){if(n!=null&&n.syncOnly)return!0;this._configService.getConfig(`command.logExecution`)!==!1&&this._logService.debug(`[CommandService]`,`${`|-`.repeat(Math.max(this._commandExecutingLevel,0))}executing command "${e.id}"`),this._commandExecutingLevel++;let r;try{r=await this._injector.invoke(e.handler,t,n),this._commandExecutingLevel--}catch(e){throw r=!1,this._commandExecutingLevel=0,e}return r}_syncExecute(e,t,n){if(n!=null&&n.syncOnly)return!0;this._configService.getConfig(`command.logExecution`)!==!1&&this._logService.debug(`[CommandService]`,`${`|-`.repeat(Math.max(0,this._commandExecutingLevel))}executing command "${e.id}".`),this._commandExecutingLevel++;let r;try{if(r=this._injector.invoke(e.handler,t,n),r instanceof Promise)throw TypeError(`[CommandService]: Command handler should not return a promise.`);this._commandExecutingLevel--}catch(e){throw r=!1,this._commandExecutingLevel=0,e}return r}};si=z([R(0,t(i)),R(1,L),R(2,Yr)],si);var ci=class{constructor(e){this.id=e,C(this,`name`,void 0),C(this,`multi`,!0),C(this,`type`,ri.COMMAND),C(this,`priority`,0),C(this,`_implementations`,[]),C(this,`handler`,async(e,t)=>{if(!this._implementations.length)return!1;let n=e.get(L),r=e.get(Zr),a=e.get(i);for(let e of this._implementations){let i=e.command.preconditions;if((!i||i&&i(r))&&(n.debug(`[MultiCommand]`,`executing implementation "${e.command.name}".`),await a.invoke(e.command.handler,t)))return!0}return!1}),this.name=e}registerImplementation(e){let t={command:e};return this._implementations.push(t),this._implementations.sort((e,t)=>t.command.priority-e.command.priority),T(()=>{let e=this._implementations.indexOf(t);this._implementations.splice(e,1)})}hasImplementations(){return this._implementations.length>0}};function li(e,t,n){return sn(e.map(e=>()=>t.syncExecuteCommand(e.id,e.params,n)))}function ui(e,t,n){return on(e.map(e=>()=>t.executeCommand(e.id,e.params,n)))}function di(e){return new fe(t=>{let n=e((...e)=>t.next(e));return()=>n==null?void 0:n.dispose()})}function fi(e){return function(t){return new fe(n=>(t.subscribe({next:t=>{n.next(t),e(t)&&n.complete()},complete:()=>n.complete(),error:e=>n.error(e)}),()=>n.unsubscribe()))}}function pi(e=0){return t=>{let n=[];return t.pipe(Te(e=>n.push(e)),ge(e),be(()=>n),Te(()=>n=[]))}}function mi(e){let t=new pe(1);return setTimeout(()=>t.next(),e),t.pipe(we(1))}function hi(e,t){let n=new v(t);return e.subscribe(n),n}const gi=e=>new Promise(t=>{xe(di(e.onCommandExecuted.bind(e)).pipe(Me(([e])=>e.type===ri.MUTATION)),Ee(300)).pipe(je(16),Ne()).subscribe(()=>{t()})});function _i(e,t){let n=0,r=e.length-1;if(t<e[0])return 0;if(t>=e[e.length-1])return e.length-1;for(;n<=r;){if(e[n]===t){for(;n<e.length&&e[n]===t;)n++;return n}if(t>e[n]&&t<e[n+1])return n+1;if(e[r]===t){for(;r<e.length&&e[r]===t;)r++;return r}if(t>e[r-1]&&t<e[r])return r;n++,r--}return-1}function vi(e,t){let n=0,r=e.length-1;for(;n<=r;){let i=Math.floor((r+n)/2);if(t<e[i]&&(i===0||t>=e[i-1]))return i;if(t>=e[i])n=i+1;else if(t<e[i])r=i-1;else return-1}return-1}function yi(e,t){let n=0,r=e.length;for(;n<r;){let i=Math.floor((n+r)/2);e[i]<=t?n=i+1:r=i}return n<e.length?n:e.length-1}function bi(e,t,n=!1){let r=e.length-1;if(t<0||t<e[0])return 0;if(r=e.length<40||t<=e[20]||t>=e[r-20]?_i(e,t):yi(e,t),n){let t=e[r];return e.indexOf(t)}return r}function xi(e){let t=new Blob([e],{type:`text/javascript`});return window.URL.createObjectURL(t)}const Si=2,Ci=1;function wi(e,t){if(t==null||e==null)return!0;let{left:n=0,top:r=0,height:i=0,width:a=0,angle:o=0}=t,{left:s=0,top:c=0,height:l=0,width:u=0,angle:d=0}=e,f=u,p=l,m=a,h=i;return Math.abs(s-n)>2||Math.abs(c-r)>2||Math.abs(f-m)>2||Math.abs(p-h)>2||Math.abs(d-o)>1}const Ti=`rgb(`,Ei=`rgba(`,Di={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchealmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],darkyellow:[139,128,0],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midbightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]};var Oi=class e{static mix(t,n,r){var i,a;r=Math.min(1,Math.max(0,r));let o=new e(t).toRgb(),s=new e(n).toRgb(),c=(i=o.a)==null?1:i,l=(a=s.a)==null?1:a;return new e({r:(s.r-o.r)*r+o.r,g:(s.g-o.g)*r+o.g,b:(s.b-o.b)*r+o.b,a:(l-c)*r+c})}static getContrastRatio(t,n){let r=new e(t).getLuminance(),i=new e(n).getLuminance();return(Math.max(r,i)+.05)/(Math.min(r,i)+.05)}constructor(t){if(C(this,`_color`,void 0),C(this,`_rgbColor`,void 0),C(this,`_isValid`,!1),t==null){this._setNullColor();return}if(t instanceof e){this._color={...t._color},this._rgbColor={...t._rgbColor};return}let n=ji(t);if(n==null){this._setNullColor();return}this._color=n;let r=Ii(this._color);if(r==null){this._setNullColor();return}this._rgbColor=r,this._isValid=!0}get isValid(){return this._isValid}toRgb(){return this._rgbColor}toRgbString(){let{r:e,g:t,b:n,a:r=1}=this.toRgb(),i=r<1;return`rgb${i?`a`:``}(${e},${t},${n}${i?`,${r}`:``})`}toString(){return this.toRgbString()}toHexString(e){let{r:t,g:n,b:r,a:i=1}=this.toRgb(),a=i<1,o=[ki(Math.round(t).toString(16)),ki(Math.round(n).toString(16)),ki(Math.round(r).toString(16)),ki(Math.round(i*255).toString(16))];return e&&o[0][0]===o[0][1]&&o[1][0]===o[1][1]&&o[2][0]===o[2][1]&&o[3][0]===o[3][1]?a?`#${o[0][0]}${o[1][0]}${o[2][0]}${o[3][0]}`:`#${o[0][0]}${o[1][0]}${o[2][0]}`:a?`#${o[0]}${o[1]}${o[2]}${o[3]}`:`#${o[0]}${o[1]}${o[2]}`}toHsv(){return Vi(this.toRgb())}toHsl(){return Bi(this.toRgb())}lighten(t=10){let n=this.toHsl();return n.l+=t,n.l=Math.min(Math.max(n.l,0),100),new e(n)}darken(t=10){let n=this.toHsl();return n.l-=t,n.l=Math.min(Math.max(n.l,0),100),new e(n)}setAlpha(t){return new e({...this._rgbColor,a:t})}getLuminance(){let{r:e,g:t,b:n}=this.toRgb();return e=Ai(e),t=Ai(t),n=Ai(n),Number((.2126*e+.7152*t+.0722*n).toFixed(3))}getBrightness(){let{r:e,g:t,b:n}=this.toRgb();return(e*299+t*587+n*114)/1e3}getAlpha(){var e;return(e=this._color.a)==null?1:e}isDark(){return this.getBrightness()<128}isLight(){return!this.isDark()}_setNullColor(){this._isValid=!1,this._color={r:0,g:0,b:0,a:0},this._rgbColor={r:0,g:0,b:0,a:0}}};const ki=e=>e.length===1?`0${e}`:e,Ai=e=>(e/=255,e<=.03928?e/12.92:((e+.055)/1.055)**2.4),ji=e=>{if(Ui(e)){if(`r`in e){let t={r:Math.round(e.r),g:Math.round(e.g),b:Math.round(e.b)};return e.a!==void 0&&(t.a=e.a),t}if(`l`in e){let t={h:Math.round(e.h),s:e.s,l:e.l};return e.a!==void 0&&(t.a=e.a),t}let t={h:Math.round(e.h),s:e.s,v:e.v};return e.a!==void 0&&(t.a=e.a),t}let t=e.trim().toLowerCase();if(Di[t]){let e=Di[t],n={r:Math.round(e[0]),g:Math.round(e[1]),b:Math.round(e[2])};return n.a=e[3]||1,n}if(t.startsWith(`#`))return Mi(t);if(t.startsWith(`rgb`))return Ni(t);if(t.startsWith(`hsl`))return Pi(t);if(t.startsWith(`hsv`))return Fi(t)},Mi=e=>{let t=e.substring(1),n=RegExp(`.{1,${t.length>=6?2:1}}`,`g`),r=t.match(n);if(!r||r.length<3)throw Error(`The color '${e}' is illegal hex color`);r[0].length===1&&(r=r.map(e=>e+e));let i={r:Number.parseInt(r[0],16),g:Number.parseInt(r[1],16),b:Number.parseInt(r[2],16)};return r.length>3&&(i.a=Number.parseInt(r[3],16)/255),i},Ni=e=>{let t=e.indexOf(`(`);if(t===-1)throw Error(`The color '${e}' is illegal rgb color`);let n=e.substring(t+1,e.length-1).split(`,`);if(n.length<3)throw Error(`The color '${e}' is illegal rgb color`);let r={r:Number.parseInt(n[0],10),g:Number.parseInt(n[1],10),b:Number.parseInt(n[2],10)};return n.length>3&&(r.a=Number.parseFloat(n[3])),r},Pi=e=>{let t=e.indexOf(`(`);if(t===-1)throw Error(`The color '${e}' is illegal hsl color`);let n=e.substring(t+1,e.length-1).split(`,`);if(n.length<3)throw Error(`The color '${e}' is illegal hsl color`);let r={h:Number.parseInt(n[0],10),s:Number.parseFloat(n[1]),l:Number.parseFloat(n[2])};return n.length>3&&(r.a=Number.parseFloat(n[3])),r},Fi=e=>{let t=e.indexOf(`(`);if(t===-1)throw Error(`The color '${e}' is illegal hsv color`);let n=e.substring(t+1,e.length-1).split(`,`);if(n.length<3)throw Error(`The color '${e}' is illegal hsv color`);let r={h:Number.parseInt(n[0],10),s:Number.parseFloat(n[1]),v:Number.parseFloat(n[2])};return n.length>3&&(r.a=Number.parseFloat(n[3])),r},Ii=e=>{let t=ji(e);if(t!=null)return`r`in t?t:`l`in t?Ri(t):zi(t)},Li=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),Ri=e=>{let{h:t,s:n,l:r}=e;t/=360,n/=100,r/=100;let i=0,a=0,o=0;if(n===0)i=a=o=r;else{let e=r<.5?r*(1+n):r+n-r*n,s=2*r-e;i=Li(s,e,t+1/3),a=Li(s,e,t),o=Li(s,e,t-1/3)}let s={r:Math.round(i*255),g:Math.round(a*255),b:Math.round(o*255)};return e.a!==void 0&&(s.a=e.a),s},zi=e=>{let{h:t,s:n,v:r}=e;t=t/360*6,n/=100,r/=100;let i=Math.floor(t),a=t-i,o=r*(1-n),s=r*(1-a*n),c=r*(1-(1-a)*n),l=i%6,u=[r,s,o,o,c,r][l],d=[c,r,r,s,o,o][l],f=[o,o,c,r,r,s][l],p={r:u*255,g:d*255,b:f*255};return e.a!==void 0&&(p.a=e.a),p},Bi=e=>{let{r:t,g:n,b:r}=e;t/=255,n/=255,r/=255;let i=Math.max(t,n,r),a=Math.min(t,n,r),o=(i+a)/2,s,c;if(i===a)s=c=0;else{let e=i-a;switch(c=o>.5?e/(2-i-a):e/(i+a),i){case t:s=(n-r)/e+(n<r?6:0);break;case n:s=(r-t)/e+2;break;default:s=(t-n)/e+4;break}s/=6}let l={h:Math.round(s*360),s:Math.round(c*100),l:Math.round(o*100)};return e.a!==void 0&&(l.a=e.a),l},Vi=e=>{let{r:t,g:n,b:r}=e;t/=255,n/=255,r/=255;let i=Math.max(t,n,r),a=Math.min(t,n,r),o,s=i,c=i-a,l=i===0?0:c/i;if(i===a)o=0;else{switch(i){case t:o=(n-r)/c+(n<r?6:0);break;case n:o=(r-t)/c+2;break;default:o=(t-n)/c+4;break}o/=6}let u={h:Math.round(o*360),s:Math.round(l*100),v:Math.round(s*100)};return e.a!==void 0&&(u.a=e.a),u},Hi=e=>e==null,Ui=e=>!Hi(e)&&typeof e==`object`;function Wi(e){return!!(/^#(?:[0]{3}|[0]{6})\b/.test(e)||/^rgb\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*\)$/.test(e)||/^rgba\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e)||/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*\)$/.test(e)||/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e))}function Gi(e){return!!(/^#(?:[Ff]{3}|[Ff]{6})\b/.test(e)||/^rgb\s*\(\s*255\s*,\s*255\s*,\s*255\s*\)$/.test(e)||/^rgba\s*\(\s*255\s*,\s*255\s*,\s*255\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e)||/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*\)$/.test(e)||/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e))}function Ki(e){return e&&(e.s!==void 0||e.p!==void 0||e.v!==void 0||e.t!==void 0||e.f!==void 0||e.si!==void 0||e.custom!==void 0)}function qi(e){if(e.t!==void 0)return e.t;if(typeof e.v==`string`)return tr.STRING;if(typeof e.v==`number`)return tr.NUMBER;if(typeof e.v==`boolean`)return tr.BOOLEAN}function Ji(e){if(e==null)return!0;let{v:t,f:n,si:r,p:i,custom:a}=e;return!(!(t==null||typeof t==`string`&&t.length===0)||n!=null&&n.length>0||r!=null&&r.length>0||i!=null||a!=null)}function Yi(e){return e!=null&&(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)}let B=function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.ROW=1]=`ROW`,e[e.COLUMN=2]=`COLUMN`,e[e.ALL=3]=`ALL`,e}({}),V=function(e){return e[e.NONE=0]=`NONE`,e[e.ROW=1]=`ROW`,e[e.COLUMN=2]=`COLUMN`,e[e.ALL=3]=`ALL`,e}({});function Xi(e){return[e.startRow,e.startColumn,e.endRow,e.endColumn]}let Zi=function(e){return e.NONE=`none`,e.BACKWARD=`backward`,e.FORWARD=`forward`,e}({}),Qi=function(e){return e.RECT=`RECT`,e.TEXT=`TEXT`,e}({});function $i(e,t,n){let r=!1,i=!1,a=e,o=t,s=e,c=t;if(n==null)return{actualRow:e,actualColumn:t,isMergedMainCell:i,isMerged:r,endRow:a,endColumn:o,startRow:s,startColumn:c};for(let l=0;l<n.length;l++){let{startRow:u,endRow:d,startColumn:f,endColumn:p}=n[l];if(e===u&&t===f){a=d,o=p,s=u,c=f,i=!0;break}if(e>=u&&e<=d&&t>=f&&t<=p){a=d,o=p,s=u,c=f,r=!0;break}}return{actualRow:e,actualColumn:t,isMergedMainCell:i,isMerged:r,endRow:a,endColumn:o,startRow:s,startColumn:c}}let ea=function(e){return e.Raw=`raw`,e.Intercepted=`intercepted`,e.Both=`both`,e}({});const ta={[nr.OFFICE]:{[j.ACCENT1]:`#4472C4`,[j.ACCENT2]:`#ED7D31`,[j.ACCENT3]:`#A5A5A5`,[j.ACCENT4]:`#70AD47`,[j.ACCENT5]:`#5B9BD5`,[j.ACCENT6]:`#70AD47`,[j.DARK1]:`#000000`,[j.DARK2]:`#44546A`,[j.LIGHT1]:`#FFFFFF`,[j.LIGHT2]:`#E7E6E6`,[j.HYPERLINK]:`#0563C1`,[j.FOLLOWED_HYPERLINK]:`#954F72`}},na=`@@@`,ra=`@`,ia=`General`;function aa(e){return e===`@@@`||e===`@`}function oa(e){return e==null||e===`General`}const sa=(e,t)=>{if(e&&!t||!e&&t)return!1;let n=e=>{let t=Fe.tokenize(e),n=``,r=!1,i=!1;for(let e of t){if(e.type===Fe.tokenTypes.POINT){r=!0;continue}if(!(i&&e.type===Fe.tokenTypes.MINUS)&&e.type!==Fe.tokenTypes.SKIP){if(e.type===Fe.tokenTypes.COLOR){i=!0;continue}else i=!1;r&&e.type===Fe.tokenTypes.ZERO||(r=!1,r||(n+=e.value||``))}}return n};return n(e)===n(t)},ca=new Set([`m d`]),la=new Set([`h:mm AM/PM`,`hh:mm AM/PM`]),ua=new Set([`$`,`¥`,`₽`,`₫`,`NT$`,`€`,`₩`,`﷼`]),da=e=>{var t,n;let r=(t=(n=Fe.parseDate(e))==null?Fe.parseTime(e):n)==null?Fe.parseNumber(e):t;if(!r)return null;let{z:i}=r;if(i){if(ca.has(i)||la.has(i)&&!/\s(A|AM|P|PM)$/i.test(e))return null;if(i.includes(`#,##0`)){if(/[.,]$/.test(e))return null;let t=e.replace(RegExp(`^[${[...ua].join(``)}]+`),``).trim();if(t.includes(`,`)&&!/^-?\d{1,3}(,\d{3})*(\.\d+)?$/.test(t))return null}}return r};function fa(e,t){let n={};for(let r in e){let i=Number(r),a=e[i];for(let e in a){let r=Number(e),o=a[r],s=t(i,r,o);s!==void 0&&(n[i]?n[i][r]=s:n[i]={[r]:s})}}return n}function pa(e){let t=0,n=Object.keys(e);for(let e of n){let n=Number(e);t=Math.max(t,n)}return t+1}const ma=e=>e==null||typeof e==`object`&&Object.keys(e).length===0;function ha(e,t,n){let r=pa(n),i=n;for(let t=r-1;t>=e;t--)ma(i[t])?delete i[t+1]:i[t+1]=i[t];ma(t)||(i[e]=t)}function ga(e,t,n){let r=Object.keys(n).reduce((e,t)=>Math.max(e,Number.parseInt(t)),0)+1;for(let i=e;i<r;i++)i<e+t?delete n[i]:n[i]!==void 0&&(n[i-t]=n[i],delete n[i])}function _a(e,t){let n=e,r=Object.keys(n),i=r.length,a=t,o=Object.keys(a),s=o.length,c={},l=0;for(let e=0;e<i;e++,l++)c[l]=n[r[e]];for(let e=0;e<s;e++,l++)c[l]=a[o[e]];return c}function va(e,t,n){let r=n;if(pa(n)>0){let n={},i=0;for(let a=e;a<=t;a++)r[a]&&(n[i]=r[a],i++);return n}return{}}function ya(e,t,n,r){let i=e>n;if(!i&&e+t>n)throw Error(`Invalid move operation`);i?ba(e,t,n,r):xa(e,t,n,r)}function ba(e,t,n,r){let i=r,a=[];for(let n=e;n<e+t;n++)a.push(i[n]);for(let r=e-1;r>=n;r--){let e=i[r];i[r+t]=e,e===void 0&&delete i[r+t]}a.forEach((e,t)=>{i[n+t]=e,e===void 0&&delete i[n+t]})}function xa(e,t,n,r){let i=r,a=[];for(let n=e;n<e+t;n++)a.push(i[n]);for(let r=e+t;r<n;r++){let e=i[r];i[r-t]=e,e===void 0&&delete i[r-t]}a.forEach((e,r)=>{i[n+r-t]=e,e===void 0&&delete i[n+r-t]})}var Sa=class e{constructor(e={}){C(this,`_matrix`,void 0),this._setOriginValue(e)}static MakeObjectMatrixSize(t){return new e({[t-1]:{}})}getMatrix(){return this._matrix}forEach(e){let t=this._matrix,n=Object.keys(t);for(let r of n){let n=Number(r),i=t[n];if(e(n,i)===!1)return this}return this}forRow(e){let t=this._matrix,n=Object.keys(t);for(let r of n){let n=Number(r),i=t[n];if(e(n,Object.keys(i).map(e=>Number(e)))===!1)return this}return this}forValue(e){let t=this._matrix;for(let n in t){let r=Number(n),i=t[r];if(i)for(let t in i){let n=Number(t),a=i[n];if(e(r,n,a)===!1)return this}}return this}swapRow(e,t){let n=this._matrix[e],r=this._matrix[t];this._matrix[e]=r,this._matrix[t]=n}getRow(e){return this._matrix[e]}getRowOrCreate(e){let t=this.getRow(e);return t==null&&(t={},this._matrix[e]=t),t}reset(){this._setOriginValue({})}hasValue(){let e=this._matrix,t=Object.keys(e);if(t.length===0)return!1;for(let n of t){let t=e[Number(n)];if(Object.keys(t).length>0)return!0}return!1}getValue(e,t){var n;return(n=this._matrix)==null||(n=n[e])==null?void 0:n[t]}setValue(e,t,n){let r=this.getRowOrCreate(e);r[t]=n}deleteValue(e,t){var n;(n=this._matrix)==null||(n=n[e])==null||delete n[t]}realDeleteValue(e,t){var n;if((n=this._matrix)==null||(n=n[e])==null||delete n[t],this.getRow(e)){let t=this.getRow(e);if(t==null)return;if(Object.keys(t).length===0){var r;(r=this._matrix)==null||delete r[e]}}}setRow(e,t){this._matrix[e]=t}moveRows(e,t,n){ya(e,t,n,this._matrix)}moveColumns(e,t,n){this.forEach((r,i)=>{ya(e,t,n,i)})}insertRows(e,t){let n=Object.keys(this._matrix);for(let r=n.length-1;r>=0;r--){let i=Number(n[r]);if(i>=e){let e=this._matrix[i];delete this._matrix[i],this._matrix[i+t]=e}}}insertColumns(e,t){let n=Object.keys(this._matrix);for(let r=0;r<n.length;r++){let i=Number(n[r]),a=this._matrix[i],o=Object.keys(a);for(let n=o.length-1;n>=0;n--){let r=Number(o[n]);if(r>=e){let e=a[r];delete a[r],a[r+t]=e}}}}removeRows(e,t){ga(e,t,this._matrix)}removeColumns(e,t){this.forEach((n,r)=>{r&&ga(e,t,r)})}getFragment(t,n,r,i){let a=new e,o=0;for(let e=t;e<=n;e++){let t={},n=0;for(let a=r;a<=i;a++)t[n]=this.getValue(e,a),n++;a.setRow(o,t),o++}return a}getSlice(t,n,r,i){let a=new e;for(let e=t;e<=n;e++)for(let t=r;t<=i;t++){let n=this.getValue(e,t);n&&a.setValue(e,t,D.deepClone(n))}return a}getSliceDataAndCellCountByRows(t,n){let r=new e,i=0;for(let e=t;e<=n;e++){let t=this.getRow(e);t&&(r.setRow(e,t),i+=Object.keys(t).length)}return{sliceData:r,cellCount:i}}getSizeOf(){return Object.keys(this._matrix).length}getLength(){return pa(this._matrix)}getRange(){let e=this.getLength()-1,t=0,n=this.getLength();for(let e=0;e<n;e++){let n=this.getRow(e);if(n){let e=pa(n)-1;t=e>t?e:t}}return{startRow:0,startColumn:0,endRow:e,endColumn:t}}getRealRange(){let e=Object.keys(this._matrix),t=e.length,n=t>0?Number(e[0]):0,r=t>0?Number(e[t-1]):0,i=-1/0,a=0;for(let t of e){let e=this.getRow(Number(t));if(e){let t=Object.keys(e);if(t.length>0){let e=Number(t[0]),n=Number(t[t.length-1]);(i===-1/0||e<i)&&(i=e),n>a&&(a=n)}}}return i===-1/0&&(i=0),{startRow:n,endRow:r,startColumn:i,endColumn:a}}getRealRowRange(){let e=Object.keys(this._matrix),t=e.length;return{startRow:t>0?Number(e[0]):0,endRow:t>0?Number(e[t-1]):0}}toNativeArray(){let e=[];return this.forValue((t,n,r)=>{e.push(r)}),e}toArray(){let e=[];return this.forRow((t,n)=>{e[t]==null&&(e[t]=[]),n.forEach(n=>{e[t][n]=this.getValue(t,n)})}),e}toFullArray(){let{endColumn:e,endRow:t}=this.getRange(),n=[];for(let r=0;r<=t;r++){let t=Array(e+1).fill(void 0);n.push(t)}return this.forValue((e,t,r)=>{n[e][t]=r}),n}toJSON(){return this._matrix}clone(){let e=JSON.stringify(this._matrix);return JSON.parse(e)}getData(){let e=JSON.stringify(this._matrix);return JSON.parse(e)}getArrayData(){let t=0,n=0,r=!1,i=!1,a=new e;return this.forEach((e,o)=>{r||(r=!0,t=e),Object.keys(o).forEach(r=>{let o=Number(r);i?o<n&&(n=o):(i=!0,n=o);let s=this.getValue(e,o);a.setValue(e-t,o-n,s)})}),a.getData()}getStartEndScope(){let e=1/0,t=-1/0,n=1/0,r=-1/0,i=Object.keys(this._matrix);i.length>0&&(e=+i[0],t=+i[i.length-1]);for(let e of i){let t=Object.keys(this._matrix[e]);t.length>0&&(n=Math.min(n,+t[0]),r=Math.max(r,+t[t.length-1]))}return{startRow:e,endRow:t,startColumn:n,endColumn:r}}getDataRange(){let e=0,t=0,n=0,r=-1,i=!1,a=!1;return this.forEach((o,s)=>{if(i||(i=!0,e=o),s==null)return;let c=pa(s)-1;c>n&&(n=c),Object.keys(s).forEach(e=>{let n=Number(e);a?n<t&&(t=n):(a=!0,t=n)}),o>r&&(r=o)}),{startRow:e,startColumn:t,endRow:r,endColumn:n}}getDiscreteRanges(){let e=[];return this.forEach((t,n)=>{Object.keys(n).forEach(n=>{let r=Number(n),i=!1;for(let n of e)if(t>=n.startRow&&t<=n.endRow+1&&r>=n.startColumn&&r<=n.endColumn+1){n.endRow=Math.max(t,n.endRow),n.endColumn=Math.max(r,n.endColumn),i=!0;break}i||e.push({startRow:t,endRow:t,startColumn:r,endColumn:r})})}),e}merge(e){this.forValue((t,n)=>{let r=e.getValue(t,n);r!=null&&this.setValue(t,n,r)})}concatRows(e){let t=e.getMatrix();for(let e in t){let n=Number(e);this.setRow(n,t[n])}}_setOriginValue(e={}){this._matrix=e}};function Ca(e){let{actualRow:t,actualColumn:n,isMerged:r,isMergedMainCell:i,mergeInfo:a}=e,{startY:o,endY:s,startX:c,endX:l}=e,u=t,d=n,f=t,p=n;if(r&&a){let{startRow:e,startColumn:t,endRow:n,endColumn:r,startY:i,endY:m,startX:h,endX:g}=a;u=e,d=t,f=n,p=r,o=i,s=m,c=h,l=g}return i&&(o=a.startY,s=a.endY,c=a.startX,l=a.endX,f=a.endRow,p=a.endColumn),{startRow:u,startColumn:d,endRow:f,endColumn:p,startY:o,endY:s,startX:c,endX:l}}const wa=Ca;function Ta(e){if(!e)return;let{actualRow:t,actualColumn:n,isMerged:r,isMergedMainCell:i,startRow:a,startColumn:o,endRow:s,endColumn:c}=e,l=t,u=n,d=t,f=n;return(r||i)&&(l=a,u=o,d=s,f=c),{startRow:l,startColumn:u,endRow:d,endColumn:f}}function Ea(e){var t;return!e||((e==null||(t=e.v)==null?void 0:t.toString())||``).length===0&&!e.p}function Da(e){return Ea(e)&&(e==null?void 0:e.coverable)!==!1}function Oa(e){if(e){if(e.rgb)return new Oi(e.rgb).toHexString();if(e.th!=null){var t;let n=(t=ta[nr.OFFICE])==null?void 0:t[e.th];if(n)return new Oi(n).toRgbString()}}return null}function ka(e){return D.isString(e)&&e.substring(0,1)===`=`&&e.length>1}function Aa(e){return D.isString(e)&&e.length>0}function ja(e,t=!1){let n=``,r=new Map([[`ff`,()=>{e.ff&&(n+=`font-family: ${e.ff}; `)}],[`fs`,()=>{if(e.fs){let t=e.fs;e.va&&(t/=2),n+=`font-size: ${t}pt; `}}],[`it`,()=>{e.it&&(n+=`font-style: italic; `)}],[`bl`,()=>{e.bl&&(n+=`font-weight: bold; `)}],[`ul`,()=>{var t;(t=e.ul)!=null&&t.s&&(n.indexOf(`text-decoration-line`)>-1?n=n.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(e,t)=>`${t} underline`):n+=`text-decoration: underline; `,e.ul.cl&&n.indexOf(`text-decoration-color`)===-1&&(n+=`text-decoration-color: ${Oa(e.ul.cl)}; `),e.ul.t&&n.indexOf(`text-decoration-style`)===-1&&(n+=`text-decoration-style: ${e.ul.t} `))}],[`st`,()=>{var t;(t=e.st)!=null&&t.s&&(n.indexOf(`text-decoration-line`)>-1?n=n.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(e,t)=>`${t} line-through`):n+=`text-decoration-line: line-through; `,e.st.cl&&n.indexOf(`text-decoration-color`)===-1&&(n+=`text-decoration-color: ${Oa(e.st.cl)}; `),e.st.t&&n.indexOf(`text-decoration-style`)===-1&&(n+=`text-decoration-style: ${e.st.t} `))}],[`ol`,()=>{var t;(t=e.ol)!=null&&t.s&&(n.indexOf(`text-decoration-line`)>-1?n=n.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(e,t)=>`${t} overline`):n+=`text-decoration-line: overline; `,e.ol.cl&&n.indexOf(`text-decoration-color`)===-1&&(n+=`text-decoration-color: ${Oa(e.ol.cl)}; `),e.ol.t&&n.indexOf(`text-decoration-style`)===-1&&(n+=`text-decoration-style: ${e.ol.t} `))}],[`bg`,()=>{e.bg&&(n+=`background: ${Oa(e.bg)}; `)}],[`bd`,()=>{var t,r,i,a;if((t=e.bd)!=null&&t.b){var o,s;n+=`border-bottom: ${Ma((o=e.bd)==null?void 0:o.b.s)} ${(s=Oa(e.bd.b.cl))==null?``:s}; `}if((r=e.bd)!=null&&r.t){var c,l;n+=`border-top: ${Ma((c=e.bd)==null?void 0:c.t.s)} ${(l=Oa(e.bd.t.cl))==null?``:l}; `}if((i=e.bd)!=null&&i.r){var u,d;n+=`border-right: ${Ma((u=e.bd)==null?void 0:u.r.s)} ${(d=Oa(e.bd.r.cl))==null?``:d}; `}if((a=e.bd)!=null&&a.l){var f,p;n+=`border-left: ${Ma((f=e.bd)==null?void 0:f.l.s)} ${(p=Oa(e.bd.l.cl))==null?``:p}; `}}],[`cl`,()=>{e.cl&&(n+=`color: ${Oa(e.cl)}; `)}],[`va`,()=>{e.va===er.SUBSCRIPT?n+=`vertical-align: sub; `:e.va===er.SUPERSCRIPT&&(n+=`vertical-align: super; `)}],[`td`,()=>{e.td===qn.LEFT_TO_RIGHT?n+=`direction: ltr; `:e.td===qn.RIGHT_TO_LEFT&&(n+=`direction: rtl; `)}],[`tr`,()=>{if(e.tr){var t,r,i;n+=`--data-rotate: (${(t=e.tr)==null?void 0:t.a}deg${(r=e.tr)!=null&&r.v?` ,${(i=e.tr)==null?void 0:i.v}`:``});`}}],[`ht`,()=>{e.ht===Yn.LEFT?n+=`text-align: left; `:e.ht===Yn.RIGHT?n+=`text-align: right; `:e.ht===Yn.CENTER?n+=`text-align: center; `:e.ht===Yn.JUSTIFIED&&(n+=`text-align: justify; `)}],[`vt`,()=>{e.vt===Xn.BOTTOM?n+=`vertical-align: bottom; `:e.vt===Xn.TOP?n+=`vertical-align: top; `:e.vt===Xn.MIDDLE&&(n+=`vertical-align: middle; `)}],[`tb`,()=>{e.tb===Zn.CLIP?n+=`white-space: nowrap; overflow-x: hidden; `:e.tb===Zn.WRAP&&(n+=`white-space: normal;`)}],[`pd`,()=>{var t,r,i,a,o,s,c,l;let u=`${(t=e.pd)==null?void 0:t.b}pt`,d=`${(r=e.pd)==null?void 0:r.t}pt`,f=`${(i=e.pd)==null?void 0:i.l}pt`,p=`${(a=e.pd)==null?void 0:a.r}pt`;(o=e.pd)!=null&&o.b&&(n+=`padding-bottom: ${u}; `),(s=e.pd)!=null&&s.t&&(n+=`padding-top: ${d}; `),(c=e.pd)!=null&&c.l&&(n+=`padding-left: ${f}; `),(l=e.pd)!=null&&l.r&&(n+=`padding-right: ${p}; `)}]]),i=[`bd`,`tr`,`tb`];for(let n in e){var a;t&&i.includes(n)||(a=r.get(n))==null||a()}return n}function Ma(e){let t=``;return e===k.NONE?t=`none`:e===k.THIN?t=`0.5pt solid`:e===k.HAIR?t=`0.5pt double`:e===k.DOTTED?t=`0.5pt dotted`:e===k.DASHED||e===k.DASH_DOT?t=`0.5pt dashed`:e===k.DASH_DOT_DOT?t=`0.5pt dotted`:e===k.DOUBLE?t=`0.5pt double`:e===k.MEDIUM?t=`1pt solid`:e===k.MEDIUM_DASHED||e===k.MEDIUM_DASH_DOT?t=`1pt dashed`:e===k.MEDIUM_DASH_DOT_DOT?t=`1pt dotted`:e===k.SLANT_DASH_DOT?t=`0.5pt dashed`:e===k.THICK&&(t=`1.5pt solid`),t}function Na(e){let t=0;if(e=e.trim(),e===`none`)t=k.NONE;else if(e===`0.5pt solid`)t=k.THIN;else if(e===`0.5pt double`)t=k.HAIR;else if(e===`0.5pt dotted`)t=k.DOTTED;else if(e===`0.5pt dashed`)t=k.DASHED;else if(e===`1pt solid`)t=k.MEDIUM;else if(e===`1pt dashed`)t=k.MEDIUM_DASHED;else if(e===`1pt dotted`)t=k.MEDIUM_DASH_DOT_DOT;else if(e===`1.5pt solid`)t=k.THICK;else if(!e.includes(`none`))t=k.THIN;else return k.NONE;return t}function Pa(e,t){let n=e.body;if(t){let{headers:r,footers:i}=e;r!=null&&r[t]?n=r[t].body:i!=null&&i[t]&&(n=i[t].body)}return n}function Fa(e,t){let{startRow:n,endRow:r,startColumn:i,endColumn:a,rangeType:o}=e;if(n<0||i<0||r<0||a<0||!(Number.isNaN(n)&&Number.isNaN(r))&&o===B.COLUMN||!(Number.isNaN(i)&&Number.isNaN(a))&&o===B.ROW||o!==B.ROW&&o!==B.COLUMN&&(Number.isNaN(i)||Number.isNaN(n)||Number.isNaN(a)||Number.isNaN(r)))return!1;if(t){let e=t.getRowCount(),n=t.getColumnCount();if(r>=e||a>=n)return!1}return!0}function Ia(e,t){return{startRow:e,endRow:e,startColumn:t,endColumn:t}}function La(e){if(ka(e))return{f:e,v:null,p:null};if(Yi(e)){if(typeof e==`string`){let t=da(e);if(t&&t.z)return{v:t.v,p:null,f:null,s:{n:{pattern:t.z||`General`}}}}return{v:e,p:null,f:null}}return Ki(e),e}function Ra(e,t){let n=new Sa,{startRow:r,startColumn:i,endRow:a,endColumn:o}=t;if(D.isArray(e))for(let t=0;t<=a-r;t++)for(let a=0;a<=o-i;a++)n.setValue(t+r,a+i,La(e[t][a]));else new Sa(e).forValue((e,t,r)=>{n.setValue(e,t,La(r))});return n.getMatrix()}function za(e,t){return Object.prototype.toString.call(e)===Object.prototype.toString.call(t)?Object.prototype.toString.call(e)===`[object Object]`||Object.prototype.toString.call(e)===`[object Array]`?Object.keys(e).length===Object.keys(t).length?Object.keys(e).every(n=>za(e[n],t[n])):!1:e===t:!1}function Ba(e,t){let n=e.ts||{},r=t.ts||{};return e.sId===t.sId?za(n,r):!1}function Va(e,t){return t.some(t=>e.indexOf(t)>-1)}Ie.extend(Re),Ie.extend(Le),Ie.extend(He),Ie.extend(ze),Ie.extend(Ue),Ie.extend(We),Ie.extend(Ve),Ie.extend(Be);function Ha(e,t,n,r){if(e>t)throw Error(`a1 should be less than a2`);if(n>r)throw Error(`b1 should be less than b2`);if(t<n||r<e)return[e,t];if(n<=e&&r>=t)return[];let i=r-n+1;return e<n&&t>r?[e,t-i]:n<=e&&r<t?[r+1-i,t-i]:n>e&&r>=t?[e,n-1]:[e,t]}function Ua(e){if(e==null)return!1;let t=e.bullet;return(t==null?void 0:t.listId)!=null}function Wa(e){if(e==null)return!1;let t=e.paragraphStyle;return Ga(t)}function Ga(e){var t;return!(e==null||(e.indentStart==null||e.indentStart.v===0)&&e.hanging==null||((t=e.hanging)==null?void 0:t.v)===0)}function Ka(e,t,n){return e.slice(0,t)+n+e.slice(t)}function qa(e,t,n){return t>n?e:e.slice(0,t)+e.slice(n)}function Ja(e){if(e==null||typeof e==`boolean`)return!1;if(typeof e==`number`)return!isNaN(e);if(typeof e==`string`){let t=e.trim();return t===``?!1:!isNaN(Number(t))}return!1}function Ya(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+(t<<6)+(t<<16)-t;return t>>>0}function Xa(e){if(e.length===0)return[];let t=e.slice().sort((e,t)=>(Array.isArray(e)?e[0]:e)-(Array.isArray(t)?t[0]:t)),n=[],r=Array.isArray(t[0])?t[0][0]:t[0],i=r;for(let e=1;e<t.length;e++){let a=t[e],o,s;Array.isArray(a)?(o=a[0],s=a[1]):(o=a,s=a),o<=i+1?i=Math.max(i,s):(n.push([r,i]),r=o,i=s)}return n.push([r,i]),n}function Za(e){if(e.length===0)return[];let t=e.slice().sort((e,t)=>e[0]-t[0]),n=[],[r,i]=t[0];for(let e=1;e<t.length;e++){let[a,o]=t[e];a<=i+1?i=Math.max(i,o):(n.push([r,i]),r=a,i=o)}return n.push([r,i]),n}function Qa(...e){let t;return t=e.length===1&&Array.isArray(e[0])?e[0]:e,le({},...t)}let $a,eo,to,no;const H=Symbol(`newer`),U=Symbol(`older`);$a=Symbol.iterator;var ro=class{constructor(e){C(this,`entry`,void 0),this.entry=e}[$a](){return this}next(){let e=this.entry;return e?(this.entry=e[H],{done:!1,value:e.key}):{done:!0,value:void 0}}};eo=Symbol.iterator;var io=class{constructor(e){C(this,`entry`,void 0),this.entry=e}[eo](){return this}next(){let e=this.entry;return e?(this.entry=e[H],{done:!1,value:e.value}):{done:!0,value:void 0}}};to=Symbol.iterator;var ao=class{constructor(e){C(this,`entry`,void 0),this.entry=e}[to](){return this}next(){let e=this.entry;return e?(this.entry=e[H],{done:!1,value:[e.key,e.value]}):{done:!0,value:void 0}}},oo=class{constructor(e,t){C(this,`key`,void 0),C(this,`value`,void 0),C(this,H,void 0),C(this,U,void 0),this.key=e,this.value=t,this[H]=void 0,this[U]=void 0}toJSON(){return{key:this.key,value:this.value}}};no=Symbol.iterator;var so=class{onShift(e){if(this._onShiftListeners.indexOf(e)===-1)return this._onShiftListeners.push(e),T(()=>tt(this._onShiftListeners,e));throw Error(`[LRUMap]: the listener has been registered!`)}constructor(...e){if(C(this,`_keymap`,void 0),C(this,`size`,0),C(this,`limit`,void 0),C(this,`oldest`,void 0),C(this,`newest`,void 0),C(this,`_onShiftListeners`,[]),co.hasLength(e,1)){if(co.isNumber(e[0])){let t=e[0];this._initialize(t,void 0);return}if(co.isIterable(e[0])){let t=e[0];this._initialize(0,t);return}return}if(co.hasLength(e,2)){let t=e[0],n=e[1];this._initialize(t,n)}}_initialize(e,t){this.oldest=void 0,this.newest=void 0,this.size=0,this.limit=e,this._keymap=new Map,t&&(this.assign(t),e<1&&(this.limit=this.size))}_markEntryAsUsed(e){e!==this.newest&&(e[H]&&(e===this.oldest&&(this.oldest=e[H]),e[H][U]=e[U]),e[U]&&(e[U][H]=e[H]),e[H]=void 0,e[U]=this.newest,this.newest&&(this.newest[H]=e),this.newest=e)}assign(e){let t,n=this.limit||Number.MAX_VALUE;this._keymap.clear();let r=e[Symbol.iterator]();for(let e=r.next();!e.done;e=r.next()){let r=new oo(e.value[0],e.value[1]);if(this._keymap.set(r.key,r),t?(t[H]=r,r[U]=t):this.oldest=r,t=r,n--===0)throw Error(`overflow`)}this.newest=t,this.size=this._keymap.size}set(e,t){let n=this._keymap.get(e);return n?(n.value=t,this._markEntryAsUsed(n),this):(this._keymap.set(e,n=new oo(e,t)),this.newest?(this.newest[H]=n,n[U]=this.newest):this.oldest=n,this.newest=n,++this.size,this.size>this.limit&&this.shift(),this)}shift(){let e=this.oldest;if(e)return this.oldest&&this.oldest[H]?(this.oldest=this.oldest[H],this.oldest[U]=void 0):(this.oldest=void 0,this.newest=void 0),e[H]=e[U]=void 0,this._keymap.delete(e.key),--this.size,this._onShiftListeners.forEach(t=>t(e)),[e.key,e.value]}get(e){let t=this._keymap.get(e);if(t)return this._markEntryAsUsed(t),t.value}has(e){return this._keymap.has(e)}find(e){let t=this._keymap.get(e);return t?t.value:void 0}delete(e){let t=this._keymap.get(e);if(t)return this._keymap.delete(t.key),t[H]&&t[U]?(t[U][H]=t[H],t[H][U]=t[U]):t[H]?(t[H][U]=void 0,this.oldest=t[H]):t[U]?(t[U][H]=void 0,this.newest=t[U]):this.oldest=this.newest=void 0,this.size--,t.value}clear(){this.oldest=void 0,this.newest=void 0,this.size=0,this._keymap.clear()}keys(){return new ro(this.oldest)}values(){return new io(this.oldest)}entries(){return this[Symbol.iterator]()}[no](){return new ao(this.oldest)}forEach(e,t){typeof t!=`object`&&(t=this);let n=this.oldest;for(;n;)e.call(t,n.value,n.key,this),n=n[H]}toJSON(){let e=Array(this.size),t=0,n=this.oldest;for(;n;)e[t++]={key:n.key,value:n.value},n=n[H];return e}toString(){let e=``,t=this.oldest;for(;t;)e+=`${String(t.key)}:${t.value}`,t=t[H],t&&(e+=` < `);return e}},co=class{static hasLength(e,t){return e.length===t}static getValueType(e){return Object.prototype.toString.apply(e)}static isObject(e){return this.getValueType(e)===`[object Object]`}static isIterable(e){return e[Symbol.iterator]!=null}static isNumber(e){return this.getValueType(e)===`[object Number]`}};function lo(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r<65||r>90)return-1;t=t*26+(r-64)}return t}const uo=1048576,fo=16384,po={sheetId:``,range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},mo={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},ho={startRow:0,startColumn:0,endRow:0,endColumn:0},go={row:0,column:0},W={ff:`Arial`,fs:11,it:A.FALSE,bl:A.FALSE,ul:{s:A.FALSE},st:{s:A.FALSE},ol:{s:A.FALSE},tr:{a:0,v:A.FALSE},td:qn.UNSPECIFIED,cl:{rgb:`#000000`},bg:{rgb:`#fff`},ht:Yn.UNSPECIFIED,vt:Xn.UNSPECIFIED,tb:Zn.UNSPECIFIED,pd:{t:0,r:0,b:0,l:0},n:null,bd:{b:null,l:null,r:null,t:null}},_o={id:`default_slide`,title:`defaultSlide`,pageSize:{width:300,height:300}},vo=[dt,pt,ft],yo={[N.HEADING_1]:{fs:20,bl:1},[N.HEADING_2]:{fs:18,bl:1},[N.HEADING_3]:{fs:16,bl:1},[N.HEADING_4]:{fs:14,bl:1},[N.HEADING_5]:{fs:12,bl:1},[N.NORMAL_TEXT]:null,[N.TITLE]:{fs:26,bl:1},[N.SUBTITLE]:{fs:15,cl:{rgb:`#999999`}},[N.NAMED_STYLE_TYPE_UNSPECIFIED]:null},bo={[N.HEADING_1]:{spaceAbove:{v:20},spaceBelow:{v:10}},[N.HEADING_2]:{spaceAbove:{v:18},spaceBelow:{v:10}},[N.HEADING_3]:{spaceAbove:{v:16},spaceBelow:{v:10}},[N.HEADING_4]:{spaceAbove:{v:14},spaceBelow:{v:8}},[N.HEADING_5]:{spaceAbove:{v:12},spaceBelow:{v:8}},[N.NORMAL_TEXT]:{spaceAbove:{v:0},spaceBelow:{v:0}},[N.TITLE]:{spaceAbove:{v:0},spaceBelow:{v:7}},[N.SUBTITLE]:{spaceAbove:{v:0},spaceBelow:{v:16}},[N.NAMED_STYLE_TYPE_UNSPECIFIED]:null},xo=`univer-sheets-chart-print-chart`,So=`univer-docs-drawing-printing`;let Co=function(e){return e.ARRAY_CONVERTOR=`ARRAY_CONVERTOR`,e.MATRIX_CONVERTOR=`MATRIX_CONVERTOR`,e}({});const wo={[P.A3]:{width:1123,height:1587},[P.A4]:{width:794,height:1124},[P.A5]:{width:559,height:794},[P.B4]:{width:944,height:1344},[P.B5]:{width:665,height:944},[P.Executive]:{width:696,height:1008},[P.Folio]:{width:816,height:1248},[P.Legal]:{width:816,height:1344},[P.Letter]:{width:816,height:1056},[P.Statement]:{width:528,height:816},[P.Tabloid]:{width:1056,height:1632}};function To(e,t){let{textRuns:n=[]}=t,r=0;for(let t of n){let{ts:n={},st:i,ed:a}=t;if(n[e]==null)return A.FALSE;switch(e){case`bl`:case`it`:if(n[e]===A.FALSE)return A.FALSE;break;case`ul`:case`st`:if(n[e].s===A.FALSE)return A.FALSE;break;default:throw Error(`unknown style key: ${e} in IStyleBase`)}r+=a-i}return t.dataStream.indexOf(`\r
|
|
4
|
+
`)===r?A.TRUE:A.FALSE}var Eo=class e{constructor(e,t,n){this._deps=n,C(this,`_range`,void 0),C(this,`_worksheet`,void 0),this._range=t,this._worksheet=e}static foreach(e,t){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e;for(let e=n;e<=i;e++)for(let n=r;n<=a;n++)t(e,n)}getRangeData(){return this._range}getValue(){return this.getValues()[0][0]}getValues(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i=[];for(let a=e;a<=t;a++){let e=[];for(let t=n;t<=r;t++)e.push(this.getMatrix().getValue(a,t)||null);i.push(e)}return i}getMatrix(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),a=new Sa;for(let o=e;o<=t;o++)for(let e=n;e<=r;e++)a.setValue(o,e,i.getValue(o,e)||null);return a}getMatrixObject(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),a=new Sa;for(let o=e;o<=t;o++)for(let t=n;t<=r;t++)a.setValue(o-e,t-n,i.getValue(o,t)||{});return a}getA1Notation(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i,a;return n<r?(i=D.numToWord(n+1)+(e+1),a=D.numToWord(r+1)+(t+1)):(i=D.numToWord(r+1)+(t+1),a=D.numToWord(n+1)+(e+1)),i===a?`${i}`:`${i}:${a}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){let e=this._deps.getStyles();return this.getValues().map(t=>t.map(t=>{var n;let r=e.getStyleByCell(t);return(r==null||(n=r.bg)==null?void 0:n.rgb)||W.bg.rgb}))}getCell(t,n){let{startRow:r,startColumn:i}=this._range,a={startRow:r+t,endRow:r+t,startColumn:i+n,endColumn:i+n};return new e(this._worksheet,a,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(e={}){return this.getObjectValues(e)[0][0]}getObjectValues(e={}){let{startRow:t,endRow:n,startColumn:r,endColumn:i}=this._range,a=this._worksheet.getCellMatrix().getFragment(t,n,r,i).getData();if(e.isIncludeStyle){let e=this._deps.getStyles();for(let s=0;s<=n-t;s++)for(let t=0;t<=i-r;t++){var o;if(a==null||(a==null||(o=a[s])==null?void 0:o[t])==null)continue;let n=a[s][t].s;n&&(a[s][t].s=e.get(n))}}return a}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){let e=this._deps.getStyles();return this.getValues().map(t=>t.map(t=>{var n;let r=e.getStyleByCell(t);return(r==null||(n=r.cl)==null?void 0:n.rgb)||W.cl.rgb}))}getFontFamilies(){return this._getStyles(`ff`)}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles(`ul`)}getUnderline(){var e,t;let{p:n}=(e=this.getValue())==null?{}:e;return n&&Array.isArray((t=n.body)==null?void 0:t.textRuns)&&n.body.textRuns.length>0?To(`ul`,n.body)===A.TRUE?{s:A.TRUE}:{s:A.FALSE}:this.getUnderlines()[0][0]}getOverlines(){return this._getStyles(`ol`)}getOverline(){return this.getOverlines()[0][0]}getStrikeThrough(){var e,t;let{p:n}=(e=this.getValue())==null?{}:e;return n&&Array.isArray((t=n.body)==null?void 0:t.textRuns)&&n.body.textRuns.length>0?To(`st`,n.body)===A.TRUE?{s:A.TRUE}:{s:A.FALSE}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles(`st`)}getFontSize(){var e,t;let n=((e=this.getValue())==null?void 0:e.p)||{};return n&&Array.isArray((t=n.body)==null?void 0:t.textRuns)&&n.body.textRuns.length>0&&n.body.textRuns.some(e=>{var t;return(e==null||(t=e.ts)==null?void 0:t.fs)!=null})?Math.max(...n.body.textRuns.map(e=>{var t;return(e==null||(t=e.ts)==null?void 0:t.fs)||0})):this.getFontSizes()[0][0]}getFontSizes(){return this._getStyles(`fs`)}getBorder(){return this.getBorders()[0][0]}getBorders(){return this._getStyles(`bd`)}getFontStyle(){var e,t;let{p:n}=(e=this.getValue())==null?{}:e;return n&&Array.isArray((t=n.body)==null?void 0:t.textRuns)&&n.body.textRuns.length>0?To(`it`,n.body)===A.TRUE?Qn.ITALIC:Qn.NORMAL:this._getFontStyles()[0][0]}_getFontStyles(){return this._getStyles(`it`)}getFontWeight(){var e,t;let{p:n}=(e=this.getValue())==null?{}:e;return n&&Array.isArray((t=n.body)==null?void 0:t.textRuns)&&n.body.textRuns.length>0?To(`bl`,n.body)===A.TRUE?$n.BOLD:$n.NORMAL:this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles(`bl`)}getGridId(){return this._worksheet.getSheetId()}getHeight(){let{_range:e,_worksheet:t}=this,{startRow:n,endRow:r}=e,i=0;for(let e=0;e<=r-n;e++){let n=t.getRowHeight(e);i+=n}return i}getHorizontalAlignment(){return this.getHorizontalAlignments()[0][0]}getHorizontalAlignments(){return this._getStyles(`ht`)}getLastColumn(){return this._range.endColumn}getLastRow(){return this._range.endRow}getNumColumns(){let{startColumn:e,endColumn:t}=this._range;return t-e+1}getNumRows(){let{startRow:e,endRow:t}=this._range;return t-e+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(e=>e.map(e=>(e==null?void 0:e.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(){let e=this._deps.getStyles();return this.getValues().map(t=>t.map(t=>e.getStyleByCell(t)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles(`vt`)}getWidth(){let{_range:e,_worksheet:t}=this,{startColumn:n,endColumn:r}=e,i=0;for(let e=0;e<=r-n;e++)i+=t.getColumnWidth(e);return i}getWrap(){return this.getWrapStrategy()===Zn.WRAP?A.TRUE:A.FALSE}getWrapStrategies(){return this._getStyles(`tb`)}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(t){e.foreach(this._range,t)}_getStyles(e){let t=this._deps.getStyles();return this.getValues().map(n=>n.map(n=>{let r=t&&t.getStyleByCell(n);return r&&r[e]||W[e]}))}};C(Eo,`transformRange`,(e,t)=>{let n=t.getMaxColumns()-1,r=t.getMaxRows()-1;return e.rangeType===B.ALL?{startColumn:0,startRow:0,endColumn:n,endRow:r}:e.rangeType===B.COLUMN?{startRow:0,endRow:r,startColumn:e.startColumn,endColumn:e.endColumn}:e.rangeType===B.ROW?{startColumn:0,endColumn:n,startRow:e.startRow,endRow:e.endRow}:{startColumn:e.startColumn,endColumn:Math.min(e.endColumn,n),startRow:e.startRow,endRow:Math.min(e.endRow,r)}});function Do(e,t,n,r=!1){if(t===0&&n===0)return e;let i={...e},a=i.startAbsoluteRefType||V.NONE,o=i.endAbsoluteRefType||V.NONE,s=i.rangeType||B.NORMAL;if(!r&&a===V.ALL&&o===V.ALL)return i;let c=Oo(i.startRow,n,i.startColumn,t,s),l=Oo(i.endRow,n,i.endColumn,t,s);return r||a===V.NONE&&o===V.NONE?i={...i,startRow:c.row,startColumn:c.column,endRow:l.row,endColumn:l.column}:(a===V.NONE?i={...i,startRow:c.row,startColumn:c.column}:a===V.COLUMN?i={...i,startRow:c.row}:a===V.ROW&&(i={...i,startColumn:c.column}),o===V.NONE?i={...i,endRow:l.row,endColumn:l.column}:o===V.COLUMN?i={...i,endRow:l.row}:o===V.ROW&&(i={...i,endColumn:l.column}),i)}function Oo(e,t,n,r,i){return i===B.NORMAL?{row:e+t,column:n+r}:i===B.ROW?{row:e+t,column:n}:i===B.COLUMN?{row:e,column:n+r}:{row:e,column:n}}function ko(e){let t=new Set,n=new Set;for(let r of e)t.add(r.startColumn),t.add(r.endColumn+1),n.add(r.startRow),n.add(r.endRow+1);let r=Array.from(t).sort((e,t)=>e-t),i=Array.from(n).sort((e,t)=>e-t);e.sort((e,t)=>e.startRow-t.startRow||e.startColumn-t.startColumn);let a=[];for(let t=0;t<i.length-1;t++)for(let n=0;n<r.length-1;n++){let o=r[n],s=r[n+1]-1,c=i[t],l=i[t+1]-1;for(let t of e){if(t.startRow>l)break;if(t.startRow<=c&&t.endRow>=l&&t.startColumn<=o&&t.endColumn>=s){a.push({startColumn:o,endColumn:s,startRow:c,endRow:l});break}}}return a}function Ao(e){e.sort((e,t)=>e.startRow-t.startRow||e.startColumn-t.startColumn);let t={};for(let n of e)t[n.startRow]||(t[n.startRow]=[]),t[n.startRow].push(n);let n=[];for(let e in t){let r=t[+e];r.sort((e,t)=>e.startColumn-t.startColumn);let i=r[0];for(let e=1;e<r.length;e++){let t=r[e];t.startColumn<=i.endColumn+1&&t.startRow===i.startRow&&t.endRow===i.endRow?i.endColumn=Math.max(i.endColumn,t.endColumn):(n.push(i),i=t)}n.push(i)}return n}function jo(e){e.sort((e,t)=>e.startColumn-t.startColumn||e.startRow-t.startRow);let t={};for(let n of e)t[n.startColumn]||(t[n.startColumn]=[]),t[n.startColumn].push(n);let n=[];for(let e in t){let r=t[+e];r.sort((e,t)=>e.startRow-t.startRow);let i=r[0];for(let e=1;e<r.length;e++){let t=r[e];t.startRow<=i.endRow+1&&t.startColumn===i.startColumn&&t.endColumn===i.endColumn?i.endRow=Math.max(i.endRow,t.endRow):(n.push(i),i=t)}n.push(i)}return n}function Mo(e){return jo(Ao(ko(e)))}function No(e,t){let n=[];return e.forEach(e=>{n.push(...G.subtract(e,t))}),G.mergeRanges(n)}function Po(e,t){let n=Fo(e.startRow,e.endRow,t.startRow,t.endRow),r=Fo(e.startColumn,e.endColumn,t.startColumn,t.endColumn);if(!n||!r)return null;let[i,a]=n,[o,s]=r;return{startRow:i,endRow:a,startColumn:o,endColumn:s,rangeType:Io(e.rangeType,t.rangeType,i,a,o,s)}}function Fo(e,t,n,r){let i=isNaN(e)?-1/0:e,a=isNaN(t)?1/0:t,o=isNaN(n)?-1/0:n,s=isNaN(r)?1/0:r,c=Math.max(i,o),l=Math.min(a,s);return c<=l?[c===-1/0?NaN:c,l===1/0?NaN:l]:null}function Io(e,t,n,r,i,a){let o=e===void 0?Lo(n,r,i,a):e,s=t===void 0?Lo(n,r,i,a):t;return o===B.ALL||s===B.ALL?o===s?o:o===B.ALL?s:o:o===s?o:(o===B.NORMAL||B.NORMAL,B.NORMAL)}function Lo(e,t,n,r){let i=!isNaN(e)&&!isNaN(t),a=!isNaN(n)&&!isNaN(r);return i&&a?B.NORMAL:i?B.ROW:a?B.COLUMN:B.ALL}var G=class e{static clone(e){return e.rangeType===void 0?{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn}:{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn,rangeType:e.rangeType}}static equals(e,t){return e==null||t==null?!1:e.endRow===t.endRow&&e.endColumn===t.endColumn&&e.startRow===t.startRow&&e.startColumn===t.startColumn&&(e.rangeType===t.rangeType||e.rangeType===void 0&&t.rangeType===B.NORMAL||t.rangeType===void 0&&e.rangeType===B.NORMAL)}static simpleRangesIntersect(e,t){let{startRow:n,endRow:r,startColumn:i,endColumn:a}=e,{startRow:o,endRow:s,startColumn:c,endColumn:l}=t;return n<=s&&r>=o&&i<=l&&a>=c}static intersects(e,t){if(e.rangeType===B.ROW&&t.rangeType===B.COLUMN||e.rangeType===B.COLUMN&&t.rangeType===B.ROW)return!0;if(e.rangeType===B.ROW&&t.rangeType===B.ROW)return e.startRow<=t.endRow&&e.endRow>=t.startRow;if(e.rangeType===B.COLUMN&&t.rangeType===B.COLUMN)return e.startColumn<=t.endColumn&&e.endColumn>=t.startColumn;let n=Number.isNaN(e.startRow)?0:e.startRow,r=Number.isNaN(e.endRow)?uo-1:e.endRow,i=Number.isNaN(e.startColumn)?0:e.startColumn,a=Number.isNaN(e.endColumn)?fo-1:e.endColumn,o=Number.isNaN(t.startRow)?0:t.startRow,s=Number.isNaN(t.endRow)?uo-1:t.endRow,c=Number.isNaN(t.startColumn)?0:t.startColumn,l=Number.isNaN(t.endColumn)?fo-1:t.endColumn,u=Math.abs(i+a-c-l),d=Math.abs(i-a)+Math.abs(c-l),f=Math.abs(n+r-o-s),p=Math.abs(n-r)+Math.abs(o-s);return u<=d&&f<=p}static doAnyRangesIntersect(e,t){let n=new Ke;return n.load(e.map(e=>({minX:e.startColumn,minY:e.startRow,maxX:e.endColumn,maxY:e.endRow}))),t.some(e=>n.search({minX:e.startColumn,minY:e.startRow,maxX:e.endColumn,maxY:e.endRow}).length>0)}static getIntersects(e,t){let n=e.startRow,r=e.endRow,i=e.startColumn,a=e.endColumn,o=t.startRow,s=t.endRow,c=t.startColumn,l=t.endColumn,u,d,f,p;if(o<=r)d=o>=n?o:n;else return null;if(s>=n)p=s>=r?r:s;else return null;if(c<=a)u=c>i?c:i;else return null;if(l>=i)f=l>=a?a:l;else return null;return{startRow:d,endRow:p,startColumn:u,endColumn:f,rangeType:B.NORMAL}}static contains(e,t){return e.startRow<=t.startRow&&e.endRow>=t.endRow&&e.startColumn<=t.startColumn&&e.endColumn>=t.endColumn}static realContain(t,n){return e.contains(t,n)&&(t.startRow<n.startRow||t.endRow>n.endRow||t.startColumn<n.startColumn||t.endColumn>n.endColumn)}static union(...e){return e.reduce((e,t)=>({startRow:Math.min(e.startRow,t.startRow),startColumn:Math.min(e.startColumn,t.startColumn),endRow:Math.max(e.endRow,t.endRow),endColumn:Math.max(e.endColumn,t.endColumn),rangeType:B.NORMAL}),e[0])}static realUnion(...t){let n=t.some(e=>e.rangeType===B.COLUMN),r=t.some(e=>e.rangeType===B.ROW),i=e.union(...t);return{startColumn:r?NaN:i.startColumn,endColumn:r?NaN:i.endColumn,startRow:n?NaN:i.startRow,endRow:n?NaN:i.endRow,rangeType:r?B.ROW:n?B.COLUMN:B.NORMAL}}static subtract(e,t){if(t.startRow>e.endRow||t.endRow<e.startRow||t.startColumn>e.endColumn||t.endColumn<e.startColumn)return[e];let n=[];t.startRow>=e.startRow&&n.push({startRow:e.startRow,startColumn:e.startColumn,endRow:t.startRow-1,endColumn:e.endColumn}),t.endRow<=e.endRow&&n.push({startRow:t.endRow+1,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn});let r=Math.max(e.startRow,t.startRow),i=Math.min(e.endRow,t.endRow);return t.startColumn>=e.startColumn&&n.push({startRow:r,startColumn:e.startColumn,endRow:i,endColumn:t.startColumn-1}),t.endColumn<=e.endColumn&&n.push({startRow:r,startColumn:t.endColumn+1,endRow:i,endColumn:e.endColumn}),n.filter(e=>e.startRow<=e.endRow&&e.startColumn<=e.endColumn)}static mergeRanges(e){return Mo(e)}static splitIntoGrid(e){return ko(e)}static subtractMulti(e,t){if(!t.length)return e;let n=e;return t.forEach(e=>{n=No(n,e)}),n}static hasIntersectionBetweenTwoRect(e,t){return!(e.left>t.right||e.right<t.left||e.top>t.bottom||e.bottom<t.top)}static getIntersectionBetweenTwoRect(e,t){let n=Math.max(e.left,t.left),r=Math.min(e.right,t.right),i=Math.max(e.top,t.top),a=Math.min(e.bottom,t.bottom);return r<=n||a<=i?null:{left:n,right:r,top:i,bottom:a,width:r-n,height:a-i}}static sort(e){return e.sort((e,t)=>e.startRow-t.startRow||e.startColumn-t.startColumn)}};C(G,`getRelativeRange`,(e,t)=>({startRow:e.startRow-t.startRow,endRow:e.endRow-e.startRow,startColumn:e.startColumn-t.startColumn,endColumn:e.endColumn-e.startColumn})),C(G,`getPositionRange`,(e,t,n)=>({...n||{},startRow:n&&[V.ROW,V.ALL].includes(n.startAbsoluteRefType||0)?n.startRow:e.startRow+t.startRow,endRow:n&&[V.ROW,V.ALL].includes(n.endAbsoluteRefType||0)?n.endRow:e.endRow+e.startRow+t.startRow,startColumn:n&&[V.COLUMN,V.ALL].includes(n.startAbsoluteRefType||0)?n.startColumn:e.startColumn+t.startColumn,endColumn:n&&[V.COLUMN,V.ALL].includes(n.endAbsoluteRefType||0)?n.endColumn:e.endColumn+e.startColumn+t.startColumn})),C(G,`moveHorizontal`,(e,t=0,n=0)=>({...e,startColumn:e.startColumn+t,endColumn:e.endColumn+t+n})),C(G,`moveVertical`,(e,t=0,n=0)=>({...e,startRow:e.startRow+t,endRow:e.endRow+t+n})),C(G,`moveOffset`,(e,t,n)=>{let r={...e};switch(e.startAbsoluteRefType){case V.ROW:r.startColumn+=t;break;case V.COLUMN:r.startRow+=n;break;case V.ALL:break;case V.NONE:default:r.startRow+=n,r.startColumn+=t;break}switch(e.endAbsoluteRefType){case V.ROW:r.endColumn+=t;break;case V.COLUMN:r.endRow+=n;break;case V.ALL:break;case V.NONE:default:r.endRow+=n,r.endColumn+=t;break}return r});function Ro(e,t){if(e.length===0||e[0].length===0)return null;let n=Array(e[0].length).fill(0),r=0,i=null;for(let a=0;a<e.length;a++){for(let r=0;r<e[0].length;r++)n[r]=t(e[a][r])?n[r]+1:0;let o=zo(n);o.area>r&&(r=o.area,i={startColumn:o.start,startRow:a-o.height+1,endColumn:o.end,endRow:a})}return i}function zo(e){let t=[],n=0,r={area:0,height:0,start:0,end:0},i=0;for(;i<e.length;)if(t.length===0||e[i]>=e[t[t.length-1]])t.push(i++);else{let a=e[t.pop()],o=t.length===0?i:i-t[t.length-1]-1;a*o>n&&(n=a*o,r={area:n,height:a,start:t.length===0?0:t[t.length-1]+1,end:i-1})}for(;t.length>0;){let a=e[t.pop()],o=t.length===0?i:i-t[t.length-1]-1;a*o>n&&(n=a*o,r={area:n,height:a,start:t.length===0?0:t[t.length-1]+1,end:i-1})}return r}function Bo(e,t){Eo.foreach(t,(t,n)=>{e[t][n]=void 0})}function Vo(e,t){let n=e.toFullArray(),r=[];for(;;){let e=Ro(n,t);if(!e)break;r.push(e),Bo(n,e)}return r}var Ho=class{constructor(e,t){C(this,`_values`,[]),C(this,`_keys`,[]),C(this,`_keyMaps`,new Map),this._values=e,this._keys=t,e.forEach(e=>{this._initKeyMap(e)})}_initKeyMap(e){this._keys.forEach(t=>{let n=e[t],r=this._keyMaps.get(t)||new Map;r.set(n,e),this._keyMaps.set(t,r)})}getValue(e,t){let n=t||this._keys;for(let t=0;t<n.length;t++){let r=this._keyMaps.get(n[t]);if(r!=null&&r.has(e))return r.get(e)}return null}hasValue(e){for(let t=0;t<this._keys.length;t++){let n=this._keyMaps.get(this._keys[t]);if(n!=null&&n.has(e))return!0}return!1}addValue(e){this._values.push(e),this._initKeyMap(e)}setValue(e,t,n){let r=this.getValue(e);r&&Object.keys(r).includes(t)&&(r[t]=n)}deleteValue(e,t){let n=this.getValue(e,t);if(n){this._keys.forEach(e=>{let t=this._keyMaps.get(e),r=n[e];t==null||t.delete(r)});let e=this._values.findIndex(e=>e===n);this._values.splice(e,1)}}getValues(){return this._values}getKeyMap(e){var t;return[...((t=this._keyMaps.get(e))==null?void 0:t.keys())||[]]}clear(){this._values=[],this._keys=[],this._keyMaps.clear()}};function Uo(e,t,n,r){return{forEach(i){for(let a=e;a<=t;a++)for(let e=n;e<=r;e++)i(a,e)}}}function Wo(e){if(e==null||e.length===0)return NaN;let t=e.toLowerCase().split(``),n=t.length,r=e=>e.charCodeAt(0)-96,i=0,a=0;for(let e=0;e<n;e++)a=r(t[e]),i+=a*26**(n-e-1);return i===0?NaN:i-1}function Go(e){let t=``;for(;e>=0;)t=String.fromCharCode(e%26+65)+t,e=Math.floor(e/26)-1;return t}function Ko(e,t){let n=``;for(;t>0;)n+=e,t--;return n}function qo(e,t=!1){let n=97;return t&&(n=65),Ko(String.fromCharCode(e%26+n),Math.floor(e/26)+1)}function Jo(e,t){return e.zIndex>t.zIndex?1:e.zIndex===t.zIndex?0:-1}function Yo(e,t){return e.zIndex>t.zIndex?-1:e.zIndex===t.zIndex?0:1}function Xo(e=`index`,t=1){return(n,r)=>n[e]>r[e]?t:n[e]===r[e]?0:-t}function Zo(e,t=!1){let n=[];for(let r of e){let{st:e,ed:i,ts:a}=r;if(r.sId===void 0&&delete r.sId,e===i||!t&&D.isEmptyObject(a)&&r.sId==null)continue;if(n.length===0){n.push(r);continue}let o=n.pop();Ba(r,o)&&D.hasIntersectionBetweenTwoRanges(o.st,o.ed,r.st,r.ed)?n.push({...r,st:o.st,ed:i}):n.push(o,r)}return n}function Qo(e,t,n,r){var i;let{textRuns:a}=e;if(a==null)return;let o=[],s=a.length,c=!1,l=(i=t.textRuns)==null?[]:i;if(l.length)for(let e of l)e.st+=r,e.ed+=r;for(let e=0;e<s;e++){let t=a[e],{st:i,ed:s}=t;if(s<=r)o.push(t);else if(r>i&&r<s){c=!0;let e={...t,ed:r};o.push(e),l.length&&o.push(...l);let i={...t,st:r+n,ed:s+n};o.push(i)}else t.st+=n,t.ed+=n,c||(c=!0,o.push(...l)),o.push(t)}c||(c=!0,o.push(...l)),e.textRuns=Zo(o)}function $o(e,t,n,r){let{paragraphs:i}=e;if(i==null)return;let{paragraphs:a}=t,o=[],s=-1;for(let e=0,t=i.length;e<t;e++){let t=i[e],{startIndex:a}=t;a>=r&&(t.startIndex+=n),s===-1&&a>=r&&(s=e),o.push(t.startIndex)}let c=-1;if(a){for(let e=0,t=a.length;e<t;e++){let t=a[e];t.startIndex+=r;let n=t.startIndex;c=o.indexOf(n)}c!==-1&&i.splice(c,1),i.push(...a),i.sort(Xo(`startIndex`))}}function es(e,t,n,r){let{sectionBreaks:i}=e;if(i==null)return;for(let e=0,t=i.length;e<t;e++){let t=i[e],{startIndex:a}=t;a>=r&&(t.startIndex+=n)}let a=t.sectionBreaks;if(a){for(let e=0,t=a.length;e<t;e++){let t=a[e];t.startIndex+=r}i.push(...a),i.sort(Xo(`startIndex`))}}function ts(e,t,n,r){let{customBlocks:i=[]}=e;for(let e=0,t=i.length;e<t;e++){let t=i[e],{startIndex:a}=t;a>=r&&(t.startIndex+=n)}let a=t.customBlocks;if(a){for(let e=0,t=a.length;e<t;e++){let t=a[e];t.startIndex+=r}i.push(...a),i.sort(Xo(`startIndex`))}i.length&&!e.customBlocks&&(e.customBlocks=i)}function ns(e,t,n,r){let{tables:i}=e;if(i==null)return;for(let e=0,t=i.length;e<t;e++){let t=i[e],{startIndex:a,endIndex:o}=t;a>r?(t.startIndex+=n,t.endIndex+=n):o>r&&(t.endIndex+=n)}let a=t.tables;if(a){for(let e=0,t=a.length;e<t;e++){let t=a[e];t.startIndex+=r,t.endIndex+=r}i.push(...a),i.sort(Xo(`startIndex`))}}const rs=e=>e.split(`$`)[0];function is(e){if(e.length<=1)return e;e.sort((e,t)=>e.startIndex-t.startIndex);let t=[],n={...e[0]};n.rangeId=rs(n.rangeId);for(let r=1;r<e.length;r++){let i=e[r];i.rangeId=rs(i.rangeId),i.rangeId===n.rangeId&&Ct(n.properties,i.properties)&&n.endIndex+1>=i.startIndex?n.endIndex=i.endIndex:(t.push(n),n={...i})}t.push(n);let r=Object.create(null);for(let e=0,n=t.length;e<n;e++){let n=t[e],i=n.rangeId;r[i]?(n.rangeId=`${i}\$${r[i]}`,r[i]=r[i]+1):r[i]=1}return t}function as(e,t){let n=e.findIndex(e=>e.startIndex<t&&e.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 os(e){if(e.length<=1)return e;e.sort((e,t)=>e.startIndex-t.startIndex);let t=[],n={...e[0]};for(let r=1;r<e.length;r++){let i=e[r];i.id===n.id&&n.endIndex+1>=i.startIndex?n.endIndex=i.endIndex:(t.push(n),n={...i})}return t.push(n),t}function ss(e,t){e.filter(e=>e.startIndex<t&&e.endIndex>=t).forEach(n=>{let r=e.indexOf(n);e.splice(r,1,{id:n.id,type:n.type,startIndex:n.startIndex,endIndex:t-1},{id:n.id,type:n.type,startIndex:t,endIndex:n.endIndex})})}function cs(e,t,n,r){e.customRanges||(e.customRanges=[]);let{customRanges:i}=e;as(i,r);for(let e=0,t=i.length;e<t;e++){let t=i[e],{startIndex:a}=t;a>=r&&(t.startIndex+=n,t.endIndex+=n)}let a=[];if(t.customRanges){for(let e=0,n=t.customRanges.length;e<n;e++){let n=t.customRanges[e];n.startIndex+=r,n.endIndex+=r,a.push(n)}i.push(...a)}e.customRanges=is(i)}function ls(e,t,n,r){e.customDecorations||(e.customDecorations=[]);let{customDecorations:i}=e;ss(i,r);for(let e=0,t=i.length;e<t;e++){let t=i[e],{startIndex:a}=t;a>=r&&(t.startIndex+=n,t.endIndex+=n)}let a=[];if(t.customDecorations){for(let e=0,n=t.customDecorations.length;e<n;e++){let n=t.customDecorations[e];n.startIndex+=r,n.endIndex+=r,a.push(n)}i.push(...a)}e.customDecorations=os(i)}function us(e,t,n){let{textRuns:r}=e,i=n,a=n+t,o=[];if(r){let n=[];for(let e=0,s=r.length;e<s;e++){let s=r[e],{st:c,ed:l}=s;if(i<=c&&a>=l){o.push({...s,st:c-i,ed:l-i});continue}else c<=i&&l>=a?(o.push({...s,st:i-i,ed:a-i}),s.ed-=t):i>=c&&i<l?(o.push({...s,st:i-i,ed:l-i}),s.ed=i):a>c&&a<=l?(o.push({...s,st:c-i,ed:a-i}),s.st=a-t,s.ed-=t):c>=a&&(s.st-=t,s.ed-=t);n.push(s)}e.textRuns=n}return o.length===0&&o.push({st:0,ed:t,ts:{}}),o}function ds(e,t,n){let{paragraphs:r}=e,i=n,a=n+t,o=[],s=null,c=!1;if(r){let l=[];for(let e=0,u=r.length;e<u;e++){let u=r[e],{startIndex:d}=u;if(d>=i&&d<a){o.push({...u,startIndex:d-n}),c=!0;continue}else d>=a&&(u.startIndex-=t);l.push(u),s==null&&c&&(s=u)}e.paragraphs=l}return o}function fs(e,t,n){let{sectionBreaks:r}=e,i=n,a=n+t-1,o=[];if(r){let s=[];for(let e=0,c=r.length;e<c;e++){let c=r[e],{startIndex:l}=c;if(l>=i&&l<=a){o.push({...c,startIndex:l-n});continue}else l>a&&(c.startIndex-=t);s.push(c)}e.sectionBreaks=s}return o}function ps(e,t,n){let{customBlocks:r=[]}=e,i=n,a=n+t-1,o=[];if(r){let s=[];for(let e=0,c=r.length;e<c;e++){let c=r[e],{startIndex:l}=c;if(l>=i&&l<=a){o.push({...c,startIndex:l-n});continue}else l>a&&(c.startIndex-=t);s.push(c)}e.customBlocks=s}return r.length&&!e.customBlocks&&(e.customBlocks=r),o}function ms(e,t,n){let{tables:r}=e,i=n,a=n+t-1,o=[];if(r){let s=[];for(let e=0,c=r.length;e<c;e++){let c=r[e],{startIndex:l,endIndex:u}=c;if(i<=l&&a>=u){o.push({...c,startIndex:l-n,endIndex:u-n});continue}else if(l<=i&&u>=a){let e=Ha(l,u,i,a);if(e.length===0||(c.startIndex=e[0],c.endIndex=e[1],c.startIndex===c.endIndex))continue}else a<l&&(c.startIndex-=t,c.endIndex-=t);s.push(c)}e.tables=s}return o}function hs(e,t,n){let{customRanges:r}=e,i=n,a=n+t-1,o=[];if(r){let n=[];for(let e=0,s=r.length;e<s;e++){let s=r[e],{startIndex:c,endIndex:l}=s;if(c>=i&&l<=a){o.push(s);continue}else if(Math.max(i,c)<=Math.min(a,l)){let e=Ha(c,l,i,a);if(e.length===0)continue;s.startIndex=e[0],s.endIndex=e[1]}else a<c&&(s.startIndex-=t,s.endIndex-=t);n.push(s)}e.customRanges=is(n)}return o}function gs(e,t,n,r=!0){let{customDecorations:i}=e,a=n,o=n+t-1,s=[];if(i){let n=[];for(let e=0,c=i.length;e<c;e++){let c=i[e],{startIndex:l,endIndex:u}=c;if(l>=a&&u<=o){s.push(c);continue}else if(Math.max(a,l)<=Math.min(o,u)){let e=Ha(l,u,a,o);if(e.length===0)continue;c.startIndex=e[0],c.endIndex=e[1]}else o<l&&r&&(c.startIndex-=t,c.endIndex-=t);n.push(c)}e.customDecorations=n}return s}let K=function(e){return e.ORDER_LIST_QUICK_1=`1.`,e.ORDER_LIST_QUICK_2=`a)`,e.ORDER_LIST_QUICK_3=`a.`,e.ORDER_LIST_QUICK_4=`i.`,e.ORDER_LIST_QUICK_5=`A.`,e.ORDER_LIST_QUICK_6=`I.`,e.ORDER_LIST_QUICK_7=`01.`,e.BULLET_LIST=`*`,e}({}),q=function(e){return 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}({});const _s={"a)":{glyphFormat:`%1)`,glyphType:M.DECIMAL},"1.":{glyphFormat:`%1.`,glyphType:M.DECIMAL},"a.":{glyphFormat:`%1.`,glyphType:M.LOWER_LETTER},"A.":{glyphFormat:`%1.`,glyphType:M.UPPER_LETTER},"i.":{glyphFormat:`%1.`,glyphType:M.LOWER_ROMAN},"I.":{glyphFormat:`%1.`,glyphType:M.UPPER_LETTER}},vs=e=>[...e,...e,...e].map((e,t)=>({glyphFormat:` %${t+1}`,glyphSymbol:e,bulletAlignment:ar.START,textStyle:{fs:12},startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*t}}})),ys=e=>e.map((e,t)=>({...e,bulletAlignment:ar.START,textStyle:{fs:12},startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*t}}})),bs=(e,t)=>Array(9).fill(0).map((n,r)=>({glyphFormat:` %${r+1}`,glyphSymbol:e,bulletAlignment:ar.START,textStyle:{fs:16},startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*r},textStyle:t}})),xs={[q.BULLET_LIST]:{listType:q.BULLET_LIST,nestingLevel:vs([`●`,`○`,`■`])},[q.BULLET_LIST_1]:{listType:q.BULLET_LIST,nestingLevel:vs([`❖`,`➢`,`■`])},[q.BULLET_LIST_2]:{listType:q.BULLET_LIST,nestingLevel:vs([`✔`,`●`,`◆`])},[q.BULLET_LIST_3]:{listType:q.BULLET_LIST,nestingLevel:vs([`■`,`◆`,`○`])},[q.BULLET_LIST_4]:{listType:q.BULLET_LIST,nestingLevel:vs([`✧`,`○`,`■`])},[q.BULLET_LIST_5]:{listType:q.BULLET_LIST,nestingLevel:vs([`➢`,`○`,`◆`])},[q.ORDER_LIST]:{listType:q.ORDER_LIST,nestingLevel:ys([{glyphFormat:`%1.`,glyphType:M.DECIMAL},{glyphFormat:`%2.`,glyphType:M.LOWER_LETTER},{glyphFormat:`%3.`,glyphType:M.LOWER_ROMAN},{glyphFormat:`%4.`,glyphType:M.DECIMAL},{glyphFormat:`%5.`,glyphType:M.LOWER_LETTER},{glyphFormat:`%6.`,glyphType:M.LOWER_ROMAN},{glyphFormat:`%7.`,glyphType:M.DECIMAL},{glyphFormat:`%8.`,glyphType:M.LOWER_LETTER},{glyphFormat:`%9.`,glyphType:M.LOWER_ROMAN}])},[q.ORDER_LIST_1]:{listType:q.ORDER_LIST,nestingLevel:ys([{glyphFormat:`%1)`,glyphType:M.DECIMAL},{glyphFormat:`%2)`,glyphType:M.LOWER_LETTER},{glyphFormat:`%3)`,glyphType:M.LOWER_ROMAN},{glyphFormat:`%4)`,glyphType:M.DECIMAL},{glyphFormat:`%5)`,glyphType:M.LOWER_LETTER},{glyphFormat:`%6)`,glyphType:M.LOWER_ROMAN},{glyphFormat:`%7)`,glyphType:M.DECIMAL},{glyphFormat:`%8)`,glyphType:M.LOWER_LETTER},{glyphFormat:`%9)`,glyphType:M.LOWER_ROMAN}])},[q.ORDER_LIST_2]:{listType:q.ORDER_LIST,nestingLevel:ys([`%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:M.DECIMAL})))},[q.ORDER_LIST_3]:{listType:q.ORDER_LIST,nestingLevel:ys([{glyphFormat:`%1.`,glyphType:M.UPPER_LETTER},{glyphFormat:`%2.`,glyphType:M.LOWER_LETTER},{glyphFormat:`%3.`,glyphType:M.LOWER_ROMAN},{glyphFormat:`%4.`,glyphType:M.UPPER_LETTER},{glyphFormat:`%5.`,glyphType:M.LOWER_LETTER},{glyphFormat:`%6.`,glyphType:M.LOWER_ROMAN},{glyphFormat:`%7.`,glyphType:M.UPPER_LETTER},{glyphFormat:`%8.`,glyphType:M.LOWER_LETTER},{glyphFormat:`%9.`,glyphType:M.LOWER_ROMAN}])},[q.ORDER_LIST_4]:{listType:q.ORDER_LIST,nestingLevel:ys([{glyphFormat:`%1.`,glyphType:M.UPPER_LETTER},{glyphFormat:`%2.`,glyphType:M.DECIMAL},{glyphFormat:`%3.`,glyphType:M.LOWER_ROMAN},{glyphFormat:`%4.`,glyphType:M.UPPER_LETTER},{glyphFormat:`%5.`,glyphType:M.DECIMAL},{glyphFormat:`%6.`,glyphType:M.LOWER_ROMAN},{glyphFormat:`%7.`,glyphType:M.UPPER_LETTER},{glyphFormat:`%8.`,glyphType:M.DECIMAL},{glyphFormat:`%9.`,glyphType:M.LOWER_ROMAN}])},[q.ORDER_LIST_5]:{listType:q.ORDER_LIST,nestingLevel:ys([{glyphFormat:`%1.`,glyphType:M.DECIMAL_ZERO},{glyphFormat:`%2.`,glyphType:M.LOWER_LETTER},{glyphFormat:`%3.`,glyphType:M.LOWER_ROMAN},{glyphFormat:`%4.`,glyphType:M.DECIMAL_ZERO},{glyphFormat:`%5.`,glyphType:M.LOWER_LETTER},{glyphFormat:`%6.`,glyphType:M.LOWER_ROMAN},{glyphFormat:`%7.`,glyphType:M.DECIMAL_ZERO},{glyphFormat:`%8.`,glyphType:M.LOWER_LETTER},{glyphFormat:`%9.`,glyphType:M.LOWER_ROMAN}])},[q.CHECK_LIST]:{listType:q.CHECK_LIST,nestingLevel:bs(`☐`)},[q.CHECK_LIST_CHECKED]:{listType:q.CHECK_LIST_CHECKED,nestingLevel:bs(`☑`,{st:{s:A.TRUE}})}},Ss=e=>{let{glyphFormat:t,glyphType:n}=e,r=D.deepClone(xs[q.ORDER_LIST]);return r.nestingLevel[0].glyphFormat=t,r.nestingLevel[0].glyphType=n,r},Cs={[q.ORDER_LIST_QUICK_2]:Ss(_s[K.ORDER_LIST_QUICK_2]),[q.ORDER_LIST_QUICK_3]:Ss(_s[K.ORDER_LIST_QUICK_3]),[q.ORDER_LIST_QUICK_4]:Ss(_s[K.ORDER_LIST_QUICK_4]),[q.ORDER_LIST_QUICK_6]:Ss(_s[K.ORDER_LIST_QUICK_6])};Object.assign(xs,Cs);const ws={[K.ORDER_LIST_QUICK_1]:q.ORDER_LIST,[K.ORDER_LIST_QUICK_2]:q.ORDER_LIST_QUICK_2,[K.ORDER_LIST_QUICK_3]:q.ORDER_LIST_QUICK_3,[K.ORDER_LIST_QUICK_4]:q.ORDER_LIST_QUICK_4,[K.ORDER_LIST_QUICK_5]:q.ORDER_LIST_3,[K.ORDER_LIST_QUICK_6]:q.ORDER_LIST_QUICK_6,[K.ORDER_LIST_QUICK_7]:q.ORDER_LIST_5,[K.BULLET_LIST]:q.BULLET_LIST};function Ts(e,t,n,r,i){return{dataStream:``,textRuns:Es(e,t,n,r,i),paragraphs:Os(e,t,n,r,i),sectionBreaks:ks(e,t,n,r,i),customBlocks:As(e,t,n,r,i),tables:js(e,t,n,r,i),customRanges:Ms(e,t,n,r,i),customDecorations:Ns(e,t,n,r,i)}}function Es(e,t,n,r,i){let{textRuns:a}=e,{textRuns:o}=t;if(a==null||o==null)return;let s=us(e,n,r);return i!==F.REPLACE&&(t.textRuns=Ds(o,s,i)),Qo(e,t,n,r),s}function Ds(e,t,n){if(t.length===0)return e;e=D.deepClone(e),t=D.deepClone(t);let r=[],i=e.length,a=t.length,o=0,s=0,c=null;function l(){return c?(r.push(c),c=null,!0):!1}for(;o<i&&s<a;){let{st:i,ed:a,ts:u}=e[o],{st:d,ed:f,ts:p,sId:m}=t[s],h;if(h=n===F.COVER?{...p,...u}:{...u},a<d)l()||r.push(e[o]),o++;else if(f<i)l()||r.push(t[s]),s++;else{let n={st:Math.min(i,d),ed:Math.max(i,d),ts:i<d?{...u}:{...p},sId:i<d?void 0:m};n.ed>n.st&&r.push(n),r.push({st:Math.max(i,d),ed:Math.min(a,f),ts:h,sId:m}),a<f?(o++,t[s].st=a,t[s].st===t[s].ed&&s++):(s++,e[o].st=f,e[o].st===e[o].ed&&o++);let l={st:Math.min(a,f),ed:Math.max(a,f),ts:a<f?{...p}:{...u},sId:a<f?m:void 0};c=l.ed>l.st?l:null}}l();let u=r[r.length-1],d=e[i-1],f=t[a-1];return u&&u.ed!==Math.max(d.ed,f.ed)&&(d.ed>f.ed?r.push(d):r.push(f)),Zo(r)}function Os(e,t,n,r,i){let{paragraphs:a}=e,{paragraphs:o}=t;if(a==null||o==null)return;let s=ds(e,n,r);if(i!==F.REPLACE){let e=[];for(let t of o){let{startIndex:n,paragraphStyle:r,bullet:a}=t,o=[];for(let e of s){let{startIndex:t,paragraphStyle:s,bullet:c}=e,l,u;if(i===F.COVER?(l={...s,...r},u={listId:``,listType:q.BULLET_LIST,nestingLevel:0,textStyle:{},...c,...a}):(l={...r,...s},u={listId:``,listType:q.BULLET_LIST,nestingLevel:0,textStyle:{},...a,...c}),n===t){o.push({startIndex:n,paragraphStyle:l,bullet:u});break}}e.push(...o),o=[]}t.paragraphs=e}return $o(e,t,n,r),s}function ks(e,t,n,r,i){let{sectionBreaks:a}=e,{sectionBreaks:o}=t;if(a==null||o==null)return;let s=fs(e,n,r);if(i!==F.REPLACE){let e=[];for(let t of o){let{startIndex:n}=t,r=[];for(let e of s){let{startIndex:a}=e;if(n===a){i===F.COVER?r.push({...e,...t}):r.push({...t,...e});break}}e.push(...r),r=[]}t.sectionBreaks=e}return es(e,t,n,r),s}function As(e,t,n,r,i){let{customBlocks:a=[]}=e,{customBlocks:o}=t;if(a==null||o==null)return;let s=ps(e,n,r);if(i!==F.REPLACE){let e=[];for(let t of o){let{startIndex:n}=t,r=[];for(let e of s){let{startIndex:a}=e;if(n===a){i===F.COVER?r.push({...e,...t}):r.push({...t,...e});break}}e.push(...r),r=[]}t.customBlocks=e}return ts(e,t,n,r),a.length&&!e.customBlocks&&(e.customBlocks=a),s}function js(e,t,n,r,i){let{tables:a}=e,{tables:o}=t;if(a==null||o==null)return;let s=ms(e,n,r);if(i!==F.REPLACE){let e=[];for(let t of o){let{startIndex:n,endIndex:r}=t,a=[];for(let e of s){let{startIndex:o,endIndex:s}=e;if(o>=n&&s<=r){i===F.COVER?a.push({...e,...t}):a.push({...t,...e});break}}e.push(...a),a=[]}t.tables=e}return ns(e,t,n,r),s}function Ms(e,t,n,r,i){e.customRanges||(e.customRanges=[]),as(e.customRanges,r),as(e.customRanges,r+n);let a=r,o=r+n-1,{customRanges:s}=t,c=[],l=new Map;return e.customRanges.forEach(e=>{let{startIndex:t,endIndex:n}=e;t>=a&&n<=o?l.set(e.rangeId,e):c.push(e)}),s?(s.forEach(e=>{let{startIndex:t,endIndex:n}=e;c.push({...e,startIndex:t+r,endIndex:n+r})}),e.customRanges=is(c),[]):[]}function Ns(e,t,n,r,i){e.customDecorations||(e.customDecorations=[]),ss(e.customDecorations,r),ss(e.customDecorations,r+n);let a=[],{customDecorations:o}=e,{customDecorations:s=[]}=t;if(i===F.REPLACE){for(let e=0;e<o.length;e++){let t=o[e],{startIndex:i,endIndex:s}=t;i>=r&&s<=r+n-1&&a.push(t)}s.forEach(e=>{let{startIndex:t,endIndex:n}=e;o.push({...e,startIndex:t+r,endIndex:n+r})})}else for(let e of s){let{id:t}=e;if(e.type===sr.DELETED){let e=o.filter(e=>e.id===t);e.length&&a.push(...e)}else o.push({...e,startIndex:e.startIndex+r,endIndex:e.endIndex+r})}for(let e of a){let{id:t}=e,n=o.findIndex(e=>e.id===t);n!==-1&&o.splice(n,1)}return e.customDecorations=os(o),a}let Ps=function(e){return e[e.copy=0]=`copy`,e[e.cut=1]=`cut`,e}({});function Fs(e,t,n,r=!0){let{textRuns:i}=e;if(i){let e=[];for(let r of i){let i=D.deepClone(r),{st:a,ed:o}=i;D.hasIntersectionBetweenTwoRanges(a,o,t,n)&&(t>=a&&t<=o?e.push({...i,st:t,ed:Math.min(n,o)}):n>=a&&n<=o?e.push({...i,st:Math.max(t,a),ed:n}):e.push(i))}return Zo(e.map(e=>{let{st:n,ed:r}=e;return{...e,st:n-t,ed:r-t}}))}else if(r)return[{st:0,ed:n-t,ts:{}}]}function Is(e,t,n){let{tables:r=[]}=e,i=[];for(let e of r){let r=D.deepClone(e),{startIndex:a,endIndex:o}=r;a>=t&&o<=n&&i.push({...r,startIndex:a-t,endIndex:o-t})}return i}function Ls(e,t,n){let{paragraphs:r=[]}=e,i=[];for(let e of r){let{startIndex:r}=e;if(r>=t&&r<n){let t=D.deepClone(e);i.push(t)}}if(i.length)return i.map(e=>({...e,startIndex:e.startIndex-t}))}function Rs(e,t,n){let{sectionBreaks:r=[]}=e,i=[];for(let e of r){let{startIndex:r}=e;r>=t&&r<=n&&i.push(D.deepClone(e))}if(i.length)return i.map(e=>({...e,startIndex:e.startIndex-t}))}function zs(e,t,n){let{customBlocks:r=[]}=e,i=[];for(let e of r){let{startIndex:r}=e;r>=t&&r<n&&i.push(D.deepClone(e))}if(i.length)return i.map(e=>({...e,startIndex:e.startIndex-t}))}function Bs(e,t,n,r=!0,i=Ps.cut){let{dataStream:a}=e,o={dataStream:a.slice(t,n)};o.textRuns=Fs(e,t,n,r);let s=Is(e,t,n);if(s.length&&(o.tables=s),o.paragraphs=Ls(e,t,n),i===Ps.cut){let i=Us(e,t,n);i?o.customDecorations=i:r&&(o.customDecorations=[])}let{customRanges:c}=Hs(e,t,n);return c?o.customRanges=c:r&&(o.customRanges=[]),o.customBlocks=zs(e,t,n),o}function Vs(e){let{dataStream:t,textRuns:n,paragraphs:r,customRanges:i,customDecorations:a,tables:o}=e,s=0,c=0;i==null||i.forEach(e=>{e.startIndex<0&&(s=Math.max(s,-e.startIndex)),e.endIndex>t.length-1&&(c=Math.max(c,e.endIndex-t.length+1))});let l=`${t}`;return n&&(n[0]&&(n[0].st=n[0].st-s),n[n.length-1]&&(n[n.length-1].ed=n[n.length-1].ed+c)),n==null||n.forEach(e=>{e.st+=s,e.ed+=s}),r==null||r.forEach(e=>{e.startIndex+=s}),i==null||i.forEach(e=>{e.startIndex+=s,e.endIndex+=s}),a==null||a.forEach(e=>{e.startIndex+=s,e.endIndex+=c}),o==null||o.forEach(e=>{e.startIndex+=s,e.endIndex+=c}),{...e,dataStream:l,textRuns:n,paragraphs:r,customRanges:i,customDecorations:a,tables:o}}function Hs(e,t,n){if(e.customRanges==null)return{};let{customRanges:r}=e;return{customRanges:r.filter(e=>Math.max(e.startIndex,t)<=Math.min(e.endIndex,n-1)).map(e=>({...e,startIndex:Math.max(e.startIndex,t),endIndex:Math.min(e.endIndex,n-1)})).map(e=>({...e,startIndex:e.startIndex-t,endIndex:e.endIndex-t})),leftOffset:0,rightOffset:0}}function Us(e,t,n){if(e.customDecorations==null)return;let{customDecorations:r=[]}=e,i=[];return r.forEach(e=>{if(Math.max(e.startIndex,t)<=Math.min(e.endIndex,n-1)){let r=D.deepClone(e);i.push({...r,startIndex:Math.max(r.startIndex-t,0),endIndex:Math.min(r.endIndex,n-1)-t})}}),i}function Ws(e,t,n){return e==null||t==null?e==null?t:e:Ds(e,t,n)}function Gs(e,t,n){if(e==null||t==null)return e==null?t:e;if(t.length===0||e.length===0)return e;if(t.length>1||e.length>1)throw Error(`Cannot cover multiple customRanges`);return n===F.REPLACE?[{...e[0]}]:[{...t[0],...e[0]}]}function Ks(e,t,n){return t.length===0||e.length===0||n===F.REPLACE?e:[...e,...t.filter(t=>!e.some(e=>t.id===e.id))]}function qs(e,t,n=F.COVER){if(t.dataStream!==``)throw Error(`Cannot compose other body with non-empty dataStream`);let r={dataStream:e.dataStream},{textRuns:i,paragraphs:a=[],customRanges:o,customDecorations:s=[]}=e,{textRuns:c,paragraphs:l=[],customRanges:u,customDecorations:d=[]}=t;r.textRuns=Ws(c,i,n),r.customRanges=Gs(u,o,n);let f=Ks(d,s,n);f.length&&(r.customDecorations=f);let p=[],m=0,h=0;for(;m<a.length&&h<l.length;){let e=a[m],t=l[h],{startIndex:n}=e,{startIndex:r}=t;n===r?(p.push(D.deepMerge(e,t)),m++,h++):n<r?(p.push(D.deepClone(e)),m++):(p.push(D.deepClone(t)),h++)}return m<a.length&&p.push(...a.slice(m)),h<l.length&&p.push(...l.slice(h)),p.length&&(r.paragraphs=p),r}function Js(e){let{body:t}=e;if(t==null)return!0;let{textRuns:n,paragraphs:r,customRanges:i,customBlocks:a,customDecorations:o,tables:s}=t;return n==null&&r==null&&i==null&&a==null&&o==null&&s==null}var Ys=class{constructor(e){this._actions=e,C(this,`_index`,0),C(this,`_offset`,0)}hasNext(){return this.peekLength()<1/0}next(e){e||(e=1/0);let t=this._actions[this._index];if(t){let n=this._offset,r=t.len;return e>=r-n?(e=r-n,this._index+=1,this._offset=0):this._offset+=e,t.t===I.DELETE||t.t===I.RETAIN&&t.body==null?D.deepClone({...t,len:e}):D.deepClone({...t,len:e,body:Bs(t.body,n,n+e,!1)})}else return{t:I.RETAIN,len:1/0}}peek(){return this._actions[this._index]}peekLength(){return this._actions[this._index]?this._actions[this._index].len-this._offset:1/0}peekType(){let e=this._actions[this._index];return e?e.t:I.RETAIN}rest(){if(!this.hasNext())return[];if(this._offset===0)return this._actions.slice(this._index);{let e=this._offset,t=this._index,n=this.next(),r=this._actions.slice(this._index);return this._offset=e,this._index=t,[n].concat(r)}}};function Xs(e,t,n){let{dataStream:r}=e,i=n,a=n+t,o=us(e,t,n),s=ds(e,t,n),c=fs(e,t,n),l=ps(e,t,n),u=ms(e,t,n),d=hs(e,t,n),f=gs(e,t,n),p=``;return r&&(e.dataStream=qa(r,i,a),p=r.slice(i,a)),{dataStream:p,textRuns:o,paragraphs:s,sectionBreaks:c,customBlocks:l,tables:u,customRanges:d,customDecorations:f}}function Zs(e,t,n,r){e.dataStream=Ka(e.dataStream,r,t.dataStream),Qo(e,t,n,r),$o(e,t,n,r),es(e,t,n,r),ts(e,t,n,r),ns(e,t,n,r),cs(e,t,n,r),ls(e,t,n,r)}function Qs(e,t,n,r,i=F.COVER){return Ts(e,t,n,r,i)}function $s(e,t,n){return t<=0?{dataStream:``}:Xs(e,t,n)}function ec(e,t,n,r){n!==0&&Zs(e,t,n,r)}function tc(e,t){let n=new Zt;return n.reset(),t.forEach(t=>{let r=D.deepClone(t);switch(r.t){case I.RETAIN:{let{coverType:t,body:i,len:a}=r;i!=null&&Qs(e,i,a,n.cursor,t),n.moveCursor(a);break}case I.INSERT:{let{body:t,len:i}=r;ec(e,t,i,n.cursor),n.moveCursor(i);break}case I.DELETE:{let{len:t}=r;$s(e,t,n.cursor);break}default:throw Error(`Unknown action type for action: ${r}.`)}}),e}var J=function(e){return e[e.COVER=0]=`COVER`,e[e.COVER_ONLY_NOT_EXISTED=1]=`COVER_ONLY_NOT_EXISTED`,e}(J||{});function nc(e,t,n,r,i){if(e==null||t==null)return t;if(e.length===0||t.length===0)return[];t=D.deepClone(t),e=D.deepClone(e);let a=[],o=t.length,s=e.length,c=0,l=0,u=null;function d(){return u?(a.push(u),u=null,!0):!1}for(;c<o&&l<s;){let{st:o,ed:s,ts:f}=t[c],{st:p,ed:m,ts:h,sId:g}=e[l],_={};if(i===J.COVER)_={...f},n===F.COVER&&r===F.REPLACE&&h&&(_=Object.assign({},h,_));else if(_={...f},n===F.REPLACE){if(r===F.REPLACE)_={...h};else if(f&&h){let e=Object.keys(f);for(let t of e)h[t]&&delete _[t]}}else if(r===F.REPLACE){if(h){let e=Object.keys(h);for(let t of e)h[t]!==void 0&&(_[t]=h[t])}}else if(h){let e=Object.keys(h);for(let t of e)_[t]!==void 0&&delete _[t]}if(s<p)d()||a.push(t[c]),c++;else if(m<o)d()||a.push(e[l]),l++;else{let n={st:Math.min(o,p),ed:Math.max(o,p),ts:o<p?{...f}:{...h},sId:o<p?void 0:g};n.ed>n.st&&a.push(),a.push({st:Math.max(o,p),ed:Math.min(s,m),ts:_,sId:g}),s<m?(c++,e[l].st=s,e[l].st===e[l].ed&&l++):(l++,t[c].st=m,t[c].st===t[c].ed&&c++);let r={st:Math.min(s,m),ed:Math.max(s,m),ts:s<m?{...h}:{...f},sId:s<m?g:void 0};u=r.ed>r.st?r:null}}d();let f=a[a.length-1],p=t[o-1],m=e[s-1];return f.ed!==Math.max(p.ed,m.ed)&&(p.ed>m.ed?a.push(p):a.push(m)),Zo(a,!0)}function rc(e,t,n,r,i){if(e==null||t==null)return t;if(e.length===0||t.length===0)return[];if(e.length>1||t.length>1)throw Error(`CustomRanges is only supported transform for length one now.`);let a=e[0],o=t[0];if(n===F.REPLACE)return i===J.COVER_ONLY_NOT_EXISTED?[D.deepClone(a)]:[D.deepClone(o)];if(r===F.REPLACE){let e=D.deepClone(o);return i===J.COVER_ONLY_NOT_EXISTED&&Object.assign(e,D.deepClone(a)),[e]}else{let e=D.deepClone(o);return i===J.COVER_ONLY_NOT_EXISTED&&Object.assign(e,D.deepClone(a)),[e]}}function ic(e,t,n,r,i){let a={startIndex:t.startIndex};if(t.paragraphStyle&&(a.paragraphStyle=D.deepClone(t.paragraphStyle),e.paragraphStyle)){if(n===F.REPLACE)if(r===F.REPLACE)i===J.COVER_ONLY_NOT_EXISTED&&(a.paragraphStyle={...e.paragraphStyle});else if(i===J.COVER_ONLY_NOT_EXISTED){let t=Object.keys(e.paragraphStyle);for(let n of t)e.paragraphStyle[n]!==void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}else{let t=Object.keys(e.paragraphStyle);for(let n of t)a.paragraphStyle[n]===void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}else if(r===F.REPLACE)if(i===J.COVER_ONLY_NOT_EXISTED){let t=Object.keys(e.paragraphStyle);for(let n of t)e.paragraphStyle[n]!==void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}else{let t=Object.keys(e.paragraphStyle);for(let n of t)a.paragraphStyle[n]===void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}else if(i===J.COVER_ONLY_NOT_EXISTED){let t=Object.keys(e.paragraphStyle);for(let e of t)a.paragraphStyle[e]&&delete a.paragraphStyle[e]}}return n===F.REPLACE&&r===F.REPLACE?a.bullet=i===J.COVER_ONLY_NOT_EXISTED?D.deepClone(e.bullet):D.deepClone(t.bullet):e.bullet===void 0?a.bullet=D.deepClone(t.bullet):n===F.REPLACE||r===F.REPLACE?a.bullet=i===J.COVER&&t.bullet?D.deepClone(t.bullet):D.deepClone(e.bullet):i===J.COVER&&t.bullet!==void 0&&(a.bullet=D.deepClone(t.bullet)),a}function ac(e,t){if(e==null||t==null)return t;if(e.length===0||t.length===0)return D.deepClone(t);let n=[];for(let r of t){let{id:t,type:i}=r,a=!1;for(let o of e)if(o.id===t){(o.type===sr.DELETED||i===sr.DELETED)&&(a=!0,n.push({...r,type:sr.DELETED}));break}a||n.push(r)}return n}function oc(e,t,n=!1){let{body:r,coverType:i=F.COVER}=e,{body:a,coverType:o=F.COVER}=t;if(r==null||r.dataStream!==``||a==null||a.dataStream!==``)throw Error(`Data stream is not supported in retain transform.`);let s={dataStream:``},c=o,{textRuns:l,paragraphs:u=[],customRanges:d,customDecorations:f}=r,{textRuns:p,paragraphs:m=[],customRanges:h,customDecorations:g}=a,_=nc(l,p,i,o,n?J.COVER_ONLY_NOT_EXISTED:J.COVER);_&&(s.textRuns=_);let ee=rc(d,h,i,o,n?J.COVER_ONLY_NOT_EXISTED:J.COVER);ee&&(s.customRanges=ee);let te=ac(f,g);te&&(s.customDecorations=te);let ne=[],re=0,ie=0;for(;re<u.length&&ie<m.length;){let e=u[re],t=m[ie],{startIndex:r}=e,{startIndex:a}=t;if(r===a){let a={startIndex:r};a=n?ic(e,t,i,o,J.COVER_ONLY_NOT_EXISTED):ic(e,t,i,o,J.COVER),ne.push(a),re++,ie++}else r<a?re++:(ne.push(D.deepClone(t)),ie++)}return ie<m.length&&ne.push(...m.slice(ie)),ne.length&&(s.paragraphs=ne),{coverType:c,body:s}}function sc(e){return Object.keys(e).length===1}var Y=class e{constructor(){C(this,`_actions`,[])}static apply(e,t){return tc(e,t)}static compose(t,n){let r=new Ys(t),i=new Ys(n),a=new e;for(;r.hasNext()||i.hasNext();)if(i.peekType()===I.INSERT)a.push(i.next());else if(r.peekType()===I.DELETE)a.push(r.next());else{let e=Math.min(r.peekLength(),i.peekLength()),t=r.next(e),n=i.next(e);if(t.t===I.INSERT&&n.t===I.RETAIN)n.body==null?a.push(t):a.push({...t,body:qs(t.body,n.body,n.coverType)});else if(t.t===I.RETAIN&&n.t===I.RETAIN)if(t.body==null&&n.body==null)a.push(t.len===1/0?n:t);else if(t.body&&n.body){let e=t.coverType===F.REPLACE||n.coverType===F.REPLACE?F.REPLACE:F.COVER;a.push({...t,t:I.RETAIN,coverType:e,body:qs(t.body,n.body,n.coverType)})}else a.push(t.body?t:n);else t.t===I.RETAIN&&n.t===I.DELETE?a.push(n):t.t===I.INSERT&&(n.t,I.DELETE)}return a.trimEndUselessRetainAction(),a.serialize()}static transform(e,t,n=`right`){return this._transform(t,e,n===`left`?`right`:`left`)}static _transform(t,n,r=`right`){let i=new Ys(t),a=new Ys(n),o=new e;for(;i.hasNext()||a.hasNext();)if(i.peekType()===I.INSERT&&(r===`left`||a.peekType()!==I.INSERT)){let e=i.next();o.retain(e.len)}else if(a.peekType()===I.INSERT)o.push(a.next());else{let e=Math.min(i.peekLength(),a.peekLength()),t=i.next(e),n=a.next(e);if(t.t===I.DELETE)continue;if(n.t===I.DELETE){o.push(n);continue}if(t.body==null||n.body==null)o.push(n);else{let{coverType:e,body:i}=oc(t,n,r===`left`);o.push({...n,t:I.RETAIN,coverType:e,body:i})}}return o.trimEndUselessRetainAction(),o.serialize()}static transformPosition(e,t,n=!1){let r=new Ys(e),i=0;for(;r.hasNext()&&i<=t;){let e=r.peekLength(),a=r.peekType();if(r.next(),a===I.DELETE){t-=Math.min(e,t-i);continue}else a===I.INSERT&&(i<t||!n)&&(t+=e);i+=e}return t}static isNoop(e){return e.length===0}static invert(e){let t=[];for(let n of e)if(n.t===I.INSERT)t.push({t:I.DELETE,len:n.len,body:n.body});else if(n.t===I.DELETE){if(n.body==null)throw Error(`Can not invert DELETE action without body property, makeInvertible must be called first.`);t.push({t:I.INSERT,body:n.body,len:n.len})}else if(n.body!=null){if(n.oldBody==null)throw Error(`Can not invert RETAIN action without oldBody property, makeInvertible must be called first.`);t.push({t:I.RETAIN,body:n.oldBody,oldBody:n.body,len:n.len,coverType:F.REPLACE})}else t.push(n);return t}static makeInvertible(e,t){let n=[],r=0;for(let i of e){if(i.t===I.DELETE&&(i.body==null||i.body&&i.body.dataStream.length!==i.len)){let e=Bs(t,r,r+i.len,!1);i.len=e.dataStream.length,i.body=e}if(i.t===I.RETAIN&&i.body!=null){let e=Bs(t,r,r+i.len,!0);i.oldBody={...e,dataStream:``},i.len=e.dataStream.length}n.push(i),i.t!==I.INSERT&&(r+=i.len)}return n}insert(e,t){let n={t:I.INSERT,body:t,len:e};return this.push(n),this}retain(e,t,n){let r={t:I.RETAIN,len:e};return t!=null&&(r.body=t),n!=null&&(r.coverType=n),this.push(r),this}delete(e){let t={t:I.DELETE,len:e};return this.push(t),this}empty(){return this._actions=[],this}serialize(){return this._actions}push(...e){if(e.length>1){for(let t of e)this.push(t);return this}let t=this._actions.length,n=this._actions[t-1],r=D.deepClone(e[0]);if(r.t===I.RETAIN&&r.len===0&&r.body==null)return this;if(typeof n==`object`){if(n.t===I.DELETE&&r.t===I.DELETE)return n.len+=r.len,this;if(n.t===I.DELETE&&r.t===I.INSERT&&(--t,n=this._actions[t-1],n==null))return this._actions.unshift(r),this;if(n.t===I.RETAIN&&r.t===I.RETAIN&&n.body==null&&r.body==null)return n.len+=r.len,this;if(n.t===I.INSERT&&sc(n.body)&&r.t===I.INSERT&&sc(r.body))return n.len+=r.len,n.body.dataStream+=r.body.dataStream,this}return t===this._actions.length?this._actions.push(r):this._actions.splice(t,0,r),this}trimEndUselessRetainAction(){let e=this._actions[this._actions.length-1];for(;e&&e.t===I.RETAIN&&Js(e);)this._actions.pop(),e=this._actions[this._actions.length-1];return this}};C(Y,`id`,`text-x`),C(Y,`uri`,`https://github.com/dream-num/univer#text-x`),Object.defineProperty(Y,`name`,{value:`text-x`});var cc=class e{static registerSubtype(e){var t;e==null||this._subTypes.has(e.name)&&((t=this._subTypes.get(e.name))==null?void 0:t.id)!==Y.id||(this._subTypes.set(e.name,e),S.type.registerSubtype(e))}static apply(e,t){if(!S.type.isNoop(t))return S.type.apply(e,t)}static compose(e,t){return S.type.compose(e,t)}static transform(e,t,n){return S.type.transform(e,t,n)}static transformPosition(e,t,n=`right`){return e&&e.length===2&&e[0]===`body`&&e[1].et===Y.name?Y.transformPosition(e[1].e,t,n===`left`):t}static invertWithDoc(e,t){return S.type.invertWithDoc(e,t)}static isNoop(e){return S.type.isNoop(e)}static getInstance(){return this._instance==null&&(this._instance=new e),this._instance}removeOp(e,t){return S.removeOp(e,t)}moveOp(e,t){return S.moveOp(e,t)}insertOp(e,t){return S.insertOp(e,t)}replaceOp(e,t,n){return S.replaceOp(e,t,n)}editOp(e,t=[`body`]){return S.editOp(t,Y.name,e)}};C(cc,`uri`,`https://github.com/dream-num/univer#json-x`),C(cc,`_subTypes`,new Map),C(cc,`_instance`,null),cc.registerSubtype(Y);let lc=function(e){return 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}({}),X=function(e){return e.PARAGRAPH=`\r`,e.SECTION_BREAK=`
|
|
5
|
+
`,e.TABLE_START=``,e.TABLE_ROW_START=`\x1B`,e.TABLE_CELL_START=``,e.TABLE_CELL_END=``,e.TABLE_ROW_END=``,e.TABLE_END=``,e.CUSTOM_RANGE_START=``,e.CUSTOM_RANGE_END=``,e.COLUMN_BREAK=`\v`,e.PAGE_BREAK=`\f`,e.DOCS_END=`\0`,e.TAB=` `,e.CUSTOM_BLOCK=`\b`,e.LETTER=``,e.SPACE=` `,e}({});function uc(e){return`${e}`}const dc=[X.TABLE_START,X.TABLE_ROW_START,X.TABLE_CELL_START,X.TABLE_CELL_END,X.TABLE_ROW_END,X.TABLE_END],fc=e=>{let t=e.endsWith(`\r
|
|
6
|
+
`)?e.slice(0,-2):e;return dc.reduce((e,t)=>e.replaceAll(t,``),t)},pc=e=>e?fc(e).replaceAll(`\r`,``)===``:!0,mc=e=>{let t=e.replace(/\n/g,`\r`),n=[],r=[],i=0,a=``,o=(o,s=!0)=>{let c=t.slice(i,o);if(D.isLegalUrl(c)){let t=O(),l=`${c}`,u={startIndex:i,endIndex:i+l.length-1,rangeId:t,rangeType:or.HYPERLINK,properties:{url:e}};r.push(u),a+=l,i=o+1,s&&(a+=`\r`,n.push({startIndex:o}))}else a+=t.slice(i,o+1),i=o+1,s&&n.push({startIndex:o})},s=0;for(let e=0;e<t.length;e++)t[e]===`\r`&&(o(e),s=e);return(s!==t.length-1||t.length===1)&&o(t.length,!1),{dataStream:a,paragraphs:n,customRanges:r}},hc={id:`default_doc`,documentStyle:{}};var gc=class extends pn{getUnitId(){throw Error(`Method not implemented.`)}constructor(e){var t;super(),C(this,`type`,x.UNIVER_DOC),C(this,`_name$`,new v(``)),C(this,`name$`,this._name$.asObservable()),C(this,`snapshot`,void 0),this.snapshot={...hc,...e},this._name$.next((t=this.snapshot.title)==null?`No Title`:t)}getRev(){var e;return(e=this.snapshot.rev)==null?1:e}incrementRev(){this.snapshot.rev=this.getRev()+1}setRev(e){this.snapshot.rev=e}setName(e){this.snapshot.title=e,this._name$.next(e)}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get zoomRatio(){var e;return((e=this.snapshot.settings)==null?void 0:e.zoomRatio)||1}resetDrawing(e,t){this.snapshot.drawings=e,this.snapshot.drawingsOrder=t}getBody(){return this.snapshot.body}getSnapshot(){return this.snapshot}getBulletPresetList(){var e;let t=(e=this.snapshot.lists)==null?{}:e;return{...xs,...t}}updateDocumentId(e){this.snapshot.id=e}updateDocumentRenderConfig(e){let{documentStyle:t}=this.snapshot;t.renderConfig==null?t.renderConfig=e:t.renderConfig={...t.renderConfig,...e}}getDocumentStyle(){return this.snapshot.documentStyle}updateDocumentStyle(e){this.snapshot.documentStyle==null?this.snapshot.documentStyle=e:this.snapshot.documentStyle={...this.snapshot.documentStyle,...e}}updateDocumentDataMargin(e){let{t,l:n,b:r,r:i}=e,{documentStyle:a}=this.snapshot;t!=null&&(a.marginTop=t),n!=null&&(a.marginLeft=n),r!=null&&(a.marginBottom=r),i!=null&&(a.marginRight=i)}updateDocumentDataPageSize(e,t){let{documentStyle:n}=this.snapshot;if(!n.pageSize){n.pageSize={width:e==null?1/0:e,height:t==null?1/0:t};return}e!==void 0&&(n.pageSize.width=e),t!==void 0&&(n.pageSize.height=t)}updateDrawing(e,t){let{drawings:n}=this,{width:r,height:i,left:a,top:o}=t,s=n==null?void 0:n[e];if(!s)return;let c=s.docTransform;c.size.width=r,c.size.height=i,c.positionH.posOffset=a,c.positionV.posOffset=o}setZoomRatio(e=1){this.snapshot.settings?this.snapshot.settings.zoomRatio=e:this.snapshot.settings={zoomRatio:e}}setDisabled(e){this.snapshot.disabled=e}getDisabled(){return this.snapshot.disabled}getTitle(){return this.snapshot.title}},_c=class e extends gc{constructor(e){var t,n;super(D.isEmptyObject(e)?Jr():e),C(this,`_unitId`,void 0),C(this,`headerModelMap`,new Map),C(this,`footerModelMap`,new Map),C(this,`change$`,new v(0)),this._unitId=(t=this.snapshot.id)==null?O(6):t,this._initializeHeaderFooterModel(),this._name$.next((n=this.snapshot.title)==null?``:n)}dispose(){super.dispose(),this.headerModelMap.forEach(e=>{e.dispose()}),this.footerModelMap.forEach(e=>{e.dispose()}),this._name$.complete()}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getCustomRanges(){var e;return(e=this.snapshot.body)==null?void 0:e.customRanges}getCustomDecorations(){var e;return(e=this.snapshot.body)==null?void 0:e.customDecorations}getSettings(){return this.snapshot.settings}reset(e){if(e.id&&e.id!==this._unitId)throw Error(`Cannot reset a document model with a different unit id!`);this.snapshot={...hc,...e},this._initializeHeaderFooterModel(),this.change$.next(this.change$.value+1)}getSelfOrHeaderFooterModel(e){if(e!=null){if(this.headerModelMap.has(e))return this.headerModelMap.get(e);if(this.footerModelMap.has(e))return this.footerModelMap.get(e)}return this}getUnitId(){return this._unitId}apply(e){if(!cc.isNoop(e))return this.snapshot=cc.apply(this.snapshot,e),e!=null&&e.some(e=>Array.isArray(e)&&((e==null?void 0:e[0])===`headers`||(e==null?void 0:e[0])===`footers`))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.change$.next(this.change$.value+1),this.snapshot}sliceBody(e,t,n=Ps.copy){let r=this.getBody();if(r!=null)return Bs(r,e,t,!1,n)}_initializeHeaderFooterModel(){let{headers:t,footers:n}=this.getSnapshot();if(t)for(let n in t){let r=t[n];this.headerModelMap.set(n,new e(r)),this.headerModelMap.get(n).updateDocumentId(this.getUnitId())}if(n)for(let t in n){let r=n[t];this.footerModelMap.set(t,new e(r)),this.footerModelMap.get(t).updateDocumentId(this.getUnitId())}}updateDocumentId(e){super.updateDocumentId(e),this._unitId=e}getPlainText(){var e,t;return fc((e=(t=this.getBody())==null?void 0:t.dataStream)==null?``:e)}};function vc(e){let{ranges:t,id:n,type:r}=e,i=new Y,a=0;for(let e=0;e<t.length;e++){let{startOffset:o,endOffset:s}=t[e];o>0&&i.push({t:I.RETAIN,len:o-a}),i.push({t:I.RETAIN,body:{dataStream:``,customDecorations:[{id:n,type:r,startIndex:0,endIndex:s-o-1}]},len:s-o}),a=s}return i}function yc(e){var t;let{id:n,segmentId:r,documentDataModel:i}=e,a=i==null?void 0:i.getBody();if(!i||!a)return!1;let o=(t=i.getSelfOrHeaderFooterModel(r))==null||(t=t.getBody())==null||(t=t.customDecorations)==null?void 0:t.find(e=>e.id===n);if(!o)return!1;let s=new Y,{startIndex:c,endIndex:l}=o,u=l-c+1;return s.push({t:I.RETAIN,len:c}),s.push({t:I.RETAIN,len:u,body:{dataStream:``,customDecorations:[{startIndex:0,endIndex:u-1,id:n,type:sr.DELETED}]}}),s}function bc(e,t,n,r){return e<=n&&t>=n||e>=n&&e<=r}function xc(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];e.collapsed?i.startIndex<e.startOffset&&e.startOffset<=i.endIndex&&n.push(i):bc(e.startOffset,e.endOffset-1,i.startIndex,i.endIndex)&&n.push(i)}return n}function Sc(e){return{...D.deepClone(e),rangeId:O()}}function Cc(e,t){let n=[],r=e[0];for(let i of t)i<e[0]||i>e[1]||(r<i&&n.push([r,i-1]),r=i+1);return r<=e[1]&&n.push([r,e[1]]),n}function wc(e,t,n,r){let i=[];for(let a=0,o=n.length;a<o;a++){let o=n[a];if((r===void 0||o.rangeType===r)&&Math.max(o.startIndex,e)<=Math.min(o.endIndex,t)&&i.push({...o}),o.startIndex>t)break}return i}function Tc(e,t){var n,r,i,a,o;let s=wc(e.startOffset,e.collapsed?e.startOffset:e.endOffset-1,(n=t.customRanges)==null?[]:n),c=Math.min(e.startOffset,(r=(i=s[0])==null?void 0:i.startIndex)==null?1/0:r),l=Math.max(e.endOffset,((a=(o=s[s.length-1])==null?void 0:o.endIndex)==null?-1/0:a)+1);return{startOffset:c,endOffset:l,collapsed:c===l}}function Ec(e){var t,n;let{rangeId:r,segmentId:i,documentDataModel:a,insert:o}=e,s=(t=a.getSelfOrHeaderFooterModel(i).getBody())==null||(t=t.customRanges)==null?void 0:t.find(e=>e.rangeId===r);if(!s)return!1;let{startIndex:c,endIndex:l}=s,u=new Y,d=l-c+1;u.push({t:I.RETAIN,len:c}),u.push({t:I.RETAIN,len:d,body:{dataStream:``,customRanges:[]}}),o&&u.push({t:I.INSERT,body:o,len:o.dataStream.length});let f=l+1+((n=o==null?void 0:o.dataStream.length)==null?0:n);return u.selections=[{startOffset:f,endOffset:f,collapsed:!0}],u}function Dc(e){let{ranges:t,rangeId:n,rangeType:r,wholeEntity:i,properties:a,body:o}=e,s=0,c=new Y,l=!1;return t.forEach(e=>{var t,u,d;let f=Tc(e,o);if(!f||!o)return!1;let{startOffset:p,endOffset:m}=f,h=(t=o.customRanges)==null?[]:t,g=(e,t,o)=>{var l,u,d,f;let p=wc(e,t,h,r),m=Math.min((l=(u=p[0])==null?void 0:u.startIndex)==null?1/0:l,e),g=Math.max((d=(f=p[p.length-1])==null?void 0:f.endIndex)==null?-1/0:d,t),_={rangeId:o?`${n}$${o}`:n,rangeType:r,startIndex:0,endIndex:g-m,wholeEntity:i,properties:{...a}};c.push({t:I.RETAIN,len:m-s}),c.push({t:I.RETAIN,len:g-m+1,body:{dataStream:``,customRanges:[_]},coverType:F.COVER}),s=g+1},_=((u=o.paragraphs)==null?[]:u).filter(e=>e.startIndex<m&&e.startIndex>p),ee=((d=o.customBlocks)==null?[]:d).filter(e=>e.startIndex<m&&e.startIndex>p);Cc([p,m-1],[..._.map(e=>e.startIndex),...ee.map(e=>e.startIndex)]).forEach(([e,t],n)=>g(e,t,n)),l=!0,c.selections=[{startOffset:f.endOffset,endOffset:f.endOffset,collapsed:!0}]}),l?c:!1}function Oc(e,t,n=0,r=null,i=!0){e.sort((e,t)=>e.startOffset-t.startOffset);let a=[],{paragraphs:o=[]}=t,s=o==null?void 0:o.find(t=>t.startIndex>=e[0].startOffset&&t.startIndex<e[0].endOffset),c=n;if(e.forEach(e=>{let{startOffset:t,endOffset:n}=e;t>c&&(a.push({t:I.RETAIN,len:t-c}),c=t),c<n&&(a.push({t:I.DELETE,len:n-c}),c=n)}),r&&a.push({t:I.INSERT,body:r,len:r.dataStream.length}),s&&i){let t=o.find(t=>t.startIndex-n>=e[e.length-1].endOffset-1);t&&(t.startIndex>c&&(a.push({t:I.RETAIN,len:t.startIndex-c}),c=t.startIndex),a.push({t:I.RETAIN,len:1,body:{dataStream:``,paragraphs:[{...t,startIndex:0,bullet:s==null?void 0:s.bullet}]},coverType:F.REPLACE}))}return a}function kc(e,t,n=0){let r=[],i=n;return e.forEach(e=>{let{startOffset:n,endOffset:a}=e;n>i&&(r.push({t:I.RETAIN,len:n-i}),i=n),a>i&&(r.push({t:I.RETAIN,len:a-i,body:{...D.deepClone(t),dataStream:``}}),i=a)}),r}const Ac=e=>{var t;let{selection:n,body:r,doc:i}=e,a=n.segmentId,o=(t=i.getSelfOrHeaderFooterModel(a))==null?void 0:t.getBody();if(!o)return!1;let s=n.collapsed?null:Bs(o,n.startOffset,n.endOffset),c=qe(s?s.dataStream:``,r.dataStream),l=0,u=c.map(([e,t])=>{switch(e){case 0:{let e={t:I.RETAIN,body:{...Bs(r,l,l+t.length,!1),dataStream:``},len:t.length};return l+=t.length,e}case 1:{let e={t:I.INSERT,body:Bs(r,l,l+t.length),len:t.length};return l+=t.length,e}default:return{t:I.DELETE,len:t.length}}}),d=new Y;return d.push({t:I.RETAIN,len:n.startOffset}),d.push(...u),d};function jc(e,t){return!!((e==null?void 0:e.length)===(t==null?void 0:t.length)&&e!=null&&e.every((e,n)=>JSON.stringify(e)===JSON.stringify(t==null?void 0:t[n])))}const Mc=e=>{var t;let{selection:n,body:r,doc:i,themeService:a}=e,o=n.segmentId,s=(t=i.getSelfOrHeaderFooterModel(o))==null?void 0:t.getBody();if(!s)return!1;let c=n.collapsed?null:Bs(s,n.startOffset,n.endOffset),l=qe(c?c.dataStream:``,r.dataStream),u=0,d=l.map(([e,t])=>{switch(e){case 0:{let e=Fs(r,u,u+t.length,!1),n=Fs(c,u,u+t.length,!1),i={t:I.RETAIN,body:jc(e,n)?void 0:{textRuns:e==null?void 0:e.map(e=>{var t,n,r,i;return{...e,ts:{...e.ts,cl:!((t=e.ts)==null||(t=t.cl)==null||(t=t.rgb)==null)&&t.includes(`.`)?{rgb:a.getColorFromTheme((n=(r=e.ts)==null||(r=r.cl)==null?void 0:r.rgb)==null?``:n)}:(i=e.ts)==null?void 0:i.cl}}}),dataStream:``},len:t.length};return u+=t.length,i}case 1:{let e={t:I.INSERT,body:Bs(r,u,u+t.length),len:t.length};return u+=t.length,e}default:return{t:I.DELETE,len:t.length}}});if(d.every(e=>e.t===I.RETAIN&&!e.body))return!1;let f=new Y;return f.push({t:I.RETAIN,len:n.startOffset}),f.push(...d),f};function Nc(e,t){let n=[],{customBlocks:r=[]}=e;for(let e of t){let{startOffset:t,endOffset:i}=e;if(!(t==null||i==null))for(let e of r){let{startIndex:r}=e;r>=t&&r<i&&n.push(e.blockId)}}return n}function Pc(e,t=``){if(!t)return[`body`];let{headers:n,footers:r}=e.getSnapshot();if(n==null&&r==null)throw Error(`Document data model must have headers or footers when update by segment id`);if((n==null?void 0:n[t])!=null)return[`headers`,t,`body`];if((r==null?void 0:r[t])!=null)return[`footers`,t,`body`];throw Error(`Segment id not found in headers or footers`)}const Fc=e=>{var t,n;let{selection:r,documentDataModel:i,drawings:a}=e,{collapsed:o,startOffset:s,segmentId:c}=r,l=new Y,u=cc.getInstance(),d=[],f=i.getSelfOrHeaderFooterModel(c).getBody();if(!f)return!1;let p=(t=(n=i.getSnapshot().drawingsOrder)==null?void 0:n.length)==null?0:t,m=0;if(o)s>0&&l.push({t:I.RETAIN,len:s});else{var h,g;let e=Oc([r],f,0,null,!1);l.push(...e);let t=Nc(f,[r]),n=(h=i.getDrawings())==null?{}:h,a=(g=i.getDrawingsOrder())==null?[]:g,o=t.sort((e,t)=>a.indexOf(e)>a.indexOf(t)?-1:a.indexOf(e)<a.indexOf(t)?1:0);if(o.length>0)for(let e of o){let t=n[e],r=a.indexOf(e);if(t==null||r<0)continue;let i=u.removeOp([`drawings`,e],t),o=u.removeOp([`drawingsOrder`,r],e);d.push(i),d.push(o),m++}}l.push({t:I.INSERT,body:{dataStream:`\b`.repeat(a.length),customBlocks:a.map((e,t)=>({startIndex:t,blockId:e.drawingId}))},len:a.length});let _=Pc(i,c),ee=u.editOp(l.serialize(),_);d.push(ee);for(let e of a){let{drawingId:t}=e,n=u.insertOp([`drawings`,t],e),r=u.insertOp([`drawingsOrder`,p-m],t);d.push(n),d.push(r)}return d.reduce((e,t)=>cc.compose(e,t),null)};function Ic(e,t){if(t===void 0)return{startOffset:e,endOffset:e,collapsed:!0};if(t<e)throw Error(`Cannot make a doc selection when endOffset ${t} is less than startOffset ${e}.`);return{startOffset:e,endOffset:t,collapsed:e===t}}function Lc(e){let{startOffset:t,endOffset:n,collapsed:r}=e;return{startOffset:Math.min(t,n),endOffset:Math.max(t,n),collapsed:r}}function Rc(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function zc(e,t,n,r){let{startOffset:i,endOffset:a}=e,o=r==null?Hc(t,n):r,s=[],c=-1;for(let e=0;e<o.length;e++){let t=o[e],{startIndex:n}=t;(i>c&&i<=n||a>c&&a<=n||n>=i&&n<=a)&&s.push(t),c=n}return s}function Bc(e,t,n){let r=[],i=Hc(t,n);for(let a of e){let e=zc(a,t,n,i);r.push(...e)}return r}const Vc=[X.PARAGRAPH,X.TABLE_START,X.TABLE_END,X.TABLE_ROW_START,X.TABLE_CELL_START,X.TABLE_CELL_END];function Hc(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r],{startIndex:a}=i,o=a-1;for(;!Vc.includes(t[o])&&o>=0;)o--;n.push({...i,paragraphStart:o+1,paragraphEnd:i.startIndex})}return n}const Uc=e=>{var t,n;let{paragraphs:r,segmentId:i,document:a}=e,o=e.listType,s=(t=(n=a.getSelfOrHeaderFooterModel(i).getBody())==null?void 0:n.paragraphs)==null?[]:t,c=r.every(e=>{var t;return((t=e.bullet)==null?void 0:t.listType.indexOf(o))===0}),l=O(6);if(r.length===1){let e=s.indexOf(r[0]),t=s[e-1],n=s[e+1];t&&t.bullet&&t.bullet.listType.indexOf(o)===0?(l=t.bullet.listId,o!==q.CHECK_LIST&&(o=t.bullet.listType)):n&&n.bullet&&n.bullet.listType.indexOf(o)===0&&(l=n.bullet.listId,o!==q.CHECK_LIST&&(o=n.bullet.listType))}let u=new Zt;u.reset();let d=new Y;for(let e of r){var f;let{startIndex:t,paragraphStyle:n={},bullet:r}=e;d.push({t:I.RETAIN,len:t-u.cursor}),d.push({t:I.RETAIN,len:1,body:{dataStream:``,paragraphs:[c?{paragraphStyle:n,startIndex:0}:{startIndex:0,paragraphStyle:{...n},bullet:{nestingLevel:(f=r==null?void 0:r.nestingLevel)==null?0:f,textStyle:{fs:20},listType:o,listId:l}}]},coverType:F.REPLACE}),u.moveCursorTo(t+1)}return d},Wc=e=>{var t;let{paragraphIndex:n,segmentId:r,document:i}=e,a=(t=i.getSelfOrHeaderFooterModel(r).getBody())==null?void 0:t.paragraphs;if(a==null)return!1;let o=a.find(e=>e.startIndex===n);if(!(o!=null&&o.bullet)||o.bullet.listType.indexOf(q.CHECK_LIST)===-1)return!1;let s=new Zt;s.reset();let c=new Y,{startIndex:l,paragraphStyle:u={}}=o,d=o.bullet.listType===q.CHECK_LIST?q.CHECK_LIST_CHECKED:q.CHECK_LIST;return c.push({t:I.RETAIN,len:l-s.cursor}),c.push({t:I.RETAIN,len:1,body:{dataStream:``,paragraphs:[{...o,paragraphStyle:u,startIndex:0,bullet:{...o.bullet,listType:d}}]},coverType:F.REPLACE}),s.moveCursorTo(l+1),c},Gc=e=>{var t;let{paragraphs:n,listType:r,segmentId:i,document:a}=e;if(((t=a.getSelfOrHeaderFooterModel(i).getBody())==null?void 0:t.paragraphs)==null)return!1;let o=O(6),s=new Zt;s.reset();let c=new Y;for(let e of n){var l;let{startIndex:t,paragraphStyle:n={},bullet:i}=e;c.push({t:I.RETAIN,len:t-s.cursor}),c.push({t:I.RETAIN,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphStyle:n,bullet:{nestingLevel:(l=i==null?void 0:i.nestingLevel)==null?0:l,textStyle:(i==null?void 0:i.listType)===r?i.textStyle:{fs:20},listType:r,listId:o}}]},coverType:F.REPLACE}),s.moveCursorTo(t+1)}return c};function Kc(e,t){return t.some(t=>e.startIndex>t.startIndex&&e.startIndex<t.endIndex)}const qc=e=>{var t,n,r;let{paragraphs:i,document:a,type:o}=e,s=new Zt;s.reset();let c=new Y,l=(t=a.getSnapshot().lists)==null?{}:t,u=(n=(r=a.getBody())==null?void 0:r.tables)==null?[]:n,d={...xs,...l};for(let e of i){let{startIndex:t,paragraphStyle:n={},bullet:r}=e,i=Kc(e,u);if(c.push({t:I.RETAIN,len:t-s.cursor}),r){let e=d[r.listType].nestingLevel.length-1;i&&(e=Math.min(e,2)),c.push({t:I.RETAIN,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphStyle:{...n},bullet:{...r,nestingLevel:Math.max(Math.min(r.nestingLevel+o,e),0)}}]},coverType:F.REPLACE})}else c.push({t:I.RETAIN,len:1});s.moveCursorTo(t+1)}return c},Jc=e=>{var t,n,r,i;let{textRanges:a,segmentId:o,document:s,style:c,paragraphTextRun:l,cursor:u,deleteLen:d,textX:f}=e,p=s.getSelfOrHeaderFooterModel(o),m=Bc(a,(t=(n=p.getBody())==null?void 0:n.paragraphs)==null?[]:t,(r=(i=p.getBody())==null?void 0:i.dataStream)==null?``:r),h=new Zt;u&&h.moveCursorTo(u);let g=f==null?new Y:f;m.sort((e,t)=>e.startIndex-t.startIndex);let _=Math.max(0,m[0].paragraphStart-1);_>h.cursor&&(g.push({t:I.RETAIN,len:_-h.cursor}),h.moveCursorTo(_)),d&&g.push({t:I.DELETE,len:d});for(let e of m){let{startIndex:t,paragraphStyle:n={}}=e,r=t-h.cursor;g.push({t:I.RETAIN,len:r,...l?{body:{dataStream:``,textRuns:[{ts:l,st:0,ed:r}]},coverType:F.REPLACE}:null}),g.push({t:I.RETAIN,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphStyle:{...n,...c}}]},coverType:F.REPLACE}),h.moveCursorTo(t+1)}return g};var Z=class{};C(Z,`customRange`,{add:Dc,delete:Ec,copyCustomRange:Sc,getCustomRangesInterestsWithSelection:xc,isIntersecting:bc}),C(Z,`customDecoration`,{add:vc,delete:yc}),C(Z,`selection`,{replace:Ac,makeSelection:Ic,normalizeSelection:Lc,delete:Oc,replaceTextRuns:Mc,retain:kc}),C(Z,`range`,{isIntersects:Rc,getParagraphsInRange:zc,getParagraphsInRanges:Bc}),C(Z,`transform`,{getPlainText:fc,fromPlainText:mc,isEmptyDocument:pc}),C(Z,`paragraph`,{bullet:{set:Gc,switch:Uc,toggleChecklist:Wc,changeNestLevel:qc},style:{set:Jc},util:{transform:Hc,getParagraphsInRange:zc,getParagraphsInRanges:Bc}}),C(Z,`drawing`,{add:Fc});function Yc(e,t,n,r){if(t===``)return e;let i=new _c({id:`mock-id`,body:e,documentStyle:{}}),a=t.length,o;for(;(o=(r?i.getBody().dataStream:i.getBody().dataStream.toLowerCase()).indexOf(t))>=0;){let e=new Y,t=cc.getInstance();if(o>0&&e.retain(o),n.length>0){var s;let t=i.sliceBody(o,o+a),r={dataStream:n};Array.isArray(t==null?void 0:t.textRuns)&&t.textRuns.length&&(r.textRuns=[{...t.textRuns[0],st:0,ed:n.length}]),!(t==null||(s=t.customRanges)==null)&&s.length&&(r.customRanges=[{...t.customRanges[0],startIndex:0,endIndex:n.length-1}]),e.insert(n.length,r)}e.delete(a),i.apply(t.editOp(e.serialize()))}let c=i.getBody();return i.dispose(),c}function Xc(e){if(e.customRanges||(e.customRanges=[]),!e.paragraphs){e.paragraphs=[];for(let t=0;t<e.dataStream.length;t++)e.dataStream[t]===`\r`&&e.paragraphs.push({startIndex:t})}return e.customBlocks||(e.customBlocks=[]),e.textRuns||(e.textRuns=[]),e.customDecorations||(e.customDecorations=[]),e.sectionBreaks||(e.sectionBreaks=[]),e.tables||(e.tables=[]),e}function Zc(e){var t;return e.body=Xc((t=e.body)==null?{dataStream:``}:t),e.drawingsOrder||(e.drawingsOrder=[]),e.drawings||(e.drawings={}),e.documentStyle||(e.documentStyle={}),e}var Qc=class e{static create(t={}){return new e(t)}constructor(e={}){C(this,`_style`,void 0),this._style=e}get fontFamily(){return this._style.ff}get fontSize(){return this._style.fs}get italic(){return this._style.it===A.TRUE}get bold(){return this._style.bl===A.TRUE}get underline(){return this._style.ul&&el.create(this._style.ul)}get bottomBorderLine(){return this._style.bbl&&el.create(this._style.bbl)}get strikethrough(){return this._style.st&&el.create(this._style.st)}get overline(){return this._style.ol&&el.create(this._style.ol)}get background(){return this._style.bg}get border(){return this._style.bd}get color(){return this._style.cl}get verticalAlign(){return this._style.va}get numberFormat(){return this._style.n}copy(){return $c.create(D.deepClone(this._style))}getValue(){return{...this._style}}},$c=class e extends Qc{static create(t={}){return new e(t)}constructor(e={}){super(e)}setFontFamily(e){return this._style.ff=e,this}setFontSize(e){return this._style.fs=e,this}setItalic(e){return this._style.it=e?1:0,this}setBold(e){return this._style.bl=e?1:0,this}setUnderline(e){return this._style.ul=e.build(),this}setBottomBorderLine(e){return this._style.bbl=e.build(),this}setStrikethrough(e){return this._style.st=e.build(),this}setOverline(e){return this._style.ol=e.build(),this}setBackground(e){return this._style.bg=e,this}setBorder(e){return this._style.bd=e,this}setColor(e){return this._style.cl=e,this}setVerticalAlign(e){return this._style.va=e,this}copy(){return e.create(D.deepClone(this._style))}build(){return this.getValue()}},el=class e{static create(t={s:1}){return new e(t)}constructor(e={s:1}){C(this,`_decoration`,void 0),this._decoration=e}get show(){return this._decoration.s===A.TRUE}get followFontColor(){return this._decoration.c===A.TRUE}get color(){return this._decoration.cl}get type(){return this._decoration.t}setShow(e){return this._decoration.s=e?1:0,this}setFollowFontColor(e){return this._decoration.c=e?1:0,this}setColor(e){return this._decoration.cl=e,this}setLineType(e){return this._decoration.t=e,this}copy(){return e.create(D.deepClone(this._decoration))}build(){return{...this._decoration}}},tl=class e{static create(t={}){return new e(t)}constructor(e={}){C(this,`_style`,void 0),this._style=e}get indentFirstLine(){return this._style.indentFirstLine}get hanging(){return this._style.hanging}get indentStart(){return this._style.indentStart}get tabStops(){return this._style.tabStops}get indentEnd(){return this._style.indentEnd}get textStyle(){return this._style.textStyle}get headingId(){return this._style.headingId}get namedStyleType(){return this._style.namedStyleType}get horizontalAlign(){return this._style.horizontalAlign}get lineSpacing(){return this._style.lineSpacing}get direction(){return this._style.direction}get spacingRule(){return this._style.spacingRule}get snapToGrid(){return this._style.snapToGrid}get spaceAbove(){return this._style.spaceAbove}get spaceBelow(){return this._style.spaceBelow}get borderBetween(){return this._style.borderBetween}get borderTop(){return this._style.borderTop}get borderBottom(){return this._style.borderBottom}get borderLeft(){return this._style.borderLeft}get borderRight(){return this._style.borderRight}get keepLines(){return this._style.keepLines===A.TRUE}get keepNext(){return this._style.keepNext===A.TRUE}get wordWrap(){return this._style.wordWrap===A.TRUE}get widowControl(){return this._style.widowControl===A.TRUE}get shading(){return this._style.shading}get suppressHyphenation(){return this._style.suppressHyphenation===A.TRUE}copy(){return nl.create(D.deepClone(this._style))}getValue(){return this._style}},nl=class e extends tl{static create(t={}){return new e(t)}constructor(e={}){super(e)}setIndentFirstLine(e){return this._style.indentFirstLine=e,this}setHanging(e){return this._style.hanging=e,this}setIndentStart(e){return this._style.indentStart=e,this}setTabStops(e){return this._style.tabStops=e,this}setIndentEnd(e){return this._style.indentEnd=e,this}setTextStyle(e){return this._style.textStyle=e,this}setHeadingId(e){return this._style.headingId=e,this}setNamedStyleType(e){return this._style.namedStyleType=e,this}setHorizontalAlign(e){return this._style.horizontalAlign=e,this}setLineSpacing(e){return this._style.lineSpacing=e,this}setDirection(e){return this._style.direction=e,this}setSpacingRule(e){return this._style.spacingRule=e,this}setSnapToGrid(e){return this._style.snapToGrid=e?1:0,this}setSpaceAbove(e){return this._style.spaceAbove=e,this}setSpaceBelow(e){return this._style.spaceBelow=e,this}setBorderBetween(e){return this._style.borderBetween=e,this}setBorderTop(e){return this._style.borderTop=e,this}setBorderBottom(e){return this._style.borderBottom=e,this}setBorderLeft(e){return this._style.borderLeft=e,this}setBorderRight(e){return this._style.borderRight=e,this}setKeepLines(e){return this._style.keepLines=e?1:0,this}setKeepNext(e){return this._style.keepNext=e?1:0,this}setWordWrap(e){return this._style.wordWrap=e?1:0,this}setWidowControl(e){return this._style.widowControl=e?1:0,this}setShading(e){return this._style.shading=e,this}setSuppressHyphenation(e){return this._style.suppressHyphenation=e?1:0,this}copy(){return e.create(D.deepClone(this._style))}build(){return this.getValue()}},rl=class e{static create(t){return new e(t)}static createByBody(t){return new e({body:t,id:`d`,documentStyle:{}})}constructor(e){if(C(this,`_data`,void 0),!e.body)throw Error(`Invalid document data, body is required`);this._data=Zc(e)}copy(){return il.create(D.deepClone(this._data))}slice(e,t){let{body:n,...r}=this._data;return il.create({...D.deepClone(r),body:Bs(n,e,t)})}toPlainText(){var e,t;return Z.transform.getPlainText((e=(t=this._data.body)==null?void 0:t.dataStream)==null?``:e).replaceAll(`\r`,`
|
|
7
|
+
`)}getParagraphStyle(){var e;return tl.create((e=this._data.body)==null||(e=e.paragraphs)==null?void 0:e[0].paragraphStyle)}getParagraphBullet(){var e;return(e=this._data.body)==null||(e=e.paragraphs)==null?void 0:e[0].bullet}getParagraphs(){var e,t;let n=(e=(t=this._data.body)==null?void 0:t.paragraphs)==null?[]:e,r=0;return n.map(e=>{let t=this.slice(r,e.startIndex);return r=e.startIndex,t})}getTextRuns(){var e,t;return((e=(t=this._data.body)==null?void 0:t.textRuns)==null?[]:e).map(e=>({...e,ts:e.ts?Qc.create(e.ts):null}))}getLinks(){var e,t;return(e=(t=this._data.body)==null||(t=t.customRanges)==null?void 0:t.filter(e=>e.rangeType===or.HYPERLINK))==null?[]:e}getData(){return this._data}},il=class e extends rl{static newEmptyData(){return Zc({id:`d`,documentStyle:{},drawings:{},drawingsOrder:[],body:{dataStream:`\r
|
|
8
|
+
`,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(t){return new e(t==null?e.newEmptyData():t)}constructor(e){super(e),C(this,`_doc`,void 0),this._doc=new _c(e)}insertText(e,t,n){var r,i;let a=((r=(i=this._data.body)==null?void 0:i.dataStream.length)==null?2:r)-2,o,s;if(typeof e==`string`?o=e:(a=Math.min(e,a),o=t),s=typeof t==`object`?t instanceof $c?t.build():t:n instanceof $c?n.build():n,!o)return this;let c={dataStream:o,textRuns:s?[{ts:s,st:a,ed:a+o.length}]:[]},l=Z.selection.replace({doc:this._doc,selection:{startOffset:a,endOffset:a,collapsed:!0},body:c});if(!l)throw Error(`Insert text failed, please check.`);return Y.apply(this._doc.getBody(),l.serialize()),this}insertRichText(e,t){var n,r;let i=((n=(r=this._data.body)==null?void 0:r.dataStream.length)==null?2:n)-2,a;typeof e==`object`?a=e instanceof rl?e.getData():e:(i=Math.min(e,i),a=t instanceof rl?t.getData():t);let o=Z.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:a.body});if(!o)throw Error(`Insert text failed, please check.`);return Y.apply(this._doc.getBody(),o.serialize()),this}delete(e,t){if(t!==void 0){if(!t)return this;let n=Z.selection.delete([{startOffset:e,endOffset:e+t,collapsed:!0}],this._data.body);Y.apply(this._doc.getBody(),n)}return this}setStyle(e,t,n){let r={dataStream:``,textRuns:[{ts:n instanceof $c?n.build():n,st:0,ed:t-e}]},i=Z.selection.retain([{startOffset:e,endOffset:t,collapsed:!0}],r);return Y.apply(this._doc.getBody(),i),this}setLink(e,t,n){let r=Z.customRange.add({rangeType:or.HYPERLINK,rangeId:O(),properties:{url:n},ranges:[{startOffset:e,endOffset:t,collapsed:!1}],body:this._data.body});if(!r)throw Error(`Insert text failed, please check.`);return Y.apply(this._doc.getBody(),r.serialize()),this}cancelLink(e,t){if(typeof e==`string`){let t=Z.customRange.delete({rangeId:e,documentDataModel:this._doc});if(!t)throw Error(`Insert text failed, please check.`);Y.apply(this._doc.getBody(),t.serialize())}else this.slice(e,t).getLinks().forEach(e=>{let t=Z.customRange.delete({rangeId:e.rangeId,documentDataModel:this._doc});if(!t)throw Error(`Insert text failed, please check.`);Y.apply(this._doc.getBody(),t.serialize())});return this}updateLink(e,t){var n;let r=(n=this._data.body)==null||(n=n.customRanges)==null?void 0:n.find(t=>t.rangeId===e);if(!r)throw Error(`Link not found`);return r.properties.url=t,this}insertParagraph(e,t){let n,r;if(typeof e==`object`){var i,a;n={dataStream:`\r`,paragraphs:[{startIndex:0,paragraphStyle:e.build()}]},r=((i=(a=this._data.body)==null?void 0:a.dataStream.length)==null?2:i)-2}else r=e,n={dataStream:`\r`,paragraphs:[{startIndex:0,paragraphStyle:t==null?void 0:t.build()}]};return this.insertRichText(r,rl.create({body:n,id:`d`,documentStyle:{}})),this}insertLink(t,n,r){let i=``,a=``;typeof t==`string`?(i=t,a=n):(i=n,a=r);let o=e.createByBody({dataStream:i,customRanges:[{rangeType:or.HYPERLINK,rangeId:O(),properties:{url:a},startIndex:0,endIndex:i.length-1}]});return typeof t==`number`?this.insertRichText(t,o):this.insertRichText(o)}};const al=`__default_document_sub_component_id20231101__`;var ol=class{constructor(){C(this,`skipNextObservers`,!1),C(this,`lastReturnValue`,void 0),C(this,`isStopPropagation`,!1)}stopPropagation(){this.isStopPropagation=!0}},sl=class extends y{constructor(...e){super(...e),C(this,`_sortedObservers`,[])}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(e){let t;t=typeof e==`function`?{next:([t,n])=>e(t,n)}:e;let n=super.subscribe(t);return this._sortedObservers.push(t),this._sortedObservers.sort((e,t)=>{var n,r;return((n=e.priority)==null?0:n)-((r=t.priority)==null?0:r)}),n.add(()=>this._sortedObservers=this._sortedObservers.filter(e=>e!==t)),n}clearObservers(){this._sortedObservers.forEach(e=>{var t;return(t=e.complete)==null?void 0:t.call(e)}),this._sortedObservers.length=0}emitEvent(e){if(!this.closed){let n=new ol;n.lastReturnValue=e;for(let r of this._sortedObservers){var t;if(n.lastReturnValue=(t=r.next)==null?void 0:t.call(r,[e,n]),n.skipNextObservers)return{handled:!0,lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}throw Error(`[EventSubject]: cannot emit event on a closed subject.`)}};function cl(e){return new fe(t=>{let n=e.subscribeEvent(e=>{t.next(e)});return()=>n.unsubscribe()})}const ll=m(`core.resource-manager.service`),ul={[b.Editor]:`Editor`,[b.Owner]:`Owner`,[b.Reader]:`Reader`,[b.UNRECOGNIZED]:`UNRECOGNIZED`},dl=e=>e?{userID:`${ul[e]}_${O(8)}`,name:ul[e],avatar:``}:{userID:``,name:``,avatar:``,anonymous:!0,canBindAnonymous:!1},fl=(e,t)=>e.startsWith(ul[t]);var pl=class extends E{constructor(...e){super(...e),C(this,`_model`,new Map),C(this,`_userChange$`,new y),C(this,`userChange$`,this._userChange$.asObservable()),C(this,`_currentUser$`,new v(dl())),C(this,`currentUser$`,this._currentUser$.asObservable())}dispose(){super.dispose(),this._model.clear(),this._userChange$.complete(),this._currentUser$.complete()}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(e){this.addUser(e),this._currentUser$.next(e)}addUser(e){this._model.set(e.userID,e),this._userChange$.next({type:`add`,user:e})}getUser(e,t){let n=this._model.get(e);if(n)return n;t&&t()}delete(e){let t=this.getUser(e);this._model.delete(e),t&&this._userChange$.next({type:`delete`,user:t})}clear(){this._model.clear(),this._userChange$.next({type:`clear`})}list(){return Array.from(this._model.values())}};let ml=class{constructor(e,t){this._resourceManagerService=e,this._userManagerService=t,C(this,`_permissionMap`,new Map([])),C(this,`_permissionOverrides`,new Map),this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){let e=this._userManagerService.getCurrentUser();e&&e.userID||this._userManagerService.setCurrentUser(dl(b.Owner))}_getRole(e){let t=this._userManagerService.getCurrentUser();return t?fl(t.userID,e):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:e=>{let t=[...this._permissionMap.keys()].reduce((e,t)=>(e[t]=this._permissionMap.get(t),e),{});return JSON.stringify(t)},parseJson:e=>JSON.parse(e),pluginName:`SHEET_AuthzIoMockService_PLUGIN`,businesses:[Oe.UNIVER_SHEET,Oe.UNIVER_DOC,Oe.UNIVER_SLIDE],onLoad:(e,t)=>{for(let e in t)this._permissionMap.set(e,t[e])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(e){let t=O(8),{objectType:n,selectRangeObject:r,worksheetObject:i}=e,a=r||i,o={objectType:n,unitID:(a==null?void 0:a.unitID)||``,name:(a==null?void 0:a.name)||``,strategies:[{action:6,role:b.Owner},{action:16,role:b.Owner},{action:17,role:b.Owner},{action:18,role:b.Owner},{action:19,role:b.Owner},{action:33,role:b.Owner},{action:34,role:b.Owner},{action:35,role:b.Owner},{action:36,role:b.Owner},{action:37,role:b.Owner},{action:38,role:b.Owner},{action:39,role:b.Owner},{action:40,role:b.Owner}],selectRangeObject:r};return this._permissionMap.set(t,o),t}async allowed(e){let{objectID:t,actions:n}=e,r=this._permissionMap.get(t);return r?n.map(e=>{let n=`${t}:${e}`;if(this._permissionOverrides.has(n))return{action:e,allowed:this._permissionOverrides.get(n)};let i=r.strategies.find(t=>t.action===e);return i?{action:e,allowed:this._getRole(i.role)}:{action:e,allowed:this._getRole(b.Owner)||this._getRole(b.Editor)}}):n.map(e=>({action:e,allowed:this._getRole(b.Owner)||this._getRole(b.Editor)}))}async batchAllowed(e){let t=await Promise.all(e.map(e=>this.allowed(e)));return e.map((e,n)=>({unitID:e.unitID,objectID:e.objectID,actions:t[n]}))}async list(e){let t=[],n=[{action:6,role:b.Owner},{action:16,role:b.Owner},{action:17,role:b.Owner},{action:18,role:b.Owner},{action:19,role:b.Owner},{action:33,role:b.Owner},{action:34,role:b.Owner},{action:35,role:b.Owner},{action:36,role:b.Owner},{action:37,role:b.Owner},{action:38,role:b.Owner},{action:39,role:b.Owner},{action:40,role:b.Owner}];return e.objectIDs.forEach(r=>{let i=this._permissionMap.get(r),a=(i==null?void 0:i.strategies)||n,o={objectID:r,unitID:e.unitID,objectType:(i==null?void 0:i.objectType)||3,name:(i==null?void 0:i.name)||``,shareOn:!1,shareRole:b.Owner,shareScope:-1,scope:{read:De.AllCollaborator,edit:De.AllCollaborator},creator:dl(b.Owner),strategies:a.map(e=>({action:e.action,role:e.role})),actions:e.actions.map(e=>{let t=`${r}:${e}`;if(this._permissionOverrides.has(t))return{action:e,allowed:this._permissionOverrides.get(t)};let n=a.find(t=>t.action===e);return n?{action:e,allowed:this._getRole(n.role)}:{action:e,allowed:this._getRole(b.Owner)||this._getRole(b.Editor)}})};t.push(o)}),t}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(e){let{objectID:t,strategies:n}=e,r=this._permissionMap.get(t);r&&n&&(r.strategies=n.map(e=>({action:e.action,role:e.role})),this._permissionMap.set(t,r),n.forEach(e=>{e.role===b.Reader?this.setPermissionOverride(t,e.action,!1):(e.role===b.Owner||e.role===b.Editor)&&this.clearPermissionOverride(t,e.action)}))}setPermissionOverride(e,t,n){let r=`${e}:${t}`;this._permissionOverrides.set(r,n)}clearPermissionOverride(e,t){let n=`${e}:${t}`;this._permissionOverrides.delete(n)}clearAllOverrides(e){let t=[];this._permissionOverrides.forEach((n,r)=>{r.startsWith(`${e}:`)&&t.push(r)}),t.forEach(e=>this._permissionOverrides.delete(e))}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(e){}};ml=z([R(0,ll),R(1,t(pl))],ml);const hl=m(`IAuthzIoIoService`),gl=m(`univer.confirm-service`);var _l=class{constructor(){C(this,`confirmOptions$`,new y)}dispose(){this.confirmOptions$.complete()}open(e){throw Error(`This is not implemented in the test service!`)}confirm(e){return Promise.resolve(!0)}close(e){throw Error(`This is not implemented in the test service!`)}};const vl=`FOCUSING_UNIT`,yl=`FOCUSING_SHEET`,bl=`FOCUSING_DOC`,xl=`FOCUSING_SLIDE`,Sl=`FOCUSING_EDITOR_BUT_HIDDEN`,Cl=`EDITOR_ACTIVATED`,wl=`FOCUSING_EDITOR_INPUT_FORMULA`,Tl=`FOCUSING_FX_BAR_EDITOR`,El=`FOCUSING_UNIVER_EDITOR`,Dl=`FOCUSING_EDITOR_INPUT_FORMULA`,Ol=`FOCUSING_COMMENT_EDITOR`,kl=`FOCUSING_PANEL_EDITOR`,Al=`FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE`,jl=`FOCUSING_COMMON_DRAWINGS`,Ml=`FOCUSING_SHAPE_TEXT_EDITOR`,Nl=`FORMULA_EDITOR_ACTIVATED`;var Pl=class extends E{constructor(...e){super(...e),C(this,`_error$`,new y),C(this,`error$`,this._error$.asObservable())}dispose(){this._error$.complete()}emit(e){this._error$.next({errorKey:e})}};let Fl=function(e){return e.URL=`URL`,e.UUID=`UUID`,e.BASE64=`BASE64`,e}({}),Il=function(e){return e.SUCCUSS=`0`,e.ERROR_EXCEED_SIZE=`1`,e.ERROR_IMAGE_TYPE=`2`,e.ERROR_UPLOAD_COUNT_LIMIT=`3`,e.ERROR_IMAGE=`4`,e}({});const Ll=m(`core.image-io.service`),Rl=m(`core.url-image.service`);var zl=`@univerjs/core`,Bl=`0.19.0`;function Vl(e=``,t=Rn.ZH_CN,n=``){return{id:e,sheetOrder:[],name:n,appVersion:Bl,locale:t,styles:{},sheets:{},resources:[]}}var Hl=class{constructor(e={}){C(this,`_styles`,void 0),C(this,`_cacheMap`,new so(1e5)),this._styles=e,this._generateCacheMap()}each(e){return Object.entries(this._styles).forEach(e),this}search(e,t){return this._cacheMap.has(t)?this._cacheMap.get(t):this._getExistingStyleId(e)||`-1`}get(e){return typeof e==`string`?(e=String(e),this._styles[e]):e}add(e,t){let n=O(6);return this._styles[n]=e,this._cacheMap.set(t,n),n}setValue(e){if(e==null)return;let t=JSON.stringify(e),n=this.search(e,t);return n===`-1`?this.add(e,t):n}addCustomStyle(e,t){t!=null&&(this._styles[e]=t,this._cacheMap.set(JSON.stringify(t),e))}remove(e){let t=this._styles[e];t&&(delete this._styles[e],this._cacheMap.delete(JSON.stringify(t)))}toJSON(){return this._styles}getStyleByCell(e){let t;t=e&&D.isObject(e.s)?e.s:(e==null?void 0:e.s)&&this.get(e.s);let n=e==null?void 0:e.interceptorStyle;return n?{...t,...n}:t}_generateCacheMap(){let{_styles:e,_cacheMap:t}=this;for(let n in e){let r=JSON.stringify(e[n]);t.set(r,n)}}_getExistingStyleId(e){let{_styles:t}=this;for(let n in t)if(D.diffValue(t[n],e))return n;return null}};const Ul=(e,t)=>t.length===e.length&&!e.some(e=>t.some(t=>!G.equals(t,e))),Wl=(e,t)=>t.length===e.length&&e.every((e,n)=>{let r=t[n];return r.unitId===e.unitId&&r.sheetId===e.sheetId&&G.equals(e.range,r.range)}),Gl={t:0,b:2,l:2,r:2},Kl=e=>({sbr:.6,sbo:e,spr:.6,spo:e});function ql(e,t,n={}){let r=e.length,{textRotation:i,paddingData:a,horizontalAlign:o=Yn.UNSPECIFIED,verticalAlign:s=Xn.UNSPECIFIED,wrapStrategy:c=Zn.UNSPECIFIED,cellValueType:l}=n,{t:u,r:d,b:f,l:p}=a||Gl,{vertexAngle:m,centerAngle:h}=tu(i);return new _c({id:`d`,body:{dataStream:`${e}\r
|
|
9
|
+
`,textRuns:[{ts:t,st:0,ed:r}],paragraphs:[{startIndex:r,paragraphStyle:{horizontalAlign:o}}],sectionBreaks:[{startIndex:r+1}]},documentStyle:{pageSize:{width:1/0,height:1/0},marginTop:u,marginBottom:f,marginRight:d,marginLeft:p,renderConfig:{horizontalAlign:o,verticalAlign:s,centerAngle:h,vertexAngle:m,wrapStrategy:c,cellValueType:l}},drawings:{},drawingsOrder:[]})}function Jl(e){if(!e)return{};let{tr:t,td:n,ht:r,vt:i,tb:a,pd:o}=e;return{textRotation:t,textDirection:n,horizontalAlign:r,verticalAlign:i,wrapStrategy:a,paddingData:o}}function Yl(e){if(!e)return{};let{ff:t,fs:n,it:r,bl:i,ul:a,st:o,ol:s,cl:c}=e,l={};return t&&(l.ff=t),n&&(l.fs=n),r&&(l.it=r),i&&(l.bl=i),a&&(l.ul=a),o&&(l.st=o),s&&(l.ol=s),c&&(l.cl=c),l}function Xl(e,t,n){var r;let i=e.getBody();if((r=i.customRanges)!=null&&r.some(e=>e.rangeType===or.HYPERLINK))return;let a=Z.customRange.add({ranges:[{startOffset:0,endOffset:i.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:or.HYPERLINK,body:i,properties:{url:t,refId:n}});a&&Y.apply(i,a.serialize())}function Zl(e){return e!=null}function Ql(){return{p:null,s:null,v:null,t:null,f:null,si:null,ref:null,xf:null}}function $l(e){let t=W.ff,n=W.fs;if(!e){let e=`${n}pt ${t}`;return{fontCache:e,fontString:e,fontSize:n,originFontSize:n,fontFamily:t}}let r=Er.ITALIC;(e.it===0||e.it===void 0)&&(r=Er.NORMAL);let i=Er.BOLD;(e.bl===0||e.bl===void 0)&&(i=Er.NORMAL);let a=n;e.fs&&(a=Math.ceil(e.fs));let o=t;if(e.ff){let n=e.ff;n=n.replace(/"/g,``).replace(/'/g,``),n.indexOf(` `)>-1&&(n=`"${n}"`),n==null&&(n=t),o=n}let{va:s}=e,c=a;if(s===er.SUBSCRIPT||s===er.SUPERSCRIPT){let{sbr:e,spr:t}=eu(o,c);c*=s===er.SUBSCRIPT?e:t}let l=`${r} ${i} ${c}pt ${o}`;return{fontCache:l,fontString:`${l}, "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif `,fontSize:c,originFontSize:a,fontFamily:o}}function eu(e,t){return Kl(t)}function tu(e){let{a:t=0,v:n=A.FALSE}=e||{a:0,v:A.FALSE},r=0,i=t;return n===A.TRUE&&(r=90,i=90),{centerAngle:r,vertexAngle:i}}function Q(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e)){let t=e.length,n=Array(t);for(let r=0;r<t;r++)n[r]=Q(e[r]);return n}let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r];t[i]=Q(e[i])}return t}function nu(e){if(e==null)return e;let t={};return e.p!==void 0&&(t.p=e.p===null?null:Q(e.p)),e.s!==void 0&&(e.s===null||typeof e.s==`string`?t.s=e.s:t.s=Q(e.s)),e.v!==void 0&&(t.v=e.v),e.t!==void 0&&(t.t=e.t),e.f!==void 0&&(t.f=e.f),e.ref!==void 0&&(t.ref=e.ref),e.xf!==void 0&&(t.xf=e.xf),e.si!==void 0&&(t.si=e.si),e.custom!==void 0&&(t.custom=e.custom===null?null:Q(e.custom)),t}function ru(e){if(e==null)return e;let t={};return e.p!==void 0&&(t.p=e.p===null?null:Q(e.p)),e.s!==void 0&&(e.s===null||typeof e.s==`string`?t.s=e.s:t.s=Q(e.s)),e.v!==void 0&&(t.v=e.v),e.t!==void 0&&(t.t=e.t),e.f!==void 0&&(t.f=e.f),e.ref!==void 0&&(t.ref=e.ref),e.xf!==void 0&&(t.xf=e.xf),e.si!==void 0&&(t.si=e.si),e.custom!==void 0&&(t.custom=e.custom===null?null:Q(e.custom)),e.rowSpan!==void 0&&(t.rowSpan=e.rowSpan),e.colSpan!==void 0&&(t.colSpan=e.colSpan),e.displayV!==void 0&&(t.displayV=e.displayV),t}function iu(e){let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r],a=Number(i),o=e[a];if(o===void 0)continue;let s={},c=Object.keys(o);for(let e=0,t=c.length;e<t;e++){let t=c[e],n=Number(t),r=o[n];r!=null&&(s[n]=nu(r))}t[a]=s}return t}function au(e){let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r],a=Number(i),o=e[a];if(o===void 0)continue;let s={};`h`in o&&o.h!==void 0&&(s.h=o.h),`ia`in o&&o.ia!==void 0&&(s.ia=o.ia),`ah`in o&&o.ah!==void 0&&(s.ah=o.ah),`hd`in o&&o.hd!==void 0&&(s.hd=o.hd),`w`in o&&o.w!==void 0&&(s.w=o.w),`s`in o&&o.s!==void 0&&(o.s===null||typeof o.s==`string`?s.s=o.s:s.s=Q(o.s)),`custom`in o&&o.custom!==void 0&&(s.custom=o.custom===null?null:Q(o.custom)),t[a]=s}return t}function ou(e){let t=e.length,n=Array(t);for(let r=0;r<t;r++){let t=e[r];n[r]={startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn,rangeType:t.rangeType,startAbsoluteRefType:t.startAbsoluteRefType,endAbsoluteRefType:t.endAbsoluteRefType}}return n}function su(e){let t={id:e.id,name:e.name,tabColor:e.tabColor,hidden:e.hidden,rowCount:e.rowCount,columnCount:e.columnCount,zoomRatio:e.zoomRatio,scrollTop:e.scrollTop,scrollLeft:e.scrollLeft,defaultColumnWidth:e.defaultColumnWidth,defaultRowHeight:e.defaultRowHeight,showGridlines:e.showGridlines,rightToLeft:e.rightToLeft,freeze:{xSplit:e.freeze.xSplit,ySplit:e.freeze.ySplit,startRow:e.freeze.startRow,startColumn:e.freeze.startColumn},rowHeader:{width:e.rowHeader.width,hidden:e.rowHeader.hidden},columnHeader:{height:e.columnHeader.height,hidden:e.columnHeader.hidden},mergeData:ou(e.mergeData),cellData:iu(e.cellData),rowData:au(e.rowData),columnData:au(e.columnData)};return e.gridlinesColor!==void 0&&(t.gridlinesColor=e.gridlinesColor),e.defaultStyle!==void 0&&(e.defaultStyle===null||typeof e.defaultStyle==`string`?t.defaultStyle=e.defaultStyle:t.defaultStyle=Q(e.defaultStyle)),e.custom!==void 0&&(t.custom=e.custom===null?null:Q(e.custom)),t}var cu=class{constructor(e,t){this._config=e,C(this,`_columnData`,{}),this._columnData=t}getColumnData(){return this._columnData}getColVisible(e){let{_columnData:t}=this,n=t[e];return n?n.hd!==A.TRUE:!0}getColumnStyle(e){var t;return(t=this._columnData[e])==null?void 0:t.s}setColumnStyle(e,t){let n=this.getColumnOrCreate(e);n.s=t}getHiddenCols(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getColVisible(a);r&&e?(r=!1,n.push({rangeType:B.COLUMN,startColumn:i,endColumn:a-1,startRow:0,endRow:0})):!r&&!e&&(r=!0,i=a)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:t,rangeType:B.COLUMN}),n}getVisibleCols(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getColVisible(a);r&&!e?(r=!1,n.push({rangeType:B.COLUMN,startColumn:i,endColumn:a-1,startRow:0,endRow:0})):!r&&e&&(r=!0,i=a)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:t,rangeType:B.COLUMN}),n}getColumnDatas(e,t){let n={},r=0;for(let i=e;i<e+t;i++){let e=this.getColumn(i);n[r]=e==null?{w:this._config.defaultColumnWidth,hd:A.FALSE}:e,r++}return n}getSize(){return pa(this._columnData)}getColumnWidth(e){var t,n;return(t=(n=this._columnData[e])==null?void 0:n.w)==null?this._config.defaultColumnWidth:t}setColumnWidth(e,t){let n=this._columnData[e];t===this._config.defaultColumnWidth?n&&(delete n.w,Object.keys(n).length===0&&delete this._columnData[e]):this._columnData[e]=n?{...n,w:t}:{w:t}}getColumn(e){return this._columnData[e]}insertColumnsWithData(e,t,n){let r=t-e+1,i=Object.keys(this._columnData);for(let t=i.length-1;t>=0;t--){let n=Number(i[t]);n>=e&&(this._columnData[n+r]=this._columnData[n],delete this._columnData[n])}for(let r=e;r<=t;r++){let t=n==null?void 0:n[r-e];t!=null&&Object.keys(t).length>0&&(this._columnData[r]={...t})}}removeColumn(e){delete this._columnData[e]}getColumnOrCreate(e){let{_columnData:t}=this,n=t[e];if(n)return n;let r={};return this._columnData[e]=r,r}setCustomMetadata(e,t){let n=this.getColumn(e);n&&(n.custom=t)}getCustomMetadata(e){var t;return(t=this.getColumn(e))==null?void 0:t.custom}},lu=class{constructor(e,t,n){this._config=e,this._viewModel=t,C(this,`_rowData`,void 0),this._rowData=n}getRowData(){return this._rowData}getRowStyle(e){var t;return(t=this._rowData[e])==null?void 0:t.s}setRowStyle(e,t){let n=this.getRowOrCreate(e);n.s=t}getRowDatas(e,t){let n={},r=0;for(let i=e;i<e+t;i++){let e=this.getRow(i);n[r]=e==null?{h:this._config.defaultRowHeight,hd:A.FALSE}:e,r++}return n}getRowHeight(e,t=1){let{_rowData:n}=this,r=this._config,i=0;for(let a=0;a<t;a++){let{ia:t,ah:o,h:s=r.defaultRowHeight}=n[a+e]||{hd:A.FALSE,h:r.defaultRowHeight};i+=(t==null||t===A.TRUE)&&typeof o==`number`?o:s}return i}setRowHeight(e,t){let n=this._rowData[e];if(t===this._config.defaultRowHeight)n&&(delete n.h,Object.keys(n).length===0&&delete this._rowData[e]);else{let r=Math.min(t,2e3);this._rowData[e]=n?{...n,h:r}:{h:r}}}getRow(e){return this._rowData[e]}insertRowsWithData(e,t,n){let r=t-e+1,i=Object.keys(this._rowData);for(let t=i.length-1;t>=0;t--){let n=Number(i[t]);n>=e&&(this._rowData[n+r]=this._rowData[n],delete this._rowData[n])}for(let r=e;r<=t;r++){let t=n==null?void 0:n[r-e];t!=null&&Object.keys(t).length>0&&(this._rowData[r]={...t})}}removeRow(e){delete this._rowData[e]}getRowOrCreate(e){let{_rowData:t}=this,n=t[e];if(n)return n;let r={};return t[e]=r,r}getHiddenRows(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getRowRawVisible(a);r&&e?(r=!1,n.push({startRow:i,endRow:a-1,startColumn:0,endColumn:0,rangeType:B.ROW})):!r&&!e&&(r=!0,i=a)}return r&&n.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:B.ROW}),n}getVisibleRows(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getRowRawVisible(a);r&&!e?(r=!1,n.push({startRow:i,endRow:a-1,startColumn:0,endColumn:0,rangeType:B.ROW})):!r&&e&&(r=!0,i=a)}return r&&n.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:B.ROW}),n}getRowRawVisible(e){let t=this.getRow(e);return t?t.hd!==A.TRUE:!0}getSize(){return pa(this._rowData)}setCustomMetadata(e,t){let n=this.getRow(e);n&&(n.custom=t)}getCustomMetadata(e){var t;return(t=this.getRow(e))==null?void 0:t.custom}};const uu=`DEFAULT_WORKSHEET_ROW_COUNT`,du=1e3,fu=`DEFAULT_WORKSHEET_COLUMN_COUNT`,pu=20,mu=`DEFAULT_WORKSHEET_ROW_HEIGHT`,hu=24,gu=`DEFAULT_WORKSHEET_COLUMN_WIDTH`,_u=88,vu=`DEFAULT_WORKSHEET_ROW_TITLE_WIDTH`,yu=46,bu=`DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT`,xu=20;function Su(e){let t={name:`Sheet1`,id:`sheet-01`,tabColor:``,hidden:A.FALSE,rowCount:du,columnCount:20,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:88,defaultRowHeight:24,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:A.TRUE,rowHeader:{width:46,hidden:A.FALSE},columnHeader:{height:20,hidden:A.FALSE},rightToLeft:A.FALSE};return Object.keys(t).forEach(n=>{let r=n;e[r]===void 0&&(e[r]=t[r])}),e}var Cu=class extends E{constructor(e){super(),C(this,`_cellCache`,new Map),C(this,`_rowCache`,new Map),C(this,`_columnCache`,new Map),C(this,`_hasRow`,!1),C(this,`_hasColumn`,!1),C(this,`_hasAll`,!1),C(this,`_allIndex`,-1),C(this,`_mergeData`,void 0),C(this,`_rangeMap`,new so(5e4)),this._init(e.concat())}_init(e){this._mergeData=e,this._createCache(e)}_clearCache(){this._cellCache.clear(),this._rowCache.clear(),this._columnCache.clear(),this._hasAll=!1,this._allIndex=-1,this._rangeMap.clear(),this._hasColumn=!1,this._hasRow=!1}_createCache(e){let t=0;for(let n of e){let{rangeType:e}=n;e===B.ROW?this._createRowCache(n,t):e===B.COLUMN?this._createColumnCache(n,t):e===B.ALL?this._createCellAllCache(t):this._createCellCache(n,t),t++}}rebuild(e){this._clearCache(),this._init(e.concat())}_createRowCache(e,t){let{startRow:n,endRow:r}=e;for(let e=n;e<=r;e++)this._rowCache.set(e,t),this._hasRow=!0}_createColumnCache(e,t){let{startColumn:n,endColumn:r}=e;for(let e=n;e<=r;e++)this._columnCache.set(e,t),this._hasColumn=!0}_createCellAllCache(e){this._hasAll=!0,this._allIndex=e}_createCellCache(e,t){for(let n=e.startRow;n<=e.endRow;n++){let r=this._cellCache.get(n);r==null&&(r=new Map,this._cellCache.set(n,r));for(let n=e.startColumn;n<=e.endColumn;n++)r.set(n,t)}}add(e){this._mergeData.push(e),this._clearCache(),this._createCache(this._mergeData)}remove(e,t){let n=this._getMergeDataIndex(e,t);n!==-1&&(this._mergeData.splice(n,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(e,t){let n=this._getMergeDataIndex(e,t);return n===-1?null:this._mergeData[n]}getMergeDataIndex(e,t){return this._getMergeDataIndex(e,t)}isRowContainsMergedCell(e){return this._hasAll||!D.isEmptyObject(this._columnCache)?!0:this._mergeData.some(t=>t.startRow<=e&&e<=t.endRow)}isColumnContainsMergedCell(e){return this._hasAll||!D.isEmptyObject(this._rowCache)?!0:this._mergeData.some(t=>t.startColumn<=e&&e<=t.endColumn)}getMergedCellRange(e,t,n,r){let i=[],a=`${e}-${t}-${n}-${r}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let o=0,s=[];for(let a of this._mergeData||[])G.intersects(a,{startRow:e,endRow:n,startColumn:t,endColumn:r})&&(i.push({...a}),s.push(o)),o++;return this._rangeMap.set(a,s),i}_getRangeFromCache(e){let t=this._rangeMap.get(e)||[],n=[];for(let e of t)n.push({...this._mergeData[e]});return n}_getMergeDataIndex(e,t){var n;if(this._hasAll)return this._allIndex;if(this._hasRow){let t=this._rowCache.get(e);if(t!==void 0)return t}if(this._hasColumn){let e=this._columnCache.get(t);if(e!==void 0)return e}let r=(n=this._cellCache.get(e))==null?void 0:n.get(t);return r===void 0?-1:r}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}},wu=class extends E{constructor(e){super(),this.getRawCell=e,C(this,`_cellContentInterceptor`,null),C(this,`_rowFilteredInterceptor`,null)}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(e,t,n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,At.Value|At.Style,n,r):this.getRawCell(e,t)}getCellValueOnly(e,t){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,At.Value):this.getRawCell(e,t)}getCellStyleOnly(e,t){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,At.Style):this.getRawCell(e,t)}getRowFiltered(e){var t,n;return(t=(n=this._rowFilteredInterceptor)==null?void 0:n.getRowFiltered(e))==null?!1:t}registerCellContentInterceptor(e){if(this._cellContentInterceptor)throw Error(`[SheetViewModel]: Interceptor already registered.`);return this._cellContentInterceptor=e,T(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(e){if(this._rowFilteredInterceptor)throw Error(`[SheetViewModel]: Interceptor already registered.`);return this._rowFilteredInterceptor=e,T(()=>this._rowFilteredInterceptor=null)}};const Tu={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};var Eu=class e{constructor(e,t,n){var r;this.unitId=e,this._styles=n,C(this,`_sheetId`,void 0),C(this,`_snapshot`,void 0),C(this,`_cellData`,void 0),C(this,`_rowManager`,void 0),C(this,`_columnManager`,void 0),C(this,`_viewModel`,void 0),C(this,`_spanModel`,void 0),C(this,`_isRowStylePrecedeColumnStyle`,!0),C(this,`_getCellHeight`,void 0),this._snapshot=Su(t);let{columnData:i,rowData:a,cellData:o}=this._snapshot;this._sheetId=(r=this._snapshot.id)==null?O(6):r,this._cellData=new Sa(o),this._viewModel=new wu((e,t)=>this.getCellRaw(e,t)),this._rowManager=new lu(this._snapshot,this._viewModel,a),this._columnManager=new cu(this._snapshot,i),this._spanModel=new Cu(this._snapshot.mergeData)}__interceptViewModel(e){e(this._viewModel)}__registerGetCellHeight(e){return this._getCellHeight=e,T(()=>{this._getCellHeight=null})}getSnapshot(){return this._snapshot}getCellHeight(e,t){return this._getCellHeight?this._getCellHeight(e,t):this._snapshot.defaultRowHeight}setMergeData(e){this._snapshot.mergeData=e,this.getSpanModel().rebuild(e)}getSpanModel(){return this._spanModel}setIsRowStylePrecedeColumnStyle(e){this._isRowStylePrecedeColumnStyle=e}getStyleDataByHash(e){return{...this._styles.get(e)}}setStyleData(e){return this._styles.setValue(e)}getColumnStyle(e,t=!1){return t?this._columnManager.getColumnStyle(e):this._styles.get(this._columnManager.getColumnStyle(e))}setColumnStyle(e,t){this._columnManager.setColumnStyle(e,t)}getRowStyle(e,t=!1){return t?this._rowManager.getRowStyle(e):this._styles.get(this._rowManager.getRowStyle(e))}setRowStyle(e,t){this._rowManager.setRowStyle(e,t)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){let e=this._snapshot.defaultStyle;return this._styles.get(e)}setDefaultCellStyle(e){this._snapshot.defaultStyle=e}getCellStyle(e,t){let n=this.getCell(e,t);if(n){let e=n.s;return typeof e==`string`?this._styles.get(e):e}return null}getComposedCellStyle(e,t,n){let r=this.getDefaultCellStyleInternal(),i=this.getRowStyle(e),a=this.getColumnStyle(t),o=this.getCell(e,t),s=this._styles.getStyleByCell(o);return(n==null?this._isRowStylePrecedeColumnStyle:n)?wn(r,a,i,o==null?void 0:o.themeStyle,s):wn(r,i,a,o==null?void 0:o.themeStyle,s)}getComposedCellStyleByCellData(e,t,n,r){let i=this.getDefaultCellStyleInternal(),a=this.getRowStyle(e),o=this.getColumnStyle(t),s=this._styles.getStyleByCell(n);return(r==null?this._isRowStylePrecedeColumnStyle:r)?wn(i,o,a,n==null?void 0:n.themeStyle,s):wn(i,a,o,n==null?void 0:n.themeStyle,s)}getComposedCellStyleWithoutSelf(e,t,n,r){let i=n===void 0?this.getComposedCellStyle(e,t,r):this.getComposedCellStyleByCellData(e,t,n,r),a=this.getCellRaw(e,t);if(!a||!a.s)return i;let o=typeof a.s==`string`?this._styles.get(a.s):a.s;if(!o)return i;for(let e in o)e in i&&delete i[e];return i}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){let e=this.getCellMatrix(),t=this.getMergeData(),n=-1,r=-1,i=-1,a=-1,o=!1,s=!1;return e.forEach((t,c)=>{Object.keys(c).forEach(c=>{let l=+c,u=e.getValue(t,l),d=u!=null&&u.s?this._styles.get(u.s):null,f=(d==null?void 0:d.bd)&&(d.bd.b||d.bd.l||d.bd.r||d.bd.t||d.bd.bc_tr||d.bd.bl_tr||d.bd.ml_tr||d.bd.tl_bc||d.bd.tl_br||d.bd.tl_mr);(u&&(u.v!==null&&u.v!==void 0&&u.v!==``||u.p)||d!=null&&d.bg||f)&&(o?n=Math.min(n,t):(n=t,o=!0),r=Math.max(r,t),s?i=Math.min(i,l):(s=!0,i=l),a=Math.max(a,l))})}),t.forEach(e=>{o?n=Math.min(n,e.startRow):(n=e.startRow,o=!0),r=Math.max(r,e.endRow),s?i=Math.min(i,e.startColumn):(i=e.startColumn,o=!0),a=Math.max(a,e.endColumn)}),!o||!s?null:{startColumn:i,startRow:n,endColumn:a,endRow:r}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){let{_snapshot:t}=this,n=su(t);return new e(this.unitId,n,this._styles)}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(e,t){return this._spanModel.getMergedCell(e,t)}getMergedCellRange(e,t,n,r){return this._spanModel.getMergedCellRange(e,t,n,r)}isRowContainsMergedCell(e){return this._spanModel.isRowContainsMergedCell(e)}isColumnContainsMergedCell(e){return this._spanModel.isColumnContainsMergedCell(e)}getCellInfoInMergeData(e,t){let n=this.getMergedCell(e,t),r=!1,i=!1,a=e,o=t,s=e,c=t;if(n){let{startRow:l,endRow:u,startColumn:d,endColumn:f}=n;e===l&&t===d?(a=u,o=f,s=l,c=d,i=!0):e>=l&&e<=u&&t>=d&&t<=f&&(a=u,o=f,s=l,c=d,r=!0)}return{actualRow:e,actualColumn:t,isMergedMainCell:i,isMerged:r,endRow:a,endColumn:o,startRow:s,startColumn:c}}getCell(e,t){return e<0||t<0?null:this._viewModel.getCell(e,t)}getCellValueOnly(e,t){return e<0||t<0?null:this._viewModel.getCellValueOnly(e,t)}getCellStyleOnly(e,t){return e<0||t<0?null:this._viewModel.getCellStyleOnly(e,t)}getCellRaw(e,t){return this.getCellMatrix().getValue(e,t)}getCellWithFilteredInterceptors(e,t,n,r){return this._viewModel.getCell(e,t,n,r)}getRowFiltered(e){return this._viewModel.getRowFiltered(e)}getRangeFilterRows(e){let t=[];for(let n=e.startRow;n<=e.endRow;n++)this.getRowFiltered(n)&&t.push(n);return t}getMatrixWithMergedCells(e,t,n,r,i=ea.Raw){let a=this.getCellMatrix(),o=this._spanModel.getMergedCellRange(e,t,n,r),s=new Sa;return Uo(e,n,t,r).forEach((e,t)=>{let n;if(i===ea.Raw)n=this.getCellRaw(e,t);else if(i===ea.Intercepted)n=this.getCell(e,t);else if(i===ea.Both){let i=this.getCellRaw(e,t);if(i){var r;n={...i};let a=(r=this.getCell(e,t))==null?void 0:r.v;Zl(a)&&n&&(n.displayV=String(a))}}n&&s.setValue(e,t,n)}),o.forEach(e=>{let{startColumn:t,startRow:n,endColumn:r,endRow:i}=e;Uo(n,i,t,r).forEach((e,o)=>{e===n&&o===t&&s.setValue(e,o,{...a.getValue(e,o),rowSpan:i-n+1,colSpan:r-t+1}),(e!==n||o!==t)&&s.realDeleteValue(e,o)})}),s}getRange(e,t,n,r){return typeof e==`object`?new Eo(this,e,{getStyles:()=>this._styles}):new Eo(this,{startRow:e,startColumn:t,endColumn:r||t,endRow:n||e},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){let{_snapshot:e}=this,{columnCount:t}=e;return t}getMaxRows(){let{_snapshot:e}=this,{rowCount:t}=e;return t}getRowCount(){return this._snapshot.rowCount}setRowCount(e){this._snapshot.rowCount=e}getColumnCount(){return this._snapshot.columnCount}setColumnCount(e){this._snapshot.columnCount=e}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){let{_snapshot:e}=this,{showGridlines:t}=e;return t===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){let{_snapshot:e}=this,{tabColor:t}=e;return t}getColumnWidth(e){return this.getColumnManager().getColumnWidth(e)}getRowHeight(e){return this._viewModel.getRowFiltered(e)?0:this.getRowManager().getRowHeight(e)}isRowFiltered(e){return this._viewModel.getRowFiltered(e)}getRowVisible(e){return!this.isRowFiltered(e)&&this.getRowRawVisible(e)}getRowRawVisible(e){return this.getRowManager().getRowRawVisible(e)}getHiddenRows(e,t){let n=this.getMaxColumns()-1,r=this._rowManager.getHiddenRows(e,t);return r.forEach(e=>e.endColumn=n),r}getColVisible(e){return this._columnManager.getColVisible(e)}getHiddenCols(e,t){let n=this.getMaxRows()-1,r=this._columnManager.getHiddenCols(e,t);return r.forEach(e=>e.endRow=n),r}getVisibleRows(){let e=this.getRowCount();return this._rowManager.getVisibleRows(0,e-1)}getVisibleCols(){let e=this.getColumnCount();return this._columnManager.getVisibleCols(0,e-1)}isRightToLeft(){let{_snapshot:e}=this,{rightToLeft:t}=e;return t}getLastRowWithContent(){return this._cellData.getRealRowRange().endRow}getLastColumnWithContent(){return this.getDataRealRange().endColumn}getDataRealRange(){return this._cellData.getRealRange()}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(e){return e&&(e.v!==void 0||e.f!==void 0||e.p!==void 0)}iterateByRow(e,t=!0){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e,o=this;return{[Symbol.iterator]:()=>{let e=n,s=r;return{next(){for(;;){if(s>a&&(e+=1,s=r),e>i)return{done:!0,value:void 0};let n=o.getCell(e,s),c=!n,l=o.getMergedCell(e,s);if(l){if(e!==l.startRow||s!==l.startColumn){s=l.endColumn+1;continue}if(c&&t){s=l.endColumn+1;continue}let r={row:e,col:s,value:n};return r.colSpan=l.endColumn-l.startColumn+1,r.rowSpan=l.endRow-l.startRow+1,s=l.endColumn+1,{done:!1,value:r}}if(c&&t)s+=1;else{let t={row:e,col:s,value:n};return s+=1,{done:!1,value:t}}}}}}}}iterateByColumn(e,t=!0,n=!0){let{startRow:r,startColumn:i,endRow:a,endColumn:o}=e,s=this;return{[Symbol.iterator]:()=>{let e=r,c=i;return{next(){for(;;){if(e>a&&(c+=1,e=r),c>o)return{done:!0,value:void 0};let i=s.getMergedCell(e,c);if(i){let r=e!==i.startRow,a=r||c!==i.startColumn;if(n&&a||!n&&r){e=i.endRow+1;continue}let o=s.getCell(i.startRow,i.startColumn);if(!o&&t){e=i.endRow+1;continue}let l={row:e,col:i.startColumn,value:o};return l.colSpan=i.endColumn-i.startColumn+1,l.rowSpan=i.endRow-i.startRow+1,e=i.endRow+1,{done:!1,value:l}}let l=s.getCell(e,c);if(!l&&t)e+=1;else{let t={row:e,col:c,value:l};return e+=1,{done:!1,value:t}}}}}}}}getCellDocumentModel(e,t,n=Tu){var r;if(!e)return;let{isDeepClone:i,displayRawFormula:a,ignoreTextRotation:o}={...Tu,...n},s,c=`document`,l=Jl(t),u=o?W.tr:l.textRotation||W.tr,d=l.horizontalAlign||W.ht,f=l.verticalAlign||W.vt,p=l.wrapStrategy||W.tb,m=l.paddingData||Gl;if(e.f&&a)s=ql(e.f.toString(),{},{verticalAlign:f}),d=W.ht;else if(e.p){let{centerAngle:t,vertexAngle:n}=tu(u);s=this._updateConfigAndGetDocumentModel(i?D.deepClone(e.p):e.p,d,m,{horizontalAlign:d,verticalAlign:f,centerAngle:t,vertexAngle:n,wrapStrategy:p,zeroWidthParagraphBreak:1})}else if(e.v!=null){let n=Yl(t);c=$l(n).fontCache;let r=Du(e);e.t===tr.FORCE_STRING&&a&&(r=`'${r}`),s=ql(r,n,{...l,textRotation:u,cellValueType:e.t})}return s&&e.linkUrl&&e.linkId&&Xl(s,e.linkUrl,e.linkId),{documentModel:s,fontString:c,textRotation:u,wrapStrategy:p,verticalAlign:f,horizontalAlign:d,paddingData:m,fill:t==null||(r=t.bg)==null?void 0:r.rgb}}_updateConfigAndGetDocumentModel(e,t,n,r){var i,a,o,s,c;if(!r||!((i=e.body)!=null&&i.dataStream))return;e.documentStyle||(e.documentStyle={}),e.documentStyle.marginTop=(a=n.t)==null?0:a,e.documentStyle.marginBottom=(o=n.b)==null?2:o,e.documentStyle.marginLeft=(s=n.l)==null?2:s,e.documentStyle.marginRight=(c=n.r)==null?2:c,e.documentStyle.pageSize={width:1/0,height:1/0},e.documentStyle.renderConfig={...e.documentStyle.renderConfig,...r};let l=e.body.paragraphs||[];for(let e of l)e.paragraphStyle||(e.paragraphStyle={}),e.paragraphStyle.horizontalAlign=t;return new _c(e)}getBlankCellDocumentModel(e,t,n){let r=this.getComposedCellStyleByCellData(t,n,e),i=Yl(r),a=this.getCellDocumentModel(e,r,{ignoreTextRotation:!0});if(a!=null)return a.documentModel==null&&(a.documentModel=ql(``,i)),a;let o=`document`,s=W.tr,c=W.ht,l=W.vt,u=W.tb,d=Gl;return o=$l({}).fontCache,{documentModel:ql(``,i),fontString:o,textRotation:s,wrapStrategy:u,verticalAlign:l,horizontalAlign:c,paddingData:d}}getCellDocumentModelWithFormula(e,t,n){let r=this.getComposedCellStyleByCellData(t,n,e);return this.getCellDocumentModel(e,r,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(e){this._snapshot.custom=e}};function Du(e){var t;if(!e)return``;let n=(t=e.p)==null||(t=t.body)==null?void 0:t.dataStream;if(n)return Z.transform.getPlainText(n);let r=e.v;return typeof r==`string`?e.t===tr.BOOLEAN?r.toUpperCase():r.replace(/[\r\n]/g,``):typeof r==`number`?e.t===tr.BOOLEAN?r?`TRUE`:`FALSE`:r.toString():typeof r==`boolean`?r?`TRUE`:`FALSE`:``}function Ou(e){if(e===null)return``;if(e!=null&&e.p){let t=e==null?void 0:e.p.body;if(t==null)return``;let n=t.dataStream;return Z.transform.getPlainText(n)}return e==null?void 0:e.v}function ku(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}let Au=class extends pn{get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(e){return typeof e==`string`||`startRow`in e||`row`in e}constructor(e={},t){super(),this._logService=t,C(this,`type`,x.UNIVER_SHEET),C(this,`_sheetCreated$`,new y),C(this,`sheetCreated$`,this._sheetCreated$.asObservable()),C(this,`_sheetDisposed$`,new y),C(this,`sheetDisposed$`,this._sheetDisposed$.asObservable()),C(this,`_activeSheet$`,new v(null)),C(this,`activeSheet$`,this._activeSheet$.asObservable()),C(this,`_worksheets`,void 0),C(this,`_styles`,void 0),C(this,`_snapshot`,void 0),C(this,`_unitId`,void 0),C(this,`_count`,void 0),C(this,`_name$`,void 0),C(this,`name$`,void 0);let n=Vl();D.isEmptyObject(e)?this._snapshot=n:this._snapshot=D.commonExtend(n,e);let{styles:r}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=O(6)),this._unitId=this._snapshot.id,this._styles=new Hl(r),this._count=1,this._worksheets=new Map,this._name$=new v(e.name||``),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete(),Array.from(this._worksheets.keys()).forEach(e=>{this._removeSheet(e)})}save(){return D.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(e){this._name$.next(e),this._snapshot.name=e}getUnitId(){return this._unitId}getRev(){var e;return(e=this._snapshot.rev)==null?1:e}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(e){this._snapshot.rev=e}addWorksheet(e,t,n){let{sheets:r,sheetOrder:i}=this._snapshot;if(r[e])return!1;r[e]=n,i.splice(t,0,e),this.ensureSheetOrderUnique();let a=new Eu(this._unitId,n,this._styles);return this._worksheets.set(e,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}ensureSheetOrderUnique(){let e=new Set,t=[];for(let n of this._snapshot.sheetOrder)e.has(n)||(e.add(n),t.push(n));this._snapshot.sheetOrder=t,e.clear()}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}addStyles(e){Object.entries(e).forEach(([e,t])=>{this._styles.addCustomStyle(e,t)})}removeStyles(e){e.forEach(e=>{this._styles.remove(e)})}getConfig(){return this._snapshot}getIndexBySheetId(e){let{sheetOrder:t}=this._snapshot;return t.findIndex(t=>t===e)}getActiveSheet(e){if(!this._activeSheet&&e===void 0)throw Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){let e=this._activeSheet;if(e)return e;let t=this._snapshot.sheetOrder;for(let e=0,n=t.length;e<n;e++){let n=this._worksheets.get(t[e]);if(n&&n.isSheetHidden()!==A.TRUE)return this.setActiveSheet(n),n}let n=this._worksheets.get(t[0]);return this.setActiveSheet(n),n}setActiveSheet(e){this._activeSheet$.next(e)}_removeSheet(e){let t=this._worksheets.get(e);return t?(this._worksheets.delete(e),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(e),1),this.ensureSheetOrderUnique(),this._sheetDisposed$.next(t),!0):!1}removeSheet(e){let t=this._removeSheet(e);return t&&delete this._snapshot.sheets[e],t}getActiveSheetIndex(){let{sheetOrder:e}=this._snapshot;return e.findIndex(e=>this._worksheets.get(e)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){let{sheetOrder:e}=this._snapshot;return e.map(e=>this._worksheets.get(e))}getSheetsName(){let{sheetOrder:e}=this._snapshot,t=[];return e.forEach(e=>{let n=this._worksheets.get(e);n&&t.push(n.getName())}),t}getSheetIndex(e){let{sheetOrder:t}=this._snapshot;return t.findIndex(t=>e.getSheetId()===t)}getSheetBySheetName(e){let{sheetOrder:t}=this._snapshot,n=t.find(t=>this._worksheets.get(t).getName()===e);return this._worksheets.get(n)}getSheetBySheetId(e){return this._worksheets.get(e)}getSheetByIndex(e){let{sheetOrder:t}=this._snapshot;return this._worksheets.get(t[e])}getHiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden===A.TRUE).map(e=>e.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden!==A.TRUE).map(e=>e.getConfig().id)}load(e){this._snapshot=e}checkSheetName(e){return this.getSheetsName().some(t=>t.toLowerCase()===e.toLowerCase())}uniqueSheetName(e=`Sheet1`){let t=e;for(;this.checkSheetName(t);)t=e+this._count,this._count++;return t}generateNewSheetName(e){let t=e+this._count;for(;this.checkSheetName(t);)t=e+this._count,this._count++;return t}_parseWorksheetSnapshots(){let{_snapshot:e,_worksheets:t}=this,{sheets:n,sheetOrder:r}=e;if(D.isEmptyObject(n)){let e=O();n[e]={id:e}}for(let e in n){let i=n[e],{name:a}=i;i.name=this.uniqueSheetName(a),i.name!==a&&this._logService.debug(`[Workbook]`,`The worksheet name ${a} is duplicated, we changed it to ${i.name}. Please fix the problem in your snapshot.`);let o=new Eu(this._unitId,i,this._styles);t.set(e,o),r.includes(e)||r.push(e)}this.ensureSheetOrderUnique(),this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(e){this._snapshot.custom=e}};Au=z([R(1,L)],Au);var ju=class extends pn{get _activePage(){let e=this._activePage$.getValue();if(!e){var t,n;let e=(t=this.getPageOrder())==null?void 0:t[0];return e?(n=this.getPages())==null?void 0:n[e]:null}return e}constructor(e){var t;super(),C(this,`type`,x.UNIVER_SLIDE),C(this,`_activePage$`,new v(null)),C(this,`activePage$`,this._activePage$.asObservable()),C(this,`_name$`,void 0),C(this,`name$`,void 0),C(this,`_snapshot`,void 0),C(this,`_unitId`,void 0),this._snapshot={..._o,...e},this._unitId=(t=this._snapshot.id)==null?O(6):t,this._name$=new v(this._snapshot.title),this.name$=this._name$.asObservable()}setName(e){var t;this._snapshot.title=e,this._name$.next(e),this._unitId=(t=this._snapshot.id)==null?O(6):t}getRev(){return 0}incrementRev(){}setRev(e){}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var e;return(e=this._snapshot.body)==null?void 0:e.pages}getPageOrder(){var e;return(e=this._snapshot.body)==null?void 0:e.pageOrder}getPage(e){let t=this.getPages();return t==null?void 0:t[e]}getElementsByPage(e){var t;return(t=this.getPage(e))==null?void 0:t.pageElements}getElement(e,t){var n;return(n=this.getElementsByPage(e))==null?void 0:n[t]}getPageSize(){return this._snapshot.pageSize}getBlankPage(){let e=O(6);return{id:e,pageType:Lr.SLIDE,zIndex:10,title:e,description:``,pageBackgroundFill:{rgb:`rgb(255,255,255)`},pageElements:{}}}setActivePage(e){this._activePage$.next(e)}getActivePage(){return this._activePage}updatePage(e,t){this._snapshot.body&&(this._snapshot.body.pages[e]=t)}appendPage(e){var t;if(!this._snapshot.body)return;this._snapshot.body.pages[e.id]=e;let n=this._activePage,r=this._snapshot.body.pageOrder.indexOf((t=n==null?void 0:n.id)==null?``:t);this._snapshot.body.pageOrder.splice(r+1,0,e.id)}};const Mu=m(`univer.current`);let Nu=class extends E{constructor(e,t,n){super(),this._injector=e,this._contextService=t,this._logService=n,C(this,`_unitsByType`,new Map),C(this,`_createHandler`,void 0),C(this,`_ctorByType`,new Map),C(this,`_currentUnits`,new Map),C(this,`_currentUnits$`,new v(this._currentUnits)),C(this,`currentUnits$`,this._currentUnits$.asObservable()),C(this,`_unitAdded$`,new y),C(this,`unitAdded$`,this._unitAdded$.asObservable()),C(this,`_unitDisposed$`,new y),C(this,`unitDisposed$`,this._unitDisposed$.asObservable()),C(this,`_focused$`,new v(null)),C(this,`focused$`,this._focused$.asObservable())}dispose(){super.dispose(),this._focused$.complete(),this._currentUnits$.complete(),this._unitAdded$.complete(),this._currentUnits.forEach(e=>e==null?void 0:e.dispose()),this._currentUnits.clear(),this._unitsByType.clear()}__setCreateHandler(e){this._createHandler=e}createUnit(e,t,n){return this._createHandler(e,t,this._ctorByType.get(e),n)}registerCtorForType(e,t){return this._ctorByType.set(e,t),{dispose:()=>{this._ctorByType.delete(e)}}}getCurrentTypeOfUnit$(e){return this.currentUnits$.pipe(be(t=>{var n;return(n=t.get(e))==null?null:n}),_e())}getCurrentUnitForType(e){return this._currentUnits.get(e)}getCurrentUnitOfType(e){return this.getCurrentUnitForType(e)}setCurrentUnitForType(e){let t=this._getUnitById(e);if(!t)throw Error(`[UniverInstanceService]: no document with unitId ${e}!`);this._currentUnits.set(t[1],t[0]),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(e){return this._unitAdded$.pipe(ve(t=>t.type===e))}__addUnit(e,t){var n;this._logService.debug(`[UniverInstanceService]: Adding unit with id ${e.getUnitId()}`);let r=e.type;this._unitsByType.has(r)||this._unitsByType.set(r,[]);let i=this._unitsByType.get(r),a=e.getUnitId();if(i.findIndex(e=>e.getUnitId()===a)!==-1)throw Error(`[UniverInstanceService]: cannot create a unit with the same unit id: ${a}.`);i.push(e),this._unitAdded$.next(e),((n=t==null?void 0:t.makeCurrent)==null||n)&&this.setCurrentUnitForType(e.getUnitId())}getTypeOfUnitDisposed$(e){return this.unitDisposed$.pipe(ve(t=>t.type===e))}getUnit(e,t){var n;let r=(n=this._getUnitById(e))==null?void 0:n[0];return t&&(r==null?void 0:r.type)!==t?null:r}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(x.UNIVER_DOC)}getUniverDocInstance(e){return this.getUnit(e,x.UNIVER_DOC)}getUniverSheetInstance(e){return this.getUnit(e,x.UNIVER_SHEET)}getAllUnitsForType(e){var t;return(t=this._unitsByType.get(e))==null?[]:t}changeDoc(e,t){let n=this.getAllUnitsForType(x.UNIVER_DOC),r=n.find(t=>t.getUnitId()===e);if(r!=null){let e=n.indexOf(r);n.splice(e,1)}this.__addUnit(t)}get focused(){var e;let t=this._focused$.getValue();return t?(e=this._getUnitById(t))==null?void 0:e[0]:null}focusUnit(e){this._focused$.next(e),this.focused instanceof Au?(this._contextService.setContextValue(vl,!0),this._contextService.setContextValue(bl,!1),this._contextService.setContextValue(yl,!0),this._contextService.setContextValue(xl,!1),this.setCurrentUnitForType(e)):this.focused instanceof _c?(this._contextService.setContextValue(vl,!0),this._contextService.setContextValue(bl,!0),this._contextService.setContextValue(yl,!1),this._contextService.setContextValue(xl,!1),this.setCurrentUnitForType(e)):this.focused instanceof ju?(this._contextService.setContextValue(vl,!0),this._contextService.setContextValue(bl,!1),this._contextService.setContextValue(yl,!1),this._contextService.setContextValue(xl,!0),this.setCurrentUnitForType(e)):(this._contextService.setContextValue(vl,!1),this._contextService.setContextValue(bl,!1),this._contextService.setContextValue(yl,!1),this._contextService.setContextValue(xl,!1))}getFocusedUnit(){return this.focused}getUnitType(e){let t=this._getUnitById(e);return t?t[1]:x.UNRECOGNIZED}disposeUnit(e){this._logService.debug(`[UniverInstanceService]: Disposing unit with id ${e}`);let t=this._getUnitById(e);if(!t)return this._logService.debug(`[UniverInstanceService]: No unit found with id ${e}`),!1;let[n,r]=t,i=this._unitsByType.get(r),a=i.indexOf(n);return i.splice(a,1),this._tryResetCurrentOnRemoval(e,r),this._tryResetFocusOnRemoval(e),this._unitDisposed$.next(n),n.dispose(),!0}_tryResetCurrentOnRemoval(e,t){let n=this.getCurrentUnitForType(t);(n==null?void 0:n.getUnitId())===e&&(this._currentUnits.set(t,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(e){var t;((t=this.focused)==null?void 0:t.getUnitId())===e&&this._focused$.next(null)}_getUnitById(e){for(let[t,n]of this._unitsByType){let r=n.find(t=>t.getUnitId()===e);if(r)return[r,t]}}};Nu=z([R(0,t(i)),R(1,Zr),R(2,t(L))],Nu);let $=function(e){return e[e.Starting=0]=`Starting`,e[e.Ready=1]=`Ready`,e[e.Rendered=2]=`Rendered`,e[e.Steady=3]=`Steady`,e}({});const Pu={[$.Starting]:`Starting`,[$.Ready]:`Ready`,[$.Rendered]:`Rendered`,[$.Steady]:`Steady`};var Fu=class extends Error{constructor(e){super(`[LifecycleService]: lifecycle stage "${Pu[e]}" will never be reached!`),this.name=`LifecycleUnreachableError`}};let Iu=class extends E{constructor(e){super(),this._logService=e,C(this,`_lifecycle$`,new v($.Starting)),C(this,`lifecycle$`,this._lifecycle$.asObservable()),C(this,`_lock`,!1),this._reportProgress($.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(e){if(this._lock)throw Error(`[LifecycleService]: cannot set new stage when related logic is all handled!`);if(e<this.stage)throw Error(`[LifecycleService]: lifecycle stage cannot go backward!`);e!==this.stage&&(this._lock=!0,this._reportProgress(e),this._lifecycle$.next(e),this._lock=!1)}dispose(){this._lifecycle$.complete(),super.dispose()}onStage(e){return ye(this.lifecycle$.pipe(ve(t=>t>=e),fi(t=>t===e),be(()=>void 0))).catch(t=>t.name===`EmptyError`?Promise.reject(new Fu(e)):Promise.reject(t))}subscribeWithPrevious(){return xe(Lu(this.stage),this._lifecycle$.pipe(Ce(1))).pipe(fi(e=>e===$.Steady))}_reportProgress(e){this._logService.debug(`[LifecycleService]`,`lifecycle progressed to "${Pu[e]}".`)}};Iu=z([R(0,L)],Iu);function Lu(e){switch(e){case $.Starting:return Se($.Starting);case $.Ready:return Se($.Starting,$.Ready);case $.Rendered:return Se($.Starting,$.Ready,$.Rendered);default:return Se($.Starting,$.Ready,$.Rendered,$.Steady)}}const Ru=m(`ILocalStorageService`);var zu=class extends E{get _currentLocale(){return this._currentLocale$.value}constructor(){super(),C(this,`_currentLocale$`,new v(Rn.ZH_CN)),C(this,`currentLocale$`,this._currentLocale$.asObservable()),C(this,`_locales`,null),C(this,`localeChanged$`,new y),C(this,`t`,(e,...t)=>{if(!this._locales)throw Error(`[LocaleService]: Locale not initialized`);let n=e.split(`.`),r=this.resolveKeyPath(this._locales[this._currentLocale],n);if(typeof r==`string`){let e=r;return t.forEach((t,n)=>{e=e.replace(`{${n}}`,t)}),e}else return e}),this.disposeWithMe(T(()=>{this._locales=null,this._currentLocale$.complete(),this.localeChanged$.complete()}))}load(e){var t;this._locales=le((t=this._locales)==null?{}:t,e)}setLocale(e){this._currentLocale$.next(e),this.localeChanged$.next()}getLocales(){var e;return(e=this._locales)==null?void 0:e[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(e,t){let n=t.shift();if(n&&e&&n in e){let r=e[n];return t.length>0&&(typeof r==`object`||Array.isArray(r))?this.resolveKeyPath(r,t):r}return null}};let Bu=class{constructor(e){this._userManagerService=e}async list(e){return{list:[{type:zn.PERSON,mentions:[{objectType:zn.PERSON,objectId:this._userManagerService.getCurrentUser().userID,label:this._userManagerService.getCurrentUser().name,metadata:{icon:this._userManagerService.getCurrentUser().avatar}}],metadata:{},title:`PEOPLE`}],page:e.page,size:e.size,total:1}}};Bu=z([R(0,n(pl))],Bu);const Vu=h(`univer.service.mention-io`);let Hu=function(e){return e.INIT=`init`,e.FETCHING=`fetching`,e.DONE=`done`,e}({});const Uu=m(`univer.permission-service`);var Wu=class extends E{constructor(...e){super(...e),C(this,`_permissionPointMap`,new Map),C(this,`_permissionPointUpdate$`,new y),C(this,`permissionPointUpdate$`,this._permissionPointUpdate$.asObservable()),C(this,`_showComponents`,!0)}setShowComponents(e){this._showComponents=e}getShowComponents(){return this._showComponents}deletePermissionPoint(e){let t=this._permissionPointMap.get(e);t&&(t.complete(),this._permissionPointMap.delete(e))}addPermissionPoint(e){let t=e instanceof v,n=t?e.getValue():e;return n.id?this._permissionPointMap.get(n.id)?(console.warn(`${n.id} PermissionPoint already exists`),!1):(this._permissionPointMap.set(n.id,t?e:new v(n)),this._permissionPointUpdate$.next(n),!0):!1}updatePermissionPoint(e,t){let n=this._permissionPointMap.get(e);if(!n)return;let r=n.getValue();r.value=t,r.status=Hu.DONE,n.next(r),this._permissionPointUpdate$.next(r)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(e){let t=this._permissionPointMap.get(e);if(t)return t.getValue()}getPermissionPoint$(e){let t=this._permissionPointMap.get(e);if(t)return t}composePermission$(e){return he(e.map(e=>{var t;let n=(t=this._permissionPointMap)==null?void 0:t.get(e);if(!n)throw Error(`[PermissionService]: ${e} permissionPoint does not exist!`);return n.asObservable()})).pipe(Pe(e=>e))}composePermission(e){return e.map(e=>{var t;let n=(t=this._permissionPointMap)==null?void 0:t.get(e);if(!n)throw Error(`[PermissionService]: ${e} permissionPoint does not exist!`);return n.getValue()})}getAllPermissionPoint(){let e=new Map;return this._permissionPointMap.forEach((t,n)=>{e.set(n,t)}),e}};function Gu(e,t){if(!t)return e;let n=[];for(let r of e){let e=t.find(([e])=>e===r[0]);if(e){if(e[1]===null)continue;n.push([r[0],e[1]])}else n.push(r)}return n}const Ku=Symbol(`DependentOn`);var qu=class extends E{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}};C(qu,`pluginName`,void 0),C(qu,`packageName`,zl),C(qu,`version`,Bl),C(qu,`type`,x.UNIVER_UNKNOWN);var Ju=class{constructor(){C(this,`_plugins`,[])}addPlugin(e){this._plugins.push(e)}removePlugins(){let e=this._plugins.slice();return this._plugins.length=0,e}forEachPlugin(e){this._plugins.forEach(e)}};function Yu(...e){return function(t){t[Ku]=e}}let Xu=class{constructor(e,t,n){this._injector=e,this._lifecycleService=t,this._logService=n,C(this,`_pluginRegistry`,new Map),C(this,`_pluginStore`,new Ju),C(this,`_seenPlugins`,new Set),C(this,`_loadedPlugins`,new Set),C(this,`_loadedPluginTypes`,new Set([x.UNIVER_UNKNOWN])),C(this,`_flushTimerByType`,new Map)}dispose(){this._pluginStore.removePlugins().forEach(e=>e.dispose()),this._flushTimerByType.forEach(e=>clearTimeout(e))}registerPlugin(e,t){this._assertPluginValid(e);let n={plugin:e,options:t};this._pluginRegistry.set(e.pluginName,n),this._logService.debug(`[PluginService]`,`Plugin "${e.pluginName}" registered.`);let{type:r}=e;this._loadedPluginTypes.has(r)&&(r===x.UNIVER_UNKNOWN?this._loadFromPlugins([n]):this._flushType(r))}startPluginsForType(e){this._loadedPluginTypes.has(e)||this._loadPluginsForType(e)}_loadPluginsForType(e){let t=Array.from(this._pluginRegistry.keys()),n=[];t.forEach(t=>{let r=this._pluginRegistry.get(t);r.plugin.type===e&&n.push(r)}),this._loadFromPlugins(n),this._loadedPluginTypes.add(e)}_assertPluginValid(e){let{type:t,pluginName:n,packageName:r,version:i}=e;if(t===x.UNRECOGNIZED)throw Error(`[PluginService]: invalid plugin type for ${e.name}. Please assign a "type" to your plugin.`);if(!n)throw Error(`[PluginService]: no plugin name for ${e.name}. Please assign a "pluginName" to your plugin.`);if(i&&i!==qu.version)throw Error(`[PluginService]: package "${r==null?`UNKNOWN`:r}" version mismatch. Plugin version is "${i}" but @univerjs/core version is "${qu.version}". Please make sure all @univerjs packages use the same version.`);if(this._seenPlugins.has(n))throw Error(`[PluginService]: duplicated plugin name for "${n}". Maybe a plugin that dependents on "${n} has already registered it. In that case please register "${n}" before the that plugin.`);this._seenPlugins.add(e.pluginName)}_flushType(e){this._flushTimerByType.get(e)===void 0&&this._flushTimerByType.set(e,setTimeout(()=>{this._loadPluginsForType(e),this._flushTimerByType.delete(e)},4))}_loadFromPlugins(e){let t=[],n=new Set,r=e=>{let{plugin:i}=e,{pluginName:a}=i;if(this._loadedPlugins.has(a)||n.has(a))return;n.add(a),this._pluginRegistry.delete(a);let o=i[Ku];o&&o.forEach(e=>{let t=this._pluginRegistry.get(e.pluginName);if(t)r(t);else if(!this._seenPlugins.has(e.pluginName)&&!n.has(e.pluginName)){if(i.type===x.UNIVER_UNKNOWN&&e.type!==x.UNIVER_UNKNOWN)throw Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${i.pluginName} and the dependency is ${e.pluginName}.`);i.type!==e.type&&e.type!==x.UNIVER_UNKNOWN&&this._logService.debug(`[PluginService]`,`Plugin "${a}" depends on "${e.pluginName}" which has different type.`),this._logService.debug(`[PluginService]`,`Plugin "${a}" depends on "${e.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(e),r({plugin:e,options:void 0})}}),t.push(e)};e.forEach(e=>r(e));let i=t.map(e=>this._initPlugin(e.plugin,e.options));this._pluginsRunLifecycle(i)}_pluginsRunLifecycle(e){let t=this._lifecycleService.stage;if(Lu(t).subscribe(t=>this._runStage(e,t)),t!==$.Steady){let t=this._lifecycleService.lifecycle$.pipe(Ce(1)).subscribe(n=>{this._runStage(e,n),n===$.Steady&&t.unsubscribe()})}}_runStage(e,t){e.forEach(e=>{switch(t){case $.Starting:e.onStarting();break;case $.Ready:e.onReady();break;case $.Rendered:e.onRendered();break;case $.Steady:e.onSteady();break}})}_initPlugin(e,t){let n=this._injector.createInstance(e,t);return this._pluginStore.addPlugin(n),this._loadedPlugins.add(e.pluginName),this._logService.debug(`[PluginService]`,`Plugin "${n.getPluginName()}" loaded.`),n}};Xu=z([R(0,t(i)),R(1,t(Iu)),R(2,L)],Xu);const Zu=m(`resource-loader-service`);let Qu=class extends E{constructor(e){super(),this._logService=e,C(this,`_resourceMap`,new Map),C(this,`_register$`,new y),C(this,`register$`,this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(e,t){return t?this.getResourcesByType(e,t):this.getAllResourceHooks().map(t=>{let n=t.toJson(e);return{name:t.pluginName,data:n}})}getResourcesByType(e,t){return this.getAllResourceHooks().filter(e=>e.businesses.includes(t)).map(t=>{let n=t.toJson(e);return{name:t.pluginName,data:n}})}registerPluginResource(e){let t=e.pluginName;if(this._resourceMap.has(t))throw Error(`the pluginName is registered {${t}}`);return this._resourceMap.set(t,e),this._register$.next(e),T(()=>this._resourceMap.delete(t))}disposePluginResource(e){this._resourceMap.delete(e)}loadResources(e,t){this.getAllResourceHooks().forEach(n=>{var r;let i=t==null||(r=t.find(e=>e.name===n.pluginName))==null?void 0:r.data;if(i)try{let t=n.parseJson(i);n.onLoad(e,t)}catch(e){this._logService.error(`[ResourceManagerService]`,`loadResources error`,e)}})}unloadResources(e,t){this.getAllResourceHooks().filter(e=>e.businesses.includes(t)).forEach(t=>{t.onUnLoad(e)})}dispose(){this._register$.complete(),this._resourceMap.clear()}};Qu=z([R(0,L)],Qu);var $u=class extends E{get darkMode(){return this._darkMode$.getValue()}constructor(){super(),C(this,`_darkMode$`,new v(!1)),C(this,`darkMode$`,this._darkMode$.asObservable()),C(this,`_validColorCache`,new Map),C(this,`_currentTheme`,Je),C(this,`_currentTheme$`,new v(this._currentTheme)),C(this,`currentTheme$`,this._currentTheme$.asObservable()),this.disposeWithMe(T(()=>{this._currentTheme=Je,this._currentTheme$.complete(),this._darkMode$.complete()}))}isValidThemeColor(e){if(this._validColorCache.has(e))return this._validColorCache.get(e);let t=!1,n=e.split(`.`);if(n.length===1)t=e in Je;else if(n.length===2){let[e,r]=n;t=e in Je&&r in this._currentTheme[e]}return this._validColorCache.set(e,t),t}getCurrentTheme(){return this._currentTheme}setTheme(e){this._currentTheme=e,this._currentTheme$.next(e)}setDarkMode(e){this._darkMode$.next(e)}getColorFromTheme(e){return ce(this._currentTheme,e)}},ed=function(e){return e[e.WAITING=0]=`WAITING`,e[e.CREATED=1]=`CREATED`,e}(ed||{});const td=m(`univer.undo-redo.service`);var nd=class{dispose(){}async dispatchToHandlers(){return!1}};const rd=`univer.command.redo`,id=`univer.command.undo`,ad=new class extends nd{constructor(...e){super(...e),C(this,`type`,ri.COMMAND),C(this,`id`,id)}handler(e){let t=e.get(td),n=t.pitchTopUndoElement();if(!n)return!1;let r=e.get(ii);return li(n.undoMutations,r)?(t.popUndoToRedo(),!0):!1}},od=new class extends nd{constructor(...e){super(...e),C(this,`type`,ri.COMMAND),C(this,`id`,rd)}handler(e){let t=e.get(td),n=t.pitchTopRedoElement();if(!n)return!1;let r=e.get(ii);return li(n.redoMutations,r)?(t.popRedoToUndo(),!0):!1}};let sd=class extends E{constructor(e,t,n){super(),this._univerInstanceService=e,this._commandService=t,this._contextService=n,C(this,`undoRedoStatus$`,void 0),C(this,`_undoRedoStatus$`,new v({undos:0,redos:0})),C(this,`_undoStacks`,new Map),C(this,`_redoStacks`,new Map),C(this,`_batchingStatus`,new Map),this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(ad)),this.disposeWithMe(this._commandService.registerCommand(od)),this.disposeWithMe(T(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(T(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(e){let{unitID:t}=e,n=this._getRedoStack(t,!0),r=this._getUndoStack(t,!0);if(n.length=0,this._batchingStatus.has(e.unitID)){let t=this._batchingStatus.get(e.unitID),n=this._pitchUndoElement(e.unitID);t===ed.WAITING||!n?(i(e),this._batchingStatus.set(e.unitID,ed.CREATED)):this._tryBatchingElements(n,e)}else i(e);function i(e){r.push(e),r.length>20&&r.splice(0,1)}this._updateStatus()}clearUndoRedo(e){let t=this._getRedoStack(e);t&&(t.length=0);let n=this._getUndoStack(e);n&&(n.length=0),this._updateStatus()}pitchTopUndoElement(){let e=this._getFocusedUnitId();return this._pitchUndoElement(e)}pitchTopRedoElement(){let e=this._getFocusedUnitId();return this._pitchRedoElement(e)}_pitchUndoElement(e){let t=this._getUndoStack(e);return t!=null&&t.length?t[t.length-1]:null}_pitchRedoElement(e){let t=this._getRedoStack(e);return t!=null&&t.length?t[t.length-1]:null}popUndoToRedo(){let e=this._getUndoStackForFocused().pop();e&&(e.redoMutations.length>0&&this._getRedoStackForFocused().push(e),this._updateStatus())}popRedoToUndo(){let e=this._getRedoStackForFocused().pop();e&&(this._getUndoStackForFocused().push(e),this._updateStatus())}rollback(e,t){let n=t||this._getFocusedUnitId(),r=this._getUndoStack(n),i=r==null?void 0:r[(r==null?void 0:r.length)-1];i&&i.id===e&&(r.pop(),li(i.undoMutations,this._commandService))}__tempBatchingUndoRedo(e){if(this._batchingStatus.has(e))throw Error(`[LocalUndoRedoService]: cannot batching undo redo twice at the same time!`);return this._batchingStatus.set(e,ed.WAITING),T(()=>this._batchingStatus.delete(e))}_updateStatus(){var e,t;let n=this._getFocusedUnitId(),r=n&&((e=this._undoStacks.get(n))==null?void 0:e.length)||0,i=n&&((t=this._redoStacks.get(n))==null?void 0:t.length)||0;this._undoRedoStatus$.next({undos:r,redos:i})}_getUndoStack(e,t=!1){let n=this._undoStacks.get(e);return!n&&t&&(n=[],this._undoStacks.set(e,n)),n||null}_getRedoStack(e,t=!1){let n=this._redoStacks.get(e);return!n&&t&&(n=[],this._redoStacks.set(e,n)),n||null}_getUndoStackForFocused(){let e=this._getFocusedUnitId();if(!e)throw Error(`No focused univer instance!`);return this._getUndoStack(e,!0)}_getRedoStackForFocused(){let e=this._getFocusedUnitId();if(!e)throw Error(`No focused univer instance!`);return this._getRedoStack(e,!0)}_tryBatchingElements(e,t){e.redoMutations.push(...t.redoMutations),e.undoMutations.push(...t.undoMutations)}_getFocusedUnitId(){let e=``,t=this._contextService.getContextValue(yl),n=this._contextService.getContextValue(Tl),r=this._contextService.getContextValue(Cl);if(t)if(n)e=ft;else if(r)e=dt;else{var i,a;e=(i=(a=this._univerInstanceService.getFocusedUnit())==null?void 0:a.getUnitId())==null?``:i}else{var o,s;e=(o=(s=this._univerInstanceService.getFocusedUnit())==null?void 0:s.getUnitId())==null?``:o}return e}};sd=z([R(0,Mu),R(1,ii),R(2,Zr)],sd);var cd=class{constructor(e,t=1e3){this._injector=e,C(this,`_imageCacheMap`,void 0),this._imageCacheMap=new so(t)}_getImageCacheKey(e,t){return`${e}-${t}`}getImage(e,t,n,r){let i=this._getImageCacheKey(e,t);return this._imageCacheMap.get(i)||((async()=>{let a=new Image,o=this._injector.has(Ll)?this._injector.get(Ll):null,s=this._injector.has(Rl)?this._injector.get(Rl):null;if(e===Fl.UUID)try{a.src=await(o==null?void 0:o.getImage(t))||``}catch(e){console.error(e)}else if(e===Fl.URL)try{a.src=await(s==null?void 0:s.getImage(t))||t}catch{a.src=t}else a.src=t;a.onload=()=>{a.removeAttribute(`data-error`),n==null||n()},a.onerror=()=>{a.setAttribute(`data-error`,`true`),r==null||r()},this._imageCacheMap.set(i,a)})(),null)}};function ld(e){return!(e.length===0||e.length>31||e.startsWith(`'`)||e.endsWith(`'`)||/[:\\\/\?\*\[\]]/.test(e))}function ud(e,t){return!(!e||e.length===0||e.length>255||t.has(e)||/[ :\\\/\?\*\[\]]/.test(e)||!/^[\p{L}_]/u.test(e)||/^\$?[A-Za-z]{1,3}\$?[0-9]+$/.test(e)||/^[rR]\d+[cC]\d+$/.test(e)||/^\d+$/.test(e))}var dd=class{constructor(e=!1){this._enableOneCellCache=e,C(this,`_tree`,new Map),C(this,`_oneCellCache`,new Map),C(this,`_kdTree`,new Map)}dispose(){this.clear()}getTree(e,t){return this._tree.has(e)||this._tree.set(e,new Map),this._tree.get(e).has(t)||this._tree.get(e).set(t,new Ge),this._tree.get(e).get(t)}_getOneCellCache(e,t,n,r){return this._oneCellCache.has(e)||this._oneCellCache.set(e,new Map),this._oneCellCache.get(e).has(t)||this._oneCellCache.get(e).set(t,new Map),this._oneCellCache.get(e).get(t).has(n)||this._oneCellCache.get(e).get(t).set(n,new Map),this._oneCellCache.get(e).get(t).get(n).has(r)||this._oneCellCache.get(e).get(t).get(n).set(r,new Set),this._oneCellCache.get(e).get(t).get(n).get(r)}_removeOneCellCache(e,t,n,r,i){let a=this._oneCellCache.get(e);if(!a)return;let o=a.get(t);if(!o)return;let s=o.get(n);if(!s)return;let c=s.get(r);c&&c.delete(i)}_removeCellCacheByRange(e){let{unitId:t,sheetId:n,range:r,id:i}=e,a=this._oneCellCache.get(t);if(!a)return;let o=a.get(n);if(!o)return;let{startRow:s,startColumn:c,endRow:l,endColumn:u}=r;for(let e=s;e<=l;e++){let t=o.get(e);if(t)for(let e=c;e<=u;e++){let n=t.get(e);n&&n.delete(i)}}}_insertOneCellCache(e,t,n,r,i){this._getOneCellCache(e,t,n,r).add(i)}_getRdTreeItems(e){let t=[];for(let[n,r]of e)for(let[e,i]of r)t.push({x:e,y:n,ids:i});return t}_searchByOneCellCache(e){var t;let{unitId:n,sheetId:r,range:i}=e,{startRow:a,startColumn:o,endRow:s,endColumn:c}=i,l=(t=this._kdTree.get(n))==null?void 0:t.get(r);if(!l)return[];let{tree:u,items:d}=l,f=u.range(o,a,c,s),p=[];for(let e of f){let t=d[e];p.push(...Array.from(t.ids))}return p}openKdTree(){for(let[t,n]of this._oneCellCache){this._kdTree.has(t)||this._kdTree.set(t,new Map);for(let[r,i]of n){var e;let n=this._getRdTreeItems(i),a=new Ye(n.length);(e=this._kdTree.get(t))==null||e.set(r,{tree:a,items:n});for(let e of n)a.add(e.x,e.y);a.finish()}}}closeKdTree(){for(let[t,n]of this._oneCellCache)for(let[r,i]of n){var e;(e=this._kdTree.get(t))==null||e.set(r,void 0)}}insert(e){let{unitId:t,sheetId:n,range:r,id:i}=e;if(!t||t.length===0)return;let{startRow:a,endRow:o,startColumn:s,endColumn:c}=r;if(this._enableOneCellCache&&a===o&&s===c){this._insertOneCellCache(t,n,a,s,i);return}let l=this.getTree(t,n);Number.isNaN(a)&&(a=0),Number.isNaN(s)&&(s=0),Number.isNaN(o)&&(o=1/0),Number.isNaN(c)&&(c=1/0),l.insert({minX:s,minY:a,maxX:c,maxY:o,id:i})}bulkInsert(e){for(let t of e)this.insert(t)}*searchGenerator(e){var t;let{unitId:n,sheetId:r,range:i}=e;if(this._enableOneCellCache){let t=this._searchByOneCellCache(e);for(let e of t)yield e}let a=(t=this._tree.get(n))==null?void 0:t.get(r);if(!a)return;let o=a.search({minX:i.startColumn,minY:i.startRow,maxX:i.endColumn,maxY:i.endRow});for(let e of o)yield e.id}bulkSearch(e,t){let n=new Set;for(let r of e)for(let e of this.searchGenerator(r))(t==null?void 0:t.has(e))!==!0&&n.add(e);return n}removeById(e,t){if(t){var n,r;(n=this._tree.get(e))==null||n.delete(t),(r=this._oneCellCache.get(e))==null||r.delete(t)}else this._tree.delete(e),this._oneCellCache.delete(e)}_removeRTreeItem(e){let{unitId:t,sheetId:n,range:r,id:i}=e,a=this.getTree(t,n),o=a.search({minX:r.startColumn,minY:r.startRow,maxX:r.endColumn,maxY:r.endRow});for(let e=0;e<o.length;e++)o[e].id===i&&a.remove(o[e])}remove(e){let{unitId:t,sheetId:n,range:r,id:i}=e,{startRow:a,startColumn:o,endRow:s,endColumn:c}=r;this._enableOneCellCache?a===s&&o===c?this._removeOneCellCache(t,n,r.startRow,r.startColumn,i):(this._removeCellCacheByRange(e),this._removeRTreeItem(e)):this._removeRTreeItem(e)}bulkRemove(e){for(let t of e)this.remove(t)}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){let e={};return this._tree.forEach((t,n)=>{e[n]={},t.forEach((t,r)=>{e[n][r]=t.toJSON()})}),e}fromJSON(e){this._tree.clear();for(let t in e){this._tree.set(t,new Map);for(let n in e[t]){let r=new Ge;r.fromJSON(e[t][n]),this._tree.get(t).set(n,r)}}}};function fd(e){return new Promise(t=>setTimeout(t,e))}function pd(e=1){return new Promise(t=>{let n=0,r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}let md=class extends E{constructor(e){super(),this._localeService=e,C(this,`_fontLocale`,void 0),C(this,`_dirty`,!0),this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(e){this._dirty=e}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}};md=z([R(0,n(zu))],md);let hd=class extends md{constructor(e,t,n,r,i,a){super(n),this.worksheet=e,this._styles=t,this._contextService=r,this._configService=i,this._injector=a,C(this,`_worksheetData`,void 0),C(this,`_renderRawFormula`,!1),C(this,`_cellData`,void 0),C(this,`_imageCacheMap`,void 0),C(this,`_skipAutoHeightForMergedCells`,!0),C(this,`_rowTotalHeight`,0),C(this,`_columnTotalWidth`,0),C(this,`_rowHeaderWidth`,0),C(this,`_columnHeaderHeight`,0),C(this,`_rowHeightAccumulation`,[]),C(this,`_columnWidthAccumulation`,[]),C(this,`_marginTop`,0),C(this,`_marginLeft`,0),C(this,`_scaleX`,void 0),C(this,`_scaleY`,void 0),C(this,`_scrollX`,void 0),C(this,`_scrollY`,void 0),this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new cd(this._injector),this.initConfig()}initConfig(){var e,t;this._skipAutoHeightForMergedCells=!((e=this._configService.getConfig(_t))!=null&&e),this.worksheet.setIsRowStylePrecedeColumnStyle((t=this._configService.getConfig(`isRowStylePrecedeColumnStyle`))==null?!1:t)}resetCache(){}getWorksheetConfig(){return this._worksheetData}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(e){this._columnHeaderHeight=e,this._worksheetData.columnHeader.height=e}set rowHeaderWidth(e){this._rowHeaderWidth=e,this._worksheetData.rowHeader.width=e}get rowHeightAccumulation(){return this._rowHeightAccumulation}get rowTotalHeight(){return this._rowTotalHeight}get columnWidthAccumulation(){return this._columnWidthAccumulation}get columnTotalWidth(){return this._columnTotalWidth}get rowHeaderWidth(){return this._rowHeaderWidth}get columnHeaderHeight(){return this._columnHeaderHeight}setMarginLeft(e){this._marginLeft=e}setMarginTop(e){this._marginTop=e}setScale(e,t){this._updateLayout(),this._scaleX=e,this._scaleY=t||e,this._updateLayout()}setScroll(e,t){D.isDefine(e)&&(this._scrollX=e),D.isDefine(t)&&(this._scrollY=t)}get scrollX(){return this._scrollX}get scrollY(){return this._scrollY}get scaleX(){return this._scaleX}get scaleY(){return this._scaleY}get rowHeaderWidthAndMarginLeft(){return this.rowHeaderWidth+this._marginLeft}get columnHeaderHeightAndMarginTop(){return this.columnHeaderHeight+this._marginTop}get imageCacheMap(){return this._imageCacheMap}_generateRowMatrixCache(e,t,n){let r=0,i=[],a=t;for(let t=0;t<e;t++){let e=n;if(this.worksheet.getRowFiltered(t))e=0;else if(a[t]!=null){let r=a[t];if(!r)continue;let{h:i=n,ah:o,ia:s}=r;e=(s==null||s===A.TRUE)&&typeof o==`number`&&o>0?o:i,r.hd===A.TRUE&&(e=0)}r+=e,i.push(r)}return{rowTotalHeight:r,rowHeightAccumulation:i}}_generateColumnMatrixCache(e,t,n){let r=0,i=[],a=t;for(let t=0;t<e;t++){let e=n;if(a[t]!=null){let n=a[t];if(!n)continue;n.w!=null&&(e=n.w),n.hd===A.TRUE&&(e=0)}r+=e,i.push(r)}return{columnTotalWidth:r,columnWidthAccumulation:i}}intersectMergeRange(e,t){return!!this.worksheet.getMergedCell(e,t)}_getOverflowBound(e,t,n,r,i=Yn.LEFT){let a=0;if(t>n){let o=this._columnWidthAccumulation.length-1;for(let s=t;s>=n;s--){let n=s;if(!Da(this.worksheet.getCell(e,n))&&n!==t||this.intersectMergeRange(e,n))return n===t?n:n+1>o?o:n+1;let{startX:c,endX:l}=vd(e,n,this.rowHeightAccumulation,this.columnWidthAccumulation);if(i===Yn.CENTER&&n===t?a+=(l-c)/2:a+=l-c,r<a)return n}return t}for(let o=t;o<=n;o++){let n=o;if(!Da(this.worksheet.getCell(e,n))&&n!==t||this.intersectMergeRange(e,n))return n===t?n:n-1<0?0:n-1;let{startX:s,endX:c}=vd(e,n,this.rowHeightAccumulation,this.columnWidthAccumulation);if(i===Yn.CENTER&&n===t?a+=(c-s)/2:a+=c-s,r<a)return n}return n}_updateLayout(){if(!this.dirty)return;let{rowData:e,columnData:t,defaultRowHeight:n,defaultColumnWidth:r,rowCount:i,columnCount:a,rowHeader:o,columnHeader:s}=this._worksheetData,{rowTotalHeight:c,rowHeightAccumulation:l}=this._generateRowMatrixCache(i,e,n),{columnTotalWidth:u,columnWidthAccumulation:d}=this._generateColumnMatrixCache(a,t,r);this._rowHeaderWidth=o.hidden===A.TRUE?0:this._dynamicallyUpdateRowHeaderWidth(o),this._columnHeaderHeight=s.hidden===A.TRUE?0:s.height,this._rowTotalHeight=c,this._rowHeightAccumulation=l,this._columnTotalWidth=u,this._columnWidthAccumulation=d,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(e){}_dynamicallyUpdateRowHeaderWidth(e){let t=`${this.worksheet.getRowCount()}`.length*8;return Math.max(e.width,t)}_hasUnMergedCellInRow(e,t,n){if(!this.worksheet.getMergeData())return!1;for(let r=t;r<=n;r++){let{isMerged:t,isMergedMainCell:n}=this.worksheet.getCellInfoInMergeData(e,r);if(!t&&!n)return!0}return!1}expandRangeByMerge(e,t){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e,o=this._worksheetData.mergeData;if(!o)return{startRow:n,startColumn:r,endRow:i,endColumn:a};let s=!0,c=new Sa,l=0,u=null;for(;s;){s=!1;for(let e=0;e<o.length;e++){let{startRow:t,startColumn:d,endRow:f,endColumn:p}=o[e];if(c.getValue(t,d))continue;let m={startColumn:r,startRow:n,endColumn:a,endRow:i},h={startColumn:d,startRow:t,endColumn:p,endRow:f};Po(m,h)&&(n=Math.min(n,t),r=Math.min(r,d),i=Math.max(i,f),a=Math.max(a,p),c.setValue(t,d,!0),s=!0,l++,u=h)}}return t&&l===1&&G.contains(u,e)?{startRow:u.startRow,startColumn:u.startColumn,endRow:u.startRow,endColumn:u.startColumn}:{startRow:n,startColumn:r,endRow:i,endColumn:a}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(e,t){return this.worksheet.getCellInfoInMergeData(e,t)}getNoMergeCellPositionByIndex(e,t,n=!0){return this.getNoMergeCellWithCoordByIndex(e,t,n)}getNoMergeCellWithCoordByIndex(e,t,n=!0){let{rowHeightAccumulation:r,columnWidthAccumulation:i,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:o}=this,{startY:s,endY:c,startX:l,endX:u}=vd(e,t,r,i);return n&&(s+=o,c+=o,l+=a,u+=a),{startY:s,endY:c,startX:l,endX:u}}getNoMergeCellPositionByIndexWithNoHeader(e,t){let{rowHeightAccumulation:n,columnWidthAccumulation:r}=this,{startY:i,endY:a,startX:o,endX:s}=vd(e,t,n,r);return{startY:i,endY:a,startX:o,endX:s}}getRowIndexByOffsetY(e,t,n,r){let{rowHeightAccumulation:i}=this;e=bd(e,t,n,this.columnHeaderHeightAndMarginTop);let a=bi(i,e,r==null?void 0:r.firstMatch);if(r!=null&&r.closeFirst){var o;Math.abs(i[a]-e)<Math.abs(e-((o=i[a-1])==null?0:o))&&(a+=1)}return a}getColumnIndexByOffsetX(e,t,n,r){let i=yd(e,t,n,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this,o=bi(a,i,r==null?void 0:r.firstMatch);if(r!=null&&r.closeFirst){var s;Math.abs(a[o]-i)<Math.abs(i-((s=a[o-1])==null?0:s))&&(o+=1)}return o}getCellIndexByOffset(e,t,n,r,i,a){return{row:this.getRowIndexByOffsetY(t,r,i,a),column:this.getColumnIndexByOffsetX(e,n,i,a)}}getCellByOffset(e,t,n,r,i){var a;let o=(a=this)==null?void 0:a.getCellIndexByOffset(e,t,n,r,i,{firstMatch:!0});return o?this.worksheet.getCellInfoInMergeData(o.row,o.column):null}getCellWithCoordByIndex(e,t,n=!0){var r;let{rowHeightAccumulation:i,columnWidthAccumulation:a,rowHeaderWidthAndMarginLeft:o,columnHeaderHeightAndMarginTop:s}=this,c=vd(e,t,i,a,(r=this.worksheet)==null?void 0:r.getCellInfoInMergeData(e,t)),{isMerged:l,isMergedMainCell:u}=c,{startY:d,endY:f,startX:p,endX:m,mergeInfo:h}=c,g=o,_=s;return n===!1&&(g=0,_=0),d+=_,f+=_,p+=g,m+=g,h.startY+=_,h.endY+=_,h.startX+=g,h.endX+=g,{actualRow:e,actualColumn:t,startX:p,startY:d,endX:m,endY:f,isMerged:l,isMergedMainCell:u,mergeInfo:h}}getCellWithCoordByOffset(e,t,n,r,i,a){let{row:o,column:s}=this.getCellIndexByOffset(e,t,n,r,i,a);return this.getCellWithCoordByIndex(o,s)}getOffsetByColumn(e){let{columnWidthAccumulation:t,rowHeaderWidthAndMarginLeft:n}=this,r=t.length-1,i=t[e];return i==null?e<0?n:t[r]+n:i+n}getOffsetByRow(e){let{rowHeightAccumulation:t,columnHeaderHeightAndMarginTop:n}=this,r=t.length-1,i=t[e];return i==null?e<0?n:t[r]+n:i+n}getOffsetRelativeToRowCol(e,t){let n=bi(this.columnWidthAccumulation,e),r=0;r=n===0?e:e-this._columnWidthAccumulation[n-1];let i=bi(this.rowHeightAccumulation,t),a=0;return a=i===0?t:t-this._rowHeightAccumulation[i-1],{row:i,column:n,columnOffset:r,rowOffset:a}}_updateConfigAndGetDocumentModel(e,t,n,r){var i,a,o,s,c;if(!r||!((i=e.body)!=null&&i.dataStream))return;e.documentStyle||(e.documentStyle={}),e.documentStyle.marginTop=(a=n.t)==null?0:a,e.documentStyle.marginBottom=(o=n.b)==null?2:o,e.documentStyle.marginLeft=(s=n.l)==null?2:s,e.documentStyle.marginRight=(c=n.r)==null?2:c,e.documentStyle.pageSize={width:1/0,height:1/0},e.documentStyle.renderConfig={...e.documentStyle.renderConfig,...r};let l=e.body.paragraphs||[];for(let e of l)e.paragraphStyle||(e.paragraphStyle={}),e.paragraphStyle.horizontalAlign=t;return new _c(e)}dispose(){super.dispose(),this._rowHeightAccumulation=[],this._columnWidthAccumulation=[],this._rowTotalHeight=0,this._columnTotalWidth=0,this._rowHeaderWidth=0,this._columnHeaderHeight=0,this._worksheetData=null,this._cellData=null,this._styles=null,this.worksheet=null}};hd=z([R(2,n(zu)),R(3,Zr),R(4,Yr),R(5,n(a))],hd);function gd(e,t,n,r){let i=e-1,a=t-1,o=n[i]||0,s=n[e];s==null&&(s=n[n.length-1]);let c=r[a]||0,l=r[t];return l==null&&(l=r[r.length-1]),{startY:o,endY:s,startX:c,endX:l}}function _d(e,t,n,r){return gd(e,t,n,r)}function vd(e,t,n,r,i){e=D.clamp(e,0,n.length-1),t=D.clamp(t,0,r.length-1);let{startY:a,endY:o,startX:s,endX:c}=gd(e,t,n,r);if(!i)return{startY:a,endY:o,startX:s,endX:c,isMerged:!1,isMergedMainCell:!1,actualRow:e,actualColumn:t,mergeInfo:{startY:a,endY:o,startX:s,endX:c,startRow:e,startColumn:t,endRow:e,endColumn:t}};let{isMerged:l,isMergedMainCell:u,startRow:d,startColumn:f,endRow:p,endColumn:m}=i,h={startRow:d,startColumn:f,endRow:p,endColumn:m,startY:a,endY:o,startX:s,endX:c},g=n.length-1,_=r.length-1;if(l&&d!==-1&&f!==-1){let e=n[d-1]||0,t=n[p]||n[g],i=r[f-1]||0,a=r[m]||r[_];h={...h,startY:e,endY:t,startX:i,endX:a}}else if(!l&&p!==-1&&m!==-1){let e=n[p]||n[g],t=r[m]||r[_];h={...h,startY:a,endY:e,startX:s,endX:t}}return{isMerged:l,isMergedMainCell:u,actualRow:e,actualColumn:t,startY:a,endY:o,startX:s,endX:c,mergeInfo:h}}function yd(e,t,n,r){let{x:i}=n;return e/t+i-r}function bd(e,t,n,r){let{y:i}=n;return e=e/t+i-r,e}const xd=[`script`,`style`,`meta`,`comment`,`link`];let Sd=function(e){return e[e.INFO=0]=`INFO`,e[e.STOP=1]=`STOP`,e[e.WARNING=2]=`WARNING`,e}({}),Cd=function(e){return e[e.DISABLED=0]=`DISABLED`,e[e.FULL_ALPHA=1]=`FULL_ALPHA`,e[e.FULL_HANGUL=2]=`FULL_HANGUL`,e[e.FULL_KATAKANA=3]=`FULL_KATAKANA`,e[e.HALF_ALPHA=4]=`HALF_ALPHA`,e[e.HALF_HANGUL=5]=`HALF_HANGUL`,e[e.HALF_KATAKANA=6]=`HALF_KATAKANA`,e[e.HIRAGANA=7]=`HIRAGANA`,e[e.NO_CONTROL=8]=`NO_CONTROL`,e[e.OFF=9]=`OFF`,e[e.ON=10]=`ON`,e}({}),wd=function(e){return e.BETWEEN=`between`,e.EQUAL=`equal`,e.GREATER_THAN=`greaterThan`,e.GREATER_THAN_OR_EQUAL=`greaterThanOrEqual`,e.LESS_THAN=`lessThan`,e.LESS_THAN_OR_EQUAL=`lessThanOrEqual`,e.NOT_BETWEEN=`notBetween`,e.NOT_EQUAL=`notEqual`,e}({}),Td=function(e){return e[e.TEXT=0]=`TEXT`,e[e.ARROW=1]=`ARROW`,e[e.CUSTOM=2]=`CUSTOM`,e}({}),Ed=function(e){return e.VALID=`valid`,e.INVALID=`invalid`,e.VALIDATING=`validating`,e}({}),Dd=function(e){return e.CUSTOM=`custom`,e.LIST=`list`,e.LIST_MULTIPLE=`listMultiple`,e.NONE=`none`,e.TEXT_LENGTH=`textLength`,e.DATE=`date`,e.TIME=`time`,e.WHOLE=`whole`,e.DECIMAL=`decimal`,e.CHECKBOX=`checkbox`,e.ANY=`any`,e}({}),Od=class extends E{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){let e=e=>{e.businesses.forEach(t=>{switch(t){case x.UNRECOGNIZED:case x.UNIVER_UNKNOWN:case x.UNIVER_SLIDE:case x.UNIVER_DOC:this._univerInstanceService.getAllUnitsForType(x.UNIVER_DOC).forEach(t=>{let n=(t.getSnapshot().resources||[]).find(t=>t.name===e.pluginName);if(n)try{let r=e.parseJson(n.data);e.onLoad(t.getUnitId(),r)}catch{console.error(`Load Document{${t.getUnitId()}} Resources{${e.pluginName}} Data Error.`)}});break;case x.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(x.UNIVER_SHEET).forEach(t=>{let n=(t.getSnapshot().resources||[]).find(t=>t.name===e.pluginName);if(n)try{let r=e.parseJson(n.data);e.onLoad(t.getUnitId(),r)}catch{console.error(`Load Workbook{${t.getUnitId()}} Resources{${e.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(t=>e(t)),this.disposeWithMe(this._resourceManagerService.register$.subscribe(t=>e(t))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(x.UNIVER_SHEET).subscribe(e=>{this._resourceManagerService.loadResources(e.getUnitId(),e.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(x.UNIVER_DOC).subscribe(e=>{yt(e.getUnitId())||this._resourceManagerService.loadResources(e.getUnitId(),e.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(x.UNIVER_SHEET).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),x.UNIVER_SHEET)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(x.UNIVER_DOC).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),x.UNIVER_DOC)}))}saveUnit(e){let t=this._univerInstanceService.getUnit(e);if(!t)return null;let n=this._resourceManagerService.getResources(e,t.type),r=D.deepClone(t.getSnapshot());return r.resources=n,r}};Od=z([R(0,t(ll)),R(1,t(Mu))],Od);var kd=class{get _univerInstanceService(){return this._injector.get(Mu)}get _pluginService(){return this._injector.get(Xu)}constructor(e={},t){C(this,`_startedTypes`,new Set),C(this,`_injector`,void 0),C(this,`_disposingCallbacks`,new un);let n=this._injector=Ad(t,e==null?void 0:e.override),{theme:r,darkMode:i,locale:a,locales:o,logLevel:s,logCommandExecution:c}=e;r&&this._injector.get($u).setTheme(r),i&&this._injector.get($u).setDarkMode(i),o&&this._injector.get(zu).load(o),a&&this._injector.get(zu).setLocale(a),s&&this._injector.get(L).setLogLevel(s),c!==void 0&&this._injector.get(Yr).setConfig(ni,c),this._init(n)}__getInjector(){return this._injector}onDispose(e){let t=this._disposingCallbacks.add(T(e));return T(()=>t.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(e){this._injector.get(zu).setLocale(e)}createUnit(e,t){return this._univerInstanceService.createUnit(e,t)}createUniverSheet(e){return this._injector.get(L).warn(`[Univer]`,`Univer.createUniverSheet is deprecated, use createUnit instead`),this._univerInstanceService.createUnit(x.UNIVER_SHEET,e)}createUniverDoc(e){return this._injector.get(L).warn(`[Univer]`,`Univer.createUniverDoc is deprecated, use createUnit instead`),this._univerInstanceService.createUnit(x.UNIVER_DOC,e)}createUniverSlide(e){return this._injector.get(L).warn(`[Univer]`,`Univer.createUniverSlide is deprecated, use createUnit instead`),this._univerInstanceService.createUnit(x.UNIVER_SLIDE,e)}_init(e){this._univerInstanceService.registerCtorForType(x.UNIVER_SHEET,Au),this._univerInstanceService.registerCtorForType(x.UNIVER_DOC,_c),this._univerInstanceService.registerCtorForType(x.UNIVER_SLIDE,ju);let t=e.get(Mu);t.__setCreateHandler((n,r,i,a)=>{if(!this._startedTypes.has(n)){this._pluginService.startPluginsForType(n),this._startedTypes.add(n);let o=e.createInstance(i,r);return t.__addUnit(o,a),this._tryProgressToReady(),o}let o=e.createInstance(i,r);return t.__addUnit(o,a),o})}_tryProgressToReady(){this._injector.get(Iu).stage<$.Ready&&(this._injector.get(Iu).stage=$.Ready)}registerPlugin(e,t){this._pluginService.registerPlugin(e,t)}registerPlugins(e){e.forEach(e=>{let[t,n]=e;this._pluginService.registerPlugin(t,n)})}};function Ad(e,t){let n=Gu([[Pl],[zu],[$u],[Iu],[Xu],[pl],[Mu,{useClass:Nu}],[Uu,{useClass:Wu}],[L,{useClass:ei,lazy:!0}],[ii,{useClass:si}],[td,{useClass:sd,lazy:!0}],[Yr,{useClass:Xr}],[Zr,{useClass:Qr}],[ll,{useClass:Qu,lazy:!0}],[Zu,{useClass:Od,lazy:!0}],[hl,{useClass:ml}],[Vu,{useClass:Bu,lazy:!0}]],t),r=e?e.createChild(n):new i(n);return St(r,[[pl],[Zu]]),r}et();export{Wo as ABCToNumber,_t as AUTO_HEIGHT_FOR_MERGED_CELLS,V as AbsoluteRefType,Ys as ActionIterator,Ar as AlignTypeH,jr as AlignTypeV,Fr as ArrangeTypeEnum,Hn as ArrowsAndMarkersShapes,It as AsyncInterceptorManager,e as AsyncLock,ml as AuthzIoLocalService,Dn as AutoFillSeries,Wr as BORDER_KEYS,Ur as BORDER_STYLE_KEYS,er as BaselineOffset,Vn as BasicShapes,cr as BlockType,A as BooleanNumber,k as BorderStyleTypes,On as BorderType,Z as BuildTextUtils,ar as BulletAlignment,Di as COLORS,Hr as COLOR_STYLE_KEYS,ni as COMMAND_LOG_EXECUTION_CONFIG_KEY,Tt as CanceledError,ea as CellModeEnum,tr as CellValueType,Oi as ColorKit,kn as ColorType,fr as ColumnSeparatorType,si as CommandService,ri as CommandType,An as CommonHideTypes,Xr as ConfigService,Qr as ContextService,jn as CopyPasteType,wt as CustomCommandExecutionError,sr as CustomDecorationType,or as CustomRangeType,go as DEFAULT_CELL,hc as DEFAULT_DOC,al as DEFAULT_DOCUMENT_SUB_COMPONENT_ID,ht as DEFAULT_EMPTY_DOCUMENT_VALUE,ia as DEFAULT_NUMBER_FORMAT,mo as DEFAULT_RANGE,po as DEFAULT_RANGE_ARRAY,ho as DEFAULT_SELECTION,_o as DEFAULT_SLIDE,W as DEFAULT_STYLES,na as DEFAULT_TEXT_FORMAT,ra as DEFAULT_TEXT_FORMAT_EXCEL,pu as DEFAULT_WORKSHEET_COLUMN_COUNT,fu as DEFAULT_WORKSHEET_COLUMN_COUNT_KEY,xu as DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT,bu as DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY,_u as DEFAULT_WORKSHEET_COLUMN_WIDTH,gu as DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY,du as DEFAULT_WORKSHEET_ROW_COUNT,uu as DEFAULT_WORKSHEET_ROW_COUNT_KEY,hu as DEFAULT_WORKSHEET_ROW_HEIGHT,mu as DEFAULT_WORKSHEET_ROW_HEIGHT_KEY,yu as DEFAULT_WORKSHEET_ROW_TITLE_WIDTH,vu as DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY,mt as DOCS_COMMENT_EDITOR_UNIT_ID_KEY,ft as DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,dt as DOCS_NORMAL_EDITOR_UNIT_ID_KEY,pt as DOCS_ZEN_EDITOR_UNIT_ID_KEY,So as DOC_DRAWING_PRINTING_COMPONENT_KEY,Qi as DOC_RANGE_TYPE,vr as DashStyleType,lc as DataStreamTreeNodeType,X as DataStreamTreeTokenType,Sd as DataValidationErrorStyle,Cd as DataValidationImeMode,wd as DataValidationOperator,Td as DataValidationRenderMode,Ed as DataValidationStatus,Dd as DataValidationType,Mn as DeleteDirection,Yu as DependentOn,ei as DesktopLogService,Nn as DeveloperMetadataVisibility,Pn as Dimension,Fn as Direction,E as Disposable,un as DisposableCollection,rr as DocStyleType,_c as DocumentDataModel,lr as DocumentFlavor,Ir as DrawingTypeEnum,Cl as EDITOR_ACTIVATED,Co as EXTENSION_NAMES,Pl as ErrorService,ol as EventState,sl as EventSubject,Ol as FOCUSING_COMMENT_EDITOR,jl as FOCUSING_COMMON_DRAWINGS,bl as FOCUSING_DOC,Sl as FOCUSING_EDITOR_BUT_HIDDEN,wl as FOCUSING_EDITOR_INPUT_FORMULA,Dl as FOCUSING_EDITOR_STANDALONE,Tl as FOCUSING_FX_BAR_EDITOR,kl as FOCUSING_PANEL_EDITOR,Ml as FOCUSING_SHAPE_TEXT_EDITOR,yl as FOCUSING_SHEET,xl as FOCUSING_SLIDE,vl as FOCUSING_UNIT,El as FOCUSING_UNIVER_EDITOR,Al as FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE,Nl as FORMULA_EDITOR_ACTIVATED,ir as FollowNumberWithType,Qn as FontItalic,Er as FontStyleType,$n as FontWeight,ur as GridType,Yn as HorizontalAlign,hl as IAuthzIoService,ii as ICommandService,Yr as IConfigService,gl as IConfirmService,Zr as IContextService,Ll as IImageIoService,Ru as ILocalStorageService,L as ILogService,Vu as IMentionIOService,Uu as IPermissionService,Zu as IResourceLoaderService,ll as IResourceManagerService,gt as IS_ROW_STYLE_PRECEDE_COLUMN_STYLE,Rl as IURLImageService,td as IUndoRedoService,Mu as IUniverInstanceService,cd as ImageCacheMap,Fl as ImageSourceType,Il as ImageUploadStatusType,t as Inject,r as InjectSelf,i as Injector,At as InterceptorEffectEnum,Nt as InterceptorManager,Ln as InterpolationPointType,S as JSON1,cc as JSONX,co as LRUHelper,so as LRUMap,Iu as LifecycleService,$ as LifecycleStages,Fu as LifecycleUnreachableError,M as ListGlyphType,sd as LocalUndoRedoService,zu as LocaleService,Rn as LocaleType,$r as LogLevel,o as LookUp,fo as MAX_COLUMN_COUNT,uo as MAX_ROW_COUNT,Si as MOVE_BUFFER_VALUE,s as Many,Zt as MemoryCursor,Bu as MentionIOLocalService,zn as MentionType,yo as NAMED_STYLE_MAP,bo as NAMED_STYLE_SPACE_MAP,N as NamedStyleType,oi as NilCommand,kr as NumberUnitType,Sa as ObjectMatrix,Dr as ObjectRelativeFromH,Or as ObjectRelativeFromV,c as Optional,Un as OtherShapes,Kr as PADDING_KEYS,wo as PAGE_SIZE,Pr as PAPER_TYPES,xs as PRESET_LIST_TYPE,xo as PRINT_CHART_COMPONENT_KEY,Rr as PageElementType,Nr as PageOrientType,Lr as PageType,P as PaperType,mr as ParagraphElementType,nl as ParagraphStyleBuilder,tl as ParagraphStyleValue,Wu as PermissionService,Hu as PermissionStatus,qu as Plugin,Xu as PluginService,gr as PositionedObjectLayoutType,q as PresetListType,Bn as ProtectionType,l as Quantity,K as QuickListType,ws as QuickListTypeMap,Zi as RANGE_DIRECTION,B as RANGE_TYPE,Ge as RBush,fn as RCDisposable,Ei as RGBA_PAREN,Ti as RGB_PAREN,Ci as ROTATE_BUFFER_VALUE,dd as RTree,Eo as Range,G as Rectangle,u as RediError,od as RedoCommand,rd as RedoCommandId,Ho as RefAlias,nn as Registry,rn as RegistryAsMap,Gn as RelativeDate,zr as RelativeSlideLink,Qu as ResourceManagerService,il as RichTextBuilder,rl as RichTextValue,dn as RxDisposable,vo as SHEET_EDITOR_UNITS,qr as STYLE_KEYS,dr as SectionType,d as Self,hd as SheetSkeleton,Kn as SheetTypes,wu as SheetViewModel,md as Skeleton,f as SkipSelf,Ps as SliceBodyType,ju as SlideDataModel,_r as SpacingRule,Wn as SpecialShapes,Hl as Styles,Vr as TEXT_DECORATION_KEYS,Gr as TEXT_ROTATION_KEYS,ta as THEME_COLORS,yr as TabStopAlignment,xr as TableAlignmentType,Sr as TableLayoutType,wr as TableRowHeightRule,br as TableSizeType,Cr as TableTextWrapType,_l as TestConfirmService,Jn as TextDecoration,el as TextDecorationBuilder,qn as TextDirection,pr as TextDirectionType,$c as TextStyleBuilder,Qc as TextStyleValue,Y as TextX,I as TextXActionType,j as ThemeColorType,nr as ThemeColors,$u as ThemeService,D as Tools,ad as UndoCommand,id as UndoCommandId,pn as UnitModel,kd as Univer,Nu as UniverInstanceService,x as UniverInstanceType,F as UpdateDocsAttributeType,pl as UserManagerService,Xn as VerticalAlign,Tr as VerticalAlignmentType,p as WithNew,Au as Workbook,Eu as Worksheet,Zn as WrapStrategy,hr as WrapTextType,Xl as addLinkToDocumentModel,gi as afterInitApply,mi as afterTime,fd as awaitTime,yi as binSearchFirstGreaterThanTarget,vi as binarySearchArray,pi as bufferDebounceTime,Ia as cellToRange,Mr as characterSpacingControlType,Va as checkForSubstrings,wi as checkIfMove,Ua as checkParagraphHasBullet,Wa as checkParagraphHasIndent,Ga as checkParagraphHasIndentByStyle,nu as cloneCellData,iu as cloneCellDataMatrix,ru as cloneCellDataWithSpanAndDisplay,Q as cloneValue,su as cloneWorksheetData,xi as codeToBlob,lo as columnLabelToNumber,qs as composeBody,Mt as composeInterceptors,wn as composeStyles,_a as concatMatrixArray,Ca as convertCellToRange,hi as convertObservableToBehaviorSubject,La as covertCellValue,Ra as covertCellValues,Pt as createAsyncInterceptorKey,dl as createDefaultUser,ql as createDocumentModelWithStyle,m as createIdentifier,jt as createInterceptorKey,vt as createInternalEditorID,En as createREGEXFromWildChar,Uo as createRowColIter,ud as customNameCharacterCheck,Ie as dayjs,se as debounce,nt as dedupe,rt as dedupeBy,za as deepCompare,pd as delayAnimationFrame,qa as deleteContent,Du as extractPureTextFromCell,g as forwardRef,di as fromCallback,cl as fromEventSubject,Xa as generateIntervalsByPoints,O as generateRandomId,ce as get,pa as getArrayLength,Bs as getBodySlice,Na as getBorderStyleType,gd as getCellCoordByIndexSimple,$i as getCellInfoInMergeData,_d as getCellPositionByIndexSimple,qi as getCellValueType,vd as getCellWithCoordByIndexCore,Oa as getColorStyle,zs as getCustomBlockSlice,Us as getCustomDecorationSlice,Hs as getCustomRangeSlice,Pa as getDocsUpdateBody,Ql as getEmptyCell,Po as getIntersectRange,da as getNumfmtParseValueFilter,Ou as getOriginCellValue,Ls as getParagraphsSlice,fc as getPlainText,In as getReverseDirection,Rs as getSectionBreakSlice,Is as getTableSlice,Fs as getTextRunSlice,yd as getTransformOffsetX,bd as getTransformOffsetY,ku as getWorksheetUID,ot as groupBy,ja as handleStyleToString,Ya as hashAlgorithm,Ha as horizontalLineSegmentsSubtraction,ha as insertMatrixArray,Ka as insertTextToContent,Jt as invertColorByHSL,Xt as invertColorByMatrix,_ as isAsyncDependencyItem,ee as isAsyncHook,Wi as isBlackColor,lt as isBooleanString,Da as isCellCoverable,Yi as isCellV,te as isClassDependencyItem,bt as isCommentEditorID,ne as isCtor,oa as isDefaultFormat,re as isDisposable,Ea as isEmptyCell,ie as isFactoryDependencyItem,Aa as isFormulaId,ka as isFormulaString,Ki as isICellData,yt as isInternalEditorID,Tn as isNodeEnv,Zl as isNotNullOrUndefined,Ji as isNullCell,$t as isNumeric,sa as isPatternEqualWithoutDecimal,Ul as isRangesEqual,Ja as isRealNum,en as isSafeNumeric,Ba as isSameStyleTextRun,aa as isTextFormat,Wl as isUnitRangesEqual,Fa as isValidRange,ae as isValueDependencyItem,Gi as isWhiteColor,st as makeArray,Ta as makeCellRangeToRangeData,wa as makeCellToSelection,uc as makeCustomRangeStream,fa as mapObjectMatrix,le as merge,Za as mergeIntervals,Qa as mergeLocales,Gu as mergeOverrideWithDependencies,cn as mergeSets,ue as mergeWith,Su as mergeWorksheetSnapshotWithDefault,Qt as mixinClass,ya as moveMatrixArray,Do as moveRangeByOffset,ld as nameCharacterCheck,Vs as normalizeBody,Zo as normalizeTextRuns,Go as numberToABC,qo as numberToListABC,Fe as numfmt,Vo as queryObjectMatrix,xt as registerDependencies,tt as remove,Ko as repeatStringNumTimes,Yc as replaceInDocumentBody,an as requestImmediateMacroTask,bn as resolveWithBasePath,at as rotate,bi as searchArray,_i as searchInOrderedArray,Xi as selectionToArray,sn as sequence,on as sequenceAsync,li as sequenceExecute,ui as sequenceExecuteAsync,de as set,oe as setDependencies,Ct as shallowEqual,xd as skipParseTagNames,va as sliceMatrixArray,Jo as sortRules,Yo as sortRulesByDesc,Xo as sortRulesFactory,ga as spliceArray,ko as splitIntoGrid,fi as takeAfter,qe as textDiff,Et as throttle,T as toDisposable,St as touchDependencies,Xs as updateAttributeByDelete,Zs as updateAttributeByInsert,tn as willLoseNumericPrecision};
|