@univerjs/core 0.8.0-beta.0 → 0.8.0-nightly.202505261607
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 +1 -1
- package/lib/es/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +2 -4
- package/LICENSE +0 -176
package/lib/cjs/index.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
`)?e.slice(0,-2):e;return hf.reduce((n,r)=>n.replaceAll(r,""),t)},df=e=>e?rs(e).replaceAll("\r","")==="":!0,ff=e=>{const t=e.replace(/\n/g,"\r"),n=[],r=[];let s=0,i="";const o=(l,u=!0)=>{const c=t.slice(s,l);if(ne.isLegalUrl(c)){const h=Bt(),d=`${c}`,f={startIndex:s,endIndex:s+d.length-1,rangeId:h,rangeType:Zt.HYPERLINK,properties:{url:e}};r.push(f),i+=d,s=l+1,u&&(i+="\r",n.push({startIndex:l}))}else i+=t.slice(s,l+1),s=l+1,u&&n.push({startIndex:l})};let a=0;for(let l=0;l<t.length;l++)t[l]==="\r"&&(o(l),a=l);return(a!==t.length-1||t.length===1)&&o(t.length,!1),{dataStream:i,paragraphs:n,customRanges:r}};var vl=typeof global=="object"&&global&&global.Object===Object&&global,gf=typeof self=="object"&&self&&self.Object===Object&&self,dn=vl||gf||Function("return this")(),yn=dn.Symbol,Ol=Object.prototype,mf=Ol.hasOwnProperty,_f=Ol.toString,Pn=yn?yn.toStringTag:void 0;function pf(e){var t=mf.call(e,Pn),n=e[Pn];try{e[Pn]=void 0;var r=!0}catch{}var s=_f.call(e);return r&&(t?e[Pn]=n:delete e[Pn]),s}var Ef=Object.prototype,Cf=Ef.toString;function Rf(e){return Cf.call(e)}var If="[object Null]",Sf="[object Undefined]",Zi=yn?yn.toStringTag:void 0;function cr(e){return e==null?e===void 0?Sf:If:Zi&&Zi in Object(e)?pf(e):Rf(e)}function Ln(e){return e!=null&&typeof e=="object"}var vf="[object Symbol]";function ss(e){return typeof e=="symbol"||Ln(e)&&cr(e)==vf}function Of(e,t){for(var n=-1,r=e==null?0:e.length,s=Array(r);++n<r;)s[n]=t(e[n],n,e);return s}var Nn=Array.isArray,Qi=yn?yn.prototype:void 0,eo=Qi?Qi.toString:void 0;function wl(e){if(typeof e=="string")return e;if(Nn(e))return Of(e,wl)+"";if(ss(e))return eo?eo.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}var wf=/\s/;function bf(e){for(var t=e.length;t--&&wf.test(e.charAt(t)););return t}var Af=/^\s+/;function Tf(e){return e&&e.slice(0,bf(e)+1).replace(Af,"")}function wt(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var to=NaN,yf=/^[-+]0x[0-9a-f]+$/i,Nf=/^0b[01]+$/i,Mf=/^0o[0-7]+$/i,Df=parseInt;function no(e){if(typeof e=="number")return e;if(ss(e))return to;if(wt(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=wt(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Tf(e);var n=Nf.test(e);return n||Mf.test(e)?Df(e.slice(2),n?2:8):yf.test(e)?to:+e}function bl(e){return e}var Lf="[object AsyncFunction]",xf="[object Function]",Uf="[object GeneratorFunction]",Pf="[object Proxy]";function di(e){if(!wt(e))return!1;var t=cr(e);return t==xf||t==Uf||t==Lf||t==Pf}var _s=dn["__core-js_shared__"],ro=function(){var e=/[^.]+$/.exec(_s&&_s.keys&&_s.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function kf(e){return!!ro&&ro in e}var Ff=Function.prototype,Bf=Ff.toString;function $f(e){if(e!=null){try{return Bf.call(e)}catch{}try{return e+""}catch{}}return""}var Hf=/[\\^$.*+?()[\]{}|]/g,jf=/^\[object .+?Constructor\]$/,Wf=Function.prototype,Yf=Object.prototype,zf=Wf.toString,Gf=Yf.hasOwnProperty,Vf=RegExp("^"+zf.call(Gf).replace(Hf,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Kf(e){if(!wt(e)||kf(e))return!1;var t=di(e)?Vf:jf;return t.test($f(e))}function Xf(e,t){return e==null?void 0:e[t]}function fi(e,t){var n=Xf(e,t);return Kf(n)?n:void 0}var so=Object.create,qf=function(){function e(){}return function(t){if(!wt(t))return{};if(so)return so(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function Jf(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function Zf(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}var Qf=800,eg=16,tg=Date.now;function ng(e){var t=0,n=0;return function(){var r=tg(),s=eg-(r-n);if(n=r,s>0){if(++t>=Qf)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function rg(e){return function(){return e}}var Vr=function(){try{var e=fi(Object,"defineProperty");return e({},"",{}),e}catch{}}(),sg=Vr?function(e,t){return Vr(e,"toString",{configurable:!0,enumerable:!1,value:rg(t),writable:!0})}:bl,ig=ng(sg),og=9007199254740991,ag=/^(?:0|[1-9]\d*)$/;function gi(e,t){var n=typeof e;return t=t==null?og:t,!!t&&(n=="number"||n!="symbol"&&ag.test(e))&&e>-1&&e%1==0&&e<t}function mi(e,t,n){t=="__proto__"&&Vr?Vr(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function is(e,t){return e===t||e!==e&&t!==t}var lg=Object.prototype,ug=lg.hasOwnProperty;function Al(e,t,n){var r=e[t];(!(ug.call(e,t)&&is(r,n))||n===void 0&&!(t in e))&&mi(e,t,n)}function cg(e,t,n,r){var s=!n;n||(n={});for(var i=-1,o=t.length;++i<o;){var a=t[i],l=void 0;l===void 0&&(l=e[a]),s?mi(n,a,l):Al(n,a,l)}return n}var io=Math.max;function hg(e,t,n){return t=io(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,i=io(r.length-t,0),o=Array(i);++s<i;)o[s]=r[t+s];s=-1;for(var a=Array(t+1);++s<t;)a[s]=r[s];return a[t]=n(o),Jf(e,this,a)}}function dg(e,t){return ig(hg(e,t,bl),e+"")}var fg=9007199254740991;function Tl(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=fg}function _i(e){return e!=null&&Tl(e.length)&&!di(e)}function gg(e,t,n){if(!wt(n))return!1;var r=typeof t;return(r=="number"?_i(n)&&gi(t,n.length):r=="string"&&t in n)?is(n[t],e):!1}function yl(e){return dg(function(t,n){var r=-1,s=n.length,i=s>1?n[s-1]:void 0,o=s>2?n[2]:void 0;for(i=e.length>3&&typeof i=="function"?(s--,i):void 0,o&&gg(n[0],n[1],o)&&(i=s<3?void 0:i,s=1),t=Object(t);++r<s;){var a=n[r];a&&e(t,a,r,i)}return t})}var mg=Object.prototype;function Nl(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||mg;return e===n}function _g(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var pg="[object Arguments]";function oo(e){return Ln(e)&&cr(e)==pg}var Ml=Object.prototype,Eg=Ml.hasOwnProperty,Cg=Ml.propertyIsEnumerable,js=oo(function(){return arguments}())?oo:function(e){return Ln(e)&&Eg.call(e,"callee")&&!Cg.call(e,"callee")};function Rg(){return!1}var Dl=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ao=Dl&&typeof module=="object"&&module&&!module.nodeType&&module,Ig=ao&&ao.exports===Dl,lo=Ig?dn.Buffer:void 0,Sg=lo?lo.isBuffer:void 0,Ll=Sg||Rg,vg="[object Arguments]",Og="[object Array]",wg="[object Boolean]",bg="[object Date]",Ag="[object Error]",Tg="[object Function]",yg="[object Map]",Ng="[object Number]",Mg="[object Object]",Dg="[object RegExp]",Lg="[object Set]",xg="[object String]",Ug="[object WeakMap]",Pg="[object ArrayBuffer]",kg="[object DataView]",Fg="[object Float32Array]",Bg="[object Float64Array]",$g="[object Int8Array]",Hg="[object Int16Array]",jg="[object Int32Array]",Wg="[object Uint8Array]",Yg="[object Uint8ClampedArray]",zg="[object Uint16Array]",Gg="[object Uint32Array]",Ze={};Ze[Fg]=Ze[Bg]=Ze[$g]=Ze[Hg]=Ze[jg]=Ze[Wg]=Ze[Yg]=Ze[zg]=Ze[Gg]=!0;Ze[vg]=Ze[Og]=Ze[Pg]=Ze[wg]=Ze[kg]=Ze[bg]=Ze[Ag]=Ze[Tg]=Ze[yg]=Ze[Ng]=Ze[Mg]=Ze[Dg]=Ze[Lg]=Ze[xg]=Ze[Ug]=!1;function Vg(e){return Ln(e)&&Tl(e.length)&&!!Ze[cr(e)]}function Kg(e){return function(t){return e(t)}}var xl=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Xn=xl&&typeof module=="object"&&module&&!module.nodeType&&module,Xg=Xn&&Xn.exports===xl,ps=Xg&&vl.process,uo=function(){try{var e=Xn&&Xn.require&&Xn.require("util").types;return e||ps&&ps.binding&&ps.binding("util")}catch{}}(),co=uo&&uo.isTypedArray,Ul=co?Kg(co):Vg;function qg(e,t){var n=Nn(e),r=!n&&js(e),s=!n&&!r&&Ll(e),i=!n&&!r&&!s&&Ul(e),o=n||r||s||i,a=o?_g(e.length,String):[],l=a.length;for(var u in e)o&&(u=="length"||s&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||gi(u,l))||a.push(u);return a}function Jg(e,t){return function(n){return e(t(n))}}function Zg(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var Qg=Object.prototype,em=Qg.hasOwnProperty;function tm(e){if(!wt(e))return Zg(e);var t=Nl(e),n=[];for(var r in e)r=="constructor"&&(t||!em.call(e,r))||n.push(r);return n}function Pl(e){return _i(e)?qg(e):tm(e)}var nm=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,rm=/^\w*$/;function sm(e,t){if(Nn(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||ss(e)?!0:rm.test(e)||!nm.test(e)||t!=null&&e in Object(t)}var Qn=fi(Object,"create");function im(){this.__data__=Qn?Qn(null):{},this.size=0}function om(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var am="__lodash_hash_undefined__",lm=Object.prototype,um=lm.hasOwnProperty;function cm(e){var t=this.__data__;if(Qn){var n=t[e];return n===am?void 0:n}return um.call(t,e)?t[e]:void 0}var hm=Object.prototype,dm=hm.hasOwnProperty;function fm(e){var t=this.__data__;return Qn?t[e]!==void 0:dm.call(t,e)}var gm="__lodash_hash_undefined__";function mm(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Qn&&t===void 0?gm:t,this}function hn(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}hn.prototype.clear=im;hn.prototype.delete=om;hn.prototype.get=cm;hn.prototype.has=fm;hn.prototype.set=mm;function _m(){this.__data__=[],this.size=0}function os(e,t){for(var n=e.length;n--;)if(is(e[n][0],t))return n;return-1}var pm=Array.prototype,Em=pm.splice;function Cm(e){var t=this.__data__,n=os(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():Em.call(t,n,1),--this.size,!0}function Rm(e){var t=this.__data__,n=os(t,e);return n<0?void 0:t[n][1]}function Im(e){return os(this.__data__,e)>-1}function Sm(e,t){var n=this.__data__,r=os(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function jt(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}jt.prototype.clear=_m;jt.prototype.delete=Cm;jt.prototype.get=Rm;jt.prototype.has=Im;jt.prototype.set=Sm;var kl=fi(dn,"Map");function vm(){this.size=0,this.__data__={hash:new hn,map:new(kl||jt),string:new hn}}function Om(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function as(e,t){var n=e.__data__;return Om(t)?n[typeof t=="string"?"string":"hash"]:n.map}function wm(e){var t=as(this,e).delete(e);return this.size-=t?1:0,t}function bm(e){return as(this,e).get(e)}function Am(e){return as(this,e).has(e)}function Tm(e,t){var n=as(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function en(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}en.prototype.clear=vm;en.prototype.delete=wm;en.prototype.get=bm;en.prototype.has=Am;en.prototype.set=Tm;var ym="Expected a function";function pi(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(ym);var n=function(){var r=arguments,s=t?t.apply(this,r):r[0],i=n.cache;if(i.has(s))return i.get(s);var o=e.apply(this,r);return n.cache=i.set(s,o)||i,o};return n.cache=new(pi.Cache||en),n}pi.Cache=en;var Nm=500;function Mm(e){var t=pi(e,function(r){return n.size===Nm&&n.clear(),r}),n=t.cache;return t}var Dm=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Lm=/\\(\\)?/g,xm=Mm(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Dm,function(n,r,s,i){t.push(s?i.replace(Lm,"$1"):r||n)}),t});function Um(e){return e==null?"":wl(e)}function Fl(e,t){return Nn(e)?e:sm(e,t)?[e]:xm(Um(e))}function Bl(e){if(typeof e=="string"||ss(e))return e;var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function Pm(e,t){t=Fl(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[Bl(t[n++])];return n&&n==r?e:void 0}function $l(e,t,n){var r=e==null?void 0:Pm(e,t);return r===void 0?n:r}var Hl=Jg(Object.getPrototypeOf,Object),km="[object Object]",Fm=Function.prototype,Bm=Object.prototype,jl=Fm.toString,$m=Bm.hasOwnProperty,Hm=jl.call(Object);function jm(e){if(!Ln(e)||cr(e)!=km)return!1;var t=Hl(e);if(t===null)return!0;var n=$m.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&jl.call(n)==Hm}function Wm(){this.__data__=new jt,this.size=0}function Ym(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function zm(e){return this.__data__.get(e)}function Gm(e){return this.__data__.has(e)}var Vm=200;function Km(e,t){var n=this.__data__;if(n instanceof jt){var r=n.__data__;if(!kl||r.length<Vm-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new en(r)}return n.set(e,t),this.size=n.size,this}function xn(e){var t=this.__data__=new jt(e);this.size=t.size}xn.prototype.clear=Wm;xn.prototype.delete=Ym;xn.prototype.get=zm;xn.prototype.has=Gm;xn.prototype.set=Km;var Wl=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ho=Wl&&typeof module=="object"&&module&&!module.nodeType&&module,Xm=ho&&ho.exports===Wl,fo=Xm?dn.Buffer:void 0;fo&&fo.allocUnsafe;function qm(e,t){return e.slice()}var go=dn.Uint8Array;function Jm(e){var t=new e.constructor(e.byteLength);return new go(t).set(new go(e)),t}function Zm(e,t){var n=Jm(e.buffer);return new e.constructor(n,e.byteOffset,e.length)}function Qm(e){return typeof e.constructor=="function"&&!Nl(e)?qf(Hl(e)):{}}function e_(e){return function(t,n,r){for(var s=-1,i=Object(t),o=r(t),a=o.length;a--;){var l=o[++s];if(n(i[l],l,i)===!1)break}return t}}var t_=e_(),Es=function(){return dn.Date.now()},n_="Expected a function",r_=Math.max,s_=Math.min;function i_(e,t,n){var r,s,i,o,a,l,u=0,c=!1,h=!1,d=!0;if(typeof e!="function")throw new TypeError(n_);t=no(t)||0,wt(n)&&(c=!!n.leading,h="maxWait"in n,i=h?r_(no(n.maxWait)||0,t):i,d="trailing"in n?!!n.trailing:d);function f(A){var j=r,Z=s;return r=s=void 0,u=A,o=e.apply(Z,j),o}function p(A){return u=A,a=setTimeout(N,t),c?f(A):o}function R(A){var j=A-l,Z=A-u,fe=t-j;return h?s_(fe,i-Z):fe}function w(A){var j=A-l,Z=A-u;return l===void 0||j>=t||j<0||h&&Z>=i}function N(){var A=Es();if(w(A))return G(A);a=setTimeout(N,R(A))}function G(A){return a=void 0,d&&r?f(A):(r=s=void 0,o)}function W(){a!==void 0&&clearTimeout(a),u=0,r=l=s=a=void 0}function se(){return a===void 0?o:G(Es())}function y(){var A=Es(),j=w(A);if(r=arguments,s=this,l=A,j){if(a===void 0)return p(l);if(h)return clearTimeout(a),a=setTimeout(N,t),f(l)}return a===void 0&&(a=setTimeout(N,t)),o}return y.cancel=W,y.flush=se,y}function Ws(e,t,n){(n!==void 0&&!is(e[t],n)||n===void 0&&!(t in e))&&mi(e,t,n)}function o_(e){return Ln(e)&&_i(e)}function Ys(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}function a_(e){return cg(e,Pl(e))}function l_(e,t,n,r,s,i,o){var a=Ys(e,n),l=Ys(t,n),u=o.get(l);if(u){Ws(e,n,u);return}var c=i?i(a,l,n+"",e,t,o):void 0,h=c===void 0;if(h){var d=Nn(l),f=!d&&Ll(l),p=!d&&!f&&Ul(l);c=l,d||f||p?Nn(a)?c=a:o_(a)?c=Zf(a):f?(h=!1,c=qm(l)):p?(h=!1,c=Zm(l)):c=[]:jm(l)||js(l)?(c=a,js(a)?c=a_(a):(!wt(a)||di(a))&&(c=Qm(l))):h=!1}h&&(o.set(l,c),s(c,l,r,i,o),o.delete(l)),Ws(e,n,c)}function Ei(e,t,n,r,s){e!==t&&t_(t,function(i,o){if(s||(s=new xn),wt(i))l_(e,t,o,n,Ei,r,s);else{var a=r?r(Ys(e,o),i,o+"",e,t,s):void 0;a===void 0&&(a=i),Ws(e,o,a)}},Pl)}var u_=yl(function(e,t,n,r){Ei(e,t,n,r)}),Ci=yl(function(e,t,n){Ei(e,t,n)});function c_(e,t,n,r){if(!wt(e))return e;t=Fl(t,e);for(var s=-1,i=t.length,o=i-1,a=e;a!=null&&++s<i;){var l=Bl(t[s]),u=n;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=o){var c=a[l];u=void 0,u===void 0&&(u=wt(c)?c:gi(t[s+1])?[]:{})}Al(a,l,u),a=a[l]}return e}function h_(e,t,n){return e==null?e:c_(e,t,n)}var Cs,mo;function d_(){if(mo)return Cs;mo=1;var e=-1,t=1,n=0;function r(_,H,v,D,b){if(_===H)return _?[[n,_]]:[];if(v!=null){var O=fe(_,H,v);if(O)return O}var k=a(_,H),B=_.substring(0,k);_=_.substring(k),H=H.substring(k),k=u(_,H);var V=_.substring(_.length-k);_=_.substring(0,_.length-k),H=H.substring(0,H.length-k);var ie=s(_,H);return B&&ie.unshift([n,B]),V&&ie.push([n,V]),G(ie,b),D&&h(ie),ie}function s(_,H){var v;if(!_)return[[t,H]];if(!H)return[[e,_]];var D=_.length>H.length?_:H,b=_.length>H.length?H:_,O=D.indexOf(b);if(O!==-1)return v=[[t,D.substring(0,O)],[n,b],[t,D.substring(O+b.length)]],_.length>H.length&&(v[0][0]=v[2][0]=e),v;if(b.length===1)return[[e,_],[t,H]];var k=c(_,H);if(k){var B=k[0],V=k[1],ie=k[2],de=k[3],ge=k[4],ye=r(B,ie),Ae=r(V,de);return ye.concat([[n,ge]],Ae)}return i(_,H)}function i(_,H){for(var v=_.length,D=H.length,b=Math.ceil((v+D)/2),O=b,k=2*b,B=new Array(k),V=new Array(k),ie=0;ie<k;ie++)B[ie]=-1,V[ie]=-1;B[O+1]=0,V[O+1]=0;for(var de=v-D,ge=de%2!==0,ye=0,Ae=0,S=0,F=0,K=0;K<b;K++){for(var q=-K+ye;q<=K-Ae;q+=2){var z=O+q,Y;q===-K||q!==K&&B[z-1]<B[z+1]?Y=B[z+1]:Y=B[z-1]+1;for(var ue=Y-q;Y<v&&ue<D&&_.charAt(Y)===H.charAt(ue);)Y++,ue++;if(B[z]=Y,Y>v)Ae+=2;else if(ue>D)ye+=2;else if(ge){var ae=O+de-q;if(ae>=0&&ae<k&&V[ae]!==-1){var $=v-V[ae];if(Y>=$)return o(_,H,Y,ue)}}}for(var te=-K+S;te<=K-F;te+=2){var ae=O+te,$;te===-K||te!==K&&V[ae-1]<V[ae+1]?$=V[ae+1]:$=V[ae-1]+1;for(var oe=$-te;$<v&&oe<D&&_.charAt(v-$-1)===H.charAt(D-oe-1);)$++,oe++;if(V[ae]=$,$>v)F+=2;else if(oe>D)S+=2;else if(!ge){var z=O+de-te;if(z>=0&&z<k&&B[z]!==-1){var Y=B[z],ue=O+Y-z;if($=v-$,Y>=$)return o(_,H,Y,ue)}}}}return[[e,_],[t,H]]}function o(_,H,v,D){var b=_.substring(0,v),O=H.substring(0,D),k=_.substring(v),B=H.substring(D),V=r(b,O),ie=r(k,B);return V.concat(ie)}function a(_,H){if(!_||!H||_.charAt(0)!==H.charAt(0))return 0;for(var v=0,D=Math.min(_.length,H.length),b=D,O=0;v<b;)_.substring(O,b)==H.substring(O,b)?(v=b,O=v):D=b,b=Math.floor((D-v)/2+v);return W(_.charCodeAt(b-1))&&b--,b}function l(_,H){var v=_.length,D=H.length;if(v==0||D==0)return 0;v>D?_=_.substring(v-D):v<D&&(H=H.substring(0,v));var b=Math.min(v,D);if(_==H)return b;for(var O=0,k=1;;){var B=_.substring(b-k),V=H.indexOf(B);if(V==-1)return O;k+=V,(V==0||_.substring(b-k)==H.substring(0,k))&&(O=k,k++)}}function u(_,H){if(!_||!H||_.slice(-1)!==H.slice(-1))return 0;for(var v=0,D=Math.min(_.length,H.length),b=D,O=0;v<b;)_.substring(_.length-b,_.length-O)==H.substring(H.length-b,H.length-O)?(v=b,O=v):D=b,b=Math.floor((D-v)/2+v);return se(_.charCodeAt(_.length-b))&&b--,b}function c(_,H){var v=_.length>H.length?_:H,D=_.length>H.length?H:_;if(v.length<4||D.length*2<v.length)return null;function b(Ae,S,F){for(var K=Ae.substring(F,F+Math.floor(Ae.length/4)),q=-1,z="",Y,ue,ae,$;(q=S.indexOf(K,q+1))!==-1;){var te=a(Ae.substring(F),S.substring(q)),oe=u(Ae.substring(0,F),S.substring(0,q));z.length<oe+te&&(z=S.substring(q-oe,q)+S.substring(q,q+te),Y=Ae.substring(0,F-oe),ue=Ae.substring(F+te),ae=S.substring(0,q-oe),$=S.substring(q+te))}return z.length*2>=Ae.length?[Y,ue,ae,$,z]:null}var O=b(v,D,Math.ceil(v.length/4)),k=b(v,D,Math.ceil(v.length/2)),B;if(!O&&!k)return null;k?O?B=O[4].length>k[4].length?O:k:B=k:B=O;var V,ie,de,ge;_.length>H.length?(V=B[0],ie=B[1],de=B[2],ge=B[3]):(de=B[0],ge=B[1],V=B[2],ie=B[3]);var ye=B[4];return[V,ie,de,ge,ye]}function h(_){for(var H=!1,v=[],D=0,b=null,O=0,k=0,B=0,V=0,ie=0;O<_.length;)_[O][0]==n?(v[D++]=O,k=V,B=ie,V=0,ie=0,b=_[O][1]):(_[O][0]==t?V+=_[O][1].length:ie+=_[O][1].length,b&&b.length<=Math.max(k,B)&&b.length<=Math.max(V,ie)&&(_.splice(v[D-1],0,[e,b]),_[v[D-1]+1][0]=t,D--,D--,O=D>0?v[D-1]:-1,k=0,B=0,V=0,ie=0,b=null,H=!0)),O++;for(H&&G(_),N(_),O=1;O<_.length;){if(_[O-1][0]==e&&_[O][0]==t){var de=_[O-1][1],ge=_[O][1],ye=l(de,ge),Ae=l(ge,de);ye>=Ae?(ye>=de.length/2||ye>=ge.length/2)&&(_.splice(O,0,[n,ge.substring(0,ye)]),_[O-1][1]=de.substring(0,de.length-ye),_[O+1][1]=ge.substring(ye),O++):(Ae>=de.length/2||Ae>=ge.length/2)&&(_.splice(O,0,[n,de.substring(0,Ae)]),_[O-1][0]=t,_[O-1][1]=ge.substring(0,ge.length-Ae),_[O+1][0]=e,_[O+1][1]=de.substring(Ae),O++),O++}O++}}var d=/[^a-zA-Z0-9]/,f=/\s/,p=/[\r\n]/,R=/\n\r?\n$/,w=/^\r?\n\r?\n/;function N(_){function H(Ae,S){if(!Ae||!S)return 6;var F=Ae.charAt(Ae.length-1),K=S.charAt(0),q=F.match(d),z=K.match(d),Y=q&&F.match(f),ue=z&&K.match(f),ae=Y&&F.match(p),$=ue&&K.match(p),te=ae&&Ae.match(R),oe=$&&S.match(w);return te||oe?5:ae||$?4:q&&!Y&&ue?3:Y||ue?2:q||z?1:0}for(var v=1;v<_.length-1;){if(_[v-1][0]==n&&_[v+1][0]==n){var D=_[v-1][1],b=_[v][1],O=_[v+1][1],k=u(D,b);if(k){var B=b.substring(b.length-k);D=D.substring(0,D.length-k),b=B+b.substring(0,b.length-k),O=B+O}for(var V=D,ie=b,de=O,ge=H(D,b)+H(b,O);b.charAt(0)===O.charAt(0);){D+=b.charAt(0),b=b.substring(1)+O.charAt(0),O=O.substring(1);var ye=H(D,b)+H(b,O);ye>=ge&&(ge=ye,V=D,ie=b,de=O)}_[v-1][1]!=V&&(V?_[v-1][1]=V:(_.splice(v-1,1),v--),_[v][1]=ie,de?_[v+1][1]=de:(_.splice(v+1,1),v--))}v++}}function G(_,H){_.push([n,""]);for(var v=0,D=0,b=0,O="",k="",B;v<_.length;){if(v<_.length-1&&!_[v][1]){_.splice(v,1);continue}switch(_[v][0]){case t:b++,k+=_[v][1],v++;break;case e:D++,O+=_[v][1],v++;break;case n:var V=v-b-D-1;if(H){if(V>=0&&A(_[V][1])){var ie=_[V][1].slice(-1);if(_[V][1]=_[V][1].slice(0,-1),O=ie+O,k=ie+k,!_[V][1]){_.splice(V,1),v--;var de=V-1;_[de]&&_[de][0]===t&&(b++,k=_[de][1]+k,de--),_[de]&&_[de][0]===e&&(D++,O=_[de][1]+O,de--),V=de}}if(y(_[v][1])){var ie=_[v][1].charAt(0);_[v][1]=_[v][1].slice(1),O+=ie,k+=ie}}if(v<_.length-1&&!_[v][1]){_.splice(v,1);break}if(O.length>0||k.length>0){O.length>0&&k.length>0&&(B=a(k,O),B!==0&&(V>=0?_[V][1]+=k.substring(0,B):(_.splice(0,0,[n,k.substring(0,B)]),v++),k=k.substring(B),O=O.substring(B)),B=u(k,O),B!==0&&(_[v][1]=k.substring(k.length-B)+_[v][1],k=k.substring(0,k.length-B),O=O.substring(0,O.length-B)));var ge=b+D;O.length===0&&k.length===0?(_.splice(v-ge,ge),v=v-ge):O.length===0?(_.splice(v-ge,ge,[t,k]),v=v-ge+1):k.length===0?(_.splice(v-ge,ge,[e,O]),v=v-ge+1):(_.splice(v-ge,ge,[e,O],[t,k]),v=v-ge+2)}v!==0&&_[v-1][0]===n?(_[v-1][1]+=_[v][1],_.splice(v,1)):v++,b=0,D=0,O="",k="";break}}_[_.length-1][1]===""&&_.pop();var ye=!1;for(v=1;v<_.length-1;)_[v-1][0]===n&&_[v+1][0]===n&&(_[v][1].substring(_[v][1].length-_[v-1][1].length)===_[v-1][1]?(_[v][1]=_[v-1][1]+_[v][1].substring(0,_[v][1].length-_[v-1][1].length),_[v+1][1]=_[v-1][1]+_[v+1][1],_.splice(v-1,1),ye=!0):_[v][1].substring(0,_[v+1][1].length)==_[v+1][1]&&(_[v-1][1]+=_[v+1][1],_[v][1]=_[v][1].substring(_[v+1][1].length)+_[v+1][1],_.splice(v+1,1),ye=!0)),v++;ye&&G(_,H)}function W(_){return _>=55296&&_<=56319}function se(_){return _>=56320&&_<=57343}function y(_){return se(_.charCodeAt(0))}function A(_){return W(_.charCodeAt(_.length-1))}function j(_){for(var H=[],v=0;v<_.length;v++)_[v][1].length>0&&H.push(_[v]);return H}function Z(_,H,v,D){return A(_)||y(D)?null:j([[n,_],[e,H],[t,v],[n,D]])}function fe(_,H,v){var D=typeof v=="number"?{index:v,length:0}:v.oldRange,b=typeof v=="number"?null:v.newRange,O=_.length,k=H.length;if(D.length===0&&(b===null||b.length===0)){var B=D.index,V=_.slice(0,B),ie=_.slice(B),de=b?b.index:null;e:{var ge=B+k-O;if(de!==null&&de!==ge||ge<0||ge>k)break e;var ye=H.slice(0,ge),Ae=H.slice(ge);if(Ae!==ie)break e;var S=Math.min(B,ge),F=V.slice(0,S),K=ye.slice(0,S);if(F!==K)break e;var q=V.slice(S),z=ye.slice(S);return Z(F,q,z,ie)}e:{if(de!==null&&de!==B)break e;var Y=B,ye=H.slice(0,Y),Ae=H.slice(Y);if(ye!==V)break e;var ue=Math.min(O-Y,k-Y),ae=ie.slice(ie.length-ue),$=Ae.slice(Ae.length-ue);if(ae!==$)break e;var q=ie.slice(0,ie.length-ue),z=Ae.slice(0,Ae.length-ue);return Z(V,q,z,ae)}}if(D.length>0&&b&&b.length===0)e:{var F=_.slice(0,D.index),ae=_.slice(D.index+D.length),S=F.length,ue=ae.length;if(k<S+ue)break e;var K=H.slice(0,S),$=H.slice(k-ue);if(F!==K||ae!==$)break e;var q=_.slice(S,O-ue),z=H.slice(S,k-ue);return Z(F,q,z,ae)}return null}function le(_,H,v,D){return r(_,H,v,D,!0)}return le.INSERT=t,le.DELETE=e,le.EQUAL=n,Cs=le,Cs}var f_=d_();const Ri=Ct(f_),g_=new Set(["true","false"]);function m_(e){return g_.has(e.toLowerCase())}var Rs,_o;function __(){if(_o)return Rs;_o=1;var e=function(t){if(t=t||{},this.Promise=t.Promise||Promise,this.queues=Object.create(null),this.domainReentrant=t.domainReentrant||!1,this.domainReentrant){if(typeof process>"u"||typeof process.domain>"u")throw new Error("Domain-reentrant locks require `process.domain` to exist. Please flip `opts.domainReentrant = false`, use a NodeJS version that still implements Domain, or install a browser polyfill.");this.domains=Object.create(null)}this.timeout=t.timeout||e.DEFAULT_TIMEOUT,this.maxOccupationTime=t.maxOccupationTime||e.DEFAULT_MAX_OCCUPATION_TIME,this.maxExecutionTime=t.maxExecutionTime||e.DEFAULT_MAX_EXECUTION_TIME,t.maxPending===1/0||Number.isInteger(t.maxPending)&&t.maxPending>=0?this.maxPending=t.maxPending:this.maxPending=e.DEFAULT_MAX_PENDING};return e.DEFAULT_TIMEOUT=0,e.DEFAULT_MAX_OCCUPATION_TIME=0,e.DEFAULT_MAX_EXECUTION_TIME=0,e.DEFAULT_MAX_PENDING=1e3,e.prototype.acquire=function(t,n,r,s){if(Array.isArray(t))return this._acquireBatch(t,n,r,s);if(typeof n!="function")throw new Error("You must pass a function to execute");var i=null,o=null,a=null;typeof r!="function"&&(s=r,r=null,a=new this.Promise(function(W,se){i=W,o=se})),s=s||{};var l=!1,u=null,c=null,h=null,d=this,f=function(W,se,y){c&&(clearTimeout(c),c=null),h&&(clearTimeout(h),h=null),W&&(d.queues[t]&&d.queues[t].length===0&&delete d.queues[t],d.domainReentrant&&delete d.domains[t]),l||(a?se?o(se):i(y):typeof r=="function"&&r(se,y),l=!0),W&&d.queues[t]&&d.queues[t].length>0&&d.queues[t].shift()()},p=function(W){if(l)return f(W);u&&(clearTimeout(u),u=null),d.domainReentrant&&W&&(d.domains[t]=process.domain);var se=s.maxExecutionTime||d.maxExecutionTime;if(se&&(h=setTimeout(function(){d.queues[t]&&f(W,new Error("Maximum execution time is exceeded "+t))},se)),n.length===1){var y=!1;try{n(function(A,j){y||(y=!0,f(W,A,j))})}catch(A){y||(y=!0,f(W,A))}}else d._promiseTry(function(){return n()}).then(function(A){f(W,void 0,A)},function(A){f(W,A)})};d.domainReentrant&&process.domain&&(p=process.domain.bind(p));var R=s.maxPending||d.maxPending;if(!d.queues[t])d.queues[t]=[],p(!0);else if(d.domainReentrant&&process.domain&&process.domain===d.domains[t])p(!1);else if(d.queues[t].length>=R)f(!1,new Error("Too many pending tasks in queue "+t));else{var w=function(){p(!0)};s.skipQueue?d.queues[t].unshift(w):d.queues[t].push(w);var N=s.timeout||d.timeout;N&&(u=setTimeout(function(){u=null,f(!1,new Error("async-lock timed out in queue "+t))},N))}var G=s.maxOccupationTime||d.maxOccupationTime;if(G&&(c=setTimeout(function(){d.queues[t]&&f(!1,new Error("Maximum occupation time is exceeded in queue "+t))},G)),a)return a},e.prototype._acquireBatch=function(t,n,r,s){typeof r!="function"&&(s=r,r=null);var i=this,o=function(l,u){return function(c){i.acquire(l,u,c,s)}},a=t.reduceRight(function(l,u){return o(u,l)},n);if(typeof r=="function")a(r);else return new this.Promise(function(l,u){a.length===1?a(function(c,h){c?u(c):l(h)}):l(a())})},e.prototype.isBusy=function(t){return t?!!this.queues[t]:Object.keys(this.queues).length>0},e.prototype._promiseTry=function(t){try{return this.Promise.resolve(t())}catch(n){return this.Promise.reject(n)}},Rs=e,Rs}var Is,po;function p_(){return po||(po=1,Is=__()),Is}var E_=p_();const C_=Ct(E_);function Yl(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||!e||typeof t!="object"||!t)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;const s=Object.prototype.hasOwnProperty.bind(t);for(let i=0;i<n.length;i++){const o=n[i];if(!s(o))return!1;const a=e[o],l=t[o];if(a!==l)return!1}return!0}var Be=(e=>(e[e.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",e[e.UNIVER_DOC=1]="UNIVER_DOC",e[e.UNIVER_SHEET=2]="UNIVER_SHEET",e[e.UNIVER_SLIDE=3]="UNIVER_SLIDE",e[e.UNIVER_PROJECT=4]="UNIVER_PROJECT",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Be||{}),xt=(e=>(e[e.Reader=0]="Reader",e[e.Editor=1]="Editor",e[e.Owner=2]="Owner",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(xt||{}),zs=(e=>(e[e.SomeCollaborator=0]="SomeCollaborator",e[e.AllCollaborator=1]="AllCollaborator",e[e.OneSelf=2]="OneSelf",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(zs||{});class ls extends st{}function R_(e=ne.generateRandomId(6),t=or.EN_US,n=""){return{id:e,locale:t,title:n,tableSource:{},drawings:{},drawingsOrder:[],headers:{},footers:{},body:{dataStream:`\r
|
|
6
6
|
`,textRuns:[],customBlocks:[],tables:[],paragraphs:[{startIndex:0,paragraphStyle:{spaceAbove:{v:5},lineSpacing:1,spaceBelow:{v:0}}}],sectionBreaks:[{startIndex:1}]},documentStyle:{pageSize:{width:793.3333333333334,height:1122.6666666666667},documentFlavor:ui.TRADITIONAL,marginTop:50,marginBottom:50,marginRight:50,marginLeft:50,renderConfig:{zeroWidthParagraphBreak:Ie.FALSE,vertexAngle:0,centerAngle:0,background:{rgb:"#ccc"}},autoHyphenation:Ie.TRUE,doNotHyphenateCaps:Ie.FALSE,consecutiveHyphenLimit:2,defaultHeaderId:"",defaultFooterId:"",evenPageHeaderId:"",evenPageFooterId:"",firstPageHeaderId:"",firstPageFooterId:"",evenAndOddHeaders:Ie.FALSE,useFirstPageHeaderFooter:Ie.FALSE,marginHeader:30,marginFooter:30},settings:{}}}var nn={},kn={},Sr={},Eo;function I_(){if(Eo)return Sr;Eo=1,Object.defineProperty(Sr,"__esModule",{value:!0});function e(r,s){if(Array.isArray(s))return!1;for(let i in r)if(!n(r[i],s[i]))return!1;for(let i in s)if(r[i]===void 0)return!1;return!0}function t(r,s){if(!Array.isArray(s)||r.length!==s.length)return!1;for(let i=0;i<r.length;i++)if(!n(r[i],s[i]))return!1;return!0}function n(r,s){return r===s?!0:r===null||s===null||typeof r!="object"||typeof s!="object"?!1:Array.isArray(r)?t(r,s):e(r,s)}return Sr.default=n,Sr}var vr={},Co;function S_(){if(Co)return vr;Co=1,Object.defineProperty(vr,"__esModule",{value:!0});function e(t){if(t===null)return null;if(Array.isArray(t))return t.map(e);if(typeof t=="object"){const n={};for(let r in t)n[r]=e(t[r]);return n}else return t}return vr.default=e,vr}var Ss={},Ro;function zl(){return Ro||(Ro=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.eachChildOf=e.advancer=e.readCursor=e.writeCursor=e.WriteCursor=e.ReadCursor=e.isValidPathItem=void 0;function t(c,h){if(!c)throw new Error(h)}const n=c=>c!=null&&typeof c=="object"&&!Array.isArray(c),r=(c,h)=>typeof c==typeof h?c>h:typeof c=="string"&&typeof h=="number";function s(c,h){for(let d in c){const f=d;h.write(f,c[f])}}e.isValidPathItem=c=>typeof c=="number"||typeof c=="string"&&c!=="__proto__";class i{constructor(h=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=h}ascend(){t(this.parents.length===this.indexes.length/2),this.idx===0?this.parents.length?(this.lcIdx=this.indexes.pop(),this.container=this.parents.pop(),this.idx=this.indexes.pop()):(this.lcIdx=0,this.idx=-1):(t(this.idx>0),this.idx--,n(this.container[this.idx])&&this.idx--)}getPath(){const h=[];let d=this.container,f=this.parents.length-1,p=this.idx;for(;p>=0;)h.unshift(d[p]),p===0?(p=this.indexes[f*2],d=this.parents[f--]):p-=n(d[p-1])?2:1;return h}}class o extends i{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return t(this.container!=null,"Invalid call to getKey before cursor descended"),this.container[this.idx]}getComponent(){let h;return this.container&&this.container.length>this.idx+1&&n(h=this.container[this.idx+1])?h:null}descendFirst(){let h=this.idx+1;if(!this.container||h>=this.container.length||n(this.container[h])&&h+1>=this.container.length)return!1;n(this.container[h])&&h++;const d=this.container[h];return Array.isArray(d)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(h),this.idx=0,this.container=d):this.idx=h,!0}nextSibling(){if(t(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;const h=this.indexes[this.indexes.length-1]+1,d=this.parents[this.parents.length-1];return h>=d.length?!1:(t(!isNaN(h)),this.indexes[this.indexes.length-1]=h,this.container=d[h],!0)}_init(h,d,f,p){this.container=h,this.idx=d,this.parents=f.slice(),this.indexes=p.slice()}clone(){const h=new o;return h._init(this.container,this.idx,this.parents,this.indexes),h}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(h,d){const f=this.getComponent();f&&d(f,h);for(const p of this)h&&h.descend(p),this.traverse(h,d),h&&h.ascend()}eachPick(h,d){this.traverse(h,(f,p)=>{f.p!=null&&d(f.p,p)})}eachDrop(h,d){this.traverse(h,(f,p)=>{f.d!=null&&d(f.d,p)})}}e.ReadCursor=o;class a extends i{constructor(h=null){super(h),this.pendingDescent=[],this._op=h}flushDescent(){t(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let h=0;h<this.pendingDescent.length;h++){const d=this.pendingDescent[h];let f=this.idx+1;if(f<this.container.length&&n(this.container[f])&&f++,t(f===this.container.length||!n(this.container[f])),f===this.container.length)this.container.push(d),this.idx=f;else if(this.container[f]===d)this.idx=f;else{if(!Array.isArray(this.container[f])){const p=this.container.splice(f,this.container.length-f);this.container.push(p),this.lcIdx>-1&&(this.lcIdx=f)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(t(r(d,this.container[this.lcIdx][0])),f=this.lcIdx+1,this.lcIdx=-1);f<this.container.length&&r(d,this.container[f][0]);)f++;if(this.indexes.push(f),this.idx=0,f<this.container.length&&this.container[f][0]===d)this.container=this.container[f];else{const p=[d];this.container.splice(f,0,p),this.container=p}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const h=this.idx+1;if(h<this.container.length&&n(this.container[h]))return this.container[h];{const d={};return this.container.splice(h,0,d),d}}write(h,d){const f=this.getComponent();t(f[h]==null||f[h]===d,"Internal consistency error: Overwritten component. File a bug"),f[h]=d}get(){return this._op}descend(h){if(!e.isValidPathItem(h))throw Error("Invalid JSON key");this.pendingDescent.push(h)}descendPath(h){return this.pendingDescent.push(...h),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(h,d=s){if(h===null)return;if(t(Array.isArray(h)),h===this._op)throw Error("Cannot merge into my own tree");const f=this.lcIdx,p=this.parents.length;let R=0;for(let w=0;w<h.length;w++){const N=h[w];typeof N=="string"||typeof N=="number"?(R++,this.descend(N)):Array.isArray(N)?this.mergeTree(N,d):typeof N=="object"&&d(N,this)}for(;R--;)this.ascend();this.lcIdx=this.parents.length===p?f:-1}at(h,d){this.descendPath(h),d(this);for(let f=0;f<h.length;f++)this.ascend();return this}writeAtPath(h,d,f){return this.at(h,()=>this.write(d,f)),this.reset(),this}writeMove(h,d,f=0){return this.writeAtPath(h,"p",f).writeAtPath(d,"d",f)}getPath(){const h=super.getPath();return h.push(...this.pendingDescent),h}}e.WriteCursor=a,e.writeCursor=()=>new a,e.readCursor=c=>new o(c);function l(c,h,d){let f,p;p=f=c?c.descendFirst():!1;function R(w){let N;for(;p;){const G=N=c.getKey();if(w!=null){let W=!1;if(h&&typeof G=="number"&&(N=h(G,c.getComponent()),N<0&&(N=~N,W=!0)),r(N,w))return null;if(N===w&&!W)return c}d&&typeof N=="number"&&d(N,c.getComponent()),p=c.nextSibling()}return null}return R.end=()=>{f&&c.ascend()},R}e.advancer=l;function u(c,h,d){let f,p,R,w;for(f=p=c&&c.descendFirst(),R=w=h&&h.descendFirst();f||R;){let N=f?c.getKey():null,G=R?h.getKey():null;N!==null&&G!==null&&(r(G,N)?G=null:N!==G&&(N=null)),d(N==null?G:N,N!=null?c:null,G!=null?h:null),N!=null&&f&&(f=c.nextSibling()),G!=null&&R&&(R=h.nextSibling())}p&&c.ascend(),w&&h.ascend()}e.eachChildOf=u}(Ss)),Ss}var vs={},Io;function Gl(){return Io||(Io=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ConflictType=void 0,function(t){t[t.RM_UNEXPECTED_CONTENT=1]="RM_UNEXPECTED_CONTENT",t[t.DROP_COLLISION=2]="DROP_COLLISION",t[t.BLACKHOLE=3]="BLACKHOLE"}(e.ConflictType||(e.ConflictType={}))}(vs)),vs}var At={},rn={},So;function Ii(){return So||(So=1,Object.defineProperty(rn,"__esModule",{value:!0}),rn.uniToStrPos=rn.strPosToUni=void 0,rn.strPosToUni=(e,t=e.length)=>{let n=0,r=0;for(;r<t;r++){const s=e.charCodeAt(r);s>=55296&&s<=57343&&(n++,r++)}if(r!==t)throw Error("Invalid offset - splits unicode bytes");return r-n},rn.uniToStrPos=(e,t)=>{let n=0;for(;t>0;t--){const r=e.charCodeAt(n);n+=r>=55296&&r<=57343?2:1}return n}),rn}var Os={},vo;function Gs(){return vo||(vo=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.uniSlice=e.dlen=e.eachOp=void 0;const t=Ii(),n=y=>{if(!Array.isArray(y))throw Error("Op must be an array of components");let A=null;for(let j=0;j<y.length;j++){const Z=y[j];switch(typeof Z){case"object":if(typeof Z.d!="number"&&typeof Z.d!="string")throw Error("Delete must be number or string");if(e.dlen(Z.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(Z.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(Z>0))throw Error("Skip components must be >0");if(typeof A=="number")throw Error("Adjacent skip components should be combined");break}A=Z}if(typeof A=="number")throw Error("Op has a trailing skip")};function r(y,A){let j=0,Z=0;for(let fe=0;fe<y.length;fe++){const le=y[fe];switch(A(le,j,Z),typeof le){case"object":j+=e.dlen(le.d);break;case"string":Z+=t.strPosToUni(le);break;case"number":j+=le,Z+=le;break}}}e.eachOp=r;function s(y,A){const j=[],Z=a(j);return r(y,(fe,le,_)=>{Z(A(fe,le,_))}),h(j)}const i=y=>y,o=y=>s(y,i);e.dlen=y=>typeof y=="number"?y:t.strPosToUni(y);const a=y=>A=>{if(!(!A||A.d===0||A.d===""))if(y.length===0)y.push(A);else if(typeof A==typeof y[y.length-1])if(typeof A=="object"){const j=y[y.length-1];j.d=typeof j.d=="string"&&typeof A.d=="string"?j.d+A.d:e.dlen(j.d)+e.dlen(A.d)}else y[y.length-1]+=A;else y.push(A)},l=y=>typeof y=="number"?y:typeof y=="string"?t.strPosToUni(y):typeof y.d=="number"?y.d:t.strPosToUni(y.d);e.uniSlice=(y,A,j)=>{const Z=t.uniToStrPos(y,A),fe=j==null?1/0:t.uniToStrPos(y,j);return y.slice(Z,fe)};const u=(y,A,j)=>typeof y=="number"?j==null?y-A:Math.min(y,j)-A:e.uniSlice(y,A,j),c=y=>{let A=0,j=0;return{take:(le,_)=>{if(A===y.length)return le===-1?null:le;const H=y[A];let v;if(typeof H=="number")return le===-1||H-j<=le?(v=H-j,++A,j=0,v):(j+=le,le);if(typeof H=="string"){if(le===-1||_==="i"||t.strPosToUni(H.slice(j))<=le)return v=H.slice(j),++A,j=0,v;{const D=j+t.uniToStrPos(H.slice(j),le);return v=H.slice(j,D),j=D,v}}else{if(le===-1||_==="d"||e.dlen(H.d)-j<=le)return v={d:u(H.d,j)},++A,j=0,v;{let D=u(H.d,j,j+le);return j+=le,{d:D}}}},peek:()=>y[A]}},h=y=>(y.length>0&&typeof y[y.length-1]=="number"&&y.pop(),y);function d(y,A,j){if(j!=="left"&&j!=="right")throw Error("side ("+j+") must be 'left' or 'right'");n(y),n(A);const Z=[],fe=a(Z),{take:le,peek:_}=c(y);for(let v=0;v<A.length;v++){const D=A[v];let b,O;switch(typeof D){case"number":for(b=D;b>0;)O=le(b,"i"),fe(O),typeof O!="string"&&(b-=l(O));break;case"string":j==="left"&&typeof _()=="string"&&fe(le(-1)),fe(t.strPosToUni(D));break;case"object":for(b=e.dlen(D.d);b>0;)switch(O=le(b,"i"),typeof O){case"number":b-=O;break;case"string":fe(O);break;case"object":b-=e.dlen(O.d)}break}}let H;for(;H=le(-1);)fe(H);return h(Z)}function f(y,A){n(y),n(A);const j=[],Z=a(j),{take:fe}=c(y);for(let _=0;_<A.length;_++){const H=A[_];let v,D;switch(typeof H){case"number":for(v=H;v>0;)D=fe(v,"d"),Z(D),typeof D!="object"&&(v-=l(D));break;case"string":Z(H);break;case"object":v=e.dlen(H.d);let b=0;for(;b<v;)switch(D=fe(v-b,"d"),typeof D){case"number":Z({d:u(H.d,b,b+D)}),b+=D;break;case"string":b+=t.strPosToUni(D);break;case"object":Z(D)}break}}let le;for(;le=fe(-1);)Z(le);return h(j)}const p=(y,A)=>{let j=0;for(let Z=0;Z<A.length&&y>j;Z++){const fe=A[Z];switch(typeof fe){case"number":{j+=fe;break}case"string":const le=t.strPosToUni(fe);j+=le,y+=le;break;case"object":y-=Math.min(e.dlen(fe.d),y-j);break}}return y},R=(y,A)=>typeof y=="number"?p(y,A):y.map(j=>p(j,A));function w(y,A,j){return s(y,(Z,fe)=>typeof Z=="object"&&typeof Z.d=="number"?{d:j.slice(A,fe,fe+Z.d)}:Z)}function N(y){return s(y,A=>{switch(typeof A){case"object":if(typeof A.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return A.d;case"string":return{d:A};case"number":return A}})}function G(y){return s(y,A=>typeof A=="object"&&typeof A.d=="string"?{d:t.strPosToUni(A.d)}:A)}function W(y){let A=!0;return r(y,j=>{typeof j=="object"&&typeof j.d=="number"&&(A=!1)}),A}function se(y){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:h,normalize:o,checkOp:n,create(A=""){if(typeof A!="string")throw Error("Initial data must be a string");return y.create(A)},apply(A,j){n(j);const Z=y.builder(A);for(let fe=0;fe<j.length;fe++){const le=j[fe];switch(typeof le){case"number":Z.skip(le);break;case"string":Z.append(le);break;case"object":Z.del(e.dlen(le.d));break}}return Z.build()},transform:d,compose:f,transformPosition:p,transformSelection:R,isInvertible:W,makeInvertible(A,j){return w(A,j,y)},stripInvertible:G,invert:N,invertWithDoc(A,j){return N(w(A,j,y))},isNoop:A=>A.length===0}}e.default=se}(Os)),Os}var Or={},Oo;function v_(){if(Oo)return Or;Oo=1,Object.defineProperty(Or,"__esModule",{value:!0});const e=Gs(),t=Ii();function n(r,s){return{get:r,getLength(){return r().length},insert(i,o,a){const l=t.strPosToUni(r(),i);return s([l,o],a)},remove(i,o,a){const l=t.strPosToUni(r(),i);return s([l,{d:o}],a)},_onOp(i){e.eachOp(i,(o,a,l)=>{switch(typeof o){case"string":this.onInsert&&this.onInsert(l,o);break;case"object":const u=e.dlen(o.d);this.onRemove&&this.onRemove(l,u)}})},onInsert:null,onRemove:null}}return Or.default=n,n.provides={text:!0},Or}var wo;function O_(){return wo||(wo=1,function(e){var t=At&&At.__createBinding||(Object.create?function(d,f,p,R){R===void 0&&(R=p),Object.defineProperty(d,R,{enumerable:!0,get:function(){return f[p]}})}:function(d,f,p,R){R===void 0&&(R=p),d[R]=f[p]}),n=At&&At.__setModuleDefault||(Object.create?function(d,f){Object.defineProperty(d,"default",{enumerable:!0,value:f})}:function(d,f){d.default=f}),r=At&&At.__importStar||function(d){if(d&&d.__esModule)return d;var f={};if(d!=null)for(var p in d)Object.hasOwnProperty.call(d,p)&&t(f,d,p);return n(f,d),f},s=At&&At.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(e,"__esModule",{value:!0}),e.type=e.remove=e.insert=void 0;const i=Ii(),o=r(Gs()),a=s(v_()),l={create(d){return d},toString(d){return d},builder(d){if(typeof d!="string")throw Error("Invalid document snapshot: "+d);const f=[];return{skip(p){let R=i.uniToStrPos(d,p);if(R>d.length)throw Error("The op is too long for this document");f.push(d.slice(0,R)),d=d.slice(R)},append(p){f.push(p)},del(p){d=d.slice(i.uniToStrPos(d,p))},build(){return f.join("")+d}}},slice:o.uniSlice},u=o.default(l),c=Object.assign(Object.assign({},u),{api:a.default});e.type=c,e.insert=(d,f)=>f.length===0?[]:d===0?[f]:[d,f],e.remove=(d,f)=>o.dlen(f)===0?[]:d===0?[{d:f}]:[d,{d:f}];var h=Gs();Object.defineProperty(e,"makeType",{enumerable:!0,get:function(){return h.default}})}(At)),At}var bo;function w_(){return bo||(bo=1,function(e){var t=kn&&kn.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(e,"__esModule",{value:!0}),e.editOp=e.replaceOp=e.insertOp=e.moveOp=e.removeOp=e.type=void 0;const n=t(I_()),r=t(S_()),s=zl(),i=Gl();function o(S,F){if(!S)throw new Error(F)}e.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:s.readCursor,writeCursor:s.writeCursor,create:S=>S,isNoop:S=>S==null,setDebug(S){},registerSubtype:N,checkValidOp:fe,normalize:le,apply:_,transformPosition:H,compose:v,tryTransform:V,transform:de,makeInvertible:O,invert:D,invertWithDoc:k,RM_UNEXPECTED_CONTENT:i.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:i.ConflictType.DROP_COLLISION,BLACKHOLE:i.ConflictType.BLACKHOLE,transformNoConflict:(S,F,K)=>Ae(()=>!0,S,F,K),typeAllowingConflictsPred:S=>Object.assign(Object.assign({},e.type),{transform:(F,K,q)=>Ae(S,F,K,q)})};const a=S=>S?S.getComponent():null;function l(S){return S&&typeof S=="object"&&!Array.isArray(S)}const u=S=>Array.isArray(S)?S.slice():S!==null&&typeof S=="object"?Object.assign({},S):S,c=S=>S&&(S.p!=null||S.r!==void 0),h=S=>S&&(S.d!=null||S.i!==void 0);function d(S,F){return o(S!=null),typeof F=="number"?(o(Array.isArray(S),"Invalid key - child is not an array"),(S=S.slice()).splice(F,1)):(o(l(S),"Invalid key - child is not an object"),delete(S=Object.assign({},S))[F]),S}function f(S,F,K){return typeof F=="number"?(o(S!=null,"Container is missing for key"),o(Array.isArray(S),"Cannot use numerical key for object container"),o(S.length>=F,"Cannot insert into out of bounds index"),S.splice(F,0,K)):(o(l(S),"Cannot insert into missing item"),o(S[F]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),S[F]=K),K}e.removeOp=(S,F=!0)=>s.writeCursor().writeAtPath(S,"r",F).get(),e.moveOp=(S,F)=>s.writeCursor().writeMove(S,F).get(),e.insertOp=(S,F)=>s.writeCursor().writeAtPath(S,"i",F).get(),e.replaceOp=(S,F,K)=>s.writeCursor().at(S,q=>{q.write("r",F),q.write("i",K)}).get(),e.editOp=(S,F,K,q=!1)=>s.writeCursor().at(S,z=>A(z,F,K,q)).get();const p=(S,F)=>S!=null&&(typeof F=="number"?Array.isArray(S):typeof S=="object"),R=(S,F)=>p(S,F)?S[F]:void 0,w={};function N(S){let F=S.type?S.type:S;F.name&&(w[F.name]=F),F.uri&&(w[F.uri]=F)}const G=S=>{const F=w[S];if(F)return F;throw Error("Missing type: "+S)};N(O_());const W=(S,F)=>S+F;N({name:"number",apply:W,compose:W,invert:S=>-S,transform:S=>S});const se=S=>S==null?null:S.et?G(S.et):S.es?w["text-unicode"]:S.ena!=null?w.number:null,y=S=>S.es?S.es:S.ena!=null?S.ena:S.e,A=(S,F,K,q=!1)=>{const[z,Y]=typeof F=="string"?[G(F),F]:[F,F.name];!q&&z.isNoop&&z.isNoop(K)||(Y==="number"?S.write("ena",K):Y==="text-unicode"?S.write("es",K):(S.write("et",Y),S.write("e",K)))};function j(S){o(typeof S=="number"),o(S>=0),o(S===(0|S))}function Z(S){typeof S=="number"?j(S):o(typeof S=="string")}function fe(S){if(S===null)return;const F=new Set,K=new Set,q=Y=>{let ue=!0,ae=!1;for(let $ in Y){const te=Y[$];if(ue=!1,o($==="p"||$==="r"||$==="d"||$==="i"||$==="e"||$==="es"||$==="ena"||$==="et","Invalid component item '"+$+"'"),$==="p")j(te),o(!F.has(te)),F.add(te),o(Y.r===void 0);else if($==="d")j(te),o(!K.has(te)),K.add(te),o(Y.i===void 0);else if($==="e"||$==="es"||$==="ena"){o(!ae),ae=!0;const oe=se(Y);o(oe,"Missing type in edit"),oe.checkValidOp&&oe.checkValidOp(y(Y))}}o(!ue)},z=(Y,ue,ae)=>{if(!Array.isArray(Y))throw Error("Op must be null or a list");if(Y.length===0)throw Error("Empty descent");ue||Z(Y[0]);let $=1,te=0,oe=0;for(let me=0;me<Y.length;me++){const be=Y[me];if(o(be!=null),Array.isArray(be)){const De=z(be,!1);if(te){const X=typeof oe,Re=typeof De;X===Re?o(oe<De,"descent keys are not in order"):o(X==="number"&&Re==="string")}oe=De,te++,$=3}else typeof be=="object"?(o($===1,`Prev not scalar - instead ${$}`),q(be),$=2):(o($!==3),Z(be),o(s.isValidPathItem(be),"Invalid path key"),$=1)}return o(te!==1,"Operation makes multiple descents. Remove some []"),o($===2||$===3),Y[0]};z(S,!0),o(F.size===K.size,"Mismatched picks and drops in op");for(let Y=0;Y<F.size;Y++)o(F.has(Y)),o(K.has(Y))}function le(S){let F=0,K=[];const q=s.writeCursor();return q.mergeTree(S,(z,Y)=>{const ue=se(z);if(ue){const $=y(z);A(Y,ue,ue.normalize?ue.normalize($):$)}for(const $ of["r","p","i","d"])if(z[$]!==void 0){const te=$==="p"||$==="d"?(ae=z[$],K[ae]==null&&(K[ae]=F++),K[ae]):z[$];Y.write($,te)}var ae}),q.get()}function _(S,F){if(fe(F),F===null)return S;const K=[];return function q(z,Y){let ue=z,ae=0,$={root:z},te=0,oe=$,me="root";function be(){for(;te<ae;te++){let De=Y[te];typeof De!="object"&&(o(p(oe,me)),oe=oe[me]=u(oe[me]),me=De)}}for(;ae<Y.length;ae++){const De=Y[ae];if(Array.isArray(De)){const X=q(ue,De);X!==ue&&X!==void 0&&(be(),ue=oe[me]=X)}else if(typeof De=="object"){De.d!=null?(be(),ue=f(oe,me,K[De.d])):De.i!==void 0&&(be(),ue=f(oe,me,De.i));const X=se(De);if(X)be(),ue=oe[me]=X.apply(ue,y(De));else if(De.e!==void 0)throw Error("Subtype "+De.et+" undefined")}else ue=R(ue,De)}return $.root}(S=function q(z,Y){const ue=[];let ae=0;for(;ae<Y.length;ae++){const me=Y[ae];if(Array.isArray(me))break;typeof me!="object"&&(ue.push(z),z=R(z,me))}for(let me=Y.length-1;me>=ae;me--)z=q(z,Y[me]);for(--ae;ae>=0;ae--){const me=Y[ae];if(typeof me!="object"){const be=ue.pop();z=z===R(be,me)?be:z===void 0?d(be,me):(te=me,oe=z,($=u($=be))[te]=oe,$)}else c(me)&&(o(z!==void 0,"Cannot pick up or remove undefined"),me.p!=null&&(K[me.p]=z),z=void 0)}var $,te,oe;return z}(S,F),F)}function H(S,F){S=S.slice(),fe(F);const K=s.readCursor(F);let q,z,Y=!1;const ue=[];for(let $=0;;$++){const te=S[$],oe=K.getComponent();if(oe&&(oe.r!==void 0?Y=!0:oe.p!=null&&(Y=!1,q=oe.p,z=$)),$>=S.length)break;let me=0;const be=s.advancer(K,void 0,(X,Re)=>{c(Re)&&me++});ue.unshift(be);const De=be(te);if(typeof te=="number"&&(S[$]-=me),!De)break}if(ue.forEach($=>$.end()),Y)return null;const ae=()=>{let $=0;if(q!=null){const te=K.getPath();$=te.length,S=te.concat(S.slice(z))}for(;$<S.length;$++){const te=S[$],oe=a(K),me=se(oe);if(me){const X=y(oe);me.transformPosition&&(S[$]=me.transformPosition(S[$],X));break}let be=0;const De=s.advancer(K,(X,Re)=>h(Re)?~(X-be):X-be,(X,Re)=>{h(Re)&&be++})(te);if(typeof te=="number"&&(S[$]+=be),!De)break}};return q!=null?K.eachDrop(null,$=>{$===q&&ae()}):ae(),S}function v(S,F){if(fe(S),fe(F),S==null)return F;if(F==null)return S;let K=0;const q=s.readCursor(S),z=s.readCursor(F),Y=s.writeCursor(),ue=[],ae=[],$=[],te=[],oe=[],me=[],be=new Set;q.traverse(null,X=>{X.p!=null&&($[X.p]=q.clone())}),z.traverse(null,X=>{X.d!=null&&(te[X.d]=z.clone())});const De=s.writeCursor();return function X(Re,ze,He,Ue,qe,Rt,Ge,et){o(ze||He);const Ve=a(ze),ct=a(He),at=!!ct&&ct.r!==void 0,Pt=!!Ve&&Ve.i!==void 0,Fe=Ve?Ve.d:null,ht=ct?ct.p:null,E=(Rt||at)&&ht==null;if(ht!=null)Ue=te[ht],Ge=ae[ht]=new s.WriteCursor;else if(ct&&ct.r!==void 0)Ue=null;else{const L=a(Ue);L&&L.d!=null&&(Ue=null)}const g=a(Ue);if(Fe!=null)if(Re=$[Fe],et=ue[Fe]=new s.WriteCursor,E)Rt&&!at&&et.write("r",!0);else{const L=oe[Fe]=K++;Ge.write("d",L)}else if(Ve&&Ve.i!==void 0)Re=null;else{const L=a(Re);L&&L.p!=null&&(Re=null)}let m;Pt?(o(qe===void 0),m=Ve.i):m=qe;const T=(ht==null?!Pt||Rt||at:m===void 0)?null:Ge.getComponent();if(ht!=null){if(!(qe!==void 0||Pt)){const L=Fe!=null?oe[Fe]:K++;me[ht]=L,et.write("p",L)}}else at&&(Pt||qe!==void 0||(ct.r,et.write("r",ct.r)));const M=E?null:se(Ve),U=se(g);if((M||U)&&(M&&M.name,U&&U.name),M&&U){o(M===U);const L=y(Ve),ee=y(g),Ce=M.compose(L,ee);A(Ge,M,Ce),be.add(g)}else M?A(Ge,M,y(Ve)):U&&(A(Ge,U,y(g)),be.add(g));const x=typeof m=="object"&&m!=null;let P=!1,I=0,Q=0,pe=0,J=0,_e=0;const we=s.advancer(Ue,(L,ee)=>h(ee)?J-L-1:L-J,(L,ee)=>{h(ee)&&J++}),ce=s.advancer(Re,(L,ee)=>c(ee)?I-L-1:L-I,(L,ee)=>{c(ee)&&I++});if(s.eachChildOf(ze,He,(L,ee,Ce)=>{let Te,Pe,ke=L,We=L,dt=L;if(typeof L=="number"){let Me=L+pe;Pe=we(Me),We=Me+J;let re=L+Q;Te=ce(re),h(a(Pe))&&(Te=null),ke=re+I,dt=L+_e,o(ke>=0,"p1PickKey is negative"),o(We>=0,"p2DropKey is negative");const lt=h(a(ee)),$e=c(a(Ce));(lt||$e&&!E)&&_e--,lt&&Q--,$e&&pe--}else Te=ce(L),Pe=we(L);et.descend(ke),Ge.descend(We);const gt=x&&!h(a(ee))?m[dt]:void 0,Ee=X(Te,ee,Ce,Pe,gt,E,Ge,et);var Qe,ve,Se;x&&!E?gt!==Ee&&(P||(m=Array.isArray(m)?m.slice():Object.assign({},m),P=!0),Qe=m,Se=Ee,typeof(ve=dt)=="number"?(o(Array.isArray(Qe)),o(ve<Qe.length)):(o(!Array.isArray(Qe)),o(Qe[ve]!==void 0)),Se===void 0?typeof ve=="number"?Qe.splice(ve,1):delete Qe[ve]:Qe[ve]=Se):o(Ee===void 0),Ge.ascend(),et.ascend()}),ce.end(),we.end(),T!=null)T.i=m;else if(!Rt&&!at&&ht==null)return m}(q,q.clone(),z,z.clone(),void 0,!1,Y,De),Y.reset(),Y.mergeTree(De.get()),Y.reset(),Y.get(),ue.map(X=>X.get()),ae.map(X=>X.get()),q.traverse(Y,(X,Re)=>{const ze=X.p;if(ze!=null){const He=oe[ze];He!=null&&Re.write("p",He);const Ue=ue[ze];Ue&&Ue.get(),Ue&&Re.mergeTree(Ue.get())}else X.r!==void 0&&Re.write("r",X.r)}),Y.reset(),Y.get(),z.traverse(Y,(X,Re)=>{const ze=X.d;if(ze!=null){const Ue=me[ze];Ue!=null&&Re.write("d",Ue);const qe=ae[ze];qe&&Re.mergeTree(qe.get())}else X.i!==void 0&&Re.write("i",X.i);const He=se(X);He&&!be.has(X)&&A(Re,He,y(X))}),Y.get()}function D(S){if(S==null)return null;const F=new s.ReadCursor(S),K=new s.WriteCursor;let q;const z=[],Y=[];return function ue(ae,$,te){const oe=ae.getComponent();let me,be=!1;if(oe){oe.p!=null&&($.write("d",oe.p),z[oe.p]=ae.clone()),oe.r!==void 0&&$.write("i",oe.r),oe.d!=null&&($.write("p",oe.d),te=void 0),oe.i!==void 0&&(te=me=oe.i);const X=se(oe);X&&(te===void 0?(q||(q=new Set),q.add(oe)):(y(oe),te=X.apply(te,y(oe)),be=!0))}let De=0;for(const X of ae){$.descend(X);const Re=typeof X=="number"?X-De:X,ze=R(te,Re);h(ae.getComponent())&&De++;const He=ue(ae,$,ze);if(te!==void 0&&He!==void 0){if(be||(be=!0,te=u(te)),!p(te,Re))throw Error("Cannot modify child - invalid operation");te[Re]=He}$.ascend()}if(me===void 0)return be?te:void 0;$.write("r",te)}(F,K,void 0),q&&(K.reset(),function ue(ae,$,te){const oe=$.getComponent();if(oe){const X=oe.d;if(X!=null&&(ae=z[X],te=Y[X]=s.writeCursor()),q.has(oe)){const Re=se(oe);if(!Re.invert)throw Error(`Cannot invert subtype ${Re.name}`);A(te,Re,Re.invert(y(oe)))}}let me=0,be=0;const De=s.advancer(ae,(X,Re)=>c(Re)?me-X-1:X-me,(X,Re)=>{c(Re)&&me++});for(const X of $)if(typeof X=="number"){const Re=X-be,ze=De(Re),He=Re+me;te.descend(He),ue(ze,$,te),h($.getComponent())&&be++,te.ascend()}else te.descend(X),ue(De(X),$,te),te.ascend();De.end()}(F.clone(),F,K),Y.length&&(K.reset(),F.traverse(K,(ue,ae)=>{const $=ue.p;if($!=null){const te=Y[$];te&&te.get(),te&&ae.mergeTree(te.get())}}))),K.get()}const b=(S,F)=>S.some(K=>typeof K=="object"&&(Array.isArray(K)?b(K,F):F(K)));function O(S,F){if(S==null||!b(S,$=>{var te;return $.r!==void 0||((te=se($))===null||te===void 0?void 0:te.makeInvertible)!=null}))return S;const K=new s.ReadCursor(S),q=new s.WriteCursor;let z=!1;const Y=[],ue=[],ae=($,te,oe)=>{const me=$.getComponent();let be=!1;if(me){me.d!=null&&te.write("d",me.d),me.i!==void 0&&te.write("i",me.i);const X=me.p;if(X!=null&&(Y[X]=$.clone(),o(oe!==void 0,"Operation picks up at an invalid key"),ue[X]=oe,te.write("p",me.p)),me.r!==void 0&&oe===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const Re=se(me);Re&&(Re.makeInvertible?z=!0:A(te,Re,y(me),!0))}let De=0;for(const X of $){te.descend(X);const Re=typeof X=="number"?X-De:X,ze=R(oe,Re),He=ae($,te,ze);ze!==He&&(be||(be=!0,oe=u(oe)),He===void 0?(oe=d(oe,Re),typeof X=="number"&&De++):oe[Re]=He),te.ascend()}return me&&(me.r!==void 0?(te.write("r",r.default(oe)),oe=void 0):me.p!=null&&(oe=void 0)),oe};return ae(K,q,F),q.get(),z&&(q.reset(),function $(te,oe,me,be,De){const X=oe.getComponent();if(X){X.i!==void 0?(be=X.i,De=!0):X.d!=null&&(be=ue[X.d],te=Y[X.d],De=!1,X.d);let Ue=se(X);if(Ue&&Ue.makeInvertible){const qe=y(X);A(me,Ue,Ue.makeInvertible(qe,be),!0)}}let Re=0,ze=0;const He=s.advancer(te,(Ue,qe)=>c(qe)?Re-Ue-1:Ue-Re,(Ue,qe)=>{c(qe)&&Re++});for(const Ue of oe)if(typeof Ue=="number"){const qe=Ue-ze,Rt=He(qe),Ge=qe+Re,et=R(be,De?qe:Ge);me.descend(Ue),$(Rt,oe,me,et,De),h(oe.getComponent())&&ze++,me.ascend()}else{const qe=R(be,Ue);me.descend(Ue),$(He(Ue),oe,me,qe,De),me.ascend()}He.end()}(K.clone(),K,q,F,!1)),q.get()}function k(S,F){return D(O(S,F))}const B=S=>{if(S==null)return null;const F=S.slice();for(let K=0;K<S.length;K++){const q=F[K];Array.isArray(q)&&(F[K]=B(q))}return F};function V(S,F,K){o(K==="left"||K==="right","Direction must be left or right");const q=K==="left"?0:1;if(F==null)return{ok:!0,result:S};fe(S),fe(F);let z=null;const Y=[],ue=[],ae=[],$=[],te=[],oe=[],me=[],be=[],De=[],X=[],Re=[],ze=[],He=[],Ue=[],qe=[];let Rt=0;const Ge=s.readCursor(S),et=s.readCursor(F),Ve=s.writeCursor();if(function g(m,T=null,M){const U=a(T);U&&(U.r!==void 0?M=T.clone():U.p!=null&&(M=null,oe[U.p]=m.clone()));const x=m.getComponent();let P;x&&(P=x.p)!=null&&(te[P]=T?T.clone():null,ae[P]=m.clone(),M&&(X[P]=!0,De[P]=M),U&&U.p!=null&&(Ue[P]=U.p));const I=s.advancer(T);for(const Q of m)g(m,I(Q),M);I.end()}(et,Ge,null),function g(m,T,M,U,x){const P=M.getComponent();let I,Q=!1;P&&((I=P.d)!=null?($[I]=M.clone(),U!=null&&(qe[U]==null&&(qe[U]=[]),qe[U].push(I)),X[I],m=te[I]||null,T=ae[I]||null,X[I]?(x&&(Re[I]=!0),x=De[I]||null):!x||q!==1&&Ue[I]!=null||z==null&&(z={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(x.getPath()),op2:e.moveOp(T.getPath(),M.getPath())}),Q=!0):P.i!==void 0&&(m=T=null,Q=!0,x&&z==null&&(z={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(x.getPath()),op2:e.insertOp(M.getPath(),P.i)})));const pe=a(m);pe&&(pe.r!==void 0?x=m.clone():pe.p!=null&&(pe.p,U=pe.p,x=null));const J=se(P);J&&x&&z==null&&(z={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(x.getPath()),op2:e.editOp(M.getPath(),J,y(P),!0)});let _e=0,we=0;const ce=s.advancer(T,(ee,Ce)=>c(Ce)?_e-ee-1:ee-_e,(ee,Ce)=>{c(Ce)&&_e++}),L=s.advancer(m);for(const ee of M)if(typeof ee=="number"){const Ce=ee-we,Te=ce(Ce);we+=+g(L(Ce+_e),Te,M,U,x)}else{const Ce=ce(ee);g(L(ee),Ce,M,U,x)}return ce.end(),L.end(),Q}(Ge,et,et.clone(),null,null),$.map(g=>g&&g.get()),z)return{ok:!1,conflict:z};Re.map(g=>!!g);const ct=[];let at=null;(function g(m,T,M,U,x){let P=!1;const I=a(T);if(c(I)){const ce=I.p;ce!=null?(M=$[ce],U=ze[ce]=s.writeCursor(),P=!0,x=null):(M=null,x=T.clone())}else h(a(M))&&(M=null);const Q=m.getComponent();if(Q){const ce=Q.p;ce!=null?(x&&(be[ce]=x),ct[ce]=x||q===1&&P?null:U.getComponent(),Y[ce]=m.clone(),M&&(me[ce]=M.clone())):Q.r!==void 0&&(x||U.write("r",!0),(x||P)&&(at==null&&(at=new Set),at.add(Q)))}let pe=0,J=0;const _e=s.advancer(T,void 0,(ce,L)=>{c(L)&&pe++}),we=s.advancer(M,(ce,L)=>h(L)?~(ce-J):ce-J,(ce,L)=>{h(L)&&J++});if(m)for(const ce of m)if(typeof ce=="string"){const L=_e(ce),ee=we(ce);U.descend(ce),g(m,L,ee,U,x),U.ascend()}else{const L=_e(ce),ee=ce-pe,Ce=c(a(L))?null:we(ee),Te=ee+J;o(Te>=0),U.descend(Te),g(m,L,Ce,U,x),U.ascend()}_e.end(),we.end()})(Ge,et,et.clone(),Ve,null),Ve.reset();let Pt=[];if(function g(m,T,M,U,x,P){o(T);const I=T.getComponent();let Q=a(U),pe=!1;const J=(ve,Se,Me)=>ve?e.moveOp(ve.getPath(),Se.getPath()):e.insertOp(Se.getPath(),Me.i);if(h(I)){const ve=I.d;ve!=null&&(ue[ve]=T.clone());const Se=ve!=null?ct[ve]:null;let Me=!1;if(I.i!==void 0||ve!=null&&Se){let re;Q&&(Q.i!==void 0||(re=Q.d)!=null&&!X[re])&&(Me=re!=null?ve!=null&&ve===Ue[re]:n.default(Q.i,I.i),Me||re!=null&&q!==1&&Ue[re]!=null||z==null&&(z={type:i.ConflictType.DROP_COLLISION,op1:J(ve!=null?Y[ve]:null,T,I),op2:J(re!=null?ae[re]:null,U,Q)})),Me||(P?z==null&&(z={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:J(ve!=null?Y[ve]:null,T,I),op2:e.removeOp(P.getPath())}):(ve!=null?(Pt[Rt]=ve,x.write("d",Se.p=Rt++)):x.write("i",r.default(I.i)),pe=!0))}else if(ve!=null&&!Se){const re=be[ve];re&&(P=re.clone())}ve!=null?(m=Y[ve],M=oe[ve],U=me[ve]):I.i!==void 0&&(m=M=null,Me||(U=null))}else c(a(m))&&(m=M=U=null);const _e=a(m),we=a(M);if(c(we)){const ve=we.p;we.r!==void 0&&(!_e||_e.r===void 0)||X[ve]?(U=null,P=M.clone()):ve!=null&&(U=$[ve],q!==1&&Ue[ve]!=null||((x=He[ve])||(x=He[ve]=s.writeCursor()),x.reset(),P=null))}else!h(I)&&h(Q)&&(U=null);Q=U!=null?U.getComponent():null;const ce=se(I);if(ce){const ve=y(I);if(P)z==null&&(z={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.editOp(T.getPath(),ce,ve,!0),op2:e.removeOp(P.getPath())});else{const Se=se(Q);let Me;if(Se){if(ce!==Se)throw Error("Transforming incompatible types");const re=y(Q);Me=ce.transform(ve,re,K)}else Me=r.default(ve);A(x,ce,Me)}}let L=0,ee=0,Ce=0,Te=0,Pe=0,ke=0,We=m!=null&&m.descendFirst(),dt=We;const gt=s.advancer(M,void 0,(ve,Se)=>{c(Se)&&Ce++});let Ee=U!=null&&U.descendFirst(),Qe=Ee;for(const ve of T)if(typeof ve=="number"){let Se;const Me=h(T.getComponent()),re=ve-ee;{let Wt;for(;We&&typeof(Wt=m.getKey())=="number";){Wt+=L;const bt=m.getComponent(),gn=c(bt);if(Wt>re||Wt===re&&(!gn||q===0&&Me))break;if(gn){L--;const tn=bt.p;Ue.includes(tn),bt.d,a(He[bt.d]),c(a(He[bt.d])),(bt.r===void 0||at&&at.has(bt))&&(tn==null||!ct[tn]||q!==1&&Ue.includes(tn))||Pe--}We=m.nextSibling()}Se=We&&Wt===re?m:null}const lt=re-L;let $e=gt(lt);const Dt=lt-Ce;let mr=null;{let Wt,bt;for(;Ee&&typeof(Wt=U.getKey())=="number";){bt=Wt-Te;const gn=U.getComponent(),tn=h(gn);if(bt>Dt)break;if(bt===Dt){if(!tn){mr=U;break}{if(q===0&&Me){mr=U;break}const Yt=$e&&c($e.getComponent());if(q===0&&Yt)break}}if(tn){const Yt=gn.d;X[Yt],Ue[Yt],gn.i===void 0&&(X[Yt]||Ue[Yt]!=null&&q!==1)?(X[Yt]||Ue[Yt]!=null&&q===0)&&(Te++,ke--):Te++}Ee=U.nextSibling()}}const xi=Dt+Te+Pe+ke;o(xi>=0,"trying to descend to a negative index"),x.descend(xi),Me&&(Se=$e=mr=null,ee++),g(Se,T,$e,mr,x,P)&&ke++,x.ascend()}else{let Se;for(;We&&(Se=m.getKey(),typeof Se!="string"||!(Se>ve||Se===ve));)We=m.nextSibling();const Me=We&&Se===ve?m:null,re=gt(ve);let lt;for(;Ee&&(lt=U.getKey(),typeof lt!="string"||!(lt>ve||lt===ve));)Ee=U.nextSibling();const $e=Ee&<===ve?U:null;x.descend(ve),g(Me,T,re,$e,x,P),x.ascend()}return gt.end(),dt&&m.ascend(),Qe&&U.ascend(),pe}(Ge,Ge.clone(),et,et.clone(),Ve,null),z)return{ok:!1,conflict:z};Ve.reset();const Fe=(g,m,T)=>g.traverse(m,(M,U)=>{M.d!=null&&T(M.d,g,U)});(X.length||ze.length)&&(Fe(et,Ve,(g,m,T)=>{X[g]&&!Re[g]&&T.write("r",!0),ze[g]&&T.mergeTree(ze[g].get())}),Ve.reset());const ht=[],E=[];if((He.length||X.length)&&!z){const g=s.readCursor(B(Ve.get()));if(Fe(g,null,(m,T)=>{ht[m]=T.clone()}),He.forEach(m=>{m&&Fe(s.readCursor(m.get()),null,(T,M)=>{ht[T]=M.clone()})}),function m(T,M,U,x,P,I){const Q=a(M);if(Q&&c(Q))if(Q.p!=null){const L=Q.p;ht[L].getPath(),U=ht[L],x=E[L]=s.writeCursor()}else Q.r!==void 0&&(U=null);else h(a(U))&&(U=null);const pe=T.getComponent();if(pe){let L;if((L=pe.d)!=null){const ee=He[L];ee&&(ee.get(),x.mergeTree(ee.get()),U=s.readCursor(ee.get()))}}let J=0,_e=0;const we=s.advancer(M,void 0,(L,ee)=>{c(ee)&&J--}),ce=s.advancer(U,(L,ee)=>h(ee)?-(L-_e)-1:L-_e,(L,ee)=>{h(ee)&&_e++});for(const L of T)if(typeof L=="number"){const ee=we(L),Ce=L+J,Te=ce(Ce),Pe=Ce+_e;x.descend(Pe),m(T,ee,Te,x),x.ascend()}else x.descend(L),m(T,we(L),ce(L),x),x.ascend();we.end(),ce.end()}(et,g,g.clone(),Ve),Ve.reset(),z)return{ok:!1,conflict:z};if(Ve.get(),E.length){const m=E.map(M=>M?M.get():null),T=s.readCursor(B(Ve.get()));if(Fe(T,Ve,(M,U,x)=>{const P=m[M];P&&(x.mergeTree(P),m[M]=null)}),m.find(M=>M)){const M=s.writeCursor(),U=s.writeCursor();let x=0,P=0;m.forEach(I=>{I!=null&&Fe(s.readCursor(I),null,Q=>{const pe=Pt[Q];M.writeMove(Y[pe].getPath(),ue[pe].getPath(),x++);const J=qe[pe];J&&J.forEach(_e=>{X[_e]||q!==1&&Ue[_e]!=null||U.writeMove(ae[_e].getPath(),$[_e].getPath(),P++)})})}),z={type:i.ConflictType.BLACKHOLE,op1:M.get(),op2:U.get()}}}}return z?{ok:!1,conflict:z}:{ok:!0,result:Ve.get()}}const ie=S=>{const F=new Error("Transform detected write conflict");throw F.conflict=S,F.type=F.name="writeConflict",F};function de(S,F,K){const q=V(S,F,K);if(q.ok)return q.result;ie(q.conflict)}const ge=S=>{const F=s.writeCursor();return s.readCursor(S).traverse(F,(K,q)=>{(h(K)||se(K))&&q.write("r",!0)}),F.get()},ye=(S,F)=>{const{type:K,op1:q,op2:z}=S;switch(K){case i.ConflictType.DROP_COLLISION:return F==="left"?[null,ge(z)]:[ge(q),null];case i.ConflictType.RM_UNEXPECTED_CONTENT:let Y=!1;return s.readCursor(q).traverse(null,ue=>{ue.r!==void 0&&(Y=!0)}),Y?[null,ge(z)]:[ge(q),null];case i.ConflictType.BLACKHOLE:return[ge(q),ge(z)];default:throw Error("Unrecognised conflict: "+K)}};function Ae(S,F,K,q){let z=null;for(;;){const Y=V(F,K,q);if(Y.ok)return v(z,Y.result);{const{conflict:ue}=Y;S(ue)||ie(ue);const[ae,$]=ye(ue,q);F=v(le(F),ae),K=v(le(K),$),z=v(z,$)}}}}(kn)),kn}var Ao;function b_(){return Ao||(Ao=1,function(e){var t=nn&&nn.__createBinding||(Object.create?function(i,o,a,l){l===void 0&&(l=a),Object.defineProperty(i,l,{enumerable:!0,get:function(){return o[a]}})}:function(i,o,a,l){l===void 0&&(l=a),i[l]=o[a]}),n=nn&&nn.__exportStar||function(i,o){for(var a in i)a!=="default"&&!o.hasOwnProperty(a)&&t(o,i,a)};Object.defineProperty(e,"__esModule",{value:!0}),n(w_(),e);var r=zl();Object.defineProperty(e,"ReadCursor",{enumerable:!0,get:function(){return r.ReadCursor}}),Object.defineProperty(e,"WriteCursor",{enumerable:!0,get:function(){return r.WriteCursor}});var s=Gl();Object.defineProperty(e,"ConflictType",{enumerable:!0,get:function(){return s.ConflictType}})}(nn)),nn}var mt=b_();const A_=Ct(mt),T_=dc({__proto__:null,default:A_},[mt]);var he=(e=>(e.RETAIN="r",e.INSERT="i",e.DELETE="d",e))(he||{});function hr(e,t=!1){const n=[];for(const r of e){const{st:s,ed:i,ts:o}=r;if(r.sId===void 0&&delete r.sId,s===i||!t&&ne.isEmptyObject(o)&&r.sId==null)continue;if(n.length===0){n.push(r);continue}const a=n.pop();Ma(r,a)&&ne.hasIntersectionBetweenTwoRanges(a.st,a.ed,r.st,r.ed)?n.push({...r,st:a.st,ed:i}):n.push(a,r)}return n}function Vl(e,t,n,r){var u;const{textRuns:s}=e;if(s==null)return;const i=[],o=s.length;let a=!1;const l=(u=t.textRuns)!=null?u:[];if(l.length)for(const c of l)c.st+=r,c.ed+=r;for(let c=0;c<o;c++){const h=s[c],{st:d,ed:f}=h;if(f<=r)i.push(h);else if(r>d&&r<f){a=!0;const p={...h,ed:r};i.push(p),l.length&&i.push(...l);const R={...h,st:r+n,ed:f+n};i.push(R)}else h.st+=n,h.ed+=n,a||(a=!0,i.push(...l)),i.push(h)}a||(a=!0,i.push(...l)),e.textRuns=hr(i)}function Kl(e,t,n,r){const{paragraphs:s}=e;if(s==null)return;const{paragraphs:i}=t,o=[];for(let l=0,u=s.length;l<u;l++){const c=s[l],{startIndex:h}=c;h>=r&&(c.startIndex+=n),o.push(c.startIndex)}let a=-1;if(i){for(let l=0,u=i.length;l<u;l++){const c=i[l];c.startIndex+=r;const h=c.startIndex;a=o.indexOf(h)}a!==-1&&s.splice(a,1),s.push(...i),s.sort(ur("startIndex"))}}function Xl(e,t,n,r){const{sectionBreaks:s}=e;if(s==null)return;for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:u}=l;u>=r&&(l.startIndex+=n)}const i=t.sectionBreaks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=r}s.push(...i),s.sort(ur("startIndex"))}}function ql(e,t,n,r){const{customBlocks:s=[]}=e;for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:u}=l;u>=r&&(l.startIndex+=n)}const i=t.customBlocks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=r}s.push(...i),s.sort(ur("startIndex"))}s.length&&!e.customBlocks&&(e.customBlocks=s)}function Jl(e,t,n,r){const{tables:s}=e;if(s==null)return;for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:u,endIndex:c}=l;u>r?(l.startIndex+=n,l.endIndex+=n):c>r&&(l.endIndex+=n)}const i=t.tables;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=r,l.endIndex+=r}s.push(...i),s.sort(ur("startIndex"))}}const Zl="$",To=e=>e.split(Zl)[0];function Si(e){if(e.length<=1)return e;e.sort((s,i)=>s.startIndex-i.startIndex);const t=[];let n={...e[0]};n.rangeId=To(n.rangeId);for(let s=1;s<e.length;s++){const i=e[s];i.rangeId=To(i.rangeId),i.rangeId===n.rangeId&&Yl(n.properties,i.properties)&&n.endIndex+1>=i.startIndex?n.endIndex=i.endIndex:(t.push(n),n={...i})}t.push(n);const r=Object.create(null);for(let s=0,i=t.length;s<i;s++){const o=t[s],a=o.rangeId;r[a]?(o.rangeId=`${a}${Zl}${r[a]}`,r[a]=r[a]+1):r[a]=1}return t}function Vs(e,t){const n=e.findIndex(s=>s.startIndex<t&&s.endIndex>=t),r=e[n];r&&e.splice(n,1,{rangeId:r.rangeId,rangeType:r.rangeType,startIndex:r.startIndex,endIndex:t-1,properties:{...r.properties}},{rangeId:r.rangeId,rangeType:r.rangeType,startIndex:t,endIndex:r.endIndex,properties:{...r.properties}})}function Ql(e){if(e.length<=1)return e;e.sort((r,s)=>r.startIndex-s.startIndex);const t=[];let n={...e[0]};for(let r=1;r<e.length;r++){const s=e[r];s.id===n.id&&n.endIndex+1>=s.startIndex?n.endIndex=s.endIndex:(t.push(n),n={...s})}return t.push(n),t}function Ks(e,t){e.filter(r=>r.startIndex<t&&r.endIndex>=t).forEach(r=>{const s=e.indexOf(r);e.splice(s,1,{id:r.id,type:r.type,startIndex:r.startIndex,endIndex:t-1},{id:r.id,type:r.type,startIndex:t,endIndex:r.endIndex})})}function y_(e,t,n,r){e.customRanges||(e.customRanges=[]);const{customRanges:s}=e;Vs(s,r);for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:u}=l;u>=r&&(l.startIndex+=n,l.endIndex+=n)}const i=[];if(t.customRanges){for(let o=0,a=t.customRanges.length;o<a;o++){const l=t.customRanges[o];l.startIndex+=r,l.endIndex+=r,i.push(l)}s.push(...i)}e.customRanges=Si(s)}function N_(e,t,n,r){e.customDecorations||(e.customDecorations=[]);const{customDecorations:s}=e;Ks(s,r);for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:u}=l;u>=r&&(l.startIndex+=n,l.endIndex+=n)}const i=[];if(t.customDecorations){for(let o=0,a=t.customDecorations.length;o<a;o++){const l=t.customDecorations[o];l.startIndex+=r,l.endIndex+=r,i.push(l)}s.push(...i)}e.customDecorations=Ql(s)}function eu(e,t,n){const{textRuns:r}=e,s=n,i=n+t,o=[];if(r){const a=[];for(let l=0,u=r.length;l<u;l++){const c=r[l],{st:h,ed:d}=c;if(s<=h&&i>=d){o.push({...c,st:h-s,ed:d-s});continue}else h<=s&&d>=i?(o.push({...c,st:s-s,ed:i-s}),c.ed-=t):s>=h&&s<d?(o.push({...c,st:s-s,ed:d-s}),c.ed=s):i>h&&i<=d?(o.push({...c,st:h-s,ed:i-s}),c.st=i-t,c.ed-=t):h>=i&&(c.st-=t,c.ed-=t);a.push(c)}e.textRuns=a}return o.length===0&&o.push({st:0,ed:t,ts:{}}),o}function tu(e,t,n){const{paragraphs:r}=e,s=n,i=n+t,o=[];if(r){const a=[];for(let l=0,u=r.length;l<u;l++){const c=r[l],{startIndex:h}=c;if(h>=s&&h<i){o.push({...c,startIndex:h-n});continue}else h>=i&&(c.startIndex-=t);a.push(c)}e.paragraphs=a}return o}function nu(e,t,n){const{sectionBreaks:r}=e,s=n,i=n+t-1,o=[];if(r){const a=[];for(let l=0,u=r.length;l<u;l++){const c=r[l],{startIndex:h}=c;if(h>=s&&h<=i){o.push({...c,startIndex:h-n});continue}else h>i&&(c.startIndex-=t);a.push(c)}e.sectionBreaks=a}return o}function ru(e,t,n){const{customBlocks:r=[]}=e,s=n,i=n+t-1,o=[];if(r){const a=[];for(let l=0,u=r.length;l<u;l++){const c=r[l],{startIndex:h}=c;if(h>=s&&h<=i){o.push({...c,startIndex:h-n});continue}else h>i&&(c.startIndex-=t);a.push(c)}e.customBlocks=a}return r.length&&!e.customBlocks&&(e.customBlocks=r),o}function su(e,t,n){const{tables:r}=e,s=n,i=n+t-1,o=[];if(r){const a=[];for(let l=0,u=r.length;l<u;l++){const c=r[l],{startIndex:h,endIndex:d}=c;if(s<=h&&i>=d){o.push({...c,startIndex:h-n,endIndex:d-n});continue}else if(h<=s&&d>=i){const f=ns(h,d,s,i);if(f.length===0||(c.startIndex=f[0],c.endIndex=f[1],c.startIndex===c.endIndex))continue}else i<h&&(c.startIndex-=t,c.endIndex-=t);a.push(c)}e.tables=a}return o}function M_(e,t,n){const{customRanges:r}=e,s=n,i=n+t-1,o=[];if(r){const a=[];for(let l=0,u=r.length;l<u;l++){const c=r[l],{startIndex:h,endIndex:d}=c;if(h>=s&&d<=i){o.push(c);continue}else if(Math.max(s,h)<=Math.min(i,d)){const f=ns(h,d,s,i);if(f.length===0)continue;c.startIndex=f[0],c.endIndex=f[1]}else i<h&&(c.startIndex-=t,c.endIndex-=t);a.push(c)}e.customRanges=Si(a)}return o}function D_(e,t,n,r=!0){const{customDecorations:s}=e,i=n,o=n+t-1,a=[];if(s){const l=[];for(let u=0,c=s.length;u<c;u++){const h=s[u],{startIndex:d,endIndex:f}=h;if(d>=i&&f<=o){a.push(h);continue}else if(Math.max(i,d)<=Math.min(o,f)){const p=ns(d,f,i,o);if(p.length===0)continue;h.startIndex=p[0],h.endIndex=p[1]}else o<d&&r&&(h.startIndex-=t,h.endIndex-=t);l.push(h)}e.customDecorations=l}return a}var iu=(e=>(e.ORDER_LIST_QUICK_1="1.",e.ORDER_LIST_QUICK_2="a)",e.ORDER_LIST_QUICK_3="a.",e.ORDER_LIST_QUICK_4="i.",e.ORDER_LIST_QUICK_5="A.",e.ORDER_LIST_QUICK_6="I.",e.ORDER_LIST_QUICK_7="01.",e.BULLET_LIST="*",e))(iu||{}),Ut=(e=>(e.BULLET_LIST="BULLET_LIST",e.BULLET_LIST_1="BULLET_LIST_1",e.BULLET_LIST_2="BULLET_LIST_2",e.BULLET_LIST_3="BULLET_LIST_3",e.BULLET_LIST_4="BULLET_LIST_4",e.BULLET_LIST_5="BULLET_LIST_5",e.ORDER_LIST="ORDER_LIST",e.ORDER_LIST_1="ORDER_LIST_1",e.ORDER_LIST_2="ORDER_LIST_2",e.ORDER_LIST_3="ORDER_LIST_3",e.ORDER_LIST_4="ORDER_LIST_4",e.ORDER_LIST_5="ORDER_LIST_5",e.ORDER_LIST_QUICK_2="ORDER_LIST_QUICK_2",e.ORDER_LIST_QUICK_3="ORDER_LIST_QUICK_3",e.ORDER_LIST_QUICK_4="ORDER_LIST_QUICK_4",e.ORDER_LIST_QUICK_5="ORDER_LIST_QUICK_5",e.ORDER_LIST_QUICK_6="ORDER_LIST_QUICK_6",e.CHECK_LIST="CHECK_LIST",e.CHECK_LIST_CHECKED="CHECK_LIST_CHECKED",e))(Ut||{});const wr={"a)":{glyphFormat:"%1)",glyphType:Ne.DECIMAL},"1.":{glyphType:Ne.DECIMAL},"a.":{glyphFormat:"%1.",glyphType:Ne.LOWER_LETTER},"A.":{glyphType:Ne.UPPER_LETTER},"i.":{glyphFormat:"%1.",glyphType:Ne.LOWER_ROMAN},"I.":{glyphFormat:"%1.",glyphType:Ne.UPPER_LETTER}},pn=e=>[...e,...e,...e].map((t,n)=>({glyphFormat:` %${n+1}`,glyphSymbol:t,bulletAlignment:lr.START,textStyle:{fs:12},startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*n}}})),En=e=>e.map((t,n)=>({...t,bulletAlignment:lr.START,textStyle:{fs:12},startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*n}}})),yo=(e,t)=>new Array(9).fill(0).map((n,r)=>({glyphFormat:` %${r+1}`,glyphSymbol:e,bulletAlignment:lr.START,textStyle:{fs:16},startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*r},textStyle:t}})),dr={BULLET_LIST:{listType:"BULLET_LIST",nestingLevel:pn(["●","○","■"])},BULLET_LIST_1:{listType:"BULLET_LIST",nestingLevel:pn(["❖","➢","■"])},BULLET_LIST_2:{listType:"BULLET_LIST",nestingLevel:pn(["✔","●","◆"])},BULLET_LIST_3:{listType:"BULLET_LIST",nestingLevel:pn(["■","◆","○"])},BULLET_LIST_4:{listType:"BULLET_LIST",nestingLevel:pn(["✧","○","■"])},BULLET_LIST_5:{listType:"BULLET_LIST",nestingLevel:pn(["➢","○","◆"])},ORDER_LIST:{listType:"ORDER_LIST",nestingLevel:En([{glyphFormat:"%1.",glyphType:Ne.DECIMAL},{glyphFormat:"%2.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%3.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%4.",glyphType:Ne.DECIMAL},{glyphFormat:"%5.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%6.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%7.",glyphType:Ne.DECIMAL},{glyphFormat:"%8.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%9.",glyphType:Ne.LOWER_ROMAN}])},ORDER_LIST_1:{listType:"ORDER_LIST",nestingLevel:En([{glyphFormat:"%1)",glyphType:Ne.DECIMAL},{glyphFormat:"%2)",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%3)",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%4)",glyphType:Ne.DECIMAL},{glyphFormat:"%5)",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%6)",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%7)",glyphType:Ne.DECIMAL},{glyphFormat:"%8)",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%9)",glyphType:Ne.LOWER_ROMAN}])},ORDER_LIST_2:{listType:"ORDER_LIST",nestingLevel:En(["%1.","%1.%2.","%1.%2.%3.","%1.%2.%3.%4.","%1.%2.%3.%4.%5.","%1.%2.%3.%4.%5.%6.","%1.%2.%3.%4.%5.%6.%7."].map(e=>({glyphFormat:e,glyphType:Ne.DECIMAL})))},ORDER_LIST_3:{listType:"ORDER_LIST",nestingLevel:En([{glyphFormat:"%1.",glyphType:Ne.UPPER_LETTER},{glyphFormat:"%2.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%3.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%4.",glyphType:Ne.UPPER_LETTER},{glyphFormat:"%5.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%6.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%7.",glyphType:Ne.UPPER_LETTER},{glyphFormat:"%8.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%9.",glyphType:Ne.LOWER_ROMAN}])},ORDER_LIST_4:{listType:"ORDER_LIST",nestingLevel:En([{glyphFormat:"%1.",glyphType:Ne.UPPER_LETTER},{glyphFormat:"%2.",glyphType:Ne.DECIMAL},{glyphFormat:"%3.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%4.",glyphType:Ne.UPPER_LETTER},{glyphFormat:"%5.",glyphType:Ne.DECIMAL},{glyphFormat:"%6.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%7.",glyphType:Ne.UPPER_LETTER},{glyphFormat:"%8.",glyphType:Ne.DECIMAL},{glyphFormat:"%9.",glyphType:Ne.LOWER_ROMAN}])},ORDER_LIST_5:{listType:"ORDER_LIST",nestingLevel:En([{glyphFormat:"%1.",glyphType:Ne.DECIMAL_ZERO},{glyphFormat:"%2.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%3.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%4.",glyphType:Ne.DECIMAL_ZERO},{glyphFormat:"%5.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%6.",glyphType:Ne.LOWER_ROMAN},{glyphFormat:"%7.",glyphType:Ne.DECIMAL_ZERO},{glyphFormat:"%8.",glyphType:Ne.LOWER_LETTER},{glyphFormat:"%9.",glyphType:Ne.LOWER_ROMAN}])},CHECK_LIST:{listType:"CHECK_LIST",nestingLevel:yo("☐")},CHECK_LIST_CHECKED:{listType:"CHECK_LIST_CHECKED",nestingLevel:yo("☑",{st:{s:Ie.TRUE}})}},br=e=>{const{glyphFormat:t,glyphType:n}=e,r=ne.deepClone(dr.ORDER_LIST);return r.nestingLevel[0].glyphFormat=t,r.nestingLevel[0].glyphType=n,r},L_={ORDER_LIST_QUICK_2:br(wr["a)"]),ORDER_LIST_QUICK_3:br(wr["a."]),ORDER_LIST_QUICK_4:br(wr["i."]),ORDER_LIST_QUICK_6:br(wr["I."])};Object.assign(dr,L_);const x_={"1.":"ORDER_LIST","a)":"ORDER_LIST_QUICK_2","a.":"ORDER_LIST_QUICK_3","i.":"ORDER_LIST_QUICK_4","A.":"ORDER_LIST_3","I.":"ORDER_LIST_QUICK_6","01.":"ORDER_LIST_5","*":"BULLET_LIST"};function U_(e,t,n,r,s){const i=P_(e,t,n,r,s),o=k_(e,t,n,r,s),a=F_(e,t,n,r,s),l=B_(e,t,n,r,s),u=$_(e,t,n,r,s),c=H_(e,t,n,r),h=j_(e,t,n,r,s);return{dataStream:"",textRuns:i,paragraphs:o,sectionBreaks:a,customBlocks:l,tables:u,customRanges:c,customDecorations:h}}function P_(e,t,n,r,s){const{textRuns:i}=e,{textRuns:o}=t;if(i==null||o==null)return;const a=eu(e,n,r);if(s!==xe.REPLACE){const l=ou(o,a,s);t.textRuns=l}return Vl(e,t,n,r),a}function ou(e,t,n){if(t.length===0)return e;e=ne.deepClone(e),t=ne.deepClone(t);const r=[],s=e.length,i=t.length;let o=0,a=0,l=null;function u(){return l?(r.push(l),l=null,!0):!1}for(;o<s&&a<i;){const{st:f,ed:p,ts:R}=e[o],{st:w,ed:N,ts:G,sId:W}=t[a];let se;if(n===xe.COVER?se={...G,...R}:se={...R},p<w)u()||r.push(e[o]),o++;else if(N<f)u()||r.push(t[a]),a++;else{const y={st:Math.min(f,w),ed:Math.max(f,w),ts:f<w?{...R}:{...G},sId:f<w?void 0:W};y.ed>y.st&&r.push(y),r.push({st:Math.max(f,w),ed:Math.min(p,N),ts:se,sId:W}),p<N?(o++,t[a].st=p,t[a].st===t[a].ed&&a++):(a++,e[o].st=N,e[o].st===e[o].ed&&o++);const A={st:Math.min(p,N),ed:Math.max(p,N),ts:p<N?{...G}:{...R},sId:p<N?W:void 0};l=A.ed>A.st?A:null}}u();const c=r[r.length-1],h=e[s-1],d=t[i-1];return c&&c.ed!==Math.max(h.ed,d.ed)&&(h.ed>d.ed?r.push(h):r.push(d)),hr(r)}function k_(e,t,n,r,s){const{paragraphs:i}=e,{paragraphs:o}=t;if(i==null||o==null)return;const a=tu(e,n,r);if(s!==xe.REPLACE){const l=[];for(const u of o){const{startIndex:c,paragraphStyle:h,bullet:d}=u;let f=[];for(const p of a){const{startIndex:R,paragraphStyle:w,bullet:N}=p;let G,W;if(s===xe.COVER?(G={...w,...h},W={listId:"",listType:Ut.BULLET_LIST,nestingLevel:0,textStyle:{},...N,...d}):(G={...h,...w},W={listId:"",listType:Ut.BULLET_LIST,nestingLevel:0,textStyle:{},...d,...N}),c===R){f.push({startIndex:c,paragraphStyle:G,bullet:W});break}}l.push(...f),f=[]}t.paragraphs=l}return Kl(e,t,n,r),a}function F_(e,t,n,r,s){const{sectionBreaks:i}=e,{sectionBreaks:o}=t;if(i==null||o==null)return;const a=nu(e,n,r);if(s!==xe.REPLACE){const l=[];for(const u of o){const{startIndex:c}=u;let h=[];for(const d of a){const{startIndex:f}=d;if(c===f){s===xe.COVER?h.push({...d,...u}):h.push({...u,...d});break}}l.push(...h),h=[]}t.sectionBreaks=l}return Xl(e,t,n,r),a}function B_(e,t,n,r,s){const{customBlocks:i=[]}=e,{customBlocks:o}=t;if(i==null||o==null)return;const a=ru(e,n,r);if(s!==xe.REPLACE){const l=[];for(const u of o){const{startIndex:c}=u;let h=[];for(const d of a){const{startIndex:f}=d;if(c===f){s===xe.COVER?h.push({...d,...u}):h.push({...u,...d});break}}l.push(...h),h=[]}t.customBlocks=l}return ql(e,t,n,r),i.length&&!e.customBlocks&&(e.customBlocks=i),a}function $_(e,t,n,r,s){const{tables:i}=e,{tables:o}=t;if(i==null||o==null)return;const a=su(e,n,r);if(s!==xe.REPLACE){const l=[];for(const u of o){const{startIndex:c,endIndex:h}=u;let d=[];for(const f of a){const{startIndex:p,endIndex:R}=f;if(p>=c&&R<=h){s===xe.COVER?d.push({...f,...u}):d.push({...u,...f});break}}l.push(...d),d=[]}t.tables=l}return Jl(e,t,n,r),a}function H_(e,t,n,r,s){e.customRanges||(e.customRanges=[]),Vs(e.customRanges,r),Vs(e.customRanges,r+n);const i=r,o=r+n-1,{customRanges:a}=t,l=[],u=new Map;e.customRanges.forEach(h=>{const{startIndex:d,endIndex:f}=h;d>=i&&f<=o?u.set(h.rangeId,h):l.push(h)});const c=[];return a?(a.forEach(h=>{const{startIndex:d,endIndex:f}=h;l.push({...h,startIndex:d+r,endIndex:f+r})}),e.customRanges=Si(l),c):[]}function j_(e,t,n,r,s){e.customDecorations||(e.customDecorations=[]),Ks(e.customDecorations,r),Ks(e.customDecorations,r+n);const i=[],{customDecorations:o}=e,{customDecorations:a=[]}=t;if(s===xe.REPLACE){for(let l=0;l<o.length;l++){const u=o[l],{startIndex:c,endIndex:h}=u;c>=r&&h<=r+n-1&&i.push(u)}a.forEach(l=>{const{startIndex:u,endIndex:c}=l;o.push({...l,startIndex:u+r,endIndex:c+r})})}else for(const l of a){const{id:u}=l;if(l.type===on.DELETED){const c=o.filter(h=>h.id===u);c.length&&i.push(...c)}else o.push({...l,startIndex:l.startIndex+r,endIndex:l.endIndex+r})}for(const l of i){const{id:u}=l,c=o.findIndex(h=>h.id===u);c!==-1&&o.splice(c,1)}return e.customDecorations=Ql(o),i}var vi=(e=>(e[e.copy=0]="copy",e[e.cut=1]="cut",e))(vi||{});function Kr(e,t,n,r=!0){const{textRuns:s}=e;if(s){const i=[];for(const o of s){const a=ne.deepClone(o),{st:l,ed:u}=a;ne.hasIntersectionBetweenTwoRanges(l,u,t,n)&&(t>=l&&t<=u?i.push({...a,st:t,ed:Math.min(n,u)}):n>=l&&n<=u?i.push({...a,st:Math.max(t,l),ed:n}):i.push(a))}return hr(i.map(o=>{const{st:a,ed:l}=o;return{...o,st:a-t,ed:l-t}}))}else if(r)return[{st:0,ed:n-t,ts:{}}]}function au(e,t,n){const{tables:r=[]}=e,s=[];for(const i of r){const o=ne.deepClone(i),{startIndex:a,endIndex:l}=o;a>=t&&l<=n&&s.push({...o,startIndex:a-t,endIndex:l-t})}return s}function lu(e,t,n){const{paragraphs:r=[]}=e,s=[];for(const i of r){const{startIndex:o}=i;if(o>=t&&o<n){const a=ne.deepClone(i);s.push(a)}}if(s.length)return s.map(i=>({...i,startIndex:i.startIndex-t}))}function W_(e,t,n){const{sectionBreaks:r=[]}=e,s=[];for(const i of r){const{startIndex:o}=i;o>=t&&o<=n&&s.push(ne.deepClone(i))}if(s.length)return s.map(i=>({...i,startIndex:i.startIndex-t}))}function uu(e,t,n){const{customBlocks:r=[]}=e,s=[];for(const i of r){const{startIndex:o}=i;o>=t&&o<n&&s.push(ne.deepClone(i))}if(s.length)return s.map(i=>({...i,startIndex:i.startIndex-t}))}function Nt(e,t,n,r=!0,s=1){const{dataStream:i}=e,o={dataStream:i.slice(t,n)};o.textRuns=Kr(e,t,n,r);const a=au(e,t,n);if(a.length&&(o.tables=a),o.paragraphs=lu(e,t,n),s===1){const u=hu(e,t,n);u?o.customDecorations=u:r&&(o.customDecorations=[])}const{customRanges:l}=cu(e,t,n);return l?o.customRanges=l:r&&(o.customRanges=[]),o.customBlocks=uu(e,t,n),o}function Y_(e){const{dataStream:t,textRuns:n,paragraphs:r,customRanges:s,customDecorations:i,tables:o}=e;let a=0,l=0;s==null||s.forEach(c=>{c.startIndex<0&&(a=Math.max(a,-c.startIndex)),c.endIndex>t.length-1&&(l=Math.max(l,c.endIndex-t.length+1))});const u=`${t}`;return n&&(n[0]&&(n[0].st=n[0].st-a),n[n.length-1]&&(n[n.length-1].ed=n[n.length-1].ed+l)),n==null||n.forEach(c=>{c.st+=a,c.ed+=a}),r==null||r.forEach(c=>{c.startIndex+=a}),s==null||s.forEach(c=>{c.startIndex+=a,c.endIndex+=a}),i==null||i.forEach(c=>{c.startIndex+=a,c.endIndex+=l}),o==null||o.forEach(c=>{c.startIndex+=a,c.endIndex+=l}),{...e,dataStream:u,textRuns:n,paragraphs:r,customRanges:s,customDecorations:i,tables:o}}function cu(e,t,n){if(e.customRanges==null)return{};const{customRanges:r}=e;return{customRanges:r.filter(a=>Math.max(a.startIndex,t)<=Math.min(a.endIndex,n-1)).map(a=>({...a,startIndex:Math.max(a.startIndex,t),endIndex:Math.min(a.endIndex,n-1)})).map(a=>({...a,startIndex:a.startIndex-t,endIndex:a.endIndex-t})),leftOffset:0,rightOffset:0}}function hu(e,t,n){if(e.customDecorations==null)return;const{customDecorations:r=[]}=e,s=[];return r.forEach(i=>{if(Math.max(i.startIndex,t)<=Math.min(i.endIndex,n-1)){const o=ne.deepClone(i);s.push({...o,startIndex:Math.max(o.startIndex-t,0),endIndex:Math.min(o.endIndex,n-1)-t})}}),s}function z_(e,t,n){return e==null||t==null?e!=null?e:t:ou(e,t,n)}function G_(e,t,n){if(e==null||t==null)return e!=null?e:t;if(t.length===0||e.length===0)return e;if(t.length>1||e.length>1)throw new Error("Cannot cover multiple customRanges");return n===xe.REPLACE?[{...e[0]}]:[{...t[0],...e[0]}]}function V_(e,t,n){return t.length===0||e.length===0||n===xe.REPLACE?e:[...e,...t.filter(r=>!e.some(s=>r.id===s.id))]}function Xs(e,t,n=xe.COVER){if(t.dataStream!=="")throw new Error("Cannot compose other body with non-empty dataStream");const r={dataStream:e.dataStream},{textRuns:s,paragraphs:i=[],customRanges:o,customDecorations:a=[]}=e,{textRuns:l,paragraphs:u=[],customRanges:c,customDecorations:h=[]}=t;r.textRuns=z_(l,s,n),r.customRanges=G_(c,o,n);const d=V_(h,a,n);d.length&&(r.customDecorations=d);const f=[];let p=0,R=0;for(;p<i.length&&R<u.length;){const w=i[p],N=u[R],{startIndex:G}=w,{startIndex:W}=N;G===W?(f.push(ne.deepMerge(w,N)),p++,R++):G<W?(f.push(ne.deepClone(w)),p++):(f.push(ne.deepClone(N)),R++)}return p<i.length&&f.push(...i.slice(p)),R<u.length&&f.push(...u.slice(R)),f.length&&(r.paragraphs=f),r}function K_(e){const{body:t}=e;if(t==null)return!0;const{textRuns:n,paragraphs:r,customRanges:s,customBlocks:i,customDecorations:o,tables:a}=t;return n==null&&r==null&&s==null&&i==null&&o==null&&a==null}class Rn{constructor(t){C(this,"_index",0);C(this,"_offset",0);this._actions=t}hasNext(){return this.peekLength()<Number.POSITIVE_INFINITY}next(t){t||(t=Number.POSITIVE_INFINITY);const n=this._actions[this._index];if(n){const r=this._offset,s=n.len;return t>=s-r?(t=s-r,this._index+=1,this._offset=0):this._offset+=t,n.t===he.DELETE||n.t===he.RETAIN&&n.body==null?ne.deepClone({...n,len:t}):ne.deepClone({...n,len:t,body:Nt(n.body,r,r+t,!1)})}else return{t:he.RETAIN,len:Number.POSITIVE_INFINITY}}peek(){return this._actions[this._index]}peekLength(){return this._actions[this._index]?this._actions[this._index].len-this._offset:Number.POSITIVE_INFINITY}peekType(){const t=this._actions[this._index];return t?t.t:he.RETAIN}rest(){if(this.hasNext()){if(this._offset===0)return this._actions.slice(this._index);{const t=this._offset,n=this._index,r=this.next(),s=this._actions.slice(this._index);return this._offset=t,this._index=n,[r].concat(s)}}else return[]}}class fn{constructor(){C(this,"cursor",0)}reset(){return this.cursor=0,this}moveCursor(t){this.cursor+=t}moveCursorTo(t){this.cursor=t}}function du(e,t,n){const{dataStream:r}=e,s=n,i=n+t,o=eu(e,t,n),a=tu(e,t,n),l=nu(e,t,n),u=ru(e,t,n),c=su(e,t,n),h=M_(e,t,n),d=D_(e,t,n);let f="";return r&&(e.dataStream=xa(r,s,i),f=r.slice(s,i)),{dataStream:f,textRuns:o,paragraphs:a,sectionBreaks:l,customBlocks:u,tables:c,customRanges:h,customDecorations:d}}function fu(e,t,n,r){e.dataStream=La(e.dataStream,r,t.dataStream),Vl(e,t,n,r),Kl(e,t,n,r),Xl(e,t,n,r),ql(e,t,n,r),Jl(e,t,n,r),y_(e,t,n,r),N_(e,t,n,r)}function X_(e,t,n,r,s=xe.COVER){return U_(e,t,n,r,s)}function q_(e,t,n){return t<=0?{dataStream:""}:du(e,t,n)}function J_(e,t,n,r){n!==0&&fu(e,t,n,r)}function Z_(e,t){const n=new fn;return n.reset(),t.forEach(r=>{const s=ne.deepClone(r);switch(s.t){case he.RETAIN:{const{coverType:i,body:o,len:a}=s;o!=null&&X_(e,o,a,n.cursor,i),n.moveCursor(a);break}case he.INSERT:{const{body:i,len:o}=s;J_(e,i,o,n.cursor),n.moveCursor(o);break}case he.DELETE:{const{len:i}=s;q_(e,i,n.cursor);break}default:throw new Error(`Unknown action type for action: ${s}.`)}}),e}function Q_(e,t,n,r,s){if(e==null||t==null)return t;if(e.length===0||t.length===0)return[];t=ne.deepClone(t),e=ne.deepClone(e);const i=[],o=t.length,a=e.length;let l=0,u=0,c=null;function h(){return c?(i.push(c),c=null,!0):!1}for(;l<o&&u<a;){const{st:R,ed:w,ts:N}=t[l],{st:G,ed:W,ts:se,sId:y}=e[u];let A={};if(s===0)A={...N},n===xe.COVER&&r===xe.REPLACE&&se&&(A=Object.assign({},se,A));else if(A={...N},n===xe.REPLACE){if(r===xe.REPLACE)A={...se};else if(N&&se){const j=Object.keys(N);for(const Z of j)se[Z]&&delete A[Z]}}else if(r===xe.REPLACE){if(se){const j=Object.keys(se);for(const Z of j)se[Z]!==void 0&&(A[Z]=se[Z])}}else if(se){const j=Object.keys(se);for(const Z of j)A[Z]!==void 0&&delete A[Z]}if(w<G)h()||i.push(t[l]),l++;else if(W<R)h()||i.push(e[u]),u++;else{const j={st:Math.min(R,G),ed:Math.max(R,G),ts:R<G?{...N}:{...se}};j.ed>j.st&&i.push(),i.push({st:Math.max(R,G),ed:Math.min(w,W),ts:A,sId:y}),w<W?(l++,e[u].st=w,e[u].st===e[u].ed&&u++):(u++,t[l].st=W,t[l].st===t[l].ed&&l++);const Z={st:Math.min(w,W),ed:Math.max(w,W),ts:w<W?{...se}:{...N},sId:w<W?y:void 0};c=Z.ed>Z.st?Z:null}}h();const d=i[i.length-1],f=t[o-1],p=e[a-1];return d.ed!==Math.max(f.ed,p.ed)&&(f.ed>p.ed?i.push(f):i.push(p)),hr(i,!0)}function ep(e,t,n,r,s){if(e==null||t==null)return t;if(e.length===0||t.length===0)return[];if(e.length>1||t.length>1)throw new Error("CustomRanges is only supported transform for length one now.");const i=e[0],o=t[0];if(n===xe.REPLACE)return s===1?[ne.deepClone(i)]:[ne.deepClone(o)];if(r===xe.REPLACE){const a=ne.deepClone(o);return s===1&&Object.assign(a,ne.deepClone(i)),[a]}else{const a=ne.deepClone(o);return s===1&&Object.assign(a,ne.deepClone(i)),[a]}}function No(e,t,n,r,s){const i={startIndex:t.startIndex};if(t.paragraphStyle&&(i.paragraphStyle=ne.deepClone(t.paragraphStyle),e.paragraphStyle)){if(n===xe.REPLACE)if(r===xe.REPLACE)s===1&&(i.paragraphStyle={...e.paragraphStyle});else if(s===1){const o=Object.keys(e.paragraphStyle);for(const a of o)e.paragraphStyle[a]!==void 0&&(i.paragraphStyle[a]=e.paragraphStyle[a])}else{const o=Object.keys(e.paragraphStyle);for(const a of o)i.paragraphStyle[a]===void 0&&(i.paragraphStyle[a]=e.paragraphStyle[a])}else if(r===xe.REPLACE)if(s===1){const o=Object.keys(e.paragraphStyle);for(const a of o)e.paragraphStyle[a]!==void 0&&(i.paragraphStyle[a]=e.paragraphStyle[a])}else{const o=Object.keys(e.paragraphStyle);for(const a of o)i.paragraphStyle[a]===void 0&&(i.paragraphStyle[a]=e.paragraphStyle[a])}else if(s===1){const o=Object.keys(e.paragraphStyle);for(const a of o)i.paragraphStyle[a]&&delete i.paragraphStyle[a]}}return n===xe.REPLACE&&r===xe.REPLACE?i.bullet=s===1?ne.deepClone(e.bullet):ne.deepClone(t.bullet):e.bullet===void 0?i.bullet=ne.deepClone(t.bullet):n===xe.REPLACE||r===xe.REPLACE?i.bullet=s===0&&t.bullet?ne.deepClone(t.bullet):ne.deepClone(e.bullet):s===0&&t.bullet!==void 0&&(i.bullet=ne.deepClone(t.bullet)),i}function tp(e,t){if(e==null||t==null)return t;if(e.length===0||t.length===0)return ne.deepClone(t);const n=[];for(const r of t){const{id:s,type:i}=r;let o=!1;for(const a of e)if(a.id===s){(a.type===on.DELETED||i===on.DELETED)&&(o=!0,n.push({...r,type:on.DELETED}));break}o||n.push(r)}return n}function np(e,t,n=!1){const{body:r,coverType:s=xe.COVER}=e,{body:i,coverType:o=xe.COVER}=t;if(r==null||r.dataStream!==""||i==null||i.dataStream!=="")throw new Error("Data stream is not supported in retain transform.");const a={dataStream:""},l=o,{textRuns:u,paragraphs:c=[],customRanges:h,customDecorations:d}=r,{textRuns:f,paragraphs:p=[],customRanges:R,customDecorations:w}=i,N=Q_(u,f,s,o,n?1:0);N&&(a.textRuns=N);const G=ep(h,R,s,o,n?1:0);G&&(a.customRanges=G);const W=tp(d,w);W&&(a.customDecorations=W);const se=[];let y=0,A=0;for(;y<c.length&&A<p.length;){const j=c[y],Z=p[A],{startIndex:fe}=j,{startIndex:le}=Z;if(fe===le){let _={startIndex:fe};n?_=No(j,Z,s,o,1):_=No(j,Z,s,o,0),se.push(_),y++,A++}else fe<le?y++:(se.push(ne.deepClone(Z)),A++)}return A<p.length&&se.push(...p.slice(A)),se.length&&(a.paragraphs=se),{coverType:l,body:a}}function Mo(e){return Object.keys(e).length===1}const bn=class bn{constructor(){C(this,"_actions",[])}static apply(t,n){return Z_(t,n)}static compose(t,n){const r=new Rn(t),s=new Rn(n),i=new bn;for(;r.hasNext()||s.hasNext();)if(s.peekType()===he.INSERT)i.push(s.next());else if(r.peekType()===he.DELETE)i.push(r.next());else{const o=Math.min(r.peekLength(),s.peekLength()),a=r.next(o),l=s.next(o);if(a.t===he.INSERT&&l.t===he.RETAIN)l.body==null?i.push(a):i.push({...a,body:Xs(a.body,l.body,l.coverType)});else if(a.t===he.RETAIN&&l.t===he.RETAIN)if(a.body==null&&l.body==null)i.push(a.len!==Number.POSITIVE_INFINITY?a:l);else if(a.body&&l.body){const u=a.coverType===xe.REPLACE||l.coverType===xe.REPLACE?xe.REPLACE:xe.COVER;i.push({...a,t:he.RETAIN,coverType:u,body:Xs(a.body,l.body,l.coverType)})}else i.push(a.body?a:l);else a.t===he.RETAIN&&l.t===he.DELETE?i.push(l):a.t===he.INSERT&&(l.t,he.DELETE)}return i.trimEndUselessRetainAction(),i.serialize()}static transform(t,n,r="right"){return this._transform(n,t,r==="left"?"right":"left")}static _transform(t,n,r="right"){const s=new Rn(t),i=new Rn(n),o=new bn;for(;s.hasNext()||i.hasNext();)if(s.peekType()===he.INSERT&&(r==="left"||i.peekType()!==he.INSERT)){const a=s.next();o.retain(a.len)}else if(i.peekType()===he.INSERT)o.push(i.next());else{const a=Math.min(s.peekLength(),i.peekLength()),l=s.next(a),u=i.next(a);if(l.t===he.DELETE)continue;if(u.t===he.DELETE){o.push(u);continue}if(l.body==null||u.body==null)o.push(u);else{const{coverType:c,body:h}=np(l,u,r==="left");o.push({...u,t:he.RETAIN,coverType:c,body:h})}}return o.trimEndUselessRetainAction(),o.serialize()}static transformPosition(t,n,r=!1){const s=new Rn(t);let i=0;for(;s.hasNext()&&i<=n;){const o=s.peekLength(),a=s.peekType();if(s.next(),a===he.DELETE){n-=Math.min(o,n-i);continue}else a===he.INSERT&&(i<n||!r)&&(n+=o);i+=o}return n}static isNoop(t){return t.length===0}static invert(t){const n=[];for(const r of t)if(r.t===he.INSERT)n.push({t:he.DELETE,len:r.len,body:r.body});else if(r.t===he.DELETE){if(r.body==null)throw new Error("Can not invert DELETE action without body property, makeInvertible must be called first.");n.push({t:he.INSERT,body:r.body,len:r.len})}else if(r.body!=null){if(r.oldBody==null)throw new Error("Can not invert RETAIN action without oldBody property, makeInvertible must be called first.");n.push({t:he.RETAIN,body:r.oldBody,oldBody:r.body,len:r.len,coverType:xe.REPLACE})}else n.push(r);return n}static makeInvertible(t,n){const r=[];let s=0;for(const i of t){if(i.t===he.DELETE&&(i.body==null||i.body&&i.body.dataStream.length!==i.len)){const o=Nt(n,s,s+i.len,!1);i.len=o.dataStream.length,i.body=o}if(i.t===he.RETAIN&&i.body!=null){const o=Nt(n,s,s+i.len,!0);i.oldBody={...o,dataStream:""},i.len=o.dataStream.length}r.push(i),i.t!==he.INSERT&&(s+=i.len)}return r}insert(t,n){const r={t:he.INSERT,body:n,len:t};return this.push(r),this}retain(t,n,r){const s={t:he.RETAIN,len:t};return n!=null&&(s.body=n),r!=null&&(s.coverType=r),this.push(s),this}delete(t){const n={t:he.DELETE,len:t};return this.push(n),this}empty(){return this._actions=[],this}serialize(){return this._actions}push(...t){if(t.length>1){for(const i of t)this.push(i);return this}let n=this._actions.length,r=this._actions[n-1];const s=ne.deepClone(t[0]);if(s.t===he.RETAIN&&s.len===0&&s.body==null)return this;if(typeof r=="object"){if(r.t===he.DELETE&&s.t===he.DELETE)return r.len+=s.len,this;if(r.t===he.DELETE&&s.t===he.INSERT&&(n-=1,r=this._actions[n-1],r==null))return this._actions.unshift(s),this;if(r.t===he.RETAIN&&s.t===he.RETAIN&&r.body==null&&s.body==null)return r.len+=s.len,this;if(r.t===he.INSERT&&Mo(r.body)&&s.t===he.INSERT&&Mo(s.body))return r.len+=s.len,r.body.dataStream+=s.body.dataStream,this}return n===this._actions.length?this._actions.push(s):this._actions.splice(n,0,s),this}trimEndUselessRetainAction(){let t=this._actions[this._actions.length-1];for(;t&&t.t===he.RETAIN&&K_(t);)this._actions.pop(),t=this._actions[this._actions.length-1];return this}};C(bn,"id","text-x"),C(bn,"uri","https://github.com/dream-num/univer#text-x");let Ye=bn;Object.defineProperty(Ye,"name",{value:"text-x"});const An=class An{static registerSubtype(t){var n;t==null||this._subTypes.has(t.name)&&((n=this._subTypes.get(t.name))==null?void 0:n.id)!==Ye.id||(this._subTypes.set(t.name,t),mt.type.registerSubtype(t))}static apply(t,n){if(!mt.type.isNoop(n))return mt.type.apply(t,n)}static compose(t,n){return mt.type.compose(t,n)}static transform(t,n,r){return mt.type.transform(t,n,r)}static transformPosition(t,n,r="right"){return t&&t.length===2&&t[0]==="body"&&t[1].et===Ye.name?Ye.transformPosition(t[1].e,n,r==="left"):n}static invertWithDoc(t,n){return mt.type.invertWithDoc(t,n)}static isNoop(t){return mt.type.isNoop(t)}static getInstance(){return this._instance==null&&(this._instance=new An),this._instance}removeOp(t,n){return mt.removeOp(t,n)}moveOp(t,n){return mt.moveOp(t,n)}insertOp(t,n){return mt.insertOp(t,n)}replaceOp(t,n,r){return mt.replaceOp(t,n,r)}editOp(t,n=["body"]){return mt.editOp(n,Ye.name,t)}};C(An,"uri","https://github.com/dream-num/univer#json-x"),C(An,"_subTypes",new Map),C(An,"_instance",null);let $t=An;$t.registerSubtype(Ye);const Oi={id:"default_doc",documentStyle:{}};class rp extends ls{constructor(n){var r;super();C(this,"type",Be.UNIVER_DOC);C(this,"_name$",new Oe.BehaviorSubject(""));C(this,"name$",this._name$.asObservable());C(this,"snapshot");this.snapshot={...Oi,...n},this._name$.next((r=this.snapshot.title)!=null?r:"No Title")}getUnitId(){throw new Error("Method not implemented.")}getRev(){var n;return(n=this.snapshot.rev)!=null?n:1}incrementRev(){this.snapshot.rev=this.getRev()+1}setRev(n){this.snapshot.rev=n}setName(n){this.snapshot.title=n,this._name$.next(n)}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get zoomRatio(){var n;return((n=this.snapshot.settings)==null?void 0:n.zoomRatio)||1}resetDrawing(n,r){this.snapshot.drawings=n,this.snapshot.drawingsOrder=r}getBody(){return this.snapshot.body}getSnapshot(){return this.snapshot}getBulletPresetList(){var s;const n=(s=this.snapshot.lists)!=null?s:{};return{...dr,...n}}updateDocumentId(n){this.snapshot.id=n}updateDocumentRenderConfig(n){const{documentStyle:r}=this.snapshot;r.renderConfig==null?r.renderConfig=n:r.renderConfig={...r.renderConfig,...n}}getDocumentStyle(){return this.snapshot.documentStyle}updateDocumentStyle(n){this.snapshot.documentStyle==null?this.snapshot.documentStyle=n:this.snapshot.documentStyle={...this.snapshot.documentStyle,...n}}updateDocumentDataMargin(n){const{t:r,l:s,b:i,r:o}=n,{documentStyle:a}=this.snapshot;r!=null&&(a.marginTop=r),s!=null&&(a.marginLeft=s),i!=null&&(a.marginBottom=i),o!=null&&(a.marginRight=o)}updateDocumentDataPageSize(n,r){const{documentStyle:s}=this.snapshot;if(!s.pageSize){n=n!=null?n:Number.POSITIVE_INFINITY,r=r!=null?r:Number.POSITIVE_INFINITY,s.pageSize={width:n,height:r};return}n!==void 0&&(s.pageSize.width=n),r!==void 0&&(s.pageSize.height=r)}updateDrawing(n,r){const{drawings:s}=this,{width:i,height:o,left:a,top:l}=r,u=s==null?void 0:s[n];if(!u)return;const c=u.docTransform;c.size.width=i,c.size.height=o,c.positionH.posOffset=a,c.positionV.posOffset=l}setZoomRatio(n=1){this.snapshot.settings==null?this.snapshot.settings={zoomRatio:n}:this.snapshot.settings.zoomRatio=1}setDisabled(n){this.snapshot.disabled=n}getDisabled(){return this.snapshot.disabled}getTitle(){return this.snapshot.title}}class Mt extends rp{constructor(n){var s,i;super(ne.isEmptyObject(n)?R_():n);C(this,"_unitId");C(this,"headerModelMap",new Map);C(this,"footerModelMap",new Map);C(this,"change$",new Oe.BehaviorSubject(0));const r=6;this._unitId=(s=this.snapshot.id)!=null?s:ne.generateRandomId(r),this._initializeHeaderFooterModel(),this._name$.next((i=this.snapshot.title)!=null?i:"")}dispose(){super.dispose(),this.headerModelMap.forEach(n=>{n.dispose()}),this.footerModelMap.forEach(n=>{n.dispose()}),this._name$.complete()}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getCustomRanges(){var n;return(n=this.snapshot.body)==null?void 0:n.customRanges}getCustomDecorations(){var n;return(n=this.snapshot.body)==null?void 0:n.customDecorations}getSettings(){return this.snapshot.settings}reset(n){if(n.id&&n.id!==this._unitId)throw new Error("Cannot reset a document model with a different unit id!");this.snapshot={...Oi,...n},this._initializeHeaderFooterModel(),this.change$.next(this.change$.value+1)}getSelfOrHeaderFooterModel(n){if(n!=null){if(this.headerModelMap.has(n))return this.headerModelMap.get(n);if(this.footerModelMap.has(n))return this.footerModelMap.get(n)}return this}getUnitId(){return this._unitId}apply(n){if(!$t.isNoop(n))return this.snapshot=$t.apply(this.snapshot,n),n!=null&&n.some(r=>Array.isArray(r)&&((r==null?void 0:r[0])==="headers"||(r==null?void 0:r[0])==="footers"))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.change$.next(this.change$.value+1),this.snapshot}sliceBody(n,r,s=vi.copy){const i=this.getBody();if(i!=null)return Nt(i,n,r,!1,s)}_initializeHeaderFooterModel(){const{headers:n,footers:r}=this.getSnapshot();if(n)for(const s in n){const i=n[s];this.headerModelMap.set(s,new Mt(i)),this.headerModelMap.get(s).updateDocumentId(this.getUnitId())}if(r)for(const s in r){const i=r[s];this.footerModelMap.set(s,new Mt(i)),this.footerModelMap.get(s).updateDocumentId(this.getUnitId())}}updateDocumentId(n){super.updateDocumentId(n),this._unitId=n}getPlainText(){var n,r;return rs((r=(n=this.getBody())==null?void 0:n.dataStream)!=null?r:"")}}function sp(e){const{ranges:t,id:n,type:r}=e,s=new Ye;let i=0;for(let o=0;o<t.length;o++){const a=t[o],{startOffset:l,endOffset:u}=a;l>0&&s.push({t:he.RETAIN,len:l-i}),s.push({t:he.RETAIN,body:{dataStream:"",customDecorations:[{id:n,type:r,startIndex:0,endIndex:u-l-1}]},len:u-l}),i=u}return s}function ip(e){var c,h,d;const{id:t,segmentId:n,documentDataModel:r}=e,s=r==null?void 0:r.getBody();if(!r||!s)return!1;const i=(d=(h=(c=r.getSelfOrHeaderFooterModel(n))==null?void 0:c.getBody())==null?void 0:h.customDecorations)==null?void 0:d.find(f=>f.id===t);if(!i)return!1;const o=new Ye,{startIndex:a,endIndex:l}=i,u=l-a+1;return o.push({t:he.RETAIN,len:a}),o.push({t:he.RETAIN,len:u,body:{dataStream:"",customDecorations:[{startIndex:0,endIndex:u-1,id:t,type:on.DELETED}]}}),o}function gu(e,t,n,r){return e<=n&&t>=n||e>=n&&e<=r}function op(e,t){const n=[];for(let r=0,s=t.length;r<s;r++){const i=t[r];e.collapsed?i.startIndex<e.startOffset&&e.startOffset<=i.endIndex&&n.push(i):gu(e.startOffset,e.endOffset-1,i.startIndex,i.endIndex)&&n.push(i)}return n}function ap(e){return{...ne.deepClone(e),rangeId:Bt()}}function lp(e,t){const n=[];let r=e[0];for(const s of t)s<e[0]||s>e[1]||(r<s&&n.push([r,s-1]),r=s+1);return r<=e[1]&&n.push([r,e[1]]),n}function mu(e,t,n,r){const s=[];for(let i=0,o=n.length;i<o;i++){const a=n[i];if((r===void 0||a.rangeType===r)&&Math.max(a.startIndex,e)<=Math.min(a.endIndex,t)&&s.push({...a}),a.startIndex>t)break}return s}function up(e,t){var i,o,a,l,u;const n=mu(e.startOffset,e.collapsed?e.startOffset:e.endOffset-1,(i=t.customRanges)!=null?i:[]),r=Math.min(e.startOffset,(a=(o=n[0])==null?void 0:o.startIndex)!=null?a:1/0),s=Math.max(e.endOffset,((u=(l=n[n.length-1])==null?void 0:l.endIndex)!=null?u:-1/0)+1);return{startOffset:r,endOffset:s,collapsed:r===s}}function cp(e){var h,d,f;const{rangeId:t,segmentId:n,documentDataModel:r,insert:s}=e,i=(d=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.customRanges)==null?void 0:d.find(p=>p.rangeId===t);if(!i)return!1;const{startIndex:o,endIndex:a}=i,l=new Ye,u=a-o+1;l.push({t:he.RETAIN,len:o}),l.push({t:he.RETAIN,len:u,body:{dataStream:"",customRanges:[]}}),s&&l.push({t:he.INSERT,body:s,len:s.dataStream.length});const c=a+1+((f=s==null?void 0:s.dataStream.length)!=null?f:0);return l.selections=[{startOffset:c,endOffset:c,collapsed:!0}],l}function hp(e){const{ranges:t,rangeId:n,rangeType:r,wholeEntity:s,properties:i,body:o}=e;let a=0;const l=new Ye;let u=!1;return t.forEach(c=>{var W,se,y;const h=up(c,o);if(!h||!o)return!1;const{startOffset:d,endOffset:f}=h,p=(W=o.customRanges)!=null?W:[],R=(A,j,Z)=>{var v,D,b,O;const fe=mu(A,j,p,r),le=Math.min((D=(v=fe[0])==null?void 0:v.startIndex)!=null?D:1/0,A),_=Math.max((O=(b=fe[fe.length-1])==null?void 0:b.endIndex)!=null?O:-1/0,j),H={rangeId:Z?`${n}$${Z}`:n,rangeType:r,startIndex:0,endIndex:_-le,wholeEntity:s,properties:{...i}};l.push({t:he.RETAIN,len:le-a}),l.push({t:he.RETAIN,len:_-le+1,body:{dataStream:"",customRanges:[H]},coverType:xe.COVER}),a=_+1},w=((se=o.paragraphs)!=null?se:[]).filter(A=>A.startIndex<f&&A.startIndex>d),N=((y=o.customBlocks)!=null?y:[]).filter(A=>A.startIndex<f&&A.startIndex>d);lp([d,f-1],[...w.map(A=>A.startIndex),...N.map(A=>A.startIndex)]).forEach(([A,j],Z)=>R(A,j,Z)),u=!0,l.selections=[{startOffset:h.endOffset,endOffset:h.endOffset,collapsed:!0}]}),u?l:!1}function _u(e,t,n=0,r=null,s=!0){e.sort((u,c)=>u.startOffset-c.startOffset);const i=[],{paragraphs:o=[]}=t,a=o==null?void 0:o.find(u=>u.startIndex>=e[0].startOffset&&u.startIndex<e[0].endOffset);let l=n;if(e.forEach(u=>{const{startOffset:c,endOffset:h}=u;c>l&&(i.push({t:he.RETAIN,len:c-l}),l=c),l<h&&(i.push({t:he.DELETE,len:h-l}),l=h)}),r&&i.push({t:he.INSERT,body:r,len:r.dataStream.length}),a&&s){const u=o.find(c=>c.startIndex-n>=e[e.length-1].endOffset-1);u&&(u.startIndex>l&&(i.push({t:he.RETAIN,len:u.startIndex-l}),l=u.startIndex),i.push({t:he.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...u,startIndex:0,bullet:a==null?void 0:a.bullet}]},coverType:xe.REPLACE}))}return i}function dp(e,t,n=0){const r=[];let s=n;return e.forEach(i=>{const{startOffset:o,endOffset:a}=i;o>s&&(r.push({t:he.RETAIN,len:o-s}),s=o),a>s&&(r.push({t:he.RETAIN,len:a-s,body:{...ne.deepClone(t),dataStream:""}}),s=a)}),r}const fp=e=>{var h;const{selection:t,body:n,doc:r}=e,s=t.segmentId,i=(h=r.getSelfOrHeaderFooterModel(s))==null?void 0:h.getBody();if(!i)return!1;const o=t.collapsed?null:Nt(i,t.startOffset,t.endOffset),a=Ri(o?o.dataStream:"",n.dataStream);let l=0;const u=a.map(([d,f])=>{switch(d){case 0:{const p={t:he.RETAIN,body:{...Nt(n,l,l+f.length,!1),dataStream:""},len:f.length};return l+=f.length,p}case 1:{const p={t:he.INSERT,body:Nt(n,l,l+f.length),len:f.length};return l+=f.length,p}default:return{t:he.DELETE,len:f.length}}}),c=new Ye;return c.push({t:he.RETAIN,len:t.startOffset}),c.push(...u),c};function gp(e,t){return!!((e==null?void 0:e.length)===(t==null?void 0:t.length)&&(e!=null&&e.every((n,r)=>JSON.stringify(n)===JSON.stringify(t==null?void 0:t[r]))))}const mp=e=>{var h;const{selection:t,body:n,doc:r}=e,s=t.segmentId,i=(h=r.getSelfOrHeaderFooterModel(s))==null?void 0:h.getBody();if(!i)return!1;const o=t.collapsed?null:Nt(i,t.startOffset,t.endOffset),a=Ri(o?o.dataStream:"",n.dataStream);let l=0;const u=a.map(([d,f])=>{switch(d){case 0:{const p=Kr(n,l,l+f.length,!1),R=Kr(o,l,l+f.length,!1),w={t:he.RETAIN,body:gp(p,R)?void 0:{textRuns:p,dataStream:""},len:f.length};return l+=f.length,w}case 1:{const p={t:he.INSERT,body:Nt(n,l,l+f.length),len:f.length};return l+=f.length,p}default:return{t:he.DELETE,len:f.length}}});if(u.every(d=>d.t===he.RETAIN&&!d.body))return!1;const c=new Ye;return c.push({t:he.RETAIN,len:t.startOffset}),c.push(...u),c};function _p(e,t){const n=[],{customBlocks:r=[]}=e;for(const s of t){const{startOffset:i,endOffset:o}=s;if(!(i==null||o==null))for(const a of r){const{startIndex:l}=a;l>=i&&l<o&&n.push(a.blockId)}}return n}function pp(e,t=""){if(!t)return["body"];const{headers:n,footers:r}=e.getSnapshot();if(n==null&&r==null)throw new Error("Document data model must have headers or footers when update by segment id");if((n==null?void 0:n[t])!=null)return["headers",t,"body"];if((r==null?void 0:r[t])!=null)return["footers",t,"body"];throw new Error("Segment id not found in headers or footers")}const Ep=e=>{var R,w,N,G;const{selection:t,documentDataModel:n,drawings:r}=e,{collapsed:s,startOffset:i,segmentId:o}=t,a=new Ye,l=$t.getInstance(),u=[],c=n.getSelfOrHeaderFooterModel(o).getBody();if(!c)return!1;const h=(w=(R=n.getSnapshot().drawingsOrder)==null?void 0:R.length)!=null?w:0;let d=0;if(s)i>0&&a.push({t:he.RETAIN,len:i});else{const W=_u([t],c,0,null,!1);a.push(...W);const se=_p(c,[t]),y=(N=n.getDrawings())!=null?N:{},A=(G=n.getDrawingsOrder())!=null?G:[],j=se.sort((Z,fe)=>A.indexOf(Z)>A.indexOf(fe)?-1:A.indexOf(Z)<A.indexOf(fe)?1:0);if(j.length>0)for(const Z of j){const fe=y[Z],le=A.indexOf(Z);if(fe==null||le<0)continue;const _=l.removeOp(["drawings",Z],fe),H=l.removeOp(["drawingsOrder",le],Z);u.push(_),u.push(H),d++}}a.push({t:he.INSERT,body:{dataStream:"\b".repeat(r.length),customBlocks:r.map((W,se)=>({startIndex:se,blockId:W.drawingId}))},len:r.length});const f=pp(n,o),p=l.editOp(a.serialize(),f);u.push(p);for(const W of r){const{drawingId:se}=W,y=l.insertOp(["drawings",se],W),A=l.insertOp(["drawingsOrder",h-d],se);u.push(y),u.push(A)}return u.reduce((W,se)=>$t.compose(W,se),null)};function Cp(e,t){if(typeof t>"u")return{startOffset:e,endOffset:e,collapsed:!0};if(t<e)throw new Error(`Cannot make a doc selection when endOffset ${t} is less than startOffset ${e}.`);return{startOffset:e,endOffset:t,collapsed:e===t}}function Rp(e){const{startOffset:t,endOffset:n,collapsed:r}=e,s=Math.min(t,n),i=Math.max(t,n);return{startOffset:s,endOffset:i,collapsed:r}}function Ip(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function qs(e,t,n,r){const{startOffset:s,endOffset:i}=e,o=r!=null?r:wi(t,n),a=[];let l=-1;for(let u=0;u<o.length;u++){const c=o[u],{startIndex:h}=c;(s>l&&s<=h||i>l&&i<=h||h>=s&&h<=i)&&a.push(c),l=h}return a}function Js(e,t,n){const r=[],s=wi(t,n);for(const i of e){const o=qs(i,t,n,s);r.push(...o)}return r}const Sp=[_t.PARAGRAPH,_t.TABLE_START,_t.TABLE_END,_t.TABLE_ROW_START,_t.TABLE_CELL_START,_t.TABLE_CELL_END];function wi(e,t){const n=[];for(let r=0;r<e.length;r++){const s=e[r],{startIndex:i}=s;let o=i-1;for(;!Sp.includes(t[o])&&o>=0;)o--;n.push({...s,paragraphStart:o+1,paragraphEnd:s.startIndex})}return n}const vp=e=>{var h,d,f;const{paragraphs:t,segmentId:n,document:r}=e;let s=e.listType;const i=(d=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.paragraphs)!=null?d:[],o=t.every(p=>{var R;return((R=p.bullet)==null?void 0:R.listType.indexOf(s))===0});let l=ne.generateRandomId(6);if(t.length===1){const p=i.indexOf(t[0]),R=i[p-1],w=i[p+1];R&&R.bullet&&R.bullet.listType.indexOf(s)===0?(l=R.bullet.listId,s!==Ut.CHECK_LIST&&(s=R.bullet.listType)):w&&w.bullet&&w.bullet.listType.indexOf(s)===0&&(l=w.bullet.listId,s!==Ut.CHECK_LIST&&(s=w.bullet.listType))}const u=new fn;u.reset();const c=new Ye;for(const p of t){const{startIndex:R,paragraphStyle:w={},bullet:N}=p;c.push({t:he.RETAIN,len:R-u.cursor}),c.push({t:he.RETAIN,len:1,body:{dataStream:"",paragraphs:[o?{paragraphStyle:w,startIndex:0}:{startIndex:0,paragraphStyle:{...w},bullet:{nestingLevel:(f=N==null?void 0:N.nestingLevel)!=null?f:0,textStyle:{fs:20},listType:s,listId:l}}]},coverType:xe.REPLACE}),u.moveCursorTo(R+1)}return c},Op=e=>{var h;const{paragraphIndex:t,segmentId:n,document:r}=e,s=(h=r.getSelfOrHeaderFooterModel(n).getBody())==null?void 0:h.paragraphs;if(s==null)return!1;const i=s.find(d=>d.startIndex===t);if(!(i!=null&&i.bullet)||i.bullet.listType.indexOf(Ut.CHECK_LIST)===-1)return!1;const o=new fn;o.reset();const a=new Ye,{startIndex:l,paragraphStyle:u={}}=i,c=i.bullet.listType===Ut.CHECK_LIST?Ut.CHECK_LIST_CHECKED:Ut.CHECK_LIST;return a.push({t:he.RETAIN,len:l-o.cursor}),a.push({t:he.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...i,paragraphStyle:u,startIndex:0,bullet:{...i.bullet,listType:c}}]},coverType:xe.REPLACE}),o.moveCursorTo(l+1),a},wp=e=>{var c,h;const{paragraphs:t,listType:n,segmentId:r,document:s}=e;if(((c=s.getSelfOrHeaderFooterModel(r).getBody())==null?void 0:c.paragraphs)==null)return!1;const a=ne.generateRandomId(6),l=new fn;l.reset();const u=new Ye;for(const d of t){const{startIndex:f,paragraphStyle:p={},bullet:R}=d;u.push({t:he.RETAIN,len:f-l.cursor}),u.push({t:he.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:p,bullet:{nestingLevel:(h=R==null?void 0:R.nestingLevel)!=null?h:0,textStyle:(R==null?void 0:R.listType)===n?R.textStyle:{fs:20},listType:n,listId:a}}]},coverType:xe.REPLACE}),l.moveCursorTo(f+1)}return u};function bp(e,t){return t.some(n=>e.startIndex>n.startIndex&&e.startIndex<n.endIndex)}const Ap=e=>{var u,c,h;const{paragraphs:t,document:n,type:r}=e,s=new fn;s.reset();const i=new Ye,o=(u=n.getSnapshot().lists)!=null?u:{},a=(h=(c=n.getBody())==null?void 0:c.tables)!=null?h:[],l={...dr,...o};for(const d of t){const{startIndex:f,paragraphStyle:p={},bullet:R}=d,w=bp(d,a);if(i.push({t:he.RETAIN,len:f-s.cursor}),R){const N=R.listType;let G=l[N].nestingLevel.length-1;w&&(G=Math.min(G,2)),i.push({t:he.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:{...p},bullet:{...R,nestingLevel:Math.max(Math.min(R.nestingLevel+r,G),0)}}]},coverType:xe.REPLACE})}else i.push({t:he.RETAIN,len:1});s.moveCursorTo(f+1)}return i},Tp=e=>{var w,N,G,W;const{textRanges:t,segmentId:n,document:r,style:s,paragraphTextRun:i,cursor:o,deleteLen:a,textX:l}=e,u=r.getSelfOrHeaderFooterModel(n),c=(N=(w=u.getBody())==null?void 0:w.paragraphs)!=null?N:[],h=(W=(G=u.getBody())==null?void 0:G.dataStream)!=null?W:"",d=Js(t,c,h),f=new fn;o&&f.moveCursorTo(o);const p=l!=null?l:new Ye;d.sort((se,y)=>se.startIndex-y.startIndex);const R=Math.max(0,d[0].paragraphStart-1);R>f.cursor&&(p.push({t:he.RETAIN,len:R-f.cursor}),f.moveCursorTo(R)),a&&p.push({t:he.DELETE,len:a});for(const se of d){const{startIndex:y,paragraphStyle:A={}}=se,j=y-f.cursor;p.push({t:he.RETAIN,len:j,...i?{body:{dataStream:"",textRuns:[{ts:i,st:0,ed:j}]},coverType:xe.REPLACE}:null}),p.push({t:he.RETAIN,len:1,body:{dataStream:"",paragraphs:[{startIndex:0,paragraphStyle:{...A,...s}}]},coverType:xe.REPLACE}),f.moveCursorTo(y+1)}return p};class ot{}C(ot,"customRange",{add:hp,delete:cp,copyCustomRange:ap,getCustomRangesInterestsWithSelection:op,isIntersecting:gu}),C(ot,"customDecoration",{add:sp,delete:ip}),C(ot,"selection",{replace:fp,makeSelection:Cp,normalizeSelection:Rp,delete:_u,replaceTextRuns:mp,retain:dp}),C(ot,"range",{isIntersects:Ip,getParagraphsInRange:qs,getParagraphsInRanges:Js}),C(ot,"transform",{getPlainText:rs,fromPlainText:ff,isEmptyDocument:df}),C(ot,"paragraph",{bullet:{set:wp,switch:vp,toggleChecklist:Op,changeNestLevel:Ap},style:{set:Tp},util:{transform:wi,getParagraphsInRange:qs,getParagraphsInRanges:Js}}),C(ot,"drawing",{add:Ep});function yp(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 pu(e){var t;return e.body=yp((t=e.body)!=null?t:{dataStream:""}),e.drawingsOrder||(e.drawingsOrder=[]),e.drawings||(e.drawings={}),e.documentStyle||(e.documentStyle={}),e}class fr{constructor(t={}){C(this,"_style");this._style=t}static create(t={}){return new fr(t)}get fontFamily(){return this._style.ff}get fontSize(){return this._style.fs}get italic(){return this._style.it===Ie.TRUE}get bold(){return this._style.bl===Ie.TRUE}get underline(){return this._style.ul&&Vt.create(this._style.ul)}get bottomBorderLine(){return this._style.bbl&&Vt.create(this._style.bbl)}get strikethrough(){return this._style.st&&Vt.create(this._style.st)}get overline(){return this._style.ol&&Vt.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 Jt.create(ne.deepClone(this._style))}getValue(){return{...this._style}}}class Jt extends fr{static create(t={}){return new Jt(t)}constructor(t={}){super(t)}setFontFamily(t){return this._style.ff=t,this}setFontSize(t){return this._style.fs=t,this}setItalic(t){return this._style.it=t?1:0,this}setBold(t){return this._style.bl=t?1:0,this}setUnderline(t){return this._style.ul=t.build(),this}setBottomBorderLine(t){return this._style.bbl=t.build(),this}setStrikethrough(t){return this._style.st=t.build(),this}setOverline(t){return this._style.ol=t.build(),this}setBackground(t){return this._style.bg=t,this}setBorder(t){return this._style.bd=t,this}setColor(t){return this._style.cl=t,this}setVerticalAlign(t){return this._style.va=t,this}copy(){return Jt.create(ne.deepClone(this._style))}build(){return this.getValue()}}class Vt{constructor(t={s:1}){C(this,"_decoration");this._decoration=t}static create(t={s:1}){return new Vt(t)}get show(){return this._decoration.s===Ie.TRUE}get followFontColor(){return this._decoration.c===Ie.TRUE}get color(){return this._decoration.cl}get type(){return this._decoration.t}setShow(t){return this._decoration.s=t?1:0,this}setFollowFontColor(t){return this._decoration.c=t?1:0,this}setColor(t){return this._decoration.cl=t,this}setLineType(t){return this._decoration.t=t,this}copy(){return Vt.create(ne.deepClone(this._decoration))}build(){return{...this._decoration}}}class gr{constructor(t={}){C(this,"_style");this._style=t}static create(t={}){return new gr(t)}get indentFirstLine(){return this._style.indentFirstLine}get hanging(){return this._style.hanging}get indentStart(){return this._style.indentStart}get tabStops(){return this._style.tabStops}get indentEnd(){return this._style.indentEnd}get textStyle(){return this._style.textStyle}get headingId(){return this._style.headingId}get namedStyleType(){return this._style.namedStyleType}get horizontalAlign(){return this._style.horizontalAlign}get lineSpacing(){return this._style.lineSpacing}get direction(){return this._style.direction}get spacingRule(){return this._style.spacingRule}get snapToGrid(){return this._style.snapToGrid}get spaceAbove(){return this._style.spaceAbove}get spaceBelow(){return this._style.spaceBelow}get borderBetween(){return this._style.borderBetween}get borderTop(){return this._style.borderTop}get borderBottom(){return this._style.borderBottom}get borderLeft(){return this._style.borderLeft}get borderRight(){return this._style.borderRight}get keepLines(){return this._style.keepLines===Ie.TRUE}get keepNext(){return this._style.keepNext===Ie.TRUE}get wordWrap(){return this._style.wordWrap===Ie.TRUE}get widowControl(){return this._style.widowControl===Ie.TRUE}get shading(){return this._style.shading}get suppressHyphenation(){return this._style.suppressHyphenation===Ie.TRUE}copy(){return er.create(ne.deepClone(this._style))}getValue(){return this._style}}class er extends gr{static create(t={}){return new er(t)}constructor(t={}){super(t)}setIndentFirstLine(t){return this._style.indentFirstLine=t,this}setHanging(t){return this._style.hanging=t,this}setIndentStart(t){return this._style.indentStart=t,this}setTabStops(t){return this._style.tabStops=t,this}setIndentEnd(t){return this._style.indentEnd=t,this}setTextStyle(t){return this._style.textStyle=t,this}setHeadingId(t){return this._style.headingId=t,this}setNamedStyleType(t){return this._style.namedStyleType=t,this}setHorizontalAlign(t){return this._style.horizontalAlign=t,this}setLineSpacing(t){return this._style.lineSpacing=t,this}setDirection(t){return this._style.direction=t,this}setSpacingRule(t){return this._style.spacingRule=t,this}setSnapToGrid(t){return this._style.snapToGrid=t?1:0,this}setSpaceAbove(t){return this._style.spaceAbove=t,this}setSpaceBelow(t){return this._style.spaceBelow=t,this}setBorderBetween(t){return this._style.borderBetween=t,this}setBorderTop(t){return this._style.borderTop=t,this}setBorderBottom(t){return this._style.borderBottom=t,this}setBorderLeft(t){return this._style.borderLeft=t,this}setBorderRight(t){return this._style.borderRight=t,this}setKeepLines(t){return this._style.keepLines=t?1:0,this}setKeepNext(t){return this._style.keepNext=t?1:0,this}setWordWrap(t){return this._style.wordWrap=t?1:0,this}setWidowControl(t){return this._style.widowControl=t?1:0,this}setShading(t){return this._style.shading=t,this}setSuppressHyphenation(t){return this._style.suppressHyphenation=t?1:0,this}copy(){return er.create(ne.deepClone(this._style))}build(){return this.getValue()}}class Kt{constructor(t){C(this,"_data");if(!t.body)throw new Error("Invalid document data, body is required");this._data=pu(t)}static create(t){return new Kt(t)}static createByBody(t){return new Kt({body:t,id:"d",documentStyle:{}})}copy(){return an.create(ne.deepClone(this._data))}slice(t,n){const{body:r,...s}=this._data;return an.create({...ne.deepClone(s),body:Nt(r,t,n)})}toPlainText(){var t,n;return ot.transform.getPlainText((n=(t=this._data.body)==null?void 0:t.dataStream)!=null?n:"").replaceAll("\r",`
|
|
7
7
|
`)}getParagraphStyle(){var t,n;return gr.create((n=(t=this._data.body)==null?void 0:t.paragraphs)==null?void 0:n[0].paragraphStyle)}getParagraphBullet(){var t,n;return(n=(t=this._data.body)==null?void 0:t.paragraphs)==null?void 0:n[0].bullet}getParagraphs(){var r,s;const t=(s=(r=this._data.body)==null?void 0:r.paragraphs)!=null?s:[];let n=0;return t.map(i=>{const o=this.slice(n,i.startIndex);return n=i.startIndex,o})}getTextRuns(){var t,n;return((n=(t=this._data.body)==null?void 0:t.textRuns)!=null?n:[]).map(r=>({...r,ts:r.ts?fr.create(r.ts):null}))}getLinks(){var t,n,r;return(r=(n=(t=this._data.body)==null?void 0:t.customRanges)==null?void 0:n.filter(s=>s.rangeType===Zt.HYPERLINK))!=null?r:[]}getData(){return this._data}}class an extends Kt{constructor(n){super(n);C(this,"_doc");this._doc=new Mt(n)}static newEmptyData(){return pu({id:"d",documentStyle:{},drawings:{},drawingsOrder:[],body:{dataStream:`\r
|
|
8
|
-
`,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(n){return new an(n!=null?n:an.newEmptyData())}insertText(n,r,s){var c,h;let i=((h=(c=this._data.body)==null?void 0:c.dataStream.length)!=null?h:2)-2,o,a;if(typeof n=="string"?o=n:(i=Math.min(n,i),o=r),typeof r=="object"?a=r instanceof Jt?r.build():r:a=s instanceof Jt?s.build():s,!o)return this;const l={dataStream:o,textRuns:a?[{ts:a,st:i,ed:i+o.length}]:[]},u=ot.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:l});if(!u)throw new Error("Insert text failed, please check.");return Ye.apply(this._doc.getBody(),u.serialize()),this}insertRichText(n,r){var a,l;let s=((l=(a=this._data.body)==null?void 0:a.dataStream.length)!=null?l:2)-2,i;typeof n=="object"?i=n instanceof Kt?n.getData():n:(s=Math.min(n,s),i=r instanceof Kt?r.getData():r);const o=ot.selection.replace({doc:this._doc,selection:{startOffset:s,endOffset:s,collapsed:!0},body:i.body});if(!o)throw new Error("Insert text failed, please check.");return Ye.apply(this._doc.getBody(),o.serialize()),this}delete(n,r){if(r!==void 0){if(!r)return this;const s=ot.selection.delete([{startOffset:n,endOffset:n+r,collapsed:!0}],this._data.body);Ye.apply(this._doc.getBody(),s)}return this}setStyle(n,r,s){const i={dataStream:"",textRuns:[{ts:s instanceof Jt?s.build():s,st:0,ed:r-n}]},o=ot.selection.retain([{startOffset:n,endOffset:r,collapsed:!0}],i);return Ye.apply(this._doc.getBody(),o),this}setLink(n,r,s){const i=ot.customRange.add({rangeType:Zt.HYPERLINK,rangeId:Bt(),properties:{url:s},ranges:[{startOffset:n,endOffset:r,collapsed:!1}],body:this._data.body});if(!i)throw new Error("Insert text failed, please check.");return Ye.apply(this._doc.getBody(),i.serialize()),this}cancelLink(n,r){if(typeof n=="string"){const s=ot.customRange.delete({rangeId:n,documentDataModel:this._doc});if(!s)throw new Error("Insert text failed, please check.");Ye.apply(this._doc.getBody(),s.serialize())}else this.slice(n,r).getLinks().forEach(i=>{const o=ot.customRange.delete({rangeId:i.rangeId,documentDataModel:this._doc});if(!o)throw new Error("Insert text failed, please check.");Ye.apply(this._doc.getBody(),o.serialize())});return this}updateLink(n,r){var i,o;const s=(o=(i=this._data.body)==null?void 0:i.customRanges)==null?void 0:o.find(a=>a.rangeId===n);if(!s)throw new Error("Link not found");return s.properties.url=r,this}insertParagraph(n,r){var o,a;let s,i;return typeof n=="object"?(s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:n.build()}]},i=((a=(o=this._data.body)==null?void 0:o.dataStream.length)!=null?a:2)-2):(i=n,s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:r==null?void 0:r.build()}]}),this.insertRichText(i,Kt.create({body:s,id:"d",documentStyle:{}})),this}insertLink(n,r,s){let i="",o="";typeof n=="string"?(i=n,o=r):(i=r,o=s);const a=an.createByBody({dataStream:i,customRanges:[{rangeType:Zt.HYPERLINK,rangeId:Bt(),properties:{url:o},startIndex:0,endIndex:i.length-1}]});return typeof n=="number"?this.insertRichText(n,a):this.insertRichText(a)}}function Np(e,t=16){let n=0,r=null;return function(...i){const o=Date.now();o-n<t?(r&&clearTimeout(r),r=setTimeout(()=>{n=o,e.apply(this,i)},t)):(n=o,e.apply(this,i))}}var On=(e=>(e[e.Style=1]="Style",e[e.Value=2]="Value",e))(On||{});function Mp(e){return`sheet_interceptor_${e}`}const Eu=e=>function(t,n){let r=-1,s=t;for(let i=0;i<=e.length;i++){if(i<=r)throw new Error("[SheetInterceptorService]: next() called multiple times!");if(r=i,i===e.length)return s;const o=e[i];let a=!1;if(s=o.handler(s,n,l=>(a=!0,l)),!a)break}return s};class Dp{constructor(t){C(this,"_interceptorsByName",new Map);C(this,"_interceptorPoints");this._interceptorPoints=t}fetchThroughInterceptors(t,n){const r=t;let s=this._interceptorsByName.get(r);return n&&(s=s.filter(n)),Eu(s||[])}intercept(t,n){const r=t;this._interceptorsByName.has(r)||this._interceptorsByName.set(r,[]);const s=this._interceptorsByName.get(r);return s.push(n),this._interceptorsByName.set(r,s.sort((i,o)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)})),()=>rr(this._interceptorsByName.get(r),n)}getInterceptPoints(){return this._interceptorPoints}dispose(){this._interceptorsByName.clear()}}function Lp(e){return`sheet_async_interceptor_${e}`}const xp=e=>async function(t,n){let r=-1,s=t;for(let i=0;i<=e.length;i++){if(i<=r)throw new Error("[SheetInterceptorService]: next() called multiple times!");if(r=i,i===e.length)return s;const o=e[i];let a=!1;if(s=await o.handler(s,n,async l=>(a=!0,l)),!a)break}return s};class Up{constructor(t){C(this,"_asyncInterceptorsByName",new Map);C(this,"_asyncInterceptorPoints");this._asyncInterceptorPoints=t}fetchThroughAsyncInterceptors(t,n){const r=t;let s=this._asyncInterceptorsByName.get(r);return n&&(s=s.filter(n)),xp(s||[])}async interceptAsync(t,n){const r=t;this._asyncInterceptorsByName.has(r)||this._asyncInterceptorsByName.set(r,[]);const s=this._asyncInterceptorsByName.get(r);return s.push(n),this._asyncInterceptorsByName.set(r,s.sort((i,o)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)})),()=>rr(this._asyncInterceptorsByName.get(r),n)}getInterceptPoints(){return this._asyncInterceptorPoints}dispose(){this._asyncInterceptorsByName.clear()}}function Pp(e,t){for(const n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}function Cu(e){return/^-?\d+(\.\d+)?$/.test(e)}function kp(e){return Cu(e)?Number(e)<=Number.MAX_SAFE_INTEGER:!1}function Fp(e){return Number(e)>Number.MAX_SAFE_INTEGER||e.length>=18}class bi{constructor(){C(this,"_data",[])}static create(){return new bi}add(t){this._data.indexOf(t)>-1||this._data.push(t)}delete(t){const n=this._data.indexOf(t);this._data.splice(n,1)}getData(){return this._data}}class Ai{constructor(){C(this,"_data",new Map)}static create(){return new Ai}add(t,n){this._data.has(t)||this._data.set(t,n)}delete(t){this._data.delete(t)}getData(){return this._data}}function Bp(e){const t=new MessageChannel;let n=!1;const r=()=>{n||e()};return t.port1.onmessage=r,t.port2.postMessage(null),()=>{n=!0,t.port1.onmessage=null,t.port1.close(),t.port2.close()}}function $p(e,t){return t.forEach(n=>e.add(n)),e}function Hp(e,t,n,r){var u;if(t==="")return e;const s={id:"mock-id",body:e,documentStyle:{}},i=new Mt(s),o=t.length;let a;for(;(a=(r?i.getBody().dataStream:i.getBody().dataStream.toLowerCase()).indexOf(t))>=0;){const c=new Ye,h=$t.getInstance();if(a>0&&c.retain(a),n.length>0){const d=i.sliceBody(a,a+o),f={dataStream:n};if(Array.isArray(d==null?void 0:d.textRuns)&&d.textRuns.length&&(f.textRuns=[{...d.textRuns[0],st:0,ed:n.length}]),(u=d==null?void 0:d.customRanges)!=null&&u.length){const p=d.customRanges[0];f.customRanges=[{...p,startIndex:0,endIndex:n.length-1}]}c.insert(n.length,f)}c.delete(o),i.apply(h.editOp(c.serialize()))}const l=i.getBody();return i.dispose(),l}const jp="__default_document_sub_component_id20231101__";class Ru{constructor(){C(this,"skipNextObservers",!1);C(this,"lastReturnValue");C(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class Wp extends Oe.Subject{constructor(){super(...arguments);C(this,"_sortedObservers",[])}subscribe(){throw new Error("[EventSubject]: please use `subscribeEvent` instead of `subscribe` method for `EventSubject`.")}next(){throw new Error("[EventSubject]: please use `emitEvent` instead of `next` method for `EventSubject`.")}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(n){let r;typeof n=="function"?r={next:([i,o])=>n(i,o)}:r=n;const s=super.subscribe(r);return this._sortedObservers.push(r),this._sortedObservers.sort((i,o)=>{var a,l;return((a=i.priority)!=null?a:0)-((l=o.priority)!=null?l:0)}),s.add(()=>this._sortedObservers=this._sortedObservers.filter(i=>i!==r)),s}clearObservers(){this._sortedObservers.forEach(n=>{var r;return(r=n.complete)==null?void 0:r.call(n)}),this._sortedObservers.length=0}emitEvent(n){var r;if(!this.closed){const s=new Ru;s.lastReturnValue=n;for(const i of this._sortedObservers){const o=(r=i.next)==null?void 0:r.call(i,[n,s]);if(s.lastReturnValue=o,s.skipNextObservers)return{handled:!0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}throw new Error("[EventSubject]: cannot emit event on a closed subject.")}}function Yp(e){return new Oe.Observable(t=>{const n=e.subscribeEvent(r=>{t.next(r)});return()=>n.unsubscribe()})}const us=je.createIdentifier("core.resource-manager.service"),Zs={[xt.Editor]:"Editor",[xt.Owner]:"Owner",[xt.Reader]:"Reader",[xt.UNRECOGNIZED]:"UNRECOGNIZED"},Xr=e=>e?{userID:`${Zs[e]}_${ne.generateRandomId(8)}`,name:Zs[e],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},zp=(e,t)=>e.startsWith(Zs[t]);class tr{constructor(){C(this,"_model",new Map);C(this,"_userChange$",new Oe.Subject);C(this,"userChange$",this._userChange$.asObservable());C(this,"_currentUser$",new Oe.BehaviorSubject(Xr()));C(this,"currentUser$",this._currentUser$.asObservable())}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(t){this.addUser(t),this._currentUser$.next(t)}addUser(t){this._model.set(t.userID,t),this._userChange$.next({type:"add",user:t})}getUser(t,n){const r=this._model.get(t);if(r)return r;n&&n()}delete(t){const n=this.getUser(t);this._model.delete(t),n&&this._userChange$.next({type:"delete",user:n})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}list(){return Array.from(this._model.values())}}var Gp=Object.getOwnPropertyDescriptor,Vp=(e,t,n,r)=>{for(var s=r>1?void 0:r?Gp(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Do=(e,t)=>(n,r)=>t(n,r,e);exports.AuthzIoLocalService=class{constructor(t,n){C(this,"_permissionMap",new Map([]));this._resourceManagerService=t,this._userManagerService=n,this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){const t=this._userManagerService.getCurrentUser();t&&t.userID||this._userManagerService.setCurrentUser(Xr(xt.Owner))}_getRole(t){const n=this._userManagerService.getCurrentUser();return n?zp(n.userID,t):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:t=>{const n=[...this._permissionMap.keys()].reduce((r,s)=>{const i=this._permissionMap.get(s);return r[s]=i,r},{});return JSON.stringify(n)},parseJson:t=>JSON.parse(t),pluginName:"SHEET_AuthzIoMockService_PLUGIN",businesses:[Be.UNIVER_SHEET,Be.UNIVER_DOC,Be.UNIVER_SLIDE],onLoad:(t,n)=>{for(const r in n)this._permissionMap.set(r,n[r])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(t){return Bt(8)}async allowed(t){return Promise.resolve([])}async batchAllowed(t){return Promise.resolve([])}async list(t){const n=[];return t.objectIDs.forEach(r=>{const s=this._permissionMap.get(r);if(s){const i={objectID:r,unitID:t.unitID,objectType:s.objectType,name:s.name,shareOn:!1,shareRole:xt.Owner,shareScope:-1,scope:{read:zs.AllCollaborator,edit:zs.AllCollaborator},creator:Xr(xt.Owner),strategies:[{action:6,role:1},{action:16,role:1},{action:17,role:1},{action:18,role:1},{action:19,role:1},{action:33,role:1},{action:34,role:1},{action:35,role:1},{action:36,role:1},{action:37,role:1},{action:38,role:1},{action:39,role:1},{action:40,role:1}],actions:t.actions.map(o=>({action:o,allowed:this._getRole(xt.Owner)||this._getRole(xt.Editor)}))};n.push(i)}}),n}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(t){}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(t){}};exports.AuthzIoLocalService=Vp([Do(0,us),Do(1,je.Inject(tr))],exports.AuthzIoLocalService);const Iu=je.createIdentifier("IAuthzIoIoService");var Kp=Object.getOwnPropertyDescriptor,Xp=(e,t,n,r)=>{for(var s=r>1?void 0:r?Kp(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},qp=(e,t)=>(n,r)=>t(n,r,e);exports.MentionIOLocalService=class{constructor(t){this._userManagerService=t}async list(t){return{list:[{type:$r.PERSON,mentions:[{objectType:$r.PERSON,objectId:this._userManagerService.getCurrentUser().userID,label:this._userManagerService.getCurrentUser().name,metadata:{icon:this._userManagerService.getCurrentUser().avatar}}],metadata:{},title:"PEOPLE"}],page:t.page,size:t.size,total:1}}};exports.MentionIOLocalService=Xp([qp(0,je.Inject(tr))],exports.MentionIOLocalService);const Su=je.createIdentifier("univer.service.mention-io"),Ti=je.createIdentifier("univer.config-service");class vu{constructor(){C(this,"_configChanged$",new Oe.Subject);C(this,"configChanged$",this._configChanged$.asObservable());C(this,"_config",new Map)}dispose(){this._configChanged$.complete()}getConfig(t){return this._config.get(t)}setConfig(t,n,r){var o;const{merge:s=!1}=r||{};let i=(o=this._config.get(t))!=null?o:{};s?i=Ci(i,n):i=n,this._config.set(t,i),this._configChanged$.next({[t]:i})}deleteConfig(t){return this._config.delete(t)}subscribeConfigValue$(t){return new Oe.Observable(n=>{Object.prototype.hasOwnProperty.call(this._config,t)&&n.next(this._config.get(t));const r=this.configChanged$.pipe(Oe.filter(s=>Object.prototype.hasOwnProperty.call(s,t))).subscribe(s=>n.next(s[t]));return()=>r.unsubscribe()})}}const zn="FOCUSING_UNIT",wn="FOCUSING_SHEET",Gn="FOCUSING_DOC",Vn="FOCUSING_SLIDE",Jp="FOCUSING_EDITOR_BUT_HIDDEN",Ou="EDITOR_ACTIVATED",Zp="FOCUSING_EDITOR_INPUT_FORMULA",wu="FOCUSING_FX_BAR_EDITOR",Qp="FOCUSING_UNIVER_EDITOR",eE="FOCUSING_EDITOR_INPUT_FORMULA",tE="FOCUSING_PANEL_EDITOR",nE="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",rE="FOCUSING_COMMON_DRAWINGS",sE="FORMULA_EDITOR_ACTIVATED";class bu extends st{constructor(){super(...arguments);C(this,"_error$",new Oe.Subject);C(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(n){this._error$.next({errorKey:n})}}const iE="0.8.0-beta.0",oE={version:iE};function aE(e="",t=or.ZH_CN,n=""){return{id:e,sheetOrder:[],name:n,appVersion:oE.version,locale:t,styles:{},sheets:{},resources:[]}}class Au{constructor(t={}){C(this,"_styles");C(this,"_cacheMap",new Zn(1e5));this._styles=t,this._generateCacheMap()}each(t){return Object.entries(this._styles).forEach(t),this}search(t,n){if(this._cacheMap.has(n))return this._cacheMap.get(n);const r=this._getExistingStyleId(t);return r||"-1"}get(t){return typeof t!="string"?t:(t=String(t),this._styles[t])}add(t,n){const r=ne.generateRandomId(6);return this._styles[r]=t,this._cacheMap.set(n,r),r}setValue(t){if(t==null)return;const n=JSON.stringify(t),r=this.search(t,n);return r!=="-1"?r:this.add(t,n)}toJSON(){return this._styles}getStyleByCell(t){let n;t&&ne.isObject(t.s)?n=t.s:n=(t==null?void 0:t.s)&&this.get(t.s);const r=t==null?void 0:t.interceptorStyle;return r?{...n,...r}:n}_generateCacheMap(){const{_styles:t,_cacheMap:n}=this;for(const r in t){const s=JSON.stringify(t[r]);n.set(s,r)}}_getExistingStyleId(t){const{_styles:n}=this;for(const r in n)if(ne.diffValue(n[r],t))return r;return null}}const lE=(e,t)=>t.length===e.length&&!e.some(n=>t.some(r=>!Qt.equals(r,n))),uE=(e,t)=>t.length===e.length&&e.every((n,r)=>{const s=t[r];return s.unitId===n.unitId&&s.sheetId===n.sheetId&&Qt.equals(n.range,s.range)}),Qs={t:0,b:2,l:2,r:2},cE=e=>({sbr:.6,sbo:e,spr:.6,spo:e}),Lo=90;function Kn(e,t,n={}){const r=e.length,{textRotation:s,paddingData:i,horizontalAlign:o=yt.UNSPECIFIED,verticalAlign:a=sn.UNSPECIFIED,wrapStrategy:l=un.UNSPECIFIED,cellValueType:u}=n,{t:c,r:h,b:d,l:f}=i||Qs,{vertexAngle:p,centerAngle:R}=Nu(s),w={id:"d",body:{dataStream:`${e}${Pa}`,textRuns:[{ts:t,st:0,ed:r}],paragraphs:[{startIndex:r,paragraphStyle:{horizontalAlign:o}}],sectionBreaks:[{startIndex:r+1}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},marginTop:c,marginBottom:d,marginRight:h,marginLeft:f,renderConfig:{horizontalAlign:o,verticalAlign:a,centerAngle:R,vertexAngle:p,wrapStrategy:l,cellValueType:u,zeroWidthParagraphBreak:1}},drawings:{},drawingsOrder:[]};return new Mt(w)}function hE(e){if(!e)return{};const{tr:t,td:n,ht:r,vt:s,tb:i,pd:o}=e;return{textRotation:t,textDirection:n,horizontalAlign:r,verticalAlign:s,wrapStrategy:i,paddingData:o}}function xo(e){if(!e)return{};const{ff:t,fs:n,it:r,bl:s,ul:i,st:o,ol:a,cl:l}=e,u={};return t&&(u.ff=t),n&&(u.fs=n),r&&(u.it=r),s&&(u.bl=s),i&&(u.ul=i),o&&(u.st=o),a&&(u.ol=a),l&&(u.cl=l),u}function Tu(e,t,n){var i;const r=e.getBody();if((i=r.customRanges)!=null&&i.some(o=>o.rangeType===Zt.HYPERLINK))return;const s=ot.customRange.add({ranges:[{startOffset:0,endOffset:r.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:Zt.HYPERLINK,body:r,properties:{url:t,refId:n}});s&&Ye.apply(r,s.serialize())}function yu(e){return e!=null}const dE='"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';function Uo(e){const t=ut.ff,n=ut.fs;if(!e){const h=`${n}pt ${t}`;return{fontCache:h,fontString:h,fontSize:n,originFontSize:n,fontFamily:t}}let r=vn.ITALIC;(e.it===0||e.it===void 0)&&(r=vn.NORMAL);let s=vn.BOLD;(e.bl===0||e.bl===void 0)&&(s=vn.NORMAL);let i=n;e.fs&&(i=Math.ceil(e.fs));let o=t;if(e.ff){let h=e.ff;h=h.replace(/"/g,"").replace(/'/g,""),h.indexOf(" ")>-1&&(h=`"${h}"`),h==null&&(h=t),o=h}const{va:a}=e;let l=i;if(a===Ft.SUBSCRIPT||a===Ft.SUPERSCRIPT){const h=fE(o,l),{sbr:d,spr:f}=h;l*=a===Ft.SUBSCRIPT?d:f}const u=`${r} ${s} ${l}pt ${o}`,c=`${u}, ${dE} `;return{fontCache:u,fontString:c,fontSize:l,originFontSize:i,fontFamily:o}}function fE(e,t){return cE(t)}function Nu(e){const{a:t=0,v:n=Ie.FALSE}=e||{a:0,v:Ie.FALSE};let r=0,s=t;return n===Ie.TRUE&&(r=Lo,s=Lo),{centerAngle:r,vertexAngle:s}}class gE{constructor(t,n){C(this,"_columnData",{});this._config=t,this._columnData=n}getColumnData(){return this._columnData}getColVisible(t){const{_columnData:n}=this,r=n[t];return r?r.hd!==Ie.TRUE:!0}getColumnStyle(t){var n;return(n=this._columnData[t])==null?void 0:n.s}setColumnStyle(t,n){const r=this.getColumnOrCreate(t);r.s=n}getHiddenCols(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getColVisible(o);s&&a?(s=!1,r.push({rangeType:Le.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:Le.COLUMN}),r}getVisibleCols(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getColVisible(o);s&&!a?(s=!1,r.push({rangeType:Le.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:Le.COLUMN}),r}getColumnDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getColumnOrCreate(i);r[s]=o,s++}return r}getSize(){return qt(this._columnData)}getColumnWidth(t){const{_columnData:n}=this,r=this._config;let s=0;return s=(n[t]||{hd:Ie.FALSE,w:r.defaultColumnWidth}).w||r.defaultColumnWidth,s}getColumn(t){const n=this._columnData[t];if(n)return n}removeColumn(t){delete this._columnData[t]}getColumnOrCreate(t){const{_columnData:n}=this,r=n[t];if(r)return r;const s={};return this._columnData[t]=s,s}setCustomMetadata(t,n){const r=this.getColumn(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getColumn(t))==null?void 0:n.custom}}class mE{constructor(t,n,r){C(this,"_rowData");this._config=t,this._viewModel=n,this._rowData=r}getRowData(){return this._rowData}getRowStyle(t){var n;return(n=this._rowData[t])==null?void 0:n.s}setRowStyle(t,n){const r=this.getRowOrCreate(t);r.s=n}getRowDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getRowOrCreate(i);r[s]=o,s++}return r}getRowHeight(t,n=1){const{_rowData:r}=this,s=this._config;let i=0;for(let o=0;o<n;o++){const a=r[o+t]||{hd:Ie.FALSE,h:s.defaultRowHeight},{ia:l,ah:u,h:c=s.defaultRowHeight}=a;i+=(l==null||l===Ie.TRUE)&&typeof u=="number"?u:c}return i}getRow(t){return this._rowData[t]}removeRow(t){delete this._rowData[t]}getRowOrCreate(t){const{_rowData:n}=this,r=n[t];if(r)return r;const s={};return n[t]=s,s}getHiddenRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:Le.ROW})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:Le.ROW}),r}getVisibleRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&!a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:Le.ROW})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:Le.ROW}),r}getRowRawVisible(t){const n=this.getRow(t);return n?n.hd!==Ie.TRUE:!0}getSize(){return qt(this._rowData)}setCustomMetadata(t,n){const r=this.getRow(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getRow(t))==null?void 0:n.custom}}const _E="DEFAULT_WORKSHEET_ROW_COUNT",Mu=1e3,pE="DEFAULT_WORKSHEET_COLUMN_COUNT",Du=20,EE="DEFAULT_WORKSHEET_ROW_HEIGHT",Lu=24,CE="DEFAULT_WORKSHEET_COLUMN_WIDTH",xu=88,RE="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",Uu=46,IE="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Pu=20;function ku(e){const t={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:Ie.FALSE,rowCount:Mu,columnCount:Du,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:xu,defaultRowHeight:Lu,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:Ie.TRUE,rowHeader:{width:Uu,hidden:Ie.FALSE},columnHeader:{height:Pu,hidden:Ie.FALSE},rightToLeft:Ie.FALSE};return Object.keys(t).forEach(n=>{const r=n;typeof e[r]>"u"&&(e[r]=t[r])}),e}class SE extends st{constructor(n){super();C(this,"_cellCache",new Map);C(this,"_rowCache",new Map);C(this,"_columnCache",new Map);C(this,"_hasRow",!1);C(this,"_hasColumn",!1);C(this,"_hasAll",!1);C(this,"_allIndex",-1);C(this,"_mergeData");C(this,"_rangeMap",new Zn(5e4));C(this,"_skeletonCache",new Zn(5e4));this._init(n.concat())}_init(n){this._mergeData=n,this._createCache(n)}_clearCache(){this._cellCache.clear(),this._rowCache.clear(),this._columnCache.clear(),this._hasAll=!1,this._allIndex=-1,this._rangeMap.clear(),this._skeletonCache.clear(),this._hasColumn=!1,this._hasRow=!1}_createCache(n){let r=0;for(const s of n){const{rangeType:i}=s;i===Le.ROW?this._createRowCache(s,r):i===Le.COLUMN?this._createColumnCache(s,r):i===Le.ALL?this._createCellAllCache(r):this._createCellCache(s,r),r++}}rebuild(n){this._clearCache(),this._init(n.concat())}_createRowCache(n,r){const{startRow:s,endRow:i}=n;for(let o=s;o<=i;o++)this._rowCache.set(o,r),this._hasRow=!0}_createColumnCache(n,r){const{startColumn:s,endColumn:i}=n;for(let o=s;o<=i;o++)this._columnCache.set(o,r),this._hasColumn=!0}_createCellAllCache(n){this._hasAll=!0,this._allIndex=n}_createCellCache(n,r){for(let s=n.startRow;s<=n.endRow;s++){let i=this._cellCache.get(s);i==null&&(i=new Map,this._cellCache.set(s,i));for(let o=n.startColumn;o<=n.endColumn;o++)i.set(o,r)}}add(n){this._mergeData.push(n),this._clearCache(),this._createCache(this._mergeData)}remove(n,r){const s=this._getMergeDataIndex(n,r);s!==-1&&(this._mergeData.splice(s,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(n,r){const s=this._getMergeDataIndex(n,r);return s!==-1?this._mergeData[s]:null}getMergeDataIndex(n,r){return this._getMergeDataIndex(n,r)}isRowContainsMergedCell(n){return this._hasAll||!ne.isEmptyObject(this._columnCache)?!0:this._mergeData.some(r=>r.startRow<=n&&n<=r.endRow)}isColumnContainsMergedCell(n){return this._hasAll||!ne.isEmptyObject(this._rowCache)?!0:this._mergeData.some(r=>r.startColumn<=n&&n<=r.endColumn)}getMergedCellRange(n,r,s,i){const o=[],a=`${n}-${r}-${s}-${i}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let l=0;const u=[];for(const c of this._mergeData||[])Qt.intersects(c,{startRow:n,endRow:s,startColumn:r,endColumn:i})&&(o.push({...c}),u.push(l)),l++;return this._rangeMap.set(a,u),o}getMergedCellRangeForSkeleton(n,r,s,i){const o=[],a=this._mergeData,l=`${n}-${r}-${s}-${i}`;if(this._skeletonCache.has(l))return this._getSkeletonRangeFromCache(l);const u=[];for(let c=0;c<a.length;c++){const{startRow:h,endRow:d,startColumn:f,endColumn:p}=a[c];for(let R=n;R<=s;R++){let w=!1;for(let N=r;N<=i;N++)if(R>=h&&R<=d&&N>=f&&N<=p){o.push({startRow:h,endRow:d,startColumn:f,endColumn:p}),u.push(c),w=!0;break}if(w)break}}return this._skeletonCache.set(l,u),o}_getRangeFromCache(n){const r=this._rangeMap.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getSkeletonRangeFromCache(n){const r=this._skeletonCache.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getMergeDataIndex(n,r){var i;if(this._hasAll)return this._allIndex;if(this._hasRow){const o=this._rowCache.get(n);if(o!==void 0)return o}if(this._hasColumn){const o=this._columnCache.get(r);if(o!==void 0)return o}const s=(i=this._cellCache.get(n))==null?void 0:i.get(r);return s!==void 0?s:-1}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}}class Fu extends st{constructor(n){super();C(this,"_cellContentInterceptor",null);C(this,"_rowFilteredInterceptor",null);this.getRawCell=n}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(n,r,s,i){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,On.Value|On.Style,s,i):this.getRawCell(n,r)}getCellValueOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,On.Value):this.getRawCell(n,r)}getCellStyleOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,On.Style):this.getRawCell(n,r)}getRowFiltered(n){var r,s;return(s=(r=this._rowFilteredInterceptor)==null?void 0:r.getRowFiltered(n))!=null?s:!1}registerCellContentInterceptor(n){if(this._cellContentInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptor=n,nt(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(n){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=n,nt(()=>this._rowFilteredInterceptor=null)}}const Po={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};class nr{constructor(t,n,r){C(this,"_sheetId");C(this,"_snapshot");C(this,"_cellData");C(this,"_rowManager");C(this,"_columnManager");C(this,"_viewModel");C(this,"_spanModel");var a;this.unitId=t,this._styles=r,this._snapshot=ku(n);const{columnData:s,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:ne.generateRandomId(6),this._cellData=new Et(o),this._viewModel=new Fu((l,u)=>this.getCellRaw(l,u)),this._rowManager=new mE(this._snapshot,this._viewModel,i),this._columnManager=new gE(this._snapshot,s),this._spanModel=new SE(this._snapshot.mergeData)}__interceptViewModel(t){t(this._viewModel)}getSnapshot(){return this._snapshot}setMergeData(t){this._snapshot.mergeData=t,this.getSpanModel().rebuild(t)}getSpanModel(){return this._spanModel}getStyleDataByHash(t){return{...this._styles.get(t)}}setStyleData(t){return this._styles.setValue(t)}getColumnStyle(t,n=!1){return n?this._columnManager.getColumnStyle(t):this._styles.get(this._columnManager.getColumnStyle(t))}setColumnStyle(t,n){this._columnManager.setColumnStyle(t,n)}getRowStyle(t,n=!1){return n?this._rowManager.getRowStyle(t):this._styles.get(this._rowManager.getRowStyle(t))}setRowStyle(t,n){this._rowManager.setRowStyle(t,n)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){const t=this._snapshot.defaultStyle;return this._styles.get(t)}setDefaultCellStyle(t){this._snapshot.defaultStyle=t}getCellStyle(t,n){const r=this.getCell(t,n);if(r){const s=r.s;return typeof s=="string"?this._styles.get(s):s}return null}getComposedCellStyle(t,n,r=!0){const s=this.getCellStyle(t,n),i=this.getDefaultCellStyleInternal(),o=this.getRowStyle(t),a=this.getColumnStyle(n);return r?Ls(i,o,a,s):Ls(i,a,o,s)}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const t=this.getCellMatrix(),n=this.getMergeData();let r=-1,s=-1,i=-1,o=-1,a=!1,l=!1;return t.forEach((u,c)=>{Object.keys(c).forEach(h=>{const d=+h,f=t.getValue(u,d),p=f!=null&&f.s?this._styles.get(f.s):null,R=(p==null?void 0:p.bd)&&(p.bd.b||p.bd.l||p.bd.r||p.bd.t||p.bd.bc_tr||p.bd.bl_tr||p.bd.ml_tr||p.bd.tl_bc||p.bd.tl_br||p.bd.tl_mr);(f&&(f.v||f.p)||p!=null&&p.bg||R)&&(a?r=Math.min(r,u):(r=u,a=!0),s=Math.max(s,u),l?i=Math.min(i,d):(l=!0,i=d),o=Math.max(o,d))})}),n.forEach(u=>{a?r=Math.min(r,u.startRow):(r=u.startRow,a=!0),s=Math.max(s,u.endRow),l?i=Math.min(i,u.startColumn):(i=u.startColumn,a=!0),o=Math.max(o,u.endColumn)}),!a||!l?null:{startColumn:i,startRow:r,endColumn:o,endRow:s}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:t}=this,n=ne.deepClone(t);return new nr(this.unitId,n,this._styles)}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(t,n){return this._spanModel.getMergedCell(t,n)}getMergedCellRange(t,n,r,s){return this._spanModel.getMergedCellRange(t,n,r,s)}isRowContainsMergedCell(t){return this._spanModel.isRowContainsMergedCell(t)}isColumnContainsMergedCell(t){return this._spanModel.isColumnContainsMergedCell(t)}getCellInfoInMergeData(t,n){const r=this.getMergedCell(t,n);let s=!1,i=!1,o=t,a=n,l=t,u=n;if(r){const{startRow:c,endRow:h,startColumn:d,endColumn:f}=r;t===c&&n===d?(o=h,a=f,l=c,u=d,i=!0):t>=c&&t<=h&&n>=d&&n<=f&&(o=h,a=f,l=c,u=d,s=!0)}return{actualRow:t,actualColumn:n,isMergedMainCell:i,isMerged:s,endRow:o,endColumn:a,startRow:l,startColumn:u}}getCell(t,n){return t<0||n<0?null:this._viewModel.getCell(t,n)}getCellValueOnly(t,n){return t<0||n<0?null:this._viewModel.getCellValueOnly(t,n)}getCellStyleOnly(t,n){return t<0||n<0?null:this._viewModel.getCellStyleOnly(t,n)}getCellRaw(t,n){return this.getCellMatrix().getValue(t,n)}getCellWithFilteredInterceptors(t,n,r,s){return this._viewModel.getCell(t,n,r,s)}getRowFiltered(t){return this._viewModel.getRowFiltered(t)}getMatrixWithMergedCells(t,n,r,s,i=Sn.Raw){const o=this.getCellMatrix(),a=this._spanModel.getMergedCellRange(t,n,r,s),l=new Et;return Hs(t,r,n,s).forEach((u,c)=>{var d;let h;if(i===Sn.Raw)h=this.getCellRaw(u,c);else if(i===Sn.Intercepted)h=this.getCell(u,c);else if(i===Sn.Both){const f=this.getCellRaw(u,c);if(f){h={...f};const p=(d=this.getCell(u,c))==null?void 0:d.v;yu(p)&&h&&(h.displayV=String(p))}}h&&l.setValue(u,c,h)}),a.forEach(u=>{const{startColumn:c,startRow:h,endColumn:d,endRow:f}=u;Hs(h,f,c,d).forEach((p,R)=>{p===h&&R===c&&l.setValue(p,R,{...o.getValue(p,R),rowSpan:f-h+1,colSpan:d-c+1}),(p!==h||R!==c)&&l.realDeleteValue(p,R)})}),l}getRange(t,n,r,s){return typeof t=="object"?new Tn(this,t,{getStyles:()=>this._styles}):new Tn(this,{startRow:t,startColumn:n,endColumn:s||n,endRow:r||t},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:t}=this,{columnCount:n}=t;return n}getMaxRows(){const{_snapshot:t}=this,{rowCount:n}=t;return n}getRowCount(){return this._snapshot.rowCount}setRowCount(t){this._snapshot.rowCount=t}getColumnCount(){return this._snapshot.columnCount}setColumnCount(t){this._snapshot.columnCount=t}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:t}=this,{showGridlines:n}=t;return n===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){const{_snapshot:t}=this,{tabColor:n}=t;return n}getColumnWidth(t){return this.getColumnManager().getColumnWidth(t)}getRowHeight(t){return this._viewModel.getRowFiltered(t)?0:this.getRowManager().getRowHeight(t)}isRowFiltered(t){return this._viewModel.getRowFiltered(t)}getRowVisible(t){return!this.isRowFiltered(t)&&this.getRowRawVisible(t)}getRowRawVisible(t){return this.getRowManager().getRowRawVisible(t)}getHiddenRows(t,n){const r=this.getMaxColumns()-1,s=this._rowManager.getHiddenRows(t,n);return s.forEach(i=>i.endColumn=r),s}getColVisible(t){return this._columnManager.getColVisible(t)}getHiddenCols(t,n){const r=this.getMaxRows()-1,s=this._columnManager.getHiddenCols(t,n);return s.forEach(i=>i.endRow=r),s}getVisibleRows(){const t=this.getRowCount();return this._rowManager.getVisibleRows(0,t-1)}getVisibleCols(){const t=this.getColumnCount();return this._columnManager.getVisibleCols(0,t-1)}isRightToLeft(){const{_snapshot:t}=this,{rightToLeft:n}=t;return n}getLastRowWithContent(){return this._cellData.getLength()-1}getLastColumnWithContent(){return this._cellData.getRange().endColumn}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(t){return t&&(t.v!==void 0||t.f!==void 0||t.p!==void 0)}iterateByRow(t,n=!0){const{startRow:r,startColumn:s,endRow:i,endColumn:o}=t,a=this;return{[Symbol.iterator]:()=>{let l=r,u=s;return{next(){for(;;){if(u>o&&(l+=1,u=s),l>i)return{done:!0,value:void 0};const c=a.getCell(l,u),h=!c,d=a.getMergedCell(l,u);if(d){if(l!==d.startRow||u!==d.startColumn){u=d.endColumn+1;continue}if(h&&n){u=d.endColumn+1;continue}const p={row:l,col:u,value:c};return p.colSpan=d.endColumn-d.startColumn+1,p.rowSpan=d.endRow-d.startRow+1,u=d.endColumn+1,{done:!1,value:p}}if(h&&n)u+=1;else{const f={row:l,col:u,value:c};return u+=1,{done:!1,value:f}}}}}}}}iterateByColumn(t,n=!0,r=!0){const{startRow:s,startColumn:i,endRow:o,endColumn:a}=t,l=this;return{[Symbol.iterator]:()=>{let u=s,c=i;return{next(){for(;;){if(u>o&&(c+=1,u=s),c>a)return{done:!0,value:void 0};const h=l.getMergedCell(u,c);if(h){const p=u!==h.startRow,R=p||c!==h.startColumn;if(r&&R||!r&&p){u=h.endRow+1;continue}const w=l.getCell(h.startRow,h.startColumn);if(!w&&n){u=h.endRow+1;continue}const G={row:u,col:h.startColumn,value:w};return G.colSpan=h.endColumn-h.startColumn+1,G.rowSpan=h.endRow-h.startRow+1,u=h.endRow+1,{done:!1,value:G}}const d=l.getCell(u,c);if(!d&&n)u+=1;else{const p={row:u,col:c,value:d};return u+=1,{done:!1,value:p}}}}}}}}_getCellDocumentModel(t,n=Po){var R;const{isDeepClone:r,displayRawFormula:s,ignoreTextRotation:i}={...Po,...n},o=this._styles.getStyleByCell(t);if(!t)return;let a,l="document";const u=hE(o),c=i?ut.tr:u.textRotation||ut.tr;let h=u.horizontalAlign||ut.ht;const d=u.verticalAlign||ut.vt,f=u.wrapStrategy||ut.tb,p=u.paddingData||Qs;if(t.f&&s)a=Kn(t.f.toString(),{},{verticalAlign:d}),h=ut.ht;else if(t.p){const{centerAngle:w,vertexAngle:N}=Nu(c);a=this._updateConfigAndGetDocumentModel(r?ne.deepClone(t.p):t.p,h,p,{horizontalAlign:h,verticalAlign:d,centerAngle:w,vertexAngle:N,wrapStrategy:f,zeroWidthParagraphBreak:1})}else if(t.v!=null){const w=xo(o);l=Uo(w).fontCache;let N=Bu(t);t.t===Xt.FORCE_STRING&&s&&(N=`'${N}`),a=Kn(N,w,{...u,textRotation:c,cellValueType:t.t})}return a&&t.linkUrl&&t.linkId&&Tu(a,t.linkUrl,t.linkId),{documentModel:a,fontString:l,textRotation:c,wrapStrategy:f,verticalAlign:d,horizontalAlign:h,paddingData:p,fill:(R=o==null?void 0:o.bg)==null?void 0:R.rgb}}_updateConfigAndGetDocumentModel(t,n,r,s){var o,a,l,u,c;if(!s||!((o=t.body)!=null&&o.dataStream))return;t.documentStyle||(t.documentStyle={}),t.documentStyle.marginTop=(a=r.t)!=null?a:0,t.documentStyle.marginBottom=(l=r.b)!=null?l:2,t.documentStyle.marginLeft=(u=r.l)!=null?u:2,t.documentStyle.marginRight=(c=r.r)!=null?c:2,t.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},t.documentStyle.renderConfig={...t.documentStyle.renderConfig,...s};const i=t.body.paragraphs||[];for(const h of i)h.paragraphStyle||(h.paragraphStyle={}),h.paragraphStyle.horizontalAlign=n;return new Mt(t)}getBlankCellDocumentModel(t){const n=this._getCellDocumentModel(t,{ignoreTextRotation:!0}),r=this._styles.getStyleByCell(t),s=xo(r);if(n!=null)return n.documentModel==null&&(n.documentModel=Kn("",s)),n;const i="";let o="document";const a=ut.tr,l=ut.ht,u=ut.vt,c=ut.tb,h=Qs;return o=Uo({}).fontCache,{documentModel:Kn(i,s),fontString:o,textRotation:a,wrapStrategy:c,verticalAlign:u,horizontalAlign:l,paddingData:h}}getCellDocumentModelWithFormula(t){return this._getCellDocumentModel(t,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(t){this._snapshot.custom=t}}function Bu(e){var r,s;if(!e)return"";const t=(s=(r=e.p)==null?void 0:r.body)==null?void 0:s.dataStream;if(t)return ot.transform.getPlainText(t);const n=e.v;return typeof n=="string"?e.t===Xt.BOOLEAN?n.toUpperCase():n.replace(/[\r\n]/g,""):typeof n=="number"?e.t===Xt.BOOLEAN?n?"TRUE":"FALSE":n.toString():typeof n=="boolean"?n?"TRUE":"FALSE":""}function vE(e){if(e===null)return"";if(e!=null&&e.p){const t=e==null?void 0:e.p.body;if(t==null)return"";const n=t.dataStream;return ot.transform.getPlainText(n)}return e==null?void 0:e.v}var OE=Object.getOwnPropertyDescriptor,wE=(e,t,n,r)=>{for(var s=r>1?void 0:r?OE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},bE=(e,t)=>(n,r)=>t(n,r,e);function AE(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}exports.Workbook=class extends ls{constructor(n={},r){super();C(this,"type",Be.UNIVER_SHEET);C(this,"_sheetCreated$",new Oe.Subject);C(this,"sheetCreated$",this._sheetCreated$.asObservable());C(this,"_sheetDisposed$",new Oe.Subject);C(this,"sheetDisposed$",this._sheetDisposed$.asObservable());C(this,"_activeSheet$",new Oe.BehaviorSubject(null));C(this,"activeSheet$",this._activeSheet$.asObservable());C(this,"_worksheets");C(this,"_styles");C(this,"_snapshot");C(this,"_unitId");C(this,"_count");C(this,"_name$");C(this,"name$");this._logService=r;const s=aE();ne.isEmptyObject(n)?this._snapshot=s:this._snapshot=ne.commonExtend(s,n);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=ne.generateRandomId(6)),this._unitId=this._snapshot.id,this._styles=new Au(i),this._count=1,this._worksheets=new Map,this._name$=new Oe.BehaviorSubject(n.name||""),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(n){return typeof n=="string"||"startRow"in n||"row"in n}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete()}save(){return ne.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(n){this._name$.next(n),this._snapshot.name=n}getUnitId(){return this._unitId}getRev(){var n;return(n=this._snapshot.rev)!=null?n:1}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(n){this._snapshot.rev=n}addWorksheet(n,r,s){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[n])return!1;i[n]=s,o.splice(r,0,n);const a=new nr(this._unitId,s,this._styles);return this._worksheets.set(n,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}getConfig(){return this._snapshot}getIndexBySheetId(n){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>s===n)}getActiveSheet(n){if(!this._activeSheet&&typeof n>"u")throw new Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){const n=this._activeSheet;if(n)return n;const r=this._snapshot.sheetOrder;for(let i=0,o=r.length;i<o;i++){const a=this._worksheets.get(r[i]);if(a&&a.isSheetHidden()!==Ie.TRUE)return this.setActiveSheet(a),a}const s=this._worksheets.get(r[0]);return this.setActiveSheet(s),s}setActiveSheet(n){this._activeSheet$.next(n)}removeSheet(n){const r=this._worksheets.get(n);return r?(this._worksheets.delete(n),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(n),1),delete this._snapshot.sheets[n],this._sheetDisposed$.next(r),!0):!1}getActiveSheetIndex(){const{sheetOrder:n}=this._snapshot;return n.findIndex(r=>this._worksheets.get(r)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:n}=this._snapshot;return n.map(r=>this._worksheets.get(r))}getSheetsName(){const{sheetOrder:n}=this._snapshot,r=[];return n.forEach(s=>{const i=this._worksheets.get(s);i&&r.push(i.getName())}),r}getSheetIndex(n){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>n.getSheetId()===s)}getSheetBySheetName(n){const{sheetOrder:r}=this._snapshot,s=r.find(i=>this._worksheets.get(i).getName()===n);return this._worksheets.get(s)}getSheetBySheetId(n){return this._worksheets.get(n)}getSheetByIndex(n){const{sheetOrder:r}=this._snapshot;return this._worksheets.get(r[n])}getHiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden===Ie.TRUE).map(n=>n.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden!==Ie.TRUE).map(n=>n.getConfig().id)}load(n){this._snapshot=n}checkSheetName(n){return this.getSheetsName().includes(n)}uniqueSheetName(n="Sheet1"){let r=n;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}generateNewSheetName(n){let r=n+this._count;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}_parseWorksheetSnapshots(){const{_snapshot:n,_worksheets:r}=this,{sheets:s,sheetOrder:i}=n;if(ne.isEmptyObject(s)){const o=ne.generateRandomId();s[o]={id:o}}for(const o in s){const a=s[o],{name:l}=a;a.name=this.uniqueSheetName(l),a.name!==l&&this._logService.debug("[Workbook]",`The worksheet name ${l} is duplicated, we changed it to ${a.name}. Please fix the problem in your snapshot.`);const u=new nr(this._unitId,a,this._styles);r.set(o,u),i.includes(o)||i.push(o)}this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(n){this._snapshot.custom=n}};exports.Workbook=wE([bE(1,Ot)],exports.Workbook);class yi extends ls{constructor(n){var r;super();C(this,"type",Be.UNIVER_SLIDE);C(this,"_activePage$",new Oe.BehaviorSubject(null));C(this,"activePage$",this._activePage$.asObservable());C(this,"_name$");C(this,"name$");C(this,"_snapshot");C(this,"_unitId");this._snapshot={..._l,...n},this._unitId=(r=this._snapshot.id)!=null?r:ne.generateRandomId(6),this._name$=new Oe.BehaviorSubject(this._snapshot.title),this.name$=this._name$.asObservable()}get _activePage(){var r,s;const n=this._activePage$.getValue();if(!n){const i=(r=this.getPageOrder())==null?void 0:r[0];return i?(s=this.getPages())==null?void 0:s[i]:null}return n}setName(n){var r;this._snapshot.title=n,this._name$.next(n),this._unitId=(r=this._snapshot.id)!=null?r:Bt(6)}getRev(){return 0}incrementRev(){}setRev(n){}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var n;return(n=this._snapshot.body)==null?void 0:n.pages}getPageOrder(){var n;return(n=this._snapshot.body)==null?void 0:n.pageOrder}getPage(n){const r=this.getPages();return r==null?void 0:r[n]}getElementsByPage(n){var r;return(r=this.getPage(n))==null?void 0:r.pageElements}getElement(n,r){var s;return(s=this.getElementsByPage(n))==null?void 0:s[r]}getPageSize(){return this._snapshot.pageSize}getBlankPage(){const n=Bt(6);return{id:n,pageType:ci.SLIDE,zIndex:10,title:n,description:"",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}setActivePage(n){this._activePage$.next(n)}getActivePage(){return this._activePage}updatePage(n,r){this._snapshot.body&&(this._snapshot.body.pages[n]=r)}appendPage(n){var i;if(!this._snapshot.body)return;this._snapshot.body.pages[n.id]=n;const r=this._activePage,s=this._snapshot.body.pageOrder.indexOf((i=r==null?void 0:r.id)!=null?i:"");this._snapshot.body.pageOrder.splice(s+1,0,n.id)}}var TE=Object.getOwnPropertyDescriptor,yE=(e,t,n,r)=>{for(var s=r>1?void 0:r?TE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},ko=(e,t)=>(n,r)=>t(n,r,e);const Mn=je.createIdentifier("univer.current");exports.UniverInstanceService=class extends st{constructor(n,r){super();C(this,"_unitsByType",new Map);C(this,"_createHandler");C(this,"_ctorByType",new Map);C(this,"_currentUnits",new Map);C(this,"_currentUnits$",new Oe.BehaviorSubject(this._currentUnits));C(this,"currentUnits$",this._currentUnits$.asObservable());C(this,"_unitAdded$",new Oe.Subject);C(this,"unitAdded$",this._unitAdded$.asObservable());C(this,"_unitDisposed$",new Oe.Subject);C(this,"unitDisposed$",this._unitDisposed$.asObservable());C(this,"_focused$",new Oe.BehaviorSubject(null));C(this,"focused$",this._focused$.asObservable());this._injector=n,this._contextService=r}dispose(){super.dispose(),this._focused$.complete()}__setCreateHandler(n){this._createHandler=n}createUnit(n,r,s){return this._createHandler(n,r,this._ctorByType.get(n),s)}registerCtorForType(n,r){return this._ctorByType.set(n,r),{dispose:()=>{this._ctorByType.delete(n)}}}getCurrentTypeOfUnit$(n){return this.currentUnits$.pipe(Oe.map(r=>{var s;return(s=r.get(n))!=null?s:null}),Oe.distinctUntilChanged())}getCurrentUnitForType(n){return this._currentUnits.get(n)}getCurrentUnitOfType(n){return this.getCurrentUnitForType(n)}setCurrentUnitForType(n){const r=this._getUnitById(n);if(!r)throw new Error(`[UniverInstanceService]: no document with unitId ${n}!`);this._currentUnits.set(r[1],r[0]),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(n){return this._unitAdded$.pipe(Oe.filter(r=>r.type===n))}__addUnit(n,r){var a;const s=n.type;this._unitsByType.has(s)||this._unitsByType.set(s,[]);const i=this._unitsByType.get(s),o=n.getUnitId();if(i.findIndex(l=>l.getUnitId()===o)!==-1)throw new Error(`[UniverInstanceService]: cannot create a unit with the same unit id: ${o}.`);i.push(n),this._unitAdded$.next(n),((a=r==null?void 0:r.makeCurrent)==null||a)&&this.setCurrentUnitForType(n.getUnitId())}getTypeOfUnitDisposed$(n){return this.unitDisposed$.pipe(Oe.filter(r=>r.type===n))}getUnit(n,r){var i;const s=(i=this._getUnitById(n))==null?void 0:i[0];return r&&(s==null?void 0:s.type)!==r?null:s}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(Be.UNIVER_DOC)}getUniverDocInstance(n){return this.getUnit(n,Be.UNIVER_DOC)}getUniverSheetInstance(n){return this.getUnit(n,Be.UNIVER_SHEET)}getAllUnitsForType(n){var r;return(r=this._unitsByType.get(n))!=null?r:[]}changeDoc(n,r){const s=this.getAllUnitsForType(Be.UNIVER_DOC),i=s.find(o=>o.getUnitId()===n);if(i!=null){const o=s.indexOf(i);s.splice(o,1)}this.__addUnit(r)}get focused(){var r;const n=this._focused$.getValue();return n?(r=this._getUnitById(n))==null?void 0:r[0]:null}focusUnit(n){this._focused$.next(n),this.focused instanceof exports.Workbook?(this._contextService.setContextValue(zn,!0),this._contextService.setContextValue(Gn,!1),this._contextService.setContextValue(wn,!0),this._contextService.setContextValue(Vn,!1),this.setCurrentUnitForType(n)):this.focused instanceof Mt?(this._contextService.setContextValue(zn,!0),this._contextService.setContextValue(Gn,!0),this._contextService.setContextValue(wn,!1),this._contextService.setContextValue(Vn,!1),this.setCurrentUnitForType(n)):this.focused instanceof yi?(this._contextService.setContextValue(zn,!0),this._contextService.setContextValue(Gn,!1),this._contextService.setContextValue(wn,!1),this._contextService.setContextValue(Vn,!0),this.setCurrentUnitForType(n)):(this._contextService.setContextValue(zn,!1),this._contextService.setContextValue(Gn,!1),this._contextService.setContextValue(wn,!1),this._contextService.setContextValue(Vn,!1))}getFocusedUnit(){return this.focused}getUnitType(n){const r=this._getUnitById(n);return r?r[1]:Be.UNRECOGNIZED}disposeUnit(n){const r=this._getUnitById(n);if(!r)return!1;const[s,i]=r,o=this._unitsByType.get(i),a=o.indexOf(s);return o.splice(a,1),this._tryResetCurrentOnRemoval(n,i),this._tryResetFocusOnRemoval(n),this._unitDisposed$.next(s),!0}_tryResetCurrentOnRemoval(n,r){const s=this.getCurrentUnitForType(r);(s==null?void 0:s.getUnitId())===n&&(this._currentUnits.set(r,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(n){var r;((r=this.focused)==null?void 0:r.getUnitId())===n&&this._focused$.next(null)}_getUnitById(n){for(const[r,s]of this._unitsByType){const i=s.find(o=>o.getUnitId()===n);if(i)return[i,r]}}};exports.UniverInstanceService=yE([ko(0,je.Inject(je.Injector)),ko(1,Dn)],exports.UniverInstanceService);var Je=(e=>(e[e.Starting=0]="Starting",e[e.Ready=1]="Ready",e[e.Rendered=2]="Rendered",e[e.Steady=3]="Steady",e))(Je||{});const NE={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"};var ME=Object.getOwnPropertyDescriptor,DE=(e,t,n,r)=>{for(var s=r>1?void 0:r?ME(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},LE=(e,t)=>(n,r)=>t(n,r,e);exports.LifecycleService=class extends st{constructor(n){super();C(this,"_lifecycle$",new Oe.BehaviorSubject(Je.Starting));C(this,"lifecycle$",this._lifecycle$.asObservable());C(this,"_lock",!1);this._logService=n,this._reportProgress(Je.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(n){if(this._lock)throw new Error("[LifecycleService]: cannot set new stage when related logic is all handled!");if(n<this.stage)throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");n!==this.stage&&(this._lock=!0,this._reportProgress(n),this._lifecycle$.next(n),this._lock=!1)}dispose(){this._lifecycle$.complete(),super.dispose()}onStage(n){return Oe.firstValueFrom(this.lifecycle$.pipe(Oe.filter(r=>r>=n),Ds(r=>r===n),Oe.map(()=>{})))}subscribeWithPrevious(){return Oe.merge($u(this.stage),this._lifecycle$.pipe(Oe.skip(1))).pipe(Ds(n=>n===Je.Steady))}_reportProgress(n){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${NE[n]}".`)}};exports.LifecycleService=DE([LE(0,Ot)],exports.LifecycleService);function $u(e){switch(e){case Je.Starting:return Oe.of(Je.Starting);case Je.Ready:return Oe.of(Je.Starting,Je.Ready);case Je.Rendered:return Oe.of(Je.Starting,Je.Ready,Je.Rendered);default:return Oe.of(Je.Starting,Je.Ready,Je.Rendered,Je.Steady)}}const xE=je.createIdentifier("ILocalStorageService");class ln extends st{constructor(){super();C(this,"_currentLocale$",new Oe.BehaviorSubject(or.ZH_CN));C(this,"currentLocale$",this._currentLocale$.asObservable());C(this,"_locales",null);C(this,"localeChanged$",new Oe.Subject);C(this,"t",(n,...r)=>{if(!this._locales)throw new Error("[LocaleService]: Locale not initialized");const s=n.split("."),i=this.resolveKeyPath(this._locales[this._currentLocale],s);if(typeof i=="string"){let o=i;return r.forEach((a,l)=>{o=o.replace(`{${l}}`,a)}),o}else return n});this.disposeWithMe(nt(()=>this.localeChanged$.complete()))}get _currentLocale(){return this._currentLocale$.value}load(n){var r;this._locales=Ci((r=this._locales)!=null?r:{},n)}setLocale(n){this._currentLocale$.next(n),this.localeChanged$.next()}getLocales(){var n;return(n=this._locales)==null?void 0:n[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(n,r){const s=r.shift();if(s&&n&&s in n){const i=n[s];return r.length>0&&(typeof i=="object"||Array.isArray(i))?this.resolveKeyPath(i,r):i}return null}}var Ni=(e=>(e.INIT="init",e.FETCHING="fetching",e.DONE="done",e))(Ni||{});const Hu=je.createIdentifier("univer.permission-service");class ju extends st{constructor(){super(...arguments);C(this,"_permissionPointMap",new Map);C(this,"_permissionPointUpdate$",new Oe.Subject);C(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable());C(this,"_showComponents",!0)}setShowComponents(n){this._showComponents=n}getShowComponents(){return this._showComponents}deletePermissionPoint(n){const r=this._permissionPointMap.get(n);r&&(r.complete(),this._permissionPointMap.delete(n))}addPermissionPoint(n){const r=n instanceof Oe.BehaviorSubject,s=r?n.getValue():n;if(!s.id)return!1;if(this._permissionPointMap.get(s.id))throw new Error(`${s.id} PermissionPoint already exists`);return this._permissionPointMap.set(s.id,r?n:new Oe.BehaviorSubject(s)),this._permissionPointUpdate$.next(s),!0}updatePermissionPoint(n,r){const s=this._permissionPointMap.get(n);if(!s)return;const i=s.getValue();i.value=r,i.status=Ni.DONE,s.next(i),this._permissionPointUpdate$.next(i)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(n){const r=this._permissionPointMap.get(n);if(r)return r.getValue()}getPermissionPoint$(n){const r=this._permissionPointMap.get(n);if(r)return r}composePermission$(n){const r=n.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.asObservable()});return Oe.combineLatest(r).pipe(Tr.map(s=>s))}composePermission(n){return n.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.getValue()})}getAllPermissionPoint(){const n=new Map;return this._permissionPointMap.forEach((r,s)=>{n.set(s,r)}),n}}var UE=Object.getOwnPropertyDescriptor,PE=(e,t,n,r)=>{for(var s=r>1?void 0:r?UE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},ws=(e,t)=>(n,r)=>t(n,r,e);const kE=4,Wu=Symbol("DependentOn");class ei extends st{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}C(ei,"pluginName"),C(ei,"type",Be.UNIVER_UNKNOWN);class FE{constructor(){C(this,"_plugins",[])}addPlugin(t){this._plugins.push(t)}removePlugins(){const t=this._plugins.slice();return this._plugins.length=0,t}forEachPlugin(t){this._plugins.forEach(t)}}function BE(...e){return function(t){t[Wu]=e}}exports.PluginService=class{constructor(t,n,r){C(this,"_pluginRegistry",new Map);C(this,"_pluginStore",new FE);C(this,"_seenPlugins",new Set);C(this,"_loadedPlugins",new Set);C(this,"_loadedPluginTypes",new Set([Be.UNIVER_UNKNOWN]));C(this,"_flushTimerByType",new Map);this._injector=t,this._lifecycleService=n,this._logService=r}dispose(){this._pluginStore.removePlugins().forEach(t=>t.dispose()),this._flushTimerByType.forEach(t=>clearTimeout(t))}registerPlugin(t,n){this._assertPluginValid(t);const r={plugin:t,options:n};this._pluginRegistry.set(t.pluginName,r),this._logService.debug("[PluginService]",`Plugin "${t.pluginName}" registered.`);const{type:s}=t;this._loadedPluginTypes.has(s)&&(s===Be.UNIVER_UNKNOWN?this._loadFromPlugins([r]):this._flushType(s))}startPluginsForType(t){this._loadedPluginTypes.has(t)||this._loadPluginsForType(t)}_loadPluginsForType(t){const n=Array.from(this._pluginRegistry.keys()),r=[];n.forEach(s=>{const i=this._pluginRegistry.get(s);i.plugin.type===t&&r.push(i)}),this._loadFromPlugins(r),this._loadedPluginTypes.add(t)}_assertPluginValid(t){const{type:n,pluginName:r}=t;if(n===Be.UNRECOGNIZED)throw new Error(`[PluginService]: invalid plugin type for ${t.name}. Please assign a "type" to your plugin.`);if(!r)throw new Error(`[PluginService]: no plugin name for ${t.name}. Please assign a "pluginName" to your plugin.`);if(this._seenPlugins.has(r))throw new Error(`[PluginService]: duplicated plugin name for "${r}". Maybe a plugin that dependents on "${r} has already registered it. In that case please register "${r}" before the that plugin.`);this._seenPlugins.add(t.pluginName)}_flushType(t){this._flushTimerByType.get(t)===void 0&&this._flushTimerByType.set(t,setTimeout(()=>{this._loadPluginsForType(t),this._flushTimerByType.delete(t)},kE))}_loadFromPlugins(t){const n=[],r=new Set,s=o=>{const{plugin:a}=o,{pluginName:l}=a;if(this._loadedPlugins.has(l)||r.has(l))return;r.add(l),this._pluginRegistry.delete(l);const u=a[Wu];u&&u.forEach(c=>{const h=this._pluginRegistry.get(c.pluginName);if(h)s(h);else if(!this._seenPlugins.has(c.pluginName)&&!r.has(c.pluginName)){if(a.type===Be.UNIVER_UNKNOWN&&c.type!==Be.UNIVER_UNKNOWN)throw new Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${a.pluginName} and the dependency is ${c.pluginName}.`);a.type!==c.type&&c.type!==Be.UNIVER_UNKNOWN&&this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${c.pluginName}" which has different type.`),this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${c.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(c),s({plugin:c,options:void 0})}}),n.push(o)};t.forEach(o=>s(o));const i=n.map(o=>this._initPlugin(o.plugin,o.options));this._pluginsRunLifecycle(i)}_pluginsRunLifecycle(t){const n=this._lifecycleService.stage;if($u(n).subscribe(r=>this._runStage(t,r)),n!==Je.Steady){const r=this._lifecycleService.lifecycle$.pipe(Oe.skip(1)).subscribe(s=>{this._runStage(t,s),s===Je.Steady&&r.unsubscribe()})}}_runStage(t,n){t.forEach(r=>{switch(n){case Je.Starting:r.onStarting();break;case Je.Ready:r.onReady();break;case Je.Rendered:r.onRendered();break;case Je.Steady:r.onSteady();break}})}_initPlugin(t,n){const r=this._injector.createInstance(t,n);return this._pluginStore.addPlugin(r),this._loadedPlugins.add(t.pluginName),this._logService.debug("[PluginService]",`Plugin "${r.getPluginName()}" loaded.`),r}};exports.PluginService=PE([ws(0,je.Inject(je.Injector)),ws(1,je.Inject(exports.LifecycleService)),ws(2,Ot)],exports.PluginService);function Yu(e,t){if(!t)return e;const n=[];for(const r of e){const s=t.find(([i])=>i===r[0]);if(s){if(s[1]===null)continue;n.push([r[0],s[1]])}else n.push(r)}return n}const ti=je.createIdentifier("resource-loader-service");var $E=Object.getOwnPropertyDescriptor,HE=(e,t,n,r)=>{for(var s=r>1?void 0:r?$E(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},jE=(e,t)=>(n,r)=>t(n,r,e);exports.ResourceManagerService=class extends st{constructor(n){super();C(this,"_resourceMap",new Map);C(this,"_register$",new Oe.Subject);C(this,"register$",this._register$.asObservable());this._logService=n}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(n,r){return r?this.getResourcesByType(n,r):this.getAllResourceHooks().map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}getResourcesByType(n,r){return this.getAllResourceHooks().filter(o=>o.businesses.includes(r)).map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}registerPluginResource(n){const r=n.pluginName;if(this._resourceMap.has(r))throw new Error(`the pluginName is registered {${r}}`);return this._resourceMap.set(r,n),this._register$.next(n),nt(()=>this._resourceMap.delete(r))}disposePluginResource(n){this._resourceMap.delete(n)}loadResources(n,r){this.getAllResourceHooks().forEach(s=>{var o;const i=(o=r==null?void 0:r.find(a=>a.name===s.pluginName))==null?void 0:o.data;if(i)try{const a=s.parseJson(i);s.onLoad(n,a)}catch(a){this._logService.error("[ResourceManagerService]","loadResources error",a)}})}unloadResources(n){this.getAllResourceHooks().forEach(r=>{r.onUnLoad(n)})}dispose(){this._register$.complete(),this._resourceMap.clear()}};exports.ResourceManagerService=HE([jE(0,Ot)],exports.ResourceManagerService);class qr extends st{constructor(){super();C(this,"_darkMode$",new Oe.BehaviorSubject(!1));C(this,"darkMode$",this._darkMode$.asObservable());C(this,"_currentTheme",hc.defaultTheme);C(this,"_currentTheme$",new Oe.BehaviorSubject(this._currentTheme));C(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(nt(()=>{this._currentTheme$.complete(),this._darkMode$.complete()}))}get darkMode(){return this._darkMode$.getValue()}getCurrentTheme(){return this._currentTheme}setTheme(n){this._currentTheme=n,this._currentTheme$.next(n)}setDarkMode(n){this._darkMode$.next(n)}getColorFromTheme(n){return $l(this._currentTheme,n)}}var WE=Object.getOwnPropertyDescriptor,YE=(e,t,n,r)=>{for(var s=r>1?void 0:r?WE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},bs=(e,t)=>(n,r)=>t(n,r,e);const cs=je.createIdentifier("univer.undo-redo.service"),zE=20;class zu{dispose(){}async dispatchToHandlers(){return!1}}const Gu="univer.command.redo",Vu="univer.command.undo",Ku=new class extends zu{constructor(){super(...arguments);C(this,"type",sr.COMMAND);C(this,"id",Vu)}handler(t){const n=t.get(cs),r=n.pitchTopUndoElement();if(!r)return!1;const s=t.get(ir);return Qr(r.undoMutations,s)?(n.popUndoToRedo(),!0):!1}},Xu=new class extends zu{constructor(){super(...arguments);C(this,"type",sr.COMMAND);C(this,"id",Gu)}handler(t){const n=t.get(cs),r=n.pitchTopRedoElement();if(!r)return!1;const s=t.get(ir);return Qr(r.redoMutations,s)?(n.popRedoToUndo(),!0):!1}};exports.LocalUndoRedoService=class extends st{constructor(n,r,s){super();C(this,"undoRedoStatus$");C(this,"_undoRedoStatus$",new Oe.BehaviorSubject({undos:0,redos:0}));C(this,"_undoStacks",new Map);C(this,"_redoStacks",new Map);C(this,"_batchingStatus",new Map);this._univerInstanceService=n,this._commandService=r,this._contextService=s,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(Ku)),this.disposeWithMe(this._commandService.registerCommand(Xu)),this.disposeWithMe(nt(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(nt(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(n){const{unitID:r}=n,s=this._getRedoStack(r,!0),i=this._getUndoStack(r,!0);if(s.length=0,this._batchingStatus.has(n.unitID)){const a=this._batchingStatus.get(n.unitID),l=this._pitchUndoElement(n.unitID);a===0||!l?(o(n),this._batchingStatus.set(n.unitID,1)):this._tryBatchingElements(l,n)}else o(n);function o(a){i.push(a),i.length>zE&&i.splice(0,1)}this._updateStatus()}clearUndoRedo(n){const r=this._getRedoStack(n);r&&(r.length=0);const s=this._getUndoStack(n);s&&(s.length=0),this._updateStatus()}pitchTopUndoElement(){const n=this._getFocusedUnitId();return this._pitchUndoElement(n)}pitchTopRedoElement(){const n=this._getFocusedUnitId();return this._pitchRedoElement(n)}_pitchUndoElement(n){const r=this._getUndoStack(n);return r!=null&&r.length?r[r.length-1]:null}_pitchRedoElement(n){const r=this._getRedoStack(n);return r!=null&&r.length?r[r.length-1]:null}popUndoToRedo(){const r=this._getUndoStackForFocused().pop();r&&(this._getRedoStackForFocused().push(r),this._updateStatus())}popRedoToUndo(){const r=this._getRedoStackForFocused().pop();r&&(this._getUndoStackForFocused().push(r),this._updateStatus())}rollback(n,r){const s=r||this._getFocusedUnitId(),i=this._getUndoStack(s),o=i==null?void 0:i[(i==null?void 0:i.length)-1];o&&o.id===n&&(i.pop(),Qr(o.undoMutations,this._commandService))}__tempBatchingUndoRedo(n){if(this._batchingStatus.has(n))throw new Error("[LocalUndoRedoService]: cannot batching undo redo twice at the same time!");return this._batchingStatus.set(n,0),nt(()=>this._batchingStatus.delete(n))}_updateStatus(){var i,o;const n=this._getFocusedUnitId(),r=n&&((i=this._undoStacks.get(n))==null?void 0:i.length)||0,s=n&&((o=this._redoStacks.get(n))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:r,redos:s})}_getUndoStack(n,r=!1){let s=this._undoStacks.get(n);return!s&&r&&(s=[],this._undoStacks.set(n,s)),s||null}_getRedoStack(n,r=!1){let s=this._redoStacks.get(n);return!s&&r&&(s=[],this._redoStacks.set(n,s)),s||null}_getUndoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getUndoStack(n,!0)}_getRedoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getRedoStack(n,!0)}_tryBatchingElements(n,r){n.redoMutations.push(...r.redoMutations),n.undoMutations.push(...r.undoMutations)}_getFocusedUnitId(){var o,a,l,u;let n="";const r=this._contextService.getContextValue(wn),s=this._contextService.getContextValue(wu),i=this._contextService.getContextValue(Ou);return r?s?n=li:i?n=ai:n=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":n=(u=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?u:"",n}};exports.LocalUndoRedoService=YE([bs(0,Mn),bs(1,ir),bs(2,Dn)],exports.LocalUndoRedoService);function GE(e){return!(e.length===0||e.length>31||e.startsWith("'")||e.endsWith("'")||/[:\\\/\?\*\[\]]/.test(e))}function VE(e){return new Promise(t=>setTimeout(t,e))}function KE(e=1){return new Promise(t=>{let n=0;const r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}var Mi=(e=>(e.URL="URL",e.UUID="UUID",e.BASE64="BASE64",e))(Mi||{}),qu=(e=>(e.SUCCUSS="0",e.ERROR_EXCEED_SIZE="1",e.ERROR_IMAGE_TYPE="2",e.ERROR_UPLOAD_COUNT_LIMIT="3",e.ERROR_IMAGE="4",e))(qu||{});const ni=je.createIdentifier("core.image-io.service");class Ju{constructor(t,n=100){C(this,"_imageCacheMap");this._injector=t,this._imageCacheMap=new Zn(n)}_getImageCacheKey(t,n){return`${t}-${n}`}getImage(t,n,r,s){const i=this._getImageCacheKey(t,n);let o=this._imageCacheMap.get(i);return o||((async()=>{o=new Image;const a=this._injector.has(ni)?this._injector.get(ni):null;if(t===Mi.UUID)try{o.src=await(a==null?void 0:a.getImage(n))||""}catch(l){console.error(l)}else o.src=n;o.onload=()=>{r==null||r()},o.onerror=()=>{s==null||s()},this._imageCacheMap.set(i,o)})(),null)}}const XE=["script","style","meta","comment","link"];var Zu=(e=>(e[e.INFO=0]="INFO",e[e.STOP=1]="STOP",e[e.WARNING=2]="WARNING",e))(Zu||{}),Qu=(e=>(e[e.DISABLED=0]="DISABLED",e[e.FULL_ALPHA=1]="FULL_ALPHA",e[e.FULL_HANGUL=2]="FULL_HANGUL",e[e.FULL_KATAKANA=3]="FULL_KATAKANA",e[e.HALF_ALPHA=4]="HALF_ALPHA",e[e.HALF_HANGUL=5]="HALF_HANGUL",e[e.HALF_KATAKANA=6]="HALF_KATAKANA",e[e.HIRAGANA=7]="HIRAGANA",e[e.NO_CONTROL=8]="NO_CONTROL",e[e.OFF=9]="OFF",e[e.ON=10]="ON",e))(Qu||{}),ec=(e=>(e.BETWEEN="between",e.EQUAL="equal",e.GREATER_THAN="greaterThan",e.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",e.LESS_THAN="lessThan",e.LESS_THAN_OR_EQUAL="lessThanOrEqual",e.NOT_BETWEEN="notBetween",e.NOT_EQUAL="notEqual",e))(ec||{}),tc=(e=>(e[e.TEXT=0]="TEXT",e[e.ARROW=1]="ARROW",e[e.CUSTOM=2]="CUSTOM",e))(tc||{}),nc=(e=>(e.VALID="valid",e.INVALID="invalid",e.VALIDATING="validating",e))(nc||{}),rc=(e=>(e.CUSTOM="custom",e.LIST="list",e.LIST_MULTIPLE="listMultiple",e.NONE="none",e.TEXT_LENGTH="textLength",e.DATE="date",e.TIME="time",e.WHOLE="whole",e.DECIMAL="decimal",e.CHECKBOX="checkbox",e.ANY="any",e))(rc||{}),qE=Object.getOwnPropertyDescriptor,JE=(e,t,n,r)=>{for(var s=r>1?void 0:r?qE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},ZE=(e,t)=>(n,r)=>t(n,r,e);exports.Skeleton=class extends st{constructor(n){super();C(this,"_fontLocale");C(this,"_dirty",!0);this._localeService=n,this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(n){this._dirty=n}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}};exports.Skeleton=JE([ZE(0,je.Inject(ln))],exports.Skeleton);var QE=Object.getOwnPropertyDescriptor,e0=(e,t,n,r)=>{for(var s=r>1?void 0:r?QE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Ar=(e,t)=>(n,r)=>t(n,r,e);exports.SheetSkeleton=class extends exports.Skeleton{constructor(n,r,s,i,o,a){super(s);C(this,"_worksheetData");C(this,"_renderRawFormula",!1);C(this,"_cellData");C(this,"_imageCacheMap");C(this,"_isRowStylePrecedeColumnStyle",!1);C(this,"_skipAutoHeightForMergedCells",!0);C(this,"_rowTotalHeight",0);C(this,"_columnTotalWidth",0);C(this,"_rowHeaderWidth",0);C(this,"_columnHeaderHeight",0);C(this,"_rowHeightAccumulation",[]);C(this,"_columnWidthAccumulation",[]);C(this,"_marginTop",0);C(this,"_marginLeft",0);C(this,"_scaleX");C(this,"_scaleY");C(this,"_scrollX");C(this,"_scrollY");this.worksheet=n,this._styles=r,this._contextService=i,this._configService=o,this._injector=a,this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new Ju(this._injector),this.initConfig()}initConfig(){var n,r;this._skipAutoHeightForMergedCells=!((n=this._configService.getConfig(Fa))!=null&&n),this._isRowStylePrecedeColumnStyle=(r=this._configService.getConfig(ka))!=null?r:!1}resetCache(){}getWorksheetConfig(){return this._worksheetData}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(n){this._columnHeaderHeight=n,this._worksheetData.columnHeader.height=n}set rowHeaderWidth(n){this._rowHeaderWidth=n,this._worksheetData.rowHeader.width=n}get rowHeightAccumulation(){return this._rowHeightAccumulation}get rowTotalHeight(){return this._rowTotalHeight}get columnWidthAccumulation(){return this._columnWidthAccumulation}get columnTotalWidth(){return this._columnTotalWidth}get rowHeaderWidth(){return this._rowHeaderWidth}get columnHeaderHeight(){return this._columnHeaderHeight}setMarginLeft(n){this._marginLeft=n}setMarginTop(n){this._marginTop=n}setScale(n,r){this._updateLayout(),this._scaleX=n,this._scaleY=r||n,this._updateLayout()}setScroll(n,r){ne.isDefine(n)&&(this._scrollX=n),ne.isDefine(r)&&(this._scrollY=r)}get scrollX(){return this._scrollX}get scrollY(){return this._scrollY}get scaleX(){return this._scaleX}get scaleY(){return this._scaleY}get rowHeaderWidthAndMarginLeft(){return this.rowHeaderWidth+this._marginLeft}get columnHeaderHeightAndMarginTop(){return this.columnHeaderHeight+this._marginTop}get imageCacheMap(){return this._imageCacheMap}_generateRowMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let u=s;if(this.worksheet.getRowFiltered(l))u=0;else if(a[l]!=null){const c=a[l];if(!c)continue;const{h=s,ah:d,ia:f}=c;(f==null||f===Ie.TRUE)&&typeof d=="number"?u=d:u=h,c.hd===Ie.TRUE&&(u=0)}i+=u,o.push(i)}return{rowTotalHeight:i,rowHeightAccumulation:o}}_generateColumnMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let u=s;if(a[l]!=null){const c=a[l];if(!c)continue;c.w!=null&&(u=c.w),c.hd===Ie.TRUE&&(u=0)}i+=u,o.push(i)}return{columnTotalWidth:i,columnWidthAccumulation:o}}intersectMergeRange(n,r){return!!this.worksheet.getMergedCell(n,r)}_getOverflowBound(n,r,s,i,o=yt.LEFT){let a=0;if(r>s){const l=this._columnWidthAccumulation.length-1;for(let u=r;u>=s;u--){const c=u,h=this.worksheet.getCell(n,c);if(!Bs(h)&&c!==r||this.intersectMergeRange(n,c))return c===r?c:c+1>l?l:c+1;const{startX:d,endX:f}=In(n,c,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===yt.CENTER&&c===r?a+=(f-d)/2:a+=f-d,i<a)return c}return r}for(let l=r;l<=s;l++){const u=l,c=this.worksheet.getCell(n,u);if(!Bs(c)&&u!==r||this.intersectMergeRange(n,u))return u===r?u:u-1<0?0:u-1;const{startX:h,endX:d}=In(n,u,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===yt.CENTER&&u===r?a+=(d-h)/2:a+=d-h,i<a)return u}return s}_updateLayout(){if(!this.dirty)return;const{rowData:n,columnData:r,defaultRowHeight:s,defaultColumnWidth:i,rowCount:o,columnCount:a,rowHeader:l,columnHeader:u}=this._worksheetData,{rowTotalHeight:c,rowHeightAccumulation:h}=this._generateRowMatrixCache(o,n,s),{columnTotalWidth:d,columnWidthAccumulation:f}=this._generateColumnMatrixCache(a,r,i);this._rowHeaderWidth=l.hidden!==Ie.TRUE?this._dynamicallyUpdateRowHeaderWidth(l):0,this._columnHeaderHeight=u.hidden!==Ie.TRUE?u.height:0,this._rowTotalHeight=c,this._rowHeightAccumulation=h,this._columnTotalWidth=d,this._columnWidthAccumulation=f,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(n){}_dynamicallyUpdateRowHeaderWidth(n){const s=`${this.worksheet.getRowCount()}`.length*8;return Math.max(n.width,s)}_hasUnMergedCellInRow(n,r,s){if(!this.worksheet.getMergeData())return!1;for(let o=r;o<=s;o++){const{isMerged:a,isMergedMainCell:l}=this.worksheet.getCellInfoInMergeData(n,o);if(!a&&!l)return!0}return!1}expandRangeByMerge(n){let{startRow:r,startColumn:s,endRow:i,endColumn:o}=n;const a=this._worksheetData.mergeData;if(!a)return{startRow:r,startColumn:s,endRow:i,endColumn:o};let l=!0;const u=new Et;for(;l;){l=!1;for(let c=0;c<a.length;c++){const{startRow:h,startColumn:d,endRow:f,endColumn:p}=a[c];if(u.getValue(h,d))continue;Cl({startColumn:s,startRow:r,endColumn:o,endRow:i},{startColumn:d,startRow:h,endColumn:p,endRow:f})&&(r=Math.min(r,h),s=Math.min(s,d),i=Math.max(i,f),o=Math.max(o,p),u.setValue(h,d,!0),l=!0)}}return{startRow:r,startColumn:s,endRow:i,endColumn:o}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(n,r){return this.worksheet.getCellInfoInMergeData(n,r)}getNoMergeCellPositionByIndex(n,r,s=!0){return this.getNoMergeCellWithCoordByIndex(n,r,s)}getNoMergeCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this;let{startY:u,endY:c,startX:h,endX:d}=In(n,r,i,o);return s&&(u+=l,c+=l,h+=a,d+=a),{startY:u,endY:c,startX:h,endX:d}}getNoMergeCellPositionByIndexWithNoHeader(n,r){const{rowHeightAccumulation:s,columnWidthAccumulation:i}=this,{startY:o,endY:a,startX:l,endX:u}=In(n,r,s,i);return{startY:o,endY:a,startX:l,endX:u}}getRowIndexByOffsetY(n,r,s,i){var l;const{rowHeightAccumulation:o}=this;n=ic(n,r,s,this.columnHeaderHeightAndMarginTop);let a=$n(o,n,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(o[a]-n)<Math.abs(n-((l=o[a-1])!=null?l:0))&&(a=a+1),a}getColumnIndexByOffsetX(n,r,s,i){var u;const o=sc(n,r,s,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this;let l=$n(a,o,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(a[l]-o)<Math.abs(o-((u=a[l-1])!=null?u:0))&&(l=l+1),l}getCellIndexByOffset(n,r,s,i,o,a){const l=this.getRowIndexByOffsetY(r,i,o,a),u=this.getColumnIndexByOffsetX(n,s,o,a);return{row:l,column:u}}getCellByOffset(n,r,s,i,o){const a=this==null?void 0:this.getCellIndexByOffset(n,r,s,i,o,{firstMatch:!0});return a?this.worksheet.getCellInfoInMergeData(a.row,a.column):null}getCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this,u=In(n,r,i,o,this.worksheet.getCellInfoInMergeData(n,r)),{isMerged:c,isMergedMainCell:h}=u;let{startY:d,endY:f,startX:p,endX:R,mergeInfo:w}=u,N=a,G=l;return s===!1&&(N=0,G=0),d+=G,f+=G,p+=N,R+=N,w.startY+=G,w.endY+=G,w.startX+=N,w.endX+=N,{actualRow:n,actualColumn:r,startX:p,startY:d,endX:R,endY:f,isMerged:c,isMergedMainCell:h,mergeInfo:w}}getCellWithCoordByOffset(n,r,s,i,o,a){const{row:l,column:u}=this.getCellIndexByOffset(n,r,s,i,o,a);return this.getCellWithCoordByIndex(l,u)}getOffsetByColumn(n){const{columnWidthAccumulation:r,rowHeaderWidthAndMarginLeft:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetByRow(n){const{rowHeightAccumulation:r,columnHeaderHeightAndMarginTop:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetRelativeToRowCol(n,r){const s=$n(this.columnWidthAccumulation,n);let i=0;s===0?i=n:i=n-this._columnWidthAccumulation[s-1];const o=$n(this.rowHeightAccumulation,r);let a=0;return o===0?a=r:a=r-this._rowHeightAccumulation[o-1],{row:o,column:s,columnOffset:i,rowOffset:a}}_updateConfigAndGetDocumentModel(n,r,s,i){var a,l,u,c,h;if(!i||!((a=n.body)!=null&&a.dataStream))return;n.documentStyle||(n.documentStyle={}),n.documentStyle.marginTop=(l=s.t)!=null?l:0,n.documentStyle.marginBottom=(u=s.b)!=null?u:2,n.documentStyle.marginLeft=(c=s.l)!=null?c:2,n.documentStyle.marginRight=(h=s.r)!=null?h:2,n.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},n.documentStyle.renderConfig={...n.documentStyle.renderConfig,...i};const o=n.body.paragraphs||[];for(const d of o)d.paragraphStyle||(d.paragraphStyle={}),d.paragraphStyle.horizontalAlign=r;return new Mt(n)}dispose(){super.dispose(),this._rowHeightAccumulation=[],this._columnWidthAccumulation=[],this._rowTotalHeight=0,this._columnTotalWidth=0,this._rowHeaderWidth=0,this._columnHeaderHeight=0,this._worksheetData=null,this._cellData=null,this._styles=null}};exports.SheetSkeleton=e0([Ar(2,je.Inject(ln)),Ar(3,Dn),Ar(4,Ti),Ar(5,je.Inject(je.Injector))],exports.SheetSkeleton);function Di(e,t,n,r){const s=e-1,i=t-1,o=n[s]||0;let a=n[e];a==null&&(a=n[n.length-1]);const l=r[i]||0;let u=r[t];return u==null&&(u=r[r.length-1]),{startY:o,endY:a,startX:l,endX:u}}function t0(e,t,n,r){return Di(e,t,n,r)}function In(e,t,n,r,s){e=ne.clamp(e,0,n.length-1),t=ne.clamp(t,0,r.length-1);let{startY:i,endY:o,startX:a,endX:l}=Di(e,t,n,r);if(!s)return{startY:i,endY:o,startX:a,endX:l,isMerged:!1,isMergedMainCell:!1,actualRow:e,actualColumn:t,mergeInfo:{startY:i,endY:o,startX:a,endX:l,startRow:e,startColumn:t,endRow:e,endColumn:t}};const{isMerged:u,isMergedMainCell:c,startRow:h,startColumn:d,endRow:f,endColumn:p}=s;let R={startRow:h,startColumn:d,endRow:f,endColumn:p,startY:i,endY:o,startX:a,endX:l};const w=n.length-1,N=r.length-1;if(u&&h!==-1&&d!==-1){const G=n[h-1]||0,W=n[f]||n[w],se=r[d-1]||0,y=r[p]||r[N];R={...R,startY:G,endY:W,startX:se,endX:y}}else if(!u&&f!==-1&&p!==-1){const G=n[f]||n[w],W=r[p]||r[N];R={...R,startY:i,endY:G,startX:a,endX:W}}return{isMerged:u,isMergedMainCell:c,actualRow:e,actualColumn:t,startY:i,endY:o,startX:a,endX:l,mergeInfo:R}}function sc(e,t,n,r){const{x:s}=n;return e/t+s-r}function ic(e,t,n,r){const{y:s}=n;return e=e/t+s-r,e}const Fo=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],As=1,Fn=8;class Li{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[n,r]=new Uint8Array(t,0,2);if(n!==219)throw new Error("Data does not appear to be in a KDBush format.");const s=r>>4;if(s!==As)throw new Error(`Got v${s} data when expected v${As}.`);const i=Fo[r&15];if(!i)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new Li(a,o,i,t)}constructor(t,n=64,r=Float64Array,s){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+n,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=Fo.indexOf(this.ArrayType),o=t*2*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);s&&s instanceof ArrayBuffer?(this.data=s,this.ids=new this.IndexArrayType(this.data,Fn,t),this.coords=new this.ArrayType(this.data,Fn+a+l,t*2),this._pos=t*2,this._finished=!0):(this.data=new ArrayBuffer(Fn+o+a+l),this.ids=new this.IndexArrayType(this.data,Fn,t),this.coords=new this.ArrayType(this.data,Fn+a+l,t*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(As<<4)+i]),new Uint16Array(this.data,2,1)[0]=n,new Uint32Array(this.data,4,1)[0]=t)}add(t,n){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=n,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ri(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,n,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:o,nodeSize:a}=this,l=[0,i.length-1,0],u=[];for(;l.length;){const c=l.pop()||0,h=l.pop()||0,d=l.pop()||0;if(h-d<=a){for(let w=d;w<=h;w++){const N=o[2*w],G=o[2*w+1];N>=t&&N<=r&&G>=n&&G<=s&&u.push(i[w])}continue}const f=d+h>>1,p=o[2*f],R=o[2*f+1];p>=t&&p<=r&&R>=n&&R<=s&&u.push(i[f]),(c===0?t<=p:n<=R)&&(l.push(d),l.push(f-1),l.push(1-c)),(c===0?r>=p:s>=R)&&(l.push(f+1),l.push(h),l.push(1-c))}return u}within(t,n,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:i,nodeSize:o}=this,a=[0,s.length-1,0],l=[],u=r*r;for(;a.length;){const c=a.pop()||0,h=a.pop()||0,d=a.pop()||0;if(h-d<=o){for(let w=d;w<=h;w++)Bo(i[2*w],i[2*w+1],t,n)<=u&&l.push(s[w]);continue}const f=d+h>>1,p=i[2*f],R=i[2*f+1];Bo(p,R,t,n)<=u&&l.push(s[f]),(c===0?t-r<=p:n-r<=R)&&(a.push(d),a.push(f-1),a.push(1-c)),(c===0?t+r>=p:n+r>=R)&&(a.push(f+1),a.push(h),a.push(1-c))}return l}}function ri(e,t,n,r,s,i){if(s-r<=n)return;const o=r+s>>1;oc(e,t,o,r,s,i),ri(e,t,n,r,o-1,1-i),ri(e,t,n,o+1,s,1-i)}function oc(e,t,n,r,s,i){for(;s>r;){if(s-r>600){const u=s-r+1,c=n-r+1,h=Math.log(u),d=.5*Math.exp(2*h/3),f=.5*Math.sqrt(h*d*(u-d)/u)*(c-u/2<0?-1:1),p=Math.max(r,Math.floor(n-c*d/u+f)),R=Math.min(s,Math.floor(n+(u-c)*d/u+f));oc(e,t,n,p,R,i)}const o=t[2*n+i];let a=r,l=s;for(Bn(e,t,r,n),t[2*s+i]>o&&Bn(e,t,r,s);a<l;){for(Bn(e,t,a,l),a++,l--;t[2*a+i]<o;)a++;for(;t[2*l+i]>o;)l--}t[2*r+i]===o?Bn(e,t,r,l):(l++,Bn(e,t,l,s)),l<=n&&(r=l+1),n<=l&&(s=l-1)}}function Bn(e,t,n,r){Ts(e,n,r),Ts(t,2*n,2*r),Ts(t,2*n+1,2*r+1)}function Ts(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function Bo(e,t,n,r){const s=e-n,i=t-r;return s*s+i*i}class n0{constructor(t=!1){C(this,"_tree",new Map);C(this,"_oneCellCache",new Map);C(this,"_kdTree",new Map);this._enableOneCellCache=t}dispose(){this.clear()}getTree(t,n){return this._tree.has(t)||this._tree.set(t,new Map),this._tree.get(t).has(n)||this._tree.get(t).set(n,new zr),this._tree.get(t).get(n)}_getOneCellCache(t,n,r,s){return this._oneCellCache.has(t)||this._oneCellCache.set(t,new Map),this._oneCellCache.get(t).has(n)||this._oneCellCache.get(t).set(n,new Map),this._oneCellCache.get(t).get(n).has(r)||this._oneCellCache.get(t).get(n).set(r,new Map),this._oneCellCache.get(t).get(n).get(r).has(s)||this._oneCellCache.get(t).get(n).get(r).set(s,new Set),this._oneCellCache.get(t).get(n).get(r).get(s)}_removeOneCellCache(t,n,r,s,i){const o=this._oneCellCache.get(t);if(!o)return;const a=o.get(n);if(!a)return;const l=a.get(r);if(!l)return;const u=l.get(s);u&&u.delete(i)}_removeCellCacheByRange(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this._oneCellCache.get(n);if(!o)return;const a=o.get(r);if(!a)return;const{startRow:l,startColumn:u,endRow:c,endColumn:h}=s;for(let d=l;d<=c;d++){const f=a.get(d);if(f)for(let p=u;p<=h;p++){const R=f.get(p);R&&R.delete(i)}}}_insertOneCellCache(t,n,r,s,i){this._getOneCellCache(t,n,r,s).add(i)}_getRdTreeItems(t){const n=[];for(const[r,s]of t)for(const[i,o]of s)n.push({x:i,y:r,ids:o});return n}_searchByOneCellCache(t){var p;const{unitId:n,sheetId:r,range:s}=t,{startRow:i,startColumn:o,endRow:a,endColumn:l}=s,u=(p=this._kdTree.get(n))==null?void 0:p.get(r);if(!u)return[];const{tree:c,items:h}=u,d=c.range(o,i,l,a),f=[];for(const R of d){const w=h[R];f.push(...Array.from(w.ids))}return f}openKdTree(){var t;for(const[n,r]of this._oneCellCache){this._kdTree.has(n)||this._kdTree.set(n,new Map);for(const[s,i]of r){const o=this._getRdTreeItems(i),a=new Li(o.length);(t=this._kdTree.get(n))==null||t.set(s,{tree:a,items:o});for(const l of o)a.add(l.x,l.y);a.finish()}}}closeKdTree(){var t;for(const[n,r]of this._oneCellCache)for(const[s,i]of r)(t=this._kdTree.get(n))==null||t.set(s,void 0)}insert(t){const{unitId:n,sheetId:r,range:s,id:i}=t;if(!n||n.length===0)return;let{startRow:o,endRow:a,startColumn:l,endColumn:u}=s;if(this._enableOneCellCache&&o===a&&l===u){this._insertOneCellCache(n,r,o,l,i);return}const c=this.getTree(n,r);Number.isNaN(o)&&(o=0),Number.isNaN(l)&&(l=0),Number.isNaN(a)&&(a=Number.POSITIVE_INFINITY),Number.isNaN(u)&&(u=Number.POSITIVE_INFINITY),c.insert({minX:l,minY:o,maxX:u,maxY:a,id:i})}bulkInsert(t){for(const n of t)this.insert(n)}*searchGenerator(t){var a;const{unitId:n,sheetId:r,range:s}=t;if(this._enableOneCellCache){const l=this._searchByOneCellCache(t);for(const u of l)yield u}const i=(a=this._tree.get(n))==null?void 0:a.get(r);if(!i)return;const o=i.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(const l of o)yield l.id}bulkSearch(t,n){const r=new Set;for(const s of t)for(const i of this.searchGenerator(s))(n==null?void 0:n.has(i))!==!0&&r.add(i);return r}removeById(t,n){var r,s;n?((r=this._tree.get(t))==null||r.delete(n),(s=this._oneCellCache.get(t))==null||s.delete(n)):(this._tree.delete(t),this._oneCellCache.delete(t))}_removeRTreeItem(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this.getTree(n,r),a=o.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(let l=0;l<a.length;l++)a[l].id===i&&o.remove(a[l])}remove(t){const{unitId:n,sheetId:r,range:s,id:i}=t,{startRow:o,startColumn:a,endRow:l,endColumn:u}=s;this._enableOneCellCache?o===l&&a===u?this._removeOneCellCache(n,r,s.startRow,s.startColumn,i):(this._removeCellCacheByRange(t),this._removeRTreeItem(t)):this._removeRTreeItem(t)}bulkRemove(t){for(const n of t)this.remove(n)}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){const t={};return this._tree.forEach((n,r)=>{t[r]={},n.forEach((s,i)=>{t[r][i]=s.toJSON()})}),t}fromJSON(t){this._tree.clear();for(const n in t){this._tree.set(n,new Map);for(const r in t[n]){const s=new zr;s.fromJSON(t[n][r]),this._tree.get(n).set(r,s)}}}}var r0=Object.getOwnPropertyDescriptor,s0=(e,t,n,r)=>{for(var s=r>1?void 0:r?r0(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},$o=(e,t)=>(n,r)=>t(n,r,e);let si=class extends st{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){const e=n=>{n.businesses.forEach(r=>{switch(r){case Be.UNRECOGNIZED:case Be.UNIVER_UNKNOWN:case Be.UNIVER_SLIDE:case Be.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType(Be.UNIVER_DOC).forEach(s=>{const o=(s.getSnapshot().resources||[]).find(a=>a.name===n.pluginName);if(o)try{const a=n.parseJson(o.data);n.onLoad(s.getUnitId(),a)}catch{console.error(`Load Document{${s.getUnitId()}} Resources{${n.pluginName}} Data Error.`)}});break}case Be.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(Be.UNIVER_SHEET).forEach(s=>{const o=(s.getSnapshot().resources||[]).find(a=>a.name===n.pluginName);if(o)try{const a=n.parseJson(o.data);n.onLoad(s.getUnitId(),a)}catch{console.error(`Load Workbook{${s.getUnitId()}} Resources{${n.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(n=>e(n)),this.disposeWithMe(this._resourceManagerService.register$.subscribe(n=>e(n))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(Be.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(Be.UNIVER_DOC).subscribe(n=>{const r=n.getUnitId();Ba(r)||this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(Be.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(Be.UNIVER_DOC).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())}))}saveUnit(e){const t=this._univerInstanceService.getUnit(e);if(!t)return null;const n=this._resourceManagerService.getResources(e,t.type),r=ne.deepClone(t.getSnapshot());return r.resources=n,r}};si=s0([$o(0,je.Inject(us)),$o(1,je.Inject(Mn))],si);class i0{constructor(t={},n){C(this,"_startedTypes",new Set);C(this,"_injector");C(this,"_disposingCallbacks",new Zr);const r=this._injector=o0(n,t==null?void 0:t.override),{theme:s,darkMode:i,locale:o,locales:a,logLevel:l}=t;s&&this._injector.get(qr).setTheme(s),i&&this._injector.get(qr).setDarkMode(i),a&&this._injector.get(ln).load(a),o&&this._injector.get(ln).setLocale(o),l&&this._injector.get(Ot).setLogLevel(l),this._init(r)}get _univerInstanceService(){return this._injector.get(Mn)}get _pluginService(){return this._injector.get(exports.PluginService)}__getInjector(){return this._injector}onDispose(t){const n=this._disposingCallbacks.add(nt(t));return nt(()=>n.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(t){this._injector.get(ln).setLocale(t)}createUnit(t,n){return this._univerInstanceService.createUnit(t,n)}createUniverSheet(t){return this._injector.get(Ot).warn("[Univer]","Univer.createUniverSheet is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(Be.UNIVER_SHEET,t)}createUniverDoc(t){return this._injector.get(Ot).warn("[Univer]","Univer.createUniverDoc is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(Be.UNIVER_DOC,t)}createUniverSlide(t){return this._injector.get(Ot).warn("[Univer]","Univer.createUniverSlide is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(Be.UNIVER_SLIDE,t)}_init(t){this._univerInstanceService.registerCtorForType(Be.UNIVER_SHEET,exports.Workbook),this._univerInstanceService.registerCtorForType(Be.UNIVER_DOC,Mt),this._univerInstanceService.registerCtorForType(Be.UNIVER_SLIDE,yi);const n=t.get(Mn);n.__setCreateHandler((r,s,i,o)=>{if(!this._startedTypes.has(r)){this._pluginService.startPluginsForType(r),this._startedTypes.add(r);const l=t.createInstance(i,s);return n.__addUnit(l,o),this._tryProgressToReady(),l}const a=t.createInstance(i,s);return n.__addUnit(a,o),a})}_tryProgressToReady(){this._injector.get(exports.LifecycleService).stage<Je.Ready&&(this._injector.get(exports.LifecycleService).stage=Je.Ready)}registerPlugin(t,n){this._pluginService.registerPlugin(t,n)}}function o0(e,t){const n=Yu([[bu],[ln],[qr],[exports.LifecycleService],[exports.PluginService],[tr],[Mn,{useClass:exports.UniverInstanceService}],[Hu,{useClass:ju}],[Ot,{useClass:Xo,lazy:!0}],[ir,{useClass:exports.CommandService}],[cs,{useClass:exports.LocalUndoRedoService,lazy:!0}],[Ti,{useClass:vu}],[Dn,{useClass:Vo}],[us,{useClass:exports.ResourceManagerService,lazy:!0}],[ti,{useClass:si,lazy:!0}],[Iu,{useClass:exports.AuthzIoLocalService}],[Su,{useClass:exports.MentionIOLocalService,lazy:!0}]],t),r=e?e.createChild(n):new je.Injector(n);return Yo(r,[[tr],[ti]]),r}function ac(e){return e.map(t=>t/255)}function lc(e){return e.map(t=>Math.round(t*255))}const It=[[.333,-.667,-.667,0,1],[-.667,.333,-.667,0,1],[-.667,-.667,.333,0,1],[0,0,0,1,0]];function a0(e){const t=e[0],n=e[1],r=e[2];let s=[It[0][0]*t+It[0][1]*n+It[0][2]*r+It[0][4],It[1][0]*t+It[1][1]*n+It[1][2]*r+It[1][4],It[2][0]*t+It[2][1]*n+It[2][2]*r+It[2][4]];return s=s.map(i=>i>1?1:i<0?0:i),s}function l0(e){return lc(a0(ac(e)))}function u0([e,t,n]){const r=Math.max(e,t,n),s=Math.min(e,t,n),i=(r+s)/2;let o=0,a=0;if(r!==s){const l=r-s;switch(a=i>.5?l/(2-r-s):l/(r+s),r){case e:o=(t-n)/l+(t<n?6:0);break;case t:o=(n-e)/l+2;break;case n:o=(e-t)/l+4;break}o/=6}return[o,a,i]}function Jr(e,t,n){const r=[e,t,n].map(s=>s<=.03928?s/12.92:((s+.055)/1.055)**2.4);return .2126*r[0]+.7152*r[1]+.0722*r[2]}function Ho(e,t){return(Math.max(e,t)+.05)/(Math.min(e,t)+.05)}function c0(e,t,n){let r,s,i;if(t===0)r=s=i=n;else{const o=(u,c,h)=>{let d=h;return d<0&&(d+=1),d>1&&(d-=1),d<.16666666666666666?u+(c-u)*6*d:d<.5?c:d<.6666666666666666?u+(c-u)*(.6666666666666666-d)*6:u},a=n<.5?n*(1+t):n+t-n*t,l=2*n-a;r=o(l,a,e+1/3),s=o(l,a,e),i=o(l,a,e-1/3)}return[r,s,i]}const ys={r:1,g:1,b:1},Ns={r:0,g:0,b:0},h0=Jr(ys.r,ys.g,ys.b),d0=Jr(Ns.r,Ns.g,Ns.b);function f0(e){const t=Jr(e[0],e[1],e[2]),n=Ho(h0,t),r=u0(e);let s=1-r[2],i,o,a;do i=c0(r[0],r[1],s),o=Jr(i[0],i[1],i[2]),a=Ho(o,d0),s+=.01;while(s<=1&&s>=0&&Math.abs(a-n)<.01);return i}function g0(e){return lc(f0(ac(e)))}gc();exports.ABCToNumber=rf;exports.AUTO_HEIGHT_FOR_MERGED_CELLS=Fa;exports.AbsoluteRefType=tt;exports.ActionIterator=Rn;exports.AlignTypeH=ll;exports.AlignTypeV=ul;exports.ArrangeTypeEnum=dl;exports.ArrowsAndMarkersShapes=da;exports.AsyncInterceptorManager=Up;exports.AsyncLock=C_;exports.AutoFillSeries=ta;exports.BaselineOffset=Ft;exports.BasicShapes=ha;exports.BlockType=ja;exports.BooleanNumber=Ie;exports.BorderStyleTypes=Xe;exports.BorderType=na;exports.BuildTextUtils=ot;exports.BulletAlignment=lr;exports.COLORS=Us;exports.CanceledError=Sc;exports.CellModeEnum=Sn;exports.CellValueType=Xt;exports.Color=cn;exports.ColorBuilder=ts;exports.ColorKit=Tt;exports.ColorType=vt;exports.ColumnSeparatorType=za;exports.CommandType=sr;exports.CommonHideTypes=ra;exports.ConfigService=vu;exports.ContextService=Vo;exports.CopyPasteType=sa;exports.CustomCommandExecutionError=Ms;exports.CustomDecorationType=on;exports.CustomRangeType=Zt;exports.DEFAULT_CELL=Ld;exports.DEFAULT_DOC=Oi;exports.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=jp;exports.DEFAULT_EMPTY_DOCUMENT_VALUE=Pa;exports.DEFAULT_RANGE=Md;exports.DEFAULT_RANGE_ARRAY=Nd;exports.DEFAULT_SELECTION=Dd;exports.DEFAULT_SLIDE=_l;exports.DEFAULT_STYLES=ut;exports.DEFAULT_WORKSHEET_COLUMN_COUNT=Du;exports.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=pE;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Pu;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=IE;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH=xu;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=CE;exports.DEFAULT_WORKSHEET_ROW_COUNT=Mu;exports.DEFAULT_WORKSHEET_ROW_COUNT_KEY=_E;exports.DEFAULT_WORKSHEET_ROW_HEIGHT=Lu;exports.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=EE;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=Uu;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=RE;exports.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=li;exports.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=ai;exports.DOCS_ZEN_EDITOR_UNIT_ID_KEY=Ua;exports.DOC_DRAWING_PRINTING_COMPONENT_KEY=Fd;exports.DOC_RANGE_TYPE=Aa;exports.DashStyleType=Ja;exports.DataStreamTreeNodeType=Sl;exports.DataStreamTreeTokenType=_t;exports.DataValidationErrorStyle=Zu;exports.DataValidationImeMode=Qu;exports.DataValidationOperator=ec;exports.DataValidationRenderMode=tc;exports.DataValidationStatus=nc;exports.DataValidationType=rc;exports.DeleteDirection=ia;exports.DependentOn=BE;exports.DesktopLogService=Xo;exports.DeveloperMetadataVisibility=oa;exports.Dimension=aa;exports.Direction=la;exports.Disposable=st;exports.DisposableCollection=Zr;exports.DocStyleType=$a;exports.DocumentDataModel=Mt;exports.DocumentFlavor=ui;exports.DrawingTypeEnum=fl;exports.EDITOR_ACTIVATED=Ou;exports.EXTENSION_NAMES=pl;exports.ErrorService=bu;exports.EventState=Ru;exports.EventSubject=Wp;exports.FOCUSING_COMMON_DRAWINGS=rE;exports.FOCUSING_DOC=Gn;exports.FOCUSING_EDITOR_BUT_HIDDEN=Jp;exports.FOCUSING_EDITOR_INPUT_FORMULA=Zp;exports.FOCUSING_EDITOR_STANDALONE=eE;exports.FOCUSING_FX_BAR_EDITOR=wu;exports.FOCUSING_PANEL_EDITOR=tE;exports.FOCUSING_SHEET=wn;exports.FOCUSING_SLIDE=Vn;exports.FOCUSING_UNIT=zn;exports.FOCUSING_UNIVER_EDITOR=Qp;exports.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=nE;exports.FORMULA_EDITOR_ACTIVATED=sE;exports.FollowNumberWithType=Ha;exports.FontItalic=Hr;exports.FontStyleType=vn;exports.FontWeight=jr;exports.GridType=Wa;exports.HLSColor=Sa;exports.HorizontalAlign=yt;exports.IAuthzIoService=Iu;exports.ICommandService=ir;exports.IConfigService=Ti;exports.IContextService=Dn;exports.IImageIoService=ni;exports.ILocalStorageService=xE;exports.ILogService=Ot;exports.IMentionIOService=Su;exports.IPermissionService=Hu;exports.IResourceLoaderService=ti;exports.IResourceManagerService=us;exports.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=ka;exports.IUndoRedoService=cs;exports.IUniverInstanceService=Mn;exports.ImageCacheMap=Ju;exports.ImageSourceType=Mi;exports.ImageUploadStatusType=qu;exports.InterceptorEffectEnum=On;exports.InterceptorManager=Dp;exports.InterpolationPointType=ua;exports.JSON1=T_;exports.JSONX=$t;exports.LRUHelper=jn;exports.LRUMap=Zn;exports.LifecycleStages=Je;exports.ListGlyphType=Ne;exports.LocaleService=ln;exports.LocaleType=or;exports.LogLevel=Ko;exports.MOVE_BUFFER_VALUE=Hn;exports.MemoryCursor=fn;exports.MentionType=$r;exports.NAMED_STYLE_MAP=Ud;exports.NAMED_STYLE_SPACE_MAP=Pd;exports.NamedStyleType=rt;exports.NilCommand=qo;exports.NumberUnitType=al;exports.ObjectMatrix=Et;exports.ObjectRelativeFromH=il;exports.ObjectRelativeFromV=ol;exports.OtherShapes=fa;exports.PAGE_SIZE=Bd;exports.PAPER_TYPES=yd;exports.PRESET_LIST_TYPE=dr;exports.PRINT_CHART_COMPONENT_KEY=kd;exports.PageElementType=gl;exports.PageOrientType=hl;exports.PageType=ci;exports.PaperType=pt;exports.ParagraphElementType=Va;exports.ParagraphStyleBuilder=er;exports.ParagraphStyleValue=gr;exports.PermissionService=ju;exports.PermissionStatus=Ni;exports.Plugin=ei;exports.PositionedObjectLayoutType=Xa;exports.PresetListType=Ut;exports.ProtectionType=ca;exports.QuickListType=iu;exports.QuickListTypeMap=x_;exports.RANGE_DIRECTION=ba;exports.RANGE_TYPE=Le;exports.RBush=zr;exports.RCDisposable=bc;exports.RGBA_PAREN=nh;exports.RGB_PAREN=th;exports.ROTATE_BUFFER_VALUE=ea;exports.RTree=n0;exports.Range=Tn;exports.Rectangle=Qt;exports.RedoCommand=Xu;exports.RedoCommandId=Gu;exports.RefAlias=nf;exports.Registry=bi;exports.RegistryAsMap=Ai;exports.RelativeDate=ma;exports.RelativeSlideLink=ml;exports.RgbColor=Wr;exports.RichTextBuilder=an;exports.RichTextValue=Kt;exports.RxDisposable=wc;exports.SHEET_EDITOR_UNITS=xd;exports.SectionType=Ya;exports.SheetTypes=_a;exports.SheetViewModel=Fu;exports.SliceBodyType=vi;exports.SlideDataModel=yi;exports.SpacingRule=qa;exports.SpecialShapes=ga;exports.Styles=Au;exports.THEME_COLORS=Ia;exports.TabStopAlignment=Za;exports.TableAlignmentType=el;exports.TableLayoutType=tl;exports.TableRowHeightRule=rl;exports.TableSizeType=Qa;exports.TableTextWrapType=nl;exports.TextDecoration=pa;exports.TextDecorationBuilder=Vt;exports.TextDirection=Jn;exports.TextDirectionType=Ga;exports.TextStyleBuilder=Jt;exports.TextStyleValue=fr;exports.TextX=Ye;exports.TextXActionType=he;exports.ThemeColor=Yr;exports.ThemeColorType=ft;exports.ThemeColors=es;exports.ThemeService=qr;exports.Tools=ne;exports.UndoCommand=Ku;exports.UndoCommandId=Vu;exports.UnitModel=ls;exports.Univer=i0;exports.UniverInstanceType=Be;exports.UpdateDocsAttributeType=xe;exports.UserManagerService=tr;exports.VerticalAlign=sn;exports.VerticalAlignmentType=sl;exports.Worksheet=nr;exports.WrapStrategy=un;exports.WrapTextType=Ka;exports.addLinkToDocumentModel=Tu;exports.afterInitApply=Pc;exports.afterTime=xc;exports.awaitTime=VE;exports.binSearchFirstGreaterThanTarget=Qo;exports.binarySearchArray=kc;exports.bufferDebounceTime=Lc;exports.cellToRange=Mh;exports.characterSpacingControlType=cl;exports.checkForSubstrings=Lh;exports.checkIfMove=Bc;exports.checkParagraphHasBullet=md;exports.checkParagraphHasIndent=_d;exports.checkParagraphHasIndentByStyle=Da;exports.codeToBlob=Fc;exports.composeBody=Xs;exports.composeInterceptors=Eu;exports.composeStyles=Ls;exports.concatMatrixArray=Rh;exports.convertBodyToHtml=eh;exports.convertCellToRange=Ta;exports.convertObservableToBehaviorSubject=Uc;exports.covertCellValue=$s;exports.covertCellValues=Dh;exports.covertTextRunToHtml=xs;exports.createAsyncInterceptorKey=Lp;exports.createDefaultUser=Xr;exports.createDocumentModelWithStyle=Kn;exports.createInterceptorKey=Mp;exports.createInternalEditorID=Td;exports.createRowColIter=Hs;exports.dayjs=Ht;exports.debounce=i_;exports.dedupe=mc;exports.dedupeBy=_c;exports.deepCompare=oi;exports.delayAnimationFrame=KE;exports.deleteContent=xa;exports.extractPureTextFromCell=Bu;exports.fromCallback=Jo;exports.fromEventSubject=Yp;exports.fromObservable=Oc;exports.generateRandomId=Bt;exports.get=$l;exports.getArrayLength=qt;exports.getBodySlice=Nt;exports.getBodySliceHtml=yr;exports.getBorderStyleType=Th;exports.getCellCoordByIndexSimple=Di;exports.getCellInfoInMergeData=Ch;exports.getCellPositionByIndexSimple=t0;exports.getCellValueType=_h;exports.getCellWithCoordByIndexCore=In;exports.getColorStyle=Lt;exports.getCustomBlockSlice=uu;exports.getCustomDecorationSlice=hu;exports.getCustomRangeSlice=cu;exports.getDocsUpdateBody=yh;exports.getIntersectRange=Cl;exports.getOriginCellValue=vE;exports.getParagraphsSlice=lu;exports.getPlainText=rs;exports.getReverseDirection=$c;exports.getSectionBreakSlice=W_;exports.getTableSlice=au;exports.getTextRunSlice=Kr;exports.getTransformOffsetX=sc;exports.getTransformOffsetY=ic;exports.getWorksheetUID=AE;exports.groupBy=Cc;exports.handleStyleToString=Ah;exports.hashAlgorithm=Ed;exports.horizontalLineSegmentsSubtraction=ns;exports.insertMatrixArray=Ps;exports.insertTextToContent=La;exports.invertColorByHSL=g0;exports.invertColorByMatrix=l0;exports.isBlackColor=gh;exports.isBooleanString=m_;exports.isCellCoverable=Bs;exports.isCellV=wa;exports.isEmptyCell=ya;exports.isFormulaId=bh;exports.isFormulaString=Na;exports.isICellData=Oa;exports.isInternalEditorID=Ba;exports.isNodeEnv=Qc;exports.isNotNullOrUndefined=yu;exports.isNullCell=ph;exports.isNumeric=Cu;exports.isRangesEqual=lE;exports.isRealNum=pd;exports.isSafeNumeric=kp;exports.isSameStyleTextRun=Ma;exports.isUnitRangesEqual=uE;exports.isValidRange=Nh;exports.isWhiteColor=mh;exports.makeArray=Rc;exports.makeCellRangeToRangeData=wh;exports.makeCellToSelection=Oh;exports.makeCustomRangeStream=cf;exports.merge=Ci;exports.mergeOverrideWithDependencies=Yu;exports.mergeSets=$p;exports.mergeWith=u_;exports.mergeWorksheetSnapshotWithDefault=ku;exports.mixinClass=Pp;exports.moveMatrixArray=Fs;exports.moveRangeByOffset=Gd;exports.nameCharacterCheck=GE;exports.normalizeBody=Y_;exports.normalizeTextRuns=hr;exports.numberToABC=of;exports.numberToListABC=af;exports.numfmt=Ad;exports.queryObjectMatrix=tf;exports.registerDependencies=Ic;exports.remove=rr;exports.repeatStringNumTimes=Il;exports.replaceInDocumentBody=Hp;exports.requestImmediateMacroTask=Bp;exports.rotate=Ec;exports.searchArray=$n;exports.searchInOrderedArray=Zo;exports.selectionToArray=Eh;exports.sequence=Go;exports.sequenceAsync=zo;exports.sequenceExecute=Qr;exports.sequenceExecuteAsync=Dc;exports.set=h_;exports.shallowEqual=Yl;exports.skipParseTagNames=XE;exports.sliceMatrixArray=Ih;exports.sortRules=lf;exports.sortRulesByDesc=uf;exports.sortRulesFactory=ur;exports.spliceArray=ks;exports.splitIntoGrid=hi;exports.takeAfter=Ds;exports.textDiff=Ri;exports.throttle=Np;exports.toDisposable=nt;exports.touchDependencies=Yo;exports.updateAttributeByDelete=du;exports.updateAttributeByInsert=fu;exports.willLoseNumericPrecision=Fp;Object.keys(je).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>je[e]})});
|
|
8
|
+
`,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(n){return new an(n!=null?n:an.newEmptyData())}insertText(n,r,s){var c,h;let i=((h=(c=this._data.body)==null?void 0:c.dataStream.length)!=null?h:2)-2,o,a;if(typeof n=="string"?o=n:(i=Math.min(n,i),o=r),typeof r=="object"?a=r instanceof Jt?r.build():r:a=s instanceof Jt?s.build():s,!o)return this;const l={dataStream:o,textRuns:a?[{ts:a,st:i,ed:i+o.length}]:[]},u=ot.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:l});if(!u)throw new Error("Insert text failed, please check.");return Ye.apply(this._doc.getBody(),u.serialize()),this}insertRichText(n,r){var a,l;let s=((l=(a=this._data.body)==null?void 0:a.dataStream.length)!=null?l:2)-2,i;typeof n=="object"?i=n instanceof Kt?n.getData():n:(s=Math.min(n,s),i=r instanceof Kt?r.getData():r);const o=ot.selection.replace({doc:this._doc,selection:{startOffset:s,endOffset:s,collapsed:!0},body:i.body});if(!o)throw new Error("Insert text failed, please check.");return Ye.apply(this._doc.getBody(),o.serialize()),this}delete(n,r){if(r!==void 0){if(!r)return this;const s=ot.selection.delete([{startOffset:n,endOffset:n+r,collapsed:!0}],this._data.body);Ye.apply(this._doc.getBody(),s)}return this}setStyle(n,r,s){const i={dataStream:"",textRuns:[{ts:s instanceof Jt?s.build():s,st:0,ed:r-n}]},o=ot.selection.retain([{startOffset:n,endOffset:r,collapsed:!0}],i);return Ye.apply(this._doc.getBody(),o),this}setLink(n,r,s){const i=ot.customRange.add({rangeType:Zt.HYPERLINK,rangeId:Bt(),properties:{url:s},ranges:[{startOffset:n,endOffset:r,collapsed:!1}],body:this._data.body});if(!i)throw new Error("Insert text failed, please check.");return Ye.apply(this._doc.getBody(),i.serialize()),this}cancelLink(n,r){if(typeof n=="string"){const s=ot.customRange.delete({rangeId:n,documentDataModel:this._doc});if(!s)throw new Error("Insert text failed, please check.");Ye.apply(this._doc.getBody(),s.serialize())}else this.slice(n,r).getLinks().forEach(i=>{const o=ot.customRange.delete({rangeId:i.rangeId,documentDataModel:this._doc});if(!o)throw new Error("Insert text failed, please check.");Ye.apply(this._doc.getBody(),o.serialize())});return this}updateLink(n,r){var i,o;const s=(o=(i=this._data.body)==null?void 0:i.customRanges)==null?void 0:o.find(a=>a.rangeId===n);if(!s)throw new Error("Link not found");return s.properties.url=r,this}insertParagraph(n,r){var o,a;let s,i;return typeof n=="object"?(s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:n.build()}]},i=((a=(o=this._data.body)==null?void 0:o.dataStream.length)!=null?a:2)-2):(i=n,s={dataStream:"\r",paragraphs:[{startIndex:0,paragraphStyle:r==null?void 0:r.build()}]}),this.insertRichText(i,Kt.create({body:s,id:"d",documentStyle:{}})),this}insertLink(n,r,s){let i="",o="";typeof n=="string"?(i=n,o=r):(i=r,o=s);const a=an.createByBody({dataStream:i,customRanges:[{rangeType:Zt.HYPERLINK,rangeId:Bt(),properties:{url:o},startIndex:0,endIndex:i.length-1}]});return typeof n=="number"?this.insertRichText(n,a):this.insertRichText(a)}}function Np(e,t=16){let n=0,r=null;return function(...i){const o=Date.now();o-n<t?(r&&clearTimeout(r),r=setTimeout(()=>{n=o,e.apply(this,i)},t)):(n=o,e.apply(this,i))}}var On=(e=>(e[e.Style=1]="Style",e[e.Value=2]="Value",e))(On||{});function Mp(e){return`sheet_interceptor_${e}`}const Eu=e=>function(t,n){let r=-1,s=t;for(let i=0;i<=e.length;i++){if(i<=r)throw new Error("[SheetInterceptorService]: next() called multiple times!");if(r=i,i===e.length)return s;const o=e[i];let a=!1;if(s=o.handler(s,n,l=>(a=!0,l)),!a)break}return s};class Dp{constructor(t){C(this,"_interceptorsByName",new Map);C(this,"_interceptorPoints");this._interceptorPoints=t}fetchThroughInterceptors(t,n){const r=t;let s=this._interceptorsByName.get(r);return n&&(s=s.filter(n)),Eu(s||[])}intercept(t,n){const r=t;this._interceptorsByName.has(r)||this._interceptorsByName.set(r,[]);const s=this._interceptorsByName.get(r);return s.push(n),this._interceptorsByName.set(r,s.sort((i,o)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)})),()=>rr(this._interceptorsByName.get(r),n)}getInterceptPoints(){return this._interceptorPoints}dispose(){this._interceptorsByName.clear()}}function Lp(e){return`sheet_async_interceptor_${e}`}const xp=e=>async function(t,n){let r=-1,s=t;for(let i=0;i<=e.length;i++){if(i<=r)throw new Error("[SheetInterceptorService]: next() called multiple times!");if(r=i,i===e.length)return s;const o=e[i];let a=!1;if(s=await o.handler(s,n,async l=>(a=!0,l)),!a)break}return s};class Up{constructor(t){C(this,"_asyncInterceptorsByName",new Map);C(this,"_asyncInterceptorPoints");this._asyncInterceptorPoints=t}fetchThroughAsyncInterceptors(t,n){const r=t;let s=this._asyncInterceptorsByName.get(r);return n&&(s=s.filter(n)),xp(s||[])}async interceptAsync(t,n){const r=t;this._asyncInterceptorsByName.has(r)||this._asyncInterceptorsByName.set(r,[]);const s=this._asyncInterceptorsByName.get(r);return s.push(n),this._asyncInterceptorsByName.set(r,s.sort((i,o)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)})),()=>rr(this._asyncInterceptorsByName.get(r),n)}getInterceptPoints(){return this._asyncInterceptorPoints}dispose(){this._asyncInterceptorsByName.clear()}}function Pp(e,t){for(const n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}function Cu(e){return/^-?\d+(\.\d+)?$/.test(e)}function kp(e){return Cu(e)?Number(e)<=Number.MAX_SAFE_INTEGER:!1}function Fp(e){return Number(e)>Number.MAX_SAFE_INTEGER||e.length>=18}class bi{constructor(){C(this,"_data",[])}static create(){return new bi}add(t){this._data.indexOf(t)>-1||this._data.push(t)}delete(t){const n=this._data.indexOf(t);this._data.splice(n,1)}getData(){return this._data}}class Ai{constructor(){C(this,"_data",new Map)}static create(){return new Ai}add(t,n){this._data.has(t)||this._data.set(t,n)}delete(t){this._data.delete(t)}getData(){return this._data}}function Bp(e){const t=new MessageChannel;let n=!1;const r=()=>{n||e()};return t.port1.onmessage=r,t.port2.postMessage(null),()=>{n=!0,t.port1.onmessage=null,t.port1.close(),t.port2.close()}}function $p(e,t){return t.forEach(n=>e.add(n)),e}function Hp(e,t,n,r){var u;if(t==="")return e;const s={id:"mock-id",body:e,documentStyle:{}},i=new Mt(s),o=t.length;let a;for(;(a=(r?i.getBody().dataStream:i.getBody().dataStream.toLowerCase()).indexOf(t))>=0;){const c=new Ye,h=$t.getInstance();if(a>0&&c.retain(a),n.length>0){const d=i.sliceBody(a,a+o),f={dataStream:n};if(Array.isArray(d==null?void 0:d.textRuns)&&d.textRuns.length&&(f.textRuns=[{...d.textRuns[0],st:0,ed:n.length}]),(u=d==null?void 0:d.customRanges)!=null&&u.length){const p=d.customRanges[0];f.customRanges=[{...p,startIndex:0,endIndex:n.length-1}]}c.insert(n.length,f)}c.delete(o),i.apply(h.editOp(c.serialize()))}const l=i.getBody();return i.dispose(),l}const jp="__default_document_sub_component_id20231101__";class Ru{constructor(){C(this,"skipNextObservers",!1);C(this,"lastReturnValue");C(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class Wp extends Oe.Subject{constructor(){super(...arguments);C(this,"_sortedObservers",[])}subscribe(){throw new Error("[EventSubject]: please use `subscribeEvent` instead of `subscribe` method for `EventSubject`.")}next(){throw new Error("[EventSubject]: please use `emitEvent` instead of `next` method for `EventSubject`.")}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(n){let r;typeof n=="function"?r={next:([i,o])=>n(i,o)}:r=n;const s=super.subscribe(r);return this._sortedObservers.push(r),this._sortedObservers.sort((i,o)=>{var a,l;return((a=i.priority)!=null?a:0)-((l=o.priority)!=null?l:0)}),s.add(()=>this._sortedObservers=this._sortedObservers.filter(i=>i!==r)),s}clearObservers(){this._sortedObservers.forEach(n=>{var r;return(r=n.complete)==null?void 0:r.call(n)}),this._sortedObservers.length=0}emitEvent(n){var r;if(!this.closed){const s=new Ru;s.lastReturnValue=n;for(const i of this._sortedObservers){const o=(r=i.next)==null?void 0:r.call(i,[n,s]);if(s.lastReturnValue=o,s.skipNextObservers)return{handled:!0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}throw new Error("[EventSubject]: cannot emit event on a closed subject.")}}function Yp(e){return new Oe.Observable(t=>{const n=e.subscribeEvent(r=>{t.next(r)});return()=>n.unsubscribe()})}const us=je.createIdentifier("core.resource-manager.service"),Zs={[xt.Editor]:"Editor",[xt.Owner]:"Owner",[xt.Reader]:"Reader",[xt.UNRECOGNIZED]:"UNRECOGNIZED"},Xr=e=>e?{userID:`${Zs[e]}_${ne.generateRandomId(8)}`,name:Zs[e],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},zp=(e,t)=>e.startsWith(Zs[t]);class tr{constructor(){C(this,"_model",new Map);C(this,"_userChange$",new Oe.Subject);C(this,"userChange$",this._userChange$.asObservable());C(this,"_currentUser$",new Oe.BehaviorSubject(Xr()));C(this,"currentUser$",this._currentUser$.asObservable())}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(t){this.addUser(t),this._currentUser$.next(t)}addUser(t){this._model.set(t.userID,t),this._userChange$.next({type:"add",user:t})}getUser(t,n){const r=this._model.get(t);if(r)return r;n&&n()}delete(t){const n=this.getUser(t);this._model.delete(t),n&&this._userChange$.next({type:"delete",user:n})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}list(){return Array.from(this._model.values())}}var Gp=Object.getOwnPropertyDescriptor,Vp=(e,t,n,r)=>{for(var s=r>1?void 0:r?Gp(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Do=(e,t)=>(n,r)=>t(n,r,e);exports.AuthzIoLocalService=class{constructor(t,n){C(this,"_permissionMap",new Map([]));this._resourceManagerService=t,this._userManagerService=n,this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){const t=this._userManagerService.getCurrentUser();t&&t.userID||this._userManagerService.setCurrentUser(Xr(xt.Owner))}_getRole(t){const n=this._userManagerService.getCurrentUser();return n?zp(n.userID,t):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:t=>{const n=[...this._permissionMap.keys()].reduce((r,s)=>{const i=this._permissionMap.get(s);return r[s]=i,r},{});return JSON.stringify(n)},parseJson:t=>JSON.parse(t),pluginName:"SHEET_AuthzIoMockService_PLUGIN",businesses:[Be.UNIVER_SHEET,Be.UNIVER_DOC,Be.UNIVER_SLIDE],onLoad:(t,n)=>{for(const r in n)this._permissionMap.set(r,n[r])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(t){return Bt(8)}async allowed(t){return Promise.resolve([])}async batchAllowed(t){return Promise.resolve([])}async list(t){const n=[];return t.objectIDs.forEach(r=>{const s=this._permissionMap.get(r);if(s){const i={objectID:r,unitID:t.unitID,objectType:s.objectType,name:s.name,shareOn:!1,shareRole:xt.Owner,shareScope:-1,scope:{read:zs.AllCollaborator,edit:zs.AllCollaborator},creator:Xr(xt.Owner),strategies:[{action:6,role:1},{action:16,role:1},{action:17,role:1},{action:18,role:1},{action:19,role:1},{action:33,role:1},{action:34,role:1},{action:35,role:1},{action:36,role:1},{action:37,role:1},{action:38,role:1},{action:39,role:1},{action:40,role:1}],actions:t.actions.map(o=>({action:o,allowed:this._getRole(xt.Owner)||this._getRole(xt.Editor)}))};n.push(i)}}),n}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(t){}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(t){}};exports.AuthzIoLocalService=Vp([Do(0,us),Do(1,je.Inject(tr))],exports.AuthzIoLocalService);const Iu=je.createIdentifier("IAuthzIoIoService");var Kp=Object.getOwnPropertyDescriptor,Xp=(e,t,n,r)=>{for(var s=r>1?void 0:r?Kp(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},qp=(e,t)=>(n,r)=>t(n,r,e);exports.MentionIOLocalService=class{constructor(t){this._userManagerService=t}async list(t){return{list:[{type:$r.PERSON,mentions:[{objectType:$r.PERSON,objectId:this._userManagerService.getCurrentUser().userID,label:this._userManagerService.getCurrentUser().name,metadata:{icon:this._userManagerService.getCurrentUser().avatar}}],metadata:{},title:"PEOPLE"}],page:t.page,size:t.size,total:1}}};exports.MentionIOLocalService=Xp([qp(0,je.Inject(tr))],exports.MentionIOLocalService);const Su=je.createIdentifier("univer.service.mention-io"),Ti=je.createIdentifier("univer.config-service");class vu{constructor(){C(this,"_configChanged$",new Oe.Subject);C(this,"configChanged$",this._configChanged$.asObservable());C(this,"_config",new Map)}dispose(){this._configChanged$.complete()}getConfig(t){return this._config.get(t)}setConfig(t,n,r){var o;const{merge:s=!1}=r||{};let i=(o=this._config.get(t))!=null?o:{};s?i=Ci(i,n):i=n,this._config.set(t,i),this._configChanged$.next({[t]:i})}deleteConfig(t){return this._config.delete(t)}subscribeConfigValue$(t){return new Oe.Observable(n=>{Object.prototype.hasOwnProperty.call(this._config,t)&&n.next(this._config.get(t));const r=this.configChanged$.pipe(Oe.filter(s=>Object.prototype.hasOwnProperty.call(s,t))).subscribe(s=>n.next(s[t]));return()=>r.unsubscribe()})}}const zn="FOCUSING_UNIT",wn="FOCUSING_SHEET",Gn="FOCUSING_DOC",Vn="FOCUSING_SLIDE",Jp="FOCUSING_EDITOR_BUT_HIDDEN",Ou="EDITOR_ACTIVATED",Zp="FOCUSING_EDITOR_INPUT_FORMULA",wu="FOCUSING_FX_BAR_EDITOR",Qp="FOCUSING_UNIVER_EDITOR",eE="FOCUSING_EDITOR_INPUT_FORMULA",tE="FOCUSING_PANEL_EDITOR",nE="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",rE="FOCUSING_COMMON_DRAWINGS",sE="FORMULA_EDITOR_ACTIVATED";class bu extends st{constructor(){super(...arguments);C(this,"_error$",new Oe.Subject);C(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(n){this._error$.next({errorKey:n})}}const iE="0.8.0-nightly.202505261607",oE={version:iE};function aE(e="",t=or.ZH_CN,n=""){return{id:e,sheetOrder:[],name:n,appVersion:oE.version,locale:t,styles:{},sheets:{},resources:[]}}class Au{constructor(t={}){C(this,"_styles");C(this,"_cacheMap",new Zn(1e5));this._styles=t,this._generateCacheMap()}each(t){return Object.entries(this._styles).forEach(t),this}search(t,n){if(this._cacheMap.has(n))return this._cacheMap.get(n);const r=this._getExistingStyleId(t);return r||"-1"}get(t){return typeof t!="string"?t:(t=String(t),this._styles[t])}add(t,n){const r=ne.generateRandomId(6);return this._styles[r]=t,this._cacheMap.set(n,r),r}setValue(t){if(t==null)return;const n=JSON.stringify(t),r=this.search(t,n);return r!=="-1"?r:this.add(t,n)}toJSON(){return this._styles}getStyleByCell(t){let n;t&&ne.isObject(t.s)?n=t.s:n=(t==null?void 0:t.s)&&this.get(t.s);const r=t==null?void 0:t.interceptorStyle;return r?{...n,...r}:n}_generateCacheMap(){const{_styles:t,_cacheMap:n}=this;for(const r in t){const s=JSON.stringify(t[r]);n.set(s,r)}}_getExistingStyleId(t){const{_styles:n}=this;for(const r in n)if(ne.diffValue(n[r],t))return r;return null}}const lE=(e,t)=>t.length===e.length&&!e.some(n=>t.some(r=>!Qt.equals(r,n))),uE=(e,t)=>t.length===e.length&&e.every((n,r)=>{const s=t[r];return s.unitId===n.unitId&&s.sheetId===n.sheetId&&Qt.equals(n.range,s.range)}),Qs={t:0,b:2,l:2,r:2},cE=e=>({sbr:.6,sbo:e,spr:.6,spo:e}),Lo=90;function Kn(e,t,n={}){const r=e.length,{textRotation:s,paddingData:i,horizontalAlign:o=yt.UNSPECIFIED,verticalAlign:a=sn.UNSPECIFIED,wrapStrategy:l=un.UNSPECIFIED,cellValueType:u}=n,{t:c,r:h,b:d,l:f}=i||Qs,{vertexAngle:p,centerAngle:R}=Nu(s),w={id:"d",body:{dataStream:`${e}${Pa}`,textRuns:[{ts:t,st:0,ed:r}],paragraphs:[{startIndex:r,paragraphStyle:{horizontalAlign:o}}],sectionBreaks:[{startIndex:r+1}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},marginTop:c,marginBottom:d,marginRight:h,marginLeft:f,renderConfig:{horizontalAlign:o,verticalAlign:a,centerAngle:R,vertexAngle:p,wrapStrategy:l,cellValueType:u,zeroWidthParagraphBreak:1}},drawings:{},drawingsOrder:[]};return new Mt(w)}function hE(e){if(!e)return{};const{tr:t,td:n,ht:r,vt:s,tb:i,pd:o}=e;return{textRotation:t,textDirection:n,horizontalAlign:r,verticalAlign:s,wrapStrategy:i,paddingData:o}}function xo(e){if(!e)return{};const{ff:t,fs:n,it:r,bl:s,ul:i,st:o,ol:a,cl:l}=e,u={};return t&&(u.ff=t),n&&(u.fs=n),r&&(u.it=r),s&&(u.bl=s),i&&(u.ul=i),o&&(u.st=o),a&&(u.ol=a),l&&(u.cl=l),u}function Tu(e,t,n){var i;const r=e.getBody();if((i=r.customRanges)!=null&&i.some(o=>o.rangeType===Zt.HYPERLINK))return;const s=ot.customRange.add({ranges:[{startOffset:0,endOffset:r.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:Zt.HYPERLINK,body:r,properties:{url:t,refId:n}});s&&Ye.apply(r,s.serialize())}function yu(e){return e!=null}const dE='"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';function Uo(e){const t=ut.ff,n=ut.fs;if(!e){const h=`${n}pt ${t}`;return{fontCache:h,fontString:h,fontSize:n,originFontSize:n,fontFamily:t}}let r=vn.ITALIC;(e.it===0||e.it===void 0)&&(r=vn.NORMAL);let s=vn.BOLD;(e.bl===0||e.bl===void 0)&&(s=vn.NORMAL);let i=n;e.fs&&(i=Math.ceil(e.fs));let o=t;if(e.ff){let h=e.ff;h=h.replace(/"/g,"").replace(/'/g,""),h.indexOf(" ")>-1&&(h=`"${h}"`),h==null&&(h=t),o=h}const{va:a}=e;let l=i;if(a===Ft.SUBSCRIPT||a===Ft.SUPERSCRIPT){const h=fE(o,l),{sbr:d,spr:f}=h;l*=a===Ft.SUBSCRIPT?d:f}const u=`${r} ${s} ${l}pt ${o}`,c=`${u}, ${dE} `;return{fontCache:u,fontString:c,fontSize:l,originFontSize:i,fontFamily:o}}function fE(e,t){return cE(t)}function Nu(e){const{a:t=0,v:n=Ie.FALSE}=e||{a:0,v:Ie.FALSE};let r=0,s=t;return n===Ie.TRUE&&(r=Lo,s=Lo),{centerAngle:r,vertexAngle:s}}class gE{constructor(t,n){C(this,"_columnData",{});this._config=t,this._columnData=n}getColumnData(){return this._columnData}getColVisible(t){const{_columnData:n}=this,r=n[t];return r?r.hd!==Ie.TRUE:!0}getColumnStyle(t){var n;return(n=this._columnData[t])==null?void 0:n.s}setColumnStyle(t,n){const r=this.getColumnOrCreate(t);r.s=n}getHiddenCols(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getColVisible(o);s&&a?(s=!1,r.push({rangeType:Le.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:Le.COLUMN}),r}getVisibleCols(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getColVisible(o);s&&!a?(s=!1,r.push({rangeType:Le.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:Le.COLUMN}),r}getColumnDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getColumnOrCreate(i);r[s]=o,s++}return r}getSize(){return qt(this._columnData)}getColumnWidth(t){const{_columnData:n}=this,r=this._config;let s=0;return s=(n[t]||{hd:Ie.FALSE,w:r.defaultColumnWidth}).w||r.defaultColumnWidth,s}getColumn(t){const n=this._columnData[t];if(n)return n}removeColumn(t){delete this._columnData[t]}getColumnOrCreate(t){const{_columnData:n}=this,r=n[t];if(r)return r;const s={};return this._columnData[t]=s,s}setCustomMetadata(t,n){const r=this.getColumn(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getColumn(t))==null?void 0:n.custom}}class mE{constructor(t,n,r){C(this,"_rowData");this._config=t,this._viewModel=n,this._rowData=r}getRowData(){return this._rowData}getRowStyle(t){var n;return(n=this._rowData[t])==null?void 0:n.s}setRowStyle(t,n){const r=this.getRowOrCreate(t);r.s=n}getRowDatas(t,n){const r={};let s=0;for(let i=t;i<t+n;i++){const o=this.getRowOrCreate(i);r[s]=o,s++}return r}getRowHeight(t,n=1){const{_rowData:r}=this,s=this._config;let i=0;for(let o=0;o<n;o++){const a=r[o+t]||{hd:Ie.FALSE,h:s.defaultRowHeight},{ia:l,ah:u,h:c=s.defaultRowHeight}=a;i+=(l==null||l===Ie.TRUE)&&typeof u=="number"?u:c}return i}getRow(t){return this._rowData[t]}removeRow(t){delete this._rowData[t]}getRowOrCreate(t){const{_rowData:n}=this,r=n[t];if(r)return r;const s={};return n[t]=s,s}getHiddenRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:Le.ROW})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:Le.ROW}),r}getVisibleRows(t=0,n=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=t;o<=n;o++){const a=this.getRowRawVisible(o);s&&!a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:Le.ROW})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:Le.ROW}),r}getRowRawVisible(t){const n=this.getRow(t);return n?n.hd!==Ie.TRUE:!0}getSize(){return qt(this._rowData)}setCustomMetadata(t,n){const r=this.getRow(t);r&&(r.custom=n)}getCustomMetadata(t){var n;return(n=this.getRow(t))==null?void 0:n.custom}}const _E="DEFAULT_WORKSHEET_ROW_COUNT",Mu=1e3,pE="DEFAULT_WORKSHEET_COLUMN_COUNT",Du=20,EE="DEFAULT_WORKSHEET_ROW_HEIGHT",Lu=24,CE="DEFAULT_WORKSHEET_COLUMN_WIDTH",xu=88,RE="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",Uu=46,IE="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Pu=20;function ku(e){const t={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:Ie.FALSE,rowCount:Mu,columnCount:Du,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:xu,defaultRowHeight:Lu,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:Ie.TRUE,rowHeader:{width:Uu,hidden:Ie.FALSE},columnHeader:{height:Pu,hidden:Ie.FALSE},rightToLeft:Ie.FALSE};return Object.keys(t).forEach(n=>{const r=n;typeof e[r]>"u"&&(e[r]=t[r])}),e}class SE extends st{constructor(n){super();C(this,"_cellCache",new Map);C(this,"_rowCache",new Map);C(this,"_columnCache",new Map);C(this,"_hasRow",!1);C(this,"_hasColumn",!1);C(this,"_hasAll",!1);C(this,"_allIndex",-1);C(this,"_mergeData");C(this,"_rangeMap",new Zn(5e4));C(this,"_skeletonCache",new Zn(5e4));this._init(n.concat())}_init(n){this._mergeData=n,this._createCache(n)}_clearCache(){this._cellCache.clear(),this._rowCache.clear(),this._columnCache.clear(),this._hasAll=!1,this._allIndex=-1,this._rangeMap.clear(),this._skeletonCache.clear(),this._hasColumn=!1,this._hasRow=!1}_createCache(n){let r=0;for(const s of n){const{rangeType:i}=s;i===Le.ROW?this._createRowCache(s,r):i===Le.COLUMN?this._createColumnCache(s,r):i===Le.ALL?this._createCellAllCache(r):this._createCellCache(s,r),r++}}rebuild(n){this._clearCache(),this._init(n.concat())}_createRowCache(n,r){const{startRow:s,endRow:i}=n;for(let o=s;o<=i;o++)this._rowCache.set(o,r),this._hasRow=!0}_createColumnCache(n,r){const{startColumn:s,endColumn:i}=n;for(let o=s;o<=i;o++)this._columnCache.set(o,r),this._hasColumn=!0}_createCellAllCache(n){this._hasAll=!0,this._allIndex=n}_createCellCache(n,r){for(let s=n.startRow;s<=n.endRow;s++){let i=this._cellCache.get(s);i==null&&(i=new Map,this._cellCache.set(s,i));for(let o=n.startColumn;o<=n.endColumn;o++)i.set(o,r)}}add(n){this._mergeData.push(n),this._clearCache(),this._createCache(this._mergeData)}remove(n,r){const s=this._getMergeDataIndex(n,r);s!==-1&&(this._mergeData.splice(s,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(n,r){const s=this._getMergeDataIndex(n,r);return s!==-1?this._mergeData[s]:null}getMergeDataIndex(n,r){return this._getMergeDataIndex(n,r)}isRowContainsMergedCell(n){return this._hasAll||!ne.isEmptyObject(this._columnCache)?!0:this._mergeData.some(r=>r.startRow<=n&&n<=r.endRow)}isColumnContainsMergedCell(n){return this._hasAll||!ne.isEmptyObject(this._rowCache)?!0:this._mergeData.some(r=>r.startColumn<=n&&n<=r.endColumn)}getMergedCellRange(n,r,s,i){const o=[],a=`${n}-${r}-${s}-${i}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let l=0;const u=[];for(const c of this._mergeData||[])Qt.intersects(c,{startRow:n,endRow:s,startColumn:r,endColumn:i})&&(o.push({...c}),u.push(l)),l++;return this._rangeMap.set(a,u),o}getMergedCellRangeForSkeleton(n,r,s,i){const o=[],a=this._mergeData,l=`${n}-${r}-${s}-${i}`;if(this._skeletonCache.has(l))return this._getSkeletonRangeFromCache(l);const u=[];for(let c=0;c<a.length;c++){const{startRow:h,endRow:d,startColumn:f,endColumn:p}=a[c];for(let R=n;R<=s;R++){let w=!1;for(let N=r;N<=i;N++)if(R>=h&&R<=d&&N>=f&&N<=p){o.push({startRow:h,endRow:d,startColumn:f,endColumn:p}),u.push(c),w=!0;break}if(w)break}}return this._skeletonCache.set(l,u),o}_getRangeFromCache(n){const r=this._rangeMap.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getSkeletonRangeFromCache(n){const r=this._skeletonCache.get(n)||[],s=[];for(const i of r)s.push({...this._mergeData[i]});return s}_getMergeDataIndex(n,r){var i;if(this._hasAll)return this._allIndex;if(this._hasRow){const o=this._rowCache.get(n);if(o!==void 0)return o}if(this._hasColumn){const o=this._columnCache.get(r);if(o!==void 0)return o}const s=(i=this._cellCache.get(n))==null?void 0:i.get(r);return s!==void 0?s:-1}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}}class Fu extends st{constructor(n){super();C(this,"_cellContentInterceptor",null);C(this,"_rowFilteredInterceptor",null);this.getRawCell=n}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(n,r,s,i){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,On.Value|On.Style,s,i):this.getRawCell(n,r)}getCellValueOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,On.Value):this.getRawCell(n,r)}getCellStyleOnly(n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,r,On.Style):this.getRawCell(n,r)}getRowFiltered(n){var r,s;return(s=(r=this._rowFilteredInterceptor)==null?void 0:r.getRowFiltered(n))!=null?s:!1}registerCellContentInterceptor(n){if(this._cellContentInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptor=n,nt(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(n){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=n,nt(()=>this._rowFilteredInterceptor=null)}}const Po={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};class nr{constructor(t,n,r){C(this,"_sheetId");C(this,"_snapshot");C(this,"_cellData");C(this,"_rowManager");C(this,"_columnManager");C(this,"_viewModel");C(this,"_spanModel");var a;this.unitId=t,this._styles=r,this._snapshot=ku(n);const{columnData:s,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:ne.generateRandomId(6),this._cellData=new Et(o),this._viewModel=new Fu((l,u)=>this.getCellRaw(l,u)),this._rowManager=new mE(this._snapshot,this._viewModel,i),this._columnManager=new gE(this._snapshot,s),this._spanModel=new SE(this._snapshot.mergeData)}__interceptViewModel(t){t(this._viewModel)}getSnapshot(){return this._snapshot}setMergeData(t){this._snapshot.mergeData=t,this.getSpanModel().rebuild(t)}getSpanModel(){return this._spanModel}getStyleDataByHash(t){return{...this._styles.get(t)}}setStyleData(t){return this._styles.setValue(t)}getColumnStyle(t,n=!1){return n?this._columnManager.getColumnStyle(t):this._styles.get(this._columnManager.getColumnStyle(t))}setColumnStyle(t,n){this._columnManager.setColumnStyle(t,n)}getRowStyle(t,n=!1){return n?this._rowManager.getRowStyle(t):this._styles.get(this._rowManager.getRowStyle(t))}setRowStyle(t,n){this._rowManager.setRowStyle(t,n)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){const t=this._snapshot.defaultStyle;return this._styles.get(t)}setDefaultCellStyle(t){this._snapshot.defaultStyle=t}getCellStyle(t,n){const r=this.getCell(t,n);if(r){const s=r.s;return typeof s=="string"?this._styles.get(s):s}return null}getComposedCellStyle(t,n,r=!0){const s=this.getCellStyle(t,n),i=this.getDefaultCellStyleInternal(),o=this.getRowStyle(t),a=this.getColumnStyle(n);return r?Ls(i,o,a,s):Ls(i,a,o,s)}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const t=this.getCellMatrix(),n=this.getMergeData();let r=-1,s=-1,i=-1,o=-1,a=!1,l=!1;return t.forEach((u,c)=>{Object.keys(c).forEach(h=>{const d=+h,f=t.getValue(u,d),p=f!=null&&f.s?this._styles.get(f.s):null,R=(p==null?void 0:p.bd)&&(p.bd.b||p.bd.l||p.bd.r||p.bd.t||p.bd.bc_tr||p.bd.bl_tr||p.bd.ml_tr||p.bd.tl_bc||p.bd.tl_br||p.bd.tl_mr);(f&&(f.v||f.p)||p!=null&&p.bg||R)&&(a?r=Math.min(r,u):(r=u,a=!0),s=Math.max(s,u),l?i=Math.min(i,d):(l=!0,i=d),o=Math.max(o,d))})}),n.forEach(u=>{a?r=Math.min(r,u.startRow):(r=u.startRow,a=!0),s=Math.max(s,u.endRow),l?i=Math.min(i,u.startColumn):(i=u.startColumn,a=!0),o=Math.max(o,u.endColumn)}),!a||!l?null:{startColumn:i,startRow:r,endColumn:o,endRow:s}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:t}=this,n=ne.deepClone(t);return new nr(this.unitId,n,this._styles)}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(t,n){return this._spanModel.getMergedCell(t,n)}getMergedCellRange(t,n,r,s){return this._spanModel.getMergedCellRange(t,n,r,s)}isRowContainsMergedCell(t){return this._spanModel.isRowContainsMergedCell(t)}isColumnContainsMergedCell(t){return this._spanModel.isColumnContainsMergedCell(t)}getCellInfoInMergeData(t,n){const r=this.getMergedCell(t,n);let s=!1,i=!1,o=t,a=n,l=t,u=n;if(r){const{startRow:c,endRow:h,startColumn:d,endColumn:f}=r;t===c&&n===d?(o=h,a=f,l=c,u=d,i=!0):t>=c&&t<=h&&n>=d&&n<=f&&(o=h,a=f,l=c,u=d,s=!0)}return{actualRow:t,actualColumn:n,isMergedMainCell:i,isMerged:s,endRow:o,endColumn:a,startRow:l,startColumn:u}}getCell(t,n){return t<0||n<0?null:this._viewModel.getCell(t,n)}getCellValueOnly(t,n){return t<0||n<0?null:this._viewModel.getCellValueOnly(t,n)}getCellStyleOnly(t,n){return t<0||n<0?null:this._viewModel.getCellStyleOnly(t,n)}getCellRaw(t,n){return this.getCellMatrix().getValue(t,n)}getCellWithFilteredInterceptors(t,n,r,s){return this._viewModel.getCell(t,n,r,s)}getRowFiltered(t){return this._viewModel.getRowFiltered(t)}getMatrixWithMergedCells(t,n,r,s,i=Sn.Raw){const o=this.getCellMatrix(),a=this._spanModel.getMergedCellRange(t,n,r,s),l=new Et;return Hs(t,r,n,s).forEach((u,c)=>{var d;let h;if(i===Sn.Raw)h=this.getCellRaw(u,c);else if(i===Sn.Intercepted)h=this.getCell(u,c);else if(i===Sn.Both){const f=this.getCellRaw(u,c);if(f){h={...f};const p=(d=this.getCell(u,c))==null?void 0:d.v;yu(p)&&h&&(h.displayV=String(p))}}h&&l.setValue(u,c,h)}),a.forEach(u=>{const{startColumn:c,startRow:h,endColumn:d,endRow:f}=u;Hs(h,f,c,d).forEach((p,R)=>{p===h&&R===c&&l.setValue(p,R,{...o.getValue(p,R),rowSpan:f-h+1,colSpan:d-c+1}),(p!==h||R!==c)&&l.realDeleteValue(p,R)})}),l}getRange(t,n,r,s){return typeof t=="object"?new Tn(this,t,{getStyles:()=>this._styles}):new Tn(this,{startRow:t,startColumn:n,endColumn:s||n,endRow:r||t},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:t}=this,{columnCount:n}=t;return n}getMaxRows(){const{_snapshot:t}=this,{rowCount:n}=t;return n}getRowCount(){return this._snapshot.rowCount}setRowCount(t){this._snapshot.rowCount=t}getColumnCount(){return this._snapshot.columnCount}setColumnCount(t){this._snapshot.columnCount=t}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:t}=this,{showGridlines:n}=t;return n===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){const{_snapshot:t}=this,{tabColor:n}=t;return n}getColumnWidth(t){return this.getColumnManager().getColumnWidth(t)}getRowHeight(t){return this._viewModel.getRowFiltered(t)?0:this.getRowManager().getRowHeight(t)}isRowFiltered(t){return this._viewModel.getRowFiltered(t)}getRowVisible(t){return!this.isRowFiltered(t)&&this.getRowRawVisible(t)}getRowRawVisible(t){return this.getRowManager().getRowRawVisible(t)}getHiddenRows(t,n){const r=this.getMaxColumns()-1,s=this._rowManager.getHiddenRows(t,n);return s.forEach(i=>i.endColumn=r),s}getColVisible(t){return this._columnManager.getColVisible(t)}getHiddenCols(t,n){const r=this.getMaxRows()-1,s=this._columnManager.getHiddenCols(t,n);return s.forEach(i=>i.endRow=r),s}getVisibleRows(){const t=this.getRowCount();return this._rowManager.getVisibleRows(0,t-1)}getVisibleCols(){const t=this.getColumnCount();return this._columnManager.getVisibleCols(0,t-1)}isRightToLeft(){const{_snapshot:t}=this,{rightToLeft:n}=t;return n}getLastRowWithContent(){return this._cellData.getLength()-1}getLastColumnWithContent(){return this._cellData.getRange().endColumn}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(t){return t&&(t.v!==void 0||t.f!==void 0||t.p!==void 0)}iterateByRow(t,n=!0){const{startRow:r,startColumn:s,endRow:i,endColumn:o}=t,a=this;return{[Symbol.iterator]:()=>{let l=r,u=s;return{next(){for(;;){if(u>o&&(l+=1,u=s),l>i)return{done:!0,value:void 0};const c=a.getCell(l,u),h=!c,d=a.getMergedCell(l,u);if(d){if(l!==d.startRow||u!==d.startColumn){u=d.endColumn+1;continue}if(h&&n){u=d.endColumn+1;continue}const p={row:l,col:u,value:c};return p.colSpan=d.endColumn-d.startColumn+1,p.rowSpan=d.endRow-d.startRow+1,u=d.endColumn+1,{done:!1,value:p}}if(h&&n)u+=1;else{const f={row:l,col:u,value:c};return u+=1,{done:!1,value:f}}}}}}}}iterateByColumn(t,n=!0,r=!0){const{startRow:s,startColumn:i,endRow:o,endColumn:a}=t,l=this;return{[Symbol.iterator]:()=>{let u=s,c=i;return{next(){for(;;){if(u>o&&(c+=1,u=s),c>a)return{done:!0,value:void 0};const h=l.getMergedCell(u,c);if(h){const p=u!==h.startRow,R=p||c!==h.startColumn;if(r&&R||!r&&p){u=h.endRow+1;continue}const w=l.getCell(h.startRow,h.startColumn);if(!w&&n){u=h.endRow+1;continue}const G={row:u,col:h.startColumn,value:w};return G.colSpan=h.endColumn-h.startColumn+1,G.rowSpan=h.endRow-h.startRow+1,u=h.endRow+1,{done:!1,value:G}}const d=l.getCell(u,c);if(!d&&n)u+=1;else{const p={row:u,col:c,value:d};return u+=1,{done:!1,value:p}}}}}}}}_getCellDocumentModel(t,n=Po){var R;const{isDeepClone:r,displayRawFormula:s,ignoreTextRotation:i}={...Po,...n},o=this._styles.getStyleByCell(t);if(!t)return;let a,l="document";const u=hE(o),c=i?ut.tr:u.textRotation||ut.tr;let h=u.horizontalAlign||ut.ht;const d=u.verticalAlign||ut.vt,f=u.wrapStrategy||ut.tb,p=u.paddingData||Qs;if(t.f&&s)a=Kn(t.f.toString(),{},{verticalAlign:d}),h=ut.ht;else if(t.p){const{centerAngle:w,vertexAngle:N}=Nu(c);a=this._updateConfigAndGetDocumentModel(r?ne.deepClone(t.p):t.p,h,p,{horizontalAlign:h,verticalAlign:d,centerAngle:w,vertexAngle:N,wrapStrategy:f,zeroWidthParagraphBreak:1})}else if(t.v!=null){const w=xo(o);l=Uo(w).fontCache;let N=Bu(t);t.t===Xt.FORCE_STRING&&s&&(N=`'${N}`),a=Kn(N,w,{...u,textRotation:c,cellValueType:t.t})}return a&&t.linkUrl&&t.linkId&&Tu(a,t.linkUrl,t.linkId),{documentModel:a,fontString:l,textRotation:c,wrapStrategy:f,verticalAlign:d,horizontalAlign:h,paddingData:p,fill:(R=o==null?void 0:o.bg)==null?void 0:R.rgb}}_updateConfigAndGetDocumentModel(t,n,r,s){var o,a,l,u,c;if(!s||!((o=t.body)!=null&&o.dataStream))return;t.documentStyle||(t.documentStyle={}),t.documentStyle.marginTop=(a=r.t)!=null?a:0,t.documentStyle.marginBottom=(l=r.b)!=null?l:2,t.documentStyle.marginLeft=(u=r.l)!=null?u:2,t.documentStyle.marginRight=(c=r.r)!=null?c:2,t.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},t.documentStyle.renderConfig={...t.documentStyle.renderConfig,...s};const i=t.body.paragraphs||[];for(const h of i)h.paragraphStyle||(h.paragraphStyle={}),h.paragraphStyle.horizontalAlign=n;return new Mt(t)}getBlankCellDocumentModel(t){const n=this._getCellDocumentModel(t,{ignoreTextRotation:!0}),r=this._styles.getStyleByCell(t),s=xo(r);if(n!=null)return n.documentModel==null&&(n.documentModel=Kn("",s)),n;const i="";let o="document";const a=ut.tr,l=ut.ht,u=ut.vt,c=ut.tb,h=Qs;return o=Uo({}).fontCache,{documentModel:Kn(i,s),fontString:o,textRotation:a,wrapStrategy:c,verticalAlign:u,horizontalAlign:l,paddingData:h}}getCellDocumentModelWithFormula(t){return this._getCellDocumentModel(t,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(t){this._snapshot.custom=t}}function Bu(e){var r,s;if(!e)return"";const t=(s=(r=e.p)==null?void 0:r.body)==null?void 0:s.dataStream;if(t)return ot.transform.getPlainText(t);const n=e.v;return typeof n=="string"?e.t===Xt.BOOLEAN?n.toUpperCase():n.replace(/[\r\n]/g,""):typeof n=="number"?e.t===Xt.BOOLEAN?n?"TRUE":"FALSE":n.toString():typeof n=="boolean"?n?"TRUE":"FALSE":""}function vE(e){if(e===null)return"";if(e!=null&&e.p){const t=e==null?void 0:e.p.body;if(t==null)return"";const n=t.dataStream;return ot.transform.getPlainText(n)}return e==null?void 0:e.v}var OE=Object.getOwnPropertyDescriptor,wE=(e,t,n,r)=>{for(var s=r>1?void 0:r?OE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},bE=(e,t)=>(n,r)=>t(n,r,e);function AE(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}exports.Workbook=class extends ls{constructor(n={},r){super();C(this,"type",Be.UNIVER_SHEET);C(this,"_sheetCreated$",new Oe.Subject);C(this,"sheetCreated$",this._sheetCreated$.asObservable());C(this,"_sheetDisposed$",new Oe.Subject);C(this,"sheetDisposed$",this._sheetDisposed$.asObservable());C(this,"_activeSheet$",new Oe.BehaviorSubject(null));C(this,"activeSheet$",this._activeSheet$.asObservable());C(this,"_worksheets");C(this,"_styles");C(this,"_snapshot");C(this,"_unitId");C(this,"_count");C(this,"_name$");C(this,"name$");this._logService=r;const s=aE();ne.isEmptyObject(n)?this._snapshot=s:this._snapshot=ne.commonExtend(s,n);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=ne.generateRandomId(6)),this._unitId=this._snapshot.id,this._styles=new Au(i),this._count=1,this._worksheets=new Map,this._name$=new Oe.BehaviorSubject(n.name||""),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(n){return typeof n=="string"||"startRow"in n||"row"in n}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete()}save(){return ne.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(n){this._name$.next(n),this._snapshot.name=n}getUnitId(){return this._unitId}getRev(){var n;return(n=this._snapshot.rev)!=null?n:1}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(n){this._snapshot.rev=n}addWorksheet(n,r,s){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[n])return!1;i[n]=s,o.splice(r,0,n);const a=new nr(this._unitId,s,this._styles);return this._worksheets.set(n,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}getConfig(){return this._snapshot}getIndexBySheetId(n){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>s===n)}getActiveSheet(n){if(!this._activeSheet&&typeof n>"u")throw new Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){const n=this._activeSheet;if(n)return n;const r=this._snapshot.sheetOrder;for(let i=0,o=r.length;i<o;i++){const a=this._worksheets.get(r[i]);if(a&&a.isSheetHidden()!==Ie.TRUE)return this.setActiveSheet(a),a}const s=this._worksheets.get(r[0]);return this.setActiveSheet(s),s}setActiveSheet(n){this._activeSheet$.next(n)}removeSheet(n){const r=this._worksheets.get(n);return r?(this._worksheets.delete(n),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(n),1),delete this._snapshot.sheets[n],this._sheetDisposed$.next(r),!0):!1}getActiveSheetIndex(){const{sheetOrder:n}=this._snapshot;return n.findIndex(r=>this._worksheets.get(r)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:n}=this._snapshot;return n.map(r=>this._worksheets.get(r))}getSheetsName(){const{sheetOrder:n}=this._snapshot,r=[];return n.forEach(s=>{const i=this._worksheets.get(s);i&&r.push(i.getName())}),r}getSheetIndex(n){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>n.getSheetId()===s)}getSheetBySheetName(n){const{sheetOrder:r}=this._snapshot,s=r.find(i=>this._worksheets.get(i).getName()===n);return this._worksheets.get(s)}getSheetBySheetId(n){return this._worksheets.get(n)}getSheetByIndex(n){const{sheetOrder:r}=this._snapshot;return this._worksheets.get(r[n])}getHiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden===Ie.TRUE).map(n=>n.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden!==Ie.TRUE).map(n=>n.getConfig().id)}load(n){this._snapshot=n}checkSheetName(n){return this.getSheetsName().includes(n)}uniqueSheetName(n="Sheet1"){let r=n;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}generateNewSheetName(n){let r=n+this._count;for(;this.checkSheetName(r);)r=n+this._count,this._count++;return r}_parseWorksheetSnapshots(){const{_snapshot:n,_worksheets:r}=this,{sheets:s,sheetOrder:i}=n;if(ne.isEmptyObject(s)){const o=ne.generateRandomId();s[o]={id:o}}for(const o in s){const a=s[o],{name:l}=a;a.name=this.uniqueSheetName(l),a.name!==l&&this._logService.debug("[Workbook]",`The worksheet name ${l} is duplicated, we changed it to ${a.name}. Please fix the problem in your snapshot.`);const u=new nr(this._unitId,a,this._styles);r.set(o,u),i.includes(o)||i.push(o)}this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(n){this._snapshot.custom=n}};exports.Workbook=wE([bE(1,Ot)],exports.Workbook);class yi extends ls{constructor(n){var r;super();C(this,"type",Be.UNIVER_SLIDE);C(this,"_activePage$",new Oe.BehaviorSubject(null));C(this,"activePage$",this._activePage$.asObservable());C(this,"_name$");C(this,"name$");C(this,"_snapshot");C(this,"_unitId");this._snapshot={..._l,...n},this._unitId=(r=this._snapshot.id)!=null?r:ne.generateRandomId(6),this._name$=new Oe.BehaviorSubject(this._snapshot.title),this.name$=this._name$.asObservable()}get _activePage(){var r,s;const n=this._activePage$.getValue();if(!n){const i=(r=this.getPageOrder())==null?void 0:r[0];return i?(s=this.getPages())==null?void 0:s[i]:null}return n}setName(n){var r;this._snapshot.title=n,this._name$.next(n),this._unitId=(r=this._snapshot.id)!=null?r:Bt(6)}getRev(){return 0}incrementRev(){}setRev(n){}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var n;return(n=this._snapshot.body)==null?void 0:n.pages}getPageOrder(){var n;return(n=this._snapshot.body)==null?void 0:n.pageOrder}getPage(n){const r=this.getPages();return r==null?void 0:r[n]}getElementsByPage(n){var r;return(r=this.getPage(n))==null?void 0:r.pageElements}getElement(n,r){var s;return(s=this.getElementsByPage(n))==null?void 0:s[r]}getPageSize(){return this._snapshot.pageSize}getBlankPage(){const n=Bt(6);return{id:n,pageType:ci.SLIDE,zIndex:10,title:n,description:"",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}setActivePage(n){this._activePage$.next(n)}getActivePage(){return this._activePage}updatePage(n,r){this._snapshot.body&&(this._snapshot.body.pages[n]=r)}appendPage(n){var i;if(!this._snapshot.body)return;this._snapshot.body.pages[n.id]=n;const r=this._activePage,s=this._snapshot.body.pageOrder.indexOf((i=r==null?void 0:r.id)!=null?i:"");this._snapshot.body.pageOrder.splice(s+1,0,n.id)}}var TE=Object.getOwnPropertyDescriptor,yE=(e,t,n,r)=>{for(var s=r>1?void 0:r?TE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},ko=(e,t)=>(n,r)=>t(n,r,e);const Mn=je.createIdentifier("univer.current");exports.UniverInstanceService=class extends st{constructor(n,r){super();C(this,"_unitsByType",new Map);C(this,"_createHandler");C(this,"_ctorByType",new Map);C(this,"_currentUnits",new Map);C(this,"_currentUnits$",new Oe.BehaviorSubject(this._currentUnits));C(this,"currentUnits$",this._currentUnits$.asObservable());C(this,"_unitAdded$",new Oe.Subject);C(this,"unitAdded$",this._unitAdded$.asObservable());C(this,"_unitDisposed$",new Oe.Subject);C(this,"unitDisposed$",this._unitDisposed$.asObservable());C(this,"_focused$",new Oe.BehaviorSubject(null));C(this,"focused$",this._focused$.asObservable());this._injector=n,this._contextService=r}dispose(){super.dispose(),this._focused$.complete()}__setCreateHandler(n){this._createHandler=n}createUnit(n,r,s){return this._createHandler(n,r,this._ctorByType.get(n),s)}registerCtorForType(n,r){return this._ctorByType.set(n,r),{dispose:()=>{this._ctorByType.delete(n)}}}getCurrentTypeOfUnit$(n){return this.currentUnits$.pipe(Oe.map(r=>{var s;return(s=r.get(n))!=null?s:null}),Oe.distinctUntilChanged())}getCurrentUnitForType(n){return this._currentUnits.get(n)}getCurrentUnitOfType(n){return this.getCurrentUnitForType(n)}setCurrentUnitForType(n){const r=this._getUnitById(n);if(!r)throw new Error(`[UniverInstanceService]: no document with unitId ${n}!`);this._currentUnits.set(r[1],r[0]),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(n){return this._unitAdded$.pipe(Oe.filter(r=>r.type===n))}__addUnit(n,r){var a;const s=n.type;this._unitsByType.has(s)||this._unitsByType.set(s,[]);const i=this._unitsByType.get(s),o=n.getUnitId();if(i.findIndex(l=>l.getUnitId()===o)!==-1)throw new Error(`[UniverInstanceService]: cannot create a unit with the same unit id: ${o}.`);i.push(n),this._unitAdded$.next(n),((a=r==null?void 0:r.makeCurrent)==null||a)&&this.setCurrentUnitForType(n.getUnitId())}getTypeOfUnitDisposed$(n){return this.unitDisposed$.pipe(Oe.filter(r=>r.type===n))}getUnit(n,r){var i;const s=(i=this._getUnitById(n))==null?void 0:i[0];return r&&(s==null?void 0:s.type)!==r?null:s}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(Be.UNIVER_DOC)}getUniverDocInstance(n){return this.getUnit(n,Be.UNIVER_DOC)}getUniverSheetInstance(n){return this.getUnit(n,Be.UNIVER_SHEET)}getAllUnitsForType(n){var r;return(r=this._unitsByType.get(n))!=null?r:[]}changeDoc(n,r){const s=this.getAllUnitsForType(Be.UNIVER_DOC),i=s.find(o=>o.getUnitId()===n);if(i!=null){const o=s.indexOf(i);s.splice(o,1)}this.__addUnit(r)}get focused(){var r;const n=this._focused$.getValue();return n?(r=this._getUnitById(n))==null?void 0:r[0]:null}focusUnit(n){this._focused$.next(n),this.focused instanceof exports.Workbook?(this._contextService.setContextValue(zn,!0),this._contextService.setContextValue(Gn,!1),this._contextService.setContextValue(wn,!0),this._contextService.setContextValue(Vn,!1),this.setCurrentUnitForType(n)):this.focused instanceof Mt?(this._contextService.setContextValue(zn,!0),this._contextService.setContextValue(Gn,!0),this._contextService.setContextValue(wn,!1),this._contextService.setContextValue(Vn,!1),this.setCurrentUnitForType(n)):this.focused instanceof yi?(this._contextService.setContextValue(zn,!0),this._contextService.setContextValue(Gn,!1),this._contextService.setContextValue(wn,!1),this._contextService.setContextValue(Vn,!0),this.setCurrentUnitForType(n)):(this._contextService.setContextValue(zn,!1),this._contextService.setContextValue(Gn,!1),this._contextService.setContextValue(wn,!1),this._contextService.setContextValue(Vn,!1))}getFocusedUnit(){return this.focused}getUnitType(n){const r=this._getUnitById(n);return r?r[1]:Be.UNRECOGNIZED}disposeUnit(n){const r=this._getUnitById(n);if(!r)return!1;const[s,i]=r,o=this._unitsByType.get(i),a=o.indexOf(s);return o.splice(a,1),this._tryResetCurrentOnRemoval(n,i),this._tryResetFocusOnRemoval(n),this._unitDisposed$.next(s),!0}_tryResetCurrentOnRemoval(n,r){const s=this.getCurrentUnitForType(r);(s==null?void 0:s.getUnitId())===n&&(this._currentUnits.set(r,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(n){var r;((r=this.focused)==null?void 0:r.getUnitId())===n&&this._focused$.next(null)}_getUnitById(n){for(const[r,s]of this._unitsByType){const i=s.find(o=>o.getUnitId()===n);if(i)return[i,r]}}};exports.UniverInstanceService=yE([ko(0,je.Inject(je.Injector)),ko(1,Dn)],exports.UniverInstanceService);var Je=(e=>(e[e.Starting=0]="Starting",e[e.Ready=1]="Ready",e[e.Rendered=2]="Rendered",e[e.Steady=3]="Steady",e))(Je||{});const NE={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"};var ME=Object.getOwnPropertyDescriptor,DE=(e,t,n,r)=>{for(var s=r>1?void 0:r?ME(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},LE=(e,t)=>(n,r)=>t(n,r,e);exports.LifecycleService=class extends st{constructor(n){super();C(this,"_lifecycle$",new Oe.BehaviorSubject(Je.Starting));C(this,"lifecycle$",this._lifecycle$.asObservable());C(this,"_lock",!1);this._logService=n,this._reportProgress(Je.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(n){if(this._lock)throw new Error("[LifecycleService]: cannot set new stage when related logic is all handled!");if(n<this.stage)throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");n!==this.stage&&(this._lock=!0,this._reportProgress(n),this._lifecycle$.next(n),this._lock=!1)}dispose(){this._lifecycle$.complete(),super.dispose()}onStage(n){return Oe.firstValueFrom(this.lifecycle$.pipe(Oe.filter(r=>r>=n),Ds(r=>r===n),Oe.map(()=>{})))}subscribeWithPrevious(){return Oe.merge($u(this.stage),this._lifecycle$.pipe(Oe.skip(1))).pipe(Ds(n=>n===Je.Steady))}_reportProgress(n){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${NE[n]}".`)}};exports.LifecycleService=DE([LE(0,Ot)],exports.LifecycleService);function $u(e){switch(e){case Je.Starting:return Oe.of(Je.Starting);case Je.Ready:return Oe.of(Je.Starting,Je.Ready);case Je.Rendered:return Oe.of(Je.Starting,Je.Ready,Je.Rendered);default:return Oe.of(Je.Starting,Je.Ready,Je.Rendered,Je.Steady)}}const xE=je.createIdentifier("ILocalStorageService");class ln extends st{constructor(){super();C(this,"_currentLocale$",new Oe.BehaviorSubject(or.ZH_CN));C(this,"currentLocale$",this._currentLocale$.asObservable());C(this,"_locales",null);C(this,"localeChanged$",new Oe.Subject);C(this,"t",(n,...r)=>{if(!this._locales)throw new Error("[LocaleService]: Locale not initialized");const s=n.split("."),i=this.resolveKeyPath(this._locales[this._currentLocale],s);if(typeof i=="string"){let o=i;return r.forEach((a,l)=>{o=o.replace(`{${l}}`,a)}),o}else return n});this.disposeWithMe(nt(()=>this.localeChanged$.complete()))}get _currentLocale(){return this._currentLocale$.value}load(n){var r;this._locales=Ci((r=this._locales)!=null?r:{},n)}setLocale(n){this._currentLocale$.next(n),this.localeChanged$.next()}getLocales(){var n;return(n=this._locales)==null?void 0:n[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(n,r){const s=r.shift();if(s&&n&&s in n){const i=n[s];return r.length>0&&(typeof i=="object"||Array.isArray(i))?this.resolveKeyPath(i,r):i}return null}}var Ni=(e=>(e.INIT="init",e.FETCHING="fetching",e.DONE="done",e))(Ni||{});const Hu=je.createIdentifier("univer.permission-service");class ju extends st{constructor(){super(...arguments);C(this,"_permissionPointMap",new Map);C(this,"_permissionPointUpdate$",new Oe.Subject);C(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable());C(this,"_showComponents",!0)}setShowComponents(n){this._showComponents=n}getShowComponents(){return this._showComponents}deletePermissionPoint(n){const r=this._permissionPointMap.get(n);r&&(r.complete(),this._permissionPointMap.delete(n))}addPermissionPoint(n){const r=n instanceof Oe.BehaviorSubject,s=r?n.getValue():n;if(!s.id)return!1;if(this._permissionPointMap.get(s.id))throw new Error(`${s.id} PermissionPoint already exists`);return this._permissionPointMap.set(s.id,r?n:new Oe.BehaviorSubject(s)),this._permissionPointUpdate$.next(s),!0}updatePermissionPoint(n,r){const s=this._permissionPointMap.get(n);if(!s)return;const i=s.getValue();i.value=r,i.status=Ni.DONE,s.next(i),this._permissionPointUpdate$.next(i)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(n){const r=this._permissionPointMap.get(n);if(r)return r.getValue()}getPermissionPoint$(n){const r=this._permissionPointMap.get(n);if(r)return r}composePermission$(n){const r=n.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.asObservable()});return Oe.combineLatest(r).pipe(Tr.map(s=>s))}composePermission(n){return n.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.getValue()})}getAllPermissionPoint(){const n=new Map;return this._permissionPointMap.forEach((r,s)=>{n.set(s,r)}),n}}var UE=Object.getOwnPropertyDescriptor,PE=(e,t,n,r)=>{for(var s=r>1?void 0:r?UE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},ws=(e,t)=>(n,r)=>t(n,r,e);const kE=4,Wu=Symbol("DependentOn");class ei extends st{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}C(ei,"pluginName"),C(ei,"type",Be.UNIVER_UNKNOWN);class FE{constructor(){C(this,"_plugins",[])}addPlugin(t){this._plugins.push(t)}removePlugins(){const t=this._plugins.slice();return this._plugins.length=0,t}forEachPlugin(t){this._plugins.forEach(t)}}function BE(...e){return function(t){t[Wu]=e}}exports.PluginService=class{constructor(t,n,r){C(this,"_pluginRegistry",new Map);C(this,"_pluginStore",new FE);C(this,"_seenPlugins",new Set);C(this,"_loadedPlugins",new Set);C(this,"_loadedPluginTypes",new Set([Be.UNIVER_UNKNOWN]));C(this,"_flushTimerByType",new Map);this._injector=t,this._lifecycleService=n,this._logService=r}dispose(){this._pluginStore.removePlugins().forEach(t=>t.dispose()),this._flushTimerByType.forEach(t=>clearTimeout(t))}registerPlugin(t,n){this._assertPluginValid(t);const r={plugin:t,options:n};this._pluginRegistry.set(t.pluginName,r),this._logService.debug("[PluginService]",`Plugin "${t.pluginName}" registered.`);const{type:s}=t;this._loadedPluginTypes.has(s)&&(s===Be.UNIVER_UNKNOWN?this._loadFromPlugins([r]):this._flushType(s))}startPluginsForType(t){this._loadedPluginTypes.has(t)||this._loadPluginsForType(t)}_loadPluginsForType(t){const n=Array.from(this._pluginRegistry.keys()),r=[];n.forEach(s=>{const i=this._pluginRegistry.get(s);i.plugin.type===t&&r.push(i)}),this._loadFromPlugins(r),this._loadedPluginTypes.add(t)}_assertPluginValid(t){const{type:n,pluginName:r}=t;if(n===Be.UNRECOGNIZED)throw new Error(`[PluginService]: invalid plugin type for ${t.name}. Please assign a "type" to your plugin.`);if(!r)throw new Error(`[PluginService]: no plugin name for ${t.name}. Please assign a "pluginName" to your plugin.`);if(this._seenPlugins.has(r))throw new Error(`[PluginService]: duplicated plugin name for "${r}". Maybe a plugin that dependents on "${r} has already registered it. In that case please register "${r}" before the that plugin.`);this._seenPlugins.add(t.pluginName)}_flushType(t){this._flushTimerByType.get(t)===void 0&&this._flushTimerByType.set(t,setTimeout(()=>{this._loadPluginsForType(t),this._flushTimerByType.delete(t)},kE))}_loadFromPlugins(t){const n=[],r=new Set,s=o=>{const{plugin:a}=o,{pluginName:l}=a;if(this._loadedPlugins.has(l)||r.has(l))return;r.add(l),this._pluginRegistry.delete(l);const u=a[Wu];u&&u.forEach(c=>{const h=this._pluginRegistry.get(c.pluginName);if(h)s(h);else if(!this._seenPlugins.has(c.pluginName)&&!r.has(c.pluginName)){if(a.type===Be.UNIVER_UNKNOWN&&c.type!==Be.UNIVER_UNKNOWN)throw new Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${a.pluginName} and the dependency is ${c.pluginName}.`);a.type!==c.type&&c.type!==Be.UNIVER_UNKNOWN&&this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${c.pluginName}" which has different type.`),this._logService.debug("[PluginService]",`Plugin "${l}" depends on "${c.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(c),s({plugin:c,options:void 0})}}),n.push(o)};t.forEach(o=>s(o));const i=n.map(o=>this._initPlugin(o.plugin,o.options));this._pluginsRunLifecycle(i)}_pluginsRunLifecycle(t){const n=this._lifecycleService.stage;if($u(n).subscribe(r=>this._runStage(t,r)),n!==Je.Steady){const r=this._lifecycleService.lifecycle$.pipe(Oe.skip(1)).subscribe(s=>{this._runStage(t,s),s===Je.Steady&&r.unsubscribe()})}}_runStage(t,n){t.forEach(r=>{switch(n){case Je.Starting:r.onStarting();break;case Je.Ready:r.onReady();break;case Je.Rendered:r.onRendered();break;case Je.Steady:r.onSteady();break}})}_initPlugin(t,n){const r=this._injector.createInstance(t,n);return this._pluginStore.addPlugin(r),this._loadedPlugins.add(t.pluginName),this._logService.debug("[PluginService]",`Plugin "${r.getPluginName()}" loaded.`),r}};exports.PluginService=PE([ws(0,je.Inject(je.Injector)),ws(1,je.Inject(exports.LifecycleService)),ws(2,Ot)],exports.PluginService);function Yu(e,t){if(!t)return e;const n=[];for(const r of e){const s=t.find(([i])=>i===r[0]);if(s){if(s[1]===null)continue;n.push([r[0],s[1]])}else n.push(r)}return n}const ti=je.createIdentifier("resource-loader-service");var $E=Object.getOwnPropertyDescriptor,HE=(e,t,n,r)=>{for(var s=r>1?void 0:r?$E(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},jE=(e,t)=>(n,r)=>t(n,r,e);exports.ResourceManagerService=class extends st{constructor(n){super();C(this,"_resourceMap",new Map);C(this,"_register$",new Oe.Subject);C(this,"register$",this._register$.asObservable());this._logService=n}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(n,r){return r?this.getResourcesByType(n,r):this.getAllResourceHooks().map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}getResourcesByType(n,r){return this.getAllResourceHooks().filter(o=>o.businesses.includes(r)).map(o=>{const a=o.toJson(n);return{name:o.pluginName,data:a}})}registerPluginResource(n){const r=n.pluginName;if(this._resourceMap.has(r))throw new Error(`the pluginName is registered {${r}}`);return this._resourceMap.set(r,n),this._register$.next(n),nt(()=>this._resourceMap.delete(r))}disposePluginResource(n){this._resourceMap.delete(n)}loadResources(n,r){this.getAllResourceHooks().forEach(s=>{var o;const i=(o=r==null?void 0:r.find(a=>a.name===s.pluginName))==null?void 0:o.data;if(i)try{const a=s.parseJson(i);s.onLoad(n,a)}catch(a){this._logService.error("[ResourceManagerService]","loadResources error",a)}})}unloadResources(n){this.getAllResourceHooks().forEach(r=>{r.onUnLoad(n)})}dispose(){this._register$.complete(),this._resourceMap.clear()}};exports.ResourceManagerService=HE([jE(0,Ot)],exports.ResourceManagerService);class qr extends st{constructor(){super();C(this,"_darkMode$",new Oe.BehaviorSubject(!1));C(this,"darkMode$",this._darkMode$.asObservable());C(this,"_currentTheme",hc.defaultTheme);C(this,"_currentTheme$",new Oe.BehaviorSubject(this._currentTheme));C(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(nt(()=>{this._currentTheme$.complete(),this._darkMode$.complete()}))}get darkMode(){return this._darkMode$.getValue()}getCurrentTheme(){return this._currentTheme}setTheme(n){this._currentTheme=n,this._currentTheme$.next(n)}setDarkMode(n){this._darkMode$.next(n)}getColorFromTheme(n){return $l(this._currentTheme,n)}}var WE=Object.getOwnPropertyDescriptor,YE=(e,t,n,r)=>{for(var s=r>1?void 0:r?WE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},bs=(e,t)=>(n,r)=>t(n,r,e);const cs=je.createIdentifier("univer.undo-redo.service"),zE=20;class zu{dispose(){}async dispatchToHandlers(){return!1}}const Gu="univer.command.redo",Vu="univer.command.undo",Ku=new class extends zu{constructor(){super(...arguments);C(this,"type",sr.COMMAND);C(this,"id",Vu)}handler(t){const n=t.get(cs),r=n.pitchTopUndoElement();if(!r)return!1;const s=t.get(ir);return Qr(r.undoMutations,s)?(n.popUndoToRedo(),!0):!1}},Xu=new class extends zu{constructor(){super(...arguments);C(this,"type",sr.COMMAND);C(this,"id",Gu)}handler(t){const n=t.get(cs),r=n.pitchTopRedoElement();if(!r)return!1;const s=t.get(ir);return Qr(r.redoMutations,s)?(n.popRedoToUndo(),!0):!1}};exports.LocalUndoRedoService=class extends st{constructor(n,r,s){super();C(this,"undoRedoStatus$");C(this,"_undoRedoStatus$",new Oe.BehaviorSubject({undos:0,redos:0}));C(this,"_undoStacks",new Map);C(this,"_redoStacks",new Map);C(this,"_batchingStatus",new Map);this._univerInstanceService=n,this._commandService=r,this._contextService=s,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(Ku)),this.disposeWithMe(this._commandService.registerCommand(Xu)),this.disposeWithMe(nt(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(nt(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(n){const{unitID:r}=n,s=this._getRedoStack(r,!0),i=this._getUndoStack(r,!0);if(s.length=0,this._batchingStatus.has(n.unitID)){const a=this._batchingStatus.get(n.unitID),l=this._pitchUndoElement(n.unitID);a===0||!l?(o(n),this._batchingStatus.set(n.unitID,1)):this._tryBatchingElements(l,n)}else o(n);function o(a){i.push(a),i.length>zE&&i.splice(0,1)}this._updateStatus()}clearUndoRedo(n){const r=this._getRedoStack(n);r&&(r.length=0);const s=this._getUndoStack(n);s&&(s.length=0),this._updateStatus()}pitchTopUndoElement(){const n=this._getFocusedUnitId();return this._pitchUndoElement(n)}pitchTopRedoElement(){const n=this._getFocusedUnitId();return this._pitchRedoElement(n)}_pitchUndoElement(n){const r=this._getUndoStack(n);return r!=null&&r.length?r[r.length-1]:null}_pitchRedoElement(n){const r=this._getRedoStack(n);return r!=null&&r.length?r[r.length-1]:null}popUndoToRedo(){const r=this._getUndoStackForFocused().pop();r&&(this._getRedoStackForFocused().push(r),this._updateStatus())}popRedoToUndo(){const r=this._getRedoStackForFocused().pop();r&&(this._getUndoStackForFocused().push(r),this._updateStatus())}rollback(n,r){const s=r||this._getFocusedUnitId(),i=this._getUndoStack(s),o=i==null?void 0:i[(i==null?void 0:i.length)-1];o&&o.id===n&&(i.pop(),Qr(o.undoMutations,this._commandService))}__tempBatchingUndoRedo(n){if(this._batchingStatus.has(n))throw new Error("[LocalUndoRedoService]: cannot batching undo redo twice at the same time!");return this._batchingStatus.set(n,0),nt(()=>this._batchingStatus.delete(n))}_updateStatus(){var i,o;const n=this._getFocusedUnitId(),r=n&&((i=this._undoStacks.get(n))==null?void 0:i.length)||0,s=n&&((o=this._redoStacks.get(n))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:r,redos:s})}_getUndoStack(n,r=!1){let s=this._undoStacks.get(n);return!s&&r&&(s=[],this._undoStacks.set(n,s)),s||null}_getRedoStack(n,r=!1){let s=this._redoStacks.get(n);return!s&&r&&(s=[],this._redoStacks.set(n,s)),s||null}_getUndoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getUndoStack(n,!0)}_getRedoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getRedoStack(n,!0)}_tryBatchingElements(n,r){n.redoMutations.push(...r.redoMutations),n.undoMutations.push(...r.undoMutations)}_getFocusedUnitId(){var o,a,l,u;let n="";const r=this._contextService.getContextValue(wn),s=this._contextService.getContextValue(wu),i=this._contextService.getContextValue(Ou);return r?s?n=li:i?n=ai:n=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":n=(u=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?u:"",n}};exports.LocalUndoRedoService=YE([bs(0,Mn),bs(1,ir),bs(2,Dn)],exports.LocalUndoRedoService);function GE(e){return!(e.length===0||e.length>31||e.startsWith("'")||e.endsWith("'")||/[:\\\/\?\*\[\]]/.test(e))}function VE(e){return new Promise(t=>setTimeout(t,e))}function KE(e=1){return new Promise(t=>{let n=0;const r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}var Mi=(e=>(e.URL="URL",e.UUID="UUID",e.BASE64="BASE64",e))(Mi||{}),qu=(e=>(e.SUCCUSS="0",e.ERROR_EXCEED_SIZE="1",e.ERROR_IMAGE_TYPE="2",e.ERROR_UPLOAD_COUNT_LIMIT="3",e.ERROR_IMAGE="4",e))(qu||{});const ni=je.createIdentifier("core.image-io.service");class Ju{constructor(t,n=100){C(this,"_imageCacheMap");this._injector=t,this._imageCacheMap=new Zn(n)}_getImageCacheKey(t,n){return`${t}-${n}`}getImage(t,n,r,s){const i=this._getImageCacheKey(t,n);let o=this._imageCacheMap.get(i);return o||((async()=>{o=new Image;const a=this._injector.has(ni)?this._injector.get(ni):null;if(t===Mi.UUID)try{o.src=await(a==null?void 0:a.getImage(n))||""}catch(l){console.error(l)}else o.src=n;o.onload=()=>{r==null||r()},o.onerror=()=>{s==null||s()},this._imageCacheMap.set(i,o)})(),null)}}const XE=["script","style","meta","comment","link"];var Zu=(e=>(e[e.INFO=0]="INFO",e[e.STOP=1]="STOP",e[e.WARNING=2]="WARNING",e))(Zu||{}),Qu=(e=>(e[e.DISABLED=0]="DISABLED",e[e.FULL_ALPHA=1]="FULL_ALPHA",e[e.FULL_HANGUL=2]="FULL_HANGUL",e[e.FULL_KATAKANA=3]="FULL_KATAKANA",e[e.HALF_ALPHA=4]="HALF_ALPHA",e[e.HALF_HANGUL=5]="HALF_HANGUL",e[e.HALF_KATAKANA=6]="HALF_KATAKANA",e[e.HIRAGANA=7]="HIRAGANA",e[e.NO_CONTROL=8]="NO_CONTROL",e[e.OFF=9]="OFF",e[e.ON=10]="ON",e))(Qu||{}),ec=(e=>(e.BETWEEN="between",e.EQUAL="equal",e.GREATER_THAN="greaterThan",e.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",e.LESS_THAN="lessThan",e.LESS_THAN_OR_EQUAL="lessThanOrEqual",e.NOT_BETWEEN="notBetween",e.NOT_EQUAL="notEqual",e))(ec||{}),tc=(e=>(e[e.TEXT=0]="TEXT",e[e.ARROW=1]="ARROW",e[e.CUSTOM=2]="CUSTOM",e))(tc||{}),nc=(e=>(e.VALID="valid",e.INVALID="invalid",e.VALIDATING="validating",e))(nc||{}),rc=(e=>(e.CUSTOM="custom",e.LIST="list",e.LIST_MULTIPLE="listMultiple",e.NONE="none",e.TEXT_LENGTH="textLength",e.DATE="date",e.TIME="time",e.WHOLE="whole",e.DECIMAL="decimal",e.CHECKBOX="checkbox",e.ANY="any",e))(rc||{}),qE=Object.getOwnPropertyDescriptor,JE=(e,t,n,r)=>{for(var s=r>1?void 0:r?qE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},ZE=(e,t)=>(n,r)=>t(n,r,e);exports.Skeleton=class extends st{constructor(n){super();C(this,"_fontLocale");C(this,"_dirty",!0);this._localeService=n,this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(n){this._dirty=n}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}};exports.Skeleton=JE([ZE(0,je.Inject(ln))],exports.Skeleton);var QE=Object.getOwnPropertyDescriptor,e0=(e,t,n,r)=>{for(var s=r>1?void 0:r?QE(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},Ar=(e,t)=>(n,r)=>t(n,r,e);exports.SheetSkeleton=class extends exports.Skeleton{constructor(n,r,s,i,o,a){super(s);C(this,"_worksheetData");C(this,"_renderRawFormula",!1);C(this,"_cellData");C(this,"_imageCacheMap");C(this,"_isRowStylePrecedeColumnStyle",!1);C(this,"_skipAutoHeightForMergedCells",!0);C(this,"_rowTotalHeight",0);C(this,"_columnTotalWidth",0);C(this,"_rowHeaderWidth",0);C(this,"_columnHeaderHeight",0);C(this,"_rowHeightAccumulation",[]);C(this,"_columnWidthAccumulation",[]);C(this,"_marginTop",0);C(this,"_marginLeft",0);C(this,"_scaleX");C(this,"_scaleY");C(this,"_scrollX");C(this,"_scrollY");this.worksheet=n,this._styles=r,this._contextService=i,this._configService=o,this._injector=a,this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new Ju(this._injector),this.initConfig()}initConfig(){var n,r;this._skipAutoHeightForMergedCells=!((n=this._configService.getConfig(Fa))!=null&&n),this._isRowStylePrecedeColumnStyle=(r=this._configService.getConfig(ka))!=null?r:!1}resetCache(){}getWorksheetConfig(){return this._worksheetData}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(n){this._columnHeaderHeight=n,this._worksheetData.columnHeader.height=n}set rowHeaderWidth(n){this._rowHeaderWidth=n,this._worksheetData.rowHeader.width=n}get rowHeightAccumulation(){return this._rowHeightAccumulation}get rowTotalHeight(){return this._rowTotalHeight}get columnWidthAccumulation(){return this._columnWidthAccumulation}get columnTotalWidth(){return this._columnTotalWidth}get rowHeaderWidth(){return this._rowHeaderWidth}get columnHeaderHeight(){return this._columnHeaderHeight}setMarginLeft(n){this._marginLeft=n}setMarginTop(n){this._marginTop=n}setScale(n,r){this._updateLayout(),this._scaleX=n,this._scaleY=r||n,this._updateLayout()}setScroll(n,r){ne.isDefine(n)&&(this._scrollX=n),ne.isDefine(r)&&(this._scrollY=r)}get scrollX(){return this._scrollX}get scrollY(){return this._scrollY}get scaleX(){return this._scaleX}get scaleY(){return this._scaleY}get rowHeaderWidthAndMarginLeft(){return this.rowHeaderWidth+this._marginLeft}get columnHeaderHeightAndMarginTop(){return this.columnHeaderHeight+this._marginTop}get imageCacheMap(){return this._imageCacheMap}_generateRowMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let u=s;if(this.worksheet.getRowFiltered(l))u=0;else if(a[l]!=null){const c=a[l];if(!c)continue;const{h=s,ah:d,ia:f}=c;(f==null||f===Ie.TRUE)&&typeof d=="number"?u=d:u=h,c.hd===Ie.TRUE&&(u=0)}i+=u,o.push(i)}return{rowTotalHeight:i,rowHeightAccumulation:o}}_generateColumnMatrixCache(n,r,s){let i=0;const o=[],a=r;for(let l=0;l<n;l++){let u=s;if(a[l]!=null){const c=a[l];if(!c)continue;c.w!=null&&(u=c.w),c.hd===Ie.TRUE&&(u=0)}i+=u,o.push(i)}return{columnTotalWidth:i,columnWidthAccumulation:o}}intersectMergeRange(n,r){return!!this.worksheet.getMergedCell(n,r)}_getOverflowBound(n,r,s,i,o=yt.LEFT){let a=0;if(r>s){const l=this._columnWidthAccumulation.length-1;for(let u=r;u>=s;u--){const c=u,h=this.worksheet.getCell(n,c);if(!Bs(h)&&c!==r||this.intersectMergeRange(n,c))return c===r?c:c+1>l?l:c+1;const{startX:d,endX:f}=In(n,c,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===yt.CENTER&&c===r?a+=(f-d)/2:a+=f-d,i<a)return c}return r}for(let l=r;l<=s;l++){const u=l,c=this.worksheet.getCell(n,u);if(!Bs(c)&&u!==r||this.intersectMergeRange(n,u))return u===r?u:u-1<0?0:u-1;const{startX:h,endX:d}=In(n,u,this.rowHeightAccumulation,this.columnWidthAccumulation);if(o===yt.CENTER&&u===r?a+=(d-h)/2:a+=d-h,i<a)return u}return s}_updateLayout(){if(!this.dirty)return;const{rowData:n,columnData:r,defaultRowHeight:s,defaultColumnWidth:i,rowCount:o,columnCount:a,rowHeader:l,columnHeader:u}=this._worksheetData,{rowTotalHeight:c,rowHeightAccumulation:h}=this._generateRowMatrixCache(o,n,s),{columnTotalWidth:d,columnWidthAccumulation:f}=this._generateColumnMatrixCache(a,r,i);this._rowHeaderWidth=l.hidden!==Ie.TRUE?this._dynamicallyUpdateRowHeaderWidth(l):0,this._columnHeaderHeight=u.hidden!==Ie.TRUE?u.height:0,this._rowTotalHeight=c,this._rowHeightAccumulation=h,this._columnTotalWidth=d,this._columnWidthAccumulation=f,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(n){}_dynamicallyUpdateRowHeaderWidth(n){const s=`${this.worksheet.getRowCount()}`.length*8;return Math.max(n.width,s)}_hasUnMergedCellInRow(n,r,s){if(!this.worksheet.getMergeData())return!1;for(let o=r;o<=s;o++){const{isMerged:a,isMergedMainCell:l}=this.worksheet.getCellInfoInMergeData(n,o);if(!a&&!l)return!0}return!1}expandRangeByMerge(n){let{startRow:r,startColumn:s,endRow:i,endColumn:o}=n;const a=this._worksheetData.mergeData;if(!a)return{startRow:r,startColumn:s,endRow:i,endColumn:o};let l=!0;const u=new Et;for(;l;){l=!1;for(let c=0;c<a.length;c++){const{startRow:h,startColumn:d,endRow:f,endColumn:p}=a[c];if(u.getValue(h,d))continue;Cl({startColumn:s,startRow:r,endColumn:o,endRow:i},{startColumn:d,startRow:h,endColumn:p,endRow:f})&&(r=Math.min(r,h),s=Math.min(s,d),i=Math.max(i,f),o=Math.max(o,p),u.setValue(h,d,!0),l=!0)}}return{startRow:r,startColumn:s,endRow:i,endColumn:o}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(n,r){return this.worksheet.getCellInfoInMergeData(n,r)}getNoMergeCellPositionByIndex(n,r,s=!0){return this.getNoMergeCellWithCoordByIndex(n,r,s)}getNoMergeCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this;let{startY:u,endY:c,startX:h,endX:d}=In(n,r,i,o);return s&&(u+=l,c+=l,h+=a,d+=a),{startY:u,endY:c,startX:h,endX:d}}getNoMergeCellPositionByIndexWithNoHeader(n,r){const{rowHeightAccumulation:s,columnWidthAccumulation:i}=this,{startY:o,endY:a,startX:l,endX:u}=In(n,r,s,i);return{startY:o,endY:a,startX:l,endX:u}}getRowIndexByOffsetY(n,r,s,i){var l;const{rowHeightAccumulation:o}=this;n=ic(n,r,s,this.columnHeaderHeightAndMarginTop);let a=$n(o,n,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(o[a]-n)<Math.abs(n-((l=o[a-1])!=null?l:0))&&(a=a+1),a}getColumnIndexByOffsetX(n,r,s,i){var u;const o=sc(n,r,s,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this;let l=$n(a,o,i==null?void 0:i.firstMatch);return i!=null&&i.closeFirst&&Math.abs(a[l]-o)<Math.abs(o-((u=a[l-1])!=null?u:0))&&(l=l+1),l}getCellIndexByOffset(n,r,s,i,o,a){const l=this.getRowIndexByOffsetY(r,i,o,a),u=this.getColumnIndexByOffsetX(n,s,o,a);return{row:l,column:u}}getCellByOffset(n,r,s,i,o){const a=this==null?void 0:this.getCellIndexByOffset(n,r,s,i,o,{firstMatch:!0});return a?this.worksheet.getCellInfoInMergeData(a.row,a.column):null}getCellWithCoordByIndex(n,r,s=!0){const{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:l}=this,u=In(n,r,i,o,this.worksheet.getCellInfoInMergeData(n,r)),{isMerged:c,isMergedMainCell:h}=u;let{startY:d,endY:f,startX:p,endX:R,mergeInfo:w}=u,N=a,G=l;return s===!1&&(N=0,G=0),d+=G,f+=G,p+=N,R+=N,w.startY+=G,w.endY+=G,w.startX+=N,w.endX+=N,{actualRow:n,actualColumn:r,startX:p,startY:d,endX:R,endY:f,isMerged:c,isMergedMainCell:h,mergeInfo:w}}getCellWithCoordByOffset(n,r,s,i,o,a){const{row:l,column:u}=this.getCellIndexByOffset(n,r,s,i,o,a);return this.getCellWithCoordByIndex(l,u)}getOffsetByColumn(n){const{columnWidthAccumulation:r,rowHeaderWidthAndMarginLeft:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetByRow(n){const{rowHeightAccumulation:r,columnHeaderHeightAndMarginTop:s}=this,i=r.length-1,o=r[n];return o!=null?o+s:n<0?s:r[i]+s}getOffsetRelativeToRowCol(n,r){const s=$n(this.columnWidthAccumulation,n);let i=0;s===0?i=n:i=n-this._columnWidthAccumulation[s-1];const o=$n(this.rowHeightAccumulation,r);let a=0;return o===0?a=r:a=r-this._rowHeightAccumulation[o-1],{row:o,column:s,columnOffset:i,rowOffset:a}}_updateConfigAndGetDocumentModel(n,r,s,i){var a,l,u,c,h;if(!i||!((a=n.body)!=null&&a.dataStream))return;n.documentStyle||(n.documentStyle={}),n.documentStyle.marginTop=(l=s.t)!=null?l:0,n.documentStyle.marginBottom=(u=s.b)!=null?u:2,n.documentStyle.marginLeft=(c=s.l)!=null?c:2,n.documentStyle.marginRight=(h=s.r)!=null?h:2,n.documentStyle.pageSize={width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},n.documentStyle.renderConfig={...n.documentStyle.renderConfig,...i};const o=n.body.paragraphs||[];for(const d of o)d.paragraphStyle||(d.paragraphStyle={}),d.paragraphStyle.horizontalAlign=r;return new Mt(n)}dispose(){super.dispose(),this._rowHeightAccumulation=[],this._columnWidthAccumulation=[],this._rowTotalHeight=0,this._columnTotalWidth=0,this._rowHeaderWidth=0,this._columnHeaderHeight=0,this._worksheetData=null,this._cellData=null,this._styles=null}};exports.SheetSkeleton=e0([Ar(2,je.Inject(ln)),Ar(3,Dn),Ar(4,Ti),Ar(5,je.Inject(je.Injector))],exports.SheetSkeleton);function Di(e,t,n,r){const s=e-1,i=t-1,o=n[s]||0;let a=n[e];a==null&&(a=n[n.length-1]);const l=r[i]||0;let u=r[t];return u==null&&(u=r[r.length-1]),{startY:o,endY:a,startX:l,endX:u}}function t0(e,t,n,r){return Di(e,t,n,r)}function In(e,t,n,r,s){e=ne.clamp(e,0,n.length-1),t=ne.clamp(t,0,r.length-1);let{startY:i,endY:o,startX:a,endX:l}=Di(e,t,n,r);if(!s)return{startY:i,endY:o,startX:a,endX:l,isMerged:!1,isMergedMainCell:!1,actualRow:e,actualColumn:t,mergeInfo:{startY:i,endY:o,startX:a,endX:l,startRow:e,startColumn:t,endRow:e,endColumn:t}};const{isMerged:u,isMergedMainCell:c,startRow:h,startColumn:d,endRow:f,endColumn:p}=s;let R={startRow:h,startColumn:d,endRow:f,endColumn:p,startY:i,endY:o,startX:a,endX:l};const w=n.length-1,N=r.length-1;if(u&&h!==-1&&d!==-1){const G=n[h-1]||0,W=n[f]||n[w],se=r[d-1]||0,y=r[p]||r[N];R={...R,startY:G,endY:W,startX:se,endX:y}}else if(!u&&f!==-1&&p!==-1){const G=n[f]||n[w],W=r[p]||r[N];R={...R,startY:i,endY:G,startX:a,endX:W}}return{isMerged:u,isMergedMainCell:c,actualRow:e,actualColumn:t,startY:i,endY:o,startX:a,endX:l,mergeInfo:R}}function sc(e,t,n,r){const{x:s}=n;return e/t+s-r}function ic(e,t,n,r){const{y:s}=n;return e=e/t+s-r,e}const Fo=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],As=1,Fn=8;class Li{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[n,r]=new Uint8Array(t,0,2);if(n!==219)throw new Error("Data does not appear to be in a KDBush format.");const s=r>>4;if(s!==As)throw new Error(`Got v${s} data when expected v${As}.`);const i=Fo[r&15];if(!i)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new Li(a,o,i,t)}constructor(t,n=64,r=Float64Array,s){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+n,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=Fo.indexOf(this.ArrayType),o=t*2*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);s&&s instanceof ArrayBuffer?(this.data=s,this.ids=new this.IndexArrayType(this.data,Fn,t),this.coords=new this.ArrayType(this.data,Fn+a+l,t*2),this._pos=t*2,this._finished=!0):(this.data=new ArrayBuffer(Fn+o+a+l),this.ids=new this.IndexArrayType(this.data,Fn,t),this.coords=new this.ArrayType(this.data,Fn+a+l,t*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(As<<4)+i]),new Uint16Array(this.data,2,1)[0]=n,new Uint32Array(this.data,4,1)[0]=t)}add(t,n){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=n,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ri(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,n,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:o,nodeSize:a}=this,l=[0,i.length-1,0],u=[];for(;l.length;){const c=l.pop()||0,h=l.pop()||0,d=l.pop()||0;if(h-d<=a){for(let w=d;w<=h;w++){const N=o[2*w],G=o[2*w+1];N>=t&&N<=r&&G>=n&&G<=s&&u.push(i[w])}continue}const f=d+h>>1,p=o[2*f],R=o[2*f+1];p>=t&&p<=r&&R>=n&&R<=s&&u.push(i[f]),(c===0?t<=p:n<=R)&&(l.push(d),l.push(f-1),l.push(1-c)),(c===0?r>=p:s>=R)&&(l.push(f+1),l.push(h),l.push(1-c))}return u}within(t,n,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:i,nodeSize:o}=this,a=[0,s.length-1,0],l=[],u=r*r;for(;a.length;){const c=a.pop()||0,h=a.pop()||0,d=a.pop()||0;if(h-d<=o){for(let w=d;w<=h;w++)Bo(i[2*w],i[2*w+1],t,n)<=u&&l.push(s[w]);continue}const f=d+h>>1,p=i[2*f],R=i[2*f+1];Bo(p,R,t,n)<=u&&l.push(s[f]),(c===0?t-r<=p:n-r<=R)&&(a.push(d),a.push(f-1),a.push(1-c)),(c===0?t+r>=p:n+r>=R)&&(a.push(f+1),a.push(h),a.push(1-c))}return l}}function ri(e,t,n,r,s,i){if(s-r<=n)return;const o=r+s>>1;oc(e,t,o,r,s,i),ri(e,t,n,r,o-1,1-i),ri(e,t,n,o+1,s,1-i)}function oc(e,t,n,r,s,i){for(;s>r;){if(s-r>600){const u=s-r+1,c=n-r+1,h=Math.log(u),d=.5*Math.exp(2*h/3),f=.5*Math.sqrt(h*d*(u-d)/u)*(c-u/2<0?-1:1),p=Math.max(r,Math.floor(n-c*d/u+f)),R=Math.min(s,Math.floor(n+(u-c)*d/u+f));oc(e,t,n,p,R,i)}const o=t[2*n+i];let a=r,l=s;for(Bn(e,t,r,n),t[2*s+i]>o&&Bn(e,t,r,s);a<l;){for(Bn(e,t,a,l),a++,l--;t[2*a+i]<o;)a++;for(;t[2*l+i]>o;)l--}t[2*r+i]===o?Bn(e,t,r,l):(l++,Bn(e,t,l,s)),l<=n&&(r=l+1),n<=l&&(s=l-1)}}function Bn(e,t,n,r){Ts(e,n,r),Ts(t,2*n,2*r),Ts(t,2*n+1,2*r+1)}function Ts(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function Bo(e,t,n,r){const s=e-n,i=t-r;return s*s+i*i}class n0{constructor(t=!1){C(this,"_tree",new Map);C(this,"_oneCellCache",new Map);C(this,"_kdTree",new Map);this._enableOneCellCache=t}dispose(){this.clear()}getTree(t,n){return this._tree.has(t)||this._tree.set(t,new Map),this._tree.get(t).has(n)||this._tree.get(t).set(n,new zr),this._tree.get(t).get(n)}_getOneCellCache(t,n,r,s){return this._oneCellCache.has(t)||this._oneCellCache.set(t,new Map),this._oneCellCache.get(t).has(n)||this._oneCellCache.get(t).set(n,new Map),this._oneCellCache.get(t).get(n).has(r)||this._oneCellCache.get(t).get(n).set(r,new Map),this._oneCellCache.get(t).get(n).get(r).has(s)||this._oneCellCache.get(t).get(n).get(r).set(s,new Set),this._oneCellCache.get(t).get(n).get(r).get(s)}_removeOneCellCache(t,n,r,s,i){const o=this._oneCellCache.get(t);if(!o)return;const a=o.get(n);if(!a)return;const l=a.get(r);if(!l)return;const u=l.get(s);u&&u.delete(i)}_removeCellCacheByRange(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this._oneCellCache.get(n);if(!o)return;const a=o.get(r);if(!a)return;const{startRow:l,startColumn:u,endRow:c,endColumn:h}=s;for(let d=l;d<=c;d++){const f=a.get(d);if(f)for(let p=u;p<=h;p++){const R=f.get(p);R&&R.delete(i)}}}_insertOneCellCache(t,n,r,s,i){this._getOneCellCache(t,n,r,s).add(i)}_getRdTreeItems(t){const n=[];for(const[r,s]of t)for(const[i,o]of s)n.push({x:i,y:r,ids:o});return n}_searchByOneCellCache(t){var p;const{unitId:n,sheetId:r,range:s}=t,{startRow:i,startColumn:o,endRow:a,endColumn:l}=s,u=(p=this._kdTree.get(n))==null?void 0:p.get(r);if(!u)return[];const{tree:c,items:h}=u,d=c.range(o,i,l,a),f=[];for(const R of d){const w=h[R];f.push(...Array.from(w.ids))}return f}openKdTree(){var t;for(const[n,r]of this._oneCellCache){this._kdTree.has(n)||this._kdTree.set(n,new Map);for(const[s,i]of r){const o=this._getRdTreeItems(i),a=new Li(o.length);(t=this._kdTree.get(n))==null||t.set(s,{tree:a,items:o});for(const l of o)a.add(l.x,l.y);a.finish()}}}closeKdTree(){var t;for(const[n,r]of this._oneCellCache)for(const[s,i]of r)(t=this._kdTree.get(n))==null||t.set(s,void 0)}insert(t){const{unitId:n,sheetId:r,range:s,id:i}=t;if(!n||n.length===0)return;let{startRow:o,endRow:a,startColumn:l,endColumn:u}=s;if(this._enableOneCellCache&&o===a&&l===u){this._insertOneCellCache(n,r,o,l,i);return}const c=this.getTree(n,r);Number.isNaN(o)&&(o=0),Number.isNaN(l)&&(l=0),Number.isNaN(a)&&(a=Number.POSITIVE_INFINITY),Number.isNaN(u)&&(u=Number.POSITIVE_INFINITY),c.insert({minX:l,minY:o,maxX:u,maxY:a,id:i})}bulkInsert(t){for(const n of t)this.insert(n)}*searchGenerator(t){var a;const{unitId:n,sheetId:r,range:s}=t;if(this._enableOneCellCache){const l=this._searchByOneCellCache(t);for(const u of l)yield u}const i=(a=this._tree.get(n))==null?void 0:a.get(r);if(!i)return;const o=i.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(const l of o)yield l.id}bulkSearch(t,n){const r=new Set;for(const s of t)for(const i of this.searchGenerator(s))(n==null?void 0:n.has(i))!==!0&&r.add(i);return r}removeById(t,n){var r,s;n?((r=this._tree.get(t))==null||r.delete(n),(s=this._oneCellCache.get(t))==null||s.delete(n)):(this._tree.delete(t),this._oneCellCache.delete(t))}_removeRTreeItem(t){const{unitId:n,sheetId:r,range:s,id:i}=t,o=this.getTree(n,r),a=o.search({minX:s.startColumn,minY:s.startRow,maxX:s.endColumn,maxY:s.endRow});for(let l=0;l<a.length;l++)a[l].id===i&&o.remove(a[l])}remove(t){const{unitId:n,sheetId:r,range:s,id:i}=t,{startRow:o,startColumn:a,endRow:l,endColumn:u}=s;this._enableOneCellCache?o===l&&a===u?this._removeOneCellCache(n,r,s.startRow,s.startColumn,i):(this._removeCellCacheByRange(t),this._removeRTreeItem(t)):this._removeRTreeItem(t)}bulkRemove(t){for(const n of t)this.remove(n)}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){const t={};return this._tree.forEach((n,r)=>{t[r]={},n.forEach((s,i)=>{t[r][i]=s.toJSON()})}),t}fromJSON(t){this._tree.clear();for(const n in t){this._tree.set(n,new Map);for(const r in t[n]){const s=new zr;s.fromJSON(t[n][r]),this._tree.get(n).set(r,s)}}}}var r0=Object.getOwnPropertyDescriptor,s0=(e,t,n,r)=>{for(var s=r>1?void 0:r?r0(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=o(s)||s);return s},$o=(e,t)=>(n,r)=>t(n,r,e);let si=class extends st{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){const e=n=>{n.businesses.forEach(r=>{switch(r){case Be.UNRECOGNIZED:case Be.UNIVER_UNKNOWN:case Be.UNIVER_SLIDE:case Be.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType(Be.UNIVER_DOC).forEach(s=>{const o=(s.getSnapshot().resources||[]).find(a=>a.name===n.pluginName);if(o)try{const a=n.parseJson(o.data);n.onLoad(s.getUnitId(),a)}catch{console.error(`Load Document{${s.getUnitId()}} Resources{${n.pluginName}} Data Error.`)}});break}case Be.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(Be.UNIVER_SHEET).forEach(s=>{const o=(s.getSnapshot().resources||[]).find(a=>a.name===n.pluginName);if(o)try{const a=n.parseJson(o.data);n.onLoad(s.getUnitId(),a)}catch{console.error(`Load Workbook{${s.getUnitId()}} Resources{${n.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(n=>e(n)),this.disposeWithMe(this._resourceManagerService.register$.subscribe(n=>e(n))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(Be.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(Be.UNIVER_DOC).subscribe(n=>{const r=n.getUnitId();Ba(r)||this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(Be.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(Be.UNIVER_DOC).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())}))}saveUnit(e){const t=this._univerInstanceService.getUnit(e);if(!t)return null;const n=this._resourceManagerService.getResources(e,t.type),r=ne.deepClone(t.getSnapshot());return r.resources=n,r}};si=s0([$o(0,je.Inject(us)),$o(1,je.Inject(Mn))],si);class i0{constructor(t={},n){C(this,"_startedTypes",new Set);C(this,"_injector");C(this,"_disposingCallbacks",new Zr);const r=this._injector=o0(n,t==null?void 0:t.override),{theme:s,darkMode:i,locale:o,locales:a,logLevel:l}=t;s&&this._injector.get(qr).setTheme(s),i&&this._injector.get(qr).setDarkMode(i),a&&this._injector.get(ln).load(a),o&&this._injector.get(ln).setLocale(o),l&&this._injector.get(Ot).setLogLevel(l),this._init(r)}get _univerInstanceService(){return this._injector.get(Mn)}get _pluginService(){return this._injector.get(exports.PluginService)}__getInjector(){return this._injector}onDispose(t){const n=this._disposingCallbacks.add(nt(t));return nt(()=>n.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(t){this._injector.get(ln).setLocale(t)}createUnit(t,n){return this._univerInstanceService.createUnit(t,n)}createUniverSheet(t){return this._injector.get(Ot).warn("[Univer]","Univer.createUniverSheet is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(Be.UNIVER_SHEET,t)}createUniverDoc(t){return this._injector.get(Ot).warn("[Univer]","Univer.createUniverDoc is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(Be.UNIVER_DOC,t)}createUniverSlide(t){return this._injector.get(Ot).warn("[Univer]","Univer.createUniverSlide is deprecated, use createUnit instead"),this._univerInstanceService.createUnit(Be.UNIVER_SLIDE,t)}_init(t){this._univerInstanceService.registerCtorForType(Be.UNIVER_SHEET,exports.Workbook),this._univerInstanceService.registerCtorForType(Be.UNIVER_DOC,Mt),this._univerInstanceService.registerCtorForType(Be.UNIVER_SLIDE,yi);const n=t.get(Mn);n.__setCreateHandler((r,s,i,o)=>{if(!this._startedTypes.has(r)){this._pluginService.startPluginsForType(r),this._startedTypes.add(r);const l=t.createInstance(i,s);return n.__addUnit(l,o),this._tryProgressToReady(),l}const a=t.createInstance(i,s);return n.__addUnit(a,o),a})}_tryProgressToReady(){this._injector.get(exports.LifecycleService).stage<Je.Ready&&(this._injector.get(exports.LifecycleService).stage=Je.Ready)}registerPlugin(t,n){this._pluginService.registerPlugin(t,n)}}function o0(e,t){const n=Yu([[bu],[ln],[qr],[exports.LifecycleService],[exports.PluginService],[tr],[Mn,{useClass:exports.UniverInstanceService}],[Hu,{useClass:ju}],[Ot,{useClass:Xo,lazy:!0}],[ir,{useClass:exports.CommandService}],[cs,{useClass:exports.LocalUndoRedoService,lazy:!0}],[Ti,{useClass:vu}],[Dn,{useClass:Vo}],[us,{useClass:exports.ResourceManagerService,lazy:!0}],[ti,{useClass:si,lazy:!0}],[Iu,{useClass:exports.AuthzIoLocalService}],[Su,{useClass:exports.MentionIOLocalService,lazy:!0}]],t),r=e?e.createChild(n):new je.Injector(n);return Yo(r,[[tr],[ti]]),r}function ac(e){return e.map(t=>t/255)}function lc(e){return e.map(t=>Math.round(t*255))}const It=[[.333,-.667,-.667,0,1],[-.667,.333,-.667,0,1],[-.667,-.667,.333,0,1],[0,0,0,1,0]];function a0(e){const t=e[0],n=e[1],r=e[2];let s=[It[0][0]*t+It[0][1]*n+It[0][2]*r+It[0][4],It[1][0]*t+It[1][1]*n+It[1][2]*r+It[1][4],It[2][0]*t+It[2][1]*n+It[2][2]*r+It[2][4]];return s=s.map(i=>i>1?1:i<0?0:i),s}function l0(e){return lc(a0(ac(e)))}function u0([e,t,n]){const r=Math.max(e,t,n),s=Math.min(e,t,n),i=(r+s)/2;let o=0,a=0;if(r!==s){const l=r-s;switch(a=i>.5?l/(2-r-s):l/(r+s),r){case e:o=(t-n)/l+(t<n?6:0);break;case t:o=(n-e)/l+2;break;case n:o=(e-t)/l+4;break}o/=6}return[o,a,i]}function Jr(e,t,n){const r=[e,t,n].map(s=>s<=.03928?s/12.92:((s+.055)/1.055)**2.4);return .2126*r[0]+.7152*r[1]+.0722*r[2]}function Ho(e,t){return(Math.max(e,t)+.05)/(Math.min(e,t)+.05)}function c0(e,t,n){let r,s,i;if(t===0)r=s=i=n;else{const o=(u,c,h)=>{let d=h;return d<0&&(d+=1),d>1&&(d-=1),d<.16666666666666666?u+(c-u)*6*d:d<.5?c:d<.6666666666666666?u+(c-u)*(.6666666666666666-d)*6:u},a=n<.5?n*(1+t):n+t-n*t,l=2*n-a;r=o(l,a,e+1/3),s=o(l,a,e),i=o(l,a,e-1/3)}return[r,s,i]}const ys={r:1,g:1,b:1},Ns={r:0,g:0,b:0},h0=Jr(ys.r,ys.g,ys.b),d0=Jr(Ns.r,Ns.g,Ns.b);function f0(e){const t=Jr(e[0],e[1],e[2]),n=Ho(h0,t),r=u0(e);let s=1-r[2],i,o,a;do i=c0(r[0],r[1],s),o=Jr(i[0],i[1],i[2]),a=Ho(o,d0),s+=.01;while(s<=1&&s>=0&&Math.abs(a-n)<.01);return i}function g0(e){return lc(f0(ac(e)))}gc();exports.ABCToNumber=rf;exports.AUTO_HEIGHT_FOR_MERGED_CELLS=Fa;exports.AbsoluteRefType=tt;exports.ActionIterator=Rn;exports.AlignTypeH=ll;exports.AlignTypeV=ul;exports.ArrangeTypeEnum=dl;exports.ArrowsAndMarkersShapes=da;exports.AsyncInterceptorManager=Up;exports.AsyncLock=C_;exports.AutoFillSeries=ta;exports.BaselineOffset=Ft;exports.BasicShapes=ha;exports.BlockType=ja;exports.BooleanNumber=Ie;exports.BorderStyleTypes=Xe;exports.BorderType=na;exports.BuildTextUtils=ot;exports.BulletAlignment=lr;exports.COLORS=Us;exports.CanceledError=Sc;exports.CellModeEnum=Sn;exports.CellValueType=Xt;exports.Color=cn;exports.ColorBuilder=ts;exports.ColorKit=Tt;exports.ColorType=vt;exports.ColumnSeparatorType=za;exports.CommandType=sr;exports.CommonHideTypes=ra;exports.ConfigService=vu;exports.ContextService=Vo;exports.CopyPasteType=sa;exports.CustomCommandExecutionError=Ms;exports.CustomDecorationType=on;exports.CustomRangeType=Zt;exports.DEFAULT_CELL=Ld;exports.DEFAULT_DOC=Oi;exports.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=jp;exports.DEFAULT_EMPTY_DOCUMENT_VALUE=Pa;exports.DEFAULT_RANGE=Md;exports.DEFAULT_RANGE_ARRAY=Nd;exports.DEFAULT_SELECTION=Dd;exports.DEFAULT_SLIDE=_l;exports.DEFAULT_STYLES=ut;exports.DEFAULT_WORKSHEET_COLUMN_COUNT=Du;exports.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=pE;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Pu;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=IE;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH=xu;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=CE;exports.DEFAULT_WORKSHEET_ROW_COUNT=Mu;exports.DEFAULT_WORKSHEET_ROW_COUNT_KEY=_E;exports.DEFAULT_WORKSHEET_ROW_HEIGHT=Lu;exports.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=EE;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=Uu;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=RE;exports.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=li;exports.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=ai;exports.DOCS_ZEN_EDITOR_UNIT_ID_KEY=Ua;exports.DOC_DRAWING_PRINTING_COMPONENT_KEY=Fd;exports.DOC_RANGE_TYPE=Aa;exports.DashStyleType=Ja;exports.DataStreamTreeNodeType=Sl;exports.DataStreamTreeTokenType=_t;exports.DataValidationErrorStyle=Zu;exports.DataValidationImeMode=Qu;exports.DataValidationOperator=ec;exports.DataValidationRenderMode=tc;exports.DataValidationStatus=nc;exports.DataValidationType=rc;exports.DeleteDirection=ia;exports.DependentOn=BE;exports.DesktopLogService=Xo;exports.DeveloperMetadataVisibility=oa;exports.Dimension=aa;exports.Direction=la;exports.Disposable=st;exports.DisposableCollection=Zr;exports.DocStyleType=$a;exports.DocumentDataModel=Mt;exports.DocumentFlavor=ui;exports.DrawingTypeEnum=fl;exports.EDITOR_ACTIVATED=Ou;exports.EXTENSION_NAMES=pl;exports.ErrorService=bu;exports.EventState=Ru;exports.EventSubject=Wp;exports.FOCUSING_COMMON_DRAWINGS=rE;exports.FOCUSING_DOC=Gn;exports.FOCUSING_EDITOR_BUT_HIDDEN=Jp;exports.FOCUSING_EDITOR_INPUT_FORMULA=Zp;exports.FOCUSING_EDITOR_STANDALONE=eE;exports.FOCUSING_FX_BAR_EDITOR=wu;exports.FOCUSING_PANEL_EDITOR=tE;exports.FOCUSING_SHEET=wn;exports.FOCUSING_SLIDE=Vn;exports.FOCUSING_UNIT=zn;exports.FOCUSING_UNIVER_EDITOR=Qp;exports.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=nE;exports.FORMULA_EDITOR_ACTIVATED=sE;exports.FollowNumberWithType=Ha;exports.FontItalic=Hr;exports.FontStyleType=vn;exports.FontWeight=jr;exports.GridType=Wa;exports.HLSColor=Sa;exports.HorizontalAlign=yt;exports.IAuthzIoService=Iu;exports.ICommandService=ir;exports.IConfigService=Ti;exports.IContextService=Dn;exports.IImageIoService=ni;exports.ILocalStorageService=xE;exports.ILogService=Ot;exports.IMentionIOService=Su;exports.IPermissionService=Hu;exports.IResourceLoaderService=ti;exports.IResourceManagerService=us;exports.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=ka;exports.IUndoRedoService=cs;exports.IUniverInstanceService=Mn;exports.ImageCacheMap=Ju;exports.ImageSourceType=Mi;exports.ImageUploadStatusType=qu;exports.InterceptorEffectEnum=On;exports.InterceptorManager=Dp;exports.InterpolationPointType=ua;exports.JSON1=T_;exports.JSONX=$t;exports.LRUHelper=jn;exports.LRUMap=Zn;exports.LifecycleStages=Je;exports.ListGlyphType=Ne;exports.LocaleService=ln;exports.LocaleType=or;exports.LogLevel=Ko;exports.MOVE_BUFFER_VALUE=Hn;exports.MemoryCursor=fn;exports.MentionType=$r;exports.NAMED_STYLE_MAP=Ud;exports.NAMED_STYLE_SPACE_MAP=Pd;exports.NamedStyleType=rt;exports.NilCommand=qo;exports.NumberUnitType=al;exports.ObjectMatrix=Et;exports.ObjectRelativeFromH=il;exports.ObjectRelativeFromV=ol;exports.OtherShapes=fa;exports.PAGE_SIZE=Bd;exports.PAPER_TYPES=yd;exports.PRESET_LIST_TYPE=dr;exports.PRINT_CHART_COMPONENT_KEY=kd;exports.PageElementType=gl;exports.PageOrientType=hl;exports.PageType=ci;exports.PaperType=pt;exports.ParagraphElementType=Va;exports.ParagraphStyleBuilder=er;exports.ParagraphStyleValue=gr;exports.PermissionService=ju;exports.PermissionStatus=Ni;exports.Plugin=ei;exports.PositionedObjectLayoutType=Xa;exports.PresetListType=Ut;exports.ProtectionType=ca;exports.QuickListType=iu;exports.QuickListTypeMap=x_;exports.RANGE_DIRECTION=ba;exports.RANGE_TYPE=Le;exports.RBush=zr;exports.RCDisposable=bc;exports.RGBA_PAREN=nh;exports.RGB_PAREN=th;exports.ROTATE_BUFFER_VALUE=ea;exports.RTree=n0;exports.Range=Tn;exports.Rectangle=Qt;exports.RedoCommand=Xu;exports.RedoCommandId=Gu;exports.RefAlias=nf;exports.Registry=bi;exports.RegistryAsMap=Ai;exports.RelativeDate=ma;exports.RelativeSlideLink=ml;exports.RgbColor=Wr;exports.RichTextBuilder=an;exports.RichTextValue=Kt;exports.RxDisposable=wc;exports.SHEET_EDITOR_UNITS=xd;exports.SectionType=Ya;exports.SheetTypes=_a;exports.SheetViewModel=Fu;exports.SliceBodyType=vi;exports.SlideDataModel=yi;exports.SpacingRule=qa;exports.SpecialShapes=ga;exports.Styles=Au;exports.THEME_COLORS=Ia;exports.TabStopAlignment=Za;exports.TableAlignmentType=el;exports.TableLayoutType=tl;exports.TableRowHeightRule=rl;exports.TableSizeType=Qa;exports.TableTextWrapType=nl;exports.TextDecoration=pa;exports.TextDecorationBuilder=Vt;exports.TextDirection=Jn;exports.TextDirectionType=Ga;exports.TextStyleBuilder=Jt;exports.TextStyleValue=fr;exports.TextX=Ye;exports.TextXActionType=he;exports.ThemeColor=Yr;exports.ThemeColorType=ft;exports.ThemeColors=es;exports.ThemeService=qr;exports.Tools=ne;exports.UndoCommand=Ku;exports.UndoCommandId=Vu;exports.UnitModel=ls;exports.Univer=i0;exports.UniverInstanceType=Be;exports.UpdateDocsAttributeType=xe;exports.UserManagerService=tr;exports.VerticalAlign=sn;exports.VerticalAlignmentType=sl;exports.Worksheet=nr;exports.WrapStrategy=un;exports.WrapTextType=Ka;exports.addLinkToDocumentModel=Tu;exports.afterInitApply=Pc;exports.afterTime=xc;exports.awaitTime=VE;exports.binSearchFirstGreaterThanTarget=Qo;exports.binarySearchArray=kc;exports.bufferDebounceTime=Lc;exports.cellToRange=Mh;exports.characterSpacingControlType=cl;exports.checkForSubstrings=Lh;exports.checkIfMove=Bc;exports.checkParagraphHasBullet=md;exports.checkParagraphHasIndent=_d;exports.checkParagraphHasIndentByStyle=Da;exports.codeToBlob=Fc;exports.composeBody=Xs;exports.composeInterceptors=Eu;exports.composeStyles=Ls;exports.concatMatrixArray=Rh;exports.convertBodyToHtml=eh;exports.convertCellToRange=Ta;exports.convertObservableToBehaviorSubject=Uc;exports.covertCellValue=$s;exports.covertCellValues=Dh;exports.covertTextRunToHtml=xs;exports.createAsyncInterceptorKey=Lp;exports.createDefaultUser=Xr;exports.createDocumentModelWithStyle=Kn;exports.createInterceptorKey=Mp;exports.createInternalEditorID=Td;exports.createRowColIter=Hs;exports.dayjs=Ht;exports.debounce=i_;exports.dedupe=mc;exports.dedupeBy=_c;exports.deepCompare=oi;exports.delayAnimationFrame=KE;exports.deleteContent=xa;exports.extractPureTextFromCell=Bu;exports.fromCallback=Jo;exports.fromEventSubject=Yp;exports.fromObservable=Oc;exports.generateRandomId=Bt;exports.get=$l;exports.getArrayLength=qt;exports.getBodySlice=Nt;exports.getBodySliceHtml=yr;exports.getBorderStyleType=Th;exports.getCellCoordByIndexSimple=Di;exports.getCellInfoInMergeData=Ch;exports.getCellPositionByIndexSimple=t0;exports.getCellValueType=_h;exports.getCellWithCoordByIndexCore=In;exports.getColorStyle=Lt;exports.getCustomBlockSlice=uu;exports.getCustomDecorationSlice=hu;exports.getCustomRangeSlice=cu;exports.getDocsUpdateBody=yh;exports.getIntersectRange=Cl;exports.getOriginCellValue=vE;exports.getParagraphsSlice=lu;exports.getPlainText=rs;exports.getReverseDirection=$c;exports.getSectionBreakSlice=W_;exports.getTableSlice=au;exports.getTextRunSlice=Kr;exports.getTransformOffsetX=sc;exports.getTransformOffsetY=ic;exports.getWorksheetUID=AE;exports.groupBy=Cc;exports.handleStyleToString=Ah;exports.hashAlgorithm=Ed;exports.horizontalLineSegmentsSubtraction=ns;exports.insertMatrixArray=Ps;exports.insertTextToContent=La;exports.invertColorByHSL=g0;exports.invertColorByMatrix=l0;exports.isBlackColor=gh;exports.isBooleanString=m_;exports.isCellCoverable=Bs;exports.isCellV=wa;exports.isEmptyCell=ya;exports.isFormulaId=bh;exports.isFormulaString=Na;exports.isICellData=Oa;exports.isInternalEditorID=Ba;exports.isNodeEnv=Qc;exports.isNotNullOrUndefined=yu;exports.isNullCell=ph;exports.isNumeric=Cu;exports.isRangesEqual=lE;exports.isRealNum=pd;exports.isSafeNumeric=kp;exports.isSameStyleTextRun=Ma;exports.isUnitRangesEqual=uE;exports.isValidRange=Nh;exports.isWhiteColor=mh;exports.makeArray=Rc;exports.makeCellRangeToRangeData=wh;exports.makeCellToSelection=Oh;exports.makeCustomRangeStream=cf;exports.merge=Ci;exports.mergeOverrideWithDependencies=Yu;exports.mergeSets=$p;exports.mergeWith=u_;exports.mergeWorksheetSnapshotWithDefault=ku;exports.mixinClass=Pp;exports.moveMatrixArray=Fs;exports.moveRangeByOffset=Gd;exports.nameCharacterCheck=GE;exports.normalizeBody=Y_;exports.normalizeTextRuns=hr;exports.numberToABC=of;exports.numberToListABC=af;exports.numfmt=Ad;exports.queryObjectMatrix=tf;exports.registerDependencies=Ic;exports.remove=rr;exports.repeatStringNumTimes=Il;exports.replaceInDocumentBody=Hp;exports.requestImmediateMacroTask=Bp;exports.rotate=Ec;exports.searchArray=$n;exports.searchInOrderedArray=Zo;exports.selectionToArray=Eh;exports.sequence=Go;exports.sequenceAsync=zo;exports.sequenceExecute=Qr;exports.sequenceExecuteAsync=Dc;exports.set=h_;exports.shallowEqual=Yl;exports.skipParseTagNames=XE;exports.sliceMatrixArray=Ih;exports.sortRules=lf;exports.sortRulesByDesc=uf;exports.sortRulesFactory=ur;exports.spliceArray=ks;exports.splitIntoGrid=hi;exports.takeAfter=Ds;exports.textDiff=Ri;exports.throttle=Np;exports.toDisposable=nt;exports.touchDependencies=Yo;exports.updateAttributeByDelete=du;exports.updateAttributeByInsert=fu;exports.willLoseNumericPrecision=Fp;Object.keys(je).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>je[e]})});
|