@univerjs/core 0.1.0-beta.5 → 0.1.1
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 +2 -1
- package/lib/es/index.js +438 -431
- package/lib/types/docs/data-model/document-data-model.d.ts +3 -2
- package/lib/types/services/lifecycle/lifecycle.d.ts +1 -1
- package/lib/types/sheets/__tests__/ranges.spec.d.ts +16 -0
- package/lib/types/sheets/range.d.ts +3 -2
- package/lib/types/types/interfaces/i-selection-data.d.ts +1 -0
- package/lib/umd/index.js +2 -1
- package/package.json +2 -2
package/lib/cjs/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";var kn=Object.defineProperty;var $n=(t,e,s)=>e in t?kn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var h=(t,e,s)=>($n(t,typeof e!="symbol"?e+"":e,s),s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("@wendellhu/redi"),A=require("rxjs"),Vn=require("rxjs/operators");function jn(){Kn()}const Et=typeof global<"u"?global:typeof self<"u"?self:window;function Kn(){typeof Et.requestIdleCallback!="function"&&(Et.requestIdleCallback=function(s){const n=Date.now();return setTimeout(function(){const i=Math.max(0,50-(Date.now()-n));s({didTimeout:i===0,timeRemaining(){return i}})},1)}),typeof Et.cancelIdleCallback!="function"&&(Et.cancelIdleCallback=function(s){clearTimeout(s)})}class ie{constructor(){h(this,"_data",[])}static create(){return new ie}add(e){this._data.indexOf(e)>-1||this._data.push(e)}delete(e){const s=this._data.indexOf(e);this._data.splice(s,1)}getData(){return this._data}}class oe{constructor(){h(this,"_data",new Map)}static create(){return new oe}add(e,s){this._data.has(e)||this._data.set(e,s)}delete(e){this._data.delete(e)}getData(){return this._data}}var w=(t=>(t[t.Univer=0]="Univer",t[t.Doc=1]="Doc",t[t.Sheet=2]="Sheet",t[t.Slide=3]="Slide",t))(w||{});class He{constructor(e){h(this,"_name");this._name=e}onStarting(e){}onReady(){}onRendered(){}onSteady(){}onDestroy(){}getPluginName(){return this._name}}h(He,"type",0);class Yn{constructor(){h(this,"_plugins",[])}addPlugin(e){this._plugins.push(e)}removePlugins(){const e=this._plugins.slice();return this._plugins.length=0,e}forEachPlugin(e){this._plugins.forEach(e)}}class zn{constructor(){h(this,"_pluginsRegisteredByBusiness",new Map)}registerPlugin(e,s){const n=e.type;this._pluginsRegisteredByBusiness.has(n)||this._pluginsRegisteredByBusiness.set(n,[]),this._pluginsRegisteredByBusiness.get(n).push({plugin:e,options:s})}getRegisterPlugins(e){return this._pluginsRegisteredByBusiness.get(e)||[]}clearPluginsOfType(e){this._pluginsRegisteredByBusiness.delete(e)}}function Y(t,e){const s=t.indexOf(e);return s>-1?(t.splice(s,1),!0):!1}function Xn(t){const e=new Set,s=[];for(const n of t)e.has(n)||(e.add(n),s.push(n));return s}function qn(t,e){for(let s=t.length-1;s>-1;s--){const n=t[s];if(e(n,s))return n}return null}async function Fe(t){for(const[e,s]of t.entries())try{if(!await s())return{index:e,result:!1}}catch(n){return{index:e,result:!1,error:n}}return{result:!0,index:-1}}function pe(t){for(const[e,s]of t.entries())try{if(!s())return{index:e,result:!1}}catch(n){return{index:e,result:!1,error:n}}return{result:!0,index:-1}}function Le(t){var e=typeof Symbol=="function"&&Symbol.iterator,s=e&&t[e],n=0;if(s)return s.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function be(t,e){var s=typeof Symbol=="function"&&t[Symbol.iterator];if(!s)return t;var n=s.call(t),r,i=[],o;try{for(;(e===void 0||e-- >0)&&!(r=n.next()).done;)i.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(s=n.return)&&s.call(n)}finally{if(o)throw o.error}}return i}function ve(t,e,s){if(s||arguments.length===2)for(var n=0,r=e.length,i;n<r;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}function ut(t){return typeof t=="function"}function Qn(t){var e=function(n){Error.call(n),n.stack=new Error().stack},s=t(e);return s.prototype=Object.create(Error.prototype),s.prototype.constructor=s,s}var Bt=Qn(function(t){return function(s){t(this),this.message=s?s.length+` errors occurred during unsubscription:
|
|
2
2
|
`+s.map(function(n,r){return r+1+") "+n.toString()}).join(`
|
|
3
3
|
`):"",this.name="UnsubscriptionError",this.errors=s}});function we(t,e){if(t){var s=t.indexOf(e);0<=s&&t.splice(s,1)}}var We=function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var e,s,n,r,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=Le(o),l=a.next();!l.done;l=a.next()){var c=l.value;c.remove(this)}}catch(R){e={error:R}}finally{try{l&&!l.done&&(s=a.return)&&s.call(a)}finally{if(e)throw e.error}}else o.remove(this);var u=this.initialTeardown;if(ut(u))try{u()}catch(R){i=R instanceof Bt?R.errors:[R]}var _=this._finalizers;if(_){this._finalizers=null;try{for(var d=Le(_),f=d.next();!f.done;f=d.next()){var E=f.value;try{De(E)}catch(R){i=i!=null?i:[],R instanceof Bt?i=ve(ve([],be(i)),be(R.errors)):i.push(R)}}}catch(R){n={error:R}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}}if(i)throw new Bt(i)}},t.prototype.add=function(e){var s;if(e&&e!==this)if(this.closed)De(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(s=this._finalizers)!==null&&s!==void 0?s:[]).push(e)}},t.prototype._hasParent=function(e){var s=this._parentage;return s===e||Array.isArray(s)&&s.includes(e)},t.prototype._addParent=function(e){var s=this._parentage;this._parentage=Array.isArray(s)?(s.push(e),s):s?[s,e]:e},t.prototype._removeParent=function(e){var s=this._parentage;s===e?this._parentage=null:Array.isArray(s)&&we(s,e)},t.prototype.remove=function(e){var s=this._finalizers;s&&we(s,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}();We.EMPTY;function Be(t){return t instanceof We||t&&"closed"in t&&ut(t.remove)&&ut(t.add)&&ut(t.unsubscribe)}function De(t){ut(t)?t():t.unsubscribe()}class Ge{constructor(e=!1){h(this,"skipNextObservers");h(this,"lastReturnValue");h(this,"isStopPropagation",!1);this.initialize(e)}initialize(e=!1){return this.skipNextObservers=e,this}stopPropagation(){this.isStopPropagation=!0}}function ke(t){return t instanceof Ut}class Ut{constructor(e,s){h(this,"_willBeUnregistered",!1);h(this,"unregisterOnNextCall",!1);this.callback=e,this.observable=s}dispose(){this.observable.remove(this)}}class Mt{constructor(e){h(this,"_observers",new Array);h(this,"_eventState");h(this,"_onObserverAdded");this._eventState=new Ge,e&&(this._onObserverAdded=e)}get observers(){return this._observers}add(e,s=!1,n=!1){if(!e)return null;const r=new Ut(e,this);return r.unregisterOnNextCall=n,s?this._observers.unshift(r):this._observers.push(r),this._onObserverAdded&&this._onObserverAdded(r),r}addOnce(e){return this.add(e,void 0,!0)}remove(e){return e&&this._observers.indexOf(e)!==-1?(this._deferUnregister(e),!0):!1}removeCallback(e){for(let s=0;s<this._observers.length;s++){const n=this._observers[s];if(!n._willBeUnregistered&&n.callback===e)return this._deferUnregister(n),!0}return!1}makeObserverTopPriority(e){this._remove(e),this._observers.unshift(e)}makeObserverBottomPriority(e){this._remove(e),this._observers.push(e)}notifyObservers(e){if(!this._observers.length)return null;const s=this._eventState;s.skipNextObservers=!1,s.lastReturnValue=e,s.isStopPropagation=!1;let n=!1;for(let r=0;r<this._observers.length;r++){const i=this._observers[r];if(!i._willBeUnregistered&&(s.lastReturnValue=i.callback(e,s),i.unregisterOnNextCall&&this._deferUnregister(i),s.isStopPropagation&&(n=!0),s.skipNextObservers))return{lastReturnValue:s.lastReturnValue,stopPropagation:n}}return{lastReturnValue:s.lastReturnValue,stopPropagation:n}}notifyObserversWithPromise(e){let s=Promise.resolve(e);if(!this._observers.length)return s;const n=this._eventState;n.skipNextObservers=!1;for(let r=0;r<this._observers.length;r++){const i=this._observers[r];n.skipNextObservers||i._willBeUnregistered||(s=s.then(()=>i.callback(e,n)),i.unregisterOnNextCall&&this._deferUnregister(i))}return s.then(()=>e)}notifyObserver(e,s){if(e._willBeUnregistered)return;const n=this._eventState;return n.skipNextObservers=!1,e.callback(s,n),e.unregisterOnNextCall&&this._deferUnregister(e),{lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}hasObservers(){return this._observers.length>0}clear(){this._observers=new Array,this._onObserverAdded=null}clone(){const e=new Mt;return e._observers=this._observers.slice(0),e}_deferUnregister(e){e.unregisterOnNextCall=!1,e._willBeUnregistered=!0,setTimeout(()=>{this._remove(e)},0)}_remove(e){if(!e)return!1;const s=this._observers.indexOf(e);return s!==-1?(this._observers.splice(s,1),!0):!1}}function L(t){let e=!1;return Be(t)?{dispose:()=>{e||(e=!0,t.unsubscribe())}}:ke(t)?{dispose:()=>{e||(e=!0,t.dispose())}}:{dispose:()=>{e||(e=!0,t())}}}function Jn(t){return L(()=>{t.unsubscribe()})}class ae{constructor(){h(this,"_disposables",new Set)}add(e){return this._disposables.add(e),{dispose:()=>{e.dispose(),this._disposables.delete(e)}}}dispose(){this._disposables.forEach(e=>{e.dispose(),this._disposables.delete(e)})}}class U{constructor(){h(this,"_disposed",!1);h(this,"_collection",new ae)}disposeWithMe(e){const s=Be(e)?L(e):e;return this._collection.add(s)}dispose(){this._disposed||(this._disposed=!0,this._collection.dispose())}}class Zn extends U{constructor(){super(...arguments);h(this,"dispose$",new A.Subject)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}}const tt=I.createIdentifier("univer.context-service");class $e extends U{constructor(){super(...arguments);h(this,"_contextChanged$",new A.Subject);h(this,"contextChanged$",this._contextChanged$.asObservable());h(this,"_contextMap",new Map)}dispose(){super.dispose(),this._contextChanged$.complete()}getContextValue(s){var n;return(n=this._contextMap.get(s))!=null?n:!1}setContextValue(s,n){this._contextMap.set(s,n),this._contextChanged$.next({[s]:n})}subscribeContextValue$(s){return new A.Observable(n=>{const r=this._contextChanged$.pipe(A.filter(i=>typeof i[s]<"u")).subscribe(i=>n.next(i[s]));return this._contextMap.has(s)&&n.next(this._contextMap.get(s)),()=>r.unsubscribe()})}}var Ve=(t=>(t[t.SILENT=0]="SILENT",t[t.ERROR=1]="ERROR",t[t.WARN=2]="WARN",t[t.INFO=3]="INFO",t[t.VERBOSE=4]="VERBOSE",t))(Ve||{});const q=I.createIdentifier("univer.log");class je extends U{constructor(){super(...arguments);h(this,"_logLevel",3)}debug(...s){this._logLevel>=4&&this._log(console.debug,...s)}log(...s){this._logLevel>=3&&this._log(console.log,...s)}warn(...s){this._logLevel>=2&&this._log(console.warn,...s)}error(...s){this._logLevel>=1&&this._log(console.error,...s)}setLogLevel(s){this._logLevel=s}_log(s,...n){const r=n[0];/^\[(.*?)\]/g.test(r)?s(`\x1B[97;104m${r}\x1B[0m`,...n.slice(1)):s(...n)}}var yn=Object.defineProperty,tr=Object.getOwnPropertyDescriptor,er=(t,e,s,n)=>{for(var r=n>1?void 0:n?tr(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&yn(e,s,r),r},Te=(t,e)=>(s,n)=>e(s,n,t),Pt=(t=>(t[t.COMMAND=0]="COMMAND",t[t.OPERATION=1]="OPERATION",t[t.MUTATION=2]="MUTATION",t))(Pt||{});const ft=I.createIdentifier("anywhere.command-service");class sr{constructor(){h(this,"_commands",new Map)}registerCommand(e){if(this._commands.has(e.id))throw new Error(`[CommandRegistry]: command "${e.id}" has been registered before.`);return this._commands.set(e.id,e),L(()=>{var s;this._commands.delete(e.id),(s=e.onDispose)==null||s.call(e)})}getCommand(e){return this._commands.has(e)?[this._commands.get(e)]:null}}exports.CommandService=class{constructor(e,s){h(this,"_commandRegistry");h(this,"_beforeCommandExecutionListeners",[]);h(this,"_commandExecutedListeners",[]);h(this,"_multiCommandDisposables",new Map);h(this,"_commandExecutingLevel",0);h(this,"_commandExecutionStack",[]);this._injector=e,this._logService=s,this._commandRegistry=new sr,this._registerCommand(Ke)}registerCommand(e){return this._registerCommand(e)}registerMultipleCommand(e){return this._registerMultiCommand(e)}beforeCommandExecuted(e){if(this._beforeCommandExecutionListeners.indexOf(e)===-1)return this._beforeCommandExecutionListeners.push(e),L(()=>{const s=this._beforeCommandExecutionListeners.indexOf(e);this._beforeCommandExecutionListeners.splice(s,1)});throw new Error("[CommandService]: could not add a listener twice.")}onCommandExecuted(e){if(this._commandExecutedListeners.indexOf(e)===-1)return this._commandExecutedListeners.push(e),L(()=>{const s=this._commandExecutedListeners.indexOf(e);this._commandExecutedListeners.splice(s,1)});throw new Error("[CommandService]: could not add a listener twice.")}async executeCommand(e,s,n){const r=this._commandRegistry.getCommand(e);if(r){const[i]=r,o={id:i.id,type:i.type,params:s},a=this._pushCommandExecutionStack(o);this._beforeCommandExecutionListeners.forEach(c=>c(o,n));const l=await this._execute(i,s);return this._commandExecutedListeners.forEach(c=>c(o,n)),a.dispose(),l}throw new Error(`[CommandService]: command "${e}" is not registered.`)}syncExecuteCommand(e,s,n){var i;const r=this._commandRegistry.getCommand(e);if(r){const[o]=r,a={id:o.id,type:o.type,params:s};if(o.type===2){const u=qn(this._commandExecutionStack,_=>_.type===0);u&&(a.params=(i=a.params)!=null?i:{},a.params.trigger=u.id)}const l=this._pushCommandExecutionStack(a);this._beforeCommandExecutionListeners.forEach(u=>u(a,n));const c=this._syncExecute(o,s);return this._commandExecutedListeners.forEach(u=>u(a,n)),l.dispose(),c}throw new Error(`[CommandService]: command "${e}" is not registered.`)}_pushCommandExecutionStack(e){return this._commandExecutionStack.push(e),L(()=>Y(this._commandExecutionStack,e))}_registerCommand(e){return this._commandRegistry.registerCommand(e)}_registerMultiCommand(e){const s=this._commandRegistry.getCommand(e.id);let n;if(s){if(s[0].multi!==!0)throw new Error("Command has registered as a single command.");n=s[0]}else{const i=new ae;n=new nr(e.id),i.add(this._commandRegistry.registerCommand(n)),i.add(L(()=>{this._multiCommandDisposables.delete(e.id)})),this._multiCommandDisposables.set(e.id,i)}const r=n.registerImplementation(e);return L(()=>{var i;r.dispose(),n.hasImplementations()||(i=this._multiCommandDisposables.get(e.id))==null||i.dispose()})}async _execute(e,s){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(this._commandExecutingLevel,0))}executing command "${e.id}"`),this._commandExecutingLevel++;let n;try{n=await this._injector.invoke(e.handler,s),this._commandExecutingLevel--}catch(r){throw n=!1,this._commandExecutingLevel=0,r}return n}_syncExecute(e,s){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(0,this._commandExecutingLevel))}executing command "${e.id}".`),this._commandExecutingLevel++;let n;try{if(n=this._injector.invoke(e.handler,s),n instanceof Promise)throw new TypeError("[CommandService]: Command handler should not return a promise.");this._commandExecutingLevel--}catch(r){throw n=!1,this._commandExecutingLevel=0,r}return n}};exports.CommandService=er([Te(0,I.Inject(I.Injector)),Te(1,q)],exports.CommandService);class nr{constructor(e){h(this,"name");h(this,"multi",!0);h(this,"type",0);h(this,"priority",0);h(this,"_implementations",[]);h(this,"handler",async(e,s)=>{if(!this._implementations.length)return!1;const n=e.get(q),r=e.get(tt),i=e.get(I.Injector);for(const o of this._implementations){const a=o.command.preconditions;if((!a||a&&a(r))&&(n.debug("[MultiCommand]",`executing implementation "${o.command.name}".`),await i.invoke(o.command.handler,s)))return!0}return!1});this.id=e,this.name=e}registerImplementation(e){const s={command:e};return this._implementations.push(s),this._implementations.sort((n,r)=>r.command.priority-n.command.priority),L(()=>{var r;const n=this._implementations.indexOf(s);this._implementations.splice(n,1),(r=e.onDispose)==null||r.call(e)})}hasImplementations(){return this._implementations.length>0}}function le(t,e,s){const n=t.map(r=>()=>e.syncExecuteCommand(r.id,r.params,s));return pe(n)}function rr(t,e,s){const n=t.map(r=>()=>e.executeCommand(r.id,r.params,s));return Fe(n)}const Ke={id:"nil",type:0,handler:()=>!0},Ye=I.createIdentifier("univer.config-service");class ir{constructor(){h(this,"_config",new Map)}getConfig(e){return this._config.get(e)}setConfig(e,s){this._config.set(e,s)}deleteConfig(e){this._config.delete(e)}}class ze extends U{constructor(){super(...arguments);h(this,"_error$",new A.Subject);h(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(s){this._error$.next({errorKey:s})}}const or="__default_document_sub_component_id20231101__";class Xe{constructor(){h(this,"_managerInfo",new Map);h(this,"_remove$",new A.Subject);h(this,"remove$",this._remove$.asObservable());h(this,"_andOrUpdate$",new A.Subject);h(this,"andOrUpdate$",this._andOrUpdate$.asObservable());h(this,"_pluginUpdate$",new A.Subject);h(this,"pluginUpdate$",this._pluginUpdate$.asObservable())}getFloatObject(e){return this._getFloatingObject(e)}getFloatObjects(e){return this._getFloatingObjects(e)}dispose(){this._remove$.complete(),this._andOrUpdate$.complete(),this._pluginUpdate$.complete(),this._managerInfo.clear()}clear(e){const s=this._clearByParam(e);this._remove$.next(s)}addOrUpdate(e){const s=this._addByParam(e);this._andOrUpdate$.next(s)}BatchAddOrUpdate(e){const s=[];e.forEach(n=>{s.push(...this._addByParam(n))}),this._andOrUpdate$.next(s)}remove(e){const s=this._removeByParam(e);this._remove$.next(s)}pluginUpdateRefresh(e){this._pluginUpdate$.next(e)}_getFloatingObjects(e){var r;if(e==null)return;const{unitId:s,subUnitId:n}=e;return(r=this._managerInfo.get(s))==null?void 0:r.get(n)}_getFloatingObject(e){var i,o;if(e==null)return;const{unitId:s,subUnitId:n,floatingObjectId:r}=e;return(o=(i=this._managerInfo.get(s))==null?void 0:i.get(n))==null?void 0:o.get(r)}_addByParam(e){const{unitId:s,subUnitId:n,floatingObject:r,floatingObjectId:i}=e;this._managerInfo.has(s)||this._managerInfo.set(s,new Map);const o=this._managerInfo.get(s);return o.has(n)||o.set(n,new Map),o.get(n).set(i,r),[{unitId:s,subUnitId:n,floatingObjectId:i,floatingObject:r}]}_clearByParam(e){const s=this._getFloatingObjects(e),{unitId:n,subUnitId:r}=e,i=[];return s==null||s.forEach((o,a)=>{i.push({unitId:n,subUnitId:r,floatingObjectId:a,floatingObject:o})}),s==null||s.clear(),i}_removeByParam(e){const s=this._getFloatingObjects(e),n=s==null?void 0:s.get(e.floatingObjectId);return n==null?[]:(s==null||s.delete(e.floatingObjectId),[{...e,floatingObject:n}])}}const qe=I.createIdentifier("univer.floating-object.service");class Qe{constructor(){h(this,"cursor",0)}reset(){return this.cursor=0,this}moveCursor(e){this.cursor+=e}moveCursorTo(e){this.cursor=e}}function Je(t,e){let s=0,n=t.length-1;for(;s<=n;){const r=Math.floor((n+s)/2);if(e<t[r]&&(r===0||e>=t[r-1]))return r;if(e>=t[r])s=r+1;else if(e<t[r])n=r-1;else return-1}return-1}function Ze(t,e){let s=0,n=0,r=0,i=-1,o=t.length-1;for(;s<t.length&&o>=0&&o>=s;){if(n=t[o],o===0?r=0:r=t[o-1],e>=r&&e<=n){i=o;break}if(n=t[s],s===0?r=0:r=t[s-1],e>=r&&e<n){i=s;break}s++,o--}return i}function ar(t,e){let s=t.length-1;return e<0?-1:e<t[0]?0:e>t[t.length-1]?Number.POSITIVE_INFINITY:(t.length<40||e<=t[20]||e>=t[s-20]?s=Ze(t,e):s=Je(t,e),s)}function lr(t){const e=new Blob([t],{type:"text/javascript"});return window.URL.createObjectURL(e)}var ye=(t=>(t[t.DEFAULT_SERIES=0]="DEFAULT_SERIES",t[t.ALTERNATE_SERIES=1]="ALTERNATE_SERIES",t))(ye||{}),N=(t=>(t[t.NONE=0]="NONE",t[t.THIN=1]="THIN",t[t.HAIR=2]="HAIR",t[t.DOTTED=3]="DOTTED",t[t.DASHED=4]="DASHED",t[t.DASH_DOT=5]="DASH_DOT",t[t.DASH_DOT_DOT=6]="DASH_DOT_DOT",t[t.DOUBLE=7]="DOUBLE",t[t.MEDIUM=8]="MEDIUM",t[t.MEDIUM_DASHED=9]="MEDIUM_DASHED",t[t.MEDIUM_DASH_DOT=10]="MEDIUM_DASH_DOT",t[t.MEDIUM_DASH_DOT_DOT=11]="MEDIUM_DASH_DOT_DOT",t[t.SLANT_DASH_DOT=12]="SLANT_DASH_DOT",t[t.THICK=13]="THICK",t))(N||{}),ts=(t=>(t.TOP="top",t.BOTTOM="bottom",t.LEFT="left",t.RIGHT="right",t.NONE="none",t.ALL="all",t.OUTSIDE="outside",t.INSIDE="inside",t.HORIZONTAL="horizontal",t.VERTICAL="vertical",t.TLBR="tlbr",t.TLBC_TLMR="tlbc_tlmr",t.TLBR_TLBC_TLMR="tlbr_tlbc_tlmr",t.BLTR="bl_tr",t.MLTR_BCTR="mltr_bctr",t))(ts||{}),H=(t=>(t[t.UNSUPPORTED=0]="UNSUPPORTED",t[t.RGB=1]="RGB",t[t.HEX=2]="HEX",t[t.THEME=3]="THEME",t))(H||{}),es=(t=>(t[t.ON=0]="ON",t[t.OFF=1]="OFF",t))(es||{}),ss=(t=>(t[t.CONDITION_TYPE_UNSPECIFIED=0]="CONDITION_TYPE_UNSPECIFIED",t[t.NUMNUMBER_BETWEENR_GREATER=1]="NUMNUMBER_BETWEENR_GREATER",t[t.NUMBER_GREATER_THAN_EQ=2]="NUMBER_GREATER_THAN_EQ",t[t.NUMBER_LESS=3]="NUMBER_LESS",t[t.NUMBER_LESS_THAN_EQ=4]="NUMBER_LESS_THAN_EQ",t[t.NUMBER_EQ=5]="NUMBER_EQ",t[t.NUMBER_NOT_EQ=6]="NUMBER_NOT_EQ",t[t.NUMBER_BETWEEN=7]="NUMBER_BETWEEN",t[t.NUMBER_NOT_BETWEEN=8]="NUMBER_NOT_BETWEEN",t[t.TEXT_CONTAINS=9]="TEXT_CONTAINS",t[t.TEXT_NOT_CONTAINS=10]="TEXT_NOT_CONTAINS",t[t.TEXT_STARTS_WITH=11]="TEXT_STARTS_WITH",t[t.TEXT_ENDS_WITH=12]="TEXT_ENDS_WITH",t[t.TEXT_EQ=13]="TEXT_EQ",t[t.TEXT_IS_EMAIL=14]="TEXT_IS_EMAIL",t[t.TEXT_IS_URL=15]="TEXT_IS_URL",t[t.DATE_EQ=16]="DATE_EQ",t[t.DATE_BEFORE=17]="DATE_BEFORE",t[t.DATE_AFTER=18]="DATE_AFTER",t[t.DATE_ON_OR_BEFORE=19]="DATE_ON_OR_BEFORE",t[t.DATE_ON_OR_AFTER=20]="DATE_ON_OR_AFTER",t[t.DATE_BETWEEN=21]="DATE_BETWEEN",t[t.DATE_NOT_BETWEEN=22]="DATE_NOT_BETWEEN",t[t.DATE_IS_VALID=23]="DATE_IS_VALID",t[t.ONE_OF_RANGE=24]="ONE_OF_RANGE",t[t.ONE_OF_LIST=25]="ONE_OF_LIST",t[t.BLANK=26]="BLANK",t[t.NOT_BLANK=27]="NOT_BLANK",t[t.CUSTOM_FORMULA=28]="CUSTOM_FORMULA",t[t.BOOLEAN=29]="BOOLEAN",t[t.TEXT_NOT_EQ=30]="TEXT_NOT_EQ",t[t.DATE_NOT_EQ=31]="DATE_NOT_EQ",t))(ss||{}),ns=(t=>(t[t.PASTE_NORMAL=0]="PASTE_NORMAL",t[t.PASTE_NO_BORDERS=1]="PASTE_NO_BORDERS",t[t.PASTE_FORMAT=2]="PASTE_FORMAT",t[t.PASTE_FORMULA=3]="PASTE_FORMULA",t[t.PASTE_DATA_VALIDATION=4]="PASTE_DATA_VALIDATION",t[t.PASTE_VALUES=5]="PASTE_VALUES",t[t.PASTE_CONDITIONAL_FORMATTING=6]="PASTE_CONDITIONAL_FORMATTING",t[t.PASTE_COLUMN_WIDTHS=7]="PASTE_COLUMN_WIDTHS",t))(ns||{}),rs=(t=>(t[t.DOCUMENT=0]="DOCUMENT",t[t.PROJECT=1]="PROJECT",t))(rs||{}),is=(t=>(t[t.COLUMNS=0]="COLUMNS",t[t.ROWS=1]="ROWS",t))(is||{}),os=(t=>(t[t.UP=0]="UP",t[t.RIGHT=1]="RIGHT",t[t.DOWN=2]="DOWN",t[t.LEFT=3]="LEFT",t))(os||{});function ur(t){switch(t){case 3:return 1;case 1:return 3;case 0:return 2;case 2:return 0}}var as=(t=>(t[t.NUMBER_FORMAT_TYPE_UNSPECIFIED=0]="NUMBER_FORMAT_TYPE_UNSPECIFIED",t[t.TEXT=1]="TEXT",t[t.NUMBER=2]="NUMBER",t[t.PERCENT=3]="PERCENT",t[t.CURRENCY=4]="CURRENCY",t[t.DATE=5]="DATE",t[t.TIME=6]="TIME",t[t.DATE_TIME=7]="DATE_TIME",t[t.SCIENTIFIC=8]="SCIENTIFIC",t))(as||{}),ls=(t=>(t[t.INTERPOLATION_POINT_TYPE_UNSPECIFIED=0]="INTERPOLATION_POINT_TYPE_UNSPECIFIED",t[t.MIN=1]="MIN",t[t.MAX=2]="MAX",t[t.NUMBER=3]="NUMBER",t[t.PERCENT=4]="PERCENT",t[t.PERCENTILE=5]="PERCENTILE",t))(ls||{}),xt=(t=>(t.EN_US="enUS",t.ZH_CN="zhCN",t))(xt||{}),us=(t=>(t[t.RANGE=0]="RANGE",t[t.SHEET=1]="SHEET",t))(us||{}),cs=(t=>(t[t.RELATIVE_DATE_UNSPECIFIED=0]="RELATIVE_DATE_UNSPECIFIED",t[t.PAST_YEAR=1]="PAST_YEAR",t[t.PAST_MONTH=2]="PAST_MONTH",t[t.PAST_WEEK=3]="PAST_WEEK",t[t.YESTERDAY=4]="YESTERDAY",t[t.TODAY=5]="TODAY",t[t.TOMORROW=6]="TOMORROW",t))(cs||{}),hs=(t=>(t[t.TYPE_UNSPECIFIED=0]="TYPE_UNSPECIFIED",t[t.TEXT_BOX=1]="TEXT_BOX",t[t.RECTANGLE=2]="RECTANGLE",t[t.ROUND_RECTANGLE=3]="ROUND_RECTANGLE",t[t.ELLIPSE=4]="ELLIPSE",t[t.ARC=5]="ARC",t[t.BENT_ARROW=6]="BENT_ARROW",t[t.BENT_UP_ARROW=7]="BENT_UP_ARROW",t[t.BEVEL=8]="BEVEL",t[t.BLOCK_ARC=9]="BLOCK_ARC",t[t.BRACE_PAIR=10]="BRACE_PAIR",t[t.BRACKET_PAIR=11]="BRACKET_PAIR",t[t.CAN=12]="CAN",t[t.CHEVRON=13]="CHEVRON",t[t.CHORD=14]="CHORD",t[t.CLOUD=15]="CLOUD",t[t.CORNER=16]="CORNER",t[t.CUBE=17]="CUBE",t[t.CURVED_DOWN_ARROW=18]="CURVED_DOWN_ARROW",t[t.CURVED_LEFT_ARROW=19]="CURVED_LEFT_ARROW",t[t.CURVED_RIGHT_ARROW=20]="CURVED_RIGHT_ARROW",t[t.CURVED_UP_ARROW=21]="CURVED_UP_ARROW",t[t.DECAGON=22]="DECAGON",t[t.DIAGONAL_STRIPE=23]="DIAGONAL_STRIPE",t[t.DIAMOND=24]="DIAMOND",t[t.DODECAGON=25]="DODECAGON",t[t.DONUT=26]="DONUT",t[t.DOUBLE_WAVE=27]="DOUBLE_WAVE",t[t.DOWN_ARROW=28]="DOWN_ARROW",t[t.DOWN_ARROW_CALLOUT=29]="DOWN_ARROW_CALLOUT",t[t.FOLDED_CORNER=30]="FOLDED_CORNER",t[t.FRAME=31]="FRAME",t[t.HALF_FRAME=32]="HALF_FRAME",t[t.HEART=33]="HEART",t[t.HEPTAGON=34]="HEPTAGON",t[t.HEXAGON=35]="HEXAGON",t[t.HOME_PLATE=36]="HOME_PLATE",t[t.HORIZONTAL_SCROLL=37]="HORIZONTAL_SCROLL",t[t.IRREGULAR_SEAL_1=38]="IRREGULAR_SEAL_1",t[t.IRREGULAR_SEAL_2=39]="IRREGULAR_SEAL_2",t[t.LEFT_ARROW=40]="LEFT_ARROW",t[t.LEFT_ARROW_CALLOUT=41]="LEFT_ARROW_CALLOUT",t[t.LEFT_BRACE=42]="LEFT_BRACE",t[t.LEFT_BRACKET=43]="LEFT_BRACKET",t[t.LEFT_RIGHT_ARROW=44]="LEFT_RIGHT_ARROW",t[t.LEFT_RIGHT_ARROW_CALLOUT=45]="LEFT_RIGHT_ARROW_CALLOUT",t[t.LEFT_RIGHT_UP_ARROW=46]="LEFT_RIGHT_UP_ARROW",t[t.LEFT_UP_ARROW=47]="LEFT_UP_ARROW",t[t.LIGHTNING_BOLT=48]="LIGHTNING_BOLT",t[t.MATH_DIVIDE=49]="MATH_DIVIDE",t[t.MATH_EQUAL=50]="MATH_EQUAL",t[t.MATH_MINUS=51]="MATH_MINUS",t[t.MATH_MULTIPLY=52]="MATH_MULTIPLY",t[t.MATH_NOT_EQUAL=53]="MATH_NOT_EQUAL",t[t.MATH_PLUS=54]="MATH_PLUS",t[t.MOON=55]="MOON",t[t.NO_SMOKING=56]="NO_SMOKING",t[t.NOTCHED_RIGHT_ARROW=57]="NOTCHED_RIGHT_ARROW",t[t.OCTAGON=58]="OCTAGON",t[t.PARALLELOGRAM=59]="PARALLELOGRAM",t[t.PENTAGON=60]="PENTAGON",t[t.PIE=61]="PIE",t[t.PLAQUE=62]="PLAQUE",t[t.PLUS=63]="PLUS",t[t.QUAD_ARROW=64]="QUAD_ARROW",t[t.QUAD_ARROW_CALLOUT=65]="QUAD_ARROW_CALLOUT",t[t.RIBBON=66]="RIBBON",t[t.RIBBON_2=67]="RIBBON_2",t[t.RIGHT_ARROW=68]="RIGHT_ARROW",t[t.RIGHT_ARROW_CALLOUT=69]="RIGHT_ARROW_CALLOUT",t[t.RIGHT_BRACE=70]="RIGHT_BRACE",t[t.RIGHT_BRACKET=71]="RIGHT_BRACKET",t[t.ROUND_1_RECTANGLE=72]="ROUND_1_RECTANGLE",t[t.ROUND_2_DIAGONAL_RECTANGLE=73]="ROUND_2_DIAGONAL_RECTANGLE",t[t.ROUND_2_SAME_RECTANGLE=74]="ROUND_2_SAME_RECTANGLE",t[t.RIGHT_TRIANGLE=75]="RIGHT_TRIANGLE",t[t.SMILEY_FACE=76]="SMILEY_FACE",t[t.SNIP_1_RECTANGLE=77]="SNIP_1_RECTANGLE",t[t.SNIP_2_DIAGONAL_RECTANGLE=78]="SNIP_2_DIAGONAL_RECTANGLE",t[t.SNIP_2_SAME_RECTANGLE=79]="SNIP_2_SAME_RECTANGLE",t[t.SNIP_ROUND_RECTANGLE=80]="SNIP_ROUND_RECTANGLE",t[t.STAR_10=81]="STAR_10",t[t.STAR_12=82]="STAR_12",t[t.STAR_16=83]="STAR_16",t[t.STAR_24=84]="STAR_24",t[t.STAR_32=85]="STAR_32",t[t.STAR_4=86]="STAR_4",t[t.STAR_5=87]="STAR_5",t[t.STAR_6=88]="STAR_6",t[t.STAR_7=89]="STAR_7",t[t.STAR_8=90]="STAR_8",t[t.STRIPED_RIGHT_ARROW=91]="STRIPED_RIGHT_ARROW",t[t.SUN=92]="SUN",t[t.TRAPEZOID=93]="TRAPEZOID",t[t.TRIANGLE=94]="TRIANGLE",t[t.UP_ARROW=95]="UP_ARROW",t[t.UP_ARROW_CALLOUT=96]="UP_ARROW_CALLOUT",t[t.UP_DOWN_ARROW=97]="UP_DOWN_ARROW",t[t.UTURN_ARROW=98]="UTURN_ARROW",t[t.VERTICAL_SCROLL=99]="VERTICAL_SCROLL",t[t.WAVE=100]="WAVE",t[t.WEDGE_ELLIPSE_CALLOUT=101]="WEDGE_ELLIPSE_CALLOUT",t[t.WEDGE_RECTANGLE_CALLOUT=102]="WEDGE_RECTANGLE_CALLOUT",t[t.WEDGE_ROUND_RECTANGLE_CALLOUT=103]="WEDGE_ROUND_RECTANGLE_CALLOUT",t[t.FLOW_CHART_ALTERNATE_PROCESS=104]="FLOW_CHART_ALTERNATE_PROCESS",t[t.FLOW_CHART_COLLATE=105]="FLOW_CHART_COLLATE",t[t.FLOW_CHART_CONNECTOR=106]="FLOW_CHART_CONNECTOR",t[t.FLOW_CHART_DECISION=107]="FLOW_CHART_DECISION",t[t.FLOW_CHART_DELAY=108]="FLOW_CHART_DELAY",t[t.FLOW_CHART_DISPLAY=109]="FLOW_CHART_DISPLAY",t[t.FLOW_CHART_DOCUMENT=110]="FLOW_CHART_DOCUMENT",t[t.FLOW_CHART_EXTRACT=111]="FLOW_CHART_EXTRACT",t[t.FLOW_CHART_INPUT_OUTPUT=112]="FLOW_CHART_INPUT_OUTPUT",t[t.FLOW_CHART_INTERNAL_STORAGE=113]="FLOW_CHART_INTERNAL_STORAGE",t[t.FLOW_CHART_MAGNETIC_DISK=114]="FLOW_CHART_MAGNETIC_DISK",t[t.FLOW_CHART_MAGNETIC_DRUM=115]="FLOW_CHART_MAGNETIC_DRUM",t[t.FLOW_CHART_MAGNETIC_TAPE=116]="FLOW_CHART_MAGNETIC_TAPE",t[t.FLOW_CHART_MANUAL_INPUT=117]="FLOW_CHART_MANUAL_INPUT",t[t.FLOW_CHART_MANUAL_OPERATION=118]="FLOW_CHART_MANUAL_OPERATION",t[t.FLOW_CHART_MERGE=119]="FLOW_CHART_MERGE",t[t.FLOW_CHART_MULTIDOCUMENT=120]="FLOW_CHART_MULTIDOCUMENT",t[t.FLOW_CHART_OFFLINE_STORAGE=121]="FLOW_CHART_OFFLINE_STORAGE",t[t.FLOW_CHART_OFFPAGE_CONNECTOR=122]="FLOW_CHART_OFFPAGE_CONNECTOR",t[t.FLOW_CHART_ONLINE_STORAGE=123]="FLOW_CHART_ONLINE_STORAGE",t[t.FLOW_CHART_OR=124]="FLOW_CHART_OR",t[t.FLOW_CHART_PREDEFINED_PROCESS=125]="FLOW_CHART_PREDEFINED_PROCESS",t[t.FLOW_CHART_PREPARATION=126]="FLOW_CHART_PREPARATION",t[t.FLOW_CHART_PROCESS=127]="FLOW_CHART_PROCESS",t[t.FLOW_CHART_PUNCHED_CARD=128]="FLOW_CHART_PUNCHED_CARD",t[t.FLOW_CHART_PUNCHED_TAPE=129]="FLOW_CHART_PUNCHED_TAPE",t[t.FLOW_CHART_SORT=130]="FLOW_CHART_SORT",t[t.FLOW_CHART_SUMMING_JUNCTION=131]="FLOW_CHART_SUMMING_JUNCTION",t[t.FLOW_CHART_TERMINATOR=132]="FLOW_CHART_TERMINATOR",t[t.ARROW_EAST=133]="ARROW_EAST",t[t.ARROW_NORTH_EAST=134]="ARROW_NORTH_EAST",t[t.ARROW_NORTH=135]="ARROW_NORTH",t[t.SPEECH=136]="SPEECH",t[t.STARBURST=137]="STARBURST",t[t.TEARDROP=138]="TEARDROP",t[t.ELLIPSE_RIBBON=139]="ELLIPSE_RIBBON",t[t.ELLIPSE_RIBBON_2=140]="ELLIPSE_RIBBON_2",t[t.CLOUD_CALLOUT=141]="CLOUD_CALLOUT",t[t.CUSTOM=142]="CUSTOM",t))(hs||{}),_s=(t=>(t[t.GRID=0]="GRID",t[t.KANBAN=1]="KANBAN",t[t.GANTT=2]="GANTT",t))(_s||{}),_t=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",t[t.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",t))(_t||{}),ds=(t=>(t[t.DASH=0]="DASH",t[t.DASH_DOT_DOT_HEAVY=1]="DASH_DOT_DOT_HEAVY",t[t.DASH_DOT_HEAVY=2]="DASH_DOT_HEAVY",t[t.DASHED_HEAVY=3]="DASHED_HEAVY",t[t.DASH_LONG=4]="DASH_LONG",t[t.DASH_LONG_HEAVY=5]="DASH_LONG_HEAVY",t[t.DOT_DASH=6]="DOT_DASH",t[t.DOT_DOT_DASH=7]="DOT_DOT_DASH",t[t.DOTTED=8]="DOTTED",t[t.DOTTED_HEAVY=9]="DOTTED_HEAVY",t[t.DOUBLE=10]="DOUBLE",t[t.NONE=11]="NONE",t[t.SINGLE=12]="SINGLE",t[t.THICK=13]="THICK",t[t.WAVE=14]="WAVE",t[t.WAVY_DOUBLE=15]="WAVY_DOUBLE",t[t.WAVY_HEAVY=16]="WAVY_HEAVY",t[t.WORDS=17]="WORDS",t))(ds||{}),X=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.LEFT=1]="LEFT",t[t.CENTER=2]="CENTER",t[t.RIGHT=3]="RIGHT",t[t.JUSTIFIED=4]="JUSTIFIED",t))(X||{}),J=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.TOP=1]="TOP",t[t.MIDDLE=2]="MIDDLE",t[t.BOTTOM=3]="BOTTOM",t))(J||{}),Z=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.OVERFLOW=1]="OVERFLOW",t[t.CLIP=2]="CLIP",t[t.WRAP=3]="WRAP",t))(Z||{}),Nt=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ITALIC=1]="ITALIC",t))(Nt||{}),St=(t=>(t[t.NORMAL=0]="NORMAL",t[t.BOLD=1]="BOLD",t))(St||{}),Lt=(t=>(t[t.NORMAL=1]="NORMAL",t[t.SUBSCRIPT=2]="SUBSCRIPT",t[t.SUPERSCRIPT=3]="SUPERSCRIPT",t))(Lt||{}),O=(t=>(t[t.FALSE=0]="FALSE",t[t.TRUE=1]="TRUE",t))(O||{}),ct=(t=>(t[t.STRING=1]="STRING",t[t.NUMBER=2]="NUMBER",t[t.BOOLEAN=3]="BOOLEAN",t[t.FORCE_STRING=4]="FORCE_STRING",t))(ct||{}),M=(t=>(t[t.DARK1=0]="DARK1",t[t.LIGHT1=1]="LIGHT1",t[t.DARK2=2]="DARK2",t[t.LIGHT2=3]="LIGHT2",t[t.ACCENT1=4]="ACCENT1",t[t.ACCENT2=5]="ACCENT2",t[t.ACCENT3=6]="ACCENT3",t[t.ACCENT4=7]="ACCENT4",t[t.ACCENT5=8]="ACCENT5",t[t.ACCENT6=9]="ACCENT6",t[t.HYPERLINK=10]="HYPERLINK",t[t.FOLLOWED_HYPERLINK=11]="FOLLOWED_HYPERLINK",t))(M||{}),Ht=(t=>(t.OFFICE="Office",t.OFFICE_2007_2010="Office 2007-2010",t.GRAYSCALE="Grayscale",t.BLUE_WARM="Blue Warm",t.BLUE="Blue",t.BLUE_II="Blue II",t.BLUE_GREEN="Blue Green",t.GREEN="Green",t.GREEN_YELLOW="Green Yellow",t.YELLOW="Yellow",t.YELLOW_ORANGE="Yellow Orange",t.ORANGE="Orange",t.ORANGE_RED="Orange Red",t.RED_ORANGE="Red Orange",t.RED="Red",t.RED_VIOLET="Red Violet",t.VIOLET="Violet",t.VIOLET_II="Violet II",t.MEDIAN="Median",t.PAPER="Paper",t.MARQUEE="Marquee",t.SLIPSTREAM="Slipstream",t.Aspect="Aspect",t))(Ht||{});const fs={[Ht.OFFICE]:{[M.ACCENT1]:"#4472C4",[M.ACCENT2]:"#ED7D31",[M.ACCENT3]:"#A5A5A5",[M.ACCENT4]:"#70AD47",[M.ACCENT5]:"#5B9BD5",[M.ACCENT6]:"#70AD47",[M.DARK1]:"#000000",[M.DARK2]:"#44546A",[M.LIGHT1]:"#FFFFFF",[M.LIGHT2]:"#E7E6E6",[M.HYPERLINK]:"#0563C1",[M.FOLLOWED_HYPERLINK]:"#954F72"}};class Ft{constructor(){h(this,"_themeValue",M.LIGHT1);h(this,"_themeColors");h(this,"_themeTint");h(this,"_rgbValue","");h(this,"_colorType");this._colorType=H.UNSUPPORTED,this._themeColors=Ht.OFFICE,this._themeTint=0}asRgbColor(){return new bt(this._rgbValue,this)}asThemeColor(){return new vt(this._themeValue,this._themeTint,this._themeColors,this)}build(){switch(this._colorType){case H.THEME:return this.asThemeColor();case H.RGB:return this.asRgbColor();case H.UNSUPPORTED:throw new Error("unsupported color type")}}setRgbColor(e){return this._colorType=H.RGB,this._rgbValue=e,this}setThemeColors(e){this._colorType=H.THEME,this._themeColors=e}setThemeTint(e){this._colorType=H.THEME,this._themeTint=e}setThemeColor(e){return this._colorType=H.THEME,this._themeValue=e,this}getColorType(){return this._colorType}}class Q{constructor(e){h(this,"_builder");this._builder=e}static rgbColorToHexValue(e){return`#${((1<<24)+(e.getRed()<<16)+(e.getGreen()<<8)+e.getBlue()).toString(16).slice(1)}`}static hexValueToRgbColor(e){e?e.indexOf("#")>-1&&(e=e.substring(1)):e="#000000";const s=+`0x${e[0]}${e[1]}`,n=+`0x${e[2]}${e[3]}`,r=+`0x${e[4]}${e[5]}`;return new Ft().setRgbColor(`rgb(${s},${n},${r})`).asRgbColor()}static hexToRgbString(e){const s=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;e=e.replace(s,(i,o,a,l)=>o+o+a+a+l+l);const n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);let r=null;if(n){const i=Number.parseInt(n[1],16),o=Number.parseInt(n[2],16),a=Number.parseInt(n[3],16);r=`rgba(${i},${o},${a})`}return r}asRgbColor(){return this._builder.asRgbColor()}asThemeColor(){return this._builder.asThemeColor()}getColorType(){return this._builder.getColorType()}clone(){return new Q(this._builder)}equals(e){return!1}}class Es{constructor(e){h(this,"_saturation",0);h(this,"_hue",0);h(this,"_lightness",0);h(this,"_alpha",0);const s=e.getRed()/255,n=e.getGreen()/255,r=e.getBlue()/255,i=e.getAlpha()/255,o=Math.min(s,Math.min(n,r)),a=Math.max(s,Math.max(n,r)),l=a-o;if(a===o){this._hue=0,this._saturation=0,this._lightness=a;return}this._lightness=(o+a)/2,this._lightness<.5?this._saturation=l/(a+o):this._saturation=l/(2-a-o),s===a&&(this._hue=(n-r)/l),n===a&&(this._hue=2+(r-s)/l),r===a&&(this._hue=4+(s-n)/l),this._hue*=60,this._hue<0&&(this._hue+=360),this._alpha=i}asRgbColor(){const e=new Ft;if(this._saturation===0)return e.setRgbColor(`rgba(${this._lightness*255},${this._lightness*255},${this._lightness*255},${this._alpha*255})`),e.asRgbColor();let s;this._lightness<.5?s=this._lightness*(1+this._saturation):s=this._lightness+this._saturation-this._lightness*this._saturation;const n=2*this._lightness-s,r=this._hue/360,i=r+1/3,o=this.setColor(s,n,i),a=this.setColor(s,n,r),l=r-1/3,c=this.setColor(s,n,l);return e.setRgbColor(`rgba(${Math.round(o*255)},${Math.round(a*255)},${Math.round(c*255)},${this._alpha*255})`),e.asRgbColor()}getLightness(){return this._lightness}getHue(){return this._hue}getSaturation(){return this._saturation}getAlpha(){return this._alpha}setColor(e,s,n){n<0&&(n+=1),n>1&&(n-=1);let r;return 6*n<1?r=s+(e-s)*6*n:2*n<1?r=e:3*n<2?r=s+(e-s)*(2/3-n)*6:r=s,r}setLightness(e){this._lightness=e}}const x=class x extends Q{constructor(s,n){super(n);h(this,"_cssString");h(this,"_red");h(this,"_green");h(this,"_blue");h(this,"_alpha");let r=s.match(x.RGBA_EXTRACT);if(r){const i=+r[1],o=+r[2],a=+r[3],l=+r[4];this._cssString=s,this._red=i,this._green=o,this._blue=a,this._alpha=l;return}if(r=s.match(x.RGB_EXTRACT),r){const i=+r[1],o=+r[2],a=+r[3];this._cssString=s,this._red=i,this._green=o,this._blue=a,this._alpha=1;return}throw new Error("Invalid rgba or rgb color")}asHexString(){return Q.rgbColorToHexValue(this)}getRed(){let s=this._red+x.RGB_COLOR_AMT;return s>255?s=255:s<0&&(s=0),s}getGreen(){let s=this._green+x.RGB_COLOR_AMT;return s>255?s=255:s<0&&(s=0),s}getBlue(){let s=this._blue+x.RGB_COLOR_AMT;return s>255?s=255:s<0&&(s=0),s}getAlpha(){return this._alpha}getColorType(){return H.RGB}clone(){return new x(this._cssString,this._builder)}asThemeColor(){throw new Error("rgb color not support to themeColor")}equals(s){return s instanceof x?s._red===this._red&&s._blue===this._blue&&s._green===this._green&&s._alpha===this._alpha:!1}getCssString(){return this._cssString}};h(x,"RGB_COLOR_AMT",0),h(x,"RGBA_EXTRACT",new RegExp("\\s*rgba\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d.\\d|\\d\\s*)\\)\\s*")),h(x,"RGB_EXTRACT",new RegExp("\\s*rgb\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*)\\)\\s*"));let bt=x;const j=class j extends Q{constructor(s,n,r,i){super(i);h(this,"_themeColorType");h(this,"_themeTint");h(this,"_themeColors");this._themeColorType=s,this._themeTint=n,this._themeColors=r}lumValue(s,n){if(s==null)return n;let r;return s<0?r=n*(1+s):r=n*(1-s)+(255-255*(1-s)),r}asRgbColor(){const s=fs[this._themeColors];if(s==null)throw new Error("not find themeColors type");const n=s[this._themeColorType];if(n==null)throw new Error("not find themeColors value");let r;if(j._cacheThemeColor.has(this._themeColors)){if(r=j._cacheThemeColor.get(this._themeColors),r.has(this._themeColorType))return r.get(this._themeColorType)}else r=new Map,j._cacheThemeColor.set(this._themeColors,r);const i=new Es(Q.hexValueToRgbColor(n));i.setLightness(this.lumValue(this._themeTint,i.getLightness()*255)/255);const o=i.asRgbColor();return r.set(this._themeColorType,o),o}clone(){return new j(this._themeColorType,this._themeTint,this._themeColors,this._builder)}equals(s){return s instanceof j?s._themeColorType===this._themeColorType:!1}getColorType(){return H.THEME}getThemeColorType(){return this._themeColorType}};h(j,"_cacheThemeColor",new Map);let vt=j;const cr="rgb(",hr="rgba(",Yt={aliceBlue:[240,248,255],antiqueWhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blancheAlmond:[255,235,205],blue:[0,0,255],blueViolet:[138,43,226],brown:[165,42,42],burlyWood:[222,184,135],cadetBlue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornFlowerBlue:[100,149,237],cornSilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkCyan:[0,139,139],darkGoldenrod:[184,132,11],darkGray:[169,169,169],darkGreen:[0,100,0],darkGrey:[169,169,169],darkKhaki:[189,183,107],darkMagenta:[139,0,139],darkOliveGreen:[85,107,47],darkOrange:[255,140,0],darkOrchid:[153,50,204],darkRed:[139,0,0],darkSalmon:[233,150,122],darkSeaGreen:[143,188,143],darkSlateBlue:[72,61,139],darkSlateGray:[47,79,79],darkSlateGrey:[47,79,79],darkTurquoise:[0,206,209],darkViolet:[148,0,211],deepPink:[255,20,147],deepSkyBlue:[0,191,255],dimGray:[105,105,105],dimGrey:[105,105,105],dodgerBlue:[30,144,255],firebrick:[178,34,34],floralWhite:[255,255,240],forestGreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostWhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenYellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotPink:[255,105,180],indianRed:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderBlush:[255,240,245],lawnGreen:[124,252,0],lemonChiffon:[255,250,205],lightblue:[173,216,230],lightCoral:[240,128,128],lightCyan:[224,255,255],lightGoldenrodYellow:[250,250,210],lightGray:[211,211,211],lightGreen:[144,238,144],lightGrey:[211,211,211],lightPink:[255,182,193],lightSalmon:[255,160,122],lightSeaGreen:[32,178,170],lightSkyBlue:[135,206,250],lightSlateGray:[119,136,153],lightSlateGrey:[119,136,153],lightSteelBlue:[176,196,222],lightYellow:[255,255,224],lime:[0,255,0],limeGreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumAquamarine:[102,205,170],mediumBlue:[0,0,205],mediumOrchid:[186,85,211],mediumPurple:[147,112,219],mediumSeaGreen:[60,179,113],mediumSlateBlue:[123,104,238],mediumSpringGreen:[0,250,154],mediumTurquoise:[72,209,204],mediumVioletRed:[199,21,133],midBightBlue:[25,25,112],mintCream:[245,255,250],mistyRose:[255,228,225],moccasin:[255,228,181],navajoWhite:[255,222,173],navy:[0,0,128],oldLace:[253,245,230],olive:[128,128,0],oliveDrab:[107,142,35],orange:[255,165,0],orangeRed:[255,69,0],orchid:[218,112,214],paleGoldenrod:[238,232,170],paleGreen:[152,251,152],paleTurquoise:[175,238,238],paleVioletRed:[219,112,147],papayaWhip:[255,239,213],peachPuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderBlue:[176,224,230],purple:[128,0,128],rebeccaPurple:[102,51,153],red:[255,0,0],rosyBrown:[188,143,143],royalBlue:[65,105,225],saddleBrown:[139,69,19],salmon:[250,128,114],sandyBrown:[244,164,96],seaGreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyBlue:[135,206,235],slateBlue:[106,90,205],slateGray:[119,128,144],slateGrey:[119,128,144],snow:[255,255,250],springGreen:[0,255,127],steelBlue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whiteSmoke:[245,245,245],yellow:[255,255,0],yellowGreen:[154,205,5]};class F{constructor(e){h(this,"_color");h(this,"_rgbColor");h(this,"_isValid",!1);if(e==null){this._setNullColor();return}if(e instanceof F){this._color={...e._color},this._rgbColor={...e._rgbColor};return}const s=gs(e);if(s==null){this._setNullColor();return}this._color=s;const n=gr(this._color);if(n==null){this._setNullColor();return}this._rgbColor=n,this._isValid=!0}static mix(e,s,n){var c,u;n=Math.min(1,Math.max(0,n));const r=new F(e).toRgb(),i=new F(s).toRgb(),o=(c=r.a)!=null?c:1,a=(u=i.a)!=null?u:1,l={r:(i.r-r.r)*n+r.r,g:(i.g-r.g)*n+r.g,b:(i.b-r.b)*n+r.b,a:(a-o)*n+o};return new F(l)}static getContrastRatio(e,s){const n=new F(e).getLuminance(),r=new F(s).getLuminance();return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}get isValid(){return this._isValid}toRgb(){return this._rgbColor}toRgbString(){const{r:e,g:s,b:n,a:r=1}=this.toRgb(),i=r<1;return`rgb${i?"a":""}(${e},${s},${n}${i?`,${r}`:""})`}toString(){return this.toRgbString()}toHexString(e){const{r:s,g:n,b:r,a:i=1}=this.toRgb(),o=i<1,a=[gt(Math.round(s).toString(16)),gt(Math.round(n).toString(16)),gt(Math.round(r).toString(16)),gt(Math.round(i*255).toString(16))];return e&&a[0][0]===a[0][1]&&a[1][0]===a[1][1]&&a[2][0]===a[2][1]&&a[3][0]===a[3][1]?o?`#${a[0][0]}${a[1][0]}${a[2][0]}${a[3][0]}`:`#${a[0][0]}${a[1][0]}${a[2][0]}`:o?`#${a[0]}${a[1]}${a[2]}${a[3]}`:`#${a[0]}${a[1]}${a[2]}`}toHsv(){return Ir(this.toRgb())}toHsl(){return Or(this.toRgb())}lighten(e=10){const s=this.toHsl();return s.l+=e,s.l=Math.min(Math.max(s.l,0),100),new F(s)}darken(e=10){const s=this.toHsl();return s.l-=e,s.l=Math.min(Math.max(s.l,0),100),new F(s)}setAlpha(e){return new F({...this._rgbColor,a:e})}getLuminance(){let{r:e,g:s,b:n}=this.toRgb();return e=Gt(e),s=Gt(s),n=Gt(n),Number((.2126*e+.7152*s+.0722*n).toFixed(3))}getBrightness(){const{r:e,g:s,b:n}=this.toRgb();return(e*299+s*587+n*114)/1e3}getAlpha(){var e;return(e=this._color.a)!=null?e:1}isDark(){return this.getBrightness()<128}isLight(){return!this.isDark()}_setNullColor(){this._isValid=!1,this._color={r:0,g:0,b:0,a:0},this._rgbColor={r:0,g:0,b:0,a:0}}}const gt=t=>t.length===1?`0${t}`:t,Gt=t=>(t/=255,t<=.03928?t/12.92:((t+.055)/1.055)**2.4),gs=t=>{if(Cr(t)){if("r"in t){const n={r:Math.round(t.r),g:Math.round(t.g),b:Math.round(t.b)};return t.a!==void 0&&(n.a=t.a),n}if("l"in t){const n={h:Math.round(t.h),s:t.s,l:t.l};return t.a!==void 0&&(n.a=t.a),n}const s={h:Math.round(t.h),s:t.s,v:t.v};return t.a!==void 0&&(s.a=t.a),s}const e=t.trim();if(Yt[e]){const s=Yt[e],n={r:Math.round(s[0]),g:Math.round(s[1]),b:Math.round(s[2])};return n.a=s[3]||1,n}if(e.startsWith("#"))return _r(e);if(e.startsWith("rgb"))return dr(e);if(e.startsWith("hsl"))return fr(e);if(e.startsWith("hsv"))return Er(e)},_r=t=>{const e=t.substring(1),s=new RegExp(`.{1,${e.length>=6?2:1}}`,"g");let n=e.match(s);if(!n||n.length<3)throw new Error(`The color '${t}' is illegal hex color`);n[0].length===1&&(n=n.map(i=>i+i));const r={r:Number.parseInt(n[0],16),g:Number.parseInt(n[1],16),b:Number.parseInt(n[2],16)};return n.length>3&&(r.a=Number.parseInt(n[3],16)/255),r},dr=t=>{const e=t.indexOf("(");if(e===-1)throw new Error(`The color '${t}' is illegal rgb color`);const s=t.substring(e+1,t.length-1).split(",");if(s.length<3)throw new Error(`The color '${t}' is illegal rgb color`);const n={r:Number.parseInt(s[0],10),g:Number.parseInt(s[1],10),b:Number.parseInt(s[2],10)};return s.length>3&&(n.a=Number.parseFloat(s[3])),n},fr=t=>{const e=t.indexOf("(");if(e===-1)throw new Error(`The color '${t}' is illegal hsl color`);const s=t.substring(e+1,t.length-1).split(",");if(s.length<3)throw new Error(`The color '${t}' is illegal hsl color`);const n={h:Number.parseInt(s[0],10),s:Number.parseFloat(s[1]),l:Number.parseFloat(s[2])};return s.length>3&&(n.a=Number.parseFloat(s[3])),n},Er=t=>{const e=t.indexOf("(");if(e===-1)throw new Error(`The color '${t}' is illegal hsv color`);const s=t.substring(e+1,t.length-1).split(",");if(s.length<3)throw new Error(`The color '${t}' is illegal hsv color`);const n={h:Number.parseInt(s[0],10),s:Number.parseFloat(s[1]),v:Number.parseFloat(s[2])};return s.length>3&&(n.a=Number.parseFloat(s[3])),n},gr=t=>{const e=gs(t);if(e!=null)return"r"in e?e:"l"in e?Rr(e):mr(e)},kt=(t,e,s)=>(s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+(e-t)*6*s:s<1/2?e:s<2/3?t+(e-t)*(2/3-s)*6:t),Rr=t=>{let{h:e,s,l:n}=t;e/=360,s/=100,n/=100;let r=0,i=0,o=0;if(s===0)r=i=o=n;else{const l=n<.5?n*(1+s):n+s-n*s,c=2*n-l;r=kt(c,l,e+1/3),i=kt(c,l,e),o=kt(c,l,e-1/3)}const a={r:Math.round(r*255),g:Math.round(i*255),b:Math.round(o*255)};return t.a!==void 0&&(a.a=t.a),a},mr=t=>{let{h:e,s,v:n}=t;e=e/360*6,s/=100,n/=100;const r=Math.floor(e),i=e-r,o=n*(1-s),a=n*(1-i*s),l=n*(1-(1-i)*s),c=r%6,u=[n,a,o,o,l,n][c],_=[l,n,n,a,o,o][c],d=[o,o,l,n,n,a][c],f={r:u*255,g:_*255,b:d*255};return t.a!==void 0&&(f.a=t.a),f},Or=t=>{let{r:e,g:s,b:n}=t;e/=255,s/=255,n/=255;const r=Math.max(e,s,n),i=Math.min(e,s,n),o=(r+i)/2;let a,l;if(r===i)a=l=0;else{const u=r-i;switch(l=o>.5?u/(2-r-i):u/(r+i),r){case e:a=(s-n)/u+(s<n?6:0);break;case s:a=(n-e)/u+2;break;default:a=(e-s)/u+4;break}a/=6}const c={h:Math.round(a*360),s:Math.round(l*100),l:Math.round(o*100)};return t.a!==void 0&&(c.a=t.a),c},Ir=t=>{let{r:e,g:s,b:n}=t;e/=255,s/=255,n/=255;const r=Math.max(e,s,n),i=Math.min(e,s,n);let o;const a=r,l=r-i,c=r===0?0:l/r;if(r===i)o=0;else{switch(r){case e:o=(s-n)/l+(s<n?6:0);break;case s:o=(n-e)/l+2;break;default:o=(e-s)/l+4;break}o/=6}const u={h:Math.round(o*360),s:Math.round(c*100),v:Math.round(a*100)};return t.a!==void 0&&(u.a=t.a),u},Ar=t=>t==null,Cr=t=>!Ar(t)&&typeof t=="object";var T=(t=>(t[t.COVER=0]="COVER",t[t.REPLACE=1]="REPLACE",t[t.INTERSECTION=2]="INTERSECTION",t))(T||{});const Nr="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Sr=(t=21)=>{let e="",s=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=Nr[s[t]&63];return e};const Lr=/^-ms-/,br=/-([a-z])/g,$=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];class g{static stringAt(e){let s="",n=e;for(;n>=$.length;)n/=$.length,n-=1,s+=$[n%$.length];const r=e%$.length;return s+=$[r],s}static indexAt(e){let s=0;for(let n=0;n<e.length-1;n+=1){const r=e.charCodeAt(n)-65,i=e.length-1-n;s+=$.length**i+$.length*r}return s+=e.charCodeAt(e.length-1)-65,s}static deleteBlank(e){return g.isString(e)?e.replace(/\s/g,""):e}static getSystemType(){const e=navigator.userAgent,s=navigator.platform==="Win32"||navigator.platform==="Windows",n=navigator.platform==="Mac68K"||navigator.platform==="MacPPC"||navigator.platform==="Macintosh"||navigator.platform==="MacIntel";if(n)return"Mac";if(navigator.platform==="X11"&&!s&&!n)return"Unix";if(String(navigator.platform).indexOf("Linux")>-1)return"Linux";if(s){if(e.indexOf("Windows NT 5.0")>-1||e.indexOf("Windows 2000")>-1)return"Windows 2000";if(e.indexOf("Windows NT 5.1")>-1||e.indexOf("Windows XP")>-1)return"Windows XP";if(e.indexOf("Windows NT 5.2")>-1||e.indexOf("Windows 2003")>-1)return"Windows 2003";if(e.indexOf("Windows NT 6.0")>-1||e.indexOf("Windows Vista")>-1)return"Windows Vista";if(e.indexOf("Windows NT 6.1")>-1||e.indexOf("Windows 7")>-1)return"Windows 7";if(e.indexOf("Windows NT 10")>-1||e.indexOf("Windows 10")>-1)return"Windows 10";if(e.indexOf("Windows NT 11")>-1||e.indexOf("Windows 11")>-1)return"Windows 11"}return"Unknown system"}static getBrowserType(){const e=navigator.userAgent,s=e.indexOf("Opera")>-1,n=e.indexOf("compatible")>-1&&e.indexOf("MSIE")>-1&&!s,r=e.indexOf("Trident")>-1&&e.indexOf("rv:11.0")>-1,i=e.indexOf("Edge")>-1,o=e.indexOf("Firefox")>-1,a=e.indexOf("Safari")>-1&&e.indexOf("Chrome")===-1,l=e.indexOf("Chrome")>-1&&e.indexOf("Safari")>-1;if(n){new RegExp("MSIE (\\d+\\.\\d+);").test(e);const u=Number.parseFloat(RegExp.$1);return u===7?"IE7":u===8?"IE8":u===9?"IE9":u===10?"IE10":"0"}return o?"FF":s?"Opera":a?"Safari":l?"Chrome":i?"Edge":r?"IE11":"Unknown browser"}static generateRandomId(e=21){return Sr(e)}static getClassName(e){return e.constructor.name}static deepMerge(e,...s){s.forEach(o=>o&&i(o));function n(o,a){o.forEach((l,c)=>{var u,_;if(g.isArray(l)){const d=(u=a[c])!=null?u:[];a[c]=d,n(l,d);return}if(g.isObject(l)){const d=(_=a[c])!=null?_:{};a[c]=d,r(l,d);return}a[c]=l})}function r(o,a){Object.keys(o).forEach(l=>{var u,_;const c=o[l];if(g.isObject(c)){const d=(u=a[l])!=null?u:{};a[l]=d,r(c,d);return}if(g.isArray(c)){const d=(_=a[l])!=null?_:[];a[l]=d,n(c,d);return}a[l]=c})}function i(o){Object.keys(o).forEach(a=>{var c,u;const l=o[a];if(g.isArray(l)){const _=(c=e[a])!=null?c:[];e[a]=_,n(l,_);return}if(g.isObject(l)){const _=(u=e[a])!=null?u:{};e[a]=_,r(l,_);return}e[a]=l})}return e}static numberFixed(e,s){return Number(Number(e).toFixed(s))}static diffValue(e,s){function n(o,a){const l=g.getValueType(o),c=g.getValueType(a);return l!==c?!1:g.isArray(o)?r(o,a):g.isObject(o)?i(o,a):g.isDate(o)?o.getTime()===a.getTime():g.isRegExp(o)?o.toString()===a.toString():o===a}function r(o,a){if(e.length!==s.length)return!1;for(let l=0,c=o.length;l<c;l++){const u=o[l],_=a[l];if(!n(u,_))return!1}return!0}function i(o,a){const l=Object.keys(o),c=Object.keys(a);if(l.length!==c.length)return!1;for(const u of l){if(!c.includes(u))return!1;const _=o[u],d=a[u];if(!n(_,d))return!1}return!0}return n(e,s)}static deepClone(e){if(!this.isDefine(e))return e;if(this.isRegExp(e))return new RegExp(e);if(this.isDate(e))return new Date(e);if(this.isArray(e)){const s=[];return e.forEach((n,r)=>{s[r]=g.deepClone(n)}),s}if(this.isObject(e)){const s={};return Object.keys(e).forEach(n=>{const r=e[n];s[n]=g.deepClone(r)}),Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s}return e}static getLanguage(){const e="en-US";return globalThis.navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||e}static getValueType(e){return Object.prototype.toString.apply(e)}static isDefine(e){return e!=null}static isBlank(e){return this.isDefine(e)?this.isString(e)?e.trim()==="":!1:!0}static isAssignableFrom(e,s){return e instanceof s}static isBoolean(e){return this.getValueType(e)==="[object Boolean]"}static isPlainObject(e){return this.isDefine(e)?Object.getPrototypeOf(e)===Object.getPrototypeOf({}):!1}static isFunction(e){return this.getValueType(e)==="[object Function]"}static isDate(e){return this.getValueType(e)==="[object Date]"}static isRegExp(e){return this.getValueType(e)==="[object RegExp]"}static isArray(e){return this.getValueType(e)==="[object Array]"}static isString(e){return this.getValueType(e)==="[object String]"}static isNumber(e){return this.getValueType(e)==="[object Number]"}static isStringNumber(e){return!isNaN(Number.parseFloat(e))&&isFinite(e)}static isObject(e){return this.getValueType(e)==="[object Object]"}static isEmptyObject(e){for(const s in e)return!1;return!0}static isMobile(){let e=0,s=0;return document.body.clientWidth&&(e=document.body.clientWidth),document.body.clientHeight&&(s=document.body.clientHeight),this.isAndroid()||this.isIPhone()||this.isTablet()||e<350&&s<500}static isTablet(){return/ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase())}static isWeChat(){const e=navigator.userAgent.toLowerCase();return String(e.match(/MicroMessenger/i))==="micromessenger"}static isAndroid(){const e=navigator.userAgent;return e.indexOf("Android")>-1||e.indexOf("Linux")>-1}static isIPhone(){return/iPhone/i.test(navigator.userAgent)}static itCount(e){return s=>{for(let n=0;n<e;n++)s&&s()}}static hasLength(e,s){return g.isDefine(e)?g.isDefine(s)?e.length===s:e.length>0:!1}static capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}static fCamelCase(e,s){return s.toUpperCase()}static camelCase(e){return e.replace(Lr,"ms-").replace(br,this.fCamelCase)}static removeNull(e){return this.isObject(e)&&Object.keys(e).forEach(s=>{const n=e[s];n==null?delete e[s]:g.removeNull(n)}),e}static fillTwoDimensionalArray(e,s,n){return new Array(e).fill(n).map(r=>new Array(s).fill(n))}static numToWord(e){let s="";for(;e>0;){let n=e%26;n=n===0?n=26:n,s=String.fromCharCode(96+n)+s,e=(e-n)/26}return s.toLocaleUpperCase()}static ABCatNum(e){if(e==null||e.length===0)return Number.NaN;const s=e.toLowerCase().split(""),n=s.length;let r=0,i=0;for(let o=0;o<n;o++)i=s[o].charCodeAt(0)-96,r+=i*26**(n-o-1);return r===0?Number.NaN:r-1}static chatAtABC(e){let i="";for(;e>=0;)i=String.fromCharCode(e%26+97)+i,e=Math.floor(e/26)-1;return i.toUpperCase()}static randSort(e){for(let s=0,n=e.length;s<n;s++){const r=Number.parseInt((Math.random()*n).toString()),i=e[r];e[r]=e[s],e[s]=i}return e}static commonExtend(e,s){const n={};for(const r in e)n[r]=e[r];for(const r in s)s[r]!=null&&(n[r]=s[r]);return n}static commonExtend1(e,s){for(const n in e)s[n]==null&&(s[n]=e[n]);return s}static arrayToObject(e){const s={};return e.forEach((n,r)=>{s[r]={},n.forEach((i,o)=>{s[r][o]=i})}),s}static hasIntersectionBetweenTwoRanges(e,s,n,r){return s>=n&&r>=e}}function vr(t){if(!t)return;const{actualRow:e,actualColumn:s,isMerged:n,isMergedMainCell:r,mergeInfo:i}=t;let{startY:o,endY:a,startX:l,endX:c}=t,u=e,_=s,d=e,f=s;if(n&&i){const{startRow:E,startColumn:R,endRow:b,endColumn:v,startY:p,endY:k,startX:it,endX:Gn}=i;u=E,_=R,d=b,f=v,o=p,a=k,l=it,c=Gn}return r&&(o=i.startY,a=i.endY,l=i.startX,c=i.endX,d=i.endRow,f=i.endColumn),{startRow:u,startColumn:_,endRow:d,endColumn:f,startY:o,endY:a,startX:l,endX:c}}function wr(t){if(!t)return;const{actualRow:e,actualColumn:s,isMerged:n,isMergedMainCell:r,startRow:i,startColumn:o,endRow:a,endColumn:l}=t;let c=e,u=s,_=e,d=s;return(n||r)&&(c=i,u=o,_=a,d=l),{startRow:c,startColumn:u,endRow:_,endColumn:d}}function Dr(t){var s;return!t||(((s=t==null?void 0:t.v)==null?void 0:s.toString())||"").length===0&&!t.p}function W(t){if(t){if(t.rgb)return t.rgb;if(t.th)return new Ft().setThemeColor(t.th).asThemeColor().asRgbColor().getCssString()}return null}function Tr(t){return g.isString(t)&&t.substring(0,1)==="="&&t.length>1}function Ur(t){return g.isString(t)&&t.indexOf("=")===-1&&t.length===6}function Mr(t){return""}function Pr(t,e=!1){var i;let s="";const n=new Map([["ff",()=>{t.ff&&(s+=`font-family: ${t.ff}; `)}],["fs",()=>{if(t.fs){let o=t.fs;t.va&&(o/=2),s+=`font-size: ${o}pt; `}}],["it",()=>{t.it&&(s+="font-style: italic; ")}],["bl",()=>{t.bl&&(s+="font-weight: bold; ")}],["ul",()=>{var o;(o=t.ul)!=null&&o.s&&(s.indexOf("text-decoration-line")>-1?s=s.replace(/(?<=text-decoration-line:.*)\b(?=;)/g," underline"):s+="text-decoration-line: underline; ",t.ul.cl&&s.indexOf("text-decoration-color")===-1&&(s+=`text-decoration-color: ${W(t.ul.cl)}; `),t.ul.t&&s.indexOf("text-decoration-style")===-1&&(s+=`text-decoration-style: ${t.ul.t} `))}],["st",()=>{var o;(o=t.st)!=null&&o.s&&(s.indexOf("text-decoration-line")>-1?s=s.replace(/(?<=text-decoration-line:.*)\b(?=;)/g," line-through"):s+="text-decoration-line: line-through; ",t.st.cl&&s.indexOf("text-decoration-color")===-1&&(s+=`text-decoration-color: ${W(t.st.cl)}; `),t.st.t&&s.indexOf("text-decoration-style")===-1&&(s+=`text-decoration-style: ${t.st.t} `))}],["ol",()=>{var o;(o=t.ol)!=null&&o.s&&(s.indexOf("text-decoration-line")>-1?s=s.replace(/(?<=text-decoration-line:.*)\b(?=;)/g," overline"):s+="text-decoration-line: overline; ",t.ol.cl&&s.indexOf("text-decoration-color")===-1&&(s+=`text-decoration-color: ${W(t.ol.cl)}; `),t.ol.t&&s.indexOf("text-decoration-style")===-1&&(s+=`text-decoration-style: ${t.ol.t} `))}],["bg",()=>{t.bg&&(s+=`background: ${W(t.bg)}; `)}],["bd",()=>{var o,a,l,c,u,_,d,f,E,R,b,v;(o=t.bd)!=null&&o.b&&(s+=`border-bottom: ${Rt((a=t.bd)==null?void 0:a.b.s)} ${(l=W(t.bd.b.cl))!=null?l:""}; `),(c=t.bd)!=null&&c.t&&(s+=`border-top: ${Rt((u=t.bd)==null?void 0:u.t.s)} ${(_=W(t.bd.t.cl))!=null?_:""}; `),(d=t.bd)!=null&&d.r&&(s+=`border-right: ${Rt((f=t.bd)==null?void 0:f.r.s)} ${(E=W(t.bd.r.cl))!=null?E:""}; `),(R=t.bd)!=null&&R.l&&(s+=`border-left: ${Rt((b=t.bd)==null?void 0:b.l.s)} ${(v=W(t.bd.l.cl))!=null?v:""}; `)}],["cl",()=>{t.cl&&(s+=`color: ${W(t.cl)}; `)}],["va",()=>{t.va===Lt.SUBSCRIPT?s+="vertical-align: sub; ":t.va===Lt.SUPERSCRIPT&&(s+="vertical-align: super; ")}],["td",()=>{t.td===_t.LEFT_TO_RIGHT?s+="direction: ltr; ":t.td===_t.RIGHT_TO_LEFT&&(s+="direction: rtl; ")}],["tr",()=>{var o,a,l;t.tr&&(s+=`data-rotate: (${(o=t.tr)==null?void 0:o.a}deg${(a=t.tr)!=null&&a.v?` ,${(l=t.tr)==null?void 0:l.v}`:""});`)}],["ht",()=>{t.ht===X.LEFT?s+="text-align: left; ":t.ht===X.RIGHT?s+="text-align: right; ":t.ht===X.CENTER?s+="text-align: center; ":t.ht===X.JUSTIFIED&&(s+="text-align: justify; ")}],["vt",()=>{t.vt===J.BOTTOM?s+="vertical-align: bottom; ":t.vt===J.TOP?s+="vertical-align: top; ":t.vt===J.MIDDLE&&(s+="vertical-align: middle; ")}],["tb",()=>{t.tb===Z.CLIP?s+="text-overflow: clip; ":t.tb===Z.OVERFLOW?s+="text-break: overflow; ":t.tb===Z.WRAP&&(s+="word-wrap: break-word;")}],["pd",()=>{var u,_,d,f,E,R,b,v;const o=`${(u=t.pd)==null?void 0:u.b}pt`,a=`${(_=t.pd)==null?void 0:_.t}pt`,l=`${(d=t.pd)==null?void 0:d.l}pt`,c=`${(f=t.pd)==null?void 0:f.r}pt`;(E=t.pd)!=null&&E.b&&(s+=`padding-bottom: ${o}; `),(R=t.pd)!=null&&R.t&&(s+=`padding-top: ${a}; `),(b=t.pd)!=null&&b.l&&(s+=`padding-left: ${l}; `),(v=t.pd)!=null&&v.r&&(s+=`padding-right: ${c}; `)}]]),r=["bd","tr","tb"];for(const o in t)e&&r.includes(o)||(i=n.get(o))==null||i();return s}function Rt(t){let e="";return t===N.NONE?e="none":t===N.THIN?e="0.5pt solid":t===N.HAIR?e="0.5pt double":t===N.DOTTED?e="0.5pt dotted":t===N.DASHED||t===N.DASH_DOT?e="0.5pt dashed":t===N.DASH_DOT_DOT?e="0.5pt dotted":t===N.DOUBLE?e="0.5pt double":t===N.MEDIUM?e="1pt solid":t===N.MEDIUM_DASHED||t===N.MEDIUM_DASH_DOT?e="1pt dashed":t===N.MEDIUM_DASH_DOT_DOT?e="1pt dotted":t===N.SLANT_DASH_DOT?e="0.5pt dashed":t===N.THICK&&(e="1.5pt solid"),e}function xr(t){let e=0;if(t=t.trim(),t==="none")e=N.NONE;else if(t==="0.5pt solid")e=N.THIN;else if(t==="0.5pt double")e=N.HAIR;else if(t==="0.5pt dotted")e=N.DOTTED;else if(t==="0.5pt dashed")e=N.DASHED;else if(t==="1pt solid")e=N.MEDIUM;else if(t==="1pt dashed")e=N.MEDIUM_DASHED;else if(t==="1pt dotted")e=N.MEDIUM_DASH_DOT_DOT;else if(t==="1.5pt solid")e=N.THICK;else return N.NONE;return e}function Ot(t,e){let s=t.body;if(e){const{headers:n,footers:r}=t;n!=null&&n[e]?s=n[e].body:r!=null&&r[e]&&(s=r[e].body)}return s}function Hr(t){const{startRow:e,endRow:s,startColumn:n,endColumn:r}=t;return!(e<0||n<0||s<0||r<0)}function ue(t,e){return Object.prototype.toString.call(t)===Object.prototype.toString.call(e)?Object.prototype.toString.call(t)==="[object Object]"||Object.prototype.toString.call(t)==="[object Array]"?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(s=>ue(t[s],e[s])):t===e:!1}function Rs(t,e){const s=t.ts||{},n=e.ts||{};return t.sId!==e.sId?!1:ue(s,n)}function ce(t,e,s,n){if(t>e&&([t,e]=[e,t]),s>n&&([s,n]=[n,s]),e<s||n<t)return[t,e];s<t&&(s=t),n>e&&(n=e);const r=n-s+1;let i=[];return t===s?i=[n+1-r,e-r]:e===n?i=[t,s-1]:i=[t,e-r],i}function Fr(t){if(t==null)return!1;const e=t.bullet;return(e==null?void 0:e.listId)!=null}function pr(t){if(t==null)return!1;const e=t.paragraphStyle;return ms(e)}function ms(t){return!(t==null||(t.indentStart==null||t.indentStart===0)&&t.hanging==null||t.hanging===0)}function Os(t,e,s){return t.slice(0,e)+s+t.slice(e)}function Is(t,e,s){return e>s?t:t.slice(0,e)+t.slice(s)}function Wr(t){return t===null||t.toString().replace(/\s/g,"")===""||typeof t=="boolean"?!1:!isNaN(t)}function Br(t){let e=0;for(let s=0;s<t.length;s++)e=t.charCodeAt(s)+(e<<6)+(e<<16)-e;return e>>>0}class ot{static hasLength(e,s){return e.length===s}static getValueType(e){return Object.prototype.toString.apply(e)}static isObject(e){return this.getValueType(e)==="[object Object]"}static isIterable(e){return e[Symbol.iterator]!=null}static isNumber(e){return this.getValueType(e)==="[object Number]"}}const C=Symbol("newer"),D=Symbol("older");class As{constructor(e){h(this,"entry");this.entry=e}[Symbol.iterator](){return this}next(){const e=this.entry;return e?(this.entry=e[C],{done:!1,value:e.key}):{done:!0,value:void 0}}}class Cs{constructor(e){h(this,"entry");this.entry=e}[Symbol.iterator](){return this}next(){const e=this.entry;return e?(this.entry=e[C],{done:!1,value:e.value}):{done:!0,value:void 0}}}class Ns{constructor(e){h(this,"entry");this.entry=e}[Symbol.iterator](){return this}next(){const e=this.entry;return e?(this.entry=e[C],{done:!1,value:[e.key,e.value]}):{done:!0,value:void 0}}}var Oo,Io;class zt{constructor(e,s){h(this,"key");h(this,"value");h(this,Oo);h(this,Io);this.key=e,this.value=s,this[C]=void 0,this[D]=void 0}toJSON(){return{key:this.key,value:this.value}}}Oo=C,Io=D;class Ss{constructor(...e){h(this,"_keymap");h(this,"size",0);h(this,"limit");h(this,"oldest");h(this,"newest");h(this,"_onShiftListeners",[]);if(ot.hasLength(e,1)){if(ot.isNumber(e[0])){const s=e[0];this._initialize(s,void 0);return}if(ot.isIterable(e[0])){const s=e[0];this._initialize(0,s);return}return}if(ot.hasLength(e,2)){const s=e[0],n=e[1];this._initialize(s,n)}}onShift(e){if(this._onShiftListeners.indexOf(e)===-1)return this._onShiftListeners.push(e),L(()=>Y(this._onShiftListeners,e));throw new Error("[LRUMap]: the listener has been registered!")}_initialize(e,s){this.oldest=void 0,this.newest=void 0,this.size=0,this.limit=e,this._keymap=new Map,s&&(this.assign(s),e<1&&(this.limit=this.size))}_markEntryAsUsed(e){e!==this.newest&&(e[C]&&(e===this.oldest&&(this.oldest=e[C]),e[C][D]=e[D]),e[D]&&(e[D][C]=e[C]),e[C]=void 0,e[D]=this.newest,this.newest&&(this.newest[C]=e),this.newest=e)}assign(e){let s,n=this.limit||Number.MAX_VALUE;this._keymap.clear();const r=e[Symbol.iterator]();for(let i=r.next();!i.done;i=r.next()){const o=new zt(i.value[0],i.value[1]);if(this._keymap.set(o.key,o),s?(s[C]=o,o[D]=s):this.oldest=o,s=o,n--===0)throw new Error("overflow")}this.newest=s,this.size=this._keymap.size}set(e,s){let n=this._keymap.get(e);return n?(n.value=s,this._markEntryAsUsed(n),this):(this._keymap.set(e,n=new zt(e,s)),this.newest?(this.newest[C]=n,n[D]=this.newest):this.oldest=n,this.newest=n,++this.size,this.size>this.limit&&this.shift(),this)}shift(){const e=this.oldest;if(e)return this.oldest&&this.oldest[C]?(this.oldest=this.oldest[C],this.oldest[D]=void 0):(this.oldest=void 0,this.newest=void 0),e[C]=e[D]=void 0,this._keymap.delete(e.key),--this.size,this._onShiftListeners.forEach(s=>s(e)),[e.key,e.value]}get(e){const s=this._keymap.get(e);if(s)return this._markEntryAsUsed(s),s.value}has(e){return this._keymap.has(e)}find(e){const s=this._keymap.get(e);return s?s.value:void 0}delete(e){const s=this._keymap.get(e);if(s)return this._keymap.delete(s.key),s[C]&&s[D]?(s[D][C]=s[C],s[C][D]=s[D]):s[C]?(s[C][D]=void 0,this.oldest=s[C]):s[D]?(s[D][C]=void 0,this.newest=s[D]):this.oldest=this.newest=void 0,this.size--,s.value}clear(){this.oldest=void 0,this.newest=void 0,this.size=0,this._keymap.clear()}keys(){return new As(this.oldest)}values(){return new Cs(this.oldest)}entries(){return this[Symbol.iterator]()}[Symbol.iterator](){return new Ns(this.oldest)}forEach(e,s){typeof s!="object"&&(s=this);let n=this.oldest;for(;n;)e.call(s,n.value,n.key,this),n=n[C]}toJSON(){const e=new Array(this.size);let s=0,n=this.oldest;for(;n;)e[s++]={key:n.key,value:n.value},n=n[C];return e}toString(){let e="",s=this.oldest;for(;s;)e+=`${String(s.key)}:${s.value}`,s=s[C],s&&(e+=" < ");return e}}function G(t){let e=0;const s=Object.keys(t);for(const n of s){const r=Number(n);e=Math.max(e,r)}return e+1}function Xt(t,e,s){const n=G(s),r=s;for(let i=n-1;i>=t;i--)r[i+1]=r[i];r[t]=e}function qt(t,e,s,n){const r=t+e,i=G(s),o=s;let a=0;const l={};for(let d=t;d<r;d++){const f=o[d];f!==void 0&&(delete o[d],l[a]=f,a++)}const c=n?G(n):0,u=t-r+c,_=i;if(u>0)for(let d=_-1;d>=r;d--)o[d]!==void 0&&(o[d+u]=o[d],delete o[d]);else if(u<0)for(let d=r;d<_;d++)o[d]!==void 0&&(o[d+u]=o[d],delete o[d]);if(n)for(let d=0;d<c;d++)o[t+d]=n[d];return l}function Gr(t,e){const s=t,n=Object.keys(s),r=n.length,i=e,o=Object.keys(i),a=o.length,l={};let c=0;for(let u=0;u<r;u++,c++){const _=n[u];l[c]=s[_]}for(let u=0;u<a;u++,c++){const _=o[u];l[c]=i[_]}return l}function kr(t,e,s){const n=s;if(G(s)>0){const i={};let o=0;for(let a=t;a<=e;a++)n[a]&&(i[o]=n[a],o++);return i}return{}}function Qt(t,e,s,n){const r=t>s;if(!r&&t+e>s)throw new Error("Invalid move operation");r?$r(t,e,s,n):Vr(t,e,s,n)}function $r(t,e,s,n){const r=n,i=[];for(let o=t;o<t+e;o++)i.push(r[o]);for(let o=t-1;o>=s;o--){const a=r[o];r[o+e]=a,a==null&&delete r[o+e]}i.forEach((o,a)=>{r[s+a]=o,o==null&&delete r[s+a]})}function Vr(t,e,s,n){const r=n,i=[];for(let o=t;o<t+e;o++)i.push(r[o]);for(let o=t+e;o<s;o++){const a=r[o];r[o-e]=a,a==null&&delete r[o-e]}i.forEach((o,a)=>{r[s+a-e]=o,o==null&&delete r[s+a-e]})}class B{constructor(e={}){h(this,"_matrix");this._setOriginValue(e)}static MakeObjectMatrixSize(e){return new B({[e-1]:{}})}getMatrix(){return this._matrix}forEach(e){const s=this._matrix,n=Object.keys(s);for(const r of n){const i=Number(r),o=s[i];if(e(i,o)===!1)return this}return this}forRow(e){const s=this._matrix,n=Object.keys(s);for(const r of n){const i=Number(r),o=s[i];if(e(i,Object.keys(o).map(l=>Number(l)))===!1)return this}return this}forValue(e){const s=this._matrix,n=Object.keys(s);for(const r of n){const i=Number(r),o=s[i];if(!o)continue;const a=Object.keys(o);for(const l of a){const c=Number(l),u=o[Number(l)];if(e(i,c,u)===!1)return this}}return this}swapRow(e,s){const n=this._matrix[e],r=this._matrix[s];this._matrix[e]=r,this._matrix[s]=n}getRow(e){return this._matrix[e]}getRowOrCreate(e){let s=this.getRow(e);return s==null&&(s={},this._matrix[e]=s),s}reset(){this._setOriginValue({})}hasValue(){const e=this._matrix,s=Object.keys(e);if(s.length===0)return!1;for(const n of s){const r=Number(n),i=e[r];if(Object.keys(i).length>0)return!0}return!1}getValue(e,s){var n,r;return(r=(n=this._matrix)==null?void 0:n[e])==null?void 0:r[s]}setValue(e,s,n){const r=this.getRowOrCreate(e);r[s]=n}deleteValue(e,s){var n,r;(r=(n=this._matrix)==null?void 0:n[e])==null||delete r[s]}realDeleteValue(e,s){var n,r,i;if((r=(n=this._matrix)==null?void 0:n[e])==null||delete r[s],this.getRow(e)){const o=this.getRow(e);if(o==null)return;Object.keys(o).length===0&&((i=this._matrix)==null||delete i[e])}}setRow(e,s){this._matrix[e]=s}moveRows(e,s,n){Qt(e,s,n,this._matrix)}moveColumns(e,s,n){this.forEach((r,i)=>{Qt(e,s,n,i)})}insertRows(e,s){for(let n=e;n<e+s;n++)Xt(n,{},this._matrix)}insertColumns(e,s){for(let n=e;n<e+s;n++)this.forEach((r,i)=>{Xt(n,void 0,i)})}removeRows(e,s){qt(e,s,this._matrix)}removeColumns(e,s){this.forEach((n,r)=>{qt(e,s,r)})}getFragment(e,s,n,r){const i=new B;let o=0;for(let a=e;a<=s;a++){const l={};let c=0;for(let u=n;u<=r;u++){const _=this.getValue(a,u);l[c]=_,c++}i.setRow(o,l),o++}return i}getSlice(e,s,n,r){const i=new B;for(let o=e;o<=s;o++)for(let a=n;a<=r;a++){const l=this.getValue(o,a);l&&i.setValue(o,a,g.deepClone(l))}return i}getSizeOf(){return Object.keys(this._matrix).length}getLength(){return G(this._matrix)}getRange(){const n=this.getLength()-1;let r=0;const i=this.getLength();for(let o=0;o<i;o++){const a=this.getRow(o);if(a){const l=G(a)-1;r=l>r?l:r}}return{startRow:0,startColumn:0,endRow:n,endColumn:r}}toNativeArray(){const e=new Array;return this.forValue((s,n,r)=>{e.push(r)}),e}toArray(){const e=[];return this.forRow((s,n)=>{e[s]==null&&(e[s]=[]),n.forEach(r=>{e[s][r]=this.getValue(s,r)})}),e}toJSON(){return this._matrix}clone(){const e=JSON.stringify(this._matrix);return JSON.parse(e)}getData(){const e=JSON.stringify(this._matrix);return JSON.parse(e)}getArrayData(){let e=0,s=0,n=!1,r=!1;const i=new B;return this.forEach((o,a)=>{n||(n=!0,e=o),Object.keys(a).forEach(l=>{const c=Number(l);r?c<s&&(s=c):(r=!0,s=c);const u=this.getValue(o,c);i.setValue(o-e,c-s,u)})}),i.getData()}getDataRange(){let e=0,s=0,n=0,r=-1,i=!1,o=!1;return this.forEach((a,l)=>{i||(i=!0,e=a);const c=G(l)-1;c>n&&(n=c),Object.keys(l).forEach(u=>{const _=Number(u);o?_<s&&(s=_):(o=!0,s=_)}),a>r&&(r=a)}),{startRow:e,startColumn:s,endRow:r,endColumn:n}}getDiscreteRanges(){const e=[];return this.forEach((s,n)=>{Object.keys(n).forEach(r=>{const i=Number(r);let o=!1;for(const a of e)if(s>=a.startRow&&s<=a.endRow+1&&i>=a.startColumn&&i<=a.endColumn+1){a.endRow=Math.max(s,a.endRow),a.endColumn=Math.max(i,a.endColumn),o=!0;break}o||e.push({startRow:s,endRow:s,startColumn:i,endColumn:i})})}),e}merge(e){this.forValue((s,n)=>{const r=e.getValue(s,n);r!=null&&this.setValue(s,n,r)})}_setOriginValue(e={}){this._matrix=e}}var he=(t=>(t.INIT="init",t.FETCHING="fetching",t.DONE="done",t))(he||{});class Ls{constructor(){h(this,"status","init")}}const jr=t=>t.some(e=>e.status==="init")?"init":t.some(e=>e.status==="fetching")?"fetching":"done";var P=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(P||{}),bs=(t=>(t[t.NONE=0]="NONE",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(bs||{});function Kr(t){return[t.startRow,t.startColumn,t.endRow,t.endColumn]}const K=class K{static clone(e){return e.rangeType!==void 0?{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn,rangeType:e.rangeType}:{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn}}static equals(e,s){return e==null||s==null?!1:e.endRow===s.endRow&&e.endColumn===s.endColumn&&e.startRow===s.startRow&&e.startColumn===s.startColumn&&(e.rangeType===s.rangeType||e.rangeType===void 0&&s.rangeType===P.NORMAL||s.rangeType===void 0&&e.rangeType===P.NORMAL)}static intersects(e,s){const n=e.startRow,r=e.endRow,i=e.startColumn,o=e.endColumn,a=s.startRow,l=s.endRow,c=s.startColumn,u=s.endColumn,_=Math.abs(i+o-c-u),d=Math.abs(i-o)+Math.abs(c-u),f=Math.abs(n+r-a-l),E=Math.abs(n-r)+Math.abs(a-l);return _<=d&&f<=E}static getIntersects(e,s){const n=e.startRow,r=e.endRow,i=e.startColumn,o=e.endColumn,a=s.startRow,l=s.endRow,c=s.startColumn,u=s.endColumn;let _,d,f,E;if(a<=r)a>=n?d=a:d=n;else return null;if(l>=n)l>=r?E=r:E=l;else return null;if(c<=o)c>i?_=c:_=i;else return null;if(u>=i)u>=o?f=o:f=u;else return null;return{startRow:d,endRow:E,startColumn:_,endColumn:f,rangeType:P.NORMAL}}static contains(e,s){return e.startRow<=s.startRow&&e.endRow>=s.endRow&&e.startColumn<=s.startColumn&&e.endColumn>=s.endColumn}static realContain(e,s){return K.contains(e,s)&&(e.startRow<s.startRow||e.endRow>s.endRow||e.startColumn<s.startColumn||e.endColumn>s.endColumn)}static union(...e){return e.reduce((s,n)=>({startRow:Math.min(s.startRow,n.startRow),startColumn:Math.min(s.startColumn,n.startColumn),endRow:Math.max(s.endRow,n.endRow),endColumn:Math.max(s.endColumn,n.endColumn),rangeType:P.NORMAL}),e[0])}static subtract(e,s){if(s.startRow>=e.endRow||s.endRow<=e.startRow||s.startColumn>=e.endColumn||s.endColumn<=e.startColumn)return[e];const n=[];s.startRow>e.startRow&&n.push({startRow:e.startRow,startColumn:e.startColumn,endRow:s.startRow,endColumn:e.endColumn}),s.endRow<e.endRow&&n.push({startRow:s.endRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn});const r=Math.max(e.startRow,s.startRow),i=Math.min(e.endRow,s.endRow);return s.startColumn>e.startColumn&&n.push({startRow:r,startColumn:e.startColumn,endRow:i,endColumn:s.startColumn}),s.endColumn<e.endColumn&&n.push({startRow:r,startColumn:s.endColumn,endRow:i,endColumn:e.endColumn}),n}};h(K,"getRelativeRange",(e,s)=>({startRow:e.startRow-s.startRow,endRow:e.endRow-e.startRow,startColumn:e.startColumn-s.startColumn,endColumn:e.endColumn-e.startColumn})),h(K,"getPositionRange",(e,s)=>({startRow:e.startRow+s.startRow,endRow:e.endRow+e.startRow+s.startRow,startColumn:e.startColumn+s.startColumn,endColumn:e.endColumn+e.startColumn+s.startColumn})),h(K,"moveHorizontal",(e,s=0,n=0)=>({...e,startColumn:e.startColumn+s,endColumn:e.endColumn+s+n})),h(K,"moveVertical",(e,s=0,n=0)=>({...e,startRow:e.startRow+s,endRow:e.endRow+s+n})),h(K,"moveOffset",(e,s,n)=>({...e,startRow:e.startRow+n,endRow:e.endRow+n,startColumn:e.startColumn+s,endColumn:e.endColumn+s}));let y=K;class Yr{constructor(e,s){h(this,"_values",[]);h(this,"_keys",[]);h(this,"_keyMaps",new Map);this._values=e,this._keys=s,e.forEach(n=>{this._initKeyMap(n)})}_initKeyMap(e){this._keys.forEach(s=>{const n=e[s],r=this._keyMaps.get(s)||new Map;r.set(n,e),this._keyMaps.set(s,r)})}getValue(e){for(let s=0;s<this._keys.length;s++){const n=this._keyMaps.get(this._keys[s]);if(n!=null&&n.has(e))return n.get(e)}return null}hasValue(e){for(let s=0;s<this._keys.length;s++){const n=this._keyMaps.get(this._keys[s]);if(n!=null&&n.has(e))return!0}return!1}addValue(e){this._values.push(e),this._initKeyMap(e)}setValue(e,s,n){const r=this.getValue(e);r&&Object.keys(r).includes(s)&&(r[s]=n)}deleteValue(e){const s=this.getValue(e);if(s){this._keys.forEach(r=>{const i=this._keyMaps.get(r),o=s[r];i==null||i.delete(o)});const n=this._values.findIndex(r=>r===s);this._values.splice(n,1)}}getValues(){return this._values}getKeyMap(e){var s;return[...((s=this._keyMaps.get(e))==null?void 0:s.keys())||[]]}clear(){this._values=[],this._keys=[],this._keyMaps.clear()}}function Jt(t,e,s,n){return{forEach(r){for(let i=t;i<=e;i++)for(let o=s;o<=n;o++)r(i,o)}}}function zr(t){if(t==null||t.length===0)return Number.NaN;const e=t.toLowerCase().split(""),s=e.length,n=o=>o.charCodeAt(0)-96;let r=0,i=0;for(let o=0;o<s;o++)i=n(e[o]),r+=i*26**(s-o-1);return r===0?Number.NaN:r-1}const wt=65,vs=90,Xr=97;function qr(t){const e=vs-wt+1;let s="";for(;t>=0;)s=String.fromCharCode(t%e+wt)+s,t=Math.floor(t/e)-1;return s}function ws(t,e){let s="";for(;e>0;)s+=t,e--;return s}function Qr(t,e=!1){const s=vs-wt+1;let n=Xr;e&&(n=wt);const r=String.fromCharCode(t%s+n),i=Math.floor(t/s)+1;return ws(r,i)}function Jr(t,e){return t.zIndex>e.zIndex?1:t.zIndex===e.zIndex?0:-1}function Zr(t,e){return t.zIndex>e.zIndex?-1:t.zIndex===e.zIndex?0:1}function rt(t="index",e=1){return(s,n)=>s[t]>n[t]?e:s[t]===n[t]?0:-e}var Ds=(t=>(t[t.PARAGRAPH=0]="PARAGRAPH",t[t.SECTION_BREAK=1]="SECTION_BREAK",t[t.TABLE=2]="TABLE",t[t.TABLE_ROW=3]="TABLE_ROW",t[t.TABLE_CELL=4]="TABLE_CELL",t))(Ds||{}),_e=(t=>(t.PARAGRAPH="\r",t.SECTION_BREAK=`
|
|
4
|
-
`,t.TABLE_START="",t.TABLE_ROW_START="\x1B",t.TABLE_CELL_START="",t.TABLE_CELL_END="",t.TABLE_ROW_END="",t.TABLE_END="",t.CUSTOM_RANGE_START="",t.CUSTOM_RANGE_END="",t.COLUMN_BREAK="\v",t.PAGE_BREAK="\f",t.DOCS_END="\0",t.TAB=" ",t.CUSTOM_BLOCK="\b",t.LETTER="",t.SPACE=" ",t))(_e||{});function de(t){const e=[];for(const s of t){const{st:n,ed:r,ts:i}=s;if(s.sId===void 0&&delete s.sId,n===r||g.isEmptyObject(i)&&s.sId==null)continue;if(e.length===0){e.push(s);continue}const o=e.pop();Rs(s,o)&&g.hasIntersectionBetweenTwoRanges(o.st,o.ed,s.st,s.ed)?e.push({...s,st:o.st,ed:r}):e.push(o,s)}return e}function Ts(t,e,s,n){var c;const{textRuns:r}=t;if(r==null)return;const i=[],o=r.length;let a=!1;const l=(c=e.textRuns)!=null?c:[];if(l.length)for(let u=0,_=l.length;u<_;u++){const d=l[u];d.st+=n,d.ed+=n}for(let u=0;u<o;u++){const _=r[u],{st:d,ed:f}=_;if(f<n)i.push(_);else if(n>=d&&n<=f)if(a)_.st+=s,_.ed+=s,i.push(_);else{a=!0,_.ed+=s;const E=[];if(l.length){const R={..._,st:d,ed:l[0].st};E.push(R),E.push(...l);const b=l[l.length-1],v={..._,st:b.ed,ed:f+s};E.push(v)}else E.push(_);i.push(...E)}else _.st+=s,_.ed+=s,a||(a=!0,i.push(...l)),i.push(_)}a||(a=!0,i.push(...l)),t.textRuns=de(i)}function fe(t,e,s,n){const{paragraphs:r}=t;if(r==null)return;const{paragraphs:i,dataStream:o}=e,a=[];let l=-1;for(let u=0,_=r.length;u<_;u++){const d=r[u],{startIndex:f}=d;f>=n&&(d.startIndex+=s),l===-1&&f>=n&&(l=u),a.push(d.startIndex)}let c=-1;if(i){for(let u=0,_=i.length;u<_;u++){const d=i[u];d.startIndex+=n;const f=d.startIndex;c=a.indexOf(f)}if(o===_e.PARAGRAPH&&i.length===1){const u=r[l],_=i[0],d=u.paragraphStyle,f=u.bullet;u.paragraphStyle=_.paragraphStyle,u.bullet=_.bullet,_.paragraphStyle=d,_.bullet=f}c!==-1&&r.splice(c,1),r.push(...i),r.sort(rt("startIndex"))}}function yr(t,e,s,n){const{sectionBreaks:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:c}=l;c>=n&&(l.startIndex+=s)}const i=e.sectionBreaks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=n}r.push(...i),r.sort(rt("startIndex"))}}function Us(t,e,s,n){const{customBlocks:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:c}=l;c>=n&&(l.startIndex+=s)}const i=e.customBlocks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=n}r.push(...i),r.sort(rt("startIndex"))}}function Ee(t,e,s,n){const{tables:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:c,endIndex:u}=l;c>n?(l.startIndex+=s,l.endIndex+=s):u>=n-1&&(l.endIndex+=s)}const i=e.tables;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=n,l.endIndex+=n}r.push(...i),r.sort(rt("startIndex"))}}function ti(t,e,s,n){const{customRanges:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:c,endIndex:u}=l;c>n?(l.startIndex+=s,l.endIndex+=s):u>=n-1&&(l.endIndex+=s)}const i=e.customRanges;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=n,l.endIndex+=n}r.push(...i),r.sort(rt("startIndex"))}}function Ms(t,e,s){const{textRuns:n}=t,r=s,i=s+e,o=[];if(n){const a=[];for(let l=0,c=n.length;l<c;l++){const u=n[l],{st:_,ed:d}=u;if(r<=_&&i>=d){o.push({...u,st:_-r,ed:d-r});continue}else _<=r&&d>=i?(o.push({...u,st:r-r,ed:i-r}),u.ed-=e):r>=_&&r<d?(o.push({...u,st:r-r,ed:d-r}),u.ed=r):i>_&&i<=d?(o.push({...u,st:_-r,ed:i-r}),u.st=i-e,u.ed-=e):_>=i&&(u.st-=e,u.ed-=e);a.push(u)}t.textRuns=a}return o}function Ps(t,e,s){const{paragraphs:n}=t,r=s,i=s+e,o=[];if(n){const a=[];for(let l=0,c=n.length;l<c;l++){const u=n[l],{startIndex:_}=u;if(_>=r&&_<i){o.push({...u,startIndex:_-s});continue}else _>=i&&(u.startIndex-=e);a.push(u)}t.paragraphs=a}return o}function xs(t,e,s){const{sectionBreaks:n}=t,r=s,i=s+e-1,o=[];if(n){const a=[];for(let l=0,c=n.length;l<c;l++){const u=n[l],{startIndex:_}=u;if(_>=r&&_<=i){o.push({...u,startIndex:_-s});continue}else _>i&&(u.startIndex-=e);a.push(u)}t.sectionBreaks=a}return o}function Hs(t,e,s){const{customBlocks:n}=t,r=s,i=s+e-1,o=[];if(n){const a=[];for(let l=0,c=n.length;l<c;l++){const u=n[l],{startIndex:_}=u;if(_>=r&&_<=i){o.push({...u,startIndex:_-s});continue}else _>i&&(u.startIndex-=e);a.push(u)}t.customBlocks=a}return o}function Fs(t,e,s){const{tables:n}=t,r=s,i=s+e-1,o=[];if(n){const a=[];for(let l=0,c=n.length;l<c;l++){const u=n[l],{startIndex:_,endIndex:d}=u;if(r<=_&&i>=d){o.push({...u,startIndex:_-s,endIndex:d-s});continue}else if(_<=r&&d>=i){const f=ce(_,d,r,i);u.startIndex=f[0],u.endIndex=f[1]}else i<_&&(u.startIndex-=e,u.endIndex-=e);a.push(u)}t.tables=a}return o}function ps(t,e,s){const{customRanges:n}=t,r=s,i=s+e-1,o=[];if(n){const a=[];for(let l=0,c=n.length;l<c;l++){const u=n[l],{startIndex:_,endIndex:d}=u;if(r<=_&&i>=d){o.push({...u,startIndex:_-s,endIndex:d-s});continue}else if(_<=r&&d>=i){const f=ce(_,d,r,i);u.startIndex=f[0],u.endIndex=f[1]}else i<_&&(u.startIndex-=e,u.endIndex-=e);a.push(u)}t.customRanges=a}return o}function ei(t,e,s){const{dataStream:n}=t,r=s,i=s+e,o=Ms(t,e,s),a=Ps(t,e,s),l=xs(t,e,s),c=Hs(t,e,s),u=Fs(t,e,s),_=ps(t,e,s);let d="";return n&&(t.dataStream=Is(n,r,i),d=n.slice(r,i)),{dataStream:d,textRuns:o,paragraphs:a,sectionBreaks:l,customBlocks:c,tables:u,customRanges:_}}function si(t,e,s,n){t.dataStream=Os(t.dataStream,n,e.dataStream),Ts(t,e,s,n),fe(t,e,s,n),yr(t,e,s,n),Us(t,e,s,n),Ee(t,e,s,n),ti(t,e,s,n)}var Ws=(t=>(t[t.character=0]="character",t[t.paragraph=1]="paragraph",t[t.table=2]="table",t[t.numbering=3]="numbering",t))(Ws||{}),Bs=(t=>(t[t.TAB=0]="TAB",t[t.SPACE=1]="SPACE",t[t.NOTHING=2]="NOTHING",t))(Bs||{}),ht=(t=>(t[t.GLYPH_TYPE_UNSPECIFIED=0]="GLYPH_TYPE_UNSPECIFIED",t[t.NONE=1]="NONE",t[t.DECIMAL=2]="DECIMAL",t[t.ZERO_DECIMAL=3]="ZERO_DECIMAL",t[t.UPPER_ALPHA=4]="UPPER_ALPHA",t[t.ALPHA=5]="ALPHA",t[t.UPPER_ROMAN=6]="UPPER_ROMAN",t[t.ROMAN=7]="ROMAN",t))(ht||{}),V=(t=>(t[t.BULLET_ALIGNMENT_UNSPECIFIED=0]="BULLET_ALIGNMENT_UNSPECIFIED",t[t.START=1]="START",t[t.CENTER=2]="CENTER",t[t.END=3]="END",t))(V||{}),Gs=(t=>(t[t.HYPERLINK=0]="HYPERLINK",t[t.FIELD=1]="FIELD",t[t.SDT=2]="SDT",t[t.BOOKMARK=3]="BOOKMARK",t[t.COMMENT=4]="COMMENT",t[t.CUSTOM=5]="CUSTOM",t))(Gs||{}),ks=(t=>(t[t.DRAWING=0]="DRAWING",t[t.CUSTOM=1]="CUSTOM",t))(ks||{}),$s=(t=>(t[t.DEFAULT=0]="DEFAULT",t[t.LINES=1]="LINES",t[t.LINES_AND_CHARS=2]="LINES_AND_CHARS",t[t.SNAP_TO_CHARS=3]="SNAP_TO_CHARS",t))($s||{}),Vs=(t=>(t[t.SECTION_TYPE_UNSPECIFIED=0]="SECTION_TYPE_UNSPECIFIED",t[t.CONTINUOUS=1]="CONTINUOUS",t[t.NEXT_PAGE=2]="NEXT_PAGE",t[t.EVEN_PAGE=3]="EVEN_PAGE",t[t.ODD_PAGE=4]="ODD_PAGE",t))(Vs||{}),js=(t=>(t[t.COLUMN_SEPARATOR_STYLE_UNSPECIFIED=0]="COLUMN_SEPARATOR_STYLE_UNSPECIFIED",t[t.NONE=1]="NONE",t[t.BETWEEN_EACH_COLUMN=2]="BETWEEN_EACH_COLUMN",t))(js||{}),Ks=(t=>(t[t.NORMAL=0]="NORMAL",t[t.TBRL=1]="TBRL",t[t.LRTBV=2]="LRTBV",t))(Ks||{}),Ys=(t=>(t[t.TEXT_RUN=0]="TEXT_RUN",t[t.AUTO_TEXT=1]="AUTO_TEXT",t[t.PAGE_BREAK=2]="PAGE_BREAK",t[t.COLUMN_BREAK=3]="COLUMN_BREAK",t[t.FOOT_NOTE_REFERENCE=4]="FOOT_NOTE_REFERENCE",t[t.HORIZONTAL_RULE=5]="HORIZONTAL_RULE",t[t.EQUATION=6]="EQUATION",t[t.DRAWING=7]="DRAWING",t[t.PERSON=8]="PERSON",t[t.RICH_LINK=9]="RICH_LINK",t))(Ys||{}),zs=(t=>(t[t.BOTH_SIDES=0]="BOTH_SIDES",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.LARGEST=3]="LARGEST",t))(zs||{}),Xs=(t=>(t[t.INLINE=0]="INLINE",t[t.WRAP_NONE=1]="WRAP_NONE",t[t.WRAP_POLYGON=2]="WRAP_POLYGON",t[t.WRAP_SQUARE=3]="WRAP_SQUARE",t[t.WRAP_THROUGH=4]="WRAP_THROUGH",t[t.WRAP_TIGHT=5]="WRAP_TIGHT",t[t.WRAP_TOP_AND_BOTTOM=6]="WRAP_TOP_AND_BOTTOM",t))(Xs||{}),qs=(t=>(t[t.NAMED_STYLE_TYPE_UNSPECIFIED=0]="NAMED_STYLE_TYPE_UNSPECIFIED",t[t.NORMAL_TEXT=1]="NORMAL_TEXT",t[t.TITLE=2]="TITLE",t[t.SUBTITLE=3]="SUBTITLE",t[t.HEADING_1=4]="HEADING_1",t[t.HEADING_2=5]="HEADING_2",t[t.HEADING_3=6]="HEADING_3",t[t.HEADING_4=7]="HEADING_4",t[t.HEADING_5=8]="HEADING_5",t[t.HEADING_6=9]="HEADING_6",t))(qs||{}),Qs=(t=>(t[t.AUTO=0]="AUTO",t[t.AT_LEAST=1]="AT_LEAST",t[t.EXACT=2]="EXACT",t))(Qs||{}),Js=(t=>(t[t.DASH_STYLE_UNSPECIFIED=0]="DASH_STYLE_UNSPECIFIED",t[t.SOLID=1]="SOLID",t[t.DOT=2]="DOT",t[t.DASH=3]="DASH",t))(Js||{}),Zs=(t=>(t[t.TAB_STOP_ALIGNMENT_UNSPECIFIED=0]="TAB_STOP_ALIGNMENT_UNSPECIFIED",t[t.START=1]="START",t[t.CENTER=2]="CENTER",t[t.END=3]="END",t))(Zs||{}),ys=(t=>(t.EVENLY_DISTRIBUTED="0",t.FIXED_WIDTH="1",t))(ys||{}),tn=(t=>(t[t.CONTENT_ALIGNMENT_UNSPECIFIED=0]="CONTENT_ALIGNMENT_UNSPECIFIED",t[t.CONTENT_ALIGNMENT_UNSUPPORTED=1]="CONTENT_ALIGNMENT_UNSUPPORTED",t[t.TOP=2]="TOP",t[t.MIDDLE=3]="MIDDLE",t[t.BOTTOM=4]="BOTTOM",t))(tn||{}),en=(t=>(t.NORMAL="normal",t.BOLD="bold",t.ITALIC="italic",t))(en||{}),sn=(t=>(t[t.CHARACTER=0]="CHARACTER",t[t.COLUMN=1]="COLUMN",t[t.INSIDE_MARGIN=2]="INSIDE_MARGIN",t[t.LEFT_MARGIN=3]="LEFT_MARGIN",t[t.MARGIN=4]="MARGIN",t[t.OUTSIDE_MARGIN=5]="OUTSIDE_MARGIN",t[t.PAGE=6]="PAGE",t[t.RIGHT_MARGIN=7]="RIGHT_MARGIN",t))(sn||{}),nn=(t=>(t[t.BOTTOM_MARGIN=0]="BOTTOM_MARGIN",t[t.INSIDE_MARGIN=1]="INSIDE_MARGIN",t[t.LINE=2]="LINE",t[t.MARGIN=3]="MARGIN",t[t.OUTSIDE_MARGIN=4]="OUTSIDE_MARGIN",t[t.PAGE=5]="PAGE",t[t.PARAGRAPH=6]="PARAGRAPH",t[t.TOP_MARGIN=7]="TOP_MARGIN",t))(nn||{}),rn=(t=>(t[t.POINT=0]="POINT",t[t.LINE=1]="LINE",t[t.CHARACTER=2]="CHARACTER",t))(rn||{}),on=(t=>(t[t.CENTER=0]="CENTER",t[t.INSIDE=1]="INSIDE",t[t.LEFT=2]="LEFT",t[t.OUTSIDE=3]="OUTSIDE",t[t.RIGHT=4]="RIGHT",t))(on||{}),an=(t=>(t[t.BOTTOM=0]="BOTTOM",t[t.CENTER=1]="CENTER",t[t.INSIDE=2]="INSIDE",t[t.OUTSIDE=3]="OUTSIDE",t[t.TOP=4]="TOP",t))(an||{}),ln=(t=>(t[t.compressPunctuation=0]="compressPunctuation",t[t.compressPunctuationAndJapaneseKana=1]="compressPunctuationAndJapaneseKana",t[t.doNotCompress=2]="doNotCompress",t))(ln||{}),un=(t=>(t[t.PORTRAIT=0]="PORTRAIT",t[t.LANDSCAPE=1]="LANDSCAPE",t))(un||{}),Dt=(t=>(t.BULLET_LIST="BULLET_LIST",t.ORDER_LIST="ORDER_LIST",t))(Dt||{});const ni={BULLET_LIST:{listType:"BULLET_LIST",nestingLevel:[{bulletAlignment:V.START,glyphFormat:" %0",textStyle:{fs:12},startNumber:0,glyphSymbol:"●",hanging:21,indentStart:21},{bulletAlignment:V.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"■",hanging:21,indentStart:42},{bulletAlignment:V.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"◆",hanging:21,indentStart:63}]},ORDER_LIST:{listType:"ORDER_LIST",nestingLevel:[{bulletAlignment:V.START,glyphFormat:" %1.",textStyle:{fs:12},startNumber:0,glyphType:ht.DECIMAL,hanging:21,indentStart:21},{bulletAlignment:V.START,glyphFormat:" %1.%2)",textStyle:{fs:12},startNumber:0,glyphType:ht.DECIMAL,hanging:21,indentStart:42},{bulletAlignment:V.START,glyphFormat:" %1.%2.%3.",textStyle:{fs:12},startNumber:0,glyphType:ht.DECIMAL,hanging:21,indentStart:63}]}};function ri(t,e,s,n,r){const i=ii(t,e,s,n,r),o=oi(t,e,s,n,r),a=ai(t,e,s,n,r),l=li(t,e,s,n,r),c=ui(t,e,s,n,r),u=ci(t,e,s,n,r);return{dataStream:"",textRuns:i,paragraphs:o,sectionBreaks:a,customBlocks:l,tables:c,customRanges:u}}function ii(t,e,s,n,r){const{textRuns:i}=t,{textRuns:o}=e;if(i==null||o==null)return;const a=Ms(t,s,n);if(r!==T.REPLACE){const l=cn(o,a,r);e.textRuns=l}return Ts(t,e,s,n),a}function cn(t,e,s){if(e.length===0)return t;t=g.deepClone(t),e=g.deepClone(e);const n=[],r=t.length,i=e.length;let o=0,a=0,l=null;function c(){return l?(n.push(l),l=null,!0):!1}for(;o<r&&a<i;){const{st:f,ed:E,ts:R}=t[o],{st:b,ed:v,ts:p,sId:k}=e[a];let it;s===T.COVER?it={...p,...R}:it={...R,...p},E<b?(c()||n.push(t[o]),o++):v<f?(c()||n.push(e[a]),a++):(n.push({st:Math.min(f,b),ed:Math.max(f,b),ts:f<b?{...R}:{...p},sId:f<b?void 0:k}),n.push({st:Math.max(f,b),ed:Math.min(E,v),ts:it,sId:k}),E<v?(o++,e[a].st=E):(a++,t[o].st=v),l={st:Math.min(E,v),ed:Math.max(E,v),ts:E<v?{...p}:{...R},sId:E<v?k:void 0})}c();const u=n[n.length-1],_=t[r-1],d=e[i-1];return u.ed!==Math.max(_.ed,d.ed)&&(_.ed>d.ed?n.push(_):n.push(d)),de(n)}function oi(t,e,s,n,r){const{paragraphs:i}=t,{paragraphs:o}=e;if(i==null||o==null)return;const a=Ps(t,s,n);if(r!==T.REPLACE){const l=[];for(const c of o){const{startIndex:u,paragraphStyle:_,bullet:d}=c;let f=[];for(const E of a){const{startIndex:R,paragraphStyle:b,bullet:v}=E;let p,k;if(r===T.COVER?(p={...b,..._},k={listId:"",listType:Dt.BULLET_LIST,nestingLevel:0,textStyle:{},...v,...d}):(p={..._,...b},k={listId:"",listType:Dt.BULLET_LIST,nestingLevel:0,textStyle:{},...d,...v}),u===R){f.push({startIndex:u,paragraphStyle:p,bullet:k});break}}l.push(...f),f=[]}e.paragraphs=l}return fe(t,e,s,n),a}function ai(t,e,s,n,r){const{sectionBreaks:i}=t,{sectionBreaks:o}=e;if(i==null||o==null)return;const a=xs(t,s,n);if(r!==T.REPLACE){const l=[];for(const c of o){const{startIndex:u}=c;let _=[];for(const d of a){const{startIndex:f}=d;if(u===f){r===T.COVER?_.push({...d,...c}):_.push({...c,...d});break}}l.push(..._),_=[]}e.sectionBreaks=l}return fe(t,e,s,n),a}function li(t,e,s,n,r){const{customBlocks:i}=t,{customBlocks:o}=e;if(i==null||o==null)return;const a=Hs(t,s,n);if(r!==T.REPLACE){const l=[];for(const c of o){const{startIndex:u}=c;let _=[];for(const d of a){const{startIndex:f}=d;if(u===f){r===T.COVER?_.push({...d,...c}):_.push({...c,...d});break}}l.push(..._),_=[]}e.customBlocks=l}return Us(t,e,s,n),a}function ui(t,e,s,n,r){const{tables:i}=t,{tables:o}=e;if(i==null||o==null)return;const a=Fs(t,s,n);if(r!==T.REPLACE){const l=[];for(const c of o){const{startIndex:u,endIndex:_}=c;let d=[];for(const f of a){const{startIndex:E,endIndex:R}=f;if(E>=u&&R<=_){r===T.COVER?d.push({...f,...c}):d.push({...c,...f});break}}l.push(...d),d=[]}e.tables=l}return Ee(t,e,s,n),a}function ci(t,e,s,n,r){const{customRanges:i}=t,{tables:o}=e;if(i==null||o==null)return;const a=ps(t,s,n);if(r!==T.REPLACE){const l=[];for(const c of o){const{startIndex:u,endIndex:_}=c;let d=[];for(const f of a){const{startIndex:E,endIndex:R}=f;if(E>=u&&R<=_){r===T.COVER?d.push({...f,...c}):d.push({...c,...f});break}}l.push(...d),d=[]}e.customRanges=l}return Ee(t,e,s,n),a}var m=(t=>(t.RETAIN="r",t.INSERT="i",t.DELETE="d",t))(m||{});function ge(t,e,s){const{dataStream:n,textRuns:r=[],paragraphs:i=[]}=t,o={dataStream:n.slice(e,s)},a=[];for(const c of r){const u=g.deepClone(c),{st:_,ed:d}=u;g.hasIntersectionBetweenTwoRanges(_,d,e,s)&&(e>=_&&e<=d?a.push({...u,st:e,ed:Math.min(s,d)}):s>=_&&s<=d?a.push({...u,st:Math.max(e,_),ed:s}):a.push(u))}a.length&&(o.textRuns=a.map(c=>{const{st:u,ed:_}=c;return{...c,st:u-e,ed:_-e}}));const l=[];for(const c of i){const{startIndex:u}=c;u>=e&&u<=s&&l.push(g.deepClone(c))}return l.length&&(o.paragraphs=l.map(c=>({...c,startIndex:c.startIndex-e}))),o}function Zt(t,e,s=T.COVER){if(e.dataStream!=="")throw new Error("Cannot compose other body with non-empty dataStream");const n={dataStream:t.dataStream},{textRuns:r=[],paragraphs:i=[]}=t,{textRuns:o=[],paragraphs:a=[]}=e,l=cn(o,r,s);l.length&&(n.textRuns=l);const c=[];let u=0,_=0;for(;u<i.length&&_<a.length;){const d=i[u],f=a[_],{startIndex:E}=d,{startIndex:R}=f;E===R?(c.push(g.deepMerge(d,f)),u++,_++):E<R?(c.push(g.deepClone(d)),u++):(c.push(g.deepClone(f)),_++)}return u<i.length&&c.push(...i.slice(u)),_<a.length&&c.push(...a.slice(_)),c.length&&(n.paragraphs=c),n}function hi(t){const{body:e}=t;if(e==null)return!0;const{textRuns:s=[],paragraphs:n=[]}=e;return s.length===0&&n.length===0}const Re={id:"default_doc",documentStyle:{}};class _i{constructor(e){h(this,"snapshot");this.snapshot={...Re,...e}}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get body(){return this.snapshot.body}get zoomRatio(){var e;return((e=this.snapshot.settings)==null?void 0:e.zoomRatio)||1}getBody(){return this.snapshot.body}getShouldRenderLoopImmediately(){return this.snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this.snapshot.container}getParentRenderUnitId(){return this.snapshot.parentRenderUnitId}getSnapshot(){return this.snapshot}updateDocumentId(e){this.snapshot.id=e}updateDocumentRenderConfig(e){const{documentStyle:s}=this.snapshot;s.renderConfig==null?s.renderConfig=e:s.renderConfig={...s.renderConfig,...e}}updateDocumentDataMargin(e){const{t:s,l:n,b:r,r:i}=e,{documentStyle:o}=this.snapshot;s!=null&&(o.marginTop=s),n!=null&&(o.marginLeft=n),r!=null&&(o.marginBottom=r),i!=null&&(o.marginRight=i)}updateDocumentDataPageSize(e,s){const{documentStyle:n}=this.snapshot;if(!n.pageSize){e=e!=null?e:Number.POSITIVE_INFINITY,s=s!=null?s:Number.POSITIVE_INFINITY,n.pageSize={width:e,height:s};return}e!==void 0&&(n.pageSize.width=e),s!==void 0&&(n.pageSize.height=s)}updateDrawing(e,s){const{drawings:n}=this,{width:r,height:i,left:o,top:a}=s,l=n==null?void 0:n[e];if(!l)return;const c=l.objectTransform;c.size.width=r,c.size.height=i,c.positionH.posOffset=o,c.positionV.posOffset=a}setZoomRatio(e=1){this.snapshot.settings==null?this.snapshot.settings={zoomRatio:e}:this.snapshot.settings.zoomRatio=1}}class et extends _i{constructor(s){var r;super(s);h(this,"_unitId");h(this,"headerModelMap",new Map);h(this,"footerModelMap",new Map);const n=6;this._unitId=(r=this.snapshot.id)!=null?r:g.generateRandomId(n),this._initializeHeaderFooterModel()}dispose(){this.headerModelMap.forEach(s=>{s.dispose()}),this.footerModelMap.forEach(s=>{s.dispose()})}getRev(){var s;return(s=this.snapshot.rev)!=null?s:1}incrementRev(){this.snapshot.rev=this.getRev()+1}getSettings(){return this.snapshot.settings}reset(s){if(s.id&&s.id!==this._unitId)throw new Error("Cannot reset a document model with a different unit id!");this.snapshot={...Re,...s},this._initializeHeaderFooterModel()}getSelfOrHeaderFooterModel(s){if(s!=null){if(this.headerModelMap.has(s))return this.headerModelMap.get(s);if(this.footerModelMap.has(s))return this.footerModelMap.get(s)}return this}getUnitId(){return this._unitId}apply(s){const n=[],r=new Qe;return r.reset(),s.forEach(i=>{if(i=g.deepClone(i),i.t===m.RETAIN){const{coverType:o,body:a,len:l,segmentId:c}=i;if(a!=null){const u=this._updateApply(a,l,r.cursor,o,c);n.push({...i,t:m.RETAIN,coverType:T.REPLACE,body:u})}else n.push({...i,t:m.RETAIN});r.moveCursor(l)}else if(i.t===m.INSERT){const{body:o,len:a,segmentId:l,line:c}=i;this._insertApply(o,a,r.cursor,l),r.moveCursor(a),n.push({t:m.DELETE,len:a,line:c,segmentId:l})}else if(i.t===m.DELETE){const{len:o,segmentId:a}=i,l=this._deleteApply(o,r.cursor,a);n.push({...i,t:m.INSERT,body:l})}else throw new Error(`Unknown action type for action: ${i}.`)}),n}sliceBody(s,n){const r=this.getBody();if(r!=null)return ge(r,s,n)}_updateApply(s,n,r,i=T.COVER,o){if(s==null)throw new Error("updateBody is none");const a=this.snapshot,l=Ot(a,o);if(l==null)throw new Error("no body has changed");return ri(l,s,n,r,i)}_deleteApply(s,n,r){const i=this.snapshot,o=Ot(i,r);if(o==null)throw new Error("no body has changed");return s<=0?{dataStream:""}:ei(o,s,n)}_insertApply(s,n,r,i){const o=this.snapshot,a=Ot(o,i);if(n!==0){if(a==null)throw new Error("no body has changed");si(a,s,n,r)}}_initializeHeaderFooterModel(){const{headers:s,footers:n}=this.getSnapshot();if(s)for(const r in s){const i=s[r];this.headerModelMap.set(r,new et(i))}if(n)for(const r in n){const i=n[r];this.footerModelMap.set(r,new et(i))}}updateDocumentId(s){super.updateDocumentId(s),this._unitId=s}}const di="0.1.0-beta.5",at={sheetId:"",range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},fi={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},Ei={startRow:0,startColumn:0,endRow:0,endColumn:0},gi={row:0,column:0},hn={id:"",sheetOrder:[],name:"",appVersion:di,locale:xt.ZH_CN,styles:{},sheets:{},resources:[]},It={ff:"Times New Roman",fs:14,it:O.FALSE,bl:O.FALSE,ul:{s:O.FALSE},st:{s:O.FALSE},ol:{s:O.FALSE},tr:{a:0,v:O.FALSE},td:_t.UNSPECIFIED,cl:{rgb:"#000"},bg:{rgb:"#fff"},ht:X.UNSPECIFIED,vt:J.UNSPECIFIED,tb:Z.UNSPECIFIED,pd:{t:0,r:0,b:0,l:0}},_n={id:"default_slide",title:"defaultSlide",pageSize:{width:300,height:300}};var dn=(t=>(t.ARRAY_CONVERTOR="ARRAY_CONVERTOR",t.MATRIX_CONVERTOR="MATRIX_CONVERTOR",t))(dn||{});class fn{constructor(e={}){h(this,"_styles");h(this,"_cacheMap",new Ss(1e5));this._styles=e,this._generateCacheMap()}each(e){return Object.entries(this._styles).forEach(e),this}search(e,s){if(this._cacheMap.has(s))return this._cacheMap.get(s);const n=this._getExistingStyleId(e);return n||"-1"}get(e){return typeof e!="string"?e:(e=String(e),this._styles[e])}add(e,s){const n=g.generateRandomId(6);return this._styles[n]=e,this._cacheMap.set(s,n),n}setValue(e){if(e==null)return;const s=JSON.stringify(e),n=this.search(e,s);return n!=="-1"?n:this.add(e,s)}toJSON(){return this._styles}getStyleByCell(e){let s;e&&g.isObject(e.s)?s=e.s:s=(e==null?void 0:e.s)&&this.get(e.s);const n=e==null?void 0:e.interceptorStyle;return n?{...s,...n}:s}_generateCacheMap(){const{_styles:e,_cacheMap:s}=this;for(const n in e){const r=JSON.stringify(e[n]);s.set(r,n)}}_getExistingStyleId(e){const{_styles:s}=this;for(const n in s)if(g.diffValue(s[n],e))return n;return null}}function Ri(t){return t&&(t.s!==void 0||t.p!==void 0||t.v!==void 0||t.t!==void 0||t.f!==void 0||t.si!==void 0)}function mi(t){if(t.t!==void 0)return t.t;if(typeof t.v=="string")return ct.STRING;if(typeof t.v=="number")return ct.NUMBER;if(typeof t.v=="boolean")return ct.BOOLEAN}function Oi(t){if(t==null)return!0;const{v:e,f:s,si:n,p:r,s:i}=t;return!(!(e==null||typeof e=="string"&&e.length===0)||s!=null&&s.length>0||n!=null&&n.length>0||r!=null)}function Ii(t){return t!=null&&(typeof t=="string"||typeof t=="number"||typeof t=="boolean")}var me=(t=>(t[t.SLIDE=0]="SLIDE",t[t.MASTER=1]="MASTER",t[t.LAYOUT=2]="LAYOUT",t[t.HANDOUT_MASTER=3]="HANDOUT_MASTER",t[t.NOTES_MASTER=4]="NOTES_MASTER",t))(me||{}),En=(t=>(t[t.SHAPE=0]="SHAPE",t[t.IMAGE=1]="IMAGE",t[t.TEXT=2]="TEXT",t[t.SPREADSHEET=3]="SPREADSHEET",t[t.DOCUMENT=4]="DOCUMENT",t[t.SLIDE=5]="SLIDE",t))(En||{}),gn=(t=>(t[t.RELATIVE_SLIDE_LINK_UNSPECIFIED=0]="RELATIVE_SLIDE_LINK_UNSPECIFIED",t[t.NEXT_SLIDE=1]="NEXT_SLIDE",t[t.PREVIOUS_SLIDE=2]="PREVIOUS_SLIDE",t[t.FIRST_SLIDE=3]="FIRST_SLIDE",t[t.LAST_SLIDE=4]="LAST_SLIDE",t))(gn||{});class Ai{constructor(e,s){h(this,"_columnData",{});this._config=e,this._columnData=s}getColumnData(){return this._columnData}getColVisible(e){const{_columnData:s}=this,n=s[e];return n?n.hd!==O.TRUE:!0}getHiddenCols(e=0,s=this.getSize()-1){const n=[];let r=!1,i=-1;for(let o=e;o<=s;o++){const a=this.getColVisible(o);r&&a?(r=!1,n.push({rangeType:P.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&!a&&(r=!0,i=o)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:s,rangeType:P.COLUMN}),n}getVisibleCols(e=0,s=this.getSize()-1){const n=[];let r=!1,i=-1;for(let o=e;o<=s;o++){const a=this.getColVisible(o);r&&!a?(r=!1,n.push({rangeType:P.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&a&&(r=!0,i=o)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:s,rangeType:P.COLUMN}),n}getColumnDatas(e,s){const n={};let r=0;for(let i=e;i<e+s;i++){const o=this.getColumnOrCreate(i);n[r]=o,r++}return n}getSize(){return G(this._columnData)}getColumnWidth(e){const{_columnData:s}=this,n=this._config;let r=0;return r=(s[e]||{hd:O.FALSE,w:n.defaultColumnWidth}).w||n.defaultColumnWidth,r}getColumn(e){const s=this._columnData[e];if(s)return s}getColumnOrCreate(e){const{_columnData:s}=this,n=this._config,r=s[e];if(r)return r;const i={w:n.defaultColumnWidth,hd:O.FALSE};return this._columnData[e]=i,i}}function mt(t,e){const{textRuns:s=[],paragraphs:n=[],sectionBreaks:r=[]}=e;let i=0;for(const o of s){const{ts:a={},st:l,ed:c}=o;if(a[t]==null)return O.FALSE;switch(t){case"bl":case"it":{if(a[t]===O.FALSE)return O.FALSE;break}case"ul":case"st":{if(a[t].s===O.FALSE)return O.FALSE;break}default:throw new Error(`unknown style key: ${t} in IStyleBase`)}i+=c-l}return e.dataStream.length-n.length-r.length===i?O.TRUE:O.FALSE}class st{constructor(e,s,n){h(this,"_range");h(this,"_worksheet");this._deps=n,this._range=s,this._worksheet=e}static foreach(e,s){const{startRow:n,startColumn:r,endRow:i,endColumn:o}=e;for(let a=n;a<=i;a++)for(let l=r;l<=o;l++)s(a,l)}getRangeData(){return this._range}getValue(){return this.getValues()[0][0]}getValues(){const{startRow:e,endRow:s,startColumn:n,endColumn:r}=this._range,i=[];for(let o=e;o<=s;o++){const a=[];for(let l=n;l<=r;l++)a.push(this.getMatrix().getValue(o,l)||null);i.push(a)}return i}getMatrix(){const{startRow:e,endRow:s,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new B;for(let a=e;a<=s;a++)for(let l=n;l<=r;l++)o.setValue(a,l,i.getValue(a,l)||null);return o}getMatrixObject(){const{startRow:e,endRow:s,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new B;for(let a=e;a<=s;a++)for(let l=n;l<=r;l++)o.setValue(a-e,l-n,i.getValue(a,l)||{});return o}getA1Notation(){const{startRow:e,endRow:s,startColumn:n,endColumn:r}=this._range;let i,o;return n<r?(i=g.numToWord(n+1)+(e+1),o=g.numToWord(r+1)+(s+1)):(i=g.numToWord(r+1)+(s+1),o=g.numToWord(n+1)+(e+1)),i===o?`${i}`:`${i}:${o}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){const e=this._deps.getStyles();return this.getValues().map(s=>s.map(n=>{var i;const r=e.getStyleByCell(n);return((i=r==null?void 0:r.bg)==null?void 0:i.rgb)||It.bg.rgb}))}getCell(e,s){const{startRow:n,endRow:r,startColumn:i,endColumn:o}=this._range,a={startRow:n+e,endRow:n+e,startColumn:i+s,endColumn:i+s};return new st(this._worksheet,a,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(e={}){return this.getObjectValues(e)[0][0]}getObjectValues(e={}){var a;const{startRow:s,endRow:n,startColumn:r,endColumn:i}=this._range,o=this._worksheet.getCellMatrix().getFragment(s,n,r,i).getData();if(e.isIncludeStyle){const l=this._deps.getStyles();for(let c=0;c<=n-s;c++)for(let u=0;u<=i-r;u++){if(o==null||((a=o==null?void 0:o[c])==null?void 0:a[u])==null)continue;const _=o[c][u].s;_&&(o[c][u].s=l.get(_))}}return o}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){const e=this._deps.getStyles();return this.getValues().map(s=>s.map(n=>{var i;const r=e.getStyleByCell(n);return((i=r==null?void 0:r.cl)==null?void 0:i.rgb)||It.cl.rgb}))}getFontFamilies(){return this._getStyles("ff")}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles("ul")}getUnderline(){var s,n;const{p:e}=(s=this.getValue())!=null?s:{};return e&&Array.isArray((n=e.body)==null?void 0:n.textRuns)&&e.body.textRuns.length>0?mt("ul",e.body)===O.TRUE?{s:O.TRUE}:{s:O.FALSE}:this.getUnderlines()[0][0]}getOverlines(){return this._getStyles("ol")}getOverline(){return this.getOverlines()[0][0]}getStrikeThrough(){var s,n;const{p:e}=(s=this.getValue())!=null?s:{};return e&&Array.isArray((n=e.body)==null?void 0:n.textRuns)&&e.body.textRuns.length>0?mt("st",e.body)===O.TRUE?{s:O.TRUE}:{s:O.FALSE}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles("st")}getFontSize(){return this.getFontSizes()[0][0]}getFontSizes(){return this._getStyles("fs")}getBorder(){return this.getBorders()[0][0]}getBorders(){return this._getStyles("bd")}getFontStyle(){var s,n;const{p:e}=(s=this.getValue())!=null?s:{};return e&&Array.isArray((n=e.body)==null?void 0:n.textRuns)&&e.body.textRuns.length>0?mt("it",e.body)===O.TRUE?Nt.ITALIC:Nt.NORMAL:this.getFontStyles()[0][0]}getFontStyles(){return this._getStyles("it")}getFontWeight(){var s,n;const{p:e}=(s=this.getValue())!=null?s:{};return e&&Array.isArray((n=e.body)==null?void 0:n.textRuns)&&e.body.textRuns.length>0?mt("bl",e.body)===O.TRUE?St.BOLD:St.NORMAL:this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles("bl")}getGridId(){return this._worksheet.getSheetId()}getHeight(){const{_range:e,_worksheet:s}=this,{startRow:n,endRow:r}=e;let i=0;for(let o=0;o<=r-n;o++){const a=s.getRowHeight(o);i+=a}return i}getHorizontalAlignment(){return this.getHorizontalAlignments()[0][0]}getHorizontalAlignments(){return this._getStyles("ht")}getLastColumn(){return this._range.endColumn}getLastRow(){return this._range.endRow}getNumColumns(){const{startColumn:e,endColumn:s}=this._range;return s-e+1}getNumRows(){const{startRow:e,endRow:s}=this._range;return s-e+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(e=>e.map(s=>(s==null?void 0:s.p)||""))}getRowIndex(){return this._range.startRow}getSheet(){return this._worksheet}getTextDirection(){return this.getTextDirections()[0][0]}getTextDirections(){return this._getStyles("td")}getTextRotation(){return this.getTextRotations()[0][0]}getTextRotations(){return this._getStyles("tr")}getTextStyle(){return this.getTextStyles()[0][0]}getTextStyles(){const e=this._deps.getStyles();return this.getValues().map(s=>s.map(n=>e.getStyleByCell(n)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles("vt")}getWidth(){const{_range:e,_worksheet:s}=this,{startColumn:n,endColumn:r}=e;let i=0;for(let o=0;o<=r-n;o++)i+=s.getColumnWidth(o);return i}getWrap(){return this.getWraps()[0][0]}getWraps(){return this._getStyles("tb")}getWrapStrategies(){return this._getStyles("tb")}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(e){st.foreach(this._range,e)}_getStyles(e){const s=this._deps.getStyles();return this.getValues().map(n=>n.map(r=>{const i=s&&s.getStyleByCell(r);return i&&i[e]||It[e]}))}}class Ci{constructor(e,s){h(this,"_rowData");this._config=e,this._rowData=s}getRowData(){return this._rowData}getRowDatas(e,s){const n={};let r=0;for(let i=e;i<e+s;i++){const o=this.getRowOrCreate(i);n[r]=o,r++}return n}getRowHeight(e,s=1){const{_rowData:n}=this,r=this._config;let i=0;for(let o=0;o<s;o++){const a=n[o+e]||{hd:O.FALSE,h:r.defaultRowHeight},{ia:l,ah:c,h:u=r.defaultRowHeight}=a;i+=(l==null||l===O.TRUE)&&typeof c=="number"?c:u}return i}getRow(e){return this._rowData[e]}getRowOrCreate(e){const{_rowData:s}=this,n=s[e];if(n)return n;const r=this._config,i={hd:O.FALSE,h:r.defaultRowHeight};return s[e]=i,i}getHiddenRows(e=0,s=this.getSize()-1){const n=[];let r=!1,i=-1;for(let o=e;o<=s;o++){const a=this.getRowVisible(o);r&&a?(r=!1,n.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:P.ROW})):!r&&!a&&(r=!0,i=o)}return r&&n.push({startRow:i,endRow:s,startColumn:0,endColumn:0,rangeType:P.ROW}),n}getVisibleRows(e=0,s=this.getSize()-1){const n=[];let r=!1,i=-1;for(let o=e;o<=s;o++){const a=this.getRowVisible(o);r&&!a?(r=!1,n.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:P.ROW})):!r&&a&&(r=!0,i=o)}return r&&n.push({startRow:i,endRow:s,startColumn:0,endColumn:0,rangeType:P.ROW}),n}getRowVisible(e){const s=this.getRow(e);return s?s.hd!==O.TRUE:!0}getSize(){return G(this._rowData)}}const Ni="DEFAULT_WORKSHEET_ROW_COUNT",Rn=1e3,Si="DEFAULT_WORKSHEET_COLUMN_COUNT",mn=20,Li="DEFAULT_WORKSHEET_ROW_HEIGHT",On=19,bi="DEFAULT_WORKSHEET_COLUMN_WIDTH",In=73,vi="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",An=46,wi="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Cn=20;function Nn(t){const e={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:O.FALSE,rowCount:Rn,columnCount:mn,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:In,defaultRowHeight:On,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:O.TRUE,rowHeader:{width:An,hidden:O.FALSE},columnHeader:{height:Cn,hidden:O.FALSE},selections:["A1"],rightToLeft:O.FALSE};return Object.keys(e).forEach(s=>{const n=s;typeof t[n]>"u"&&(t[n]=e[n])}),t}class Sn extends U{constructor(){super(...arguments);h(this,"_cellContentInterceptors",[]);h(this,"_rowFilteredInterceptors",[]);h(this,"_rowVisibleInterceptors",[]);h(this,"_colVisibleInterceptors",[])}dispose(){super.dispose(),this._cellContentInterceptors.length=0,this._rowFilteredInterceptors.length=0,this._rowVisibleInterceptors.length=0,this._colVisibleInterceptors.length=0}getCell(s,n){for(const r of this._cellContentInterceptors){const i=r.getCell(s,n);if(typeof i<"u")return i}return null}registerCellContentInterceptor(s){if(this._cellContentInterceptors.includes(s))throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptors.push(s),L(()=>Y(this._cellContentInterceptors,s))}registerRowFilteredInterceptor(s){if(this._rowFilteredInterceptors.includes(s))throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptors.push(s),L(()=>Y(this._rowFilteredInterceptors,s))}registerRowVisibleInterceptor(s){if(this._rowVisibleInterceptors.includes(s))throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowVisibleInterceptors.push(s),L(()=>Y(this._rowVisibleInterceptors,s))}registerColVisibleInterceptor(s){if(this._colVisibleInterceptors.includes(s))throw new Error("[SheetViewModel]: Interceptor already registered.");return this._colVisibleInterceptors.push(s),L(()=>Y(this._colVisibleInterceptors,s))}}class dt{constructor(e,s){h(this,"_initialized");h(this,"_sheetId");h(this,"_snapshot");h(this,"_cellData");h(this,"_rowManager");h(this,"_columnManager");h(this,"_viewModel");var o;this._styles=s,this._snapshot=Nn(e);const{columnData:n,rowData:r,cellData:i}=this._snapshot;this._sheetId=(o=this._snapshot.id)!=null?o:g.generateRandomId(6),this._initialized=!1,this._cellData=new B(i),this._rowManager=new Ci(this._snapshot,r),this._columnManager=new Ai(this._snapshot,n),this._viewModel=new Sn}__interceptViewModel(e){e(this._viewModel)}getSnapshot(){return this._snapshot}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const e=this.getCellMatrix(),s=this.getMergeData();let n=-1,r=-1,i=-1,o=-1,a=!1,l=!1;return e.forEach((c,u)=>{Object.keys(u).forEach(_=>{const d=+_,f=e.getValue(c,d),E=f!=null&&f.s?this._styles.get(f.s):null,R=(E==null?void 0:E.bd)&&(E.bd.b||E.bd.l||E.bd.r||E.bd.t||E.bd.bc_tr||E.bd.bl_tr||E.bd.ml_tr||E.bd.tl_bc||E.bd.tl_br||E.bd.tl_mr);(f&&(f.v||f.p)||E!=null&&E.bg||R)&&(a?n=Math.min(n,c):(n=c,a=!0),r=Math.max(r,c),l?i=Math.min(i,d):(l=!0,i=d),o=Math.max(o,d))})}),s.forEach(c=>{a?n=Math.min(n,c.startRow):(n=c.startRow,a=!0),r=Math.max(r,c.endRow),l?i=Math.min(i,c.startColumn):(i=c.startColumn,a=!0),o=Math.max(o,c.endColumn)}),!a||!l?null:{startColumn:i,startRow:n,endColumn:o,endRow:r}}getRowManager(){return this._rowManager}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:e}=this,s=g.deepClone(e);return new dt(s,this._styles)}getMergeData(){return this._snapshot.mergeData}getMergedCells(e,s){const n=this._snapshot.mergeData,r=[];for(let i=0;i<n.length;i++){const o=n[i];y.intersects({startRow:e,startColumn:s,endRow:e,endColumn:s},o)&&r.push(o)}return r.length?r:null}getMergedCell(e,s){const n=this._snapshot.mergeData;for(let r=0;r<n.length;r++){const i=n[r];if(y.intersects({startRow:e,startColumn:s,endRow:e,endColumn:s},i))return i}return null}getCell(e,s){return e<0||s<0?null:this._viewModel.getCell(e,s)}getCellRaw(e,s){return this.getCellMatrix().getValue(e,s)}getMatrixWithMergedCells(e,s,n,r){const i=this.getCellMatrix(),o=this._snapshot.mergeData.filter(l=>y.intersects({startRow:e,startColumn:s,endRow:n,endColumn:r},l)),a=new B;return Jt(e,n,s,r).forEach((l,c)=>{const u=i.getValue(l,c);u&&a.setValue(l,c,u)}),o.forEach(l=>{const{startColumn:c,startRow:u,endColumn:_,endRow:d}=l;Jt(u,d,c,_).forEach((f,E)=>{f===u&&E===c&&a.setValue(f,E,{...i.getValue(f,E),rowSpan:d-u+1,colSpan:_-c+1}),(f!==u||E!==c)&&a.realDeleteValue(f,E)})}),a}getRange(e,s,n,r){return typeof e=="object"?new st(this,e,{getStyles:()=>this._styles}):new st(this,{startRow:e,startColumn:s,endColumn:r||s,endRow:n||e},{getStyles:()=>this._styles})}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:e}=this,{columnCount:s}=e;return s}getMaxRows(){const{_snapshot:e}=this,{rowCount:s}=e;return s}getRowCount(){return this._snapshot.rowCount}setRowCount(e){this._snapshot.rowCount=e}getColumnCount(){return this._snapshot.columnCount}setColumnCount(e){this._snapshot.columnCount=e}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:e}=this,{showGridlines:s}=e;return s===0}getTabColor(){const{_snapshot:e}=this,{tabColor:s}=e;return s}getColumnWidth(e){return this.getColumnManager().getColumnWidth(e)}getRowHeight(e){return this.getRowManager().getRowHeight(e)}getRowVisible(e){return this.getRowManager().getRowVisible(e)}getHiddenRows(e,s){const n=this.getMaxColumns()-1,r=this._rowManager.getHiddenRows(e,s);return r.forEach(i=>i.endColumn=n),r}getColVisible(e){return this._columnManager.getColVisible(e)}getHiddenCols(e,s){const n=this.getMaxRows()-1,r=this._columnManager.getHiddenCols(e,s);return r.forEach(i=>i.endRow=n),r}getVisibleRows(){const e=this.getRowCount();return this._rowManager.getVisibleRows(0,e-1)}getVisibleCols(){const e=this.getColumnCount();return this._columnManager.getVisibleCols(0,e-1)}isRightToLeft(){const{_snapshot:e}=this,{rightToLeft:s}=e;return s}getLastRowWithContent(){return this._cellData.getLength()-1}getLastColumnWithContent(){return this._cellData.getRange().endColumn}cellHasValue(e){return e&&(e.v!==void 0||e.f!==void 0||e.p!==void 0)}}var Di=Object.defineProperty,Ti=Object.getOwnPropertyDescriptor,Ui=(t,e,s,n)=>{for(var r=n>1?void 0:n?Ti(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&Di(e,s,r),r},Mi=(t,e)=>(s,n)=>e(s,n,t);function Pi(t,e){return`${t.getUnitId()}|${e.getSheetId()}`}exports.Workbook=class extends U{constructor(s={},n){super();h(this,"_sheetCreated$",new A.Subject);h(this,"sheetCreated$",this._sheetCreated$.asObservable());h(this,"_sheetDisposed$",new A.Subject);h(this,"sheetDisposed$",this._sheetDisposed$.asObservable());h(this,"_activeSheet$",new A.BehaviorSubject(null));h(this,"activeSheet$",this._activeSheet$.asObservable());h(this,"_worksheets");h(this,"_styles");h(this,"_snapshot");h(this,"_unitId");h(this,"_count");this._logService=n,this._snapshot=g.commonExtend(hn,s);const{styles:r}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=g.generateRandomId(6)),this._unitId=this._snapshot.id,this._styles=new fn(r),this._count=1,this._worksheets=new Map,this._passWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._snapshot.name}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete()}save(){return g.deepClone(this._snapshot)}static isIRangeType(s){return typeof s=="string"||"startRow"in s||"row"in s}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}getUnitId(){return this._unitId}getRev(){var s;return(s=this._snapshot.rev)!=null?s:1}incrementRev(){this._snapshot.rev=this.getRev()+1}getShouldRenderLoopImmediately(){return this._snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this._snapshot.container}addWorksheet(s,n,r){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[s])return!1;i[s]=r,o.splice(n,0,s);const a=new dt(r,this._styles);return this._worksheets.set(s,a),this._sheetCreated$.next(a),!0}getParentRenderUnitId(){return this._snapshot.parentRenderUnitId}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}getConfig(){return this._snapshot}getIndexBySheetId(s){const{sheetOrder:n}=this._snapshot;return n.findIndex(r=>r===s)}getRawActiveSheet(){return this._activeSheet}getActiveSheet(){const s=this.getRawActiveSheet();if(!s){const n=this._worksheets.get(this._snapshot.sheetOrder[0]);return this.setActiveSheet(n),n}return s}setActiveSheet(s){this._activeSheet$.next(s)}removeSheet(s){var r;return this._worksheets.get(s)?(((r=this._activeSheet)==null?void 0:r.getSheetId())===s&&this.setActiveSheet(null),this._worksheets.delete(s),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(s),1),delete this._snapshot.sheets[s],!0):!1}getActiveSheetIndex(){const{sheetOrder:s}=this._snapshot;return s.findIndex(n=>this._worksheets.get(n)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:s}=this._snapshot;return s.map(n=>this._worksheets.get(n))}getSheetsName(){const{sheetOrder:s}=this._snapshot,n=[];return s.forEach(r=>{const i=this._worksheets.get(r);i&&n.push(i.getName())}),n}getSheetIndex(s){const{sheetOrder:n}=this._snapshot;return n.findIndex(r=>s.getSheetId()===r)}getSheetBySheetName(s){const{sheetOrder:n}=this._snapshot,r=n.find(i=>this._worksheets.get(i).getName()===s);return this._worksheets.get(r)}getSheetBySheetId(s){return this._worksheets.get(s)}getSheetByIndex(s){const{sheetOrder:n}=this._snapshot;return this._worksheets.get(n[s])}getHiddenWorksheets(){return this.getSheets().filter(s=>s.getConfig().hidden===O.TRUE).map(s=>s.getConfig().id)}transformRangeType(s){if(typeof s=="string")return this._getCellRange(s);if(typeof s!="string"&&"row"in s){const n=s;return{sheetId:"",range:{startRow:n.row[0],startColumn:n.column[0],endRow:n.row[1],endColumn:n.column[1]}}}return typeof s!="string"&&"startRow"in s?{sheetId:"",range:s}:at}load(s){this._snapshot=s}checkSheetName(s){return this.getSheetsName().includes(s)}uniqueSheetName(s="Sheet1"){let n=s;for(;this.checkSheetName(n);)n=s+this._count,this._count++;return n}generateNewSheetName(s){let n=s+this._count;for(;this.checkSheetName(n);)n=s+this._count,this._count++;return n}_getCellRange(s){var u,_,d,f,E;let n="",r="";if(s.indexOf("!")>-1){const R=s.split("!");n=R[0],r=R[1],n=n.replace(/\\'/g,"'").replace(/''/g,"'"),n.substring(0,1)==="'"&&n.substring(n.length-1,1)==="'"&&(n=n.substring(1,n.length-1))}else r=s;if(r.indexOf(":")===-1){const R=Number.parseInt(r.replace(/[^0-9]/g,""),10)-1,b=g.ABCatNum(r.replace(/[^A-Za-z]/g,""));return!Number.isNaN(R)&&!Number.isNaN(b)?{sheetId:n,range:{startRow:R,endRow:R,startColumn:b,endColumn:b}}:at}r=r.split(":");const i=[0,0],o=[0,0],a=((u=this.getSheetBySheetName(n))==null?void 0:u.getMaxRows())||((_=this.getActiveSheet())==null?void 0:_.getMaxRows()),l=((d=this.getSheetBySheetName(n))==null?void 0:d.getMaxColumns())||((f=this.getActiveSheet())==null?void 0:f.getMaxColumns());return i[0]=Number.parseInt(r[0].replace(/[^0-9]/g,""),10)-1,i[1]=Number.parseInt(r[1].replace(/[^0-9]/g,""),10)-1,Number.isNaN(i[0])&&(i[0]=0),Number.isNaN(i[1])&&(i[1]=a),i[0]>i[1]||(o[0]=g.ABCatNum(r[0].replace(/[^A-Za-z]/g,"")),o[1]=g.ABCatNum(r[1].replace(/[^A-Za-z]/g,"")),Number.isNaN(o[0])&&(o[0]=0),Number.isNaN(o[1])&&(o[1]=l),o[0]>o[1])?at:{sheetId:((E=this.getSheetBySheetName(n))==null?void 0:E.getSheetId())||"",range:{startRow:i[0],endRow:i[1],startColumn:o[0],endColumn:o[1]}}}_passWorksheetSnapshots(){const{_snapshot:s,_worksheets:n}=this,{sheets:r,sheetOrder:i}=s;if(g.isEmptyObject(r)){const o=g.generateRandomId();r[o]={id:o}}for(const o in r){const a=r[o],{name:l}=a;a.name=this.uniqueSheetName(l),a.name!==l&&this._logService.error(`The worksheet name ${l} is duplicated, we change it to ${a.name}`);const c=new dt(a,this._styles);n.set(o,c),i.includes(o)||i.push(o)}}};exports.Workbook=Ui([Mi(1,q)],exports.Workbook);class Oe{constructor(e){h(this,"_snapshot");h(this,"_unitId");var s;this._snapshot={..._n,...e},this._unitId=(s=this._snapshot.id)!=null?s:g.generateRandomId(6)}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var e;return(e=this._snapshot.body)==null?void 0:e.pages}getPageOrder(){var e;return(e=this._snapshot.body)==null?void 0:e.pageOrder}getPage(e){const s=this.getPages();return s==null?void 0:s[e]}getElementsByPage(e){var s;return(s=this.getPage(e))==null?void 0:s.pageElements}getElement(e,s){var n;return(n=this.getElementsByPage(e))==null?void 0:n[s]}getPageSize(){return this._snapshot.pageSize}addPage(){return{id:"cover_1",pageType:me.SLIDE,zIndex:1,title:"cover",description:"this is first page, cover",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}}const Tt="FOCUSING_SHEET",yt="FOCUSING_DOC",te="FOCUSING_SLIDE",xi="FOCUSING_EDITOR_BUT_HIDDEN",Ln="EDITOR_ACTIVATED",Hi="FOCUSING_EDITOR_INPUT_FORMULA",bn="FOCUSING_FORMULA_EDITOR",Fi="FOCUSING_UNIVER_EDITOR";var pi=Object.defineProperty,Wi=Object.getOwnPropertyDescriptor,Bi=(t,e,s,n)=>{for(var r=n>1?void 0:n?Wi(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&pi(e,s,r),r},Gi=(t,e)=>(s,n)=>e(s,n,t),vn=(t=>(t[t.UNKNOWN=0]="UNKNOWN",t[t.DOC=1]="DOC",t[t.SHEET=2]="SHEET",t[t.SLIDE=3]="SLIDE",t))(vn||{});const nt=I.createIdentifier("univer.current");let ee=class extends U{constructor(e,s){super();h(this,"_focused",null);h(this,"_focused$",new A.BehaviorSubject(null));h(this,"focused$",this._focused$.asObservable());h(this,"_currentSheet$",new A.BehaviorSubject(null));h(this,"currentSheet$",this._currentSheet$.asObservable());h(this,"_currentDoc$",new A.BehaviorSubject(null));h(this,"currentDoc$",this._currentDoc$.asObservable());h(this,"_currentSlide$",new A.BehaviorSubject(null));h(this,"currentSlide$",this._currentSlide$.asObservable());h(this,"_sheetAdded$",new A.Subject);h(this,"sheetAdded$",this._sheetAdded$.asObservable());h(this,"_docAdded$",new A.Subject);h(this,"docAdded$",this._docAdded$.asObservable());h(this,"_slideAdded$",new A.Subject);h(this,"slideAdded$",this._slideAdded$.asObservable());h(this,"_sheetDisposed$",new A.Subject);h(this,"sheetDisposed$",this._sheetDisposed$.asObservable());h(this,"_docDisposed$",new A.Subject);h(this,"docDisposed$",this._docDisposed$.asObservable());h(this,"_slideDisposed$",new A.Subject);h(this,"slideDisposed$",this._slideDisposed$.asObservable());h(this,"_sheets",[]);h(this,"_docs",[]);h(this,"_slides",[]);this._handler=e,this._contextService=s}dispose(){super.dispose(),this._focused$.complete(),this._currentDoc$.complete(),this._currentSheet$.complete(),this._currentSlide$.complete(),this._sheetAdded$.complete(),this._docAdded$.complete(),this._slideAdded$.complete(),this._sheetDisposed$.complete(),this._docDisposed$.complete(),this._slideDisposed$.complete()}createDoc(e){return this._handler.createUniverDoc(e)}createSheet(e){return this._handler.createUniverSheet(e)}createSlide(e){return this._handler.createUniverSlide(e)}addSheet(e){this._sheets.push(e),this._sheetAdded$.next(e),this.setCurrentUniverSheetInstance(e.getUnitId())}changeDoc(e,s){const n=this._docs.find(r=>r.getUnitId()===e);if(n!=null){const r=this._docs.indexOf(n);this._docs.splice(r,1)}this.addDoc(s)}addDoc(e){this._docs.push(e),this._docAdded$.next(e),this.setCurrentUniverDocInstance(e.getUnitId())}addSlide(e){this._slides.push(e),this._slideAdded$.next(e),this.setCurrentUniverSlideInstance(e.getUnitId())}getUniverSheetInstance(e){return this._sheets.find(s=>s.getUnitId()===e)}getUniverDocInstance(e){return this._docs.find(s=>s.getUnitId()===e)}getUniverSlideInstance(e){return this._slides.find(s=>s.getUnitId()===e)}getAllUniverSheetsInstance(){return this._sheets}getAllUniverDocsInstance(){return this._docs}getAllUniverSlidesInstance(){return this._slides}setCurrentUniverSheetInstance(e){this._currentSheet$.next(this.getUniverSheetInstance(e)||null)}setCurrentUniverSlideInstance(e){this._currentSlide$.next(this.getUniverSlideInstance(e)||null)}setCurrentUniverDocInstance(e){this._currentDoc$.next(this.getUniverDocInstance(e)||null)}getCurrentUniverSheetInstance(){const e=this._currentSheet$.getValue();if(!e)throw new Error("No current sheet!");return e}getCurrentUniverDocInstance(){const e=this._currentDoc$.getValue();if(!e)throw new Error("No current doc!");return e}getCurrentUniverSlideInstance(){const e=this._currentSlide$.getValue();if(!e)throw new Error("No current slide!");return e}focusUniverInstance(e){e&&(this._focused=this.getUniverSheetInstance(e)||this.getUniverDocInstance(e)||this.getUniverSlideInstance(e)||null),this._focused$.next(e),[yt,Tt,te].forEach(s=>this._contextService.setContextValue(s,!1)),this._focused instanceof exports.Workbook?this._contextService.setContextValue(Tt,!0):this._focused instanceof et?this._contextService.setContextValue(yt,!0):this._focused instanceof Oe&&this._contextService.setContextValue(te,!0)}getFocusedUniverInstance(){return this._focused}getDocumentType(e){if(this.getUniverDocInstance(e))return 1;if(this.getUniverSheetInstance(e))return 2;if(this.getUniverSlideInstance(e))return 3;throw new Error(`[UniverInstanceService]: No document with unitId ${e}`)}disposeDocument(e){const s=this.getUniverDocInstance(e);if(s){const i=this._docs.indexOf(s);return this._docs.splice(i,1),this._docDisposed$.next(s),this.focusUniverInstance(null),!0}const n=this.getUniverSheetInstance(e);if(n){const i=this._sheets.indexOf(n);return this._sheets.splice(i,1),this._sheetDisposed$.next(n),this.focusUniverInstance(null),!0}const r=this.getUniverSlideInstance(e);if(r){const i=this._slides.indexOf(r);return this._slides.splice(i,1),this._slideDisposed$.next(r),this.focusUniverInstance(null),!0}return!1}};ee=Bi([Gi(1,tt)],ee);var S=(t=>(t[t.Starting=0]="Starting",t[t.Ready=1]="Ready",t[t.Rendered=2]="Rendered",t[t.Steady=3]="Steady",t))(S||{});const ki={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"},At=new Map;function Ie(t,e){return function(r){Ae(t,e)}}function Ae(t,e){At.has(t)||At.set(t,[]),At.get(t).push(e)}var $i=Object.defineProperty,Vi=Object.getOwnPropertyDescriptor,wn=(t,e,s,n)=>{for(var r=n>1?void 0:n?Vi(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&$i(e,s,r),r},se=(t,e)=>(s,n)=>e(s,n,t);exports.LifecycleService=class extends U{constructor(s){super();h(this,"_lifecycle$",new A.BehaviorSubject(S.Starting));h(this,"lifecycle$",this._lifecycle$.asObservable());this._logService=s,this._reportProgress(S.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(s){if(s<this.stage)throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");s!==this.stage&&(this._reportProgress(s),this._lifecycle$.next(s))}dispose(){this._lifecycle$.complete(),super.dispose()}subscribeWithPrevious(){return new A.Observable(s=>(this.stage===S.Starting||(this.stage===S.Ready?s.next(S.Starting):this.stage===S.Rendered?(s.next(S.Starting),s.next(S.Ready)):(s.next(S.Starting),s.next(S.Ready),s.next(S.Rendered))),this._lifecycle$.subscribe(s)))}_reportProgress(s){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${ki[s]}".`)}};exports.LifecycleService=wn([se(0,q)],exports.LifecycleService);let z=class extends U{constructor(e,s){super();h(this,"_started",!1);this._lifecycleService=e,this._injector=s}start(){this._started||(this._started=!0,this.disposeWithMe(L(this._lifecycleService.subscribeWithPrevious().subscribe(e=>this.initModulesOnStage(e)))))}initModulesOnStage(e){const s=At.get(e);s==null||s.forEach(n=>{this._injector.has(n)&&this._injector.get(n)})}};z=wn([se(0,I.Inject(exports.LifecycleService)),se(1,I.Inject(I.Injector))],z);class lt extends U{constructor(){super();h(this,"_currentLocale",xt.ZH_CN);h(this,"_locales",null);h(this,"localeChanged$",new A.Subject);h(this,"t",(s,...n)=>{if(!this._locales)throw new Error("Locale not initialized");function r(a,l){const c=l.shift();if(c&&a&&c in a){const u=a[c];return l.length>0&&(typeof u=="object"||Array.isArray(u))?r(u,l):u}return null}const i=s.split("."),o=r(this._locales[this._currentLocale],i);if(typeof o=="string"){let a=o;return n.forEach((l,c)=>{a=a.replace(`{${c}}`,l)}),a}else return s});this.disposeWithMe(L(()=>this.localeChanged$.complete()))}load(s){var n;this._locales=g.deepMerge((n=this._locales)!=null?n:{},s)}setLocale(s){this._currentLocale=s,this.localeChanged$.next()}getLocales(){var s;return(s=this._locales)==null?void 0:s[this._currentLocale]}}const Ce=I.createIdentifier("resource-manager-service"),Dn=I.createIdentifier("ResourcePersistenceService");Ae(S.Ready,Dn);var ji=Object.defineProperty,Ki=Object.getOwnPropertyDescriptor,Yi=(t,e,s,n)=>{for(var r=n>1?void 0:n?Ki(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&ji(e,s,r),r},Ue=(t,e)=>(s,n)=>e(s,n,t);const Ne=I.createIdentifier("univer.permission-service"),Me="PERMISSION";exports.PermissionService=class extends U{constructor(s,n){super();h(this,"_permissionPointMap",new Map);h(this,"deletePermissionPoint",(s,n)=>{const r=this._permissionPointMap.get(s);if(r){const i=r.get(n);i&&(i.complete(),this._permissionPointMap.delete(n))}});h(this,"addPermissionPoint",(s,n)=>{const r=this._permissionPointMap.get(s)||new Map;return r.has(n.id)?!1:(r.set(n.id,new A.BehaviorSubject(n)),this._permissionPointMap.set(s,r),!0)});h(this,"updatePermissionPoint",(s,n,r)=>{const i=this._permissionPointMap.get(s);if(!i)return;const o=i.get(n);if(o){const a=o.getValue();a.value=r,a.status=he.DONE,o.next(a)}});h(this,"getPermissionPoint",(s,n)=>{const r=this._permissionPointMap.get(s);if(!r)return;const i=r.get(n);if(i)return i.getValue()});this._resourceManagerService=s,this._univerInstanceService=n}_init(){this.disposeWithMe(L(this._univerInstanceService.sheetAdded$.subscribe(s=>{this._resourceManagerService.registerPluginResource(s.getUnitId(),Me,{onChange:(n,r)=>{r.forEach(i=>{this.getPermissionPoint(n,i.id)?this.updatePermissionPoint(n,i.id,i.value):this.addPermissionPoint(n,i)})},toJson:n=>this._toJson(n),parseJson:n=>this._parseJson(n)})}))),this.disposeWithMe(L(this._univerInstanceService.sheetDisposed$.subscribe(s=>{this._resourceManagerService.disposePluginResource(s.getUnitId(),Me)})))}_toJson(s){const n=this._permissionPointMap.get(s);let r=[];return n&&(r=[...n.keys()].reduce((i,o)=>{const a=n.get(o);return a&&i.push(a.getValue()),i},[])),JSON.stringify(r)}_parseJson(s){return JSON.parse(s)}composePermission$(s,n){const r=this._permissionPointMap.get(s),i=n.map(o=>{const a=r==null?void 0:r.get(o);if(!a)throw new Error(`${o} permissionPoint is not exist`);return a.asObservable()});return A.combineLatest(i).pipe(Vn.map(o=>(o.every(a=>this._permissionPointMap.get(a.id)),o)))}composePermission(s,n){const r=this._permissionPointMap.get(s);return n.map(o=>{const a=r==null?void 0:r.get(o);if(!a)throw new Error(`${o} permissionPoint is not exist`);return a.getValue()})}};exports.PermissionService=Yi([Ie(S.Starting,exports.PermissionService),Ue(0,I.Inject(Ce)),Ue(1,I.Inject(nt))],exports.PermissionService);const Tn="univer.editable";class Ct extends Ls{constructor(s){super();h(this,"id",Tn);h(this,"value",!0);h(this,"unitID");this.unitID=s}}var zi=Object.defineProperty,Xi=Object.getOwnPropertyDescriptor,qi=(t,e,s,n)=>{for(var r=n>1?void 0:n?Xi(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&zi(e,s,r),r},Pe=(t,e)=>(s,n)=>e(s,n,t);exports.UniverPermissionService=class extends U{constructor(e,s){super(),this._permissionService=e,this._univerInstanceService=s,this._init()}_init(){this._univerInstanceService.sheetAdded$.subscribe(e=>{const s=new Ct(e.getUnitId());this._permissionService.addPermissionPoint(e.getUnitId(),s)})}getEditable(e){let s=e;s||(s=this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId());const n=new Ct(s),r=this._permissionService.getPermissionPoint(s,n.id);return r==null?void 0:r.value}setEditable(e,s){const n=new Ct(e);this._permissionService.updatePermissionPoint(e,n.id,s)}};exports.UniverPermissionService=qi([Ie(S.Starting,exports.UniverPermissionService),Pe(0,I.Inject(Ne)),Pe(1,I.Inject(nt))],exports.UniverPermissionService);class Un extends U{constructor(){super(...arguments);h(this,"_resourceMap",new Map);h(this,"_register$",new A.Subject);h(this,"register$",this._register$.asObservable())}getAllResource(s){const n=this._resourceMap.get(s);return n?[...n.keys()].reduce((r,i)=>{const o=n.get(i);return o&&r.push({unitID:s,resourceName:i,hook:o}),r},[]):[]}registerPluginResource(s,n,r){const i=this._resourceMap.get(s)||new Map;if(i.has(n))throw new Error("the pluginName is registered");return i.set(n,r),this._resourceMap.set(s,i),this._register$.next({unitID:s,resourceName:n,hook:r}),L(()=>i.delete(n))}disposePluginResource(s,n){const r=this._resourceMap.get(s);r==null||r.delete(n)}dispose(){this._register$.complete(),this._resourceMap.clear()}}class ne extends U{constructor(){super();h(this,"_currentTheme");h(this,"_currentTheme$",new A.BehaviorSubject({}));h(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(L(()=>this._currentTheme$.complete()))}getCurrentTheme(){if(!this._currentTheme)throw new Error("[ThemeService]: current theme is not set!");return this._currentTheme}setTheme(s){this._currentTheme=s,this._currentTheme$.next(s)}}const Mn="__defaultDocumentNormalEditorSpecialUnitId_20231006__",Pn="__defaultDocumentFormulaBarEditorSpecialUnitId_20231012__",Qi=`\r
|
|
4
|
+
`,t.TABLE_START="",t.TABLE_ROW_START="\x1B",t.TABLE_CELL_START="",t.TABLE_CELL_END="",t.TABLE_ROW_END="",t.TABLE_END="",t.CUSTOM_RANGE_START="",t.CUSTOM_RANGE_END="",t.COLUMN_BREAK="\v",t.PAGE_BREAK="\f",t.DOCS_END="\0",t.TAB=" ",t.CUSTOM_BLOCK="\b",t.LETTER="",t.SPACE=" ",t))(_e||{});function de(t){const e=[];for(const s of t){const{st:n,ed:r,ts:i}=s;if(s.sId===void 0&&delete s.sId,n===r||g.isEmptyObject(i)&&s.sId==null)continue;if(e.length===0){e.push(s);continue}const o=e.pop();Rs(s,o)&&g.hasIntersectionBetweenTwoRanges(o.st,o.ed,s.st,s.ed)?e.push({...s,st:o.st,ed:r}):e.push(o,s)}return e}function Ts(t,e,s,n){var c;const{textRuns:r}=t;if(r==null)return;const i=[],o=r.length;let a=!1;const l=(c=e.textRuns)!=null?c:[];if(l.length)for(let u=0,_=l.length;u<_;u++){const d=l[u];d.st+=n,d.ed+=n}for(let u=0;u<o;u++){const _=r[u],{st:d,ed:f}=_;if(f<n)i.push(_);else if(n>=d&&n<=f)if(a)_.st+=s,_.ed+=s,i.push(_);else{a=!0,_.ed+=s;const E=[];if(l.length){const R={..._,st:d,ed:l[0].st};E.push(R),E.push(...l);const b=l[l.length-1],v={..._,st:b.ed,ed:f+s};E.push(v)}else E.push(_);i.push(...E)}else _.st+=s,_.ed+=s,a||(a=!0,i.push(...l)),i.push(_)}a||(a=!0,i.push(...l)),t.textRuns=de(i)}function fe(t,e,s,n){const{paragraphs:r}=t;if(r==null)return;const{paragraphs:i,dataStream:o}=e,a=[];let l=-1;for(let u=0,_=r.length;u<_;u++){const d=r[u],{startIndex:f}=d;f>=n&&(d.startIndex+=s),l===-1&&f>=n&&(l=u),a.push(d.startIndex)}let c=-1;if(i){for(let u=0,_=i.length;u<_;u++){const d=i[u];d.startIndex+=n;const f=d.startIndex;c=a.indexOf(f)}if(o===_e.PARAGRAPH&&i.length===1){const u=r[l],_=i[0],d=u.paragraphStyle,f=u.bullet;u.paragraphStyle=_.paragraphStyle,u.bullet=_.bullet,_.paragraphStyle=d,_.bullet=f}c!==-1&&r.splice(c,1),r.push(...i),r.sort(rt("startIndex"))}}function yr(t,e,s,n){const{sectionBreaks:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:c}=l;c>=n&&(l.startIndex+=s)}const i=e.sectionBreaks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=n}r.push(...i),r.sort(rt("startIndex"))}}function Us(t,e,s,n){const{customBlocks:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:c}=l;c>=n&&(l.startIndex+=s)}const i=e.customBlocks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=n}r.push(...i),r.sort(rt("startIndex"))}}function Ee(t,e,s,n){const{tables:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:c,endIndex:u}=l;c>n?(l.startIndex+=s,l.endIndex+=s):u>=n-1&&(l.endIndex+=s)}const i=e.tables;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=n,l.endIndex+=n}r.push(...i),r.sort(rt("startIndex"))}}function ti(t,e,s,n){const{customRanges:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:c,endIndex:u}=l;c>n?(l.startIndex+=s,l.endIndex+=s):u>=n-1&&(l.endIndex+=s)}const i=e.customRanges;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=n,l.endIndex+=n}r.push(...i),r.sort(rt("startIndex"))}}function Ms(t,e,s){const{textRuns:n}=t,r=s,i=s+e,o=[];if(n){const a=[];for(let l=0,c=n.length;l<c;l++){const u=n[l],{st:_,ed:d}=u;if(r<=_&&i>=d){o.push({...u,st:_-r,ed:d-r});continue}else _<=r&&d>=i?(o.push({...u,st:r-r,ed:i-r}),u.ed-=e):r>=_&&r<d?(o.push({...u,st:r-r,ed:d-r}),u.ed=r):i>_&&i<=d?(o.push({...u,st:_-r,ed:i-r}),u.st=i-e,u.ed-=e):_>=i&&(u.st-=e,u.ed-=e);a.push(u)}t.textRuns=a}return o}function Ps(t,e,s){const{paragraphs:n}=t,r=s,i=s+e,o=[];if(n){const a=[];for(let l=0,c=n.length;l<c;l++){const u=n[l],{startIndex:_}=u;if(_>=r&&_<i){o.push({...u,startIndex:_-s});continue}else _>=i&&(u.startIndex-=e);a.push(u)}t.paragraphs=a}return o}function xs(t,e,s){const{sectionBreaks:n}=t,r=s,i=s+e-1,o=[];if(n){const a=[];for(let l=0,c=n.length;l<c;l++){const u=n[l],{startIndex:_}=u;if(_>=r&&_<=i){o.push({...u,startIndex:_-s});continue}else _>i&&(u.startIndex-=e);a.push(u)}t.sectionBreaks=a}return o}function Hs(t,e,s){const{customBlocks:n}=t,r=s,i=s+e-1,o=[];if(n){const a=[];for(let l=0,c=n.length;l<c;l++){const u=n[l],{startIndex:_}=u;if(_>=r&&_<=i){o.push({...u,startIndex:_-s});continue}else _>i&&(u.startIndex-=e);a.push(u)}t.customBlocks=a}return o}function Fs(t,e,s){const{tables:n}=t,r=s,i=s+e-1,o=[];if(n){const a=[];for(let l=0,c=n.length;l<c;l++){const u=n[l],{startIndex:_,endIndex:d}=u;if(r<=_&&i>=d){o.push({...u,startIndex:_-s,endIndex:d-s});continue}else if(_<=r&&d>=i){const f=ce(_,d,r,i);u.startIndex=f[0],u.endIndex=f[1]}else i<_&&(u.startIndex-=e,u.endIndex-=e);a.push(u)}t.tables=a}return o}function ps(t,e,s){const{customRanges:n}=t,r=s,i=s+e-1,o=[];if(n){const a=[];for(let l=0,c=n.length;l<c;l++){const u=n[l],{startIndex:_,endIndex:d}=u;if(r<=_&&i>=d){o.push({...u,startIndex:_-s,endIndex:d-s});continue}else if(_<=r&&d>=i){const f=ce(_,d,r,i);u.startIndex=f[0],u.endIndex=f[1]}else i<_&&(u.startIndex-=e,u.endIndex-=e);a.push(u)}t.customRanges=a}return o}function ei(t,e,s){const{dataStream:n}=t,r=s,i=s+e,o=Ms(t,e,s),a=Ps(t,e,s),l=xs(t,e,s),c=Hs(t,e,s),u=Fs(t,e,s),_=ps(t,e,s);let d="";return n&&(t.dataStream=Is(n,r,i),d=n.slice(r,i)),{dataStream:d,textRuns:o,paragraphs:a,sectionBreaks:l,customBlocks:c,tables:u,customRanges:_}}function si(t,e,s,n){t.dataStream=Os(t.dataStream,n,e.dataStream),Ts(t,e,s,n),fe(t,e,s,n),yr(t,e,s,n),Us(t,e,s,n),Ee(t,e,s,n),ti(t,e,s,n)}var Ws=(t=>(t[t.character=0]="character",t[t.paragraph=1]="paragraph",t[t.table=2]="table",t[t.numbering=3]="numbering",t))(Ws||{}),Bs=(t=>(t[t.TAB=0]="TAB",t[t.SPACE=1]="SPACE",t[t.NOTHING=2]="NOTHING",t))(Bs||{}),ht=(t=>(t[t.GLYPH_TYPE_UNSPECIFIED=0]="GLYPH_TYPE_UNSPECIFIED",t[t.NONE=1]="NONE",t[t.DECIMAL=2]="DECIMAL",t[t.ZERO_DECIMAL=3]="ZERO_DECIMAL",t[t.UPPER_ALPHA=4]="UPPER_ALPHA",t[t.ALPHA=5]="ALPHA",t[t.UPPER_ROMAN=6]="UPPER_ROMAN",t[t.ROMAN=7]="ROMAN",t))(ht||{}),V=(t=>(t[t.BULLET_ALIGNMENT_UNSPECIFIED=0]="BULLET_ALIGNMENT_UNSPECIFIED",t[t.START=1]="START",t[t.CENTER=2]="CENTER",t[t.END=3]="END",t))(V||{}),Gs=(t=>(t[t.HYPERLINK=0]="HYPERLINK",t[t.FIELD=1]="FIELD",t[t.SDT=2]="SDT",t[t.BOOKMARK=3]="BOOKMARK",t[t.COMMENT=4]="COMMENT",t[t.CUSTOM=5]="CUSTOM",t))(Gs||{}),ks=(t=>(t[t.DRAWING=0]="DRAWING",t[t.CUSTOM=1]="CUSTOM",t))(ks||{}),$s=(t=>(t[t.DEFAULT=0]="DEFAULT",t[t.LINES=1]="LINES",t[t.LINES_AND_CHARS=2]="LINES_AND_CHARS",t[t.SNAP_TO_CHARS=3]="SNAP_TO_CHARS",t))($s||{}),Vs=(t=>(t[t.SECTION_TYPE_UNSPECIFIED=0]="SECTION_TYPE_UNSPECIFIED",t[t.CONTINUOUS=1]="CONTINUOUS",t[t.NEXT_PAGE=2]="NEXT_PAGE",t[t.EVEN_PAGE=3]="EVEN_PAGE",t[t.ODD_PAGE=4]="ODD_PAGE",t))(Vs||{}),js=(t=>(t[t.COLUMN_SEPARATOR_STYLE_UNSPECIFIED=0]="COLUMN_SEPARATOR_STYLE_UNSPECIFIED",t[t.NONE=1]="NONE",t[t.BETWEEN_EACH_COLUMN=2]="BETWEEN_EACH_COLUMN",t))(js||{}),Ks=(t=>(t[t.NORMAL=0]="NORMAL",t[t.TBRL=1]="TBRL",t[t.LRTBV=2]="LRTBV",t))(Ks||{}),Ys=(t=>(t[t.TEXT_RUN=0]="TEXT_RUN",t[t.AUTO_TEXT=1]="AUTO_TEXT",t[t.PAGE_BREAK=2]="PAGE_BREAK",t[t.COLUMN_BREAK=3]="COLUMN_BREAK",t[t.FOOT_NOTE_REFERENCE=4]="FOOT_NOTE_REFERENCE",t[t.HORIZONTAL_RULE=5]="HORIZONTAL_RULE",t[t.EQUATION=6]="EQUATION",t[t.DRAWING=7]="DRAWING",t[t.PERSON=8]="PERSON",t[t.RICH_LINK=9]="RICH_LINK",t))(Ys||{}),zs=(t=>(t[t.BOTH_SIDES=0]="BOTH_SIDES",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.LARGEST=3]="LARGEST",t))(zs||{}),Xs=(t=>(t[t.INLINE=0]="INLINE",t[t.WRAP_NONE=1]="WRAP_NONE",t[t.WRAP_POLYGON=2]="WRAP_POLYGON",t[t.WRAP_SQUARE=3]="WRAP_SQUARE",t[t.WRAP_THROUGH=4]="WRAP_THROUGH",t[t.WRAP_TIGHT=5]="WRAP_TIGHT",t[t.WRAP_TOP_AND_BOTTOM=6]="WRAP_TOP_AND_BOTTOM",t))(Xs||{}),qs=(t=>(t[t.NAMED_STYLE_TYPE_UNSPECIFIED=0]="NAMED_STYLE_TYPE_UNSPECIFIED",t[t.NORMAL_TEXT=1]="NORMAL_TEXT",t[t.TITLE=2]="TITLE",t[t.SUBTITLE=3]="SUBTITLE",t[t.HEADING_1=4]="HEADING_1",t[t.HEADING_2=5]="HEADING_2",t[t.HEADING_3=6]="HEADING_3",t[t.HEADING_4=7]="HEADING_4",t[t.HEADING_5=8]="HEADING_5",t[t.HEADING_6=9]="HEADING_6",t))(qs||{}),Qs=(t=>(t[t.AUTO=0]="AUTO",t[t.AT_LEAST=1]="AT_LEAST",t[t.EXACT=2]="EXACT",t))(Qs||{}),Js=(t=>(t[t.DASH_STYLE_UNSPECIFIED=0]="DASH_STYLE_UNSPECIFIED",t[t.SOLID=1]="SOLID",t[t.DOT=2]="DOT",t[t.DASH=3]="DASH",t))(Js||{}),Zs=(t=>(t[t.TAB_STOP_ALIGNMENT_UNSPECIFIED=0]="TAB_STOP_ALIGNMENT_UNSPECIFIED",t[t.START=1]="START",t[t.CENTER=2]="CENTER",t[t.END=3]="END",t))(Zs||{}),ys=(t=>(t.EVENLY_DISTRIBUTED="0",t.FIXED_WIDTH="1",t))(ys||{}),tn=(t=>(t[t.CONTENT_ALIGNMENT_UNSPECIFIED=0]="CONTENT_ALIGNMENT_UNSPECIFIED",t[t.CONTENT_ALIGNMENT_UNSUPPORTED=1]="CONTENT_ALIGNMENT_UNSUPPORTED",t[t.TOP=2]="TOP",t[t.MIDDLE=3]="MIDDLE",t[t.BOTTOM=4]="BOTTOM",t))(tn||{}),en=(t=>(t.NORMAL="normal",t.BOLD="bold",t.ITALIC="italic",t))(en||{}),sn=(t=>(t[t.CHARACTER=0]="CHARACTER",t[t.COLUMN=1]="COLUMN",t[t.INSIDE_MARGIN=2]="INSIDE_MARGIN",t[t.LEFT_MARGIN=3]="LEFT_MARGIN",t[t.MARGIN=4]="MARGIN",t[t.OUTSIDE_MARGIN=5]="OUTSIDE_MARGIN",t[t.PAGE=6]="PAGE",t[t.RIGHT_MARGIN=7]="RIGHT_MARGIN",t))(sn||{}),nn=(t=>(t[t.BOTTOM_MARGIN=0]="BOTTOM_MARGIN",t[t.INSIDE_MARGIN=1]="INSIDE_MARGIN",t[t.LINE=2]="LINE",t[t.MARGIN=3]="MARGIN",t[t.OUTSIDE_MARGIN=4]="OUTSIDE_MARGIN",t[t.PAGE=5]="PAGE",t[t.PARAGRAPH=6]="PARAGRAPH",t[t.TOP_MARGIN=7]="TOP_MARGIN",t))(nn||{}),rn=(t=>(t[t.POINT=0]="POINT",t[t.LINE=1]="LINE",t[t.CHARACTER=2]="CHARACTER",t))(rn||{}),on=(t=>(t[t.CENTER=0]="CENTER",t[t.INSIDE=1]="INSIDE",t[t.LEFT=2]="LEFT",t[t.OUTSIDE=3]="OUTSIDE",t[t.RIGHT=4]="RIGHT",t))(on||{}),an=(t=>(t[t.BOTTOM=0]="BOTTOM",t[t.CENTER=1]="CENTER",t[t.INSIDE=2]="INSIDE",t[t.OUTSIDE=3]="OUTSIDE",t[t.TOP=4]="TOP",t))(an||{}),ln=(t=>(t[t.compressPunctuation=0]="compressPunctuation",t[t.compressPunctuationAndJapaneseKana=1]="compressPunctuationAndJapaneseKana",t[t.doNotCompress=2]="doNotCompress",t))(ln||{}),un=(t=>(t[t.PORTRAIT=0]="PORTRAIT",t[t.LANDSCAPE=1]="LANDSCAPE",t))(un||{}),Dt=(t=>(t.BULLET_LIST="BULLET_LIST",t.ORDER_LIST="ORDER_LIST",t))(Dt||{});const ni={BULLET_LIST:{listType:"BULLET_LIST",nestingLevel:[{bulletAlignment:V.START,glyphFormat:" %0",textStyle:{fs:12},startNumber:0,glyphSymbol:"●",hanging:21,indentStart:21},{bulletAlignment:V.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"■",hanging:21,indentStart:42},{bulletAlignment:V.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"◆",hanging:21,indentStart:63}]},ORDER_LIST:{listType:"ORDER_LIST",nestingLevel:[{bulletAlignment:V.START,glyphFormat:" %1.",textStyle:{fs:12},startNumber:0,glyphType:ht.DECIMAL,hanging:21,indentStart:21},{bulletAlignment:V.START,glyphFormat:" %1.%2)",textStyle:{fs:12},startNumber:0,glyphType:ht.DECIMAL,hanging:21,indentStart:42},{bulletAlignment:V.START,glyphFormat:" %1.%2.%3.",textStyle:{fs:12},startNumber:0,glyphType:ht.DECIMAL,hanging:21,indentStart:63}]}};function ri(t,e,s,n,r){const i=ii(t,e,s,n,r),o=oi(t,e,s,n,r),a=ai(t,e,s,n,r),l=li(t,e,s,n,r),c=ui(t,e,s,n,r),u=ci(t,e,s,n,r);return{dataStream:"",textRuns:i,paragraphs:o,sectionBreaks:a,customBlocks:l,tables:c,customRanges:u}}function ii(t,e,s,n,r){const{textRuns:i}=t,{textRuns:o}=e;if(i==null||o==null)return;const a=Ms(t,s,n);if(r!==T.REPLACE){const l=cn(o,a,r);e.textRuns=l}return Ts(t,e,s,n),a}function cn(t,e,s){if(e.length===0)return t;t=g.deepClone(t),e=g.deepClone(e);const n=[],r=t.length,i=e.length;let o=0,a=0,l=null;function c(){return l?(n.push(l),l=null,!0):!1}for(;o<r&&a<i;){const{st:f,ed:E,ts:R}=t[o],{st:b,ed:v,ts:p,sId:k}=e[a];let it;s===T.COVER?it={...p,...R}:it={...R,...p},E<b?(c()||n.push(t[o]),o++):v<f?(c()||n.push(e[a]),a++):(n.push({st:Math.min(f,b),ed:Math.max(f,b),ts:f<b?{...R}:{...p},sId:f<b?void 0:k}),n.push({st:Math.max(f,b),ed:Math.min(E,v),ts:it,sId:k}),E<v?(o++,e[a].st=E):(a++,t[o].st=v),l={st:Math.min(E,v),ed:Math.max(E,v),ts:E<v?{...p}:{...R},sId:E<v?k:void 0})}c();const u=n[n.length-1],_=t[r-1],d=e[i-1];return u.ed!==Math.max(_.ed,d.ed)&&(_.ed>d.ed?n.push(_):n.push(d)),de(n)}function oi(t,e,s,n,r){const{paragraphs:i}=t,{paragraphs:o}=e;if(i==null||o==null)return;const a=Ps(t,s,n);if(r!==T.REPLACE){const l=[];for(const c of o){const{startIndex:u,paragraphStyle:_,bullet:d}=c;let f=[];for(const E of a){const{startIndex:R,paragraphStyle:b,bullet:v}=E;let p,k;if(r===T.COVER?(p={...b,..._},k={listId:"",listType:Dt.BULLET_LIST,nestingLevel:0,textStyle:{},...v,...d}):(p={..._,...b},k={listId:"",listType:Dt.BULLET_LIST,nestingLevel:0,textStyle:{},...d,...v}),u===R){f.push({startIndex:u,paragraphStyle:p,bullet:k});break}}l.push(...f),f=[]}e.paragraphs=l}return fe(t,e,s,n),a}function ai(t,e,s,n,r){const{sectionBreaks:i}=t,{sectionBreaks:o}=e;if(i==null||o==null)return;const a=xs(t,s,n);if(r!==T.REPLACE){const l=[];for(const c of o){const{startIndex:u}=c;let _=[];for(const d of a){const{startIndex:f}=d;if(u===f){r===T.COVER?_.push({...d,...c}):_.push({...c,...d});break}}l.push(..._),_=[]}e.sectionBreaks=l}return fe(t,e,s,n),a}function li(t,e,s,n,r){const{customBlocks:i}=t,{customBlocks:o}=e;if(i==null||o==null)return;const a=Hs(t,s,n);if(r!==T.REPLACE){const l=[];for(const c of o){const{startIndex:u}=c;let _=[];for(const d of a){const{startIndex:f}=d;if(u===f){r===T.COVER?_.push({...d,...c}):_.push({...c,...d});break}}l.push(..._),_=[]}e.customBlocks=l}return Us(t,e,s,n),a}function ui(t,e,s,n,r){const{tables:i}=t,{tables:o}=e;if(i==null||o==null)return;const a=Fs(t,s,n);if(r!==T.REPLACE){const l=[];for(const c of o){const{startIndex:u,endIndex:_}=c;let d=[];for(const f of a){const{startIndex:E,endIndex:R}=f;if(E>=u&&R<=_){r===T.COVER?d.push({...f,...c}):d.push({...c,...f});break}}l.push(...d),d=[]}e.tables=l}return Ee(t,e,s,n),a}function ci(t,e,s,n,r){const{customRanges:i}=t,{tables:o}=e;if(i==null||o==null)return;const a=ps(t,s,n);if(r!==T.REPLACE){const l=[];for(const c of o){const{startIndex:u,endIndex:_}=c;let d=[];for(const f of a){const{startIndex:E,endIndex:R}=f;if(E>=u&&R<=_){r===T.COVER?d.push({...f,...c}):d.push({...c,...f});break}}l.push(...d),d=[]}e.customRanges=l}return Ee(t,e,s,n),a}var m=(t=>(t.RETAIN="r",t.INSERT="i",t.DELETE="d",t))(m||{});function ge(t,e,s){const{dataStream:n,textRuns:r=[],paragraphs:i=[]}=t,o={dataStream:n.slice(e,s)},a=[];for(const c of r){const u=g.deepClone(c),{st:_,ed:d}=u;g.hasIntersectionBetweenTwoRanges(_,d,e,s)&&(e>=_&&e<=d?a.push({...u,st:e,ed:Math.min(s,d)}):s>=_&&s<=d?a.push({...u,st:Math.max(e,_),ed:s}):a.push(u))}a.length&&(o.textRuns=a.map(c=>{const{st:u,ed:_}=c;return{...c,st:u-e,ed:_-e}}));const l=[];for(const c of i){const{startIndex:u}=c;u>=e&&u<=s&&l.push(g.deepClone(c))}return l.length&&(o.paragraphs=l.map(c=>({...c,startIndex:c.startIndex-e}))),o}function Zt(t,e,s=T.COVER){if(e.dataStream!=="")throw new Error("Cannot compose other body with non-empty dataStream");const n={dataStream:t.dataStream},{textRuns:r=[],paragraphs:i=[]}=t,{textRuns:o=[],paragraphs:a=[]}=e,l=cn(o,r,s);l.length&&(n.textRuns=l);const c=[];let u=0,_=0;for(;u<i.length&&_<a.length;){const d=i[u],f=a[_],{startIndex:E}=d,{startIndex:R}=f;E===R?(c.push(g.deepMerge(d,f)),u++,_++):E<R?(c.push(g.deepClone(d)),u++):(c.push(g.deepClone(f)),_++)}return u<i.length&&c.push(...i.slice(u)),_<a.length&&c.push(...a.slice(_)),c.length&&(n.paragraphs=c),n}function hi(t){const{body:e}=t;if(e==null)return!0;const{textRuns:s=[],paragraphs:n=[]}=e;return s.length===0&&n.length===0}const Re={id:"default_doc",documentStyle:{}};class _i{constructor(e){h(this,"snapshot");this.snapshot={...Re,...e}}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get body(){return this.snapshot.body}get zoomRatio(){var e;return((e=this.snapshot.settings)==null?void 0:e.zoomRatio)||1}getBody(){return this.snapshot.body}getShouldRenderLoopImmediately(){return this.snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this.snapshot.container}getParentRenderUnitId(){return this.snapshot.parentRenderUnitId}getSnapshot(){return this.snapshot}updateDocumentId(e){this.snapshot.id=e}updateDocumentRenderConfig(e){const{documentStyle:s}=this.snapshot;s.renderConfig==null?s.renderConfig=e:s.renderConfig={...s.renderConfig,...e}}updateDocumentStyle(e){this.snapshot.documentStyle==null?this.snapshot.documentStyle=e:this.snapshot.documentStyle={...this.snapshot.documentStyle,...e}}updateDocumentDataMargin(e){const{t:s,l:n,b:r,r:i}=e,{documentStyle:o}=this.snapshot;s!=null&&(o.marginTop=s),n!=null&&(o.marginLeft=n),r!=null&&(o.marginBottom=r),i!=null&&(o.marginRight=i)}updateDocumentDataPageSize(e,s){const{documentStyle:n}=this.snapshot;if(!n.pageSize){e=e!=null?e:Number.POSITIVE_INFINITY,s=s!=null?s:Number.POSITIVE_INFINITY,n.pageSize={width:e,height:s};return}e!==void 0&&(n.pageSize.width=e),s!==void 0&&(n.pageSize.height=s)}updateDrawing(e,s){const{drawings:n}=this,{width:r,height:i,left:o,top:a}=s,l=n==null?void 0:n[e];if(!l)return;const c=l.objectTransform;c.size.width=r,c.size.height=i,c.positionH.posOffset=o,c.positionV.posOffset=a}setZoomRatio(e=1){this.snapshot.settings==null?this.snapshot.settings={zoomRatio:e}:this.snapshot.settings.zoomRatio=1}}class et extends _i{constructor(s){var r;super(s);h(this,"_unitId");h(this,"headerModelMap",new Map);h(this,"footerModelMap",new Map);const n=6;this._unitId=(r=this.snapshot.id)!=null?r:g.generateRandomId(n),this._initializeHeaderFooterModel()}dispose(){this.headerModelMap.forEach(s=>{s.dispose()}),this.footerModelMap.forEach(s=>{s.dispose()})}getRev(){var s;return(s=this.snapshot.rev)!=null?s:1}incrementRev(){this.snapshot.rev=this.getRev()+1}getSettings(){return this.snapshot.settings}reset(s){if(s.id&&s.id!==this._unitId)throw new Error("Cannot reset a document model with a different unit id!");this.snapshot={...Re,...s},this._initializeHeaderFooterModel()}getSelfOrHeaderFooterModel(s){if(s!=null){if(this.headerModelMap.has(s))return this.headerModelMap.get(s);if(this.footerModelMap.has(s))return this.footerModelMap.get(s)}return this}getUnitId(){return this._unitId}apply(s){const n=[],r=new Qe;return r.reset(),s.forEach(i=>{if(i=g.deepClone(i),i.t===m.RETAIN){const{coverType:o,body:a,len:l,segmentId:c}=i;if(a!=null){const u=this._updateApply(a,l,r.cursor,o,c);n.push({...i,t:m.RETAIN,coverType:T.REPLACE,body:u})}else n.push({...i,t:m.RETAIN});r.moveCursor(l)}else if(i.t===m.INSERT){const{body:o,len:a,segmentId:l,line:c}=i;this._insertApply(o,a,r.cursor,l),r.moveCursor(a),n.push({t:m.DELETE,len:a,line:c,segmentId:l})}else if(i.t===m.DELETE){const{len:o,segmentId:a}=i,l=this._deleteApply(o,r.cursor,a);n.push({...i,t:m.INSERT,body:l})}else throw new Error(`Unknown action type for action: ${i}.`)}),n}sliceBody(s,n){const r=this.getBody();if(r!=null)return ge(r,s,n)}_updateApply(s,n,r,i=T.COVER,o){if(s==null)throw new Error("updateBody is none");const a=this.snapshot,l=Ot(a,o);if(l==null)throw new Error("no body has changed");return ri(l,s,n,r,i)}_deleteApply(s,n,r){const i=this.snapshot,o=Ot(i,r);if(o==null)throw new Error("no body has changed");return s<=0?{dataStream:""}:ei(o,s,n)}_insertApply(s,n,r,i){const o=this.snapshot,a=Ot(o,i);if(n!==0){if(a==null)throw new Error("no body has changed");si(a,s,n,r)}}_initializeHeaderFooterModel(){const{headers:s,footers:n}=this.getSnapshot();if(s)for(const r in s){const i=s[r];this.headerModelMap.set(r,new et(i))}if(n)for(const r in n){const i=n[r];this.footerModelMap.set(r,new et(i))}}updateDocumentId(s){super.updateDocumentId(s),this._unitId=s}}const di="0.1.1",at={sheetId:"",range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},fi={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},Ei={startRow:0,startColumn:0,endRow:0,endColumn:0},gi={row:0,column:0},hn={id:"",sheetOrder:[],name:"",appVersion:di,locale:xt.ZH_CN,styles:{},sheets:{},resources:[]},It={ff:"Times New Roman",fs:14,it:O.FALSE,bl:O.FALSE,ul:{s:O.FALSE},st:{s:O.FALSE},ol:{s:O.FALSE},tr:{a:0,v:O.FALSE},td:_t.UNSPECIFIED,cl:{rgb:"#000"},bg:{rgb:"#fff"},ht:X.UNSPECIFIED,vt:J.UNSPECIFIED,tb:Z.UNSPECIFIED,pd:{t:0,r:0,b:0,l:0}},_n={id:"default_slide",title:"defaultSlide",pageSize:{width:300,height:300}};var dn=(t=>(t.ARRAY_CONVERTOR="ARRAY_CONVERTOR",t.MATRIX_CONVERTOR="MATRIX_CONVERTOR",t))(dn||{});class fn{constructor(e={}){h(this,"_styles");h(this,"_cacheMap",new Ss(1e5));this._styles=e,this._generateCacheMap()}each(e){return Object.entries(this._styles).forEach(e),this}search(e,s){if(this._cacheMap.has(s))return this._cacheMap.get(s);const n=this._getExistingStyleId(e);return n||"-1"}get(e){return typeof e!="string"?e:(e=String(e),this._styles[e])}add(e,s){const n=g.generateRandomId(6);return this._styles[n]=e,this._cacheMap.set(s,n),n}setValue(e){if(e==null)return;const s=JSON.stringify(e),n=this.search(e,s);return n!=="-1"?n:this.add(e,s)}toJSON(){return this._styles}getStyleByCell(e){let s;e&&g.isObject(e.s)?s=e.s:s=(e==null?void 0:e.s)&&this.get(e.s);const n=e==null?void 0:e.interceptorStyle;return n?{...s,...n}:s}_generateCacheMap(){const{_styles:e,_cacheMap:s}=this;for(const n in e){const r=JSON.stringify(e[n]);s.set(r,n)}}_getExistingStyleId(e){const{_styles:s}=this;for(const n in s)if(g.diffValue(s[n],e))return n;return null}}function Ri(t){return t&&(t.s!==void 0||t.p!==void 0||t.v!==void 0||t.t!==void 0||t.f!==void 0||t.si!==void 0)}function mi(t){if(t.t!==void 0)return t.t;if(typeof t.v=="string")return ct.STRING;if(typeof t.v=="number")return ct.NUMBER;if(typeof t.v=="boolean")return ct.BOOLEAN}function Oi(t){if(t==null)return!0;const{v:e,f:s,si:n,p:r,s:i}=t;return!(!(e==null||typeof e=="string"&&e.length===0)||s!=null&&s.length>0||n!=null&&n.length>0||r!=null)}function Ii(t){return t!=null&&(typeof t=="string"||typeof t=="number"||typeof t=="boolean")}var me=(t=>(t[t.SLIDE=0]="SLIDE",t[t.MASTER=1]="MASTER",t[t.LAYOUT=2]="LAYOUT",t[t.HANDOUT_MASTER=3]="HANDOUT_MASTER",t[t.NOTES_MASTER=4]="NOTES_MASTER",t))(me||{}),En=(t=>(t[t.SHAPE=0]="SHAPE",t[t.IMAGE=1]="IMAGE",t[t.TEXT=2]="TEXT",t[t.SPREADSHEET=3]="SPREADSHEET",t[t.DOCUMENT=4]="DOCUMENT",t[t.SLIDE=5]="SLIDE",t))(En||{}),gn=(t=>(t[t.RELATIVE_SLIDE_LINK_UNSPECIFIED=0]="RELATIVE_SLIDE_LINK_UNSPECIFIED",t[t.NEXT_SLIDE=1]="NEXT_SLIDE",t[t.PREVIOUS_SLIDE=2]="PREVIOUS_SLIDE",t[t.FIRST_SLIDE=3]="FIRST_SLIDE",t[t.LAST_SLIDE=4]="LAST_SLIDE",t))(gn||{});class Ai{constructor(e,s){h(this,"_columnData",{});this._config=e,this._columnData=s}getColumnData(){return this._columnData}getColVisible(e){const{_columnData:s}=this,n=s[e];return n?n.hd!==O.TRUE:!0}getHiddenCols(e=0,s=this.getSize()-1){const n=[];let r=!1,i=-1;for(let o=e;o<=s;o++){const a=this.getColVisible(o);r&&a?(r=!1,n.push({rangeType:P.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&!a&&(r=!0,i=o)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:s,rangeType:P.COLUMN}),n}getVisibleCols(e=0,s=this.getSize()-1){const n=[];let r=!1,i=-1;for(let o=e;o<=s;o++){const a=this.getColVisible(o);r&&!a?(r=!1,n.push({rangeType:P.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&a&&(r=!0,i=o)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:s,rangeType:P.COLUMN}),n}getColumnDatas(e,s){const n={};let r=0;for(let i=e;i<e+s;i++){const o=this.getColumnOrCreate(i);n[r]=o,r++}return n}getSize(){return G(this._columnData)}getColumnWidth(e){const{_columnData:s}=this,n=this._config;let r=0;return r=(s[e]||{hd:O.FALSE,w:n.defaultColumnWidth}).w||n.defaultColumnWidth,r}getColumn(e){const s=this._columnData[e];if(s)return s}getColumnOrCreate(e){const{_columnData:s}=this,n=this._config,r=s[e];if(r)return r;const i={w:n.defaultColumnWidth,hd:O.FALSE};return this._columnData[e]=i,i}}function mt(t,e){const{textRuns:s=[]}=e;let n=0;for(const i of s){const{ts:o={},st:a,ed:l}=i;if(o[t]==null)return O.FALSE;switch(t){case"bl":case"it":{if(o[t]===O.FALSE)return O.FALSE;break}case"ul":case"st":{if(o[t].s===O.FALSE)return O.FALSE;break}default:throw new Error(`unknown style key: ${t} in IStyleBase`)}n+=l-a}return e.dataStream.indexOf(`\r
|
|
5
|
+
`)===n?O.TRUE:O.FALSE}class st{constructor(e,s,n){h(this,"_range");h(this,"_worksheet");this._deps=n,this._range=s,this._worksheet=e}static foreach(e,s){const{startRow:n,startColumn:r,endRow:i,endColumn:o}=e;for(let a=n;a<=i;a++)for(let l=r;l<=o;l++)s(a,l)}getRangeData(){return this._range}getValue(){return this.getValues()[0][0]}getValues(){const{startRow:e,endRow:s,startColumn:n,endColumn:r}=this._range,i=[];for(let o=e;o<=s;o++){const a=[];for(let l=n;l<=r;l++)a.push(this.getMatrix().getValue(o,l)||null);i.push(a)}return i}getMatrix(){const{startRow:e,endRow:s,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new B;for(let a=e;a<=s;a++)for(let l=n;l<=r;l++)o.setValue(a,l,i.getValue(a,l)||null);return o}getMatrixObject(){const{startRow:e,endRow:s,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new B;for(let a=e;a<=s;a++)for(let l=n;l<=r;l++)o.setValue(a-e,l-n,i.getValue(a,l)||{});return o}getA1Notation(){const{startRow:e,endRow:s,startColumn:n,endColumn:r}=this._range;let i,o;return n<r?(i=g.numToWord(n+1)+(e+1),o=g.numToWord(r+1)+(s+1)):(i=g.numToWord(r+1)+(s+1),o=g.numToWord(n+1)+(e+1)),i===o?`${i}`:`${i}:${o}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){const e=this._deps.getStyles();return this.getValues().map(s=>s.map(n=>{var i;const r=e.getStyleByCell(n);return((i=r==null?void 0:r.bg)==null?void 0:i.rgb)||It.bg.rgb}))}getCell(e,s){const{startRow:n,endRow:r,startColumn:i,endColumn:o}=this._range,a={startRow:n+e,endRow:n+e,startColumn:i+s,endColumn:i+s};return new st(this._worksheet,a,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(e={}){return this.getObjectValues(e)[0][0]}getObjectValues(e={}){var a;const{startRow:s,endRow:n,startColumn:r,endColumn:i}=this._range,o=this._worksheet.getCellMatrix().getFragment(s,n,r,i).getData();if(e.isIncludeStyle){const l=this._deps.getStyles();for(let c=0;c<=n-s;c++)for(let u=0;u<=i-r;u++){if(o==null||((a=o==null?void 0:o[c])==null?void 0:a[u])==null)continue;const _=o[c][u].s;_&&(o[c][u].s=l.get(_))}}return o}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){const e=this._deps.getStyles();return this.getValues().map(s=>s.map(n=>{var i;const r=e.getStyleByCell(n);return((i=r==null?void 0:r.cl)==null?void 0:i.rgb)||It.cl.rgb}))}getFontFamilies(){return this._getStyles("ff")}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles("ul")}getUnderline(){var s,n;const{p:e}=(s=this.getValue())!=null?s:{};return e&&Array.isArray((n=e.body)==null?void 0:n.textRuns)&&e.body.textRuns.length>0?mt("ul",e.body)===O.TRUE?{s:O.TRUE}:{s:O.FALSE}:this.getUnderlines()[0][0]}getOverlines(){return this._getStyles("ol")}getOverline(){return this.getOverlines()[0][0]}getStrikeThrough(){var s,n;const{p:e}=(s=this.getValue())!=null?s:{};return e&&Array.isArray((n=e.body)==null?void 0:n.textRuns)&&e.body.textRuns.length>0?mt("st",e.body)===O.TRUE?{s:O.TRUE}:{s:O.FALSE}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles("st")}getFontSize(){return this.getFontSizes()[0][0]}getFontSizes(){return this._getStyles("fs")}getBorder(){return this.getBorders()[0][0]}getBorders(){return this._getStyles("bd")}getFontStyle(){var s,n;const{p:e}=(s=this.getValue())!=null?s:{};return e&&Array.isArray((n=e.body)==null?void 0:n.textRuns)&&e.body.textRuns.length>0?mt("it",e.body)===O.TRUE?Nt.ITALIC:Nt.NORMAL:this._getFontStyles()[0][0]}_getFontStyles(){return this._getStyles("it")}getFontWeight(){var s,n;const{p:e}=(s=this.getValue())!=null?s:{};return e&&Array.isArray((n=e.body)==null?void 0:n.textRuns)&&e.body.textRuns.length>0?mt("bl",e.body)===O.TRUE?St.BOLD:St.NORMAL:this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles("bl")}getGridId(){return this._worksheet.getSheetId()}getHeight(){const{_range:e,_worksheet:s}=this,{startRow:n,endRow:r}=e;let i=0;for(let o=0;o<=r-n;o++){const a=s.getRowHeight(o);i+=a}return i}getHorizontalAlignment(){return this.getHorizontalAlignments()[0][0]}getHorizontalAlignments(){return this._getStyles("ht")}getLastColumn(){return this._range.endColumn}getLastRow(){return this._range.endRow}getNumColumns(){const{startColumn:e,endColumn:s}=this._range;return s-e+1}getNumRows(){const{startRow:e,endRow:s}=this._range;return s-e+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(e=>e.map(s=>(s==null?void 0:s.p)||""))}getRowIndex(){return this._range.startRow}getSheet(){return this._worksheet}getTextDirection(){return this.getTextDirections()[0][0]}getTextDirections(){return this._getStyles("td")}getTextRotation(){return this.getTextRotations()[0][0]}getTextRotations(){return this._getStyles("tr")}getTextStyle(){return this.getTextStyles()[0][0]}getTextStyles(){const e=this._deps.getStyles();return this.getValues().map(s=>s.map(n=>e.getStyleByCell(n)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles("vt")}getWidth(){const{_range:e,_worksheet:s}=this,{startColumn:n,endColumn:r}=e;let i=0;for(let o=0;o<=r-n;o++)i+=s.getColumnWidth(o);return i}getWrap(){return this.getWraps()[0][0]}getWraps(){return this._getStyles("tb")}getWrapStrategies(){return this._getStyles("tb")}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(e){st.foreach(this._range,e)}_getStyles(e){const s=this._deps.getStyles();return this.getValues().map(n=>n.map(r=>{const i=s&&s.getStyleByCell(r);return i&&i[e]||It[e]}))}}class Ci{constructor(e,s){h(this,"_rowData");this._config=e,this._rowData=s}getRowData(){return this._rowData}getRowDatas(e,s){const n={};let r=0;for(let i=e;i<e+s;i++){const o=this.getRowOrCreate(i);n[r]=o,r++}return n}getRowHeight(e,s=1){const{_rowData:n}=this,r=this._config;let i=0;for(let o=0;o<s;o++){const a=n[o+e]||{hd:O.FALSE,h:r.defaultRowHeight},{ia:l,ah:c,h:u=r.defaultRowHeight}=a;i+=(l==null||l===O.TRUE)&&typeof c=="number"?c:u}return i}getRow(e){return this._rowData[e]}getRowOrCreate(e){const{_rowData:s}=this,n=s[e];if(n)return n;const r=this._config,i={hd:O.FALSE,h:r.defaultRowHeight};return s[e]=i,i}getHiddenRows(e=0,s=this.getSize()-1){const n=[];let r=!1,i=-1;for(let o=e;o<=s;o++){const a=this.getRowVisible(o);r&&a?(r=!1,n.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:P.ROW})):!r&&!a&&(r=!0,i=o)}return r&&n.push({startRow:i,endRow:s,startColumn:0,endColumn:0,rangeType:P.ROW}),n}getVisibleRows(e=0,s=this.getSize()-1){const n=[];let r=!1,i=-1;for(let o=e;o<=s;o++){const a=this.getRowVisible(o);r&&!a?(r=!1,n.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:P.ROW})):!r&&a&&(r=!0,i=o)}return r&&n.push({startRow:i,endRow:s,startColumn:0,endColumn:0,rangeType:P.ROW}),n}getRowVisible(e){const s=this.getRow(e);return s?s.hd!==O.TRUE:!0}getSize(){return G(this._rowData)}}const Ni="DEFAULT_WORKSHEET_ROW_COUNT",Rn=1e3,Si="DEFAULT_WORKSHEET_COLUMN_COUNT",mn=20,Li="DEFAULT_WORKSHEET_ROW_HEIGHT",On=19,bi="DEFAULT_WORKSHEET_COLUMN_WIDTH",In=73,vi="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",An=46,wi="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Cn=20;function Nn(t){const e={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:O.FALSE,rowCount:Rn,columnCount:mn,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:In,defaultRowHeight:On,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:O.TRUE,rowHeader:{width:An,hidden:O.FALSE},columnHeader:{height:Cn,hidden:O.FALSE},selections:["A1"],rightToLeft:O.FALSE};return Object.keys(e).forEach(s=>{const n=s;typeof t[n]>"u"&&(t[n]=e[n])}),t}class Sn extends U{constructor(){super(...arguments);h(this,"_cellContentInterceptors",[]);h(this,"_rowFilteredInterceptors",[]);h(this,"_rowVisibleInterceptors",[]);h(this,"_colVisibleInterceptors",[])}dispose(){super.dispose(),this._cellContentInterceptors.length=0,this._rowFilteredInterceptors.length=0,this._rowVisibleInterceptors.length=0,this._colVisibleInterceptors.length=0}getCell(s,n){for(const r of this._cellContentInterceptors){const i=r.getCell(s,n);if(typeof i<"u")return i}return null}registerCellContentInterceptor(s){if(this._cellContentInterceptors.includes(s))throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptors.push(s),L(()=>Y(this._cellContentInterceptors,s))}registerRowFilteredInterceptor(s){if(this._rowFilteredInterceptors.includes(s))throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptors.push(s),L(()=>Y(this._rowFilteredInterceptors,s))}registerRowVisibleInterceptor(s){if(this._rowVisibleInterceptors.includes(s))throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowVisibleInterceptors.push(s),L(()=>Y(this._rowVisibleInterceptors,s))}registerColVisibleInterceptor(s){if(this._colVisibleInterceptors.includes(s))throw new Error("[SheetViewModel]: Interceptor already registered.");return this._colVisibleInterceptors.push(s),L(()=>Y(this._colVisibleInterceptors,s))}}class dt{constructor(e,s){h(this,"_initialized");h(this,"_sheetId");h(this,"_snapshot");h(this,"_cellData");h(this,"_rowManager");h(this,"_columnManager");h(this,"_viewModel");var o;this._styles=s,this._snapshot=Nn(e);const{columnData:n,rowData:r,cellData:i}=this._snapshot;this._sheetId=(o=this._snapshot.id)!=null?o:g.generateRandomId(6),this._initialized=!1,this._cellData=new B(i),this._rowManager=new Ci(this._snapshot,r),this._columnManager=new Ai(this._snapshot,n),this._viewModel=new Sn}__interceptViewModel(e){e(this._viewModel)}getSnapshot(){return this._snapshot}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const e=this.getCellMatrix(),s=this.getMergeData();let n=-1,r=-1,i=-1,o=-1,a=!1,l=!1;return e.forEach((c,u)=>{Object.keys(u).forEach(_=>{const d=+_,f=e.getValue(c,d),E=f!=null&&f.s?this._styles.get(f.s):null,R=(E==null?void 0:E.bd)&&(E.bd.b||E.bd.l||E.bd.r||E.bd.t||E.bd.bc_tr||E.bd.bl_tr||E.bd.ml_tr||E.bd.tl_bc||E.bd.tl_br||E.bd.tl_mr);(f&&(f.v||f.p)||E!=null&&E.bg||R)&&(a?n=Math.min(n,c):(n=c,a=!0),r=Math.max(r,c),l?i=Math.min(i,d):(l=!0,i=d),o=Math.max(o,d))})}),s.forEach(c=>{a?n=Math.min(n,c.startRow):(n=c.startRow,a=!0),r=Math.max(r,c.endRow),l?i=Math.min(i,c.startColumn):(i=c.startColumn,a=!0),o=Math.max(o,c.endColumn)}),!a||!l?null:{startColumn:i,startRow:n,endColumn:o,endRow:r}}getRowManager(){return this._rowManager}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:e}=this,s=g.deepClone(e);return new dt(s,this._styles)}getMergeData(){return this._snapshot.mergeData}getMergedCells(e,s){const n=this._snapshot.mergeData,r=[];for(let i=0;i<n.length;i++){const o=n[i];y.intersects({startRow:e,startColumn:s,endRow:e,endColumn:s},o)&&r.push(o)}return r.length?r:null}getMergedCell(e,s){const n=this._snapshot.mergeData;for(let r=0;r<n.length;r++){const i=n[r];if(y.intersects({startRow:e,startColumn:s,endRow:e,endColumn:s},i))return i}return null}getCell(e,s){return e<0||s<0?null:this._viewModel.getCell(e,s)}getCellRaw(e,s){return this.getCellMatrix().getValue(e,s)}getMatrixWithMergedCells(e,s,n,r){const i=this.getCellMatrix(),o=this._snapshot.mergeData.filter(l=>y.intersects({startRow:e,startColumn:s,endRow:n,endColumn:r},l)),a=new B;return Jt(e,n,s,r).forEach((l,c)=>{const u=i.getValue(l,c);u&&a.setValue(l,c,u)}),o.forEach(l=>{const{startColumn:c,startRow:u,endColumn:_,endRow:d}=l;Jt(u,d,c,_).forEach((f,E)=>{f===u&&E===c&&a.setValue(f,E,{...i.getValue(f,E),rowSpan:d-u+1,colSpan:_-c+1}),(f!==u||E!==c)&&a.realDeleteValue(f,E)})}),a}getRange(e,s,n,r){return typeof e=="object"?new st(this,e,{getStyles:()=>this._styles}):new st(this,{startRow:e,startColumn:s,endColumn:r||s,endRow:n||e},{getStyles:()=>this._styles})}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:e}=this,{columnCount:s}=e;return s}getMaxRows(){const{_snapshot:e}=this,{rowCount:s}=e;return s}getRowCount(){return this._snapshot.rowCount}setRowCount(e){this._snapshot.rowCount=e}getColumnCount(){return this._snapshot.columnCount}setColumnCount(e){this._snapshot.columnCount=e}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:e}=this,{showGridlines:s}=e;return s===0}getTabColor(){const{_snapshot:e}=this,{tabColor:s}=e;return s}getColumnWidth(e){return this.getColumnManager().getColumnWidth(e)}getRowHeight(e){return this.getRowManager().getRowHeight(e)}getRowVisible(e){return this.getRowManager().getRowVisible(e)}getHiddenRows(e,s){const n=this.getMaxColumns()-1,r=this._rowManager.getHiddenRows(e,s);return r.forEach(i=>i.endColumn=n),r}getColVisible(e){return this._columnManager.getColVisible(e)}getHiddenCols(e,s){const n=this.getMaxRows()-1,r=this._columnManager.getHiddenCols(e,s);return r.forEach(i=>i.endRow=n),r}getVisibleRows(){const e=this.getRowCount();return this._rowManager.getVisibleRows(0,e-1)}getVisibleCols(){const e=this.getColumnCount();return this._columnManager.getVisibleCols(0,e-1)}isRightToLeft(){const{_snapshot:e}=this,{rightToLeft:s}=e;return s}getLastRowWithContent(){return this._cellData.getLength()-1}getLastColumnWithContent(){return this._cellData.getRange().endColumn}cellHasValue(e){return e&&(e.v!==void 0||e.f!==void 0||e.p!==void 0)}}var Di=Object.defineProperty,Ti=Object.getOwnPropertyDescriptor,Ui=(t,e,s,n)=>{for(var r=n>1?void 0:n?Ti(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&Di(e,s,r),r},Mi=(t,e)=>(s,n)=>e(s,n,t);function Pi(t,e){return`${t.getUnitId()}|${e.getSheetId()}`}exports.Workbook=class extends U{constructor(s={},n){super();h(this,"_sheetCreated$",new A.Subject);h(this,"sheetCreated$",this._sheetCreated$.asObservable());h(this,"_sheetDisposed$",new A.Subject);h(this,"sheetDisposed$",this._sheetDisposed$.asObservable());h(this,"_activeSheet$",new A.BehaviorSubject(null));h(this,"activeSheet$",this._activeSheet$.asObservable());h(this,"_worksheets");h(this,"_styles");h(this,"_snapshot");h(this,"_unitId");h(this,"_count");this._logService=n,this._snapshot=g.commonExtend(hn,s);const{styles:r}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=g.generateRandomId(6)),this._unitId=this._snapshot.id,this._styles=new fn(r),this._count=1,this._worksheets=new Map,this._passWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._snapshot.name}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete()}save(){return g.deepClone(this._snapshot)}static isIRangeType(s){return typeof s=="string"||"startRow"in s||"row"in s}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}getUnitId(){return this._unitId}getRev(){var s;return(s=this._snapshot.rev)!=null?s:1}incrementRev(){this._snapshot.rev=this.getRev()+1}getShouldRenderLoopImmediately(){return this._snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this._snapshot.container}addWorksheet(s,n,r){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[s])return!1;i[s]=r,o.splice(n,0,s);const a=new dt(r,this._styles);return this._worksheets.set(s,a),this._sheetCreated$.next(a),!0}getParentRenderUnitId(){return this._snapshot.parentRenderUnitId}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}getConfig(){return this._snapshot}getIndexBySheetId(s){const{sheetOrder:n}=this._snapshot;return n.findIndex(r=>r===s)}getRawActiveSheet(){return this._activeSheet}getActiveSheet(){const s=this.getRawActiveSheet();if(!s){const n=this._worksheets.get(this._snapshot.sheetOrder[0]);return this.setActiveSheet(n),n}return s}setActiveSheet(s){this._activeSheet$.next(s)}removeSheet(s){var r;return this._worksheets.get(s)?(((r=this._activeSheet)==null?void 0:r.getSheetId())===s&&this.setActiveSheet(null),this._worksheets.delete(s),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(s),1),delete this._snapshot.sheets[s],!0):!1}getActiveSheetIndex(){const{sheetOrder:s}=this._snapshot;return s.findIndex(n=>this._worksheets.get(n)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:s}=this._snapshot;return s.map(n=>this._worksheets.get(n))}getSheetsName(){const{sheetOrder:s}=this._snapshot,n=[];return s.forEach(r=>{const i=this._worksheets.get(r);i&&n.push(i.getName())}),n}getSheetIndex(s){const{sheetOrder:n}=this._snapshot;return n.findIndex(r=>s.getSheetId()===r)}getSheetBySheetName(s){const{sheetOrder:n}=this._snapshot,r=n.find(i=>this._worksheets.get(i).getName()===s);return this._worksheets.get(r)}getSheetBySheetId(s){return this._worksheets.get(s)}getSheetByIndex(s){const{sheetOrder:n}=this._snapshot;return this._worksheets.get(n[s])}getHiddenWorksheets(){return this.getSheets().filter(s=>s.getConfig().hidden===O.TRUE).map(s=>s.getConfig().id)}transformRangeType(s){if(typeof s=="string")return this._getCellRange(s);if(typeof s!="string"&&"row"in s){const n=s;return{sheetId:"",range:{startRow:n.row[0],startColumn:n.column[0],endRow:n.row[1],endColumn:n.column[1]}}}return typeof s!="string"&&"startRow"in s?{sheetId:"",range:s}:at}load(s){this._snapshot=s}checkSheetName(s){return this.getSheetsName().includes(s)}uniqueSheetName(s="Sheet1"){let n=s;for(;this.checkSheetName(n);)n=s+this._count,this._count++;return n}generateNewSheetName(s){let n=s+this._count;for(;this.checkSheetName(n);)n=s+this._count,this._count++;return n}_getCellRange(s){var u,_,d,f,E;let n="",r="";if(s.indexOf("!")>-1){const R=s.split("!");n=R[0],r=R[1],n=n.replace(/\\'/g,"'").replace(/''/g,"'"),n.substring(0,1)==="'"&&n.substring(n.length-1,1)==="'"&&(n=n.substring(1,n.length-1))}else r=s;if(r.indexOf(":")===-1){const R=Number.parseInt(r.replace(/[^0-9]/g,""),10)-1,b=g.ABCatNum(r.replace(/[^A-Za-z]/g,""));return!Number.isNaN(R)&&!Number.isNaN(b)?{sheetId:n,range:{startRow:R,endRow:R,startColumn:b,endColumn:b}}:at}r=r.split(":");const i=[0,0],o=[0,0],a=((u=this.getSheetBySheetName(n))==null?void 0:u.getMaxRows())||((_=this.getActiveSheet())==null?void 0:_.getMaxRows()),l=((d=this.getSheetBySheetName(n))==null?void 0:d.getMaxColumns())||((f=this.getActiveSheet())==null?void 0:f.getMaxColumns());return i[0]=Number.parseInt(r[0].replace(/[^0-9]/g,""),10)-1,i[1]=Number.parseInt(r[1].replace(/[^0-9]/g,""),10)-1,Number.isNaN(i[0])&&(i[0]=0),Number.isNaN(i[1])&&(i[1]=a),i[0]>i[1]||(o[0]=g.ABCatNum(r[0].replace(/[^A-Za-z]/g,"")),o[1]=g.ABCatNum(r[1].replace(/[^A-Za-z]/g,"")),Number.isNaN(o[0])&&(o[0]=0),Number.isNaN(o[1])&&(o[1]=l),o[0]>o[1])?at:{sheetId:((E=this.getSheetBySheetName(n))==null?void 0:E.getSheetId())||"",range:{startRow:i[0],endRow:i[1],startColumn:o[0],endColumn:o[1]}}}_passWorksheetSnapshots(){const{_snapshot:s,_worksheets:n}=this,{sheets:r,sheetOrder:i}=s;if(g.isEmptyObject(r)){const o=g.generateRandomId();r[o]={id:o}}for(const o in r){const a=r[o],{name:l}=a;a.name=this.uniqueSheetName(l),a.name!==l&&this._logService.error(`The worksheet name ${l} is duplicated, we change it to ${a.name}`);const c=new dt(a,this._styles);n.set(o,c),i.includes(o)||i.push(o)}}};exports.Workbook=Ui([Mi(1,q)],exports.Workbook);class Oe{constructor(e){h(this,"_snapshot");h(this,"_unitId");var s;this._snapshot={..._n,...e},this._unitId=(s=this._snapshot.id)!=null?s:g.generateRandomId(6)}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var e;return(e=this._snapshot.body)==null?void 0:e.pages}getPageOrder(){var e;return(e=this._snapshot.body)==null?void 0:e.pageOrder}getPage(e){const s=this.getPages();return s==null?void 0:s[e]}getElementsByPage(e){var s;return(s=this.getPage(e))==null?void 0:s.pageElements}getElement(e,s){var n;return(n=this.getElementsByPage(e))==null?void 0:n[s]}getPageSize(){return this._snapshot.pageSize}addPage(){return{id:"cover_1",pageType:me.SLIDE,zIndex:1,title:"cover",description:"this is first page, cover",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}}const Tt="FOCUSING_SHEET",yt="FOCUSING_DOC",te="FOCUSING_SLIDE",xi="FOCUSING_EDITOR_BUT_HIDDEN",Ln="EDITOR_ACTIVATED",Hi="FOCUSING_EDITOR_INPUT_FORMULA",bn="FOCUSING_FORMULA_EDITOR",Fi="FOCUSING_UNIVER_EDITOR";var pi=Object.defineProperty,Wi=Object.getOwnPropertyDescriptor,Bi=(t,e,s,n)=>{for(var r=n>1?void 0:n?Wi(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&pi(e,s,r),r},Gi=(t,e)=>(s,n)=>e(s,n,t),vn=(t=>(t[t.UNKNOWN=0]="UNKNOWN",t[t.DOC=1]="DOC",t[t.SHEET=2]="SHEET",t[t.SLIDE=3]="SLIDE",t))(vn||{});const nt=I.createIdentifier("univer.current");let ee=class extends U{constructor(e,s){super();h(this,"_focused",null);h(this,"_focused$",new A.BehaviorSubject(null));h(this,"focused$",this._focused$.asObservable());h(this,"_currentSheet$",new A.BehaviorSubject(null));h(this,"currentSheet$",this._currentSheet$.asObservable());h(this,"_currentDoc$",new A.BehaviorSubject(null));h(this,"currentDoc$",this._currentDoc$.asObservable());h(this,"_currentSlide$",new A.BehaviorSubject(null));h(this,"currentSlide$",this._currentSlide$.asObservable());h(this,"_sheetAdded$",new A.Subject);h(this,"sheetAdded$",this._sheetAdded$.asObservable());h(this,"_docAdded$",new A.Subject);h(this,"docAdded$",this._docAdded$.asObservable());h(this,"_slideAdded$",new A.Subject);h(this,"slideAdded$",this._slideAdded$.asObservable());h(this,"_sheetDisposed$",new A.Subject);h(this,"sheetDisposed$",this._sheetDisposed$.asObservable());h(this,"_docDisposed$",new A.Subject);h(this,"docDisposed$",this._docDisposed$.asObservable());h(this,"_slideDisposed$",new A.Subject);h(this,"slideDisposed$",this._slideDisposed$.asObservable());h(this,"_sheets",[]);h(this,"_docs",[]);h(this,"_slides",[]);this._handler=e,this._contextService=s}dispose(){super.dispose(),this._focused$.complete(),this._currentDoc$.complete(),this._currentSheet$.complete(),this._currentSlide$.complete(),this._sheetAdded$.complete(),this._docAdded$.complete(),this._slideAdded$.complete(),this._sheetDisposed$.complete(),this._docDisposed$.complete(),this._slideDisposed$.complete()}createDoc(e){return this._handler.createUniverDoc(e)}createSheet(e){return this._handler.createUniverSheet(e)}createSlide(e){return this._handler.createUniverSlide(e)}addSheet(e){this._sheets.push(e),this._sheetAdded$.next(e),this.setCurrentUniverSheetInstance(e.getUnitId())}changeDoc(e,s){const n=this._docs.find(r=>r.getUnitId()===e);if(n!=null){const r=this._docs.indexOf(n);this._docs.splice(r,1)}this.addDoc(s)}addDoc(e){this._docs.push(e),this._docAdded$.next(e),this.setCurrentUniverDocInstance(e.getUnitId())}addSlide(e){this._slides.push(e),this._slideAdded$.next(e),this.setCurrentUniverSlideInstance(e.getUnitId())}getUniverSheetInstance(e){return this._sheets.find(s=>s.getUnitId()===e)}getUniverDocInstance(e){return this._docs.find(s=>s.getUnitId()===e)}getUniverSlideInstance(e){return this._slides.find(s=>s.getUnitId()===e)}getAllUniverSheetsInstance(){return this._sheets}getAllUniverDocsInstance(){return this._docs}getAllUniverSlidesInstance(){return this._slides}setCurrentUniverSheetInstance(e){this._currentSheet$.next(this.getUniverSheetInstance(e)||null)}setCurrentUniverSlideInstance(e){this._currentSlide$.next(this.getUniverSlideInstance(e)||null)}setCurrentUniverDocInstance(e){this._currentDoc$.next(this.getUniverDocInstance(e)||null)}getCurrentUniverSheetInstance(){const e=this._currentSheet$.getValue();if(!e)throw new Error("No current sheet!");return e}getCurrentUniverDocInstance(){const e=this._currentDoc$.getValue();if(!e)throw new Error("No current doc!");return e}getCurrentUniverSlideInstance(){const e=this._currentSlide$.getValue();if(!e)throw new Error("No current slide!");return e}focusUniverInstance(e){e&&(this._focused=this.getUniverSheetInstance(e)||this.getUniverDocInstance(e)||this.getUniverSlideInstance(e)||null),this._focused$.next(e),[yt,Tt,te].forEach(s=>this._contextService.setContextValue(s,!1)),this._focused instanceof exports.Workbook?this._contextService.setContextValue(Tt,!0):this._focused instanceof et?this._contextService.setContextValue(yt,!0):this._focused instanceof Oe&&this._contextService.setContextValue(te,!0)}getFocusedUniverInstance(){return this._focused}getDocumentType(e){if(this.getUniverDocInstance(e))return 1;if(this.getUniverSheetInstance(e))return 2;if(this.getUniverSlideInstance(e))return 3;throw new Error(`[UniverInstanceService]: No document with unitId ${e}`)}disposeDocument(e){const s=this.getUniverDocInstance(e);if(s){const i=this._docs.indexOf(s);return this._docs.splice(i,1),this._docDisposed$.next(s),this.focusUniverInstance(null),!0}const n=this.getUniverSheetInstance(e);if(n){const i=this._sheets.indexOf(n);return this._sheets.splice(i,1),this._sheetDisposed$.next(n),this.focusUniverInstance(null),!0}const r=this.getUniverSlideInstance(e);if(r){const i=this._slides.indexOf(r);return this._slides.splice(i,1),this._slideDisposed$.next(r),this.focusUniverInstance(null),!0}return!1}};ee=Bi([Gi(1,tt)],ee);var S=(t=>(t[t.Starting=0]="Starting",t[t.Ready=1]="Ready",t[t.Rendered=2]="Rendered",t[t.Steady=3]="Steady",t))(S||{});const ki={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"},At=new Map;function Ie(t,e){return function(r){Ae(t,e)}}function Ae(t,e){At.has(t)||At.set(t,[]),At.get(t).push(e)}var $i=Object.defineProperty,Vi=Object.getOwnPropertyDescriptor,wn=(t,e,s,n)=>{for(var r=n>1?void 0:n?Vi(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&$i(e,s,r),r},se=(t,e)=>(s,n)=>e(s,n,t);exports.LifecycleService=class extends U{constructor(s){super();h(this,"_lifecycle$",new A.BehaviorSubject(S.Starting));h(this,"lifecycle$",this._lifecycle$.asObservable());this._logService=s,this._reportProgress(S.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(s){if(s<this.stage)throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");s!==this.stage&&(this._reportProgress(s),this._lifecycle$.next(s))}dispose(){this._lifecycle$.complete(),super.dispose()}subscribeWithPrevious(){return new A.Observable(s=>(this.stage===S.Starting||(this.stage===S.Ready?s.next(S.Starting):this.stage===S.Rendered?(s.next(S.Starting),s.next(S.Ready)):(s.next(S.Starting),s.next(S.Ready),s.next(S.Rendered))),this._lifecycle$.subscribe(s)))}_reportProgress(s){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${ki[s]}".`)}};exports.LifecycleService=wn([se(0,q)],exports.LifecycleService);let z=class extends U{constructor(e,s){super();h(this,"_started",!1);this._lifecycleService=e,this._injector=s}start(){this._started||(this._started=!0,this.disposeWithMe(L(this._lifecycleService.subscribeWithPrevious().subscribe(e=>this.initModulesOnStage(e)))))}initModulesOnStage(e){const s=At.get(e);s==null||s.forEach(n=>{this._injector.has(n)&&this._injector.get(n)})}};z=wn([se(0,I.Inject(exports.LifecycleService)),se(1,I.Inject(I.Injector))],z);class lt extends U{constructor(){super();h(this,"_currentLocale",xt.ZH_CN);h(this,"_locales",null);h(this,"localeChanged$",new A.Subject);h(this,"t",(s,...n)=>{if(!this._locales)throw new Error("Locale not initialized");function r(a,l){const c=l.shift();if(c&&a&&c in a){const u=a[c];return l.length>0&&(typeof u=="object"||Array.isArray(u))?r(u,l):u}return null}const i=s.split("."),o=r(this._locales[this._currentLocale],i);if(typeof o=="string"){let a=o;return n.forEach((l,c)=>{a=a.replace(`{${c}}`,l)}),a}else return s});this.disposeWithMe(L(()=>this.localeChanged$.complete()))}load(s){var n;this._locales=g.deepMerge((n=this._locales)!=null?n:{},s)}setLocale(s){this._currentLocale=s,this.localeChanged$.next()}getLocales(){var s;return(s=this._locales)==null?void 0:s[this._currentLocale]}}const Ce=I.createIdentifier("resource-manager-service"),Dn=I.createIdentifier("ResourcePersistenceService");Ae(S.Ready,Dn);var ji=Object.defineProperty,Ki=Object.getOwnPropertyDescriptor,Yi=(t,e,s,n)=>{for(var r=n>1?void 0:n?Ki(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&ji(e,s,r),r},Ue=(t,e)=>(s,n)=>e(s,n,t);const Ne=I.createIdentifier("univer.permission-service"),Me="PERMISSION";exports.PermissionService=class extends U{constructor(s,n){super();h(this,"_permissionPointMap",new Map);h(this,"deletePermissionPoint",(s,n)=>{const r=this._permissionPointMap.get(s);if(r){const i=r.get(n);i&&(i.complete(),this._permissionPointMap.delete(n))}});h(this,"addPermissionPoint",(s,n)=>{const r=this._permissionPointMap.get(s)||new Map;return r.has(n.id)?!1:(r.set(n.id,new A.BehaviorSubject(n)),this._permissionPointMap.set(s,r),!0)});h(this,"updatePermissionPoint",(s,n,r)=>{const i=this._permissionPointMap.get(s);if(!i)return;const o=i.get(n);if(o){const a=o.getValue();a.value=r,a.status=he.DONE,o.next(a)}});h(this,"getPermissionPoint",(s,n)=>{const r=this._permissionPointMap.get(s);if(!r)return;const i=r.get(n);if(i)return i.getValue()});this._resourceManagerService=s,this._univerInstanceService=n}_init(){this.disposeWithMe(L(this._univerInstanceService.sheetAdded$.subscribe(s=>{this._resourceManagerService.registerPluginResource(s.getUnitId(),Me,{onChange:(n,r)=>{r.forEach(i=>{this.getPermissionPoint(n,i.id)?this.updatePermissionPoint(n,i.id,i.value):this.addPermissionPoint(n,i)})},toJson:n=>this._toJson(n),parseJson:n=>this._parseJson(n)})}))),this.disposeWithMe(L(this._univerInstanceService.sheetDisposed$.subscribe(s=>{this._resourceManagerService.disposePluginResource(s.getUnitId(),Me)})))}_toJson(s){const n=this._permissionPointMap.get(s);let r=[];return n&&(r=[...n.keys()].reduce((i,o)=>{const a=n.get(o);return a&&i.push(a.getValue()),i},[])),JSON.stringify(r)}_parseJson(s){return JSON.parse(s)}composePermission$(s,n){const r=this._permissionPointMap.get(s),i=n.map(o=>{const a=r==null?void 0:r.get(o);if(!a)throw new Error(`${o} permissionPoint is not exist`);return a.asObservable()});return A.combineLatest(i).pipe(Vn.map(o=>(o.every(a=>this._permissionPointMap.get(a.id)),o)))}composePermission(s,n){const r=this._permissionPointMap.get(s);return n.map(o=>{const a=r==null?void 0:r.get(o);if(!a)throw new Error(`${o} permissionPoint is not exist`);return a.getValue()})}};exports.PermissionService=Yi([Ie(S.Starting,exports.PermissionService),Ue(0,I.Inject(Ce)),Ue(1,I.Inject(nt))],exports.PermissionService);const Tn="univer.editable";class Ct extends Ls{constructor(s){super();h(this,"id",Tn);h(this,"value",!0);h(this,"unitID");this.unitID=s}}var zi=Object.defineProperty,Xi=Object.getOwnPropertyDescriptor,qi=(t,e,s,n)=>{for(var r=n>1?void 0:n?Xi(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&zi(e,s,r),r},Pe=(t,e)=>(s,n)=>e(s,n,t);exports.UniverPermissionService=class extends U{constructor(e,s){super(),this._permissionService=e,this._univerInstanceService=s,this._init()}_init(){this._univerInstanceService.sheetAdded$.subscribe(e=>{const s=new Ct(e.getUnitId());this._permissionService.addPermissionPoint(e.getUnitId(),s)})}getEditable(e){let s=e;s||(s=this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId());const n=new Ct(s),r=this._permissionService.getPermissionPoint(s,n.id);return r==null?void 0:r.value}setEditable(e,s){const n=new Ct(e);this._permissionService.updatePermissionPoint(e,n.id,s)}};exports.UniverPermissionService=qi([Ie(S.Starting,exports.UniverPermissionService),Pe(0,I.Inject(Ne)),Pe(1,I.Inject(nt))],exports.UniverPermissionService);class Un extends U{constructor(){super(...arguments);h(this,"_resourceMap",new Map);h(this,"_register$",new A.Subject);h(this,"register$",this._register$.asObservable())}getAllResource(s){const n=this._resourceMap.get(s);return n?[...n.keys()].reduce((r,i)=>{const o=n.get(i);return o&&r.push({unitID:s,resourceName:i,hook:o}),r},[]):[]}registerPluginResource(s,n,r){const i=this._resourceMap.get(s)||new Map;if(i.has(n))throw new Error("the pluginName is registered");return i.set(n,r),this._resourceMap.set(s,i),this._register$.next({unitID:s,resourceName:n,hook:r}),L(()=>i.delete(n))}disposePluginResource(s,n){const r=this._resourceMap.get(s);r==null||r.delete(n)}dispose(){this._register$.complete(),this._resourceMap.clear()}}class ne extends U{constructor(){super();h(this,"_currentTheme");h(this,"_currentTheme$",new A.BehaviorSubject({}));h(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(L(()=>this._currentTheme$.complete()))}getCurrentTheme(){if(!this._currentTheme)throw new Error("[ThemeService]: current theme is not set!");return this._currentTheme}setTheme(s){this._currentTheme=s,this._currentTheme$.next(s)}}const Mn="__defaultDocumentNormalEditorSpecialUnitId_20231006__",Pn="__defaultDocumentFormulaBarEditorSpecialUnitId_20231012__",Qi=`\r
|
|
5
6
|
`;var Ji=Object.defineProperty,Zi=Object.getOwnPropertyDescriptor,yi=(t,e,s,n)=>{for(var r=n>1?void 0:n?Zi(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&Ji(e,s,r),r},$t=(t,e)=>(s,n)=>e(s,n,t);const pt=I.createIdentifier("univer.undo-redo.service"),to=20;class xn{dispose(){}async dispatchToHandlers(){return!1}}const Hn="univer.command.redo",Fn="univer.command.undo",pn=new class extends xn{constructor(){super(...arguments);h(this,"type",Pt.COMMAND);h(this,"id",Fn)}async handler(e){const s=e.get(pt),n=s.pitchTopUndoElement();if(!n)return!1;const r=e.get(ft);return(n.undo?await n.undo(n.undoMutations):le(n.undoMutations,r))?(s.popUndoToRedo(),!0):!1}},Wn=new class extends xn{constructor(){super(...arguments);h(this,"type",Pt.COMMAND);h(this,"id",Hn)}async handler(e){const s=e.get(pt),n=s.pitchTopRedoElement();if(!n)return!1;const r=e.get(ft);return(n.redo?await n.redo(n.redoMutations):le(n.redoMutations,r))?(s.popRedoToUndo(),!0):!1}};exports.LocalUndoRedoService=class extends U{constructor(s,n,r){super();h(this,"undoRedoStatus$");h(this,"_undoRedoStatus$",new A.BehaviorSubject({undos:0,redos:0}));h(this,"_undoStacks",new Map);h(this,"_redoStacks",new Map);this._univerInstanceService=s,this._commandService=n,this._contextService=r,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(pn)),this.disposeWithMe(this._commandService.registerCommand(Wn)),this.disposeWithMe(L(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(L(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(s){const{unitID:n}=s,r=this._getRedoStack(n,!0),i=this._getUndoStack(n,!0);r.length=0,i.push(s),i.length>to&&i.splice(0,1),this._updateStatus()}clearUndoRedo(s){const n=this._getRedoStack(s);n&&(n.length=0);const r=this._getUndoStack(s);r&&(r.length=0),this._updateStatus()}pitchTopUndoElement(){const s=this._getUndoStackForFocused();return s.length?s[s.length-1]:null}pitchTopRedoElement(){const s=this._getRedoStackForFocused();return s.length?s[s.length-1]:null}popUndoToRedo(){const n=this._getUndoStackForFocused().pop();n&&(this._getRedoStackForFocused().push(n),this._updateStatus())}popRedoToUndo(){const n=this._getRedoStackForFocused().pop();n&&(this._getUndoStackForFocused().push(n),this._updateStatus())}_updateStatus(){var i,o;const s=this._getFocusedUniverInstanceId(),n=s&&((i=this._undoStacks.get(s))==null?void 0:i.length)||0,r=s&&((o=this._redoStacks.get(s))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:n,redos:r})}_getUndoStack(s,n=!1){let r=this._undoStacks.get(s);return!r&&n&&(r=[],this._undoStacks.set(s,r)),r||null}_getRedoStack(s,n=!1){let r=this._redoStacks.get(s);return!r&&n&&(r=[],this._redoStacks.set(s,r)),r||null}_getUndoStackForFocused(){const s=this._getFocusedUniverInstanceId();if(!s)throw new Error("No focused univer instance!");return this._getUndoStack(s,!0)}_getRedoStackForFocused(){const s=this._getFocusedUniverInstanceId();if(!s)throw new Error("No focused univer instance!");return this._getRedoStack(s,!0)}_getFocusedUniverInstanceId(){var o,a,l,c;let s="";const n=this._contextService.getContextValue(Tt),r=this._contextService.getContextValue(bn),i=this._contextService.getContextValue(Ln);return n?r?s=Pn:i?s=Mn:s=(a=(o=this._univerInstanceService.getFocusedUniverInstance())==null?void 0:o.getUnitId())!=null?a:"":s=(c=(l=this._univerInstanceService.getFocusedUniverInstance())==null?void 0:l.getUnitId())!=null?c:"",s}};exports.LocalUndoRedoService=yi([$t(0,nt),$t(1,ft),$t(2,tt)],exports.LocalUndoRedoService);class Wt extends U{constructor(){super(...arguments);h(this,"_started",!1)}addPlugins(s){if(this._started){const n=s.map(([r,i])=>this._initPlugin(r,i));this._pluginsRunLifecycle(n,S.Starting),setTimeout(()=>this._takePluginsThroughLifecycle(n,!0))}else{const n=s.map(([r,i])=>this._initPlugin(r,i));this._takePluginsThroughLifecycle(n),this._started=!0}}_takePluginsThroughLifecycle(s,n=!1){this.disposeWithMe(L(this._lifecycleService.subscribeWithPrevious().subscribe(r=>{n&&r===S.Starting||this._pluginsRunLifecycle(s,r)})))}_pluginsRunLifecycle(s,n){s.forEach(r=>{switch(n){case S.Starting:r.onStarting(this._injector);break;case S.Ready:r.onReady();break;case S.Rendered:r.onRendered();break;case S.Steady:r.onSteady();break}}),this._lifecycleInitializerService.initModulesOnStage(n)}_initPlugin(s,n){return this._injector.createInstance(s,n)}}var eo=Object.defineProperty,so=Object.getOwnPropertyDescriptor,no=(t,e,s,n)=>{for(var r=n>1?void 0:n?so(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&eo(e,s,r),r},Vt=(t,e)=>(s,n)=>e(s,n,t);exports.UniverDoc=class extends Wt{constructor(e,s,n){super(),this._injector=e,this._lifecycleService=s,this._lifecycleInitializerService=n}createDoc(e){return this._injector.createInstance(et,e)}};exports.UniverDoc=no([Vt(0,I.Inject(I.Injector)),Vt(1,I.Inject(exports.LifecycleService)),Vt(2,I.Inject(z))],exports.UniverDoc);var ro=Object.defineProperty,io=Object.getOwnPropertyDescriptor,oo=(t,e,s,n)=>{for(var r=n>1?void 0:n?io(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&ro(e,s,r),r},jt=(t,e)=>(s,n)=>e(s,n,t);exports.UniverSheet=class extends Wt{constructor(e,s,n){super(),this._injector=e,this._lifecycleService=s,this._lifecycleInitializerService=n}createSheet(e){return this._injector.createInstance(exports.Workbook,e)}};exports.UniverSheet=oo([jt(0,I.Inject(I.Injector)),jt(1,I.Inject(exports.LifecycleService)),jt(2,I.Inject(z))],exports.UniverSheet);var ao=Object.defineProperty,lo=Object.getOwnPropertyDescriptor,uo=(t,e,s,n)=>{for(var r=n>1?void 0:n?lo(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&ao(e,s,r),r},Kt=(t,e)=>(s,n)=>e(s,n,t);exports.UniverSlide=class extends Wt{constructor(e,s,n){super(),this._injector=e,this._lifecycleService=s,this._lifecycleInitializerService=n}createSlide(e){return this._injector.createInstance(Oe,e)}};exports.UniverSlide=uo([Kt(0,I.Inject(I.Injector)),Kt(1,I.Inject(exports.LifecycleService)),Kt(2,I.Inject(z))],exports.UniverSlide);const co=200;class ho extends Wt{constructor(s={}){super();h(this,"_injector");h(this,"_univerPluginStore",new Yn);h(this,"_univerPluginRegistry",new zn);h(this,"_univerSheet",null);h(this,"_univerDoc",null);h(this,"_univerSlide",null);h(this,"_initLazyPluginsTimer");this._injector=this._initDependencies();const{theme:n,locale:r,locales:i,logLevel:o}=s;n&&this._injector.get(ne).setTheme(n),i&&this._injector.get(lt).load(i),r&&this._injector.get(lt).setLocale(r),o&&this._injector.get(q).setLogLevel(o)}get _univerInstanceService(){return this._injector.get(nt)}get _lifecycleService(){return this._injector.get(exports.LifecycleService)}get _lifecycleInitializerService(){return this._injector.get(z)}__getInjector(){return this._injector}dispose(){this._injector.dispose(),super.dispose()}setLocale(s){this._injector.get(lt).setLocale(s)}createUniverSheet(s){let n;const r=()=>{n=this._univerSheet.createSheet(s),this._univerInstanceService.addSheet(n)};if(this._univerSheet)r();else{this._tryProgressToStart();const i=this._univerSheet=this._injector.createInstance(exports.UniverSheet),o=this._univerPluginRegistry.getRegisterPlugins(w.Sheet).map(a=>[a.plugin,a.options]);this._univerPluginRegistry.clearPluginsOfType(w.Sheet),i.addPlugins(o),r(),this._tryProgressToReady()}return n}createUniverDoc(s){let n;const r=()=>{n=this._univerDoc.createDoc(s),this._univerInstanceService.addDoc(n)};if(this._univerDoc)r();else{this._tryProgressToStart();const i=this._univerDoc=this._injector.createInstance(exports.UniverDoc),o=this._univerPluginRegistry.getRegisterPlugins(w.Doc).map(a=>[a.plugin,a.options]);this._univerPluginRegistry.clearPluginsOfType(w.Doc),i.addPlugins(o),r(),this._tryProgressToReady()}return n}createUniverSlide(s){let n;const r=()=>{n=this._univerSlide.createSlide(s),this._univerInstanceService.addSlide(n)};if(this._univerSlide)r();else{this._tryProgressToStart();const i=this._univerSlide=this._injector.createInstance(exports.UniverSlide),o=this._univerPluginRegistry.getRegisterPlugins(w.Slide).map(a=>[a.plugin,a.options]);this._univerPluginRegistry.clearPluginsOfType(w.Slide),i.addPlugins(o),r(),this._tryProgressToReady()}return n}_initDependencies(){return new I.Injector([[nt,{useFactory:s=>new ee({createUniverDoc:n=>this.createUniverDoc(n),createUniverSheet:n=>this.createUniverSheet(n),createUniverSlide:n=>this.createUniverSlide(n)},s),deps:[tt]}],[ze],[lt],[ne],[exports.LifecycleService],[z],[Ne,{useClass:exports.PermissionService}],[exports.UniverPermissionService],[q,{useClass:je,lazy:!0}],[ft,{useClass:exports.CommandService,lazy:!0}],[pt,{useClass:exports.LocalUndoRedoService,lazy:!0}],[Ye,{useClass:ir}],[tt,{useClass:$e}],[qe,{useClass:Xe,lazy:!0}],[Ce,{useClass:Un,lazy:!0}]])}_tryProgressToStart(){this._started||(this._injector.get(z).start(),this._started=!0)}_tryProgressToReady(){this._injector.get(exports.LifecycleService).stage<S.Ready&&(this._injector.get(exports.LifecycleService).stage=S.Ready,this._univerPluginStore.forEachPlugin(n=>n.onReady()))}registerPlugin(s,n){if(s.type===w.Univer)this._registerUniverPlugin(s,n);else if(s.type===w.Sheet)this._registerSheetsPlugin(s,n);else if(s.type===w.Doc)this._registerDocsPlugin(s,n);else if(s.type===w.Slide)this._registerSlidesPlugin(s,n);else throw new Error(`Unimplemented plugin system for business: "${s.type}".`);if(this._started)return this._scheduleInitPluginAfterStarted()}_scheduleInitPluginAfterStarted(){this._initLazyPluginsTimer===void 0&&(this._initLazyPluginsTimer=setTimeout(()=>this._flushLazyPlugins(),co))}_flushLazyPlugins(){this._initLazyPluginsTimer=void 0;const s=this._univerPluginRegistry.getRegisterPlugins(w.Univer);if(s.length){this._univerPluginRegistry.clearPluginsOfType(w.Univer);const n=s.map(r=>this._injector.createInstance(r.plugin,r.options));this._takePluginsThroughLifecycle(n)}if(this._univerSheet){const n=this._univerPluginRegistry.getRegisterPlugins(w.Sheet).map(r=>[r.plugin,r.options]);n.length&&(this._univerSheet.addPlugins(n),this._univerPluginRegistry.clearPluginsOfType(w.Sheet))}if(this._univerDoc){const n=this._univerPluginRegistry.getRegisterPlugins(w.Doc).map(r=>[r.plugin,r.options]);n.length&&(this._univerDoc.addPlugins(n),this._univerPluginRegistry.clearPluginsOfType(w.Doc))}if(this._univerSlide){const n=this._univerPluginRegistry.getRegisterPlugins(w.Slide).map(r=>[r.plugin,r.options]);n.length&&(this._univerSlide.addPlugins(n),this._univerPluginRegistry.clearPluginsOfType(w.Slide))}}_registerUniverPlugin(s,n){if(this._started)this._univerPluginRegistry.registerPlugin(s,n);else{const r=this._injector.createInstance(s,n);r.onStarting(this._injector),this._univerPluginStore.addPlugin(r)}}_registerSheetsPlugin(s,n){this._univerPluginRegistry.registerPlugin(s,n)}_registerDocsPlugin(s,n){this._univerPluginRegistry.registerPlugin(s,n)}_registerSlidesPlugin(s,n){this._univerPluginRegistry.registerPlugin(s,n)}}function _o(t,e=16){let s=0,n=null;return function(...i){const o=Date.now();o-s<e?(n&&clearTimeout(n),n=setTimeout(()=>{s=o,t.apply(this,i)},e)):(s=o,t.apply(this,i))}}function fo(t){const e=new MessageChannel;let s=!1;return e.port1.onmessage=()=>{s||t()},e.port2.postMessage(null),()=>{s=!0}}class re{constructor(e){h(this,"_index",0);h(this,"_offset",0);this._actions=e}hasNext(){return this.peekLength()<Number.POSITIVE_INFINITY}next(e){e||(e=Number.POSITIVE_INFINITY);const s=this._actions[this._index];if(s){const n=this._offset,r=s.len;return e>=r-n?(e=r-n,this._index+=1,this._offset=0):this._offset+=e,s.t===m.DELETE||s.t===m.RETAIN&&s.body==null?g.deepClone({...s,len:e}):g.deepClone({...s,len:e,body:ge(s.body,n,n+e)})}else return{t:m.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 e=this._actions[this._index];return e?e.t:m.RETAIN}rest(){if(this.hasNext()){if(this._offset===0)return this._actions.slice(this._index);{const e=this._offset,s=this._index,n=this.next(),r=this._actions.slice(this._index);return this._offset=e,this._index=s,[n].concat(r)}}else return[]}}function xe(t){return Object.keys(t).length===1}class Se{constructor(){h(this,"_actions",[])}static compose(e,s){const n=new re(e),r=new re(s),i=new Se;for(;n.hasNext()||r.hasNext();)if(r.peekType()===m.INSERT)i.push(r.next());else if(n.peekType()===m.DELETE)i.push(n.next());else{const o=Math.min(n.peekLength(),r.peekLength()),a=n.next(o),l=r.next(o);a.t===m.INSERT&&l.t===m.RETAIN?l.body==null?i.push(a):i.push({...a,body:Zt(a.body,l.body,l.coverType)}):a.t===m.RETAIN&&l.t===m.RETAIN?a.body==null&&l.body==null?i.push(a.len!==Number.POSITIVE_INFINITY?a:l):a.body&&l.body?i.push({...a,body:Zt(a.body,l.body,l.coverType)}):i.push(a.body?a:l):a.t===m.RETAIN&&l.t===m.DELETE?i.push(l):a.t===m.INSERT&&(l.t,m.DELETE)}return i.trimEndUselessRetainAction(),i.serialize()}insert(e,s,n){const r={t:m.INSERT,body:s,len:e,line:0,segmentId:n};return this.push(r),this}retain(e,s,n,r){const i={t:m.RETAIN,len:e,segmentId:s};return n!=null&&(i.body=n),r!=null&&(i.coverType=r),this.push(i),this}delete(e,s){const n={t:m.DELETE,len:e,line:0,segmentId:s};return this.push(n),this}serialize(){return this._actions}push(...e){if(e.length>1){for(const i of e)this.push(i);return this}let s=this._actions.length,n=this._actions[s-1];const r=g.deepClone(e[0]);if(r.t===m.RETAIN&&r.len===0&&r.body==null)return this;if(typeof n=="object"){if(n.t===m.DELETE&&r.t===m.DELETE)return n.len+=r.len,this;if(n.t===m.DELETE&&r.t===m.INSERT&&(s-=1,n=this._actions[s-1],n==null))return this._actions.unshift(r),this;if(n.t===m.RETAIN&&r.t===m.RETAIN&&n.body==null&&r.body==null)return n.len+=r.len,this;if(n.t===m.INSERT&&xe(n.body)&&r.t===m.INSERT&&xe(r.body))return n.len+=r.len,n.body.dataStream+=r.body.dataStream,this}return s===this._actions.length?this._actions.push(r):this._actions.splice(s,0,r),this}trimEndUselessRetainAction(){let e=this._actions[this._actions.length-1];for(;e&&e.t===m.RETAIN&&hi(e);)this._actions.pop(),e=this._actions[this._actions.length-1];return this}}class Eo extends Mt{add(e){if(!e)return null;const s=new Ut(e,this);return this._observers=[s],this._onObserverAdded&&this._onObserverAdded(s),s}makeObserverTopPriority(){}makeObserverBottomPriority(){}}const go=I.createIdentifier("ILocalStorageService"),Ro=t=>`sheet_interceptor_${t}`,Bn=t=>function(e,s){let n=-1;function r(i,o){if(i<=n)throw new Error("[SheetInterceptorService]: next() called multiple times!");return n=i,i===t.length?o:t[i].handler(o,s,r.bind(null,i+1))}return r(0,e)};class mo{constructor(e){h(this,"_interceptorsByName",new Map);h(this,"_interceptorPoints");this._interceptorPoints=e}fetchThroughInterceptors(e){const s=e,n=this._interceptorsByName.get(s);return Bn(n||[])}intercept(e,s){const n=e;this._interceptorsByName.has(n)||this._interceptorsByName.set(n,[]);const r=this._interceptorsByName.get(n);return r.push(s),this._interceptorsByName.set(n,r.sort((i,o)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)})),()=>Y(this._interceptorsByName.get(n),s)}getInterceptPoints(){return this._interceptorPoints}}jn();exports.ABCToNumber=zr;exports.AbsoluteRefType=bs;exports.ActionIterator=re;exports.AlignTypeH=on;exports.AlignTypeV=an;exports.AutoFillSeries=ye;exports.BaselineOffset=Lt;exports.BlockType=ks;exports.BooleanNumber=O;exports.BorderStyleTypes=N;exports.BorderType=ts;exports.BulletAlignment=V;exports.COLORS=Yt;exports.CellValueType=ct;exports.Color=Q;exports.ColorBuilder=Ft;exports.ColorKit=F;exports.ColorType=H;exports.ColumnSeparatorType=js;exports.CommandType=Pt;exports.CommonHideTypes=es;exports.ConditionType=ss;exports.ContentAlignment=tn;exports.ContextService=$e;exports.CopyPasteType=ns;exports.CustomRangeType=Gs;exports.DEFAULT_CELL=gi;exports.DEFAULT_DOC=Re;exports.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=or;exports.DEFAULT_EMPTY_DOCUMENT_VALUE=Qi;exports.DEFAULT_RANGE=fi;exports.DEFAULT_RANGE_ARRAY=at;exports.DEFAULT_SELECTION=Ei;exports.DEFAULT_SLIDE=_n;exports.DEFAULT_STYLES=It;exports.DEFAULT_WORKBOOK=hn;exports.DEFAULT_WORKSHEET_COLUMN_COUNT=mn;exports.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=Si;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Cn;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=wi;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH=In;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=bi;exports.DEFAULT_WORKSHEET_ROW_COUNT=Rn;exports.DEFAULT_WORKSHEET_ROW_COUNT_KEY=Ni;exports.DEFAULT_WORKSHEET_ROW_HEIGHT=On;exports.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=Li;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=An;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=vi;exports.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=Pn;exports.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=Mn;exports.DashStyleType=Js;exports.DataStreamTreeNodeType=Ds;exports.DataStreamTreeTokenType=_e;exports.DesktopLogService=je;exports.DeveloperMetadataVisibility=rs;exports.Dimension=is;exports.Direction=os;exports.Disposable=U;exports.DisposableCollection=ae;exports.DocStyleType=Ws;exports.DocumentDataModel=et;exports.EDITOR_ACTIVATED=Ln;exports.EXTENSION_NAMES=dn;exports.Entry=zt;exports.EntryIterator=Ns;exports.ErrorService=ze;exports.EventState=Ge;exports.FOCUSING_DOC=yt;exports.FOCUSING_EDITOR_BUT_HIDDEN=xi;exports.FOCUSING_EDITOR_INPUT_FORMULA=Hi;exports.FOCUSING_FORMULA_EDITOR=bn;exports.FOCUSING_SHEET=Tt;exports.FOCUSING_SLIDE=te;exports.FOCUSING_UNIVER_EDITOR=Fi;exports.FloatingObjectManagerService=Xe;exports.FollowNumberWithType=Bs;exports.FontItalic=Nt;exports.FontStyleType=en;exports.FontWeight=St;exports.FormatType=as;exports.GlyphType=ht;exports.GridType=$s;exports.HLSColor=Es;exports.HorizontalAlign=X;exports.ICommandService=ft;exports.IConfigService=Ye;exports.IContextService=tt;exports.IFloatingObjectManagerService=qe;exports.ILocalStorageService=go;exports.ILogService=q;exports.IPermissionService=Ne;exports.IResourceManagerService=Ce;exports.ISnapshotPersistenceService=Dn;exports.IUndoRedoService=pt;exports.IUniverInstanceService=nt;exports.InterceptorManager=mo;exports.InterpolationPointType=ls;exports.KeyIterator=As;exports.LRUHelper=ot;exports.LRUMap=Ss;exports.LifecycleStages=S;exports.LocaleService=lt;exports.LocaleType=xt;exports.LogLevel=Ve;exports.MemoryCursor=Qe;exports.NamedStyleType=qs;exports.NilCommand=Ke;exports.NumberUnitType=rn;exports.ObjectMatrix=B;exports.ObjectRelativeFromH=sn;exports.ObjectRelativeFromV=nn;exports.Observable=Mt;exports.ObservableHooks=Eo;exports.Observer=Ut;exports.OnLifecycle=Ie;exports.PRESET_LIST_TYPE=ni;exports.PageElementType=En;exports.PageOrientType=un;exports.PageType=me;exports.ParagraphElementType=Ys;exports.PermissionPoint=Ls;exports.PermissionStatus=he;exports.Plugin=He;exports.PluginType=w;exports.PositionedObjectLayoutType=Xs;exports.PresetListType=Dt;exports.ProtectionType=us;exports.RANGE_TYPE=P;exports.RGBA_PAREN=hr;exports.RGB_PAREN=cr;exports.Range=st;exports.Rectangle=y;exports.RedoCommand=Wn;exports.RedoCommandId=Hn;exports.RefAlias=Yr;exports.Registry=ie;exports.RegistryAsMap=oe;exports.RelativeDate=cs;exports.RelativeSlideLink=gn;exports.ResourceManagerService=Un;exports.RgbColor=bt;exports.RxDisposable=Zn;exports.SectionType=Vs;exports.ShapeType=hs;exports.SheetTypes=_s;exports.SheetViewModel=Sn;exports.Slide=Oe;exports.SpacingRule=Qs;exports.Styles=fn;exports.THEME_COLORS=fs;exports.TabStopAlignment=Zs;exports.TextDecoration=ds;exports.TextDirection=_t;exports.TextDirectionType=Ks;exports.TextX=Se;exports.TextXActionType=m;exports.ThemeColor=vt;exports.ThemeColorType=M;exports.ThemeColors=Ht;exports.ThemeService=ne;exports.Tools=g;exports.UndoCommand=pn;exports.UndoCommandId=Fn;exports.Univer=ho;exports.UniverEditablePermission=Ct;exports.UniverEditablePermissionPoint=Tn;exports.UniverInstanceType=vn;exports.UpdateDocsAttributeType=T;exports.ValueIterator=Cs;exports.VerticalAlign=J;exports.WidthType=ys;exports.Worksheet=dt;exports.WrapStrategy=Z;exports.WrapTextType=zs;exports.binarySearchArray=Je;exports.characterSpacingControlType=ln;exports.checkParagraphHasBullet=Fr;exports.checkParagraphHasIndent=pr;exports.checkParagraphHasIndentByStyle=ms;exports.codeToBlob=lr;exports.composeBody=Zt;exports.composeInterceptors=Bn;exports.concatMatrixArray=Gr;exports.createInterceptorKey=Ro;exports.createRowColIter=Jt;exports.dedupe=Xn;exports.deepCompare=ue;exports.deleteContent=Is;exports.fromObservable=Jn;exports.getArrayLength=G;exports.getBodySlice=ge;exports.getBorderStyleType=xr;exports.getCellValueType=mi;exports.getColorStyle=W;exports.getDocsUpdateBody=Ot;exports.getReverseDirection=ur;exports.getTypeFromPermissionItemList=jr;exports.getWorksheetUID=Pi;exports.handleJsonToDom=Mr;exports.handleStyleToString=Pr;exports.hashAlgorithm=Br;exports.horizontalLineSegmentsSubtraction=ce;exports.insertMatrixArray=Xt;exports.insertTextToContent=Os;exports.isCellV=Ii;exports.isEmptyCell=Dr;exports.isFormulaId=Ur;exports.isFormulaString=Tr;exports.isICellData=Ri;exports.isNullCell=Oi;exports.isObserver=ke;exports.isRealNum=Wr;exports.isSameStyleTextRun=Rs;exports.isValidRange=Hr;exports.makeCellRangeToRangeData=wr;exports.makeCellToSelection=vr;exports.mergeWorksheetSnapshotWithDefault=Nn;exports.moveMatrixArray=Qt;exports.normalizeTextRuns=de;exports.numberToABC=qr;exports.numberToListABC=Qr;exports.orderSearchArray=Ze;exports.remove=Y;exports.repeatStringNumTimes=ws;exports.requestImmediateMacroTask=fo;exports.runOnLifecycle=Ae;exports.searchArray=ar;exports.selectionToArray=Kr;exports.sequence=pe;exports.sequenceAsync=Fe;exports.sequenceExecute=le;exports.sequenceExecuteAsync=rr;exports.sliceMatrixArray=kr;exports.sortRules=Jr;exports.sortRulesByDesc=Zr;exports.sortRulesFactory=rt;exports.spliceArray=qt;exports.throttle=_o;exports.toDisposable=L;
|